runwork 0.5.0 → 0.6.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 (116) hide show
  1. package/dist/agents/__tests__/claude-code-stats.test.d.ts +1 -0
  2. package/dist/agents/__tests__/claude-code-stats.test.js +153 -0
  3. package/dist/agents/__tests__/claude-desktop-stats.test.d.ts +1 -0
  4. package/dist/agents/__tests__/claude-desktop-stats.test.js +280 -0
  5. package/dist/agents/__tests__/codex-stats.test.d.ts +1 -0
  6. package/dist/agents/__tests__/codex-stats.test.js +262 -0
  7. package/dist/agents/__tests__/cursor-stats.test.d.ts +1 -0
  8. package/dist/agents/__tests__/cursor-stats.test.js +183 -0
  9. package/dist/agents/__tests__/graceful-degradation.test.d.ts +1 -0
  10. package/dist/agents/__tests__/graceful-degradation.test.js +123 -0
  11. package/dist/agents/__tests__/instruction-hint.test.d.ts +1 -0
  12. package/dist/agents/__tests__/instruction-hint.test.js +69 -0
  13. package/dist/agents/__tests__/intro-skill.test.d.ts +1 -0
  14. package/dist/agents/__tests__/intro-skill.test.js +135 -0
  15. package/dist/agents/__tests__/schema-validation.test.d.ts +1 -0
  16. package/dist/agents/__tests__/schema-validation.test.js +212 -0
  17. package/dist/agents/claude-code.d.ts +16 -1
  18. package/dist/agents/claude-code.js +344 -21
  19. package/dist/agents/claude-desktop.d.ts +10 -1
  20. package/dist/agents/claude-desktop.js +250 -8
  21. package/dist/agents/cline.d.ts +13 -0
  22. package/dist/agents/cline.js +88 -0
  23. package/dist/agents/codex.d.ts +7 -2
  24. package/dist/agents/codex.js +130 -18
  25. package/dist/agents/cursor.d.ts +6 -1
  26. package/dist/agents/cursor.js +164 -7
  27. package/dist/agents/detect.js +30 -7
  28. package/dist/agents/gemini.d.ts +6 -3
  29. package/dist/agents/gemini.js +57 -20
  30. package/dist/agents/generic-adapter.d.ts +23 -0
  31. package/dist/agents/generic-adapter.js +106 -0
  32. package/dist/agents/intro-skill.d.ts +36 -0
  33. package/dist/agents/intro-skill.js +358 -0
  34. package/dist/agents/registry.d.ts +53 -0
  35. package/dist/agents/registry.js +219 -0
  36. package/dist/agents/types.d.ts +44 -1
  37. package/dist/agents/types.js +11 -4
  38. package/dist/agents/utils/instruction-hint.d.ts +11 -0
  39. package/dist/agents/utils/instruction-hint.js +62 -0
  40. package/dist/agents/utils/json-config.js +3 -3
  41. package/dist/agents/windsurf.d.ts +2 -0
  42. package/dist/agents/windsurf.js +26 -9
  43. package/dist/api/client.d.ts +85 -2
  44. package/dist/api/client.js +40 -10
  45. package/dist/auth/__tests__/login-flow.test.d.ts +1 -0
  46. package/dist/auth/__tests__/login-flow.test.js +125 -0
  47. package/dist/auth/login-flow.d.ts +16 -0
  48. package/dist/auth/login-flow.js +101 -1
  49. package/dist/commands/clone.d.ts +9 -1
  50. package/dist/commands/clone.js +40 -12
  51. package/dist/commands/deploy.js +27 -4
  52. package/dist/commands/dev.js +35 -1
  53. package/dist/commands/doctor.d.ts +2 -0
  54. package/dist/commands/doctor.js +82 -0
  55. package/dist/commands/info.js +6 -2
  56. package/dist/commands/init.d.ts +10 -2
  57. package/dist/commands/init.js +58 -15
  58. package/dist/commands/integrations.js +47 -10
  59. package/dist/commands/login.js +31 -4
  60. package/dist/commands/mcp.js +143 -15
  61. package/dist/commands/setup.js +47 -122
  62. package/dist/commands/skills.js +230 -12
  63. package/dist/commands/sync.d.ts +8 -0
  64. package/dist/commands/sync.js +398 -65
  65. package/dist/commands/welcome.js +6 -3
  66. package/dist/generated/version.d.ts +1 -1
  67. package/dist/generated/version.js +1 -1
  68. package/dist/health/__tests__/checks.test.d.ts +1 -0
  69. package/dist/health/__tests__/checks.test.js +223 -0
  70. package/dist/health/checks.d.ts +20 -0
  71. package/dist/health/checks.js +392 -0
  72. package/dist/health/runner.d.ts +2 -0
  73. package/dist/health/runner.js +26 -0
  74. package/dist/health/types.d.ts +12 -0
  75. package/dist/health/types.js +1 -0
  76. package/dist/index.js +32 -0
  77. package/dist/sync/__tests__/change-detect.test.d.ts +1 -0
  78. package/dist/sync/__tests__/change-detect.test.js +123 -0
  79. package/dist/sync/__tests__/hash.test.d.ts +1 -0
  80. package/dist/sync/__tests__/hash.test.js +18 -0
  81. package/dist/sync/change-detect.d.ts +19 -0
  82. package/dist/sync/change-detect.js +136 -0
  83. package/dist/sync/conflict-ui.d.ts +5 -0
  84. package/dist/sync/conflict-ui.js +78 -0
  85. package/dist/sync/executor.d.ts +21 -0
  86. package/dist/sync/executor.js +98 -0
  87. package/dist/sync/hash.d.ts +1 -0
  88. package/dist/sync/hash.js +4 -0
  89. package/dist/sync/types.d.ts +24 -0
  90. package/dist/sync/types.js +1 -0
  91. package/dist/types.d.ts +12 -0
  92. package/dist/ui/__tests__/banner.test.js +17 -1
  93. package/dist/ui/banner.d.ts +1 -1
  94. package/dist/ui/banner.js +27 -2
  95. package/dist/utils/__tests__/resolve.test.d.ts +1 -0
  96. package/dist/utils/__tests__/resolve.test.js +95 -0
  97. package/dist/utils/__tests__/sqlite.test.d.ts +1 -0
  98. package/dist/utils/__tests__/sqlite.test.js +77 -0
  99. package/dist/utils/agent-guidance.d.ts +32 -0
  100. package/dist/utils/agent-guidance.js +106 -0
  101. package/dist/utils/fs.js +2 -2
  102. package/dist/utils/help-json.d.ts +56 -0
  103. package/dist/utils/help-json.js +85 -0
  104. package/dist/utils/resolve.d.ts +12 -0
  105. package/dist/utils/resolve.js +52 -0
  106. package/dist/utils/setup-state.d.ts +3 -0
  107. package/dist/utils/setup-state.js +19 -0
  108. package/dist/utils/sqlite.d.ts +7 -0
  109. package/dist/utils/sqlite.js +24 -0
  110. package/dist/utils/which.d.ts +6 -0
  111. package/dist/utils/which.js +18 -0
  112. package/package.json +7 -3
  113. package/dist/agents/copilot-cli.d.ts +0 -10
  114. package/dist/agents/copilot-cli.js +0 -46
  115. package/dist/agents/copilot-vscode.d.ts +0 -10
  116. package/dist/agents/copilot-vscode.js +0 -37
