@namzu/sdk 69.2.0 → 69.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/authorization/readonly-commands.d.ts.map +1 -1
  3. package/dist/authorization/readonly-commands.js +30 -2
  4. package/dist/authorization/readonly-commands.js.map +1 -1
  5. package/dist/constants/plugin/index.d.ts +8 -0
  6. package/dist/constants/plugin/index.d.ts.map +1 -1
  7. package/dist/constants/plugin/index.js +8 -0
  8. package/dist/constants/plugin/index.js.map +1 -1
  9. package/dist/plugin/common-layout/index.d.ts +5 -0
  10. package/dist/plugin/common-layout/index.d.ts.map +1 -0
  11. package/dist/plugin/common-layout/index.js +3 -0
  12. package/dist/plugin/common-layout/index.js.map +1 -0
  13. package/dist/plugin/common-layout/mcp.d.ts +21 -0
  14. package/dist/plugin/common-layout/mcp.d.ts.map +1 -0
  15. package/dist/plugin/common-layout/mcp.js +305 -0
  16. package/dist/plugin/common-layout/mcp.js.map +1 -0
  17. package/dist/plugin/common-layout/paths.d.ts +27 -0
  18. package/dist/plugin/common-layout/paths.d.ts.map +1 -0
  19. package/dist/plugin/common-layout/paths.js +48 -0
  20. package/dist/plugin/common-layout/paths.js.map +1 -0
  21. package/dist/plugin/common-layout/read.d.ts +25 -0
  22. package/dist/plugin/common-layout/read.d.ts.map +1 -0
  23. package/dist/plugin/common-layout/read.js +1155 -0
  24. package/dist/plugin/common-layout/read.js.map +1 -0
  25. package/dist/plugin/common-layout/types.d.ts +66 -0
  26. package/dist/plugin/common-layout/types.d.ts.map +1 -0
  27. package/dist/plugin/common-layout/types.js +2 -0
  28. package/dist/plugin/common-layout/types.js.map +1 -0
  29. package/dist/plugin/common-layout-names.d.ts +65 -0
  30. package/dist/plugin/common-layout-names.d.ts.map +1 -0
  31. package/dist/plugin/common-layout-names.js +94 -0
  32. package/dist/plugin/common-layout-names.js.map +1 -0
  33. package/dist/plugin/hook-module/capabilities.d.ts +41 -0
  34. package/dist/plugin/hook-module/capabilities.d.ts.map +1 -0
  35. package/dist/plugin/hook-module/capabilities.js +438 -0
  36. package/dist/plugin/hook-module/capabilities.js.map +1 -0
  37. package/dist/plugin/hook-module/consent.d.ts +39 -0
  38. package/dist/plugin/hook-module/consent.d.ts.map +1 -0
  39. package/dist/plugin/hook-module/consent.js +59 -0
  40. package/dist/plugin/hook-module/consent.js.map +1 -0
  41. package/dist/plugin/hook-module/events.d.ts +33 -0
  42. package/dist/plugin/hook-module/events.d.ts.map +1 -0
  43. package/dist/plugin/hook-module/events.js +149 -0
  44. package/dist/plugin/hook-module/events.js.map +1 -0
  45. package/dist/plugin/hook-module/host.d.ts +79 -0
  46. package/dist/plugin/hook-module/host.d.ts.map +1 -0
  47. package/dist/plugin/hook-module/host.js +546 -0
  48. package/dist/plugin/hook-module/host.js.map +1 -0
  49. package/dist/plugin/hook-module/index.d.ts +11 -0
  50. package/dist/plugin/hook-module/index.d.ts.map +1 -0
  51. package/dist/plugin/hook-module/index.js +6 -0
  52. package/dist/plugin/hook-module/index.js.map +1 -0
  53. package/dist/plugin/hook-module/scan.d.ts +99 -0
  54. package/dist/plugin/hook-module/scan.d.ts.map +1 -0
  55. package/dist/plugin/hook-module/scan.js +789 -0
  56. package/dist/plugin/hook-module/scan.js.map +1 -0
  57. package/dist/plugin/hook-module/worker-source.d.ts +31 -0
  58. package/dist/plugin/hook-module/worker-source.d.ts.map +1 -0
  59. package/dist/plugin/hook-module/worker-source.js +498 -0
  60. package/dist/plugin/hook-module/worker-source.js.map +1 -0
  61. package/dist/plugin/index.d.ts +5 -2
  62. package/dist/plugin/index.d.ts.map +1 -1
  63. package/dist/plugin/index.js +4 -1
  64. package/dist/plugin/index.js.map +1 -1
  65. package/dist/plugin/lifecycle.d.ts +57 -0
  66. package/dist/plugin/lifecycle.d.ts.map +1 -1
  67. package/dist/plugin/lifecycle.js +92 -11
  68. package/dist/plugin/lifecycle.js.map +1 -1
  69. package/dist/plugin/loader.d.ts +30 -0
  70. package/dist/plugin/loader.d.ts.map +1 -1
  71. package/dist/plugin/loader.js +76 -19
  72. package/dist/plugin/loader.js.map +1 -1
  73. package/dist/plugin/shell-hook-env.d.ts +7 -0
  74. package/dist/plugin/shell-hook-env.d.ts.map +1 -1
  75. package/dist/plugin/shell-hook-env.js.map +1 -1
  76. package/dist/plugin/shell-hook.d.ts +10 -1
  77. package/dist/plugin/shell-hook.d.ts.map +1 -1
  78. package/dist/plugin/shell-hook.js +81 -70
  79. package/dist/plugin/shell-hook.js.map +1 -1
  80. package/dist/prompt/coding-agent-doctrine.d.ts +1 -1
  81. package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
  82. package/dist/prompt/coding-agent-doctrine.js +1 -1
  83. package/dist/provider/side-request-reasoning.d.ts.map +1 -1
  84. package/dist/provider/side-request-reasoning.js +5 -1
  85. package/dist/provider/side-request-reasoning.js.map +1 -1
  86. package/dist/public-runtime.d.ts +3 -2
  87. package/dist/public-runtime.d.ts.map +1 -1
  88. package/dist/public-runtime.js +2 -2
  89. package/dist/public-runtime.js.map +1 -1
  90. package/dist/runtime/query/auto-review/classifier.d.ts.map +1 -1
  91. package/dist/runtime/query/auto-review/classifier.js +13 -2
  92. package/dist/runtime/query/auto-review/classifier.js.map +1 -1
  93. package/dist/runtime/query/auto-review/failure.d.ts +12 -5
  94. package/dist/runtime/query/auto-review/failure.d.ts.map +1 -1
  95. package/dist/runtime/query/auto-review/failure.js +42 -7
  96. package/dist/runtime/query/auto-review/failure.js.map +1 -1
  97. package/dist/runtime/query/review-policy.d.ts.map +1 -1
  98. package/dist/runtime/query/review-policy.js +22 -6
  99. package/dist/runtime/query/review-policy.js.map +1 -1
  100. package/dist/runtime/query/turn/check-scope.d.ts +18 -0
  101. package/dist/runtime/query/turn/check-scope.d.ts.map +1 -0
  102. package/dist/runtime/query/turn/check-scope.js +90 -0
  103. package/dist/runtime/query/turn/check-scope.js.map +1 -0
  104. package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
  105. package/dist/runtime/query/turn/outcome-ledger.js +13 -0
  106. package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
  107. package/dist/skills/loader.d.ts +8 -2
  108. package/dist/skills/loader.d.ts.map +1 -1
  109. package/dist/skills/loader.js +22 -11
  110. package/dist/skills/loader.js.map +1 -1
  111. package/dist/skills/registry.d.ts.map +1 -1
  112. package/dist/skills/registry.js +9 -1
  113. package/dist/skills/registry.js.map +1 -1
  114. package/dist/tools/builtins/job.d.ts.map +1 -1
  115. package/dist/tools/builtins/job.js +4 -1
  116. package/dist/tools/builtins/job.js.map +1 -1
  117. package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
  118. package/dist/tools/builtins/wait-for-job.js +2 -1
  119. package/dist/tools/builtins/wait-for-job.js.map +1 -1
  120. package/dist/types/plugin/index.d.ts +73 -0
  121. package/dist/types/plugin/index.d.ts.map +1 -1
  122. package/dist/types/plugin/index.js +28 -6
  123. package/dist/types/plugin/index.js.map +1 -1
  124. package/dist/types/skills/index.d.ts +6 -0
  125. package/dist/types/skills/index.d.ts.map +1 -1
  126. package/package.json +2 -1
  127. package/src/authorization/readonly-commands.ts +30 -2
  128. package/src/constants/plugin/index.ts +9 -0
  129. package/src/plugin/common-layout/index.ts +19 -0
  130. package/src/plugin/common-layout/mcp.ts +362 -0
  131. package/src/plugin/common-layout/paths.ts +70 -0
  132. package/src/plugin/common-layout/read.ts +1282 -0
  133. package/src/plugin/common-layout/types.ts +77 -0
  134. package/src/plugin/common-layout-names.ts +108 -0
  135. package/src/plugin/hook-module/capabilities.ts +500 -0
  136. package/src/plugin/hook-module/consent.ts +96 -0
  137. package/src/plugin/hook-module/events.ts +177 -0
  138. package/src/plugin/hook-module/host.ts +649 -0
  139. package/src/plugin/hook-module/index.ts +52 -0
  140. package/src/plugin/hook-module/scan.ts +1004 -0
  141. package/src/plugin/hook-module/worker-source.ts +500 -0
  142. package/src/plugin/index.ts +13 -1
  143. package/src/plugin/lifecycle.ts +179 -17
  144. package/src/plugin/loader.ts +97 -18
  145. package/src/plugin/shell-hook-env.ts +7 -0
  146. package/src/plugin/shell-hook.ts +91 -70
  147. package/src/prompt/coding-agent-doctrine.ts +1 -1
  148. package/src/provider/side-request-reasoning.ts +5 -1
  149. package/src/public-runtime.ts +35 -0
  150. package/src/runtime/query/auto-review/classifier.ts +14 -2
  151. package/src/runtime/query/auto-review/failure.ts +52 -7
  152. package/src/runtime/query/review-policy.ts +30 -6
  153. package/src/runtime/query/turn/check-scope.ts +90 -0
  154. package/src/runtime/query/turn/outcome-ledger.ts +11 -0
  155. package/src/skills/loader.ts +26 -9
  156. package/src/skills/registry.ts +9 -1
  157. package/src/tools/builtins/job.ts +4 -1
  158. package/src/tools/builtins/wait-for-job.ts +3 -1
  159. package/src/types/plugin/index.ts +81 -24
  160. package/src/types/skills/index.ts +7 -0
