@kolisachint/hoocode-agent 0.5.2 → 0.5.4

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 (174) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/cli/args.d.ts +1 -1
  3. package/dist/cli/args.d.ts.map +1 -1
  4. package/dist/cli/args.js +10 -7
  5. package/dist/cli/args.js.map +1 -1
  6. package/dist/core/agent-session.d.ts.map +1 -1
  7. package/dist/core/agent-session.js +10 -2
  8. package/dist/core/agent-session.js.map +1 -1
  9. package/dist/core/capabilities/deferral.d.ts +78 -0
  10. package/dist/core/capabilities/deferral.d.ts.map +1 -0
  11. package/dist/core/capabilities/deferral.js +99 -0
  12. package/dist/core/capabilities/deferral.js.map +1 -0
  13. package/dist/core/capabilities/dense.d.ts +51 -0
  14. package/dist/core/capabilities/dense.d.ts.map +1 -0
  15. package/dist/core/capabilities/dense.js +121 -0
  16. package/dist/core/capabilities/dense.js.map +1 -0
  17. package/dist/core/capabilities/lexical.d.ts +43 -0
  18. package/dist/core/capabilities/lexical.d.ts.map +1 -0
  19. package/dist/core/capabilities/lexical.js +104 -0
  20. package/dist/core/capabilities/lexical.js.map +1 -0
  21. package/dist/core/capabilities/registry.d.ts +56 -0
  22. package/dist/core/capabilities/registry.d.ts.map +1 -0
  23. package/dist/core/capabilities/registry.js +0 -0
  24. package/dist/core/capabilities/registry.js.map +1 -0
  25. package/dist/core/capabilities/search.d.ts +47 -0
  26. package/dist/core/capabilities/search.d.ts.map +1 -0
  27. package/dist/core/capabilities/search.js +82 -0
  28. package/dist/core/capabilities/search.js.map +1 -0
  29. package/dist/core/extensions/loader.d.ts +27 -3
  30. package/dist/core/extensions/loader.d.ts.map +1 -1
  31. package/dist/core/extensions/loader.js +61 -7
  32. package/dist/core/extensions/loader.js.map +1 -1
  33. package/dist/core/extensions/plugins/authoring.d.ts +56 -9
  34. package/dist/core/extensions/plugins/authoring.d.ts.map +1 -1
  35. package/dist/core/extensions/plugins/authoring.js +0 -0
  36. package/dist/core/extensions/plugins/authoring.js.map +1 -1
  37. package/dist/core/extensions/plugins/drift.d.ts +75 -0
  38. package/dist/core/extensions/plugins/drift.d.ts.map +1 -0
  39. package/dist/core/extensions/plugins/drift.js +194 -0
  40. package/dist/core/extensions/plugins/drift.js.map +1 -0
  41. package/dist/core/extensions/plugins/formats/claude.d.ts.map +1 -1
  42. package/dist/core/extensions/plugins/formats/claude.js +5 -0
  43. package/dist/core/extensions/plugins/formats/claude.js.map +1 -1
  44. package/dist/core/extensions/plugins/formats/copilot.d.ts +6 -0
  45. package/dist/core/extensions/plugins/formats/copilot.d.ts.map +1 -1
  46. package/dist/core/extensions/plugins/formats/copilot.js +57 -16
  47. package/dist/core/extensions/plugins/formats/copilot.js.map +1 -1
  48. package/dist/core/extensions/plugins/formats/index.d.ts +39 -1
  49. package/dist/core/extensions/plugins/formats/index.d.ts.map +1 -1
  50. package/dist/core/extensions/plugins/formats/index.js +90 -13
  51. package/dist/core/extensions/plugins/formats/index.js.map +1 -1
  52. package/dist/core/extensions/plugins/formats/jsonManifest.d.ts +14 -0
  53. package/dist/core/extensions/plugins/formats/jsonManifest.d.ts.map +1 -1
  54. package/dist/core/extensions/plugins/formats/jsonManifest.js +37 -4
  55. package/dist/core/extensions/plugins/formats/jsonManifest.js.map +1 -1
  56. package/dist/core/extensions/plugins/formats/platform-targets.d.ts +48 -24
  57. package/dist/core/extensions/plugins/formats/platform-targets.d.ts.map +1 -1
  58. package/dist/core/extensions/plugins/formats/platform-targets.js +62 -30
  59. package/dist/core/extensions/plugins/formats/platform-targets.js.map +1 -1
  60. package/dist/core/extensions/plugins/formats/shared.d.ts +22 -0
  61. package/dist/core/extensions/plugins/formats/shared.d.ts.map +1 -1
  62. package/dist/core/extensions/plugins/formats/shared.js +81 -4
  63. package/dist/core/extensions/plugins/formats/shared.js.map +1 -1
  64. package/dist/core/extensions/plugins/formats/types.d.ts +10 -1
  65. package/dist/core/extensions/plugins/formats/types.d.ts.map +1 -1
  66. package/dist/core/extensions/plugins/formats/types.js.map +1 -1
  67. package/dist/core/extensions/plugins/gates.d.ts +64 -0
  68. package/dist/core/extensions/plugins/gates.d.ts.map +1 -0
  69. package/dist/core/extensions/plugins/gates.js +297 -0
  70. package/dist/core/extensions/plugins/gates.js.map +1 -0
  71. package/dist/core/extensions/plugins/hooks-bridge.d.ts +1 -1
  72. package/dist/core/extensions/plugins/hooks-bridge.d.ts.map +1 -1
  73. package/dist/core/extensions/plugins/hooks-bridge.js +12 -8
  74. package/dist/core/extensions/plugins/hooks-bridge.js.map +1 -1
  75. package/dist/core/extensions/plugins/index.d.ts +36 -5
  76. package/dist/core/extensions/plugins/index.d.ts.map +1 -1
  77. package/dist/core/extensions/plugins/index.js +66 -15
  78. package/dist/core/extensions/plugins/index.js.map +1 -1
  79. package/dist/core/extensions/plugins/install.d.ts +43 -24
  80. package/dist/core/extensions/plugins/install.d.ts.map +1 -1
  81. package/dist/core/extensions/plugins/install.js +167 -54
  82. package/dist/core/extensions/plugins/install.js.map +1 -1
  83. package/dist/core/extensions/plugins/locations.d.ts +84 -0
  84. package/dist/core/extensions/plugins/locations.d.ts.map +1 -0
  85. package/dist/core/extensions/plugins/locations.js +137 -0
  86. package/dist/core/extensions/plugins/locations.js.map +1 -0
  87. package/dist/core/extensions/plugins/manifest.d.ts +21 -1
  88. package/dist/core/extensions/plugins/manifest.d.ts.map +1 -1
  89. package/dist/core/extensions/plugins/manifest.js +2 -2
  90. package/dist/core/extensions/plugins/manifest.js.map +1 -1
  91. package/dist/core/extensions/plugins/packaging.d.ts +115 -0
  92. package/dist/core/extensions/plugins/packaging.d.ts.map +1 -0
  93. package/dist/core/extensions/plugins/packaging.js +362 -0
  94. package/dist/core/extensions/plugins/packaging.js.map +1 -0
  95. package/dist/core/extensions/plugins/smoke.d.ts +33 -0
  96. package/dist/core/extensions/plugins/smoke.d.ts.map +1 -0
  97. package/dist/core/extensions/plugins/smoke.js +231 -0
  98. package/dist/core/extensions/plugins/smoke.js.map +1 -0
  99. package/dist/core/extensions/plugins/trigger-eval.d.ts +136 -0
  100. package/dist/core/extensions/plugins/trigger-eval.d.ts.map +1 -0
  101. package/dist/core/extensions/plugins/trigger-eval.js +0 -0
  102. package/dist/core/extensions/plugins/trigger-eval.js.map +1 -0
  103. package/dist/core/package-manager.d.ts +6 -0
  104. package/dist/core/package-manager.d.ts.map +1 -1
  105. package/dist/core/package-manager.js.map +1 -1
  106. package/dist/core/resource-loader.d.ts +2 -0
  107. package/dist/core/resource-loader.d.ts.map +1 -1
  108. package/dist/core/resource-loader.js +15 -0
  109. package/dist/core/resource-loader.js.map +1 -1
  110. package/dist/core/settings-manager.d.ts +2 -2
  111. package/dist/core/settings-manager.d.ts.map +1 -1
  112. package/dist/core/settings-manager.js +3 -3
  113. package/dist/core/settings-manager.js.map +1 -1
  114. package/dist/core/settings-types.d.ts +1 -1
  115. package/dist/core/settings-types.d.ts.map +1 -1
  116. package/dist/core/settings-types.js.map +1 -1
  117. package/dist/core/skills.d.ts +9 -0
  118. package/dist/core/skills.d.ts.map +1 -1
  119. package/dist/core/skills.js +23 -3
  120. package/dist/core/skills.js.map +1 -1
  121. package/dist/core/tools/package-plugin.d.ts +19 -0
  122. package/dist/core/tools/package-plugin.d.ts.map +1 -0
  123. package/dist/core/tools/package-plugin.js +81 -0
  124. package/dist/core/tools/package-plugin.js.map +1 -0
  125. package/dist/core/tools/plugin-tool-names.d.ts +1 -0
  126. package/dist/core/tools/plugin-tool-names.d.ts.map +1 -1
  127. package/dist/core/tools/plugin-tool-names.js +6 -0
  128. package/dist/core/tools/plugin-tool-names.js.map +1 -1
  129. package/dist/core/tools/plugins.d.ts.map +1 -1
  130. package/dist/core/tools/plugins.js +48 -7
  131. package/dist/core/tools/plugins.js.map +1 -1
  132. package/dist/core/tools/propose-plugin.d.ts.map +1 -1
  133. package/dist/core/tools/propose-plugin.js +49 -21
  134. package/dist/core/tools/propose-plugin.js.map +1 -1
  135. package/dist/core/tools/webfetch.d.ts +3 -1
  136. package/dist/core/tools/webfetch.d.ts.map +1 -1
  137. package/dist/core/tools/webfetch.js +8 -2
  138. package/dist/core/tools/webfetch.js.map +1 -1
  139. package/dist/core/tools/websearch.d.ts +2 -0
  140. package/dist/core/tools/websearch.d.ts.map +1 -1
  141. package/dist/core/tools/websearch.js +2 -1
  142. package/dist/core/tools/websearch.js.map +1 -1
  143. package/dist/core/tools/webtools-shared.d.ts +23 -2
  144. package/dist/core/tools/webtools-shared.d.ts.map +1 -1
  145. package/dist/core/tools/webtools-shared.js +59 -9
  146. package/dist/core/tools/webtools-shared.js.map +1 -1
  147. package/dist/extensions/core/marketplace.d.ts +14 -3
  148. package/dist/extensions/core/marketplace.d.ts.map +1 -1
  149. package/dist/extensions/core/marketplace.js +77 -18
  150. package/dist/extensions/core/marketplace.js.map +1 -1
  151. package/dist/extensions/core/mcp-deferred.d.ts +39 -2
  152. package/dist/extensions/core/mcp-deferred.d.ts.map +1 -1
  153. package/dist/extensions/core/mcp-deferred.js +74 -10
  154. package/dist/extensions/core/mcp-deferred.js.map +1 -1
  155. package/dist/extensions/core/mcp-loader.d.ts.map +1 -1
  156. package/dist/extensions/core/mcp-loader.js +52 -9
  157. package/dist/extensions/core/mcp-loader.js.map +1 -1
  158. package/dist/extensions/core/scaffold.d.ts +3 -3
  159. package/dist/extensions/core/scaffold.d.ts.map +1 -1
  160. package/dist/extensions/core/scaffold.js +9 -9
  161. package/dist/extensions/core/scaffold.js.map +1 -1
  162. package/dist/main.d.ts.map +1 -1
  163. package/dist/main.js +25 -7
  164. package/dist/main.js.map +1 -1
  165. package/dist/utils/tools-manager.d.ts +8 -0
  166. package/dist/utils/tools-manager.d.ts.map +1 -1
  167. package/dist/utils/tools-manager.js +12 -3
  168. package/dist/utils/tools-manager.js.map +1 -1
  169. package/docs/providers.md +11 -0
  170. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  171. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  172. package/examples/extensions/sandbox/package.json +1 -1
  173. package/examples/extensions/with-deps/package.json +1 -1
  174. package/package.json +5 -4