@@ -64,38 +64,89 @@ const listCommand = new Command('list')
64
64
  process.exit(1);
65
65
  }
66
66
  });
67
+ async function readStdin() {
68
+ const chunks = [];
69
+ for await (const chunk of process.stdin) {
70
+ chunks.push(Buffer.from(chunk));
71
+ }
72
+ return Buffer.concat(chunks).toString('utf-8');
73
+ }
67
74
  const pushCommand = new Command('push')
68
- .description('Upload a local skill file to workspace (upsert by name)')
69
- .argument('<file>', 'Path to skill .md file')
75
+ .description('Upload a local skill file to workspace (upsert by name). Accepts piped content via stdin.')
76
+ .argument('[first]', 'Skill name (if piping content) or file path (name from frontmatter)')
77
+ .argument('[second]', 'File path (when first arg is the skill name)')
70
78
  .option('--workspace <id>', 'Workspace ID')
71
- .action(async (file, opts, command) => {
79
+ .action(async (first, second, opts, command) => {
72
80
  const useJson = shouldOutputJson(command.optsWithGlobals().json);
73
81
  const credentials = requireAuth();
74
82
  const client = new ApiClient(credentials);
75
83
  const { workspaceId } = await resolveWorkspace(client, opts);
76
- if (!existsSync(file)) {
77
- console.error(`File not found: ${file}`);
84
+ // Resolve args: figure out which is the name and which is the file
85
+ let nameArg;
86
+ let filePath;
87
+ if (first && second) {
88
+ // Two args: name + file
89
+ nameArg = first;
90
+ filePath = second;
91
+ }
92
+ else if (first) {
93
+ // One arg: is it a file or a name?
94
+ if (existsSync(first)) {
95
+ filePath = first;
96
+ }
97
+ else if (!process.stdin.isTTY) {
98
+ // Not a file and stdin has data: treat as name, read from stdin
99
+ nameArg = first;
100
+ }
101
+ else {
102
+ // Assume it's a file path that doesn't exist
103
+ console.error(`File not found: ${first}`);
104
+ process.exit(1);
105
+ }
106
+ }
107
+ else if (!process.stdin.isTTY) {
108
+ // No args, stdin has data: read from stdin, name must be in frontmatter
109
+ }
110
+ else {
111
+ console.error('Usage:\n runwork skills push <file>\n runwork skills push <name> <file>\n cat skill.md | runwork skills push <name>');
78
112
  process.exit(1);
79
113
  }
114
+ // Read content from file or stdin
115
+ let content;
116
+ if (filePath) {
117
+ if (!existsSync(filePath)) {
118
+ console.error(`File not found: ${filePath}`);
119
+ process.exit(1);
120
+ }
121
+ content = readFileSync(filePath, 'utf-8');
122
+ }
123
+ else {
124
+ content = await readStdin();
125
+ if (!content.trim()) {
126
+ console.error('No input received from stdin.');
127
+ process.exit(1);
128
+ }
129
+ }
80
130
  try {
81
- const content = readFileSync(file, 'utf-8');
82
131
  // Parse frontmatter
83
132
  const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
84
- let name = '';
133
+ let name = nameArg || '';
85
134
  let description = '';
86
135
  let body = content;
87
136
  if (frontmatterMatch) {
88
137
  const fm = frontmatterMatch[1];
89
138
  body = frontmatterMatch[2];
90
- const nameMatch = fm.match(/^name:\s*(.+)$/m);
91
139
  const descMatch = fm.match(/^description:\s*(.+)$/m);
92
- if (nameMatch)
93
- name = nameMatch[1].trim();
94
140
  if (descMatch)
95
141
  description = descMatch[1].trim();
142
+ if (!name) {
143
+ const nameMatch = fm.match(/^name:\s*(.+)$/m);
144
+ if (nameMatch)
145
+ name = nameMatch[1].trim();
146
+ }
96
147
  }
97
148
  if (!name) {
98
- console.error('Skill file must have a "name" in YAML frontmatter:\n---\nname: my-skill\ndescription: What it does\n---');
149
+ console.error('Skill name required. Provide as first argument or in YAML frontmatter:\n runwork skills push "My Skill" ./skill.md\n cat skill.md | runwork skills push "My Skill"');
99
150
  process.exit(1);
100
151
  }
101
152
  // Check if skill already exists (upsert by name)
@@ -128,7 +179,174 @@ const pushCommand = new Command('push')
128
179
  process.exit(1);
129
180
  }
130
181
  });
182
+ const pullCommand = new Command('pull')
183
+ .alias('download')
184
+ .description('Download a skill from the workspace and print to stdout (or save to file)')
185
+ .argument('<name>', 'Skill name or ID')
186
+ .option('--workspace <id>', 'Workspace ID')
187
+ .option('-o, --output <file>', 'Save to file instead of stdout')
188
+ .action(async (nameOrId, opts, command) => {
189
+ const useJson = shouldOutputJson(command.optsWithGlobals().json);
190
+ const credentials = requireAuth();
191
+ const client = new ApiClient(credentials);
192
+ const { workspaceId } = await resolveWorkspace(client, opts);
193
+ try {
194
+ // Search external skills first
195
+ const externalSkills = await client.listExternalSkills(workspaceId);
196
+ const externalMatch = externalSkills.find(s => s.id === nameOrId || s.name === nameOrId || s.name.toLowerCase() === nameOrId.toLowerCase());
197
+ if (externalMatch) {
198
+ if (!externalMatch.content) {
199
+ console.error(`Skill "${externalMatch.name}" exists but has no content.`);
200
+ process.exit(1);
201
+ }
202
+ const fullContent = buildSkillOutput(externalMatch.name, externalMatch.description, externalMatch.content);
203
+ if (useJson) {
204
+ jsonOut({ skill: externalMatch });
205
+ return;
206
+ }
207
+ if (opts.output) {
208
+ const { writeFileSync: writeFile } = await import('fs');
209
+ writeFile(opts.output, fullContent);
210
+ console.error(`Saved skill "${externalMatch.name}" to ${opts.output}`);
211
+ }
212
+ else {
213
+ process.stdout.write(fullContent);
214
+ }
215
+ return;
216
+ }
217
+ // Search app skills (includeContent to avoid a second round-trip)
218
+ const allSkills = await client.listWorkspaceSkills(workspaceId, true);
219
+ const appSkill = allSkills.find(s => s.id === nameOrId || s.name === nameOrId || s.name.toLowerCase() === nameOrId.toLowerCase());
220
+ if (appSkill?.appId) {
221
+ const content = appSkill.content;
222
+ if (!content) {
223
+ console.error(`Skill "${appSkill.name}" exists but has no content yet.`);
224
+ process.exit(1);
225
+ }
226
+ if (useJson) {
227
+ jsonOut({ skill: { name: appSkill.name, type: appSkill.type, content } });
228
+ return;
229
+ }
230
+ if (opts.output) {
231
+ const { writeFileSync: writeFile } = await import('fs');
232
+ writeFile(opts.output, content);
233
+ console.error(`Saved skill "${appSkill.name}" to ${opts.output}`);
234
+ }
235
+ else {
236
+ process.stdout.write(content);
237
+ }
238
+ return;
239
+ }
240
+ // Also check MCP-generated skills (they don't have downloadable content)
241
+ const mcpSkill = allSkills.find(s => s.type === 'mcp' && (s.id === nameOrId || s.name === nameOrId || s.name.toLowerCase() === nameOrId.toLowerCase()));
242
+ if (mcpSkill) {
243
+ console.error(`Skill "${mcpSkill.name}" is auto-generated from an MCP server and cannot be downloaded.`);
244
+ process.exit(1);
245
+ }
246
+ console.error(`Skill "${nameOrId}" not found. Run \`runwork skills list\` to see available skills.`);
247
+ process.exit(1);
248
+ }
249
+ catch (err) {
250
+ console.error('Failed to pull skill:', err instanceof Error ? err.message : err);
251
+ process.exit(1);
252
+ }
253
+ });
254
+ function buildSkillOutput(name, description, content) {
255
+ // If content already has frontmatter, return as-is
256
+ if (content.trimStart().startsWith('---\n'))
257
+ return content;
258
+ return `---\nname: ${name}\ndescription: ${description}\n---\n\n${content}`;
259
+ }
260
+ pushCommand.alias('upload');
261
+ const searchCommand = new Command('search')
262
+ .description('Search community skills from skills.sh')
263
+ .argument('<query>', 'Search query')
264
+ .option('--limit <n>', 'Max results (1-50)', '10')
265
+ .action(async (query, opts, command) => {
266
+ const useJson = shouldOutputJson(command.optsWithGlobals().json);
267
+ const credentials = requireAuth();
268
+ const client = new ApiClient(credentials);
269
+ try {
270
+ const results = await client.searchCommunitySkills(query, Number(opts.limit));
271
+ if (useJson) {
272
+ jsonOut(results);
273
+ return;
274
+ }
275
+ if (results.skills.length === 0) {
276
+ console.log(`No community skills found for "${query}".`);
277
+ return;
278
+ }
279
+ console.log(`\n ${results.count} result${results.count !== 1 ? 's' : ''} for "${query}"\n`);
280
+ console.log(` ${'Name'.padEnd(30)} ${'Source'.padEnd(35)} Installs`);
281
+ console.log(' ' + '-'.repeat(80));
282
+ for (const s of results.skills) {
283
+ const installs = s.install_count >= 1000
284
+ ? `${(s.install_count / 1000).toFixed(1)}K`
285
+ : String(s.install_count);
286
+ console.log(` ${s.title.padEnd(30)} ${s.source.padEnd(35)} ${installs}`);
287
+ }
288
+ console.log(`\n Install with: runwork skills install <source>/<id>`);
289
+ console.log('');
290
+ }
291
+ catch (err) {
292
+ console.error('Search failed:', err instanceof Error ? err.message : err);
293
+ process.exit(1);
294
+ }
295
+ });
296
+ const installCommand = new Command('install')
297
+ .description('Install a community skill from skills.sh into your workspace')
298
+ .argument('<identifier>', 'Skill identifier: source/skill-id (e.g. vercel-labs/skills/find-skills)')
299
+ .option('--workspace <id>', 'Workspace ID')
300
+ .action(async (identifier, opts, command) => {
301
+ const useJson = shouldOutputJson(command.optsWithGlobals().json);
302
+ const credentials = requireAuth();
303
+ const client = new ApiClient(credentials);
304
+ const { workspaceId } = await resolveWorkspace(client, opts);
305
+ // Parse identifier: "owner/repo/skill-id" or "owner/repo" (skill-id = last segment)
306
+ const parts = identifier.split('/');
307
+ let source;
308
+ let skillId;
309
+ if (parts.length >= 3) {
310
+ source = parts.slice(0, -1).join('/');
311
+ skillId = parts[parts.length - 1];
312
+ }
313
+ else if (parts.length === 2) {
314
+ // Try as source/skillId directly
315
+ source = parts[0];
316
+ skillId = parts[1];
317
+ }
318
+ else {
319
+ console.error('Invalid identifier. Use format: owner/repo/skill-id or owner/repo');
320
+ process.exit(1);
321
+ }
322
+ try {
323
+ const skill = await client.getCommunitySkillContent(source, skillId);
324
+ if (!skill.content) {
325
+ console.error(`Skill "${identifier}" found but has no content.`);
326
+ process.exit(1);
327
+ }
328
+ const imported = await client.importExternalSkill(workspaceId, {
329
+ name: skill.title || skillId,
330
+ description: skill.description || '',
331
+ content: skill.content,
332
+ importedFrom: `skills.sh:${source}/${skillId}`,
333
+ });
334
+ if (useJson) {
335
+ jsonOut({ skill: imported, source: identifier });
336
+ return;
337
+ }
338
+ console.log(`Installed "${skill.title || skillId}" from ${source}`);
339
+ console.log('Run `runwork sync` to update your local agent configs.');
340
+ }
341
+ catch (err) {
342
+ console.error('Install failed:', err instanceof Error ? err.message : err);
343
+ process.exit(1);
344
+ }
345
+ });
131
346
  export const skillsCommand = new Command('skills')
132
347
  .description('Manage workspace skills')
133
348
  .addCommand(listCommand)
134
- .addCommand(pushCommand);
349
+ .addCommand(pushCommand)
350
+ .addCommand(pullCommand)
351
+ .addCommand(searchCommand)
352
+ .addCommand(installCommand);
@@ -1,2 +1,10 @@
1
1
  import { Command } from 'commander';
2
+ import type { SetupState, Credentials } from '../types.js';
3
+ export interface SyncOptions {
4
+ dryRun: boolean;
5
+ pullOnly: boolean;
6
+ prefer?: 'local' | 'remote';
7
+ yes: boolean;
8
+ }
9
+ export declare function syncFromState(state: SetupState, statePath: string, credentials: Credentials, opts: SyncOptions): Promise<void>;
2
10
  export declare const syncCommand: Command;