@superdoc-dev/sdk 1.0.0-alpha.3 → 1.0.0-alpha.4
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/generated/client.d.ts +1790 -0
- package/dist/generated/client.d.ts.map +1 -0
- package/dist/generated/client.js +66 -0
- package/dist/generated/contract.d.ts +13676 -0
- package/dist/generated/contract.d.ts.map +1 -0
- package/dist/generated/contract.js +17809 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/runtime/embedded-cli.d.ts +5 -0
- package/dist/runtime/embedded-cli.d.ts.map +1 -0
- package/dist/runtime/embedded-cli.js +94 -0
- package/dist/runtime/errors.d.ts +17 -0
- package/dist/runtime/errors.d.ts.map +1 -0
- package/dist/runtime/errors.js +18 -0
- package/dist/runtime/host.d.ts +36 -0
- package/dist/runtime/host.d.ts.map +1 -0
- package/dist/runtime/host.js +345 -0
- package/dist/runtime/process.d.ts +16 -0
- package/dist/runtime/process.d.ts.map +1 -0
- package/dist/runtime/process.js +27 -0
- package/dist/runtime/transport-common.d.ts +44 -0
- package/dist/runtime/transport-common.d.ts.map +1 -0
- package/dist/runtime/transport-common.js +65 -0
- package/dist/skills.d.ts +25 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +140 -0
- package/dist/tools.d.ts +113 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +360 -0
- package/package.json +19 -10
- package/tools/catalog.json +17128 -0
- package/tools/tool-name-map.json +96 -0
- package/tools/tools-policy.json +100 -0
- package/tools/tools.anthropic.json +3275 -0
- package/tools/tools.generic.json +16573 -0
- package/tools/tools.openai.json +3557 -0
- package/tools/tools.vercel.json +3557 -0
- package/skills/editing-docx.md +0 -157
- package/src/__tests__/skills.test.ts +0 -166
- package/src/__tests__/tools.test.ts +0 -96
- package/src/generated/client.ts +0 -3643
- package/src/generated/contract.ts +0 -15952
- package/src/index.ts +0 -87
- package/src/runtime/__tests__/process.test.ts +0 -38
- package/src/runtime/__tests__/transport-common.test.ts +0 -174
- package/src/runtime/embedded-cli.ts +0 -109
- package/src/runtime/errors.ts +0 -30
- package/src/runtime/host.ts +0 -481
- package/src/runtime/process.ts +0 -45
- package/src/runtime/transport-common.ts +0 -169
- package/src/skills.ts +0 -195
- package/src/tools.ts +0 -701
package/src/skills.ts
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { fileURLToPath } from 'node:url';
|
|
5
|
-
import { SuperDocCliError } from './runtime/errors';
|
|
6
|
-
|
|
7
|
-
const skillsDir = path.resolve(fileURLToPath(new URL('../skills', import.meta.url)));
|
|
8
|
-
const SKILL_NAME_RE = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
9
|
-
const SUPPORTED_SKILL_RUNTIMES = ['claude'] as const;
|
|
10
|
-
const SUPPORTED_INSTALL_SCOPES = ['project', 'user'] as const;
|
|
11
|
-
|
|
12
|
-
type SkillRuntime = (typeof SUPPORTED_SKILL_RUNTIMES)[number];
|
|
13
|
-
type SkillInstallScope = (typeof SUPPORTED_INSTALL_SCOPES)[number];
|
|
14
|
-
|
|
15
|
-
export interface InstallSkillOptions {
|
|
16
|
-
runtime?: SkillRuntime;
|
|
17
|
-
scope?: SkillInstallScope;
|
|
18
|
-
targetDir?: string;
|
|
19
|
-
cwd?: string;
|
|
20
|
-
homeDir?: string;
|
|
21
|
-
overwrite?: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface InstalledSkillResult {
|
|
25
|
-
name: string;
|
|
26
|
-
runtime: SkillRuntime;
|
|
27
|
-
scope: SkillInstallScope | 'custom';
|
|
28
|
-
path: string;
|
|
29
|
-
written: boolean;
|
|
30
|
-
overwritten: boolean;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function resolveSkillFilePath(skillName: string): string {
|
|
34
|
-
const filePath = path.resolve(skillsDir, `${skillName}.md`);
|
|
35
|
-
const root = `${skillsDir}${path.sep}`;
|
|
36
|
-
if (!filePath.startsWith(root)) {
|
|
37
|
-
throw new SuperDocCliError('Skill name resolved outside SDK skill directory.', {
|
|
38
|
-
code: 'INVALID_ARGUMENT',
|
|
39
|
-
details: { skillName },
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
return filePath;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function normalizeSkillName(name: string): string {
|
|
46
|
-
const normalized = name.trim();
|
|
47
|
-
if (!normalized || !SKILL_NAME_RE.test(normalized)) {
|
|
48
|
-
throw new SuperDocCliError('Skill name is required.', {
|
|
49
|
-
code: 'INVALID_ARGUMENT',
|
|
50
|
-
details: { name },
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
return normalized;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* List the names of all SDK skills bundled with this package.
|
|
58
|
-
*
|
|
59
|
-
* @returns Sorted array of skill names (without the `.md` extension).
|
|
60
|
-
* @throws {SuperDocCliError} With code `SKILL_IO_ERROR` if the skills directory cannot be read.
|
|
61
|
-
*/
|
|
62
|
-
export function listSkills(): string[] {
|
|
63
|
-
try {
|
|
64
|
-
return readdirSync(skillsDir)
|
|
65
|
-
.filter((entry) => path.extname(entry) === '.md')
|
|
66
|
-
.map((entry) => path.basename(entry, '.md'))
|
|
67
|
-
.sort();
|
|
68
|
-
} catch (error) {
|
|
69
|
-
throw new SuperDocCliError('Unable to enumerate SDK skills.', {
|
|
70
|
-
code: 'SKILL_IO_ERROR',
|
|
71
|
-
details: {
|
|
72
|
-
skillsDir,
|
|
73
|
-
message: error instanceof Error ? error.message : String(error),
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Read the content of a bundled SDK skill by name.
|
|
81
|
-
*
|
|
82
|
-
* @param name - Skill name (e.g. `"editing-docx"`). Must match `[A-Za-z0-9][A-Za-z0-9_-]*`.
|
|
83
|
-
* @returns The skill file content as a UTF-8 string.
|
|
84
|
-
* @throws {SuperDocCliError} With code `INVALID_ARGUMENT` if the name is empty or contains invalid characters.
|
|
85
|
-
* @throws {SuperDocCliError} With code `SKILL_NOT_FOUND` if no skill with that name exists.
|
|
86
|
-
* @throws {SuperDocCliError} With code `SKILL_IO_ERROR` for other file-system read failures.
|
|
87
|
-
*/
|
|
88
|
-
export function getSkill(name: string): string {
|
|
89
|
-
const normalized = normalizeSkillName(name);
|
|
90
|
-
|
|
91
|
-
const filePath = resolveSkillFilePath(normalized);
|
|
92
|
-
try {
|
|
93
|
-
return readFileSync(filePath, 'utf8');
|
|
94
|
-
} catch (error) {
|
|
95
|
-
const nodeError = error as NodeJS.ErrnoException;
|
|
96
|
-
if (nodeError?.code === 'ENOENT') {
|
|
97
|
-
let available: string[] = [];
|
|
98
|
-
try {
|
|
99
|
-
available = listSkills();
|
|
100
|
-
} catch {
|
|
101
|
-
// Keep available empty when directory enumeration itself fails.
|
|
102
|
-
}
|
|
103
|
-
throw new SuperDocCliError('Requested SDK skill was not found.', {
|
|
104
|
-
code: 'SKILL_NOT_FOUND',
|
|
105
|
-
details: {
|
|
106
|
-
name: normalized,
|
|
107
|
-
available,
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
throw new SuperDocCliError('Requested SDK skill was not found.', {
|
|
113
|
-
code: 'SKILL_IO_ERROR',
|
|
114
|
-
details: {
|
|
115
|
-
name: normalized,
|
|
116
|
-
message: error instanceof Error ? error.message : String(error),
|
|
117
|
-
},
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Install a bundled SDK skill into an agent runtime directory.
|
|
124
|
-
*
|
|
125
|
-
* Defaults to Claude's project-local skill path: `./.claude/skills/<name>/SKILL.md`.
|
|
126
|
-
*/
|
|
127
|
-
export function installSkill(name: string, options: InstallSkillOptions = {}): InstalledSkillResult {
|
|
128
|
-
const normalizedName = normalizeSkillName(name);
|
|
129
|
-
const runtime = options.runtime ?? 'claude';
|
|
130
|
-
if (!SUPPORTED_SKILL_RUNTIMES.includes(runtime)) {
|
|
131
|
-
throw new SuperDocCliError('Unsupported skill runtime.', {
|
|
132
|
-
code: 'INVALID_ARGUMENT',
|
|
133
|
-
details: { runtime, supportedRuntimes: SUPPORTED_SKILL_RUNTIMES },
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const scope = options.scope ?? 'project';
|
|
138
|
-
if (!SUPPORTED_INSTALL_SCOPES.includes(scope)) {
|
|
139
|
-
throw new SuperDocCliError('Unsupported skill install scope.', {
|
|
140
|
-
code: 'INVALID_ARGUMENT',
|
|
141
|
-
details: { scope, supportedScopes: SUPPORTED_INSTALL_SCOPES },
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const skillsRoot =
|
|
146
|
-
options.targetDir !== undefined
|
|
147
|
-
? path.resolve(options.targetDir)
|
|
148
|
-
: scope === 'user'
|
|
149
|
-
? path.resolve(options.homeDir ?? os.homedir(), '.claude', 'skills')
|
|
150
|
-
: path.resolve(options.cwd ?? process.cwd(), '.claude', 'skills');
|
|
151
|
-
const skillFile = path.join(skillsRoot, normalizedName, 'SKILL.md');
|
|
152
|
-
const overwrite = options.overwrite ?? true;
|
|
153
|
-
const alreadyExists = existsSync(skillFile);
|
|
154
|
-
|
|
155
|
-
if (!overwrite && alreadyExists) {
|
|
156
|
-
return {
|
|
157
|
-
name: normalizedName,
|
|
158
|
-
runtime,
|
|
159
|
-
scope: options.targetDir !== undefined ? 'custom' : scope,
|
|
160
|
-
path: skillFile,
|
|
161
|
-
written: false,
|
|
162
|
-
overwritten: false,
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
try {
|
|
167
|
-
const content = getSkill(name);
|
|
168
|
-
mkdirSync(path.dirname(skillFile), { recursive: true });
|
|
169
|
-
writeFileSync(skillFile, content, 'utf8');
|
|
170
|
-
} catch (error) {
|
|
171
|
-
if (error instanceof SuperDocCliError) {
|
|
172
|
-
throw error;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
throw new SuperDocCliError('Unable to install SDK skill.', {
|
|
176
|
-
code: 'SKILL_IO_ERROR',
|
|
177
|
-
details: {
|
|
178
|
-
name: normalizedName,
|
|
179
|
-
runtime,
|
|
180
|
-
scope: options.targetDir !== undefined ? 'custom' : scope,
|
|
181
|
-
path: skillFile,
|
|
182
|
-
message: error instanceof Error ? error.message : String(error),
|
|
183
|
-
},
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return {
|
|
188
|
-
name: normalizedName,
|
|
189
|
-
runtime,
|
|
190
|
-
scope: options.targetDir !== undefined ? 'custom' : scope,
|
|
191
|
-
path: skillFile,
|
|
192
|
-
written: true,
|
|
193
|
-
overwritten: alreadyExists,
|
|
194
|
-
};
|
|
195
|
-
}
|