nolo-cli 0.10.0 → 0.11.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.
Files changed (106) hide show
  1. package/{_executeModel-YAXYAUOK.js → _executeModel-ZEDPX6OF.js} +47 -45
  2. package/{action-TLI3V62L.js → action-AA4IJ5K2.js} +9 -9
  3. package/{addContentAction-PLWJSCOZ.js → addContentAction-QYVO4SYP.js} +8 -8
  4. package/{addDialogAgentAction-BJ6SB76X.js → addDialogAgentAction-WVVKT5WQ.js} +10 -10
  5. package/{agentDeleteCommand-2VYX73U5.js → agentDeleteCommand-RDPGYIWF.js} +25 -25
  6. package/{agentEmailCommands-3GDZIX64.js → agentEmailCommands-2HJJKS5F.js} +59 -56
  7. package/{agentListCommands-UWVBT3LH.js → agentListCommands-HFEVV3ZW.js} +30 -29
  8. package/{agentMachineCommands-WOKMUG2Y.js → agentMachineCommands-25ZOENJU.js} +28 -28
  9. package/{agentRecordCommands-MVNZRH3U.js → agentRecordCommands-GTCOAM3L.js} +50 -47
  10. package/{agentRunCommand-K7THIJLA.js → agentRunCommand-YBS3JDLD.js} +57 -53
  11. package/{agentRuntimeLocal-WJIGU24U.js → agentRuntimeLocal-UQBMQI2M.js} +11 -11
  12. package/{agentSlice-LL5TKZEO.js → agentSlice-6EKOBCCS.js} +9 -9
  13. package/{authCommand-TC2SW2CQ.js → authCommand-O2OWACN4.js} +12 -12
  14. package/{authCommands-XPEHTKSM.js → authCommands-H7365TZP.js} +6 -6
  15. package/{chunk-TYSCFY6S.js → chunk-2W2VYVI5.js} +334 -90
  16. package/{chunk-4SIMLBEU.js → chunk-3NSIQZZ6.js} +3 -3
  17. package/{chunk-AUQ747NZ.js → chunk-4SOKXIW4.js} +70 -6
  18. package/{chunk-PIVFPOW6.js → chunk-5MOUAAMK.js} +75 -71
  19. package/{chunk-A67QFHAA.js → chunk-5OIFWVX7.js} +1 -1
  20. package/{chunk-5JGGZCZL.js → chunk-7D3JY6C2.js} +2 -2
  21. package/{chunk-OR2XR25C.js → chunk-AEZAORLG.js} +4 -4
  22. package/chunk-AFON4QUU.js +112 -0
  23. package/{chunk-6KUOUWMP.js → chunk-BX6U3ETE.js} +19 -12
  24. package/{chunk-CDTLMEB3.js → chunk-C2MDQQ4O.js} +1 -1
  25. package/{chunk-SL35K7AH.js → chunk-C4FTUXVF.js} +2 -82
  26. package/{chunk-GAKEBQD6.js → chunk-D6OQHXVG.js} +11 -7
  27. package/{chunk-WPE4F4Z6.js → chunk-DWGAEFJL.js} +1 -1
  28. package/{chunk-HJGEVL7C.js → chunk-E4HNJSHC.js} +19 -19
  29. package/{chunk-TNPIMII7.js → chunk-EVZKZF32.js} +72 -39
  30. package/{chunk-C3RUNRHT.js → chunk-FXXSGWAJ.js} +1 -1
  31. package/{chunk-7KNKFIRO.js → chunk-GBDSZATH.js} +3 -3
  32. package/{chunk-7U44LYTR.js → chunk-IPYUUY4E.js} +1 -1
  33. package/{chunk-QAALPJS7.js → chunk-KJR5KAUQ.js} +2 -2
  34. package/{chunk-OZMMKDBI.js → chunk-KQQVGRA3.js} +23 -23
  35. package/{chunk-AVMKZHBC.js → chunk-L53FGHA4.js} +3 -2
  36. package/{chunk-CL3IOKGK.js → chunk-LAX2JSTX.js} +2 -2
  37. package/{chunk-NPVBXJY2.js → chunk-LP65VRCI.js} +5 -5
  38. package/chunk-LTRXGFMS.js +83 -0
  39. package/{chunk-KBKYAONQ.js → chunk-MQI77IRB.js} +2 -2
  40. package/{chunk-HFASY3WO.js → chunk-NEM67FX7.js} +1 -1
  41. package/{chunk-BE2OOJ5P.js → chunk-O26GI2JP.js} +8 -8
  42. package/{chunk-PAKN26FP.js → chunk-OUI3ZHYD.js} +1 -1
  43. package/{chunk-2O4IZNTG.js → chunk-PXQN7IBQ.js} +2 -2
  44. package/{chunk-4IJYA27C.js → chunk-PXZAAB4L.js} +4 -4
  45. package/{chunk-I5URP43I.js → chunk-Q3UKJVU4.js} +9 -9
  46. package/{chunk-AS4PVWA4.js → chunk-QNMFBBZK.js} +1 -1
  47. package/{chunk-6SLCD4RB.js → chunk-S3GS2PRL.js} +10 -10
  48. package/{chunk-T7R3NGUU.js → chunk-SV5MWASH.js} +16 -16
  49. package/{chunk-6JJWFVZ6.js → chunk-TACHTH5D.js} +15 -15
  50. package/chunk-VC6OZXO5.js +298 -0
  51. package/{chunk-ZQ2UM4KG.js → chunk-WZSRQNQG.js} +1 -292
  52. package/{chunk-EXXFGKF7.js → chunk-X2S7JTIG.js} +222 -45
  53. package/{chunk-DSZUWUYB.js → chunk-XFOLQLDN.js} +1 -1
  54. package/{chunk-YIHFXH5Q.js → chunk-XYZA7S7V.js} +6 -6
  55. package/{chunk-3Y3HW5PX.js → chunk-ZEYDOXHF.js} +105 -126
  56. package/{chunk-5KLGBAAR.js → chunk-ZPRK73XY.js} +1 -1
  57. package/{cliExecutor-DNE7TCC4.js → cliExecutor-K3F7DMRO.js} +2 -2
  58. package/{createAgentAutomationAction-CCE7CWGQ.js → createAgentAutomationAction-LTI5QU35.js} +21 -21
  59. package/{createDialogAction-QTRR4AT7.js → createDialogAction-OJJ7L3L3.js} +23 -22
  60. package/{createPageAction-Y4KQOAJE.js → createPageAction-5MXWVRGY.js} +26 -25
  61. package/{dbSlice-WWNV2SGX.js → dbSlice-RQFQQVHT.js} +7 -7
  62. package/{deleteFile-OW53A6BX.js → deleteFile-7XP5BGC7.js} +5 -5
  63. package/{dialogCommands-SMKIAC3Y.js → dialogCommands-JTJ3RPPW.js} +21 -21
  64. package/{dialogSlice-PT7YBWNE.js → dialogSlice-OWROKURJ.js} +19 -19
  65. package/{docCreateCommands-RFNA4HNM.js → docCreateCommands-WJBEW2V7.js} +22 -21
  66. package/{docDeleteCommands-4YZ325M6.js → docDeleteCommands-BVEHJOY5.js} +24 -23
  67. package/{docReadCommands-RT6VAFFG.js → docReadCommands-NEWOZIJV.js} +22 -21
  68. package/{docStore-QUQZAFZF.js → docStore-3DXRYBMD.js} +20 -20
  69. package/{docUpdateCommands-EKKKNYPW.js → docUpdateCommands-C7WHT7UU.js} +22 -21
  70. package/fetchMessages-KTNM7QAR.js +1 -1
  71. package/{handleSendMessageAction-5NSYAS53.js → handleSendMessageAction-B5PRR7BE.js} +24 -24
  72. package/index.js +58 -58
  73. package/{localDialogRead-2VRI24F4.js → localDialogRead-YSKFFRTT.js} +1 -1
  74. package/{machineCommands-DOOSIUKG.js → machineCommands-IIIREAEK.js} +64 -59
  75. package/{machineWsRunDispatch-PIOIQRBW.js → machineWsRunDispatch-3SIU6ILW.js} +49 -46
  76. package/package.json +1 -1
  77. package/{read-GW7ZEI23.js → read-QJNKRROM.js} +5 -5
  78. package/{readDocTool-HUFU6OCT.js → readDocTool-H6X6KO6X.js} +1 -1
  79. package/{readlineWorkspace-QEAOH5EP.js → readlineWorkspace-HGP3I3OC.js} +80 -67
  80. package/{removeDialogAgentAction-OHMCNSSD.js → removeDialogAgentAction-TCT35SOF.js} +12 -12
  81. package/{runAgentClientLoop-AIGLXC3R.js → runAgentClientLoop-EFM4PTVI.js} +43 -41
  82. package/{setDialogExtraReferencesAction-YJUM5BWQ.js → setDialogExtraReferencesAction-CGYLZMFH.js} +10 -10
  83. package/{setPrimaryDialogAgentAction-EBAREZDM.js → setPrimaryDialogAgentAction-F6BFQDJU.js} +12 -12
  84. package/{settingSlice-UW4IUI5L.js → settingSlice-2I5HMG47.js} +8 -8
  85. package/skillDiscovery-UGSQGX2U.js +16 -0
  86. package/{spaceCommands-BKHSPR73.js → spaceCommands-MT7BWCIL.js} +27 -27
  87. package/{spaceSlice-TYNWE3OC.js → spaceSlice-BS5TSW3W.js} +19 -19
  88. package/{streamAgentChatTurn-HRMFFA7E.js → streamAgentChatTurn-I3VBFNR3.js} +82 -78
  89. package/{tableCommands-O7O2LBEG.js → tableCommands-M3DJUETS.js} +10 -10
  90. package/{toolApiClient-QI3YBNWB.js → toolApiClient-C7P7YSE4.js} +2 -2
  91. package/{tools-3JNDS3WH.js → tools-XSD2BOEN.js} +31 -29
  92. package/{tuiSummaryLlmCaller-RV3THLZF.js → tuiSummaryLlmCaller-32NRHTT2.js} +3 -3
  93. package/{updateDialogTitleAction-OCETSKCP.js → updateDialogTitleAction-7FYNJOGP.js} +22 -22
  94. package/{agentPullCommand-O2MTUAFR.js → agentPullCommand-GOL2S4W2.js} +1 -1
  95. package/{chunk-DZ3XJVET.js → chunk-3QAF2LTL.js} +3 -3
  96. package/{chunk-EHLHSX7R.js → chunk-5MMZUWSG.js} +3 -3
  97. package/{chunk-X7W4TNB4.js → chunk-CMKUBIGW.js} +3 -3
  98. package/{chunk-4CQLVGRV.js → chunk-ID4G2MAR.js} +3 -3
  99. package/{chunk-5MIDPSSK.js → chunk-JK7VW2FN.js} +3 -3
  100. package/{chunk-UTLZINAP.js → chunk-OOM6SJNR.js} +9 -9
  101. package/{chunk-VVX233PH.js → chunk-PNEW2Z3T.js} +9 -9
  102. package/{chunk-TILFE6LV.js → chunk-YOCHZD7D.js} +3 -3
  103. package/{chunk-JRKKFRAV.js → chunk-YTBMA7NO.js} +3 -3
  104. package/{db-HCJ5PRB5.js → db-6QED3ZVO.js} +3 -3
  105. package/{runtimeDoctorCommands-LRHLPDRC.js → runtimeDoctorCommands-ID43Z7VX.js} +3 -3
  106. package/{understanding-3CUQQ6SV.js → understanding-ZOESBLF3.js} +3 -3
