@yourgpt/copilot-sdk 2.1.4 → 2.1.5-alpha.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/dist/MessageTree-CoIt_4nB.d.cts +161 -0
- package/dist/MessageTree-CzaN9Eul.d.ts +161 -0
- package/dist/{ThreadManager-Dkp_eLty.d.ts → ThreadManager-BEAECB7Y.d.ts} +1 -1
- package/dist/{ThreadManager-LfFRhr4e.d.cts → ThreadManager-Cw5fwyCN.d.cts} +1 -1
- package/dist/{chunk-POZNNKNJ.cjs → chunk-246B6X5D.cjs} +8 -2
- package/dist/chunk-246B6X5D.cjs.map +1 -0
- package/dist/{chunk-QLH6TSCC.js → chunk-4QXY2PBG.js} +8 -2
- package/dist/chunk-4QXY2PBG.js.map +1 -0
- package/dist/{chunk-7PKGRYHY.js → chunk-5Q72LZ5H.js} +3107 -357
- package/dist/chunk-5Q72LZ5H.js.map +1 -0
- package/dist/chunk-BJYA5NDL.cjs +96 -0
- package/dist/chunk-BJYA5NDL.cjs.map +1 -0
- package/dist/{chunk-LZMBBGWH.js → chunk-ENFWM3EY.js} +4 -4
- package/dist/{chunk-LZMBBGWH.js.map → chunk-ENFWM3EY.js.map} +1 -1
- package/dist/{chunk-OQPRIB73.cjs → chunk-I3SQUNTT.cjs} +71 -25
- package/dist/chunk-I3SQUNTT.cjs.map +1 -0
- package/dist/{chunk-N6VZ7FOW.cjs → chunk-IXWNDR7H.cjs} +3290 -522
- package/dist/chunk-IXWNDR7H.cjs.map +1 -0
- package/dist/{chunk-WAPGTQDR.cjs → chunk-JKGFQUHJ.cjs} +10 -10
- package/dist/{chunk-WAPGTQDR.cjs.map → chunk-JKGFQUHJ.cjs.map} +1 -1
- package/dist/{chunk-XGITAEXU.js → chunk-LLM7AHMO.js} +2 -2
- package/dist/{chunk-XGITAEXU.js.map → chunk-LLM7AHMO.js.map} +1 -1
- package/dist/{chunk-ASV6JLYG.cjs → chunk-NUXLAZOE.cjs} +2 -2
- package/dist/{chunk-ASV6JLYG.cjs.map → chunk-NUXLAZOE.cjs.map} +1 -1
- package/dist/{chunk-37KEHUCE.js → chunk-UXJ6LIZB.js} +51 -7
- package/dist/chunk-UXJ6LIZB.js.map +1 -0
- package/dist/chunk-VNLLW3ZI.js +94 -0
- package/dist/chunk-VNLLW3ZI.js.map +1 -0
- package/dist/core/index.cjs +99 -91
- package/dist/core/index.d.cts +7 -7
- package/dist/core/index.d.ts +7 -7
- package/dist/core/index.js +5 -5
- package/dist/{index-BHkRA0mM.d.cts → index-CiExk87c.d.cts} +1 -1
- package/dist/{index-tB0qI8my.d.ts → index-Dwrcf-CP.d.ts} +1 -1
- package/dist/mcp/index.d.cts +3 -3
- package/dist/mcp/index.d.ts +3 -3
- package/dist/react/index.cjs +113 -52
- package/dist/react/index.d.cts +673 -77
- package/dist/react/index.d.ts +673 -77
- package/dist/react/index.js +7 -6
- package/dist/server/index.cjs +339 -0
- package/dist/server/index.cjs.map +1 -0
- package/dist/server/index.d.cts +171 -0
- package/dist/server/index.d.ts +171 -0
- package/dist/server/index.js +332 -0
- package/dist/server/index.js.map +1 -0
- package/dist/tools/anthropic/index.cjs +3 -3
- package/dist/tools/anthropic/index.d.cts +1 -1
- package/dist/tools/anthropic/index.d.ts +1 -1
- package/dist/tools/anthropic/index.js +3 -3
- package/dist/tools/brave/index.cjs +6 -6
- package/dist/tools/brave/index.d.cts +1 -1
- package/dist/tools/brave/index.d.ts +1 -1
- package/dist/tools/brave/index.js +3 -3
- package/dist/tools/exa/index.cjs +6 -6
- package/dist/tools/exa/index.d.cts +1 -1
- package/dist/tools/exa/index.d.ts +1 -1
- package/dist/tools/exa/index.js +3 -3
- package/dist/tools/google/index.cjs +6 -6
- package/dist/tools/google/index.d.cts +1 -1
- package/dist/tools/google/index.d.ts +1 -1
- package/dist/tools/google/index.js +3 -3
- package/dist/tools/openai/index.cjs +6 -6
- package/dist/tools/openai/index.d.cts +1 -1
- package/dist/tools/openai/index.d.ts +1 -1
- package/dist/tools/openai/index.js +3 -3
- package/dist/tools/searxng/index.cjs +6 -6
- package/dist/tools/searxng/index.d.cts +1 -1
- package/dist/tools/searxng/index.d.ts +1 -1
- package/dist/tools/searxng/index.js +3 -3
- package/dist/tools/serper/index.cjs +6 -6
- package/dist/tools/serper/index.d.cts +1 -1
- package/dist/tools/serper/index.d.ts +1 -1
- package/dist/tools/serper/index.js +3 -3
- package/dist/tools/tavily/index.cjs +6 -6
- package/dist/tools/tavily/index.d.cts +1 -1
- package/dist/tools/tavily/index.d.ts +1 -1
- package/dist/tools/tavily/index.js +3 -3
- package/dist/tools/web-search/index.cjs +7 -7
- package/dist/tools/web-search/index.d.cts +2 -2
- package/dist/tools/web-search/index.d.ts +2 -2
- package/dist/tools/web-search/index.js +4 -4
- package/dist/{tools-coIcskZ4.d.ts → tools-DHZhF5km.d.cts} +161 -1
- package/dist/{tools-coIcskZ4.d.cts → tools-DHZhF5km.d.ts} +161 -1
- package/dist/{types-rjaSVmEF.d.ts → types-BTyJu0WD.d.ts} +1 -1
- package/dist/types-BckL3hiw.d.cts +93 -0
- package/dist/types-BckL3hiw.d.ts +93 -0
- package/dist/{types-C8t4Ut8f.d.cts → types-BdX7uPj0.d.cts} +1 -1
- package/dist/{types-DG2ya08y.d.ts → types-BeFBBZ5i.d.cts} +64 -1
- package/dist/{types-DG2ya08y.d.cts → types-BeFBBZ5i.d.ts} +64 -1
- package/dist/ui/index.cjs +509 -209
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.cts +81 -4
- package/dist/ui/index.d.ts +81 -4
- package/dist/ui/index.js +457 -158
- package/dist/ui/index.js.map +1 -1
- package/package.json +6 -1
- package/dist/chunk-37KEHUCE.js.map +0 -1
- package/dist/chunk-7PKGRYHY.js.map +0 -1
- package/dist/chunk-N6VZ7FOW.cjs.map +0 -1
- package/dist/chunk-OQPRIB73.cjs.map +0 -1
- package/dist/chunk-POZNNKNJ.cjs.map +0 -1
- package/dist/chunk-QLH6TSCC.js.map +0 -1
package/dist/react/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
export { AbstractAgentLoop, AbstractChat, CopilotProvider, ReactChat, ReactChatState, ReactThreadManager, ReactThreadManagerState, createMessageIntentHandler, createPermissionStorage, createReactChat, createReactChatState, createReactThreadManager, createReactThreadManagerState, createSessionPermissionCache, createToolIntentHandler, formatKnowledgeResultsForAI, initialAgentLoopState, searchKnowledgeBase, useAIAction, useAIActions, useAIContext, useAIContexts, useAITools, useAgent, useCapabilities, useChat, useCopilot, useDevLogger, useFeatureSupport, useKnowledgeBase, useMCPClient, useMCPTools, useMCPUIIntents, useSuggestions, useSupportedMediaTypes, useThreadManager, useTool, useToolExecutor, useToolWithSchema, useTools, useToolsWithSchema } from '../chunk-
|
|
2
|
-
export { createLocalStorageAdapter, createMemoryAdapter, createServerAdapter, generateSuggestionReason } from '../chunk-
|
|
1
|
+
export { AbstractAgentLoop, AbstractChat, CopilotProvider, MessageHistoryContext, MessageTree, ReactChat, ReactChatState, ReactThreadManager, ReactThreadManagerState, SkillProvider, createMessageIntentHandler, createPermissionStorage, createReactChat, createReactChatState, createReactThreadManager, createReactThreadManagerState, createSessionPermissionCache, createToolIntentHandler, defaultMessageHistoryConfig, defineSkill, formatKnowledgeResultsForAI, initialAgentLoopState, isCompactionMarker, keepToolPairsAtomic, searchKnowledgeBase, toDisplayMessage, toLLMMessage, toLLMMessages, useAIAction, useAIActions, useAIContext, useAIContexts, useAITools, useAgent, useCapabilities, useChat, useContextStats, useCopilot, useDevLogger, useFeatureSupport, useKnowledgeBase, useMCPClient, useMCPTools, useMCPUIIntents, useMessageHistory, useMessageHistoryContext, useSkill, useSkillStatus, useSuggestions, useSupportedMediaTypes, useThreadManager, useTool, useToolExecutor, useToolWithSchema, useTools, useToolsWithSchema } from '../chunk-5Q72LZ5H.js';
|
|
2
|
+
export { createLocalStorageAdapter, createMemoryAdapter, createServerAdapter, generateSuggestionReason } from '../chunk-UXJ6LIZB.js';
|
|
3
3
|
import '../chunk-EWVQWTNV.js';
|
|
4
|
-
import '../chunk-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import '../chunk-VNLLW3ZI.js';
|
|
5
|
+
import '../chunk-ENFWM3EY.js';
|
|
6
|
+
export { tool } from '../chunk-4QXY2PBG.js';
|
|
7
|
+
import '../chunk-LLM7AHMO.js';
|
|
8
|
+
import '../chunk-RQ74USYU.js';
|
|
7
9
|
import '../chunk-7W7QLZNC.js';
|
|
8
10
|
import '../chunk-CEOMTQTP.js';
|
|
9
11
|
import '../chunk-PPFHA6IL.js';
|
|
@@ -11,7 +13,6 @@ import '../chunk-DABZYCVX.js';
|
|
|
11
13
|
import '../chunk-MNDGIW47.js';
|
|
12
14
|
import '../chunk-VD74IPKB.js';
|
|
13
15
|
import '../chunk-53UGJNHN.js';
|
|
14
|
-
import '../chunk-RQ74USYU.js';
|
|
15
16
|
import '../chunk-DGUM43GV.js';
|
|
16
17
|
//# sourceMappingURL=index.js.map
|
|
17
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkBJYA5NDL_cjs = require('../chunk-BJYA5NDL.cjs');
|
|
4
|
+
require('../chunk-JEQ2X3Z6.cjs');
|
|
5
|
+
|
|
6
|
+
// src/server/compact-session.ts
|
|
7
|
+
var COMPACTION_PROMPT = `You are summarizing a conversation to preserve its key context while reducing token usage. Create a structured summary that includes:
|
|
8
|
+
|
|
9
|
+
1. **User's primary goals and requests** \u2014 what the user is trying to accomplish
|
|
10
|
+
2. **Technical decisions made** \u2014 libraries chosen, schemas designed, approaches selected
|
|
11
|
+
3. **Tool call outcomes** \u2014 what tools were called, key arguments, result status and brief outcome
|
|
12
|
+
4. **Errors encountered** \u2014 what went wrong and how it was resolved
|
|
13
|
+
5. **User messages** \u2014 verbatim if short (<50 words), paraphrased if long
|
|
14
|
+
6. **Pending tasks** \u2014 unresolved questions or next steps mentioned
|
|
15
|
+
7. **Current work state** \u2014 what was in progress when this summary was created
|
|
16
|
+
|
|
17
|
+
Rules:
|
|
18
|
+
- Preserve ALL specific values: file names, variable names, URLs, error messages, IDs
|
|
19
|
+
- Be detailed on recent work, more concise on earlier work
|
|
20
|
+
- Output structured prose (not bullet JSON)
|
|
21
|
+
- Do NOT include meta-commentary about the summarization itself`;
|
|
22
|
+
async function compactSession(options) {
|
|
23
|
+
const {
|
|
24
|
+
messages,
|
|
25
|
+
existingSummary,
|
|
26
|
+
workingMemory = [],
|
|
27
|
+
model = "claude-haiku-4-5-20251001",
|
|
28
|
+
maxSummaryTokens = 1024,
|
|
29
|
+
fetchImpl = fetch,
|
|
30
|
+
apiKey = typeof process !== "undefined" ? process.env.ANTHROPIC_API_KEY : void 0,
|
|
31
|
+
apiBaseUrl = "https://api.anthropic.com"
|
|
32
|
+
} = options;
|
|
33
|
+
if (!apiKey) {
|
|
34
|
+
throw new Error(
|
|
35
|
+
"compactSession: No API key provided. Set ANTHROPIC_API_KEY or pass options.apiKey."
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
const parts = [];
|
|
39
|
+
if (workingMemory.length > 0) {
|
|
40
|
+
parts.push(
|
|
41
|
+
`[Working memory \u2014 always preserve these facts]
|
|
42
|
+
${workingMemory.join("\n")}`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
if (existingSummary) {
|
|
46
|
+
parts.push(`[Previous summary \u2014 extend/update this]
|
|
47
|
+
${existingSummary}`);
|
|
48
|
+
}
|
|
49
|
+
const conversationText = messages.map((m) => `${m.role.toUpperCase()}: ${m.content ?? "(no content)"}`).join("\n\n");
|
|
50
|
+
parts.push(`[Conversation to summarize]
|
|
51
|
+
${conversationText}`);
|
|
52
|
+
const userContent = parts.join("\n\n---\n\n");
|
|
53
|
+
const response = await fetchImpl(`${apiBaseUrl}/v1/messages`, {
|
|
54
|
+
method: "POST",
|
|
55
|
+
headers: {
|
|
56
|
+
"Content-Type": "application/json",
|
|
57
|
+
"x-api-key": apiKey,
|
|
58
|
+
"anthropic-version": "2023-06-01"
|
|
59
|
+
},
|
|
60
|
+
body: JSON.stringify({
|
|
61
|
+
model,
|
|
62
|
+
max_tokens: maxSummaryTokens,
|
|
63
|
+
system: COMPACTION_PROMPT,
|
|
64
|
+
messages: [{ role: "user", content: userContent }]
|
|
65
|
+
})
|
|
66
|
+
});
|
|
67
|
+
if (!response.ok) {
|
|
68
|
+
const err = await response.text();
|
|
69
|
+
throw new Error(
|
|
70
|
+
`compactSession: Anthropic API error ${response.status}: ${err}`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
const data = await response.json();
|
|
74
|
+
const summary = data.content.filter((b) => b.type === "text").map((b) => b.text).join("");
|
|
75
|
+
return { summary };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// src/skill-system/frontmatter.ts
|
|
79
|
+
function parseSkillFile(raw) {
|
|
80
|
+
const frontmatterRegex = /^---\r?\n([\s\S]*?)\r?\n---/;
|
|
81
|
+
const match = frontmatterRegex.exec(raw);
|
|
82
|
+
if (!match) {
|
|
83
|
+
return { frontmatter: {}, content: raw.trim() };
|
|
84
|
+
}
|
|
85
|
+
const frontmatterBlock = match[1];
|
|
86
|
+
const frontmatter = parseFrontmatterBlock(frontmatterBlock);
|
|
87
|
+
const afterFrontmatter = raw.slice(match.index + match[0].length);
|
|
88
|
+
const content = afterFrontmatter.replace(/^\r?\n/, "").trim();
|
|
89
|
+
return { frontmatter, content };
|
|
90
|
+
}
|
|
91
|
+
function parseFrontmatterBlock(block) {
|
|
92
|
+
const result = {};
|
|
93
|
+
const lines = block.split(/\r?\n/);
|
|
94
|
+
for (const line of lines) {
|
|
95
|
+
const colonIndex = line.indexOf(":");
|
|
96
|
+
if (colonIndex === -1) continue;
|
|
97
|
+
const key = line.slice(0, colonIndex).trim();
|
|
98
|
+
const value = line.slice(colonIndex + 1).trim();
|
|
99
|
+
if (!key || !value) continue;
|
|
100
|
+
switch (key) {
|
|
101
|
+
case "name":
|
|
102
|
+
result.name = stripQuotes(value);
|
|
103
|
+
break;
|
|
104
|
+
case "description":
|
|
105
|
+
result.description = stripQuotes(value);
|
|
106
|
+
break;
|
|
107
|
+
case "strategy":
|
|
108
|
+
result.strategy = stripQuotes(value);
|
|
109
|
+
break;
|
|
110
|
+
case "version":
|
|
111
|
+
result.version = stripQuotes(value);
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
function stripQuotes(value) {
|
|
118
|
+
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
119
|
+
return value.slice(1, -1);
|
|
120
|
+
}
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// src/skill-system/load-skills.ts
|
|
125
|
+
var VALID_STRATEGIES = /* @__PURE__ */ new Set(["eager", "auto", "manual"]);
|
|
126
|
+
function isValidStrategy(s) {
|
|
127
|
+
return VALID_STRATEGIES.has(s);
|
|
128
|
+
}
|
|
129
|
+
async function loadSkills(options = {}) {
|
|
130
|
+
const registry = new chunkBJYA5NDL_cjs.SkillRegistry();
|
|
131
|
+
const diagnostics = [];
|
|
132
|
+
const sourceMap = /* @__PURE__ */ new Map();
|
|
133
|
+
if (options.dir) {
|
|
134
|
+
const dirSkills = await loadFromDir(options.dir);
|
|
135
|
+
for (const skill of dirSkills) {
|
|
136
|
+
registry.register(skill);
|
|
137
|
+
sourceMap.set(skill.name, "server-dir");
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (options.remoteUrls?.length) {
|
|
141
|
+
const urlSkills = await loadFromUrls(options.remoteUrls);
|
|
142
|
+
for (const skill of urlSkills) {
|
|
143
|
+
const existingSource = sourceMap.get(skill.name);
|
|
144
|
+
if (existingSource) {
|
|
145
|
+
diagnostics.push({
|
|
146
|
+
type: "collision",
|
|
147
|
+
name: skill.name,
|
|
148
|
+
winner: existingSource,
|
|
149
|
+
loser: "remote-url"
|
|
150
|
+
});
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
registry.register(skill);
|
|
154
|
+
sourceMap.set(skill.name, "remote-url");
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
if (options.clientSkills?.length) {
|
|
158
|
+
for (const inline of options.clientSkills) {
|
|
159
|
+
const existingSource = sourceMap.get(inline.name);
|
|
160
|
+
if (existingSource) {
|
|
161
|
+
diagnostics.push({
|
|
162
|
+
type: "collision",
|
|
163
|
+
name: inline.name,
|
|
164
|
+
winner: existingSource,
|
|
165
|
+
loser: "client-inline"
|
|
166
|
+
});
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const skill = {
|
|
170
|
+
name: inline.name,
|
|
171
|
+
description: inline.description,
|
|
172
|
+
content: inline.content,
|
|
173
|
+
strategy: inline.strategy ?? "auto",
|
|
174
|
+
source: { type: "inline", content: inline.content }
|
|
175
|
+
};
|
|
176
|
+
registry.register(skill);
|
|
177
|
+
sourceMap.set(inline.name, "client-inline");
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return {
|
|
181
|
+
skills: registry.getAll(),
|
|
182
|
+
diagnostics,
|
|
183
|
+
buildSystemPrompt(basePrompt) {
|
|
184
|
+
const parts = [];
|
|
185
|
+
if (basePrompt) {
|
|
186
|
+
parts.push(basePrompt);
|
|
187
|
+
}
|
|
188
|
+
const eagerContent = registry.buildEagerContent();
|
|
189
|
+
if (eagerContent) {
|
|
190
|
+
parts.push(eagerContent);
|
|
191
|
+
}
|
|
192
|
+
const catalog = registry.buildCatalog();
|
|
193
|
+
if (catalog) {
|
|
194
|
+
parts.push(
|
|
195
|
+
`You have access to specialized skills. Call load_skill({ name }) when relevant.
|
|
196
|
+
|
|
197
|
+
${catalog}`
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
return parts.join("\n\n").trim();
|
|
201
|
+
},
|
|
202
|
+
tools: {
|
|
203
|
+
load_skill: {
|
|
204
|
+
description: "Load a skill by name to get full instructions for a specialized task.",
|
|
205
|
+
parameters: {
|
|
206
|
+
type: "object",
|
|
207
|
+
properties: {
|
|
208
|
+
name: {
|
|
209
|
+
type: "string",
|
|
210
|
+
description: "The name of the skill to load."
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
required: ["name"]
|
|
214
|
+
},
|
|
215
|
+
execute: async ({ name }) => {
|
|
216
|
+
const skill = registry.get(name);
|
|
217
|
+
if (!skill) {
|
|
218
|
+
return {
|
|
219
|
+
error: `Skill "${name}" not found. Available skills: ${registry.getAuto().map((s) => s.name).join(", ") || "none"}`
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
const sourceTypeMap = {
|
|
223
|
+
inline: "client-inline",
|
|
224
|
+
url: "remote-url",
|
|
225
|
+
file: "server-dir"
|
|
226
|
+
};
|
|
227
|
+
return {
|
|
228
|
+
name: skill.name,
|
|
229
|
+
description: skill.description,
|
|
230
|
+
strategy: skill.strategy ?? "auto",
|
|
231
|
+
content: skill.content,
|
|
232
|
+
source: sourceTypeMap[skill.source.type]
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
async function loadFromDir(dir) {
|
|
240
|
+
const { readdir, readFile } = await import('fs/promises');
|
|
241
|
+
const path = await import('path');
|
|
242
|
+
let entries;
|
|
243
|
+
try {
|
|
244
|
+
entries = await readdir(dir);
|
|
245
|
+
} catch {
|
|
246
|
+
return [];
|
|
247
|
+
}
|
|
248
|
+
const skills = [];
|
|
249
|
+
for (const entry of entries) {
|
|
250
|
+
const entryPath = path.join(dir, entry);
|
|
251
|
+
if (entry.endsWith(".md")) {
|
|
252
|
+
const skill = await loadSkillFromFile(entryPath, readFile, path);
|
|
253
|
+
if (skill) skills.push(skill);
|
|
254
|
+
} else {
|
|
255
|
+
const skillMdPath = path.join(entryPath, "SKILL.md");
|
|
256
|
+
try {
|
|
257
|
+
const skill = await loadSkillFromFile(skillMdPath, readFile, path);
|
|
258
|
+
if (skill) skills.push(skill);
|
|
259
|
+
} catch {
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
return skills;
|
|
264
|
+
}
|
|
265
|
+
async function loadSkillFromFile(filePath, readFile, path) {
|
|
266
|
+
let raw;
|
|
267
|
+
try {
|
|
268
|
+
raw = await readFile(filePath, "utf-8");
|
|
269
|
+
} catch {
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
const { frontmatter, content } = parseSkillFile(raw);
|
|
273
|
+
const fileName = path.basename(filePath, ".md");
|
|
274
|
+
const name = frontmatter.name ?? (fileName === "SKILL" ? void 0 : fileName);
|
|
275
|
+
if (!name) {
|
|
276
|
+
console.warn(
|
|
277
|
+
`[copilot-sdk/skills] Skipping skill at ${filePath}: no name in frontmatter and could not derive from filename`
|
|
278
|
+
);
|
|
279
|
+
return null;
|
|
280
|
+
}
|
|
281
|
+
const strategy = frontmatter.strategy && isValidStrategy(frontmatter.strategy) ? frontmatter.strategy : "auto";
|
|
282
|
+
return {
|
|
283
|
+
name,
|
|
284
|
+
description: frontmatter.description ?? `Skill: ${name}`,
|
|
285
|
+
content,
|
|
286
|
+
strategy,
|
|
287
|
+
version: frontmatter.version,
|
|
288
|
+
source: { type: "file", path: filePath }
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
async function loadFromUrls(urls) {
|
|
292
|
+
const skills = [];
|
|
293
|
+
await Promise.allSettled(
|
|
294
|
+
urls.map(async (url) => {
|
|
295
|
+
try {
|
|
296
|
+
const res = await fetch(url);
|
|
297
|
+
if (!res.ok) {
|
|
298
|
+
console.warn(
|
|
299
|
+
`[copilot-sdk/skills] Failed to fetch skill from ${url}: HTTP ${res.status}`
|
|
300
|
+
);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
const raw = await res.text();
|
|
304
|
+
const { frontmatter, content } = parseSkillFile(raw);
|
|
305
|
+
if (!frontmatter.name) {
|
|
306
|
+
console.warn(
|
|
307
|
+
`[copilot-sdk/skills] Skipping remote skill at ${url}: no name in frontmatter`
|
|
308
|
+
);
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
const strategy = frontmatter.strategy && isValidStrategy(frontmatter.strategy) ? frontmatter.strategy : "auto";
|
|
312
|
+
skills.push({
|
|
313
|
+
name: frontmatter.name,
|
|
314
|
+
description: frontmatter.description ?? `Skill: ${frontmatter.name}`,
|
|
315
|
+
content,
|
|
316
|
+
strategy,
|
|
317
|
+
version: frontmatter.version,
|
|
318
|
+
source: { type: "url", url }
|
|
319
|
+
});
|
|
320
|
+
} catch (err) {
|
|
321
|
+
console.warn(
|
|
322
|
+
`[copilot-sdk/skills] Error loading remote skill from ${url}:`,
|
|
323
|
+
err
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
})
|
|
327
|
+
);
|
|
328
|
+
return skills;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
Object.defineProperty(exports, "SkillRegistry", {
|
|
332
|
+
enumerable: true,
|
|
333
|
+
get: function () { return chunkBJYA5NDL_cjs.SkillRegistry; }
|
|
334
|
+
});
|
|
335
|
+
exports.compactSession = compactSession;
|
|
336
|
+
exports.loadSkills = loadSkills;
|
|
337
|
+
exports.parseSkillFile = parseSkillFile;
|
|
338
|
+
//# sourceMappingURL=index.cjs.map
|
|
339
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/server/compact-session.ts","../../src/skill-system/frontmatter.ts","../../src/skill-system/load-skills.ts"],"names":["SkillRegistry"],"mappings":";;;;;;AA0CA,IAAM,iBAAA,GAAoB,CAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,+DAAA,CAAA;AAgB1B,eAAsB,eACpB,OAAA,EAC+B;AAC/B,EAAA,MAAM;AAAA,IACJ,QAAA;AAAA,IACA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* compactSession — server-side summarization helper\n *\n * Call this in your /api/compact route handler.\n * Uses a structured prompt that preserves all semantically important content.\n *\n * @example\n * ```ts\n * // app/api/compact/route.ts\n * import { compactSession } from '@yourgpt/copilot-sdk/server';\n *\n * export async function POST(req: Request) {\n * const { messages, existingSummary, workingMemory } = await req.json();\n * const summary = await compactSession({ messages, existingSummary, workingMemory });\n * return Response.json({ summary });\n * }\n * ```\n */\n\nexport interface CompactSessionOptions {\n messages: Array<{ role: string; content?: string | null }>;\n existingSummary?: string | null;\n workingMemory?: string[];\n /**\n * Model to use for summarization.\n * @default 'claude-haiku-4-5' (cheaper model fine for summaries)\n */\n model?: string;\n /** Max tokens for the summary output. @default 1024 */\n maxSummaryTokens?: number;\n /** Custom fetch implementation (for non-browser environments). */\n fetchImpl?: typeof fetch;\n /** Anthropic API key. Falls back to process.env.ANTHROPIC_API_KEY. */\n apiKey?: string;\n /** Base URL for Anthropic API. @default 'https://api.anthropic.com' */\n apiBaseUrl?: string;\n}\n\nexport interface CompactSessionResult {\n summary: string;\n}\n\nconst COMPACTION_PROMPT = `You are summarizing a conversation to preserve its key context while reducing token usage. Create a structured summary that includes:\n\n1. **User's primary goals and requests** — what the user is trying to accomplish\n2. **Technical decisions made** — libraries chosen, schemas designed, approaches selected\n3. **Tool call outcomes** — what tools were called, key arguments, result status and brief outcome\n4. **Errors encountered** — what went wrong and how it was resolved\n5. **User messages** — verbatim if short (<50 words), paraphrased if long\n6. **Pending tasks** — unresolved questions or next steps mentioned\n7. **Current work state** — what was in progress when this summary was created\n\nRules:\n- Preserve ALL specific values: file names, variable names, URLs, error messages, IDs\n- Be detailed on recent work, more concise on earlier work\n- Output structured prose (not bullet JSON)\n- Do NOT include meta-commentary about the summarization itself`;\n\nexport async function compactSession(\n options: CompactSessionOptions,\n): Promise<CompactSessionResult> {\n const {\n messages,\n existingSummary,\n workingMemory = [],\n model = \"claude-haiku-4-5-20251001\",\n maxSummaryTokens = 1024,\n fetchImpl = fetch,\n apiKey = typeof process !== \"undefined\"\n ? process.env.ANTHROPIC_API_KEY\n : undefined,\n apiBaseUrl = \"https://api.anthropic.com\",\n } = options;\n\n if (!apiKey) {\n throw new Error(\n \"compactSession: No API key provided. Set ANTHROPIC_API_KEY or pass options.apiKey.\",\n );\n }\n\n // Build the content to summarize\n const parts: string[] = [];\n\n if (workingMemory.length > 0) {\n parts.push(\n `[Working memory — always preserve these facts]\\n${workingMemory.join(\"\\n\")}`,\n );\n }\n\n if (existingSummary) {\n parts.push(`[Previous summary — extend/update this]\\n${existingSummary}`);\n }\n\n const conversationText = messages\n .map((m) => `${m.role.toUpperCase()}: ${m.content ?? \"(no content)\"}`)\n .join(\"\\n\\n\");\n\n parts.push(`[Conversation to summarize]\\n${conversationText}`);\n\n const userContent = parts.join(\"\\n\\n---\\n\\n\");\n\n const response = await fetchImpl(`${apiBaseUrl}/v1/messages`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"x-api-key\": apiKey,\n \"anthropic-version\": \"2023-06-01\",\n },\n body: JSON.stringify({\n model,\n max_tokens: maxSummaryTokens,\n system: COMPACTION_PROMPT,\n messages: [{ role: \"user\", content: userContent }],\n }),\n });\n\n if (!response.ok) {\n const err = await response.text();\n throw new Error(\n `compactSession: Anthropic API error ${response.status}: ${err}`,\n );\n }\n\n const data = (await response.json()) as {\n content: Array<{ type: string; text: string }>;\n };\n\n const summary = data.content\n .filter((b) => b.type === \"text\")\n .map((b) => b.text)\n .join(\"\");\n\n return { summary };\n}\n","/**\n * Frontmatter parser for skill .md files\n *\n * Parses YAML-like frontmatter blocks delimited by ---\n * Supports single-line scalars only (no external YAML dependency).\n *\n * Example skill file:\n * ---\n * name: code-review\n * description: Performs thorough code reviews\n * strategy: auto\n * version: 1.0.0\n * ---\n *\n * ## Instructions\n * When reviewing code...\n */\n\nexport interface ParsedFrontmatter {\n name?: string;\n description?: string;\n strategy?: string;\n version?: string;\n}\n\nexport interface ParsedSkillFile {\n frontmatter: ParsedFrontmatter;\n content: string;\n}\n\n/**\n * Parse a skill markdown file.\n * Extracts frontmatter fields and returns the body content (without --- block).\n */\nexport function parseSkillFile(raw: string): ParsedSkillFile {\n const frontmatterRegex = /^---\\r?\\n([\\s\\S]*?)\\r?\\n---/;\n const match = frontmatterRegex.exec(raw);\n\n if (!match) {\n return { frontmatter: {}, content: raw.trim() };\n }\n\n const frontmatterBlock = match[1];\n const frontmatter = parseFrontmatterBlock(frontmatterBlock);\n\n // Content is everything after the closing ---\n const afterFrontmatter = raw.slice(match.index + match[0].length);\n const content = afterFrontmatter.replace(/^\\r?\\n/, \"\").trim();\n\n return { frontmatter, content };\n}\n\n/**\n * Parse individual frontmatter key: value pairs (single-line scalars only).\n */\nfunction parseFrontmatterBlock(block: string): ParsedFrontmatter {\n const result: ParsedFrontmatter = {};\n const lines = block.split(/\\r?\\n/);\n\n for (const line of lines) {\n const colonIndex = line.indexOf(\":\");\n if (colonIndex === -1) continue;\n\n const key = line.slice(0, colonIndex).trim();\n const value = line.slice(colonIndex + 1).trim();\n\n if (!key || !value) continue;\n\n // Only accept known keys, ignore others\n switch (key) {\n case \"name\":\n result.name = stripQuotes(value);\n break;\n case \"description\":\n result.description = stripQuotes(value);\n break;\n case \"strategy\":\n result.strategy = stripQuotes(value);\n break;\n case \"version\":\n result.version = stripQuotes(value);\n break;\n }\n }\n\n return result;\n}\n\n/** Strip optional surrounding quotes from a YAML scalar value */\nfunction stripQuotes(value: string): string {\n if (\n (value.startsWith('\"') && value.endsWith('\"')) ||\n (value.startsWith(\"'\") && value.endsWith(\"'\"))\n ) {\n return value.slice(1, -1);\n }\n return value;\n}\n","/**\n * loadSkills() — Server-side skill loader\n *\n * Loads skills from three sources with precedence:\n * server-dir > remote-url > client-inline\n *\n * Returns skills, diagnostics, buildSystemPrompt(), and the load_skill tool.\n *\n * Node.js only — uses fs and fetch.\n */\n\nimport type {\n LoadSkillsOptions,\n LoadSkillsResult,\n ResolvedSkill,\n SkillDiagnostic,\n SkillDiagnosticWinner,\n SkillStrategy,\n} from \"./types\";\nimport { parseSkillFile } from \"./frontmatter\";\nimport { SkillRegistry } from \"./registry\";\n\nconst VALID_STRATEGIES = new Set<SkillStrategy>([\"eager\", \"auto\", \"manual\"]);\n\nfunction isValidStrategy(s: string): s is SkillStrategy {\n return VALID_STRATEGIES.has(s as SkillStrategy);\n}\n\n/**\n * Load skills from server directory, remote URLs, and/or inline client skills.\n *\n * @example\n * ```typescript\n * import { loadSkills } from '@yourgpt/copilot-sdk/server';\n *\n * const { skills, buildSystemPrompt, tools } = await loadSkills({\n * dir: path.join(process.cwd(), 'skills'),\n * });\n *\n * // Use in your API route\n * const systemPrompt = buildSystemPrompt('You are a helpful assistant.');\n * ```\n */\nexport async function loadSkills(\n options: LoadSkillsOptions = {},\n): Promise<LoadSkillsResult> {\n const registry = new SkillRegistry();\n const diagnostics: SkillDiagnostic[] = [];\n\n // Track which names came from which source (for collision detection)\n const sourceMap = new Map<string, SkillDiagnosticWinner>();\n\n // ──────────────────────────────────────────────────\n // Source 1: Server directory (highest precedence)\n // ──────────────────────────────────────────────────\n if (options.dir) {\n const dirSkills = await loadFromDir(options.dir);\n for (const skill of dirSkills) {\n registry.register(skill);\n sourceMap.set(skill.name, \"server-dir\");\n }\n }\n\n // ──────────────────────────────────────────────────\n // Source 2: Remote URLs (medium precedence)\n // ──────────────────────────────────────────────────\n if (options.remoteUrls?.length) {\n const urlSkills = await loadFromUrls(options.remoteUrls);\n for (const skill of urlSkills) {\n const existingSource = sourceMap.get(skill.name);\n if (existingSource) {\n diagnostics.push({\n type: \"collision\",\n name: skill.name,\n winner: existingSource,\n loser: \"remote-url\",\n });\n continue; // Skip — lower precedence source loses\n }\n registry.register(skill);\n sourceMap.set(skill.name, \"remote-url\");\n }\n }\n\n // ──────────────────────────────────────────────────\n // Source 3: Client inline (lowest precedence)\n // ──────────────────────────────────────────────────\n if (options.clientSkills?.length) {\n for (const inline of options.clientSkills) {\n const existingSource = sourceMap.get(inline.name);\n if (existingSource) {\n diagnostics.push({\n type: \"collision\",\n name: inline.name,\n winner: existingSource,\n loser: \"client-inline\",\n });\n continue;\n }\n\n const skill: ResolvedSkill = {\n name: inline.name,\n description: inline.description,\n content: inline.content,\n strategy: inline.strategy ?? \"auto\",\n source: { type: \"inline\", content: inline.content },\n };\n registry.register(skill);\n sourceMap.set(inline.name, \"client-inline\");\n }\n }\n\n // ──────────────────────────────────────────────────\n // Build result\n // ──────────────────────────────────────────────────\n return {\n skills: registry.getAll(),\n diagnostics,\n\n buildSystemPrompt(basePrompt?: string): string {\n const parts: string[] = [];\n\n if (basePrompt) {\n parts.push(basePrompt);\n }\n\n // Prepend eager skill content (always active)\n const eagerContent = registry.buildEagerContent();\n if (eagerContent) {\n parts.push(eagerContent);\n }\n\n // Append auto catalog (discoverable via load_skill)\n const catalog = registry.buildCatalog();\n if (catalog) {\n parts.push(\n `You have access to specialized skills. Call load_skill({ name }) when relevant.\\n\\n${catalog}`,\n );\n }\n\n return parts.join(\"\\n\\n\").trim();\n },\n\n tools: {\n load_skill: {\n description:\n \"Load a skill by name to get full instructions for a specialized task.\",\n parameters: {\n type: \"object\",\n properties: {\n name: {\n type: \"string\",\n description: \"The name of the skill to load.\",\n },\n },\n required: [\"name\"],\n },\n execute: async ({ name }: { name: string }) => {\n const skill = registry.get(name);\n if (!skill) {\n return {\n error: `Skill \"${name}\" not found. Available skills: ${\n registry\n .getAuto()\n .map((s) => s.name)\n .join(\", \") || \"none\"\n }`,\n };\n }\n const sourceTypeMap = {\n inline: \"client-inline\",\n url: \"remote-url\",\n file: \"server-dir\",\n } as const;\n return {\n name: skill.name,\n description: skill.description,\n strategy: skill.strategy ?? \"auto\",\n content: skill.content,\n source: sourceTypeMap[skill.source.type],\n };\n },\n },\n },\n };\n}\n\n// ──────────────────────────────────────────────────\n// Internal helpers\n// ──────────────────────────────────────────────────\n\nasync function loadFromDir(dir: string): Promise<ResolvedSkill[]> {\n // Dynamic import to avoid bundling fs in browser builds\n const { readdir, readFile } = await import(\"fs/promises\");\n const path = await import(\"path\");\n\n let entries: string[];\n try {\n entries = await readdir(dir);\n } catch {\n // Directory doesn't exist or unreadable — not an error\n return [];\n }\n\n const skills: ResolvedSkill[] = [];\n\n for (const entry of entries) {\n const entryPath = path.join(dir, entry);\n\n if (entry.endsWith(\".md\")) {\n // Flat .md file\n const skill = await loadSkillFromFile(entryPath, readFile, path);\n if (skill) skills.push(skill);\n } else {\n // Check for folder-based skill: entry/SKILL.md\n const skillMdPath = path.join(entryPath, \"SKILL.md\");\n try {\n const skill = await loadSkillFromFile(skillMdPath, readFile, path);\n if (skill) skills.push(skill);\n } catch {\n // Not a skill folder — skip\n }\n }\n }\n\n return skills;\n}\n\nasync function loadSkillFromFile(\n filePath: string,\n readFile: (path: string, encoding: \"utf-8\") => Promise<string>,\n path: { basename: (p: string, ext?: string) => string },\n): Promise<ResolvedSkill | null> {\n let raw: string;\n try {\n raw = await readFile(filePath, \"utf-8\");\n } catch {\n return null;\n }\n\n const { frontmatter, content } = parseSkillFile(raw);\n\n // Derive name from frontmatter or filename\n const fileName = path.basename(filePath, \".md\");\n const name =\n frontmatter.name ?? (fileName === \"SKILL\" ? undefined : fileName);\n\n if (!name) {\n console.warn(\n `[copilot-sdk/skills] Skipping skill at ${filePath}: no name in frontmatter and could not derive from filename`,\n );\n return null;\n }\n\n const strategy =\n frontmatter.strategy && isValidStrategy(frontmatter.strategy)\n ? frontmatter.strategy\n : \"auto\";\n\n return {\n name,\n description: frontmatter.description ?? `Skill: ${name}`,\n content,\n strategy,\n version: frontmatter.version,\n source: { type: \"file\", path: filePath },\n };\n}\n\nasync function loadFromUrls(urls: string[]): Promise<ResolvedSkill[]> {\n const skills: ResolvedSkill[] = [];\n\n await Promise.allSettled(\n urls.map(async (url) => {\n try {\n const res = await fetch(url);\n if (!res.ok) {\n console.warn(\n `[copilot-sdk/skills] Failed to fetch skill from ${url}: HTTP ${res.status}`,\n );\n return;\n }\n const raw = await res.text();\n const { frontmatter, content } = parseSkillFile(raw);\n\n if (!frontmatter.name) {\n console.warn(\n `[copilot-sdk/skills] Skipping remote skill at ${url}: no name in frontmatter`,\n );\n return;\n }\n\n const strategy =\n frontmatter.strategy && isValidStrategy(frontmatter.strategy)\n ? frontmatter.strategy\n : \"auto\";\n\n skills.push({\n name: frontmatter.name,\n description: frontmatter.description ?? `Skill: ${frontmatter.name}`,\n content,\n strategy,\n version: frontmatter.version,\n source: { type: \"url\", url },\n });\n } catch (err) {\n console.warn(\n `[copilot-sdk/skills] Error loading remote skill from ${url}:`,\n err,\n );\n }\n }),\n );\n\n return skills;\n}\n"]}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { L as LoadSkillsOptions, a as LoadSkillsResult, R as ResolvedSkill } from '../types-BckL3hiw.cjs';
|
|
2
|
+
export { C as ClientInlineSkill, g as LoadSkillError, f as LoadSkillResult, S as SkillDefinition, d as SkillDiagnostic, e as SkillDiagnosticWinner, b as SkillSource, c as SkillStrategy } from '../types-BckL3hiw.cjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* compactSession — server-side summarization helper
|
|
6
|
+
*
|
|
7
|
+
* Call this in your /api/compact route handler.
|
|
8
|
+
* Uses a structured prompt that preserves all semantically important content.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // app/api/compact/route.ts
|
|
13
|
+
* import { compactSession } from '@yourgpt/copilot-sdk/server';
|
|
14
|
+
*
|
|
15
|
+
* export async function POST(req: Request) {
|
|
16
|
+
* const { messages, existingSummary, workingMemory } = await req.json();
|
|
17
|
+
* const summary = await compactSession({ messages, existingSummary, workingMemory });
|
|
18
|
+
* return Response.json({ summary });
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
interface CompactSessionOptions {
|
|
23
|
+
messages: Array<{
|
|
24
|
+
role: string;
|
|
25
|
+
content?: string | null;
|
|
26
|
+
}>;
|
|
27
|
+
existingSummary?: string | null;
|
|
28
|
+
workingMemory?: string[];
|
|
29
|
+
/**
|
|
30
|
+
* Model to use for summarization.
|
|
31
|
+
* @default 'claude-haiku-4-5' (cheaper model fine for summaries)
|
|
32
|
+
*/
|
|
33
|
+
model?: string;
|
|
34
|
+
/** Max tokens for the summary output. @default 1024 */
|
|
35
|
+
maxSummaryTokens?: number;
|
|
36
|
+
/** Custom fetch implementation (for non-browser environments). */
|
|
37
|
+
fetchImpl?: typeof fetch;
|
|
38
|
+
/** Anthropic API key. Falls back to process.env.ANTHROPIC_API_KEY. */
|
|
39
|
+
apiKey?: string;
|
|
40
|
+
/** Base URL for Anthropic API. @default 'https://api.anthropic.com' */
|
|
41
|
+
apiBaseUrl?: string;
|
|
42
|
+
}
|
|
43
|
+
interface CompactSessionResult {
|
|
44
|
+
summary: string;
|
|
45
|
+
}
|
|
46
|
+
declare function compactSession(options: CompactSessionOptions): Promise<CompactSessionResult>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* loadSkills() — Server-side skill loader
|
|
50
|
+
*
|
|
51
|
+
* Loads skills from three sources with precedence:
|
|
52
|
+
* server-dir > remote-url > client-inline
|
|
53
|
+
*
|
|
54
|
+
* Returns skills, diagnostics, buildSystemPrompt(), and the load_skill tool.
|
|
55
|
+
*
|
|
56
|
+
* Node.js only — uses fs and fetch.
|
|
57
|
+
*/
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Load skills from server directory, remote URLs, and/or inline client skills.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* import { loadSkills } from '@yourgpt/copilot-sdk/server';
|
|
65
|
+
*
|
|
66
|
+
* const { skills, buildSystemPrompt, tools } = await loadSkills({
|
|
67
|
+
* dir: path.join(process.cwd(), 'skills'),
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* // Use in your API route
|
|
71
|
+
* const systemPrompt = buildSystemPrompt('You are a helpful assistant.');
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
declare function loadSkills(options?: LoadSkillsOptions): Promise<LoadSkillsResult>;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* SkillRegistry — manages registered skills
|
|
78
|
+
*
|
|
79
|
+
* Shared between server (loadSkills) and client (SkillProvider).
|
|
80
|
+
* Framework-agnostic — no React dependencies.
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
declare class SkillRegistry {
|
|
84
|
+
private skills;
|
|
85
|
+
/**
|
|
86
|
+
* Register a skill. Silently overwrites if name already exists.
|
|
87
|
+
* Use collision detection in loadSkills() instead.
|
|
88
|
+
*/
|
|
89
|
+
register(skill: ResolvedSkill): void;
|
|
90
|
+
/**
|
|
91
|
+
* Unregister a skill by name.
|
|
92
|
+
*/
|
|
93
|
+
unregister(name: string): void;
|
|
94
|
+
/**
|
|
95
|
+
* Get a skill by name.
|
|
96
|
+
*/
|
|
97
|
+
get(name: string): ResolvedSkill | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Get all registered skills.
|
|
100
|
+
*/
|
|
101
|
+
getAll(): ResolvedSkill[];
|
|
102
|
+
/**
|
|
103
|
+
* Get all skills with strategy === "eager".
|
|
104
|
+
* These are injected directly into the system prompt.
|
|
105
|
+
*/
|
|
106
|
+
getEager(): ResolvedSkill[];
|
|
107
|
+
/**
|
|
108
|
+
* Get all skills with strategy === "auto".
|
|
109
|
+
* These appear in the catalog and are loadable on demand.
|
|
110
|
+
*/
|
|
111
|
+
getAuto(): ResolvedSkill[];
|
|
112
|
+
/**
|
|
113
|
+
* Check if a skill is registered.
|
|
114
|
+
*/
|
|
115
|
+
has(name: string): boolean;
|
|
116
|
+
/**
|
|
117
|
+
* Number of registered skills.
|
|
118
|
+
*/
|
|
119
|
+
get count(): number;
|
|
120
|
+
/**
|
|
121
|
+
* Build a skill catalog string for "auto" skills.
|
|
122
|
+
* Appended to the system prompt so the AI can discover available skills.
|
|
123
|
+
*/
|
|
124
|
+
buildCatalog(): string;
|
|
125
|
+
/**
|
|
126
|
+
* Concatenate content of all "eager" skills.
|
|
127
|
+
* These instructions are always active without requiring load_skill.
|
|
128
|
+
*/
|
|
129
|
+
buildEagerContent(): string;
|
|
130
|
+
/**
|
|
131
|
+
* Resolve content for a skill by name.
|
|
132
|
+
* For inline/file/url skills, content is already resolved at registration time.
|
|
133
|
+
*/
|
|
134
|
+
resolveContent(name: string): Promise<string | undefined>;
|
|
135
|
+
private resolveStrategy;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Frontmatter parser for skill .md files
|
|
140
|
+
*
|
|
141
|
+
* Parses YAML-like frontmatter blocks delimited by ---
|
|
142
|
+
* Supports single-line scalars only (no external YAML dependency).
|
|
143
|
+
*
|
|
144
|
+
* Example skill file:
|
|
145
|
+
* ---
|
|
146
|
+
* name: code-review
|
|
147
|
+
* description: Performs thorough code reviews
|
|
148
|
+
* strategy: auto
|
|
149
|
+
* version: 1.0.0
|
|
150
|
+
* ---
|
|
151
|
+
*
|
|
152
|
+
* ## Instructions
|
|
153
|
+
* When reviewing code...
|
|
154
|
+
*/
|
|
155
|
+
interface ParsedFrontmatter {
|
|
156
|
+
name?: string;
|
|
157
|
+
description?: string;
|
|
158
|
+
strategy?: string;
|
|
159
|
+
version?: string;
|
|
160
|
+
}
|
|
161
|
+
interface ParsedSkillFile {
|
|
162
|
+
frontmatter: ParsedFrontmatter;
|
|
163
|
+
content: string;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Parse a skill markdown file.
|
|
167
|
+
* Extracts frontmatter fields and returns the body content (without --- block).
|
|
168
|
+
*/
|
|
169
|
+
declare function parseSkillFile(raw: string): ParsedSkillFile;
|
|
170
|
+
|
|
171
|
+
export { type CompactSessionOptions, type CompactSessionResult, LoadSkillsOptions, LoadSkillsResult, ResolvedSkill, SkillRegistry, compactSession, loadSkills, parseSkillFile };
|