blun-king-cli 9.1.624 → 9.1.625
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/CHANGELOG.md +62 -213
- package/LIESMICH.txt +57 -74
- package/README.md +76 -119
- package/agent-spine-plugin/scripts/check-install.js +4 -4
- package/agent-spine-plugin/src/hook.js +0 -4
- package/agent-spine-plugin/src/lib/documents.js +1 -1
- package/agent-spine-plugin/src/lib/hook-context.js +0 -1
- package/agent-spine-plugin/src/lib/host-instruction-budget.js +2 -1
- package/agent-spine-plugin/src/lib/preflight.js +9 -38
- package/agent-spine-plugin/src/lib/source-roots.js +1 -1
- package/bin/agentspine-king-goal-inbox.mjs +127 -127
- package/bin/agentspine-king-goal-intake.mjs +106 -106
- package/bin/agentspine-king-host-runner.mjs +109 -109
- package/bin/agentspine-king-snapshot-policy.cjs +80 -80
- package/bin/agentspine-king-status-policy.mjs +226 -226
- package/bin/agentspine-king-worker-host.mjs +160 -160
- package/bin/core-bootstrap.js +71 -100
- package/bin/launcher-mode.js +93 -93
- package/bin/launcher-restart-policy.cjs +131 -131
- package/bin/launcher-runtime.js +89 -254
- package/bin/managed-node.js +186 -186
- package/bin/managed-plugin-selection.cjs +109 -116
- package/bin/native-module-repair.js +201 -201
- package/bin/node-runtime.js +34 -34
- package/bin/node-version.js +49 -49
- package/bin/plugin-bootstrap.js +149 -172
- package/bin/private-paths.js +1578 -1624
- package/bin/runtime-exit-ledger.cjs +144 -144
- package/bin/runtime-exit-ledger.d.cts +23 -23
- package/bin/standard-tools-bootstrap.js +277 -272
- package/bin/turn-thinking-policy.cjs +82 -82
- package/bin/update-copy.js +200 -200
- package/bin/update-lease.js +597 -599
- package/bin/update-notice.js +1568 -1568
- package/bin/verify-agent-behavior.cjs +122 -122
- package/bin/verify-agent-components.cjs +104 -104
- package/bin/verify-bundled-agent-sources.cjs +91 -96
- package/bin/windows-node-crash-dump.cjs +289 -289
- package/blun.mjs +187640 -180475
- package/bundled-agent-sources.json +26 -30
- package/codebase-index/codebase_index.py +462 -470
- package/dist-web/assets/{CodeBlockNode-TKKkJX8L.js → CodeBlockNode-BMbuG85x.js} +1 -1
- package/dist-web/assets/{CodeBlockShell.vue_vue_type_style_index_0_lang-CUj2Ds5x.js → CodeBlockShell.vue_vue_type_style_index_0_lang-C1fv7l_Z.js} +1 -1
- package/dist-web/assets/DesignSystemView-6HgAUEmC.css +1 -0
- package/dist-web/assets/DesignSystemView-CEEBqXSX.js +12 -0
- package/dist-web/assets/{Tooltip-CTWv7WCU.js → Tooltip--YoauJ24.js} +1 -1
- package/dist-web/assets/{abnfDiagram-N423BO3Z-DA8V8Zjh.js → abnfDiagram-N423BO3Z-DZvBWkRg.js} +1 -1
- package/dist-web/assets/{arc-YtddKbdY.js → arc-B04JATeX.js} +1 -1
- package/dist-web/assets/{architectureDiagram-T3A2C74G-CGEiObmo.js → architectureDiagram-T3A2C74G-DmYnMep2.js} +1 -1
- package/dist-web/assets/{blockDiagram-VBNYF7ZC-Bd5Vt50e.js → blockDiagram-VBNYF7ZC-DJ1gPS1C.js} +1 -1
- package/dist-web/assets/{c4Diagram-5PPSVZJV-D2ApPM54.js → c4Diagram-5PPSVZJV-DmjxvUbd.js} +1 -1
- package/dist-web/assets/channel-472fcEvw.js +1 -0
- package/dist-web/assets/{chunk-2GRJ4B5K-BDcIEZSl.js → chunk-2GRJ4B5K-AB0raj3I.js} +1 -1
- package/dist-web/assets/{chunk-2Q5K7J3B-6aSabCX7.js → chunk-2Q5K7J3B-Drf039vM.js} +1 -1
- package/dist-web/assets/{chunk-5RXB4S5H-BFRQvIJS.js → chunk-5RXB4S5H-D5ILttmz.js} +1 -1
- package/dist-web/assets/{chunk-5VM5RSS4-ChAa-DNY.js → chunk-5VM5RSS4-DrLSdi8y.js} +1 -1
- package/dist-web/assets/{chunk-6Q2QTUOP-BIfrb2Jc.js → chunk-6Q2QTUOP-LiaqdEOQ.js} +1 -1
- package/dist-web/assets/{chunk-GF5L2VYU-BR0gvtWI.js → chunk-GF5L2VYU-AIYkb--o.js} +1 -1
- package/dist-web/assets/{chunk-JWPE2WC7-BgXKsx5E.js → chunk-JWPE2WC7-CogdNl0i.js} +1 -1
- package/dist-web/assets/{chunk-KBJHAD2P-I8mrZhpz.js → chunk-KBJHAD2P-DHjpNtZv.js} +1 -1
- package/dist-web/assets/{chunk-RYQCIY6F-BMPaem92.js → chunk-RYQCIY6F-BUSOqH2X.js} +1 -1
- package/dist-web/assets/{chunk-XXDRQBXY-COy0J-0j.js → chunk-XXDRQBXY-BpoMV0bh.js} +1 -1
- package/dist-web/assets/classDiagram-JCYQIIEL-BTZeLngj.js +1 -0
- package/dist-web/assets/classDiagram-v2-OCEON4UE-BTZeLngj.js +1 -0
- package/dist-web/assets/{cose-bilkent-JH36ORCC-MosTTRdo.js → cose-bilkent-JH36ORCC-BJr2I61o.js} +1 -1
- package/dist-web/assets/{cynefin-VYW2F7L2-5tjPgrkP.js → cynefin-VYW2F7L2-HtysQZ4A.js} +1 -1
- package/dist-web/assets/{cynefinDiagram-MW4NZA55-CbDcdInR.js → cynefinDiagram-MW4NZA55-CcpC_2uv.js} +1 -1
- package/dist-web/assets/{dagre-VZM6K2ZE-YaBom1ZH.js → dagre-VZM6K2ZE-D8Ao0LUg.js} +1 -1
- package/dist-web/assets/{diagram-7IWD3JNH-Da4m-Hgz.js → diagram-7IWD3JNH-BITiLhjX.js} +1 -1
- package/dist-web/assets/{diagram-B4RE2ZJO-CAUUegxg.js → diagram-B4RE2ZJO-CJtwfy9f.js} +1 -1
- package/dist-web/assets/{diagram-LBJQPF4R-o21mWKG4.js → diagram-LBJQPF4R-BsVTh6w8.js} +1 -1
- package/dist-web/assets/{diagram-Q27KOJAE-BA3z3sXf.js → diagram-Q27KOJAE-pA_MUCUf.js} +1 -1
- package/dist-web/assets/{diagram-UB23O5K3-CGRdSSDK.js → diagram-UB23O5K3-CIY8z7vu.js} +1 -1
- package/dist-web/assets/{ebnfDiagram-BXEA7PRR-Bw-iU9FP.js → ebnfDiagram-BXEA7PRR-C3FMioqp.js} +1 -1
- package/dist-web/assets/{erDiagram-JOGREHBK-BwM1yiR0.js → erDiagram-JOGREHBK-CzoyKmKc.js} +1 -1
- package/dist-web/assets/{flowDiagram-UKHOOZJN-z05eOR1Q.js → flowDiagram-UKHOOZJN-DOqfushy.js} +1 -1
- package/dist-web/assets/{ganttDiagram-PKOTCBZU-BMUubNTl.js → ganttDiagram-PKOTCBZU-Cf9XQSWl.js} +1 -1
- package/dist-web/assets/{gitGraphDiagram-DS77QQ5N-Dccbi1wU.js → gitGraphDiagram-DS77QQ5N-DHUDofE5.js} +1 -1
- package/dist-web/assets/{index-h0KEOmkU.js → index-B6qEMQMx.js} +14 -14
- package/dist-web/assets/{index-C9eDH3u-.css → index-BmKj7CB1.css} +1 -1
- package/dist-web/assets/{index-BBbC5LRF.js → index-DokxDX1w.js} +1 -1
- package/dist-web/assets/{index-D48p0M2S.js → index-auojtiAA.js} +2 -2
- package/dist-web/assets/{index10-Qbuw1N6u.js → index10-Drb2n5e5.js} +1 -1
- package/dist-web/assets/{index11-g8v025wN.js → index11-Cx-aV4G2.js} +1 -1
- package/dist-web/assets/{index5-BYNcV8BY.js → index5-Dg3qGTyH.js} +1 -1
- package/dist-web/assets/{index6-BetANtnV.js → index6-BgvtIICP.js} +1 -1
- package/dist-web/assets/{index7-BcPbgCKN.js → index7-uEnniPQG.js} +1 -1
- package/dist-web/assets/{index8-B1lp-RvF.js → index8-h4IKc0ek.js} +2 -2
- package/dist-web/assets/{infoDiagram-6WML65LV-BF_pbUnN.js → infoDiagram-6WML65LV-D-3tvEiJ.js} +1 -1
- package/dist-web/assets/{ishikawaDiagram-WSZJBQD7-Dedv4urS.js → ishikawaDiagram-WSZJBQD7-DIIBNv7a.js} +1 -1
- package/dist-web/assets/{journeyDiagram-NVQOT4AX-B1Ex3b6o.js → journeyDiagram-NVQOT4AX-DP4r1Vlx.js} +1 -1
- package/dist-web/assets/{kanban-definition-27J2QSJJ-BtCGliBH.js → kanban-definition-27J2QSJJ-C3_Ztgxv.js} +1 -1
- package/dist-web/assets/{linear-ByItc8Qr.js → linear-DnqhIw-y.js} +1 -1
- package/dist-web/assets/{mermaid.core-B1M2O7nN.js → mermaid.core-xYUgBa3T.js} +4 -4
- package/dist-web/assets/{mindmap-definition-FAOFIHXS-D0UHKUyj.js → mindmap-definition-FAOFIHXS-l-dq-zfr.js} +1 -1
- package/dist-web/assets/{pegDiagram-VL7TDLO6-D7zYCVmG.js → pegDiagram-VL7TDLO6-C8vXQiaJ.js} +1 -1
- package/dist-web/assets/{pieDiagram-7S7Q4E2Y-Bd0i9CHa.js → pieDiagram-7S7Q4E2Y-CyNRSsI6.js} +1 -1
- package/dist-web/assets/{quadrantDiagram-CIZ2JOQS-MG-Ug47d.js → quadrantDiagram-CIZ2JOQS-D-w8AD_g.js} +1 -1
- package/dist-web/assets/{railroadDiagram-AXF67PYL-AZdl90Gj.js → railroadDiagram-AXF67PYL-BLkyQCWy.js} +1 -1
- package/dist-web/assets/{requirementDiagram-LRYGKXZP-DjplF9kt.js → requirementDiagram-LRYGKXZP-CEWO7XfT.js} +1 -1
- package/dist-web/assets/{sankeyDiagram-W5VNT64P-Bi9Zgfjs.js → sankeyDiagram-W5VNT64P-ByGoAaGj.js} +1 -1
- package/dist-web/assets/{sequenceDiagram-SI44F4Z6-ChEpdCvb.js → sequenceDiagram-SI44F4Z6-Bhn9GQtd.js} +1 -1
- package/dist-web/assets/{sizeCapture-X5ZJPWSS-B5RFUdaa.js → sizeCapture-X5ZJPWSS-jVKR9CTu.js} +1 -1
- package/dist-web/assets/{stateDiagram-OKZ733FA-BkRblSKp.js → stateDiagram-OKZ733FA-wW3XbegA.js} +1 -1
- package/dist-web/assets/stateDiagram-v2-UEYNNEHI-B8aids-Z.js +1 -0
- package/dist-web/assets/{swimlanes-SLNWSIFB-DLXH6Zhc.js → swimlanes-SLNWSIFB-B8QyFS7G.js} +2 -2
- package/dist-web/assets/swimlanesDiagram-ULZ7WXOC-B8XAkdSm.js +8 -0
- package/dist-web/assets/{timeline-definition-Z64GVDOM-C_N88siO.js → timeline-definition-Z64GVDOM-DpvxS-1A.js} +1 -1
- package/dist-web/assets/{vennDiagram-T6HMQDX7-DMsnvDt0.js → vennDiagram-T6HMQDX7-BzGM0ihY.js} +1 -1
- package/dist-web/assets/{vue.runtime.esm-bundler-B-3uIy85.js → vue.runtime.esm-bundler-BOcpwIX1.js} +1 -1
- package/dist-web/assets/{wardleyDiagram-T6FBY63Y-C9SJIPzq.js → wardleyDiagram-T6FBY63Y-2DKAOs5e.js} +1 -1
- package/dist-web/assets/{xychartDiagram-ELKLHX3M-DZLWA6Go.js → xychartDiagram-ELKLHX3M-B0SP0TXd.js} +1 -1
- package/dist-web/index.html +32 -32
- package/dist-web/vis/index.html.gz +0 -0
- package/package.json +1 -1
- package/scripts/fix-node-pty-perms.js +53 -53
- package/standard-skills/blun-app-design-system/SKILL.md +30 -30
- package/standard-skills/blun-app-design-system/provenance.json +17 -17
- package/standard-skills/blun-app-design-system/references/tokens.md +48 -48
- package/standard-skills/blun-app-design-system/scripts/check-blun-design.mjs +49 -49
- package/standard-skills/translate-native/README.md +1 -1
- package/standard-skills/translate-native/scripts/blun_language_guard.py +2 -0
- package/standard-skills/translate-native/scripts/language_gateway.py +2 -0
- package/standard-skills/translate-native/scripts/pre_output_guard.py +2 -0
- package/standard-tools/language-guard/blun_language_guard.py +2 -0
- package/standard-tools/language-guard/language_gateway.py +2 -0
- package/standard-tools/language-guard/pre_output_guard.py +2 -0
- package/telegram-plugin/blun.plugin.json +20 -20
- package/telegram-plugin/commands/access.md +37 -37
- package/telegram-plugin/dist/bridge.mjs +310 -187
- package/telegram-plugin/dist/mcp-server.mjs +174 -261
- package/telegram-plugin/dist/noise.mjs +1 -19
- package/worker-host.mjs +13747 -16824
- package/bin/profile-handoff.cjs +0 -152
- package/bin/profile-launch.cjs +0 -120
- package/dist-web/assets/DesignSystemView-DwK1aQMo.js +0 -12
- package/dist-web/assets/DesignSystemView-szjTj7ns.css +0 -1
- package/dist-web/assets/channel-BnluexuN.js +0 -1
- package/dist-web/assets/classDiagram-JCYQIIEL-BliFdSD9.js +0 -1
- package/dist-web/assets/classDiagram-v2-OCEON4UE-BliFdSD9.js +0 -1
- package/dist-web/assets/stateDiagram-v2-UEYNNEHI-fVkQcACW.js +0 -1
- package/dist-web/assets/swimlanesDiagram-ULZ7WXOC-Bg-BiZJQ.js +0 -8
|
@@ -1,272 +1,277 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const { randomUUID } = require('node:crypto');
|
|
4
|
-
const fs = require('node:fs');
|
|
5
|
-
const path = require('node:path');
|
|
6
|
-
|
|
7
|
-
const {
|
|
8
|
-
ensurePrivateDirectory,
|
|
9
|
-
securePrivateFile,
|
|
10
|
-
securePrivateTree,
|
|
11
|
-
writePrivateFile,
|
|
12
|
-
} = require('./private-paths');
|
|
13
|
-
|
|
14
|
-
function isObject(value) {
|
|
15
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function readCatalogue(packageRoot) {
|
|
19
|
-
const manifestPath = path.join(packageRoot, 'standard-tools', 'manifest.json');
|
|
20
|
-
const parsed = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
21
|
-
if (!isObject(parsed) || parsed.version !== 1 || !isObject(parsed.tools)) {
|
|
22
|
-
throw new Error(`Ungueltiger Standard-Tools-Katalog: ${manifestPath}`);
|
|
23
|
-
}
|
|
24
|
-
for (const [name, tool] of Object.entries(parsed.tools)) {
|
|
25
|
-
if (!isObject(tool) || !Array.isArray(tool.detectTokens)
|
|
26
|
-
|| !tool.detectTokens.every((token) => typeof token === 'string' && token.length > 0)) {
|
|
27
|
-
throw new Error(`Ungueltiger Standard-Tool-Eintrag: ${name}`);
|
|
28
|
-
}
|
|
29
|
-
if (tool.platforms !== undefined
|
|
30
|
-
&& (!Array.isArray(tool.platforms)
|
|
31
|
-
|| !tool.platforms.every((platform) => platform === 'darwin' || platform === 'win32'))) {
|
|
32
|
-
throw new Error(`Ungueltige Standard-Tool-Plattform: ${name}`);
|
|
33
|
-
}
|
|
34
|
-
if (tool.owner === 'user-mcp'
|
|
35
|
-
&& (!isObject(tool.config) || typeof tool.config.enabled !== 'boolean')) {
|
|
36
|
-
throw new Error(`Standard-Tool braucht einen Aktivierungszustand: ${name}`);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return parsed;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function readMcpDocument(configPath) {
|
|
43
|
-
if (!fs.existsSync(configPath)) return { mcpServers: {} };
|
|
44
|
-
let parsed;
|
|
45
|
-
try {
|
|
46
|
-
parsed = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
47
|
-
} catch (error) {
|
|
48
|
-
throw new Error(`Ungueltige MCP-Konfiguration (JSON): ${configPath}`, { cause: error });
|
|
49
|
-
}
|
|
50
|
-
if (!isObject(parsed) || (parsed.mcpServers !== undefined && !isObject(parsed.mcpServers))) {
|
|
51
|
-
throw new Error(`Ungueltige MCP-Konfiguration: ${configPath}`);
|
|
52
|
-
}
|
|
53
|
-
return parsed.mcpServers === undefined ? { ...parsed, mcpServers: {} } : parsed;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function serverSearchText(name, config) {
|
|
57
|
-
const values = [name];
|
|
58
|
-
if (isObject(config)) {
|
|
59
|
-
if (typeof config.command === 'string') values.push(config.command);
|
|
60
|
-
if (Array.isArray(config.args)) {
|
|
61
|
-
values.push(...config.args.filter((value) => typeof value === 'string'));
|
|
62
|
-
}
|
|
63
|
-
if (typeof config.url === 'string') values.push(config.url);
|
|
64
|
-
}
|
|
65
|
-
return values.join('\n').toLowerCase();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function hasEquivalentServer(servers, name, tool) {
|
|
69
|
-
if (Object.hasOwn(servers, name)) return true;
|
|
70
|
-
const tokens = tool.detectTokens.map((token) => token.toLowerCase());
|
|
71
|
-
return Object.entries(servers).some(([serverName, config]) => {
|
|
72
|
-
const searchText = serverSearchText(serverName, config);
|
|
73
|
-
return tokens.some((token) => searchText.includes(token));
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function sameStringArray(left, right) {
|
|
78
|
-
return Array.isArray(left)
|
|
79
|
-
&& Array.isArray(right)
|
|
80
|
-
&& left.length === right.length
|
|
81
|
-
&& left.every((value, index) => value === right[index]);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function recognizedBundledServer(name, current, expected) {
|
|
85
|
-
if (!isObject(current)) return false;
|
|
86
|
-
const exact = current.transport === expected.transport
|
|
87
|
-
&& current.command === expected.command
|
|
88
|
-
&& sameStringArray(current.args, expected.args);
|
|
89
|
-
if (exact) return true;
|
|
90
|
-
return name === 'context7'
|
|
91
|
-
&& current.transport === 'stdio'
|
|
92
|
-
&& current.command === 'npx'
|
|
93
|
-
&& Array.isArray(current.args)
|
|
94
|
-
&& current.args[0] === '-y'
|
|
95
|
-
&& /^@upstash\/context7-mcp(?:@[^\s]+)?$/u.test(current.args[1] ?? '');
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function migrateBundledTool(name, current, expected) {
|
|
99
|
-
if (!recognizedBundledServer(name, current, expected)) return false;
|
|
100
|
-
let changed = false;
|
|
101
|
-
if (current.enabled === false && name !== 'blun-language-guard') {
|
|
102
|
-
current.enabled = true;
|
|
103
|
-
changed = true;
|
|
104
|
-
}
|
|
105
|
-
if (name === 'agent-browser') {
|
|
106
|
-
if (current.startupTimeoutMs === 30_000) {
|
|
107
|
-
current.startupTimeoutMs = expected.startupTimeoutMs;
|
|
108
|
-
changed = true;
|
|
109
|
-
}
|
|
110
|
-
if (current.toolTimeoutMs === 60_000) {
|
|
111
|
-
current.toolTimeoutMs = expected.toolTimeoutMs;
|
|
112
|
-
changed = true;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
if (name === 'blun-language-guard'
|
|
116
|
-
&& (current.toolTimeoutMs === 30_000 || current.toolTimeoutMs === 60_000)) {
|
|
117
|
-
current.toolTimeoutMs = expected.toolTimeoutMs;
|
|
118
|
-
changed = true;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
const
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
servers
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { randomUUID } = require('node:crypto');
|
|
4
|
+
const fs = require('node:fs');
|
|
5
|
+
const path = require('node:path');
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
ensurePrivateDirectory,
|
|
9
|
+
securePrivateFile,
|
|
10
|
+
securePrivateTree,
|
|
11
|
+
writePrivateFile,
|
|
12
|
+
} = require('./private-paths');
|
|
13
|
+
|
|
14
|
+
function isObject(value) {
|
|
15
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function readCatalogue(packageRoot) {
|
|
19
|
+
const manifestPath = path.join(packageRoot, 'standard-tools', 'manifest.json');
|
|
20
|
+
const parsed = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
21
|
+
if (!isObject(parsed) || parsed.version !== 1 || !isObject(parsed.tools)) {
|
|
22
|
+
throw new Error(`Ungueltiger Standard-Tools-Katalog: ${manifestPath}`);
|
|
23
|
+
}
|
|
24
|
+
for (const [name, tool] of Object.entries(parsed.tools)) {
|
|
25
|
+
if (!isObject(tool) || !Array.isArray(tool.detectTokens)
|
|
26
|
+
|| !tool.detectTokens.every((token) => typeof token === 'string' && token.length > 0)) {
|
|
27
|
+
throw new Error(`Ungueltiger Standard-Tool-Eintrag: ${name}`);
|
|
28
|
+
}
|
|
29
|
+
if (tool.platforms !== undefined
|
|
30
|
+
&& (!Array.isArray(tool.platforms)
|
|
31
|
+
|| !tool.platforms.every((platform) => platform === 'darwin' || platform === 'win32'))) {
|
|
32
|
+
throw new Error(`Ungueltige Standard-Tool-Plattform: ${name}`);
|
|
33
|
+
}
|
|
34
|
+
if (tool.owner === 'user-mcp'
|
|
35
|
+
&& (!isObject(tool.config) || typeof tool.config.enabled !== 'boolean')) {
|
|
36
|
+
throw new Error(`Standard-Tool braucht einen Aktivierungszustand: ${name}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return parsed;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function readMcpDocument(configPath) {
|
|
43
|
+
if (!fs.existsSync(configPath)) return { mcpServers: {} };
|
|
44
|
+
let parsed;
|
|
45
|
+
try {
|
|
46
|
+
parsed = JSON.parse(fs.readFileSync(configPath, 'utf8'));
|
|
47
|
+
} catch (error) {
|
|
48
|
+
throw new Error(`Ungueltige MCP-Konfiguration (JSON): ${configPath}`, { cause: error });
|
|
49
|
+
}
|
|
50
|
+
if (!isObject(parsed) || (parsed.mcpServers !== undefined && !isObject(parsed.mcpServers))) {
|
|
51
|
+
throw new Error(`Ungueltige MCP-Konfiguration: ${configPath}`);
|
|
52
|
+
}
|
|
53
|
+
return parsed.mcpServers === undefined ? { ...parsed, mcpServers: {} } : parsed;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function serverSearchText(name, config) {
|
|
57
|
+
const values = [name];
|
|
58
|
+
if (isObject(config)) {
|
|
59
|
+
if (typeof config.command === 'string') values.push(config.command);
|
|
60
|
+
if (Array.isArray(config.args)) {
|
|
61
|
+
values.push(...config.args.filter((value) => typeof value === 'string'));
|
|
62
|
+
}
|
|
63
|
+
if (typeof config.url === 'string') values.push(config.url);
|
|
64
|
+
}
|
|
65
|
+
return values.join('\n').toLowerCase();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function hasEquivalentServer(servers, name, tool) {
|
|
69
|
+
if (Object.hasOwn(servers, name)) return true;
|
|
70
|
+
const tokens = tool.detectTokens.map((token) => token.toLowerCase());
|
|
71
|
+
return Object.entries(servers).some(([serverName, config]) => {
|
|
72
|
+
const searchText = serverSearchText(serverName, config);
|
|
73
|
+
return tokens.some((token) => searchText.includes(token));
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function sameStringArray(left, right) {
|
|
78
|
+
return Array.isArray(left)
|
|
79
|
+
&& Array.isArray(right)
|
|
80
|
+
&& left.length === right.length
|
|
81
|
+
&& left.every((value, index) => value === right[index]);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function recognizedBundledServer(name, current, expected) {
|
|
85
|
+
if (!isObject(current)) return false;
|
|
86
|
+
const exact = current.transport === expected.transport
|
|
87
|
+
&& current.command === expected.command
|
|
88
|
+
&& sameStringArray(current.args, expected.args);
|
|
89
|
+
if (exact) return true;
|
|
90
|
+
return name === 'context7'
|
|
91
|
+
&& current.transport === 'stdio'
|
|
92
|
+
&& current.command === 'npx'
|
|
93
|
+
&& Array.isArray(current.args)
|
|
94
|
+
&& current.args[0] === '-y'
|
|
95
|
+
&& /^@upstash\/context7-mcp(?:@[^\s]+)?$/u.test(current.args[1] ?? '');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function migrateBundledTool(name, current, expected) {
|
|
99
|
+
if (!recognizedBundledServer(name, current, expected)) return false;
|
|
100
|
+
let changed = false;
|
|
101
|
+
if (current.enabled === false && name !== 'blun-language-guard') {
|
|
102
|
+
current.enabled = true;
|
|
103
|
+
changed = true;
|
|
104
|
+
}
|
|
105
|
+
if (name === 'agent-browser') {
|
|
106
|
+
if (current.startupTimeoutMs === 30_000) {
|
|
107
|
+
current.startupTimeoutMs = expected.startupTimeoutMs;
|
|
108
|
+
changed = true;
|
|
109
|
+
}
|
|
110
|
+
if (current.toolTimeoutMs === 60_000) {
|
|
111
|
+
current.toolTimeoutMs = expected.toolTimeoutMs;
|
|
112
|
+
changed = true;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
if (name === 'blun-language-guard'
|
|
116
|
+
&& (current.toolTimeoutMs === 30_000 || current.toolTimeoutMs === 60_000)) {
|
|
117
|
+
current.toolTimeoutMs = expected.toolTimeoutMs;
|
|
118
|
+
changed = true;
|
|
119
|
+
}
|
|
120
|
+
if (name === 'blun-language-guard'
|
|
121
|
+
&& (!isObject(current.env) || current.env.PYTHONDONTWRITEBYTECODE !== '1')) {
|
|
122
|
+
current.env = { ...(isObject(current.env) ? current.env : {}), PYTHONDONTWRITEBYTECODE: '1' };
|
|
123
|
+
changed = true;
|
|
124
|
+
}
|
|
125
|
+
return changed;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
function writeMcpDocument(configPath, document) {
|
|
129
|
+
const temporaryPath = path.join(
|
|
130
|
+
path.dirname(configPath),
|
|
131
|
+
`.${path.basename(configPath)}.${process.pid}.${randomUUID()}.tmp`,
|
|
132
|
+
);
|
|
133
|
+
try {
|
|
134
|
+
writePrivateFile(temporaryPath, `${JSON.stringify(document, null, 2)}\n`);
|
|
135
|
+
fs.renameSync(temporaryPath, configPath);
|
|
136
|
+
} catch (error) {
|
|
137
|
+
fs.rmSync(temporaryPath, { force: true });
|
|
138
|
+
throw error;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function bundledToolConfig(name, tool, { packageRoot, blunDir, platform, env }) {
|
|
143
|
+
const config = structuredClone(tool.config);
|
|
144
|
+
config.enabled = true;
|
|
145
|
+
if (name === 'blun-language-guard') {
|
|
146
|
+
config.command = platform === 'win32' ? 'python' : 'python3';
|
|
147
|
+
config.args = [
|
|
148
|
+
path.join(
|
|
149
|
+
packageRoot,
|
|
150
|
+
'standard-tools',
|
|
151
|
+
'language-guard',
|
|
152
|
+
'blun_language_guard.py',
|
|
153
|
+
),
|
|
154
|
+
'serve',
|
|
155
|
+
];
|
|
156
|
+
config.env = {
|
|
157
|
+
...(isObject(config.env) ? config.env : {}),
|
|
158
|
+
PYTHONDONTWRITEBYTECODE: '1',
|
|
159
|
+
PYTHONUTF8: '1',
|
|
160
|
+
BLUN_LANGUAGE_GUARD_KEY_FILE: path.join(
|
|
161
|
+
blunDir,
|
|
162
|
+
'secrets',
|
|
163
|
+
'blun-language-guard-signing.key',
|
|
164
|
+
),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
if (name === 'windows-mcp' && platform === 'win32') {
|
|
168
|
+
const localUvx = typeof env.USERPROFILE === 'string'
|
|
169
|
+
? path.join(env.USERPROFILE, '.local', 'bin', 'uvx.exe')
|
|
170
|
+
: undefined;
|
|
171
|
+
config.command = localUvx !== undefined && fs.existsSync(localUvx) ? localUvx : 'uvx';
|
|
172
|
+
}
|
|
173
|
+
return config;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function availableStandardToolNames({
|
|
177
|
+
packageRoot,
|
|
178
|
+
platform = process.platform,
|
|
179
|
+
}) {
|
|
180
|
+
const catalogue = readCatalogue(packageRoot);
|
|
181
|
+
return Object.entries(catalogue.tools)
|
|
182
|
+
.filter(([, tool]) => tool.owner === 'user-mcp' || tool.owner === 'managed-plugin')
|
|
183
|
+
.filter(([, tool]) => !Array.isArray(tool.platforms) || tool.platforms.includes(platform))
|
|
184
|
+
.map(([name]) => name);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function seedStandardTools({
|
|
188
|
+
packageRoot,
|
|
189
|
+
blunDir,
|
|
190
|
+
names,
|
|
191
|
+
platform = process.platform,
|
|
192
|
+
env = process.env,
|
|
193
|
+
}) {
|
|
194
|
+
const catalogue = readCatalogue(packageRoot);
|
|
195
|
+
if (!Array.isArray(names) || names.length === 0) {
|
|
196
|
+
throw new Error('Mindestens ein Standard-Tool muss ausdruecklich ausgewaehlt werden.');
|
|
197
|
+
}
|
|
198
|
+
const selectedNames = [...new Set(names)];
|
|
199
|
+
for (const name of selectedNames) {
|
|
200
|
+
const tool = catalogue.tools[name];
|
|
201
|
+
if (!isObject(tool) || tool.owner !== 'user-mcp') {
|
|
202
|
+
throw new Error(`Unbekanntes Standard-Tool: ${name}`);
|
|
203
|
+
}
|
|
204
|
+
if (Array.isArray(tool.platforms) && !tool.platforms.includes(platform)) {
|
|
205
|
+
throw new Error(`Standard-Tool ist auf dieser Plattform nicht verfuegbar: ${name}`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
const configPath = path.join(blunDir, 'mcp.json');
|
|
209
|
+
ensurePrivateDirectory(blunDir);
|
|
210
|
+
if (fs.existsSync(configPath)) securePrivateFile(configPath);
|
|
211
|
+
const document = readMcpDocument(configPath);
|
|
212
|
+
const servers = { ...document.mcpServers };
|
|
213
|
+
const added = [];
|
|
214
|
+
const updated = [];
|
|
215
|
+
|
|
216
|
+
for (const name of selectedNames) {
|
|
217
|
+
const tool = catalogue.tools[name];
|
|
218
|
+
const expected = bundledToolConfig(name, tool, {
|
|
219
|
+
packageRoot,
|
|
220
|
+
blunDir,
|
|
221
|
+
platform,
|
|
222
|
+
env,
|
|
223
|
+
});
|
|
224
|
+
if (Object.hasOwn(servers, name)) {
|
|
225
|
+
if (migrateBundledTool(name, servers[name], expected)) updated.push(name);
|
|
226
|
+
continue;
|
|
227
|
+
}
|
|
228
|
+
if (hasEquivalentServer(servers, name, tool)) continue;
|
|
229
|
+
servers[name] = expected;
|
|
230
|
+
added.push(name);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (added.length > 0 || updated.length > 0) {
|
|
234
|
+
writeMcpDocument(configPath, { ...document, mcpServers: servers });
|
|
235
|
+
}
|
|
236
|
+
return { added, updated, configPath };
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function seedStandardDesignSkill({ packageRoot, blunDir }) {
|
|
240
|
+
const sourcePath = path.join(
|
|
241
|
+
packageRoot,
|
|
242
|
+
'standard-skills',
|
|
243
|
+
'blun-app-design-system',
|
|
244
|
+
);
|
|
245
|
+
const sourceStat = fs.lstatSync(sourcePath);
|
|
246
|
+
if (!sourceStat.isDirectory() || sourceStat.isSymbolicLink()) {
|
|
247
|
+
throw new Error(`Ungueltiger BLUN-Standard-Skill: ${sourcePath}`);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const skillsDir = path.join(blunDir, 'skills');
|
|
251
|
+
ensurePrivateDirectory(skillsDir);
|
|
252
|
+
const destinationPath = path.join(skillsDir, 'blun-app-design-system');
|
|
253
|
+
const installed = !fs.existsSync(destinationPath);
|
|
254
|
+
if (!installed) {
|
|
255
|
+
const destinationStat = fs.lstatSync(destinationPath);
|
|
256
|
+
if (!destinationStat.isDirectory() || destinationStat.isSymbolicLink()) {
|
|
257
|
+
throw new Error(`Ungueltiges Ziel fuer BLUN-Standard-Skill: ${destinationPath}`);
|
|
258
|
+
}
|
|
259
|
+
} else {
|
|
260
|
+
ensurePrivateDirectory(destinationPath);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
fs.cpSync(sourcePath, destinationPath, {
|
|
264
|
+
recursive: true,
|
|
265
|
+
force: true,
|
|
266
|
+
errorOnExist: false,
|
|
267
|
+
});
|
|
268
|
+
securePrivateTree(destinationPath);
|
|
269
|
+
return { installed, updated: !installed, destinationPath };
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
module.exports = {
|
|
273
|
+
availableStandardToolNames,
|
|
274
|
+
readCatalogue,
|
|
275
|
+
seedStandardDesignSkill,
|
|
276
|
+
seedStandardTools,
|
|
277
|
+
};
|