@@ -0,0 +1,298 @@
1
+ import {
2
+ dump,
3
+ load
4
+ } from "./chunk-WZSRQNQG.js";
5
+ import {
6
+ asTrimmedNonEmptyStringArray
7
+ } from "./chunk-I42VC5KR.js";
8
+ import {
9
+ asOptionalTrimmedString
10
+ } from "./chunk-G3SUCT4W.js";
11
+
12
+ // packages/ai/skills/skillDocProtocol.ts
13
+ var SKILL_DOC_ENUMS = {
14
+ triggerMode: ["explicit", "required", "recommended"],
15
+ budgetTier: ["low", "medium", "high"],
16
+ modality: ["text", "image", "video", "audio", "3d"],
17
+ docKind: ["knowledge", "instruction", "skill"]
18
+ };
19
+ var SKILL_CONFIG_BLOCK = "skill-config";
20
+ var EVAL_CONFIG_BLOCK = "eval-config";
21
+ var WORKFLOW_CONFIG_BLOCK = "workflow-config";
22
+ var normalizeStringArray = (value) => {
23
+ if (!Array.isArray(value)) return void 0;
24
+ const items = [...new Set(asTrimmedNonEmptyStringArray(value))];
25
+ return items.length > 0 ? items : void 0;
26
+ };
27
+ var normalizeBoolean = (value) => typeof value === "boolean" ? value : void 0;
28
+ var normalizeSkillEnumValue = (key, value) => typeof value === "string" && SKILL_DOC_ENUMS[key].includes(value) ? value : void 0;
29
+ var normalizeSkillBudgetTier = (value) => normalizeSkillEnumValue("budgetTier", value);
30
+ var normalizeSkillModalities = (value) => {
31
+ const raw = normalizeStringArray(value);
32
+ if (!raw) return void 0;
33
+ const filtered = raw.flatMap((item) => {
34
+ const modality = normalizeSkillEnumValue("modality", item);
35
+ return modality ? [modality] : [];
36
+ });
37
+ return filtered.length > 0 ? Array.from(new Set(filtered)) : void 0;
38
+ };
39
+ var normalizeSkillConfig = (value, fallbackTools) => {
40
+ if (!value || typeof value !== "object") return void 0;
41
+ const record = value;
42
+ const name = asOptionalTrimmedString(record.name) ?? "";
43
+ const description = asOptionalTrimmedString(record.description) ?? "";
44
+ if (!name || !description) return void 0;
45
+ const triggerMode = normalizeSkillEnumValue("triggerMode", record.triggerMode);
46
+ const budgetTier = normalizeSkillEnumValue("budgetTier", record.budgetTier);
47
+ const modalities = normalizeSkillModalities(record.modalities);
48
+ const toolNames = normalizeStringArray(record.toolNames) ?? normalizeStringArray(fallbackTools) ?? void 0;
49
+ const discover = record.discover && typeof record.discover === "object" ? {
50
+ keywords: normalizeStringArray(
51
+ record.discover.keywords
52
+ ),
53
+ examples: normalizeStringArray(
54
+ record.discover.examples
55
+ )
56
+ } : void 0;
57
+ return {
58
+ version: "0.1",
59
+ kind: "skill",
60
+ id: asOptionalTrimmedString(record.id),
61
+ name,
62
+ description,
63
+ triggerMode,
64
+ toolNames,
65
+ preferredAgents: normalizeStringArray(record.preferredAgents),
66
+ budgetTier,
67
+ dispatchPreferred: normalizeBoolean(record.dispatchPreferred),
68
+ modalities,
69
+ requiredSkills: normalizeStringArray(record.requiredSkills),
70
+ recommendedSkills: normalizeStringArray(record.recommendedSkills),
71
+ promptPatch: asOptionalTrimmedString(record.promptPatch),
72
+ discover: discover?.keywords || discover?.examples ? discover : void 0
73
+ };
74
+ };
75
+ var normalizeEvalConfig = (value) => {
76
+ if (!value || typeof value !== "object") return void 0;
77
+ const record = value;
78
+ if (!Array.isArray(record.cases)) return void 0;
79
+ const cases = [];
80
+ for (const item of record.cases) {
81
+ if (!item || typeof item !== "object") continue;
82
+ const testCase = item;
83
+ const input = asOptionalTrimmedString(testCase.input) ?? "";
84
+ if (!input) continue;
85
+ cases.push({
86
+ input,
87
+ expectedTools: normalizeStringArray(testCase.expectedTools),
88
+ expectedSignals: normalizeStringArray(testCase.expectedSignals),
89
+ forbiddenSignals: normalizeStringArray(testCase.forbiddenSignals)
90
+ });
91
+ }
92
+ return cases.length > 0 ? {
93
+ version: "0.1",
94
+ cases
95
+ } : void 0;
96
+ };
97
+ var normalizeWorkflowConfig = (value) => {
98
+ if (!value || typeof value !== "object") return void 0;
99
+ const record = value;
100
+ const name = asOptionalTrimmedString(record.name) ?? "";
101
+ const description = asOptionalTrimmedString(record.description) ?? "";
102
+ if (!name || !description) return void 0;
103
+ const budgetTier = normalizeSkillEnumValue("budgetTier", record.budgetTier);
104
+ return {
105
+ version: "0.1",
106
+ kind: "workflow",
107
+ id: asOptionalTrimmedString(record.id),
108
+ name,
109
+ description,
110
+ defaultAgent: asOptionalTrimmedString(record.defaultAgent),
111
+ inputs: normalizeStringArray(record.inputs),
112
+ recommendedTools: normalizeStringArray(record.recommendedTools),
113
+ requiredTools: normalizeStringArray(record.requiredTools),
114
+ requiredOutputs: normalizeStringArray(record.requiredOutputs),
115
+ gates: normalizeStringArray(record.gates),
116
+ budgetTier,
117
+ contextStrategy: asOptionalTrimmedString(record.contextStrategy),
118
+ failureProtocol: asOptionalTrimmedString(record.failureProtocol)
119
+ };
120
+ };
121
+ var normalizePageSkillMetadata = (value, fallbackTools) => {
122
+ if (!value || typeof value !== "object") return void 0;
123
+ const record = value;
124
+ const kind = normalizeSkillEnumValue("docKind", record.kind);
125
+ const meta = {
126
+ kind,
127
+ requiredSkills: normalizeStringArray(record.requiredSkills),
128
+ recommendedSkills: normalizeStringArray(record.recommendedSkills),
129
+ skillConfig: normalizeSkillConfig(record.skillConfig, fallbackTools),
130
+ evalConfig: normalizeEvalConfig(record.evalConfig),
131
+ workflowConfig: normalizeWorkflowConfig(record.workflowConfig)
132
+ };
133
+ if (meta.skillConfig && !meta.kind) {
134
+ meta.kind = "skill";
135
+ }
136
+ if (meta.workflowConfig && !meta.kind) {
137
+ meta.kind = "instruction";
138
+ }
139
+ return meta.kind || meta.requiredSkills || meta.recommendedSkills || meta.skillConfig || meta.evalConfig || meta.workflowConfig ? meta : void 0;
140
+ };
141
+ var extractCommentBlock = (markdown, blockName) => {
142
+ if (!markdown) return void 0;
143
+ const matcher = new RegExp(
144
+ `<!--\\s*${blockName}\\s*\\n([\\s\\S]*?)-->`,
145
+ "i"
146
+ );
147
+ const match = markdown.match(matcher);
148
+ return asOptionalTrimmedString(match?.[1]);
149
+ };
150
+ var removeCommentBlock = (markdown, blockName) => markdown.replace(
151
+ new RegExp(`\\n?<!--\\s*${blockName}\\s*\\n[\\s\\S]*?-->\\s*`, "gi"),
152
+ "\n\n"
153
+ );
154
+ var parseYamlObject = (raw) => {
155
+ if (!raw) return void 0;
156
+ try {
157
+ const parsed = load(raw);
158
+ return parsed && typeof parsed === "object" ? parsed : void 0;
159
+ } catch {
160
+ return void 0;
161
+ }
162
+ };
163
+ var parseSkillDocProtocol = (markdown, existingMeta, fallbackTools) => {
164
+ const source = typeof markdown === "string" ? markdown : "";
165
+ const skillBlock = parseYamlObject(extractCommentBlock(source, SKILL_CONFIG_BLOCK));
166
+ const evalBlock = parseYamlObject(extractCommentBlock(source, EVAL_CONFIG_BLOCK));
167
+ const workflowBlock = parseYamlObject(extractCommentBlock(source, WORKFLOW_CONFIG_BLOCK));
168
+ const cleanedContent = removeCommentBlock(
169
+ removeCommentBlock(
170
+ removeCommentBlock(source, SKILL_CONFIG_BLOCK),
171
+ EVAL_CONFIG_BLOCK
172
+ ),
173
+ WORKFLOW_CONFIG_BLOCK
174
+ ).replace(/\n{3,}/g, "\n\n").trim();
175
+ const parsedMeta = normalizePageSkillMetadata(
176
+ {
177
+ ...existingMeta ?? {},
178
+ ...skillBlock ? {
179
+ kind: existingMeta?.kind === "skill" || skillBlock.kind === "skill" ? "skill" : existingMeta?.kind,
180
+ requiredSkills: skillBlock.requiredSkills ?? existingMeta?.requiredSkills,
181
+ recommendedSkills: skillBlock.recommendedSkills ?? existingMeta?.recommendedSkills,
182
+ skillConfig: skillBlock
183
+ } : {},
184
+ ...evalBlock ? { evalConfig: evalBlock } : {},
185
+ ...workflowBlock ? { workflowConfig: workflowBlock } : {}
186
+ },
187
+ fallbackTools
188
+ );
189
+ return {
190
+ content: cleanedContent,
191
+ meta: parsedMeta
192
+ };
193
+ };
194
+ var resolvePageSkillMetadata = (page) => {
195
+ if (!page) return void 0;
196
+ const existingMeta = normalizePageSkillMetadata(page.meta, page.tools);
197
+ return parseSkillDocProtocol(page.content ?? "", existingMeta, page.tools).meta;
198
+ };
199
+ var yamlBlock = (value) => dump(value, { lineWidth: 120, noRefs: true }).trim();
200
+ var buildSkillConfigComment = (config) => {
201
+ const payload = {
202
+ version: config.version,
203
+ kind: config.kind,
204
+ ...config.id ? { id: config.id } : {},
205
+ name: config.name,
206
+ description: config.description,
207
+ ...config.triggerMode ? { triggerMode: config.triggerMode } : {},
208
+ ...config.requiredSkills?.length ? { requiredSkills: config.requiredSkills } : {},
209
+ ...config.recommendedSkills?.length ? { recommendedSkills: config.recommendedSkills } : {},
210
+ ...config.toolNames?.length ? { toolNames: config.toolNames } : {},
211
+ ...config.preferredAgents?.length ? { preferredAgents: config.preferredAgents } : {},
212
+ ...config.budgetTier ? { budgetTier: config.budgetTier } : {},
213
+ ...typeof config.dispatchPreferred === "boolean" ? { dispatchPreferred: config.dispatchPreferred } : {},
214
+ ...config.modalities?.length ? { modalities: config.modalities } : {},
215
+ ...config.discover?.keywords?.length || config.discover?.examples?.length ? {
216
+ discover: {
217
+ ...config.discover?.keywords?.length ? { keywords: config.discover.keywords } : {},
218
+ ...config.discover?.examples?.length ? { examples: config.discover.examples } : {}
219
+ }
220
+ } : {},
221
+ ...config.promptPatch ? { promptPatch: config.promptPatch } : {}
222
+ };
223
+ return `<!-- ${SKILL_CONFIG_BLOCK}
224
+ ${yamlBlock(payload)}
225
+ -->`;
226
+ };
227
+ var buildEvalConfigComment = (config) => `<!-- ${EVAL_CONFIG_BLOCK}
228
+ ${yamlBlock({
229
+ version: config.version,
230
+ cases: config.cases
231
+ })}
232
+ -->`;
233
+ var buildWorkflowConfigComment = (config) => `<!-- ${WORKFLOW_CONFIG_BLOCK}
234
+ ${yamlBlock({
235
+ version: config.version,
236
+ kind: config.kind,
237
+ ...config.id ? { id: config.id } : {},
238
+ name: config.name,
239
+ description: config.description,
240
+ ...config.defaultAgent ? { defaultAgent: config.defaultAgent } : {},
241
+ ...config.inputs?.length ? { inputs: config.inputs } : {},
242
+ ...config.recommendedTools?.length ? { recommendedTools: config.recommendedTools } : {},
243
+ ...config.requiredTools?.length ? { requiredTools: config.requiredTools } : {},
244
+ ...config.requiredOutputs?.length ? { requiredOutputs: config.requiredOutputs } : {},
245
+ ...config.gates?.length ? { gates: config.gates } : {},
246
+ ...config.budgetTier ? { budgetTier: config.budgetTier } : {},
247
+ ...config.contextStrategy ? { contextStrategy: config.contextStrategy } : {},
248
+ ...config.failureProtocol ? { failureProtocol: config.failureProtocol } : {}
249
+ })}
250
+ -->`;
251
+ var buildSkillDocMarkdown = (options) => {
252
+ const sections = [
253
+ asOptionalTrimmedString(options.body) ?? "",
254
+ buildSkillConfigComment(options.skillConfig),
255
+ options.evalConfig ? buildEvalConfigComment(options.evalConfig) : "",
256
+ options.workflowConfig ? buildWorkflowConfigComment(options.workflowConfig) : ""
257
+ ].filter(Boolean);
258
+ return sections.join("\n\n").trim();
259
+ };
260
+ var extractFrontmatter = (markdown) => {
261
+ const match = markdown.match(/^\s*---\s*\n([\s\S]*?)\n\s*---\s*\n?/);
262
+ if (!match) return { body: markdown.trim() };
263
+ const frontmatter = parseYamlObject(match[1]);
264
+ const body = markdown.slice(match[0].length).trim();
265
+ return { frontmatter, body };
266
+ };
267
+ var normalizeAllowedTools = (value) => {
268
+ if (Array.isArray(value)) {
269
+ return normalizeStringArray(value) ?? [];
270
+ }
271
+ if (typeof value === "string") {
272
+ return value.split(/\s+/).map((item) => item.trim()).filter(Boolean);
273
+ }
274
+ return [];
275
+ };
276
+ var parseExternalSkillMarkdown = (markdown) => {
277
+ const { frontmatter, body } = extractFrontmatter(markdown);
278
+ return {
279
+ name: asOptionalTrimmedString(frontmatter?.name),
280
+ description: asOptionalTrimmedString(frontmatter?.description),
281
+ compatibility: asOptionalTrimmedString(frontmatter?.compatibility),
282
+ allowedTools: normalizeAllowedTools(frontmatter?.["allowed-tools"]),
283
+ metadata: frontmatter?.metadata && typeof frontmatter.metadata === "object" ? Object.fromEntries(
284
+ Object.entries(frontmatter.metadata).filter(([, value]) => typeof value === "string").map(([key, value]) => [key, String(value)])
285
+ ) : void 0,
286
+ body
287
+ };
288
+ };
289
+
290
+ export {
291
+ normalizeStringArray,
292
+ normalizeSkillBudgetTier,
293
+ normalizeSkillModalities,
294
+ parseSkillDocProtocol,
295
+ resolvePageSkillMetadata,
296
+ buildSkillDocMarkdown,
297
+ parseExternalSkillMarkdown
298
+ };
@@ -1,10 +1,3 @@
1
- import {
2
- asTrimmedNonEmptyStringArray
3
- } from "./chunk-I42VC5KR.js";
4
- import {
5
- asOptionalTrimmedString
6
- } from "./chunk-G3SUCT4W.js";
7
-
8
1
  // node_modules/js-yaml/dist/js-yaml.mjs