@@ -1 +1 @@
1
- {"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/core/skills.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAA6B,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AA2D9E,MAAM,WAAW,gBAAgB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,iGAAiG;IACjG,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACpC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,KAAK;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;IACvB,sBAAsB,EAAE,OAAO,CAAC;IAChC,mFAAmF;IACnF,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB;IAChC,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,WAAW,EAAE,kBAAkB,EAAE,CAAC;CAClC;AA+CD,MAAM,WAAW,wBAAwB;IACxC,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;CACf;AAsCD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,gBAAgB,CAGrF;AAsKD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CA6B7D;AAWD,MAAM,WAAW,iBAAiB;IACjC,kDAAkD;IAClD,GAAG,EAAE,MAAM,CAAC;IACZ,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,0CAA0C;IAC1C,eAAe,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAeD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAyGvE","sourcesContent":["import { existsSync, readdirSync, readFileSync, statSync } from \"fs\";\nimport ignore from \"ignore\";\nimport { homedir } from \"os\";\nimport { basename, dirname, isAbsolute, join, relative, resolve, sep } from \"path\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../config.js\";\nimport { parseFrontmatter } from \"../utils/frontmatter.js\";\nimport { canonicalizePath } from \"../utils/paths.js\";\nimport { normalizeTools } from \"./agent-frontmatter.js\";\nimport type { ResourceDiagnostic } from \"./diagnostics.js\";\nimport { createSyntheticSourceInfo, type SourceInfo } from \"./source-info.js\";\n\n/** Max name length per spec */\nconst MAX_NAME_LENGTH = 64;\n\n/** Max description length per spec */\nconst MAX_DESCRIPTION_LENGTH = 1024;\n\nconst IGNORE_FILE_NAMES = [\".gitignore\", \".ignore\", \".fdignore\"];\n\ntype IgnoreMatcher = ReturnType<typeof ignore>;\n\nfunction toPosixPath(p: string): string {\n\treturn p.split(sep).join(\"/\");\n}\n\nfunction prefixIgnorePattern(line: string, prefix: string): string | null {\n\tconst trimmed = line.trim();\n\tif (!trimmed) return null;\n\tif (trimmed.startsWith(\"#\") && !trimmed.startsWith(\"\\\\#\")) return null;\n\n\tlet pattern = line;\n\tlet negated = false;\n\n\tif (pattern.startsWith(\"!\")) {\n\t\tnegated = true;\n\t\tpattern = pattern.slice(1);\n\t} else if (pattern.startsWith(\"\\\\!\")) {\n\t\tpattern = pattern.slice(1);\n\t}\n\n\tif (pattern.startsWith(\"/\")) {\n\t\tpattern = pattern.slice(1);\n\t}\n\n\tconst prefixed = prefix ? `${prefix}${pattern}` : pattern;\n\treturn negated ? `!${prefixed}` : prefixed;\n}\n\nfunction addIgnoreRules(ig: IgnoreMatcher, dir: string, rootDir: string): void {\n\tconst relativeDir = relative(rootDir, dir);\n\tconst prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : \"\";\n\n\tfor (const filename of IGNORE_FILE_NAMES) {\n\t\tconst ignorePath = join(dir, filename);\n\t\tif (!existsSync(ignorePath)) continue;\n\t\ttry {\n\t\t\tconst content = readFileSync(ignorePath, \"utf-8\");\n\t\t\tconst patterns = content\n\t\t\t\t.split(/\\r?\\n/)\n\t\t\t\t.map((line) => prefixIgnorePattern(line, prefix))\n\t\t\t\t.filter((line): line is string => Boolean(line));\n\t\t\tif (patterns.length > 0) {\n\t\t\t\tig.add(patterns);\n\t\t\t}\n\t\t} catch {}\n\t}\n}\n\nexport interface SkillFrontmatter {\n\tname?: string;\n\tdescription?: string;\n\t\"disable-model-invocation\"?: boolean;\n\t/** Tools this skill requires. Mapped via the Claude Code alias table (same as agent `tools`). */\n\t\"allowed-tools\"?: string | string[];\n\t[key: string]: unknown;\n}\n\nexport interface Skill {\n\tname: string;\n\tdescription: string;\n\tfilePath: string;\n\tbaseDir: string;\n\tsourceInfo: SourceInfo;\n\tdisableModelInvocation: boolean;\n\t/** Normalized hoocode tool names this skill needs, parsed from `allowed-tools`. */\n\tallowedTools?: string[];\n}\n\nexport interface LoadSkillsResult {\n\tskills: Skill[];\n\tdiagnostics: ResourceDiagnostic[];\n}\n\n/**\n * Validate skill name per Agent Skills spec.\n * Returns array of validation error messages (empty if valid).\n */\nfunction validateName(name: string, parentDirName: string): string[] {\n\tconst errors: string[] = [];\n\n\tif (name !== parentDirName) {\n\t\terrors.push(`name \"${name}\" does not match parent directory \"${parentDirName}\"`);\n\t}\n\n\tif (name.length > MAX_NAME_LENGTH) {\n\t\terrors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);\n\t}\n\n\tif (!/^[a-z0-9-]+$/.test(name)) {\n\t\terrors.push(`name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)`);\n\t}\n\n\tif (name.startsWith(\"-\") || name.endsWith(\"-\")) {\n\t\terrors.push(`name must not start or end with a hyphen`);\n\t}\n\n\tif (name.includes(\"--\")) {\n\t\terrors.push(`name must not contain consecutive hyphens`);\n\t}\n\n\treturn errors;\n}\n\n/**\n * Validate description per Agent Skills spec.\n */\nfunction validateDescription(description: string | undefined): string[] {\n\tconst errors: string[] = [];\n\n\tif (!description || description.trim() === \"\") {\n\t\terrors.push(\"description is required\");\n\t} else if (description.length > MAX_DESCRIPTION_LENGTH) {\n\t\terrors.push(`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`);\n\t}\n\n\treturn errors;\n}\n\nexport interface LoadSkillsFromDirOptions {\n\t/** Directory to scan for skills */\n\tdir: string;\n\t/** Source identifier for these skills */\n\tsource: string;\n}\n\nfunction createSkillSourceInfo(filePath: string, baseDir: string, source: string): SourceInfo {\n\tswitch (source) {\n\t\tcase \"user\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tscope: \"user\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tcase \"project\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tscope: \"project\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tcase \"claude-user\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tscope: \"user\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tcase \"claude-project\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tscope: \"project\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tcase \"path\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tdefault:\n\t\t\treturn createSyntheticSourceInfo(filePath, { source, baseDir });\n\t}\n}\n\n/**\n * Load skills from a directory.\n *\n * Discovery rules:\n * - if a directory contains SKILL.md, treat it as a skill root and do not recurse further\n * - otherwise, load direct .md children in the root\n * - recurse into subdirectories to find SKILL.md\n */\nexport function loadSkillsFromDir(options: LoadSkillsFromDirOptions): LoadSkillsResult {\n\tconst { dir, source } = options;\n\treturn loadSkillsFromDirInternal(dir, source, true);\n}\n\nfunction loadSkillsFromDirInternal(\n\tdir: string,\n\tsource: string,\n\tincludeRootFiles: boolean,\n\tignoreMatcher?: IgnoreMatcher,\n\trootDir?: string,\n): LoadSkillsResult {\n\tconst skills: Skill[] = [];\n\tconst diagnostics: ResourceDiagnostic[] = [];\n\n\tif (!existsSync(dir)) {\n\t\treturn { skills, diagnostics };\n\t}\n\n\tconst root = rootDir ?? dir;\n\tconst ig = ignoreMatcher ?? ignore();\n\taddIgnoreRules(ig, dir, root);\n\n\ttry {\n\t\tconst entries = readdirSync(dir, { withFileTypes: true });\n\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.name !== \"SKILL.md\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst fullPath = join(dir, entry.name);\n\n\t\t\tlet isFile = entry.isFile();\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\ttry {\n\t\t\t\t\tisFile = statSync(fullPath).isFile();\n\t\t\t\t} catch {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst relPath = toPosixPath(relative(root, fullPath));\n\t\t\tif (!isFile || ig.ignores(relPath)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst result = loadSkillFromFile(fullPath, source);\n\t\t\tif (result.skill) {\n\t\t\t\tskills.push(result.skill);\n\t\t\t}\n\t\t\tdiagnostics.push(...result.diagnostics);\n\t\t\treturn { skills, diagnostics };\n\t\t}\n\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.name.startsWith(\".\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Skip node_modules to avoid scanning dependencies\n\t\t\tif (entry.name === \"node_modules\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst fullPath = join(dir, entry.name);\n\n\t\t\t// For symlinks, check if they point to a directory and follow them\n\t\t\tlet isDirectory = entry.isDirectory();\n\t\t\tlet isFile = entry.isFile();\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\ttry {\n\t\t\t\t\tconst stats = statSync(fullPath);\n\t\t\t\t\tisDirectory = stats.isDirectory();\n\t\t\t\t\tisFile = stats.isFile();\n\t\t\t\t} catch {\n\t\t\t\t\t// Broken symlink, skip it\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst relPath = toPosixPath(relative(root, fullPath));\n\t\t\tconst ignorePath = isDirectory ? `${relPath}/` : relPath;\n\t\t\tif (ig.ignores(ignorePath)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (isDirectory) {\n\t\t\t\tconst subResult = loadSkillsFromDirInternal(fullPath, source, false, ig, root);\n\t\t\t\tskills.push(...subResult.skills);\n\t\t\t\tdiagnostics.push(...subResult.diagnostics);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!isFile || !includeRootFiles || !entry.name.endsWith(\".md\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst result = loadSkillFromFile(fullPath, source);\n\t\t\tif (result.skill) {\n\t\t\t\tskills.push(result.skill);\n\t\t\t}\n\t\t\tdiagnostics.push(...result.diagnostics);\n\t\t}\n\t} catch {}\n\n\treturn { skills, diagnostics };\n}\n\nfunction loadSkillFromFile(\n\tfilePath: string,\n\tsource: string,\n): { skill: Skill | null; diagnostics: ResourceDiagnostic[] } {\n\tconst diagnostics: ResourceDiagnostic[] = [];\n\n\ttry {\n\t\tconst rawContent = readFileSync(filePath, \"utf-8\");\n\t\tconst { frontmatter } = parseFrontmatter<SkillFrontmatter>(rawContent);\n\t\tconst skillDir = dirname(filePath);\n\t\tconst parentDirName = basename(skillDir);\n\n\t\t// Validate description\n\t\tconst descErrors = validateDescription(frontmatter.description);\n\t\tfor (const error of descErrors) {\n\t\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\n\t\t}\n\n\t\t// Use name from frontmatter, or fall back to parent directory name\n\t\tconst name = frontmatter.name || parentDirName;\n\n\t\t// Validate name\n\t\tconst nameErrors = validateName(name, parentDirName);\n\t\tfor (const error of nameErrors) {\n\t\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\n\t\t}\n\n\t\t// Still load the skill even with warnings (unless description is completely missing)\n\t\tif (!frontmatter.description || frontmatter.description.trim() === \"\") {\n\t\t\treturn { skill: null, diagnostics };\n\t\t}\n\n\t\tlet allowedTools: string[] | undefined;\n\t\tif (frontmatter[\"allowed-tools\"] !== undefined) {\n\t\t\tconst normalized = normalizeTools(frontmatter[\"allowed-tools\"], filePath);\n\t\t\tdiagnostics.push(...normalized.diagnostics);\n\t\t\tif (normalized.tools.length > 0) {\n\t\t\t\tallowedTools = normalized.tools;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tskill: {\n\t\t\t\tname,\n\t\t\t\tdescription: frontmatter.description,\n\t\t\t\tfilePath,\n\t\t\t\tbaseDir: skillDir,\n\t\t\t\tsourceInfo: createSkillSourceInfo(filePath, skillDir, source),\n\t\t\t\tdisableModelInvocation: frontmatter[\"disable-model-invocation\"] === true,\n\t\t\t\tallowedTools,\n\t\t\t},\n\t\t\tdiagnostics,\n\t\t};\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : \"failed to parse skill file\";\n\t\tdiagnostics.push({ type: \"warning\", message, path: filePath });\n\t\treturn { skill: null, diagnostics };\n\t}\n}\n\n/**\n * Format skills for inclusion in a system prompt.\n * Uses XML format per Agent Skills standard.\n * See: https://agentskills.io/integrate-skills\n *\n * Skills with disableModelInvocation=true are excluded from the prompt\n * (they can only be invoked explicitly via /skill:name commands).\n */\nexport function formatSkillsForPrompt(skills: Skill[]): string {\n\tconst visibleSkills = skills.filter((s) => !s.disableModelInvocation);\n\n\tif (visibleSkills.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst lines = [\n\t\t\"\\n\\nThe following skills provide specialized instructions for specific tasks.\",\n\t\t\"Use the read tool to load a skill's file when the task matches its description.\",\n\t\t\"When a skill file references a relative path, resolve it against the skill directory (parent of SKILL.md / dirname of the path) and use that absolute path in tool commands.\",\n\t\t\"\",\n\t\t\"<available_skills>\",\n\t];\n\n\tfor (const skill of visibleSkills) {\n\t\tlines.push(\" <skill>\");\n\t\tlines.push(` <name>${escapeXml(skill.name)}</name>`);\n\t\tlines.push(` <description>${escapeXml(skill.description)}</description>`);\n\t\tif (skill.allowedTools && skill.allowedTools.length > 0) {\n\t\t\tlines.push(` <tools>${escapeXml(skill.allowedTools.join(\", \"))}</tools>`);\n\t\t}\n\t\tlines.push(` <location>${escapeXml(skill.filePath)}</location>`);\n\t\tlines.push(\" </skill>\");\n\t}\n\n\tlines.push(\"</available_skills>\");\n\n\treturn lines.join(\"\\n\");\n}\n\nfunction escapeXml(str: string): string {\n\treturn str\n\t\t.replace(/&/g, \"&amp;\")\n\t\t.replace(/</g, \"&lt;\")\n\t\t.replace(/>/g, \"&gt;\")\n\t\t.replace(/\"/g, \"&quot;\")\n\t\t.replace(/'/g, \"&apos;\");\n}\n\nexport interface LoadSkillsOptions {\n\t/** Working directory for project-local skills. */\n\tcwd: string;\n\t/** Agent config directory for global skills. */\n\tagentDir: string;\n\t/** Explicit skill paths (files or directories) */\n\tskillPaths: string[];\n\t/** Include default skills directories. */\n\tincludeDefaults: boolean;\n\t/**\n\t * Discover skills from `.claude/skills/` directories (D7 native import).\n\t * Defaults to true. Set false in tests or when explicit path control is needed.\n\t */\n\tincludeClaude?: boolean;\n}\n\nfunction normalizePath(input: string): string {\n\tconst trimmed = input.trim();\n\tif (trimmed === \"~\") return homedir();\n\tif (trimmed.startsWith(\"~/\")) return join(homedir(), trimmed.slice(2));\n\tif (trimmed.startsWith(\"~\")) return join(homedir(), trimmed.slice(1));\n\treturn trimmed;\n}\n\nfunction resolveSkillPath(p: string, cwd: string): string {\n\tconst normalized = normalizePath(p);\n\treturn isAbsolute(normalized) ? normalized : resolve(cwd, normalized);\n}\n\n/**\n * Load skills from all configured locations.\n * Returns skills and any validation diagnostics.\n */\nexport function loadSkills(options: LoadSkillsOptions): LoadSkillsResult {\n\tconst { cwd, agentDir, skillPaths, includeDefaults, includeClaude = true } = options;\n\n\t// Resolve agentDir - if not provided, use default from config\n\tconst resolvedAgentDir = agentDir ?? getAgentDir();\n\n\tconst skillMap = new Map<string, Skill>();\n\tconst realPathSet = new Set<string>();\n\tconst allDiagnostics: ResourceDiagnostic[] = [];\n\tconst collisionDiagnostics: ResourceDiagnostic[] = [];\n\n\tfunction addSkills(result: LoadSkillsResult) {\n\t\tallDiagnostics.push(...result.diagnostics);\n\t\tfor (const skill of result.skills) {\n\t\t\t// Resolve symlinks to detect duplicate files\n\t\t\tconst realPath = canonicalizePath(skill.filePath);\n\n\t\t\t// Skip silently if we've already loaded this exact file (via symlink)\n\t\t\tif (realPathSet.has(realPath)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst existing = skillMap.get(skill.name);\n\t\t\tif (existing) {\n\t\t\t\tcollisionDiagnostics.push({\n\t\t\t\t\ttype: \"collision\",\n\t\t\t\t\tmessage: `name \"${skill.name}\" collision`,\n\t\t\t\t\tpath: skill.filePath,\n\t\t\t\t\tcollision: {\n\t\t\t\t\t\tresourceType: \"skill\",\n\t\t\t\t\t\tname: skill.name,\n\t\t\t\t\t\twinnerPath: existing.filePath,\n\t\t\t\t\t\tloserPath: skill.filePath,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tskillMap.set(skill.name, skill);\n\t\t\t\trealPathSet.add(realPath);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (includeDefaults) {\n\t\tif (includeClaude) {\n\t\t\t// D7 native import: mirror agent-registry.ts for interop with .claude/ directories\n\t\t\taddSkills(loadSkillsFromDirInternal(join(homedir(), \".claude\", \"skills\"), \"claude-user\", true));\n\t\t\taddSkills(loadSkillsFromDirInternal(resolve(cwd, \".claude\", \"skills\"), \"claude-project\", true));\n\t\t}\n\t\t// hoocode-native locations take precedence (loaded after = win on name collision)\n\t\taddSkills(loadSkillsFromDirInternal(join(resolvedAgentDir, \"skills\"), \"user\", true));\n\t\taddSkills(loadSkillsFromDirInternal(resolve(cwd, CONFIG_DIR_NAME, \"skills\"), \"project\", true));\n\t}\n\n\tconst userSkillsDir = join(resolvedAgentDir, \"skills\");\n\tconst projectSkillsDir = resolve(cwd, CONFIG_DIR_NAME, \"skills\");\n\n\tconst isUnderPath = (target: string, root: string): boolean => {\n\t\tconst normalizedRoot = resolve(root);\n\t\tif (target === normalizedRoot) {\n\t\t\treturn true;\n\t\t}\n\t\tconst prefix = normalizedRoot.endsWith(sep) ? normalizedRoot : `${normalizedRoot}${sep}`;\n\t\treturn target.startsWith(prefix);\n\t};\n\n\tconst getSource = (resolvedPath: string): \"user\" | \"project\" | \"path\" => {\n\t\tif (!includeDefaults) {\n\t\t\tif (isUnderPath(resolvedPath, userSkillsDir)) return \"user\";\n\t\t\tif (isUnderPath(resolvedPath, projectSkillsDir)) return \"project\";\n\t\t}\n\t\treturn \"path\";\n\t};\n\n\tfor (const rawPath of skillPaths) {\n\t\tconst resolvedPath = resolveSkillPath(rawPath, cwd);\n\t\tif (!existsSync(resolvedPath)) {\n\t\t\tallDiagnostics.push({ type: \"warning\", message: \"skill path does not exist\", path: resolvedPath });\n\t\t\tcontinue;\n\t\t}\n\n\t\ttry {\n\t\t\tconst stats = statSync(resolvedPath);\n\t\t\tconst source = getSource(resolvedPath);\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\taddSkills(loadSkillsFromDirInternal(resolvedPath, source, true));\n\t\t\t} else if (stats.isFile() && resolvedPath.endsWith(\".md\")) {\n\t\t\t\tconst result = loadSkillFromFile(resolvedPath, source);\n\t\t\t\tif (result.skill) {\n\t\t\t\t\taddSkills({ skills: [result.skill], diagnostics: result.diagnostics });\n\t\t\t\t} else {\n\t\t\t\t\tallDiagnostics.push(...result.diagnostics);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tallDiagnostics.push({ type: \"warning\", message: \"skill path is not a markdown file\", path: resolvedPath });\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : \"failed to read skill path\";\n\t\t\tallDiagnostics.push({ type: \"warning\", message, path: resolvedPath });\n\t\t}\n\t}\n\n\treturn {\n\t\tskills: Array.from(skillMap.values()),\n\t\tdiagnostics: [...allDiagnostics, ...collisionDiagnostics],\n\t};\n}\n"]}
1
+ {"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/core/skills.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAA6B,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AA2D9E,MAAM,WAAW,gBAAgB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,iGAAiG;IACjG,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACpC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,KAAK;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;IACvB,sBAAsB,EAAE,OAAO,CAAC;IAChC,mFAAmF;IACnF,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,gBAAgB;IAChC,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,WAAW,EAAE,kBAAkB,EAAE,CAAC;CAClC;AA+CD,MAAM,WAAW,wBAAwB;IACxC,mCAAmC;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;CACf;AAsCD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,wBAAwB,GAAG,gBAAgB,CAGrF;AA+KD;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CA6B7D;AAWD,MAAM,WAAW,iBAAiB;IACjC,kDAAkD;IAClD,GAAG,EAAE,MAAM,CAAC;IACZ,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,0CAA0C;IAC1C,eAAe,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAeD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAmHvE","sourcesContent":["import { existsSync, readdirSync, readFileSync, statSync } from \"fs\";\nimport ignore from \"ignore\";\nimport { homedir } from \"os\";\nimport { basename, dirname, isAbsolute, join, relative, resolve, sep } from \"path\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../config.js\";\nimport { parseFrontmatter } from \"../utils/frontmatter.js\";\nimport { canonicalizePath } from \"../utils/paths.js\";\nimport { normalizeTools } from \"./agent-frontmatter.js\";\nimport type { ResourceDiagnostic } from \"./diagnostics.js\";\nimport { isPluginRoot } from \"./extensions/plugins/formats/index.js\";\nimport { createSyntheticSourceInfo, type SourceInfo } from \"./source-info.js\";\n\n/** Max name length per spec */\nconst MAX_NAME_LENGTH = 64;\n\n/** Max description length per spec */\nconst MAX_DESCRIPTION_LENGTH = 1024;\n\nconst IGNORE_FILE_NAMES = [\".gitignore\", \".ignore\", \".fdignore\"];\n\ntype IgnoreMatcher = ReturnType<typeof ignore>;\n\nfunction toPosixPath(p: string): string {\n\treturn p.split(sep).join(\"/\");\n}\n\nfunction prefixIgnorePattern(line: string, prefix: string): string | null {\n\tconst trimmed = line.trim();\n\tif (!trimmed) return null;\n\tif (trimmed.startsWith(\"#\") && !trimmed.startsWith(\"\\\\#\")) return null;\n\n\tlet pattern = line;\n\tlet negated = false;\n\n\tif (pattern.startsWith(\"!\")) {\n\t\tnegated = true;\n\t\tpattern = pattern.slice(1);\n\t} else if (pattern.startsWith(\"\\\\!\")) {\n\t\tpattern = pattern.slice(1);\n\t}\n\n\tif (pattern.startsWith(\"/\")) {\n\t\tpattern = pattern.slice(1);\n\t}\n\n\tconst prefixed = prefix ? `${prefix}${pattern}` : pattern;\n\treturn negated ? `!${prefixed}` : prefixed;\n}\n\nfunction addIgnoreRules(ig: IgnoreMatcher, dir: string, rootDir: string): void {\n\tconst relativeDir = relative(rootDir, dir);\n\tconst prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : \"\";\n\n\tfor (const filename of IGNORE_FILE_NAMES) {\n\t\tconst ignorePath = join(dir, filename);\n\t\tif (!existsSync(ignorePath)) continue;\n\t\ttry {\n\t\t\tconst content = readFileSync(ignorePath, \"utf-8\");\n\t\t\tconst patterns = content\n\t\t\t\t.split(/\\r?\\n/)\n\t\t\t\t.map((line) => prefixIgnorePattern(line, prefix))\n\t\t\t\t.filter((line): line is string => Boolean(line));\n\t\t\tif (patterns.length > 0) {\n\t\t\t\tig.add(patterns);\n\t\t\t}\n\t\t} catch {}\n\t}\n}\n\nexport interface SkillFrontmatter {\n\tname?: string;\n\tdescription?: string;\n\t\"disable-model-invocation\"?: boolean;\n\t/** Tools this skill requires. Mapped via the Claude Code alias table (same as agent `tools`). */\n\t\"allowed-tools\"?: string | string[];\n\t[key: string]: unknown;\n}\n\nexport interface Skill {\n\tname: string;\n\tdescription: string;\n\tfilePath: string;\n\tbaseDir: string;\n\tsourceInfo: SourceInfo;\n\tdisableModelInvocation: boolean;\n\t/** Normalized hoocode tool names this skill needs, parsed from `allowed-tools`. */\n\tallowedTools?: string[];\n}\n\nexport interface LoadSkillsResult {\n\tskills: Skill[];\n\tdiagnostics: ResourceDiagnostic[];\n}\n\n/**\n * Validate skill name per Agent Skills spec.\n * Returns array of validation error messages (empty if valid).\n */\nfunction validateName(name: string, parentDirName: string): string[] {\n\tconst errors: string[] = [];\n\n\tif (name !== parentDirName) {\n\t\terrors.push(`name \"${name}\" does not match parent directory \"${parentDirName}\"`);\n\t}\n\n\tif (name.length > MAX_NAME_LENGTH) {\n\t\terrors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);\n\t}\n\n\tif (!/^[a-z0-9-]+$/.test(name)) {\n\t\terrors.push(`name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)`);\n\t}\n\n\tif (name.startsWith(\"-\") || name.endsWith(\"-\")) {\n\t\terrors.push(`name must not start or end with a hyphen`);\n\t}\n\n\tif (name.includes(\"--\")) {\n\t\terrors.push(`name must not contain consecutive hyphens`);\n\t}\n\n\treturn errors;\n}\n\n/**\n * Validate description per Agent Skills spec.\n */\nfunction validateDescription(description: string | undefined): string[] {\n\tconst errors: string[] = [];\n\n\tif (!description || description.trim() === \"\") {\n\t\terrors.push(\"description is required\");\n\t} else if (description.length > MAX_DESCRIPTION_LENGTH) {\n\t\terrors.push(`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`);\n\t}\n\n\treturn errors;\n}\n\nexport interface LoadSkillsFromDirOptions {\n\t/** Directory to scan for skills */\n\tdir: string;\n\t/** Source identifier for these skills */\n\tsource: string;\n}\n\nfunction createSkillSourceInfo(filePath: string, baseDir: string, source: string): SourceInfo {\n\tswitch (source) {\n\t\tcase \"user\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tscope: \"user\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tcase \"project\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tscope: \"project\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tcase \"claude-user\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tscope: \"user\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tcase \"claude-project\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tscope: \"project\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tcase \"path\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tdefault:\n\t\t\treturn createSyntheticSourceInfo(filePath, { source, baseDir });\n\t}\n}\n\n/**\n * Load skills from a directory.\n *\n * Discovery rules:\n * - if a directory contains SKILL.md, treat it as a skill root and do not recurse further\n * - otherwise, load direct .md children in the root\n * - recurse into subdirectories to find SKILL.md\n */\nexport function loadSkillsFromDir(options: LoadSkillsFromDirOptions): LoadSkillsResult {\n\tconst { dir, source } = options;\n\treturn loadSkillsFromDirInternal(dir, source, true);\n}\n\nfunction loadSkillsFromDirInternal(\n\tdir: string,\n\tsource: string,\n\tincludeRootFiles: boolean,\n\tignoreMatcher?: IgnoreMatcher,\n\trootDir?: string,\n): LoadSkillsResult {\n\tconst skills: Skill[] = [];\n\tconst diagnostics: ResourceDiagnostic[] = [];\n\n\tif (!existsSync(dir)) {\n\t\treturn { skills, diagnostics };\n\t}\n\n\tconst root = rootDir ?? dir;\n\tconst ig = ignoreMatcher ?? ignore();\n\taddIgnoreRules(ig, dir, root);\n\n\ttry {\n\t\tconst entries = readdirSync(dir, { withFileTypes: true });\n\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.name !== \"SKILL.md\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst fullPath = join(dir, entry.name);\n\n\t\t\tlet isFile = entry.isFile();\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\ttry {\n\t\t\t\t\tisFile = statSync(fullPath).isFile();\n\t\t\t\t} catch {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst relPath = toPosixPath(relative(root, fullPath));\n\t\t\tif (!isFile || ig.ignores(relPath)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst result = loadSkillFromFile(fullPath, source);\n\t\t\tif (result.skill) {\n\t\t\t\tskills.push(result.skill);\n\t\t\t}\n\t\t\tdiagnostics.push(...result.diagnostics);\n\t\t\treturn { skills, diagnostics };\n\t\t}\n\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.name.startsWith(\".\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Skip node_modules to avoid scanning dependencies\n\t\t\tif (entry.name === \"node_modules\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst fullPath = join(dir, entry.name);\n\n\t\t\t// For symlinks, check if they point to a directory and follow them\n\t\t\tlet isDirectory = entry.isDirectory();\n\t\t\tlet isFile = entry.isFile();\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\ttry {\n\t\t\t\t\tconst stats = statSync(fullPath);\n\t\t\t\t\tisDirectory = stats.isDirectory();\n\t\t\t\t\tisFile = stats.isFile();\n\t\t\t\t} catch {\n\t\t\t\t\t// Broken symlink, skip it\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst relPath = toPosixPath(relative(root, fullPath));\n\t\t\tconst ignorePath = isDirectory ? `${relPath}/` : relPath;\n\t\t\tif (ig.ignores(ignorePath)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (isDirectory) {\n\t\t\t\t// A plugin directory is not a skill tree. Its `skills/<name>/SKILL.md`\n\t\t\t\t// files belong to the plugin and are contributed through the plugin\n\t\t\t\t// loader (namespaced to it); descending here would additionally\n\t\t\t\t// surface them as loose top-level skills under their bare names.\n\t\t\t\t// This matters most under `.claude/skills/`, which legitimately holds\n\t\t\t\t// both plain skills and skills-directory plugins side by side.\n\t\t\t\tif (isPluginRoot(fullPath)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst subResult = loadSkillsFromDirInternal(fullPath, source, false, ig, root);\n\t\t\t\tskills.push(...subResult.skills);\n\t\t\t\tdiagnostics.push(...subResult.diagnostics);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!isFile || !includeRootFiles || !entry.name.endsWith(\".md\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst result = loadSkillFromFile(fullPath, source);\n\t\t\tif (result.skill) {\n\t\t\t\tskills.push(result.skill);\n\t\t\t}\n\t\t\tdiagnostics.push(...result.diagnostics);\n\t\t}\n\t} catch {}\n\n\treturn { skills, diagnostics };\n}\n\nfunction loadSkillFromFile(\n\tfilePath: string,\n\tsource: string,\n): { skill: Skill | null; diagnostics: ResourceDiagnostic[] } {\n\tconst diagnostics: ResourceDiagnostic[] = [];\n\n\ttry {\n\t\tconst rawContent = readFileSync(filePath, \"utf-8\");\n\t\tconst { frontmatter } = parseFrontmatter<SkillFrontmatter>(rawContent);\n\t\tconst skillDir = dirname(filePath);\n\t\tconst parentDirName = basename(skillDir);\n\n\t\t// Validate description\n\t\tconst descErrors = validateDescription(frontmatter.description);\n\t\tfor (const error of descErrors) {\n\t\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\n\t\t}\n\n\t\t// Use name from frontmatter, or fall back to parent directory name\n\t\tconst name = frontmatter.name || parentDirName;\n\n\t\t// Validate name\n\t\tconst nameErrors = validateName(name, parentDirName);\n\t\tfor (const error of nameErrors) {\n\t\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\n\t\t}\n\n\t\t// Still load the skill even with warnings (unless description is completely missing)\n\t\tif (!frontmatter.description || frontmatter.description.trim() === \"\") {\n\t\t\treturn { skill: null, diagnostics };\n\t\t}\n\n\t\tlet allowedTools: string[] | undefined;\n\t\tif (frontmatter[\"allowed-tools\"] !== undefined) {\n\t\t\tconst normalized = normalizeTools(frontmatter[\"allowed-tools\"], filePath);\n\t\t\tdiagnostics.push(...normalized.diagnostics);\n\t\t\tif (normalized.tools.length > 0) {\n\t\t\t\tallowedTools = normalized.tools;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tskill: {\n\t\t\t\tname,\n\t\t\t\tdescription: frontmatter.description,\n\t\t\t\tfilePath,\n\t\t\t\tbaseDir: skillDir,\n\t\t\t\tsourceInfo: createSkillSourceInfo(filePath, skillDir, source),\n\t\t\t\tdisableModelInvocation: frontmatter[\"disable-model-invocation\"] === true,\n\t\t\t\tallowedTools,\n\t\t\t},\n\t\t\tdiagnostics,\n\t\t};\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : \"failed to parse skill file\";\n\t\tdiagnostics.push({ type: \"warning\", message, path: filePath });\n\t\treturn { skill: null, diagnostics };\n\t}\n}\n\n/**\n * Format skills for inclusion in a system prompt.\n * Uses XML format per Agent Skills standard.\n * See: https://agentskills.io/integrate-skills\n *\n * Skills with disableModelInvocation=true are excluded from the prompt\n * (they can only be invoked explicitly via /skill:name commands).\n */\nexport function formatSkillsForPrompt(skills: Skill[]): string {\n\tconst visibleSkills = skills.filter((s) => !s.disableModelInvocation);\n\n\tif (visibleSkills.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst lines = [\n\t\t\"\\n\\nThe following skills provide specialized instructions for specific tasks.\",\n\t\t\"Use the read tool to load a skill's file when the task matches its description.\",\n\t\t\"When a skill file references a relative path, resolve it against the skill directory (parent of SKILL.md / dirname of the path) and use that absolute path in tool commands.\",\n\t\t\"\",\n\t\t\"<available_skills>\",\n\t];\n\n\tfor (const skill of visibleSkills) {\n\t\tlines.push(\" <skill>\");\n\t\tlines.push(` <name>${escapeXml(skill.name)}</name>`);\n\t\tlines.push(` <description>${escapeXml(skill.description)}</description>`);\n\t\tif (skill.allowedTools && skill.allowedTools.length > 0) {\n\t\t\tlines.push(` <tools>${escapeXml(skill.allowedTools.join(\", \"))}</tools>`);\n\t\t}\n\t\tlines.push(` <location>${escapeXml(skill.filePath)}</location>`);\n\t\tlines.push(\" </skill>\");\n\t}\n\n\tlines.push(\"</available_skills>\");\n\n\treturn lines.join(\"\\n\");\n}\n\nfunction escapeXml(str: string): string {\n\treturn str\n\t\t.replace(/&/g, \"&amp;\")\n\t\t.replace(/</g, \"&lt;\")\n\t\t.replace(/>/g, \"&gt;\")\n\t\t.replace(/\"/g, \"&quot;\")\n\t\t.replace(/'/g, \"&apos;\");\n}\n\nexport interface LoadSkillsOptions {\n\t/** Working directory for project-local skills. */\n\tcwd: string;\n\t/** Agent config directory for global skills. */\n\tagentDir: string;\n\t/** Explicit skill paths (files or directories) */\n\tskillPaths: string[];\n\t/** Include default skills directories. */\n\tincludeDefaults: boolean;\n\t/**\n\t * Discover skills from `.claude/skills/` directories (D7 native import).\n\t * Defaults to true. Set false in tests or when explicit path control is needed.\n\t */\n\tincludeClaude?: boolean;\n\t/**\n\t * Contributed skill directory -> owning plugin id. Skills loaded from such a\n\t * directory are named `<plugin>:<skill>`, matching Claude Code.\n\t *\n\t * Applied here rather than by the caller because the name map below is\n\t * first-wins by name: two plugins shipping a `review` skill would collide and\n\t * lose one *before* any later rename could tell them apart.\n\t */\n\tnamespaces?: Map<string, string>;\n}\n\nfunction normalizePath(input: string): string {\n\tconst trimmed = input.trim();\n\tif (trimmed === \"~\") return homedir();\n\tif (trimmed.startsWith(\"~/\")) return join(homedir(), trimmed.slice(2));\n\tif (trimmed.startsWith(\"~\")) return join(homedir(), trimmed.slice(1));\n\treturn trimmed;\n}\n\nfunction resolveSkillPath(p: string, cwd: string): string {\n\tconst normalized = normalizePath(p);\n\treturn isAbsolute(normalized) ? normalized : resolve(cwd, normalized);\n}\n\n/**\n * Load skills from all configured locations.\n * Returns skills and any validation diagnostics.\n */\nexport function loadSkills(options: LoadSkillsOptions): LoadSkillsResult {\n\tconst { cwd, agentDir, skillPaths, includeDefaults, includeClaude = true, namespaces } = options;\n\n\t// Resolve agentDir - if not provided, use default from config\n\tconst resolvedAgentDir = agentDir ?? getAgentDir();\n\n\tconst skillMap = new Map<string, Skill>();\n\tconst realPathSet = new Set<string>();\n\tconst allDiagnostics: ResourceDiagnostic[] = [];\n\tconst collisionDiagnostics: ResourceDiagnostic[] = [];\n\n\tfunction addSkills(result: LoadSkillsResult) {\n\t\tallDiagnostics.push(...result.diagnostics);\n\t\tfor (const skill of result.skills) {\n\t\t\t// Resolve symlinks to detect duplicate files\n\t\t\tconst realPath = canonicalizePath(skill.filePath);\n\n\t\t\t// Skip silently if we've already loaded this exact file (via symlink)\n\t\t\tif (realPathSet.has(realPath)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst existing = skillMap.get(skill.name);\n\t\t\tif (existing) {\n\t\t\t\tcollisionDiagnostics.push({\n\t\t\t\t\ttype: \"collision\",\n\t\t\t\t\tmessage: `name \"${skill.name}\" collision`,\n\t\t\t\t\tpath: skill.filePath,\n\t\t\t\t\tcollision: {\n\t\t\t\t\t\tresourceType: \"skill\",\n\t\t\t\t\t\tname: skill.name,\n\t\t\t\t\t\twinnerPath: existing.filePath,\n\t\t\t\t\t\tloserPath: skill.filePath,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tskillMap.set(skill.name, skill);\n\t\t\t\trealPathSet.add(realPath);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (includeDefaults) {\n\t\tif (includeClaude) {\n\t\t\t// D7 native import: mirror agent-registry.ts for interop with .claude/ directories\n\t\t\taddSkills(loadSkillsFromDirInternal(join(homedir(), \".claude\", \"skills\"), \"claude-user\", true));\n\t\t\taddSkills(loadSkillsFromDirInternal(resolve(cwd, \".claude\", \"skills\"), \"claude-project\", true));\n\t\t}\n\t\t// hoocode-native locations take precedence (loaded after = win on name collision)\n\t\taddSkills(loadSkillsFromDirInternal(join(resolvedAgentDir, \"skills\"), \"user\", true));\n\t\taddSkills(loadSkillsFromDirInternal(resolve(cwd, CONFIG_DIR_NAME, \"skills\"), \"project\", true));\n\t}\n\n\tconst userSkillsDir = join(resolvedAgentDir, \"skills\");\n\tconst projectSkillsDir = resolve(cwd, CONFIG_DIR_NAME, \"skills\");\n\n\tconst isUnderPath = (target: string, root: string): boolean => {\n\t\tconst normalizedRoot = resolve(root);\n\t\tif (target === normalizedRoot) {\n\t\t\treturn true;\n\t\t}\n\t\tconst prefix = normalizedRoot.endsWith(sep) ? normalizedRoot : `${normalizedRoot}${sep}`;\n\t\treturn target.startsWith(prefix);\n\t};\n\n\tconst getSource = (resolvedPath: string): \"user\" | \"project\" | \"path\" => {\n\t\tif (!includeDefaults) {\n\t\t\tif (isUnderPath(resolvedPath, userSkillsDir)) return \"user\";\n\t\t\tif (isUnderPath(resolvedPath, projectSkillsDir)) return \"project\";\n\t\t}\n\t\treturn \"path\";\n\t};\n\n\t/** Prefix a batch of skills with `namespace:` before they enter the name map. */\n\tconst addNamespaced = (result: LoadSkillsResult, namespace: string | undefined) => {\n\t\tif (!namespace) return addSkills(result);\n\t\taddSkills({\n\t\t\t...result,\n\t\t\tskills: result.skills.map((skill) => ({ ...skill, name: `${namespace}:${skill.name}` })),\n\t\t});\n\t};\n\n\tfor (const rawPath of skillPaths) {\n\t\tconst resolvedPath = resolveSkillPath(rawPath, cwd);\n\t\tconst namespace = namespaces?.get(rawPath) ?? namespaces?.get(resolvedPath);\n\t\tif (!existsSync(resolvedPath)) {\n\t\t\tallDiagnostics.push({ type: \"warning\", message: \"skill path does not exist\", path: resolvedPath });\n\t\t\tcontinue;\n\t\t}\n\n\t\ttry {\n\t\t\tconst stats = statSync(resolvedPath);\n\t\t\tconst source = getSource(resolvedPath);\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\taddNamespaced(loadSkillsFromDirInternal(resolvedPath, source, true), namespace);\n\t\t\t} else if (stats.isFile() && resolvedPath.endsWith(\".md\")) {\n\t\t\t\tconst result = loadSkillFromFile(resolvedPath, source);\n\t\t\t\tif (result.skill) {\n\t\t\t\t\taddNamespaced({ skills: [result.skill], diagnostics: result.diagnostics }, namespace);\n\t\t\t\t} else {\n\t\t\t\t\tallDiagnostics.push(...result.diagnostics);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tallDiagnostics.push({ type: \"warning\", message: \"skill path is not a markdown file\", path: resolvedPath });\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : \"failed to read skill path\";\n\t\t\tallDiagnostics.push({ type: \"warning\", message, path: resolvedPath });\n\t\t}\n\t}\n\n\treturn {\n\t\tskills: Array.from(skillMap.values()),\n\t\tdiagnostics: [...allDiagnostics, ...collisionDiagnostics],\n\t};\n}\n"]}
@@ -6,6 +6,7 @@ import { CONFIG_DIR_NAME, getAgentDir } from "../config.js";
6
6
  import { parseFrontmatter } from "../utils/frontmatter.js";
