@alavida/agentpack 0.1.2 → 0.1.3

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 (43) hide show
  1. package/README.md +11 -1
  2. package/bin/intent.js +20 -0
  3. package/package.json +11 -5
  4. package/skills/agentpack-cli/SKILL.md +4 -1
  5. package/skills/authoring-skillgraphs-from-knowledge/SKILL.md +148 -0
  6. package/skills/authoring-skillgraphs-from-knowledge/references/authored-metadata.md +6 -0
  7. package/skills/developing-and-testing-skills/SKILL.md +109 -0
  8. package/skills/developing-and-testing-skills/references/local-workbench.md +7 -0
  9. package/skills/getting-started-skillgraphs/SKILL.md +115 -0
  10. package/skills/getting-started-skillgraphs/references/command-routing.md +7 -0
  11. package/skills/identifying-skill-opportunities/SKILL.md +119 -0
  12. package/skills/identifying-skill-opportunities/references/capability-boundaries.md +6 -0
  13. package/skills/maintaining-skillgraph-freshness/SKILL.md +110 -0
  14. package/skills/repairing-broken-skill-or-plugin-state/SKILL.md +112 -0
  15. package/skills/repairing-broken-skill-or-plugin-state/references/diagnostic-flows.md +6 -0
  16. package/skills/shipping-production-plugins-and-packages/SKILL.md +123 -0
  17. package/skills/shipping-production-plugins-and-packages/references/plugin-delivery.md +6 -0
  18. package/src/application/skills/build-skill-workbench-model.js +194 -0
  19. package/src/application/skills/run-skill-workbench-action.js +23 -0
  20. package/src/application/skills/start-skill-dev-workbench.js +192 -0
  21. package/src/cli.js +1 -1
  22. package/src/commands/skills.js +7 -1
  23. package/src/dashboard/App.jsx +343 -0
  24. package/src/dashboard/components/Breadcrumbs.jsx +45 -0
  25. package/src/dashboard/components/ControlStrip.jsx +153 -0
  26. package/src/dashboard/components/InspectorPanel.jsx +203 -0
  27. package/src/dashboard/components/SkillGraph.jsx +567 -0
  28. package/src/dashboard/components/Tooltip.jsx +111 -0
  29. package/src/dashboard/dist/dashboard.js +26692 -0
  30. package/src/dashboard/index.html +81 -0
  31. package/src/dashboard/lib/api.js +19 -0
  32. package/src/dashboard/lib/router.js +15 -0
  33. package/src/dashboard/main.jsx +4 -0
  34. package/src/domain/plugins/load-plugin-definition.js +163 -0
  35. package/src/domain/plugins/plugin-diagnostic-error.js +18 -0
  36. package/src/domain/plugins/plugin-requirements.js +15 -0
  37. package/src/domain/skills/skill-graph.js +1 -0
  38. package/src/infrastructure/runtime/open-browser.js +20 -0
  39. package/src/infrastructure/runtime/skill-dev-workbench-server.js +96 -0
  40. package/src/infrastructure/runtime/watch-skill-workbench.js +68 -0
  41. package/src/lib/plugins.js +19 -28
  42. package/src/lib/skills.js +60 -12
  43. package/src/utils/errors.js +33 -1
package/src/lib/skills.js CHANGED
@@ -29,6 +29,7 @@ import {
29
29
  readBuildState,
30
30
  writeBuildState,
31
31
  } from '../domain/skills/skill-provenance.js';
32
+ import { startSkillDevWorkbench } from '../application/skills/start-skill-dev-workbench.js';
32
33
  import { AgentpackError, EXIT_CODES, NetworkError, NotFoundError, ValidationError } from '../utils/errors.js';
33
34
 
34
35
  const GITHUB_PACKAGES_REGISTRY = 'https://npm.pkg.github.com';
