@mfdaves/okf-mcp 0.3.3 → 0.5.1
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/.agents/skills/okf-v02-migration/SKILL.md +37 -0
- package/.agents/skills/okf-v02-migration/agents/openai.yaml +6 -0
- package/.agents/skills/okf-v02-migration/references/field-mapping.md +26 -0
- package/README.md +217 -79
- package/okf/bundles/okf-mcp/distribution/reference-bundle.md +2 -2
- package/okf/bundles/okf-mcp/index.md +7 -0
- package/okf/bundles/okf-mcp/interfaces/http-authoring-api.md +2 -2
- package/okf/bundles/okf-mcp/interfaces/mcp-tools.md +9 -5
- package/okf/bundles/okf-mcp/overview/okf-mcp.md +2 -2
- package/okf/bundles/okf-mcp/policies/authoring-safety.md +5 -3
- package/okf/bundles/okf-mcp/runtime/file-concept-store.md +7 -5
- package/okf/bundles/okf-mcp/runtime/indexer.md +6 -4
- package/okf/bundles/okf-mcp/runtime/mcp-server.md +7 -7
- package/okf/bundles/okf-mcp/specs/attested-computation.md +24 -0
- package/okf/bundles/okf-mcp/specs/concept-format.md +5 -3
- package/okf/bundles/okf-mcp/specs/git-sources.md +23 -0
- package/okf/bundles/okf-mcp/workflows/v02-migration.md +24 -0
- package/package.json +10 -3
- package/server.json +5 -5
- package/src/assets.js +469 -0
- package/src/authoring.js +492 -20
- package/src/cli.js +468 -37
- package/src/computation.js +366 -0
- package/src/git-source.js +551 -0
- package/src/graph.js +71 -18
- package/src/http-server.js +8 -1
- package/src/index.js +5 -0
- package/src/indexer.js +428 -24
- package/src/markdown.js +129 -0
- package/src/mcp-server.js +450 -315
- package/src/migration.js +687 -0
- package/src/parser.js +135 -54
- package/src/plugins.js +30 -50
- package/src/project.js +74 -17
- package/src/remote.js +232 -17
- package/src/search-index.js +83 -0
- package/src/search.js +103 -47
- package/src/store.js +421 -25
- package/src/v02.js +545 -0
- package/src/validation.js +13 -2
- package/src/mcp-protocol.js +0 -283
package/src/markdown.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const commonmark = require("commonmark");
|
|
4
|
+
|
|
5
|
+
const parser = new commonmark.Parser({ smart: false });
|
|
6
|
+
|
|
7
|
+
function nodeText(node) {
|
|
8
|
+
let output = "";
|
|
9
|
+
const walker = node.walker();
|
|
10
|
+
let event;
|
|
11
|
+
while ((event = walker.next())) {
|
|
12
|
+
if (event.entering && ["text", "code"].includes(event.node.type)) {
|
|
13
|
+
output += event.node.literal || "";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return output;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function isDocumentChild(node) {
|
|
20
|
+
return Boolean(node && node.parent && node.parent.type === "document");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function isTopLevelItem(node) {
|
|
24
|
+
return Boolean(
|
|
25
|
+
node
|
|
26
|
+
&& node.parent
|
|
27
|
+
&& node.parent.type === "list"
|
|
28
|
+
&& node.parent.parent
|
|
29
|
+
&& node.parent.parent.type === "document",
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function markdownStructure(body) {
|
|
34
|
+
const source = String(body || "").replace(/\r\n/g, "\n");
|
|
35
|
+
const lines = source.split("\n");
|
|
36
|
+
const tree = parser.parse(source);
|
|
37
|
+
const headings = [];
|
|
38
|
+
const items = [];
|
|
39
|
+
const codeBlocks = [];
|
|
40
|
+
const walker = tree.walker();
|
|
41
|
+
let event;
|
|
42
|
+
while ((event = walker.next())) {
|
|
43
|
+
if (!event.entering) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const node = event.node;
|
|
47
|
+
if (node.type === "heading" && isDocumentChild(node)) {
|
|
48
|
+
headings.push({
|
|
49
|
+
node,
|
|
50
|
+
level: node.level,
|
|
51
|
+
text: nodeText(node).trim(),
|
|
52
|
+
startLine: node.sourcepos[0][0],
|
|
53
|
+
endLine: node.sourcepos[1][0],
|
|
54
|
+
});
|
|
55
|
+
} else if (node.type === "item" && isTopLevelItem(node)) {
|
|
56
|
+
items.push({
|
|
57
|
+
node,
|
|
58
|
+
startLine: node.sourcepos[0][0],
|
|
59
|
+
endLine: node.sourcepos[1][0],
|
|
60
|
+
});
|
|
61
|
+
} else if (node.type === "code_block" && isDocumentChild(node)) {
|
|
62
|
+
const fenceCharacter = node._fenceChar;
|
|
63
|
+
const fenceLength = Number(node._fenceLength || 0);
|
|
64
|
+
const closingLine = lines[node.sourcepos[1][0] - 1] || "";
|
|
65
|
+
const closed = Boolean(
|
|
66
|
+
node._isFenced
|
|
67
|
+
&& fenceCharacter
|
|
68
|
+
&& new RegExp(`^ {0,3}${fenceCharacter === "`" ? "`" : "~"}{${fenceLength},}\\s*$`).test(closingLine),
|
|
69
|
+
);
|
|
70
|
+
codeBlocks.push({
|
|
71
|
+
node,
|
|
72
|
+
startLine: node.sourcepos[0][0],
|
|
73
|
+
endLine: node.sourcepos[1][0],
|
|
74
|
+
fenced: Boolean(node._isFenced),
|
|
75
|
+
closed,
|
|
76
|
+
language: String(node.info || "").trim().split(/\s+/)[0] || "",
|
|
77
|
+
content: String(node.literal || "").replace(/\n$/, ""),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
source,
|
|
83
|
+
lines,
|
|
84
|
+
tree,
|
|
85
|
+
headings,
|
|
86
|
+
items,
|
|
87
|
+
codeBlocks,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function sectionEndLine(structure, heading) {
|
|
92
|
+
const next = structure.headings.find((entry) => (
|
|
93
|
+
entry.startLine > heading.startLine && entry.level <= heading.level
|
|
94
|
+
));
|
|
95
|
+
return next ? next.startLine : Number.POSITIVE_INFINITY;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function sectionNodes(heading, options) {
|
|
99
|
+
const nodes = [];
|
|
100
|
+
let current = heading && heading.node ? heading.node.next : null;
|
|
101
|
+
while (current) {
|
|
102
|
+
if (current.type === "heading" && (
|
|
103
|
+
options && options.stopAtAnyHeading
|
|
104
|
+
|| current.level <= heading.level
|
|
105
|
+
)) {
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
nodes.push(current);
|
|
109
|
+
current = current.next;
|
|
110
|
+
}
|
|
111
|
+
return nodes;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function itemLiteral(structure, item) {
|
|
115
|
+
if (item.startLine !== item.endLine) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const line = structure.lines[item.startLine - 1] || "";
|
|
119
|
+
const match = line.match(/^\s*(?:[-+*]|\d+[.)])\s+(.+?)\s*$/);
|
|
120
|
+
return match ? match[1] : null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
module.exports = {
|
|
124
|
+
itemLiteral,
|
|
125
|
+
markdownStructure,
|
|
126
|
+
nodeText,
|
|
127
|
+
sectionEndLine,
|
|
128
|
+
sectionNodes,
|
|
129
|
+
};
|