@vellumai/assistant 0.8.9-dev.202606091926.ebb2d62 → 0.8.9-dev.202606091946.122706e

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/openapi.yaml CHANGED
@@ -16251,6 +16251,8 @@ paths:
16251
16251
  - name
16252
16252
  - input
16253
16253
  additionalProperties: false
16254
+ deprecated: true
16255
+ description: "Deprecated: superseded by contentBlocks (the tool_use variant). Flat list of tool calls."
16254
16256
  surfaces:
16255
16257
  type: array
16256
16258
  items:
@@ -16302,6 +16304,8 @@ paths:
16302
16304
  - surfaceType
16303
16305
  - data
16304
16306
  additionalProperties: false
16307
+ deprecated: true
16308
+ description: "Deprecated: superseded by contentBlocks (the surface variant). Flat list of surfaces."
16305
16309
  textSegments:
16306
16310
  type: array
16307
16311
  items:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vellumai/assistant",
3
- "version": "0.8.9-dev.202606091926.ebb2d62",
3
+ "version": "0.8.9-dev.202606091946.122706e",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -39,18 +39,21 @@ import type {
39
39
 
40
40
  // The agent loop invokes the default post-compaction re-injection hook directly
41
41
  // when it compacts in place. Stub it so these unit tests can drive the
42
- // re-injection result without the daemon-level injector chain. Tests assign
43
- // `postCompactImpl` to observe the call or force a failure; when unset
44
- // the hook is a no-op that returns the history it was handed.
42
+ // re-injection result without the daemon-level injector chain. The hook writes
43
+ // the re-injected history back onto the context; tests assign `postCompactImpl`
44
+ // to observe the call or force a failure; when unset the hook leaves the
45
+ // history it was handed untouched.
45
46
  let postCompactImpl:
46
47
  | ((input: PostCompactContext) => Promise<Message[]>)
47
48
  | null = null;
48
49
  mock.module(
49
50
  "../plugins/defaults/memory-retrieval/hooks/post-compact.js",
50
51
  () => ({
51
- default: async (input: PostCompactContext) => ({
52
- messages: postCompactImpl ? await postCompactImpl(input) : input.history,
53
- }),
52
+ default: async (input: PostCompactContext): Promise<void> => {
53
+ input.history = postCompactImpl
54
+ ? await postCompactImpl(input)
55
+ : input.history;
56
+ },
54
57
  }),
55
58
  );
56
59
 
@@ -107,7 +107,9 @@ import {
107
107
  writeSlackMetadata,
108
108
  } from "../messaging/providers/slack/message-metadata.js";
109
109
  import { parentAlias } from "../messaging/providers/slack/render-transcript.js";
110
- import postCompact from "../plugins/defaults/memory-retrieval/hooks/post-compact.js";
110
+ import postCompact, {
111
+ type PostCompactContext,
112
+ } from "../plugins/defaults/memory-retrieval/hooks/post-compact.js";
111
113
  import {
112
114
  buildUnifiedTurnContextBlock,
113
115
  type UnifiedTurnContextOptions,
@@ -1029,7 +1031,7 @@ describe("applyRuntimeInjections — injection mode", () => {
1029
1031
  // only resolve when `applyRuntimeInjections` finds it by conversation id
1030
1032
  // AND the agent loop hands the post-compaction hook the turn-identity fields
1031
1033
  // flat (`requestId`, `conversationId`, `trust`)
1032
- const { messages: result } = await postCompact({
1034
+ const postCompactCtx: PostCompactContext = {
1033
1035
  history: baseMessages,
1034
1036
  requestId: "reinject-req",
1035
1037
  conversationId: "injection-mode-conv",
@@ -1038,7 +1040,9 @@ describe("applyRuntimeInjections — injection mode", () => {
1038
1040
  mode: "full",
1039
1041
  modelProfile: null,
1040
1042
  actorContext: null,
1041
- });
1043
+ };
1044
+ await postCompact(postCompactCtx);
1045
+ const result = postCompactCtx.history;
1042
1046
  const allText = result[0].content
1043
1047
  .filter((b): b is { type: "text"; text: string } => b.type === "text")
1044
1048
  .map((b) => b.text)
@@ -399,11 +399,11 @@ describe("plugin bootstrap", () => {
399
399
  expect(initFired).toBe(true);
400
400
  });
401
401
 
402
- test("requiresFlag disabled: init does not fire and no tools/routes/skills are registered", async () => {
402
+ test("requiresFlag disabled: init does not fire and no tools/routes are registered", async () => {
403
403
  setOverridesForTesting({ "plugin-gated-disabled": false });
404
404
 
405
405
  let initFired = false;
406
- // Attach tool/route/skill contributions alongside init. If gating works,
406
+ // Attach tool/route contributions alongside init. If gating works,
407
407
  // none of them should land in their respective registries.
408
408
  const plugin = buildPlugin(
409
409
  "gated-off",
@@ -430,24 +430,14 @@ describe("plugin bootstrap", () => {
430
430
  handler: async () => new Response("ok"),
431
431
  },
432
432
  ],
433
- skills: [
434
- {
435
- id: "gated-off/skill",
436
- name: "gated-off-skill",
437
- description: "should not be catalogued",
438
- body: "# unused",
439
- },
440
- ],
441
433
  },
442
434
  { requiresFlag: ["plugin-gated-disabled"] },
443
435
  );
444
436
  registerPlugin(plugin);
445
437
 
446
- // Grab tool / route / skill introspection helpers lazily so the import
438
+ // Grab tool / route introspection helpers lazily so the import
447
439
  // side effect happens after `mock.module` has taken effect.
448
440
  const { getTool } = await import("../tools/registry.js");
449
- const { getPluginSkillRefCount } =
450
- await import("../plugins/plugin-skill-contributions.js");
451
441
  const { matchSkillRoute } =
452
442
  await import("../runtime/skill-route-registry.js");
453
443
 
@@ -459,8 +449,6 @@ describe("plugin bootstrap", () => {
459
449
  expect(getTool("gated-off-tool")).toBeUndefined();
460
450
  // No route wired up — `matchSkillRoute` returns null when nothing matches.
461
451
  expect(matchSkillRoute("/_plugin/gated-off/status", "GET")).toBeNull();
462
- // No skill catalogued under this plugin's name — ref count stays 0.
463
- expect(getPluginSkillRefCount("gated-off")).toBe(0);
464
452
  });
465
453
 
466
454
  test("requiresFlag absent: plugin activates unconditionally", async () => {
@@ -78,14 +78,6 @@ describe("plugin core types", () => {
78
78
  handler: async () => new Response("ok", { status: 200 }),
79
79
  },
80
80
  ],
81
- skills: [
82
- {
83
- id: "sample-skill",
84
- name: "Sample Skill",
85
- description: "Demo plugin-contributed skill",
86
- body: "## Sample\n\nPlugin-provided skill body.",
87
- },
88
- ],
89
81
  } satisfies Plugin;
90
82
 
91
83
  // Minimal runtime check so the test body is non-empty.
@@ -252,6 +252,129 @@ describe("workspace skills", () => {
252
252
  });
253
253
  });
254
254
 
255
+ describe("plugin-resident skills", () => {
256
+ const pluginsDir = join(TEST_DIR, "plugins");
257
+
258
+ /**
259
+ * Materialize a skill on disk inside an installed plugin directory:
260
+ * `plugins/<plugin>/skills/<skillId>/SKILL.md`. A `package.json` is written
261
+ * for the plugin by default since that is the install gate the discovery
262
+ * scan keys on; pass `withPackageJson: false` to simulate a stray directory.
263
+ */
264
+ function writePluginSkill(
265
+ pluginName: string,
266
+ skillId: string,
267
+ name: string,
268
+ description: string,
269
+ body: string = "Plugin skill body",
270
+ {
271
+ withPackageJson = true,
272
+ packageName,
273
+ }: { withPackageJson?: boolean; packageName?: string } = {},
274
+ ): void {
275
+ const pluginDir = join(pluginsDir, pluginName);
276
+ mkdirSync(pluginDir, { recursive: true });
277
+ if (withPackageJson) {
278
+ writeFileSync(
279
+ join(pluginDir, "package.json"),
280
+ JSON.stringify({ name: packageName ?? pluginName, version: "1.0.0" }),
281
+ );
282
+ }
283
+ const skillDir = join(pluginDir, "skills", skillId);
284
+ mkdirSync(skillDir, { recursive: true });
285
+ writeFileSync(
286
+ join(skillDir, "SKILL.md"),
287
+ `---\nname: "${name}"\ndescription: "${description}"\n---\n\n${body}\n`,
288
+ );
289
+ }
290
+
291
+ beforeEach(() => {
292
+ mkdirSync(join(TEST_DIR, "skills"), { recursive: true });
293
+ });
294
+
295
+ afterEach(() => {
296
+ for (const dir of [join(TEST_DIR, "skills"), pluginsDir]) {
297
+ if (existsSync(dir)) rmSync(dir, { recursive: true, force: true });
298
+ }
299
+ });
300
+
301
+ test("discovers skills shipped inside an installed plugin, attributed to it", () => {
302
+ writePluginSkill("caveman", "caveman", "Caveman", "Terse mode");
303
+
304
+ const skill = loadSkillCatalog().find((s) => s.id === "caveman");
305
+ expect(skill).toBeDefined();
306
+ expect(skill!.source).toBe("plugin");
307
+ expect(skill!.pluginName).toBe("caveman");
308
+ });
309
+
310
+ test("loadSkillBySelector loads a plugin-resident skill body", () => {
311
+ writePluginSkill(
312
+ "caveman",
313
+ "caveman",
314
+ "Caveman",
315
+ "Terse mode",
316
+ "Full plugin skill body",
317
+ );
318
+
319
+ const result = loadSkillBySelector("caveman");
320
+ expect(result.error).toBeUndefined();
321
+ expect(result.skill).toBeDefined();
322
+ expect(result.skill!.source).toBe("plugin");
323
+ expect(result.skill!.body).toBe("Full plugin skill body");
324
+ expect(result.skill!.pluginName).toBe("caveman");
325
+ });
326
+
327
+ test("ignores plugin directories without a package.json (staging/stray dirs)", () => {
328
+ writePluginSkill(
329
+ "half-installed",
330
+ "ghost",
331
+ "Ghost",
332
+ "Should be skipped",
333
+ "body",
334
+ { withPackageJson: false },
335
+ );
336
+
337
+ const skill = loadSkillCatalog().find((s) => s.id === "ghost");
338
+ expect(skill).toBeUndefined();
339
+ });
340
+
341
+ test("ignores plugin dirs whose package.json name mismatches the directory", () => {
342
+ // Mirrors the loader's recognition gate: an un-adapted clone whose
343
+ // package.json declares `caveman-installer` in a `caveman` dir is skipped.
344
+ writePluginSkill("caveman", "caveman", "Caveman", "Terse mode", "body", {
345
+ packageName: "caveman-installer",
346
+ });
347
+
348
+ const skill = loadSkillCatalog().find((s) => s.id === "caveman");
349
+ expect(skill).toBeUndefined();
350
+ });
351
+
352
+ test("workspace skill overrides a plugin-resident skill with the same id", () => {
353
+ const WORKSPACE_DIR = join(
354
+ tmpdir(),
355
+ `vellum-workspace-test-${crypto.randomUUID()}`,
356
+ );
357
+ const workspaceSkillsDir = join(WORKSPACE_DIR, ".vellum", "skills");
358
+ mkdirSync(join(workspaceSkillsDir, "shared-id"), { recursive: true });
359
+ writeFileSync(
360
+ join(workspaceSkillsDir, "shared-id", "SKILL.md"),
361
+ `---\nname: "Workspace Wins"\ndescription: "Workspace version"\n---\n\nbody\n`,
362
+ );
363
+ writePluginSkill("caveman", "shared-id", "Plugin Loses", "Plugin version");
364
+
365
+ try {
366
+ const skill = loadSkillCatalog(workspaceSkillsDir).find(
367
+ (s) => s.id === "shared-id",
368
+ );
369
+ expect(skill).toBeDefined();
370
+ expect(skill!.source).toBe("workspace");
371
+ expect(skill!.name).toBe("Workspace Wins");
372
+ } finally {
373
+ rmSync(WORKSPACE_DIR, { recursive: true, force: true });
374
+ }
375
+ });
376
+ });
377
+
255
378
  describe("tool manifest detection", () => {
256
379
  beforeEach(() => {
257
380
  mkdirSync(join(TEST_DIR, "skills"), { recursive: true });
package/src/agent/loop.ts CHANGED
@@ -23,7 +23,9 @@ import type {
23
23
  } from "../plugin-api/types.js";
24
24
  import { defaultCompact } from "../plugins/defaults/compaction/compact.js";
25
25
  import type { ContextWindowResult } from "../plugins/defaults/compaction/window-manager.js";
26
- import postCompact from "../plugins/defaults/memory-retrieval/hooks/post-compact.js";
26
+ import postCompact, {
27
+ type PostCompactContext,
28
+ } from "../plugins/defaults/memory-retrieval/hooks/post-compact.js";
27
29
  import { runHook } from "../plugins/pipeline.js";
28
30
  import type { CompactionCircuitEvent } from "../plugins/types.js";
29
31
  import { normalizeThinkingConfigForWire } from "../providers/thinking-config.js";
@@ -767,7 +769,7 @@ export class AgentLoop {
767
769
  // Re-inject onto the same base the `compaction_completed` dispatch commits:
768
770
  // the compacted messages when the pipeline compacted, the stripped
769
771
  // pre-compaction history otherwise.
770
- const injection = await postCompact({
772
+ const postCompactCtx: PostCompactContext = {
771
773
  history: compactResult.compacted ? compactResult.messages : rawHistory,
772
774
  requestId,
773
775
  conversationId: this.conversationId,
@@ -777,8 +779,11 @@ export class AgentLoop {
777
779
  mode: "full",
778
780
  modelProfile,
779
781
  actorContext,
780
- });
781
- return injection.messages;
782
+ };
783
+ // The hook writes the re-injected history back onto the context; read it
784
+ // from there once the hook settles.
785
+ await postCompact(postCompactCtx);
786
+ return postCompactCtx.history;
782
787
  }
783
788
 
784
789
  async run(options: AgentLoopRunOptions): Promise<AgentLoopRunResult> {
@@ -374,9 +374,40 @@ export const ConversationMessageSchema = z.object({
374
374
  .optional(),
375
375
  /** Display timestamp as an ISO-8601 string. */
376
376
  timestamp: z.string(),
377
+ /**
378
+ * Flat list of attachment metadata for the row. Not yet supersedable by
379
+ * `contentBlocks`: `renderHistoryContent` emits an `attachment` content
380
+ * block only for file-block refs with an inline placement, so orphan rows
381
+ * (unmatched ids, count mismatch, no DB rows — see `alignAttachments`) ship
382
+ * here alone. Kept non-deprecated until `contentBlocks` reaches attachment
383
+ * parity, so clients that migrate off the positional arrays don't drop those
384
+ * chips.
385
+ */
377
386
  attachments: z.array(ConversationMessageAttachmentSchema),
378
- toolCalls: z.array(ConversationMessageToolCallSchema).optional(),
379
- surfaces: z.array(ConversationMessageSurfaceSchema).optional(),
387
+ /**
388
+ * @deprecated Superseded by `contentBlocks` (the `tool_use` variant). Flat
389
+ * list of tool calls for the row.
390
+ */
391
+ toolCalls: z
392
+ .array(ConversationMessageToolCallSchema)
393
+ .meta({
394
+ deprecated: true,
395
+ description:
396
+ "Deprecated: superseded by contentBlocks (the tool_use variant). Flat list of tool calls.",
397
+ })
398
+ .optional(),
399
+ /**
400
+ * @deprecated Superseded by `contentBlocks` (the `surface` variant). Flat
401
+ * list of surfaces for the row.
402
+ */
403
+ surfaces: z
404
+ .array(ConversationMessageSurfaceSchema)
405
+ .meta({
406
+ deprecated: true,
407
+ description:
408
+ "Deprecated: superseded by contentBlocks (the surface variant). Flat list of surfaces.",
409
+ })
410
+ .optional(),
380
411
  /**
381
412
  * @deprecated Superseded by `contentBlocks`. Text split by tool-call
382
413
  * boundaries; positional sibling of `contentOrder`.
@@ -1,4 +1,5 @@
1
1
  import {
2
+ type Dirent,
2
3
  existsSync,
3
4
  lstatSync,
4
5
  readdirSync,
@@ -17,10 +18,6 @@ import {
17
18
 
18
19
  import { z } from "zod";
19
20
 
20
- import {
21
- getPluginContributedSkillDefinition,
22
- getPluginContributedSkillSummaries,
23
- } from "../plugins/plugin-skill-contributions.js";
24
21
  import { parseFrontmatterFields } from "../skills/frontmatter.js";
25
22
  import type { InlineCommandExpansion } from "../skills/inline-command-expansions.js";
26
23
  import { parseInlineCommandExpansions } from "../skills/inline-command-expansions.js";
@@ -29,6 +26,7 @@ import { computeSkillVersionHash } from "../skills/version-hash.js";
29
26
  import { getLogger } from "../util/logger.js";
30
27
  import {
31
28
  getWorkspaceDirDisplay,
29
+ getWorkspacePluginsDir,
32
30
  getWorkspaceSkillsDir,
33
31
  } from "../util/platform.js";
34
32
  import { stripCommentLines } from "../util/strip-comment-lines.js";
@@ -66,9 +64,9 @@ const SkillMetadataSchema = z
66
64
  * - `workspace`: user-authored skill living in a conversation's working dir.
67
65
  * - `extra`: third-party directory roots passed via `loadSkillCatalog`'s
68
66
  * `extraDirs` argument (primarily for tests).
69
- * - `plugin`: contributed at runtime by a loaded plugin via
70
- * `PluginSkillRegistration`. Body is held in-memory by
71
- * `plugins/plugin-skill-contributions.ts`, not on disk.
67
+ * - `plugin`: shipped on disk inside an installed plugin at
68
+ * `<workspaceDir>/plugins/<name>/skills/<id>/SKILL.md`, attributed back to
69
+ * the owning plugin via `pluginName`.
72
70
  */
73
71
  export type SkillSource =
74
72
  | "bundled"
@@ -90,6 +88,12 @@ export interface SkillSummary {
90
88
  icon?: string;
91
89
  emoji?: string;
92
90
  source: SkillSource;
91
+ /**
92
+ * Name of the plugin that ships this skill on disk. Set only for
93
+ * `source: "plugin"` skills, attributing them to the installed plugin
94
+ * directory under `<workspaceDir>/plugins/`.
95
+ */
96
+ pluginName?: string;
93
97
  /** Parsed tool manifest metadata, if the skill has a valid TOOLS.json. */
94
98
  toolManifest?: SkillToolManifestMeta;
95
99
  /** IDs of child skills that this skill includes (metadata-only, not auto-activated). */
@@ -646,6 +650,81 @@ function discoverSkillDirectories(skillsDir: string): string[] {
646
650
  return dirs.sort((a, b) => a.localeCompare(b));
647
651
  }
648
652
 
653
+ /**
654
+ * Whether `pluginDir` is a recognized installed plugin: it must carry a
655
+ * parseable `package.json` whose `name` equals the directory name. This
656
+ * mirrors the external plugin loader's recognition gate, which skips any
657
+ * directory whose `manifest.name` does not match its directory name.
658
+ */
659
+ function isRecognizedPluginDir(pluginDir: string, dirName: string): boolean {
660
+ const manifestPath = join(pluginDir, "package.json");
661
+ if (!existsSync(manifestPath)) return false;
662
+ try {
663
+ const parsed: unknown = JSON.parse(readFileSync(manifestPath, "utf-8"));
664
+ return (
665
+ typeof parsed === "object" &&
666
+ parsed !== null &&
667
+ "name" in parsed &&
668
+ (parsed as { name: unknown }).name === dirName
669
+ );
670
+ } catch (err) {
671
+ log.warn(
672
+ { err, manifestPath },
673
+ "Skipping plugin dir with unparseable package.json for resident skills",
674
+ );
675
+ return false;
676
+ }
677
+ }
678
+
679
+ /**
680
+ * Discover skills shipped on disk inside installed plugins. Each installed
681
+ * plugin — a directory under `<workspaceDir>/plugins/` recognized by
682
+ * {@link isRecognizedPluginDir} — may ship skills at `skills/<id>/SKILL.md`.
683
+ * Returned summaries are attributed to the owning plugin via `pluginName`.
684
+ */
685
+ function discoverPluginResidentSkills(): SkillSummary[] {
686
+ const pluginsDir = getWorkspacePluginsDir();
687
+ if (!existsSync(pluginsDir)) return [];
688
+
689
+ let entries: Dirent[];
690
+ try {
691
+ entries = readdirSync(pluginsDir, { withFileTypes: true });
692
+ } catch (err) {
693
+ log.warn(
694
+ { err, pluginsDir },
695
+ "Failed to read plugins directory for resident skills",
696
+ );
697
+ return [];
698
+ }
699
+
700
+ const summaries: SkillSummary[] = [];
701
+ for (const entry of entries) {
702
+ if (!entry.isDirectory() && !entry.isSymbolicLink()) continue;
703
+ const pluginDir = join(pluginsDir, entry.name);
704
+ // Mirror the plugin loader's recognition gate: a directory is a real
705
+ // installed plugin only if it carries a parseable `package.json` whose
706
+ // `name` matches the directory. This rejects staging dirs, stray files,
707
+ // and malformed/mismatched clones (e.g. an un-adapted `caveman-installer`)
708
+ // that the loader itself would skip, so the catalog never surfaces skills
709
+ // from a directory the runtime would refuse to load.
710
+ if (!isRecognizedPluginDir(pluginDir, entry.name)) continue;
711
+
712
+ const skillsDir = join(pluginDir, "skills");
713
+ if (!existsSync(skillsDir)) continue;
714
+
715
+ for (const directory of discoverSkillDirectories(skillsDir)) {
716
+ const skill = readSkillFromDirectory(directory, skillsDir, "plugin");
717
+ if (!skill) continue;
718
+ summaries.push({
719
+ ...skillSummaryFromDefinition(skill, "plugin"),
720
+ pluginName: entry.name,
721
+ });
722
+ }
723
+ }
724
+
725
+ return summaries;
726
+ }
727
+
649
728
  // ─── Catalog loading ─────────────────────────────────────────────────────────
650
729
 
651
730
  function skillSummaryFromDefinition(
@@ -754,12 +833,11 @@ export function loadSkillCatalog(
754
833
  catalog.push(skill);
755
834
  }
756
835
 
757
- // Load plugin-contributed skills. They sit above bundled/extra but below
758
- // managed and workspace so that user-authored filesystem skills can
759
- // override a plugin-provided skill by declaring the same id under
760
- // `~/.vellum/workspace/skills/`. Registration is owned by the plugin
761
- // bootstrap — this call is a pure read against the in-memory registry.
762
- const pluginSkills = getPluginContributedSkillSummaries();
836
+ // Discover skills shipped on disk inside installed plugins. They sit above
837
+ // bundled/extra but below managed and workspace so a user-authored
838
+ // filesystem skill can override a plugin-provided skill by declaring the
839
+ // same id under `$VELLUM_WORKSPACE_DIR/skills/`.
840
+ const pluginSkills = discoverPluginResidentSkills();
763
841
  for (const skill of pluginSkills) {
764
842
  if (seenIds.has(skill.id)) {
765
843
  const existingIndex = catalog.findIndex((s) => s.id === skill.id);
@@ -769,14 +847,14 @@ export function loadSkillCatalog(
769
847
  catalog[existingIndex].source === "extra")
770
848
  ) {
771
849
  log.info(
772
- { id: skill.id, pluginSkill: true },
850
+ { id: skill.id, pluginName: skill.pluginName },
773
851
  "Plugin skill overrides bundled/extra skill",
774
852
  );
775
853
  catalog[existingIndex] = skill;
776
854
  continue;
777
855
  }
778
856
  log.warn(
779
- { id: skill.id },
857
+ { id: skill.id, pluginName: skill.pluginName },
780
858
  "Skipping duplicate plugin skill id (already present in catalog)",
781
859
  );
782
860
  continue;
@@ -992,41 +1070,13 @@ export function listReferenceFiles(directoryPath: string): string | null {
992
1070
  }
993
1071
 
994
1072
  function loadSkillDefinition(skill: SkillSummary): SkillLookupResult {
995
- // Plugin-contributed skills live in-memory, not on disk. The registry
996
- // (see `plugins/plugin-skill-contributions.ts`) stores a pre-built
997
- // SkillDefinition we can return directly — no file read, no frontmatter
998
- // parse. We still run placeholder / feature-gate substitution on the
999
- // body so plugin skills behave the same as filesystem skills from the
1000
- // model's perspective.
1001
- if (skill.source === "plugin") {
1002
- const pluginDef = getPluginContributedSkillDefinition(skill.id);
1003
- if (!pluginDef) {
1004
- // The skill was in the catalog when the selector ran but has since
1005
- // been unregistered (plugin hot-reload, shutdown race). Fail loudly
1006
- // rather than returning a mystery undefined.
1007
- return {
1008
- error: `Plugin-contributed skill "${skill.id}" is no longer registered`,
1009
- };
1010
- }
1011
- // Shallow-clone so mutating the returned `body` below does not touch
1012
- // the registry's stored copy — the registry must stay the source of
1013
- // truth across repeated `skill_load` calls.
1014
- const loaded: SkillDefinition = { ...pluginDef };
1015
- loaded.body = loaded.body.replaceAll("{baseDir}", loaded.directoryPath);
1016
- loaded.body = loaded.body.replaceAll(
1017
- "{workspaceDir}",
1018
- getWorkspaceDirDisplay(),
1019
- );
1020
- loaded.body = applyFeatureGatedSections(loaded.body);
1021
- return { skill: loaded };
1022
- }
1023
-
1024
1073
  let loaded: SkillDefinition | null;
1025
1074
  if (skill.bundled) {
1026
1075
  loaded = readBundledSkillFromDirectory(skill.directoryPath);
1027
- } else if (skill.source === "workspace") {
1028
- // Workspace skills live outside ~/.vellum/workspace/skills, so use their parent
1029
- // directory as the root to avoid the isOutsideSkillsRoot rejection.
1076
+ } else if (skill.source === "workspace" || skill.source === "plugin") {
1077
+ // Workspace and plugin-resident skills live outside
1078
+ // $VELLUM_WORKSPACE_DIR/skills, so use the skill's parent directory as the
1079
+ // root to avoid the isOutsideSkillsRoot rejection.
1030
1080
  loaded = readSkillFromDirectory(
1031
1081
  skill.directoryPath,
1032
1082
  dirname(skill.directoryPath),
@@ -1042,6 +1092,7 @@ function loadSkillDefinition(skill: SkillSummary): SkillLookupResult {
1042
1092
  if (!loaded) {
1043
1093
  return { error: `Failed to load SKILL.md for "${skill.id}"` };
1044
1094
  }
1095
+ loaded.pluginName = skill.pluginName;
1045
1096
  // Replace {baseDir} placeholders with the actual skill directory path
1046
1097
  loaded.body = loaded.body.replaceAll("{baseDir}", loaded.directoryPath);
1047
1098
  // Replace {workspaceDir} placeholders with the runtime workspace display path