9
2
  function isNothing(subject) {
10
3
  return typeof subject === "undefined" || subject === null;
@@ -2588,291 +2581,7 @@ var safeLoad = renamed("safeLoad", "load");
2588
2581
  var safeLoadAll = renamed("safeLoadAll", "loadAll");
2589
2582
  var safeDump = renamed("safeDump", "dump");
2590
2583
 
2591
- // packages/ai/skills/skillDocProtocol.ts
2592
- var SKILL_DOC_ENUMS = {
2593
- triggerMode: ["explicit", "required", "recommended"],
2594
- budgetTier: ["low", "medium", "high"],
2595
- modality: ["text", "image", "video", "audio", "3d"],
2596
- docKind: ["knowledge", "instruction", "skill"]
2597
- };
2598
- var SKILL_CONFIG_BLOCK = "skill-config";
2599
- var EVAL_CONFIG_BLOCK = "eval-config";
2600
- var WORKFLOW_CONFIG_BLOCK = "workflow-config";
2601
- var normalizeStringArray = (value) => {
2602
- if (!Array.isArray(value)) return void 0;
2603
- const items = [...new Set(asTrimmedNonEmptyStringArray(value))];
2604
- return items.length > 0 ? items : void 0;
2605
- };
2606
- var normalizeBoolean = (value) => typeof value === "boolean" ? value : void 0;
2607
- var normalizeSkillEnumValue = (key, value) => typeof value === "string" && SKILL_DOC_ENUMS[key].includes(value) ? value : void 0;
2608
- var normalizeSkillBudgetTier = (value) => normalizeSkillEnumValue("budgetTier", value);
2609
- var normalizeSkillModalities = (value) => {
2610
- const raw = normalizeStringArray(value);
2611
- if (!raw) return void 0;
2612
- const filtered = raw.flatMap((item) => {
2613
- const modality = normalizeSkillEnumValue("modality", item);
2614
- return modality ? [modality] : [];
2615
- });
2616
- return filtered.length > 0 ? Array.from(new Set(filtered)) : void 0;
2617
- };
2618
- var normalizeSkillConfig = (value, fallbackTools) => {
2619
- if (!value || typeof value !== "object") return void 0;
2620
- const record = value;
2621
- const name = asOptionalTrimmedString(record.name) ?? "";
2622
- const description = asOptionalTrimmedString(record.description) ?? "";
2623
- if (!name || !description) return void 0;
2624
- const triggerMode = normalizeSkillEnumValue("triggerMode", record.triggerMode);
2625
- const budgetTier = normalizeSkillEnumValue("budgetTier", record.budgetTier);
2626
- const modalities = normalizeSkillModalities(record.modalities);
2627
- const toolNames = normalizeStringArray(record.toolNames) ?? normalizeStringArray(fallbackTools) ?? void 0;
2628
- const discover = record.discover && typeof record.discover === "object" ? {
2629
- keywords: normalizeStringArray(
2630
- record.discover.keywords
2631
- ),
2632
- examples: normalizeStringArray(
2633
- record.discover.examples
2634
- )
2635
- } : void 0;
2636
- return {
2637
- version: "0.1",
2638
- kind: "skill",
2639
- id: asOptionalTrimmedString(record.id),
2640
- name,
2641
- description,
2642
- triggerMode,
2643
- toolNames,
2644
- preferredAgents: normalizeStringArray(record.preferredAgents),
2645
- budgetTier,
2646
- dispatchPreferred: normalizeBoolean(record.dispatchPreferred),
2647
- modalities,
2648
- requiredSkills: normalizeStringArray(record.requiredSkills),
2649
- recommendedSkills: normalizeStringArray(record.recommendedSkills),
2650
- promptPatch: asOptionalTrimmedString(record.promptPatch),
2651
- discover: discover?.keywords || discover?.examples ? discover : void 0
2652
- };
2653
- };
2654
- var normalizeEvalConfig = (value) => {
2655
- if (!value || typeof value !== "object") return void 0;
2656
- const record = value;
2657
- if (!Array.isArray(record.cases)) return void 0;
2658
- const cases = [];
2659
- for (const item of record.cases) {
2660
- if (!item || typeof item !== "object") continue;
2661
- const testCase = item;
2662
- const input = asOptionalTrimmedString(testCase.input) ?? "";
2663
- if (!input) continue;
2664
- cases.push({
2665
- input,
2666
- expectedTools: normalizeStringArray(testCase.expectedTools),
2667
- expectedSignals: normalizeStringArray(testCase.expectedSignals),
2668
- forbiddenSignals: normalizeStringArray(testCase.forbiddenSignals)
2669
- });
2670
- }
2671
- return cases.length > 0 ? {
2672
- version: "0.1",
2673
- cases
2674
- } : void 0;
2675
- };
2676
- var normalizeWorkflowConfig = (value) => {
2677
- if (!value || typeof value !== "object") return void 0;
2678
- const record = value;
2679
- const name = asOptionalTrimmedString(record.name) ?? "";
2680
- const description = asOptionalTrimmedString(record.description) ?? "";
2681
- if (!name || !description) return void 0;
2682
- const budgetTier = normalizeSkillEnumValue("budgetTier", record.budgetTier);
2683
- return {
2684
- version: "0.1",
2685
- kind: "workflow",
2686
- id: asOptionalTrimmedString(record.id),
2687
- name,
2688
- description,
2689
- defaultAgent: asOptionalTrimmedString(record.defaultAgent),
2690
- inputs: normalizeStringArray(record.inputs),
2691
- recommendedTools: normalizeStringArray(record.recommendedTools),
2692
- requiredTools: normalizeStringArray(record.requiredTools),
2693
- requiredOutputs: normalizeStringArray(record.requiredOutputs),
2694
- gates: normalizeStringArray(record.gates),
2695
- budgetTier,
2696
- contextStrategy: asOptionalTrimmedString(record.contextStrategy),
2697
- failureProtocol: asOptionalTrimmedString(record.failureProtocol)
2698
- };
2699
- };
2700
- var normalizePageSkillMetadata = (value, fallbackTools) => {
2701
- if (!value || typeof value !== "object") return void 0;
2702
- const record = value;
2703
- const kind = normalizeSkillEnumValue("docKind", record.kind);
2704
- const meta = {
2705
- kind,
2706
- requiredSkills: normalizeStringArray(record.requiredSkills),
2707
- recommendedSkills: normalizeStringArray(record.recommendedSkills),
2708
- skillConfig: normalizeSkillConfig(record.skillConfig, fallbackTools),
2709
- evalConfig: normalizeEvalConfig(record.evalConfig),
2710
- workflowConfig: normalizeWorkflowConfig(record.workflowConfig)
2711
- };
2712
- if (meta.skillConfig && !meta.kind) {
2713
- meta.kind = "skill";
2714
- }
2715
- if (meta.workflowConfig && !meta.kind) {
2716
- meta.kind = "instruction";
2717
- }
2718
- return meta.kind || meta.requiredSkills || meta.recommendedSkills || meta.skillConfig || meta.evalConfig || meta.workflowConfig ? meta : void 0;
2719
- };
2720
- var extractCommentBlock = (markdown, blockName) => {
2721
- if (!markdown) return void 0;
2722
- const matcher = new RegExp(
2723
- `<!--\\s*${blockName}\\s*\\n([\\s\\S]*?)-->`,
2724
- "i"
2725
- );
2726
- const match = markdown.match(matcher);
2727
- return asOptionalTrimmedString(match?.[1]);
2728
- };
2729
- var removeCommentBlock = (markdown, blockName) => markdown.replace(
2730
- new RegExp(`\\n?<!--\\s*${blockName}\\s*\\n[\\s\\S]*?-->\\s*`, "gi"),
2731
- "\n\n"
2732
- );
2733
- var parseYamlObject = (raw) => {
2734
- if (!raw) return void 0;
2735
- try {
2736
- const parsed = load(raw);
2737
- return parsed && typeof parsed === "object" ? parsed : void 0;
2738
- } catch {
2739
- return void 0;
2740
- }
2741
- };
2742
- var parseSkillDocProtocol = (markdown, existingMeta, fallbackTools) => {
2743
- const source = typeof markdown === "string" ? markdown : "";
2744
- const skillBlock = parseYamlObject(extractCommentBlock(source, SKILL_CONFIG_BLOCK));
2745
- const evalBlock = parseYamlObject(extractCommentBlock(source, EVAL_CONFIG_BLOCK));
2746
- const workflowBlock = parseYamlObject(extractCommentBlock(source, WORKFLOW_CONFIG_BLOCK));
2747
- const cleanedContent = removeCommentBlock(
2748
- removeCommentBlock(
2749
- removeCommentBlock(source, SKILL_CONFIG_BLOCK),
2750
- EVAL_CONFIG_BLOCK
2751
- ),
2752
- WORKFLOW_CONFIG_BLOCK
2753
- ).replace(/\n{3,}/g, "\n\n").trim();
2754
- const parsedMeta = normalizePageSkillMetadata(
2755
- {
2756
- ...existingMeta ?? {},
2757
- ...skillBlock ? {
2758
- kind: existingMeta?.kind === "skill" || skillBlock.kind === "skill" ? "skill" : existingMeta?.kind,
2759
- requiredSkills: skillBlock.requiredSkills ?? existingMeta?.requiredSkills,
2760
- recommendedSkills: skillBlock.recommendedSkills ?? existingMeta?.recommendedSkills,
2761
- skillConfig: skillBlock
2762
- } : {},
2763
- ...evalBlock ? { evalConfig: evalBlock } : {},
2764
- ...workflowBlock ? { workflowConfig: workflowBlock } : {}
2765
- },
2766
- fallbackTools
2767
- );
2768
- return {
2769
- content: cleanedContent,
2770
- meta: parsedMeta
2771
- };
2772
- };
2773
- var resolvePageSkillMetadata = (page) => {
2774
- if (!page) return void 0;
2775
- const existingMeta = normalizePageSkillMetadata(page.meta, page.tools);
2776
- return parseSkillDocProtocol(page.content ?? "", existingMeta, page.tools).meta;
2777
- };
2778
- var yamlBlock = (value) => dump(value, { lineWidth: 120, noRefs: true }).trim();
2779
- var buildSkillConfigComment = (config) => {
2780
- const payload = {
2781
- version: config.version,
2782
- kind: config.kind,
2783
- ...config.id ? { id: config.id } : {},
2784
- name: config.name,
2785
- description: config.description,
2786
- ...config.triggerMode ? { triggerMode: config.triggerMode } : {},
2787
- ...config.requiredSkills?.length ? { requiredSkills: config.requiredSkills } : {},
2788
- ...config.recommendedSkills?.length ? { recommendedSkills: config.recommendedSkills } : {},
2789
- ...config.toolNames?.length ? { toolNames: config.toolNames } : {},
2790
- ...config.preferredAgents?.length ? { preferredAgents: config.preferredAgents } : {},
2791
- ...config.budgetTier ? { budgetTier: config.budgetTier } : {},
2792
- ...typeof config.dispatchPreferred === "boolean" ? { dispatchPreferred: config.dispatchPreferred } : {},
2793
- ...config.modalities?.length ? { modalities: config.modalities } : {},
2794
- ...config.discover?.keywords?.length || config.discover?.examples?.length ? {
2795
- discover: {
2796
- ...config.discover?.keywords?.length ? { keywords: config.discover.keywords } : {},
2797
- ...config.discover?.examples?.length ? { examples: config.discover.examples } : {}
2798
- }
2799
- } : {},
2800
- ...config.promptPatch ? { promptPatch: config.promptPatch } : {}
2801
- };
2802
- return `<!-- ${SKILL_CONFIG_BLOCK}
2803
- ${yamlBlock(payload)}
2804
- -->`;
2805
- };
2806
- var buildEvalConfigComment = (config) => `<!-- ${EVAL_CONFIG_BLOCK}
2807
- ${yamlBlock({
2808
- version: config.version,
2809
- cases: config.cases
2810
- })}
2811
- -->`;
2812
- var buildWorkflowConfigComment = (config) => `<!-- ${WORKFLOW_CONFIG_BLOCK}
2813
- ${yamlBlock({
2814
- version: config.version,
2815
- kind: config.kind,
2816
- ...config.id ? { id: config.id } : {},
2817
- name: config.name,
2818
- description: config.description,
2819
- ...config.defaultAgent ? { defaultAgent: config.defaultAgent } : {},
2820
- ...config.inputs?.length ? { inputs: config.inputs } : {},
2821
- ...config.recommendedTools?.length ? { recommendedTools: config.recommendedTools } : {},
2822
- ...config.requiredTools?.length ? { requiredTools: config.requiredTools } : {},
2823
- ...config.requiredOutputs?.length ? { requiredOutputs: config.requiredOutputs } : {},
2824
- ...config.gates?.length ? { gates: config.gates } : {},
2825
- ...config.budgetTier ? { budgetTier: config.budgetTier } : {},
2826
- ...config.contextStrategy ? { contextStrategy: config.contextStrategy } : {},
2827
- ...config.failureProtocol ? { failureProtocol: config.failureProtocol } : {}
2828
- })}
2829
- -->`;
2830
- var buildSkillDocMarkdown = (options) => {
2831
- const sections = [
2832
- asOptionalTrimmedString(options.body) ?? "",
2833
- buildSkillConfigComment(options.skillConfig),
2834
- options.evalConfig ? buildEvalConfigComment(options.evalConfig) : "",
2835
- options.workflowConfig ? buildWorkflowConfigComment(options.workflowConfig) : ""
2836
- ].filter(Boolean);
2837
- return sections.join("\n\n").trim();
2838
- };
2839
- var extractFrontmatter = (markdown) => {
2840
- const match = markdown.match(/^\s*---\s*\n([\s\S]*?)\n\s*---\s*\n?/);
2841
- if (!match) return { body: markdown.trim() };
2842
- const frontmatter = parseYamlObject(match[1]);
2843
- const body = markdown.slice(match[0].length).trim();
2844
- return { frontmatter, body };
2845
- };
2846
- var normalizeAllowedTools = (value) => {
2847
- if (Array.isArray(value)) {
2848
- return normalizeStringArray(value) ?? [];
2849
- }
2850
- if (typeof value === "string") {
2851
- return value.split(/\s+/).map((item) => item.trim()).filter(Boolean);
2852
- }
2853
- return [];
2854
- };
2855
- var parseExternalSkillMarkdown = (markdown) => {
2856
- const { frontmatter, body } = extractFrontmatter(markdown);
2857
- return {
2858
- name: asOptionalTrimmedString(frontmatter?.name),
2859
- description: asOptionalTrimmedString(frontmatter?.description),
2860
- compatibility: asOptionalTrimmedString(frontmatter?.compatibility),
2861
- allowedTools: normalizeAllowedTools(frontmatter?.["allowed-tools"]),
2862
- metadata: frontmatter?.metadata && typeof frontmatter.metadata === "object" ? Object.fromEntries(
2863
- Object.entries(frontmatter.metadata).filter(([, value]) => typeof value === "string").map(([key, value]) => [key, String(value)])
2864
- ) : void 0,
2865
- body
2866
- };
2867
- };
2868
-
2869
2584
  export {
2870
2585
  load,
2871
- normalizeStringArray,
2872
- normalizeSkillBudgetTier,
2873
- normalizeSkillModalities,
2874
- parseSkillDocProtocol,
2875
- resolvePageSkillMetadata,
2876
- buildSkillDocMarkdown,
2877
- parseExternalSkillMarkdown
2586
+ dump
2878
2587
  };