skilld 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -0
- package/dist/_chunks/add.mjs +10 -9
- package/dist/_chunks/add.mjs.map +1 -1
- package/dist/_chunks/agent-prompt.mjs +4 -4
- package/dist/_chunks/agent-prompt.mjs.map +1 -1
- package/dist/_chunks/agent.mjs +282 -109
- package/dist/_chunks/agent.mjs.map +1 -1
- package/dist/_chunks/args.mjs +2 -2
- package/dist/_chunks/args.mjs.map +1 -1
- package/dist/_chunks/assemble.mjs +4 -4
- package/dist/_chunks/assemble.mjs.map +1 -1
- package/dist/_chunks/author.mjs +12 -11
- package/dist/_chunks/author.mjs.map +1 -1
- package/dist/_chunks/cache.mjs +21 -138
- package/dist/_chunks/cache.mjs.map +1 -1
- package/dist/_chunks/cache2.mjs +3 -3
- package/dist/_chunks/cache2.mjs.map +1 -1
- package/dist/_chunks/client.mjs +4 -3
- package/dist/_chunks/client.mjs.map +1 -1
- package/dist/_chunks/core.mjs +1 -1
- package/dist/_chunks/detect.mjs +1 -1
- package/dist/_chunks/detect.mjs.map +1 -1
- package/dist/_chunks/detect2.mjs +1 -1
- package/dist/_chunks/eject.mjs +7 -7
- package/dist/_chunks/eject.mjs.map +1 -1
- package/dist/_chunks/embedding-cache.mjs +1 -1
- package/dist/_chunks/embedding-cache2.mjs +14 -13
- package/dist/_chunks/embedding-cache2.mjs.map +1 -1
- package/dist/_chunks/env.mjs +1 -1
- package/dist/_chunks/env.mjs.map +1 -1
- package/dist/_chunks/index-identity.mjs +365 -0
- package/dist/_chunks/index-identity.mjs.map +1 -0
- package/dist/_chunks/index-identity2.mjs +2 -0
- package/dist/_chunks/install-many.mjs +20 -18
- package/dist/_chunks/install-many.mjs.map +1 -1
- package/dist/_chunks/install.mjs +34 -29
- package/dist/_chunks/install.mjs.map +1 -1
- package/dist/_chunks/intro.mjs +6 -6
- package/dist/_chunks/intro.mjs.map +1 -1
- package/dist/_chunks/list.mjs +5 -4
- package/dist/_chunks/list.mjs.map +1 -1
- package/dist/_chunks/lockfile.mjs +8 -6
- package/dist/_chunks/lockfile.mjs.map +1 -1
- package/dist/_chunks/login.mjs +7 -6
- package/dist/_chunks/login.mjs.map +1 -1
- package/dist/_chunks/logout.mjs +2 -2
- package/dist/_chunks/logout.mjs.map +1 -1
- package/dist/_chunks/map.mjs +1 -1
- package/dist/_chunks/map.mjs.map +1 -1
- package/dist/_chunks/markdown.mjs +2 -2
- package/dist/_chunks/markdown.mjs.map +1 -1
- package/dist/_chunks/menu.mjs +1 -1
- package/dist/_chunks/menu.mjs.map +1 -1
- package/dist/_chunks/model-picker.mjs +1 -1
- package/dist/_chunks/model-picker.mjs.map +1 -1
- package/dist/_chunks/monorepo.mjs +5 -4
- package/dist/_chunks/monorepo.mjs.map +1 -1
- package/dist/_chunks/package-json.mjs +7 -5
- package/dist/_chunks/package-json.mjs.map +1 -1
- package/dist/_chunks/paths.mjs +1 -1
- package/dist/_chunks/paths.mjs.map +1 -1
- package/dist/_chunks/pipeline.mjs +34 -26
- package/dist/_chunks/pipeline.mjs.map +1 -1
- package/dist/_chunks/pool.mjs +1 -1
- package/dist/_chunks/pool2.mjs +2 -2
- package/dist/_chunks/pool2.mjs.map +1 -1
- package/dist/_chunks/portable.mjs +8 -7
- package/dist/_chunks/portable.mjs.map +1 -1
- package/dist/_chunks/prepare-hook.mjs +1 -1
- package/dist/_chunks/prepare-hook2.mjs +3 -3
- package/dist/_chunks/prepare-hook2.mjs.map +1 -1
- package/dist/_chunks/prepare.mjs +17 -11
- package/dist/_chunks/prepare.mjs.map +1 -1
- package/dist/_chunks/prepare2.mjs +12 -10
- package/dist/_chunks/prepare2.mjs.map +1 -1
- package/dist/_chunks/prompts.mjs +8 -6
- package/dist/_chunks/prompts.mjs.map +1 -1
- package/dist/_chunks/pull.mjs +9 -8
- package/dist/_chunks/pull.mjs.map +1 -1
- package/dist/_chunks/regex.mjs +1 -1
- package/dist/_chunks/retriv.mjs +2 -2
- package/dist/_chunks/retriv2.mjs +22 -4
- package/dist/_chunks/retriv2.mjs.map +1 -1
- package/dist/_chunks/sanitize.mjs +1 -1
- package/dist/_chunks/sanitize.mjs.map +1 -1
- package/dist/_chunks/search-helpers.mjs +5 -5
- package/dist/_chunks/search-helpers.mjs.map +1 -1
- package/dist/_chunks/search-interactive.mjs +4 -4
- package/dist/_chunks/search-interactive.mjs.map +1 -1
- package/dist/_chunks/search.mjs +6 -6
- package/dist/_chunks/search.mjs.map +1 -1
- package/dist/_chunks/semver.mjs +111 -77
- package/dist/_chunks/semver.mjs.map +1 -1
- package/dist/_chunks/skill-installer.mjs +1 -1
- package/dist/_chunks/skill-installer2.mjs +26 -17
- package/dist/_chunks/skill-installer2.mjs.map +1 -1
- package/dist/_chunks/skills.mjs +7 -7
- package/dist/_chunks/skills.mjs.map +1 -1
- package/dist/_chunks/store.mjs +2 -2
- package/dist/_chunks/store.mjs.map +1 -1
- package/dist/_chunks/sync.mjs +26 -19
- package/dist/_chunks/sync.mjs.map +1 -1
- package/dist/_chunks/sync2.mjs +1 -1
- package/dist/_chunks/telemetry.mjs +3 -3
- package/dist/_chunks/telemetry.mjs.map +1 -1
- package/dist/_chunks/uninstall.mjs +32 -28
- package/dist/_chunks/uninstall.mjs.map +1 -1
- package/dist/_chunks/update.mjs +14 -13
- package/dist/_chunks/update.mjs.map +1 -1
- package/dist/_chunks/upload.mjs +13 -10
- package/dist/_chunks/upload.mjs.map +1 -1
- package/dist/_chunks/validate.mjs +1 -1
- package/dist/_chunks/validate.mjs.map +1 -1
- package/dist/_chunks/version.mjs +1 -1
- package/dist/_chunks/version.mjs.map +1 -1
- package/dist/_chunks/whoami.mjs +1 -1
- package/dist/_chunks/whoami.mjs.map +1 -1
- package/dist/_chunks/wizard.mjs +1 -1
- package/dist/_chunks/wizard2.mjs +8 -8
- package/dist/_chunks/wizard2.mjs.map +1 -1
- package/dist/_chunks/yaml.mjs +1 -1
- package/dist/_chunks/yaml.mjs.map +1 -1
- package/dist/cli-entry.d.mts +1 -1
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +111 -35
- package/dist/cli.mjs.map +1 -1
- package/dist/prepare.d.mts +1 -1
- package/dist/prepare.mjs +6 -4
- package/dist/prepare.mjs.map +1 -1
- package/dist/retriv/worker.d.mts.map +1 -1
- package/dist/retriv/worker.mjs +11 -5
- package/dist/retriv/worker.mjs.map +1 -1
- package/package.json +24 -24
package/dist/_chunks/args.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { targets } from "./detect.mjs";
|
|
2
2
|
import "./agent.mjs";
|
|
3
3
|
const sharedArgs = {
|
|
4
4
|
global: {
|
|
@@ -37,6 +37,6 @@ const sharedArgs = {
|
|
|
37
37
|
default: false
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
export { sharedArgs
|
|
40
|
+
export { sharedArgs };
|
|
41
41
|
|
|
42
42
|
//# sourceMappingURL=args.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"args.mjs","names":["agents"],"sources":["../../src/cli/args.ts"],"sourcesContent":["import { agents } from '../agent/index.ts'\n\nexport const sharedArgs = {\n global: {\n type: 'boolean' as const,\n alias: 'g',\n description: 'Install globally to ~/<agent>/skills',\n default: false,\n },\n agent: {\n type: 'enum' as const,\n options: Object.keys(agents),\n alias: 'a',\n description: 'Target agent — where skills are installed',\n },\n model: {\n type: 'string' as const,\n alias: 'm',\n description: 'Enhancement model for SKILL.md generation',\n valueHint: 'id',\n },\n yes: {\n type: 'boolean' as const,\n alias: 'y',\n description: 'Skip prompts, use defaults',\n default: false,\n },\n force: {\n type: 'boolean' as const,\n alias: 'f',\n description: 'Ignore all caches, re-fetch docs and regenerate',\n default: false,\n },\n debug: {\n type: 'boolean' as const,\n description: 'Save raw enhancement output to logs/ for each section',\n default: false,\n },\n}\n"],"mappings":";;AAEA,MAAa,aAAa;CACxB,QAAQ;EACN,MAAM;EACN,OAAO;EACP,aAAa;EACb,SAAS;
|
|
1
|
+
{"version":3,"file":"args.mjs","names":["agents"],"sources":["../../src/cli/args.ts"],"sourcesContent":["import { agents } from '../agent/index.ts'\n\nexport const sharedArgs = {\n global: {\n type: 'boolean' as const,\n alias: 'g',\n description: 'Install globally to ~/<agent>/skills',\n default: false,\n },\n agent: {\n type: 'enum' as const,\n options: Object.keys(agents),\n alias: 'a',\n description: 'Target agent — where skills are installed',\n },\n model: {\n type: 'string' as const,\n alias: 'm',\n description: 'Enhancement model for SKILL.md generation',\n valueHint: 'id',\n },\n yes: {\n type: 'boolean' as const,\n alias: 'y',\n description: 'Skip prompts, use defaults',\n default: false,\n },\n force: {\n type: 'boolean' as const,\n alias: 'f',\n description: 'Ignore all caches, re-fetch docs and regenerate',\n default: false,\n },\n debug: {\n type: 'boolean' as const,\n description: 'Save raw enhancement output to logs/ for each section',\n default: false,\n },\n}\n"],"mappings":";;AAEA,MAAa,aAAa;CACxB,QAAQ;EACN,MAAM;EACN,OAAO;EACP,aAAa;EACb,SAAS;CACX;CACA,OAAO;EACL,MAAM;EACN,SAAS,OAAO,KAAKA,OAAM;EAC3B,OAAO;EACP,aAAa;CACf;CACA,OAAO;EACL,MAAM;EACN,OAAO;EACP,aAAa;EACb,WAAW;CACb;CACA,KAAK;EACH,MAAM;EACN,OAAO;EACP,aAAa;EACb,SAAS;CACX;CACA,OAAO;EACL,MAAM;EACN,OAAO;EACP,aAAa;EACb,SAAS;CACX;CACA,OAAO;EACL,MAAM;EACN,aAAa;EACb,SAAS;CACX;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { cleanSectionOutput } from "./agent.mjs";
|
|
2
|
+
import { SECTION_MERGE_ORDER, SECTION_OUTPUT_FILES, extractMarkedSections, getSectionValidator, wrapSection } from "./prompts.mjs";
|
|
3
|
+
import { API_CHANGE_BULLET_RE, SECTION_HEADING_RE, SOURCE_LINK_RE } from "./regex.mjs";
|
|
4
|
+
import { iterateSkills } from "./skills.mjs";
|
|
5
5
|
import { existsSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { styleText } from "node:util";
|
|
7
7
|
import * as p from "@clack/prompts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assemble.mjs","names":[],"sources":["../../src/commands/assemble.ts"],"sourcesContent":["/**\n * `skilld assemble` — merge pasted LLM output back into SKILL.md\n *\n * Auto-discovers skill directories with pending output files when run without arguments.\n */\n\nimport type { SkillSection } from '../agent/index.ts'\nimport { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { styleText } from 'node:util'\nimport * as p from '@clack/prompts'\nimport { defineCommand } from 'citty'\nimport { join, relative, resolve } from 'pathe'\nimport { cleanSectionOutput } from '../agent/clis/index.ts'\nimport {\n extractMarkedSections,\n getSectionValidator,\n SECTION_MERGE_ORDER,\n SECTION_OUTPUT_FILES,\n wrapSection,\n} from '../agent/index.ts'\nimport { API_CHANGE_BULLET_RE, SECTION_HEADING_RE, SOURCE_LINK_RE } from '../core/regex.ts'\nimport { iterateSkills } from '../core/skills.ts'\n\nconst STATIC_REGEX_4 = /^## .+$/m\n\nconst OUTPUT_FILE_SET = new Set(Object.values(SECTION_OUTPUT_FILES))\n\n/**\n * Find installed skill dirs that have pending section output files.\n */\nfunction discoverSkillDirsWithOutputs(): string[] {\n const dirs: string[] = []\n for (const skill of iterateSkills({})) {\n if (readdirSync(skill.dir).some(f => OUTPUT_FILE_SET.has(f)))\n dirs.push(skill.dir)\n }\n return dirs\n}\n\nexport async function assembleCommand(dir: string | undefined): Promise<void> {\n const cwd = process.cwd()\n\n let dirs: string[]\n if (dir) {\n dirs = [resolve(cwd, dir)]\n }\n else {\n // Check cwd first — if it has SKILL.md + output files, use it\n if (existsSync(join(cwd, 'SKILL.md'))\n && readdirSync(cwd).some(f => OUTPUT_FILE_SET.has(f))) {\n dirs = [cwd]\n }\n else {\n dirs = discoverSkillDirsWithOutputs()\n if (dirs.length === 0) {\n p.log.error('No skill directories with output files found. Run `skilld add` first.')\n return\n }\n }\n }\n\n for (const targetDir of dirs)\n assembleDir(targetDir, cwd)\n}\n\nfunction assembleDir(targetDir: string, cwd: string): void {\n if (!existsSync(targetDir)) {\n p.log.error(`Directory not found: ${targetDir}`)\n return\n }\n\n const skillMdPath = join(targetDir, 'SKILL.md')\n if (!existsSync(skillMdPath)) {\n p.log.error(`No SKILL.md found in ${targetDir}`)\n return\n }\n\n const existingSkillMd = readFileSync(skillMdPath, 'utf-8')\n\n // Find and read section output files\n const sections: Array<{ section: SkillSection, content: string }> = []\n const warnings: string[] = []\n\n for (const [section, outputFile] of Object.entries(SECTION_OUTPUT_FILES) as Array<[SkillSection, string]>) {\n const filePath = join(targetDir, outputFile)\n if (!existsSync(filePath))\n continue\n\n const raw = readFileSync(filePath, 'utf-8').trim()\n if (!raw) {\n p.log.warn(`Empty file: ${outputFile}`)\n continue\n }\n\n const cleaned = cleanSectionOutput(raw)\n if (!cleaned) {\n const missing: string[] = []\n if (!SECTION_HEADING_RE.test(raw))\n missing.push('h2 heading (## ...)')\n if (!API_CHANGE_BULLET_RE.test(raw))\n missing.push('change label (- BREAKING/DEPRECATED/NEW: ...)')\n if (!SOURCE_LINK_RE.test(raw))\n missing.push('[source] link')\n p.log.warn(`${outputFile}: content rejected — missing ${missing.join(', ')}`)\n continue\n }\n\n const validator = getSectionValidator(section)\n if (validator) {\n for (const w of validator(cleaned))\n warnings.push(`${section}: ${w.warning}`)\n }\n\n sections.push({ section, content: cleaned })\n p.log.success(`Loaded ${outputFile}`)\n }\n\n if (sections.length === 0) {\n p.log.warn(`No section output files in ${relative(cwd, targetDir)}. Expected: ${Object.values(SECTION_OUTPUT_FILES).join(', ')}`)\n return\n }\n\n for (const w of warnings)\n p.log.warn(styleText('yellow', w))\n\n // Wrap each section with comment markers\n const wrappedSections: Array<{ section: SkillSection, wrapped: string }> = []\n for (const section of SECTION_MERGE_ORDER) {\n const result = sections.find(s => s.section === section)\n if (result)\n wrappedSections.push({ section, wrapped: wrapSection(section, result.content) })\n }\n\n // Try marker-based replacement first (re-assembly of previously assembled SKILL.md)\n const existingMarkers = extractMarkedSections(existingSkillMd)\n let newSkillMd: string\n\n if (existingMarkers.size > 0) {\n // Replace existing marked sections in-place, append new ones at the end\n newSkillMd = existingSkillMd\n // Process in reverse offset order to preserve indices\n const replacements = wrappedSections\n .filter(s => existingMarkers.has(s.section))\n .sort((a, b) => existingMarkers.get(b.section)!.start - existingMarkers.get(a.section)!.start)\n for (const { section, wrapped } of replacements) {\n const { start, end } = existingMarkers.get(section)!\n newSkillMd = newSkillMd.slice(0, start) + wrapped + newSkillMd.slice(end)\n }\n // Append sections that don't have existing markers\n const newSections = wrappedSections.filter(s => !existingMarkers.has(s.section))\n if (newSections.length > 0)\n newSkillMd = `${newSkillMd.trimEnd()}\\n\\n${newSections.map(s => s.wrapped).join('\\n\\n')}\\n`\n }\n else {\n // First assembly — find header boundary and append all sections\n const body = wrappedSections.map(s => s.wrapped).join('\\n\\n')\n const fmEnd = existingSkillMd.indexOf('\\n---\\n', 4)\n const afterFm = fmEnd !== -1 ? existingSkillMd.slice(fmEnd + 5) : existingSkillMd\n\n const firstLlmHeading = body.match(STATIC_REGEX_4)?.[0]\n let headerPart = afterFm\n if (firstLlmHeading) {\n const idx = afterFm.indexOf(firstLlmHeading)\n if (idx !== -1)\n headerPart = afterFm.slice(0, idx)\n }\n\n const fmPart = fmEnd !== -1 ? existingSkillMd.slice(0, fmEnd + 5) : ''\n const cleanHeader = headerPart.trimEnd()\n newSkillMd = fmPart\n ? `${fmPart}${cleanHeader}\\n\\n${body}\\n`\n : `${cleanHeader}\\n\\n${body}\\n`\n }\n\n writeFileSync(skillMdPath, newSkillMd)\n p.log.success(`Updated ${relative(cwd, skillMdPath)} with ${sections.length} section(s)`)\n}\n\nexport const assembleCommandDef = defineCommand({\n meta: { name: 'assemble', description: 'Merge enhancement output files into SKILL.md' },\n args: {\n dir: {\n type: 'positional',\n description: 'Skill directory with output files (auto-discovers installed skills)',\n required: false,\n },\n },\n async run({ args }) {\n await assembleCommand(args.dir)\n },\n})\n"],"mappings":";;;;;;;;;AAuBA,MAAM,iBAAiB;AAEvB,MAAM,kBAAkB,IAAI,IAAI,OAAO,OAAO,
|
|
1
|
+
{"version":3,"file":"assemble.mjs","names":[],"sources":["../../src/commands/assemble.ts"],"sourcesContent":["/**\n * `skilld assemble` — merge pasted LLM output back into SKILL.md\n *\n * Auto-discovers skill directories with pending output files when run without arguments.\n */\n\nimport type { SkillSection } from '../agent/index.ts'\nimport { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs'\nimport { styleText } from 'node:util'\nimport * as p from '@clack/prompts'\nimport { defineCommand } from 'citty'\nimport { join, relative, resolve } from 'pathe'\nimport { cleanSectionOutput } from '../agent/clis/index.ts'\nimport {\n extractMarkedSections,\n getSectionValidator,\n SECTION_MERGE_ORDER,\n SECTION_OUTPUT_FILES,\n wrapSection,\n} from '../agent/index.ts'\nimport { API_CHANGE_BULLET_RE, SECTION_HEADING_RE, SOURCE_LINK_RE } from '../core/regex.ts'\nimport { iterateSkills } from '../core/skills.ts'\n\nconst STATIC_REGEX_4 = /^## .+$/m\n\nconst OUTPUT_FILE_SET = new Set(Object.values(SECTION_OUTPUT_FILES))\n\n/**\n * Find installed skill dirs that have pending section output files.\n */\nfunction discoverSkillDirsWithOutputs(): string[] {\n const dirs: string[] = []\n for (const skill of iterateSkills({})) {\n if (readdirSync(skill.dir).some(f => OUTPUT_FILE_SET.has(f)))\n dirs.push(skill.dir)\n }\n return dirs\n}\n\nexport async function assembleCommand(dir: string | undefined): Promise<void> {\n const cwd = process.cwd()\n\n let dirs: string[]\n if (dir) {\n dirs = [resolve(cwd, dir)]\n }\n else {\n // Check cwd first — if it has SKILL.md + output files, use it\n if (existsSync(join(cwd, 'SKILL.md'))\n && readdirSync(cwd).some(f => OUTPUT_FILE_SET.has(f))) {\n dirs = [cwd]\n }\n else {\n dirs = discoverSkillDirsWithOutputs()\n if (dirs.length === 0) {\n p.log.error('No skill directories with output files found. Run `skilld add` first.')\n return\n }\n }\n }\n\n for (const targetDir of dirs)\n assembleDir(targetDir, cwd)\n}\n\nfunction assembleDir(targetDir: string, cwd: string): void {\n if (!existsSync(targetDir)) {\n p.log.error(`Directory not found: ${targetDir}`)\n return\n }\n\n const skillMdPath = join(targetDir, 'SKILL.md')\n if (!existsSync(skillMdPath)) {\n p.log.error(`No SKILL.md found in ${targetDir}`)\n return\n }\n\n const existingSkillMd = readFileSync(skillMdPath, 'utf-8')\n\n // Find and read section output files\n const sections: Array<{ section: SkillSection, content: string }> = []\n const warnings: string[] = []\n\n for (const [section, outputFile] of Object.entries(SECTION_OUTPUT_FILES) as Array<[SkillSection, string]>) {\n const filePath = join(targetDir, outputFile)\n if (!existsSync(filePath))\n continue\n\n const raw = readFileSync(filePath, 'utf-8').trim()\n if (!raw) {\n p.log.warn(`Empty file: ${outputFile}`)\n continue\n }\n\n const cleaned = cleanSectionOutput(raw)\n if (!cleaned) {\n const missing: string[] = []\n if (!SECTION_HEADING_RE.test(raw))\n missing.push('h2 heading (## ...)')\n if (!API_CHANGE_BULLET_RE.test(raw))\n missing.push('change label (- BREAKING/DEPRECATED/NEW: ...)')\n if (!SOURCE_LINK_RE.test(raw))\n missing.push('[source] link')\n p.log.warn(`${outputFile}: content rejected — missing ${missing.join(', ')}`)\n continue\n }\n\n const validator = getSectionValidator(section)\n if (validator) {\n for (const w of validator(cleaned))\n warnings.push(`${section}: ${w.warning}`)\n }\n\n sections.push({ section, content: cleaned })\n p.log.success(`Loaded ${outputFile}`)\n }\n\n if (sections.length === 0) {\n p.log.warn(`No section output files in ${relative(cwd, targetDir)}. Expected: ${Object.values(SECTION_OUTPUT_FILES).join(', ')}`)\n return\n }\n\n for (const w of warnings)\n p.log.warn(styleText('yellow', w))\n\n // Wrap each section with comment markers\n const wrappedSections: Array<{ section: SkillSection, wrapped: string }> = []\n for (const section of SECTION_MERGE_ORDER) {\n const result = sections.find(s => s.section === section)\n if (result)\n wrappedSections.push({ section, wrapped: wrapSection(section, result.content) })\n }\n\n // Try marker-based replacement first (re-assembly of previously assembled SKILL.md)\n const existingMarkers = extractMarkedSections(existingSkillMd)\n let newSkillMd: string\n\n if (existingMarkers.size > 0) {\n // Replace existing marked sections in-place, append new ones at the end\n newSkillMd = existingSkillMd\n // Process in reverse offset order to preserve indices\n const replacements = wrappedSections\n .filter(s => existingMarkers.has(s.section))\n .sort((a, b) => existingMarkers.get(b.section)!.start - existingMarkers.get(a.section)!.start)\n for (const { section, wrapped } of replacements) {\n const { start, end } = existingMarkers.get(section)!\n newSkillMd = newSkillMd.slice(0, start) + wrapped + newSkillMd.slice(end)\n }\n // Append sections that don't have existing markers\n const newSections = wrappedSections.filter(s => !existingMarkers.has(s.section))\n if (newSections.length > 0)\n newSkillMd = `${newSkillMd.trimEnd()}\\n\\n${newSections.map(s => s.wrapped).join('\\n\\n')}\\n`\n }\n else {\n // First assembly — find header boundary and append all sections\n const body = wrappedSections.map(s => s.wrapped).join('\\n\\n')\n const fmEnd = existingSkillMd.indexOf('\\n---\\n', 4)\n const afterFm = fmEnd !== -1 ? existingSkillMd.slice(fmEnd + 5) : existingSkillMd\n\n const firstLlmHeading = body.match(STATIC_REGEX_4)?.[0]\n let headerPart = afterFm\n if (firstLlmHeading) {\n const idx = afterFm.indexOf(firstLlmHeading)\n if (idx !== -1)\n headerPart = afterFm.slice(0, idx)\n }\n\n const fmPart = fmEnd !== -1 ? existingSkillMd.slice(0, fmEnd + 5) : ''\n const cleanHeader = headerPart.trimEnd()\n newSkillMd = fmPart\n ? `${fmPart}${cleanHeader}\\n\\n${body}\\n`\n : `${cleanHeader}\\n\\n${body}\\n`\n }\n\n writeFileSync(skillMdPath, newSkillMd)\n p.log.success(`Updated ${relative(cwd, skillMdPath)} with ${sections.length} section(s)`)\n}\n\nexport const assembleCommandDef = defineCommand({\n meta: { name: 'assemble', description: 'Merge enhancement output files into SKILL.md' },\n args: {\n dir: {\n type: 'positional',\n description: 'Skill directory with output files (auto-discovers installed skills)',\n required: false,\n },\n },\n async run({ args }) {\n await assembleCommand(args.dir)\n },\n})\n"],"mappings":";;;;;;;;;AAuBA,MAAM,iBAAiB;AAEvB,MAAM,kBAAkB,IAAI,IAAI,OAAO,OAAO,oBAAoB,CAAC;;;CAKnE,KAAA,MAAS,SAAA,cAAA,CAAA,CAAA,GAAyC,IAAA,YAAA,MAAA,GAAA,CAAA,CAAA,MAAA,MAAA,gBAAA,IAAA,CAAA,CAAA,GAAA,KAAA,KAAA,MAAA,GAAA;CAChD,OAAM;AACN;AAIA,eAAO,gBAAA,KAAA;CACT,MAAA,MAAA,QAAA,IAAA;CAEA,IAAA;CACE,IAAA,KAAM,OAAM,CAAA,QAAY,KAAA,GAAA,CAAA;MAEpB,IAAA,WAAA,KAAA,KAAA,UAAA,CAAA,KAAA,YAAA,GAAA,CAAA,CAAA,MAAA,MAAA,gBAAA,IAAA,CAAA,CAAA,GAAA,OAAA,CAAA,GAAA;MACA;EAKF,OAAA,6BAAyB;EAIpB,IAAA,KAAA,WAAA,GAAA;GACH,EAAA,IAAO,MAAA,uEAA6B;GACpC;EACE;CACA;CACF,KAAA,MAAA,aAAA,MAAA,YAAA,WAAA,GAAA;AACF;AAGF,SAAK,YAAM,WACT,KAAA;CACJ,IAAA,CAAA,WAAA,SAAA,GAAA;EAEA,EAAA,IAAA,MAAS,wBAAkD,WAAA;EACzD;CACE;CACA,MAAA,cAAA,KAAA,WAAA,UAAA;CACF,IAAA,CAAA,WAAA,WAAA,GAAA;EAEA,EAAA,IAAM,MAAA,wBAA8B,WAAU;EAC9C;CACE;CACA,MAAA,kBAAA,aAAA,aAAA,OAAA;CACF,MAAA,WAAA,CAAA;CAEA,MAAM,WAAA,CAAA;CAGN,KAAA,MAAM,CAAA,SAA+D,eAAA,OAAA,QAAA,oBAAA,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AA,WAAA,EAAA,QAAA,SAAA,OAAA,YAAA;AAEA;AACA,MAAE,qBAAuB,cAAc;CACzC,MAAA;EAEA,MAAa;EACX,aAAM;CAAE;CAAkB,MAAA,EAAA,KAAA;EAA4D,MAAA;EACtF,aACO;EACH,UAAM;CACN,EAAA;CACA,MAAA,IAAA,EAAU,QAAA;EACZ,MACF,gBAAA,KAAA,GAAA;CACA;AACE,CAAA;AAEJ,SAAC"}
|
package/dist/_chunks/author.mjs
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
1
|
+
import { getModelLabel } from "./agent.mjs";
|
|
2
|
+
import { computeSkillDirName, timedSpinner, writeGeneratedSkillMd } from "./prompts.mjs";
|
|
3
|
+
import { defaultFeatures, readConfig } from "./index-identity.mjs";
|
|
4
|
+
import { skillInternalDir } from "./paths.mjs";
|
|
5
|
+
import { GIT_PLUS_PREFIX_RE, GIT_SUFFIX_RE, README_FILENAME_RE } from "./regex.mjs";
|
|
6
|
+
import { sanitizeMarkdown } from "./sanitize.mjs";
|
|
7
|
+
import { appendToJsonArray, patchPackageJson, readPackageJsonSafe } from "./package-json.mjs";
|
|
8
|
+
import { createReferenceCache, ensureCacheDir } from "./cache.mjs";
|
|
9
|
+
import { guard } from "./menu.mjs";
|
|
10
|
+
import { fetchGitHubDiscussions, fetchGitHubIssues, formatDiscussionAsMarkdown, formatIssueAsMarkdown, generateDiscussionIndex, generateIssueIndex, isGhAvailable, parseGitHubUrl, readLocalPackageInfo } from "./semver.mjs";
|
|
11
|
+
import { detectMonorepoPackages } from "./monorepo.mjs";
|
|
12
|
+
import { detectChangelog, enhanceSkillWithLLM, selectLlmConfig, writePromptFiles } from "./pipeline.mjs";
|
|
12
13
|
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync } from "node:fs";
|
|
13
14
|
import { styleText } from "node:util";
|
|
14
15
|
import * as p from "@clack/prompts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"author.mjs","names":[],"sources":["../../src/commands/author.ts"],"sourcesContent":["import type { OptimizeModel } from '../agent/index.ts'\nimport type { ReferenceCache } from '../cache/index.ts'\nimport type { FeaturesConfig } from '../core/config.ts'\nimport type { LlmConfig } from './llm-prompts.ts'\nimport { existsSync, mkdirSync, readdirSync, readFileSync, rmSync } from 'node:fs'\nimport { styleText } from 'node:util'\nimport * as p from '@clack/prompts'\nimport { defineCommand } from 'citty'\nimport { join, relative, resolve } from 'pathe'\nimport {\n\n computeSkillDirName,\n getModelLabel,\n writeGeneratedSkillMd,\n} from '../agent/index.ts'\nimport { enhanceSkillWithLLM, writePromptFiles } from '../agent/skill-builder.ts'\nimport { createReferenceCache, ensureCacheDir } from '../cache/index.ts'\nimport { guard } from '../cli/menu.ts'\nimport { defaultFeatures, readConfig } from '../core/config.ts'\nimport { timedSpinner } from '../core/formatting.ts'\nimport { detectMonorepoPackages } from '../core/monorepo.ts'\nimport { appendToJsonArray, patchPackageJson, readPackageJsonSafe } from '../core/package-json.ts'\nimport { skillInternalDir } from '../core/paths.ts'\nimport { GIT_PLUS_PREFIX_RE, GIT_SUFFIX_RE, README_FILENAME_RE } from '../core/regex.ts'\nimport { sanitizeMarkdown } from '../core/sanitize.ts'\nimport { parseGitHubUrl } from '../core/url.ts'\nimport {\n fetchGitHubDiscussions,\n fetchGitHubIssues,\n formatDiscussionAsMarkdown,\n formatIssueAsMarkdown,\n generateDiscussionIndex,\n generateIssueIndex,\n isGhAvailable,\n readLocalPackageInfo,\n} from '../sources/index.ts'\nimport { selectLlmConfig } from './llm-prompts.ts'\nimport { detectChangelog } from './sync/pipeline.ts'\n\nconst STATIC_REGEX_1 = /\\.mdx?$/\n\n// ── Docs resolution ──\n\nfunction walkMarkdownFiles(dir: string, base = ''): Array<{ path: string, content: string }> {\n const results: Array<{ path: string, content: string }> = []\n if (!existsSync(dir))\n return results\n\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n const rel = base ? `${base}/${entry.name}` : entry.name\n const full = join(dir, entry.name)\n if (entry.isDirectory()) {\n results.push(...walkMarkdownFiles(full, rel))\n }\n else if (STATIC_REGEX_1.test(entry.name)) {\n results.push({ path: rel, content: readFileSync(full, 'utf-8') })\n }\n }\n return results\n}\n\n/**\n * Resolve docs from local filesystem. Cascade:\n * 1. Package-level docs/ directory\n * 2. Monorepo-root docs/ directory (if monorepoRoot provided)\n * 3. Monorepo-root docs/content/ (Nuxt Content convention)\n * 4. llms.txt in package dir\n * 5. README.md in package dir\n */\nfunction resolveLocalDocs(\n cache: ReferenceCache,\n packageDir: string,\n monorepoRoot?: string,\n): { docsType: 'docs' | 'llms.txt' | 'readme', docSource: string } {\n const cachedDocs: Array<{ path: string, content: string }> = []\n\n const cacheChangelog = () => cacheLocalChangelog(cache, packageDir, monorepoRoot)\n\n // 1. Package-level docs/\n const docsDir = join(packageDir, 'docs')\n if (existsSync(docsDir)) {\n const mdFiles = walkMarkdownFiles(docsDir)\n if (mdFiles.length > 0) {\n for (const f of mdFiles)\n cachedDocs.push({ path: `docs/${f.path}`, content: sanitizeMarkdown(f.content) })\n cache.write(cachedDocs)\n cacheChangelog()\n return { docsType: 'docs', docSource: `local docs/ (${mdFiles.length} files)` }\n }\n }\n\n // 2. Monorepo-root docs/ or docs/content/\n if (monorepoRoot) {\n for (const candidate of ['docs/content', 'docs']) {\n const rootDocsDir = join(monorepoRoot, candidate)\n if (existsSync(rootDocsDir)) {\n const mdFiles = walkMarkdownFiles(rootDocsDir)\n if (mdFiles.length > 0) {\n for (const f of mdFiles)\n cachedDocs.push({ path: `docs/${f.path}`, content: sanitizeMarkdown(f.content) })\n cache.write(cachedDocs)\n cacheChangelog()\n return { docsType: 'docs', docSource: `monorepo ${candidate}/ (${mdFiles.length} files)` }\n }\n }\n }\n }\n\n // 3. llms.txt (package dir, then monorepo root)\n for (const dir of [packageDir, monorepoRoot].filter(Boolean) as string[]) {\n const llmsPath = join(dir, 'llms.txt')\n if (existsSync(llmsPath)) {\n cachedDocs.push({ path: 'llms.txt', content: sanitizeMarkdown(readFileSync(llmsPath, 'utf-8')) })\n cache.write(cachedDocs)\n cacheChangelog()\n const source = dir === packageDir ? 'local llms.txt' : 'monorepo llms.txt'\n return { docsType: 'llms.txt', docSource: source }\n }\n }\n\n // 4. README.md (package dir, then monorepo root)\n for (const dir of [packageDir, monorepoRoot].filter(Boolean) as string[]) {\n const readmeFile = readdirSync(dir).find(f => README_FILENAME_RE.test(f))\n if (readmeFile) {\n cachedDocs.push({ path: 'docs/README.md', content: sanitizeMarkdown(readFileSync(join(dir, readmeFile), 'utf-8')) })\n cache.write(cachedDocs)\n cacheChangelog()\n const source = dir === packageDir ? 'local README.md' : 'monorepo README.md'\n return { docsType: 'readme', docSource: source }\n }\n }\n\n cacheChangelog()\n return { docsType: 'readme', docSource: 'none' }\n}\n\nfunction cacheLocalChangelog(cache: ReferenceCache, dir: string, monorepoRoot?: string): void {\n const candidates = ['CHANGELOG.md', 'changelog.md']\n const changelogFile = candidates.find(f => existsSync(join(dir, f)))\n || (monorepoRoot ? candidates.find(f => existsSync(join(monorepoRoot, f))) : undefined)\n const changelogDir = changelogFile && existsSync(join(dir, changelogFile)) ? dir : monorepoRoot\n if (changelogFile && changelogDir) {\n cache.write([{\n path: `releases/${changelogFile}`,\n content: sanitizeMarkdown(readFileSync(join(changelogDir, changelogFile), 'utf-8')),\n }])\n }\n}\n\n// ── Remote supplements ──\n\nasync function fetchRemoteSupplements(opts: {\n cache: ReferenceCache\n repoUrl?: string\n features: FeaturesConfig\n onProgress: (msg: string) => void\n}): Promise<{ hasIssues: boolean, hasDiscussions: boolean }> {\n const { cache, repoUrl, features, onProgress } = opts\n\n if (!repoUrl || !isGhAvailable())\n return { hasIssues: false, hasDiscussions: false }\n\n const gh = parseGitHubUrl(repoUrl)\n if (!gh)\n return { hasIssues: false, hasDiscussions: false }\n\n let hasIssues = false\n const issuesDir = join(cache.dir, 'issues')\n if (features.issues && !existsSync(issuesDir)) {\n onProgress('Fetching issues via GitHub API')\n const issues = await fetchGitHubIssues(gh.owner, gh.repo, 30).catch(() => [])\n if (issues.length > 0) {\n onProgress(`Caching ${issues.length} issues`)\n cache.write(issues.map(issue => ({\n path: `issues/issue-${issue.number}.md`,\n content: formatIssueAsMarkdown(issue),\n })))\n cache.write([{\n path: 'issues/_INDEX.md',\n content: generateIssueIndex(issues),\n }])\n hasIssues = true\n }\n }\n else {\n hasIssues = features.issues && existsSync(issuesDir)\n }\n\n let hasDiscussions = false\n const discussionsDir = join(cache.dir, 'discussions')\n if (features.discussions && !existsSync(discussionsDir)) {\n onProgress('Fetching discussions via GitHub API')\n const discussions = await fetchGitHubDiscussions(gh.owner, gh.repo, 20).catch(() => [])\n if (discussions.length > 0) {\n onProgress(`Caching ${discussions.length} discussions`)\n cache.write(discussions.map(d => ({\n path: `discussions/discussion-${d.number}.md`,\n content: formatDiscussionAsMarkdown(d),\n })))\n cache.write([{\n path: 'discussions/_INDEX.md',\n content: generateDiscussionIndex(discussions),\n }])\n hasDiscussions = true\n }\n }\n else {\n hasDiscussions = features.discussions && existsSync(discussionsDir)\n }\n\n return { hasIssues, hasDiscussions }\n}\n\n// ── package.json patching ──\n\nexport function patchPackageJsonFiles(packageDir: string): void {\n const pkgPath = join(packageDir, 'package.json')\n if (!existsSync(pkgPath))\n return\n\n const wrote = patchPackageJson(pkgPath, (raw, pkg) => {\n if (!Array.isArray(pkg.files)) {\n p.log.warn('No `files` array in package.json. Add `\"skills\"` to your files array manually.')\n return null\n }\n\n if ((pkg.files as string[]).some((f: string) => f === 'skills' || f === 'skills/' || f === 'skills/**'))\n return null\n\n return appendToJsonArray(raw, ['files'], 'skills')\n })\n\n if (wrote)\n p.log.success('Added `\"skills\"` to package.json files array')\n}\n\n// ── Core author flow for a single package ──\n\nasync function authorSinglePackage(opts: {\n packageDir: string\n packageName: string\n version: string\n description?: string\n repoUrl?: string\n monorepoRoot?: string\n out?: string\n llmConfig?: LlmConfig | null\n force?: boolean\n debug?: boolean\n}): Promise<string | null> {\n const { packageDir, packageName, version } = opts\n const spin = timedSpinner()\n\n const sanitizedName = computeSkillDirName(packageName)\n const outDir = opts.out ? resolve(packageDir, opts.out) : join(packageDir, 'skills', sanitizedName)\n\n // Validate --out doesn't point at the package root or a parent\n if (opts.out) {\n const rel = relative(packageDir, outDir)\n if (!rel || rel === '.' || rel.startsWith('..')) {\n p.log.error('--out must point to a child directory, not the package root or a parent')\n return null\n }\n }\n\n if (existsSync(outDir))\n rmSync(outDir, { recursive: true, force: true })\n mkdirSync(outDir, { recursive: true })\n\n const cache = createReferenceCache(packageName, version)\n\n if (opts.force) {\n cache.clearForce()\n }\n\n ensureCacheDir()\n const features = readConfig().features ?? defaultFeatures\n\n // Resolve local docs\n spin.start('Resolving local docs')\n const { docsType, docSource } = resolveLocalDocs(cache, packageDir, opts.monorepoRoot)\n spin.stop(`Resolved docs: ${docSource}`)\n\n // Fetch remote supplements (issues/discussions)\n const supSpin = timedSpinner()\n supSpin.start('Checking remote supplements')\n const { hasIssues, hasDiscussions } = await fetchRemoteSupplements({\n cache,\n repoUrl: opts.repoUrl,\n features,\n onProgress: msg => supSpin.message(msg),\n })\n const supParts: string[] = []\n if (hasIssues)\n supParts.push('issues')\n if (hasDiscussions)\n supParts.push('discussions')\n supSpin.stop(supParts.length > 0 ? `Fetched ${supParts.join(', ')}` : 'No remote supplements')\n\n // Create temporary .skilld/ symlinks (LLM needs these to read docs)\n cache.linkInto(outDir, packageDir, docsType, { features })\n\n // Detect changelog + releases\n const hasChangelog = detectChangelog(packageDir, cache.dir)\n const hasReleases = existsSync(join(cache.dir, 'releases'))\n\n // Generate base SKILL.md\n writeGeneratedSkillMd(outDir, {\n name: packageName,\n version,\n description: opts.description,\n relatedSkills: [],\n hasIssues,\n hasDiscussions,\n hasReleases,\n hasChangelog,\n docsType,\n hasShippedDocs: false,\n pkgFiles: [],\n dirName: sanitizedName,\n repoUrl: opts.repoUrl,\n features,\n eject: true,\n })\n p.log.success(`Created base skill: ${relative(packageDir, outDir)}`)\n\n // LLM enhancement (config resolved by caller)\n const skilldDir = skillInternalDir(outDir)\n try {\n const llmConfig = opts.llmConfig\n const baseCtx = {\n packageName,\n version,\n skillDir: outDir,\n dirName: sanitizedName,\n references: {\n docsType,\n hasShippedDocs: false,\n pkgFiles: [],\n hasIssues,\n hasDiscussions,\n hasReleases,\n hasChangelog,\n },\n resolved: { repoUrl: opts.repoUrl },\n relatedSkills: [],\n features,\n }\n if (llmConfig?.promptOnly) {\n writePromptFiles(baseCtx, {\n sections: llmConfig.sections,\n customPrompt: llmConfig.customPrompt,\n })\n }\n else if (llmConfig) {\n p.log.step(getModelLabel(llmConfig.model))\n await enhanceSkillWithLLM(baseCtx, {\n model: llmConfig.model,\n force: opts.force,\n debug: opts.debug,\n sections: llmConfig.sections,\n customPrompt: llmConfig.customPrompt,\n eject: true,\n })\n }\n\n cache.eject(outDir, packageDir, docsType, { features })\n }\n finally {\n // Always clean up .skilld/ symlinks, even if LLM enhancement fails\n if (existsSync(skilldDir))\n rmSync(skilldDir, { recursive: true, force: true })\n }\n\n // Only patch package.json when output is under skills/\n const relOut = relative(packageDir, outDir)\n if (relOut === 'skills' || relOut.startsWith('skills/'))\n patchPackageJsonFiles(packageDir)\n else if (opts.out)\n p.log.info('Output is outside skills/, skipping package.json patch. Add the path to \"files\" manually if publishing.')\n\n return outDir\n}\n\n// ── Main command ──\n\nasync function resolveLlmConfig(model?: OptimizeModel, yes?: boolean): Promise<LlmConfig | null | undefined> {\n const globalConfig = readConfig()\n if (globalConfig.skipLlm || (yes && !model))\n return undefined\n return selectLlmConfig(model, 'Generate skill sections')\n}\n\nasync function authorCommand(opts: {\n out?: string\n model?: OptimizeModel\n yes?: boolean\n force?: boolean\n debug?: boolean\n}): Promise<void> {\n const cwd = process.cwd()\n\n // Check for monorepo\n const monoPackages = detectMonorepoPackages(cwd)\n\n if (monoPackages && monoPackages.length > 0) {\n p.intro(`${styleText(['bold', 'magenta'], 'skilld')} author ${styleText('gray', `(monorepo: ${monoPackages.length} packages)`)}`)\n\n if (opts.out) {\n p.log.error('--out is not supported in monorepo mode (each package gets its own skills/ directory)')\n return\n }\n\n const selected = guard(await p.multiselect({\n message: 'Which packages should ship skills?',\n options: monoPackages.map(pkg => ({\n label: pkg.name,\n value: pkg,\n hint: pkg.description,\n })),\n }))\n\n if (selected.length === 0)\n return\n\n // Resolve LLM config once for all packages\n const llmConfig = await resolveLlmConfig(opts.model, opts.yes)\n if (llmConfig === null) {\n p.cancel('Cancelled')\n return\n }\n\n // Resolve monorepo-level repoUrl for packages that lack their own\n const rootPkgResult = readPackageJsonSafe(join(cwd, 'package.json'))\n const rootPkg = rootPkgResult?.parsed as Record<string, any> | undefined\n const rootRepoUrl = typeof rootPkg?.repository === 'string'\n ? rootPkg.repository\n : rootPkg?.repository?.url?.replace(GIT_PLUS_PREFIX_RE, '').replace(GIT_SUFFIX_RE, '')\n\n const results: Array<{ name: string, outDir: string }> = []\n\n for (const pkg of selected) {\n p.log.step(`${styleText('cyan', pkg.name)}@${pkg.version}`)\n const outDir = await authorSinglePackage({\n packageDir: pkg.dir,\n packageName: pkg.name,\n version: pkg.version,\n description: pkg.description,\n repoUrl: pkg.repoUrl || rootRepoUrl,\n monorepoRoot: cwd,\n llmConfig,\n force: opts.force,\n debug: opts.debug,\n })\n if (outDir)\n results.push({ name: pkg.name, outDir })\n }\n\n if (results.length > 0) {\n p.log.message('')\n for (const { name, outDir } of results)\n p.log.success(`${name} → ${relative(cwd, outDir)}`)\n\n printConsumerGuidance(results.map(r => r.name))\n }\n\n p.outro('Done')\n return\n }\n\n // Single package mode\n const pkgInfo = readLocalPackageInfo(cwd)\n if (!pkgInfo) {\n p.log.error('No package.json found in current directory')\n return\n }\n\n const { name: packageName, version, repoUrl } = pkgInfo\n\n p.intro(`${styleText(['bold', 'magenta'], 'skilld')} author ${styleText('cyan', packageName)}@${version}`)\n\n const llmConfig = await resolveLlmConfig(opts.model, opts.yes)\n if (llmConfig === null) {\n p.cancel('Cancelled')\n return\n }\n\n const outDir = await authorSinglePackage({\n packageDir: cwd,\n packageName,\n version,\n description: pkgInfo.description,\n repoUrl,\n out: opts.out,\n llmConfig,\n force: opts.force,\n debug: opts.debug,\n })\n\n if (outDir) {\n printConsumerGuidance([packageName])\n p.outro(`Authored skill to ${relative(cwd, outDir)}`)\n }\n}\n\nfunction printConsumerGuidance(packageNames: string[]): void {\n const names = packageNames.join(', ')\n p.log.info(\n `${styleText('gray', `Consumers get ${packageNames.length > 1 ? 'these skills' : 'this skill'} automatically:`)}\\n`\n + ` ${styleText('gray', `1. Install ${names} as a dependency`)}\\n`\n + ` ${styleText('gray', '2. Run ')}${styleText('cyan', 'skilld prepare')}${styleText('gray', ' (or add to package.json: ')}${styleText('cyan', '\"prepare\": \"skilld prepare\"')}${styleText('gray', ')')}`,\n )\n}\n\nexport const authorCommandDef = defineCommand({\n meta: { name: 'package', description: 'Generate a package skill from documentation' },\n args: {\n out: {\n type: 'string',\n alias: 'o',\n description: 'Output directory (default: ./skills/<name>/)',\n },\n model: {\n type: 'string',\n alias: 'm',\n description: 'Enhancement model for SKILL.md generation',\n valueHint: 'id',\n },\n yes: {\n type: 'boolean',\n alias: 'y',\n description: 'Skip prompts, use defaults',\n default: false,\n },\n force: {\n type: 'boolean',\n alias: 'f',\n description: 'Clear cache and regenerate',\n default: false,\n },\n debug: {\n type: 'boolean',\n description: 'Save raw enhancement output to logs/',\n default: false,\n },\n },\n async run({ args }) {\n await authorCommand({\n out: args.out,\n model: args.model as OptimizeModel | undefined,\n yes: args.yes,\n force: args.force,\n debug: args.debug,\n })\n },\n})\n\nexport const authorGroupDef = defineCommand({\n meta: { name: 'author', description: 'Create, generate, and publish skills' },\n subCommands: {\n package: () => import('./author.ts').then(m => m.authorCommandDef),\n publish: () => import('./upload.ts').then(m => m.uploadCommandDef),\n eject: () => import('./sync/eject.ts').then(m => m.ejectCommandDef),\n validate: () => import('./validate.ts').then(m => m.validateCommandDef),\n assemble: () => import('./assemble.ts').then(m => m.assembleCommandDef),\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;AAuCA,MAAM,iBAAiB;AAIvB,SAAS,kBAAkB,KAAa,OAAO,IAA8C;CAC3F,MAAM,UAAoD,EAAE;CAC5D,IAAI,CAAC,WAAW,IAAI,EAClB,OAAO;CAET,KAAK,MAAM,SAAS,YAAY,KAAK,EAAE,eAAe,MAAM,CAAC,EAAE;EAC7D,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,MAAM,SAAS,MAAM;EACnD,MAAM,OAAO,KAAK,KAAK,MAAM,KAAK;EAClC,IAAI,MAAM,aAAa,EACrB,QAAQ,KAAK,GAAG,kBAAkB,MAAM,IAAI,CAAC;OAE1C,IAAI,eAAe,KAAK,MAAM,KAAK,EACtC,QAAQ,KAAK;GAAE,MAAM;GAAK,SAAS,aAAa,MAAM,QAAQ;GAAE,CAAC;;CAGrE,OAAO;;;;;;;;;GAWT,KAAA,MAAS,KAAA,SACP,WACA,KAAA;IAGA,MAAM,QAAA,EAAuD;IAE7D,SAAM,iBAAuB,EAAA,QAAA;IAG7B,CAAA;GACA,MAAI,MAAA,WAAqB;GACvB,gBAAgB;GAChB,OAAI;IACF,UAAW;IACS,WAAM,gBAAU,QAAA,OAAA;IAAQ;;;KAE5C,cAAgB,KAAA,MAAA,aAAA,CAAA,gBAAA,OAAA,EAAA;QAChB,cAAO,KAAA,cAAA,UAAA;MAAE,WAAU,YAAA,EAAA;SAAQ,UAAW,kBAAgB,YAAe;OAAU,QAAA,SAAA,GAAA;;;KAK/E,SAAA,iBACS,EAAA,QAAA;KACT,CAAA;IACA,MAAI,MAAA,WAAW;IACb,gBAAgB;IAChB,OAAI;KACF,UAAW;KACS,WAAM,YAAU,UAAA,KAAA,QAAA,OAAA;KAAQ;;;;MAG5C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,KAAA,KAAA;CAEF,EAAA,IAAI,KAAA,GAAQ,UAAA,QAAA,iBAAA,aAAA,SAAA,IAAA,iBAAA,aAAA,iBAAA,CAAA,MAAA,UAAA,QAAA,cAAA,MAAA,kBAAA,CAAA,MAAA,UAAA,QAAA,UAAA,GAAA,UAAA,QAAA,iBAAA,GAAA,UAAA,QAAA,6BAAA,GAAA,UAAA,QAAA,kCAAA,GAAA,UAAA,QAAA,IAAA,GAAA;;MAER,mBAAM,cAAqB;;;EAIjC,aAAS;EACP;CACA,MAAM;;GAOR,MAAa;GACX,OAAM;GAAE,aAAM;GAAW;EAA4D,OAAA;GACrF,MAAM;GACJ,OAAK;GACH,aAAM;GACN,WAAO;GACP;OACD;GACD,MAAO;GACL,OAAM;GACN,aAAO;GACP,SAAA;GACA;SACD;GACD,MAAK;GACH,OAAM;GACN,aAAO;GACP,SAAA;GACA;SACD;GACD,MAAO;GACL,aAAM;GACN,SAAO;GACP;;OAED,IAAA,EAAA,QAAA;EACD,MAAA,cAAO;GACL,KAAA,KAAM;GACN,OAAA,KAAA;GACA,KAAA,KAAS;GACV,OAAA,KAAA;GACF,OAAA,KAAA;GACD,CAAA;;;MAGI,iBAAY,cAAA;OACZ;QACA;eACY;;;EAGhB,eAAA,OAAA,gBAAA,MAAA,MAAA,EAAA,iBAAA;EAEF,eAAa,OAAiB,gBAAc,MAAA,MAAA,EAAA,iBAAA;EAC1C,aAAM,OAAA,eAAA,MAAA,MAAA,EAAA,gBAAA;EAAE,gBAAM,OAAA,kBAAA,MAAA,MAAA,EAAA,mBAAA;EAAU,gBAAa,OAAA,kBAAA,MAAA,MAAA,EAAA,mBAAA;EAAwC;CAC7E,CAAA;SAEE,kBAAsB"}
|
|
1
|
+
{"version":3,"file":"author.mjs","names":[],"sources":["../../src/commands/author.ts"],"sourcesContent":["import type { OptimizeModel } from '../agent/index.ts'\nimport type { ReferenceCache } from '../cache/index.ts'\nimport type { FeaturesConfig } from '../core/config.ts'\nimport type { LlmConfig } from './llm-prompts.ts'\nimport { existsSync, mkdirSync, readdirSync, readFileSync, rmSync } from 'node:fs'\nimport { styleText } from 'node:util'\nimport * as p from '@clack/prompts'\nimport { defineCommand } from 'citty'\nimport { join, relative, resolve } from 'pathe'\nimport {\n\n computeSkillDirName,\n getModelLabel,\n writeGeneratedSkillMd,\n} from '../agent/index.ts'\nimport { enhanceSkillWithLLM, writePromptFiles } from '../agent/skill-builder.ts'\nimport { createReferenceCache, ensureCacheDir } from '../cache/index.ts'\nimport { guard } from '../cli/menu.ts'\nimport { defaultFeatures, readConfig } from '../core/config.ts'\nimport { timedSpinner } from '../core/formatting.ts'\nimport { detectMonorepoPackages } from '../core/monorepo.ts'\nimport { appendToJsonArray, patchPackageJson, readPackageJsonSafe } from '../core/package-json.ts'\nimport { skillInternalDir } from '../core/paths.ts'\nimport { GIT_PLUS_PREFIX_RE, GIT_SUFFIX_RE, README_FILENAME_RE } from '../core/regex.ts'\nimport { sanitizeMarkdown } from '../core/sanitize.ts'\nimport { parseGitHubUrl } from '../core/url.ts'\nimport {\n fetchGitHubDiscussions,\n fetchGitHubIssues,\n formatDiscussionAsMarkdown,\n formatIssueAsMarkdown,\n generateDiscussionIndex,\n generateIssueIndex,\n isGhAvailable,\n readLocalPackageInfo,\n} from '../sources/index.ts'\nimport { selectLlmConfig } from './llm-prompts.ts'\nimport { detectChangelog } from './sync/pipeline.ts'\n\nconst STATIC_REGEX_1 = /\\.mdx?$/\n\n// ── Docs resolution ──\n\nfunction walkMarkdownFiles(dir: string, base = ''): Array<{ path: string, content: string }> {\n const results: Array<{ path: string, content: string }> = []\n if (!existsSync(dir))\n return results\n\n for (const entry of readdirSync(dir, { withFileTypes: true })) {\n const rel = base ? `${base}/${entry.name}` : entry.name\n const full = join(dir, entry.name)\n if (entry.isDirectory()) {\n results.push(...walkMarkdownFiles(full, rel))\n }\n else if (STATIC_REGEX_1.test(entry.name)) {\n results.push({ path: rel, content: readFileSync(full, 'utf-8') })\n }\n }\n return results\n}\n\n/**\n * Resolve docs from local filesystem. Cascade:\n * 1. Package-level docs/ directory\n * 2. Monorepo-root docs/ directory (if monorepoRoot provided)\n * 3. Monorepo-root docs/content/ (Nuxt Content convention)\n * 4. llms.txt in package dir\n * 5. README.md in package dir\n */\nfunction resolveLocalDocs(\n cache: ReferenceCache,\n packageDir: string,\n monorepoRoot?: string,\n): { docsType: 'docs' | 'llms.txt' | 'readme', docSource: string } {\n const cachedDocs: Array<{ path: string, content: string }> = []\n\n const cacheChangelog = () => cacheLocalChangelog(cache, packageDir, monorepoRoot)\n\n // 1. Package-level docs/\n const docsDir = join(packageDir, 'docs')\n if (existsSync(docsDir)) {\n const mdFiles = walkMarkdownFiles(docsDir)\n if (mdFiles.length > 0) {\n for (const f of mdFiles)\n cachedDocs.push({ path: `docs/${f.path}`, content: sanitizeMarkdown(f.content) })\n cache.write(cachedDocs)\n cacheChangelog()\n return { docsType: 'docs', docSource: `local docs/ (${mdFiles.length} files)` }\n }\n }\n\n // 2. Monorepo-root docs/ or docs/content/\n if (monorepoRoot) {\n for (const candidate of ['docs/content', 'docs']) {\n const rootDocsDir = join(monorepoRoot, candidate)\n if (existsSync(rootDocsDir)) {\n const mdFiles = walkMarkdownFiles(rootDocsDir)\n if (mdFiles.length > 0) {\n for (const f of mdFiles)\n cachedDocs.push({ path: `docs/${f.path}`, content: sanitizeMarkdown(f.content) })\n cache.write(cachedDocs)\n cacheChangelog()\n return { docsType: 'docs', docSource: `monorepo ${candidate}/ (${mdFiles.length} files)` }\n }\n }\n }\n }\n\n // 3. llms.txt (package dir, then monorepo root)\n for (const dir of [packageDir, monorepoRoot].filter(Boolean) as string[]) {\n const llmsPath = join(dir, 'llms.txt')\n if (existsSync(llmsPath)) {\n cachedDocs.push({ path: 'llms.txt', content: sanitizeMarkdown(readFileSync(llmsPath, 'utf-8')) })\n cache.write(cachedDocs)\n cacheChangelog()\n const source = dir === packageDir ? 'local llms.txt' : 'monorepo llms.txt'\n return { docsType: 'llms.txt', docSource: source }\n }\n }\n\n // 4. README.md (package dir, then monorepo root)\n for (const dir of [packageDir, monorepoRoot].filter(Boolean) as string[]) {\n const readmeFile = readdirSync(dir).find(f => README_FILENAME_RE.test(f))\n if (readmeFile) {\n cachedDocs.push({ path: 'docs/README.md', content: sanitizeMarkdown(readFileSync(join(dir, readmeFile), 'utf-8')) })\n cache.write(cachedDocs)\n cacheChangelog()\n const source = dir === packageDir ? 'local README.md' : 'monorepo README.md'\n return { docsType: 'readme', docSource: source }\n }\n }\n\n cacheChangelog()\n return { docsType: 'readme', docSource: 'none' }\n}\n\nfunction cacheLocalChangelog(cache: ReferenceCache, dir: string, monorepoRoot?: string): void {\n const candidates = ['CHANGELOG.md', 'changelog.md']\n const changelogFile = candidates.find(f => existsSync(join(dir, f)))\n || (monorepoRoot ? candidates.find(f => existsSync(join(monorepoRoot, f))) : undefined)\n const changelogDir = changelogFile && existsSync(join(dir, changelogFile)) ? dir : monorepoRoot\n if (changelogFile && changelogDir) {\n cache.write([{\n path: `releases/${changelogFile}`,\n content: sanitizeMarkdown(readFileSync(join(changelogDir, changelogFile), 'utf-8')),\n }])\n }\n}\n\n// ── Remote supplements ──\n\nasync function fetchRemoteSupplements(opts: {\n cache: ReferenceCache\n repoUrl?: string\n features: FeaturesConfig\n onProgress: (msg: string) => void\n}): Promise<{ hasIssues: boolean, hasDiscussions: boolean }> {\n const { cache, repoUrl, features, onProgress } = opts\n\n if (!repoUrl || !isGhAvailable())\n return { hasIssues: false, hasDiscussions: false }\n\n const gh = parseGitHubUrl(repoUrl)\n if (!gh)\n return { hasIssues: false, hasDiscussions: false }\n\n let hasIssues = false\n const issuesDir = join(cache.dir, 'issues')\n if (features.issues && !existsSync(issuesDir)) {\n onProgress('Fetching issues via GitHub API')\n const issues = await fetchGitHubIssues(gh.owner, gh.repo, 30).catch(() => [])\n if (issues.length > 0) {\n onProgress(`Caching ${issues.length} issues`)\n cache.write(issues.map(issue => ({\n path: `issues/issue-${issue.number}.md`,\n content: formatIssueAsMarkdown(issue),\n })))\n cache.write([{\n path: 'issues/_INDEX.md',\n content: generateIssueIndex(issues),\n }])\n hasIssues = true\n }\n }\n else {\n hasIssues = features.issues && existsSync(issuesDir)\n }\n\n let hasDiscussions = false\n const discussionsDir = join(cache.dir, 'discussions')\n if (features.discussions && !existsSync(discussionsDir)) {\n onProgress('Fetching discussions via GitHub API')\n const discussions = await fetchGitHubDiscussions(gh.owner, gh.repo, 20).catch(() => [])\n if (discussions.length > 0) {\n onProgress(`Caching ${discussions.length} discussions`)\n cache.write(discussions.map(d => ({\n path: `discussions/discussion-${d.number}.md`,\n content: formatDiscussionAsMarkdown(d),\n })))\n cache.write([{\n path: 'discussions/_INDEX.md',\n content: generateDiscussionIndex(discussions),\n }])\n hasDiscussions = true\n }\n }\n else {\n hasDiscussions = features.discussions && existsSync(discussionsDir)\n }\n\n return { hasIssues, hasDiscussions }\n}\n\n// ── package.json patching ──\n\nexport function patchPackageJsonFiles(packageDir: string): void {\n const pkgPath = join(packageDir, 'package.json')\n if (!existsSync(pkgPath))\n return\n\n const wrote = patchPackageJson(pkgPath, (raw, pkg) => {\n if (!Array.isArray(pkg.files)) {\n p.log.warn('No `files` array in package.json. Add `\"skills\"` to your files array manually.')\n return null\n }\n\n if ((pkg.files as string[]).some((f: string) => f === 'skills' || f === 'skills/' || f === 'skills/**'))\n return null\n\n return appendToJsonArray(raw, ['files'], 'skills')\n })\n\n if (wrote)\n p.log.success('Added `\"skills\"` to package.json files array')\n}\n\n// ── Core author flow for a single package ──\n\nasync function authorSinglePackage(opts: {\n packageDir: string\n packageName: string\n version: string\n description?: string\n repoUrl?: string\n monorepoRoot?: string\n out?: string\n llmConfig?: LlmConfig | null\n force?: boolean\n debug?: boolean\n}): Promise<string | null> {\n const { packageDir, packageName, version } = opts\n const spin = timedSpinner()\n\n const sanitizedName = computeSkillDirName(packageName)\n const outDir = opts.out ? resolve(packageDir, opts.out) : join(packageDir, 'skills', sanitizedName)\n\n // Validate --out doesn't point at the package root or a parent\n if (opts.out) {\n const rel = relative(packageDir, outDir)\n if (!rel || rel === '.' || rel.startsWith('..')) {\n p.log.error('--out must point to a child directory, not the package root or a parent')\n return null\n }\n }\n\n if (existsSync(outDir))\n rmSync(outDir, { recursive: true, force: true })\n mkdirSync(outDir, { recursive: true })\n\n const cache = createReferenceCache(packageName, version)\n\n if (opts.force) {\n cache.clearForce()\n }\n\n ensureCacheDir()\n const features = readConfig().features ?? defaultFeatures\n\n // Resolve local docs\n spin.start('Resolving local docs')\n const { docsType, docSource } = resolveLocalDocs(cache, packageDir, opts.monorepoRoot)\n spin.stop(`Resolved docs: ${docSource}`)\n\n // Fetch remote supplements (issues/discussions)\n const supSpin = timedSpinner()\n supSpin.start('Checking remote supplements')\n const { hasIssues, hasDiscussions } = await fetchRemoteSupplements({\n cache,\n repoUrl: opts.repoUrl,\n features,\n onProgress: msg => supSpin.message(msg),\n })\n const supParts: string[] = []\n if (hasIssues)\n supParts.push('issues')\n if (hasDiscussions)\n supParts.push('discussions')\n supSpin.stop(supParts.length > 0 ? `Fetched ${supParts.join(', ')}` : 'No remote supplements')\n\n // Create temporary .skilld/ symlinks (LLM needs these to read docs)\n cache.linkInto(outDir, packageDir, docsType, { features })\n\n // Detect changelog + releases\n const hasChangelog = detectChangelog(packageDir, cache.dir)\n const hasReleases = existsSync(join(cache.dir, 'releases'))\n\n // Generate base SKILL.md\n writeGeneratedSkillMd(outDir, {\n name: packageName,\n version,\n description: opts.description,\n relatedSkills: [],\n hasIssues,\n hasDiscussions,\n hasReleases,\n hasChangelog,\n docsType,\n hasShippedDocs: false,\n pkgFiles: [],\n dirName: sanitizedName,\n repoUrl: opts.repoUrl,\n features,\n eject: true,\n })\n p.log.success(`Created base skill: ${relative(packageDir, outDir)}`)\n\n // LLM enhancement (config resolved by caller)\n const skilldDir = skillInternalDir(outDir)\n try {\n const llmConfig = opts.llmConfig\n const baseCtx = {\n packageName,\n version,\n skillDir: outDir,\n dirName: sanitizedName,\n references: {\n docsType,\n hasShippedDocs: false,\n pkgFiles: [],\n hasIssues,\n hasDiscussions,\n hasReleases,\n hasChangelog,\n },\n resolved: { repoUrl: opts.repoUrl },\n relatedSkills: [],\n features,\n }\n if (llmConfig?.promptOnly) {\n writePromptFiles(baseCtx, {\n sections: llmConfig.sections,\n customPrompt: llmConfig.customPrompt,\n })\n }\n else if (llmConfig) {\n p.log.step(getModelLabel(llmConfig.model))\n await enhanceSkillWithLLM(baseCtx, {\n model: llmConfig.model,\n force: opts.force,\n debug: opts.debug,\n sections: llmConfig.sections,\n customPrompt: llmConfig.customPrompt,\n eject: true,\n })\n }\n\n cache.eject(outDir, packageDir, docsType, { features })\n }\n finally {\n // Always clean up .skilld/ symlinks, even if LLM enhancement fails\n if (existsSync(skilldDir))\n rmSync(skilldDir, { recursive: true, force: true })\n }\n\n // Only patch package.json when output is under skills/\n const relOut = relative(packageDir, outDir)\n if (relOut === 'skills' || relOut.startsWith('skills/'))\n patchPackageJsonFiles(packageDir)\n else if (opts.out)\n p.log.info('Output is outside skills/, skipping package.json patch. Add the path to \"files\" manually if publishing.')\n\n return outDir\n}\n\n// ── Main command ──\n\nasync function resolveLlmConfig(model?: OptimizeModel, yes?: boolean): Promise<LlmConfig | null | undefined> {\n const globalConfig = readConfig()\n if (globalConfig.skipLlm || (yes && !model))\n return undefined\n return selectLlmConfig(model, 'Generate skill sections')\n}\n\nasync function authorCommand(opts: {\n out?: string\n model?: OptimizeModel\n yes?: boolean\n force?: boolean\n debug?: boolean\n}): Promise<void> {\n const cwd = process.cwd()\n\n // Check for monorepo\n const monoPackages = detectMonorepoPackages(cwd)\n\n if (monoPackages && monoPackages.length > 0) {\n p.intro(`${styleText(['bold', 'magenta'], 'skilld')} author ${styleText('gray', `(monorepo: ${monoPackages.length} packages)`)}`)\n\n if (opts.out) {\n p.log.error('--out is not supported in monorepo mode (each package gets its own skills/ directory)')\n return\n }\n\n const selected = guard(await p.multiselect({\n message: 'Which packages should ship skills?',\n options: monoPackages.map(pkg => ({\n label: pkg.name,\n value: pkg,\n hint: pkg.description,\n })),\n }))\n\n if (selected.length === 0)\n return\n\n // Resolve LLM config once for all packages\n const llmConfig = await resolveLlmConfig(opts.model, opts.yes)\n if (llmConfig === null) {\n p.cancel('Cancelled')\n return\n }\n\n // Resolve monorepo-level repoUrl for packages that lack their own\n const rootPkgResult = readPackageJsonSafe(join(cwd, 'package.json'))\n const rootPkg = rootPkgResult?.parsed as Record<string, any> | undefined\n const rootRepoUrl = typeof rootPkg?.repository === 'string'\n ? rootPkg.repository\n : rootPkg?.repository?.url?.replace(GIT_PLUS_PREFIX_RE, '').replace(GIT_SUFFIX_RE, '')\n\n const results: Array<{ name: string, outDir: string }> = []\n\n for (const pkg of selected) {\n p.log.step(`${styleText('cyan', pkg.name)}@${pkg.version}`)\n const outDir = await authorSinglePackage({\n packageDir: pkg.dir,\n packageName: pkg.name,\n version: pkg.version,\n description: pkg.description,\n repoUrl: pkg.repoUrl || rootRepoUrl,\n monorepoRoot: cwd,\n llmConfig,\n force: opts.force,\n debug: opts.debug,\n })\n if (outDir)\n results.push({ name: pkg.name, outDir })\n }\n\n if (results.length > 0) {\n p.log.message('')\n for (const { name, outDir } of results)\n p.log.success(`${name} → ${relative(cwd, outDir)}`)\n\n printConsumerGuidance(results.map(r => r.name))\n }\n\n p.outro('Done')\n return\n }\n\n // Single package mode\n const pkgInfo = readLocalPackageInfo(cwd)\n if (!pkgInfo) {\n p.log.error('No package.json found in current directory')\n return\n }\n\n const { name: packageName, version, repoUrl } = pkgInfo\n\n p.intro(`${styleText(['bold', 'magenta'], 'skilld')} author ${styleText('cyan', packageName)}@${version}`)\n\n const llmConfig = await resolveLlmConfig(opts.model, opts.yes)\n if (llmConfig === null) {\n p.cancel('Cancelled')\n return\n }\n\n const outDir = await authorSinglePackage({\n packageDir: cwd,\n packageName,\n version,\n description: pkgInfo.description,\n repoUrl,\n out: opts.out,\n llmConfig,\n force: opts.force,\n debug: opts.debug,\n })\n\n if (outDir) {\n printConsumerGuidance([packageName])\n p.outro(`Authored skill to ${relative(cwd, outDir)}`)\n }\n}\n\nfunction printConsumerGuidance(packageNames: string[]): void {\n const names = packageNames.join(', ')\n p.log.info(\n `${styleText('gray', `Consumers get ${packageNames.length > 1 ? 'these skills' : 'this skill'} automatically:`)}\\n`\n + ` ${styleText('gray', `1. Install ${names} as a dependency`)}\\n`\n + ` ${styleText('gray', '2. Run ')}${styleText('cyan', 'skilld prepare')}${styleText('gray', ' (or add to package.json: ')}${styleText('cyan', '\"prepare\": \"skilld prepare\"')}${styleText('gray', ')')}`,\n )\n}\n\nexport const authorCommandDef = defineCommand({\n meta: { name: 'package', description: 'Generate a package skill from documentation' },\n args: {\n out: {\n type: 'string',\n alias: 'o',\n description: 'Output directory (default: ./skills/<name>/)',\n },\n model: {\n type: 'string',\n alias: 'm',\n description: 'Enhancement model for SKILL.md generation',\n valueHint: 'id',\n },\n yes: {\n type: 'boolean',\n alias: 'y',\n description: 'Skip prompts, use defaults',\n default: false,\n },\n force: {\n type: 'boolean',\n alias: 'f',\n description: 'Clear cache and regenerate',\n default: false,\n },\n debug: {\n type: 'boolean',\n description: 'Save raw enhancement output to logs/',\n default: false,\n },\n },\n async run({ args }) {\n await authorCommand({\n out: args.out,\n model: args.model as OptimizeModel | undefined,\n yes: args.yes,\n force: args.force,\n debug: args.debug,\n })\n },\n})\n\nexport const authorGroupDef = defineCommand({\n meta: { name: 'author', description: 'Create, generate, and publish skills' },\n subCommands: {\n package: () => import('./author.ts').then(m => m.authorCommandDef),\n publish: () => import('./upload.ts').then(m => m.uploadCommandDef),\n eject: () => import('./sync/eject.ts').then(m => m.ejectCommandDef),\n validate: () => import('./validate.ts').then(m => m.validateCommandDef),\n assemble: () => import('./assemble.ts').then(m => m.assembleCommandDef),\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;AAuCA,MAAM,iBAAiB;AAIvB,SAAS,kBAAkB,KAAa,OAAO,IAA8C;CAC3F,MAAM,UAAoD,CAAC;CAC3D,IAAI,CAAC,WA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{
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { defaultFeatures, hasIndexEmbeddingIdentity, readConfig, resolveEmbeddingIdentity } from "./index-identity.mjs";
|
|
2
|
+
import { REFERENCES_DIR, REPOS_DIR, getPackageDbPath, getRepoCacheDir, skillInternalDir } from "./paths.mjs";
|
|
3
|
+
import { sanitizeMarkdown } from "./sanitize.mjs";
|
|
4
|
+
import { getCacheDir, getPkgKeyFiles, getVersionKey, hasShippedDocs, resolvePkgDir } from "./prepare.mjs";
|
|
5
5
|
import { copyFileSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, symlinkSync, unlinkSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { dirname, join, resolve } from "pathe";
|
|
7
|
-
const STATIC_REGEX_1$1 = /^ {2}(\w+):\s*(.+)/;
|
|
8
|
-
const defaultFeatures = {
|
|
9
|
-
search: true,
|
|
10
|
-
issues: true,
|
|
11
|
-
discussions: true,
|
|
12
|
-
releases: true
|
|
13
|
-
};
|
|
14
|
-
function getActiveFeatures(overrides) {
|
|
15
|
-
const fromConfig = readConfig().features;
|
|
16
|
-
const merged = {
|
|
17
|
-
...defaultFeatures,
|
|
18
|
-
...fromConfig ?? {}
|
|
19
|
-
};
|
|
20
|
-
return overrides ? {
|
|
21
|
-
...merged,
|
|
22
|
-
...overrides
|
|
23
|
-
} : merged;
|
|
24
|
-
}
|
|
25
|
-
let configCache;
|
|
26
|
-
function hasConfig() {
|
|
27
|
-
return existsSync(CONFIG_PATH);
|
|
28
|
-
}
|
|
29
|
-
function hasCompletedWizard() {
|
|
30
|
-
if (!existsSync(CONFIG_PATH)) return false;
|
|
31
|
-
const config = readConfig();
|
|
32
|
-
return config.features !== void 0 || config.model !== void 0 || config.skipLlm !== void 0;
|
|
33
|
-
}
|
|
34
|
-
function readConfig() {
|
|
35
|
-
if (configCache) return {
|
|
36
|
-
...configCache,
|
|
37
|
-
features: configCache.features ? { ...configCache.features } : void 0,
|
|
38
|
-
projects: configCache.projects ? [...configCache.projects] : void 0
|
|
39
|
-
};
|
|
40
|
-
if (!existsSync(CONFIG_PATH)) return {};
|
|
41
|
-
const content = readFileSync(CONFIG_PATH, "utf-8");
|
|
42
|
-
const config = {};
|
|
43
|
-
let inBlock = null;
|
|
44
|
-
const projects = [];
|
|
45
|
-
const features = {};
|
|
46
|
-
for (const line of content.split("\n")) {
|
|
47
|
-
if (line.startsWith("projects:")) {
|
|
48
|
-
inBlock = "projects";
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
if (line.startsWith("features:")) {
|
|
52
|
-
inBlock = "features";
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
if (inBlock === "projects") {
|
|
56
|
-
if (line.startsWith(" - ")) {
|
|
57
|
-
projects.push(yamlUnescape(line.slice(4)));
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
inBlock = null;
|
|
61
|
-
}
|
|
62
|
-
if (inBlock === "features") {
|
|
63
|
-
const m = line.match(STATIC_REGEX_1$1);
|
|
64
|
-
if (m) {
|
|
65
|
-
const key = m[1];
|
|
66
|
-
if (key in defaultFeatures) features[key] = m[2] === "true";
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
inBlock = null;
|
|
70
|
-
}
|
|
71
|
-
const kv = yamlParseKV(line);
|
|
72
|
-
if (!kv) continue;
|
|
73
|
-
const [key, value] = kv;
|
|
74
|
-
if (key === "model" && value) config.model = value;
|
|
75
|
-
if (key === "agent" && value) config.agent = value;
|
|
76
|
-
if (key === "skipLlm") config.skipLlm = value === "true";
|
|
77
|
-
}
|
|
78
|
-
if (projects.length > 0) config.projects = projects;
|
|
79
|
-
if (Object.keys(features).length > 0) config.features = {
|
|
80
|
-
...defaultFeatures,
|
|
81
|
-
...features
|
|
82
|
-
};
|
|
83
|
-
configCache = config;
|
|
84
|
-
return config;
|
|
85
|
-
}
|
|
86
|
-
function writeConfig(config) {
|
|
87
|
-
mkdirSync(CACHE_DIR, {
|
|
88
|
-
recursive: true,
|
|
89
|
-
mode: 448
|
|
90
|
-
});
|
|
91
|
-
let yaml = "";
|
|
92
|
-
if (config.model) yaml += `model: ${config.model}\n`;
|
|
93
|
-
if (config.agent) yaml += `agent: ${config.agent}\n`;
|
|
94
|
-
if (config.skipLlm) yaml += `skipLlm: true\n`;
|
|
95
|
-
if (config.features) {
|
|
96
|
-
yaml += "features:\n";
|
|
97
|
-
for (const [k, v] of Object.entries(config.features)) yaml += ` ${k}: ${v}\n`;
|
|
98
|
-
}
|
|
99
|
-
if (config.projects?.length) {
|
|
100
|
-
yaml += "projects:\n";
|
|
101
|
-
for (const p of config.projects) yaml += ` - ${yamlEscape(p)}\n`;
|
|
102
|
-
}
|
|
103
|
-
writeFileSync(CONFIG_PATH, yaml, { mode: 384 });
|
|
104
|
-
configCache = void 0;
|
|
105
|
-
}
|
|
106
|
-
function updateConfig(updates) {
|
|
107
|
-
writeConfig({
|
|
108
|
-
...readConfig(),
|
|
109
|
-
...updates
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
function registerProject(projectPath) {
|
|
113
|
-
const config = readConfig();
|
|
114
|
-
const projects = new Set(config.projects || []);
|
|
115
|
-
projects.add(projectPath);
|
|
116
|
-
writeConfig({
|
|
117
|
-
...config,
|
|
118
|
-
projects: [...projects]
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
function unregisterProject(projectPath) {
|
|
122
|
-
const config = readConfig();
|
|
123
|
-
const projects = (config.projects || []).filter((p) => p !== projectPath);
|
|
124
|
-
writeConfig({
|
|
125
|
-
...config,
|
|
126
|
-
projects
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
function getRegisteredProjects() {
|
|
130
|
-
return readConfig().projects || [];
|
|
131
|
-
}
|
|
132
7
|
const STATIC_REGEX_1 = /^issues\/issue-(\d+)\.md$/;
|
|
133
8
|
const STATIC_REGEX_2 = /^discussions\/discussion-(\d+)\.md$/;
|
|
134
9
|
function classifyCachedDoc(path) {
|
|
@@ -251,7 +126,8 @@ function linkPkgNamed(skillDir, name, cwd, version) {
|
|
|
251
126
|
symlinkSync(pkgPath, linkPath, "junction");
|
|
252
127
|
}
|
|
253
128
|
function writeSections(name, version, sections) {
|
|
254
|
-
const
|
|
129
|
+
const cacheDir = getCacheDir(name, version);
|
|
130
|
+
const sectionsDir = join(cacheDir, "sections");
|
|
255
131
|
mkdirSync(sectionsDir, {
|
|
256
132
|
recursive: true,
|
|
257
133
|
mode: 448
|
|
@@ -350,12 +226,18 @@ function linkAllReferences(skillDir, packageName, cwd, version, docsType, extraP
|
|
|
350
226
|
linkPkg(skillDir, packageName, cwd, version);
|
|
351
227
|
linkPkgNamed(skillDir, packageName, cwd, version);
|
|
352
228
|
if (!hasShippedDocs(packageName, cwd, version) && docsType !== "readme") linkCachedDir(skillDir, packageName, version, "docs");
|
|
353
|
-
if (f.issues)
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
if (f.
|
|
358
|
-
|
|
229
|
+
if (f.issues) {
|
|
230
|
+
if (repoInfo) linkRepoCachedDir(skillDir, repoInfo.owner, repoInfo.repo, "issues");
|
|
231
|
+
else linkCachedDir(skillDir, packageName, version, "issues");
|
|
232
|
+
}
|
|
233
|
+
if (f.discussions) {
|
|
234
|
+
if (repoInfo) linkRepoCachedDir(skillDir, repoInfo.owner, repoInfo.repo, "discussions");
|
|
235
|
+
else linkCachedDir(skillDir, packageName, version, "discussions");
|
|
236
|
+
}
|
|
237
|
+
if (f.releases) {
|
|
238
|
+
if (repoInfo) linkRepoCachedDir(skillDir, repoInfo.owner, repoInfo.repo, "releases");
|
|
239
|
+
else linkCachedDir(skillDir, packageName, version, "releases");
|
|
240
|
+
}
|
|
359
241
|
linkCachedDir(skillDir, packageName, version, "sections");
|
|
360
242
|
if (extraPackages) {
|
|
361
243
|
for (const pkg of extraPackages) if (pkg.name !== packageName) linkPkgNamed(skillDir, pkg.name, cwd, pkg.version);
|
|
@@ -409,7 +291,8 @@ function loadCachedReferences(opts) {
|
|
|
409
291
|
const docsType = detected.docsType;
|
|
410
292
|
const docSource = detected.docSource ?? readmeUrl ?? "readme";
|
|
411
293
|
const docsToIndex = [];
|
|
412
|
-
|
|
294
|
+
const dbPath = getPackageDbPath(packageName, version);
|
|
295
|
+
if (!existsSync(dbPath) || !hasIndexEmbeddingIdentity(dbPath, resolveEmbeddingIdentity())) {
|
|
413
296
|
onProgress("Reading cached docs for indexing");
|
|
414
297
|
const cached = readCachedDocs(packageName, version);
|
|
415
298
|
for (const doc of cached) docsToIndex.push({
|
|
@@ -479,6 +362,6 @@ function createReferenceCache(packageName, version) {
|
|
|
479
362
|
keyFiles: (cwd) => getPkgKeyFiles(packageName, cwd, version)
|
|
480
363
|
};
|
|
481
364
|
}
|
|
482
|
-
export {
|
|
365
|
+
export { createReferenceCache, ensureCacheDir, getSkillReferenceDirs, listReferenceFiles, writeToRepoCache };
|
|
483
366
|
|
|
484
367
|
//# sourceMappingURL=cache.mjs.map
|