@orth/cli 0.3.0 → 0.4.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 (80) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +113 -109
  3. package/dist/analytics.d.ts +37 -3
  4. package/dist/analytics.js +253 -39
  5. package/dist/api.d.ts +28 -2
  6. package/dist/api.js +67 -13
  7. package/dist/command-actions.d.ts +10 -0
  8. package/dist/command-actions.js +42 -0
  9. package/dist/commands/account.d.ts +9 -1
  10. package/dist/commands/account.js +26 -10
  11. package/dist/commands/api.d.ts +3 -0
  12. package/dist/commands/api.js +104 -114
  13. package/dist/commands/auth.d.ts +3 -1
  14. package/dist/commands/auth.js +53 -9
  15. package/dist/commands/onboard/flow.d.ts +22 -0
  16. package/dist/commands/onboard/flow.js +155 -0
  17. package/dist/commands/onboard/guide.d.ts +8 -0
  18. package/dist/commands/onboard/guide.js +73 -0
  19. package/dist/commands/onboard/listing.d.ts +18 -0
  20. package/dist/commands/onboard/listing.js +166 -0
  21. package/dist/commands/onboard/progress.d.ts +44 -0
  22. package/dist/commands/onboard/progress.js +108 -0
  23. package/dist/commands/onboard/register.d.ts +2 -0
  24. package/dist/commands/onboard/register.js +261 -0
  25. package/dist/commands/onboard/requests.d.ts +24 -0
  26. package/dist/commands/onboard/requests.js +96 -0
  27. package/dist/commands/onboard/review.d.ts +31 -0
  28. package/dist/commands/onboard/review.js +228 -0
  29. package/dist/commands/onboard/setup.d.ts +68 -0
  30. package/dist/commands/onboard/setup.js +215 -0
  31. package/dist/commands/onboard/shared.d.ts +41 -0
  32. package/dist/commands/onboard/shared.js +97 -0
  33. package/dist/commands/onboard/tools.d.ts +19 -0
  34. package/dist/commands/onboard/tools.js +104 -0
  35. package/dist/commands/org.d.ts +21 -0
  36. package/dist/commands/org.js +126 -0
  37. package/dist/commands/payouts.d.ts +44 -0
  38. package/dist/commands/payouts.js +125 -0
  39. package/dist/commands/run.d.ts +1 -1
  40. package/dist/commands/run.js +18 -26
  41. package/dist/commands/search.d.ts +8 -1
  42. package/dist/commands/search.js +26 -4
  43. package/dist/commands/skills/browse.d.ts +15 -0
  44. package/dist/commands/skills/browse.js +194 -0
  45. package/dist/commands/skills/create.d.ts +5 -0
  46. package/dist/commands/skills/create.js +62 -0
  47. package/dist/commands/skills/init.d.ts +4 -0
  48. package/dist/commands/skills/init.js +123 -0
  49. package/dist/commands/skills/install.d.ts +6 -0
  50. package/dist/commands/skills/install.js +191 -0
  51. package/dist/commands/skills/local-files.d.ts +15 -0
  52. package/dist/commands/skills/local-files.js +110 -0
  53. package/dist/commands/skills/register.d.ts +2 -0
  54. package/dist/commands/skills/register.js +130 -0
  55. package/dist/commands/skills/shared.d.ts +43 -0
  56. package/dist/commands/skills/shared.js +69 -0
  57. package/dist/commands/skills/upload.d.ts +9 -0
  58. package/dist/commands/skills/upload.js +223 -0
  59. package/dist/commands/skills/verification.d.ts +5 -0
  60. package/dist/commands/skills/verification.js +74 -0
  61. package/dist/commands/telemetry.d.ts +3 -0
  62. package/dist/commands/telemetry.js +38 -0
  63. package/dist/config.d.ts +48 -1
  64. package/dist/config.js +99 -3
  65. package/dist/http.d.ts +15 -0
  66. package/dist/http.js +41 -0
  67. package/dist/index.js +131 -165
  68. package/dist/organizations.d.ts +14 -0
  69. package/dist/organizations.js +77 -0
  70. package/dist/urls.d.ts +3 -0
  71. package/dist/urls.js +34 -0
  72. package/dist/utils.d.ts +20 -0
  73. package/dist/utils.js +112 -0
  74. package/dist/version.d.ts +5 -0
  75. package/dist/version.js +21 -0
  76. package/dist/x402.d.ts +7 -0
  77. package/dist/x402.js +27 -0
  78. package/package.json +23 -22
  79. package/dist/commands/skills.d.ts +0 -66
  80. package/dist/commands/skills.js +0 -821