@@ -152,7 +152,11 @@ function mappingAt(
152
152
  return found?.kind === 'mapping' ? found.entries : undefined
153
153
  }
154
154
 
155
- function toSkillMetadata(parsed: ParsedFrontmatter, dirPath: string): SkillMetadata {
155
+ function toSkillMetadata(
156
+ parsed: ParsedFrontmatter,
157
+ dirPath: string,
158
+ anyFolderName = false,
159
+ ): SkillMetadata {
156
160
  const source = sourceLabel(dirPath)
157
161
  const { values } = parsed
158
162
 
@@ -166,7 +170,7 @@ function toSkillMetadata(parsed: ParsedFrontmatter, dirPath: string): SkillMetad
166
170
  throw new Error(`${source} missing required field: description`)
167
171
  }
168
172
 
169
- validateSkillName(name, dirPath)
173
+ validateSkillName(name, dirPath, anyFolderName)
170
174
  validateDescription(description, dirPath)
171
175
 
172
176
  const skillMetadata: SkillMetadata = { name, description }
@@ -272,7 +276,7 @@ const REASONING_EFFORTS: readonly ReasoningEffort[] = [
272
276
 
273
277
  const SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/
274
278
 
275
- function validateSkillName(name: string, dirPath: string): void {
279
+ function validateSkillName(name: string, dirPath: string, anyFolderName = false): void {
276
280
  if (name.length > 64) {
277
281
  throw new Error(`SKILL.md at "${dirPath}": name exceeds 64 characters`)
278
282
  }
@@ -282,7 +286,7 @@ function validateSkillName(name: string, dirPath: string): void {
282
286
  )
283
287
  }
284
288
  const expectedName = basename(dirPath)
285
- if (name !== expectedName) {
289
+ if (!anyFolderName && name !== expectedName) {
286
290
  throw new Error(
287
291
  `SKILL.md at "${dirPath}": name "${name}" must match directory name "${expectedName}"`,
288
292
  )
@@ -313,23 +317,30 @@ function estimateTokens(text: string): number {
313
317
  * so the two cannot disagree about what a valid skill is.
314
318
  *
315
319
  * @param dirPath The skill's folder: the name must match its last segment.
320
+ * @param options `anyFolderName` skips that match, for a plugin whose own folder
321
+ * is the skill (the folder is named for a version, not the skill).
316
322
  */
317
323
  export function parseSkillMarkdown(
318
324
  raw: string,
319
325
  dirPath: string,
326
+ options?: { readonly anyFolderName?: boolean },
320
327
  ): { readonly metadata: SkillMetadata; readonly body: string } {
321
328
  const parsed = parseFrontmatter(raw, sourceLabel(dirPath), SKILL_FRONTMATTER_OPTIONS)
322
- return { metadata: toSkillMetadata(parsed, dirPath), body: parsed.body }
329
+ return {
330
+ metadata: toSkillMetadata(parsed, dirPath, options?.anyFolderName === true),
331
+ body: parsed.body,
332
+ }
323
333
  }
324
334
 
325
335
  export async function loadSkill(
326
336
  dirPath: string,
327
337
  level: SkillDisclosureLevel = 'metadata',
328
338
  log?: Logger,
339
+ options?: { readonly anyFolderName?: boolean },
329
340
  ): Promise<SkillLoadResult> {
330
341
  const skillMdPath = join(dirPath, SKILL_FILENAME)
331
342
  const raw = await readFile(skillMdPath, 'utf-8')
332
- const parsedSkill = parseSkillMarkdown(raw, dirPath)
343
+ const parsedSkill = parseSkillMarkdown(raw, dirPath, options)
333
344
  const metadata = parsedSkill.metadata
334
345
 
335
346
  const skill: Skill = {
@@ -354,7 +365,9 @@ export async function loadSkill(
354
365
  // it. Without a `log`, this loader emits nothing (`resolveLogger` is
355
366
  // `NOOP_LOGGER`), which is the deliberate default rather than a fallback
356
367
  // to somebody else's stream.
357
- const logger = resolveLogger(log).child({ [SCOPE_ATTRIBUTE]: 'skills/loader' })
368
+ const logger = resolveLogger(log).child({
369
+ [SCOPE_ATTRIBUTE]: 'skills/loader',
370
+ })
358
371
  logger.debug('Loaded skill', {
359
372
  'namzu.skills.name': metadata.name,
360
373
  'namzu.skills.level': level,
@@ -371,7 +384,9 @@ export async function loadSkill(
371
384
  export async function discoverSkills(parentDir: string, log?: Logger): Promise<string[]> {
372
385
  // Resolved here too — see loadSkill above for why module scope froze
373
386
  // this logger's level, and its very reference, at import time.
374
- const logger = resolveLogger(log).child({ [SCOPE_ATTRIBUTE]: 'skills/loader' })
387
+ const logger = resolveLogger(log).child({
388
+ [SCOPE_ATTRIBUTE]: 'skills/loader',
389
+ })
375
390
  const dirs: string[] = []
376
391
 
377
392
  try {
@@ -389,7 +404,9 @@ export async function discoverSkills(parentDir: string, log?: Logger): Promise<s
389
404
  } catch {}
390
405
  }
391
406
  } catch {
392
- logger.debug('Skills directory not found', { 'namzu.skills.parent_dir': parentDir })
407
+ logger.debug('Skills directory not found', {
408
+ 'namzu.skills.parent_dir': parentDir,
409
+ })
393
410
  }
394
411
 
395
412
  return dirs.sort()
@@ -11,6 +11,7 @@ import {
11
11
  import { SCOPE_ATTRIBUTE } from '../utils/log/types.js'
12
12
  import { type Logger, resolveLogger } from '../utils/logger.js'
13
13
 
14
+ import { expandPluginRootText } from '../plugin/common-layout/paths.js'
14
15
  import { SKILL_FILENAME, discoverSkills, loadSkill } from './loader.js'
15
16
 
16
17
  /** Two skills claiming one registered name. */
@@ -205,7 +206,14 @@ export class SkillRegistry {
205
206
  // registry the registered one, which is the divergence this re-keying
206
207
  // exists to prevent, reintroduced one line below the comment saying
207
208
  // so.
208
- const rekeyed: Skill = { ...result.skill, metadata: { ...result.skill.metadata, name } }
209
+ const rekeyed: Skill = {
210
+ ...result.skill,
211
+ ...(result.skill.body !== undefined && existing.pluginRoot !== undefined
212
+ ? { body: expandPluginRootText(result.skill.body, existing.pluginRoot) }
213
+ : {}),
214
+ ...(existing.pluginRoot !== undefined ? { pluginRoot: existing.pluginRoot } : {}),
215
+ metadata: { ...result.skill.metadata, name },
216
+ }
209
217
  this.skills.set(name, rekeyed)
210
218
  await this.stamp(name, existing.dirPath)
211
219
  return { ...result, skill: rekeyed }
@@ -63,7 +63,10 @@ export const JobTool = defineTool({
63
63
  const label =
64
64
  input.action === 'list'
65
65
  ? 'List background jobs'
66
- : `${input.action === 'kill' ? 'Stop background job' : 'Read background output'} · ${input.id ?? '(missing id)'}`
66
+ : // No id in the row: it is the model's handle on the job, not something the person reads.
67
+ input.action === 'kill'
68
+ ? 'Stop background job'
69
+ : 'Read background output'
67
70
  return { kind: 'generic', presentation: 'activity', label }
68
71
  },
69
72
 
@@ -119,7 +119,9 @@ export const WaitForJobTool = defineTool({
119
119
  return {
120
120
  kind: 'generic',
121
121
  presentation: 'activity',
122
- label: `${input.output_contains === undefined ? 'Wait for background job' : 'Wait for job output'} · ${input.id ?? '(missing id)'}`,
122
+ // No id in the row: it is the model's handle on the job, not something the person reads.
123
+ label:
124
+ input.output_contains === undefined ? 'Wait for background job' : 'Wait for job output',
123
125
  }
124
126
  },
125
127
 
@@ -1,5 +1,9 @@
1
1
  import { z } from 'zod'
2
2
  import {
3
+ COMMON_LAYOUT_MAX_AGENTS,
4
+ COMMON_LAYOUT_MAX_COMMANDS,
5
+ COMMON_LAYOUT_MAX_MCP_SERVERS,
6
+ COMMON_LAYOUT_MAX_SKILLS,
3
7
  MAX_AGENT_DIRS_PER_PLUGIN,
4
8
  MAX_COMMAND_DIRS_PER_PLUGIN,
5
9
  MAX_CONNECTORS_PER_PLUGIN,
@@ -839,7 +843,9 @@ export type PluginHookResultFor<E extends PluginHookEvent> = E extends 'user_pro
839
843
  : E extends 'pre_compact'
840
844
  ? Extract<
841
845
  PluginHookResult,
842
- { action: 'continue' | 'annotate' | 'skip' | 'error' }
846
+ {
847
+ action: 'continue' | 'annotate' | 'skip' | 'error'
848
+ }
843
849
  >
844
850
  : E extends 'turn_end' | 'subagent_stop'
845
851
  ? Extract<PluginHookResult, { action: 'continue' | 'skip' | 'error' }>
@@ -902,6 +908,19 @@ export interface PluginMCPServerConfig {
902
908
  readonly connectTimeoutMs?: number
903
909
  }
904
910
 
911
+ /**
912
+ * A server a plugin reaches over the network instead of starting. It is read
913
+ * and reported; nothing connects to it yet, and the plugin file holds no
914
+ * secret (a header value may name an environment variable as `${NAME}`).
915
+ */
916
+ export interface PluginRemoteMCPServerConfig {
917
+ readonly name: string
918
+ readonly url: string
919
+ /** Absent means `http`. */
920
+ readonly transport?: 'http' | 'sse'
921
+ readonly headers?: Readonly<Record<string, string>>
922
+ }
923
+
905
924
  // ---------------------------------------------------------------------------
906
925
  // Plugin manifest — validated at load time
907
926
  // ---------------------------------------------------------------------------
@@ -928,6 +947,8 @@ export interface PluginManifest {
928
947
  */
929
948
  readonly hookEntries?: Readonly<Record<string, unknown>>
930
949
  readonly mcpServers?: readonly PluginMCPServerConfig[]
950
+ /** Servers reached over the network: read and reported, never started by the lifecycle. */
951
+ readonly remoteMcpServers?: readonly PluginRemoteMCPServerConfig[]
931
952
  readonly connectors?: readonly string[]
932
953
  readonly personas?: readonly string[]
933
954
  /**
@@ -946,6 +967,11 @@ export interface PluginManifest {
946
967
  readonly platforms?: readonly string[]
947
968
  /** Runtime versions the plugin supports. Absent means any. */
948
969
  readonly engines?: { readonly namzu?: string }
970
+ /**
971
+ * Which layout the manifest was read from. Set only by the common-layout
972
+ * reader, never by the schema: a `plugin.json` cannot claim it.
973
+ */
974
+ readonly layout?: 'common'
949
975
  }
950
976
 
951
977
  export const PluginMCPServerConfigSchema = z
@@ -958,6 +984,15 @@ export const PluginMCPServerConfigSchema = z
958
984
  })
959
985
  .strict()
960
986
 
987
+ export const PluginRemoteMCPServerConfigSchema = z
988
+ .object({
989
+ name: z.string().min(1),
990
+ url: z.string().min(1).max(2048),
991
+ transport: z.enum(['http', 'sse']).optional(),
992
+ headers: z.record(z.string(), z.string()).optional(),
993
+ })
994
+ .strict()
995
+
961
996
  /** A folder inside the plugin: relative, no `..` step, no drive or root. */
962
997
  const PluginRelativeDirSchema = z
963
998
  .string()
@@ -968,29 +1003,51 @@ const PluginRelativeDirSchema = z
968
1003
  'must be a folder inside the plugin, with no ".." and no absolute path',
969
1004
  )
970
1005
 
971
- export const PluginManifestSchema = z.object({
972
- name: z
973
- .string()
974
- .min(1)
975
- .max(PLUGIN_NAME_MAX_LENGTH)
976
- .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'Plugin name must be lowercase kebab-case'),
977
- version: z.string().min(1),
978
- description: z.string().min(1),
979
- author: z.string().optional(),
980
- instructions: z.string().min(1).optional(),
981
- tools: z.array(z.string()).max(MAX_TOOLS_PER_PLUGIN).optional(),
982
- skills: z.array(z.string()).max(MAX_SKILLS_PER_PLUGIN).optional(),
983
- hooks: z.array(z.string()).max(MAX_HOOKS_PER_PLUGIN).optional(),
984
- hookEntries: z.record(z.string(), z.unknown()).optional(),
985
- mcpServers: z.array(PluginMCPServerConfigSchema).max(MAX_MCP_SERVERS_PER_PLUGIN).optional(),
986
- connectors: z.array(z.string()).max(MAX_CONNECTORS_PER_PLUGIN).optional(),
987
- personas: z.array(z.string()).max(MAX_PERSONAS_PER_PLUGIN).optional(),
988
- commands: z.array(PluginRelativeDirSchema).max(MAX_COMMAND_DIRS_PER_PLUGIN).optional(),
989
- agents: z.array(PluginRelativeDirSchema).max(MAX_AGENT_DIRS_PER_PLUGIN).optional(),
990
- /** Operating systems the plugin supports, as `process.platform` names them. Absent means all. */
991
- platforms: z.array(z.string().min(1)).max(16).optional(),
992
- /** Runtime versions the plugin supports. Absent means any. */
993
- engines: z.object({ namzu: z.string().min(1).max(200).optional() }).optional(),
1006
+ const makePluginManifestSchema = (limits: {
1007
+ readonly mcpServers: number
1008
+ readonly skills: number
1009
+ readonly commands: number
1010
+ readonly agents: number
1011
+ }) =>
1012
+ z.object({
1013
+ name: z
1014
+ .string()
1015
+ .min(1)
1016
+ .max(PLUGIN_NAME_MAX_LENGTH)
1017
+ .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'Plugin name must be lowercase kebab-case'),
1018
+ version: z.string().min(1),
1019
+ description: z.string().min(1),
1020
+ author: z.string().optional(),
1021
+ instructions: z.string().min(1).optional(),
1022
+ tools: z.array(z.string()).max(MAX_TOOLS_PER_PLUGIN).optional(),
1023
+ skills: z.array(z.string()).max(limits.skills).optional(),
1024
+ hooks: z.array(z.string()).max(MAX_HOOKS_PER_PLUGIN).optional(),
1025
+ hookEntries: z.record(z.string(), z.unknown()).optional(),
1026
+ mcpServers: z.array(PluginMCPServerConfigSchema).max(limits.mcpServers).optional(),
1027
+ remoteMcpServers: z.array(PluginRemoteMCPServerConfigSchema).max(limits.mcpServers).optional(),
1028
+ connectors: z.array(z.string()).max(MAX_CONNECTORS_PER_PLUGIN).optional(),
1029
+ personas: z.array(z.string()).max(MAX_PERSONAS_PER_PLUGIN).optional(),
1030
+ commands: z.array(PluginRelativeDirSchema).max(limits.commands).optional(),
1031
+ agents: z.array(PluginRelativeDirSchema).max(limits.agents).optional(),
1032
+ /** Operating systems the plugin supports, as `process.platform` names them. Absent means all. */
1033
+ platforms: z.array(z.string().min(1)).max(16).optional(),
1034
+ /** Runtime versions the plugin supports. Absent means any. */
1035
+ engines: z.object({ namzu: z.string().min(1).max(200).optional() }).optional(),
1036
+ })
1037
+
1038
+ export const PluginManifestSchema = makePluginManifestSchema({
1039
+ mcpServers: MAX_MCP_SERVERS_PER_PLUGIN,
1040
+ skills: MAX_SKILLS_PER_PLUGIN,
1041
+ commands: MAX_COMMAND_DIRS_PER_PLUGIN,
1042
+ agents: MAX_AGENT_DIRS_PER_PLUGIN,
1043
+ })
1044
+
1045
+ /** The same shape with the larger limits a plugin in the common plugin layout may use. */
1046
+ export const CommonLayoutManifestSchema = makePluginManifestSchema({
1047
+ mcpServers: COMMON_LAYOUT_MAX_MCP_SERVERS,
1048
+ skills: COMMON_LAYOUT_MAX_SKILLS,
1049
+ commands: COMMON_LAYOUT_MAX_COMMANDS,
1050
+ agents: COMMON_LAYOUT_MAX_AGENTS,
994
1051
  })
995
1052
 
996
1053
  // ---------------------------------------------------------------------------
@@ -133,6 +133,13 @@ export interface Skill {
133
133
  body?: string
134
134
 
135
135
  dirPath: string
136
+
137
+ /**
138
+ * The folder of the plugin that contributed this skill. Set by the plugin
139
+ * lifecycle; the registry puts it in for `\${NAMZU_PLUGIN_ROOT}` (and the
140
+ * common layout's spelling of it) when the body is read.
141
+ */
142
+ pluginRoot?: string
136
143
  }
137
144
 
138
145
  export type SkillDisclosureLevel = 'metadata' | 'full' | 'assets'