7
7
  import { canonicalizePath } from "../utils/paths.js";
8
8
  import { normalizeTools } from "./agent-frontmatter.js";
9
+ import { isPluginRoot } from "./extensions/plugins/formats/index.js";
9
10
  import { createSyntheticSourceInfo } from "./source-info.js";
10
11
  /** Max name length per spec */
11
12
  const MAX_NAME_LENGTH = 64;
@@ -204,6 +205,15 @@ function loadSkillsFromDirInternal(dir, source, includeRootFiles, ignoreMatcher,
204
205
  continue;
205
206
  }
206
207
  if (isDirectory) {
208
+ // A plugin directory is not a skill tree. Its `skills/<name>/SKILL.md`
209
+ // files belong to the plugin and are contributed through the plugin
210
+ // loader (namespaced to it); descending here would additionally
211
+ // surface them as loose top-level skills under their bare names.
212
+ // This matters most under `.claude/skills/`, which legitimately holds
213
+ // both plain skills and skills-directory plugins side by side.
214
+ if (isPluginRoot(fullPath)) {
215
+ continue;
216
+ }
207
217
  const subResult = loadSkillsFromDirInternal(fullPath, source, false, ig, root);
208
218
  skills.push(...subResult.skills);
209
219
  diagnostics.push(...subResult.diagnostics);
@@ -332,7 +342,7 @@ function resolveSkillPath(p, cwd) {
332
342
  * Returns skills and any validation diagnostics.
333
343
  */
334
344
  export function loadSkills(options) {
335
- const { cwd, agentDir, skillPaths, includeDefaults, includeClaude = true } = options;
345
+ const { cwd, agentDir, skillPaths, includeDefaults, includeClaude = true, namespaces } = options;
336
346
  // Resolve agentDir - if not provided, use default from config
337
347
  const resolvedAgentDir = agentDir ?? getAgentDir();
338
348
  const skillMap = new Map();
@@ -397,8 +407,18 @@ export function loadSkills(options) {
397
407
  }
398
408
  return "path";
399
409
  };
410
+ /** Prefix a batch of skills with `namespace:` before they enter the name map. */
411
+ const addNamespaced = (result, namespace) => {
412
+ if (!namespace)
413
+ return addSkills(result);
414
+ addSkills({
415
+ ...result,
416
+ skills: result.skills.map((skill) => ({ ...skill, name: `${namespace}:${skill.name}` })),
417
+ });
418
+ };
400
419
  for (const rawPath of skillPaths) {
401
420
  const resolvedPath = resolveSkillPath(rawPath, cwd);
421
+ const namespace = namespaces?.get(rawPath) ?? namespaces?.get(resolvedPath);
402
422
  if (!existsSync(resolvedPath)) {
403
423
  allDiagnostics.push({ type: "warning", message: "skill path does not exist", path: resolvedPath });
404
424
  continue;
@@ -407,12 +427,12 @@ export function loadSkills(options) {
407
427
  const stats = statSync(resolvedPath);
408
428
  const source = getSource(resolvedPath);
409
429
  if (stats.isDirectory()) {
410
- addSkills(loadSkillsFromDirInternal(resolvedPath, source, true));
430
+ addNamespaced(loadSkillsFromDirInternal(resolvedPath, source, true), namespace);
411
431
  }
412
432
  else if (stats.isFile() && resolvedPath.endsWith(".md")) {
413
433
  const result = loadSkillFromFile(resolvedPath, source);
414
434
  if (result.skill) {
415
- addSkills({ skills: [result.skill], diagnostics: result.diagnostics });
435
+ addNamespaced({ skills: [result.skill], diagnostics: result.diagnostics }, namespace);
416
436
  }
417
437
  else {
418
438
  allDiagnostics.push(...result.diagnostics);
@@ -1 +1 @@
1
- {"version":3,"file":"skills.js","sourceRoot":"","sources":["../../src/core/skills.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACrE,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,yBAAyB,EAAmB,MAAM,kBAAkB,CAAC;AAE9E,+BAA+B;AAC/B,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,sCAAsC;AACtC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAEpC,MAAM,iBAAiB,GAAG,CAAC,YAAY,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;AAIjE,SAAS,WAAW,CAAC,CAAS,EAAU;IACvC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAAA,CAC9B;AAED,SAAS,mBAAmB,CAAC,IAAY,EAAE,MAAc,EAAiB;IACzE,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,IAAI,OAAO,C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AC;IACF,CAAC;IAED,OAAO;QACN,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACrC,WAAW,EAAE,CAAC,GAAG,cAAc,EAAE,GAAG,oBAAoB,CAAC;KACzD,CAAC;AAAA,CACF","sourcesContent":["import { existsSync, readdirSync, readFileSync, statSync } from \"fs\";\nimport ignore from \"ignore\";\nimport { homedir } from \"os\";\nimport { basename, dirname, isAbsolute, join, relative, resolve, sep } from \"path\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../config.js\";\nimport { parseFrontmatter } from \"../utils/frontmatter.js\";\nimport { canonicalizePath } from \"../utils/paths.js\";\nimport { normalizeTools } from \"./agent-frontmatter.js\";\nimport type { ResourceDiagnostic } from \"./diagnostics.js\";\nimport { createSyntheticSourceInfo, type SourceInfo } from \"./source-info.js\";\n\n/** Max name length per spec */\nconst MAX_NAME_LENGTH = 64;\n\n/** Max description length per spec */\nconst MAX_DESCRIPTION_LENGTH = 1024;\n\nconst IGNORE_FILE_NAMES = [\".gitignore\", \".ignore\", \".fdignore\"];\n\ntype IgnoreMatcher = ReturnType<typeof ignore>;\n\nfunction toPosixPath(p: string): string {\n\treturn p.split(sep).join(\"/\");\n}\n\nfunction prefixIgnorePattern(line: string, prefix: string): string | null {\n\tconst trimmed = line.trim();\n\tif (!trimmed) return null;\n\tif (trimmed.startsWith(\"#\") && !trimmed.startsWith(\"\\\\#\")) return null;\n\n\tlet pattern = line;\n\tlet negated = false;\n\n\tif (pattern.startsWith(\"!\")) {\n\t\tnegated = true;\n\t\tpattern = pattern.slice(1);\n\t} else if (pattern.startsWith(\"\\\\!\")) {\n\t\tpattern = pattern.slice(1);\n\t}\n\n\tif (pattern.startsWith(\"/\")) {\n\t\tpattern = pattern.slice(1);\n\t}\n\n\tconst prefixed = prefix ? `${prefix}${pattern}` : pattern;\n\treturn negated ? `!${prefixed}` : prefixed;\n}\n\nfunction addIgnoreRules(ig: IgnoreMatcher, dir: string, rootDir: string): void {\n\tconst relativeDir = relative(rootDir, dir);\n\tconst prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : \"\";\n\n\tfor (const filename of IGNORE_FILE_NAMES) {\n\t\tconst ignorePath = join(dir, filename);\n\t\tif (!existsSync(ignorePath)) continue;\n\t\ttry {\n\t\t\tconst content = readFileSync(ignorePath, \"utf-8\");\n\t\t\tconst patterns = content\n\t\t\t\t.split(/\\r?\\n/)\n\t\t\t\t.map((line) => prefixIgnorePattern(line, prefix))\n\t\t\t\t.filter((line): line is string => Boolean(line));\n\t\t\tif (patterns.length > 0) {\n\t\t\t\tig.add(patterns);\n\t\t\t}\n\t\t} catch {}\n\t}\n}\n\nexport interface SkillFrontmatter {\n\tname?: string;\n\tdescription?: string;\n\t\"disable-model-invocation\"?: boolean;\n\t/** Tools this skill requires. Mapped via the Claude Code alias table (same as agent `tools`). */\n\t\"allowed-tools\"?: string | string[];\n\t[key: string]: unknown;\n}\n\nexport interface Skill {\n\tname: string;\n\tdescription: string;\n\tfilePath: string;\n\tbaseDir: string;\n\tsourceInfo: SourceInfo;\n\tdisableModelInvocation: boolean;\n\t/** Normalized hoocode tool names this skill needs, parsed from `allowed-tools`. */\n\tallowedTools?: string[];\n}\n\nexport interface LoadSkillsResult {\n\tskills: Skill[];\n\tdiagnostics: ResourceDiagnostic[];\n}\n\n/**\n * Validate skill name per Agent Skills spec.\n * Returns array of validation error messages (empty if valid).\n */\nfunction validateName(name: string, parentDirName: string): string[] {\n\tconst errors: string[] = [];\n\n\tif (name !== parentDirName) {\n\t\terrors.push(`name \"${name}\" does not match parent directory \"${parentDirName}\"`);\n\t}\n\n\tif (name.length > MAX_NAME_LENGTH) {\n\t\terrors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);\n\t}\n\n\tif (!/^[a-z0-9-]+$/.test(name)) {\n\t\terrors.push(`name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)`);\n\t}\n\n\tif (name.startsWith(\"-\") || name.endsWith(\"-\")) {\n\t\terrors.push(`name must not start or end with a hyphen`);\n\t}\n\n\tif (name.includes(\"--\")) {\n\t\terrors.push(`name must not contain consecutive hyphens`);\n\t}\n\n\treturn errors;\n}\n\n/**\n * Validate description per Agent Skills spec.\n */\nfunction validateDescription(description: string | undefined): string[] {\n\tconst errors: string[] = [];\n\n\tif (!description || description.trim() === \"\") {\n\t\terrors.push(\"description is required\");\n\t} else if (description.length > MAX_DESCRIPTION_LENGTH) {\n\t\terrors.push(`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`);\n\t}\n\n\treturn errors;\n}\n\nexport interface LoadSkillsFromDirOptions {\n\t/** Directory to scan for skills */\n\tdir: string;\n\t/** Source identifier for these skills */\n\tsource: string;\n}\n\nfunction createSkillSourceInfo(filePath: string, baseDir: string, source: string): SourceInfo {\n\tswitch (source) {\n\t\tcase \"user\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tscope: \"user\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tcase \"project\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tscope: \"project\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tcase \"claude-user\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tscope: \"user\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tcase \"claude-project\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tscope: \"project\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tcase \"path\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tdefault:\n\t\t\treturn createSyntheticSourceInfo(filePath, { source, baseDir });\n\t}\n}\n\n/**\n * Load skills from a directory.\n *\n * Discovery rules:\n * - if a directory contains SKILL.md, treat it as a skill root and do not recurse further\n * - otherwise, load direct .md children in the root\n * - recurse into subdirectories to find SKILL.md\n */\nexport function loadSkillsFromDir(options: LoadSkillsFromDirOptions): LoadSkillsResult {\n\tconst { dir, source } = options;\n\treturn loadSkillsFromDirInternal(dir, source, true);\n}\n\nfunction loadSkillsFromDirInternal(\n\tdir: string,\n\tsource: string,\n\tincludeRootFiles: boolean,\n\tignoreMatcher?: IgnoreMatcher,\n\trootDir?: string,\n): LoadSkillsResult {\n\tconst skills: Skill[] = [];\n\tconst diagnostics: ResourceDiagnostic[] = [];\n\n\tif (!existsSync(dir)) {\n\t\treturn { skills, diagnostics };\n\t}\n\n\tconst root = rootDir ?? dir;\n\tconst ig = ignoreMatcher ?? ignore();\n\taddIgnoreRules(ig, dir, root);\n\n\ttry {\n\t\tconst entries = readdirSync(dir, { withFileTypes: true });\n\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.name !== \"SKILL.md\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst fullPath = join(dir, entry.name);\n\n\t\t\tlet isFile = entry.isFile();\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\ttry {\n\t\t\t\t\tisFile = statSync(fullPath).isFile();\n\t\t\t\t} catch {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst relPath = toPosixPath(relative(root, fullPath));\n\t\t\tif (!isFile || ig.ignores(relPath)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst result = loadSkillFromFile(fullPath, source);\n\t\t\tif (result.skill) {\n\t\t\t\tskills.push(result.skill);\n\t\t\t}\n\t\t\tdiagnostics.push(...result.diagnostics);\n\t\t\treturn { skills, diagnostics };\n\t\t}\n\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.name.startsWith(\".\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Skip node_modules to avoid scanning dependencies\n\t\t\tif (entry.name === \"node_modules\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst fullPath = join(dir, entry.name);\n\n\t\t\t// For symlinks, check if they point to a directory and follow them\n\t\t\tlet isDirectory = entry.isDirectory();\n\t\t\tlet isFile = entry.isFile();\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\ttry {\n\t\t\t\t\tconst stats = statSync(fullPath);\n\t\t\t\t\tisDirectory = stats.isDirectory();\n\t\t\t\t\tisFile = stats.isFile();\n\t\t\t\t} catch {\n\t\t\t\t\t// Broken symlink, skip it\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst relPath = toPosixPath(relative(root, fullPath));\n\t\t\tconst ignorePath = isDirectory ? `${relPath}/` : relPath;\n\t\t\tif (ig.ignores(ignorePath)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (isDirectory) {\n\t\t\t\tconst subResult = loadSkillsFromDirInternal(fullPath, source, false, ig, root);\n\t\t\t\tskills.push(...subResult.skills);\n\t\t\t\tdiagnostics.push(...subResult.diagnostics);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!isFile || !includeRootFiles || !entry.name.endsWith(\".md\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst result = loadSkillFromFile(fullPath, source);\n\t\t\tif (result.skill) {\n\t\t\t\tskills.push(result.skill);\n\t\t\t}\n\t\t\tdiagnostics.push(...result.diagnostics);\n\t\t}\n\t} catch {}\n\n\treturn { skills, diagnostics };\n}\n\nfunction loadSkillFromFile(\n\tfilePath: string,\n\tsource: string,\n): { skill: Skill | null; diagnostics: ResourceDiagnostic[] } {\n\tconst diagnostics: ResourceDiagnostic[] = [];\n\n\ttry {\n\t\tconst rawContent = readFileSync(filePath, \"utf-8\");\n\t\tconst { frontmatter } = parseFrontmatter<SkillFrontmatter>(rawContent);\n\t\tconst skillDir = dirname(filePath);\n\t\tconst parentDirName = basename(skillDir);\n\n\t\t// Validate description\n\t\tconst descErrors = validateDescription(frontmatter.description);\n\t\tfor (const error of descErrors) {\n\t\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\n\t\t}\n\n\t\t// Use name from frontmatter, or fall back to parent directory name\n\t\tconst name = frontmatter.name || parentDirName;\n\n\t\t// Validate name\n\t\tconst nameErrors = validateName(name, parentDirName);\n\t\tfor (const error of nameErrors) {\n\t\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\n\t\t}\n\n\t\t// Still load the skill even with warnings (unless description is completely missing)\n\t\tif (!frontmatter.description || frontmatter.description.trim() === \"\") {\n\t\t\treturn { skill: null, diagnostics };\n\t\t}\n\n\t\tlet allowedTools: string[] | undefined;\n\t\tif (frontmatter[\"allowed-tools\"] !== undefined) {\n\t\t\tconst normalized = normalizeTools(frontmatter[\"allowed-tools\"], filePath);\n\t\t\tdiagnostics.push(...normalized.diagnostics);\n\t\t\tif (normalized.tools.length > 0) {\n\t\t\t\tallowedTools = normalized.tools;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tskill: {\n\t\t\t\tname,\n\t\t\t\tdescription: frontmatter.description,\n\t\t\t\tfilePath,\n\t\t\t\tbaseDir: skillDir,\n\t\t\t\tsourceInfo: createSkillSourceInfo(filePath, skillDir, source),\n\t\t\t\tdisableModelInvocation: frontmatter[\"disable-model-invocation\"] === true,\n\t\t\t\tallowedTools,\n\t\t\t},\n\t\t\tdiagnostics,\n\t\t};\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : \"failed to parse skill file\";\n\t\tdiagnostics.push({ type: \"warning\", message, path: filePath });\n\t\treturn { skill: null, diagnostics };\n\t}\n}\n\n/**\n * Format skills for inclusion in a system prompt.\n * Uses XML format per Agent Skills standard.\n * See: https://agentskills.io/integrate-skills\n *\n * Skills with disableModelInvocation=true are excluded from the prompt\n * (they can only be invoked explicitly via /skill:name commands).\n */\nexport function formatSkillsForPrompt(skills: Skill[]): string {\n\tconst visibleSkills = skills.filter((s) => !s.disableModelInvocation);\n\n\tif (visibleSkills.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst lines = [\n\t\t\"\\n\\nThe following skills provide specialized instructions for specific tasks.\",\n\t\t\"Use the read tool to load a skill's file when the task matches its description.\",\n\t\t\"When a skill file references a relative path, resolve it against the skill directory (parent of SKILL.md / dirname of the path) and use that absolute path in tool commands.\",\n\t\t\"\",\n\t\t\"<available_skills>\",\n\t];\n\n\tfor (const skill of visibleSkills) {\n\t\tlines.push(\" <skill>\");\n\t\tlines.push(` <name>${escapeXml(skill.name)}</name>`);\n\t\tlines.push(` <description>${escapeXml(skill.description)}</description>`);\n\t\tif (skill.allowedTools && skill.allowedTools.length > 0) {\n\t\t\tlines.push(` <tools>${escapeXml(skill.allowedTools.join(\", \"))}</tools>`);\n\t\t}\n\t\tlines.push(` <location>${escapeXml(skill.filePath)}</location>`);\n\t\tlines.push(\" </skill>\");\n\t}\n\n\tlines.push(\"</available_skills>\");\n\n\treturn lines.join(\"\\n\");\n}\n\nfunction escapeXml(str: string): string {\n\treturn str\n\t\t.replace(/&/g, \"&amp;\")\n\t\t.replace(/</g, \"&lt;\")\n\t\t.replace(/>/g, \"&gt;\")\n\t\t.replace(/\"/g, \"&quot;\")\n\t\t.replace(/'/g, \"&apos;\");\n}\n\nexport interface LoadSkillsOptions {\n\t/** Working directory for project-local skills. */\n\tcwd: string;\n\t/** Agent config directory for global skills. */\n\tagentDir: string;\n\t/** Explicit skill paths (files or directories) */\n\tskillPaths: string[];\n\t/** Include default skills directories. */\n\tincludeDefaults: boolean;\n\t/**\n\t * Discover skills from `.claude/skills/` directories (D7 native import).\n\t * Defaults to true. Set false in tests or when explicit path control is needed.\n\t */\n\tincludeClaude?: boolean;\n}\n\nfunction normalizePath(input: string): string {\n\tconst trimmed = input.trim();\n\tif (trimmed === \"~\") return homedir();\n\tif (trimmed.startsWith(\"~/\")) return join(homedir(), trimmed.slice(2));\n\tif (trimmed.startsWith(\"~\")) return join(homedir(), trimmed.slice(1));\n\treturn trimmed;\n}\n\nfunction resolveSkillPath(p: string, cwd: string): string {\n\tconst normalized = normalizePath(p);\n\treturn isAbsolute(normalized) ? normalized : resolve(cwd, normalized);\n}\n\n/**\n * Load skills from all configured locations.\n * Returns skills and any validation diagnostics.\n */\nexport function loadSkills(options: LoadSkillsOptions): LoadSkillsResult {\n\tconst { cwd, agentDir, skillPaths, includeDefaults, includeClaude = true } = options;\n\n\t// Resolve agentDir - if not provided, use default from config\n\tconst resolvedAgentDir = agentDir ?? getAgentDir();\n\n\tconst skillMap = new Map<string, Skill>();\n\tconst realPathSet = new Set<string>();\n\tconst allDiagnostics: ResourceDiagnostic[] = [];\n\tconst collisionDiagnostics: ResourceDiagnostic[] = [];\n\n\tfunction addSkills(result: LoadSkillsResult) {\n\t\tallDiagnostics.push(...result.diagnostics);\n\t\tfor (const skill of result.skills) {\n\t\t\t// Resolve symlinks to detect duplicate files\n\t\t\tconst realPath = canonicalizePath(skill.filePath);\n\n\t\t\t// Skip silently if we've already loaded this exact file (via symlink)\n\t\t\tif (realPathSet.has(realPath)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst existing = skillMap.get(skill.name);\n\t\t\tif (existing) {\n\t\t\t\tcollisionDiagnostics.push({\n\t\t\t\t\ttype: \"collision\",\n\t\t\t\t\tmessage: `name \"${skill.name}\" collision`,\n\t\t\t\t\tpath: skill.filePath,\n\t\t\t\t\tcollision: {\n\t\t\t\t\t\tresourceType: \"skill\",\n\t\t\t\t\t\tname: skill.name,\n\t\t\t\t\t\twinnerPath: existing.filePath,\n\t\t\t\t\t\tloserPath: skill.filePath,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tskillMap.set(skill.name, skill);\n\t\t\t\trealPathSet.add(realPath);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (includeDefaults) {\n\t\tif (includeClaude) {\n\t\t\t// D7 native import: mirror agent-registry.ts for interop with .claude/ directories\n\t\t\taddSkills(loadSkillsFromDirInternal(join(homedir(), \".claude\", \"skills\"), \"claude-user\", true));\n\t\t\taddSkills(loadSkillsFromDirInternal(resolve(cwd, \".claude\", \"skills\"), \"claude-project\", true));\n\t\t}\n\t\t// hoocode-native locations take precedence (loaded after = win on name collision)\n\t\taddSkills(loadSkillsFromDirInternal(join(resolvedAgentDir, \"skills\"), \"user\", true));\n\t\taddSkills(loadSkillsFromDirInternal(resolve(cwd, CONFIG_DIR_NAME, \"skills\"), \"project\", true));\n\t}\n\n\tconst userSkillsDir = join(resolvedAgentDir, \"skills\");\n\tconst projectSkillsDir = resolve(cwd, CONFIG_DIR_NAME, \"skills\");\n\n\tconst isUnderPath = (target: string, root: string): boolean => {\n\t\tconst normalizedRoot = resolve(root);\n\t\tif (target === normalizedRoot) {\n\t\t\treturn true;\n\t\t}\n\t\tconst prefix = normalizedRoot.endsWith(sep) ? normalizedRoot : `${normalizedRoot}${sep}`;\n\t\treturn target.startsWith(prefix);\n\t};\n\n\tconst getSource = (resolvedPath: string): \"user\" | \"project\" | \"path\" => {\n\t\tif (!includeDefaults) {\n\t\t\tif (isUnderPath(resolvedPath, userSkillsDir)) return \"user\";\n\t\t\tif (isUnderPath(resolvedPath, projectSkillsDir)) return \"project\";\n\t\t}\n\t\treturn \"path\";\n\t};\n\n\tfor (const rawPath of skillPaths) {\n\t\tconst resolvedPath = resolveSkillPath(rawPath, cwd);\n\t\tif (!existsSync(resolvedPath)) {\n\t\t\tallDiagnostics.push({ type: \"warning\", message: \"skill path does not exist\", path: resolvedPath });\n\t\t\tcontinue;\n\t\t}\n\n\t\ttry {\n\t\t\tconst stats = statSync(resolvedPath);\n\t\t\tconst source = getSource(resolvedPath);\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\taddSkills(loadSkillsFromDirInternal(resolvedPath, source, true));\n\t\t\t} else if (stats.isFile() && resolvedPath.endsWith(\".md\")) {\n\t\t\t\tconst result = loadSkillFromFile(resolvedPath, source);\n\t\t\t\tif (result.skill) {\n\t\t\t\t\taddSkills({ skills: [result.skill], diagnostics: result.diagnostics });\n\t\t\t\t} else {\n\t\t\t\t\tallDiagnostics.push(...result.diagnostics);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tallDiagnostics.push({ type: \"warning\", message: \"skill path is not a markdown file\", path: resolvedPath });\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : \"failed to read skill path\";\n\t\t\tallDiagnostics.push({ type: \"warning\", message, path: resolvedPath });\n\t\t}\n\t}\n\n\treturn {\n\t\tskills: Array.from(skillMap.values()),\n\t\tdiagnostics: [...allDiagnostics, ...collisionDiagnostics],\n\t};\n}\n"]}
1
+ {"version":3,"file":"skills.js","sourceRoot":"","sources":["../../src/core/skills.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC;AACrE,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AACnF,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAmB,MAAM,kBAAkB,CAAC;AAE9E,+BAA+B;AAC/B,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,sCAAsC;AACtC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAEpC,MAAM,iBAAiB,GAAG,CAAC,YAAY,EAAE,SAAS,E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CACF","sourcesContent":["import { existsSync, readdirSync, readFileSync, statSync } from \"fs\";\nimport ignore from \"ignore\";\nimport { homedir } from \"os\";\nimport { basename, dirname, isAbsolute, join, relative, resolve, sep } from \"path\";\nimport { CONFIG_DIR_NAME, getAgentDir } from \"../config.js\";\nimport { parseFrontmatter } from \"../utils/frontmatter.js\";\nimport { canonicalizePath } from \"../utils/paths.js\";\nimport { normalizeTools } from \"./agent-frontmatter.js\";\nimport type { ResourceDiagnostic } from \"./diagnostics.js\";\nimport { isPluginRoot } from \"./extensions/plugins/formats/index.js\";\nimport { createSyntheticSourceInfo, type SourceInfo } from \"./source-info.js\";\n\n/** Max name length per spec */\nconst MAX_NAME_LENGTH = 64;\n\n/** Max description length per spec */\nconst MAX_DESCRIPTION_LENGTH = 1024;\n\nconst IGNORE_FILE_NAMES = [\".gitignore\", \".ignore\", \".fdignore\"];\n\ntype IgnoreMatcher = ReturnType<typeof ignore>;\n\nfunction toPosixPath(p: string): string {\n\treturn p.split(sep).join(\"/\");\n}\n\nfunction prefixIgnorePattern(line: string, prefix: string): string | null {\n\tconst trimmed = line.trim();\n\tif (!trimmed) return null;\n\tif (trimmed.startsWith(\"#\") && !trimmed.startsWith(\"\\\\#\")) return null;\n\n\tlet pattern = line;\n\tlet negated = false;\n\n\tif (pattern.startsWith(\"!\")) {\n\t\tnegated = true;\n\t\tpattern = pattern.slice(1);\n\t} else if (pattern.startsWith(\"\\\\!\")) {\n\t\tpattern = pattern.slice(1);\n\t}\n\n\tif (pattern.startsWith(\"/\")) {\n\t\tpattern = pattern.slice(1);\n\t}\n\n\tconst prefixed = prefix ? `${prefix}${pattern}` : pattern;\n\treturn negated ? `!${prefixed}` : prefixed;\n}\n\nfunction addIgnoreRules(ig: IgnoreMatcher, dir: string, rootDir: string): void {\n\tconst relativeDir = relative(rootDir, dir);\n\tconst prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : \"\";\n\n\tfor (const filename of IGNORE_FILE_NAMES) {\n\t\tconst ignorePath = join(dir, filename);\n\t\tif (!existsSync(ignorePath)) continue;\n\t\ttry {\n\t\t\tconst content = readFileSync(ignorePath, \"utf-8\");\n\t\t\tconst patterns = content\n\t\t\t\t.split(/\\r?\\n/)\n\t\t\t\t.map((line) => prefixIgnorePattern(line, prefix))\n\t\t\t\t.filter((line): line is string => Boolean(line));\n\t\t\tif (patterns.length > 0) {\n\t\t\t\tig.add(patterns);\n\t\t\t}\n\t\t} catch {}\n\t}\n}\n\nexport interface SkillFrontmatter {\n\tname?: string;\n\tdescription?: string;\n\t\"disable-model-invocation\"?: boolean;\n\t/** Tools this skill requires. Mapped via the Claude Code alias table (same as agent `tools`). */\n\t\"allowed-tools\"?: string | string[];\n\t[key: string]: unknown;\n}\n\nexport interface Skill {\n\tname: string;\n\tdescription: string;\n\tfilePath: string;\n\tbaseDir: string;\n\tsourceInfo: SourceInfo;\n\tdisableModelInvocation: boolean;\n\t/** Normalized hoocode tool names this skill needs, parsed from `allowed-tools`. */\n\tallowedTools?: string[];\n}\n\nexport interface LoadSkillsResult {\n\tskills: Skill[];\n\tdiagnostics: ResourceDiagnostic[];\n}\n\n/**\n * Validate skill name per Agent Skills spec.\n * Returns array of validation error messages (empty if valid).\n */\nfunction validateName(name: string, parentDirName: string): string[] {\n\tconst errors: string[] = [];\n\n\tif (name !== parentDirName) {\n\t\terrors.push(`name \"${name}\" does not match parent directory \"${parentDirName}\"`);\n\t}\n\n\tif (name.length > MAX_NAME_LENGTH) {\n\t\terrors.push(`name exceeds ${MAX_NAME_LENGTH} characters (${name.length})`);\n\t}\n\n\tif (!/^[a-z0-9-]+$/.test(name)) {\n\t\terrors.push(`name contains invalid characters (must be lowercase a-z, 0-9, hyphens only)`);\n\t}\n\n\tif (name.startsWith(\"-\") || name.endsWith(\"-\")) {\n\t\terrors.push(`name must not start or end with a hyphen`);\n\t}\n\n\tif (name.includes(\"--\")) {\n\t\terrors.push(`name must not contain consecutive hyphens`);\n\t}\n\n\treturn errors;\n}\n\n/**\n * Validate description per Agent Skills spec.\n */\nfunction validateDescription(description: string | undefined): string[] {\n\tconst errors: string[] = [];\n\n\tif (!description || description.trim() === \"\") {\n\t\terrors.push(\"description is required\");\n\t} else if (description.length > MAX_DESCRIPTION_LENGTH) {\n\t\terrors.push(`description exceeds ${MAX_DESCRIPTION_LENGTH} characters (${description.length})`);\n\t}\n\n\treturn errors;\n}\n\nexport interface LoadSkillsFromDirOptions {\n\t/** Directory to scan for skills */\n\tdir: string;\n\t/** Source identifier for these skills */\n\tsource: string;\n}\n\nfunction createSkillSourceInfo(filePath: string, baseDir: string, source: string): SourceInfo {\n\tswitch (source) {\n\t\tcase \"user\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tscope: \"user\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tcase \"project\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tscope: \"project\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tcase \"claude-user\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tscope: \"user\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tcase \"claude-project\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tscope: \"project\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tcase \"path\":\n\t\t\treturn createSyntheticSourceInfo(filePath, {\n\t\t\t\tsource: \"local\",\n\t\t\t\tbaseDir,\n\t\t\t});\n\t\tdefault:\n\t\t\treturn createSyntheticSourceInfo(filePath, { source, baseDir });\n\t}\n}\n\n/**\n * Load skills from a directory.\n *\n * Discovery rules:\n * - if a directory contains SKILL.md, treat it as a skill root and do not recurse further\n * - otherwise, load direct .md children in the root\n * - recurse into subdirectories to find SKILL.md\n */\nexport function loadSkillsFromDir(options: LoadSkillsFromDirOptions): LoadSkillsResult {\n\tconst { dir, source } = options;\n\treturn loadSkillsFromDirInternal(dir, source, true);\n}\n\nfunction loadSkillsFromDirInternal(\n\tdir: string,\n\tsource: string,\n\tincludeRootFiles: boolean,\n\tignoreMatcher?: IgnoreMatcher,\n\trootDir?: string,\n): LoadSkillsResult {\n\tconst skills: Skill[] = [];\n\tconst diagnostics: ResourceDiagnostic[] = [];\n\n\tif (!existsSync(dir)) {\n\t\treturn { skills, diagnostics };\n\t}\n\n\tconst root = rootDir ?? dir;\n\tconst ig = ignoreMatcher ?? ignore();\n\taddIgnoreRules(ig, dir, root);\n\n\ttry {\n\t\tconst entries = readdirSync(dir, { withFileTypes: true });\n\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.name !== \"SKILL.md\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst fullPath = join(dir, entry.name);\n\n\t\t\tlet isFile = entry.isFile();\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\ttry {\n\t\t\t\t\tisFile = statSync(fullPath).isFile();\n\t\t\t\t} catch {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst relPath = toPosixPath(relative(root, fullPath));\n\t\t\tif (!isFile || ig.ignores(relPath)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst result = loadSkillFromFile(fullPath, source);\n\t\t\tif (result.skill) {\n\t\t\t\tskills.push(result.skill);\n\t\t\t}\n\t\t\tdiagnostics.push(...result.diagnostics);\n\t\t\treturn { skills, diagnostics };\n\t\t}\n\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.name.startsWith(\".\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Skip node_modules to avoid scanning dependencies\n\t\t\tif (entry.name === \"node_modules\") {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst fullPath = join(dir, entry.name);\n\n\t\t\t// For symlinks, check if they point to a directory and follow them\n\t\t\tlet isDirectory = entry.isDirectory();\n\t\t\tlet isFile = entry.isFile();\n\t\t\tif (entry.isSymbolicLink()) {\n\t\t\t\ttry {\n\t\t\t\t\tconst stats = statSync(fullPath);\n\t\t\t\t\tisDirectory = stats.isDirectory();\n\t\t\t\t\tisFile = stats.isFile();\n\t\t\t\t} catch {\n\t\t\t\t\t// Broken symlink, skip it\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst relPath = toPosixPath(relative(root, fullPath));\n\t\t\tconst ignorePath = isDirectory ? `${relPath}/` : relPath;\n\t\t\tif (ig.ignores(ignorePath)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (isDirectory) {\n\t\t\t\t// A plugin directory is not a skill tree. Its `skills/<name>/SKILL.md`\n\t\t\t\t// files belong to the plugin and are contributed through the plugin\n\t\t\t\t// loader (namespaced to it); descending here would additionally\n\t\t\t\t// surface them as loose top-level skills under their bare names.\n\t\t\t\t// This matters most under `.claude/skills/`, which legitimately holds\n\t\t\t\t// both plain skills and skills-directory plugins side by side.\n\t\t\t\tif (isPluginRoot(fullPath)) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst subResult = loadSkillsFromDirInternal(fullPath, source, false, ig, root);\n\t\t\t\tskills.push(...subResult.skills);\n\t\t\t\tdiagnostics.push(...subResult.diagnostics);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (!isFile || !includeRootFiles || !entry.name.endsWith(\".md\")) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst result = loadSkillFromFile(fullPath, source);\n\t\t\tif (result.skill) {\n\t\t\t\tskills.push(result.skill);\n\t\t\t}\n\t\t\tdiagnostics.push(...result.diagnostics);\n\t\t}\n\t} catch {}\n\n\treturn { skills, diagnostics };\n}\n\nfunction loadSkillFromFile(\n\tfilePath: string,\n\tsource: string,\n): { skill: Skill | null; diagnostics: ResourceDiagnostic[] } {\n\tconst diagnostics: ResourceDiagnostic[] = [];\n\n\ttry {\n\t\tconst rawContent = readFileSync(filePath, \"utf-8\");\n\t\tconst { frontmatter } = parseFrontmatter<SkillFrontmatter>(rawContent);\n\t\tconst skillDir = dirname(filePath);\n\t\tconst parentDirName = basename(skillDir);\n\n\t\t// Validate description\n\t\tconst descErrors = validateDescription(frontmatter.description);\n\t\tfor (const error of descErrors) {\n\t\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\n\t\t}\n\n\t\t// Use name from frontmatter, or fall back to parent directory name\n\t\tconst name = frontmatter.name || parentDirName;\n\n\t\t// Validate name\n\t\tconst nameErrors = validateName(name, parentDirName);\n\t\tfor (const error of nameErrors) {\n\t\t\tdiagnostics.push({ type: \"warning\", message: error, path: filePath });\n\t\t}\n\n\t\t// Still load the skill even with warnings (unless description is completely missing)\n\t\tif (!frontmatter.description || frontmatter.description.trim() === \"\") {\n\t\t\treturn { skill: null, diagnostics };\n\t\t}\n\n\t\tlet allowedTools: string[] | undefined;\n\t\tif (frontmatter[\"allowed-tools\"] !== undefined) {\n\t\t\tconst normalized = normalizeTools(frontmatter[\"allowed-tools\"], filePath);\n\t\t\tdiagnostics.push(...normalized.diagnostics);\n\t\t\tif (normalized.tools.length > 0) {\n\t\t\t\tallowedTools = normalized.tools;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tskill: {\n\t\t\t\tname,\n\t\t\t\tdescription: frontmatter.description,\n\t\t\t\tfilePath,\n\t\t\t\tbaseDir: skillDir,\n\t\t\t\tsourceInfo: createSkillSourceInfo(filePath, skillDir, source),\n\t\t\t\tdisableModelInvocation: frontmatter[\"disable-model-invocation\"] === true,\n\t\t\t\tallowedTools,\n\t\t\t},\n\t\t\tdiagnostics,\n\t\t};\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : \"failed to parse skill file\";\n\t\tdiagnostics.push({ type: \"warning\", message, path: filePath });\n\t\treturn { skill: null, diagnostics };\n\t}\n}\n\n/**\n * Format skills for inclusion in a system prompt.\n * Uses XML format per Agent Skills standard.\n * See: https://agentskills.io/integrate-skills\n *\n * Skills with disableModelInvocation=true are excluded from the prompt\n * (they can only be invoked explicitly via /skill:name commands).\n */\nexport function formatSkillsForPrompt(skills: Skill[]): string {\n\tconst visibleSkills = skills.filter((s) => !s.disableModelInvocation);\n\n\tif (visibleSkills.length === 0) {\n\t\treturn \"\";\n\t}\n\n\tconst lines = [\n\t\t\"\\n\\nThe following skills provide specialized instructions for specific tasks.\",\n\t\t\"Use the read tool to load a skill's file when the task matches its description.\",\n\t\t\"When a skill file references a relative path, resolve it against the skill directory (parent of SKILL.md / dirname of the path) and use that absolute path in tool commands.\",\n\t\t\"\",\n\t\t\"<available_skills>\",\n\t];\n\n\tfor (const skill of visibleSkills) {\n\t\tlines.push(\" <skill>\");\n\t\tlines.push(` <name>${escapeXml(skill.name)}</name>`);\n\t\tlines.push(` <description>${escapeXml(skill.description)}</description>`);\n\t\tif (skill.allowedTools && skill.allowedTools.length > 0) {\n\t\t\tlines.push(` <tools>${escapeXml(skill.allowedTools.join(\", \"))}</tools>`);\n\t\t}\n\t\tlines.push(` <location>${escapeXml(skill.filePath)}</location>`);\n\t\tlines.push(\" </skill>\");\n\t}\n\n\tlines.push(\"</available_skills>\");\n\n\treturn lines.join(\"\\n\");\n}\n\nfunction escapeXml(str: string): string {\n\treturn str\n\t\t.replace(/&/g, \"&amp;\")\n\t\t.replace(/</g, \"&lt;\")\n\t\t.replace(/>/g, \"&gt;\")\n\t\t.replace(/\"/g, \"&quot;\")\n\t\t.replace(/'/g, \"&apos;\");\n}\n\nexport interface LoadSkillsOptions {\n\t/** Working directory for project-local skills. */\n\tcwd: string;\n\t/** Agent config directory for global skills. */\n\tagentDir: string;\n\t/** Explicit skill paths (files or directories) */\n\tskillPaths: string[];\n\t/** Include default skills directories. */\n\tincludeDefaults: boolean;\n\t/**\n\t * Discover skills from `.claude/skills/` directories (D7 native import).\n\t * Defaults to true. Set false in tests or when explicit path control is needed.\n\t */\n\tincludeClaude?: boolean;\n\t/**\n\t * Contributed skill directory -> owning plugin id. Skills loaded from such a\n\t * directory are named `<plugin>:<skill>`, matching Claude Code.\n\t *\n\t * Applied here rather than by the caller because the name map below is\n\t * first-wins by name: two plugins shipping a `review` skill would collide and\n\t * lose one *before* any later rename could tell them apart.\n\t */\n\tnamespaces?: Map<string, string>;\n}\n\nfunction normalizePath(input: string): string {\n\tconst trimmed = input.trim();\n\tif (trimmed === \"~\") return homedir();\n\tif (trimmed.startsWith(\"~/\")) return join(homedir(), trimmed.slice(2));\n\tif (trimmed.startsWith(\"~\")) return join(homedir(), trimmed.slice(1));\n\treturn trimmed;\n}\n\nfunction resolveSkillPath(p: string, cwd: string): string {\n\tconst normalized = normalizePath(p);\n\treturn isAbsolute(normalized) ? normalized : resolve(cwd, normalized);\n}\n\n/**\n * Load skills from all configured locations.\n * Returns skills and any validation diagnostics.\n */\nexport function loadSkills(options: LoadSkillsOptions): LoadSkillsResult {\n\tconst { cwd, agentDir, skillPaths, includeDefaults, includeClaude = true, namespaces } = options;\n\n\t// Resolve agentDir - if not provided, use default from config\n\tconst resolvedAgentDir = agentDir ?? getAgentDir();\n\n\tconst skillMap = new Map<string, Skill>();\n\tconst realPathSet = new Set<string>();\n\tconst allDiagnostics: ResourceDiagnostic[] = [];\n\tconst collisionDiagnostics: ResourceDiagnostic[] = [];\n\n\tfunction addSkills(result: LoadSkillsResult) {\n\t\tallDiagnostics.push(...result.diagnostics);\n\t\tfor (const skill of result.skills) {\n\t\t\t// Resolve symlinks to detect duplicate files\n\t\t\tconst realPath = canonicalizePath(skill.filePath);\n\n\t\t\t// Skip silently if we've already loaded this exact file (via symlink)\n\t\t\tif (realPathSet.has(realPath)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst existing = skillMap.get(skill.name);\n\t\t\tif (existing) {\n\t\t\t\tcollisionDiagnostics.push({\n\t\t\t\t\ttype: \"collision\",\n\t\t\t\t\tmessage: `name \"${skill.name}\" collision`,\n\t\t\t\t\tpath: skill.filePath,\n\t\t\t\t\tcollision: {\n\t\t\t\t\t\tresourceType: \"skill\",\n\t\t\t\t\t\tname: skill.name,\n\t\t\t\t\t\twinnerPath: existing.filePath,\n\t\t\t\t\t\tloserPath: skill.filePath,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tskillMap.set(skill.name, skill);\n\t\t\t\trealPathSet.add(realPath);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (includeDefaults) {\n\t\tif (includeClaude) {\n\t\t\t// D7 native import: mirror agent-registry.ts for interop with .claude/ directories\n\t\t\taddSkills(loadSkillsFromDirInternal(join(homedir(), \".claude\", \"skills\"), \"claude-user\", true));\n\t\t\taddSkills(loadSkillsFromDirInternal(resolve(cwd, \".claude\", \"skills\"), \"claude-project\", true));\n\t\t}\n\t\t// hoocode-native locations take precedence (loaded after = win on name collision)\n\t\taddSkills(loadSkillsFromDirInternal(join(resolvedAgentDir, \"skills\"), \"user\", true));\n\t\taddSkills(loadSkillsFromDirInternal(resolve(cwd, CONFIG_DIR_NAME, \"skills\"), \"project\", true));\n\t}\n\n\tconst userSkillsDir = join(resolvedAgentDir, \"skills\");\n\tconst projectSkillsDir = resolve(cwd, CONFIG_DIR_NAME, \"skills\");\n\n\tconst isUnderPath = (target: string, root: string): boolean => {\n\t\tconst normalizedRoot = resolve(root);\n\t\tif (target === normalizedRoot) {\n\t\t\treturn true;\n\t\t}\n\t\tconst prefix = normalizedRoot.endsWith(sep) ? normalizedRoot : `${normalizedRoot}${sep}`;\n\t\treturn target.startsWith(prefix);\n\t};\n\n\tconst getSource = (resolvedPath: string): \"user\" | \"project\" | \"path\" => {\n\t\tif (!includeDefaults) {\n\t\t\tif (isUnderPath(resolvedPath, userSkillsDir)) return \"user\";\n\t\t\tif (isUnderPath(resolvedPath, projectSkillsDir)) return \"project\";\n\t\t}\n\t\treturn \"path\";\n\t};\n\n\t/** Prefix a batch of skills with `namespace:` before they enter the name map. */\n\tconst addNamespaced = (result: LoadSkillsResult, namespace: string | undefined) => {\n\t\tif (!namespace) return addSkills(result);\n\t\taddSkills({\n\t\t\t...result,\n\t\t\tskills: result.skills.map((skill) => ({ ...skill, name: `${namespace}:${skill.name}` })),\n\t\t});\n\t};\n\n\tfor (const rawPath of skillPaths) {\n\t\tconst resolvedPath = resolveSkillPath(rawPath, cwd);\n\t\tconst namespace = namespaces?.get(rawPath) ?? namespaces?.get(resolvedPath);\n\t\tif (!existsSync(resolvedPath)) {\n\t\t\tallDiagnostics.push({ type: \"warning\", message: \"skill path does not exist\", path: resolvedPath });\n\t\t\tcontinue;\n\t\t}\n\n\t\ttry {\n\t\t\tconst stats = statSync(resolvedPath);\n\t\t\tconst source = getSource(resolvedPath);\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\taddNamespaced(loadSkillsFromDirInternal(resolvedPath, source, true), namespace);\n\t\t\t} else if (stats.isFile() && resolvedPath.endsWith(\".md\")) {\n\t\t\t\tconst result = loadSkillFromFile(resolvedPath, source);\n\t\t\t\tif (result.skill) {\n\t\t\t\t\taddNamespaced({ skills: [result.skill], diagnostics: result.diagnostics }, namespace);\n\t\t\t\t} else {\n\t\t\t\t\tallDiagnostics.push(...result.diagnostics);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tallDiagnostics.push({ type: \"warning\", message: \"skill path is not a markdown file\", path: resolvedPath });\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tconst message = error instanceof Error ? error.message : \"failed to read skill path\";\n\t\t\tallDiagnostics.push({ type: \"warning\", message, path: resolvedPath });\n\t\t}\n\t}\n\n\treturn {\n\t\tskills: Array.from(skillMap.values()),\n\t\tdiagnostics: [...allDiagnostics, ...collisionDiagnostics],\n\t};\n}\n"]}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * PackagePlugin — the autonomous half of the publish lane (spec §3.2).
3
+ *
4
+ * Everything before the button: run the eval gates at publish strictness, write
5
+ * a README if the plugin has none, produce the marketplace index entry, and hand
6
+ * back the instructions for the step the model must not take. The tool touches no
7
+ * remote and cannot publish; `/plugin publish` (a human command) is where the
8
+ * artifact actually leaves the machine.
9
+ *
10
+ * It is autonomous because none of it is irreversible — it writes two files into
11
+ * a directory the plugin already owns — and because the value of the lane is that
12
+ * the human's remaining decision is *just* the approval, with the mechanics
13
+ * already done and the checks already run. It is in
14
+ * {@link PLUGIN_SYSTEM_TOOL_NAMES} all the same: an authored subagent that could
15
+ * package is one step from a subagent that could publish.
16
+ */
17
+ import { type ToolDefinition } from "../extensions/types.js";
18
+ export declare function createPackagePluginToolDefinition(): ToolDefinition;
19
+ //# sourceMappingURL=package-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-plugin.d.ts","sourceRoot":"","sources":["../../../src/core/tools/package-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,OAAO,EAAc,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAyBzE,wBAAgB,iCAAiC,IAAI,cAAc,CAyDlE","sourcesContent":["/**\n * PackagePlugin — the autonomous half of the publish lane (spec §3.2).\n *\n * Everything before the button: run the eval gates at publish strictness, write\n * a README if the plugin has none, produce the marketplace index entry, and hand\n * back the instructions for the step the model must not take. The tool touches no\n * remote and cannot publish; `/plugin publish` (a human command) is where the\n * artifact actually leaves the machine.\n *\n * It is autonomous because none of it is irreversible — it writes two files into\n * a directory the plugin already owns — and because the value of the lane is that\n * the human's remaining decision is *just* the approval, with the mechanics\n * already done and the checks already run. It is in\n * {@link PLUGIN_SYSTEM_TOOL_NAMES} all the same: an authored subagent that could\n * package is one step from a subagent that could publish.\n */\n\nimport { type Static, Type } from \"typebox\";\nimport { getPlugin } from \"../extensions/plugins/authoring.js\";\nimport { normalizePlatformToken } from \"../extensions/plugins/formats/platform-targets.js\";\nimport { entryNeedsSource, packagePlugin, resolvePackagePlatform } from \"../extensions/plugins/packaging.js\";\nimport { defineTool, type ToolDefinition } from \"../extensions/types.js\";\nimport { PACKAGE_PLUGIN_TOOL_NAME } from \"./plugin-tool-names.js\";\n\nconst packageParams = Type.Object(\n\t{\n\t\tid: Type.String({ description: \"Id of the installed or authored plugin to package.\" }),\n\t\tplatform: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"claude\"), Type.Literal(\"github\")], {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Target ecosystem. Omit to use the plugin's own — where it lives decides, then what it declares. \" +\n\t\t\t\t\t\"`agents` is not a choice here: it belongs to no marketplace, so nothing can be published for it.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\ninterface PackagePluginDetails {\n\tid: string;\n\tpackaged: boolean;\n\t/** Whether the gates were green — i.e. whether the plugin may be published at all. */\n\tready: boolean;\n\tplatform?: string;\n}\n\nexport function createPackagePluginToolDefinition(): ToolDefinition {\n\treturn defineTool<typeof packageParams, PackagePluginDetails>({\n\t\tname: PACKAGE_PLUGIN_TOOL_NAME,\n\t\tlabel: PACKAGE_PLUGIN_TOOL_NAME,\n\t\tdescription:\n\t\t\t\"Prepare a local plugin for publication: run its checks at publish strictness (structural, safety, and a \" +\n\t\t\t\"behavioral smoke run of any hooks/MCP servers), generate a README if it has none, and produce the \" +\n\t\t\t\"marketplace.json entry. Writes only inside the plugin's own directory and contacts no remote — it cannot \" +\n\t\t\t\"publish. Use it to find out whether a plugin is publishable and to hand the user a ready-to-submit bundle; \" +\n\t\t\t\"they run /plugin publish to do the actual submission.\",\n\t\tpromptSnippet: \"Package a plugin for publication (gates + README + index entry; never publishes).\",\n\t\tpromptGuidelines: [\n\t\t\t\"Packaging is safe and autonomous — it only writes into the plugin's own directory. Publishing is not: never open a PR, push, or submit a plugin to a marketplace yourself, even when asked to 'just publish it'. Package it, show the result, and point at /plugin publish.\",\n\t\t\t\"Its checks are stricter than authoring's, so a plugin that authored fine can still fail here. Report what failed and offer to fix it rather than presenting a red result as done.\",\n\t\t],\n\t\tparameters: packageParams,\n\t\tasync execute(_id, params: Static<typeof packageParams>, _signal, _onUpdate, ctx) {\n\t\t\tconst fail = (text: string) => ({\n\t\t\t\tcontent: [{ type: \"text\" as const, text }],\n\t\t\t\tdetails: { id: params.id, packaged: false, ready: false },\n\t\t\t});\n\n\t\t\tconst plugin = getPlugin(ctx.cwd, params.id);\n\t\t\tif (!plugin) return fail(`No plugin named \"${params.id}\" is installed or authored here.`);\n\n\t\t\t// The schema already excludes `agents`, so this only folds the aliases\n\t\t\t// (`copilot`, `gh`) a model might reasonably reach for.\n\t\t\tconst requested = params.platform ? normalizePlatformToken(params.platform) : undefined;\n\t\t\tconst platform = requested === \"claude\" || requested === \"github\" ? requested : resolvePackagePlatform(plugin);\n\n\t\t\tconst result = await packagePlugin(plugin, platform);\n\t\t\tconst text = [\n\t\t\t\t`Packaged \"${params.id}\" for ${result.platform} in ${result.dir}`,\n\t\t\t\t`Wrote: ${result.written.join(\", \")}`,\n\t\t\t\t\"\",\n\t\t\t\tresult.instructions,\n\t\t\t].join(\"\\n\");\n\t\t\tctx.ui.notify(\n\t\t\t\tresult.ok\n\t\t\t\t\t? `Packaged \"${params.id}\" for ${result.platform} — ready to publish with /plugin publish ${params.id}.`\n\t\t\t\t\t: `Packaged \"${params.id}\" for ${result.platform}, but its checks failed — not publishable yet.`,\n\t\t\t\tresult.ok ? \"info\" : \"warning\",\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\tresult.ok && entryNeedsSource(result.entry)\n\t\t\t\t\t\t\t\t? `${text}\\n\\nThe entry's \\`source\\` is a placeholder — the user must say where the plugin will be hosted.`\n\t\t\t\t\t\t\t\t: text,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdetails: { id: params.id, packaged: true, ready: result.ok, platform: result.platform },\n\t\t\t};\n\t\t},\n\t});\n}\n"]}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * PackagePlugin — the autonomous half of the publish lane (spec §3.2).
3
+ *
4
+ * Everything before the button: run the eval gates at publish strictness, write
5
+ * a README if the plugin has none, produce the marketplace index entry, and hand
6
+ * back the instructions for the step the model must not take. The tool touches no
7
+ * remote and cannot publish; `/plugin publish` (a human command) is where the
8
+ * artifact actually leaves the machine.
9
+ *
10
+ * It is autonomous because none of it is irreversible — it writes two files into
11
+ * a directory the plugin already owns — and because the value of the lane is that
12
+ * the human's remaining decision is *just* the approval, with the mechanics
13
+ * already done and the checks already run. It is in
14
+ * {@link PLUGIN_SYSTEM_TOOL_NAMES} all the same: an authored subagent that could
15
+ * package is one step from a subagent that could publish.
16
+ */
17
+ import { Type } from "typebox";
18
+ import { getPlugin } from "../extensions/plugins/authoring.js";
19
+ import { normalizePlatformToken } from "../extensions/plugins/formats/platform-targets.js";
20
+ import { entryNeedsSource, packagePlugin, resolvePackagePlatform } from "../extensions/plugins/packaging.js";
21
+ import { defineTool } from "../extensions/types.js";
22
+ import { PACKAGE_PLUGIN_TOOL_NAME } from "./plugin-tool-names.js";
23
+ const packageParams = Type.Object({
24
+ id: Type.String({ description: "Id of the installed or authored plugin to package." }),
25
+ platform: Type.Optional(Type.Union([Type.Literal("claude"), Type.Literal("github")], {
26
+ description: "Target ecosystem. Omit to use the plugin's own — where it lives decides, then what it declares. " +
27
+ "`agents` is not a choice here: it belongs to no marketplace, so nothing can be published for it.",
28
+ })),
29
+ }, { additionalProperties: false });
30
+ export function createPackagePluginToolDefinition() {
31
+ return defineTool({
32
+ name: PACKAGE_PLUGIN_TOOL_NAME,
33
+ label: PACKAGE_PLUGIN_TOOL_NAME,
34
+ description: "Prepare a local plugin for publication: run its checks at publish strictness (structural, safety, and a " +
35
+ "behavioral smoke run of any hooks/MCP servers), generate a README if it has none, and produce the " +
36
+ "marketplace.json entry. Writes only inside the plugin's own directory and contacts no remote — it cannot " +
37
+ "publish. Use it to find out whether a plugin is publishable and to hand the user a ready-to-submit bundle; " +
38
+ "they run /plugin publish to do the actual submission.",
39
+ promptSnippet: "Package a plugin for publication (gates + README + index entry; never publishes).",
40
+ promptGuidelines: [
41
+ "Packaging is safe and autonomous — it only writes into the plugin's own directory. Publishing is not: never open a PR, push, or submit a plugin to a marketplace yourself, even when asked to 'just publish it'. Package it, show the result, and point at /plugin publish.",
42
+ "Its checks are stricter than authoring's, so a plugin that authored fine can still fail here. Report what failed and offer to fix it rather than presenting a red result as done.",
43
+ ],
44
+ parameters: packageParams,
45
+ async execute(_id, params, _signal, _onUpdate, ctx) {
46
+ const fail = (text) => ({
47
+ content: [{ type: "text", text }],
48
+ details: { id: params.id, packaged: false, ready: false },
49
+ });
50
+ const plugin = getPlugin(ctx.cwd, params.id);
51
+ if (!plugin)
52
+ return fail(`No plugin named "${params.id}" is installed or authored here.`);
53
+ // The schema already excludes `agents`, so this only folds the aliases
54
+ // (`copilot`, `gh`) a model might reasonably reach for.
55
+ const requested = params.platform ? normalizePlatformToken(params.platform) : undefined;
56
+ const platform = requested === "claude" || requested === "github" ? requested : resolvePackagePlatform(plugin);
57
+ const result = await packagePlugin(plugin, platform);
58
+ const text = [
59
+ `Packaged "${params.id}" for ${result.platform} in ${result.dir}`,
60
+ `Wrote: ${result.written.join(", ")}`,
61
+ "",
62
+ result.instructions,
63
+ ].join("\n");
64
+ ctx.ui.notify(result.ok
65
+ ? `Packaged "${params.id}" for ${result.platform} — ready to publish with /plugin publish ${params.id}.`
66
+ : `Packaged "${params.id}" for ${result.platform}, but its checks failed — not publishable yet.`, result.ok ? "info" : "warning");
67
+ return {
68
+ content: [
69
+ {
70
+ type: "text",
71
+ text: result.ok && entryNeedsSource(result.entry)
72
+ ? `${text}\n\nThe entry's \`source\` is a placeholder — the user must say where the plugin will be hosted.`
73
+ : text,
74
+ },
75
+ ],
76
+ details: { id: params.id, packaged: true, ready: result.ok, platform: result.platform },
77
+ };
78
+ },
79
+ });
80
+ }
81
+ //# sourceMappingURL=package-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-plugin.js","sourceRoot":"","sources":["../../../src/core/tools/package-plugin.ts"],"names":[],"mappings":"AAAA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E,SAAS,MAAM,CAAC,QAAQ,kDAAgD,EACjG,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAC9B,CAAC;YACF,OAAO;gBACN,OAAO,EAAE;oBACR;wBACC,IAAI,EAAE,MAAe;wBACrB,IAAI,EACH,MAAM,CAAC,EAAE,IAAI,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC;4BAC1C,CAAC,CAAC,GAAG,IAAI,oGAAkG;4BAC3G,CAAC,CAAC,IAAI;qBACR;iBACD;gBACD,OAAO,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE;aACvF,CAAC;QAAA,CACF;KACD,CAAC,CAAC;AAAA,CACH","sourcesContent":["/**\n * PackagePlugin — the autonomous half of the publish lane (spec §3.2).\n *\n * Everything before the button: run the eval gates at publish strictness, write\n * a README if the plugin has none, produce the marketplace index entry, and hand\n * back the instructions for the step the model must not take. The tool touches no\n * remote and cannot publish; `/plugin publish` (a human command) is where the\n * artifact actually leaves the machine.\n *\n * It is autonomous because none of it is irreversible — it writes two files into\n * a directory the plugin already owns — and because the value of the lane is that\n * the human's remaining decision is *just* the approval, with the mechanics\n * already done and the checks already run. It is in\n * {@link PLUGIN_SYSTEM_TOOL_NAMES} all the same: an authored subagent that could\n * package is one step from a subagent that could publish.\n */\n\nimport { type Static, Type } from \"typebox\";\nimport { getPlugin } from \"../extensions/plugins/authoring.js\";\nimport { normalizePlatformToken } from \"../extensions/plugins/formats/platform-targets.js\";\nimport { entryNeedsSource, packagePlugin, resolvePackagePlatform } from \"../extensions/plugins/packaging.js\";\nimport { defineTool, type ToolDefinition } from \"../extensions/types.js\";\nimport { PACKAGE_PLUGIN_TOOL_NAME } from \"./plugin-tool-names.js\";\n\nconst packageParams = Type.Object(\n\t{\n\t\tid: Type.String({ description: \"Id of the installed or authored plugin to package.\" }),\n\t\tplatform: Type.Optional(\n\t\t\tType.Union([Type.Literal(\"claude\"), Type.Literal(\"github\")], {\n\t\t\t\tdescription:\n\t\t\t\t\t\"Target ecosystem. Omit to use the plugin's own — where it lives decides, then what it declares. \" +\n\t\t\t\t\t\"`agents` is not a choice here: it belongs to no marketplace, so nothing can be published for it.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ additionalProperties: false },\n);\n\ninterface PackagePluginDetails {\n\tid: string;\n\tpackaged: boolean;\n\t/** Whether the gates were green — i.e. whether the plugin may be published at all. */\n\tready: boolean;\n\tplatform?: string;\n}\n\nexport function createPackagePluginToolDefinition(): ToolDefinition {\n\treturn defineTool<typeof packageParams, PackagePluginDetails>({\n\t\tname: PACKAGE_PLUGIN_TOOL_NAME,\n\t\tlabel: PACKAGE_PLUGIN_TOOL_NAME,\n\t\tdescription:\n\t\t\t\"Prepare a local plugin for publication: run its checks at publish strictness (structural, safety, and a \" +\n\t\t\t\"behavioral smoke run of any hooks/MCP servers), generate a README if it has none, and produce the \" +\n\t\t\t\"marketplace.json entry. Writes only inside the plugin's own directory and contacts no remote — it cannot \" +\n\t\t\t\"publish. Use it to find out whether a plugin is publishable and to hand the user a ready-to-submit bundle; \" +\n\t\t\t\"they run /plugin publish to do the actual submission.\",\n\t\tpromptSnippet: \"Package a plugin for publication (gates + README + index entry; never publishes).\",\n\t\tpromptGuidelines: [\n\t\t\t\"Packaging is safe and autonomous — it only writes into the plugin's own directory. Publishing is not: never open a PR, push, or submit a plugin to a marketplace yourself, even when asked to 'just publish it'. Package it, show the result, and point at /plugin publish.\",\n\t\t\t\"Its checks are stricter than authoring's, so a plugin that authored fine can still fail here. Report what failed and offer to fix it rather than presenting a red result as done.\",\n\t\t],\n\t\tparameters: packageParams,\n\t\tasync execute(_id, params: Static<typeof packageParams>, _signal, _onUpdate, ctx) {\n\t\t\tconst fail = (text: string) => ({\n\t\t\t\tcontent: [{ type: \"text\" as const, text }],\n\t\t\t\tdetails: { id: params.id, packaged: false, ready: false },\n\t\t\t});\n\n\t\t\tconst plugin = getPlugin(ctx.cwd, params.id);\n\t\t\tif (!plugin) return fail(`No plugin named \"${params.id}\" is installed or authored here.`);\n\n\t\t\t// The schema already excludes `agents`, so this only folds the aliases\n\t\t\t// (`copilot`, `gh`) a model might reasonably reach for.\n\t\t\tconst requested = params.platform ? normalizePlatformToken(params.platform) : undefined;\n\t\t\tconst platform = requested === \"claude\" || requested === \"github\" ? requested : resolvePackagePlatform(plugin);\n\n\t\t\tconst result = await packagePlugin(plugin, platform);\n\t\t\tconst text = [\n\t\t\t\t`Packaged \"${params.id}\" for ${result.platform} in ${result.dir}`,\n\t\t\t\t`Wrote: ${result.written.join(\", \")}`,\n\t\t\t\t\"\",\n\t\t\t\tresult.instructions,\n\t\t\t].join(\"\\n\");\n\t\t\tctx.ui.notify(\n\t\t\t\tresult.ok\n\t\t\t\t\t? `Packaged \"${params.id}\" for ${result.platform} — ready to publish with /plugin publish ${params.id}.`\n\t\t\t\t\t: `Packaged \"${params.id}\" for ${result.platform}, but its checks failed — not publishable yet.`,\n\t\t\t\tresult.ok ? \"info\" : \"warning\",\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: \"text\" as const,\n\t\t\t\t\t\ttext:\n\t\t\t\t\t\t\tresult.ok && entryNeedsSource(result.entry)\n\t\t\t\t\t\t\t\t? `${text}\\n\\nThe entry's \\`source\\` is a placeholder — the user must say where the plugin will be hosted.`\n\t\t\t\t\t\t\t\t: text,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t\tdetails: { id: params.id, packaged: true, ready: result.ok, platform: result.platform },\n\t\t\t};\n\t\t},\n\t});\n}\n"]}
@@ -17,6 +17,7 @@ export declare const UNINSTALL_PLUGIN_TOOL_NAME = "UninstallPlugin";
17
17
  export declare const PROPOSE_PLUGIN_TOOL_NAME = "ProposePlugin";
18
18
  export declare const UPDATE_PLUGIN_TOOL_NAME = "UpdatePlugin";
19
19
  export declare const REMOVE_PLUGIN_CAPABILITY_TOOL_NAME = "RemovePluginCapability";
20
+ export declare const PACKAGE_PLUGIN_TOOL_NAME = "PackagePlugin";
20
21
  /** Every capability-acquisition tool — the guardrail set stripped from authored allowlists. */
21
22
  export declare const PLUGIN_SYSTEM_TOOL_NAMES: readonly string[];
22
23
  //# sourceMappingURL=plugin-tool-names.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-tool-names.d.ts","sourceRoot":"","sources":["../../../src/core/tools/plugin-tool-names.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AACxD,eAAO,MAAM,sBAAsB,gBAAgB,CAAC;AACpD,eAAO,MAAM,gCAAgC,yBAAyB,CAAC;AACvE,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AACxD,eAAO,MAAM,0BAA0B,oBAAoB,CAAC;AAS5D,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AACxD,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AACtD,eAAO,MAAM,kCAAkC,2BAA2B,CAAC;AAE3E,iGAA+F;AAC/F,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EASrD,CAAC","sourcesContent":["/**\n * Canonical names of the plugin-system (capability-acquisition) tools, in one\n * dependency-free module so the tool definitions, the authoring engine, and the\n * privilege-amplification guardrail can all reference them without an import\n * cycle.\n *\n * {@link PLUGIN_SYSTEM_TOOL_NAMES} is the guardrail set: these tools live on the\n * top-level agent only and may never appear in an authored subagent's allowlist\n * (otherwise a low-trust authored agent could bootstrap privilege via an\n * author → spawn → install loop).\n */\n\n// Lifecycle tools (spec §1).\nexport const SEARCH_PLUGINS_TOOL_NAME = \"SearchPlugins\";\nexport const LIST_PLUGINS_TOOL_NAME = \"ListPlugins\";\nexport const SUGGEST_PLUGIN_INSTALL_TOOL_NAME = \"SuggestPluginInstall\";\nexport const INSTALL_PLUGIN_TOOL_NAME = \"InstallPlugin\";\nexport const UNINSTALL_PLUGIN_TOOL_NAME = \"UninstallPlugin\";\n\n// Authoring tools (spec §3). A single risk-gated authoring tool (ProposePlugin)\n// computes risk from *content* — passive skills/commands/read-only subagents run\n// autonomously; executable content (hooks, MCP servers, mutating subagents)\n// auto-triggers a human-confirmation gate in the same tool. UpdatePlugin merges\n// inline-authored content into an existing local plugin (no remote fetch, so the\n// supply-chain vector that keeps marketplace UpdatePlugin out of the model's\n// hands is structurally absent — see propose-plugin.ts).\nexport const PROPOSE_PLUGIN_TOOL_NAME = \"ProposePlugin\";\nexport const UPDATE_PLUGIN_TOOL_NAME = \"UpdatePlugin\";\nexport const REMOVE_PLUGIN_CAPABILITY_TOOL_NAME = \"RemovePluginCapability\";\n\n/** Every capability-acquisition tool — the guardrail set stripped from authored allowlists. */\nexport const PLUGIN_SYSTEM_TOOL_NAMES: readonly string[] = [\n\tSEARCH_PLUGINS_TOOL_NAME,\n\tLIST_PLUGINS_TOOL_NAME,\n\tSUGGEST_PLUGIN_INSTALL_TOOL_NAME,\n\tINSTALL_PLUGIN_TOOL_NAME,\n\tUNINSTALL_PLUGIN_TOOL_NAME,\n\tPROPOSE_PLUGIN_TOOL_NAME,\n\tUPDATE_PLUGIN_TOOL_NAME,\n\tREMOVE_PLUGIN_CAPABILITY_TOOL_NAME,\n];\n"]}
1
+ {"version":3,"file":"plugin-tool-names.d.ts","sourceRoot":"","sources":["../../../src/core/tools/plugin-tool-names.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AACxD,eAAO,MAAM,sBAAsB,gBAAgB,CAAC;AACpD,eAAO,MAAM,gCAAgC,yBAAyB,CAAC;AACvE,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AACxD,eAAO,MAAM,0BAA0B,oBAAoB,CAAC;AAS5D,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AACxD,eAAO,MAAM,uBAAuB,iBAAiB,CAAC;AACtD,eAAO,MAAM,kCAAkC,2BAA2B,CAAC;AAM3E,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AAExD,iGAA+F;AAC/F,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAUrD,CAAC","sourcesContent":["/**\n * Canonical names of the plugin-system (capability-acquisition) tools, in one\n * dependency-free module so the tool definitions, the authoring engine, and the\n * privilege-amplification guardrail can all reference them without an import\n * cycle.\n *\n * {@link PLUGIN_SYSTEM_TOOL_NAMES} is the guardrail set: these tools live on the\n * top-level agent only and may never appear in an authored subagent's allowlist\n * (otherwise a low-trust authored agent could bootstrap privilege via an\n * author → spawn → install loop).\n */\n\n// Lifecycle tools (spec §1).\nexport const SEARCH_PLUGINS_TOOL_NAME = \"SearchPlugins\";\nexport const LIST_PLUGINS_TOOL_NAME = \"ListPlugins\";\nexport const SUGGEST_PLUGIN_INSTALL_TOOL_NAME = \"SuggestPluginInstall\";\nexport const INSTALL_PLUGIN_TOOL_NAME = \"InstallPlugin\";\nexport const UNINSTALL_PLUGIN_TOOL_NAME = \"UninstallPlugin\";\n\n// Authoring tools (spec §3). A single risk-gated authoring tool (ProposePlugin)\n// computes risk from *content* — passive skills/commands/read-only subagents run\n// autonomously; executable content (hooks, MCP servers, mutating subagents)\n// auto-triggers a human-confirmation gate in the same tool. UpdatePlugin merges\n// inline-authored content into an existing local plugin (no remote fetch, so the\n// supply-chain vector that keeps marketplace UpdatePlugin out of the model's\n// hands is structurally absent — see propose-plugin.ts).\nexport const PROPOSE_PLUGIN_TOOL_NAME = \"ProposePlugin\";\nexport const UPDATE_PLUGIN_TOOL_NAME = \"UpdatePlugin\";\nexport const REMOVE_PLUGIN_CAPABILITY_TOOL_NAME = \"RemovePluginCapability\";\n\n// Publish lane (spec §3.2). Packaging is autonomous — it gates the plugin,\n// writes a README and produces the marketplace index entry — but it stops at the\n// trust boundary: nothing here contacts a remote or publishes anything. The\n// publish itself is `/plugin publish`, a human command.\nexport const PACKAGE_PLUGIN_TOOL_NAME = \"PackagePlugin\";\n\n/** Every capability-acquisition tool — the guardrail set stripped from authored allowlists. */\nexport const PLUGIN_SYSTEM_TOOL_NAMES: readonly string[] = [\n\tSEARCH_PLUGINS_TOOL_NAME,\n\tLIST_PLUGINS_TOOL_NAME,\n\tSUGGEST_PLUGIN_INSTALL_TOOL_NAME,\n\tINSTALL_PLUGIN_TOOL_NAME,\n\tUNINSTALL_PLUGIN_TOOL_NAME,\n\tPROPOSE_PLUGIN_TOOL_NAME,\n\tUPDATE_PLUGIN_TOOL_NAME,\n\tREMOVE_PLUGIN_CAPABILITY_TOOL_NAME,\n\tPACKAGE_PLUGIN_TOOL_NAME,\n];\n"]}
@@ -25,6 +25,11 @@ export const UNINSTALL_PLUGIN_TOOL_NAME = "UninstallPlugin";
25
25
  export const PROPOSE_PLUGIN_TOOL_NAME = "ProposePlugin";
26
26
  export const UPDATE_PLUGIN_TOOL_NAME = "UpdatePlugin";
27
27
  export const REMOVE_PLUGIN_CAPABILITY_TOOL_NAME = "RemovePluginCapability";
28
+ // Publish lane (spec §3.2). Packaging is autonomous — it gates the plugin,
29
+ // writes a README and produces the marketplace index entry — but it stops at the
30
+ // trust boundary: nothing here contacts a remote or publishes anything. The
31
+ // publish itself is `/plugin publish`, a human command.
32
+ export const PACKAGE_PLUGIN_TOOL_NAME = "PackagePlugin";
28
33
  /** Every capability-acquisition tool — the guardrail set stripped from authored allowlists. */
29
34
  export const PLUGIN_SYSTEM_TOOL_NAMES = [
30
35
  SEARCH_PLUGINS_TOOL_NAME,
@@ -35,5 +40,6 @@ export const PLUGIN_SYSTEM_TOOL_NAMES = [
35
40
  PROPOSE_PLUGIN_TOOL_NAME,
36
41
  UPDATE_PLUGIN_TOOL_NAME,
37
42
  REMOVE_PLUGIN_CAPABILITY_TOOL_NAME,
43
+ PACKAGE_PLUGIN_TOOL_NAME,
38
44
  ];
39
45
  //# sourceMappingURL=plugin-tool-names.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-tool-names.js","sourceRoot":"","sources":["../../../src/core/tools/plugin-tool-names.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,8BAA6B;AAC7B,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC;AACxD,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAAC;AACpD,MAAM,CAAC,MAAM,gCAAgC,GAAG,sBAAsB,CAAC;AACvE,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC;AACxD,MAAM,CAAC,MAAM,0BAA0B,GAAG,iBAAiB,CAAC;AAE5D,iFAAgF;AAChF,mFAAiF;AACjF,4EAA4E;AAC5E,gFAAgF;AAChF,iFAAiF;AACjF,6EAA6E;AAC7E,2DAAyD;AACzD,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC;AACxD,MAAM,CAAC,MAAM,uBAAuB,GAAG,cAAc,CAAC;AACtD,MAAM,CAAC,MAAM,kCAAkC,GAAG,wBAAwB,CAAC;AAE3E,iGAA+F;AAC/F,MAAM,CAAC,MAAM,wBAAwB,GAAsB;IAC1D,wBAAwB;IACxB,sBAAsB;IACtB,gCAAgC;IAChC,wBAAwB;IACxB,0BAA0B;IAC1B,wBAAwB;IACxB,uBAAuB;IACvB,kCAAkC;CAClC,CAAC","sourcesContent":["/**\n * Canonical names of the plugin-system (capability-acquisition) tools, in one\n * dependency-free module so the tool definitions, the authoring engine, and the\n * privilege-amplification guardrail can all reference them without an import\n * cycle.\n *\n * {@link PLUGIN_SYSTEM_TOOL_NAMES} is the guardrail set: these tools live on the\n * top-level agent only and may never appear in an authored subagent's allowlist\n * (otherwise a low-trust authored agent could bootstrap privilege via an\n * author → spawn → install loop).\n */\n\n// Lifecycle tools (spec §1).\nexport const SEARCH_PLUGINS_TOOL_NAME = \"SearchPlugins\";\nexport const LIST_PLUGINS_TOOL_NAME = \"ListPlugins\";\nexport const SUGGEST_PLUGIN_INSTALL_TOOL_NAME = \"SuggestPluginInstall\";\nexport const INSTALL_PLUGIN_TOOL_NAME = \"InstallPlugin\";\nexport const UNINSTALL_PLUGIN_TOOL_NAME = \"UninstallPlugin\";\n\n// Authoring tools (spec §3). A single risk-gated authoring tool (ProposePlugin)\n// computes risk from *content* — passive skills/commands/read-only subagents run\n// autonomously; executable content (hooks, MCP servers, mutating subagents)\n// auto-triggers a human-confirmation gate in the same tool. UpdatePlugin merges\n// inline-authored content into an existing local plugin (no remote fetch, so the\n// supply-chain vector that keeps marketplace UpdatePlugin out of the model's\n// hands is structurally absent — see propose-plugin.ts).\nexport const PROPOSE_PLUGIN_TOOL_NAME = \"ProposePlugin\";\nexport const UPDATE_PLUGIN_TOOL_NAME = \"UpdatePlugin\";\nexport const REMOVE_PLUGIN_CAPABILITY_TOOL_NAME = \"RemovePluginCapability\";\n\n/** Every capability-acquisition tool — the guardrail set stripped from authored allowlists. */\nexport const PLUGIN_SYSTEM_TOOL_NAMES: readonly string[] = [\n\tSEARCH_PLUGINS_TOOL_NAME,\n\tLIST_PLUGINS_TOOL_NAME,\n\tSUGGEST_PLUGIN_INSTALL_TOOL_NAME,\n\tINSTALL_PLUGIN_TOOL_NAME,\n\tUNINSTALL_PLUGIN_TOOL_NAME,\n\tPROPOSE_PLUGIN_TOOL_NAME,\n\tUPDATE_PLUGIN_TOOL_NAME,\n\tREMOVE_PLUGIN_CAPABILITY_TOOL_NAME,\n];\n"]}
1
+ {"version":3,"file":"plugin-tool-names.js","sourceRoot":"","sources":["../../../src/core/tools/plugin-tool-names.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,8BAA6B;AAC7B,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC;AACxD,MAAM,CAAC,MAAM,sBAAsB,GAAG,aAAa,CAAC;AACpD,MAAM,CAAC,MAAM,gCAAgC,GAAG,sBAAsB,CAAC;AACvE,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC;AACxD,MAAM,CAAC,MAAM,0BAA0B,GAAG,iBAAiB,CAAC;AAE5D,iFAAgF;AAChF,mFAAiF;AACjF,4EAA4E;AAC5E,gFAAgF;AAChF,iFAAiF;AACjF,6EAA6E;AAC7E,2DAAyD;AACzD,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC;AACxD,MAAM,CAAC,MAAM,uBAAuB,GAAG,cAAc,CAAC;AACtD,MAAM,CAAC,MAAM,kCAAkC,GAAG,wBAAwB,CAAC;AAE3E,8EAA2E;AAC3E,mFAAiF;AACjF,4EAA4E;AAC5E,wDAAwD;AACxD,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC;AAExD,iGAA+F;AAC/F,MAAM,CAAC,MAAM,wBAAwB,GAAsB;IAC1D,wBAAwB;IACxB,sBAAsB;IACtB,gCAAgC;IAChC,wBAAwB;IACxB,0BAA0B;IAC1B,wBAAwB;IACxB,uBAAuB;IACvB,kCAAkC;IAClC,wBAAwB;CACxB,CAAC","sourcesContent":["/**\n * Canonical names of the plugin-system (capability-acquisition) tools, in one\n * dependency-free module so the tool definitions, the authoring engine, and the\n * privilege-amplification guardrail can all reference them without an import\n * cycle.\n *\n * {@link PLUGIN_SYSTEM_TOOL_NAMES} is the guardrail set: these tools live on the\n * top-level agent only and may never appear in an authored subagent's allowlist\n * (otherwise a low-trust authored agent could bootstrap privilege via an\n * author → spawn → install loop).\n */\n\n// Lifecycle tools (spec §1).\nexport const SEARCH_PLUGINS_TOOL_NAME = \"SearchPlugins\";\nexport const LIST_PLUGINS_TOOL_NAME = \"ListPlugins\";\nexport const SUGGEST_PLUGIN_INSTALL_TOOL_NAME = \"SuggestPluginInstall\";\nexport const INSTALL_PLUGIN_TOOL_NAME = \"InstallPlugin\";\nexport const UNINSTALL_PLUGIN_TOOL_NAME = \"UninstallPlugin\";\n\n// Authoring tools (spec §3). A single risk-gated authoring tool (ProposePlugin)\n// computes risk from *content* — passive skills/commands/read-only subagents run\n// autonomously; executable content (hooks, MCP servers, mutating subagents)\n// auto-triggers a human-confirmation gate in the same tool. UpdatePlugin merges\n// inline-authored content into an existing local plugin (no remote fetch, so the\n// supply-chain vector that keeps marketplace UpdatePlugin out of the model's\n// hands is structurally absent — see propose-plugin.ts).\nexport const PROPOSE_PLUGIN_TOOL_NAME = \"ProposePlugin\";\nexport const UPDATE_PLUGIN_TOOL_NAME = \"UpdatePlugin\";\nexport const REMOVE_PLUGIN_CAPABILITY_TOOL_NAME = \"RemovePluginCapability\";\n\n// Publish lane (spec §3.2). Packaging is autonomous — it gates the plugin,\n// writes a README and produces the marketplace index entry — but it stops at the\n// trust boundary: nothing here contacts a remote or publishes anything. The\n// publish itself is `/plugin publish`, a human command.\nexport const PACKAGE_PLUGIN_TOOL_NAME = \"PackagePlugin\";\n\n/** Every capability-acquisition tool — the guardrail set stripped from authored allowlists. */\nexport const PLUGIN_SYSTEM_TOOL_NAMES: readonly string[] = [\n\tSEARCH_PLUGINS_TOOL_NAME,\n\tLIST_PLUGINS_TOOL_NAME,\n\tSUGGEST_PLUGIN_INSTALL_TOOL_NAME,\n\tINSTALL_PLUGIN_TOOL_NAME,\n\tUNINSTALL_PLUGIN_TOOL_NAME,\n\tPROPOSE_PLUGIN_TOOL_NAME,\n\tUPDATE_PLUGIN_TOOL_NAME,\n\tREMOVE_PLUGIN_CAPABILITY_TOOL_NAME,\n\tPACKAGE_PLUGIN_TOOL_NAME,\n];\n"]}