@xagent-ai/cli 1.0.1 → 1.1.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.
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- package/README.md +280 -280
- package/README_CN.md +3 -3
- package/dist/ai-client.d.ts.map +1 -1
- package/dist/ai-client.js +84 -82
- package/dist/ai-client.js.map +1 -1
- package/dist/auth.d.ts +0 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +75 -105
- package/dist/auth.js.map +1 -1
- package/dist/cli.js +166 -13
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +3 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +48 -7
- package/dist/config.js.map +1 -1
- package/dist/context-compressor.d.ts +5 -5
- package/dist/context-compressor.js +8 -8
- package/dist/context-compressor.js.map +1 -1
- package/dist/gui-subagent/action-parser/actionParser.d.ts +7 -0
- package/dist/gui-subagent/action-parser/actionParser.d.ts.map +1 -1
- package/dist/gui-subagent/action-parser/actionParser.js +6 -3
- package/dist/gui-subagent/action-parser/actionParser.js.map +1 -1
- package/dist/gui-subagent/action-parser/constants.d.ts +6 -0
- package/dist/gui-subagent/action-parser/constants.d.ts.map +1 -1
- package/dist/gui-subagent/action-parser/constants.js +5 -3
- package/dist/gui-subagent/action-parser/constants.js.map +1 -1
- package/dist/gui-subagent/action-parser/index.d.ts +6 -0
- package/dist/gui-subagent/action-parser/index.d.ts.map +1 -1
- package/dist/gui-subagent/action-parser/index.js +5 -3
- package/dist/gui-subagent/action-parser/index.js.map +1 -1
- package/dist/gui-subagent/action-parser/types.d.ts +4 -0
- package/dist/gui-subagent/action-parser/types.d.ts.map +1 -1
- package/dist/gui-subagent/action-parser/types.js +3 -3
- package/dist/gui-subagent/agent/gui-agent.d.ts +39 -0
- package/dist/gui-subagent/agent/gui-agent.d.ts.map +1 -1
- package/dist/gui-subagent/agent/gui-agent.js +164 -89
- package/dist/gui-subagent/agent/gui-agent.js.map +1 -1
- package/dist/gui-subagent/agent/index.d.ts +1 -1
- package/dist/gui-subagent/agent/index.d.ts.map +1 -1
- package/dist/gui-subagent/agent/index.js.map +1 -1
- package/dist/gui-subagent/index.d.ts +27 -1
- package/dist/gui-subagent/index.d.ts.map +1 -1
- package/dist/gui-subagent/index.js +6 -0
- package/dist/gui-subagent/index.js.map +1 -1
- package/dist/logger.js +1 -1
- package/dist/logger.js.map +1 -1
- package/dist/mcp.d.ts +1 -0
- package/dist/mcp.d.ts.map +1 -1
- package/dist/mcp.js +140 -29
- package/dist/mcp.js.map +1 -1
- package/dist/remote-ai-client.d.ts +111 -0
- package/dist/remote-ai-client.d.ts.map +1 -0
- package/dist/remote-ai-client.js +558 -0
- package/dist/remote-ai-client.js.map +1 -0
- package/dist/sdk-output-adapter.d.ts +232 -0
- package/dist/sdk-output-adapter.d.ts.map +1 -0
- package/dist/sdk-output-adapter.js +636 -0
- package/dist/sdk-output-adapter.js.map +1 -0
- package/dist/sdk-session-v2.d.ts +13 -0
- package/dist/sdk-session-v2.d.ts.map +1 -0
- package/dist/sdk-session-v2.js +46 -0
- package/dist/sdk-session-v2.js.map +1 -0
- package/dist/sdk-session.d.ts +13 -0
- package/dist/sdk-session.d.ts.map +1 -0
- package/dist/sdk-session.js +48 -0
- package/dist/sdk-session.js.map +1 -0
- package/dist/session-manager.js +3 -3
- package/dist/session-manager.js.map +1 -1
- package/dist/session.d.ts +46 -3
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +539 -104
- package/dist/session.js.map +1 -1
- package/dist/skill-invoker.d.ts +40 -4
- package/dist/skill-invoker.d.ts.map +1 -1
- package/dist/skill-invoker.js +310 -1184
- package/dist/skill-invoker.js.map +1 -1
- package/dist/skill-loader.d.ts +15 -1
- package/dist/skill-loader.d.ts.map +1 -1
- package/dist/skill-loader.js +49 -32
- package/dist/skill-loader.js.map +1 -1
- package/dist/slash-commands.d.ts +4 -2
- package/dist/slash-commands.d.ts.map +1 -1
- package/dist/slash-commands.js +149 -15
- package/dist/slash-commands.js.map +1 -1
- package/dist/smart-approval.d.ts +2 -1
- package/dist/smart-approval.d.ts.map +1 -1
- package/dist/smart-approval.js +29 -3
- package/dist/smart-approval.js.map +1 -1
- package/dist/system-prompt-generator.d.ts +4 -5
- package/dist/system-prompt-generator.d.ts.map +1 -1
- package/dist/system-prompt-generator.js +131 -81
- package/dist/system-prompt-generator.js.map +1 -1
- package/dist/tools.d.ts +17 -6
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +264 -211
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -1
- package/dist/types.js.map +1 -1
- package/docs/architecture/mcp-integration-guide.md +194 -131
- package/docs/architecture/overview.md +169 -93
- package/docs/architecture/tool-system-design.md +56 -11
- package/docs/cli/commands.md +238 -189
- package/docs/smart-mode.md +281 -257
- package/docs/third-party-models.md +247 -256
- package/package.json +6 -2
- package/src/ai-client.ts +107 -105
- package/src/auth.ts +82 -116
- package/src/cancellation.ts +1 -1
- package/src/cli.ts +178 -13
- package/src/config.ts +57 -8
- package/src/context-compressor.ts +8 -8
- package/src/gui-subagent/action-parser/actionParser.ts +6 -3
- package/src/gui-subagent/action-parser/constants.ts +5 -3
- package/src/gui-subagent/action-parser/index.ts +5 -3
- package/src/gui-subagent/action-parser/types.ts +3 -3
- package/src/gui-subagent/agent/gui-agent.ts +210 -103
- package/src/gui-subagent/agent/index.ts +1 -1
- package/src/gui-subagent/index.ts +26 -2
- package/src/index.ts +18 -18
- package/src/logger.ts +1 -1
- package/src/mcp.ts +149 -30
- package/src/remote-ai-client.ts +671 -0
- package/src/session-manager.ts +3 -3
- package/src/session.ts +704 -156
- package/src/skill-invoker.ts +340 -1293
- package/src/skill-loader.ts +55 -34
- package/src/slash-commands.ts +165 -15
- package/src/smart-approval.ts +34 -3
- package/src/system-prompt-generator.ts +145 -88
- package/src/tools.ts +309 -224
- package/src/types.ts +0 -1
- package/scripts/init-skills-path.js +0 -58
package/dist/skill-invoker.js
CHANGED
|
@@ -252,191 +252,225 @@ export async function readSkillContent(skillPath, keywords, maxLength = 5000) {
|
|
|
252
252
|
// ============================================================
|
|
253
253
|
// SKILL Trigger Keywords Mapping
|
|
254
254
|
// ============================================================
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
};
|
|
255
|
+
// NOTE: SKILL_TRIGGERS is disabled for experiment purposes.
|
|
256
|
+
// Let the LLM decide which skill to use based on system prompt information.
|
|
257
|
+
// interface SkillTrigger {
|
|
258
|
+
// skillId: string;
|
|
259
|
+
// keywords: string[];
|
|
260
|
+
// category: string;
|
|
261
|
+
// }
|
|
262
|
+
// export const SKILL_TRIGGERS: Record<string, SkillTrigger> = {
|
|
263
|
+
// docx: {
|
|
264
|
+
// skillId: 'docx',
|
|
265
|
+
// keywords: [
|
|
266
|
+
// 'word document', 'docx', 'microsoft word', 'create word', 'edit word',
|
|
267
|
+
// 'create .docx', '.docx file', 'word file', 'document creation',
|
|
268
|
+
// 'word editing', 'tracked changes', 'comments'
|
|
269
|
+
// ],
|
|
270
|
+
// category: 'Document Processing'
|
|
271
|
+
// },
|
|
272
|
+
// pdf: {
|
|
273
|
+
// skillId: 'pdf',
|
|
274
|
+
// keywords: [
|
|
275
|
+
// 'pdf', 'create pdf', 'edit pdf', 'pdf document', 'pdf file',
|
|
276
|
+
// 'extract pdf', 'merge pdf', 'split pdf', 'pdf form', 'manipulate pdf'
|
|
277
|
+
// ],
|
|
278
|
+
// category: 'Document Processing'
|
|
279
|
+
// },
|
|
280
|
+
// pptx: {
|
|
281
|
+
// skillId: 'pptx',
|
|
282
|
+
// keywords: [
|
|
283
|
+
// 'powerpoint', 'ppt', 'pptx', 'presentation', 'slide',
|
|
284
|
+
// 'create presentation', 'edit powerpoint', 'create slides',
|
|
285
|
+
// 'powerpoint file', 'presentation file'
|
|
286
|
+
// ],
|
|
287
|
+
// category: 'Document Processing'
|
|
288
|
+
// },
|
|
289
|
+
// xlsx: {
|
|
290
|
+
// skillId: 'xlsx',
|
|
291
|
+
// keywords: [
|
|
292
|
+
// 'excel', 'spreadsheet', 'xlsx', 'create excel', 'edit spreadsheet',
|
|
293
|
+
// 'excel file', 'spreadsheet file', 'formulas', 'data analysis'
|
|
294
|
+
// ],
|
|
295
|
+
// category: 'Spreadsheet & Data'
|
|
296
|
+
// },
|
|
297
|
+
// frontend_design: {
|
|
298
|
+
// skillId: 'frontend-design',
|
|
299
|
+
// keywords: [
|
|
300
|
+
// 'web page', 'website', 'web app', 'frontend', 'ui', 'user interface',
|
|
301
|
+
// 'create website', 'build website', 'web component', 'html css',
|
|
302
|
+
// 'landing page', 'dashboard', 'react', 'vue', 'web interface'
|
|
303
|
+
// ],
|
|
304
|
+
// category: 'Frontend & Web Development'
|
|
305
|
+
// },
|
|
306
|
+
// web_artifacts_builder: {
|
|
307
|
+
// skillId: 'web-artifacts-builder',
|
|
308
|
+
// keywords: [
|
|
309
|
+
// 'complex react', 'react artifact', 'stateful artifact', 'routing',
|
|
310
|
+
// 'web artifact', 'interactive artifact', 'web-based tool'
|
|
311
|
+
// ],
|
|
312
|
+
// category: 'Frontend & Web Development'
|
|
313
|
+
// },
|
|
314
|
+
// webapp_testing: {
|
|
315
|
+
// skillId: 'webapp-testing',
|
|
316
|
+
// keywords: [
|
|
317
|
+
// 'test web', 'web testing', 'browser test', 'playwright', 'e2e test',
|
|
318
|
+
// 'frontend test', 'capture screenshot', 'verify web'
|
|
319
|
+
// ],
|
|
320
|
+
// category: 'Frontend & Web Development'
|
|
321
|
+
// },
|
|
322
|
+
// canvas_design: {
|
|
323
|
+
// skillId: 'canvas-design',
|
|
324
|
+
// keywords: [
|
|
325
|
+
// 'poster', 'artwork', 'visual art', 'canvas', 'design art',
|
|
326
|
+
// 'create poster', 'create artwork', 'visual design', 'graphic art'
|
|
327
|
+
// ],
|
|
328
|
+
// category: 'Visual & Creative Design'
|
|
329
|
+
// },
|
|
330
|
+
// algorithmic_art: {
|
|
331
|
+
// skillId: 'algorithmic-art',
|
|
332
|
+
// keywords: [
|
|
333
|
+
// 'generative art', 'algorithmic art', 'p5.js', 'particle system',
|
|
334
|
+
// 'flow field', 'creative coding', 'code art'
|
|
335
|
+
// ],
|
|
336
|
+
// category: 'Visual & Creative Design'
|
|
337
|
+
// },
|
|
338
|
+
// theme_factory: {
|
|
339
|
+
// skillId: 'theme-factory',
|
|
340
|
+
// keywords: [
|
|
341
|
+
// 'theme', 'color scheme', 'font theme', 'styling theme',
|
|
342
|
+
// 'consistent theme', 'apply theme', 'theme colors'
|
|
343
|
+
// ],
|
|
344
|
+
// category: 'Visual & Creative Design'
|
|
345
|
+
// },
|
|
346
|
+
// brand_guidelines: {
|
|
347
|
+
// skillId: 'brand-guidelines',
|
|
348
|
+
// keywords: [
|
|
349
|
+
// 'brand colors', 'brand guidelines', 'anthropic brand',
|
|
350
|
+
// 'official brand', 'brand styling'
|
|
351
|
+
// ],
|
|
352
|
+
// category: 'Visual & Creative Design'
|
|
353
|
+
// },
|
|
354
|
+
// slack_gif_creator: {
|
|
355
|
+
// skillId: 'slack-gif-creator',
|
|
356
|
+
// keywords: [
|
|
357
|
+
// 'slack gif', 'animated gif', 'gif for slack', 'slack animation'
|
|
358
|
+
// ],
|
|
359
|
+
// category: 'Visual & Creative Design'
|
|
360
|
+
// },
|
|
361
|
+
// mcp_builder: {
|
|
362
|
+
// skillId: 'mcp-builder',
|
|
363
|
+
// keywords: [
|
|
364
|
+
// 'mcp server', 'model context protocol', 'create mcp',
|
|
365
|
+
// 'mcp integration', 'external api integration'
|
|
366
|
+
// ],
|
|
367
|
+
// category: 'Development & Integration'
|
|
368
|
+
// },
|
|
369
|
+
// skill_creator: {
|
|
370
|
+
// skillId: 'skill-creator',
|
|
371
|
+
// keywords: [
|
|
372
|
+
// 'create skill', 'new skill', 'skill development',
|
|
373
|
+
// 'extend capabilities', 'custom skill'
|
|
374
|
+
// ],
|
|
375
|
+
// category: 'Development & Integration'
|
|
376
|
+
// },
|
|
377
|
+
// doc_coauthoring: {
|
|
378
|
+
// skillId: 'doc-coauthoring',
|
|
379
|
+
// keywords: [
|
|
380
|
+
// 'documentation', 'technical docs', 'write documentation',
|
|
381
|
+
// 'coauthor', 'doc writing', 'technical writing'
|
|
382
|
+
// ],
|
|
383
|
+
// category: 'Communication & Documentation'
|
|
384
|
+
// }
|
|
385
|
+
// };
|
|
387
386
|
// ============================================================
|
|
388
387
|
// SkillInvoker Main Class
|
|
389
388
|
// ============================================================
|
|
390
389
|
export class SkillInvoker {
|
|
391
390
|
skillLoader;
|
|
392
391
|
initialized = false;
|
|
393
|
-
skillCache = new Map();
|
|
392
|
+
skillCache = new Map(); // Stores metadata only
|
|
393
|
+
skillContentCache = new Map(); // Stores full SKILL.md content
|
|
394
394
|
constructor(skillLoader) {
|
|
395
395
|
this.skillLoader = skillLoader || getSkillLoader();
|
|
396
396
|
}
|
|
397
397
|
async initialize() {
|
|
398
398
|
if (this.initialized)
|
|
399
399
|
return;
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
400
|
+
// Use discoverSkills to only discover directories without loading full content
|
|
401
|
+
const skillIds = await this.skillLoader.discoverSkills();
|
|
402
|
+
// Create minimal SkillInfo objects with metadata only
|
|
403
|
+
for (const skillId of skillIds) {
|
|
404
|
+
const skillPath = this.skillLoader.getSkillDirectory?.(skillId) || '';
|
|
405
|
+
const skillInfo = {
|
|
406
|
+
id: skillId,
|
|
407
|
+
name: skillId,
|
|
408
|
+
description: '', // Will be loaded lazily
|
|
409
|
+
license: 'Unknown',
|
|
410
|
+
version: '1.0.0',
|
|
411
|
+
author: 'Anonymous',
|
|
412
|
+
category: '',
|
|
413
|
+
markdown: '', // Full content loaded lazily
|
|
414
|
+
skillsPath: skillPath
|
|
415
|
+
};
|
|
416
|
+
this.skillCache.set(skillId, skillInfo);
|
|
403
417
|
}
|
|
404
418
|
this.initialized = true;
|
|
405
419
|
}
|
|
406
420
|
/**
|
|
407
|
-
*
|
|
421
|
+
* Load skill metadata (name, description, category) from SKILL.md frontmatter
|
|
422
|
+
* This is called lazily when skill details are needed
|
|
423
|
+
*/
|
|
424
|
+
async loadSkillMetadata(skillId) {
|
|
425
|
+
const skill = this.skillCache.get(skillId);
|
|
426
|
+
if (!skill)
|
|
427
|
+
return;
|
|
428
|
+
// Check if metadata already loaded
|
|
429
|
+
if (skill.description && skill.category)
|
|
430
|
+
return;
|
|
431
|
+
const skillPath = skill.skillsPath;
|
|
432
|
+
const skillMdPath = path.join(skillPath, 'SKILL.md');
|
|
433
|
+
try {
|
|
434
|
+
const content = await fs.readFile(skillMdPath, 'utf-8');
|
|
435
|
+
const parsed = this.skillLoader.parseSkillMarkdown(content);
|
|
436
|
+
skill.name = parsed.name || skillId;
|
|
437
|
+
skill.description = parsed.description || '';
|
|
438
|
+
skill.license = parsed.license || 'Unknown';
|
|
439
|
+
skill.version = parsed.version || '1.0.0';
|
|
440
|
+
skill.author = parsed.author || 'Anonymous';
|
|
441
|
+
// Extract category from path
|
|
442
|
+
const pathParts = skillPath.split(path.sep);
|
|
443
|
+
const skillsIndex = pathParts.findIndex(p => p === 'skills');
|
|
444
|
+
if (skillsIndex >= 0 && pathParts.length > skillsIndex + 1) {
|
|
445
|
+
skill.category = pathParts[skillsIndex + 1];
|
|
446
|
+
}
|
|
447
|
+
skill.markdown = content; // Now we have the full content
|
|
448
|
+
this.skillContentCache.set(skillId, content);
|
|
449
|
+
}
|
|
450
|
+
catch (error) {
|
|
451
|
+
console.warn(`[SkillInvoker] Failed to load metadata for skill ${skillId}:`, error);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Get list of all available skills (with metadata)
|
|
408
456
|
*/
|
|
409
457
|
async listAvailableSkills() {
|
|
410
458
|
await this.initialize();
|
|
411
|
-
|
|
459
|
+
// Load metadata for all skills if not already loaded
|
|
460
|
+
for (const skillId of this.skillCache.keys()) {
|
|
461
|
+
await this.loadSkillMetadata(skillId);
|
|
462
|
+
}
|
|
463
|
+
return Array.from(this.skillCache.values());
|
|
412
464
|
}
|
|
413
465
|
/**
|
|
414
466
|
* Match the most relevant skill based on user input
|
|
467
|
+
* NOTE: SKILL_TRIGGERS disabled. Let LLM decide based on system prompt.
|
|
468
|
+
* Returns null to indicate no explicit match - LLM should use its own judgment.
|
|
415
469
|
*/
|
|
416
470
|
async matchSkill(userInput) {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
// First check predefined trigger keywords
|
|
421
|
-
for (const trigger of Object.values(SKILL_TRIGGERS)) {
|
|
422
|
-
const matchedKeywords = trigger.keywords.filter(kw => lowerInput.includes(kw.toLowerCase()));
|
|
423
|
-
if (matchedKeywords.length > 0) {
|
|
424
|
-
const confidence = matchedKeywords.length / trigger.keywords.length;
|
|
425
|
-
const skill = this.skillCache.get(trigger.skillId);
|
|
426
|
-
if (skill) {
|
|
427
|
-
const result = {
|
|
428
|
-
skill,
|
|
429
|
-
confidence,
|
|
430
|
-
matchedKeywords,
|
|
431
|
-
category: trigger.category
|
|
432
|
-
};
|
|
433
|
-
if (!bestMatch || confidence > bestMatch.confidence) {
|
|
434
|
-
bestMatch = result;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
return bestMatch;
|
|
471
|
+
// SKILL_TRIGGERS is disabled for experiment purposes.
|
|
472
|
+
// The LLM should decide which skill to use based on system prompt information.
|
|
473
|
+
return null;
|
|
440
474
|
}
|
|
441
475
|
/**
|
|
442
476
|
* Get skill details
|
|
@@ -449,6 +483,10 @@ export class SkillInvoker {
|
|
|
449
483
|
* Execute skill
|
|
450
484
|
*/
|
|
451
485
|
async executeSkill(params) {
|
|
486
|
+
// Ensure initialized
|
|
487
|
+
await this.initialize();
|
|
488
|
+
// Load skill metadata if not already loaded
|
|
489
|
+
await this.loadSkillMetadata(params.skillId);
|
|
452
490
|
const skill = this.skillCache.get(params.skillId);
|
|
453
491
|
if (!skill) {
|
|
454
492
|
return {
|
|
@@ -513,66 +551,81 @@ export class SkillInvoker {
|
|
|
513
551
|
}
|
|
514
552
|
/**
|
|
515
553
|
* Get executor for skill
|
|
516
|
-
*
|
|
554
|
+
* Unified dynamic approach - all skills use GenericSkillExecutor
|
|
517
555
|
*/
|
|
518
556
|
getSkillExecutor(skillId) {
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
557
|
+
return new GenericSkillExecutor();
|
|
558
|
+
}
|
|
559
|
+
// ============================================================================
|
|
560
|
+
// Remote Mode Tool Support Methods
|
|
561
|
+
// ============================================================================
|
|
562
|
+
/**
|
|
563
|
+
* Check if it's a Skill tool
|
|
564
|
+
* Used for remote mode tool execution
|
|
565
|
+
*/
|
|
566
|
+
isSkillTool(toolName) {
|
|
567
|
+
// Check if it's a skill ID in cache
|
|
568
|
+
return this.skillCache.has(toolName);
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Get all Skill definitions (for syncing to remote server)
|
|
572
|
+
* NOTE: triggers field is empty since SKILL_TRIGGERS is disabled
|
|
573
|
+
*/
|
|
574
|
+
getAllSkillDefinitions() {
|
|
575
|
+
const definitions = [];
|
|
576
|
+
for (const skill of this.skillCache.values()) {
|
|
577
|
+
definitions.push({
|
|
578
|
+
id: skill.id,
|
|
579
|
+
name: skill.name,
|
|
580
|
+
description: skill.description,
|
|
581
|
+
category: skill.category,
|
|
582
|
+
triggers: [] // SKILL_TRIGGERS disabled - LLM decides based on description
|
|
583
|
+
});
|
|
525
584
|
}
|
|
526
|
-
|
|
527
|
-
|
|
585
|
+
return definitions;
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Execute Skill tool (for remote mode tool execution)
|
|
589
|
+
* @param toolName - Tool name (skillId)
|
|
590
|
+
* @param params - Tool parameters
|
|
591
|
+
* @returns Execution result
|
|
592
|
+
*/
|
|
593
|
+
async executeSkillTool(toolName, params) {
|
|
594
|
+
// Check if skill exists in cache
|
|
595
|
+
if (!this.skillCache.has(toolName)) {
|
|
596
|
+
return { success: false, error: `Skill not found: ${toolName}` };
|
|
528
597
|
}
|
|
529
|
-
|
|
530
|
-
|
|
598
|
+
try {
|
|
599
|
+
const result = await this.executeSkill({
|
|
600
|
+
skillId: toolName,
|
|
601
|
+
taskDescription: params.taskDescription || params.description || '',
|
|
602
|
+
inputFile: params.inputFile,
|
|
603
|
+
outputFile: params.outputFile,
|
|
604
|
+
options: params.options || {}
|
|
605
|
+
});
|
|
606
|
+
return { success: result.success, result };
|
|
531
607
|
}
|
|
532
|
-
|
|
533
|
-
return
|
|
608
|
+
catch (error) {
|
|
609
|
+
return { success: false, error: error.message };
|
|
534
610
|
}
|
|
535
|
-
return new DefaultSkillExecutor();
|
|
536
611
|
}
|
|
537
612
|
/**
|
|
538
|
-
*
|
|
613
|
+
* Get all available Skill ID list
|
|
614
|
+
* NOTE: SKILL_TRIGGERS disabled - return all skill IDs from cache
|
|
539
615
|
*/
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
for (const trigger of Object.values(SKILL_TRIGGERS)) {
|
|
543
|
-
const skill = this.skillCache.get(trigger.skillId);
|
|
544
|
-
if (skill) {
|
|
545
|
-
const existing = categories.get(trigger.category) || [];
|
|
546
|
-
existing.push({
|
|
547
|
-
skillId: trigger.skillId,
|
|
548
|
-
name: skill.name,
|
|
549
|
-
description: skill.description
|
|
550
|
-
});
|
|
551
|
-
categories.set(trigger.category, existing);
|
|
552
|
-
}
|
|
553
|
-
}
|
|
554
|
-
let instructions = '\n## Available Skills\n\n';
|
|
555
|
-
instructions += 'When users request tasks matching these domains, invoke the "InvokeSkill" tool:\n\n';
|
|
556
|
-
for (const [category, skills] of categories) {
|
|
557
|
-
instructions += `### ${category}\n`;
|
|
558
|
-
for (const skill of skills) {
|
|
559
|
-
instructions += `**${skill.name}** (${skill.skillId}): ${skill.description}\n`;
|
|
560
|
-
instructions += ` �?Use: InvokeSkill(skillId="${skill.skillId}", taskDescription="...")\n`;
|
|
561
|
-
}
|
|
562
|
-
instructions += '\n';
|
|
563
|
-
}
|
|
564
|
-
return instructions;
|
|
616
|
+
getAvailableSkillIds() {
|
|
617
|
+
return Array.from(this.skillCache.keys());
|
|
565
618
|
}
|
|
566
619
|
}
|
|
567
620
|
/**
|
|
568
|
-
*
|
|
621
|
+
* Generic Skill Executor - Unified dynamic approach for all skills
|
|
569
622
|
*/
|
|
570
|
-
class
|
|
623
|
+
class GenericSkillExecutor {
|
|
571
624
|
async execute(skill, params) {
|
|
572
625
|
const outputMessages = [];
|
|
573
626
|
const files = [];
|
|
574
627
|
const nextSteps = [];
|
|
575
|
-
outputMessages.push(`##
|
|
628
|
+
outputMessages.push(`## ${skill.name} Skill - Execution Guide\n`);
|
|
576
629
|
outputMessages.push(`**Task**: ${params.taskDescription}\n`);
|
|
577
630
|
try {
|
|
578
631
|
// Generate task ID
|
|
@@ -607,1016 +660,89 @@ class DocumentSkillExecutor {
|
|
|
607
660
|
}
|
|
608
661
|
}
|
|
609
662
|
/**
|
|
610
|
-
* Extract relevant skill content
|
|
663
|
+
* Extract relevant skill content dynamically
|
|
611
664
|
*/
|
|
612
665
|
async extractRelevantContent(skill, params, fullContent, nextSteps, taskId) {
|
|
613
|
-
const taskLower = params.taskDescription.toLowerCase();
|
|
614
666
|
const workspaceBase = getWorkspaceDescription();
|
|
615
667
|
const taskWorkspace = `${workspaceBase}/${taskId}`;
|
|
616
|
-
//
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
case 'canvas-design':
|
|
641
|
-
requiredFiles = ['skills/canvas-design/SKILL.md'];
|
|
642
|
-
break;
|
|
643
|
-
case 'algorithmic-art':
|
|
644
|
-
requiredFiles = ['skills/algorithmic-art/SKILL.md', 'skills/algorithmic-art/templates/generator_template.js'];
|
|
645
|
-
break;
|
|
646
|
-
case 'theme-factory':
|
|
647
|
-
requiredFiles = ['skills/theme-factory/SKILL.md', 'skills/theme-factory/themes/'];
|
|
648
|
-
break;
|
|
649
|
-
case 'brand-guidelines':
|
|
650
|
-
requiredFiles = ['skills/brand-guidelines/SKILL.md'];
|
|
651
|
-
break;
|
|
652
|
-
case 'internal-comms':
|
|
653
|
-
requiredFiles = ['skills/internal-comms/SKILL.md', 'skills/internal-comms/examples/'];
|
|
654
|
-
break;
|
|
655
|
-
case 'doc-coauthoring':
|
|
656
|
-
requiredFiles = ['skills/doc-coauthoring/SKILL.md'];
|
|
657
|
-
break;
|
|
658
|
-
case 'mcp-builder':
|
|
659
|
-
requiredFiles = ['skills/mcp-builder/SKILL.md', 'skills/mcp-builder/reference/'];
|
|
660
|
-
break;
|
|
661
|
-
case 'skill-creator':
|
|
662
|
-
requiredFiles = ['skills/skill-creator/SKILL.md'];
|
|
663
|
-
break;
|
|
664
|
-
case 'slack-gif-creator':
|
|
665
|
-
requiredFiles = ['skills/slack-gif-creator/SKILL.md', 'skills/slack-gif-creator/core/'];
|
|
666
|
-
break;
|
|
667
|
-
default:
|
|
668
|
-
requiredFiles = [`skills/${skill.id}/SKILL.md`];
|
|
668
|
+
// Dynamically discover files in skill directory
|
|
669
|
+
const skillPath = skill.skillsPath;
|
|
670
|
+
let allFiles = [];
|
|
671
|
+
try {
|
|
672
|
+
const entries = await fs.readdir(skillPath, { withFileTypes: true });
|
|
673
|
+
for (const entry of entries) {
|
|
674
|
+
const fullPath = path.join(skillPath, entry.name);
|
|
675
|
+
if (entry.isFile()) {
|
|
676
|
+
allFiles.push(fullPath);
|
|
677
|
+
}
|
|
678
|
+
else if (entry.isDirectory()) {
|
|
679
|
+
// Recursively list files in subdirectories (limited depth)
|
|
680
|
+
const subEntries = await fs.readdir(fullPath, { withFileTypes: true });
|
|
681
|
+
for (const subEntry of subEntries) {
|
|
682
|
+
if (subEntry.isFile()) {
|
|
683
|
+
allFiles.push(path.join(fullPath, subEntry.name));
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
catch {
|
|
690
|
+
// Fallback to just SKILL.md if directory can't be read
|
|
691
|
+
allFiles = [path.join(skillPath, 'SKILL.md')];
|
|
669
692
|
}
|
|
693
|
+
// Step 1: Read SKILL.md first
|
|
694
|
+
const skillMdPathOnly = path.join(skillPath, 'SKILL.md');
|
|
670
695
|
nextSteps.push({
|
|
671
696
|
step: 1,
|
|
672
|
-
action: 'Read skill
|
|
673
|
-
description: `Read: ${
|
|
674
|
-
reason: 'Understand the skill workflow and best practices'
|
|
697
|
+
action: 'Read SKILL.md to understand the skill workflow',
|
|
698
|
+
description: `Read: ${skillMdPathOnly}`,
|
|
699
|
+
reason: 'Understand the skill workflow and best practices from the main documentation'
|
|
675
700
|
});
|
|
701
|
+
// Step 2: Explore skill directory and read reference files if needed (optional)
|
|
676
702
|
nextSteps.push({
|
|
677
703
|
step: 2,
|
|
678
|
-
action: '
|
|
679
|
-
description: `
|
|
680
|
-
reason: '
|
|
704
|
+
action: 'Explore skill directory and read reference files (if needed)',
|
|
705
|
+
description: `Explore: ${skillPath}`,
|
|
706
|
+
reason: 'Discover available reference files and read them based on SKILL.md guidance'
|
|
681
707
|
});
|
|
682
708
|
nextSteps.push({
|
|
683
709
|
step: 3,
|
|
710
|
+
action: 'Analyze documentation, verify data/content completeness, and design approach',
|
|
711
|
+
description: `For content creation: ensure all info/materials collected. For info retrieval: ensure all required data retrieved. Then design execution plan for: ${taskWorkspace}`,
|
|
712
|
+
reason: 'Review requirements, verify data/content completeness, fill gaps if needed, then plan execution based on the documentation'
|
|
713
|
+
});
|
|
714
|
+
nextSteps.push({
|
|
715
|
+
step: 4,
|
|
684
716
|
action: 'Execute your plan',
|
|
685
717
|
description: 'Create workspace, write code, run scripts, verify output',
|
|
686
718
|
reason: 'Execute the task using your own understanding'
|
|
687
719
|
});
|
|
688
720
|
return `### Skill Execution\n\n` +
|
|
689
721
|
`**Your task**: ${params.taskDescription}\n\n` +
|
|
690
|
-
`**Read
|
|
691
|
-
|
|
722
|
+
`**Step 1**: Read SKILL.md to understand the skill workflow\n` +
|
|
723
|
+
` - read_file: ${skillMdPathOnly}\n\n` +
|
|
724
|
+
`**Step 2**: Explore skill directory and read reference files (if needed)\n` +
|
|
725
|
+
` - ListDirectory(path="${skillPath}")\n` +
|
|
726
|
+
` - read_file relevant .md and script files as needed\n\n` +
|
|
692
727
|
`Then analyze the documentation and create your own execution plan.\n\n` +
|
|
693
728
|
`**Workspace**: \`${taskWorkspace}\`\n\n` +
|
|
694
729
|
`**⚠️ Windows Path Execution**: Use absolute paths, NOT \`cd && command\`:\n` +
|
|
695
730
|
` - ✅ Correct: \`node "${taskWorkspace}/script.js"\`\n` +
|
|
696
731
|
` - ❌ Wrong: \`cd "${taskWorkspace}" && node script.js\` (fails in PowerShell 5.1)\n` +
|
|
697
732
|
` - ✅ Correct: \`python "${taskWorkspace}/script.py"\`\n\n` +
|
|
698
|
-
`**📦 Dependency
|
|
699
|
-
` -
|
|
700
|
-
` -
|
|
701
|
-
` -
|
|
702
|
-
` -
|
|
733
|
+
`**📦 Dependency Management**:\n` +
|
|
734
|
+
` - BashTool automatically sets NODE_PATH when executing, scripts can use require() directly\n` +
|
|
735
|
+
` - ✅ Correct: Bash(command="node script.js", cwd="${taskWorkspace}")\n` +
|
|
736
|
+
` - ❌ Wrong: cd "${taskWorkspace}" && node script.js (loses NODE_PATH!)\n` +
|
|
737
|
+
` - If script needs to run by user manually, pass NODE_PATH in command:\n` +
|
|
738
|
+
` Windows: set NODE_PATH=xAgent/node_modules/path && node script.js\n` +
|
|
739
|
+
` Linux/Mac: NODE_PATH=xAgent/node_modules/path node script.js\n\n` +
|
|
703
740
|
`**🧹 Cleanup**: Delete all intermediate/temporary files when task completes:\n` +
|
|
704
741
|
` - Remove: all files generated during the task\n` +
|
|
705
742
|
` - Keep: Only the final output file (output.pptx/docx/xlsx/pdf)\n\n` +
|
|
706
743
|
`**Instructions**: read_file the documentation, understand the API, and create your own execution plan.\n` +
|
|
707
744
|
`**If you encounter issues**: Explain what went wrong and suggest a different approach.\n`;
|
|
708
745
|
}
|
|
709
|
-
/**
|
|
710
|
-
* Extract PPTX-related content and generate steps
|
|
711
|
-
*/
|
|
712
|
-
extractPptxContent(taskLower, fullContent, nextSteps, skillPath, taskWorkspace) {
|
|
713
|
-
const content = fullContent.replace(/^---\n[\s\S]*?\n---/, '').trim();
|
|
714
|
-
const html2pptxPath = `${skillPath}/scripts/html2pptx.js`;
|
|
715
|
-
const scriptsPath = `${skillPath}/scripts`;
|
|
716
|
-
// Check if using template
|
|
717
|
-
const useTemplate = taskLower.includes('template') || taskLower.includes('template');
|
|
718
|
-
if (useTemplate) {
|
|
719
|
-
// Add template usage steps
|
|
720
|
-
nextSteps.push({
|
|
721
|
-
step: 1,
|
|
722
|
-
action: 'Read documentation and script',
|
|
723
|
-
description: `Read pptx/html2pptx.md and ${html2pptxPath} - CRITICAL: Read the USAGE section at the top of html2pptx.js to understand the correct API: const { slide, placeholders } = await html2pptx('slide.html', pptx);`,
|
|
724
|
-
file: html2pptxPath,
|
|
725
|
-
reason: 'Understand html2pptx API - MUST read the usage example in the file header'
|
|
726
|
-
});
|
|
727
|
-
nextSteps.push({
|
|
728
|
-
step: 2,
|
|
729
|
-
action: 'Create workspace directory',
|
|
730
|
-
description: `Create directory: ${taskWorkspace}`,
|
|
731
|
-
reason: 'Create workspace directory for this task'
|
|
732
|
-
});
|
|
733
|
-
nextSteps.push({
|
|
734
|
-
step: 3,
|
|
735
|
-
action: 'Create HTML slide file in workspace',
|
|
736
|
-
description: `Create slide.html inside ${taskWorkspace}/ (720pt × 405pt for 16:9)`,
|
|
737
|
-
reason: 'Create slide HTML file in workspace to avoid polluting target directory'
|
|
738
|
-
});
|
|
739
|
-
nextSteps.push({
|
|
740
|
-
step: 4,
|
|
741
|
-
action: 'Create PPTX conversion script in workspace',
|
|
742
|
-
description: `Create convert.js inside ${taskWorkspace}/ using CommonJS: const { slide, placeholders } = await html2pptx('slide.html', pptx); // slide is already added, use slide.addChart()/addText() for content`,
|
|
743
|
-
reason: 'Write Node.js script - MUST use destructured { slide, placeholders } from html2pptx()'
|
|
744
|
-
});
|
|
745
|
-
nextSteps.push({
|
|
746
|
-
step: 5,
|
|
747
|
-
action: 'Run the script',
|
|
748
|
-
description: `node "${taskWorkspace.replace(/\\/g, '/')}/convert.js"`,
|
|
749
|
-
reason: 'Generate PPTX file using html2pptx (use absolute path for Windows compatibility)'
|
|
750
|
-
});
|
|
751
|
-
nextSteps.push({
|
|
752
|
-
step: 6,
|
|
753
|
-
action: 'Generate thumbnail grid for visual validation',
|
|
754
|
-
description: `Run: python "${scriptsPath}/thumbnail.py" ${taskWorkspace}/output.pptx ${taskWorkspace}/thumbnails --cols 4`,
|
|
755
|
-
reason: 'Create thumbnail grid to verify slide layout and visual quality'
|
|
756
|
-
});
|
|
757
|
-
nextSteps.push({
|
|
758
|
-
step: 7,
|
|
759
|
-
action: 'Copy output to target directory',
|
|
760
|
-
description: `Copy ${taskWorkspace}/output.pptx to target directory`,
|
|
761
|
-
reason: 'Only save final file to specified path, keep workspace clean'
|
|
762
|
-
});
|
|
763
|
-
const patterns = [
|
|
764
|
-
/##\s*Creating\s*a\s*new\s*PowerPoint\s*presentation\s*\*\*using\s*a\s*template\*\*[\s\S]*?(?=##\s+)/i,
|
|
765
|
-
/##\s*Using\s*a\s*template[\s\S]*?(?=##\s+)/i
|
|
766
|
-
];
|
|
767
|
-
for (const pattern of patterns) {
|
|
768
|
-
const match = content.match(pattern);
|
|
769
|
-
if (match) {
|
|
770
|
-
return `### Using a Template\n\n${match[0].trim()}`;
|
|
771
|
-
}
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
// Not using template
|
|
775
|
-
nextSteps.push({
|
|
776
|
-
step: 1,
|
|
777
|
-
action: 'Read documentation and script',
|
|
778
|
-
description: `Read pptx/html2pptx.md and ${html2pptxPath} - CRITICAL: Read the USAGE section at the top of html2pptx.js to understand the correct API: const { slide, placeholders } = await html2pptx('slide.html', pptx);`,
|
|
779
|
-
file: html2pptxPath,
|
|
780
|
-
reason: 'Understand html2pptx API - MUST read the usage example in the file header'
|
|
781
|
-
});
|
|
782
|
-
nextSteps.push({
|
|
783
|
-
step: 2,
|
|
784
|
-
action: 'Create workspace directory',
|
|
785
|
-
description: `Create directory: ${taskWorkspace}`,
|
|
786
|
-
reason: 'Create workspace directory for this task'
|
|
787
|
-
});
|
|
788
|
-
nextSteps.push({
|
|
789
|
-
step: 3,
|
|
790
|
-
action: 'Create HTML slide file in workspace',
|
|
791
|
-
description: `Create slide.html inside ${taskWorkspace}/ (720pt × 405pt for 16:9)`,
|
|
792
|
-
reason: 'Create slide HTML file in workspace to avoid polluting target directory'
|
|
793
|
-
});
|
|
794
|
-
nextSteps.push({
|
|
795
|
-
step: 4,
|
|
796
|
-
action: 'Create PPTX conversion script in workspace',
|
|
797
|
-
description: `Create convert.js inside ${taskWorkspace}/ using CommonJS: const { slide, placeholders } = await html2pptx('slide.html', pptx); // slide is already added, use slide.addChart()/addText() for content`,
|
|
798
|
-
reason: 'Write Node.js script - MUST use destructured { slide, placeholders } from html2pptx()'
|
|
799
|
-
});
|
|
800
|
-
nextSteps.push({
|
|
801
|
-
step: 5,
|
|
802
|
-
action: 'Run the script',
|
|
803
|
-
description: `node "${taskWorkspace.replace(/\\/g, '/')}/convert.js"`,
|
|
804
|
-
reason: 'Generate PPTX file using html2pptx (use absolute path for Windows compatibility)'
|
|
805
|
-
});
|
|
806
|
-
nextSteps.push({
|
|
807
|
-
step: 6,
|
|
808
|
-
action: 'Generate thumbnail grid for visual validation',
|
|
809
|
-
description: `Run: python "${scriptsPath}/thumbnail.py" ${taskWorkspace}/output.pptx ${taskWorkspace}/thumbnails --cols 4`,
|
|
810
|
-
reason: 'Create thumbnail grid to verify slide layout and visual quality'
|
|
811
|
-
});
|
|
812
|
-
nextSteps.push({
|
|
813
|
-
step: 7,
|
|
814
|
-
action: 'Copy output to target directory',
|
|
815
|
-
description: `Copy ${taskWorkspace}/output.pptx to target directory`,
|
|
816
|
-
reason: 'Only save final file to specified path, keep workspace clean'
|
|
817
|
-
});
|
|
818
|
-
const patterns = [
|
|
819
|
-
/##\s*Creating\s*a\s*new\s*PowerPoint[\s\S]*?(?=##\s+)/i,
|
|
820
|
-
/###\s*Workflow[\s\S]*?(?=###\s+|$)/i
|
|
821
|
-
];
|
|
822
|
-
for (const pattern of patterns) {
|
|
823
|
-
const match = content.match(pattern);
|
|
824
|
-
if (match) {
|
|
825
|
-
return `### Creating New Presentation\n\n${match[0].trim()}`;
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
return extractContent(content, ['html2pptx', 'Creating', 'Workflow']);
|
|
829
|
-
}
|
|
830
|
-
/**
|
|
831
|
-
* Extract DOCX-related content and generate steps
|
|
832
|
-
*/
|
|
833
|
-
extractDocxContent(taskLower, fullContent, nextSteps, params, skillPath, taskWorkspace) {
|
|
834
|
-
const content = fullContent.replace(/^---\n[\s\S]*?\n---/, '').trim();
|
|
835
|
-
const unpackScript = `${skillPath}/ooxml/scripts/unpack.py`;
|
|
836
|
-
const packScript = `${skillPath}/ooxml/scripts/pack.py`;
|
|
837
|
-
const scriptsPath = `${skillPath}/scripts`;
|
|
838
|
-
const isNew = taskLower.includes('create') || taskLower.includes('new');
|
|
839
|
-
const isEditing = taskLower.includes('edit') || taskLower.includes('modify') || taskLower.includes('modify');
|
|
840
|
-
if (isNew) {
|
|
841
|
-
// Create new document
|
|
842
|
-
nextSteps.push({
|
|
843
|
-
step: 1,
|
|
844
|
-
action: 'Read documentation',
|
|
845
|
-
description: 'Read docx-js.md for API reference',
|
|
846
|
-
file: `${skillPath}/docx-js.md`,
|
|
847
|
-
reason: 'Understand how to use docx-js library to create Word documents'
|
|
848
|
-
});
|
|
849
|
-
nextSteps.push({
|
|
850
|
-
step: 2,
|
|
851
|
-
action: 'Create script in workspace',
|
|
852
|
-
description: `Create create_doc.js in ${taskWorkspace}: const { Document, Paragraph, TextRun, Packer } = await import("docx");`,
|
|
853
|
-
reason: 'Create Word document code using docx library with dynamic import'
|
|
854
|
-
});
|
|
855
|
-
nextSteps.push({
|
|
856
|
-
step: 3,
|
|
857
|
-
action: 'Run the script',
|
|
858
|
-
description: `node "${taskWorkspace.replace(/\\/g, '/')}/create_doc.js"`,
|
|
859
|
-
reason: 'Generate DOCX file in workspace (use absolute path for Windows compatibility)'
|
|
860
|
-
});
|
|
861
|
-
nextSteps.push({ step: 4,
|
|
862
|
-
action: 'Copy output to target directory',
|
|
863
|
-
description: `Copy ${taskWorkspace}/output.docx to target directory`,
|
|
864
|
-
reason: 'Only save final file to specified path, keep workspace clean'
|
|
865
|
-
});
|
|
866
|
-
return extractContent(content, ['Creating', 'docx-js', 'Workflow']);
|
|
867
|
-
}
|
|
868
|
-
if (isEditing) {
|
|
869
|
-
// Edit existing document - use existing scripts
|
|
870
|
-
nextSteps.push({
|
|
871
|
-
step: 1,
|
|
872
|
-
action: 'Read documentation',
|
|
873
|
-
description: 'Read ooxml.md for editing API',
|
|
874
|
-
file: `${skillPath}/ooxml.md`,
|
|
875
|
-
reason: 'Understand how to edit existing Word documents'
|
|
876
|
-
});
|
|
877
|
-
nextSteps.push({
|
|
878
|
-
step: 2,
|
|
879
|
-
action: 'Create workspace directory',
|
|
880
|
-
description: `Create workspace directory: ${taskWorkspace}/`,
|
|
881
|
-
reason: 'Create workspace directory for intermediate files'
|
|
882
|
-
});
|
|
883
|
-
if (params.inputFile) {
|
|
884
|
-
nextSteps.push({
|
|
885
|
-
step: 3,
|
|
886
|
-
action: 'Unpack document in workspace',
|
|
887
|
-
description: `Run: python "${unpackScript}" "${params.inputFile}" ${taskWorkspace}/docx_input`,
|
|
888
|
-
reason: 'Unpack DOCX file using existing unpack.py script'
|
|
889
|
-
});
|
|
890
|
-
}
|
|
891
|
-
nextSteps.push({
|
|
892
|
-
step: 4,
|
|
893
|
-
action: 'Create editing script in workspace',
|
|
894
|
-
description: `Create edit_doc.py in ${taskWorkspace}: from scripts.document import Document; doc = Document("${taskWorkspace}/docx_input");`,
|
|
895
|
-
reason: 'Create Python editing script using existing Document library'
|
|
896
|
-
});
|
|
897
|
-
if (params.inputFile || params.outputFile) {
|
|
898
|
-
nextSteps.push({
|
|
899
|
-
step: 5,
|
|
900
|
-
action: 'Pack document',
|
|
901
|
-
description: `Run: python "${packScript}" ${taskWorkspace}/docx_input ${taskWorkspace}/output.docx`,
|
|
902
|
-
reason: 'Repack DOCX using existing pack.py script'
|
|
903
|
-
});
|
|
904
|
-
}
|
|
905
|
-
nextSteps.push({
|
|
906
|
-
step: 6,
|
|
907
|
-
action: 'Copy output to target directory',
|
|
908
|
-
description: `Copy ${taskWorkspace}/output.docx to target directory`,
|
|
909
|
-
reason: 'Only save final file to specified path'
|
|
910
|
-
});
|
|
911
|
-
return extractContent(content, ['Editing', 'redlining', 'ooxml']);
|
|
912
|
-
}
|
|
913
|
-
// Default case
|
|
914
|
-
nextSteps.push({
|
|
915
|
-
step: 1,
|
|
916
|
-
action: 'Read documentation',
|
|
917
|
-
description: 'Read ooxml.md or docx-js.md',
|
|
918
|
-
reason: 'Understand document processing methods'
|
|
919
|
-
});
|
|
920
|
-
nextSteps.push({
|
|
921
|
-
step: 2,
|
|
922
|
-
action: 'Create or edit document',
|
|
923
|
-
description: 'Write code using appropriate library',
|
|
924
|
-
reason: 'Perform document operations'
|
|
925
|
-
});
|
|
926
|
-
return extractContent(content, ['Creating', 'Editing', 'document', 'docx']);
|
|
927
|
-
}
|
|
928
|
-
/**
|
|
929
|
-
* Extract PDF-related content and generate steps
|
|
930
|
-
*/
|
|
931
|
-
extractPdfContent(taskLower, fullContent, nextSteps, params, skillPath, taskWorkspace) {
|
|
932
|
-
const content = fullContent.replace(/^---\n[\s\S]*?\n---/, '').trim();
|
|
933
|
-
const scriptsPath = `${skillPath}/scripts`;
|
|
934
|
-
const isForm = taskLower.includes('form') || taskLower.includes('form');
|
|
935
|
-
const isExtract = taskLower.includes('extract') || taskLower.includes('extract');
|
|
936
|
-
const isMerge = taskLower.includes('merge') || taskLower.includes('merge');
|
|
937
|
-
const isConvert = taskLower.includes('convert') || taskLower.includes('image');
|
|
938
|
-
nextSteps.push({
|
|
939
|
-
step: 1,
|
|
940
|
-
action: 'Read documentation',
|
|
941
|
-
description: 'Read reference.md for PDF operations',
|
|
942
|
-
file: `${skillPath}/reference.md`,
|
|
943
|
-
reason: 'Understand PDF operation methods'
|
|
944
|
-
});
|
|
945
|
-
nextSteps.push({
|
|
946
|
-
step: 2,
|
|
947
|
-
action: 'Create workspace directory',
|
|
948
|
-
description: `Create workspace directory: ${taskWorkspace}/`,
|
|
949
|
-
reason: 'Create workspace directory for intermediate files'
|
|
950
|
-
});
|
|
951
|
-
if (isForm) {
|
|
952
|
-
// Check for fillable fields first
|
|
953
|
-
nextSteps.push({
|
|
954
|
-
step: 3,
|
|
955
|
-
action: 'Check form fields',
|
|
956
|
-
description: `Run: python "${scriptsPath}/check_fillable_fields.py" <input_pdf>`,
|
|
957
|
-
reason: 'Check if PDF has fillable form fields'
|
|
958
|
-
});
|
|
959
|
-
nextSteps.push({
|
|
960
|
-
step: 4,
|
|
961
|
-
action: 'Create PDF form script in workspace',
|
|
962
|
-
description: `Create form_script.py in ${taskWorkspace}: use "${scriptsPath}/fill_fillable_fields.py" or "${scriptsPath}/fill_pdf_form_with_annotations.py"`,
|
|
963
|
-
reason: 'Create PDF form processing script using existing scripts'
|
|
964
|
-
});
|
|
965
|
-
}
|
|
966
|
-
else if (isExtract) {
|
|
967
|
-
nextSteps.push({
|
|
968
|
-
step: 3,
|
|
969
|
-
action: 'Create extraction script in workspace',
|
|
970
|
-
description: `Create extract_script.py in ${taskWorkspace}: use pypdf or pdfplumber for text extraction`,
|
|
971
|
-
reason: 'Create PDF content extraction script'
|
|
972
|
-
});
|
|
973
|
-
}
|
|
974
|
-
else if (isMerge) {
|
|
975
|
-
nextSteps.push({
|
|
976
|
-
step: 3,
|
|
977
|
-
action: 'Create merge script in workspace',
|
|
978
|
-
description: `Create merge_script.py in ${taskWorkspace}: use pypdf to combine PDF files`,
|
|
979
|
-
reason: 'Create PDF merge script'
|
|
980
|
-
});
|
|
981
|
-
}
|
|
982
|
-
else if (isConvert) {
|
|
983
|
-
nextSteps.push({
|
|
984
|
-
step: 3,
|
|
985
|
-
action: 'Convert PDF to images',
|
|
986
|
-
description: `Run: python "${scriptsPath}/convert_pdf_to_images.py" <input_pdf> ${taskWorkspace}/images`,
|
|
987
|
-
reason: 'Convert PDF to images using existing script'
|
|
988
|
-
});
|
|
989
|
-
}
|
|
990
|
-
else {
|
|
991
|
-
nextSteps.push({
|
|
992
|
-
step: 3,
|
|
993
|
-
action: 'Create PDF processing script in workspace',
|
|
994
|
-
description: `Create pdf_script.py in ${taskWorkspace}: use pypdf for desired operations`,
|
|
995
|
-
reason: 'Create PDF processing script'
|
|
996
|
-
});
|
|
997
|
-
}
|
|
998
|
-
nextSteps.push({
|
|
999
|
-
step: 5,
|
|
1000
|
-
action: 'Run the script',
|
|
1001
|
-
description: `python "${taskWorkspace.replace(/\\/g, '/')}/pdf_script.py"`,
|
|
1002
|
-
reason: 'Execute PDF operation script in workspace (use absolute path for Windows compatibility)'
|
|
1003
|
-
});
|
|
1004
|
-
nextSteps.push({
|
|
1005
|
-
step: 6,
|
|
1006
|
-
action: 'Copy output to target directory',
|
|
1007
|
-
description: `Copy ${taskWorkspace}/output.pdf to target directory`,
|
|
1008
|
-
reason: 'Only save final file to specified path'
|
|
1009
|
-
});
|
|
1010
|
-
return extractContent(content, ['Creating', 'pdf', 'PDF']);
|
|
1011
|
-
}
|
|
1012
|
-
/**
|
|
1013
|
-
* Extract XLSX relevant content and generate steps
|
|
1014
|
-
*/
|
|
1015
|
-
extractXlsxContent(taskLower, fullContent, nextSteps, skillPath, taskWorkspace) {
|
|
1016
|
-
const content = fullContent.replace(/^---\n[\s\S]*?\n---/, '').trim();
|
|
1017
|
-
const hasFormulas = taskLower.includes('formula') || taskLower.includes('公式');
|
|
1018
|
-
const hasData = taskLower.includes('data') || taskLower.includes('数据分析');
|
|
1019
|
-
nextSteps.push({
|
|
1020
|
-
step: 1,
|
|
1021
|
-
action: 'Read documentation',
|
|
1022
|
-
description: 'Read SKILL.md for Excel operations',
|
|
1023
|
-
file: `${skillPath}/SKILL.md`,
|
|
1024
|
-
reason: 'Understand Excel operation methods'
|
|
1025
|
-
});
|
|
1026
|
-
nextSteps.push({
|
|
1027
|
-
step: 2,
|
|
1028
|
-
action: 'Create workspace directory',
|
|
1029
|
-
description: `Create workspace directory: ${taskWorkspace}/`,
|
|
1030
|
-
reason: 'Create workspace directory for intermediate files'
|
|
1031
|
-
});
|
|
1032
|
-
if (hasFormulas || hasData) {
|
|
1033
|
-
nextSteps.push({
|
|
1034
|
-
step: 3,
|
|
1035
|
-
action: 'Create spreadsheet script in workspace',
|
|
1036
|
-
description: `Create create_xlsx.py in ${taskWorkspace}: use openpyxl to create workbook with formulas`,
|
|
1037
|
-
reason: 'Create spreadsheet script with formulas in workspace'
|
|
1038
|
-
});
|
|
1039
|
-
}
|
|
1040
|
-
else {
|
|
1041
|
-
nextSteps.push({
|
|
1042
|
-
step: 3,
|
|
1043
|
-
action: 'Create spreadsheet script in workspace',
|
|
1044
|
-
description: `Create create_xlsx.py in ${taskWorkspace}: use openpyxl to create workbook`,
|
|
1045
|
-
reason: 'Create spreadsheet script in workspace'
|
|
1046
|
-
});
|
|
1047
|
-
}
|
|
1048
|
-
nextSteps.push({
|
|
1049
|
-
step: 4,
|
|
1050
|
-
action: 'Run the script',
|
|
1051
|
-
description: `python "${taskWorkspace.replace(/\\/g, '/')}/create_xlsx.py"`,
|
|
1052
|
-
reason: 'Generate XLSX file in workspace (use absolute path for Windows compatibility)'
|
|
1053
|
-
});
|
|
1054
|
-
if (hasFormulas) {
|
|
1055
|
-
nextSteps.push({
|
|
1056
|
-
step: 5,
|
|
1057
|
-
action: 'Recalculate formulas',
|
|
1058
|
-
description: `Run: python "${skillPath}/recalc.py" ${taskWorkspace}/output.xlsx to recalculate all formulas and check for errors`,
|
|
1059
|
-
reason: 'Recalculate formulas and verify no formula errors (#REF!, #DIV/0!, etc.)'
|
|
1060
|
-
});
|
|
1061
|
-
nextSteps.push({
|
|
1062
|
-
step: 6,
|
|
1063
|
-
action: 'Fix formula errors if any',
|
|
1064
|
-
description: `Check recalc.py output JSON for error locations and fix formula errors in ${taskWorkspace}`,
|
|
1065
|
-
reason: 'Ensure ZERO formula errors before final output'
|
|
1066
|
-
});
|
|
1067
|
-
nextSteps.push({
|
|
1068
|
-
step: 7,
|
|
1069
|
-
action: 'Copy output to target directory',
|
|
1070
|
-
description: `Copy ${taskWorkspace}/output.xlsx to target directory`,
|
|
1071
|
-
reason: 'Only save final file to specified path'
|
|
1072
|
-
});
|
|
1073
|
-
}
|
|
1074
|
-
else {
|
|
1075
|
-
nextSteps.push({
|
|
1076
|
-
step: 5,
|
|
1077
|
-
action: 'Copy output to target directory',
|
|
1078
|
-
description: `Copy ${taskWorkspace}/output.xlsx to target directory`,
|
|
1079
|
-
reason: 'Only save final file to specified path'
|
|
1080
|
-
});
|
|
1081
|
-
}
|
|
1082
|
-
return extractContent(content, ['Excel', 'xlsx', 'spreadsheet']);
|
|
1083
|
-
}
|
|
1084
|
-
/**
|
|
1085
|
-
* Extract default content
|
|
1086
|
-
*/
|
|
1087
|
-
extractDefaultContent(skill, fullContent, nextSteps) {
|
|
1088
|
-
const content = fullContent.replace(/^---\n[\s\S]*?\n---/, '').trim();
|
|
1089
|
-
const firstLines = content.split('\n').slice(0, 100).join('\n');
|
|
1090
|
-
nextSteps.push({
|
|
1091
|
-
step: 1,
|
|
1092
|
-
action: 'Read SKILL.md',
|
|
1093
|
-
description: `Read ${skill.id}/SKILL.md for full instructions`,
|
|
1094
|
-
file: `${skill.skillsPath}/SKILL.md`,
|
|
1095
|
-
reason: 'Understand complete execution workflow'
|
|
1096
|
-
});
|
|
1097
|
-
return `### ${skill.name}\n\n${firstLines}\n\n(See ${skill.skillsPath}/SKILL.md for full instructions)`;
|
|
1098
|
-
}
|
|
1099
|
-
}
|
|
1100
|
-
/**
|
|
1101
|
-
* Frontend Development Skill Executor
|
|
1102
|
-
*/
|
|
1103
|
-
class FrontendSkillExecutor {
|
|
1104
|
-
async execute(skill, params) {
|
|
1105
|
-
const outputMessages = [];
|
|
1106
|
-
const files = [];
|
|
1107
|
-
const nextSteps = [];
|
|
1108
|
-
outputMessages.push(`## ${skill.name} Skill - Execution Guide\n`);
|
|
1109
|
-
outputMessages.push(`**Task**: ${params.taskDescription}\n`);
|
|
1110
|
-
// Get or generate task ID
|
|
1111
|
-
const taskId = params.taskId || `${skill.id}-${Date.now()}`;
|
|
1112
|
-
try {
|
|
1113
|
-
// Read SKILL.md content
|
|
1114
|
-
const skillMdPath = path.join(skill.skillsPath, 'SKILL.md');
|
|
1115
|
-
files.push(skillMdPath);
|
|
1116
|
-
const skillContent = await fs.readFile(skillMdPath, 'utf-8');
|
|
1117
|
-
// Generate execution steps
|
|
1118
|
-
const taskContent = await this.extractFrontendContent(skill, params, skillContent, nextSteps, taskId);
|
|
1119
|
-
outputMessages.push(taskContent);
|
|
1120
|
-
// Add input/output files to list if they exist
|
|
1121
|
-
if (params.inputFile)
|
|
1122
|
-
files.push(params.inputFile);
|
|
1123
|
-
if (params.outputFile)
|
|
1124
|
-
files.push(params.outputFile);
|
|
1125
|
-
return {
|
|
1126
|
-
success: true,
|
|
1127
|
-
output: outputMessages.join('\n'),
|
|
1128
|
-
files: files,
|
|
1129
|
-
nextSteps: nextSteps,
|
|
1130
|
-
requiresManualExecution: true
|
|
1131
|
-
};
|
|
1132
|
-
}
|
|
1133
|
-
catch (error) {
|
|
1134
|
-
return {
|
|
1135
|
-
success: false,
|
|
1136
|
-
error: error.message
|
|
1137
|
-
};
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
/**
|
|
1141
|
-
* Extract relevant content based on frontend skill type and generate steps
|
|
1142
|
-
*/
|
|
1143
|
-
async extractFrontendContent(skill, params, fullContent, nextSteps, taskId) {
|
|
1144
|
-
const taskLower = params.taskDescription.toLowerCase();
|
|
1145
|
-
const workspaceBase = getWorkspaceDescription();
|
|
1146
|
-
const taskWorkspace = `${workspaceBase}/${taskId}`;
|
|
1147
|
-
// Add common steps
|
|
1148
|
-
nextSteps.push({
|
|
1149
|
-
step: 1,
|
|
1150
|
-
action: 'Design Thinking',
|
|
1151
|
-
description: 'Understand requirements, define aesthetic direction',
|
|
1152
|
-
reason: 'Clarify design direction and goals'
|
|
1153
|
-
});
|
|
1154
|
-
nextSteps.push({
|
|
1155
|
-
step: 2,
|
|
1156
|
-
action: 'Create implementation',
|
|
1157
|
-
description: 'Write production-grade HTML/CSS/JS or React code',
|
|
1158
|
-
reason: 'Implement frontend interface'
|
|
1159
|
-
});
|
|
1160
|
-
switch (skill.id) {
|
|
1161
|
-
case 'frontend-design':
|
|
1162
|
-
nextSteps.push({
|
|
1163
|
-
step: 3,
|
|
1164
|
-
action: 'Create workspace directory',
|
|
1165
|
-
description: `Create workspace directory: ${taskWorkspace}/`,
|
|
1166
|
-
reason: 'Create workspace directory for frontend files'
|
|
1167
|
-
});
|
|
1168
|
-
nextSteps.push({
|
|
1169
|
-
step: 4,
|
|
1170
|
-
action: 'Create frontend files in workspace',
|
|
1171
|
-
description: `Create index.html, styles.css, app.js in ${taskWorkspace}`,
|
|
1172
|
-
reason: 'Create frontend files in workspace'
|
|
1173
|
-
});
|
|
1174
|
-
if (taskLower.includes('landing')) {
|
|
1175
|
-
nextSteps.push({
|
|
1176
|
-
step: 5,
|
|
1177
|
-
action: 'Focus areas',
|
|
1178
|
-
description: 'Hero section, features, pricing, testimonials, footer',
|
|
1179
|
-
reason: 'Implement landing page sections'
|
|
1180
|
-
});
|
|
1181
|
-
}
|
|
1182
|
-
else if (taskLower.includes('dashboard')) {
|
|
1183
|
-
nextSteps.push({
|
|
1184
|
-
step: 5,
|
|
1185
|
-
action: 'Focus areas',
|
|
1186
|
-
description: 'Charts, data visualization, navigation panels',
|
|
1187
|
-
reason: 'Implement dashboard functionality'
|
|
1188
|
-
});
|
|
1189
|
-
}
|
|
1190
|
-
nextSteps.push({
|
|
1191
|
-
step: 6,
|
|
1192
|
-
action: 'Verify in browser',
|
|
1193
|
-
description: `Open files in ${taskWorkspace} to verify`,
|
|
1194
|
-
reason: 'Verify in browser'
|
|
1195
|
-
});
|
|
1196
|
-
nextSteps.push({
|
|
1197
|
-
step: 7,
|
|
1198
|
-
action: 'Copy files to target directory',
|
|
1199
|
-
description: `Copy frontend files from ${taskWorkspace} to target directory`,
|
|
1200
|
-
reason: 'Only save final files to specified path'
|
|
1201
|
-
});
|
|
1202
|
-
return extractContent(fullContent, ['frontend', 'design', 'web', 'interface']);
|
|
1203
|
-
case 'web-artifacts-builder':
|
|
1204
|
-
nextSteps.push({
|
|
1205
|
-
step: 3,
|
|
1206
|
-
action: 'Create workspace directory',
|
|
1207
|
-
description: `Create workspace directory: ${taskWorkspace}/`,
|
|
1208
|
-
reason: 'Create workspace directory for component files'
|
|
1209
|
-
});
|
|
1210
|
-
nextSteps.push({
|
|
1211
|
-
step: 4,
|
|
1212
|
-
action: 'Build React artifact in workspace',
|
|
1213
|
-
description: `Create React component files in ${taskWorkspace} using shadcn/ui`,
|
|
1214
|
-
reason: 'Build React component in workspace'
|
|
1215
|
-
});
|
|
1216
|
-
nextSteps.push({
|
|
1217
|
-
step: 5,
|
|
1218
|
-
action: 'Test artifact',
|
|
1219
|
-
description: `Test the artifact in ${taskWorkspace}`,
|
|
1220
|
-
reason: 'Test component functionality'
|
|
1221
|
-
});
|
|
1222
|
-
nextSteps.push({
|
|
1223
|
-
step: 6,
|
|
1224
|
-
action: 'Copy artifact to target directory',
|
|
1225
|
-
description: `Copy component files from ${taskWorkspace} to target directory`,
|
|
1226
|
-
reason: 'Only save final files to specified path'
|
|
1227
|
-
});
|
|
1228
|
-
return extractContent(fullContent, ['Web Artifacts Builder', 'React', 'Quick Start']);
|
|
1229
|
-
case 'webapp-testing':
|
|
1230
|
-
const scriptsPath = `${skill.skillsPath}/scripts`;
|
|
1231
|
-
nextSteps.push({
|
|
1232
|
-
step: 3,
|
|
1233
|
-
action: 'Read documentation and helper script',
|
|
1234
|
-
description: 'Read SKILL.md and scripts/with_server.py',
|
|
1235
|
-
file: `${scriptsPath}/with_server.py`,
|
|
1236
|
-
reason: 'Understand webapp testing workflow and with_server.py usage'
|
|
1237
|
-
});
|
|
1238
|
-
nextSteps.push({
|
|
1239
|
-
step: 4,
|
|
1240
|
-
action: 'Create workspace directory',
|
|
1241
|
-
description: `Create workspace directory: ${taskWorkspace}/`,
|
|
1242
|
-
reason: 'Create workspace directory for test files'
|
|
1243
|
-
});
|
|
1244
|
-
nextSteps.push({
|
|
1245
|
-
step: 5,
|
|
1246
|
-
action: 'Write Playwright tests in workspace',
|
|
1247
|
-
description: `Create test.py in ${taskWorkspace} for web application testing`,
|
|
1248
|
-
reason: 'Write test scripts in workspace'
|
|
1249
|
-
});
|
|
1250
|
-
nextSteps.push({
|
|
1251
|
-
step: 6,
|
|
1252
|
-
action: 'Run tests with server',
|
|
1253
|
-
description: `Run: python "${scriptsPath}/with_server.py" --server "<start_command>" --port <port> -- python ${taskWorkspace}/test.py`,
|
|
1254
|
-
reason: 'Run tests with server using existing with_server.py helper'
|
|
1255
|
-
});
|
|
1256
|
-
nextSteps.push({
|
|
1257
|
-
step: 7,
|
|
1258
|
-
action: 'Copy test reports to target directory',
|
|
1259
|
-
description: `Copy test reports from ${taskWorkspace} to target directory`,
|
|
1260
|
-
reason: 'Only save test reports to specified path'
|
|
1261
|
-
});
|
|
1262
|
-
return extractContent(fullContent, ['test', 'web', 'playwright', 'testing']);
|
|
1263
|
-
default:
|
|
1264
|
-
return extractContent(fullContent, ['frontend', 'design', 'web']);
|
|
1265
|
-
}
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
1268
|
-
/**
|
|
1269
|
-
* Visual Design Skill Executor
|
|
1270
|
-
*/
|
|
1271
|
-
class VisualDesignSkillExecutor {
|
|
1272
|
-
async execute(skill, params) {
|
|
1273
|
-
const outputMessages = [];
|
|
1274
|
-
const files = [];
|
|
1275
|
-
const nextSteps = [];
|
|
1276
|
-
outputMessages.push(`## ${skill.name} Skill - Execution Guide\n`);
|
|
1277
|
-
outputMessages.push(`**Task**: ${params.taskDescription}\n`);
|
|
1278
|
-
// Get or generate task ID
|
|
1279
|
-
const taskId = params.taskId || `${skill.id}-${Date.now()}`;
|
|
1280
|
-
try {
|
|
1281
|
-
// Read SKILL.md content
|
|
1282
|
-
const skillMdPath = path.join(skill.skillsPath, 'SKILL.md');
|
|
1283
|
-
files.push(skillMdPath);
|
|
1284
|
-
const skillContent = await fs.readFile(skillMdPath, 'utf-8');
|
|
1285
|
-
// Generate execution steps
|
|
1286
|
-
const taskContent = await this.extractVisualContent(skill, params, skillContent, nextSteps, taskId);
|
|
1287
|
-
outputMessages.push(taskContent);
|
|
1288
|
-
// Add input/output files to list if they exist
|
|
1289
|
-
if (params.inputFile)
|
|
1290
|
-
files.push(params.inputFile);
|
|
1291
|
-
if (params.outputFile)
|
|
1292
|
-
files.push(params.outputFile);
|
|
1293
|
-
return {
|
|
1294
|
-
success: true,
|
|
1295
|
-
output: outputMessages.join('\n'),
|
|
1296
|
-
files: files,
|
|
1297
|
-
nextSteps: nextSteps,
|
|
1298
|
-
requiresManualExecution: true
|
|
1299
|
-
};
|
|
1300
|
-
}
|
|
1301
|
-
catch (error) {
|
|
1302
|
-
return {
|
|
1303
|
-
success: false,
|
|
1304
|
-
error: error.message
|
|
1305
|
-
};
|
|
1306
|
-
}
|
|
1307
|
-
}
|
|
1308
|
-
/**
|
|
1309
|
-
* Extract relevant content based on visual design skill type and generate steps
|
|
1310
|
-
*/
|
|
1311
|
-
async extractVisualContent(skill, params, fullContent, nextSteps, taskId) {
|
|
1312
|
-
const taskLower = params.taskDescription.toLowerCase();
|
|
1313
|
-
const workspaceBase = getWorkspaceDescription();
|
|
1314
|
-
const taskWorkspace = `${workspaceBase}/${taskId}`;
|
|
1315
|
-
switch (skill.id) {
|
|
1316
|
-
case 'canvas-design':
|
|
1317
|
-
// Canvas Design: Two-step process
|
|
1318
|
-
nextSteps.push({
|
|
1319
|
-
step: 1,
|
|
1320
|
-
action: 'Create workspace directory',
|
|
1321
|
-
description: `Create workspace directory: ${taskWorkspace}/`,
|
|
1322
|
-
reason: 'Create workspace directory for design files'
|
|
1323
|
-
});
|
|
1324
|
-
nextSteps.push({
|
|
1325
|
-
step: 2,
|
|
1326
|
-
action: 'Design Philosophy Creation',
|
|
1327
|
-
description: `Create manifesto/md file in ${taskWorkspace} defining aesthetic movement`,
|
|
1328
|
-
reason: 'Create design philosophy document in workspace'
|
|
1329
|
-
});
|
|
1330
|
-
nextSteps.push({
|
|
1331
|
-
step: 3,
|
|
1332
|
-
action: 'Canvas Creation',
|
|
1333
|
-
description: `Express philosophy visually using PDF/PNG output in ${taskWorkspace}`,
|
|
1334
|
-
reason: 'Express philosophy visually on canvas in workspace'
|
|
1335
|
-
});
|
|
1336
|
-
nextSteps.push({
|
|
1337
|
-
step: 4,
|
|
1338
|
-
action: 'Copy output to target directory',
|
|
1339
|
-
description: `Copy output files from ${taskWorkspace} to target directory`,
|
|
1340
|
-
reason: 'Only save final files to specified path'
|
|
1341
|
-
});
|
|
1342
|
-
return extractContent(fullContent, ['design', 'art', 'visual', 'philosophy']);
|
|
1343
|
-
case 'algorithmic-art':
|
|
1344
|
-
// Algorithmic Art
|
|
1345
|
-
nextSteps.push({
|
|
1346
|
-
step: 1,
|
|
1347
|
-
action: 'Create workspace directory',
|
|
1348
|
-
description: `Create workspace directory: ${taskWorkspace}/`,
|
|
1349
|
-
reason: 'Create workspace directory for generative art files'
|
|
1350
|
-
});
|
|
1351
|
-
nextSteps.push({
|
|
1352
|
-
step: 2,
|
|
1353
|
-
action: 'Algorithmic Philosophy',
|
|
1354
|
-
description: `Define generative art philosophy in ${taskWorkspace}`,
|
|
1355
|
-
reason: 'Create generative art philosophy in workspace'
|
|
1356
|
-
});
|
|
1357
|
-
nextSteps.push({
|
|
1358
|
-
step: 3,
|
|
1359
|
-
action: 'P5.js Implementation',
|
|
1360
|
-
description: `Write p5.js code in ${taskWorkspace} for generative art`,
|
|
1361
|
-
reason: 'Implement generative art code in workspace'
|
|
1362
|
-
});
|
|
1363
|
-
nextSteps.push({
|
|
1364
|
-
step: 4,
|
|
1365
|
-
action: 'Generate artwork',
|
|
1366
|
-
description: `Run p5.js code in ${taskWorkspace} to generate artwork`,
|
|
1367
|
-
reason: 'Run generative art code'
|
|
1368
|
-
});
|
|
1369
|
-
nextSteps.push({
|
|
1370
|
-
step: 5,
|
|
1371
|
-
action: 'Copy output to target directory',
|
|
1372
|
-
description: `Copy output files from ${taskWorkspace} to target directory`,
|
|
1373
|
-
reason: 'Only save final files to specified path'
|
|
1374
|
-
});
|
|
1375
|
-
return extractContent(fullContent, ['generative', 'algorithmic', 'art']);
|
|
1376
|
-
case 'theme-factory':
|
|
1377
|
-
// Theme Factory
|
|
1378
|
-
nextSteps.push({
|
|
1379
|
-
step: 1,
|
|
1380
|
-
action: 'Create workspace directory',
|
|
1381
|
-
description: `Create workspace directory: ${taskWorkspace}/`,
|
|
1382
|
-
reason: 'Create workspace directory for theme files'
|
|
1383
|
-
});
|
|
1384
|
-
nextSteps.push({
|
|
1385
|
-
step: 2,
|
|
1386
|
-
action: 'Select theme',
|
|
1387
|
-
description: `Choose from available themes or create custom in ${taskWorkspace}`,
|
|
1388
|
-
reason: 'Select or create theme in workspace'
|
|
1389
|
-
});
|
|
1390
|
-
nextSteps.push({
|
|
1391
|
-
step: 3,
|
|
1392
|
-
action: 'Apply theme',
|
|
1393
|
-
description: `Apply colors, fonts to design in ${taskWorkspace}`,
|
|
1394
|
-
reason: 'Apply theme to design in workspace'
|
|
1395
|
-
});
|
|
1396
|
-
nextSteps.push({
|
|
1397
|
-
step: 4,
|
|
1398
|
-
action: 'Copy output to target directory',
|
|
1399
|
-
description: `Copy theme files from ${taskWorkspace} to target directory`,
|
|
1400
|
-
reason: 'Only save final files to specified path'
|
|
1401
|
-
});
|
|
1402
|
-
return extractContent(fullContent, ['Theme Factory', 'Themes', 'apply']);
|
|
1403
|
-
case 'brand-guidelines':
|
|
1404
|
-
// Brand Guidelines
|
|
1405
|
-
nextSteps.push({
|
|
1406
|
-
step: 1,
|
|
1407
|
-
action: 'Create workspace directory',
|
|
1408
|
-
description: `Create workspace directory: ${taskWorkspace}/`,
|
|
1409
|
-
reason: 'Create workspace directory for brand files'
|
|
1410
|
-
});
|
|
1411
|
-
nextSteps.push({
|
|
1412
|
-
step: 2,
|
|
1413
|
-
action: 'Apply brand colors',
|
|
1414
|
-
description: `Use Anthropic brand colors and typography in ${taskWorkspace}`,
|
|
1415
|
-
reason: 'Apply brand colors in workspace'
|
|
1416
|
-
});
|
|
1417
|
-
nextSteps.push({
|
|
1418
|
-
step: 3,
|
|
1419
|
-
action: 'Follow guidelines',
|
|
1420
|
-
description: `Apply brand styling consistently in ${taskWorkspace}`,
|
|
1421
|
-
reason: 'Follow brand guidelines in workspace'
|
|
1422
|
-
});
|
|
1423
|
-
nextSteps.push({
|
|
1424
|
-
step: 4,
|
|
1425
|
-
action: 'Copy output to target directory',
|
|
1426
|
-
description: `Copy brand files from ${taskWorkspace} to target directory`,
|
|
1427
|
-
reason: 'Only save final files to specified path'
|
|
1428
|
-
});
|
|
1429
|
-
return extractContent(fullContent, ['Brand Guidelines', 'Colors', 'Typography']);
|
|
1430
|
-
default:
|
|
1431
|
-
nextSteps.push({
|
|
1432
|
-
step: 1,
|
|
1433
|
-
action: 'Create workspace directory',
|
|
1434
|
-
description: `Create workspace directory: ${taskWorkspace}/`,
|
|
1435
|
-
reason: 'Create workspace directory for design files'
|
|
1436
|
-
});
|
|
1437
|
-
nextSteps.push({
|
|
1438
|
-
step: 2,
|
|
1439
|
-
action: 'Create visual design',
|
|
1440
|
-
description: `Write design code or use canvas in ${taskWorkspace}`,
|
|
1441
|
-
reason: 'Create visual design in workspace'
|
|
1442
|
-
});
|
|
1443
|
-
nextSteps.push({
|
|
1444
|
-
step: 3,
|
|
1445
|
-
action: 'Copy output to target directory',
|
|
1446
|
-
description: `Copy output files from ${taskWorkspace} to target directory`,
|
|
1447
|
-
reason: 'Only save final files to specified path'
|
|
1448
|
-
});
|
|
1449
|
-
return extractContent(fullContent, ['design', 'art', 'visual']);
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
}
|
|
1453
|
-
/**
|
|
1454
|
-
* Documentation Skill Executor
|
|
1455
|
-
*/
|
|
1456
|
-
class DocumentationSkillExecutor {
|
|
1457
|
-
async execute(skill, params) {
|
|
1458
|
-
const outputMessages = [];
|
|
1459
|
-
const files = [];
|
|
1460
|
-
const nextSteps = [];
|
|
1461
|
-
outputMessages.push(`## ${skill.name} Skill - Execution Guide\n`);
|
|
1462
|
-
outputMessages.push(`**Task**: ${params.taskDescription}\n`);
|
|
1463
|
-
// Get or generate task ID
|
|
1464
|
-
const taskId = params.taskId || `${skill.id}-${Date.now()}`;
|
|
1465
|
-
try {
|
|
1466
|
-
// Read SKILL.md content
|
|
1467
|
-
const skillMdPath = path.join(skill.skillsPath, 'SKILL.md');
|
|
1468
|
-
files.push(skillMdPath);
|
|
1469
|
-
const skillContent = await fs.readFile(skillMdPath, 'utf-8');
|
|
1470
|
-
// Generate execution steps
|
|
1471
|
-
const taskContent = await this.extractDocContent(skill, params, skillContent, nextSteps, taskId);
|
|
1472
|
-
outputMessages.push(taskContent);
|
|
1473
|
-
// Add input/output files to list if they exist
|
|
1474
|
-
if (params.inputFile)
|
|
1475
|
-
files.push(params.inputFile);
|
|
1476
|
-
if (params.outputFile)
|
|
1477
|
-
files.push(params.outputFile);
|
|
1478
|
-
return {
|
|
1479
|
-
success: true,
|
|
1480
|
-
output: outputMessages.join('\n'),
|
|
1481
|
-
files: files,
|
|
1482
|
-
nextSteps: nextSteps,
|
|
1483
|
-
requiresManualExecution: true
|
|
1484
|
-
};
|
|
1485
|
-
}
|
|
1486
|
-
catch (error) {
|
|
1487
|
-
return {
|
|
1488
|
-
success: false,
|
|
1489
|
-
error: error.message
|
|
1490
|
-
};
|
|
1491
|
-
}
|
|
1492
|
-
}
|
|
1493
|
-
/**
|
|
1494
|
-
* Extract relevant content based on documentation skill type and generate steps
|
|
1495
|
-
*/
|
|
1496
|
-
async extractDocContent(skill, params, fullContent, nextSteps, taskId) {
|
|
1497
|
-
const taskLower = params.taskDescription.toLowerCase();
|
|
1498
|
-
const workspaceBase = getWorkspaceDescription();
|
|
1499
|
-
const taskWorkspace = `${workspaceBase}/${taskId}`;
|
|
1500
|
-
switch (skill.id) {
|
|
1501
|
-
case 'internal-comms':
|
|
1502
|
-
// Internal Comms
|
|
1503
|
-
if (taskLower.includes('status') || taskLower.includes('report')) {
|
|
1504
|
-
nextSteps.push({
|
|
1505
|
-
step: 1,
|
|
1506
|
-
action: 'Gather information',
|
|
1507
|
-
description: 'Collect progress, plans, problems',
|
|
1508
|
-
reason: 'Gather status information'
|
|
1509
|
-
});
|
|
1510
|
-
nextSteps.push({
|
|
1511
|
-
step: 2,
|
|
1512
|
-
action: 'Write update',
|
|
1513
|
-
description: 'Draft 3P update format',
|
|
1514
|
-
reason: 'Write status update'
|
|
1515
|
-
});
|
|
1516
|
-
}
|
|
1517
|
-
else if (taskLower.includes('newsletter')) {
|
|
1518
|
-
nextSteps.push({
|
|
1519
|
-
step: 1,
|
|
1520
|
-
action: 'Create newsletter',
|
|
1521
|
-
description: 'Write company newsletter content',
|
|
1522
|
-
reason: 'Create company newsletter'
|
|
1523
|
-
});
|
|
1524
|
-
}
|
|
1525
|
-
return extractContent(fullContent, ['documentation', 'writing', 'internal']);
|
|
1526
|
-
case 'doc-coauthoring':
|
|
1527
|
-
// Doc Co-Authoring: Three-stage process
|
|
1528
|
-
nextSteps.push({
|
|
1529
|
-
step: 1,
|
|
1530
|
-
action: 'Create workspace directory',
|
|
1531
|
-
description: `Create workspace directory: ${taskWorkspace}/`,
|
|
1532
|
-
reason: 'Create workspace directory for document drafts'
|
|
1533
|
-
});
|
|
1534
|
-
nextSteps.push({
|
|
1535
|
-
step: 2,
|
|
1536
|
-
action: 'Stage 1: Context Gathering',
|
|
1537
|
-
description: 'Gather requirements and initial questions',
|
|
1538
|
-
reason: 'Gather document background and requirements'
|
|
1539
|
-
});
|
|
1540
|
-
nextSteps.push({
|
|
1541
|
-
step: 3,
|
|
1542
|
-
action: 'Stage 2: Refinement',
|
|
1543
|
-
description: `Structure and draft content in ${taskWorkspace}`,
|
|
1544
|
-
reason: 'Structure and draft document in workspace'
|
|
1545
|
-
});
|
|
1546
|
-
nextSteps.push({
|
|
1547
|
-
step: 4,
|
|
1548
|
-
action: 'Stage 3: Reader Testing',
|
|
1549
|
-
description: `Test with fresh Claude and refine in ${taskWorkspace}`,
|
|
1550
|
-
reason: 'Test and refine document in workspace'
|
|
1551
|
-
});
|
|
1552
|
-
nextSteps.push({
|
|
1553
|
-
step: 5,
|
|
1554
|
-
action: 'Copy final document to target directory',
|
|
1555
|
-
description: `Copy final document from ${taskWorkspace} to target directory`,
|
|
1556
|
-
reason: 'Only save final document to specified path'
|
|
1557
|
-
});
|
|
1558
|
-
return extractContent(fullContent, ['documentation', 'coauthor', 'workflow']);
|
|
1559
|
-
default:
|
|
1560
|
-
return extractContent(fullContent, ['documentation', 'writing', 'guide']);
|
|
1561
|
-
}
|
|
1562
|
-
}
|
|
1563
|
-
}
|
|
1564
|
-
/**
|
|
1565
|
-
* Default Skill Executor
|
|
1566
|
-
*/
|
|
1567
|
-
class DefaultSkillExecutor {
|
|
1568
|
-
async execute(skill, params) {
|
|
1569
|
-
const outputMessages = [];
|
|
1570
|
-
const files = [];
|
|
1571
|
-
const nextSteps = [];
|
|
1572
|
-
outputMessages.push(`## ${skill.name} Skill - Execution Guide\n`);
|
|
1573
|
-
outputMessages.push(`**Task**: ${params.taskDescription}\n`);
|
|
1574
|
-
try {
|
|
1575
|
-
// Read SKILL.md content
|
|
1576
|
-
const skillMdPath = path.join(skill.skillsPath, 'SKILL.md');
|
|
1577
|
-
files.push(skillMdPath);
|
|
1578
|
-
const skillContent = await fs.readFile(skillMdPath, 'utf-8');
|
|
1579
|
-
// Generate execution steps
|
|
1580
|
-
const taskContent = this.extractDefaultContent(skill, skillContent, nextSteps);
|
|
1581
|
-
outputMessages.push(taskContent);
|
|
1582
|
-
// Add input/output files to list if they exist
|
|
1583
|
-
if (params.inputFile)
|
|
1584
|
-
files.push(params.inputFile);
|
|
1585
|
-
if (params.outputFile)
|
|
1586
|
-
files.push(params.outputFile);
|
|
1587
|
-
return {
|
|
1588
|
-
success: true,
|
|
1589
|
-
output: outputMessages.join('\n'),
|
|
1590
|
-
files: files,
|
|
1591
|
-
nextSteps: nextSteps,
|
|
1592
|
-
requiresManualExecution: true
|
|
1593
|
-
};
|
|
1594
|
-
}
|
|
1595
|
-
catch (error) {
|
|
1596
|
-
return {
|
|
1597
|
-
success: false,
|
|
1598
|
-
error: error.message
|
|
1599
|
-
};
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1602
|
-
/**
|
|
1603
|
-
* Extract default skill content and generate steps
|
|
1604
|
-
*/
|
|
1605
|
-
extractDefaultContent(skill, fullContent, nextSteps) {
|
|
1606
|
-
nextSteps.push({
|
|
1607
|
-
step: 1,
|
|
1608
|
-
action: 'Read SKILL.md',
|
|
1609
|
-
description: `Read ${skill.skillsPath}/SKILL.md for full instructions`,
|
|
1610
|
-
reason: 'Understand complete execution workflow'
|
|
1611
|
-
});
|
|
1612
|
-
nextSteps.push({
|
|
1613
|
-
step: 2,
|
|
1614
|
-
action: 'Follow workflow',
|
|
1615
|
-
description: 'Execute according to SKILL.md instructions',
|
|
1616
|
-
reason: 'Follow SKILL.md guidance for execution'
|
|
1617
|
-
});
|
|
1618
|
-
return extractContent(fullContent, ['skill', 'guide', 'how to', skill.name]);
|
|
1619
|
-
}
|
|
1620
746
|
}
|
|
1621
747
|
// ============================================================
|
|
1622
748
|
// ============================================================
|
|
@@ -1627,7 +753,7 @@ class DefaultSkillExecutor {
|
|
|
1627
753
|
* @returns Execution result with guidance
|
|
1628
754
|
*/
|
|
1629
755
|
export async function executeSkill(skill, params) {
|
|
1630
|
-
const executor = new
|
|
756
|
+
const executor = new GenericSkillExecutor();
|
|
1631
757
|
return executor.execute(skill, params);
|
|
1632
758
|
}
|
|
1633
759
|
// ============================================================
|