@@ -263,21 +264,26 @@ export function devSkill(target, {
263
264
  export function startSkillDev(target, {
264
265
  cwd = process.cwd(),
265
266
  sync = true,
267
+ dashboard = true,
266
268
  onStart = () => {},
267
269
  onRebuild = () => {},
268
270
  } = {}) {
269
- const repoRoot = findRepoRoot(cwd);
270
- const { skillDir } = resolveLocalPackagedSkillDir(repoRoot, target);
271
+ const outerRepoRoot = findRepoRoot(cwd);
272
+ const { skillDir } = resolveLocalPackagedSkillDir(outerRepoRoot, target);
273
+ const repoRoot = findRepoRoot(skillDir);
271
274
  let closed = false;
272
275
  let timer = null;
273
276
  let currentNames = [];
274
277
  let watcher = null;
278
+ let workbench = null;
279
+ let initialResult = null;
275
280
 
276
281
  const cleanup = () => {
277
282
  if (closed) return { name: currentNames[0] || null, unlinked: false, removed: [] };
278
283
  closed = true;
279
284
  clearTimeout(timer);
280
285
  if (watcher) watcher.close();
286
+ if (workbench) workbench.close();
281
287
  const removed = removeSkillLinksByNames(repoRoot, currentNames, normalizeDisplayPath);
282
288
  detachProcessCleanup();
283
289
  return {
@@ -305,8 +311,22 @@ export function startSkillDev(target, {
305
311
  processCleanupHandlers.clear();
306
312
  };
307
313
 
308
- const run = () => {
309
- const result = devSkill(target, { cwd, sync });
314
+ const enrichResult = (result) => ({
315
+ ...result,
316
+ workbench: workbench
317
+ ? {
318
+ enabled: true,
319
+ url: workbench.url,
320
+ port: workbench.port,
321
+ }
322
+ : {
323
+ enabled: false,
324
+ url: null,
325
+ port: null,
326
+ },
327
+ });
328
+
329
+ const applyDevResult = (result) => {
310
330
  const nextNames = result.linkedSkills.map((entry) => entry.name);
311
331
  const staleNames = currentNames.filter((name) => !nextNames.includes(name));
312
332
  if (staleNames.length > 0) {
@@ -316,8 +336,31 @@ export function startSkillDev(target, {
316
336
  return result;
317
337
  };
318
338
 
319
- const initialResult = run();
320
- onStart(initialResult);
339
+ const startOrRefreshWorkbench = async () => {
340
+ if (dashboard && !workbench) {
341
+ workbench = await startSkillDevWorkbench({
342
+ repoRoot,
343
+ skillDir,
344
+ open: true,
345
+ disableBrowser: process.env.AGENTPACK_DISABLE_BROWSER === '1',
346
+ });
347
+ } else if (workbench) {
348
+ workbench.refresh();
349
+ }
350
+ };
351
+
352
+ initialResult = enrichResult(applyDevResult(devSkill(target, { cwd, sync })));
353
+ const ready = Promise.resolve(startOrRefreshWorkbench())
354
+ .then(() => {
355
+ const result = enrichResult(initialResult);
356
+ initialResult = result;
357
+ onStart(result);
358
+ return result;
359
+ })
360
+ .catch((error) => {
361
+ cleanup();
362
+ throw error;
363
+ });
321
364
 
322
365
  attachProcessCleanup();
323
366
 
@@ -325,17 +368,22 @@ export function startSkillDev(target, {
325
368
  if (closed) return;
326
369
  clearTimeout(timer);
327
370
  timer = setTimeout(() => {
328
- try {
329
- const result = run();
330
- onRebuild(result);
331
- } catch (error) {
332
- onRebuild({ error });
333
- }
371
+ Promise.resolve()
372
+ .then(() => applyDevResult(devSkill(target, { cwd, sync })))
373
+ .then(async (result) => {
374
+ await startOrRefreshWorkbench();
375
+ return enrichResult(result);
376
+ })
377
+ .then(onRebuild)
378
+ .catch((error) => {
379
+ onRebuild({ error });
380
+ });
334
381
  }, 100);
335
382
  });
336
383
 
337
384
  return {
338
385
  initialResult,
386
+ ready,
339
387
  close() {
340
388
  return cleanup();
341
389
  },
@@ -14,18 +14,31 @@ export const EXIT_CODES = {
14
14
  * Carries a machine-readable code and mapped exit code.
15
15
  */
16
16
  export class AgentpackError extends Error {
17
- constructor(message, { code, exitCode = EXIT_CODES.GENERAL, suggestion } = {}) {
17
+ constructor(message, {
18
+ code,
19
+ exitCode = EXIT_CODES.GENERAL,
20
+ suggestion,
21
+ path,
22
+ nextSteps,
23
+ details,
24
+ } = {}) {
18
25
  super(message);
19
26
  this.name = 'AgentpackError';
20
27
  this.code = code || 'general_error';
21
28
  this.exitCode = exitCode;
22
29
  this.suggestion = suggestion;
30
+ this.path = path;
31
+ this.nextSteps = nextSteps || [];
32
+ this.details = details || {};
23
33
  }
24
34
 
25
35
  toJSON() {
26
36
  return {
27
37
  error: this.code,
28
38
  message: this.message,
39
+ ...(this.path && { path: this.path }),
40
+ ...(this.nextSteps.length > 0 && { nextSteps: this.nextSteps }),
41
+ ...(Object.keys(this.details).length > 0 && { details: this.details }),
29
42
  ...(this.suggestion && { suggestion: this.suggestion }),
30
43
  };
31
44
  }
@@ -58,6 +71,25 @@ export class NotFoundError extends AgentpackError {
58
71
  export function formatError(err) {
59
72
  if (err instanceof AgentpackError) {
60
73
  let msg = `Error: ${err.message}`;
74
+ if (err.path) {
75
+ msg += `\nPath: ${err.path}`;
76
+ }
77
+ if (err.nextSteps?.length) {
78
+ for (const step of err.nextSteps) {
79
+ const actionLabel = step.action === 'create_file'
80
+ ? `Create ${step.path}`
81
+ : step.action === 'edit_file'
82
+ ? `Edit ${step.path}`
83
+ : step.reason;
84
+ msg += `\nNext: ${actionLabel}`;
85
+ if (step.reason && step.reason !== actionLabel) {
86
+ msg += `\nWhy: ${step.reason}`;
87
+ }
88
+ if (step.example) {
89
+ msg += `\nExample:\n${JSON.stringify(step.example, null, 2)}`;
90
+ }
91
+ }
92
+ }
61
93
  if (err.suggestion) {
62
94
  msg += `\n\nSuggestion: ${err.suggestion}`;
63
95
  }