@@ -1,821 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.skillsListCommand = skillsListCommand;
40
- exports.skillsMineCommand = skillsMineCommand;
41
- exports.skillsSearchCommand = skillsSearchCommand;
42
- exports.skillsShowCommand = skillsShowCommand;
43
- exports.skillsCreateCommand = skillsCreateCommand;
44
- exports.skillsInstallCommand = skillsInstallCommand;
45
- exports.skillsInitCommand = skillsInitCommand;
46
- exports.skillsSubmitCommand = skillsSubmitCommand;
47
- exports.skillsPushCommand = skillsPushCommand;
48
- exports.skillsUpdateCommand = skillsUpdateCommand;
49
- exports.skillsRequestVerificationCommand = skillsRequestVerificationCommand;
50
- exports.skillsPublishCommand = skillsPublishCommand;
51
- exports.skillsRequestCommand = skillsRequestCommand;
52
- const chalk_1 = __importDefault(require("chalk"));
53
- const ora_1 = __importDefault(require("ora"));
54
- const api_js_1 = require("../api.js");
55
- const fs = __importStar(require("fs"));
56
- const path = __importStar(require("path"));
57
- const os = __importStar(require("os"));
58
- // Agent skill directories (user-level global skills)
59
- const AGENT_DIRS = {
60
- cursor: path.join(os.homedir(), ".cursor", "skills"),
61
- "claude-code": path.join(os.homedir(), ".claude", "skills"),
62
- copilot: path.join(os.homedir(), ".github", "skills"),
63
- windsurf: path.join(os.homedir(), ".codeium", "windsurf", "skills"),
64
- codex: path.join(os.homedir(), ".agents", "skills"), // Codex uses ~/.agents/skills/ for user-scoped skills
65
- gemini: path.join(os.homedir(), ".gemini", "skills"),
66
- openclaw: path.join(os.homedir(), ".openclaw", "skills"),
67
- };
68
- // ─────────────────────────────────────────────────────────────────────────────
69
- // orth skills list
70
- // ─────────────────────────────────────────────────────────────────────────────
71
- async function skillsListCommand(options) {
72
- const spinner = (0, ora_1.default)("Loading skills...").start();
73
- try {
74
- const limit = parseInt(options.limit, 10);
75
- const data = await (0, api_js_1.apiRequest)(`/skills?limit=${limit}`);
76
- spinner.stop();
77
- if (!data.skills || data.skills.length === 0) {
78
- console.log(chalk_1.default.yellow("No discoverable skills found."));
79
- return;
80
- }
81
- console.log(chalk_1.default.bold(`\nDiscoverable Skills (${data.total} total):\n`));
82
- for (const skill of data.skills) {
83
- const verified = skill.verified ? chalk_1.default.blue(" ✓") : "";
84
- const installs = chalk_1.default.gray(`(${skill.installCount} installs)`);
85
- const source = skill.sourceType === "github" && skill.githubOwner
86
- ? chalk_1.default.gray(` [${skill.githubOwner}/${skill.githubRepo}]`)
87
- : chalk_1.default.gray(" [uploaded]");
88
- console.log(chalk_1.default.cyan.bold(skill.name) + verified + source + " " + installs);
89
- if (skill.description) {
90
- console.log(chalk_1.default.gray(` ${skill.description.slice(0, 100)}${skill.description.length > 100 ? "..." : ""}`));
91
- }
92
- if (skill.tags && skill.tags.length > 0) {
93
- console.log(chalk_1.default.gray(" Tags: ") +
94
- skill.tags.map((t) => chalk_1.default.magenta(t)).join(", "));
95
- }
96
- console.log(chalk_1.default.gray(` Slug: ${skill.slug}`));
97
- console.log();
98
- }
99
- console.log(chalk_1.default.gray("Run 'orth skills show <slug>' to see skill details"));
100
- console.log(chalk_1.default.gray("Run 'orth skills add <slug>' to add a skill locally"));
101
- }
102
- catch (error) {
103
- spinner.stop();
104
- console.error(chalk_1.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
105
- process.exit(1);
106
- }
107
- }
108
- // ─────────────────────────────────────────────────────────────────────────────
109
- // orth skills mine
110
- // ─────────────────────────────────────────────────────────────────────────────
111
- async function skillsMineCommand(options) {
112
- const spinner = (0, ora_1.default)("Loading your skills...").start();
113
- try {
114
- const limit = parseInt(options.limit, 10) || 50;
115
- const data = await (0, api_js_1.apiRequest)(`/skills/mine?limit=${limit}`);
116
- spinner.stop();
117
- if (!data.skills || data.skills.length === 0) {
118
- console.log(chalk_1.default.gray("\n No skills yet. Create one with: orth skills init\n"));
119
- return;
120
- }
121
- console.log(chalk_1.default.bold(`\nYour Skills (${data.total} total):\n`));
122
- for (const skill of data.skills) {
123
- const verified = skill.verified ? chalk_1.default.blue(" ✓") : "";
124
- const discoverable = skill.discoverable ? chalk_1.default.green(" [public]") : chalk_1.default.gray(" [private]");
125
- const files = chalk_1.default.gray(`${skill.fileCount} files`);
126
- console.log(` ${chalk_1.default.cyan.bold(skill.name)}${verified}${discoverable} ${files}`);
127
- console.log(` Slug: ${chalk_1.default.white(skill.slug)}`);
128
- if (skill.description) {
129
- console.log(chalk_1.default.gray(` ${skill.description.slice(0, 100)}${skill.description.length > 100 ? "..." : ""}`));
130
- }
131
- console.log();
132
- }
133
- }
134
- catch (error) {
135
- spinner.stop();
136
- console.error(chalk_1.default.red("Failed to load skills:"), error instanceof Error ? error.message : String(error));
137
- process.exit(1);
138
- }
139
- }
140
- // ─────────────────────────────────────────────────────────────────────────────
141
- // orth skills search <query>
142
- // ─────────────────────────────────────────────────────────────────────────────
143
- async function skillsSearchCommand(query, options) {
144
- const spinner = (0, ora_1.default)("Searching skills...").start();
145
- try {
146
- const data = await (0, api_js_1.apiRequest)("/skills/search", {
147
- method: "POST",
148
- body: { query, limit: parseInt(options.limit, 10) },
149
- });
150
- spinner.stop();
151
- if (!data.results || data.results.length === 0) {
152
- console.log(chalk_1.default.yellow("No skills found matching your query."));
153
- return data;
154
- }
155
- console.log(chalk_1.default.bold(`\nFound ${data.count} skills:\n`));
156
- for (const skill of data.results) {
157
- const verified = skill.verified ? chalk_1.default.blue(" ✓") : "";
158
- const installs = chalk_1.default.gray(`(${skill.installCount} installs)`);
159
- console.log(chalk_1.default.cyan.bold(skill.name) + verified + " " + installs);
160
- if (skill.description) {
161
- console.log(chalk_1.default.gray(` ${skill.description.slice(0, 100)}${skill.description.length > 100 ? "..." : ""}`));
162
- }
163
- console.log(chalk_1.default.gray(` Slug: ${skill.slug}`));
164
- console.log();
165
- }
166
- console.log(chalk_1.default.gray("Run 'orth skills show <slug>' for full details"));
167
- return data;
168
- }
169
- catch (error) {
170
- spinner.stop();
171
- throw error;
172
- }
173
- }
174
- // ─────────────────────────────────────────────────────────────────────────────
175
- // orth skills show <slug>
176
- // ─────────────────────────────────────────────────────────────────────────────
177
- async function skillsShowCommand(slug) {
178
- const spinner = (0, ora_1.default)("Loading skill...").start();
179
- try {
180
- const data = await (0, api_js_1.apiRequest)(`/skills/${slug}`);
181
- spinner.stop();
182
- const skill = data.skill;
183
- console.log(chalk_1.default.bold(`\n${chalk_1.default.cyan(skill.name)}\n`));
184
- if (skill.description) {
185
- console.log(chalk_1.default.white(skill.description));
186
- console.log();
187
- }
188
- // Metadata
189
- console.log(chalk_1.default.bold("Details:"));
190
- console.log(chalk_1.default.gray(" Slug: ") + skill.slug);
191
- console.log(chalk_1.default.gray(" Source: ") +
192
- (skill.sourceType === "github"
193
- ? `GitHub (${skill.githubOwner}/${skill.githubRepo})`
194
- : "Uploaded"));
195
- console.log(chalk_1.default.gray(" Installs: ") + chalk_1.default.green(String(skill.installCount)));
196
- if (skill.verified) {
197
- console.log(chalk_1.default.gray(" Verified: ") + chalk_1.default.blue("Yes ✓"));
198
- }
199
- if (skill.tags && skill.tags.length > 0) {
200
- console.log(chalk_1.default.gray(" Tags: ") +
201
- skill.tags.map((t) => chalk_1.default.magenta(t)).join(", "));
202
- }
203
- console.log();
204
- // Files
205
- if (skill.files && skill.files.length > 0) {
206
- console.log(chalk_1.default.bold("Files:"));
207
- for (const file of skill.files) {
208
- const primary = file.isPrimary ? chalk_1.default.green(" (primary)") : "";
209
- console.log(chalk_1.default.gray(" ") + chalk_1.default.white(file.filePath) + primary);
210
- }
211
- console.log();
212
- // Show primary file content preview
213
- const primaryFile = skill.files.find((f) => f.isPrimary);
214
- if (primaryFile) {
215
- console.log(chalk_1.default.bold(`── ${primaryFile.filePath} ──\n`));
216
- const lines = primaryFile.content.split("\n");
217
- const preview = lines.slice(0, 30).join("\n");
218
- console.log(preview);
219
- if (lines.length > 30) {
220
- console.log(chalk_1.default.gray(`\n... ${lines.length - 30} more lines`));
221
- }
222
- }
223
- }
224
- console.log();
225
- if (skill.installCommand) {
226
- console.log(chalk_1.default.bold("Install:"));
227
- console.log(chalk_1.default.white(` ${skill.installCommand}`));
228
- }
229
- console.log(chalk_1.default.gray(`\nRun 'orth skills add ${skill.slug}' to add locally`));
230
- }
231
- catch (error) {
232
- spinner.stop();
233
- console.error(chalk_1.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
234
- process.exit(1);
235
- }
236
- }
237
- // ─────────────────────────────────────────────────────────────────────────────
238
- // orth skills create <githubRepo>
239
- // ─────────────────────────────────────────────────────────────────────────────
240
- async function skillsCreateCommand(githubRepo, options) {
241
- const spinner = (0, ora_1.default)("Creating skill from GitHub...").start();
242
- try {
243
- // Parse GitHub URL or owner/repo format
244
- let githubOwner;
245
- let githubRepoName;
246
- const urlMatch = githubRepo.match(/github\.com\/([^/]+)\/([^/\s#?]+)/);
247
- if (urlMatch) {
248
- githubOwner = urlMatch[1];
249
- githubRepoName = urlMatch[2].replace(/\.git$/, "");
250
- }
251
- else {
252
- const parts = githubRepo.split("/");
253
- if (parts.length < 2) {
254
- spinner.stop();
255
- console.error(chalk_1.default.red("Error: Provide a GitHub URL or owner/repo format"));
256
- process.exit(1);
257
- }
258
- githubOwner = parts[0];
259
- githubRepoName = parts[1];
260
- }
261
- const data = await (0, api_js_1.apiRequest)("/skills", {
262
- method: "POST",
263
- body: {
264
- githubOwner,
265
- githubRepo: githubRepoName,
266
- githubPath: options.path,
267
- githubRef: options.ref || "main",
268
- name: options.name,
269
- sourceType: "github",
270
- },
271
- });
272
- spinner.stop();
273
- console.log(chalk_1.default.green(`\n✓ ${data.message}`));
274
- console.log(chalk_1.default.bold(`\n${data.skill.name}`));
275
- console.log(chalk_1.default.gray(` Slug: ${data.skill.slug}`));
276
- if (data.skill.description) {
277
- console.log(chalk_1.default.gray(` ${data.skill.description}`));
278
- }
279
- console.log(chalk_1.default.bold("\nYour skill is on the platform but not yet verified."));
280
- console.log(chalk_1.default.white(`To request verification: ${chalk_1.default.cyan(`orth skills request-verification ${data.skill.slug}`)}`));
281
- console.log(chalk_1.default.gray("Once verified, you can toggle discoverability anytime."));
282
- }
283
- catch (error) {
284
- spinner.stop();
285
- console.error(chalk_1.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
286
- process.exit(1);
287
- }
288
- }
289
- // ─────────────────────────────────────────────────────────────────────────────
290
- // orth skills add <slug>
291
- // ─────────────────────────────────────────────────────────────────────────────
292
- async function skillsInstallCommand(slug, options) {
293
- const spinner = (0, ora_1.default)("Fetching skill...").start();
294
- try {
295
- const data = await (0, api_js_1.apiRequest)(`/skills/${slug}`);
296
- const skill = data.skill;
297
- spinner.stop();
298
- if (!skill.files || skill.files.length === 0) {
299
- console.log(chalk_1.default.yellow("This skill has no files to install."));
300
- return;
301
- }
302
- const primaryFile = skill.files.find((f) => f.isPrimary);
303
- if (!primaryFile) {
304
- console.log(chalk_1.default.yellow("No primary SKILL.md file found."));
305
- return;
306
- }
307
- // Determine which agents to install for
308
- if (options.agent && !AGENT_DIRS[options.agent]) {
309
- spinner.stop();
310
- console.error(chalk_1.default.red(`Error: Unknown agent '${options.agent}'. Valid agents: ${Object.keys(AGENT_DIRS).join(", ")}`));
311
- process.exit(1);
312
- }
313
- const agents = options.agent
314
- ? { [options.agent]: AGENT_DIRS[options.agent] }
315
- : AGENT_DIRS;
316
- const skillDirName = skill.slug.replace(/\//g, "-");
317
- let installed = 0;
318
- for (const [agentName, baseDir] of Object.entries(agents)) {
319
- if (!baseDir)
320
- continue;
321
- // Only install for agents whose base directory already exists
322
- if (!fs.existsSync(path.dirname(baseDir)))
323
- continue;
324
- const skillDir = path.join(baseDir, skillDirName);
325
- try {
326
- // Create directories
327
- fs.mkdirSync(skillDir, { recursive: true });
328
- // Write all files (with path traversal protection)
329
- for (const file of skill.files) {
330
- // Sanitize file path to prevent path traversal
331
- const sanitized = file.filePath.replace(/\.\.\//g, "").replace(/\.\.\\/g, "");
332
- const filePath = path.resolve(skillDir, sanitized);
333
- // Ensure resolved path is within skillDir
334
- if (!filePath.startsWith(path.resolve(skillDir))) {
335
- console.log(chalk_1.default.yellow(` Skipped unsafe file path: ${file.filePath}`));
336
- continue;
337
- }
338
- const fileDir = path.dirname(filePath);
339
- fs.mkdirSync(fileDir, { recursive: true });
340
- fs.writeFileSync(filePath, file.content, "utf-8");
341
- }
342
- console.log(chalk_1.default.green(` ✓ Installed for ${agentName}: ${skillDir}`));
343
- installed++;
344
- }
345
- catch {
346
- // Skip agents whose directories don't exist / can't be created
347
- console.log(chalk_1.default.gray(` - Skipped ${agentName} (directory not accessible)`));
348
- }
349
- }
350
- // Record the install
351
- try {
352
- await (0, api_js_1.apiRequest)(`/skills/${slug}/install`, { method: "POST" });
353
- }
354
- catch {
355
- // Non-critical - don't fail the install
356
- }
357
- if (installed > 0) {
358
- console.log(chalk_1.default.green(`\n✓ Installed "${skill.name}" for ${installed} agent(s)`));
359
- }
360
- else {
361
- console.log(chalk_1.default.yellow("\nNo agents were found. Install manually by copying SKILL.md to your agent's skills directory."));
362
- }
363
- }
364
- catch (error) {
365
- spinner.stop();
366
- console.error(chalk_1.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
367
- process.exit(1);
368
- }
369
- }
370
- // ─────────────────────────────────────────────────────────────────────────────
371
- // orth skills init [name]
372
- // ─────────────────────────────────────────────────────────────────────────────
373
- // Known binary/large file extensions to skip when reading local files
374
- const SKIP_EXTENSIONS = new Set([
375
- ".png", ".jpg", ".jpeg", ".gif", ".webp", ".ico", ".svg",
376
- ".mp4", ".mp3", ".wav", ".ogg",
377
- ".zip", ".tar", ".gz", ".bz2", ".rar", ".7z",
378
- ".woff", ".woff2", ".ttf", ".eot",
379
- ".exe", ".dll", ".so", ".dylib",
380
- ".pdf", ".doc", ".docx", ".xls", ".xlsx",
381
- ".lock", ".bin",
382
- ]);
383
- const SKIP_DIRS = new Set([
384
- "node_modules", ".git", "__pycache__", ".venv", "venv",
385
- "dist", "build", ".next", ".cache",
386
- ]);
387
- async function skillsInitCommand(name, options) {
388
- try {
389
- const skillName = name || "my-skill";
390
- const dirPath = options.path || path.join(process.cwd(), skillName);
391
- // Check if directory already exists and has content
392
- if (fs.existsSync(dirPath)) {
393
- const contents = fs.readdirSync(dirPath);
394
- if (contents.length > 0) {
395
- const skillMdExists = contents.includes("SKILL.md");
396
- if (skillMdExists) {
397
- console.error(chalk_1.default.red(`Error: ${dirPath} already contains a SKILL.md file`));
398
- process.exit(1);
399
- }
400
- }
401
- }
402
- // Create directory
403
- fs.mkdirSync(dirPath, { recursive: true });
404
- // Generate SKILL.md template
405
- const slugName = skillName
406
- .toLowerCase()
407
- .replace(/[^a-z0-9]+/g, "-")
408
- .replace(/-+/g, "-")
409
- .replace(/^-+|-+$/g, "");
410
- const skillMdContent = `---
411
- name: ${slugName}
412
- description: TODO - Describe what this skill does and when an agent should use it. Be specific about triggers.
413
- ---
414
-
415
- # ${skillName.charAt(0).toUpperCase() + skillName.slice(1).replace(/-/g, " ")}
416
-
417
- TODO - Add instructions for the AI agent here.
418
-
419
- ## When to Use This Skill
420
-
421
- Use this skill when the user:
422
- - TODO - Describe specific triggers
423
- - TODO - Add more triggers
424
-
425
- ## Workflow
426
-
427
- ### Step 1: TODO
428
-
429
- Describe the first step.
430
-
431
- ### Step 2: TODO
432
-
433
- Describe the next step.
434
- `;
435
- fs.writeFileSync(path.join(dirPath, "SKILL.md"), skillMdContent, "utf-8");
436
- // Create optional subdirectories unless --bare
437
- if (!options.bare) {
438
- const subDirs = ["scripts", "references", "assets"];
439
- for (const sub of subDirs) {
440
- const subPath = path.join(dirPath, sub);
441
- fs.mkdirSync(subPath, { recursive: true });
442
- // Add .gitkeep to keep empty dirs in git
443
- fs.writeFileSync(path.join(subPath, ".gitkeep"), "", "utf-8");
444
- }
445
- }
446
- console.log(chalk_1.default.green(`\n✓ Skill initialized at ${dirPath}\n`));
447
- console.log(chalk_1.default.bold("Files created:"));
448
- console.log(chalk_1.default.white(" SKILL.md") + chalk_1.default.gray(" (primary - edit this!)"));
449
- if (!options.bare) {
450
- console.log(chalk_1.default.gray(" scripts/ - Executable scripts"));
451
- console.log(chalk_1.default.gray(" references/ - Reference docs loaded on demand"));
452
- console.log(chalk_1.default.gray(" assets/ - Files used in output"));
453
- }
454
- console.log(chalk_1.default.bold("\nNext steps:"));
455
- console.log(chalk_1.default.white(" 1. Edit SKILL.md with your skill's instructions"));
456
- console.log(chalk_1.default.white(" 2. Add any supporting files to scripts/, references/, or assets/"));
457
- console.log(chalk_1.default.white(` 3. Submit to Orthogonal: ${chalk_1.default.cyan(`orth skills submit ${dirPath}`)}`));
458
- }
459
- catch (error) {
460
- console.error(chalk_1.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
461
- process.exit(1);
462
- }
463
- }
464
- // ─────────────────────────────────────────────────────────────────────────────
465
- // orth skills submit [path]
466
- // ─────────────────────────────────────────────────────────────────────────────
467
- function readFilesRecursive(dirPath, basePath = "") {
468
- const files = [];
469
- const entries = fs.readdirSync(dirPath, { withFileTypes: true });
470
- for (const entry of entries) {
471
- const fullPath = path.join(dirPath, entry.name);
472
- const relativePath = basePath ? `${basePath}/${entry.name}` : entry.name;
473
- if (entry.isDirectory()) {
474
- if (SKIP_DIRS.has(entry.name) || entry.name.startsWith("."))
475
- continue;
476
- files.push(...readFilesRecursive(fullPath, relativePath));
477
- }
478
- else if (entry.isFile()) {
479
- // Skip dotfiles and binary files
480
- if (entry.name.startsWith("."))
481
- continue;
482
- const ext = entry.name.includes(".")
483
- ? "." + entry.name.split(".").pop().toLowerCase()
484
- : "";
485
- if (SKIP_EXTENSIONS.has(ext))
486
- continue;
487
- try {
488
- const content = fs.readFileSync(fullPath, "utf-8");
489
- files.push({
490
- filePath: relativePath,
491
- content,
492
- isPrimary: entry.name === "SKILL.md" && basePath === "",
493
- });
494
- }
495
- catch {
496
- // Skip files that can't be read as UTF-8
497
- }
498
- }
499
- }
500
- return files;
501
- }
502
- /**
503
- * Simple YAML frontmatter parser for SKILL.md files.
504
- * Supports single-line `name:` and `description:` values.
505
- * Multi-line YAML values (block scalars, folded strings) are not supported —
506
- * descriptions should be kept to a single line in frontmatter.
507
- */
508
- function parseFrontmatter(content) {
509
- const match = content.match(/^---\s*\n([\s\S]*?)\n---/);
510
- if (!match)
511
- return {};
512
- const fm = match[1] || "";
513
- const result = {};
514
- for (const line of fm.split("\n")) {
515
- const nameMatch = line.match(/^name:\s*(.+)$/);
516
- if (nameMatch?.[1])
517
- result.name = nameMatch[1].trim();
518
- const descMatch = line.match(/^description:\s*(.+)$/);
519
- if (descMatch?.[1])
520
- result.description = descMatch[1].trim();
521
- }
522
- return result;
523
- }
524
- async function skillsSubmitCommand(inputPath, options) {
525
- const dirPath = inputPath ? path.resolve(inputPath) : process.cwd();
526
- const spinner = (0, ora_1.default)("Reading skill files...").start();
527
- try {
528
- // Validate directory exists
529
- if (!fs.existsSync(dirPath) || !fs.statSync(dirPath).isDirectory()) {
530
- spinner.stop();
531
- console.error(chalk_1.default.red(`Error: ${dirPath} is not a directory`));
532
- process.exit(1);
533
- }
534
- // Read all files
535
- const files = readFilesRecursive(dirPath);
536
- if (files.length === 0) {
537
- spinner.stop();
538
- console.error(chalk_1.default.red("Error: No files found in the directory"));
539
- process.exit(1);
540
- }
541
- // Validate SKILL.md exists
542
- const primaryFile = files.find((f) => f.isPrimary);
543
- if (!primaryFile) {
544
- spinner.stop();
545
- console.error(chalk_1.default.red("Error: No SKILL.md found in the root of the directory"));
546
- console.log(chalk_1.default.gray("Run 'orth skills init' to create a skill template"));
547
- process.exit(1);
548
- }
549
- // Parse frontmatter
550
- const frontmatter = parseFrontmatter(primaryFile.content);
551
- const skillName = options.name || frontmatter.name;
552
- const skillDescription = frontmatter.description;
553
- if (!skillName) {
554
- spinner.stop();
555
- console.error(chalk_1.default.red("Error: Skill name is required. Add 'name:' to SKILL.md frontmatter or use --name"));
556
- process.exit(1);
557
- }
558
- if (!skillDescription) {
559
- spinner.stop();
560
- console.error(chalk_1.default.red("Error: Skill description is required. Add 'description:' to SKILL.md frontmatter"));
561
- process.exit(1);
562
- }
563
- // Check size limits
564
- const totalSize = files.reduce((acc, f) => acc + f.content.length, 0);
565
- if (files.length > 50) {
566
- spinner.stop();
567
- console.error(chalk_1.default.red("Error: Too many files (max 50)"));
568
- process.exit(1);
569
- }
570
- if (totalSize > 1024 * 1024) {
571
- spinner.stop();
572
- console.error(chalk_1.default.red("Error: Total content too large (max 1MB)"));
573
- process.exit(1);
574
- }
575
- spinner.text = "Submitting skill to Orthogonal...";
576
- const tags = options.tags
577
- ? options.tags.split(",").map((t) => t.trim())
578
- : undefined;
579
- const data = await (0, api_js_1.apiRequest)("/skills", {
580
- method: "POST",
581
- body: {
582
- sourceType: "upload",
583
- name: skillName,
584
- description: skillDescription,
585
- files: files.map((f) => ({
586
- filePath: f.filePath,
587
- content: f.content,
588
- isPrimary: f.isPrimary,
589
- })),
590
- tags,
591
- discoverable: false,
592
- ...(options.org ? { organizationId: options.org } : {}),
593
- },
594
- });
595
- spinner.stop();
596
- console.log(chalk_1.default.green(`\n✓ ${data.message}`));
597
- console.log(chalk_1.default.bold(`\n${data.skill.name}`));
598
- console.log(chalk_1.default.gray(` Slug: ${data.skill.slug}`));
599
- console.log(chalk_1.default.gray(` Files: ${files.length}`));
600
- if (data.skill.description) {
601
- console.log(chalk_1.default.gray(` ${data.skill.description.slice(0, 100)}`));
602
- }
603
- console.log(chalk_1.default.bold("\nYour skill is on the platform but not yet verified."));
604
- console.log(chalk_1.default.white(`To request verification: ${chalk_1.default.cyan(`orth skills request-verification ${data.skill.slug}`)}`));
605
- console.log(chalk_1.default.gray("Once verified, you can toggle discoverability anytime."));
606
- console.log(chalk_1.default.gray(`Dashboard: https://orthogonal.com/dashboard/skills`));
607
- }
608
- catch (error) {
609
- spinner.stop();
610
- console.error(chalk_1.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
611
- process.exit(1);
612
- }
613
- }
614
- // ─────────────────────────────────────────────────────────────────────────────
615
- // orth skills push <slug> [path]
616
- // Push local skill files to remote (replaces remote with local)
617
- // ─────────────────────────────────────────────────────────────────────────────
618
- async function skillsPushCommand(slug, inputPath, options) {
619
- const dirPath = inputPath ? path.resolve(inputPath) : process.cwd();
620
- const spinner = (0, ora_1.default)("Reading skill files...").start();
621
- try {
622
- // Validate directory exists
623
- if (!fs.existsSync(dirPath) || !fs.statSync(dirPath).isDirectory()) {
624
- spinner.stop();
625
- console.error(chalk_1.default.red(`Error: ${dirPath} is not a directory`));
626
- process.exit(1);
627
- }
628
- // Read all files
629
- const files = readFilesRecursive(dirPath);
630
- if (files.length === 0) {
631
- spinner.stop();
632
- console.error(chalk_1.default.red("Error: No files found in the directory"));
633
- process.exit(1);
634
- }
635
- // Validate SKILL.md exists
636
- const primaryFile = files.find((f) => f.isPrimary);
637
- if (!primaryFile) {
638
- spinner.stop();
639
- console.error(chalk_1.default.red("Error: No SKILL.md found in the root of the directory"));
640
- process.exit(1);
641
- }
642
- // Parse frontmatter
643
- // Note: Unlike submit, name/description are optional for updates
644
- // We only send them if provided (to allow partial updates)
645
- const frontmatter = parseFrontmatter(primaryFile.content);
646
- const skillName = options.name || frontmatter.name;
647
- const skillDescription = frontmatter.description;
648
- // Check size limits
649
- const totalSize = files.reduce((acc, f) => acc + f.content.length, 0);
650
- if (files.length > 50) {
651
- spinner.stop();
652
- console.error(chalk_1.default.red("Error: Too many files (max 50)"));
653
- process.exit(1);
654
- }
655
- if (totalSize > 1024 * 1024) {
656
- spinner.stop();
657
- console.error(chalk_1.default.red("Error: Total content too large (max 1MB)"));
658
- process.exit(1);
659
- }
660
- spinner.text = "Pushing skill to Orthogonal...";
661
- const tags = options.tags
662
- ? options.tags.split(",").map((t) => t.trim())
663
- : undefined;
664
- const updatePayload = {
665
- files: files.map((f) => ({
666
- filePath: f.filePath,
667
- content: f.content,
668
- isPrimary: f.isPrimary,
669
- })),
670
- };
671
- if (skillName)
672
- updatePayload.name = skillName;
673
- if (skillDescription)
674
- updatePayload.description = skillDescription;
675
- if (tags)
676
- updatePayload.tags = tags;
677
- const data = await (0, api_js_1.apiRequest)(`/skills/${slug}`, {
678
- method: "PUT",
679
- body: updatePayload,
680
- });
681
- spinner.stop();
682
- console.log(chalk_1.default.green(`\n✓ Skill pushed successfully`));
683
- console.log(chalk_1.default.bold(`\n${data.skill.name}`));
684
- console.log(chalk_1.default.gray(` Slug: ${data.skill.slug}`));
685
- console.log(chalk_1.default.gray(` Files: ${files.length}`));
686
- if (data.skill.description) {
687
- console.log(chalk_1.default.gray(` ${data.skill.description.slice(0, 100)}`));
688
- }
689
- }
690
- catch (error) {
691
- spinner.stop();
692
- console.error(chalk_1.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
693
- process.exit(1);
694
- }
695
- }
696
- // ─────────────────────────────────────────────────────────────────────────────
697
- // orth skills update <slug> [path]
698
- // Pull latest version from Orthogonal and update local files
699
- // ─────────────────────────────────────────────────────────────────────────────
700
- async function skillsUpdateCommand(slug, inputPath, options) {
701
- const spinner = (0, ora_1.default)(`Fetching skill '${slug}' from Orthogonal...`).start();
702
- try {
703
- // Fetch skill from API
704
- const data = await (0, api_js_1.apiRequest)(`/skills/${slug}`);
705
- const skill = data.skill;
706
- if (!skill.files || skill.files.length === 0) {
707
- spinner.stop();
708
- console.error(chalk_1.default.red("Error: Skill has no files to download"));
709
- process.exit(1);
710
- }
711
- // Determine target directory
712
- const skillDirName = slug.replace(/\//g, "-");
713
- const dirPath = inputPath
714
- ? path.resolve(inputPath)
715
- : path.join(process.cwd(), skillDirName);
716
- // Check if directory exists and has content
717
- if (fs.existsSync(dirPath) && !options.force) {
718
- const contents = fs.readdirSync(dirPath);
719
- if (contents.length > 0) {
720
- spinner.stop();
721
- console.log(chalk_1.default.yellow(`Directory ${dirPath} already exists with content.`));
722
- console.log(chalk_1.default.white(`Use ${chalk_1.default.cyan("--force")} to overwrite existing files.`));
723
- process.exit(1);
724
- }
725
- }
726
- spinner.text = "Writing files...";
727
- // Create directory
728
- fs.mkdirSync(dirPath, { recursive: true });
729
- // Write all files
730
- for (const file of skill.files) {
731
- // Sanitize file path to prevent path traversal
732
- const sanitized = file.filePath.replace(/\.\.\//g, "").replace(/\.\.\\/g, "");
733
- const filePath = path.resolve(dirPath, sanitized);
734
- // Ensure resolved path is within dirPath
735
- if (!filePath.startsWith(path.resolve(dirPath))) {
736
- console.log(chalk_1.default.yellow(` Skipped unsafe file path: ${file.filePath}`));
737
- continue;
738
- }
739
- const fileDir = path.dirname(filePath);
740
- fs.mkdirSync(fileDir, { recursive: true });
741
- fs.writeFileSync(filePath, file.content, "utf-8");
742
- }
743
- spinner.stop();
744
- console.log(chalk_1.default.green(`\n✓ Skill updated from Orthogonal`));
745
- console.log(chalk_1.default.bold(`\n${skill.name}`));
746
- console.log(chalk_1.default.gray(` Path: ${dirPath}`));
747
- console.log(chalk_1.default.gray(` Files: ${skill.files.length}`));
748
- console.log(chalk_1.default.bold("\nFiles written:"));
749
- for (const file of skill.files) {
750
- const primary = file.isPrimary ? chalk_1.default.green(" (primary)") : "";
751
- console.log(chalk_1.default.gray(" ") + chalk_1.default.white(file.filePath) + primary);
752
- }
753
- console.log(chalk_1.default.gray(`\nTo push changes back: ${chalk_1.default.cyan(`orth skills push ${slug} ${dirPath}`)}`));
754
- }
755
- catch (error) {
756
- spinner.stop();
757
- console.error(chalk_1.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
758
- process.exit(1);
759
- }
760
- }
761
- // ─────────────────────────────────────────────────────────────────────────────
762
- // orth skills request-verification <slug>
763
- // ─────────────────────────────────────────────────────────────────────────────
764
- async function skillsRequestVerificationCommand(slug) {
765
- const spinner = (0, ora_1.default)("Submitting verification request...").start();
766
- try {
767
- // First get the skill to find its ID
768
- const skillData = await (0, api_js_1.apiRequest)(`/skills/${slug}`);
769
- if (!skillData.skill) {
770
- spinner.stop();
771
- console.error(chalk_1.default.red(`Error: Skill '${slug}' not found`));
772
- process.exit(1);
773
- }
774
- // Request verification via the public API endpoint
775
- await (0, api_js_1.apiRequest)(`/skills/${slug}/request-verification`, {
776
- method: "POST",
777
- });
778
- spinner.stop();
779
- console.log(chalk_1.default.green("\n✓ Verification request submitted!"));
780
- console.log(chalk_1.default.gray("Our team will review your skill. Once verified, you can toggle discoverability anytime."));
781
- console.log(chalk_1.default.gray("Check the status on your dashboard."));
782
- }
783
- catch (error) {
784
- spinner.stop();
785
- console.error(chalk_1.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
786
- process.exit(1);
787
- }
788
- }
789
- // ─────────────────────────────────────────────────────────────────────────────
790
- // orth skills publish <slug> (deprecated - redirects to request-verification)
791
- // ─────────────────────────────────────────────────────────────────────────────
792
- async function skillsPublishCommand(slug, options) {
793
- console.log(chalk_1.default.yellow("Note: Direct publishing has been replaced with a verification workflow."));
794
- console.log(chalk_1.default.white(`\nTo request your skill to be verified, run:\n ${chalk_1.default.cyan(`orth skills request-verification ${slug}`)}`));
795
- console.log(chalk_1.default.white("Once verified, you can toggle discoverability from your dashboard."));
796
- console.log(chalk_1.default.gray("\nOr manage from the dashboard: https://orthogonal.com/dashboard/skills"));
797
- }
798
- // ─────────────────────────────────────────────────────────────────────────────
799
- // orth skills request <input>
800
- // ─────────────────────────────────────────────────────────────────────────────
801
- async function skillsRequestCommand(input) {
802
- const spinner = (0, ora_1.default)("Submitting skill request...").start();
803
- try {
804
- // Determine if input is a GitHub URL or description
805
- const isGitHub = input.includes("github.com") ||
806
- /^[a-zA-Z0-9_-]+\/[a-zA-Z0-9_.-]+$/.test(input);
807
- const body = isGitHub ? { githubRepo: input } : { description: input };
808
- await (0, api_js_1.apiRequest)("/requests/skill", {
809
- method: "POST",
810
- body,
811
- });
812
- spinner.stop();
813
- console.log(chalk_1.default.green("\n✓ Skill request submitted!"));
814
- console.log(chalk_1.default.gray("Our team has been notified and will review your request."));
815
- }
816
- catch (error) {
817
- spinner.stop();
818
- console.error(chalk_1.default.red(`Error: ${error instanceof Error ? error.message : "Unknown error"}`));
819
- process.exit(1);
820
- }
821
- }