skilld-harness 3.0.0-beta.1

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["invalid","invalid","unavailable"],"sources":["../src/internal/result.ts","../src/internal/input.ts","../src/internal/output/collect.ts","../src/internal/output/promote.ts","../src/internal/output/validate.ts","../src/internal/source/host.ts","../src/internal/source/archive.ts","../src/internal/source/npm.ts","../src/harness.ts"],"sourcesContent":["export type Result<T, E>\n = | { readonly _tag: 'Ok', readonly value: T }\n | { readonly _tag: 'Err', readonly error: E }\n\nexport const ok = <T>(value: T): Result<T, never> => ({ _tag: 'Ok', value })\nexport const err = <E>(error: E): Result<never, E> => ({ _tag: 'Err', error })\n","import type { SkillOutputPolicy, SkillRun, SkillRunError } from '../types.ts'\nimport type { Result } from './result.ts'\nimport { resolve } from 'node:path'\nimport { isSkillName, resolveWithin } from './paths.ts'\nimport { err, ok } from './result.ts'\n\nfunction invalid(message: string): Result<never, SkillRunError> {\n return err({ _tag: 'InvalidInput', message })\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === 'string' && value.trim().length > 0\n}\n\nexport function parseSkillRun(input: SkillRun): Result<SkillRun, SkillRunError> {\n if (!input || typeof input !== 'object' || !('_tag' in input))\n return invalid('Skill run input must be an object with a tag.')\n\n if (input._tag === 'PackageSkill') {\n if (!input.source || !input.destination)\n return invalid('Package Skill input is incomplete.')\n if (!isNonEmptyString(input.destination.rootDir) || !isSkillName(input.destination.name))\n return invalid('Package Skill destination is invalid.')\n if (input.source._tag === 'NpmPackage') {\n if (!isNonEmptyString(input.source.spec))\n return invalid('npm package spec is required.')\n return ok({\n _tag: 'PackageSkill',\n source: { _tag: 'NpmPackage', spec: input.source.spec },\n destination: { rootDir: resolve(input.destination.rootDir), name: input.destination.name },\n })\n }\n if (input.source._tag === 'LocalPackage') {\n if (!isNonEmptyString(input.source.rootDir) || !isNonEmptyString(input.source.packageDir))\n return invalid('Local package paths are required.')\n if (resolveWithin(input.source.rootDir, input.source.packageDir) === null)\n return invalid('Local package directory must stay inside its root directory.')\n return ok({\n _tag: 'PackageSkill',\n source: {\n _tag: 'LocalPackage',\n rootDir: resolve(input.source.rootDir),\n packageDir: input.source.packageDir,\n },\n destination: { rootDir: resolve(input.destination.rootDir), name: input.destination.name },\n })\n }\n return invalid('Package source tag is invalid.')\n }\n\n if (input._tag === 'ProjectSkill') {\n if (!isNonEmptyString(input.projectDir) || !input.destination)\n return invalid('Project Skill input is incomplete.')\n if (!isNonEmptyString(input.destination.rootDir) || !isSkillName(input.destination.name))\n return invalid('Project Skill destination is invalid.')\n return ok({\n _tag: 'ProjectSkill',\n projectDir: resolve(input.projectDir),\n destination: { rootDir: resolve(input.destination.rootDir), name: input.destination.name },\n })\n }\n\n if (input._tag === 'ReviewSkill') {\n if (!isNonEmptyString(input.skillDir))\n return invalid('Skill review directory is required.')\n return ok({ _tag: 'ReviewSkill', skillDir: resolve(input.skillDir) })\n }\n\n return invalid('Skill run tag is invalid.')\n}\n\nexport function parseOutputPolicy(policy: SkillOutputPolicy): SkillOutputPolicy {\n for (const [name, value] of Object.entries(policy)) {\n if (!Number.isSafeInteger(value) || value <= 0)\n throw new TypeError(`${name} must be a positive integer.`)\n }\n return Object.freeze(policy)\n}\n","import type { SkillOutputPolicy, SkillRunError } from '../../types.ts'\nimport type { Result } from '../result.ts'\nimport type { HarnessAgentSandboxConfig } from '@ai-sdk/harness/agent'\nimport { normalizeOutputPath } from '../paths.ts'\nimport { err, ok } from '../result.ts'\n\nexport type SandboxSession = Parameters<NonNullable<HarnessAgentSandboxConfig['onSession']>>[0]['session']\n\nexport interface CollectedFile {\n readonly path: string\n readonly content: Uint8Array\n}\n\nconst invalid = (message: string, issues: ReadonlyArray<string>): Result<never, SkillRunError> =>\n err({ _tag: 'InvalidSkill', message, issues })\n\nconst inventory = async (\n sandbox: SandboxSession,\n outputDir: string,\n signal?: AbortSignal,\n): Promise<Result<ReadonlyArray<{ type: string, path: string, size: number }>, SkillRunError>> => {\n if (signal?.aborted)\n return err({ _tag: 'Cancelled', message: 'Skill run was cancelled.' })\n const command = 'find -P \"$SKILLD_OUTPUT\" -mindepth 1 -printf \\'%y\\\\0%P\\\\0%s\\\\0\\''\n const result = await Promise.resolve().then(() => sandbox.run({\n command,\n env: { LC_ALL: 'C', SKILLD_OUTPUT: outputDir },\n abortSignal: signal,\n })).catch(error => error as Error)\n if (result instanceof Error)\n return invalid('Harness output cannot be inspected.', [result.message])\n if (result.exitCode !== 0)\n return invalid('Harness output directory is missing.', [result.stderr.trim() || 'No output directory.'])\n\n const fields = result.stdout.split('\\0')\n if (fields.at(-1) === '')\n fields.pop()\n if (fields.length % 3 !== 0)\n return invalid('Harness output inventory is invalid.', ['File inventory has an incomplete entry.'])\n\n const entries: Array<{ type: string, path: string, size: number }> = []\n for (let index = 0; index < fields.length; index += 3) {\n const type = fields[index]\n const path = fields[index + 1]\n const size = Number(fields[index + 2])\n if (!type || !path || !Number.isSafeInteger(size) || size < 0)\n return invalid('Harness output inventory is invalid.', ['File inventory has invalid fields.'])\n entries.push({ type, path, size })\n }\n return ok(entries)\n}\n\nexport const collectSandboxOutput = async (\n sandbox: SandboxSession,\n outputDir: string,\n policy: SkillOutputPolicy,\n signal?: AbortSignal,\n): Promise<Result<ReadonlyArray<CollectedFile>, SkillRunError>> => {\n const before = await inventory(sandbox, outputDir, signal)\n if (before._tag === 'Err')\n return before\n\n const files: CollectedFile[] = []\n const seen = new Set<string>()\n let totalBytes = 0\n for (const entry of before.value) {\n if (signal?.aborted)\n return err({ _tag: 'Cancelled', message: 'Skill run was cancelled.' })\n const path = normalizeOutputPath(entry.path)\n if (path === null)\n return invalid('Harness output contains an invalid path.', [entry.path])\n if (entry.type === 'd')\n continue\n if (entry.type !== 'f')\n return invalid('Harness output contains a linked or special entry.', [path])\n if (seen.has(path))\n return invalid('Harness output contains duplicate paths.', [path])\n if (files.length >= policy.maxOutputFiles)\n return invalid('Harness output contains too many files.', [`Limit: ${policy.maxOutputFiles}`])\n if (entry.size > policy.maxOutputFileBytes)\n return invalid('Harness output contains an oversized file.', [path])\n if (totalBytes + entry.size > policy.maxOutputBytes)\n return invalid('Harness output exceeds the total byte limit.', [`Limit: ${policy.maxOutputBytes}`])\n\n const content = await Promise.resolve().then(() => sandbox.readBinaryFile({ path: `${outputDir}/${path}`, abortSignal: signal })).catch(error => error as Error)\n if (content instanceof Error) {\n if (signal?.aborted)\n return err({ _tag: 'Cancelled', message: 'Skill run was cancelled.' })\n return invalid('Harness output cannot be read.', [path, content.message])\n }\n if (content === null || content.byteLength !== entry.size)\n return invalid('Harness output changed during collection.', [path])\n seen.add(path)\n files.push({ path, content: Uint8Array.from(content) })\n totalBytes += content.byteLength\n }\n\n const after = await inventory(sandbox, outputDir, signal)\n if (after._tag === 'Err')\n return after\n if (JSON.stringify(before.value) !== JSON.stringify(after.value))\n return invalid('Harness output changed during collection.', ['File inventory changed.'])\n\n files.sort((left, right) => left.path.localeCompare(right.path))\n return ok(files)\n}\n","import type { GeneratedSkill, SkillRunError, SourceAttempt } from '../../types.ts'\nimport type { Result } from '../result.ts'\nimport type { CollectedFile } from './collect.ts'\nimport { randomUUID } from 'node:crypto'\nimport { lstat, mkdir, open, realpath, rename, rm, rmdir, unlink, writeFile } from 'node:fs/promises'\nimport { dirname, join, resolve } from 'node:path'\nimport { err, ok } from '../result.ts'\n\nfunction pathError(message: string, path: string): Result<never, SkillRunError> {\n return err({ _tag: 'UnsafeOutputPath', message, path })\n}\n\nconst missing = Symbol('missing')\n\nasync function statOrMissing(path: string) {\n return lstat(path).catch(error => (error as NodeJS.ErrnoException).code === 'ENOENT' ? missing : Promise.reject(error))\n}\n\nexport const promoteSkill = async (\n rootDir: string,\n name: string,\n files: ReadonlyArray<CollectedFile>,\n attempts: ReadonlyArray<SourceAttempt>,\n): Promise<Result<GeneratedSkill, SkillRunError>> => {\n const root = resolve(rootDir)\n let rootStat = await statOrMissing(root).catch(error => error as Error)\n if (rootStat instanceof Error)\n return pathError('Output root cannot be inspected.', root)\n let createdRoot = false\n if (rootStat === missing) {\n const parent = dirname(root)\n const parentStat = await statOrMissing(parent).catch(error => error as Error)\n if (parentStat instanceof Error || parentStat === missing || !parentStat.isDirectory() || parentStat.isSymbolicLink())\n return pathError('Output root parent must be an existing directory.', parent)\n const canonicalParent = await realpath(parent).catch(error => error as Error)\n if (canonicalParent instanceof Error || canonicalParent !== parent)\n return pathError('Output root parent must not pass through a symbolic link.', parent)\n const created = await mkdir(root, { mode: 0o700 }).then(() => true, error => error as NodeJS.ErrnoException)\n if (created instanceof Error && created.code !== 'EEXIST')\n return pathError('Output root cannot be created.', root)\n createdRoot = created === true\n rootStat = await statOrMissing(root).catch(error => error as Error)\n }\n if (rootStat instanceof Error || rootStat === missing || !rootStat.isDirectory() || rootStat.isSymbolicLink())\n return pathError('Output root must be a directory, not a symbolic link.', root)\n const canonicalRoot = await realpath(root).catch(error => error as Error)\n if (canonicalRoot instanceof Error)\n return pathError('Output root cannot be resolved.', root)\n if (canonicalRoot !== root)\n return pathError('Output root must not pass through a symbolic link.', root)\n\n const target = join(root, name)\n const targetStat = await statOrMissing(target).catch(error => error as Error)\n if (targetStat instanceof Error)\n return pathError('Output path cannot be inspected.', target)\n if (targetStat !== missing && (!targetStat.isDirectory() || targetStat.isSymbolicLink()))\n return pathError('Output path must be a directory, not a symbolic link.', target)\n\n const lockPath = join(root, `.skilld-${name}.lock`)\n const lock = await open(lockPath, 'wx').catch(error => error as NodeJS.ErrnoException)\n if (lock instanceof Error) {\n if (lock.code === 'EEXIST')\n return err({ _tag: 'OutputBusy', message: 'Another Skill run owns this output path.', path: target })\n return err({ _tag: 'PromotionFailed', message: 'Output lock could not be created.', path: target, cause: lock })\n }\n\n const nonce = randomUUID()\n const staging = join(root, `.skilld-${name}-${nonce}.next`)\n const backup = join(root, `.skilld-${name}-${nonce}.previous`)\n let movedCurrent = false\n let promoted = false\n let failureMessage = 'Skill output could not be promoted.'\n let failureCause: unknown\n\n try {\n await mkdir(staging, { mode: 0o700 })\n for (const file of files) {\n const destination = join(staging, file.path)\n await mkdir(dirname(destination), { recursive: true, mode: 0o700 })\n await writeFile(destination, file.content, { flag: 'wx', mode: 0o600 })\n }\n\n if (targetStat !== missing) {\n await rename(target, backup)\n movedCurrent = true\n }\n await rename(staging, target)\n promoted = true\n }\n catch (cause) {\n failureCause = cause\n if (movedCurrent && !promoted) {\n const current = await statOrMissing(target).catch(error => error as Error)\n if (current instanceof Error) {\n failureMessage = 'Skill output rollback could not inspect its destination.'\n failureCause = new AggregateError([cause, current])\n }\n if (current === missing) {\n const rollback = await rename(backup, target).catch(error => error as Error)\n if (rollback instanceof Error) {\n failureMessage = 'Skill output rollback failed.'\n failureCause = new AggregateError([cause, rollback])\n }\n }\n }\n }\n\n const lockCleanupErrors: unknown[] = []\n await lock.close().catch(error => lockCleanupErrors.push(error))\n await unlink(lockPath).catch(error => lockCleanupErrors.push(error))\n\n if (promoted) {\n const warnings: string[] = []\n if (lockCleanupErrors.length > 0) {\n const detail = lockCleanupErrors.map(error => error instanceof Error ? error.message : String(error)).join('; ')\n warnings.push(`Output lock cleanup failed at ${lockPath}: ${detail}`)\n }\n if (movedCurrent) {\n const backupCleanup = await rm(backup, { recursive: true }).catch(error => error as Error)\n if (backupCleanup instanceof Error)\n warnings.push(`Previous Skill cleanup failed at ${backup}: ${backupCleanup.message}`)\n }\n return ok({\n _tag: 'GeneratedSkill',\n name,\n outputDir: target,\n files: files.map(file => ({ path: file.path, bytes: file.content.byteLength })),\n sourceAttempts: attempts,\n warnings,\n })\n }\n\n const cleanupErrors = [...lockCleanupErrors]\n await rm(staging, { recursive: true, force: true }).catch(error => cleanupErrors.push(error))\n if (createdRoot)\n await rmdir(root).catch(error => cleanupErrors.push(error))\n const causes = failureCause === undefined ? cleanupErrors : [failureCause, ...cleanupErrors]\n const cause = causes.length <= 1 ? causes[0] : new AggregateError(causes, 'Skill output cleanup failed.')\n return err({ _tag: 'PromotionFailed', message: failureMessage, path: target, cause })\n}\n","import type { SkillReview, SkillReviewFinding, SkillRunError } from '../../types.ts'\nimport type { Result } from '../result.ts'\nimport type { CollectedFile } from './collect.ts'\nimport { parseDocument } from 'yaml'\nimport { isSkillName, normalizeOutputPath } from '../paths.ts'\nimport { err, ok } from '../result.ts'\n\nconst allowedFrontmatter = new Set([\n 'name',\n 'description',\n 'license',\n 'compatibility',\n 'metadata',\n 'allowed-tools',\n])\n\nconst invalid = (issues: ReadonlyArray<string>): Result<never, SkillRunError> =>\n err({ _tag: 'InvalidSkill', message: 'Skill output failed deterministic checks.', issues })\n\nfunction decodeText(content: Uint8Array): string | null {\n try {\n return new TextDecoder('utf-8', { fatal: true }).decode(content)\n }\n catch {\n return null\n }\n}\n\nconst isStringMap = (value: unknown): boolean =>\n value !== null\n && typeof value === 'object'\n && !Array.isArray(value)\n && Object.values(value).every(item => typeof item === 'string')\n\nexport const validateGeneratedSkill = (\n name: string,\n files: ReadonlyArray<CollectedFile>,\n): Result<void, SkillRunError> => {\n const issues: string[] = []\n const skillFiles = files.filter(file => file.path === 'SKILL.md')\n if (skillFiles.length !== 1)\n return invalid(['Output must contain exactly one SKILL.md file.'])\n\n const source = decodeText(skillFiles[0]!.content)\n if (source === null)\n return invalid(['SKILL.md must contain valid UTF-8 text.'])\n const match = source.match(/^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n([\\s\\S]*)$/)\n if (!match)\n return invalid(['SKILL.md must start with YAML frontmatter.'])\n if (match[2]?.trim().length === 0)\n issues.push('SKILL.md instructions must not be empty.')\n\n const document = parseDocument(match[1]!, { uniqueKeys: true })\n for (const error of document.errors)\n issues.push(`Frontmatter: ${error.message}`)\n for (const warning of document.warnings)\n issues.push(`Frontmatter: ${warning.message}`)\n\n const value = document.errors.length === 0 ? document.toJS() as unknown : null\n if (!value || typeof value !== 'object' || Array.isArray(value)) {\n issues.push('Frontmatter must be a mapping.')\n return invalid(issues)\n }\n\n const frontmatter = value as Record<string, unknown>\n for (const key of Object.keys(frontmatter)) {\n if (!allowedFrontmatter.has(key))\n issues.push(`Frontmatter field is not supported: ${key}`)\n }\n if (frontmatter.name !== name)\n issues.push('Frontmatter name must match the Skill directory name.')\n if (typeof frontmatter.name !== 'string' || !isSkillName(frontmatter.name))\n issues.push('Frontmatter name is invalid.')\n if (typeof frontmatter.description !== 'string' || frontmatter.description.trim().length === 0 || frontmatter.description.length > 1024)\n issues.push('Frontmatter description must contain 1 to 1024 characters.')\n if (frontmatter.license !== undefined && typeof frontmatter.license !== 'string')\n issues.push('Frontmatter license must be a string.')\n if (frontmatter.compatibility !== undefined && (typeof frontmatter.compatibility !== 'string' || frontmatter.compatibility.length > 500))\n issues.push('Frontmatter compatibility must be a string of at most 500 characters.')\n if (frontmatter.metadata !== undefined && !isStringMap(frontmatter.metadata))\n issues.push('Frontmatter metadata must map strings to strings.')\n if (frontmatter['allowed-tools'] !== undefined && typeof frontmatter['allowed-tools'] !== 'string')\n issues.push('Frontmatter allowed-tools must be a string.')\n\n return issues.length === 0 ? ok(undefined) : invalid(issues)\n}\n\nconst findingLevels = new Set(['error', 'warning', 'note'])\n\nexport const validateSkillReview = (\n files: ReadonlyArray<CollectedFile>,\n): Result<SkillReview, SkillRunError> => {\n if (files.length !== 1 || files[0]?.path !== 'review.json')\n return invalid(['Review output must contain only review.json.'])\n\n let value: unknown\n try {\n const source = decodeText(files[0].content)\n if (source === null)\n return invalid(['review.json must contain valid UTF-8 text.'])\n value = JSON.parse(source)\n }\n catch {\n return invalid(['review.json must contain valid JSON.'])\n }\n if (!value || typeof value !== 'object' || Array.isArray(value))\n return invalid(['review.json must contain an object.'])\n\n const review = value as Record<string, unknown>\n if (Object.keys(review).some(key => key !== 'summary' && key !== 'findings'))\n return invalid(['review.json contains unsupported fields.'])\n if (typeof review.summary !== 'string' || review.summary.trim().length === 0)\n return invalid(['Review summary is required.'])\n if (!Array.isArray(review.findings))\n return invalid(['Review findings must be an array.'])\n\n const findings: SkillReviewFinding[] = []\n for (const item of review.findings) {\n if (!item || typeof item !== 'object' || Array.isArray(item))\n return invalid(['Each review finding must be an object.'])\n const finding = item as Record<string, unknown>\n if (Object.keys(finding).some(key => !['level', 'path', 'message', 'fix'].includes(key)))\n return invalid(['A review finding contains unsupported fields.'])\n if (typeof finding.level !== 'string' || !findingLevels.has(finding.level))\n return invalid(['A review finding level is invalid.'])\n if (typeof finding.path !== 'string' || normalizeOutputPath(finding.path) === null)\n return invalid(['A review finding path is invalid.'])\n if (typeof finding.message !== 'string' || finding.message.trim().length === 0 || typeof finding.fix !== 'string' || finding.fix.trim().length === 0)\n return invalid(['A review finding is incomplete.'])\n findings.push(finding as unknown as SkillReviewFinding)\n }\n\n return ok({ _tag: 'SkillReview', summary: review.summary, findings })\n}\n","import type { SkillOutputPolicy, SkillRunError, SourceAttempt } from '../../types.ts'\nimport type { Result } from '../result.ts'\nimport { constants } from 'node:fs'\nimport { lstat, open, opendir, realpath } from 'node:fs/promises'\nimport { join, relative, resolve, sep } from 'node:path'\nimport { err, ok } from '../result.ts'\n\nexport interface PreparedFile {\n readonly path: string\n readonly content: Uint8Array\n}\n\nexport interface PreparedSource {\n readonly files: ReadonlyArray<PreparedFile>\n readonly attempts: ReadonlyArray<SourceAttempt>\n readonly npmResolution?: {\n readonly package: string\n readonly version: string\n }\n}\n\nconst ignoredNames = new Set([\n '.git',\n '.hg',\n '.next',\n '.nuxt',\n '.output',\n '.skilld',\n '.turbo',\n 'coverage',\n 'dist',\n 'node_modules',\n 'target',\n])\n\nexport async function collectHostDirectory(directory: string, policy: SkillOutputPolicy, sourceLabel = directory, signal?: AbortSignal): Promise<Result<PreparedSource, SkillRunError>> {\n const root = resolve(directory)\n const unavailable = (message: string, cause?: unknown): Result<never, SkillRunError> => err({\n _tag: 'SourceUnavailable',\n message,\n attempts: [{ source: sourceLabel, status: 'skipped', reason: message }],\n cause,\n })\n const cancelled = (): Result<never, SkillRunError> => err({ _tag: 'Cancelled', message: 'Skill run was cancelled.' })\n if (signal?.aborted)\n return cancelled()\n const rootStat = await lstat(root).catch(error => error as NodeJS.ErrnoException)\n if (rootStat instanceof Error)\n return unavailable('Source directory is unavailable.', rootStat)\n if (!rootStat.isDirectory() || rootStat.isSymbolicLink())\n return unavailable('Source path must be a directory, not a symbolic link.')\n const canonicalRoot = await realpath(root).catch(error => error as NodeJS.ErrnoException)\n if (canonicalRoot instanceof Error)\n return unavailable('Source directory cannot be resolved.', canonicalRoot)\n if (canonicalRoot !== root)\n return unavailable('Source path must not pass through a symbolic link.')\n\n const files: PreparedFile[] = []\n let totalBytes = 0\n\n const walk = async (current: string): Promise<Result<void, SkillRunError>> => {\n if (signal?.aborted)\n return cancelled()\n const canonicalCurrent = await realpath(current).catch(error => error as NodeJS.ErrnoException)\n if (canonicalCurrent instanceof Error || canonicalCurrent !== current)\n return unavailable('Source directory changed during collection.', canonicalCurrent instanceof Error ? canonicalCurrent : undefined)\n const directoryHandle = await opendir(current).catch(error => error as NodeJS.ErrnoException)\n if (directoryHandle instanceof Error)\n return unavailable('Source directory cannot be read.', directoryHandle)\n\n for await (const entry of directoryHandle) {\n if (signal?.aborted)\n return cancelled()\n if (ignoredNames.has(entry.name))\n continue\n const absolute = join(current, entry.name)\n const stat = await lstat(absolute).catch(error => error as NodeJS.ErrnoException)\n if (stat instanceof Error)\n return unavailable('Source entry cannot be read.', stat)\n if (stat.isSymbolicLink())\n return unavailable('Source contains a symbolic link.')\n if (stat.isDirectory()) {\n const nested = await walk(absolute)\n if (nested._tag === 'Err')\n return nested\n continue\n }\n if (!stat.isFile())\n return unavailable('Source contains a special file.')\n\n const path = relative(root, absolute).split(sep).join('/')\n const handle = await open(absolute, constants.O_RDONLY | constants.O_NOFOLLOW).catch(error => error as NodeJS.ErrnoException)\n if (handle instanceof Error)\n return unavailable('Source file cannot be opened without following links.', handle)\n const openedStat = await handle.stat().catch(error => error as NodeJS.ErrnoException)\n if (openedStat instanceof Error) {\n await handle.close()\n return unavailable('Source file cannot be inspected.', openedStat)\n }\n if (!openedStat.isFile() || openedStat.dev !== stat.dev || openedStat.ino !== stat.ino) {\n await handle.close()\n return unavailable('Source file changed during collection.')\n }\n if (openedStat.size > policy.maxSourceFileBytes) {\n await handle.close()\n continue\n }\n if (files.length >= policy.maxSourceFiles) {\n await handle.close()\n return unavailable('Source contains too many files.')\n }\n if (totalBytes + openedStat.size > policy.maxSourceBytes) {\n await handle.close()\n return unavailable('Source exceeds the total byte limit.')\n }\n\n const content = await handle.readFile().catch(error => error as NodeJS.ErrnoException)\n await handle.close()\n if (content instanceof Error)\n return unavailable('Source file cannot be read.', content)\n if (content.byteLength !== openedStat.size)\n return unavailable('Source file changed during collection.')\n if (signal?.aborted)\n return cancelled()\n files.push({ path, content })\n totalBytes += content.byteLength\n }\n return ok(undefined)\n }\n\n const walked = await walk(root)\n if (walked._tag === 'Err')\n return walked\n if (files.length === 0)\n return unavailable('Source directory has no usable files.')\n\n files.sort((left, right) => left.path.localeCompare(right.path))\n return ok({ files, attempts: [{ source: sourceLabel, status: 'used' }] })\n}\n","import type { SkillOutputPolicy, SkillRunError } from '../../types.ts'\nimport type { Result } from '../result.ts'\nimport type { PreparedFile } from './host.ts'\nimport { Readable } from 'node:stream'\nimport { createGunzip } from 'node:zlib'\nimport { normalizeOutputPath } from '../paths.ts'\nimport { err, ok } from '../result.ts'\n\nconst blockBytes = 512\n\nexport type ArchiveLayout = 'npm' | 'github'\n\ninterface PendingEntry {\n readonly kind: 'directory' | 'file' | 'metadata' | 'skip'\n readonly path?: string\n readonly metadataType?: 'long-path' | 'pax'\n readonly size: number\n remaining: number\n padding: number\n readonly chunks: Array<Buffer<ArrayBufferLike>>\n}\n\nfunction unavailable(message: string, cause?: unknown): Result<never, SkillRunError> {\n return err({ _tag: 'SourceUnavailable', message, attempts: [], cause })\n}\n\nfunction readString(buffer: Uint8Array, start: number, length: number): string {\n const bytes = buffer.subarray(start, start + length)\n const zero = bytes.indexOf(0)\n return Buffer.from(zero === -1 ? bytes : bytes.subarray(0, zero)).toString('utf8').trim()\n}\n\nfunction readOctal(buffer: Uint8Array, start: number, length: number): number | null {\n const value = readString(buffer, start, length).replace(/^\\s+|\\s+$/g, '')\n if (!/^[0-7]+$/.test(value))\n return null\n const parsed = Number.parseInt(value, 8)\n return Number.isSafeInteger(parsed) ? parsed : null\n}\n\nfunction hasValidChecksum(header: Uint8Array): boolean {\n const expected = readOctal(header, 148, 8)\n if (expected === null)\n return false\n let actual = 0\n for (let index = 0; index < header.byteLength; index += 1)\n actual += index >= 148 && index < 156 ? 32 : header[index]!\n return actual === expected\n}\n\nfunction parsePaxPath(content: Uint8Array): string | null {\n const text = Buffer.from(content).toString('utf8')\n let offset = 0\n let path: string | null = null\n while (offset < text.length) {\n const space = text.indexOf(' ', offset)\n if (space === -1)\n return null\n const length = Number.parseInt(text.slice(offset, space), 10)\n if (!Number.isSafeInteger(length) || length <= 0 || offset + length > text.length)\n return null\n const record = text.slice(space + 1, offset + length - 1)\n const equals = record.indexOf('=')\n if (equals !== -1 && record.slice(0, equals) === 'path')\n path = record.slice(equals + 1)\n offset += length\n }\n return path\n}\n\nfunction archivePath(value: string, layout: ArchiveLayout): string | null {\n const normalized = normalizeOutputPath(value)\n if (normalized === null)\n return null\n const segments = normalized.split('/')\n if (layout === 'npm') {\n if (segments[0] !== 'package' || segments.length < 2)\n return null\n }\n else if (segments.length < 2) {\n return null\n }\n return normalizeOutputPath(segments.slice(1).join('/'))\n}\n\nfunction entryContent(entry: PendingEntry): Buffer<ArrayBufferLike> {\n return entry.chunks.length === 1\n ? entry.chunks[0]!\n : Buffer.concat(entry.chunks, entry.size)\n}\n\nexport async function extractArchive(\n compressed: AsyncIterable<Uint8Array>,\n policy: SkillOutputPolicy,\n layout: ArchiveLayout,\n): Promise<Result<ReadonlyArray<PreparedFile>, SkillRunError>> {\n const source = Readable.from(compressed)\n const gunzip = createGunzip()\n source.on('error', error => gunzip.destroy(error))\n source.pipe(gunzip)\n const files: PreparedFile[] = []\n const seen = new Set<string>()\n const maxArchiveBytes = policy.maxSourceBytes + (policy.maxSourceFiles + 2) * blockBytes * 2\n let archiveBytes = 0\n let fileEntries = 0\n let nextPath: string | null = null\n let pending: Buffer<ArrayBufferLike> = Buffer.alloc(0)\n let entry: PendingEntry | null = null\n let totalBytes = 0\n let ended = false\n\n try {\n for await (const value of gunzip) {\n const chunk = Buffer.isBuffer(value) ? value : Buffer.from(value as Uint8Array)\n archiveBytes += chunk.byteLength\n if (archiveBytes > maxArchiveBytes)\n return unavailable('Source archive exceeds the uncompressed byte limit.')\n pending = pending.byteLength === 0 ? chunk : Buffer.concat([pending, chunk])\n\n while (pending.byteLength > 0) {\n if (ended) {\n if (pending.some(byte => byte !== 0))\n return unavailable('Source archive has data after its end marker.')\n pending = Buffer.alloc(0)\n break\n }\n\n if (entry !== null) {\n if (entry.remaining > 0) {\n const consumed = Math.min(entry.remaining, pending.byteLength)\n if (entry.kind === 'file' || entry.kind === 'metadata')\n entry.chunks.push(pending.subarray(0, consumed))\n pending = pending.subarray(consumed)\n entry.remaining -= consumed\n if (entry.remaining > 0)\n break\n }\n if (entry.padding > 0) {\n const consumed = Math.min(entry.padding, pending.byteLength)\n pending = pending.subarray(consumed)\n entry.padding -= consumed\n if (entry.padding > 0)\n break\n }\n\n if (entry.kind === 'metadata') {\n const content = entryContent(entry)\n nextPath = entry.metadataType === 'pax'\n ? parsePaxPath(content)\n : content.toString('utf8').replace(/\\0.*$/s, '').trim()\n if (nextPath === null || nextPath.length === 0)\n return unavailable('Source archive has invalid path metadata.')\n }\n else if (entry.kind === 'file' && entry.path) {\n files.push({ path: entry.path, content: Uint8Array.from(entryContent(entry)) })\n totalBytes += entry.size\n }\n entry = null\n continue\n }\n\n if (pending.byteLength < blockBytes)\n break\n const header = pending.subarray(0, blockBytes)\n pending = pending.subarray(blockBytes)\n if (header.every(byte => byte === 0)) {\n ended = true\n continue\n }\n if (!hasValidChecksum(header))\n return unavailable('Source archive has an invalid header checksum.')\n\n const size = readOctal(header, 124, 12)\n if (size === null)\n return unavailable('Source archive has an invalid entry size.')\n const name = readString(header, 0, 100)\n const prefix = readString(header, 345, 155)\n const headerPath = prefix.length > 0 ? `${prefix}/${name}` : name\n const type = String.fromCharCode(header[156] ?? 0)\n const padding = (blockBytes - size % blockBytes) % blockBytes\n\n if (type === 'x' || type === 'L') {\n if (size > policy.maxSourceFileBytes)\n return unavailable('Source archive path metadata exceeds the file byte limit.')\n entry = {\n kind: 'metadata',\n metadataType: type === 'x' ? 'pax' : 'long-path',\n size,\n remaining: size,\n padding,\n chunks: [],\n }\n continue\n }\n if (type === '5') {\n nextPath = null\n entry = { kind: 'directory', size, remaining: size, padding, chunks: [] }\n continue\n }\n if (type !== '0' && type !== '\\0')\n return unavailable('Source archive contains a linked or special entry.')\n\n const path = archivePath(nextPath ?? headerPath, layout)\n nextPath = null\n if (path === null)\n return unavailable('Source archive contains an invalid path.')\n if (seen.has(path))\n return unavailable('Source archive contains duplicate paths.')\n seen.add(path)\n fileEntries += 1\n if (fileEntries > policy.maxSourceFiles)\n return unavailable('Source archive contains too many files.')\n if (size <= policy.maxSourceFileBytes && totalBytes + size > policy.maxSourceBytes)\n return unavailable('Source archive exceeds the total byte limit.')\n\n entry = {\n kind: size > policy.maxSourceFileBytes ? 'skip' : 'file',\n path,\n size,\n remaining: size,\n padding,\n chunks: [],\n }\n }\n }\n }\n catch (cause) {\n const message = cause instanceof Error ? cause.message : ''\n return unavailable(message.startsWith('Source archive ')\n ? message\n : 'Source archive is not valid gzip data.', cause)\n }\n\n if (entry !== null || pending.some(byte => byte !== 0) || !ended)\n return unavailable('Source archive ended before its final entry.')\n if (files.length === 0)\n return unavailable('Source archive has no usable files.')\n files.sort((left, right) => left.path.localeCompare(right.path))\n return ok(files)\n}\n","import type { Hash } from 'node:crypto'\nimport type { SkillOutputPolicy, SkillRunError, SourceAttempt } from '../../types.ts'\nimport type { Result } from '../result.ts'\nimport type { PreparedFile, PreparedSource } from './host.ts'\nimport { createHash } from 'node:crypto'\nimport { posix } from 'node:path'\nimport { err, ok } from '../result.ts'\nimport { extractArchive } from './archive.ts'\n\ninterface NpmDist {\n readonly tarball: string\n readonly integrity?: string\n readonly shasum?: string\n}\n\ninterface NpmRepository {\n readonly type?: string\n readonly url?: string\n}\n\ninterface NpmVersion {\n readonly version: string\n readonly dist: NpmDist\n readonly gitHead?: string\n readonly repository?: NpmRepository | string\n}\n\ninterface IntegrityVerifier {\n readonly update: (content: Uint8Array) => void\n readonly valid: () => boolean\n}\n\nconst packageSpecPattern = /^(@[^/@]+\\/[^/@]+|[^/@]+)(?:@(\\S+))?$/\nconst exactVersionPattern = /^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-[\\da-z-]+(?:\\.[\\da-z-]+)*)?(?:\\+[\\da-z-]+(?:\\.[\\da-z-]+)*)?$/i\nconst gitCommitPattern = /^[0-9a-f]{40}$/i\nconst npmRequestTimeoutMs = 30_000\nconst npmRedirectLimit = 3\nconst packumentByteLimit = 10 * 1024 * 1024\n\nexport type FetchClient = (input: string | URL | Request, init?: RequestInit) => Promise<Response>\n\nfunction unavailable(message: string, attempts: ReadonlyArray<SourceAttempt>, cause?: unknown): Result<never, SkillRunError> {\n return err({ _tag: 'SourceUnavailable', message, attempts, cause })\n}\n\nfunction parsePackageSpec(spec: string): { name: string, version: string } | null {\n const match = spec.match(packageSpecPattern)\n return match?.[1] ? { name: match[1], version: match[2] ?? 'latest' } : null\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\nfunction parseRepository(value: unknown): NpmRepository | string | undefined {\n if (typeof value === 'string')\n return value\n if (!isRecord(value))\n return undefined\n return {\n type: typeof value.type === 'string' ? value.type : undefined,\n url: typeof value.url === 'string' ? value.url : undefined,\n }\n}\n\nfunction parseVersion(packument: unknown, requested: string): { resolvedVersion: string, version: NpmVersion, repository?: NpmRepository | string } | null {\n if (!isRecord(packument) || !isRecord(packument['dist-tags']) || !isRecord(packument.versions))\n return null\n const tagged = packument['dist-tags'][requested]\n const resolvedVersion = typeof tagged === 'string' ? tagged : requested\n const value = packument.versions[resolvedVersion]\n if (!isRecord(value) || typeof value.version !== 'string' || !isRecord(value.dist) || typeof value.dist.tarball !== 'string')\n return null\n return {\n resolvedVersion,\n repository: parseRepository(packument.repository),\n version: {\n version: value.version,\n gitHead: typeof value.gitHead === 'string' ? value.gitHead : undefined,\n repository: parseRepository(value.repository),\n dist: {\n tarball: value.dist.tarball,\n integrity: typeof value.dist.integrity === 'string' ? value.dist.integrity : undefined,\n shasum: typeof value.dist.shasum === 'string' ? value.dist.shasum : undefined,\n },\n },\n }\n}\n\nasync function cancelBody(response: Response): Promise<void> {\n if (!response.body)\n return\n // A failed cleanup cannot replace the source failure.\n await response.body.cancel().catch(() => undefined)\n}\n\nfunction declaredBytes(response: Response): number | null {\n const value = response.headers.get('content-length')\n if (value === null || !/^\\d+$/.test(value))\n return null\n const bytes = Number(value)\n return Number.isSafeInteger(bytes) ? bytes : null\n}\n\nasync function* responseChunks(\n response: Response,\n maxBytes: number,\n limitMessage: string,\n onChunk: (content: Uint8Array) => void = () => {},\n): AsyncGenerator<Uint8Array> {\n const declared = declaredBytes(response)\n if (declared !== null && declared > maxBytes) {\n await cancelBody(response)\n throw new Error(limitMessage)\n }\n if (!response.body)\n return\n\n const reader = response.body.getReader()\n let complete = false\n let totalBytes = 0\n try {\n while (true) {\n const result = await reader.read()\n if (result.done) {\n complete = true\n return\n }\n totalBytes += result.value.byteLength\n if (totalBytes > maxBytes)\n throw new Error(limitMessage)\n onChunk(result.value)\n yield result.value\n }\n }\n finally {\n if (!complete) {\n // A failed cleanup cannot replace the source failure.\n await reader.cancel().catch(() => undefined)\n }\n reader.releaseLock()\n }\n}\n\nasync function readBoundedResponse(response: Response, maxBytes: number): Promise<Result<Uint8Array, SkillRunError>> {\n const chunks: Uint8Array[] = []\n let totalBytes = 0\n try {\n for await (const chunk of responseChunks(response, maxBytes, 'npm response exceeds the byte limit.')) {\n chunks.push(chunk)\n totalBytes += chunk.byteLength\n }\n }\n catch (cause) {\n return unavailable(cause instanceof Error ? cause.message : 'npm response cannot be read.', [], cause)\n }\n return ok(Uint8Array.from(Buffer.concat(chunks, totalBytes)))\n}\n\nasync function fetchWithRedirects(fetchClient: FetchClient, url: string, init: RequestInit = {}, signal?: AbortSignal): Promise<Result<Response, SkillRunError>> {\n const timeout = AbortSignal.timeout(npmRequestTimeoutMs)\n const requestSignal = signal ? AbortSignal.any([signal, timeout]) : timeout\n let current = url\n for (let redirects = 0; redirects <= npmRedirectLimit; redirects += 1) {\n const response = await fetchClient(current, { ...init, redirect: 'manual', signal: requestSignal }).catch(error => error as Error)\n if (response instanceof Error)\n return unavailable(timeout.aborted ? 'npm request timed out.' : 'npm request failed.', [], response)\n if (![301, 302, 303, 307, 308].includes(response.status))\n return ok(response)\n if (redirects === npmRedirectLimit) {\n await cancelBody(response)\n return unavailable('npm request exceeded the redirect limit.', [])\n }\n const location = response.headers.get('location')\n if (!location) {\n await cancelBody(response)\n return unavailable('npm redirect is missing its location.', [])\n }\n const redirected = await Promise.resolve().then(() => new URL(location, current)).catch(() => null)\n if (redirected === null) {\n await cancelBody(response)\n return unavailable('npm redirect location is invalid.', [])\n }\n if (redirected.protocol !== 'https:') {\n await cancelBody(response)\n return unavailable('npm redirect URL must use HTTPS.', [])\n }\n await cancelBody(response)\n current = redirected.href\n }\n return unavailable('npm request exceeded the redirect limit.', [])\n}\n\nfunction createIntegrityVerifier(dist: NpmDist): IntegrityVerifier | null {\n const values = dist.integrity?.split(/\\s+/).filter(Boolean) ?? []\n let expected = values.flatMap((value) => {\n const match = value.match(/^(sha(?:1|256|384|512))-([A-Za-z0-9+/=]+)$/)\n return match?.[1] && match[2] ? [{ algorithm: match[1], digest: match[2] }] : []\n })\n if (expected.length > 0) {\n const strength = { sha1: 1, sha256: 2, sha384: 3, sha512: 4 } as const\n const strongest = Math.max(...expected.map(value => strength[value.algorithm as keyof typeof strength]))\n expected = expected.filter(value => strength[value.algorithm as keyof typeof strength] === strongest)\n }\n if (values.length === 0 && dist.shasum && /^[0-9a-f]{40}$/i.test(dist.shasum))\n expected.push({ algorithm: 'sha1', digest: Buffer.from(dist.shasum, 'hex').toString('base64') })\n if (expected.length === 0)\n return null\n\n const hashes = new Map<string, Hash>()\n for (const value of expected)\n hashes.set(value.algorithm, createHash(value.algorithm))\n return {\n update(content) {\n for (const hash of hashes.values())\n hash.update(content)\n },\n valid() {\n const actual = new Map([...hashes].map(([algorithm, hash]) => [algorithm, hash.digest('base64')]))\n return expected.some(value => actual.get(value.algorithm) === value.digest)\n },\n }\n}\n\nfunction repositoryUrl(repository: NpmRepository | string | undefined): string | null {\n if (typeof repository === 'string')\n return repository\n return typeof repository?.url === 'string' ? repository.url : null\n}\n\nfunction githubArchiveUrl(repository: NpmRepository | string | undefined, gitHead: string | undefined): string | null {\n if (!gitHead || !gitCommitPattern.test(gitHead))\n return null\n const source = repositoryUrl(repository)\n if (source === null)\n return null\n const match = source.match(/^(?:(?:git\\+)?https?:\\/\\/(?:git@)?github\\.com\\/|git:\\/\\/github\\.com\\/|git@github\\.com:)([\\w.-]+)\\/([\\w.-]+?)(?:\\.git)?\\/?$/)\n if (!match?.[1] || !match[2])\n return null\n return `https://codeload.github.com/${encodeURIComponent(match[1])}/${encodeURIComponent(match[2])}/tar.gz/${gitHead}`\n}\n\nfunction skipped(source: string, reason: string): SourceAttempt {\n return { source, status: 'skipped', reason }\n}\n\nfunction used(source: string): SourceAttempt {\n return { source, status: 'used' }\n}\n\nfunction withAttempts(error: SkillRunError, attempts: ReadonlyArray<SourceAttempt>): Result<never, SkillRunError> {\n return error._tag === 'SourceUnavailable'\n ? unavailable(error.message, attempts, error.cause)\n : err(error)\n}\n\nfunction remainingPolicy(policy: SkillOutputPolicy, files: ReadonlyArray<PreparedFile>): SkillOutputPolicy | null {\n const usedBytes = files.reduce((total, file) => total + file.content.byteLength, 0)\n const maxSourceFiles = policy.maxSourceFiles - files.length\n const maxSourceBytes = policy.maxSourceBytes - usedBytes\n if (maxSourceFiles <= 0 || maxSourceBytes <= 0)\n return null\n return { ...policy, maxSourceFiles, maxSourceBytes }\n}\n\nasync function extractResponse(\n response: Response,\n policy: SkillOutputPolicy,\n layout: 'github' | 'npm',\n verifier?: IntegrityVerifier,\n): Promise<Result<ReadonlyArray<PreparedFile>, SkillRunError>> {\n return extractArchive(\n responseChunks(\n response,\n policy.maxSourceBytes,\n 'Source archive exceeds the compressed byte limit.',\n content => verifier?.update(content),\n ),\n policy,\n layout,\n )\n}\n\nexport async function prepareNpmPackage(spec: string, policy: SkillOutputPolicy, fetchClient: FetchClient, signal?: AbortSignal): Promise<Result<PreparedSource, SkillRunError>> {\n const parsed = parsePackageSpec(spec)\n if (parsed === null)\n return unavailable('npm package spec is invalid.', [])\n\n const attempts: SourceAttempt[] = []\n const registryUrl = `https://registry.npmjs.org/${encodeURIComponent(parsed.name)}`\n const registryResponse = await fetchWithRedirects(fetchClient, registryUrl, {\n headers: { accept: 'application/vnd.npm.install-v1+json' },\n }, signal)\n if (registryResponse._tag === 'Err')\n return withAttempts(registryResponse.error, [skipped(registryUrl, registryResponse.error.message)])\n const response = registryResponse.value\n if (!response.ok) {\n await cancelBody(response)\n const message = `npm registry returned HTTP ${response.status}.`\n return unavailable(message, [skipped(registryUrl, message)])\n }\n\n const packumentBytes = await readBoundedResponse(response, packumentByteLimit)\n if (packumentBytes._tag === 'Err')\n return withAttempts(packumentBytes.error, [skipped(registryUrl, packumentBytes.error.message)])\n\n let packument: unknown\n try {\n packument = JSON.parse(Buffer.from(packumentBytes.value).toString('utf8')) as unknown\n }\n catch (cause) {\n const message = 'npm registry returned invalid package data.'\n return unavailable(message, [skipped(registryUrl, message)], cause)\n }\n\n const resolution = parseVersion(packument, parsed.version)\n if (resolution === null || !exactVersionPattern.test(resolution.resolvedVersion) || resolution.version.version !== resolution.resolvedVersion) {\n const message = 'npm package did not resolve to an exact version.'\n return unavailable(message, [skipped(registryUrl, message)])\n }\n const { repository, resolvedVersion, version } = resolution\n if (!version.dist.tarball.startsWith('https://')) {\n const message = 'npm package archive URL must use HTTPS.'\n return unavailable(message, [skipped(registryUrl, message)])\n }\n attempts.push(used(registryUrl))\n\n const fetchedArchive = await fetchWithRedirects(fetchClient, version.dist.tarball, {}, signal)\n if (fetchedArchive._tag === 'Err')\n return withAttempts(fetchedArchive.error, [...attempts, skipped(version.dist.tarball, fetchedArchive.error.message)])\n const archiveResponse = fetchedArchive.value\n if (!archiveResponse.ok) {\n await cancelBody(archiveResponse)\n const message = `npm package archive returned HTTP ${archiveResponse.status}.`\n return unavailable(message, [...attempts, skipped(version.dist.tarball, message)])\n }\n\n const verifier = createIntegrityVerifier(version.dist)\n if (verifier === null) {\n await cancelBody(archiveResponse)\n const message = 'npm package archive has no supported integrity value.'\n return unavailable(message, [...attempts, skipped(version.dist.tarball, message)])\n }\n const extracted = await extractResponse(archiveResponse, policy, 'npm', verifier)\n if (extracted._tag === 'Err')\n return withAttempts(extracted.error, [...attempts, skipped(version.dist.tarball, extracted.error.message)])\n if (!verifier.valid()) {\n const message = 'npm package archive integrity check failed.'\n return unavailable(message, [...attempts, skipped(version.dist.tarball, message)])\n }\n attempts.push(used(version.dist.tarball))\n let files = [...extracted.value]\n\n const repositoryArchive = githubArchiveUrl(version.repository ?? repository, version.gitHead)\n const available = remainingPolicy(policy, files)\n if (repositoryArchive !== null && available === null) {\n attempts.push(skipped(repositoryArchive, 'Prepared package files reached the source limit.'))\n }\n else if (repositoryArchive !== null && available !== null) {\n const fetchedRepository = await fetchWithRedirects(fetchClient, repositoryArchive, {}, signal)\n if (fetchedRepository._tag === 'Err') {\n attempts.push(skipped(repositoryArchive, fetchedRepository.error.message))\n }\n else if (!fetchedRepository.value.ok) {\n const message = `GitHub source archive returned HTTP ${fetchedRepository.value.status}.`\n await cancelBody(fetchedRepository.value)\n attempts.push(skipped(repositoryArchive, message))\n }\n else {\n const repositoryFiles = await extractResponse(fetchedRepository.value, available, 'github')\n if (repositoryFiles._tag === 'Err') {\n attempts.push(skipped(repositoryArchive, repositoryFiles.error.message))\n }\n else {\n files = [\n ...files,\n ...repositoryFiles.value.map(file => ({ ...file, path: posix.join('repository', file.path) })),\n ]\n attempts.push(used(repositoryArchive))\n }\n }\n }\n\n files.sort((left, right) => left.path.localeCompare(right.path))\n return ok({\n files,\n attempts,\n npmResolution: { package: parsed.name, version: resolvedVersion },\n })\n}\n","import type { HarnessV1Skill } from '@ai-sdk/harness'\nimport type { SandboxSession } from './internal/output/collect.ts'\nimport type { Result } from './internal/result.ts'\nimport type { PreparedSource } from './internal/source/host.ts'\nimport type { FetchClient } from './internal/source/npm.ts'\nimport type {\n CreateSkillHarnessOptions,\n SkillDestination,\n SkillHarness,\n SkillOutputPolicy,\n SkillRun,\n SkillRunError,\n SkillRunResult,\n} from './types.ts'\nimport { lstat, realpath } from 'node:fs/promises'\nimport { join, posix, resolve } from 'node:path'\nimport { HarnessAgent } from '@ai-sdk/harness/agent'\nimport { parseOutputPolicy, parseSkillRun } from './internal/input.ts'\nimport { collectSandboxOutput } from './internal/output/collect.ts'\nimport { promoteSkill } from './internal/output/promote.ts'\nimport { validateGeneratedSkill, validateSkillReview } from './internal/output/validate.ts'\nimport { resolveWithin } from './internal/paths.ts'\nimport { err, ok } from './internal/result.ts'\nimport { collectHostDirectory } from './internal/source/host.ts'\nimport { prepareNpmPackage } from './internal/source/npm.ts'\nimport { DEFAULT_OUTPUT_POLICY, loadSkilldMaintainedSkill } from './skills.ts'\n\ninterface PreparedRun {\n readonly skillName: 'generate-package-skill' | 'generate-project-skill' | 'review-skill'\n readonly outputName: string\n readonly source: PreparedSource\n readonly current?: PreparedSource\n readonly destination?: SkillDestination\n}\n\ninterface ActiveSandbox {\n readonly sandbox: SandboxSession\n readonly workDir: string\n}\n\nfunction cancelled(): SkillRunResult {\n return err({ _tag: 'Cancelled', message: 'Skill run was cancelled.' })\n}\n\nasync function prepareCurrentSkill(destination: SkillDestination, policy: SkillOutputPolicy, signal?: AbortSignal): Promise<Result<PreparedSource | undefined, SkillRunError>> {\n const root = resolve(destination.rootDir)\n const rootStat = await lstat(root).catch(error => error as NodeJS.ErrnoException)\n if (rootStat instanceof Error) {\n if (rootStat.code === 'ENOENT')\n return ok(undefined)\n return err({ _tag: 'UnsafeOutputPath', message: 'Output root cannot be inspected.', path: root })\n }\n if (!rootStat.isDirectory() || rootStat.isSymbolicLink())\n return err({ _tag: 'UnsafeOutputPath', message: 'Output root must be a directory, not a symbolic link.', path: root })\n const canonicalRoot = await realpath(root).catch(error => error as Error)\n if (canonicalRoot instanceof Error || canonicalRoot !== root)\n return err({ _tag: 'UnsafeOutputPath', message: 'Output root must not pass through a symbolic link.', path: root })\n\n const target = join(root, destination.name)\n const targetStat = await lstat(target).catch(error => error as NodeJS.ErrnoException)\n if (targetStat instanceof Error) {\n if (targetStat.code === 'ENOENT')\n return ok(undefined)\n return err({ _tag: 'UnsafeOutputPath', message: 'Output path cannot be inspected.', path: target })\n }\n if (!targetStat.isDirectory() || targetStat.isSymbolicLink())\n return err({ _tag: 'UnsafeOutputPath', message: 'Output path must be a directory, not a symbolic link.', path: target })\n return collectHostDirectory(target, policy, 'current Skill', signal)\n}\n\nasync function prepareRun(input: SkillRun, policy: SkillOutputPolicy, fetchClient: FetchClient, signal?: AbortSignal): Promise<Result<PreparedRun, SkillRunError>> {\n if (signal?.aborted)\n return err({ _tag: 'Cancelled', message: 'Skill run was cancelled.' })\n\n const current = input._tag === 'ReviewSkill'\n ? ok(undefined)\n : await prepareCurrentSkill(input.destination, policy, signal)\n if (current._tag === 'Err')\n return current\n\n if (input._tag === 'ProjectSkill') {\n const source = await collectHostDirectory(input.projectDir, policy, input.projectDir, signal)\n return source._tag === 'Err'\n ? source\n : ok({ skillName: 'generate-project-skill', outputName: input.destination.name, source: source.value, current: current.value, destination: input.destination })\n }\n\n if (input._tag === 'ReviewSkill') {\n const source = await collectHostDirectory(input.skillDir, policy, input.skillDir, signal)\n return source._tag === 'Err'\n ? source\n : ok({ skillName: 'review-skill', outputName: 'review', source: source.value })\n }\n\n if (input.source._tag === 'NpmPackage') {\n const source = await prepareNpmPackage(input.source.spec, policy, fetchClient, signal)\n if (signal?.aborted)\n return err({ _tag: 'Cancelled', message: 'Skill run was cancelled.' })\n return source._tag === 'Err'\n ? source\n : ok({ skillName: 'generate-package-skill', outputName: input.destination.name, source: source.value, current: current.value, destination: input.destination })\n }\n\n const packageDir = resolveWithin(input.source.rootDir, input.source.packageDir)\n if (packageDir === null)\n return err({ _tag: 'InvalidInput', message: 'Local package directory must stay inside its root directory.' })\n const manifest = await lstat(join(packageDir, 'package.json')).catch(error => error as NodeJS.ErrnoException)\n if (manifest instanceof Error || !manifest.isFile() || manifest.isSymbolicLink()) {\n return err({\n _tag: 'SourceUnavailable',\n message: 'Local package directory must contain package.json.',\n attempts: [{ source: packageDir, status: 'skipped', reason: 'package.json is unavailable.' }],\n })\n }\n\n const source = await collectHostDirectory(packageDir, policy, packageDir, signal)\n return source._tag === 'Err'\n ? source\n : ok({ skillName: 'generate-package-skill', outputName: input.destination.name, source: source.value, current: current.value, destination: input.destination })\n}\n\nfunction requestContent(skill: HarnessV1Skill): string {\n const request = skill.files?.find(file => file.path === 'assets/harness-request.md')\n if (!request)\n throw new Error(`Harness request asset is missing for ${skill.name}.`)\n return request.content\n}\n\nfunction renderRequest(template: string, sourcePath: string, currentSkillPath: string, outputPath: string, skillName: string): string {\n return template\n .replaceAll('{{SOURCE_PATH}}', sourcePath)\n .replaceAll('{{CURRENT_SKILL_PATH}}', currentSkillPath)\n .replaceAll('{{OUTPUT_PATH}}', outputPath)\n .replaceAll('{{SKILL_NAME}}', skillName)\n}\n\nasync function writePreparedSource(active: ActiveSandbox, prepared: PreparedRun, signal?: AbortSignal): Promise<void> {\n const sourcePath = posix.join(active.workDir, 'input/source')\n const reset = await active.sandbox.run({\n command: 'rm -rf -- \"$SKILLD_INPUT\" \"$SKILLD_OUTPUT\" && mkdir -p -- \"$SKILLD_INPUT\"',\n env: {\n SKILLD_INPUT: posix.join(active.workDir, 'input'),\n SKILLD_OUTPUT: posix.join(active.workDir, 'skilld-output'),\n },\n abortSignal: signal,\n })\n if (reset.exitCode !== 0)\n throw new Error(reset.stderr.trim() || 'Harness work directory cannot be prepared.')\n for (const file of prepared.source.files) {\n await active.sandbox.writeBinaryFile({\n path: posix.join(sourcePath, file.path),\n content: file.content,\n abortSignal: signal,\n })\n }\n for (const file of prepared.current?.files ?? []) {\n await active.sandbox.writeBinaryFile({\n path: posix.join(active.workDir, 'input/current-skill', file.path),\n content: file.content,\n abortSignal: signal,\n })\n }\n await active.sandbox.writeTextFile({\n path: posix.join(active.workDir, 'input/source-manifest.json'),\n content: `${JSON.stringify({\n sourceAttempts: prepared.source.attempts,\n npmResolution: prepared.source.npmResolution,\n hasCurrentSkill: prepared.current !== undefined,\n }, null, 2)}\\n`,\n abortSignal: signal,\n })\n}\n\nfunction toAgentError(cause: unknown, signal?: AbortSignal): SkillRunResult {\n return signal?.aborted\n ? cancelled()\n : err({ _tag: 'AgentFailed', message: 'Harness Agent failed during the Skill run.', cause })\n}\n\nexport function createSkillHarness(options: CreateSkillHarnessOptions): SkillHarness {\n const policy = parseOutputPolicy({ ...DEFAULT_OUTPUT_POLICY, ...options.outputPolicy })\n const fetchClient: FetchClient = options.fetch ?? globalThis.fetch.bind(globalThis)\n const sandboxConfig = { ...options.sandboxConfig }\n const harness = options.harness\n const sandbox = options.sandbox\n\n return {\n run: async (input, runOptions = {}): Promise<SkillRunResult> => {\n const parsed = parseSkillRun(input)\n if (parsed._tag === 'Err')\n return parsed\n\n const prepared = await prepareRun(parsed.value, policy, fetchClient, runOptions.signal)\n if (prepared._tag === 'Err')\n return prepared\n\n const skill = await loadSkilldMaintainedSkill(prepared.value.skillName)\n let active: ActiveSandbox | undefined\n const userOnSession = sandboxConfig.onSession\n const agent = new HarnessAgent({\n harness,\n sandbox,\n skills: [skill],\n permissionMode: 'allow-all',\n sandboxConfig: {\n ...sandboxConfig,\n onSession: async (sessionOptions) => {\n active = { sandbox: sessionOptions.session, workDir: sessionOptions.sessionWorkDir }\n await writePreparedSource(active, prepared.value, runOptions.signal)\n await userOnSession?.(sessionOptions)\n },\n },\n })\n\n const sessionResult = await agent.createSession({ abortSignal: runOptions.signal }).then(ok, cause => err(cause))\n if (sessionResult._tag === 'Err')\n return toAgentError(sessionResult.error, runOptions.signal)\n const session = sessionResult.value\n\n try {\n if (!active)\n return err({ _tag: 'AgentFailed', message: 'Harness did not provide its sandbox session.' })\n const sourcePath = posix.join(active.workDir, 'input/source')\n const currentSkillPath = posix.join(active.workDir, 'input/current-skill')\n const outputPath = posix.join(active.workDir, 'skilld-output', prepared.value.outputName)\n const prompt = renderRequest(requestContent(skill), sourcePath, currentSkillPath, outputPath, prepared.value.outputName)\n const generated = await agent.generate({ session, prompt, abortSignal: runOptions.signal }).then(ok, cause => err(cause))\n if (generated._tag === 'Err')\n return toAgentError(generated.error, runOptions.signal)\n if (runOptions.signal?.aborted)\n return cancelled()\n\n const collected = await collectSandboxOutput(active.sandbox, outputPath, policy, runOptions.signal)\n if (collected._tag === 'Err')\n return collected\n\n if (prepared.value.skillName === 'review-skill')\n return validateSkillReview(collected.value)\n\n const validated = validateGeneratedSkill(prepared.value.outputName, collected.value)\n if (validated._tag === 'Err')\n return validated\n if (!prepared.value.destination)\n return err({ _tag: 'InvalidInput', message: 'Skill destination is required.' })\n return promoteSkill(\n prepared.value.destination.rootDir,\n prepared.value.destination.name,\n collected.value,\n prepared.value.source.attempts,\n )\n }\n finally {\n await session.destroy()\n }\n },\n }\n}\n"],"mappings":";;;;;;;;;AAIA,MAAa,MAAS,WAAgC;CAAE,MAAM;CAAM;AAAM;AAC1E,MAAa,OAAU,WAAgC;CAAE,MAAM;CAAO;AAAM;ACC5E,SAASA,UAAQ,SAA+C;CAC9D,OAAO,IAAI;EAAE,MAAM;EAAgB;CAAQ,CAAC;AA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,MAAM,SAAS,cAAc,eAAe,KAAK,GAAG,YAAY,kBAAkB,YAAY,SAAS,MAAM,UAAU;GACvH,MAAM,YAAY,MAAM,MAAM,SAAS;IAAE;IAAS;IAAQ,aAAa,WAAW;GAAO,CAAC,CAAC,CAAC,KAAK,KAAI,UAAS,IAAI,KAAK,CAAC;GACxH,IAAI,UAAU,SAAS,OACrB,OAAO,aAAa,UAAU,OAAO,WAAW,MAAM;GACxD,IAAI,WAAW,QAAQ,SACrB,OAAO,UAAU;GAEnB,MAAM,YAAY,MAAM,qBAAqB,OAAO,SAAS,YAAY,QAAQ,WAAW,MAAM;GAClG,IAAI,UAAU,SAAS,OACrB,OAAO;GAET,IAAI,SAAS,MAAM,cAAc,gBAC/B,OAAO,oBAAoB,UAAU,KAAK;GAE5C,MAAM,YAAY,uBAAuB,SAAS,MAAM,YAAY,UAAU,KAAK;GACnF,IAAI,UAAU,SAAS,OACrB,OAAO;GACT,IAAI,CAAC,SAAS,MAAM,aAClB,OAAO,IAAI;IAAE,MAAM;IAAgB,SAAS;GAAiC,CAAC;GAChF,OAAO,aACL,SAAS,MAAM,YAAY,SAC3B,SAAS,MAAM,YAAY,MAC3B,UAAU,OACV,SAAS,MAAM,OAAO,QACxB;EACF,UACQ;GACN,MAAM,QAAQ,QAAQ;EACxB;CACF,EACF;AACF"}
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: generate-package-skill
3
+ description: Generate or update an Agent Skill for an npm or local package using its public API and current documentation.
4
+ ---
5
+
6
+ # Generate a package Skill
7
+
8
+ Create a focused Skill that helps an Agent use one package correctly.
9
+
10
+ ## Inputs
11
+
12
+ Ask for a package name, package directory, or prepared package source.
13
+ Ask for the destination only when the request does not provide one.
14
+
15
+ ## Research
16
+
17
+ 1. Record the exact installed or prepared package version.
18
+ 2. Read the package manifest and every exported entry point.
19
+ 3. Read public type entry points and their source definitions.
20
+ 4. Read current official documentation and runnable examples.
21
+ 5. Check release notes and migration guides for the exact version.
22
+ 6. Prefer public exports over internal files.
23
+ 7. Record advice only when the prepared source or official documentation proves it.
24
+
25
+ For an npm package, use the installed or prepared package source first.
26
+ Use current official documentation when the prepared source lacks required details.
27
+ For each version-specific rule, cite the source path or official documentation URL.
28
+ Use `path:line` citations for prepared source when line numbers add value.
29
+
30
+ ## Output
31
+
32
+ Write one directory whose name matches the Skill name.
33
+ The directory must contain `SKILL.md`.
34
+ Put detailed or conditional material in `references/`.
35
+ Put reusable commands or code in `scripts/` when execution adds value.
36
+
37
+ The `SKILL.md` frontmatter must contain only:
38
+
39
+ ```yaml
40
+ ---
41
+ name: package-name
42
+ description: Clear trigger conditions and the result this Skill provides.
43
+ ---
44
+ ```
45
+
46
+ Use lowercase letters, numbers, and single hyphens in the name.
47
+ Keep the name at 64 characters or fewer.
48
+ Keep the description at 1024 characters or fewer.
49
+
50
+ ## Quality checks
51
+
52
+ - Keep instructions specific to the package.
53
+ - Use current APIs and package vocabulary.
54
+ - Include small examples for common tasks.
55
+ - State environment or version limits.
56
+ - Cite public APIs, version limits, and migration advice.
57
+ - Link each reference from `SKILL.md`.
58
+ - Remove generated filler and repeated prose.
59
+ - Do not copy large documentation sections.
60
+ - Do not include credentials, caches, build output, or dependency directories.
61
+
62
+ For a direct run, show the generated files for user review.
63
+ Replace an existing Skill only after the user approves the files.
64
+ Do not claim that the Skill passed Harness checks.
@@ -0,0 +1,11 @@
1
+ # Harness request
2
+
3
+ Use the prepared package source at `{{SOURCE_PATH}}`.
4
+ If it exists, use the current Skill at `{{CURRENT_SKILL_PATH}}` as the update baseline.
5
+ Generate the package Skill at `{{OUTPUT_PATH}}`.
6
+ The Skill directory name must be `{{SKILL_NAME}}`.
7
+
8
+ Read this Skill fully before writing files.
9
+ Use only the visible prepared source and cited official documentation.
10
+ Write no files outside `{{OUTPUT_PATH}}`.
11
+ Finish only after checking every output rule in this Skill.
@@ -0,0 +1,62 @@
1
+ ---
2
+ name: generate-project-skill
3
+ description: Generate or update an Agent Skill from the observed workflows, boundaries, and conventions of one software project.
4
+ ---
5
+
6
+ # Generate a project Skill
7
+
8
+ Create a compact, searchable Skill from the project itself.
9
+
10
+ ## Inputs
11
+
12
+ Use the project directory or prepared project source.
13
+ Ask for the destination only when the request does not provide one.
14
+
15
+ ## Inspect
16
+
17
+ 1. Read project instructions and decision records first.
18
+ 2. Read manifests, exported entry points, and build configuration.
19
+ 3. Find the test, lint, typecheck, build, and release commands.
20
+ 4. Trace the main public workflows through their real entry points.
21
+ 5. Note generated directories and files an Agent must not edit.
22
+ 6. Check recent changes when they explain current conventions.
23
+
24
+ ## Project navigation
25
+
26
+ 1. Identify the project name, purpose, key files, and main directories.
27
+ 2. Use project-relative paths for every file pointer.
28
+ 3. Add focused search commands for source and documentation.
29
+ 4. Keep search results linked to the real project files.
30
+ 5. Never add a generated directory prefix to a project-relative path.
31
+ 6. Tell the Agent when project changes require a new Skill run.
32
+
33
+ Ignore dependency directories, version-control data, generated output, caches, and credentials.
34
+ Do not follow symbolic links while collecting project files.
35
+
36
+ ## Output
37
+
38
+ Write one directory whose name matches the Skill name.
39
+ The directory must contain `SKILL.md`.
40
+ Use `references/` for architecture details and command guides.
41
+ Use `scripts/` only for reusable automation.
42
+
43
+ The `SKILL.md` frontmatter must contain only `name` and `description`.
44
+ Use lowercase letters, numbers, and single hyphens in the name.
45
+ Keep the name at 64 characters or fewer.
46
+
47
+ ## Quality checks
48
+
49
+ - Describe when the Skill applies.
50
+ - Use project terms exactly.
51
+ - Point to source files instead of copying them.
52
+ - Run project commands only when they add useful evidence.
53
+ - Record the observed command and outcome.
54
+ - Include repeatable search commands for project source and documentation.
55
+ - Keep file pointers rooted at the real project directory.
56
+ - Separate rules from optional guidance.
57
+ - Remove stale, inferred, or duplicated instructions.
58
+ - Link each reference from `SKILL.md`.
59
+
60
+ For a direct run, show the generated files for user review.
61
+ Do not replace an existing Skill until the user approves it.
62
+ Do not claim that the Skill passed Harness checks.
@@ -0,0 +1,11 @@
1
+ # Harness request
2
+
3
+ Use the prepared project source at `{{SOURCE_PATH}}`.
4
+ If it exists, use the current Skill at `{{CURRENT_SKILL_PATH}}` as the update baseline.
5
+ Generate the project Skill at `{{OUTPUT_PATH}}`.
6
+ The Skill directory name must be `{{SKILL_NAME}}`.
7
+
8
+ Read this Skill fully before writing files.
9
+ Do not follow links or read outside the visible prepared source.
10
+ Write no files outside `{{OUTPUT_PATH}}`.
11
+ Finish only after checking every output rule in this Skill.
@@ -0,0 +1,5 @@
1
+ [
2
+ "generate-package-skill",
3
+ "generate-project-skill",
4
+ "review-skill"
5
+ ]
@@ -0,0 +1,28 @@
1
+ ---
2
+ name: review-skill
3
+ description: Review an Agent Skill for valid structure, clear triggers, usable instructions, current evidence, and risky or unclear actions.
4
+ ---
5
+
6
+ # Review a Skill
7
+
8
+ Review the supplied Skill as an Agent would use it.
9
+
10
+ ## Checks
11
+
12
+ 1. Confirm `SKILL.md` exists and its parent directory matches its name.
13
+ 2. Confirm frontmatter uses supported fields and valid values.
14
+ 3. Confirm the description states clear trigger conditions.
15
+ 4. Follow every linked reference and script.
16
+ 5. Report missing or broken links.
17
+ 6. Reject symbolic links, special files, and paths that leave the Skill directory.
18
+ 7. Check instructions for missing inputs, unclear outcomes, and silent failure paths.
19
+ 8. Check commands for destructive scope, credential exposure, and unverified downloads.
20
+ 9. Check examples against the cited API or project source.
21
+ 10. Find repeated prose and material that belongs in a reference.
22
+
23
+ Rank each finding as `error`, `warning`, or `note`.
24
+ Give the exact path and a direct fix.
25
+ Do not rewrite the Skill unless the request asks for changes.
26
+
27
+ For a direct run, present the findings to the user.
28
+ The user decides whether to apply them.
@@ -0,0 +1,24 @@
1
+ # Harness request
2
+
3
+ Review the prepared Skill at `{{SOURCE_PATH}}`.
4
+ Write the result to `{{OUTPUT_PATH}}/review.json`.
5
+
6
+ Read this Skill fully before reviewing.
7
+ Write no other output files.
8
+ Use this JSON shape:
9
+
10
+ ```json
11
+ {
12
+ "summary": "One short conclusion.",
13
+ "findings": [
14
+ {
15
+ "level": "error",
16
+ "path": "SKILL.md",
17
+ "message": "One clear problem.",
18
+ "fix": "One direct fix."
19
+ }
20
+ ]
21
+ }
22
+ ```
23
+
24
+ Use only `error`, `warning`, or `note` for `level`.
@@ -0,0 +1,67 @@
1
+ ---
2
+ name: skilld
3
+ description: Search, view, install, upgrade, verify, and remove Skills with skilld CLI, including private repository access.
4
+ ---
5
+
6
+ # Use skilld CLI
7
+
8
+ Use skilld CLI to search for and install Skills.
9
+
10
+ ## Search for a Skill
11
+
12
+ Run a focused search:
13
+
14
+ ```sh
15
+ skilld search <query>
16
+ ```
17
+
18
+ Read the result names and descriptions before choosing.
19
+ Refine the query when several Skills cover different tasks.
20
+
21
+ ## Install a Skill
22
+
23
+ Install the selector returned by search into the detected Agent target:
24
+
25
+ ```sh
26
+ skilld install <selector>
27
+ ```
28
+
29
+ Install into global Agent targets:
30
+
31
+ ```sh
32
+ skilld install <selector> --global
33
+ ```
34
+
35
+ Install this skilld-maintained Skill globally:
36
+
37
+ ```sh
38
+ skilld install skilld --global
39
+ ```
40
+
41
+ Always use the source selector shown by `skilld search`.
42
+ If private repository access is required, run `skilld auth login`.
43
+ Do not print access tokens or copy them into project files.
44
+
45
+ After installation, report the installed Skill name and Agent target.
46
+
47
+ ## View a Skill
48
+
49
+ ```sh
50
+ skilld list
51
+ skilld view <skill>
52
+ ```
53
+
54
+ Use `list` to show installed Skills.
55
+ Use `view` to show one Skill's path, source status, and Agent targets.
56
+
57
+ ## Maintain installed Skills
58
+
59
+ ```sh
60
+ skilld upgrade <skill>
61
+ skilld verify <skill>
62
+ skilld remove <skill>
63
+ ```
64
+
65
+ Use `upgrade` to install a newer Artifact.
66
+ Use `verify` to check the installed bytes and source status.
67
+ Use `remove` only when the request names the Skill to remove.
@@ -0,0 +1,6 @@
1
+ [
2
+ "generate-package-skill",
3
+ "generate-project-skill",
4
+ "review-skill",
5
+ "skilld"
6
+ ]
@@ -0,0 +1,14 @@
1
+ import { HarnessV1Skill } from "@ai-sdk/harness";
2
+ declare function harnessSkillNames(): Promise<ReadonlyArray<string>>;
3
+ declare function skilldMaintainedSkillNames(): Promise<ReadonlyArray<string>>;
4
+ declare function loadSkilldMaintainedSkill(name: string): Promise<HarnessV1Skill>;
5
+ declare const DEFAULT_OUTPUT_POLICY: Readonly<{
6
+ maxSourceFiles: 2000;
7
+ maxSourceFileBytes: number;
8
+ maxSourceBytes: number;
9
+ maxOutputFiles: 64;
10
+ maxOutputFileBytes: number;
11
+ maxOutputBytes: number;
12
+ }>;
13
+ export { DEFAULT_OUTPUT_POLICY, harnessSkillNames, loadSkilldMaintainedSkill, skilldMaintainedSkillNames };
14
+ //# sourceMappingURL=skills.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skills.d.mts","names":[],"sources":["../src/skills.ts"],"mappings":";iBAsDsB,qBAAqB,QAAQ;iBAK7B,8BAA8B,QAAQ;iBAKtC,0BAA0B,eAAe,QAAQ;cAqB1D,uBAAqB"}
@@ -0,0 +1,2 @@
1
+ import { DEFAULT_OUTPUT_POLICY, harnessSkillNames, loadSkilldMaintainedSkill, skilldMaintainedSkillNames } from "./_chunks/skills.mjs";
2
+ export { DEFAULT_OUTPUT_POLICY, harnessSkillNames, loadSkilldMaintainedSkill, skilldMaintainedSkillNames };
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "skilld-harness",
3
+ "type": "module",
4
+ "version": "3.0.0-beta.1",
5
+ "description": "Run skilld-maintained Skills with checked, atomic output",
6
+ "author": {
7
+ "name": "Harlan Wilton",
8
+ "email": "harlan@harlanzw.com",
9
+ "url": "https://harlanzw.com/"
10
+ },
11
+ "contributors": [
12
+ {
13
+ "name": "Ori",
14
+ "url": "https://github.com/oritwoen"
15
+ }
16
+ ],
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/skilld-dev/skilld.git",
21
+ "directory": "packages/harness"
22
+ },
23
+ "keywords": [
24
+ "agent",
25
+ "skills",
26
+ "harness",
27
+ "ai-sdk"
28
+ ],
29
+ "sideEffects": false,
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.mts",
33
+ "import": "./dist/index.mjs"
34
+ },
35
+ "./skills": {
36
+ "types": "./dist/skills.d.mts",
37
+ "import": "./dist/skills.mjs"
38
+ },
39
+ "./package.json": "./package.json"
40
+ },
41
+ "files": [
42
+ "dist"
43
+ ],
44
+ "engines": {
45
+ "node": ">=22.0.0"
46
+ },
47
+ "scripts": {
48
+ "build": "obuild && node scripts/copy-skilld-maintained-skills.mjs",
49
+ "lint": "eslint .",
50
+ "lint:fix": "eslint . --fix",
51
+ "typecheck": "tsc --noEmit",
52
+ "test": "vitest",
53
+ "test:run": "vitest run",
54
+ "publint": "publint",
55
+ "attw": "node scripts/check-package-types.mjs",
56
+ "prepack": "pnpm run build"
57
+ },
58
+ "dependencies": {
59
+ "@ai-sdk/harness": "catalog:",
60
+ "ws": "catalog:",
61
+ "yaml": "catalog:",
62
+ "zod": "catalog:"
63
+ },
64
+ "devDependencies": {
65
+ "@ai-sdk/provider-utils": "catalog:",
66
+ "@antfu/eslint-config": "catalog:dev-lint",
67
+ "@arethetypeswrong/cli": "catalog:",
68
+ "@types/node": "catalog:dev-build",
69
+ "@typescript/native": "catalog:",
70
+ "eslint": "catalog:dev-lint",
71
+ "obuild": "catalog:dev-build",
72
+ "publint": "catalog:",
73
+ "typescript": "catalog:",
74
+ "vitest": "catalog:dev-test"
75
+ }
76
+ }