@agentyx/core 0.8.0 → 0.9.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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["formatIssues","isInside","formatIssues"],"sources":["../src/errors.ts","../src/issues.ts","../src/config/errors.ts","../src/hook/schema.ts","../src/mcp/schema.ts","../src/skill/schema.ts","../src/tool/schema.ts","../src/pack/schema.ts","../src/source/schema.ts","../src/config/schema.ts","../src/config/json-schema.ts","../src/config/loader.ts","../src/assets.ts","../src/pack/errors.ts","../src/pack/registry.ts","../src/skill/errors.ts","../src/skill/markdown.ts","../src/skill/registry.ts","../src/skill/built-in.ts","../src/source/errors.ts","../src/source/registry.ts","../src/config/project.ts","../src/hook/errors.ts","../src/hook/registry.ts","../src/hook/built-in.ts","../src/pack/resolver.ts","../src/hook/resolver.ts","../src/mcp/errors.ts","../src/mcp/registry.ts","../src/mcp/built-in.ts","../src/mcp/resolver.ts","../src/skill/resolver.ts","../src/tool/errors.ts","../src/tool/registry.ts","../src/tool/built-in.ts","../src/tool/resolver.ts","../src/config/resolver.ts","../src/manifest/errors.ts","../src/manifest/schema.ts","../src/manifest/io.ts","../src/meta.ts","../src/project/executable.ts","../src/project/signals.ts","../src/project/detector.ts","../src/project/recommend.ts","../src/project-graph.ts","../src/source/inspection.ts"],"sourcesContent":["/**\n * Base class for every failure Agentyx raises deliberately.\n *\n * Consumers can catch `AgentyxError` to separate expected domain failures from\n * unexpected runtime errors, and branch on the stable `code` when they need to\n * handle a specific failure.\n */\nexport class AgentyxError extends Error {\n readonly code: string;\n\n constructor(code: string, message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = \"AgentyxError\";\n this.code = code;\n }\n}\n","import type { ZodError } from \"zod\";\n\n/** A single problem in an Agentyx document, addressed by its location in it. */\nexport interface AgentyxIssue {\n /** Dotted path to the offending value, or `(root)` for the document itself. */\n readonly path: string;\n readonly message: string;\n}\n\n/**\n * Turns a Zod failure into locations a reader can find in the file.\n *\n * Shared by every document Agentyx validates, so a problem in `.agentyx.json`\n * and a problem in `.agentyx.lock.json` are reported the same way.\n */\nexport function toAgentyxIssues(error: ZodError): readonly AgentyxIssue[] {\n return error.issues.map((issue) => ({\n path: formatIssuePath(issue.path),\n message: issue.message,\n }));\n}\n\nfunction formatIssuePath(path: readonly PropertyKey[]): string {\n if (path.length === 0) {\n return \"(root)\";\n }\n\n return path.reduce<string>((formatted, segment) => {\n if (typeof segment === \"number\") {\n return `${formatted}[${segment}]`;\n }\n\n return formatted === \"\" ? String(segment) : `${formatted}.${String(segment)}`;\n }, \"\");\n}\n","import type { ZodError } from \"zod\";\nimport { AgentyxError } from \"../errors.js\";\nimport { type AgentyxIssue, toAgentyxIssues } from \"../issues.js\";\n\n/** A single configuration problem, addressed by its location in the document. */\nexport type AgentyxConfigIssue = AgentyxIssue;\n\n/** Raised when the supplied directory has no `.agentyx.json`. */\nexport class AgentyxConfigNotFoundError extends AgentyxError {\n readonly filePath: string;\n\n constructor(filePath: string, options?: ErrorOptions) {\n super(\"agentyx_config_not_found\", `Agentyx configuration file not found: ${filePath}`, options);\n this.name = \"AgentyxConfigNotFoundError\";\n this.filePath = filePath;\n }\n}\n\n/** Raised when `.agentyx.json` is not valid JSON. */\nexport class AgentyxConfigParseError extends AgentyxError {\n readonly filePath: string;\n\n constructor(filePath: string, reason: string, options?: ErrorOptions) {\n super(\"agentyx_config_parse_error\", `${filePath} is not valid JSON: ${reason}`, options);\n this.name = \"AgentyxConfigParseError\";\n this.filePath = filePath;\n }\n}\n\n/** Raised when the document parses as JSON but violates the Agentyx schema. */\nexport class AgentyxConfigValidationError extends AgentyxError {\n readonly issues: readonly AgentyxConfigIssue[];\n /** The file the configuration came from, when it was read from disk. */\n readonly filePath: string | undefined;\n\n constructor(error: ZodError, filePath?: string) {\n const issues = toAgentyxIssues(error);\n const location = filePath === undefined ? \"\" : ` in ${filePath}`;\n const details = issues.map((issue) => ` - ${issue.path}: ${issue.message}`).join(\"\\n\");\n\n super(\"agentyx_config_invalid\", `Invalid Agentyx configuration${location}:\\n${details}`);\n this.name = \"AgentyxConfigValidationError\";\n this.issues = issues;\n this.filePath = filePath;\n }\n}\n\nexport class UnknownEnabledCapabilityError extends AgentyxError {\n readonly capabilityName: string;\n readonly knownCapabilities: readonly string[];\n\n constructor(capabilityName: string, knownCapabilities: readonly string[]) {\n const known = knownCapabilities.length > 0 ? [...knownCapabilities].sort().join(\", \") : \"none\";\n\n super(\n \"unknown_enabled_capability\",\n `Unknown enabled capability \"${capabilityName}\". Known optional capabilities: ${known}.`,\n );\n this.name = \"UnknownEnabledCapabilityError\";\n this.capabilityName = capabilityName;\n this.knownCapabilities = knownCapabilities;\n }\n}\n\n/** Raised when a configured local Skill directory cannot be loaded safely. */\nexport class LocalSkillDirectoryError extends AgentyxError {\n readonly directory: string;\n\n constructor(directory: string, reason: string, options?: ErrorOptions) {\n super(\n \"local_skill_directory_error\",\n `Could not load local Skill directory \"${directory}\": ${reason}`,\n options,\n );\n this.name = \"LocalSkillDirectoryError\";\n this.directory = directory;\n }\n}\n\n/** Raised when a configured project-context path is missing or escapes the project. */\nexport class ProjectContextPathError extends AgentyxError {\n readonly path: string;\n\n constructor(path: string, reason: string, options?: ErrorOptions) {\n super(\n \"project_context_path_error\",\n `Invalid project context path \"${path}\": ${reason}.`,\n options,\n );\n this.name = \"ProjectContextPathError\";\n this.path = path;\n }\n}\n","import { z } from \"zod\";\n\nexport const HOOK_ACTIVATION_LEVELS = [\"default\", \"optional\"] as const;\n\nexport const hookActivationLevelSchema = z.enum(HOOK_ACTIVATION_LEVELS);\n\nexport const HOOK_EVENTS = [\"SessionStart\"] as const;\n\nexport const hookEventSchema = z.enum(HOOK_EVENTS);\n\nexport const hookNameSchema = z\n .string()\n .min(1, \"Hook names must be non-empty strings.\")\n .regex(\n /^[a-z0-9]+(?:-[a-z0-9]+)*$/,\n 'Hook names must be lowercase kebab-case, for example \"session-doctor-bootstrap\".',\n );\n\nexport const hookDefinitionSchema = z.strictObject({\n name: hookNameSchema.describe(\"Unique hook identifier.\"),\n description: z.string().trim().min(1, \"Hook descriptions must be non-empty strings.\"),\n event: hookEventSchema.describe(\"The provider lifecycle event this hook runs on.\"),\n command: z.string().trim().min(1, \"Hook command must be a non-empty string.\"),\n args: z.array(z.string()).default([]),\n});\n\nexport const hookReferenceSchema = z\n .union([\n hookNameSchema,\n z.strictObject({\n name: hookNameSchema.describe(\"Hook identifier.\"),\n activation: hookActivationLevelSchema.default(\"default\"),\n }),\n ])\n .transform((value) =>\n typeof value === \"string\"\n ? {\n name: value,\n activation: \"default\" as const,\n }\n : value,\n )\n .pipe(\n z.strictObject({\n name: hookNameSchema.describe(\"Hook identifier.\"),\n activation: hookActivationLevelSchema.describe(\n \"Whether this hook is active by default or explicit opt-in.\",\n ),\n }),\n );\n\nexport type HookActivationLevel = z.infer<typeof hookActivationLevelSchema>;\nexport type HookEvent = z.infer<typeof hookEventSchema>;\nexport type HookDefinition = z.infer<typeof hookDefinitionSchema>;\nexport type HookDefinitionInput = z.input<typeof hookDefinitionSchema>;\nexport type HookReference = z.infer<typeof hookReferenceSchema>;\nexport type HookReferenceInput = z.input<typeof hookReferenceSchema>;\n","import { z } from \"zod\";\n\nexport const MCP_CAPABILITY_LEVELS = [\"default\", \"optional\"] as const;\n\nexport const mcpCapabilityLevelSchema = z.enum(MCP_CAPABILITY_LEVELS);\n\nexport const MCP_CONTEXT_COSTS = [\"low\", \"medium\", \"high\"] as const;\n\nexport const mcpContextCostSchema = z.enum(MCP_CONTEXT_COSTS);\n\n/**\n * Whether *launching* this server, as configured, can by itself fetch a package from a registry.\n *\n * Agentyx itself never downloads or installs anything. This describes the command a provider would\n * run once the server is enabled: `\"local\"` only ever runs an already-local binary or calls a\n * remote HTTP endpoint; `\"may-download\"` shells out through something like `npx`, which can fetch a\n * package on first launch even when Agentyx did nothing but write the configuration.\n */\nexport const MCP_RUNTIMES = [\"local\", \"may-download\"] as const;\n\nexport const mcpRuntimeSchema = z.enum(MCP_RUNTIMES);\n\nexport const mcpServerNameSchema = z\n .string()\n .min(1, \"MCP server names must be non-empty strings.\")\n .regex(\n /^[a-z0-9]+(?:-[a-z0-9]+)*$/,\n 'MCP server names must be lowercase kebab-case, for example \"context7\".',\n );\n\nexport const mcpEnvReferenceSchema = z.strictObject({\n fromEnv: z\n .string()\n .trim()\n .min(1, \"Environment variable references must be non-empty strings.\")\n .regex(/^[A-Za-z_][A-Za-z0-9_]*$/, \"Environment variable names must be valid shell names.\"),\n});\n\nconst commonMcpServerDefinitionSchema = z.strictObject({\n name: mcpServerNameSchema.describe(\"Unique MCP server identifier.\"),\n description: z.string().trim().min(1, \"MCP server descriptions must be non-empty strings.\"),\n transport: z.enum([\"stdio\", \"http\"]),\n contextCost: mcpContextCostSchema\n .describe(\"Qualitative context/tool-schema overhead classification; not token accounting.\")\n .optional(),\n runtime: mcpRuntimeSchema\n .describe(\"Whether launching this server can fetch a package on first use; see MCP_RUNTIMES.\")\n .optional(),\n});\n\nconst explicitMcpServerReferenceSchema = z.strictObject({\n name: mcpServerNameSchema.describe(\"MCP server identifier.\"),\n activation: mcpCapabilityLevelSchema\n .describe(\"Whether this MCP capability is active by default or explicit opt-in.\")\n .default(\"default\"),\n});\n\nexport const mcpServerReferenceSchema = z\n .union([mcpServerNameSchema, explicitMcpServerReferenceSchema])\n .transform((value) =>\n typeof value === \"string\"\n ? {\n name: value,\n activation: \"default\" as const,\n }\n : value,\n )\n .pipe(\n z.strictObject({\n name: mcpServerNameSchema.describe(\"MCP server identifier.\"),\n activation: mcpCapabilityLevelSchema.describe(\n \"Whether this MCP capability is active by default or explicit opt-in.\",\n ),\n }),\n );\n\nexport const stdioMcpServerDefinitionSchema = commonMcpServerDefinitionSchema.extend({\n transport: z.literal(\"stdio\"),\n command: z.string().trim().min(1, \"MCP stdio command must be a non-empty string.\"),\n args: z.array(z.string()).default([]),\n env: z.record(z.string().min(1), mcpEnvReferenceSchema).default({}),\n});\n\nexport const httpMcpServerDefinitionSchema = commonMcpServerDefinitionSchema.extend({\n transport: z.literal(\"http\"),\n url: z.url(\"MCP HTTP URL must be a valid URL.\"),\n headers: z.record(z.string().min(1), mcpEnvReferenceSchema).default({}),\n});\n\nexport const mcpServerDefinitionSchema = z.discriminatedUnion(\"transport\", [\n stdioMcpServerDefinitionSchema,\n httpMcpServerDefinitionSchema,\n]);\n\nexport type McpEnvReference = z.infer<typeof mcpEnvReferenceSchema>;\nexport type McpCapabilityLevel = z.infer<typeof mcpCapabilityLevelSchema>;\nexport type McpContextCost = z.infer<typeof mcpContextCostSchema>;\nexport type McpRuntime = z.infer<typeof mcpRuntimeSchema>;\nexport type McpServerDefinition = z.infer<typeof mcpServerDefinitionSchema>;\nexport type McpServerDefinitionInput = z.input<typeof mcpServerDefinitionSchema>;\nexport type McpServerReference = z.infer<typeof mcpServerReferenceSchema>;\nexport type McpServerReferenceInput = z.input<typeof mcpServerReferenceSchema>;\n","import { z } from \"zod\";\n\n/**\n * Skill names double as directory names for `SKILL.md` files, so they are\n * constrained to a lowercase slug. That keeps them stable across filesystems\n * and makes them safe to join onto a path.\n */\nexport const skillNameSchema = z\n .string()\n .min(1, \"Skill names must be non-empty strings.\")\n .regex(\n /^[a-z0-9]+(?:-[a-z0-9]+)*$/,\n 'Skill names must be lowercase kebab-case, for example \"typescript-modern\".',\n );\n\n/**\n * The metadata a Skill carries, and exactly what a `SKILL.md` frontmatter block\n * may declare. Kept separate from the full definition so the parser can reject\n * a frontmatter key that tries to supply the body.\n */\nexport const skillMetadataSchema = z.strictObject({\n name: skillNameSchema.describe(\"Unique skill identifier.\"),\n description: z\n .string()\n .trim()\n .min(1, \"Skill descriptions must be non-empty strings.\")\n .describe(\"One-line summary of what the skill tells an agent to do.\"),\n});\n\n/**\n * A Skill is reusable instruction text for a coding agent. It is deliberately\n * provider-independent: nothing here says how or where a provider installs it.\n */\nexport const skillDefinitionSchema = skillMetadataSchema.extend({\n content: z\n .string()\n .trim()\n .min(1, \"Skill content must be non-empty.\")\n .describe(\"The Markdown instructions handed to an agent.\"),\n});\n\n/** A validated skill definition. */\nexport type SkillDefinition = z.infer<typeof skillDefinitionSchema>;\n\n/** The shape accepted when authoring a skill definition. */\nexport type SkillDefinitionInput = z.input<typeof skillDefinitionSchema>;\n","import { z } from \"zod\";\n\nexport const TOOL_ACTIVATION_LEVELS = [\"default\", \"optional\"] as const;\n\nexport const toolActivationLevelSchema = z.enum(TOOL_ACTIVATION_LEVELS);\n\nexport const toolNameSchema = z\n .string()\n .min(1, \"Tool names must be non-empty strings.\")\n .regex(\n /^[a-z0-9]+(?:-[a-z0-9]+)*$/,\n 'Tool names must be lowercase kebab-case, for example \"rtk\".',\n );\n\nexport const toolReferenceSchema = z\n .union([\n toolNameSchema,\n z.strictObject({\n name: toolNameSchema.describe(\"Tool identifier.\"),\n activation: toolActivationLevelSchema.default(\"default\"),\n }),\n ])\n .transform((value) =>\n typeof value === \"string\"\n ? {\n name: value,\n activation: \"default\" as const,\n }\n : value,\n )\n .pipe(\n z.strictObject({\n name: toolNameSchema.describe(\"Tool identifier.\"),\n activation: toolActivationLevelSchema,\n }),\n );\n\nexport const toolDefinitionSchema = z.strictObject({\n name: toolNameSchema.describe(\"Unique tool identifier.\"),\n description: z.string().trim().min(1, \"Tool descriptions must be non-empty strings.\"),\n kind: z.literal(\"executable\"),\n command: z.string().trim().min(1, \"Tool executable command must be a non-empty string.\"),\n optional: z.boolean().default(true),\n installHint: z.string().trim().min(1, \"Tool install hints must be non-empty strings.\").optional(),\n});\n\nexport type ToolActivationLevel = z.infer<typeof toolActivationLevelSchema>;\nexport type ToolDefinition = z.infer<typeof toolDefinitionSchema>;\nexport type ToolDefinitionInput = z.input<typeof toolDefinitionSchema>;\nexport type ToolReference = z.infer<typeof toolReferenceSchema>;\nexport type ToolReferenceInput = z.input<typeof toolReferenceSchema>;\n","import { z } from \"zod\";\nimport { hookReferenceSchema } from \"../hook/schema.js\";\nimport { mcpServerReferenceSchema } from \"../mcp/schema.js\";\nimport { skillNameSchema } from \"../skill/schema.js\";\nimport { toolReferenceSchema } from \"../tool/schema.js\";\n\nexport const PACK_CATEGORIES = [\n \"engineering\",\n \"language\",\n \"framework\",\n \"efficiency\",\n \"workflow\",\n] as const;\n\nexport const packCategorySchema = z.enum(PACK_CATEGORIES);\n\n/**\n * Pack names are plain identifiers. They are intentionally not constrained to\n * a closed list so that external registries can contribute packs later.\n */\nexport const packNameSchema = z.string().min(1, \"Pack names must be non-empty strings.\");\n\n/** A pack is a composable provider-neutral capability bundle. */\nexport const packDefinitionSchema = z.strictObject({\n name: packNameSchema.describe(\"Unique pack identifier.\"),\n category: packCategorySchema\n .describe(\"Discoverability category; does not affect resolution.\")\n .default(\"engineering\"),\n description: z\n .string()\n .min(1, \"Pack descriptions must be non-empty when provided.\")\n .describe(\"Short human-readable summary of the pack.\")\n .optional(),\n skills: z\n .array(skillNameSchema)\n .describe(\"Skills this pack contributes, in declaration order.\")\n .default([]),\n mcpServers: z\n .array(mcpServerReferenceSchema)\n .describe(\"MCP servers this pack contributes, in declaration order.\")\n .default([]),\n tools: z\n .array(toolReferenceSchema)\n .describe(\"Local tools this pack contributes, in declaration order.\")\n .default([]),\n hooks: z\n .array(hookReferenceSchema)\n .describe(\"Provider lifecycle hooks this pack contributes, in declaration order.\")\n .default([]),\n});\n\n/** A validated pack definition, with defaults always present. */\nexport type PackDefinition = z.infer<typeof packDefinitionSchema>;\nexport type PackCategory = z.infer<typeof packCategorySchema>;\n\n/** The shape accepted when authoring a pack definition. */\nexport type PackDefinitionInput = z.input<typeof packDefinitionSchema>;\n","import { z } from \"zod\";\nimport { skillNameSchema } from \"../skill/schema.js\";\n\nexport const trustedSourceNameSchema = z\n .string()\n .min(1, \"Trusted source names must be non-empty strings.\")\n .regex(\n /^[a-z0-9]+(?:-[a-z0-9]+)*$/,\n 'Trusted source names must be lowercase kebab-case, for example \"superpowers\".',\n );\n\nexport const trustedSourcePathSchema = z\n .string()\n .min(1, \"Trusted source paths must be non-empty strings.\")\n .regex(\n /^(?!\\/)(?![A-Za-z]:)(?!.*(?:^|\\/)\\.\\.(?:\\/|$))[^\\\\\\0]+$/,\n \"Trusted source paths must be portable project-relative paths without parent traversal.\",\n );\n\nexport const trustedSourceReferenceSchema = z.strictObject({\n name: trustedSourceNameSchema.describe(\"Known trusted source identifier.\"),\n path: trustedSourcePathSchema.describe(\"Project-relative checkout path for this source.\"),\n ref: z\n .string()\n .trim()\n .min(1, \"Trusted source refs must be non-empty strings.\")\n .describe(\"Reviewed immutable commit, signed tag or pinned release identifier.\"),\n});\n\nexport const trustedSourceDefinitionSchema = z.strictObject({\n name: trustedSourceNameSchema,\n displayName: z.string().min(1),\n repository: z.string().url(),\n type: z.literal(\"codex-plugin\"),\n manifestPath: z.string().min(1),\n recommendedPath: trustedSourcePathSchema,\n description: z.string().min(1),\n installStatus: z.enum([\"metadata-only\", \"installable\"]),\n installNote: z.string().min(1),\n});\n\nexport const codexPluginManifestSchema = z\n .object({\n name: trustedSourceNameSchema,\n version: z.string().min(1),\n description: z.string().min(1),\n repository: z.string().url(),\n license: z.string().min(1),\n skills: z.string().min(1),\n })\n .passthrough();\n\nexport const trustedSourceSkillSummarySchema = z.strictObject({\n name: skillNameSchema,\n description: z.string().min(1),\n hasResources: z.boolean(),\n});\n\nexport type TrustedSourceReference = z.infer<typeof trustedSourceReferenceSchema>;\nexport type TrustedSourceDefinition = z.infer<typeof trustedSourceDefinitionSchema>;\nexport type CodexPluginManifest = z.infer<typeof codexPluginManifestSchema>;\nexport type TrustedSourceSkillSummary = z.infer<typeof trustedSourceSkillSummarySchema>;\n","import { z } from \"zod\";\nimport { packDefinitionSchema, packNameSchema } from \"../pack/schema.js\";\nimport { trustedSourceReferenceSchema } from \"../source/schema.js\";\n\n/**\n * Targets stay free-form strings on purpose: third-party adapters should be\n * able to register providers without a change to this schema.\n */\nexport const agentyxTargetSchema = z.string().min(1, \"Targets must be non-empty strings.\");\n\nexport const enabledCapabilityNameSchema = z\n .string()\n .min(1, \"Enabled capability names must be non-empty strings.\")\n .regex(\n /^[a-z0-9]+(?:-[a-z0-9]+)*$/,\n 'Enabled capability names must be lowercase kebab-case, for example \"rtk\".',\n );\n\n/**\n * Portable project-relative path to a directory whose direct children are Agent Skills.\n * Backslashes, absolute paths and parent traversal are rejected so the same config is safe on\n * every supported platform.\n */\nexport const skillDirectorySchema = z\n .string()\n .min(1, \"Skill directories must be non-empty strings.\")\n .regex(\n /^(?!\\/)(?![A-Za-z]:)(?!.*(?:^|\\/)\\.\\.(?:\\/|$))[^\\\\\\0]+$/,\n \"Skill directories must be portable project-relative paths without parent traversal.\",\n );\n\nconst projectIdSchema = z\n .string()\n .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, \"Project ids must be lowercase kebab-case identifiers.\");\nconst projectTextSchema = z\n .string()\n .min(1, \"Must not be blank.\")\n .refine((value) => value.trim().length > 0, \"Must not be blank.\")\n .refine(\n (value) =>\n Array.from(value).every((character) => {\n const codePoint = character.codePointAt(0) ?? 0;\n return codePoint > 31 && (codePoint < 127 || codePoint > 159);\n }),\n \"Must be single-line text without control characters.\",\n );\nconst projectUrlSchema = z.string().url(\"Must be a valid URL.\");\nconst projectResourceNames = z\n .array(projectTextSchema)\n .refine((items) => new Set(items).size === items.length, \"Entries must be unique.\");\nconst projectDocsSchema = z\n .array(projectUrlSchema)\n .refine((items) => new Set(items).size === items.length, \"Documentation URLs must be unique.\");\nconst projectOwnsSchema = z\n .array(projectIdSchema)\n .refine((items) => new Set(items).size === items.length, \"Ownership entries must be unique.\");\n\nexport const projectMetadataSchema = z.strictObject({\n id: projectIdSchema.describe(\"Stable, human-authored project identifier in kebab-case.\"),\n name: projectTextSchema.describe(\"Human-readable project name.\"),\n description: projectTextSchema.optional().describe(\"Short description of this project.\"),\n repository: projectUrlSchema\n .optional()\n .describe(\"Repository URL; descriptive and never fetched.\"),\n docs: projectDocsSchema.default([]).describe(\"Documentation URLs; descriptive only.\"),\n mcp: projectResourceNames.default([]).describe(\"MCP server identifiers available to consult.\"),\n owns: projectOwnsSchema.default([]).describe(\"Architectural capabilities owned by this project.\"),\n});\n\nexport const projectRelationTypeSchema = z.enum([\"uses\", \"integrates\", \"consumes\", \"extends\"]);\n\nexport const projectRelationSchema = z.strictObject({\n id: projectIdSchema.describe(\"Stable identifier for the related project.\"),\n name: projectTextSchema.describe(\"Human-readable related project name.\"),\n type: projectRelationTypeSchema.describe(\"How the current project relates to this project.\"),\n role: projectIdSchema.describe(\"Architectural role of the related project.\"),\n repository: projectUrlSchema\n .optional()\n .describe(\"Repository URL; descriptive and never fetched.\"),\n docs: projectDocsSchema.default([]).describe(\"Documentation URLs; descriptive only.\"),\n mcp: projectResourceNames.default([]).describe(\"MCP server identifiers available to consult.\"),\n owns: projectOwnsSchema.default([]).describe(\"Architectural capabilities owned by this project.\"),\n guidance: z.array(projectTextSchema).default([]).describe(\"Human-authored guidance for agents.\"),\n});\n\nexport const projectCommandSchema = z.strictObject({\n command: projectTextSchema.describe(\"Suggested command; Agentyx never executes it.\"),\n cwd: z.string().min(1).default(\".\").describe(\"Project-relative working directory.\"),\n});\n\nexport const projectContextSchema = z\n .strictObject({\n commands: z\n .record(\n z\n .string()\n .min(1)\n .refine((name) => name.trim().length > 0, \"Command names must not be blank.\"),\n projectCommandSchema,\n )\n .default({}),\n areas: z\n .array(\n z.strictObject({\n path: z.string().min(1),\n purpose: projectTextSchema,\n }),\n )\n .default([]),\n constraints: z.array(projectTextSchema).default([]),\n })\n .describe(\"Explicit repository-local facts for the generated project context Skill.\");\n\n/** The `.agentyx.json` project configuration. */\nexport const agentyxConfigSchema = z\n .strictObject({\n $schema: z\n .string()\n .min(1, \"$schema must be a non-empty string.\")\n .describe(\"Optional path or URL to the Agentyx JSON Schema.\")\n .optional(),\n packs: z.array(packNameSchema).describe(\"Capability packs this project selects.\").default([]),\n enable: z\n .array(enabledCapabilityNameSchema)\n .describe(\"Optional capabilities to activate by explicit identifier.\")\n .default([]),\n targets: z\n .array(agentyxTargetSchema)\n .describe(\"Coding-agent providers this project targets.\")\n .default([]),\n skillDirectories: z\n .array(skillDirectorySchema)\n .describe(\"Project-relative roots containing local Agent Skills.\")\n .optional(),\n localPacks: z\n .array(packDefinitionSchema)\n .describe(\"Project-owned packs that can reference built-in or local Skills.\")\n .optional(),\n trustedSources: z\n .array(trustedSourceReferenceSchema)\n .describe(\"Pinned local checkouts of known external skill/plugin sources.\")\n .optional(),\n project: projectMetadataSchema.optional().describe(\"Identity and ownership for this project.\"),\n relations: z\n .array(projectRelationSchema)\n .optional()\n .describe(\"Direct architectural relationships.\"),\n context: projectContextSchema.optional(),\n })\n .superRefine((config, context) => {\n const relations = config.relations ?? [];\n if (relations.length > 0 && config.project === undefined) {\n context.addIssue({\n code: \"custom\",\n path: [\"project\"],\n message: \"Project metadata is required when relations are configured.\",\n });\n }\n const ids = new Set<string>();\n for (const [index, relation] of relations.entries()) {\n if (config.project?.id === relation.id) {\n context.addIssue({\n code: \"custom\",\n path: [\"relations\", index, \"id\"],\n message: \"A project cannot relate to itself.\",\n });\n }\n if (ids.has(relation.id)) {\n context.addIssue({\n code: \"custom\",\n path: [\"relations\", index, \"id\"],\n message: \"Related project ids must be unique.\",\n });\n }\n ids.add(relation.id);\n }\n const areaPaths = config.context?.areas.map((area) => area.path) ?? [];\n if (new Set(areaPaths).size !== areaPaths.length) {\n context.addIssue({\n code: \"custom\",\n path: [\"context\", \"areas\"],\n message: \"Area paths must be unique.\",\n });\n }\n });\n\n/** A validated configuration, with defaults applied. */\nexport type AgentyxConfig = z.infer<typeof agentyxConfigSchema>;\n\n/** The shape accepted in a `.agentyx.json` file. */\nexport type AgentyxConfigInput = z.input<typeof agentyxConfigSchema>;\nexport type ProjectMetadata = z.infer<typeof projectMetadataSchema>;\nexport type ProjectRelation = z.infer<typeof projectRelationSchema>;\nexport type ProjectContext = z.infer<typeof projectContextSchema>;\n","import { z } from \"zod\";\nimport { agentyxConfigSchema } from \"./schema.js\";\n\n/** Canonical identifier of the published `.agentyx.json` schema. */\nexport const AGENTYX_CONFIG_SCHEMA_ID =\n \"https://raw.githubusercontent.com/Andersseen/agentyx/main/packages/core/schema/agentyx.schema.json\";\n\n/**\n * Derives the JSON Schema for `.agentyx.json` from the Zod model, which stays the\n * single source of truth. The committed `schema/agentyx.schema.json` is generated\n * from this function and verified by tests.\n *\n * The `input` view is used so that fields with defaults stay optional, which is\n * what an author writing the file cares about.\n */\nexport function buildAgentyxConfigJsonSchema(): Record<string, unknown> {\n return {\n $schema: \"https://json-schema.org/draft/2020-12/schema\",\n $id: AGENTYX_CONFIG_SCHEMA_ID,\n title: \"Agentyx project configuration\",\n description: \"Configuration for an Agentyx project (.agentyx.json).\",\n ...z.toJSONSchema(agentyxConfigSchema, { io: \"input\" }),\n };\n}\n","import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport {\n AgentyxConfigNotFoundError,\n AgentyxConfigParseError,\n AgentyxConfigValidationError,\n} from \"./errors.js\";\nimport { type AgentyxConfig, agentyxConfigSchema } from \"./schema.js\";\n\nexport const AGENTYX_CONFIG_FILENAME = \".agentyx.json\";\n\n/** The absolute path `.agentyx.json` is read from for a given project. */\nexport function agentyxConfigPath(projectPath: string = process.cwd()): string {\n return resolve(projectPath, AGENTYX_CONFIG_FILENAME);\n}\n\n/**\n * Validates an already-parsed configuration document.\n *\n * @throws {AgentyxConfigValidationError} when the document violates the schema.\n */\nexport function parseAgentyxConfig(value: unknown, filePath?: string): AgentyxConfig {\n const result = agentyxConfigSchema.safeParse(value);\n\n if (!result.success) {\n throw new AgentyxConfigValidationError(result.error, filePath);\n }\n\n return result.data;\n}\n\n/**\n * Reads and validates `.agentyx.json` from `projectPath`.\n *\n * Parent directories are not searched, and invalid configurations are never\n * silently repaired.\n *\n * @throws {AgentyxConfigNotFoundError} when the file does not exist.\n * @throws {AgentyxConfigParseError} when the file is not valid JSON.\n * @throws {AgentyxConfigValidationError} when the document violates the schema.\n */\nexport async function loadAgentyxConfig(\n projectPath: string = process.cwd(),\n): Promise<AgentyxConfig> {\n const filePath = agentyxConfigPath(projectPath);\n let contents: string;\n\n try {\n contents = await readFile(filePath, \"utf8\");\n } catch (cause) {\n if (isFileNotFound(cause)) {\n throw new AgentyxConfigNotFoundError(filePath, { cause });\n }\n\n throw cause;\n }\n\n let document: unknown;\n\n try {\n document = JSON.parse(contents);\n } catch (cause) {\n const reason = cause instanceof Error ? cause.message : String(cause);\n throw new AgentyxConfigParseError(filePath, reason, { cause });\n }\n\n return parseAgentyxConfig(document, filePath);\n}\n\nfunction isFileNotFound(cause: unknown): boolean {\n return cause instanceof Error && (cause as NodeJS.ErrnoException).code === \"ENOENT\";\n}\n","import { fileURLToPath } from \"node:url\";\n\n/**\n * Location of the non-code assets that ship with `@agentyx/core`.\n *\n * **This module must stay directly under `src/`.** The path is derived from\n * `import.meta.url` rather than the working directory, and `src/assets.ts` and\n * the bundled `dist/index.mjs` sit at the same depth below the package root, so\n * one relative path is correct both in development and in the published\n * package. Moving this file into a subdirectory breaks built-in skill loading;\n * `packages/core/test/built-in-skills.test.ts` guards against that.\n *\n * `skills/` is listed in the package's `files`, so it is published alongside\n * `dist/`.\n */\nexport const BUILT_IN_SKILLS_PATH = fileURLToPath(new URL(\"../skills\", import.meta.url));\nexport const PROJECT_CONTEXT_TEMPLATE_PATH = fileURLToPath(\n new URL(\"../templates/project-context.md\", import.meta.url),\n);\n","import { AgentyxError } from \"../errors.js\";\n\n/** Raised when a requested pack is not present in the registry. */\nexport class UnknownPackError extends AgentyxError {\n readonly packName: string;\n readonly requiredBy: string | undefined;\n readonly knownPacks: readonly string[];\n\n constructor(packName: string, requiredBy: string | undefined, knownPacks: readonly string[]) {\n const origin = requiredBy === undefined ? \"\" : ` (required by \"${requiredBy}\")`;\n const known = knownPacks.length > 0 ? [...knownPacks].sort().join(\", \") : \"none\";\n\n super(\"unknown_pack\", `Unknown pack \"${packName}\"${origin}. Known packs: ${known}.`);\n this.name = \"UnknownPackError\";\n this.packName = packName;\n this.requiredBy = requiredBy;\n this.knownPacks = knownPacks;\n }\n}\n\n/** @deprecated Packs no longer inherit from other packs. */\nexport class CircularPackDependencyError extends AgentyxError {\n /** The cycle path, starting and ending with the same pack. */\n readonly cycle: readonly string[];\n\n constructor(cycle: readonly string[]) {\n super(\"circular_pack_dependency\", `Circular pack dependency: ${cycle.join(\" -> \")}.`);\n this.name = \"CircularPackDependencyError\";\n this.cycle = cycle;\n }\n}\n\n/** Raised when a registry is built from definitions that reuse a pack name. */\nexport class DuplicatePackError extends AgentyxError {\n readonly packName: string;\n\n constructor(packName: string) {\n super(\"duplicate_pack\", `Duplicate pack definition: \"${packName}\".`);\n this.name = \"DuplicatePackError\";\n this.packName = packName;\n }\n}\n","import { DuplicatePackError } from \"./errors.js\";\nimport { type PackDefinition, type PackDefinitionInput, packDefinitionSchema } from \"./schema.js\";\n\n/**\n * A registry is a name lookup over pack definitions. Keeping it a plain map\n * means the resolver stays independent of where definitions come from, so\n * external registries can be added later without touching resolution.\n */\nexport type PackRegistry = ReadonlyMap<string, PackDefinition>;\n\n/** Validates definitions and indexes them by name. */\nexport function createPackRegistry(definitions: Iterable<PackDefinitionInput>): PackRegistry {\n const registry = new Map<string, PackDefinition>();\n\n for (const definition of definitions) {\n const pack = packDefinitionSchema.parse(definition);\n\n if (registry.has(pack.name)) {\n throw new DuplicatePackError(pack.name);\n }\n\n registry.set(pack.name, pack);\n }\n\n return registry;\n}\n\n/**\n * The packs Agentyx ships with, expressed as data. Relationships live here, not\n * in the resolver.\n */\nexport const builtInPacks: readonly PackDefinitionInput[] = [\n {\n name: \"technical\",\n category: \"engineering\",\n description: \"General software-engineering quality independent of language or framework.\",\n skills: [\"engineering-principles\", \"code-quality\", \"api-design\", \"code-review\"],\n },\n {\n name: \"typescript\",\n category: \"language\",\n description: \"TypeScript language conventions for strict, modern code.\",\n skills: [\"typescript-strict\", \"typescript-modeling\", \"typescript-modern\"],\n },\n {\n name: \"angular\",\n category: \"framework\",\n description: \"Modern Angular development environment.\",\n skills: [\"angular-modern\", \"angular-signals\", \"angular-architecture\", \"angular-testing\"],\n mcpServers: [\"context7\"],\n },\n {\n name: \"efficiency\",\n category: \"efficiency\",\n description: \"Reduce context and tool overhead without weakening verification.\",\n skills: [\n \"context-efficient-development\",\n \"concise-output\",\n \"targeted-exploration\",\n \"focused-verification\",\n ],\n mcpServers: [{ name: \"codebase-memory\", activation: \"optional\" }],\n tools: [{ name: \"rtk\", activation: \"optional\" }],\n hooks: [{ name: \"session-doctor-bootstrap\", activation: \"default\" }],\n },\n {\n name: \"agentic\",\n category: \"workflow\",\n description: \"Provider-neutral development workflows for substantial coding-agent work.\",\n skills: [\n \"brainstorming\",\n \"planning\",\n \"systematic-debugging\",\n \"verification\",\n \"parallel-work\",\n \"worktree-workflow\",\n \"subagent-driven-development\",\n \"requesting-code-review\",\n ],\n },\n {\n name: \"testing\",\n category: \"engineering\",\n description: \"Test design, isolation and stability at every level of the pyramid.\",\n skills: [\"test-strategy\", \"test-doubles\", \"e2e-testing\", \"flaky-tests\"],\n mcpServers: [{ name: \"playwright\", activation: \"optional\" }],\n },\n {\n name: \"security\",\n category: \"engineering\",\n description: \"Application security fundamentals for untrusted input, secrets and access.\",\n skills: [\"secure-coding\", \"secrets-handling\", \"dependency-security\", \"auth-patterns\"],\n },\n {\n name: \"performance\",\n category: \"engineering\",\n description: \"Measure before optimizing, across application, browser and database.\",\n skills: [\"performance-profiling\", \"web-vitals\", \"query-performance\"],\n mcpServers: [{ name: \"chrome-devtools\", activation: \"optional\" }],\n },\n {\n name: \"accessibility\",\n category: \"engineering\",\n description: \"Accessible markup, ARIA and keyboard interaction for web interfaces.\",\n skills: [\"semantic-html\", \"aria-patterns\", \"keyboard-navigation\"],\n mcpServers: [{ name: \"chrome-devtools\", activation: \"optional\" }],\n },\n {\n name: \"refactoring\",\n category: \"engineering\",\n description: \"Change structure safely, including in legacy code with weak tests.\",\n skills: [\"refactoring-safely\", \"legacy-code\", \"dependency-hygiene\"],\n },\n {\n name: \"documentation\",\n category: \"engineering\",\n description: \"Documentation, interface reference and decision records that stay useful.\",\n skills: [\"technical-writing\", \"api-documentation\", \"decision-records\"],\n },\n {\n name: \"observability\",\n category: \"engineering\",\n description: \"Logging, metrics, tracing and incident response for running systems.\",\n skills: [\"structured-logging\", \"metrics-and-tracing\", \"incident-response\"],\n mcpServers: [{ name: \"sentry\", activation: \"optional\" }],\n },\n {\n name: \"data\",\n category: \"engineering\",\n description: \"Schema design, migrations and transactional correctness.\",\n skills: [\"data-modeling\", \"schema-migrations\", \"transactions-and-consistency\"],\n mcpServers: [{ name: \"supabase\", activation: \"optional\" }],\n },\n {\n name: \"git\",\n category: \"workflow\",\n description: \"Commit, branch and pull-request practice for reviewable history.\",\n skills: [\"commit-hygiene\", \"branching-strategy\", \"pull-requests\"],\n mcpServers: [{ name: \"github\", activation: \"optional\" }],\n },\n {\n name: \"devops\",\n category: \"workflow\",\n description: \"Continuous integration, containers, deployment safety and infrastructure.\",\n skills: [\"ci-pipelines\", \"containerization\", \"deployment-safety\", \"infrastructure-as-code\"],\n },\n];\n\n/** The registry used by default when no explicit registry is supplied. */\nexport const builtInPackRegistry: PackRegistry = createPackRegistry(builtInPacks);\n","import type { ZodError } from \"zod\";\nimport { AgentyxError } from \"../errors.js\";\n\n/**\n * Raised when a pack references a skill the registry does not know.\n *\n * The offending name is exposed as `skillName`; `pack` stays the JS pack\n * trace inherited from `Error`.\n */\nexport class UnknownSkillError extends AgentyxError {\n readonly skillName: string;\n /** The pack that declared the skill, when the failure came from resolution. */\n readonly requiredBy: string | undefined;\n readonly knownSkills: readonly string[];\n\n constructor(skillName: string, requiredBy: string | undefined, knownSkills: readonly string[]) {\n const origin = requiredBy === undefined ? \"\" : ` (required by pack \"${requiredBy}\")`;\n const known = knownSkills.length > 0 ? [...knownSkills].sort().join(\", \") : \"none\";\n\n super(\"unknown_skill\", `Unknown skill \"${skillName}\"${origin}. Known skills: ${known}.`);\n this.name = \"UnknownSkillError\";\n this.skillName = skillName;\n this.requiredBy = requiredBy;\n this.knownSkills = knownSkills;\n }\n}\n\n/** Raised when a registry is built from sources that reuse a skill name. */\nexport class DuplicateSkillError extends AgentyxError {\n readonly skillName: string;\n\n constructor(skillName: string) {\n super(\"duplicate_skill\", `Duplicate skill definition: \"${skillName}\".`);\n this.name = \"DuplicateSkillError\";\n this.skillName = skillName;\n }\n}\n\n/**\n * Raised when a skill exists but cannot be turned into a valid definition —\n * malformed `SKILL.md` frontmatter, a missing field, an unreadable file.\n *\n * Built-in skills ship with Agentyx, so this is a programmer error rather than\n * something a user can fix in their project.\n */\nexport class InvalidSkillError extends AgentyxError {\n /** Where the skill came from: a file path, or a label for an in-memory source. */\n readonly origin: string;\n readonly reason: string;\n\n constructor(origin: string, reason: string | ZodError, options?: ErrorOptions) {\n const detail = typeof reason === \"string\" ? reason : formatIssues(reason);\n\n super(\"invalid_skill\", `Invalid skill in ${origin}: ${detail}`, options);\n this.name = \"InvalidSkillError\";\n this.origin = origin;\n this.reason = detail;\n }\n}\n\nfunction formatIssues(error: ZodError): string {\n return error.issues\n .map((issue) => {\n const path = issue.path.map(String).join(\".\");\n\n return path === \"\" ? issue.message : `${path}: ${issue.message}`;\n })\n .join(\"; \");\n}\n","import { InvalidSkillError } from \"./errors.js\";\nimport {\n type SkillDefinition,\n type SkillDefinitionInput,\n skillDefinitionSchema,\n skillMetadataSchema,\n} from \"./schema.js\";\n\nconst DELIMITER = \"---\";\nconst BYTE_ORDER_MARK = /^\\uFEFF/;\nconst LINE_BREAK = /[\\r\\n]/;\n\n/**\n * A `SKILL.md` file is a frontmatter block followed by the Markdown body:\n *\n * ```md\n * ---\n * name: planning\n * description: Plan non-trivial work before editing.\n * ---\n *\n * Instructions...\n * ```\n *\n * The frontmatter is a deliberately small YAML subset — a flat block of\n * `key: value` pairs, values optionally quoted — so that core keeps depending\n * on Zod alone. Anything richer is rejected rather than guessed at.\n *\n * The body is preserved as written apart from trimming the blank lines around\n * it, and `origin` is only used to make errors readable.\n *\n * @throws {InvalidSkillError} when the frontmatter or the resulting skill is invalid.\n */\nexport function parseSkillMarkdown(markdown: string, origin: string): SkillDefinition {\n const lines = markdown.replace(BYTE_ORDER_MARK, \"\").split(/\\r?\\n/);\n\n if (lines[0]?.trim() !== DELIMITER) {\n throw new InvalidSkillError(\n origin,\n `the file must start with a \"${DELIMITER}\" frontmatter line`,\n );\n }\n\n const closing = lines.findIndex((line, index) => index > 0 && line.trim() === DELIMITER);\n\n if (closing === -1) {\n throw new InvalidSkillError(\n origin,\n `the frontmatter block is never closed with \"${DELIMITER}\"`,\n );\n }\n\n const metadata = skillMetadataSchema.safeParse(parseFrontmatter(lines.slice(1, closing), origin));\n\n if (!metadata.success) {\n throw new InvalidSkillError(origin, metadata.error);\n }\n\n const skill = skillDefinitionSchema.safeParse({\n ...metadata.data,\n content: lines.slice(closing + 1).join(\"\\n\"),\n });\n\n if (!skill.success) {\n throw new InvalidSkillError(origin, skill.error);\n }\n\n return skill.data;\n}\n\n/**\n * Renders a skill as canonical `SKILL.md` text — the inverse of\n * `parseSkillMarkdown`, and the single representation every consumer installs.\n *\n * Keeping this in core is what stops a provider from owning a copy of a skill\n * body: an adapter decides *where* a skill goes, never what it says.\n *\n * The output is deterministic. Frontmatter is always `name` then `description`,\n * the body is the trimmed content, and the file ends with exactly one newline,\n * so re-rendering an unchanged skill produces a byte-identical file and an\n * installer can compare content instead of guessing.\n *\n * @throws {InvalidSkillError} when the definition is invalid, or when the\n * description cannot be represented in the flat frontmatter subset the parser\n * accepts.\n */\nexport function formatSkillMarkdown(skill: SkillDefinitionInput): string {\n const origin = typeof skill.name === \"string\" ? `skill \"${skill.name}\"` : \"skill definition\";\n const parsed = skillDefinitionSchema.safeParse(skill);\n\n if (!parsed.success) {\n throw new InvalidSkillError(origin, parsed.error);\n }\n\n const { name, description, content } = parsed.data;\n\n if (LINE_BREAK.test(description)) {\n throw new InvalidSkillError(origin, \"the description must not contain a line break\");\n }\n\n return `${DELIMITER}\\nname: ${name}\\ndescription: ${description}\\n${DELIMITER}\\n\\n${content}\\n`;\n}\n\nfunction parseFrontmatter(lines: readonly string[], origin: string): Record<string, string> {\n const entries = new Map<string, string>();\n\n for (const [index, line] of lines.entries()) {\n if (line.trim() === \"\") {\n continue;\n }\n\n const separator = line.indexOf(\":\");\n // +2: the opening delimiter line, plus the shift from a zero-based index.\n const lineNumber = index + 2;\n\n if (separator === -1) {\n throw new InvalidSkillError(\n origin,\n `frontmatter line ${lineNumber} is not \"key: value\": ${line}`,\n );\n }\n\n const key = line.slice(0, separator).trim();\n\n if (key === \"\") {\n throw new InvalidSkillError(origin, `frontmatter line ${lineNumber} has an empty key`);\n }\n\n if (entries.has(key)) {\n throw new InvalidSkillError(\n origin,\n `duplicate frontmatter key \"${key}\" on line ${lineNumber}`,\n );\n }\n\n entries.set(key, unquote(line.slice(separator + 1).trim()));\n }\n\n return Object.fromEntries(entries);\n}\n\nfunction unquote(value: string): string {\n const quoted = /^\"(.*)\"$|^'(.*)'$/.exec(value);\n\n return quoted?.[1] ?? quoted?.[2] ?? value;\n}\n","import { DuplicateSkillError, InvalidSkillError, UnknownSkillError } from \"./errors.js\";\nimport {\n type SkillDefinition,\n type SkillDefinitionInput,\n skillDefinitionSchema,\n skillNameSchema,\n} from \"./schema.js\";\n\n/**\n * Where a single skill comes from. The name is known up front so that listing\n * and existence checks stay cheap, and `load` is only called when something\n * actually needs the instructions — a design that keeps `resolve` working on\n * identifiers alone.\n *\n * This is also the seam an external or remote registry would plug into later.\n */\nexport interface SkillSource {\n readonly name: string;\n /** Produces the definition. Called at most once per registry. */\n load(): SkillDefinitionInput;\n}\n\n/** A name lookup over skills, independent of where the definitions live. */\nexport interface SkillRegistry {\n /** Registered names in registration order. Never reads a skill body. */\n readonly names: readonly string[];\n has(name: string): boolean;\n /**\n * Loads, validates and caches a skill.\n *\n * @throws {UnknownSkillError} when the name is not registered.\n * @throws {InvalidSkillError} when the source yields an invalid definition.\n */\n get(name: string): SkillDefinition;\n}\n\n/**\n * Indexes skill sources by name.\n *\n * Names and duplicates are validated here; the definitions themselves are\n * validated the first time each skill is loaded.\n *\n * @throws {DuplicateSkillError} when two sources share a name.\n * @throws {InvalidSkillError} when a source name is not a valid skill name.\n */\nexport function createSkillRegistry(sources: Iterable<SkillSource>): SkillRegistry {\n const byName = new Map<string, SkillSource>();\n\n for (const source of sources) {\n const name = skillNameSchema.safeParse(source.name);\n\n if (!name.success) {\n throw new InvalidSkillError(`skill source \"${source.name}\"`, name.error);\n }\n\n if (byName.has(name.data)) {\n throw new DuplicateSkillError(name.data);\n }\n\n byName.set(name.data, source);\n }\n\n const names = [...byName.keys()];\n const loaded = new Map<string, SkillDefinition>();\n\n return {\n names,\n has: (name) => byName.has(name),\n get: (name) => {\n const cached = loaded.get(name);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const source = byName.get(name);\n\n if (source === undefined) {\n throw new UnknownSkillError(name, undefined, names);\n }\n\n const origin = `skill \"${name}\"`;\n const skill = skillDefinitionSchema.safeParse(source.load());\n\n if (!skill.success) {\n throw new InvalidSkillError(origin, skill.error);\n }\n\n if (skill.data.name !== name) {\n throw new InvalidSkillError(origin, `it declares the name \"${skill.data.name}\"`);\n }\n\n loaded.set(name, skill.data);\n\n return skill.data;\n },\n };\n}\n","import { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { BUILT_IN_SKILLS_PATH } from \"../assets.js\";\nimport { InvalidSkillError } from \"./errors.js\";\nimport { parseSkillMarkdown } from \"./markdown.js\";\nimport { createSkillRegistry, type SkillRegistry } from \"./registry.js\";\nimport type { SkillDefinition } from \"./schema.js\";\n\n/**\n * The skills Agentyx ships with. The names are the directory names under\n * `packages/core/skills`, and knowing them without touching the filesystem is\n * what lets pack resolution validate references without reading any body.\n */\nexport const builtInSkillNames = [\n \"engineering-principles\",\n \"code-quality\",\n \"api-design\",\n \"code-review\",\n \"planning\",\n \"systematic-debugging\",\n \"verification\",\n \"brainstorming\",\n \"parallel-work\",\n \"worktree-workflow\",\n \"subagent-driven-development\",\n \"requesting-code-review\",\n \"typescript-strict\",\n \"typescript-modeling\",\n \"typescript-modern\",\n \"angular-modern\",\n \"angular-signals\",\n \"angular-architecture\",\n \"angular-testing\",\n \"context-efficient-development\",\n \"concise-output\",\n \"targeted-exploration\",\n \"focused-verification\",\n \"test-strategy\",\n \"test-doubles\",\n \"e2e-testing\",\n \"flaky-tests\",\n \"secure-coding\",\n \"secrets-handling\",\n \"dependency-security\",\n \"auth-patterns\",\n \"performance-profiling\",\n \"web-vitals\",\n \"query-performance\",\n \"semantic-html\",\n \"aria-patterns\",\n \"keyboard-navigation\",\n \"refactoring-safely\",\n \"legacy-code\",\n \"dependency-hygiene\",\n \"technical-writing\",\n \"api-documentation\",\n \"decision-records\",\n \"structured-logging\",\n \"metrics-and-tracing\",\n \"incident-response\",\n \"data-modeling\",\n \"schema-migrations\",\n \"transactions-and-consistency\",\n \"commit-hygiene\",\n \"branching-strategy\",\n \"pull-requests\",\n \"ci-pipelines\",\n \"containerization\",\n \"deployment-safety\",\n \"infrastructure-as-code\",\n] as const;\n\n/** The absolute path of a built-in skill's `SKILL.md`. */\nexport function builtInSkillPath(name: string): string {\n return join(BUILT_IN_SKILLS_PATH, name, \"SKILL.md\");\n}\n\n/** The registry used by default when no explicit registry is supplied. */\nexport const builtInSkillRegistry: SkillRegistry = createSkillRegistry(\n builtInSkillNames.map((name) => ({ name, load: () => loadBuiltInSkill(name) })),\n);\n\n/**\n * Reads one built-in `SKILL.md`.\n *\n * Reading is synchronous on purpose: the files are small package assets, they\n * are only touched when a command asks for instructions, and a synchronous read\n * keeps `SkillRegistry.get` a plain lookup instead of infecting every caller\n * with a promise.\n */\nfunction loadBuiltInSkill(name: string): SkillDefinition {\n const filePath = builtInSkillPath(name);\n let markdown: string;\n\n try {\n markdown = readFileSync(filePath, \"utf8\");\n } catch (cause) {\n const reason = cause instanceof Error ? cause.message : String(cause);\n\n throw new InvalidSkillError(filePath, `the file could not be read: ${reason}`, { cause });\n }\n\n return parseSkillMarkdown(markdown, filePath);\n}\n","import { AgentyxError } from \"../errors.js\";\n\nexport class DuplicateTrustedSourceError extends AgentyxError {\n readonly sourceName: string;\n\n constructor(sourceName: string) {\n super(\"duplicate_trusted_source\", `Duplicate trusted source \"${sourceName}\".`);\n this.name = \"DuplicateTrustedSourceError\";\n this.sourceName = sourceName;\n }\n}\n\nexport class UnknownTrustedSourceError extends AgentyxError {\n readonly sourceName: string;\n readonly knownSources: readonly string[];\n\n constructor(sourceName: string, knownSources: readonly string[]) {\n const known = knownSources.length > 0 ? [...knownSources].sort().join(\", \") : \"none\";\n\n super(\n \"unknown_trusted_source\",\n `Unknown trusted source \"${sourceName}\". Known trusted sources: ${known}.`,\n );\n this.name = \"UnknownTrustedSourceError\";\n this.sourceName = sourceName;\n this.knownSources = knownSources;\n }\n}\n\nexport class TrustedSourceLoadError extends AgentyxError {\n readonly sourceName: string;\n\n constructor(sourceName: string, reason: string, options?: ErrorOptions) {\n super(\n \"trusted_source_load_error\",\n `Could not load trusted source \"${sourceName}\": ${reason}`,\n options,\n );\n this.name = \"TrustedSourceLoadError\";\n this.sourceName = sourceName;\n }\n}\n","import { DuplicateTrustedSourceError, UnknownTrustedSourceError } from \"./errors.js\";\nimport {\n type TrustedSourceDefinition,\n type TrustedSourceReference,\n trustedSourceDefinitionSchema,\n} from \"./schema.js\";\n\nexport type TrustedSourceRegistry = ReadonlyMap<string, TrustedSourceDefinition>;\n\nexport const knownTrustedSources: readonly TrustedSourceDefinition[] = [\n trustedSourceDefinitionSchema.parse({\n name: \"superpowers\",\n displayName: \"Superpowers\",\n repository: \"https://github.com/obra/superpowers\",\n type: \"codex-plugin\",\n manifestPath: \".codex-plugin/plugin.json\",\n recommendedPath: \".agentyx/sources/superpowers\",\n description:\n \"Agentic planning, TDD, debugging, code review and delivery workflows packaged as a Codex plugin.\",\n installStatus: \"metadata-only\",\n installNote:\n \"Agentyx can inspect and verify the local plugin checkout, but does not install its resource-bearing skills yet.\",\n }),\n];\n\nexport const knownTrustedSourceRegistry: TrustedSourceRegistry =\n createTrustedSourceRegistry(knownTrustedSources);\n\nexport function createTrustedSourceRegistry(\n definitions: Iterable<TrustedSourceDefinition>,\n): TrustedSourceRegistry {\n const registry = new Map<string, TrustedSourceDefinition>();\n\n for (const definition of definitions) {\n const parsed = trustedSourceDefinitionSchema.parse(definition);\n\n if (registry.has(parsed.name)) {\n throw new DuplicateTrustedSourceError(parsed.name);\n }\n\n registry.set(parsed.name, parsed);\n }\n\n return registry;\n}\n\nexport function getTrustedSourceDefinition(\n source: string | TrustedSourceReference,\n registry: TrustedSourceRegistry = knownTrustedSourceRegistry,\n): TrustedSourceDefinition {\n const name = typeof source === \"string\" ? source : source.name;\n const definition = registry.get(name);\n\n if (definition === undefined) {\n throw new UnknownTrustedSourceError(name, [...registry.keys()]);\n }\n\n return definition;\n}\n","import type { Dirent } from \"node:fs\";\nimport { readFileSync } from \"node:fs\";\nimport { readdir, readFile, realpath, stat } from \"node:fs/promises\";\nimport { isAbsolute, join, relative, resolve, sep } from \"node:path\";\nimport { PROJECT_CONTEXT_TEMPLATE_PATH } from \"../assets.js\";\nimport type { PackRegistry } from \"../pack/registry.js\";\nimport { builtInPackRegistry, builtInPacks, createPackRegistry } from \"../pack/registry.js\";\nimport { builtInSkillRegistry } from \"../skill/built-in.js\";\nimport { DuplicateSkillError } from \"../skill/errors.js\";\nimport { parseSkillMarkdown } from \"../skill/markdown.js\";\nimport { createSkillRegistry, type SkillRegistry, type SkillSource } from \"../skill/registry.js\";\nimport type { SkillDefinition } from \"../skill/schema.js\";\nimport { getTrustedSourceDefinition } from \"../source/registry.js\";\nimport { LocalSkillDirectoryError, ProjectContextPathError } from \"./errors.js\";\nimport { loadAgentyxConfig } from \"./loader.js\";\nimport type { AgentyxConfig } from \"./schema.js\";\n\n/** A validated project configuration plus the registries it owns. */\nexport interface AgentyxProject {\n readonly config: AgentyxConfig;\n readonly packRegistry: PackRegistry;\n readonly skillRegistry: SkillRegistry;\n readonly graph: import(\"../project-graph.js\").ProjectGraph | undefined;\n}\n\n/**\n * Loads `.agentyx.json` and any checked-in Agent Skills it declares.\n *\n * A Skill root contains one directory per Skill, each with a `SKILL.md`. Roots must resolve inside\n * the project even through symlinks. Loading is local-only: this function never clones a repository\n * or accesses the network.\n */\nexport async function loadAgentyxProject(\n projectPath: string = process.cwd(),\n): Promise<AgentyxProject> {\n const projectDir = resolve(projectPath);\n const config = await loadAgentyxConfig(projectDir);\n await validateContextPaths(projectDir, config.context);\n for (const source of config.trustedSources ?? []) {\n getTrustedSourceDefinition(source);\n }\n\n const localSources = await loadLocalSkillSources(projectDir, config.skillDirectories ?? []);\n if (localSources.some((source) => source.name === \"agentyx-project-context\")) {\n throw new DuplicateSkillError(\"agentyx-project-context\");\n }\n const generatedSources =\n config.project !== undefined || (config.context !== undefined && hasContext(config.context))\n ? [createProjectContextSkill(config.project, config.relations ?? [], config.context)]\n : [];\n const skillRegistry = createSkillRegistry([\n ...builtInSkillRegistry.names.map(\n (name): SkillSource => ({\n name,\n load: () => builtInSkillRegistry.get(name),\n }),\n ),\n ...localSources,\n ...generatedSources,\n ]);\n const packRegistry =\n config.localPacks === undefined\n ? builtInPackRegistry\n : createPackRegistry([...builtInPacks, ...config.localPacks]);\n\n const graph =\n config.project === undefined\n ? undefined\n : { project: config.project, relations: config.relations ?? [] };\n return { config, packRegistry, skillRegistry, graph };\n}\n\nfunction createProjectContextSkill(\n project: import(\"./schema.js\").ProjectMetadata | undefined,\n relations: readonly import(\"./schema.js\").ProjectRelation[],\n context: import(\"./schema.js\").ProjectContext | undefined,\n): SkillSource {\n return {\n name: \"agentyx-project-context\",\n load: () => {\n const template = readFileSync(PROJECT_CONTEXT_TEMPLATE_PATH, \"utf8\").trim();\n const data = JSON.stringify({ project, relations, context }, null, 2);\n const longestFence = Math.max(\n 0,\n ...Array.from(data.matchAll(/`+/g), (match) => match[0].length),\n );\n const fence = \"`\".repeat(Math.max(3, longestFence + 1));\n return {\n name: \"agentyx-project-context\",\n description: \"Repository facts and direct architectural relationships.\",\n content: template.replace(\"{{PROJECT_FACTS}}\", `${fence}json\\n${data}\\n${fence}`),\n };\n },\n };\n}\n\nfunction hasContext(context: import(\"./schema.js\").ProjectContext): boolean {\n return (\n Object.keys(context.commands).length > 0 ||\n context.areas.length > 0 ||\n context.constraints.length > 0\n );\n}\n\nasync function validateContextPaths(\n projectDir: string,\n context: import(\"./schema.js\").ProjectContext | undefined,\n): Promise<void> {\n if (context === undefined) return;\n const paths = [\n ...Object.values(context.commands).map(({ cwd }) => cwd),\n ...context.areas.map(({ path }) => path),\n ];\n const projectRealPath = await realpath(projectDir);\n for (const path of paths) {\n if (/^(?:\\/|[A-Za-z]:)|\\\\|(?:^|\\/)\\.\\.(?:\\/|$)/.test(path)) {\n throw new ProjectContextPathError(\n path,\n \"it must be project-relative and cannot traverse parents\",\n );\n }\n const resolvedPath = resolve(projectDir, path);\n let resolvedRealPath: string;\n try {\n resolvedRealPath = await realpath(resolvedPath);\n const pathStat = await stat(resolvedRealPath);\n if (!pathStat.isDirectory()) {\n throw new ProjectContextPathError(path, \"it must name a directory\");\n }\n } catch (cause) {\n if (cause instanceof ProjectContextPathError) throw cause;\n throw new ProjectContextPathError(\n path,\n \"it does not exist or cannot be read\",\n cause instanceof Error ? { cause } : undefined,\n );\n }\n if (!isInside(resolvedRealPath, projectRealPath)) {\n throw new ProjectContextPathError(path, \"it resolves outside the project\");\n }\n }\n}\n\nasync function loadLocalSkillSources(\n projectDir: string,\n directories: readonly string[],\n): Promise<readonly SkillSource[]> {\n const projectRealPath = await realpath(projectDir);\n const sources: SkillSource[] = [];\n\n for (const directory of directories) {\n const root = resolve(projectDir, directory);\n let rootRealPath: string;\n\n try {\n rootRealPath = await realpath(root);\n } catch (cause) {\n throw localDirectoryError(directory, \"the directory does not exist or cannot be read\", cause);\n }\n\n if (!isInside(rootRealPath, projectRealPath)) {\n throw new LocalSkillDirectoryError(directory, \"the resolved path is outside the project\");\n }\n\n let entries: Dirent[];\n\n try {\n entries = await readdir(rootRealPath, { withFileTypes: true });\n } catch (cause) {\n throw localDirectoryError(directory, \"the directory cannot be listed\", cause);\n }\n\n for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {\n if (!entry.isDirectory()) {\n continue;\n }\n\n const filePath = join(rootRealPath, entry.name, \"SKILL.md\");\n let realFilePath: string;\n\n try {\n realFilePath = await realpath(filePath);\n } catch (cause) {\n if (cause instanceof Error && (cause as NodeJS.ErrnoException).code === \"ENOENT\") {\n continue;\n }\n\n throw localDirectoryError(directory, `cannot read ${entry.name}/SKILL.md`, cause);\n }\n\n if (!isInside(realFilePath, rootRealPath)) {\n throw new LocalSkillDirectoryError(\n directory,\n `${entry.name}/SKILL.md resolves outside the skill directory`,\n );\n }\n\n let markdown: string;\n\n try {\n markdown = await readFile(realFilePath, \"utf8\");\n } catch (cause) {\n throw localDirectoryError(directory, `cannot read ${entry.name}/SKILL.md`, cause);\n }\n\n const skill: SkillDefinition = parseSkillMarkdown(markdown, filePath);\n\n if (skill.name !== entry.name) {\n throw new LocalSkillDirectoryError(\n directory,\n `${entry.name}/SKILL.md declares the name \"${skill.name}\"`,\n );\n }\n\n sources.push({ name: skill.name, load: () => skill });\n }\n }\n\n return sources;\n}\n\nfunction isInside(path: string, root: string): boolean {\n const pathFromRoot = relative(root, path);\n\n return (\n pathFromRoot === \"\" ||\n (!pathFromRoot.startsWith(`..${sep}`) && pathFromRoot !== \"..\" && !isAbsolute(pathFromRoot))\n );\n}\n\nfunction localDirectoryError(\n directory: string,\n reason: string,\n cause: unknown,\n): LocalSkillDirectoryError {\n return new LocalSkillDirectoryError(\n directory,\n reason,\n cause instanceof Error ? { cause } : undefined,\n );\n}\n","import type { ZodError } from \"zod\";\nimport { AgentyxError } from \"../errors.js\";\n\nexport class UnknownHookError extends AgentyxError {\n readonly hookName: string;\n readonly requiredBy: string | undefined;\n readonly knownHooks: readonly string[];\n\n constructor(hookName: string, requiredBy: string | undefined, knownHooks: readonly string[]) {\n const origin = requiredBy === undefined ? \"\" : ` (required by \"${requiredBy}\")`;\n const known = knownHooks.length > 0 ? [...knownHooks].sort().join(\", \") : \"none\";\n\n super(\"unknown_hook\", `Unknown hook \"${hookName}\"${origin}. Known hooks: ${known}.`);\n this.name = \"UnknownHookError\";\n this.hookName = hookName;\n this.requiredBy = requiredBy;\n this.knownHooks = knownHooks;\n }\n}\n\nexport class DuplicateHookError extends AgentyxError {\n readonly hookName: string;\n\n constructor(hookName: string) {\n super(\"duplicate_hook\", `Duplicate hook definition: \"${hookName}\".`);\n this.name = \"DuplicateHookError\";\n this.hookName = hookName;\n }\n}\n\nexport class InvalidHookError extends AgentyxError {\n readonly origin: string;\n readonly reason: string;\n\n constructor(origin: string, reason: string | ZodError, options?: ErrorOptions) {\n const detail = typeof reason === \"string\" ? reason : formatIssues(reason);\n\n super(\"invalid_hook\", `Invalid hook in ${origin}: ${detail}`, options);\n this.name = \"InvalidHookError\";\n this.origin = origin;\n this.reason = detail;\n }\n}\n\nfunction formatIssues(error: ZodError): string {\n return error.issues\n .map((issue) => {\n const path = issue.path.map(String).join(\".\");\n\n return path === \"\" ? issue.message : `${path}: ${issue.message}`;\n })\n .join(\"; \");\n}\n","import { DuplicateHookError, InvalidHookError, UnknownHookError } from \"./errors.js\";\nimport {\n type HookDefinition,\n type HookDefinitionInput,\n hookDefinitionSchema,\n hookNameSchema,\n} from \"./schema.js\";\n\nexport interface HookSource {\n readonly name: string;\n load(): HookDefinitionInput;\n}\n\nexport interface HookMetadata {\n readonly name: string;\n readonly description: string;\n readonly event: HookDefinition[\"event\"];\n}\n\nexport interface HookRegistry {\n readonly names: readonly string[];\n has(name: string): boolean;\n listMetadata(): readonly HookMetadata[];\n get(name: string): HookDefinition;\n}\n\nexport function createHookRegistry(sources: Iterable<HookSource>): HookRegistry {\n const byName = new Map<string, HookSource>();\n\n for (const source of sources) {\n const name = hookNameSchema.safeParse(source.name);\n\n if (!name.success) {\n throw new InvalidHookError(`Hook source \"${source.name}\"`, name.error);\n }\n\n if (byName.has(name.data)) {\n throw new DuplicateHookError(name.data);\n }\n\n byName.set(name.data, source);\n }\n\n const names = [...byName.keys()];\n const loaded = new Map<string, HookDefinition>();\n const get = (name: string): HookDefinition => {\n const cached = loaded.get(name);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const source = byName.get(name);\n\n if (source === undefined) {\n throw new UnknownHookError(name, undefined, names);\n }\n\n const origin = `Hook \"${name}\"`;\n const hook = hookDefinitionSchema.safeParse(source.load());\n\n if (!hook.success) {\n throw new InvalidHookError(origin, hook.error);\n }\n\n if (hook.data.name !== name) {\n throw new InvalidHookError(origin, `it declares the name \"${hook.data.name}\"`);\n }\n\n loaded.set(name, hook.data);\n\n return hook.data;\n };\n\n return {\n names,\n has: (name) => byName.has(name),\n listMetadata: () =>\n names.map((name) => {\n const hook = get(name);\n\n return {\n name: hook.name,\n description: hook.description,\n event: hook.event,\n };\n }),\n get,\n };\n}\n","import { createHookRegistry, type HookSource } from \"./registry.js\";\n\n/**\n * The hooks Agentyx ships with.\n *\n * `session-doctor-bootstrap` runs `agentyx doctor --hook` on session start: silent when the project\n * is healthy, one short line otherwise.\n *\n * The runtime contract this depends on is explicit, not assumed:\n *\n * - The command name is `agentyx` — the `bin` entry `@agentyx/cli` publishes — never a bare package\n * name for `npx` to fall back to. There is no npm package literally named `agentyx`, so if the\n * fallback ever triggered it would look up the wrong package entirely.\n * - `--no-install` makes that fallback impossible: `npx` runs the project-local\n * `node_modules/.bin/agentyx` when present and fails immediately otherwise, and never attempts a\n * registry lookup or download of any kind. A persistent hook must not depend on implicit network\n * access.\n * - This means a *persistent* hook requires `@agentyx/cli` to be an actual project dependency (for\n * example `pnpm add -D @agentyx/cli`), not just invoked ad hoc through `pnpm dlx @agentyx/cli`,\n * which never adds anything to the project. `doctor` (run directly, not through `--hook`) detects\n * a missing local binary and reports it as `hook_runtime_unavailable` — see\n * `packages/cli/src/commands/doctor.ts`. A missing binary makes the hook itself exit non-zero and\n * print nothing useful, but it never blocks a session or performs a side effect beyond that.\n */\nexport const builtInHookSources: readonly HookSource[] = [\n {\n name: \"session-doctor-bootstrap\",\n load: () => ({\n name: \"session-doctor-bootstrap\",\n description: \"Reports Agentyx project health at session start; silent when healthy.\",\n event: \"SessionStart\",\n command: \"npx\",\n args: [\"--no-install\", \"agentyx\", \"doctor\", \"--hook\"],\n }),\n },\n];\n\nexport const builtInHookRegistry = createHookRegistry(builtInHookSources);\n\nexport const builtInHookNames: readonly string[] = builtInHookRegistry.names;\n","import { UnknownPackError } from \"./errors.js\";\nimport { builtInPackRegistry, type PackRegistry } from \"./registry.js\";\n\n/**\n * Resolves selected packs without hidden inheritance.\n *\n * The result preserves configured order, removes duplicates by first\n * occurrence, and validates every requested pack.\n *\n * @throws {UnknownPackError} when a requested pack is missing.\n */\nexport function resolvePacks(\n requestedPacks: readonly string[],\n registry: PackRegistry = builtInPackRegistry,\n): string[] {\n const resolved: string[] = [];\n const seen = new Set<string>();\n\n for (const name of requestedPacks) {\n if (seen.has(name)) {\n continue;\n }\n\n if (!registry.has(name)) {\n throw new UnknownPackError(name, undefined, [...registry.keys()]);\n }\n\n seen.add(name);\n resolved.push(name);\n }\n\n return resolved;\n}\n","import { builtInPackRegistry, type PackRegistry } from \"../pack/registry.js\";\nimport { resolvePacks } from \"../pack/resolver.js\";\nimport { builtInHookRegistry } from \"./built-in.js\";\nimport { UnknownHookError } from \"./errors.js\";\nimport type { HookRegistry } from \"./registry.js\";\nimport type { HookReference } from \"./schema.js\";\n\nexport function collectPackHookReferences(\n resolvedPacks: readonly string[],\n packRegistry: PackRegistry,\n hookRegistry: HookRegistry,\n): HookReference[] {\n const hooks: HookReference[] = [];\n const seen = new Set<string>();\n\n for (const packName of resolvedPacks) {\n for (const hook of packRegistry.get(packName)?.hooks ?? []) {\n const hookName = hook.name;\n\n if (seen.has(hookName)) {\n continue;\n }\n\n if (!hookRegistry.has(hookName)) {\n throw new UnknownHookError(hookName, packName, hookRegistry.names);\n }\n\n seen.add(hookName);\n hooks.push(hook);\n }\n }\n\n return hooks;\n}\n\nexport function filterEffectiveHooks(\n hooks: readonly HookReference[],\n enabledCapabilities: readonly string[],\n): string[] {\n const enabled = new Set(enabledCapabilities);\n\n return hooks\n .filter((hook) => hook.activation === \"default\" || enabled.has(hook.name))\n .map((hook) => hook.name);\n}\n\nexport function collectPackHooks(\n resolvedPacks: readonly string[],\n packRegistry: PackRegistry,\n hookRegistry: HookRegistry,\n enabledCapabilities: readonly string[] = [],\n): string[] {\n return filterEffectiveHooks(\n collectPackHookReferences(resolvedPacks, packRegistry, hookRegistry),\n enabledCapabilities,\n );\n}\n\nexport function resolvePackHookReferences(\n requestedPacks: readonly string[],\n packRegistry: PackRegistry = builtInPackRegistry,\n hookRegistry: HookRegistry = builtInHookRegistry,\n): HookReference[] {\n return collectPackHookReferences(\n resolvePacks(requestedPacks, packRegistry),\n packRegistry,\n hookRegistry,\n );\n}\n\nexport function resolvePackHooks(\n requestedPacks: readonly string[],\n packRegistry: PackRegistry = builtInPackRegistry,\n hookRegistry: HookRegistry = builtInHookRegistry,\n enabledCapabilities: readonly string[] = [],\n): string[] {\n return collectPackHooks(\n resolvePacks(requestedPacks, packRegistry),\n packRegistry,\n hookRegistry,\n enabledCapabilities,\n );\n}\n","import type { ZodError } from \"zod\";\nimport { AgentyxError } from \"../errors.js\";\n\nexport class UnknownMcpServerError extends AgentyxError {\n readonly serverName: string;\n readonly requiredBy: string | undefined;\n readonly knownServers: readonly string[];\n\n constructor(serverName: string, requiredBy: string | undefined, knownServers: readonly string[]) {\n const origin = requiredBy === undefined ? \"\" : ` (required by \"${requiredBy}\")`;\n const known = knownServers.length > 0 ? [...knownServers].sort().join(\", \") : \"none\";\n\n super(\n \"unknown_mcp_server\",\n `Unknown MCP server \"${serverName}\"${origin}. Known MCP servers: ${known}.`,\n );\n this.name = \"UnknownMcpServerError\";\n this.serverName = serverName;\n this.requiredBy = requiredBy;\n this.knownServers = knownServers;\n }\n}\n\nexport class DuplicateMcpServerError extends AgentyxError {\n readonly serverName: string;\n\n constructor(serverName: string) {\n super(\"duplicate_mcp_server\", `Duplicate MCP server definition: \"${serverName}\".`);\n this.name = \"DuplicateMcpServerError\";\n this.serverName = serverName;\n }\n}\n\nexport class InvalidMcpServerError extends AgentyxError {\n readonly origin: string;\n readonly reason: string;\n\n constructor(origin: string, reason: string | ZodError, options?: ErrorOptions) {\n const detail = typeof reason === \"string\" ? reason : formatIssues(reason);\n\n super(\"invalid_mcp_server\", `Invalid MCP server in ${origin}: ${detail}`, options);\n this.name = \"InvalidMcpServerError\";\n this.origin = origin;\n this.reason = detail;\n }\n}\n\nfunction formatIssues(error: ZodError): string {\n return error.issues\n .map((issue) => {\n const path = issue.path.map(String).join(\".\");\n\n return path === \"\" ? issue.message : `${path}: ${issue.message}`;\n })\n .join(\"; \");\n}\n","import { DuplicateMcpServerError, InvalidMcpServerError, UnknownMcpServerError } from \"./errors.js\";\nimport {\n type McpServerDefinition,\n type McpServerDefinitionInput,\n mcpServerDefinitionSchema,\n mcpServerNameSchema,\n} from \"./schema.js\";\n\nexport interface McpServerSource {\n readonly name: string;\n load(): McpServerDefinitionInput;\n}\n\nexport interface McpServerMetadata {\n readonly name: string;\n readonly description: string;\n readonly transport: McpServerDefinition[\"transport\"];\n readonly contextCost?: McpServerDefinition[\"contextCost\"];\n readonly runtime?: McpServerDefinition[\"runtime\"];\n}\n\nexport interface McpServerRegistry {\n readonly names: readonly string[];\n has(name: string): boolean;\n listMetadata(): readonly McpServerMetadata[];\n get(name: string): McpServerDefinition;\n}\n\nexport function createMcpServerRegistry(sources: Iterable<McpServerSource>): McpServerRegistry {\n const byName = new Map<string, McpServerSource>();\n\n for (const source of sources) {\n const name = mcpServerNameSchema.safeParse(source.name);\n\n if (!name.success) {\n throw new InvalidMcpServerError(`MCP server source \"${source.name}\"`, name.error);\n }\n\n if (byName.has(name.data)) {\n throw new DuplicateMcpServerError(name.data);\n }\n\n byName.set(name.data, source);\n }\n\n const names = [...byName.keys()];\n const loaded = new Map<string, McpServerDefinition>();\n const get = (name: string): McpServerDefinition => {\n const cached = loaded.get(name);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const source = byName.get(name);\n\n if (source === undefined) {\n throw new UnknownMcpServerError(name, undefined, names);\n }\n\n const origin = `MCP server \"${name}\"`;\n const server = mcpServerDefinitionSchema.safeParse(source.load());\n\n if (!server.success) {\n throw new InvalidMcpServerError(origin, server.error);\n }\n\n if (server.data.name !== name) {\n throw new InvalidMcpServerError(origin, `it declares the name \"${server.data.name}\"`);\n }\n\n loaded.set(name, server.data);\n\n return server.data;\n };\n\n return {\n names,\n has: (name) => byName.has(name),\n listMetadata: () =>\n names.map((name) => {\n const server = get(name);\n\n return {\n name: server.name,\n description: server.description,\n transport: server.transport,\n contextCost: server.contextCost,\n runtime: server.runtime,\n };\n }),\n get,\n };\n}\n","import { createMcpServerRegistry, type McpServerSource } from \"./registry.js\";\n\n/**\n * The MCP servers Agentyx ships with, expressed as data.\n *\n * `runtime` is honest about what *enabling* a server does once a provider launches it. Agentyx\n * itself performs no network access and installs nothing — but a `stdio` server whose `command` is\n * `npx` can fetch a package from the registry on first launch, exactly like running that `npx`\n * command by hand would. Those are marked `\"may-download\"`; a remote HTTP server or a command\n * expected to already be installed locally is `\"local\"`. `doctor`, `mcp show` and `pack show`\n * surface this so a user knows before they enable it.\n *\n * `npx`-launched packages are pinned to a known-compatible version rather than `@latest`, so\n * enabling a server is reproducible and does not silently pick up a new release between installs.\n */\nexport const builtInMcpServerSources: readonly McpServerSource[] = [\n {\n name: \"context7\",\n load: () => ({\n name: \"context7\",\n description: \"Fetch up-to-date library documentation from Context7.\",\n transport: \"http\",\n contextCost: \"medium\",\n runtime: \"local\",\n url: \"https://mcp.context7.com/mcp\",\n }),\n },\n {\n name: \"playwright\",\n load: () => ({\n name: \"playwright\",\n description: \"Automate and inspect browsers through Playwright MCP.\",\n transport: \"stdio\",\n contextCost: \"high\",\n runtime: \"may-download\",\n command: \"npx\",\n args: [\"@playwright/mcp@0.0.81\"],\n }),\n },\n {\n name: \"codebase-memory\",\n load: () => ({\n name: \"codebase-memory\",\n description: \"Structural code-intelligence MCP backed by a persistent code knowledge graph.\",\n transport: \"stdio\",\n contextCost: \"high\",\n runtime: \"local\",\n command: \"codebase-memory-mcp\",\n }),\n },\n {\n name: \"github\",\n load: () => ({\n name: \"github\",\n description: \"Read repositories, issues, pull requests and workflow runs on GitHub.\",\n transport: \"http\",\n contextCost: \"high\",\n runtime: \"local\",\n url: \"https://api.githubcopilot.com/mcp/\",\n }),\n },\n {\n name: \"sentry\",\n load: () => ({\n name: \"sentry\",\n description: \"Inspect production issues, events and stack traces recorded by Sentry.\",\n transport: \"http\",\n contextCost: \"medium\",\n runtime: \"local\",\n url: \"https://mcp.sentry.dev/mcp\",\n }),\n },\n {\n name: \"chrome-devtools\",\n load: () => ({\n name: \"chrome-devtools\",\n description: \"Record performance traces and inspect pages through Chrome DevTools.\",\n transport: \"stdio\",\n contextCost: \"high\",\n runtime: \"may-download\",\n command: \"npx\",\n args: [\"-y\", \"chrome-devtools-mcp@1.9.0\"],\n }),\n },\n {\n name: \"supabase\",\n load: () => ({\n name: \"supabase\",\n description: \"Inspect and query Supabase project schemas, tables and logs.\",\n transport: \"stdio\",\n contextCost: \"high\",\n runtime: \"may-download\",\n command: \"npx\",\n args: [\"-y\", \"@supabase/mcp-server-supabase@0.13.0\"],\n env: { SUPABASE_ACCESS_TOKEN: { fromEnv: \"SUPABASE_ACCESS_TOKEN\" } },\n }),\n },\n];\n\nexport const builtInMcpServerRegistry = createMcpServerRegistry(builtInMcpServerSources);\n\nexport const builtInMcpServerNames: readonly string[] = builtInMcpServerRegistry.names;\n","import { builtInPackRegistry, type PackRegistry } from \"../pack/registry.js\";\nimport { resolvePacks } from \"../pack/resolver.js\";\nimport { builtInMcpServerRegistry } from \"./built-in.js\";\nimport { UnknownMcpServerError } from \"./errors.js\";\nimport type { McpServerRegistry } from \"./registry.js\";\nimport type { McpServerReference } from \"./schema.js\";\n\nexport function collectPackMcpServerReferences(\n resolvedPacks: readonly string[],\n packRegistry: PackRegistry,\n mcpRegistry: McpServerRegistry,\n): McpServerReference[] {\n const servers: McpServerReference[] = [];\n const seen = new Set<string>();\n\n for (const packName of resolvedPacks) {\n for (const server of packRegistry.get(packName)?.mcpServers ?? []) {\n const serverName = server.name;\n\n if (seen.has(serverName)) {\n continue;\n }\n\n if (!mcpRegistry.has(serverName)) {\n throw new UnknownMcpServerError(serverName, packName, mcpRegistry.names);\n }\n\n seen.add(serverName);\n servers.push(server);\n }\n }\n\n return servers;\n}\n\nexport function filterEffectiveMcpServers(\n servers: readonly McpServerReference[],\n enabledCapabilities: readonly string[],\n): string[] {\n const enabled = new Set(enabledCapabilities);\n\n return servers\n .filter((server) => server.activation === \"default\" || enabled.has(server.name))\n .map((server) => server.name);\n}\n\nexport function collectPackMcpServers(\n resolvedPacks: readonly string[],\n packRegistry: PackRegistry,\n mcpRegistry: McpServerRegistry,\n enabledCapabilities: readonly string[] = [],\n): string[] {\n return filterEffectiveMcpServers(\n collectPackMcpServerReferences(resolvedPacks, packRegistry, mcpRegistry),\n enabledCapabilities,\n );\n}\n\nexport function resolvePackMcpServerReferences(\n requestedPacks: readonly string[],\n packRegistry: PackRegistry = builtInPackRegistry,\n mcpRegistry: McpServerRegistry = builtInMcpServerRegistry,\n): McpServerReference[] {\n return collectPackMcpServerReferences(\n resolvePacks(requestedPacks, packRegistry),\n packRegistry,\n mcpRegistry,\n );\n}\n\nexport function resolvePackMcpServers(\n requestedPacks: readonly string[],\n packRegistry: PackRegistry = builtInPackRegistry,\n mcpRegistry: McpServerRegistry = builtInMcpServerRegistry,\n enabledCapabilities: readonly string[] = [],\n): string[] {\n return collectPackMcpServers(\n resolvePacks(requestedPacks, packRegistry),\n packRegistry,\n mcpRegistry,\n enabledCapabilities,\n );\n}\n","import { builtInPackRegistry, type PackRegistry } from \"../pack/registry.js\";\nimport { resolvePacks } from \"../pack/resolver.js\";\nimport { builtInSkillRegistry } from \"./built-in.js\";\nimport { UnknownSkillError } from \"./errors.js\";\nimport type { SkillRegistry } from \"./registry.js\";\n\n/**\n * Collects the skills contributed by an already-resolved pack chain.\n *\n * Only identifiers are produced — no skill body is read — so this stays cheap\n * enough to run on every `resolve`.\n *\n * @throws {UnknownSkillError} when a pack references a skill the registry lacks.\n */\nexport function collectPackSkills(\n resolvedPacks: readonly string[],\n packRegistry: PackRegistry,\n skillRegistry: SkillRegistry,\n): string[] {\n const skills: string[] = [];\n const seen = new Set<string>();\n\n for (const packName of resolvedPacks) {\n for (const skillName of packRegistry.get(packName)?.skills ?? []) {\n if (seen.has(skillName)) {\n continue;\n }\n\n if (!skillRegistry.has(skillName)) {\n throw new UnknownSkillError(skillName, packName, skillRegistry.names);\n }\n\n seen.add(skillName);\n skills.push(skillName);\n }\n }\n\n return skills;\n}\n\n/**\n * Resolves the requested packs and returns the skills they contribute.\n *\n * The result follows the resolved pack order, then each pack's declaration\n * order, and is de-duplicated by first occurrence. Skills do not extend other\n * skills, so there is nothing further to expand.\n *\n * @throws {UnknownPackError} when a requested pack is missing.\n * @throws {UnknownSkillError} when a pack references a skill the registry lacks.\n */\nexport function resolvePackSkills(\n requestedPacks: readonly string[],\n packRegistry: PackRegistry = builtInPackRegistry,\n skillRegistry: SkillRegistry = builtInSkillRegistry,\n): string[] {\n return collectPackSkills(resolvePacks(requestedPacks, packRegistry), packRegistry, skillRegistry);\n}\n","import { AgentyxError } from \"../errors.js\";\n\nexport class UnknownToolError extends AgentyxError {\n readonly toolName: string;\n readonly requiredBy: string | undefined;\n readonly knownTools: readonly string[];\n\n constructor(toolName: string, requiredBy: string | undefined, knownTools: readonly string[]) {\n const origin = requiredBy === undefined ? \"\" : ` (required by \"${requiredBy}\")`;\n const known = knownTools.length > 0 ? [...knownTools].sort().join(\", \") : \"none\";\n\n super(\"unknown_tool\", `Unknown tool \"${toolName}\"${origin}. Known tools: ${known}.`);\n this.name = \"UnknownToolError\";\n this.toolName = toolName;\n this.requiredBy = requiredBy;\n this.knownTools = knownTools;\n }\n}\n\nexport class DuplicateToolError extends AgentyxError {\n readonly toolName: string;\n\n constructor(toolName: string) {\n super(\"duplicate_tool\", `Duplicate tool definition: \"${toolName}\".`);\n this.name = \"DuplicateToolError\";\n this.toolName = toolName;\n }\n}\n\nexport class InvalidToolError extends AgentyxError {\n constructor(origin: string, reason: unknown, options?: ErrorOptions) {\n const message = reason instanceof Error ? reason.message : String(reason);\n\n super(\"invalid_tool\", `Invalid ${origin}: ${message}.`, options);\n this.name = \"InvalidToolError\";\n }\n}\n","import { DuplicateToolError, InvalidToolError, UnknownToolError } from \"./errors.js\";\nimport {\n type ToolDefinition,\n type ToolDefinitionInput,\n toolDefinitionSchema,\n toolNameSchema,\n} from \"./schema.js\";\n\nexport interface ToolSource {\n readonly name: string;\n load(): ToolDefinitionInput;\n}\n\nexport interface ToolMetadata {\n readonly name: string;\n readonly description: string;\n readonly kind: ToolDefinition[\"kind\"];\n readonly command: string;\n readonly optional: boolean;\n}\n\nexport interface ToolRegistry {\n readonly names: readonly string[];\n has(name: string): boolean;\n listMetadata(): readonly ToolMetadata[];\n get(name: string): ToolDefinition;\n}\n\nexport function createToolRegistry(sources: Iterable<ToolSource>): ToolRegistry {\n const byName = new Map<string, ToolSource>();\n\n for (const source of sources) {\n const name = toolNameSchema.safeParse(source.name);\n\n if (!name.success) {\n throw new InvalidToolError(`tool source \"${source.name}\"`, name.error);\n }\n\n if (byName.has(name.data)) {\n throw new DuplicateToolError(name.data);\n }\n\n byName.set(name.data, source);\n }\n\n const names = [...byName.keys()];\n const loaded = new Map<string, ToolDefinition>();\n const get = (name: string): ToolDefinition => {\n const cached = loaded.get(name);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const source = byName.get(name);\n\n if (source === undefined) {\n throw new UnknownToolError(name, undefined, names);\n }\n\n const origin = `tool \"${name}\"`;\n const tool = toolDefinitionSchema.safeParse(source.load());\n\n if (!tool.success) {\n throw new InvalidToolError(origin, tool.error);\n }\n\n if (tool.data.name !== name) {\n throw new InvalidToolError(origin, `it declares the name \"${tool.data.name}\"`);\n }\n\n loaded.set(name, tool.data);\n\n return tool.data;\n };\n\n return {\n names,\n has: (name) => byName.has(name),\n listMetadata: () =>\n names.map((name) => {\n const tool = get(name);\n\n return {\n name: tool.name,\n description: tool.description,\n kind: tool.kind,\n command: tool.command,\n optional: tool.optional,\n };\n }),\n get,\n };\n}\n","import { createToolRegistry, type ToolSource } from \"./registry.js\";\n\nexport const builtInToolSources: readonly ToolSource[] = [\n {\n name: \"rtk\",\n load: () => ({\n name: \"rtk\",\n description:\n \"Rust Token Killer command-output proxy for reducing coding-agent context noise.\",\n kind: \"executable\",\n command: \"rtk\",\n optional: true,\n installHint: \"Install from the rtk-ai/rtk project if your local workflow benefits from it.\",\n }),\n },\n];\n\nexport const builtInToolRegistry = createToolRegistry(builtInToolSources);\n\nexport const builtInToolNames: readonly string[] = builtInToolRegistry.names;\n","import { builtInPackRegistry, type PackRegistry } from \"../pack/registry.js\";\nimport { resolvePacks } from \"../pack/resolver.js\";\nimport { builtInToolRegistry } from \"./built-in.js\";\nimport { UnknownToolError } from \"./errors.js\";\nimport type { ToolRegistry } from \"./registry.js\";\nimport type { ToolReference } from \"./schema.js\";\n\nexport function collectPackToolReferences(\n resolvedPacks: readonly string[],\n packRegistry: PackRegistry,\n toolRegistry: ToolRegistry,\n): ToolReference[] {\n const tools: ToolReference[] = [];\n const seen = new Set<string>();\n\n for (const packName of resolvedPacks) {\n for (const tool of packRegistry.get(packName)?.tools ?? []) {\n if (seen.has(tool.name)) {\n continue;\n }\n\n if (!toolRegistry.has(tool.name)) {\n throw new UnknownToolError(tool.name, packName, toolRegistry.names);\n }\n\n seen.add(tool.name);\n tools.push(tool);\n }\n }\n\n return tools;\n}\n\nexport function filterEffectiveTools(\n tools: readonly ToolReference[],\n enabledCapabilities: readonly string[],\n): string[] {\n const enabled = new Set(enabledCapabilities);\n\n return tools\n .filter((tool) => tool.activation === \"default\" || enabled.has(tool.name))\n .map((tool) => tool.name);\n}\n\nexport function resolvePackToolReferences(\n requestedPacks: readonly string[],\n packRegistry: PackRegistry = builtInPackRegistry,\n toolRegistry: ToolRegistry = builtInToolRegistry,\n): ToolReference[] {\n return collectPackToolReferences(\n resolvePacks(requestedPacks, packRegistry),\n packRegistry,\n toolRegistry,\n );\n}\n\nexport function resolvePackTools(\n requestedPacks: readonly string[],\n packRegistry: PackRegistry = builtInPackRegistry,\n toolRegistry: ToolRegistry = builtInToolRegistry,\n enabledCapabilities: readonly string[] = [],\n): string[] {\n return filterEffectiveTools(\n resolvePackToolReferences(requestedPacks, packRegistry, toolRegistry),\n enabledCapabilities,\n );\n}\n","import { builtInHookRegistry } from \"../hook/built-in.js\";\nimport type { HookRegistry } from \"../hook/registry.js\";\nimport { collectPackHookReferences, filterEffectiveHooks } from \"../hook/resolver.js\";\nimport type { HookReference } from \"../hook/schema.js\";\nimport { builtInMcpServerRegistry } from \"../mcp/built-in.js\";\nimport type { McpServerRegistry } from \"../mcp/registry.js\";\nimport { collectPackMcpServerReferences, filterEffectiveMcpServers } from \"../mcp/resolver.js\";\nimport type { McpServerReference } from \"../mcp/schema.js\";\nimport { builtInPackRegistry, type PackRegistry } from \"../pack/registry.js\";\nimport { resolvePacks } from \"../pack/resolver.js\";\nimport { builtInSkillRegistry } from \"../skill/built-in.js\";\nimport type { SkillRegistry } from \"../skill/registry.js\";\nimport { collectPackSkills } from \"../skill/resolver.js\";\nimport { builtInToolRegistry } from \"../tool/built-in.js\";\nimport type { ToolRegistry } from \"../tool/registry.js\";\nimport { collectPackToolReferences, filterEffectiveTools } from \"../tool/resolver.js\";\nimport type { ToolReference } from \"../tool/schema.js\";\nimport { UnknownEnabledCapabilityError } from \"./errors.js\";\nimport type { AgentyxConfig } from \"./schema.js\";\n\n/** A project configuration with its selected packs resolved. */\nexport interface ResolvedAgentyxConfig {\n /** The packs the project asked for, in configuration order. */\n readonly requestedPacks: readonly string[];\n /** Selected packs, de-duplicated while preserving configuration order. */\n readonly resolvedPacks: readonly string[];\n /**\n * Skill identifiers contributed by the resolved packs, in resolution order.\n * Identifiers only — reading the instructions is a separate, explicit step.\n */\n readonly skills: readonly string[];\n readonly declaredMcpServers: readonly McpServerReference[];\n readonly mcpServers: readonly string[];\n readonly declaredTools: readonly ToolReference[];\n readonly tools: readonly string[];\n readonly declaredHooks: readonly HookReference[];\n readonly hooks: readonly string[];\n readonly enabled: readonly string[];\n readonly targets: readonly string[];\n}\n\n/**\n * Combines a validated project configuration with pack and skill resolution.\n * The input is never mutated.\n *\n * @throws {UnknownPackError} when a configured pack is missing.\n * @throws {UnknownSkillError} when a pack references an unknown skill.\n */\nexport function resolveAgentyxConfig(\n config: AgentyxConfig,\n registry: PackRegistry = builtInPackRegistry,\n skillRegistry: SkillRegistry = builtInSkillRegistry,\n mcpRegistry: McpServerRegistry = builtInMcpServerRegistry,\n toolRegistry: ToolRegistry = builtInToolRegistry,\n hookRegistry: HookRegistry = builtInHookRegistry,\n): ResolvedAgentyxConfig {\n const requestedPacks = [...config.packs];\n const resolvedPacks = resolvePacks(requestedPacks, registry);\n const declaredMcpServers = collectPackMcpServerReferences(resolvedPacks, registry, mcpRegistry);\n const declaredTools = collectPackToolReferences(resolvedPacks, registry, toolRegistry);\n const declaredHooks = collectPackHookReferences(resolvedPacks, registry, hookRegistry);\n const knownOptionalCapabilities = [\n ...declaredMcpServers\n .filter((server) => server.activation === \"optional\")\n .map((server) => server.name),\n ...declaredTools.filter((tool) => tool.activation === \"optional\").map((tool) => tool.name),\n ...declaredHooks.filter((hook) => hook.activation === \"optional\").map((hook) => hook.name),\n ];\n\n for (const capability of config.enable) {\n if (!knownOptionalCapabilities.includes(capability)) {\n throw new UnknownEnabledCapabilityError(capability, knownOptionalCapabilities);\n }\n }\n\n return {\n requestedPacks,\n resolvedPacks,\n skills: unique([\n ...collectPackSkills(resolvedPacks, registry, skillRegistry),\n ...(config.project !== undefined ||\n (config.relations?.length ?? 0) > 0 ||\n hasProjectContext(config.context)\n ? [\"agentyx-project-context\"]\n : []),\n ]),\n declaredMcpServers,\n mcpServers: filterEffectiveMcpServers(declaredMcpServers, config.enable),\n declaredTools,\n tools: filterEffectiveTools(declaredTools, config.enable),\n declaredHooks,\n hooks: filterEffectiveHooks(declaredHooks, config.enable),\n enabled: [...config.enable],\n targets: [...config.targets],\n };\n}\n\nfunction hasProjectContext(context: AgentyxConfig[\"context\"]): boolean {\n return (\n context !== undefined &&\n (Object.keys(context.commands).length > 0 ||\n context.areas.length > 0 ||\n context.constraints.length > 0)\n );\n}\n\nfunction unique(values: readonly string[]): string[] {\n return [...new Set(values)];\n}\n","import type { ZodError } from \"zod\";\nimport { AgentyxError } from \"../errors.js\";\nimport { type AgentyxIssue, toAgentyxIssues } from \"../issues.js\";\n\n/** Raised when `.agentyx.lock.json` is not valid JSON. */\nexport class AgentyxManifestParseError extends AgentyxError {\n readonly filePath: string;\n\n constructor(filePath: string, reason: string, options?: ErrorOptions) {\n super(\"agentyx_manifest_parse_error\", `${filePath} is not valid JSON: ${reason}`, options);\n this.name = \"AgentyxManifestParseError\";\n this.filePath = filePath;\n }\n}\n\n/**\n * Raised when the manifest parses as JSON but is not a manifest Agentyx\n * understands.\n *\n * This is never repaired. The manifest is what tells Agentyx which files it is\n * allowed to overwrite and delete, so guessing at a damaged one would be\n * guessing about destructive operations.\n */\nexport class AgentyxManifestValidationError extends AgentyxError {\n readonly issues: readonly AgentyxIssue[];\n readonly filePath: string | undefined;\n\n constructor(error: ZodError, filePath?: string) {\n const issues = toAgentyxIssues(error);\n const location = filePath === undefined ? \"\" : ` in ${filePath}`;\n const details = issues.map((issue) => ` - ${issue.path}: ${issue.message}`).join(\"\\n\");\n\n super(\n \"agentyx_manifest_invalid\",\n `Invalid Agentyx install manifest${location}:\\n${details}\\nDelete the file to start from a clean install record.`,\n );\n this.name = \"AgentyxManifestValidationError\";\n this.issues = issues;\n this.filePath = filePath;\n }\n}\n","import { z } from \"zod\";\n\n/**\n * The manifest format version.\n *\n * A manifest written by a newer Agentyx fails validation instead of being\n * reinterpreted, because acting on a half-understood record of managed files is\n * how an installer deletes something it should not.\n */\nexport const INSTALL_MANIFEST_VERSION = 1;\n\n/**\n * A path Agentyx manages, relative to the project root and always written with\n * `/` separators so a manifest reads the same on every platform.\n */\nexport const managedPathSchema = z\n .string()\n .min(1, \"Managed paths must be non-empty strings.\")\n .refine((value) => !value.startsWith(\"/\"), \"Managed paths must be relative to the project root.\")\n .refine((value) => !value.includes(\"\\\\\"), \"Managed paths must use `/` separators.\")\n .refine(\n (value) => !value.split(\"/\").includes(\"..\"),\n \"Managed paths must not traverse outside the project root.\",\n );\n\n/** A SHA-256 digest of the exact bytes Agentyx last wrote to a managed path. */\nexport const contentHashSchema = z\n .string()\n .regex(/^[0-9a-f]{64}$/, \"Content hashes must be lowercase hexadecimal SHA-256 digests.\");\n\nconst targetsSchema = z\n .array(z.string().min(1, \"Targets must be non-empty strings.\"))\n .min(1, \"A manifest entry must record at least one target.\");\n\n/** A `SKILL.md` file Agentyx wrote, owned entirely by Agentyx. */\nexport const skillManifestEntrySchema = z.strictObject({\n kind: z.literal(\"skill\"),\n path: managedPathSchema,\n skill: z.string().min(1, \"Skill names must be non-empty strings.\"),\n targets: targetsSchema,\n hash: contentHashSchema,\n});\n\n/**\n * A provider MCP configuration file Agentyx contributed entries to.\n *\n * Unlike a skill file this one is shared with the user, so the entry records\n * the server keys Agentyx added rather than claiming the whole document.\n * `created` says whether the file existed before Agentyx first wrote it, which\n * is the only thing that makes removing the file itself safe.\n */\nexport const mcpManifestEntrySchema = z.strictObject({\n kind: z.literal(\"mcp\"),\n path: managedPathSchema,\n servers: z.array(z.string().min(1, \"MCP server names must be non-empty strings.\")),\n targets: targetsSchema,\n hash: contentHashSchema,\n created: z.boolean(),\n});\n\n/**\n * A provider hook configuration file Agentyx contributed entries to.\n *\n * Shares the `mcp` entry's shape and rationale: the file is shared with the\n * user, so the entry records the hook names Agentyx added rather than\n * claiming the whole document.\n */\nexport const hookManifestEntrySchema = z.strictObject({\n kind: z.literal(\"hook\"),\n path: managedPathSchema,\n hooks: z.array(z.string().min(1, \"Hook names must be non-empty strings.\")),\n targets: targetsSchema,\n hash: contentHashSchema,\n created: z.boolean(),\n});\n\nexport const installManifestEntrySchema = z.discriminatedUnion(\"kind\", [\n skillManifestEntrySchema,\n mcpManifestEntrySchema,\n hookManifestEntrySchema,\n]);\n\n/** The `.agentyx.lock.json` record of everything Agentyx installed into a project. */\nexport const installManifestSchema = z.strictObject({\n version: z.literal(INSTALL_MANIFEST_VERSION),\n entries: z.array(installManifestEntrySchema).default([]),\n});\n\nexport type SkillManifestEntry = z.infer<typeof skillManifestEntrySchema>;\nexport type McpManifestEntry = z.infer<typeof mcpManifestEntrySchema>;\nexport type HookManifestEntry = z.infer<typeof hookManifestEntrySchema>;\nexport type InstallManifestEntry = z.infer<typeof installManifestEntrySchema>;\n\n/** A validated manifest, with defaults applied. */\nexport type InstallManifest = z.infer<typeof installManifestSchema>;\n\n/** The shape accepted in a `.agentyx.lock.json` file. */\nexport type InstallManifestInput = z.input<typeof installManifestSchema>;\n","import { createHash } from \"node:crypto\";\nimport { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { AgentyxManifestParseError, AgentyxManifestValidationError } from \"./errors.js\";\nimport {\n INSTALL_MANIFEST_VERSION,\n type InstallManifest,\n type InstallManifestEntry,\n installManifestSchema,\n} from \"./schema.js\";\n\nexport const AGENTYX_MANIFEST_FILENAME = \".agentyx.lock.json\";\n\n/** The absolute path `.agentyx.lock.json` is read from for a given project. */\nexport function agentyxManifestPath(projectPath: string = process.cwd()): string {\n return resolve(projectPath, AGENTYX_MANIFEST_FILENAME);\n}\n\n/** A manifest that claims nothing — what a project has before its first install. */\nexport function emptyInstallManifest(): InstallManifest {\n return { version: INSTALL_MANIFEST_VERSION, entries: [] };\n}\n\n/**\n * The SHA-256 digest Agentyx records for managed content.\n *\n * Comparing this digest with the file on disk is what separates \"Agentyx wrote\n * this and may replace it\" from \"someone else owns this file\", so it is\n * computed over the exact bytes written, never over a normalised form.\n */\nexport function hashContent(content: string): string {\n return createHash(\"sha256\").update(content, \"utf8\").digest(\"hex\");\n}\n\n/**\n * Validates an already-parsed manifest document.\n *\n * @throws {AgentyxManifestValidationError} when the document violates the schema.\n */\nexport function parseInstallManifest(value: unknown, filePath?: string): InstallManifest {\n const result = installManifestSchema.safeParse(value);\n\n if (!result.success) {\n throw new AgentyxManifestValidationError(result.error, filePath);\n }\n\n return result.data;\n}\n\n/**\n * Reads `.agentyx.lock.json` from `projectPath`.\n *\n * A missing manifest is a legitimate state — the project has simply never been\n * installed into — and yields an empty manifest. A manifest that exists but\n * cannot be understood is a hard failure: it governs which files Agentyx may\n * overwrite and delete, and a damaged one is never guessed at.\n *\n * @throws {AgentyxManifestParseError} when the file is not valid JSON.\n * @throws {AgentyxManifestValidationError} when the document violates the schema.\n */\nexport async function loadInstallManifest(\n projectPath: string = process.cwd(),\n): Promise<InstallManifest> {\n const filePath = agentyxManifestPath(projectPath);\n let contents: string;\n\n try {\n contents = await readFile(filePath, \"utf8\");\n } catch (cause) {\n if (cause instanceof Error && (cause as NodeJS.ErrnoException).code === \"ENOENT\") {\n return emptyInstallManifest();\n }\n\n throw cause;\n }\n\n let document: unknown;\n\n try {\n document = JSON.parse(contents);\n } catch (cause) {\n const reason = cause instanceof Error ? cause.message : String(cause);\n throw new AgentyxManifestParseError(filePath, reason, { cause });\n }\n\n return parseInstallManifest(document, filePath);\n}\n\n/**\n * Serialises a manifest for writing.\n *\n * Entries and their lists are sorted so that reinstalling an unchanged project\n * produces a byte-identical file and the manifest never shows up as noise in a\n * diff. Writing is deliberately not done here — only the install executor\n * touches the filesystem.\n */\nexport function formatInstallManifest(manifest: InstallManifest): string {\n const entries = [...manifest.entries]\n .map((entry) => {\n if (entry.kind === \"skill\") {\n return { ...entry, targets: sorted(entry.targets) };\n }\n\n if (entry.kind === \"mcp\") {\n return { ...entry, targets: sorted(entry.targets), servers: sorted(entry.servers) };\n }\n\n return { ...entry, targets: sorted(entry.targets), hooks: sorted(entry.hooks) };\n })\n .sort((left, right) => left.path.localeCompare(right.path));\n\n return `${JSON.stringify({ version: manifest.version, entries }, null, 2)}\\n`;\n}\n\n/**\n * Indexes manifest entries by managed path.\n *\n * Every ownership question — may this file be overwritten, may it be deleted —\n * is a lookup by path, so callers do not scan the list themselves.\n */\nexport function manifestEntriesByPath(\n manifest: InstallManifest,\n): ReadonlyMap<string, InstallManifestEntry> {\n return new Map(manifest.entries.map((entry) => [entry.path, entry]));\n}\n\nfunction sorted(values: readonly string[]): string[] {\n return [...values].sort();\n}\n","export const agentyxCoreName = \"agentyx-core\";\n\nexport function getCoreStatus(): string {\n return \"ready\";\n}\n","import { constants } from \"node:fs\";\nimport { access } from \"node:fs/promises\";\nimport { delimiter } from \"node:path\";\n\n/** Whether `command` resolves to an executable file, via `PATH` unless it already contains a `/`. */\nexport async function isExecutableOnPath(command: string): Promise<boolean> {\n if (command.includes(\"/\")) {\n return isFileExecutable(command);\n }\n\n for (const directory of (process.env.PATH ?? \"\").split(delimiter)) {\n if (directory.length === 0) {\n continue;\n }\n\n if (await isFileExecutable(`${directory}/${command}`)) {\n return true;\n }\n }\n\n return false;\n}\n\nasync function isFileExecutable(path: string): Promise<boolean> {\n try {\n await access(path, constants.X_OK);\n return true;\n } catch {\n return false;\n }\n}\n","import type { Dirent } from \"node:fs\";\nimport { access, readdir, readFile } from \"node:fs/promises\";\nimport { extname, join } from \"node:path\";\nimport { builtInToolRegistry } from \"../tool/built-in.js\";\nimport { isExecutableOnPath } from \"./executable.js\";\n\nexport const PACKAGE_MANAGERS = [\"pnpm\", \"npm\", \"yarn\", \"bun\"] as const;\n\nexport type PackageManagerName = (typeof PACKAGE_MANAGERS)[number];\n\nexport interface PackageManagerDetection {\n readonly name: PackageManagerName | undefined;\n readonly source: \"lockfile\" | \"package-json\" | undefined;\n readonly lockfiles: readonly string[];\n readonly ambiguous: boolean;\n}\n\nexport interface ProjectPackageJsonDetection {\n readonly present: boolean;\n readonly valid: boolean;\n readonly path: string;\n readonly name: string | undefined;\n readonly packageManager: string | undefined;\n readonly scripts: Readonly<Record<string, string>>;\n readonly error: string | undefined;\n}\n\nexport type DependencyField =\n | \"dependencies\"\n | \"devDependencies\"\n | \"peerDependencies\"\n | \"optionalDependencies\";\n\n/** A single matched dependency: which package, and which `package.json` field it came from. */\nexport interface TechnologyMatch {\n readonly dependency: string;\n readonly field: DependencyField;\n}\n\nexport interface ContainerFileSignals {\n readonly dockerfile: boolean;\n readonly compose: boolean;\n}\n\nexport interface CiFileSignals {\n readonly githubActions: boolean;\n}\n\nexport interface MonorepoSignal {\n readonly detected: boolean;\n readonly markers: readonly string[];\n}\n\nexport interface RepositorySizeSignal {\n readonly filesScanned: number;\n /** True when the bounded traversal stopped before finishing; `filesScanned` is a lower bound. */\n readonly capped: boolean;\n}\n\n/**\n * Deliberately small, provider-neutral facts about a repository, gathered from a bounded set of\n * known files and `package.json` dependencies — never a full filesystem listing.\n *\n * This is pure detection: it makes no judgement about which packs or capabilities fit. That\n * judgement lives in `recommendCapabilities` (`./recommend.js`), which consumes these signals.\n */\nexport interface ProjectSignals {\n readonly projectDir: string;\n readonly packageJson: ProjectPackageJsonDetection;\n readonly packageManager: PackageManagerDetection;\n readonly typescript: {\n readonly dependency: TechnologyMatch | undefined;\n readonly tsconfig: boolean;\n };\n readonly angular: TechnologyMatch | undefined;\n readonly testFrameworks: readonly TechnologyMatch[];\n readonly browserTesting: readonly TechnologyMatch[];\n readonly observability: readonly TechnologyMatch[];\n readonly dataTooling: readonly TechnologyMatch[];\n readonly accessibilityTooling: readonly TechnologyMatch[];\n readonly containers: ContainerFileSignals;\n readonly ci: CiFileSignals;\n readonly monorepo: MonorepoSignal;\n readonly repositorySize: RepositorySizeSignal;\n readonly localTools: { readonly rtkAvailable: boolean };\n}\n\n/** Package name patterns matched exactly, or as a `@scope/*` prefix. */\nconst TEST_FRAMEWORK_PATTERNS = [\n \"vitest\",\n \"jest\",\n \"@jest/*\",\n \"@playwright/test\",\n \"cypress\",\n \"karma\",\n];\nconst BROWSER_TESTING_PATTERNS = [\"@playwright/test\", \"cypress\"];\nconst OBSERVABILITY_PATTERNS = [\"@sentry/*\", \"@opentelemetry/*\"];\nconst DATA_TOOLING_PATTERNS = [\n \"@supabase/*\",\n \"drizzle-orm\",\n \"prisma\",\n \"@prisma/client\",\n \"typeorm\",\n \"sequelize\",\n];\nconst ACCESSIBILITY_PATTERNS = [\"axe-core\", \"@axe-core/*\", \"pa11y\"];\n\nconst DEPENDENCY_FIELDS: readonly DependencyField[] = [\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n \"optionalDependencies\",\n];\n\nconst CONTAINER_IGNORED = new Set([\"node_modules\", \".git\", \"dist\", \"build\", \"coverage\"]);\n\n/** Extensions counted as source files by the bounded repository-size scan. */\nconst SOURCE_FILE_EXTENSIONS = new Set([\n \".ts\",\n \".tsx\",\n \".js\",\n \".jsx\",\n \".mjs\",\n \".cjs\",\n \".vue\",\n \".svelte\",\n \".py\",\n \".go\",\n \".rs\",\n \".java\",\n \".kt\",\n \".rb\",\n \".php\",\n \".css\",\n \".scss\",\n \".html\",\n]);\n\n/** Maximum directory entries visited by `scanRepositorySize`, regardless of match. */\nexport const REPOSITORY_SCAN_ENTRY_LIMIT = 5000;\n\ninterface PackageJson {\n readonly name?: unknown;\n readonly packageManager?: unknown;\n readonly workspaces?: unknown;\n readonly scripts?: unknown;\n readonly dependencies?: unknown;\n readonly devDependencies?: unknown;\n readonly peerDependencies?: unknown;\n readonly optionalDependencies?: unknown;\n}\n\nconst lockfileManagers: ReadonlyMap<string, PackageManagerName> = new Map([\n [\"pnpm-lock.yaml\", \"pnpm\"],\n [\"package-lock.json\", \"npm\"],\n [\"yarn.lock\", \"yarn\"],\n [\"bun.lock\", \"bun\"],\n [\"bun.lockb\", \"bun\"],\n]);\n\n/** Gathers every project signal with a bounded, cheap set of reads. */\nexport async function collectProjectSignals(projectDir: string): Promise<ProjectSignals> {\n const packageJsonPath = join(projectDir, \"package.json\");\n const packageJsonResult = await readPackageJson(packageJsonPath);\n const packageJson = packageJsonResult.data;\n\n const [packageManager, containers, ci, monorepo, repositorySize, tsconfig, rtkAvailable] =\n await Promise.all([\n detectPackageManager(projectDir, packageJson),\n detectContainerFiles(projectDir),\n detectCiFiles(projectDir),\n detectMonorepo(projectDir, packageJson),\n scanRepositorySize(projectDir),\n exists(join(projectDir, \"tsconfig.json\")),\n isExecutableOnPath(builtInToolRegistry.get(\"rtk\").command),\n ]);\n\n return {\n projectDir,\n packageJson: {\n present: packageJsonResult.present,\n valid: packageJsonResult.valid,\n path: packageJsonPath,\n name: getString(packageJson?.name),\n packageManager: getString(packageJson?.packageManager),\n scripts: getStringRecord(packageJson?.scripts),\n error: packageJsonResult.error,\n },\n packageManager,\n typescript: {\n dependency: findDependency(packageJson, \"typescript\"),\n tsconfig,\n },\n angular: findDependency(packageJson, \"@angular/core\"),\n testFrameworks: findAnyDependency(packageJson, TEST_FRAMEWORK_PATTERNS),\n browserTesting: findAnyDependency(packageJson, BROWSER_TESTING_PATTERNS),\n observability: findAnyDependency(packageJson, OBSERVABILITY_PATTERNS),\n dataTooling: findAnyDependency(packageJson, DATA_TOOLING_PATTERNS),\n accessibilityTooling: findAnyDependency(packageJson, ACCESSIBILITY_PATTERNS),\n containers,\n ci,\n monorepo,\n repositorySize,\n localTools: { rtkAvailable },\n };\n}\n\n/**\n * Counts source-like files under a bounded traversal, ignoring dependency, VCS and build output\n * directories. Stops after visiting `entryLimit` directory entries — cheap even on a monorepo — and\n * reports `capped` so callers never mistake a partial scan for a complete one.\n */\nexport async function scanRepositorySize(\n projectDir: string,\n options: { readonly entryLimit?: number } = {},\n): Promise<RepositorySizeSignal> {\n const entryLimit = options.entryLimit ?? REPOSITORY_SCAN_ENTRY_LIMIT;\n const directories = [projectDir];\n let filesScanned = 0;\n let entriesVisited = 0;\n let capped = false;\n\n while (directories.length > 0 && !capped) {\n const directory = directories.shift();\n\n if (directory === undefined) {\n break;\n }\n\n let entries: Dirent[];\n\n try {\n entries = await readdir(directory, { withFileTypes: true });\n } catch {\n continue;\n }\n\n for (const entry of entries) {\n if (entriesVisited >= entryLimit) {\n capped = true;\n break;\n }\n\n entriesVisited += 1;\n\n if (entry.isDirectory()) {\n if (entry.name.startsWith(\".\") || CONTAINER_IGNORED.has(entry.name)) {\n continue;\n }\n\n directories.push(join(directory, entry.name));\n } else if (entry.isFile() && SOURCE_FILE_EXTENSIONS.has(extname(entry.name))) {\n filesScanned += 1;\n }\n }\n }\n\n return { filesScanned, capped };\n}\n\nfunction findDependency(\n packageJson: PackageJson | undefined,\n pattern: string,\n): TechnologyMatch | undefined {\n for (const field of DEPENDENCY_FIELDS) {\n const value = packageJson?.[field];\n\n if (!isRecord(value)) {\n continue;\n }\n\n if (pattern.endsWith(\"/*\")) {\n const prefix = pattern.slice(0, -1);\n const name = Object.keys(value).find((key) => key.startsWith(prefix));\n\n if (name !== undefined) {\n return { dependency: name, field };\n }\n\n continue;\n }\n\n if (pattern in value) {\n return { dependency: pattern, field };\n }\n }\n\n return undefined;\n}\n\nfunction findAnyDependency(\n packageJson: PackageJson | undefined,\n patterns: readonly string[],\n): readonly TechnologyMatch[] {\n const matches: TechnologyMatch[] = [];\n const seen = new Set<string>();\n\n for (const pattern of patterns) {\n const match = findDependency(packageJson, pattern);\n\n if (match !== undefined && !seen.has(match.dependency)) {\n seen.add(match.dependency);\n matches.push(match);\n }\n }\n\n return matches;\n}\n\nasync function detectContainerFiles(projectDir: string): Promise<ContainerFileSignals> {\n const [dockerfile, dockerCompose, compose] = await Promise.all([\n exists(join(projectDir, \"Dockerfile\")),\n exists(join(projectDir, \"docker-compose.yml\")),\n exists(join(projectDir, \"compose.yml\")),\n ]);\n\n return { dockerfile, compose: dockerCompose || compose };\n}\n\nasync function detectCiFiles(projectDir: string): Promise<CiFileSignals> {\n return { githubActions: await exists(join(projectDir, \".github\", \"workflows\")) };\n}\n\nasync function detectMonorepo(\n projectDir: string,\n packageJson: PackageJson | undefined,\n): Promise<MonorepoSignal> {\n const markers: string[] = [];\n\n if (await exists(join(projectDir, \"pnpm-workspace.yaml\"))) {\n markers.push(\"pnpm-workspace.yaml\");\n }\n\n if (await exists(join(projectDir, \"turbo.json\"))) {\n markers.push(\"turbo.json\");\n }\n\n if (await exists(join(projectDir, \"nx.json\"))) {\n markers.push(\"nx.json\");\n }\n\n const workspaces = packageJson?.workspaces;\n\n if (Array.isArray(workspaces) || isRecord(workspaces)) {\n markers.push(\"package.json workspaces\");\n }\n\n return { detected: markers.length > 0, markers };\n}\n\nasync function detectPackageManager(\n projectDir: string,\n packageJson: PackageJson | undefined,\n): Promise<PackageManagerDetection> {\n const lockfiles: string[] = [];\n const managers = new Set<PackageManagerName>();\n\n for (const [file, manager] of lockfileManagers) {\n if (await exists(join(projectDir, file))) {\n lockfiles.push(file);\n managers.add(manager);\n }\n }\n\n if (managers.size === 1) {\n return {\n name: [...managers][0],\n source: \"lockfile\",\n lockfiles,\n ambiguous: false,\n };\n }\n\n if (managers.size > 1) {\n return {\n name: undefined,\n source: \"lockfile\",\n lockfiles,\n ambiguous: true,\n };\n }\n\n const declared = parsePackageManagerName(getString(packageJson?.packageManager));\n\n return {\n name: declared,\n source: declared === undefined ? undefined : \"package-json\",\n lockfiles,\n ambiguous: false,\n };\n}\n\nasync function readPackageJson(path: string): Promise<{\n readonly present: boolean;\n readonly valid: boolean;\n readonly data: PackageJson | undefined;\n readonly error: string | undefined;\n}> {\n let contents: string;\n\n try {\n contents = await readFile(path, \"utf8\");\n } catch (cause) {\n if (isNotFound(cause)) {\n return { present: false, valid: false, data: undefined, error: undefined };\n }\n\n const reason = cause instanceof Error ? cause.message : String(cause);\n return { present: true, valid: false, data: undefined, error: reason };\n }\n\n try {\n return { present: true, valid: true, data: JSON.parse(contents), error: undefined };\n } catch (cause) {\n const reason = cause instanceof Error ? cause.message : String(cause);\n return { present: true, valid: false, data: undefined, error: reason };\n }\n}\n\nfunction parsePackageManagerName(value: string | undefined): PackageManagerName | undefined {\n const name = value?.split(\"@\")[0];\n\n return PACKAGE_MANAGERS.includes(name as PackageManagerName)\n ? (name as PackageManagerName)\n : undefined;\n}\n\nfunction getString(value: unknown): string | undefined {\n return typeof value === \"string\" ? value : undefined;\n}\n\nfunction getStringRecord(value: unknown): Readonly<Record<string, string>> {\n if (!isRecord(value)) return {};\n return Object.fromEntries(\n Object.entries(value).filter(\n (entry): entry is [string, string] => typeof entry[1] === \"string\",\n ),\n );\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nasync function exists(path: string): Promise<boolean> {\n try {\n await access(path);\n return true;\n } catch (cause) {\n if (isNotFound(cause)) {\n return false;\n }\n\n throw cause;\n }\n}\n\nfunction isNotFound(cause: unknown): boolean {\n return cause instanceof Error && (cause as NodeJS.ErrnoException).code === \"ENOENT\";\n}\n","import type { AgentyxConfigInput } from \"../config/schema.js\";\nimport { collectProjectSignals, type ProjectSignals } from \"./signals.js\";\n\nexport type {\n PackageManagerDetection,\n PackageManagerName,\n ProjectPackageJsonDetection,\n} from \"./signals.js\";\nexport { PACKAGE_MANAGERS } from \"./signals.js\";\n\nexport interface ProjectDetection {\n readonly projectDir: string;\n readonly packageJson: ProjectSignals[\"packageJson\"];\n readonly packageManager: ProjectSignals[\"packageManager\"];\n /** The richer, provider-neutral facts `recommendCapabilities` (`./recommend.js`) turns into suggestions. */\n readonly signals: ProjectSignals;\n}\n\n/**\n * Factual project detection only. It gathers `ProjectSignals` and never decides which packs or\n * capabilities fit — that policy lives in `recommendCapabilities`, kept separate so each half stays\n * independently testable.\n */\nexport async function detectProject(projectDir: string): Promise<ProjectDetection> {\n const signals = await collectProjectSignals(projectDir);\n\n return {\n projectDir,\n packageJson: signals.packageJson,\n packageManager: signals.packageManager,\n signals,\n };\n}\n\nexport function buildAgentyxConfig(input: {\n readonly packs: readonly string[];\n readonly enable?: readonly string[];\n readonly targets: readonly string[];\n}): AgentyxConfigInput {\n return {\n packs: [...input.packs],\n enable: [...(input.enable ?? [])],\n targets: [...input.targets],\n };\n}\n\nexport function formatAgentyxConfig(config: AgentyxConfigInput): string {\n return `${JSON.stringify(config, null, 2)}\\n`;\n}\n","import { builtInPackRegistry } from \"../pack/registry.js\";\nimport type { ProjectSignals, TechnologyMatch } from \"./signals.js\";\n\nexport const RECOMMENDATION_CONFIDENCES = [\"high\", \"medium\"] as const;\nexport type RecommendationConfidence = (typeof RECOMMENDATION_CONFIDENCES)[number];\n\nexport type RecommendationKind = \"pack\" | \"capability\";\n\n/**\n * A deterministic suggestion, always with a human-readable reason. `high` means a direct, strong\n * signal (an exact dependency or file match); `medium` means useful but less certain, such as a\n * size heuristic. There is no `low` tier in v1 — a signal too weak for `medium` is not surfaced.\n */\nexport interface Recommendation {\n readonly kind: RecommendationKind;\n readonly name: string;\n readonly confidence: RecommendationConfidence;\n readonly reasons: readonly string[];\n /** Packs that declare this as an optional capability. Present only for `kind: \"capability\"`. */\n readonly contributedBy?: readonly string[];\n}\n\nexport interface RecommendationResult {\n readonly packs: readonly Recommendation[];\n readonly capabilities: readonly Recommendation[];\n}\n\nexport interface RecommendCapabilitiesOptions {\n /** Packs already selected in the project's own `.agentyx.json`, if one exists. */\n readonly configuredPacks?: readonly string[] | undefined;\n}\n\n/**\n * Heuristic thresholds for the `codebase-memory` capability suggestion, in scanned source files.\n * These are approximate signals, not exact token accounting, and a monorepo is treated as already\n * complex enough to lower the bar.\n */\nexport const CODEBASE_MEMORY_FILE_THRESHOLD = 2000;\nexport const CODEBASE_MEMORY_MONOREPO_FILE_THRESHOLD = 800;\n\n/**\n * Applies conservative, deterministic policy on top of `ProjectSignals`. This is the only place\n * that turns an observed fact into a product suggestion — `ProjectSignals` stays fact-only so it\n * can be tested independently of pack names or capability policy.\n *\n * Never enables anything and never touches the filesystem: the caller decides what, if anything,\n * to do with the result.\n */\nexport function recommendCapabilities(\n signals: ProjectSignals,\n options: RecommendCapabilitiesOptions = {},\n): RecommendationResult {\n const packs = recommendPacks(signals);\n const configuredPacks = options.configuredPacks ?? [];\n const activePacks = new Set([...packs.map((pack) => pack.name), ...configuredPacks]);\n const capabilities = recommendOptionalCapabilities(signals, activePacks, configuredPacks);\n\n return { packs, capabilities };\n}\n\nfunction recommendPacks(signals: ProjectSignals): readonly Recommendation[] {\n const packs: Recommendation[] = [];\n\n if (signals.packageJson.present) {\n packs.push(\n packRecommendation(\"technical\", \"high\", [\n \"package.json detected — baseline engineering practices apply to any software project.\",\n ]),\n );\n }\n\n const typescriptReasons = [\n ...(signals.typescript.dependency !== undefined\n ? [dependencyReason(\"TypeScript\", signals.typescript.dependency)]\n : []),\n ...(signals.typescript.tsconfig ? [\"tsconfig.json detected.\"] : []),\n ];\n\n if (typescriptReasons.length > 0) {\n packs.push(packRecommendation(\"typescript\", \"high\", typescriptReasons));\n }\n\n if (signals.angular !== undefined) {\n packs.push(\n packRecommendation(\"angular\", \"high\", [dependencyReason(\"@angular/core\", signals.angular)]),\n );\n }\n\n const testingMatches = dedupeMatches([...signals.testFrameworks, ...signals.browserTesting]);\n\n if (testingMatches.length > 0) {\n packs.push(\n packRecommendation(\n \"testing\",\n \"high\",\n testingMatches.map((match) => dependencyReason(match.dependency, match)),\n ),\n );\n }\n\n const devopsReasons = [\n ...(signals.containers.dockerfile ? [\"Dockerfile detected.\"] : []),\n ...(signals.containers.compose ? [\"Container compose file detected.\"] : []),\n ...(signals.ci.githubActions ? [\"GitHub Actions workflow detected (.github/workflows).\"] : []),\n ];\n\n if (devopsReasons.length > 0) {\n packs.push(packRecommendation(\"devops\", \"high\", devopsReasons));\n }\n\n if (signals.observability.length > 0) {\n packs.push(\n packRecommendation(\n \"observability\",\n \"high\",\n signals.observability.map((match) => dependencyReason(match.dependency, match)),\n ),\n );\n }\n\n if (signals.dataTooling.length > 0) {\n packs.push(\n packRecommendation(\n \"data\",\n \"high\",\n signals.dataTooling.map((match) => dependencyReason(match.dependency, match)),\n ),\n );\n }\n\n if (signals.accessibilityTooling.length > 0) {\n packs.push(\n packRecommendation(\n \"accessibility\",\n \"high\",\n signals.accessibilityTooling.map((match) => dependencyReason(match.dependency, match)),\n ),\n );\n }\n\n return packs;\n}\n\nfunction recommendOptionalCapabilities(\n signals: ProjectSignals,\n activePacks: ReadonlySet<string>,\n configuredPacks: readonly string[],\n): readonly Recommendation[] {\n const capabilities: Recommendation[] = [];\n\n const playwrightMatch = signals.browserTesting.find(\n (match) => match.dependency === \"@playwright/test\",\n );\n\n if (activePacks.has(\"testing\") && playwrightMatch !== undefined) {\n capabilities.push(\n capabilityRecommendation(\"playwright\", \"high\", [\n \"Playwright is already part of this project; browser MCP may be useful for interactive browser work.\",\n ]),\n );\n }\n\n const sentryMatch = signals.observability.find((match) =>\n match.dependency.startsWith(\"@sentry/\"),\n );\n\n if (sentryMatch !== undefined) {\n capabilities.push(\n capabilityRecommendation(\"sentry\", \"high\", [\"Sentry is already configured as a dependency.\"]),\n );\n }\n\n const supabaseMatch = signals.dataTooling.find((match) =>\n match.dependency.startsWith(\"@supabase/\"),\n );\n\n if (supabaseMatch !== undefined) {\n capabilities.push(\n capabilityRecommendation(\"supabase\", \"high\", [\n \"Supabase is already configured as a dependency.\",\n ]),\n );\n }\n\n if (configuredPacks.includes(\"efficiency\") && signals.localTools.rtkAvailable) {\n capabilities.push(\n capabilityRecommendation(\"rtk\", \"high\", [\"RTK is already installed locally.\"]),\n );\n }\n\n const sizeThreshold = signals.monorepo.detected\n ? CODEBASE_MEMORY_MONOREPO_FILE_THRESHOLD\n : CODEBASE_MEMORY_FILE_THRESHOLD;\n\n if (signals.repositorySize.filesScanned >= sizeThreshold || signals.repositorySize.capped) {\n capabilities.push(\n capabilityRecommendation(\"codebase-memory\", \"medium\", [repositorySizeReason(signals)]),\n );\n }\n\n return capabilities;\n}\n\nfunction repositorySizeReason(signals: ProjectSignals): string {\n const { filesScanned, capped } = signals.repositorySize;\n const scope = signals.monorepo.detected ? \" across this monorepo\" : \"\";\n const scanNote = capped\n ? `at least ${filesScanned} source files (the scan was capped before finishing)`\n : `${filesScanned} source files`;\n\n return (\n `Heuristic: found ${scanNote}${scope}. A persistent codebase-memory MCP may reduce repeated ` +\n \"full-tree reads on a repository this size — this is an approximate signal, not an exact token \" +\n \"measurement.\"\n );\n}\n\nfunction packRecommendation(\n name: string,\n confidence: RecommendationConfidence,\n reasons: readonly string[],\n): Recommendation {\n return { kind: \"pack\", name, confidence, reasons };\n}\n\n/** Provenance comes from the pack registry itself — never a second, hand-maintained capability map. */\nfunction capabilityRecommendation(\n name: string,\n confidence: RecommendationConfidence,\n reasons: readonly string[],\n): Recommendation {\n return {\n kind: \"capability\",\n name,\n confidence,\n reasons,\n contributedBy: packsDeclaringOptionalCapability(name),\n };\n}\n\nfunction packsDeclaringOptionalCapability(name: string): readonly string[] {\n const packs: string[] = [];\n\n for (const pack of builtInPackRegistry.values()) {\n const declares =\n pack.mcpServers.some((server) => server.name === name && server.activation === \"optional\") ||\n pack.tools.some((tool) => tool.name === name && tool.activation === \"optional\") ||\n pack.hooks.some((hook) => hook.name === name && hook.activation === \"optional\");\n\n if (declares) {\n packs.push(pack.name);\n }\n }\n\n return packs;\n}\n\nfunction dependencyReason(label: string, match: TechnologyMatch): string {\n return label === match.dependency\n ? `Detected ${match.dependency} in ${match.field}.`\n : `Detected ${label} (${match.dependency}) in ${match.field}.`;\n}\n\nfunction dedupeMatches(matches: readonly TechnologyMatch[]): readonly TechnologyMatch[] {\n const seen = new Set<string>();\n const result: TechnologyMatch[] = [];\n\n for (const match of matches) {\n if (!seen.has(match.dependency)) {\n seen.add(match.dependency);\n result.push(match);\n }\n }\n\n return result;\n}\n","import type { ProjectMetadata, ProjectRelation } from \"./config/schema.js\";\nimport { AgentyxError } from \"./errors.js\";\n\nexport class ProjectGraphNotConfiguredError extends AgentyxError {\n constructor() {\n super(\n \"project_graph_not_configured\",\n \"Project Graph requires a project object in .agentyx.json.\",\n );\n this.name = \"ProjectGraphNotConfiguredError\";\n }\n}\n\nexport interface ProjectGraph {\n readonly project: ProjectMetadata;\n readonly relations: readonly ProjectRelation[];\n}\n\nexport function createProjectGraph(\n project: ProjectMetadata,\n relations: readonly ProjectRelation[],\n): ProjectGraph {\n return { project, relations: [...relations] };\n}\n\nexport function renderProjectGraphText(graph: ProjectGraph): string {\n const rows = graph.relations.map((relation, index) => {\n const branch = index === graph.relations.length - 1 ? \"└──\" : \"├──\";\n return `${branch} ${relation.type} [${relation.role}] → ${relation.name}`;\n });\n return [graph.project.name, ...rows].join(\"\\n\");\n}\n\nexport function renderProjectGraphJson(graph: ProjectGraph): string {\n return `${JSON.stringify(graph, null, 2)}\\n`;\n}\n\nexport function renderProjectGraphMermaid(graph: ProjectGraph): string {\n const current = mermaidId(graph.project.id);\n const rows = graph.relations.map(\n (relation) =>\n ` ${current}[\"${mermaidText(graph.project.name)}\"] -->|${mermaidText(`${relation.type}: ${relation.role}`)}| ${mermaidId(relation.id)}[\"${mermaidText(relation.name)}\"]`,\n );\n return [\"graph LR\", ...rows].join(\"\\n\");\n}\n\nexport function renderProjectGraphSvg(graph: ProjectGraph): string {\n const width = 720;\n const rowHeight = 92;\n const height = Math.max(180, 100 + graph.relations.length * rowHeight);\n const centerX = 360;\n const centerY = height / 2;\n const svg = [\n `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${width} ${height}\" role=\"img\" aria-labelledby=\"title desc\">`,\n `<title id=\"title\">${xml(graph.project.name)} project graph</title>`,\n `<desc id=\"desc\">Direct architectural relationships from ${xml(graph.project.name)}.</desc>`,\n '<defs><marker id=\"arrow\" markerWidth=\"10\" markerHeight=\"8\" refX=\"9\" refY=\"4\" orient=\"auto\"><path d=\"M0,0 L10,4 L0,8 z\" fill=\"#526579\"/></marker></defs>',\n ];\n graph.relations.forEach((relation, index) => {\n const y = 54 + index * rowHeight;\n const right = index % 2 === 0;\n const x = right ? 500 : 0;\n const edgeStart = right ? centerX + 128 : centerX - 128;\n const edgeEnd = right ? x : x + 220;\n svg.push(\n `<line x1=\"${edgeStart}\" y1=\"${centerY}\" x2=\"${edgeEnd}\" y2=\"${y + 24}\" stroke=\"#526579\" stroke-width=\"2\" marker-end=\"url(#arrow)\"/>`,\n );\n svg.push(\n `<text x=\"${right ? 494 : 226}\" y=\"${Math.round((centerY + y + 24) / 2) - 7}\" class=\"edge\">${xml(truncate(`${relation.type} · ${relation.role}`, 34))}</text>`,\n );\n svg.push(`<rect x=\"${x}\" y=\"${y}\" width=\"220\" height=\"48\" rx=\"10\" class=\"node\"/>`);\n svg.push(\n `<text x=\"${x + 110}\" y=\"${y + 30}\" class=\"label\">${xml(truncate(relation.name, 22))}</text>`,\n );\n });\n svg.push(\n `<rect x=\"${centerX - 128}\" y=\"${centerY - 34}\" width=\"256\" height=\"68\" rx=\"14\" class=\"current\"/>`,\n );\n svg.push(\n `<text x=\"${centerX}\" y=\"${centerY + 6}\" class=\"label\">${xml(truncate(graph.project.name, 30))}</text>`,\n );\n svg.push(\n \"<style>text{font-family:system-ui,sans-serif}.node{fill:#fff;stroke:#8da0b3;stroke-width:2}.current{fill:#e8f2ff;stroke:#2563a5;stroke-width:3}.label{text-anchor:middle;font-size:16px;font-weight:600;fill:#172536}.edge{text-anchor:middle;font-size:12px;fill:#34495e;paint-order:stroke;stroke:#fff;stroke-width:5px;stroke-linejoin:round}</style>\",\n );\n svg.push(\"</svg>\");\n return `${svg.join(\"\\n\")}\\n`;\n}\n\nexport function findProjectCapabilityOwners(graph: ProjectGraph, capability: string) {\n const owners = graph.relations.filter((relation) => relation.owns.includes(capability));\n return {\n capability,\n currentProject: graph.project.owns.includes(capability) ? graph.project : undefined,\n relatedProjects: owners,\n };\n}\n\nfunction xml(value: string): string {\n return value\n .replaceAll(\"&\", \"&amp;\")\n .replaceAll(\"<\", \"&lt;\")\n .replaceAll(\">\", \"&gt;\")\n .replaceAll('\"', \"&quot;\")\n .replaceAll(\"'\", \"&apos;\");\n}\n\nfunction mermaidText(value: string): string {\n return value\n .replaceAll(\"&\", \"&amp;\")\n .replaceAll(\"|\", \"&#124;\")\n .replaceAll(\"[\", \"&#91;\")\n .replaceAll(\"]\", \"&#93;\")\n .replaceAll('\"', \"&quot;\")\n .replaceAll(\"<\", \"&lt;\")\n .replaceAll(\">\", \"&gt;\");\n}\n\nfunction mermaidId(value: string): string {\n return `node_${Array.from(value)\n .map((char) => char.codePointAt(0)?.toString(16) ?? \"0\")\n .join(\"\")}`;\n}\n\nfunction truncate(value: string, limit: number): string {\n const characters = Array.from(value);\n return characters.length > limit ? `${characters.slice(0, limit - 1).join(\"\")}…` : value;\n}\n","import type { Dirent } from \"node:fs\";\nimport { readdir, readFile, realpath } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, relative, resolve, sep } from \"node:path\";\nimport { parseSkillMarkdown } from \"../skill/markdown.js\";\nimport { TrustedSourceLoadError } from \"./errors.js\";\nimport { getTrustedSourceDefinition } from \"./registry.js\";\nimport {\n type CodexPluginManifest,\n codexPluginManifestSchema,\n type TrustedSourceDefinition,\n type TrustedSourceReference,\n type TrustedSourceSkillSummary,\n} from \"./schema.js\";\n\nexport interface TrustedSourceInspection {\n readonly definition: TrustedSourceDefinition;\n readonly reference: TrustedSourceReference;\n readonly rootPath: string;\n readonly manifest: CodexPluginManifest;\n readonly skillsPath: string;\n readonly skills: readonly TrustedSourceSkillSummary[];\n readonly installable: boolean;\n readonly installNote: string;\n}\n\nexport async function inspectTrustedSource(\n projectPath: string,\n reference: TrustedSourceReference,\n): Promise<TrustedSourceInspection> {\n const definition = getTrustedSourceDefinition(reference);\n const projectDir = resolve(projectPath);\n const projectRealPath = await realpath(projectDir);\n const root = resolve(projectDir, reference.path);\n const rootRealPath = await realpathOrThrow(\n reference.name,\n root,\n \"the checkout path cannot be read\",\n );\n\n if (!isInside(rootRealPath, projectRealPath)) {\n throw new TrustedSourceLoadError(\n reference.name,\n \"the checkout path resolves outside the project\",\n );\n }\n\n const manifestPath = join(rootRealPath, definition.manifestPath);\n const manifest = await readManifest(reference.name, manifestPath);\n\n if (manifest.name !== definition.name) {\n throw new TrustedSourceLoadError(\n reference.name,\n `${definition.manifestPath} declares the name \"${manifest.name}\"`,\n );\n }\n\n if (manifest.repository !== definition.repository) {\n throw new TrustedSourceLoadError(\n reference.name,\n `${definition.manifestPath} declares repository \"${manifest.repository}\"`,\n );\n }\n\n const skillsPath = resolve(dirname(manifestPath), manifest.skills);\n\n if (!isInside(skillsPath, rootRealPath)) {\n throw new TrustedSourceLoadError(\n reference.name,\n \"the manifest skills path resolves outside the checkout\",\n );\n }\n\n const skillsRealPath = await realpathOrThrow(\n reference.name,\n skillsPath,\n \"the manifest skills path cannot be read\",\n );\n\n if (!isInside(skillsRealPath, rootRealPath)) {\n throw new TrustedSourceLoadError(\n reference.name,\n \"the manifest skills path resolves outside the checkout\",\n );\n }\n\n const skills = await inspectSkillSummaries(reference.name, skillsRealPath);\n const installable =\n definition.installStatus === \"installable\" && skills.every((skill) => !skill.hasResources);\n\n return {\n definition,\n reference,\n rootPath: rootRealPath,\n manifest,\n skillsPath: skillsRealPath,\n skills,\n installable,\n installNote: definition.installNote,\n };\n}\n\nasync function readManifest(sourceName: string, path: string): Promise<CodexPluginManifest> {\n let raw: string;\n\n try {\n raw = await readFile(path, \"utf8\");\n } catch (cause) {\n throw trustedSourceLoadError(sourceName, \"the plugin manifest cannot be read\", cause);\n }\n\n try {\n return codexPluginManifestSchema.parse(JSON.parse(raw));\n } catch (cause) {\n throw trustedSourceLoadError(sourceName, \"the plugin manifest is invalid\", cause);\n }\n}\n\nasync function inspectSkillSummaries(\n sourceName: string,\n skillsPath: string,\n): Promise<readonly TrustedSourceSkillSummary[]> {\n let entries: Dirent[];\n\n try {\n entries = await readdir(skillsPath, { withFileTypes: true });\n } catch (cause) {\n throw trustedSourceLoadError(sourceName, \"the plugin skills directory cannot be listed\", cause);\n }\n\n const skills: TrustedSourceSkillSummary[] = [];\n\n for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {\n if (!entry.isDirectory()) {\n continue;\n }\n\n const skillRoot = join(skillsPath, entry.name);\n const skillPath = join(skillRoot, \"SKILL.md\");\n let markdown: string;\n\n try {\n markdown = await readFile(skillPath, \"utf8\");\n } catch (cause) {\n if (cause instanceof Error && (cause as NodeJS.ErrnoException).code === \"ENOENT\") {\n continue;\n }\n\n throw trustedSourceLoadError(sourceName, `cannot read ${entry.name}/SKILL.md`, cause);\n }\n\n const skill = parseSkillMarkdown(markdown, skillPath);\n\n if (skill.name !== entry.name) {\n throw new TrustedSourceLoadError(\n sourceName,\n `${entry.name}/SKILL.md declares the name \"${skill.name}\"`,\n );\n }\n\n skills.push({\n name: skill.name,\n description: skill.description,\n hasResources: await hasResources(skillRoot),\n });\n }\n\n return skills;\n}\n\nasync function hasResources(skillRoot: string): Promise<boolean> {\n const entries = await readdir(skillRoot, { withFileTypes: true });\n\n return entries.some((entry) => entry.name !== \"SKILL.md\");\n}\n\nasync function realpathOrThrow(sourceName: string, path: string, reason: string): Promise<string> {\n try {\n return await realpath(path);\n } catch (cause) {\n throw trustedSourceLoadError(sourceName, reason, cause);\n }\n}\n\nfunction isInside(path: string, root: string): boolean {\n const pathFromRoot = relative(root, path);\n\n return (\n pathFromRoot === \"\" ||\n (!pathFromRoot.startsWith(`..${sep}`) && pathFromRoot !== \"..\" && !isAbsolute(pathFromRoot))\n );\n}\n\nfunction trustedSourceLoadError(\n sourceName: string,\n reason: string,\n cause: unknown,\n): TrustedSourceLoadError {\n return new TrustedSourceLoadError(\n sourceName,\n reason,\n cause instanceof Error ? { cause } : undefined,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAOA,IAAa,eAAb,cAAkC,MAAM;CACtC;CAEA,YAAY,MAAc,SAAiB,SAAwB;EACjE,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;EACZ,KAAK,OAAO;CACd;AACF;;;;;;;;;ACAA,SAAgB,gBAAgB,OAA0C;CACxE,O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,YAAY,GACrB;EAGF,MAAM,YAAY,KAAK,YAAY,MAAM,IAAI;EAC7C,MAAM,YAAY,KAAK,WAAW,UAAU;EAC5C,IAAI;EAEJ,IAAI;GACF,WAAW,MAAM,SAAS,WAAW,MAAM;EAC7C,SAAS,OAAO;GACd,IAAI,iBAAiB,SAAU,MAAgC,SAAS,UACtE;GAGF,MAAM,uBAAuB,YAAY,eAAe,MAAM,KAAK,YAAY,KAAK;EACtF;EAEA,MAAM,QAAQ,mBAAmB,UAAU,SAAS;EAEpD,IAAI,MAAM,SAAS,MAAM,MACvB,MAAM,IAAI,uBACR,YACA,GAAG,MAAM,KAAK,+BAA+B,MAAM,KAAK,EAC1D;EAGF,OAAO,KAAK;GACV,MAAM,MAAM;GACZ,aAAa,MAAM;GACnB,cAAc,MAAM,aAAa,SAAS;EAC5C,CAAC;CACH;CAEA,OAAO;AACT;AAEA,eAAe,aAAa,WAAqC;CAG/D,QAAO,MAFe,QAAQ,WAAW,EAAE,eAAe,KAAK,CAAC,EAAA,CAEjD,MAAM,UAAU,MAAM,SAAS,UAAU;AAC1D;AAEA,eAAe,gBAAgB,YAAoB,MAAc,QAAiC;CAChG,IAAI;EACF,OAAO,MAAM,SAAS,IAAI;CAC5B,SAAS,OAAO;EACd,MAAM,uBAAuB,YAAY,QAAQ,KAAK;CACxD;AACF;AAEA,SAAS,SAAS,MAAc,MAAuB;CACrD,MAAM,eAAe,SAAS,MAAM,IAAI;CAExC,OACE,iBAAiB,MAChB,CAAC,aAAa,WAAW,KAAK,KAAK,KAAK,iBAAiB,QAAQ,CAAC,WAAW,YAAY;AAE9F;AAEA,SAAS,uBACP,YACA,QACA,OACwB;CACxB,OAAO,IAAI,uBACT,YACA,QACA,iBAAiB,QAAQ,EAAE,MAAM,IAAI,KAAA,CACvC;AACF"}
1
+ {"version":3,"file":"index.mjs","names":["formatIssues","isInside","formatIssues"],"sources":["../src/errors.ts","../src/issues.ts","../src/config/errors.ts","../src/hook/schema.ts","../src/mcp/schema.ts","../src/skill/schema.ts","../src/tool/schema.ts","../src/pack/schema.ts","../src/source/schema.ts","../src/config/schema.ts","../src/config/json-schema.ts","../src/config/loader.ts","../src/assets.ts","../src/pack/errors.ts","../src/pack/registry.ts","../src/skill/errors.ts","../src/skill/markdown.ts","../src/skill/registry.ts","../src/skill/built-in.ts","../src/source/errors.ts","../src/source/registry.ts","../src/config/project.ts","../src/hook/errors.ts","../src/hook/registry.ts","../src/hook/built-in.ts","../src/pack/resolver.ts","../src/hook/resolver.ts","../src/mcp/errors.ts","../src/mcp/registry.ts","../src/mcp/built-in.ts","../src/mcp/resolver.ts","../src/skill/resolver.ts","../src/tool/errors.ts","../src/tool/registry.ts","../src/tool/built-in.ts","../src/tool/resolver.ts","../src/config/resolver.ts","../src/manifest/errors.ts","../src/manifest/schema.ts","../src/manifest/io.ts","../src/meta.ts","../src/project/executable.ts","../src/project/signals.ts","../src/project/detector.ts","../src/project/recommend.ts","../src/project-graph.ts","../src/source/inspection.ts"],"sourcesContent":["/**\n * Base class for every failure Agentyx raises deliberately.\n *\n * Consumers can catch `AgentyxError` to separate expected domain failures from\n * unexpected runtime errors, and branch on the stable `code` when they need to\n * handle a specific failure.\n */\nexport class AgentyxError extends Error {\n readonly code: string;\n\n constructor(code: string, message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = \"AgentyxError\";\n this.code = code;\n }\n}\n","import type { ZodError } from \"zod\";\n\n/** A single problem in an Agentyx document, addressed by its location in it. */\nexport interface AgentyxIssue {\n /** Dotted path to the offending value, or `(root)` for the document itself. */\n readonly path: string;\n readonly message: string;\n}\n\n/**\n * Turns a Zod failure into locations a reader can find in the file.\n *\n * Shared by every document Agentyx validates, so a problem in `.agentyx.json`\n * and a problem in `.agentyx.lock.json` are reported the same way.\n */\nexport function toAgentyxIssues(error: ZodError): readonly AgentyxIssue[] {\n return error.issues.map((issue) => ({\n path: formatIssuePath(issue.path),\n message: issue.message,\n }));\n}\n\nfunction formatIssuePath(path: readonly PropertyKey[]): string {\n if (path.length === 0) {\n return \"(root)\";\n }\n\n return path.reduce<string>((formatted, segment) => {\n if (typeof segment === \"number\") {\n return `${formatted}[${segment}]`;\n }\n\n return formatted === \"\" ? String(segment) : `${formatted}.${String(segment)}`;\n }, \"\");\n}\n","import type { ZodError } from \"zod\";\nimport { AgentyxError } from \"../errors.js\";\nimport { type AgentyxIssue, toAgentyxIssues } from \"../issues.js\";\n\n/** A single configuration problem, addressed by its location in the document. */\nexport type AgentyxConfigIssue = AgentyxIssue;\n\n/** Raised when the supplied directory has no `.agentyx.json`. */\nexport class AgentyxConfigNotFoundError extends AgentyxError {\n readonly filePath: string;\n\n constructor(filePath: string, options?: ErrorOptions) {\n super(\"agentyx_config_not_found\", `Agentyx configuration file not found: ${filePath}`, options);\n this.name = \"AgentyxConfigNotFoundError\";\n this.filePath = filePath;\n }\n}\n\n/** Raised when `.agentyx.json` is not valid JSON. */\nexport class AgentyxConfigParseError extends AgentyxError {\n readonly filePath: string;\n\n constructor(filePath: string, reason: string, options?: ErrorOptions) {\n super(\"agentyx_config_parse_error\", `${filePath} is not valid JSON: ${reason}`, options);\n this.name = \"AgentyxConfigParseError\";\n this.filePath = filePath;\n }\n}\n\n/** Raised when the document parses as JSON but violates the Agentyx schema. */\nexport class AgentyxConfigValidationError extends AgentyxError {\n readonly issues: readonly AgentyxConfigIssue[];\n /** The file the configuration came from, when it was read from disk. */\n readonly filePath: string | undefined;\n\n constructor(error: ZodError, filePath?: string) {\n const issues = toAgentyxIssues(error);\n const location = filePath === undefined ? \"\" : ` in ${filePath}`;\n const details = issues.map((issue) => ` - ${issue.path}: ${issue.message}`).join(\"\\n\");\n\n super(\"agentyx_config_invalid\", `Invalid Agentyx configuration${location}:\\n${details}`);\n this.name = \"AgentyxConfigValidationError\";\n this.issues = issues;\n this.filePath = filePath;\n }\n}\n\nexport class UnknownEnabledCapabilityError extends AgentyxError {\n readonly capabilityName: string;\n readonly knownCapabilities: readonly string[];\n\n constructor(capabilityName: string, knownCapabilities: readonly string[]) {\n const known = knownCapabilities.length > 0 ? [...knownCapabilities].sort().join(\", \") : \"none\";\n\n super(\n \"unknown_enabled_capability\",\n `Unknown enabled capability \"${capabilityName}\". Known optional capabilities: ${known}.`,\n );\n this.name = \"UnknownEnabledCapabilityError\";\n this.capabilityName = capabilityName;\n this.knownCapabilities = knownCapabilities;\n }\n}\n\n/** Raised when a configured local Skill directory cannot be loaded safely. */\nexport class LocalSkillDirectoryError extends AgentyxError {\n readonly directory: string;\n\n constructor(directory: string, reason: string, options?: ErrorOptions) {\n super(\n \"local_skill_directory_error\",\n `Could not load local Skill directory \"${directory}\": ${reason}`,\n options,\n );\n this.name = \"LocalSkillDirectoryError\";\n this.directory = directory;\n }\n}\n\n/** Raised when a configured project-context path is missing or escapes the project. */\nexport class ProjectContextPathError extends AgentyxError {\n readonly path: string;\n\n constructor(path: string, reason: string, options?: ErrorOptions) {\n super(\n \"project_context_path_error\",\n `Invalid project context path \"${path}\": ${reason}.`,\n options,\n );\n this.name = \"ProjectContextPathError\";\n this.path = path;\n }\n}\n","import { z } from \"zod\";\n\nexport const HOOK_ACTIVATION_LEVELS = [\"default\", \"optional\"] as const;\n\nexport const hookActivationLevelSchema = z.enum(HOOK_ACTIVATION_LEVELS);\n\nexport const HOOK_EVENTS = [\"SessionStart\"] as const;\n\nexport const hookEventSchema = z.enum(HOOK_EVENTS);\n\nexport const hookNameSchema = z\n .string()\n .min(1, \"Hook names must be non-empty strings.\")\n .regex(\n /^[a-z0-9]+(?:-[a-z0-9]+)*$/,\n 'Hook names must be lowercase kebab-case, for example \"session-doctor-bootstrap\".',\n );\n\nexport const hookDefinitionSchema = z.strictObject({\n name: hookNameSchema.describe(\"Unique hook identifier.\"),\n description: z.string().trim().min(1, \"Hook descriptions must be non-empty strings.\"),\n event: hookEventSchema.describe(\"The provider lifecycle event this hook runs on.\"),\n command: z.string().trim().min(1, \"Hook command must be a non-empty string.\"),\n args: z.array(z.string()).default([]),\n});\n\nexport const hookReferenceSchema = z\n .union([\n hookNameSchema,\n z.strictObject({\n name: hookNameSchema.describe(\"Hook identifier.\"),\n activation: hookActivationLevelSchema.default(\"default\"),\n }),\n ])\n .transform((value) =>\n typeof value === \"string\"\n ? {\n name: value,\n activation: \"default\" as const,\n }\n : value,\n )\n .pipe(\n z.strictObject({\n name: hookNameSchema.describe(\"Hook identifier.\"),\n activation: hookActivationLevelSchema.describe(\n \"Whether this hook is active by default or explicit opt-in.\",\n ),\n }),\n );\n\nexport type HookActivationLevel = z.infer<typeof hookActivationLevelSchema>;\nexport type HookEvent = z.infer<typeof hookEventSchema>;\nexport type HookDefinition = z.infer<typeof hookDefinitionSchema>;\nexport type HookDefinitionInput = z.input<typeof hookDefinitionSchema>;\nexport type HookReference = z.infer<typeof hookReferenceSchema>;\nexport type HookReferenceInput = z.input<typeof hookReferenceSchema>;\n","import { z } from \"zod\";\n\nexport const MCP_CAPABILITY_LEVELS = [\"default\", \"optional\"] as const;\n\nexport const mcpCapabilityLevelSchema = z.enum(MCP_CAPABILITY_LEVELS);\n\nexport const MCP_CONTEXT_COSTS = [\"low\", \"medium\", \"high\"] as const;\n\nexport const mcpContextCostSchema = z.enum(MCP_CONTEXT_COSTS);\n\n/**\n * Whether *launching* this server, as configured, can by itself fetch a package from a registry.\n *\n * Agentyx itself never downloads or installs anything. This describes the command a provider would\n * run once the server is enabled: `\"local\"` only ever runs an already-local binary or calls a\n * remote HTTP endpoint; `\"may-download\"` shells out through something like `npx`, which can fetch a\n * package on first launch even when Agentyx did nothing but write the configuration.\n */\nexport const MCP_RUNTIMES = [\"local\", \"may-download\"] as const;\n\nexport const mcpRuntimeSchema = z.enum(MCP_RUNTIMES);\n\nexport const mcpServerNameSchema = z\n .string()\n .min(1, \"MCP server names must be non-empty strings.\")\n .regex(\n /^[a-z0-9]+(?:-[a-z0-9]+)*$/,\n 'MCP server names must be lowercase kebab-case, for example \"context7\".',\n );\n\nexport const mcpEnvReferenceSchema = z.strictObject({\n fromEnv: z\n .string()\n .trim()\n .min(1, \"Environment variable references must be non-empty strings.\")\n .regex(/^[A-Za-z_][A-Za-z0-9_]*$/, \"Environment variable names must be valid shell names.\"),\n});\n\nconst commonMcpServerDefinitionSchema = z.strictObject({\n name: mcpServerNameSchema.describe(\"Unique MCP server identifier.\"),\n description: z.string().trim().min(1, \"MCP server descriptions must be non-empty strings.\"),\n transport: z.enum([\"stdio\", \"http\"]),\n contextCost: mcpContextCostSchema\n .describe(\"Qualitative context/tool-schema overhead classification; not token accounting.\")\n .optional(),\n runtime: mcpRuntimeSchema\n .describe(\"Whether launching this server can fetch a package on first use; see MCP_RUNTIMES.\")\n .optional(),\n});\n\nconst explicitMcpServerReferenceSchema = z.strictObject({\n name: mcpServerNameSchema.describe(\"MCP server identifier.\"),\n activation: mcpCapabilityLevelSchema\n .describe(\"Whether this MCP capability is active by default or explicit opt-in.\")\n .default(\"default\"),\n});\n\nexport const mcpServerReferenceSchema = z\n .union([mcpServerNameSchema, explicitMcpServerReferenceSchema])\n .transform((value) =>\n typeof value === \"string\"\n ? {\n name: value,\n activation: \"default\" as const,\n }\n : value,\n )\n .pipe(\n z.strictObject({\n name: mcpServerNameSchema.describe(\"MCP server identifier.\"),\n activation: mcpCapabilityLevelSchema.describe(\n \"Whether this MCP capability is active by default or explicit opt-in.\",\n ),\n }),\n );\n\nexport const stdioMcpServerDefinitionSchema = commonMcpServerDefinitionSchema.extend({\n transport: z.literal(\"stdio\"),\n command: z.string().trim().min(1, \"MCP stdio command must be a non-empty string.\"),\n args: z.array(z.string()).default([]),\n env: z.record(z.string().min(1), mcpEnvReferenceSchema).default({}),\n});\n\nexport const httpMcpServerDefinitionSchema = commonMcpServerDefinitionSchema.extend({\n transport: z.literal(\"http\"),\n url: z.url(\"MCP HTTP URL must be a valid URL.\"),\n headers: z.record(z.string().min(1), mcpEnvReferenceSchema).default({}),\n});\n\nexport const mcpServerDefinitionSchema = z.discriminatedUnion(\"transport\", [\n stdioMcpServerDefinitionSchema,\n httpMcpServerDefinitionSchema,\n]);\n\nexport type McpEnvReference = z.infer<typeof mcpEnvReferenceSchema>;\nexport type McpCapabilityLevel = z.infer<typeof mcpCapabilityLevelSchema>;\nexport type McpContextCost = z.infer<typeof mcpContextCostSchema>;\nexport type McpRuntime = z.infer<typeof mcpRuntimeSchema>;\nexport type McpServerDefinition = z.infer<typeof mcpServerDefinitionSchema>;\nexport type McpServerDefinitionInput = z.input<typeof mcpServerDefinitionSchema>;\nexport type McpServerReference = z.infer<typeof mcpServerReferenceSchema>;\nexport type McpServerReferenceInput = z.input<typeof mcpServerReferenceSchema>;\n","import { z } from \"zod\";\n\n/**\n * Skill names double as directory names for `SKILL.md` files, so they are\n * constrained to a lowercase slug. That keeps them stable across filesystems\n * and makes them safe to join onto a path.\n */\nexport const skillNameSchema = z\n .string()\n .min(1, \"Skill names must be non-empty strings.\")\n .regex(\n /^[a-z0-9]+(?:-[a-z0-9]+)*$/,\n 'Skill names must be lowercase kebab-case, for example \"typescript-modern\".',\n );\n\n/**\n * The metadata a Skill carries, and exactly what a `SKILL.md` frontmatter block\n * may declare. Kept separate from the full definition so the parser can reject\n * a frontmatter key that tries to supply the body.\n */\nexport const skillMetadataSchema = z.strictObject({\n name: skillNameSchema.describe(\"Unique skill identifier.\"),\n description: z\n .string()\n .trim()\n .min(1, \"Skill descriptions must be non-empty strings.\")\n .describe(\"One-line summary of what the skill tells an agent to do.\"),\n});\n\n/**\n * A Skill is reusable instruction text for a coding agent. It is deliberately\n * provider-independent: nothing here says how or where a provider installs it.\n */\nexport const skillDefinitionSchema = skillMetadataSchema.extend({\n content: z\n .string()\n .trim()\n .min(1, \"Skill content must be non-empty.\")\n .describe(\"The Markdown instructions handed to an agent.\"),\n});\n\n/** A validated skill definition. */\nexport type SkillDefinition = z.infer<typeof skillDefinitionSchema>;\n\n/** The shape accepted when authoring a skill definition. */\nexport type SkillDefinitionInput = z.input<typeof skillDefinitionSchema>;\n","import { z } from \"zod\";\n\nexport const TOOL_ACTIVATION_LEVELS = [\"default\", \"optional\"] as const;\n\nexport const toolActivationLevelSchema = z.enum(TOOL_ACTIVATION_LEVELS);\n\nexport const toolNameSchema = z\n .string()\n .min(1, \"Tool names must be non-empty strings.\")\n .regex(\n /^[a-z0-9]+(?:-[a-z0-9]+)*$/,\n 'Tool names must be lowercase kebab-case, for example \"rtk\".',\n );\n\nexport const toolReferenceSchema = z\n .union([\n toolNameSchema,\n z.strictObject({\n name: toolNameSchema.describe(\"Tool identifier.\"),\n activation: toolActivationLevelSchema.default(\"default\"),\n }),\n ])\n .transform((value) =>\n typeof value === \"string\"\n ? {\n name: value,\n activation: \"default\" as const,\n }\n : value,\n )\n .pipe(\n z.strictObject({\n name: toolNameSchema.describe(\"Tool identifier.\"),\n activation: toolActivationLevelSchema,\n }),\n );\n\nexport const toolDefinitionSchema = z.strictObject({\n name: toolNameSchema.describe(\"Unique tool identifier.\"),\n description: z.string().trim().min(1, \"Tool descriptions must be non-empty strings.\"),\n kind: z.literal(\"executable\"),\n command: z.string().trim().min(1, \"Tool executable command must be a non-empty string.\"),\n optional: z.boolean().default(true),\n installHint: z.string().trim().min(1, \"Tool install hints must be non-empty strings.\").optional(),\n});\n\nexport type ToolActivationLevel = z.infer<typeof toolActivationLevelSchema>;\nexport type ToolDefinition = z.infer<typeof toolDefinitionSchema>;\nexport type ToolDefinitionInput = z.input<typeof toolDefinitionSchema>;\nexport type ToolReference = z.infer<typeof toolReferenceSchema>;\nexport type ToolReferenceInput = z.input<typeof toolReferenceSchema>;\n","import { z } from \"zod\";\nimport { hookReferenceSchema } from \"../hook/schema.js\";\nimport { mcpServerReferenceSchema } from \"../mcp/schema.js\";\nimport { skillNameSchema } from \"../skill/schema.js\";\nimport { toolReferenceSchema } from \"../tool/schema.js\";\n\nexport const PACK_CATEGORIES = [\n \"engineering\",\n \"language\",\n \"framework\",\n \"efficiency\",\n \"workflow\",\n] as const;\n\nexport const packCategorySchema = z.enum(PACK_CATEGORIES);\n\n/**\n * Pack names are plain identifiers. They are intentionally not constrained to\n * a closed list so that external registries can contribute packs later.\n */\nexport const packNameSchema = z.string().min(1, \"Pack names must be non-empty strings.\");\n\n/** A pack is a composable provider-neutral capability bundle. */\nexport const packDefinitionSchema = z.strictObject({\n name: packNameSchema.describe(\"Unique pack identifier.\"),\n category: packCategorySchema\n .describe(\"Discoverability category; does not affect resolution.\")\n .default(\"engineering\"),\n description: z\n .string()\n .min(1, \"Pack descriptions must be non-empty when provided.\")\n .describe(\"Short human-readable summary of the pack.\")\n .optional(),\n skills: z\n .array(skillNameSchema)\n .describe(\"Skills this pack contributes, in declaration order.\")\n .default([]),\n mcpServers: z\n .array(mcpServerReferenceSchema)\n .describe(\"MCP servers this pack contributes, in declaration order.\")\n .default([]),\n tools: z\n .array(toolReferenceSchema)\n .describe(\"Local tools this pack contributes, in declaration order.\")\n .default([]),\n hooks: z\n .array(hookReferenceSchema)\n .describe(\"Provider lifecycle hooks this pack contributes, in declaration order.\")\n .default([]),\n});\n\n/** A validated pack definition, with defaults always present. */\nexport type PackDefinition = z.infer<typeof packDefinitionSchema>;\nexport type PackCategory = z.infer<typeof packCategorySchema>;\n\n/** The shape accepted when authoring a pack definition. */\nexport type PackDefinitionInput = z.input<typeof packDefinitionSchema>;\n","import { z } from \"zod\";\nimport { skillNameSchema } from \"../skill/schema.js\";\n\nexport const trustedSourceNameSchema = z\n .string()\n .min(1, \"Trusted source names must be non-empty strings.\")\n .regex(\n /^[a-z0-9]+(?:-[a-z0-9]+)*$/,\n 'Trusted source names must be lowercase kebab-case, for example \"superpowers\".',\n );\n\nexport const trustedSourcePathSchema = z\n .string()\n .min(1, \"Trusted source paths must be non-empty strings.\")\n .regex(\n /^(?!\\/)(?![A-Za-z]:)(?!.*(?:^|\\/)\\.\\.(?:\\/|$))[^\\\\\\0]+$/,\n \"Trusted source paths must be portable project-relative paths without parent traversal.\",\n );\n\nexport const trustedSourceReferenceSchema = z.strictObject({\n name: trustedSourceNameSchema.describe(\"Known trusted source identifier.\"),\n path: trustedSourcePathSchema.describe(\"Project-relative checkout path for this source.\"),\n ref: z\n .string()\n .trim()\n .min(1, \"Trusted source refs must be non-empty strings.\")\n .describe(\"Reviewed immutable commit, signed tag or pinned release identifier.\"),\n});\n\nexport const trustedSourceDefinitionSchema = z.strictObject({\n name: trustedSourceNameSchema,\n displayName: z.string().min(1),\n repository: z.string().url(),\n type: z.literal(\"codex-plugin\"),\n manifestPath: z.string().min(1),\n recommendedPath: trustedSourcePathSchema,\n description: z.string().min(1),\n installStatus: z.enum([\"metadata-only\", \"installable\"]),\n installNote: z.string().min(1),\n});\n\nexport const codexPluginManifestSchema = z\n .object({\n name: trustedSourceNameSchema,\n version: z.string().min(1),\n description: z.string().min(1),\n repository: z.string().url(),\n license: z.string().min(1),\n skills: z.string().min(1),\n })\n .passthrough();\n\nexport const trustedSourceSkillSummarySchema = z.strictObject({\n name: skillNameSchema,\n description: z.string().min(1),\n hasResources: z.boolean(),\n});\n\nexport type TrustedSourceReference = z.infer<typeof trustedSourceReferenceSchema>;\nexport type TrustedSourceDefinition = z.infer<typeof trustedSourceDefinitionSchema>;\nexport type CodexPluginManifest = z.infer<typeof codexPluginManifestSchema>;\nexport type TrustedSourceSkillSummary = z.infer<typeof trustedSourceSkillSummarySchema>;\n","import { z } from \"zod\";\nimport { packDefinitionSchema, packNameSchema } from \"../pack/schema.js\";\nimport { trustedSourceReferenceSchema } from \"../source/schema.js\";\n\n/**\n * Targets stay free-form strings on purpose: third-party adapters should be\n * able to register providers without a change to this schema.\n */\nexport const agentyxTargetSchema = z.string().min(1, \"Targets must be non-empty strings.\");\n\nexport const enabledCapabilityNameSchema = z\n .string()\n .min(1, \"Enabled capability names must be non-empty strings.\")\n .regex(\n /^[a-z0-9]+(?:-[a-z0-9]+)*$/,\n 'Enabled capability names must be lowercase kebab-case, for example \"rtk\".',\n );\n\n/**\n * Portable project-relative path to a directory whose direct children are Agent Skills.\n * Backslashes, absolute paths and parent traversal are rejected so the same config is safe on\n * every supported platform.\n */\nexport const skillDirectorySchema = z\n .string()\n .min(1, \"Skill directories must be non-empty strings.\")\n .regex(\n /^(?!\\/)(?![A-Za-z]:)(?!.*(?:^|\\/)\\.\\.(?:\\/|$))[^\\\\\\0]+$/,\n \"Skill directories must be portable project-relative paths without parent traversal.\",\n );\n\nconst projectIdSchema = z\n .string()\n .regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, \"Project ids must be lowercase kebab-case identifiers.\");\nconst projectTextSchema = z\n .string()\n .min(1, \"Must not be blank.\")\n .refine((value) => value.trim().length > 0, \"Must not be blank.\")\n .refine(\n (value) =>\n Array.from(value).every((character) => {\n const codePoint = character.codePointAt(0) ?? 0;\n return codePoint > 31 && (codePoint < 127 || codePoint > 159);\n }),\n \"Must be single-line text without control characters.\",\n );\nconst projectUrlSchema = z.string().url(\"Must be a valid URL.\");\nconst projectResourceNames = z\n .array(projectTextSchema)\n .refine((items) => new Set(items).size === items.length, \"Entries must be unique.\");\nconst projectDocsSchema = z\n .array(projectUrlSchema)\n .refine((items) => new Set(items).size === items.length, \"Documentation URLs must be unique.\");\nconst projectOwnsSchema = z\n .array(projectIdSchema)\n .refine((items) => new Set(items).size === items.length, \"Ownership entries must be unique.\");\n\nexport const projectMetadataSchema = z.strictObject({\n id: projectIdSchema.describe(\"Stable, human-authored project identifier in kebab-case.\"),\n name: projectTextSchema.describe(\"Human-readable project name.\"),\n description: projectTextSchema.optional().describe(\"Short description of this project.\"),\n repository: projectUrlSchema\n .optional()\n .describe(\"Repository URL; descriptive and never fetched.\"),\n docs: projectDocsSchema.default([]).describe(\"Documentation URLs; descriptive only.\"),\n mcp: projectResourceNames.default([]).describe(\"MCP server identifiers available to consult.\"),\n owns: projectOwnsSchema.default([]).describe(\"Architectural capabilities owned by this project.\"),\n});\n\nexport const projectRelationTypeSchema = z.enum([\"uses\", \"integrates\", \"consumes\", \"extends\"]);\n\nexport const projectRelationSchema = z.strictObject({\n id: projectIdSchema.describe(\"Stable identifier for the related project.\"),\n name: projectTextSchema.describe(\"Human-readable related project name.\"),\n type: projectRelationTypeSchema.describe(\"How the current project relates to this project.\"),\n role: projectIdSchema.describe(\"Architectural role of the related project.\"),\n repository: projectUrlSchema\n .optional()\n .describe(\"Repository URL; descriptive and never fetched.\"),\n docs: projectDocsSchema.default([]).describe(\"Documentation URLs; descriptive only.\"),\n mcp: projectResourceNames.default([]).describe(\"MCP server identifiers available to consult.\"),\n owns: projectOwnsSchema.default([]).describe(\"Architectural capabilities owned by this project.\"),\n guidance: z.array(projectTextSchema).default([]).describe(\"Human-authored guidance for agents.\"),\n});\n\nexport const projectCommandSchema = z.strictObject({\n command: projectTextSchema.describe(\"Suggested command; Agentyx never executes it.\"),\n cwd: z.string().min(1).default(\".\").describe(\"Project-relative working directory.\"),\n});\n\nexport const projectContextSchema = z\n .strictObject({\n commands: z\n .record(\n z\n .string()\n .min(1)\n .refine((name) => name.trim().length > 0, \"Command names must not be blank.\"),\n projectCommandSchema,\n )\n .default({}),\n areas: z\n .array(\n z.strictObject({\n path: z.string().min(1),\n purpose: projectTextSchema,\n }),\n )\n .default([]),\n constraints: z.array(projectTextSchema).default([]),\n })\n .describe(\"Explicit repository-local facts for the generated project context Skill.\");\n\n/** The `.agentyx.json` project configuration. */\nexport const agentyxConfigSchema = z\n .strictObject({\n $schema: z\n .string()\n .min(1, \"$schema must be a non-empty string.\")\n .describe(\"Optional path or URL to the Agentyx JSON Schema.\")\n .optional(),\n packs: z.array(packNameSchema).describe(\"Capability packs this project selects.\").default([]),\n enable: z\n .array(enabledCapabilityNameSchema)\n .describe(\"Optional capabilities to activate by explicit identifier.\")\n .default([]),\n targets: z\n .array(agentyxTargetSchema)\n .describe(\"Coding-agent providers this project targets.\")\n .default([]),\n skillDirectories: z\n .array(skillDirectorySchema)\n .describe(\"Project-relative roots containing local Agent Skills.\")\n .optional(),\n localPacks: z\n .array(packDefinitionSchema)\n .describe(\"Project-owned packs that can reference built-in or local Skills.\")\n .optional(),\n trustedSources: z\n .array(trustedSourceReferenceSchema)\n .describe(\"Pinned local checkouts of known external skill/plugin sources.\")\n .optional(),\n project: projectMetadataSchema.optional().describe(\"Identity and ownership for this project.\"),\n relations: z\n .array(projectRelationSchema)\n .optional()\n .describe(\"Direct architectural relationships.\"),\n context: projectContextSchema.optional(),\n })\n .superRefine((config, context) => {\n const relations = config.relations ?? [];\n if (relations.length > 0 && config.project === undefined) {\n context.addIssue({\n code: \"custom\",\n path: [\"project\"],\n message: \"Project metadata is required when relations are configured.\",\n });\n }\n const ids = new Set<string>();\n for (const [index, relation] of relations.entries()) {\n if (config.project?.id === relation.id) {\n context.addIssue({\n code: \"custom\",\n path: [\"relations\", index, \"id\"],\n message: \"A project cannot relate to itself.\",\n });\n }\n if (ids.has(relation.id)) {\n context.addIssue({\n code: \"custom\",\n path: [\"relations\", index, \"id\"],\n message: \"Related project ids must be unique.\",\n });\n }\n ids.add(relation.id);\n }\n const areaPaths = config.context?.areas.map((area) => area.path) ?? [];\n if (new Set(areaPaths).size !== areaPaths.length) {\n context.addIssue({\n code: \"custom\",\n path: [\"context\", \"areas\"],\n message: \"Area paths must be unique.\",\n });\n }\n });\n\n/** A validated configuration, with defaults applied. */\nexport type AgentyxConfig = z.infer<typeof agentyxConfigSchema>;\n\n/** The shape accepted in a `.agentyx.json` file. */\nexport type AgentyxConfigInput = z.input<typeof agentyxConfigSchema>;\nexport type ProjectMetadata = z.infer<typeof projectMetadataSchema>;\nexport type ProjectRelation = z.infer<typeof projectRelationSchema>;\nexport type ProjectContext = z.infer<typeof projectContextSchema>;\n","import { z } from \"zod\";\nimport { agentyxConfigSchema } from \"./schema.js\";\n\n/** Canonical identifier of the published `.agentyx.json` schema. */\nexport const AGENTYX_CONFIG_SCHEMA_ID =\n \"https://raw.githubusercontent.com/Andersseen/agentyx/main/packages/core/schema/agentyx.schema.json\";\n\n/**\n * Derives the JSON Schema for `.agentyx.json` from the Zod model, which stays the\n * single source of truth. The committed `schema/agentyx.schema.json` is generated\n * from this function and verified by tests.\n *\n * The `input` view is used so that fields with defaults stay optional, which is\n * what an author writing the file cares about.\n */\nexport function buildAgentyxConfigJsonSchema(): Record<string, unknown> {\n return {\n $schema: \"https://json-schema.org/draft/2020-12/schema\",\n $id: AGENTYX_CONFIG_SCHEMA_ID,\n title: \"Agentyx project configuration\",\n description: \"Configuration for an Agentyx project (.agentyx.json).\",\n ...z.toJSONSchema(agentyxConfigSchema, { io: \"input\" }),\n };\n}\n","import { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport {\n AgentyxConfigNotFoundError,\n AgentyxConfigParseError,\n AgentyxConfigValidationError,\n} from \"./errors.js\";\nimport { type AgentyxConfig, agentyxConfigSchema } from \"./schema.js\";\n\nexport const AGENTYX_CONFIG_FILENAME = \".agentyx.json\";\n\n/** The absolute path `.agentyx.json` is read from for a given project. */\nexport function agentyxConfigPath(projectPath: string = process.cwd()): string {\n return resolve(projectPath, AGENTYX_CONFIG_FILENAME);\n}\n\n/**\n * Validates an already-parsed configuration document.\n *\n * @throws {AgentyxConfigValidationError} when the document violates the schema.\n */\nexport function parseAgentyxConfig(value: unknown, filePath?: string): AgentyxConfig {\n const result = agentyxConfigSchema.safeParse(value);\n\n if (!result.success) {\n throw new AgentyxConfigValidationError(result.error, filePath);\n }\n\n return result.data;\n}\n\n/**\n * Reads and validates `.agentyx.json` from `projectPath`.\n *\n * Parent directories are not searched, and invalid configurations are never\n * silently repaired.\n *\n * @throws {AgentyxConfigNotFoundError} when the file does not exist.\n * @throws {AgentyxConfigParseError} when the file is not valid JSON.\n * @throws {AgentyxConfigValidationError} when the document violates the schema.\n */\nexport async function loadAgentyxConfig(\n projectPath: string = process.cwd(),\n): Promise<AgentyxConfig> {\n const filePath = agentyxConfigPath(projectPath);\n let contents: string;\n\n try {\n contents = await readFile(filePath, \"utf8\");\n } catch (cause) {\n if (isFileNotFound(cause)) {\n throw new AgentyxConfigNotFoundError(filePath, { cause });\n }\n\n throw cause;\n }\n\n let document: unknown;\n\n try {\n document = JSON.parse(contents);\n } catch (cause) {\n const reason = cause instanceof Error ? cause.message : String(cause);\n throw new AgentyxConfigParseError(filePath, reason, { cause });\n }\n\n return parseAgentyxConfig(document, filePath);\n}\n\nfunction isFileNotFound(cause: unknown): boolean {\n return cause instanceof Error && (cause as NodeJS.ErrnoException).code === \"ENOENT\";\n}\n","import { fileURLToPath } from \"node:url\";\n\n/**\n * Location of the non-code assets that ship with `@agentyx/core`.\n *\n * **This module must stay directly under `src/`.** The path is derived from\n * `import.meta.url` rather than the working directory, and `src/assets.ts` and\n * the bundled `dist/index.mjs` sit at the same depth below the package root, so\n * one relative path is correct both in development and in the published\n * package. Moving this file into a subdirectory breaks built-in skill loading;\n * `packages/core/test/built-in-skills.test.ts` guards against that.\n *\n * `skills/` is listed in the package's `files`, so it is published alongside\n * `dist/`.\n */\nexport const BUILT_IN_SKILLS_PATH = fileURLToPath(new URL(\"../skills\", import.meta.url));\nexport const PROJECT_CONTEXT_TEMPLATE_PATH = fileURLToPath(\n new URL(\"../templates/project-context.md\", import.meta.url),\n);\n","import { AgentyxError } from \"../errors.js\";\n\n/** Raised when a requested pack is not present in the registry. */\nexport class UnknownPackError extends AgentyxError {\n readonly packName: string;\n readonly requiredBy: string | undefined;\n readonly knownPacks: readonly string[];\n\n constructor(packName: string, requiredBy: string | undefined, knownPacks: readonly string[]) {\n const origin = requiredBy === undefined ? \"\" : ` (required by \"${requiredBy}\")`;\n const known = knownPacks.length > 0 ? [...knownPacks].sort().join(\", \") : \"none\";\n\n super(\"unknown_pack\", `Unknown pack \"${packName}\"${origin}. Known packs: ${known}.`);\n this.name = \"UnknownPackError\";\n this.packName = packName;\n this.requiredBy = requiredBy;\n this.knownPacks = knownPacks;\n }\n}\n\n/** @deprecated Packs no longer inherit from other packs. */\nexport class CircularPackDependencyError extends AgentyxError {\n /** The cycle path, starting and ending with the same pack. */\n readonly cycle: readonly string[];\n\n constructor(cycle: readonly string[]) {\n super(\"circular_pack_dependency\", `Circular pack dependency: ${cycle.join(\" -> \")}.`);\n this.name = \"CircularPackDependencyError\";\n this.cycle = cycle;\n }\n}\n\n/** Raised when a registry is built from definitions that reuse a pack name. */\nexport class DuplicatePackError extends AgentyxError {\n readonly packName: string;\n\n constructor(packName: string) {\n super(\"duplicate_pack\", `Duplicate pack definition: \"${packName}\".`);\n this.name = \"DuplicatePackError\";\n this.packName = packName;\n }\n}\n","import { DuplicatePackError } from \"./errors.js\";\nimport { type PackDefinition, type PackDefinitionInput, packDefinitionSchema } from \"./schema.js\";\n\n/**\n * A registry is a name lookup over pack definitions. Keeping it a plain map\n * means the resolver stays independent of where definitions come from, so\n * external registries can be added later without touching resolution.\n */\nexport type PackRegistry = ReadonlyMap<string, PackDefinition>;\n\n/** Validates definitions and indexes them by name. */\nexport function createPackRegistry(definitions: Iterable<PackDefinitionInput>): PackRegistry {\n const registry = new Map<string, PackDefinition>();\n\n for (const definition of definitions) {\n const pack = packDefinitionSchema.parse(definition);\n\n if (registry.has(pack.name)) {\n throw new DuplicatePackError(pack.name);\n }\n\n registry.set(pack.name, pack);\n }\n\n return registry;\n}\n\n/**\n * The packs Agentyx ships with, expressed as data. Relationships live here, not\n * in the resolver.\n */\nexport const builtInPacks: readonly PackDefinitionInput[] = [\n {\n name: \"technical\",\n category: \"engineering\",\n description: \"General software-engineering quality independent of language or framework.\",\n skills: [\"engineering-principles\", \"code-quality\", \"api-design\", \"code-review\"],\n },\n {\n name: \"typescript\",\n category: \"language\",\n description: \"TypeScript language conventions for strict, modern code.\",\n skills: [\"typescript-strict\", \"typescript-modeling\", \"typescript-modern\"],\n },\n {\n name: \"rust\",\n category: \"language\",\n description:\n \"Modern, idiomatic Rust development with safe ownership, Cargo verification, portability, and filesystem-aware engineering.\",\n skills: [\n \"rust-idiomatic-development\",\n \"rust-filesystem-safety\",\n \"rust-testing-portability\",\n \"cargo-project-verification\",\n ],\n },\n {\n name: \"angular\",\n category: \"framework\",\n description: \"Modern Angular development environment.\",\n skills: [\"angular-modern\", \"angular-signals\", \"angular-architecture\", \"angular-testing\"],\n mcpServers: [\"context7\"],\n },\n {\n name: \"efficiency\",\n category: \"efficiency\",\n description: \"Reduce context and tool overhead without weakening verification.\",\n skills: [\n \"context-efficient-development\",\n \"concise-output\",\n \"targeted-exploration\",\n \"focused-verification\",\n ],\n mcpServers: [{ name: \"codebase-memory\", activation: \"optional\" }],\n tools: [{ name: \"rtk\", activation: \"optional\" }],\n hooks: [{ name: \"session-doctor-bootstrap\", activation: \"default\" }],\n },\n {\n name: \"agentic\",\n category: \"workflow\",\n description: \"Provider-neutral development workflows for substantial coding-agent work.\",\n skills: [\n \"brainstorming\",\n \"planning\",\n \"systematic-debugging\",\n \"verification\",\n \"parallel-work\",\n \"worktree-workflow\",\n \"subagent-driven-development\",\n \"requesting-code-review\",\n ],\n },\n {\n name: \"testing\",\n category: \"engineering\",\n description: \"Test design, isolation and stability at every level of the pyramid.\",\n skills: [\"test-strategy\", \"test-doubles\", \"e2e-testing\", \"flaky-tests\"],\n mcpServers: [{ name: \"playwright\", activation: \"optional\" }],\n },\n {\n name: \"security\",\n category: \"engineering\",\n description: \"Application security fundamentals for untrusted input, secrets and access.\",\n skills: [\"secure-coding\", \"secrets-handling\", \"dependency-security\", \"auth-patterns\"],\n },\n {\n name: \"performance\",\n category: \"engineering\",\n description: \"Measure before optimizing, across application, browser and database.\",\n skills: [\"performance-profiling\", \"web-vitals\", \"query-performance\"],\n mcpServers: [{ name: \"chrome-devtools\", activation: \"optional\" }],\n },\n {\n name: \"accessibility\",\n category: \"engineering\",\n description: \"Accessible markup, ARIA and keyboard interaction for web interfaces.\",\n skills: [\"semantic-html\", \"aria-patterns\", \"keyboard-navigation\"],\n mcpServers: [{ name: \"chrome-devtools\", activation: \"optional\" }],\n },\n {\n name: \"refactoring\",\n category: \"engineering\",\n description: \"Change structure safely, including in legacy code with weak tests.\",\n skills: [\"refactoring-safely\", \"legacy-code\", \"dependency-hygiene\"],\n },\n {\n name: \"documentation\",\n category: \"engineering\",\n description: \"Documentation, interface reference and decision records that stay useful.\",\n skills: [\"technical-writing\", \"api-documentation\", \"decision-records\"],\n },\n {\n name: \"observability\",\n category: \"engineering\",\n description: \"Logging, metrics, tracing and incident response for running systems.\",\n skills: [\"structured-logging\", \"metrics-and-tracing\", \"incident-response\"],\n mcpServers: [{ name: \"sentry\", activation: \"optional\" }],\n },\n {\n name: \"data\",\n category: \"engineering\",\n description: \"Schema design, migrations and transactional correctness.\",\n skills: [\"data-modeling\", \"schema-migrations\", \"transactions-and-consistency\"],\n mcpServers: [{ name: \"supabase\", activation: \"optional\" }],\n },\n {\n name: \"git\",\n category: \"workflow\",\n description: \"Commit, branch and pull-request practice for reviewable history.\",\n skills: [\"commit-hygiene\", \"branching-strategy\", \"pull-requests\"],\n mcpServers: [{ name: \"github\", activation: \"optional\" }],\n },\n {\n name: \"devops\",\n category: \"workflow\",\n description: \"Continuous integration, containers, deployment safety and infrastructure.\",\n skills: [\"ci-pipelines\", \"containerization\", \"deployment-safety\", \"infrastructure-as-code\"],\n },\n];\n\n/** The registry used by default when no explicit registry is supplied. */\nexport const builtInPackRegistry: PackRegistry = createPackRegistry(builtInPacks);\n","import type { ZodError } from \"zod\";\nimport { AgentyxError } from \"../errors.js\";\n\n/**\n * Raised when a pack references a skill the registry does not know.\n *\n * The offending name is exposed as `skillName`; `pack` stays the JS pack\n * trace inherited from `Error`.\n */\nexport class UnknownSkillError extends AgentyxError {\n readonly skillName: string;\n /** The pack that declared the skill, when the failure came from resolution. */\n readonly requiredBy: string | undefined;\n readonly knownSkills: readonly string[];\n\n constructor(skillName: string, requiredBy: string | undefined, knownSkills: readonly string[]) {\n const origin = requiredBy === undefined ? \"\" : ` (required by pack \"${requiredBy}\")`;\n const known = knownSkills.length > 0 ? [...knownSkills].sort().join(\", \") : \"none\";\n\n super(\"unknown_skill\", `Unknown skill \"${skillName}\"${origin}. Known skills: ${known}.`);\n this.name = \"UnknownSkillError\";\n this.skillName = skillName;\n this.requiredBy = requiredBy;\n this.knownSkills = knownSkills;\n }\n}\n\n/** Raised when a registry is built from sources that reuse a skill name. */\nexport class DuplicateSkillError extends AgentyxError {\n readonly skillName: string;\n\n constructor(skillName: string) {\n super(\"duplicate_skill\", `Duplicate skill definition: \"${skillName}\".`);\n this.name = \"DuplicateSkillError\";\n this.skillName = skillName;\n }\n}\n\n/**\n * Raised when a skill exists but cannot be turned into a valid definition —\n * malformed `SKILL.md` frontmatter, a missing field, an unreadable file.\n *\n * Built-in skills ship with Agentyx, so this is a programmer error rather than\n * something a user can fix in their project.\n */\nexport class InvalidSkillError extends AgentyxError {\n /** Where the skill came from: a file path, or a label for an in-memory source. */\n readonly origin: string;\n readonly reason: string;\n\n constructor(origin: string, reason: string | ZodError, options?: ErrorOptions) {\n const detail = typeof reason === \"string\" ? reason : formatIssues(reason);\n\n super(\"invalid_skill\", `Invalid skill in ${origin}: ${detail}`, options);\n this.name = \"InvalidSkillError\";\n this.origin = origin;\n this.reason = detail;\n }\n}\n\nfunction formatIssues(error: ZodError): string {\n return error.issues\n .map((issue) => {\n const path = issue.path.map(String).join(\".\");\n\n return path === \"\" ? issue.message : `${path}: ${issue.message}`;\n })\n .join(\"; \");\n}\n","import { InvalidSkillError } from \"./errors.js\";\nimport {\n type SkillDefinition,\n type SkillDefinitionInput,\n skillDefinitionSchema,\n skillMetadataSchema,\n} from \"./schema.js\";\n\nconst DELIMITER = \"---\";\nconst BYTE_ORDER_MARK = /^\\uFEFF/;\nconst LINE_BREAK = /[\\r\\n]/;\n\n/**\n * A `SKILL.md` file is a frontmatter block followed by the Markdown body:\n *\n * ```md\n * ---\n * name: planning\n * description: Plan non-trivial work before editing.\n * ---\n *\n * Instructions...\n * ```\n *\n * The frontmatter is a deliberately small YAML subset — a flat block of\n * `key: value` pairs, values optionally quoted — so that core keeps depending\n * on Zod alone. Anything richer is rejected rather than guessed at.\n *\n * The body is preserved as written apart from trimming the blank lines around\n * it, and `origin` is only used to make errors readable.\n *\n * @throws {InvalidSkillError} when the frontmatter or the resulting skill is invalid.\n */\nexport function parseSkillMarkdown(markdown: string, origin: string): SkillDefinition {\n const lines = markdown.replace(BYTE_ORDER_MARK, \"\").split(/\\r?\\n/);\n\n if (lines[0]?.trim() !== DELIMITER) {\n throw new InvalidSkillError(\n origin,\n `the file must start with a \"${DELIMITER}\" frontmatter line`,\n );\n }\n\n const closing = lines.findIndex((line, index) => index > 0 && line.trim() === DELIMITER);\n\n if (closing === -1) {\n throw new InvalidSkillError(\n origin,\n `the frontmatter block is never closed with \"${DELIMITER}\"`,\n );\n }\n\n const metadata = skillMetadataSchema.safeParse(parseFrontmatter(lines.slice(1, closing), origin));\n\n if (!metadata.success) {\n throw new InvalidSkillError(origin, metadata.error);\n }\n\n const skill = skillDefinitionSchema.safeParse({\n ...metadata.data,\n content: lines.slice(closing + 1).join(\"\\n\"),\n });\n\n if (!skill.success) {\n throw new InvalidSkillError(origin, skill.error);\n }\n\n return skill.data;\n}\n\n/**\n * Renders a skill as canonical `SKILL.md` text — the inverse of\n * `parseSkillMarkdown`, and the single representation every consumer installs.\n *\n * Keeping this in core is what stops a provider from owning a copy of a skill\n * body: an adapter decides *where* a skill goes, never what it says.\n *\n * The output is deterministic. Frontmatter is always `name` then `description`,\n * the body is the trimmed content, and the file ends with exactly one newline,\n * so re-rendering an unchanged skill produces a byte-identical file and an\n * installer can compare content instead of guessing.\n *\n * @throws {InvalidSkillError} when the definition is invalid, or when the\n * description cannot be represented in the flat frontmatter subset the parser\n * accepts.\n */\nexport function formatSkillMarkdown(skill: SkillDefinitionInput): string {\n const origin = typeof skill.name === \"string\" ? `skill \"${skill.name}\"` : \"skill definition\";\n const parsed = skillDefinitionSchema.safeParse(skill);\n\n if (!parsed.success) {\n throw new InvalidSkillError(origin, parsed.error);\n }\n\n const { name, description, content } = parsed.data;\n\n if (LINE_BREAK.test(description)) {\n throw new InvalidSkillError(origin, \"the description must not contain a line break\");\n }\n\n return `${DELIMITER}\\nname: ${name}\\ndescription: ${description}\\n${DELIMITER}\\n\\n${content}\\n`;\n}\n\nfunction parseFrontmatter(lines: readonly string[], origin: string): Record<string, string> {\n const entries = new Map<string, string>();\n\n for (const [index, line] of lines.entries()) {\n if (line.trim() === \"\") {\n continue;\n }\n\n const separator = line.indexOf(\":\");\n // +2: the opening delimiter line, plus the shift from a zero-based index.\n const lineNumber = index + 2;\n\n if (separator === -1) {\n throw new InvalidSkillError(\n origin,\n `frontmatter line ${lineNumber} is not \"key: value\": ${line}`,\n );\n }\n\n const key = line.slice(0, separator).trim();\n\n if (key === \"\") {\n throw new InvalidSkillError(origin, `frontmatter line ${lineNumber} has an empty key`);\n }\n\n if (entries.has(key)) {\n throw new InvalidSkillError(\n origin,\n `duplicate frontmatter key \"${key}\" on line ${lineNumber}`,\n );\n }\n\n entries.set(key, unquote(line.slice(separator + 1).trim()));\n }\n\n return Object.fromEntries(entries);\n}\n\nfunction unquote(value: string): string {\n const quoted = /^\"(.*)\"$|^'(.*)'$/.exec(value);\n\n return quoted?.[1] ?? quoted?.[2] ?? value;\n}\n","import { DuplicateSkillError, InvalidSkillError, UnknownSkillError } from \"./errors.js\";\nimport {\n type SkillDefinition,\n type SkillDefinitionInput,\n skillDefinitionSchema,\n skillNameSchema,\n} from \"./schema.js\";\n\n/**\n * Where a single skill comes from. The name is known up front so that listing\n * and existence checks stay cheap, and `load` is only called when something\n * actually needs the instructions — a design that keeps `resolve` working on\n * identifiers alone.\n *\n * This is also the seam an external or remote registry would plug into later.\n */\nexport interface SkillSource {\n readonly name: string;\n /** Produces the definition. Called at most once per registry. */\n load(): SkillDefinitionInput;\n}\n\n/** A name lookup over skills, independent of where the definitions live. */\nexport interface SkillRegistry {\n /** Registered names in registration order. Never reads a skill body. */\n readonly names: readonly string[];\n has(name: string): boolean;\n /**\n * Loads, validates and caches a skill.\n *\n * @throws {UnknownSkillError} when the name is not registered.\n * @throws {InvalidSkillError} when the source yields an invalid definition.\n */\n get(name: string): SkillDefinition;\n}\n\n/**\n * Indexes skill sources by name.\n *\n * Names and duplicates are validated here; the definitions themselves are\n * validated the first time each skill is loaded.\n *\n * @throws {DuplicateSkillError} when two sources share a name.\n * @throws {InvalidSkillError} when a source name is not a valid skill name.\n */\nexport function createSkillRegistry(sources: Iterable<SkillSource>): SkillRegistry {\n const byName = new Map<string, SkillSource>();\n\n for (const source of sources) {\n const name = skillNameSchema.safeParse(source.name);\n\n if (!name.success) {\n throw new InvalidSkillError(`skill source \"${source.name}\"`, name.error);\n }\n\n if (byName.has(name.data)) {\n throw new DuplicateSkillError(name.data);\n }\n\n byName.set(name.data, source);\n }\n\n const names = [...byName.keys()];\n const loaded = new Map<string, SkillDefinition>();\n\n return {\n names,\n has: (name) => byName.has(name),\n get: (name) => {\n const cached = loaded.get(name);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const source = byName.get(name);\n\n if (source === undefined) {\n throw new UnknownSkillError(name, undefined, names);\n }\n\n const origin = `skill \"${name}\"`;\n const skill = skillDefinitionSchema.safeParse(source.load());\n\n if (!skill.success) {\n throw new InvalidSkillError(origin, skill.error);\n }\n\n if (skill.data.name !== name) {\n throw new InvalidSkillError(origin, `it declares the name \"${skill.data.name}\"`);\n }\n\n loaded.set(name, skill.data);\n\n return skill.data;\n },\n };\n}\n","import { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { BUILT_IN_SKILLS_PATH } from \"../assets.js\";\nimport { InvalidSkillError } from \"./errors.js\";\nimport { parseSkillMarkdown } from \"./markdown.js\";\nimport { createSkillRegistry, type SkillRegistry } from \"./registry.js\";\nimport type { SkillDefinition } from \"./schema.js\";\n\n/**\n * The skills Agentyx ships with. The names are the directory names under\n * `packages/core/skills`, and knowing them without touching the filesystem is\n * what lets pack resolution validate references without reading any body.\n */\nexport const builtInSkillNames = [\n \"engineering-principles\",\n \"code-quality\",\n \"api-design\",\n \"code-review\",\n \"planning\",\n \"systematic-debugging\",\n \"verification\",\n \"brainstorming\",\n \"parallel-work\",\n \"worktree-workflow\",\n \"subagent-driven-development\",\n \"requesting-code-review\",\n \"typescript-strict\",\n \"typescript-modeling\",\n \"typescript-modern\",\n \"rust-idiomatic-development\",\n \"rust-filesystem-safety\",\n \"rust-testing-portability\",\n \"cargo-project-verification\",\n \"angular-modern\",\n \"angular-signals\",\n \"angular-architecture\",\n \"angular-testing\",\n \"context-efficient-development\",\n \"concise-output\",\n \"targeted-exploration\",\n \"focused-verification\",\n \"test-strategy\",\n \"test-doubles\",\n \"e2e-testing\",\n \"flaky-tests\",\n \"secure-coding\",\n \"secrets-handling\",\n \"dependency-security\",\n \"auth-patterns\",\n \"performance-profiling\",\n \"web-vitals\",\n \"query-performance\",\n \"semantic-html\",\n \"aria-patterns\",\n \"keyboard-navigation\",\n \"refactoring-safely\",\n \"legacy-code\",\n \"dependency-hygiene\",\n \"technical-writing\",\n \"api-documentation\",\n \"decision-records\",\n \"structured-logging\",\n \"metrics-and-tracing\",\n \"incident-response\",\n \"data-modeling\",\n \"schema-migrations\",\n \"transactions-and-consistency\",\n \"commit-hygiene\",\n \"branching-strategy\",\n \"pull-requests\",\n \"ci-pipelines\",\n \"containerization\",\n \"deployment-safety\",\n \"infrastructure-as-code\",\n] as const;\n\n/** The absolute path of a built-in skill's `SKILL.md`. */\nexport function builtInSkillPath(name: string): string {\n return join(BUILT_IN_SKILLS_PATH, name, \"SKILL.md\");\n}\n\n/** The registry used by default when no explicit registry is supplied. */\nexport const builtInSkillRegistry: SkillRegistry = createSkillRegistry(\n builtInSkillNames.map((name) => ({ name, load: () => loadBuiltInSkill(name) })),\n);\n\n/**\n * Reads one built-in `SKILL.md`.\n *\n * Reading is synchronous on purpose: the files are small package assets, they\n * are only touched when a command asks for instructions, and a synchronous read\n * keeps `SkillRegistry.get` a plain lookup instead of infecting every caller\n * with a promise.\n */\nfunction loadBuiltInSkill(name: string): SkillDefinition {\n const filePath = builtInSkillPath(name);\n let markdown: string;\n\n try {\n markdown = readFileSync(filePath, \"utf8\");\n } catch (cause) {\n const reason = cause instanceof Error ? cause.message : String(cause);\n\n throw new InvalidSkillError(filePath, `the file could not be read: ${reason}`, { cause });\n }\n\n return parseSkillMarkdown(markdown, filePath);\n}\n","import { AgentyxError } from \"../errors.js\";\n\nexport class DuplicateTrustedSourceError extends AgentyxError {\n readonly sourceName: string;\n\n constructor(sourceName: string) {\n super(\"duplicate_trusted_source\", `Duplicate trusted source \"${sourceName}\".`);\n this.name = \"DuplicateTrustedSourceError\";\n this.sourceName = sourceName;\n }\n}\n\nexport class UnknownTrustedSourceError extends AgentyxError {\n readonly sourceName: string;\n readonly knownSources: readonly string[];\n\n constructor(sourceName: string, knownSources: readonly string[]) {\n const known = knownSources.length > 0 ? [...knownSources].sort().join(\", \") : \"none\";\n\n super(\n \"unknown_trusted_source\",\n `Unknown trusted source \"${sourceName}\". Known trusted sources: ${known}.`,\n );\n this.name = \"UnknownTrustedSourceError\";\n this.sourceName = sourceName;\n this.knownSources = knownSources;\n }\n}\n\nexport class TrustedSourceLoadError extends AgentyxError {\n readonly sourceName: string;\n\n constructor(sourceName: string, reason: string, options?: ErrorOptions) {\n super(\n \"trusted_source_load_error\",\n `Could not load trusted source \"${sourceName}\": ${reason}`,\n options,\n );\n this.name = \"TrustedSourceLoadError\";\n this.sourceName = sourceName;\n }\n}\n","import { DuplicateTrustedSourceError, UnknownTrustedSourceError } from \"./errors.js\";\nimport {\n type TrustedSourceDefinition,\n type TrustedSourceReference,\n trustedSourceDefinitionSchema,\n} from \"./schema.js\";\n\nexport type TrustedSourceRegistry = ReadonlyMap<string, TrustedSourceDefinition>;\n\nexport const knownTrustedSources: readonly TrustedSourceDefinition[] = [\n trustedSourceDefinitionSchema.parse({\n name: \"superpowers\",\n displayName: \"Superpowers\",\n repository: \"https://github.com/obra/superpowers\",\n type: \"codex-plugin\",\n manifestPath: \".codex-plugin/plugin.json\",\n recommendedPath: \".agentyx/sources/superpowers\",\n description:\n \"Agentic planning, TDD, debugging, code review and delivery workflows packaged as a Codex plugin.\",\n installStatus: \"metadata-only\",\n installNote:\n \"Agentyx can inspect and verify the local plugin checkout, but does not install its resource-bearing skills yet.\",\n }),\n];\n\nexport const knownTrustedSourceRegistry: TrustedSourceRegistry =\n createTrustedSourceRegistry(knownTrustedSources);\n\nexport function createTrustedSourceRegistry(\n definitions: Iterable<TrustedSourceDefinition>,\n): TrustedSourceRegistry {\n const registry = new Map<string, TrustedSourceDefinition>();\n\n for (const definition of definitions) {\n const parsed = trustedSourceDefinitionSchema.parse(definition);\n\n if (registry.has(parsed.name)) {\n throw new DuplicateTrustedSourceError(parsed.name);\n }\n\n registry.set(parsed.name, parsed);\n }\n\n return registry;\n}\n\nexport function getTrustedSourceDefinition(\n source: string | TrustedSourceReference,\n registry: TrustedSourceRegistry = knownTrustedSourceRegistry,\n): TrustedSourceDefinition {\n const name = typeof source === \"string\" ? source : source.name;\n const definition = registry.get(name);\n\n if (definition === undefined) {\n throw new UnknownTrustedSourceError(name, [...registry.keys()]);\n }\n\n return definition;\n}\n","import type { Dirent } from \"node:fs\";\nimport { readFileSync } from \"node:fs\";\nimport { readdir, readFile, realpath, stat } from \"node:fs/promises\";\nimport { isAbsolute, join, relative, resolve, sep } from \"node:path\";\nimport { PROJECT_CONTEXT_TEMPLATE_PATH } from \"../assets.js\";\nimport type { PackRegistry } from \"../pack/registry.js\";\nimport { builtInPackRegistry, builtInPacks, createPackRegistry } from \"../pack/registry.js\";\nimport { builtInSkillRegistry } from \"../skill/built-in.js\";\nimport { DuplicateSkillError } from \"../skill/errors.js\";\nimport { parseSkillMarkdown } from \"../skill/markdown.js\";\nimport { createSkillRegistry, type SkillRegistry, type SkillSource } from \"../skill/registry.js\";\nimport type { SkillDefinition } from \"../skill/schema.js\";\nimport { getTrustedSourceDefinition } from \"../source/registry.js\";\nimport { LocalSkillDirectoryError, ProjectContextPathError } from \"./errors.js\";\nimport { loadAgentyxConfig } from \"./loader.js\";\nimport type { AgentyxConfig } from \"./schema.js\";\n\n/** A validated project configuration plus the registries it owns. */\nexport interface AgentyxProject {\n readonly config: AgentyxConfig;\n readonly packRegistry: PackRegistry;\n readonly skillRegistry: SkillRegistry;\n readonly graph: import(\"../project-graph.js\").ProjectGraph | undefined;\n}\n\n/**\n * Loads `.agentyx.json` and any checked-in Agent Skills it declares.\n *\n * A Skill root contains one directory per Skill, each with a `SKILL.md`. Roots must resolve inside\n * the project even through symlinks. Loading is local-only: this function never clones a repository\n * or accesses the network.\n */\nexport async function loadAgentyxProject(\n projectPath: string = process.cwd(),\n): Promise<AgentyxProject> {\n const projectDir = resolve(projectPath);\n const config = await loadAgentyxConfig(projectDir);\n await validateContextPaths(projectDir, config.context);\n for (const source of config.trustedSources ?? []) {\n getTrustedSourceDefinition(source);\n }\n\n const localSources = await loadLocalSkillSources(projectDir, config.skillDirectories ?? []);\n if (localSources.some((source) => source.name === \"agentyx-project-context\")) {\n throw new DuplicateSkillError(\"agentyx-project-context\");\n }\n const generatedSources =\n config.project !== undefined || (config.context !== undefined && hasContext(config.context))\n ? [createProjectContextSkill(config.project, config.relations ?? [], config.context)]\n : [];\n const skillRegistry = createSkillRegistry([\n ...builtInSkillRegistry.names.map(\n (name): SkillSource => ({\n name,\n load: () => builtInSkillRegistry.get(name),\n }),\n ),\n ...localSources,\n ...generatedSources,\n ]);\n const packRegistry =\n config.localPacks === undefined\n ? builtInPackRegistry\n : createPackRegistry([...builtInPacks, ...config.localPacks]);\n\n const graph =\n config.project === undefined\n ? undefined\n : { project: config.project, relations: config.relations ?? [] };\n return { config, packRegistry, skillRegistry, graph };\n}\n\nfunction createProjectContextSkill(\n project: import(\"./schema.js\").ProjectMetadata | undefined,\n relations: readonly import(\"./schema.js\").ProjectRelation[],\n context: import(\"./schema.js\").ProjectContext | undefined,\n): SkillSource {\n return {\n name: \"agentyx-project-context\",\n load: () => {\n const template = readFileSync(PROJECT_CONTEXT_TEMPLATE_PATH, \"utf8\").trim();\n const data = JSON.stringify({ project, relations, context }, null, 2);\n const longestFence = Math.max(\n 0,\n ...Array.from(data.matchAll(/`+/g), (match) => match[0].length),\n );\n const fence = \"`\".repeat(Math.max(3, longestFence + 1));\n return {\n name: \"agentyx-project-context\",\n description: \"Repository facts and direct architectural relationships.\",\n content: template.replace(\"{{PROJECT_FACTS}}\", `${fence}json\\n${data}\\n${fence}`),\n };\n },\n };\n}\n\nfunction hasContext(context: import(\"./schema.js\").ProjectContext): boolean {\n return (\n Object.keys(context.commands).length > 0 ||\n context.areas.length > 0 ||\n context.constraints.length > 0\n );\n}\n\nasync function validateContextPaths(\n projectDir: string,\n context: import(\"./schema.js\").ProjectContext | undefined,\n): Promise<void> {\n if (context === undefined) return;\n const paths = [\n ...Object.values(context.commands).map(({ cwd }) => cwd),\n ...context.areas.map(({ path }) => path),\n ];\n const projectRealPath = await realpath(projectDir);\n for (const path of paths) {\n if (/^(?:\\/|[A-Za-z]:)|\\\\|(?:^|\\/)\\.\\.(?:\\/|$)/.test(path)) {\n throw new ProjectContextPathError(\n path,\n \"it must be project-relative and cannot traverse parents\",\n );\n }\n const resolvedPath = resolve(projectDir, path);\n let resolvedRealPath: string;\n try {\n resolvedRealPath = await realpath(resolvedPath);\n const pathStat = await stat(resolvedRealPath);\n if (!pathStat.isDirectory()) {\n throw new ProjectContextPathError(path, \"it must name a directory\");\n }\n } catch (cause) {\n if (cause instanceof ProjectContextPathError) throw cause;\n throw new ProjectContextPathError(\n path,\n \"it does not exist or cannot be read\",\n cause instanceof Error ? { cause } : undefined,\n );\n }\n if (!isInside(resolvedRealPath, projectRealPath)) {\n throw new ProjectContextPathError(path, \"it resolves outside the project\");\n }\n }\n}\n\nasync function loadLocalSkillSources(\n projectDir: string,\n directories: readonly string[],\n): Promise<readonly SkillSource[]> {\n const projectRealPath = await realpath(projectDir);\n const sources: SkillSource[] = [];\n\n for (const directory of directories) {\n const root = resolve(projectDir, directory);\n let rootRealPath: string;\n\n try {\n rootRealPath = await realpath(root);\n } catch (cause) {\n throw localDirectoryError(directory, \"the directory does not exist or cannot be read\", cause);\n }\n\n if (!isInside(rootRealPath, projectRealPath)) {\n throw new LocalSkillDirectoryError(directory, \"the resolved path is outside the project\");\n }\n\n let entries: Dirent[];\n\n try {\n entries = await readdir(rootRealPath, { withFileTypes: true });\n } catch (cause) {\n throw localDirectoryError(directory, \"the directory cannot be listed\", cause);\n }\n\n for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {\n if (!entry.isDirectory()) {\n continue;\n }\n\n const filePath = join(rootRealPath, entry.name, \"SKILL.md\");\n let realFilePath: string;\n\n try {\n realFilePath = await realpath(filePath);\n } catch (cause) {\n if (cause instanceof Error && (cause as NodeJS.ErrnoException).code === \"ENOENT\") {\n continue;\n }\n\n throw localDirectoryError(directory, `cannot read ${entry.name}/SKILL.md`, cause);\n }\n\n if (!isInside(realFilePath, rootRealPath)) {\n throw new LocalSkillDirectoryError(\n directory,\n `${entry.name}/SKILL.md resolves outside the skill directory`,\n );\n }\n\n let markdown: string;\n\n try {\n markdown = await readFile(realFilePath, \"utf8\");\n } catch (cause) {\n throw localDirectoryError(directory, `cannot read ${entry.name}/SKILL.md`, cause);\n }\n\n const skill: SkillDefinition = parseSkillMarkdown(markdown, filePath);\n\n if (skill.name !== entry.name) {\n throw new LocalSkillDirectoryError(\n directory,\n `${entry.name}/SKILL.md declares the name \"${skill.name}\"`,\n );\n }\n\n sources.push({ name: skill.name, load: () => skill });\n }\n }\n\n return sources;\n}\n\nfunction isInside(path: string, root: string): boolean {\n const pathFromRoot = relative(root, path);\n\n return (\n pathFromRoot === \"\" ||\n (!pathFromRoot.startsWith(`..${sep}`) && pathFromRoot !== \"..\" && !isAbsolute(pathFromRoot))\n );\n}\n\nfunction localDirectoryError(\n directory: string,\n reason: string,\n cause: unknown,\n): LocalSkillDirectoryError {\n return new LocalSkillDirectoryError(\n directory,\n reason,\n cause instanceof Error ? { cause } : undefined,\n );\n}\n","import type { ZodError } from \"zod\";\nimport { AgentyxError } from \"../errors.js\";\n\nexport class UnknownHookError extends AgentyxError {\n readonly hookName: string;\n readonly requiredBy: string | undefined;\n readonly knownHooks: readonly string[];\n\n constructor(hookName: string, requiredBy: string | undefined, knownHooks: readonly string[]) {\n const origin = requiredBy === undefined ? \"\" : ` (required by \"${requiredBy}\")`;\n const known = knownHooks.length > 0 ? [...knownHooks].sort().join(\", \") : \"none\";\n\n super(\"unknown_hook\", `Unknown hook \"${hookName}\"${origin}. Known hooks: ${known}.`);\n this.name = \"UnknownHookError\";\n this.hookName = hookName;\n this.requiredBy = requiredBy;\n this.knownHooks = knownHooks;\n }\n}\n\nexport class DuplicateHookError extends AgentyxError {\n readonly hookName: string;\n\n constructor(hookName: string) {\n super(\"duplicate_hook\", `Duplicate hook definition: \"${hookName}\".`);\n this.name = \"DuplicateHookError\";\n this.hookName = hookName;\n }\n}\n\nexport class InvalidHookError extends AgentyxError {\n readonly origin: string;\n readonly reason: string;\n\n constructor(origin: string, reason: string | ZodError, options?: ErrorOptions) {\n const detail = typeof reason === \"string\" ? reason : formatIssues(reason);\n\n super(\"invalid_hook\", `Invalid hook in ${origin}: ${detail}`, options);\n this.name = \"InvalidHookError\";\n this.origin = origin;\n this.reason = detail;\n }\n}\n\nfunction formatIssues(error: ZodError): string {\n return error.issues\n .map((issue) => {\n const path = issue.path.map(String).join(\".\");\n\n return path === \"\" ? issue.message : `${path}: ${issue.message}`;\n })\n .join(\"; \");\n}\n","import { DuplicateHookError, InvalidHookError, UnknownHookError } from \"./errors.js\";\nimport {\n type HookDefinition,\n type HookDefinitionInput,\n hookDefinitionSchema,\n hookNameSchema,\n} from \"./schema.js\";\n\nexport interface HookSource {\n readonly name: string;\n load(): HookDefinitionInput;\n}\n\nexport interface HookMetadata {\n readonly name: string;\n readonly description: string;\n readonly event: HookDefinition[\"event\"];\n}\n\nexport interface HookRegistry {\n readonly names: readonly string[];\n has(name: string): boolean;\n listMetadata(): readonly HookMetadata[];\n get(name: string): HookDefinition;\n}\n\nexport function createHookRegistry(sources: Iterable<HookSource>): HookRegistry {\n const byName = new Map<string, HookSource>();\n\n for (const source of sources) {\n const name = hookNameSchema.safeParse(source.name);\n\n if (!name.success) {\n throw new InvalidHookError(`Hook source \"${source.name}\"`, name.error);\n }\n\n if (byName.has(name.data)) {\n throw new DuplicateHookError(name.data);\n }\n\n byName.set(name.data, source);\n }\n\n const names = [...byName.keys()];\n const loaded = new Map<string, HookDefinition>();\n const get = (name: string): HookDefinition => {\n const cached = loaded.get(name);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const source = byName.get(name);\n\n if (source === undefined) {\n throw new UnknownHookError(name, undefined, names);\n }\n\n const origin = `Hook \"${name}\"`;\n const hook = hookDefinitionSchema.safeParse(source.load());\n\n if (!hook.success) {\n throw new InvalidHookError(origin, hook.error);\n }\n\n if (hook.data.name !== name) {\n throw new InvalidHookError(origin, `it declares the name \"${hook.data.name}\"`);\n }\n\n loaded.set(name, hook.data);\n\n return hook.data;\n };\n\n return {\n names,\n has: (name) => byName.has(name),\n listMetadata: () =>\n names.map((name) => {\n const hook = get(name);\n\n return {\n name: hook.name,\n description: hook.description,\n event: hook.event,\n };\n }),\n get,\n };\n}\n","import { createHookRegistry, type HookSource } from \"./registry.js\";\n\n/**\n * The hooks Agentyx ships with.\n *\n * `session-doctor-bootstrap` runs `agentyx doctor --hook` on session start: silent when the project\n * is healthy, one short line otherwise.\n *\n * The runtime contract this depends on is explicit, not assumed:\n *\n * - The command name is `agentyx` — the `bin` entry `@agentyx/cli` publishes — never a bare package\n * name for `npx` to fall back to. There is no npm package literally named `agentyx`, so if the\n * fallback ever triggered it would look up the wrong package entirely.\n * - `--no-install` makes that fallback impossible: `npx` runs the project-local\n * `node_modules/.bin/agentyx` when present and fails immediately otherwise, and never attempts a\n * registry lookup or download of any kind. A persistent hook must not depend on implicit network\n * access.\n * - This means a *persistent* hook requires `@agentyx/cli` to be an actual project dependency (for\n * example `pnpm add -D @agentyx/cli`), not just invoked ad hoc through `pnpm dlx @agentyx/cli`,\n * which never adds anything to the project. `doctor` (run directly, not through `--hook`) detects\n * a missing local binary and reports it as `hook_runtime_unavailable` — see\n * `packages/cli/src/commands/doctor.ts`. A missing binary makes the hook itself exit non-zero and\n * print nothing useful, but it never blocks a session or performs a side effect beyond that.\n */\nexport const builtInHookSources: readonly HookSource[] = [\n {\n name: \"session-doctor-bootstrap\",\n load: () => ({\n name: \"session-doctor-bootstrap\",\n description: \"Reports Agentyx project health at session start; silent when healthy.\",\n event: \"SessionStart\",\n command: \"npx\",\n args: [\"--no-install\", \"agentyx\", \"doctor\", \"--hook\"],\n }),\n },\n];\n\nexport const builtInHookRegistry = createHookRegistry(builtInHookSources);\n\nexport const builtInHookNames: readonly string[] = builtInHookRegistry.names;\n","import { UnknownPackError } from \"./errors.js\";\nimport { builtInPackRegistry, type PackRegistry } from \"./registry.js\";\n\n/**\n * Resolves selected packs without hidden inheritance.\n *\n * The result preserves configured order, removes duplicates by first\n * occurrence, and validates every requested pack.\n *\n * @throws {UnknownPackError} when a requested pack is missing.\n */\nexport function resolvePacks(\n requestedPacks: readonly string[],\n registry: PackRegistry = builtInPackRegistry,\n): string[] {\n const resolved: string[] = [];\n const seen = new Set<string>();\n\n for (const name of requestedPacks) {\n if (seen.has(name)) {\n continue;\n }\n\n if (!registry.has(name)) {\n throw new UnknownPackError(name, undefined, [...registry.keys()]);\n }\n\n seen.add(name);\n resolved.push(name);\n }\n\n return resolved;\n}\n","import { builtInPackRegistry, type PackRegistry } from \"../pack/registry.js\";\nimport { resolvePacks } from \"../pack/resolver.js\";\nimport { builtInHookRegistry } from \"./built-in.js\";\nimport { UnknownHookError } from \"./errors.js\";\nimport type { HookRegistry } from \"./registry.js\";\nimport type { HookReference } from \"./schema.js\";\n\nexport function collectPackHookReferences(\n resolvedPacks: readonly string[],\n packRegistry: PackRegistry,\n hookRegistry: HookRegistry,\n): HookReference[] {\n const hooks: HookReference[] = [];\n const seen = new Set<string>();\n\n for (const packName of resolvedPacks) {\n for (const hook of packRegistry.get(packName)?.hooks ?? []) {\n const hookName = hook.name;\n\n if (seen.has(hookName)) {\n continue;\n }\n\n if (!hookRegistry.has(hookName)) {\n throw new UnknownHookError(hookName, packName, hookRegistry.names);\n }\n\n seen.add(hookName);\n hooks.push(hook);\n }\n }\n\n return hooks;\n}\n\nexport function filterEffectiveHooks(\n hooks: readonly HookReference[],\n enabledCapabilities: readonly string[],\n): string[] {\n const enabled = new Set(enabledCapabilities);\n\n return hooks\n .filter((hook) => hook.activation === \"default\" || enabled.has(hook.name))\n .map((hook) => hook.name);\n}\n\nexport function collectPackHooks(\n resolvedPacks: readonly string[],\n packRegistry: PackRegistry,\n hookRegistry: HookRegistry,\n enabledCapabilities: readonly string[] = [],\n): string[] {\n return filterEffectiveHooks(\n collectPackHookReferences(resolvedPacks, packRegistry, hookRegistry),\n enabledCapabilities,\n );\n}\n\nexport function resolvePackHookReferences(\n requestedPacks: readonly string[],\n packRegistry: PackRegistry = builtInPackRegistry,\n hookRegistry: HookRegistry = builtInHookRegistry,\n): HookReference[] {\n return collectPackHookReferences(\n resolvePacks(requestedPacks, packRegistry),\n packRegistry,\n hookRegistry,\n );\n}\n\nexport function resolvePackHooks(\n requestedPacks: readonly string[],\n packRegistry: PackRegistry = builtInPackRegistry,\n hookRegistry: HookRegistry = builtInHookRegistry,\n enabledCapabilities: readonly string[] = [],\n): string[] {\n return collectPackHooks(\n resolvePacks(requestedPacks, packRegistry),\n packRegistry,\n hookRegistry,\n enabledCapabilities,\n );\n}\n","import type { ZodError } from \"zod\";\nimport { AgentyxError } from \"../errors.js\";\n\nexport class UnknownMcpServerError extends AgentyxError {\n readonly serverName: string;\n readonly requiredBy: string | undefined;\n readonly knownServers: readonly string[];\n\n constructor(serverName: string, requiredBy: string | undefined, knownServers: readonly string[]) {\n const origin = requiredBy === undefined ? \"\" : ` (required by \"${requiredBy}\")`;\n const known = knownServers.length > 0 ? [...knownServers].sort().join(\", \") : \"none\";\n\n super(\n \"unknown_mcp_server\",\n `Unknown MCP server \"${serverName}\"${origin}. Known MCP servers: ${known}.`,\n );\n this.name = \"UnknownMcpServerError\";\n this.serverName = serverName;\n this.requiredBy = requiredBy;\n this.knownServers = knownServers;\n }\n}\n\nexport class DuplicateMcpServerError extends AgentyxError {\n readonly serverName: string;\n\n constructor(serverName: string) {\n super(\"duplicate_mcp_server\", `Duplicate MCP server definition: \"${serverName}\".`);\n this.name = \"DuplicateMcpServerError\";\n this.serverName = serverName;\n }\n}\n\nexport class InvalidMcpServerError extends AgentyxError {\n readonly origin: string;\n readonly reason: string;\n\n constructor(origin: string, reason: string | ZodError, options?: ErrorOptions) {\n const detail = typeof reason === \"string\" ? reason : formatIssues(reason);\n\n super(\"invalid_mcp_server\", `Invalid MCP server in ${origin}: ${detail}`, options);\n this.name = \"InvalidMcpServerError\";\n this.origin = origin;\n this.reason = detail;\n }\n}\n\nfunction formatIssues(error: ZodError): string {\n return error.issues\n .map((issue) => {\n const path = issue.path.map(String).join(\".\");\n\n return path === \"\" ? issue.message : `${path}: ${issue.message}`;\n })\n .join(\"; \");\n}\n","import { DuplicateMcpServerError, InvalidMcpServerError, UnknownMcpServerError } from \"./errors.js\";\nimport {\n type McpServerDefinition,\n type McpServerDefinitionInput,\n mcpServerDefinitionSchema,\n mcpServerNameSchema,\n} from \"./schema.js\";\n\nexport interface McpServerSource {\n readonly name: string;\n load(): McpServerDefinitionInput;\n}\n\nexport interface McpServerMetadata {\n readonly name: string;\n readonly description: string;\n readonly transport: McpServerDefinition[\"transport\"];\n readonly contextCost?: McpServerDefinition[\"contextCost\"];\n readonly runtime?: McpServerDefinition[\"runtime\"];\n}\n\nexport interface McpServerRegistry {\n readonly names: readonly string[];\n has(name: string): boolean;\n listMetadata(): readonly McpServerMetadata[];\n get(name: string): McpServerDefinition;\n}\n\nexport function createMcpServerRegistry(sources: Iterable<McpServerSource>): McpServerRegistry {\n const byName = new Map<string, McpServerSource>();\n\n for (const source of sources) {\n const name = mcpServerNameSchema.safeParse(source.name);\n\n if (!name.success) {\n throw new InvalidMcpServerError(`MCP server source \"${source.name}\"`, name.error);\n }\n\n if (byName.has(name.data)) {\n throw new DuplicateMcpServerError(name.data);\n }\n\n byName.set(name.data, source);\n }\n\n const names = [...byName.keys()];\n const loaded = new Map<string, McpServerDefinition>();\n const get = (name: string): McpServerDefinition => {\n const cached = loaded.get(name);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const source = byName.get(name);\n\n if (source === undefined) {\n throw new UnknownMcpServerError(name, undefined, names);\n }\n\n const origin = `MCP server \"${name}\"`;\n const server = mcpServerDefinitionSchema.safeParse(source.load());\n\n if (!server.success) {\n throw new InvalidMcpServerError(origin, server.error);\n }\n\n if (server.data.name !== name) {\n throw new InvalidMcpServerError(origin, `it declares the name \"${server.data.name}\"`);\n }\n\n loaded.set(name, server.data);\n\n return server.data;\n };\n\n return {\n names,\n has: (name) => byName.has(name),\n listMetadata: () =>\n names.map((name) => {\n const server = get(name);\n\n return {\n name: server.name,\n description: server.description,\n transport: server.transport,\n contextCost: server.contextCost,\n runtime: server.runtime,\n };\n }),\n get,\n };\n}\n","import { createMcpServerRegistry, type McpServerSource } from \"./registry.js\";\n\n/**\n * The MCP servers Agentyx ships with, expressed as data.\n *\n * `runtime` is honest about what *enabling* a server does once a provider launches it. Agentyx\n * itself performs no network access and installs nothing — but a `stdio` server whose `command` is\n * `npx` can fetch a package from the registry on first launch, exactly like running that `npx`\n * command by hand would. Those are marked `\"may-download\"`; a remote HTTP server or a command\n * expected to already be installed locally is `\"local\"`. `doctor`, `mcp show` and `pack show`\n * surface this so a user knows before they enable it.\n *\n * `npx`-launched packages are pinned to a known-compatible version rather than `@latest`, so\n * enabling a server is reproducible and does not silently pick up a new release between installs.\n */\nexport const builtInMcpServerSources: readonly McpServerSource[] = [\n {\n name: \"context7\",\n load: () => ({\n name: \"context7\",\n description: \"Fetch up-to-date library documentation from Context7.\",\n transport: \"http\",\n contextCost: \"medium\",\n runtime: \"local\",\n url: \"https://mcp.context7.com/mcp\",\n }),\n },\n {\n name: \"playwright\",\n load: () => ({\n name: \"playwright\",\n description: \"Automate and inspect browsers through Playwright MCP.\",\n transport: \"stdio\",\n contextCost: \"high\",\n runtime: \"may-download\",\n command: \"npx\",\n args: [\"@playwright/mcp@0.0.81\"],\n }),\n },\n {\n name: \"codebase-memory\",\n load: () => ({\n name: \"codebase-memory\",\n description: \"Structural code-intelligence MCP backed by a persistent code knowledge graph.\",\n transport: \"stdio\",\n contextCost: \"high\",\n runtime: \"local\",\n command: \"codebase-memory-mcp\",\n }),\n },\n {\n name: \"github\",\n load: () => ({\n name: \"github\",\n description: \"Read repositories, issues, pull requests and workflow runs on GitHub.\",\n transport: \"http\",\n contextCost: \"high\",\n runtime: \"local\",\n url: \"https://api.githubcopilot.com/mcp/\",\n }),\n },\n {\n name: \"sentry\",\n load: () => ({\n name: \"sentry\",\n description: \"Inspect production issues, events and stack traces recorded by Sentry.\",\n transport: \"http\",\n contextCost: \"medium\",\n runtime: \"local\",\n url: \"https://mcp.sentry.dev/mcp\",\n }),\n },\n {\n name: \"chrome-devtools\",\n load: () => ({\n name: \"chrome-devtools\",\n description: \"Record performance traces and inspect pages through Chrome DevTools.\",\n transport: \"stdio\",\n contextCost: \"high\",\n runtime: \"may-download\",\n command: \"npx\",\n args: [\"-y\", \"chrome-devtools-mcp@1.9.0\"],\n }),\n },\n {\n name: \"supabase\",\n load: () => ({\n name: \"supabase\",\n description: \"Inspect and query Supabase project schemas, tables and logs.\",\n transport: \"stdio\",\n contextCost: \"high\",\n runtime: \"may-download\",\n command: \"npx\",\n args: [\"-y\", \"@supabase/mcp-server-supabase@0.13.0\"],\n env: { SUPABASE_ACCESS_TOKEN: { fromEnv: \"SUPABASE_ACCESS_TOKEN\" } },\n }),\n },\n];\n\nexport const builtInMcpServerRegistry = createMcpServerRegistry(builtInMcpServerSources);\n\nexport const builtInMcpServerNames: readonly string[] = builtInMcpServerRegistry.names;\n","import { builtInPackRegistry, type PackRegistry } from \"../pack/registry.js\";\nimport { resolvePacks } from \"../pack/resolver.js\";\nimport { builtInMcpServerRegistry } from \"./built-in.js\";\nimport { UnknownMcpServerError } from \"./errors.js\";\nimport type { McpServerRegistry } from \"./registry.js\";\nimport type { McpServerReference } from \"./schema.js\";\n\nexport function collectPackMcpServerReferences(\n resolvedPacks: readonly string[],\n packRegistry: PackRegistry,\n mcpRegistry: McpServerRegistry,\n): McpServerReference[] {\n const servers: McpServerReference[] = [];\n const seen = new Set<string>();\n\n for (const packName of resolvedPacks) {\n for (const server of packRegistry.get(packName)?.mcpServers ?? []) {\n const serverName = server.name;\n\n if (seen.has(serverName)) {\n continue;\n }\n\n if (!mcpRegistry.has(serverName)) {\n throw new UnknownMcpServerError(serverName, packName, mcpRegistry.names);\n }\n\n seen.add(serverName);\n servers.push(server);\n }\n }\n\n return servers;\n}\n\nexport function filterEffectiveMcpServers(\n servers: readonly McpServerReference[],\n enabledCapabilities: readonly string[],\n): string[] {\n const enabled = new Set(enabledCapabilities);\n\n return servers\n .filter((server) => server.activation === \"default\" || enabled.has(server.name))\n .map((server) => server.name);\n}\n\nexport function collectPackMcpServers(\n resolvedPacks: readonly string[],\n packRegistry: PackRegistry,\n mcpRegistry: McpServerRegistry,\n enabledCapabilities: readonly string[] = [],\n): string[] {\n return filterEffectiveMcpServers(\n collectPackMcpServerReferences(resolvedPacks, packRegistry, mcpRegistry),\n enabledCapabilities,\n );\n}\n\nexport function resolvePackMcpServerReferences(\n requestedPacks: readonly string[],\n packRegistry: PackRegistry = builtInPackRegistry,\n mcpRegistry: McpServerRegistry = builtInMcpServerRegistry,\n): McpServerReference[] {\n return collectPackMcpServerReferences(\n resolvePacks(requestedPacks, packRegistry),\n packRegistry,\n mcpRegistry,\n );\n}\n\nexport function resolvePackMcpServers(\n requestedPacks: readonly string[],\n packRegistry: PackRegistry = builtInPackRegistry,\n mcpRegistry: McpServerRegistry = builtInMcpServerRegistry,\n enabledCapabilities: readonly string[] = [],\n): string[] {\n return collectPackMcpServers(\n resolvePacks(requestedPacks, packRegistry),\n packRegistry,\n mcpRegistry,\n enabledCapabilities,\n );\n}\n","import { builtInPackRegistry, type PackRegistry } from \"../pack/registry.js\";\nimport { resolvePacks } from \"../pack/resolver.js\";\nimport { builtInSkillRegistry } from \"./built-in.js\";\nimport { UnknownSkillError } from \"./errors.js\";\nimport type { SkillRegistry } from \"./registry.js\";\n\n/**\n * Collects the skills contributed by an already-resolved pack chain.\n *\n * Only identifiers are produced — no skill body is read — so this stays cheap\n * enough to run on every `resolve`.\n *\n * @throws {UnknownSkillError} when a pack references a skill the registry lacks.\n */\nexport function collectPackSkills(\n resolvedPacks: readonly string[],\n packRegistry: PackRegistry,\n skillRegistry: SkillRegistry,\n): string[] {\n const skills: string[] = [];\n const seen = new Set<string>();\n\n for (const packName of resolvedPacks) {\n for (const skillName of packRegistry.get(packName)?.skills ?? []) {\n if (seen.has(skillName)) {\n continue;\n }\n\n if (!skillRegistry.has(skillName)) {\n throw new UnknownSkillError(skillName, packName, skillRegistry.names);\n }\n\n seen.add(skillName);\n skills.push(skillName);\n }\n }\n\n return skills;\n}\n\n/**\n * Resolves the requested packs and returns the skills they contribute.\n *\n * The result follows the resolved pack order, then each pack's declaration\n * order, and is de-duplicated by first occurrence. Skills do not extend other\n * skills, so there is nothing further to expand.\n *\n * @throws {UnknownPackError} when a requested pack is missing.\n * @throws {UnknownSkillError} when a pack references a skill the registry lacks.\n */\nexport function resolvePackSkills(\n requestedPacks: readonly string[],\n packRegistry: PackRegistry = builtInPackRegistry,\n skillRegistry: SkillRegistry = builtInSkillRegistry,\n): string[] {\n return collectPackSkills(resolvePacks(requestedPacks, packRegistry), packRegistry, skillRegistry);\n}\n","import { AgentyxError } from \"../errors.js\";\n\nexport class UnknownToolError extends AgentyxError {\n readonly toolName: string;\n readonly requiredBy: string | undefined;\n readonly knownTools: readonly string[];\n\n constructor(toolName: string, requiredBy: string | undefined, knownTools: readonly string[]) {\n const origin = requiredBy === undefined ? \"\" : ` (required by \"${requiredBy}\")`;\n const known = knownTools.length > 0 ? [...knownTools].sort().join(\", \") : \"none\";\n\n super(\"unknown_tool\", `Unknown tool \"${toolName}\"${origin}. Known tools: ${known}.`);\n this.name = \"UnknownToolError\";\n this.toolName = toolName;\n this.requiredBy = requiredBy;\n this.knownTools = knownTools;\n }\n}\n\nexport class DuplicateToolError extends AgentyxError {\n readonly toolName: string;\n\n constructor(toolName: string) {\n super(\"duplicate_tool\", `Duplicate tool definition: \"${toolName}\".`);\n this.name = \"DuplicateToolError\";\n this.toolName = toolName;\n }\n}\n\nexport class InvalidToolError extends AgentyxError {\n constructor(origin: string, reason: unknown, options?: ErrorOptions) {\n const message = reason instanceof Error ? reason.message : String(reason);\n\n super(\"invalid_tool\", `Invalid ${origin}: ${message}.`, options);\n this.name = \"InvalidToolError\";\n }\n}\n","import { DuplicateToolError, InvalidToolError, UnknownToolError } from \"./errors.js\";\nimport {\n type ToolDefinition,\n type ToolDefinitionInput,\n toolDefinitionSchema,\n toolNameSchema,\n} from \"./schema.js\";\n\nexport interface ToolSource {\n readonly name: string;\n load(): ToolDefinitionInput;\n}\n\nexport interface ToolMetadata {\n readonly name: string;\n readonly description: string;\n readonly kind: ToolDefinition[\"kind\"];\n readonly command: string;\n readonly optional: boolean;\n}\n\nexport interface ToolRegistry {\n readonly names: readonly string[];\n has(name: string): boolean;\n listMetadata(): readonly ToolMetadata[];\n get(name: string): ToolDefinition;\n}\n\nexport function createToolRegistry(sources: Iterable<ToolSource>): ToolRegistry {\n const byName = new Map<string, ToolSource>();\n\n for (const source of sources) {\n const name = toolNameSchema.safeParse(source.name);\n\n if (!name.success) {\n throw new InvalidToolError(`tool source \"${source.name}\"`, name.error);\n }\n\n if (byName.has(name.data)) {\n throw new DuplicateToolError(name.data);\n }\n\n byName.set(name.data, source);\n }\n\n const names = [...byName.keys()];\n const loaded = new Map<string, ToolDefinition>();\n const get = (name: string): ToolDefinition => {\n const cached = loaded.get(name);\n\n if (cached !== undefined) {\n return cached;\n }\n\n const source = byName.get(name);\n\n if (source === undefined) {\n throw new UnknownToolError(name, undefined, names);\n }\n\n const origin = `tool \"${name}\"`;\n const tool = toolDefinitionSchema.safeParse(source.load());\n\n if (!tool.success) {\n throw new InvalidToolError(origin, tool.error);\n }\n\n if (tool.data.name !== name) {\n throw new InvalidToolError(origin, `it declares the name \"${tool.data.name}\"`);\n }\n\n loaded.set(name, tool.data);\n\n return tool.data;\n };\n\n return {\n names,\n has: (name) => byName.has(name),\n listMetadata: () =>\n names.map((name) => {\n const tool = get(name);\n\n return {\n name: tool.name,\n description: tool.description,\n kind: tool.kind,\n command: tool.command,\n optional: tool.optional,\n };\n }),\n get,\n };\n}\n","import { createToolRegistry, type ToolSource } from \"./registry.js\";\n\nexport const builtInToolSources: readonly ToolSource[] = [\n {\n name: \"rtk\",\n load: () => ({\n name: \"rtk\",\n description:\n \"Rust Token Killer command-output proxy for reducing coding-agent context noise.\",\n kind: \"executable\",\n command: \"rtk\",\n optional: true,\n installHint: \"Install from the rtk-ai/rtk project if your local workflow benefits from it.\",\n }),\n },\n];\n\nexport const builtInToolRegistry = createToolRegistry(builtInToolSources);\n\nexport const builtInToolNames: readonly string[] = builtInToolRegistry.names;\n","import { builtInPackRegistry, type PackRegistry } from \"../pack/registry.js\";\nimport { resolvePacks } from \"../pack/resolver.js\";\nimport { builtInToolRegistry } from \"./built-in.js\";\nimport { UnknownToolError } from \"./errors.js\";\nimport type { ToolRegistry } from \"./registry.js\";\nimport type { ToolReference } from \"./schema.js\";\n\nexport function collectPackToolReferences(\n resolvedPacks: readonly string[],\n packRegistry: PackRegistry,\n toolRegistry: ToolRegistry,\n): ToolReference[] {\n const tools: ToolReference[] = [];\n const seen = new Set<string>();\n\n for (const packName of resolvedPacks) {\n for (const tool of packRegistry.get(packName)?.tools ?? []) {\n if (seen.has(tool.name)) {\n continue;\n }\n\n if (!toolRegistry.has(tool.name)) {\n throw new UnknownToolError(tool.name, packName, toolRegistry.names);\n }\n\n seen.add(tool.name);\n tools.push(tool);\n }\n }\n\n return tools;\n}\n\nexport function filterEffectiveTools(\n tools: readonly ToolReference[],\n enabledCapabilities: readonly string[],\n): string[] {\n const enabled = new Set(enabledCapabilities);\n\n return tools\n .filter((tool) => tool.activation === \"default\" || enabled.has(tool.name))\n .map((tool) => tool.name);\n}\n\nexport function resolvePackToolReferences(\n requestedPacks: readonly string[],\n packRegistry: PackRegistry = builtInPackRegistry,\n toolRegistry: ToolRegistry = builtInToolRegistry,\n): ToolReference[] {\n return collectPackToolReferences(\n resolvePacks(requestedPacks, packRegistry),\n packRegistry,\n toolRegistry,\n );\n}\n\nexport function resolvePackTools(\n requestedPacks: readonly string[],\n packRegistry: PackRegistry = builtInPackRegistry,\n toolRegistry: ToolRegistry = builtInToolRegistry,\n enabledCapabilities: readonly string[] = [],\n): string[] {\n return filterEffectiveTools(\n resolvePackToolReferences(requestedPacks, packRegistry, toolRegistry),\n enabledCapabilities,\n );\n}\n","import { builtInHookRegistry } from \"../hook/built-in.js\";\nimport type { HookRegistry } from \"../hook/registry.js\";\nimport { collectPackHookReferences, filterEffectiveHooks } from \"../hook/resolver.js\";\nimport type { HookReference } from \"../hook/schema.js\";\nimport { builtInMcpServerRegistry } from \"../mcp/built-in.js\";\nimport type { McpServerRegistry } from \"../mcp/registry.js\";\nimport { collectPackMcpServerReferences, filterEffectiveMcpServers } from \"../mcp/resolver.js\";\nimport type { McpServerReference } from \"../mcp/schema.js\";\nimport { builtInPackRegistry, type PackRegistry } from \"../pack/registry.js\";\nimport { resolvePacks } from \"../pack/resolver.js\";\nimport { builtInSkillRegistry } from \"../skill/built-in.js\";\nimport type { SkillRegistry } from \"../skill/registry.js\";\nimport { collectPackSkills } from \"../skill/resolver.js\";\nimport { builtInToolRegistry } from \"../tool/built-in.js\";\nimport type { ToolRegistry } from \"../tool/registry.js\";\nimport { collectPackToolReferences, filterEffectiveTools } from \"../tool/resolver.js\";\nimport type { ToolReference } from \"../tool/schema.js\";\nimport { UnknownEnabledCapabilityError } from \"./errors.js\";\nimport type { AgentyxConfig } from \"./schema.js\";\n\n/** A project configuration with its selected packs resolved. */\nexport interface ResolvedAgentyxConfig {\n /** The packs the project asked for, in configuration order. */\n readonly requestedPacks: readonly string[];\n /** Selected packs, de-duplicated while preserving configuration order. */\n readonly resolvedPacks: readonly string[];\n /**\n * Skill identifiers contributed by the resolved packs, in resolution order.\n * Identifiers only — reading the instructions is a separate, explicit step.\n */\n readonly skills: readonly string[];\n readonly declaredMcpServers: readonly McpServerReference[];\n readonly mcpServers: readonly string[];\n readonly declaredTools: readonly ToolReference[];\n readonly tools: readonly string[];\n readonly declaredHooks: readonly HookReference[];\n readonly hooks: readonly string[];\n readonly enabled: readonly string[];\n readonly targets: readonly string[];\n}\n\n/**\n * Combines a validated project configuration with pack and skill resolution.\n * The input is never mutated.\n *\n * @throws {UnknownPackError} when a configured pack is missing.\n * @throws {UnknownSkillError} when a pack references an unknown skill.\n */\nexport function resolveAgentyxConfig(\n config: AgentyxConfig,\n registry: PackRegistry = builtInPackRegistry,\n skillRegistry: SkillRegistry = builtInSkillRegistry,\n mcpRegistry: McpServerRegistry = builtInMcpServerRegistry,\n toolRegistry: ToolRegistry = builtInToolRegistry,\n hookRegistry: HookRegistry = builtInHookRegistry,\n): ResolvedAgentyxConfig {\n const requestedPacks = [...config.packs];\n const resolvedPacks = resolvePacks(requestedPacks, registry);\n const declaredMcpServers = collectPackMcpServerReferences(resolvedPacks, registry, mcpRegistry);\n const declaredTools = collectPackToolReferences(resolvedPacks, registry, toolRegistry);\n const declaredHooks = collectPackHookReferences(resolvedPacks, registry, hookRegistry);\n const knownOptionalCapabilities = [\n ...declaredMcpServers\n .filter((server) => server.activation === \"optional\")\n .map((server) => server.name),\n ...declaredTools.filter((tool) => tool.activation === \"optional\").map((tool) => tool.name),\n ...declaredHooks.filter((hook) => hook.activation === \"optional\").map((hook) => hook.name),\n ];\n\n for (const capability of config.enable) {\n if (!knownOptionalCapabilities.includes(capability)) {\n throw new UnknownEnabledCapabilityError(capability, knownOptionalCapabilities);\n }\n }\n\n return {\n requestedPacks,\n resolvedPacks,\n skills: unique([\n ...collectPackSkills(resolvedPacks, registry, skillRegistry),\n ...(config.project !== undefined ||\n (config.relations?.length ?? 0) > 0 ||\n hasProjectContext(config.context)\n ? [\"agentyx-project-context\"]\n : []),\n ]),\n declaredMcpServers,\n mcpServers: filterEffectiveMcpServers(declaredMcpServers, config.enable),\n declaredTools,\n tools: filterEffectiveTools(declaredTools, config.enable),\n declaredHooks,\n hooks: filterEffectiveHooks(declaredHooks, config.enable),\n enabled: [...config.enable],\n targets: [...config.targets],\n };\n}\n\nfunction hasProjectContext(context: AgentyxConfig[\"context\"]): boolean {\n return (\n context !== undefined &&\n (Object.keys(context.commands).length > 0 ||\n context.areas.length > 0 ||\n context.constraints.length > 0)\n );\n}\n\nfunction unique(values: readonly string[]): string[] {\n return [...new Set(values)];\n}\n","import type { ZodError } from \"zod\";\nimport { AgentyxError } from \"../errors.js\";\nimport { type AgentyxIssue, toAgentyxIssues } from \"../issues.js\";\n\n/** Raised when `.agentyx.lock.json` is not valid JSON. */\nexport class AgentyxManifestParseError extends AgentyxError {\n readonly filePath: string;\n\n constructor(filePath: string, reason: string, options?: ErrorOptions) {\n super(\"agentyx_manifest_parse_error\", `${filePath} is not valid JSON: ${reason}`, options);\n this.name = \"AgentyxManifestParseError\";\n this.filePath = filePath;\n }\n}\n\n/**\n * Raised when the manifest parses as JSON but is not a manifest Agentyx\n * understands.\n *\n * This is never repaired. The manifest is what tells Agentyx which files it is\n * allowed to overwrite and delete, so guessing at a damaged one would be\n * guessing about destructive operations.\n */\nexport class AgentyxManifestValidationError extends AgentyxError {\n readonly issues: readonly AgentyxIssue[];\n readonly filePath: string | undefined;\n\n constructor(error: ZodError, filePath?: string) {\n const issues = toAgentyxIssues(error);\n const location = filePath === undefined ? \"\" : ` in ${filePath}`;\n const details = issues.map((issue) => ` - ${issue.path}: ${issue.message}`).join(\"\\n\");\n\n super(\n \"agentyx_manifest_invalid\",\n `Invalid Agentyx install manifest${location}:\\n${details}\\nDelete the file to start from a clean install record.`,\n );\n this.name = \"AgentyxManifestValidationError\";\n this.issues = issues;\n this.filePath = filePath;\n }\n}\n","import { z } from \"zod\";\n\n/**\n * The manifest format version.\n *\n * A manifest written by a newer Agentyx fails validation instead of being\n * reinterpreted, because acting on a half-understood record of managed files is\n * how an installer deletes something it should not.\n */\nexport const INSTALL_MANIFEST_VERSION = 1;\n\n/**\n * A path Agentyx manages, relative to the project root and always written with\n * `/` separators so a manifest reads the same on every platform.\n */\nexport const managedPathSchema = z\n .string()\n .min(1, \"Managed paths must be non-empty strings.\")\n .refine((value) => !value.startsWith(\"/\"), \"Managed paths must be relative to the project root.\")\n .refine((value) => !value.includes(\"\\\\\"), \"Managed paths must use `/` separators.\")\n .refine(\n (value) => !value.split(\"/\").includes(\"..\"),\n \"Managed paths must not traverse outside the project root.\",\n );\n\n/** A SHA-256 digest of the exact bytes Agentyx last wrote to a managed path. */\nexport const contentHashSchema = z\n .string()\n .regex(/^[0-9a-f]{64}$/, \"Content hashes must be lowercase hexadecimal SHA-256 digests.\");\n\nconst targetsSchema = z\n .array(z.string().min(1, \"Targets must be non-empty strings.\"))\n .min(1, \"A manifest entry must record at least one target.\");\n\n/** A `SKILL.md` file Agentyx wrote, owned entirely by Agentyx. */\nexport const skillManifestEntrySchema = z.strictObject({\n kind: z.literal(\"skill\"),\n path: managedPathSchema,\n skill: z.string().min(1, \"Skill names must be non-empty strings.\"),\n targets: targetsSchema,\n hash: contentHashSchema,\n});\n\n/**\n * A provider MCP configuration file Agentyx contributed entries to.\n *\n * Unlike a skill file this one is shared with the user, so the entry records\n * the server keys Agentyx added rather than claiming the whole document.\n * `created` says whether the file existed before Agentyx first wrote it, which\n * is the only thing that makes removing the file itself safe.\n */\nexport const mcpManifestEntrySchema = z.strictObject({\n kind: z.literal(\"mcp\"),\n path: managedPathSchema,\n servers: z.array(z.string().min(1, \"MCP server names must be non-empty strings.\")),\n targets: targetsSchema,\n hash: contentHashSchema,\n created: z.boolean(),\n});\n\n/**\n * A provider hook configuration file Agentyx contributed entries to.\n *\n * Shares the `mcp` entry's shape and rationale: the file is shared with the\n * user, so the entry records the hook names Agentyx added rather than\n * claiming the whole document.\n */\nexport const hookManifestEntrySchema = z.strictObject({\n kind: z.literal(\"hook\"),\n path: managedPathSchema,\n hooks: z.array(z.string().min(1, \"Hook names must be non-empty strings.\")),\n targets: targetsSchema,\n hash: contentHashSchema,\n created: z.boolean(),\n});\n\nexport const installManifestEntrySchema = z.discriminatedUnion(\"kind\", [\n skillManifestEntrySchema,\n mcpManifestEntrySchema,\n hookManifestEntrySchema,\n]);\n\n/** The `.agentyx.lock.json` record of everything Agentyx installed into a project. */\nexport const installManifestSchema = z.strictObject({\n version: z.literal(INSTALL_MANIFEST_VERSION),\n entries: z.array(installManifestEntrySchema).default([]),\n});\n\nexport type SkillManifestEntry = z.infer<typeof skillManifestEntrySchema>;\nexport type McpManifestEntry = z.infer<typeof mcpManifestEntrySchema>;\nexport type HookManifestEntry = z.infer<typeof hookManifestEntrySchema>;\nexport type InstallManifestEntry = z.infer<typeof installManifestEntrySchema>;\n\n/** A validated manifest, with defaults applied. */\nexport type InstallManifest = z.infer<typeof installManifestSchema>;\n\n/** The shape accepted in a `.agentyx.lock.json` file. */\nexport type InstallManifestInput = z.input<typeof installManifestSchema>;\n","import { createHash } from \"node:crypto\";\nimport { readFile } from \"node:fs/promises\";\nimport { resolve } from \"node:path\";\nimport { AgentyxManifestParseError, AgentyxManifestValidationError } from \"./errors.js\";\nimport {\n INSTALL_MANIFEST_VERSION,\n type InstallManifest,\n type InstallManifestEntry,\n installManifestSchema,\n} from \"./schema.js\";\n\nexport const AGENTYX_MANIFEST_FILENAME = \".agentyx.lock.json\";\n\n/** The absolute path `.agentyx.lock.json` is read from for a given project. */\nexport function agentyxManifestPath(projectPath: string = process.cwd()): string {\n return resolve(projectPath, AGENTYX_MANIFEST_FILENAME);\n}\n\n/** A manifest that claims nothing — what a project has before its first install. */\nexport function emptyInstallManifest(): InstallManifest {\n return { version: INSTALL_MANIFEST_VERSION, entries: [] };\n}\n\n/**\n * The SHA-256 digest Agentyx records for managed content.\n *\n * Comparing this digest with the file on disk is what separates \"Agentyx wrote\n * this and may replace it\" from \"someone else owns this file\", so it is\n * computed over the exact bytes written, never over a normalised form.\n */\nexport function hashContent(content: string): string {\n return createHash(\"sha256\").update(content, \"utf8\").digest(\"hex\");\n}\n\n/**\n * Validates an already-parsed manifest document.\n *\n * @throws {AgentyxManifestValidationError} when the document violates the schema.\n */\nexport function parseInstallManifest(value: unknown, filePath?: string): InstallManifest {\n const result = installManifestSchema.safeParse(value);\n\n if (!result.success) {\n throw new AgentyxManifestValidationError(result.error, filePath);\n }\n\n return result.data;\n}\n\n/**\n * Reads `.agentyx.lock.json` from `projectPath`.\n *\n * A missing manifest is a legitimate state — the project has simply never been\n * installed into — and yields an empty manifest. A manifest that exists but\n * cannot be understood is a hard failure: it governs which files Agentyx may\n * overwrite and delete, and a damaged one is never guessed at.\n *\n * @throws {AgentyxManifestParseError} when the file is not valid JSON.\n * @throws {AgentyxManifestValidationError} when the document violates the schema.\n */\nexport async function loadInstallManifest(\n projectPath: string = process.cwd(),\n): Promise<InstallManifest> {\n const filePath = agentyxManifestPath(projectPath);\n let contents: string;\n\n try {\n contents = await readFile(filePath, \"utf8\");\n } catch (cause) {\n if (cause instanceof Error && (cause as NodeJS.ErrnoException).code === \"ENOENT\") {\n return emptyInstallManifest();\n }\n\n throw cause;\n }\n\n let document: unknown;\n\n try {\n document = JSON.parse(contents);\n } catch (cause) {\n const reason = cause instanceof Error ? cause.message : String(cause);\n throw new AgentyxManifestParseError(filePath, reason, { cause });\n }\n\n return parseInstallManifest(document, filePath);\n}\n\n/**\n * Serialises a manifest for writing.\n *\n * Entries and their lists are sorted so that reinstalling an unchanged project\n * produces a byte-identical file and the manifest never shows up as noise in a\n * diff. Writing is deliberately not done here — only the install executor\n * touches the filesystem.\n */\nexport function formatInstallManifest(manifest: InstallManifest): string {\n const entries = [...manifest.entries]\n .map((entry) => {\n if (entry.kind === \"skill\") {\n return { ...entry, targets: sorted(entry.targets) };\n }\n\n if (entry.kind === \"mcp\") {\n return { ...entry, targets: sorted(entry.targets), servers: sorted(entry.servers) };\n }\n\n return { ...entry, targets: sorted(entry.targets), hooks: sorted(entry.hooks) };\n })\n .sort((left, right) => left.path.localeCompare(right.path));\n\n return `${JSON.stringify({ version: manifest.version, entries }, null, 2)}\\n`;\n}\n\n/**\n * Indexes manifest entries by managed path.\n *\n * Every ownership question — may this file be overwritten, may it be deleted —\n * is a lookup by path, so callers do not scan the list themselves.\n */\nexport function manifestEntriesByPath(\n manifest: InstallManifest,\n): ReadonlyMap<string, InstallManifestEntry> {\n return new Map(manifest.entries.map((entry) => [entry.path, entry]));\n}\n\nfunction sorted(values: readonly string[]): string[] {\n return [...values].sort();\n}\n","export const agentyxCoreName = \"agentyx-core\";\n\nexport function getCoreStatus(): string {\n return \"ready\";\n}\n","import { constants } from \"node:fs\";\nimport { access } from \"node:fs/promises\";\nimport { delimiter } from \"node:path\";\n\n/** Whether `command` resolves to an executable file, via `PATH` unless it already contains a `/`. */\nexport async function isExecutableOnPath(command: string): Promise<boolean> {\n if (command.includes(\"/\")) {\n return isFileExecutable(command);\n }\n\n for (const directory of (process.env.PATH ?? \"\").split(delimiter)) {\n if (directory.length === 0) {\n continue;\n }\n\n if (await isFileExecutable(`${directory}/${command}`)) {\n return true;\n }\n }\n\n return false;\n}\n\nasync function isFileExecutable(path: string): Promise<boolean> {\n try {\n await access(path, constants.X_OK);\n return true;\n } catch {\n return false;\n }\n}\n","import type { Dirent } from \"node:fs\";\nimport { access, readdir, readFile } from \"node:fs/promises\";\nimport { extname, join } from \"node:path\";\nimport { builtInToolRegistry } from \"../tool/built-in.js\";\nimport { isExecutableOnPath } from \"./executable.js\";\n\nexport const PACKAGE_MANAGERS = [\"pnpm\", \"npm\", \"yarn\", \"bun\"] as const;\n\nexport type PackageManagerName = (typeof PACKAGE_MANAGERS)[number];\n\nexport interface PackageManagerDetection {\n readonly name: PackageManagerName | undefined;\n readonly source: \"lockfile\" | \"package-json\" | undefined;\n readonly lockfiles: readonly string[];\n readonly ambiguous: boolean;\n}\n\nexport interface ProjectPackageJsonDetection {\n readonly present: boolean;\n readonly valid: boolean;\n readonly path: string;\n readonly name: string | undefined;\n readonly packageManager: string | undefined;\n readonly scripts: Readonly<Record<string, string>>;\n readonly error: string | undefined;\n}\n\nexport type DependencyField =\n | \"dependencies\"\n | \"devDependencies\"\n | \"peerDependencies\"\n | \"optionalDependencies\";\n\n/** A single matched dependency: which package, and which `package.json` field it came from. */\nexport interface TechnologyMatch {\n readonly dependency: string;\n readonly field: DependencyField;\n}\n\nexport interface ContainerFileSignals {\n readonly dockerfile: boolean;\n readonly compose: boolean;\n}\n\nexport interface CiFileSignals {\n readonly githubActions: boolean;\n}\n\n/**\n * Rust facts. `detected` requires a `Cargo.toml` that declares a `[package]` or `[workspace]`\n * table; stray `.rs` files never count. The other fields are supporting context only.\n */\nexport interface RustSignal {\n readonly detected: boolean;\n readonly workspace: boolean;\n readonly cargoLock: boolean;\n /** `rust-toolchain.toml` or `rust-toolchain`, whichever is present. */\n readonly toolchainFile: string | undefined;\n}\n\nexport interface MonorepoSignal {\n readonly detected: boolean;\n readonly markers: readonly string[];\n}\n\nexport interface RepositorySizeSignal {\n readonly filesScanned: number;\n /** True when the bounded traversal stopped before finishing; `filesScanned` is a lower bound. */\n readonly capped: boolean;\n}\n\n/**\n * Deliberately small, provider-neutral facts about a repository, gathered from a bounded set of\n * known files and `package.json` dependencies — never a full filesystem listing.\n *\n * This is pure detection: it makes no judgement about which packs or capabilities fit. That\n * judgement lives in `recommendCapabilities` (`./recommend.js`), which consumes these signals.\n */\nexport interface ProjectSignals {\n readonly projectDir: string;\n readonly packageJson: ProjectPackageJsonDetection;\n readonly packageManager: PackageManagerDetection;\n readonly typescript: {\n readonly dependency: TechnologyMatch | undefined;\n readonly tsconfig: boolean;\n };\n readonly angular: TechnologyMatch | undefined;\n readonly rust: RustSignal;\n readonly testFrameworks: readonly TechnologyMatch[];\n readonly browserTesting: readonly TechnologyMatch[];\n readonly observability: readonly TechnologyMatch[];\n readonly dataTooling: readonly TechnologyMatch[];\n readonly accessibilityTooling: readonly TechnologyMatch[];\n readonly containers: ContainerFileSignals;\n readonly ci: CiFileSignals;\n readonly monorepo: MonorepoSignal;\n readonly repositorySize: RepositorySizeSignal;\n readonly localTools: { readonly rtkAvailable: boolean };\n}\n\n/** Package name patterns matched exactly, or as a `@scope/*` prefix. */\nconst TEST_FRAMEWORK_PATTERNS = [\n \"vitest\",\n \"jest\",\n \"@jest/*\",\n \"@playwright/test\",\n \"cypress\",\n \"karma\",\n];\nconst BROWSER_TESTING_PATTERNS = [\"@playwright/test\", \"cypress\"];\nconst OBSERVABILITY_PATTERNS = [\"@sentry/*\", \"@opentelemetry/*\"];\nconst DATA_TOOLING_PATTERNS = [\n \"@supabase/*\",\n \"drizzle-orm\",\n \"prisma\",\n \"@prisma/client\",\n \"typeorm\",\n \"sequelize\",\n];\nconst ACCESSIBILITY_PATTERNS = [\"axe-core\", \"@axe-core/*\", \"pa11y\"];\n\nconst DEPENDENCY_FIELDS: readonly DependencyField[] = [\n \"dependencies\",\n \"devDependencies\",\n \"peerDependencies\",\n \"optionalDependencies\",\n];\n\nconst CONTAINER_IGNORED = new Set([\"node_modules\", \".git\", \"dist\", \"build\", \"coverage\"]);\n\n/** Extensions counted as source files by the bounded repository-size scan. */\nconst SOURCE_FILE_EXTENSIONS = new Set([\n \".ts\",\n \".tsx\",\n \".js\",\n \".jsx\",\n \".mjs\",\n \".cjs\",\n \".vue\",\n \".svelte\",\n \".py\",\n \".go\",\n \".rs\",\n \".java\",\n \".kt\",\n \".rb\",\n \".php\",\n \".css\",\n \".scss\",\n \".html\",\n]);\n\n/** Maximum directory entries visited by `scanRepositorySize`, regardless of match. */\nexport const REPOSITORY_SCAN_ENTRY_LIMIT = 5000;\n\ninterface PackageJson {\n readonly name?: unknown;\n readonly packageManager?: unknown;\n readonly workspaces?: unknown;\n readonly scripts?: unknown;\n readonly dependencies?: unknown;\n readonly devDependencies?: unknown;\n readonly peerDependencies?: unknown;\n readonly optionalDependencies?: unknown;\n}\n\nconst lockfileManagers: ReadonlyMap<string, PackageManagerName> = new Map([\n [\"pnpm-lock.yaml\", \"pnpm\"],\n [\"package-lock.json\", \"npm\"],\n [\"yarn.lock\", \"yarn\"],\n [\"bun.lock\", \"bun\"],\n [\"bun.lockb\", \"bun\"],\n]);\n\n/** Gathers every project signal with a bounded, cheap set of reads. */\nexport async function collectProjectSignals(projectDir: string): Promise<ProjectSignals> {\n const packageJsonPath = join(projectDir, \"package.json\");\n const packageJsonResult = await readPackageJson(packageJsonPath);\n const packageJson = packageJsonResult.data;\n\n const [packageManager, containers, ci, monorepo, repositorySize, tsconfig, rtkAvailable, rust] =\n await Promise.all([\n detectPackageManager(projectDir, packageJson),\n detectContainerFiles(projectDir),\n detectCiFiles(projectDir),\n detectMonorepo(projectDir, packageJson),\n scanRepositorySize(projectDir),\n exists(join(projectDir, \"tsconfig.json\")),\n isExecutableOnPath(builtInToolRegistry.get(\"rtk\").command),\n detectRust(projectDir),\n ]);\n\n return {\n projectDir,\n packageJson: {\n present: packageJsonResult.present,\n valid: packageJsonResult.valid,\n path: packageJsonPath,\n name: getString(packageJson?.name),\n packageManager: getString(packageJson?.packageManager),\n scripts: getStringRecord(packageJson?.scripts),\n error: packageJsonResult.error,\n },\n packageManager,\n typescript: {\n dependency: findDependency(packageJson, \"typescript\"),\n tsconfig,\n },\n angular: findDependency(packageJson, \"@angular/core\"),\n rust,\n testFrameworks: findAnyDependency(packageJson, TEST_FRAMEWORK_PATTERNS),\n browserTesting: findAnyDependency(packageJson, BROWSER_TESTING_PATTERNS),\n observability: findAnyDependency(packageJson, OBSERVABILITY_PATTERNS),\n dataTooling: findAnyDependency(packageJson, DATA_TOOLING_PATTERNS),\n accessibilityTooling: findAnyDependency(packageJson, ACCESSIBILITY_PATTERNS),\n containers,\n ci,\n monorepo,\n repositorySize,\n localTools: { rtkAvailable },\n };\n}\n\n/**\n * Counts source-like files under a bounded traversal, ignoring dependency, VCS and build output\n * directories. Stops after visiting `entryLimit` directory entries — cheap even on a monorepo — and\n * reports `capped` so callers never mistake a partial scan for a complete one.\n */\nexport async function scanRepositorySize(\n projectDir: string,\n options: { readonly entryLimit?: number } = {},\n): Promise<RepositorySizeSignal> {\n const entryLimit = options.entryLimit ?? REPOSITORY_SCAN_ENTRY_LIMIT;\n const directories = [projectDir];\n let filesScanned = 0;\n let entriesVisited = 0;\n let capped = false;\n\n while (directories.length > 0 && !capped) {\n const directory = directories.shift();\n\n if (directory === undefined) {\n break;\n }\n\n let entries: Dirent[];\n\n try {\n entries = await readdir(directory, { withFileTypes: true });\n } catch {\n continue;\n }\n\n for (const entry of entries) {\n if (entriesVisited >= entryLimit) {\n capped = true;\n break;\n }\n\n entriesVisited += 1;\n\n if (entry.isDirectory()) {\n if (entry.name.startsWith(\".\") || CONTAINER_IGNORED.has(entry.name)) {\n continue;\n }\n\n directories.push(join(directory, entry.name));\n } else if (entry.isFile() && SOURCE_FILE_EXTENSIONS.has(extname(entry.name))) {\n filesScanned += 1;\n }\n }\n }\n\n return { filesScanned, capped };\n}\n\nfunction findDependency(\n packageJson: PackageJson | undefined,\n pattern: string,\n): TechnologyMatch | undefined {\n for (const field of DEPENDENCY_FIELDS) {\n const value = packageJson?.[field];\n\n if (!isRecord(value)) {\n continue;\n }\n\n if (pattern.endsWith(\"/*\")) {\n const prefix = pattern.slice(0, -1);\n const name = Object.keys(value).find((key) => key.startsWith(prefix));\n\n if (name !== undefined) {\n return { dependency: name, field };\n }\n\n continue;\n }\n\n if (pattern in value) {\n return { dependency: pattern, field };\n }\n }\n\n return undefined;\n}\n\nfunction findAnyDependency(\n packageJson: PackageJson | undefined,\n patterns: readonly string[],\n): readonly TechnologyMatch[] {\n const matches: TechnologyMatch[] = [];\n const seen = new Set<string>();\n\n for (const pattern of patterns) {\n const match = findDependency(packageJson, pattern);\n\n if (match !== undefined && !seen.has(match.dependency)) {\n seen.add(match.dependency);\n matches.push(match);\n }\n }\n\n return matches;\n}\n\nasync function detectRust(projectDir: string): Promise<RustSignal> {\n let manifest: string;\n\n try {\n manifest = await readFile(join(projectDir, \"Cargo.toml\"), \"utf8\");\n } catch (cause) {\n if (isNotFound(cause) || isNotReadableAsFile(cause)) {\n return { detected: false, workspace: false, cargoLock: false, toolchainFile: undefined };\n }\n\n throw cause;\n }\n\n const workspace = /^\\s*\\[workspace\\]/m.test(manifest);\n const detected = workspace || /^\\s*\\[package\\]/m.test(manifest);\n const [cargoLock, toolchainToml, toolchain] = await Promise.all([\n exists(join(projectDir, \"Cargo.lock\")),\n exists(join(projectDir, \"rust-toolchain.toml\")),\n exists(join(projectDir, \"rust-toolchain\")),\n ]);\n\n return {\n detected,\n workspace,\n cargoLock,\n toolchainFile: toolchainToml ? \"rust-toolchain.toml\" : toolchain ? \"rust-toolchain\" : undefined,\n };\n}\n\nfunction isNotReadableAsFile(cause: unknown): boolean {\n const code = cause instanceof Error ? (cause as NodeJS.ErrnoException).code : undefined;\n\n return code === \"EISDIR\" || code === \"ENOTDIR\";\n}\n\nasync function detectContainerFiles(projectDir: string): Promise<ContainerFileSignals> {\n const [dockerfile, dockerCompose, compose] = await Promise.all([\n exists(join(projectDir, \"Dockerfile\")),\n exists(join(projectDir, \"docker-compose.yml\")),\n exists(join(projectDir, \"compose.yml\")),\n ]);\n\n return { dockerfile, compose: dockerCompose || compose };\n}\n\nasync function detectCiFiles(projectDir: string): Promise<CiFileSignals> {\n return { githubActions: await exists(join(projectDir, \".github\", \"workflows\")) };\n}\n\nasync function detectMonorepo(\n projectDir: string,\n packageJson: PackageJson | undefined,\n): Promise<MonorepoSignal> {\n const markers: string[] = [];\n\n if (await exists(join(projectDir, \"pnpm-workspace.yaml\"))) {\n markers.push(\"pnpm-workspace.yaml\");\n }\n\n if (await exists(join(projectDir, \"turbo.json\"))) {\n markers.push(\"turbo.json\");\n }\n\n if (await exists(join(projectDir, \"nx.json\"))) {\n markers.push(\"nx.json\");\n }\n\n const workspaces = packageJson?.workspaces;\n\n if (Array.isArray(workspaces) || isRecord(workspaces)) {\n markers.push(\"package.json workspaces\");\n }\n\n return { detected: markers.length > 0, markers };\n}\n\nasync function detectPackageManager(\n projectDir: string,\n packageJson: PackageJson | undefined,\n): Promise<PackageManagerDetection> {\n const lockfiles: string[] = [];\n const managers = new Set<PackageManagerName>();\n\n for (const [file, manager] of lockfileManagers) {\n if (await exists(join(projectDir, file))) {\n lockfiles.push(file);\n managers.add(manager);\n }\n }\n\n if (managers.size === 1) {\n return {\n name: [...managers][0],\n source: \"lockfile\",\n lockfiles,\n ambiguous: false,\n };\n }\n\n if (managers.size > 1) {\n return {\n name: undefined,\n source: \"lockfile\",\n lockfiles,\n ambiguous: true,\n };\n }\n\n const declared = parsePackageManagerName(getString(packageJson?.packageManager));\n\n return {\n name: declared,\n source: declared === undefined ? undefined : \"package-json\",\n lockfiles,\n ambiguous: false,\n };\n}\n\nasync function readPackageJson(path: string): Promise<{\n readonly present: boolean;\n readonly valid: boolean;\n readonly data: PackageJson | undefined;\n readonly error: string | undefined;\n}> {\n let contents: string;\n\n try {\n contents = await readFile(path, \"utf8\");\n } catch (cause) {\n if (isNotFound(cause)) {\n return { present: false, valid: false, data: undefined, error: undefined };\n }\n\n const reason = cause instanceof Error ? cause.message : String(cause);\n return { present: true, valid: false, data: undefined, error: reason };\n }\n\n try {\n return { present: true, valid: true, data: JSON.parse(contents), error: undefined };\n } catch (cause) {\n const reason = cause instanceof Error ? cause.message : String(cause);\n return { present: true, valid: false, data: undefined, error: reason };\n }\n}\n\nfunction parsePackageManagerName(value: string | undefined): PackageManagerName | undefined {\n const name = value?.split(\"@\")[0];\n\n return PACKAGE_MANAGERS.includes(name as PackageManagerName)\n ? (name as PackageManagerName)\n : undefined;\n}\n\nfunction getString(value: unknown): string | undefined {\n return typeof value === \"string\" ? value : undefined;\n}\n\nfunction getStringRecord(value: unknown): Readonly<Record<string, string>> {\n if (!isRecord(value)) return {};\n return Object.fromEntries(\n Object.entries(value).filter(\n (entry): entry is [string, string] => typeof entry[1] === \"string\",\n ),\n );\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nasync function exists(path: string): Promise<boolean> {\n try {\n await access(path);\n return true;\n } catch (cause) {\n if (isNotFound(cause)) {\n return false;\n }\n\n throw cause;\n }\n}\n\nfunction isNotFound(cause: unknown): boolean {\n return cause instanceof Error && (cause as NodeJS.ErrnoException).code === \"ENOENT\";\n}\n","import type { AgentyxConfigInput } from \"../config/schema.js\";\nimport { collectProjectSignals, type ProjectSignals } from \"./signals.js\";\n\nexport type {\n PackageManagerDetection,\n PackageManagerName,\n ProjectPackageJsonDetection,\n} from \"./signals.js\";\nexport { PACKAGE_MANAGERS } from \"./signals.js\";\n\nexport interface ProjectDetection {\n readonly projectDir: string;\n readonly packageJson: ProjectSignals[\"packageJson\"];\n readonly packageManager: ProjectSignals[\"packageManager\"];\n /** The richer, provider-neutral facts `recommendCapabilities` (`./recommend.js`) turns into suggestions. */\n readonly signals: ProjectSignals;\n}\n\n/**\n * Factual project detection only. It gathers `ProjectSignals` and never decides which packs or\n * capabilities fit — that policy lives in `recommendCapabilities`, kept separate so each half stays\n * independently testable.\n */\nexport async function detectProject(projectDir: string): Promise<ProjectDetection> {\n const signals = await collectProjectSignals(projectDir);\n\n return {\n projectDir,\n packageJson: signals.packageJson,\n packageManager: signals.packageManager,\n signals,\n };\n}\n\nexport function buildAgentyxConfig(input: {\n readonly packs: readonly string[];\n readonly enable?: readonly string[];\n readonly targets: readonly string[];\n}): AgentyxConfigInput {\n return {\n packs: [...input.packs],\n enable: [...(input.enable ?? [])],\n targets: [...input.targets],\n };\n}\n\nexport function formatAgentyxConfig(config: AgentyxConfigInput): string {\n return `${JSON.stringify(config, null, 2)}\\n`;\n}\n","import { builtInPackRegistry } from \"../pack/registry.js\";\nimport type { ProjectSignals, TechnologyMatch } from \"./signals.js\";\n\nexport const RECOMMENDATION_CONFIDENCES = [\"high\", \"medium\"] as const;\nexport type RecommendationConfidence = (typeof RECOMMENDATION_CONFIDENCES)[number];\n\nexport type RecommendationKind = \"pack\" | \"capability\";\n\n/**\n * A deterministic suggestion, always with a human-readable reason. `high` means a direct, strong\n * signal (an exact dependency or file match); `medium` means useful but less certain, such as a\n * size heuristic. There is no `low` tier in v1 — a signal too weak for `medium` is not surfaced.\n */\nexport interface Recommendation {\n readonly kind: RecommendationKind;\n readonly name: string;\n readonly confidence: RecommendationConfidence;\n readonly reasons: readonly string[];\n /** Packs that declare this as an optional capability. Present only for `kind: \"capability\"`. */\n readonly contributedBy?: readonly string[];\n}\n\nexport interface RecommendationResult {\n readonly packs: readonly Recommendation[];\n readonly capabilities: readonly Recommendation[];\n}\n\nexport interface RecommendCapabilitiesOptions {\n /** Packs already selected in the project's own `.agentyx.json`, if one exists. */\n readonly configuredPacks?: readonly string[] | undefined;\n}\n\n/**\n * Heuristic thresholds for the `codebase-memory` capability suggestion, in scanned source files.\n * These are approximate signals, not exact token accounting, and a monorepo is treated as already\n * complex enough to lower the bar.\n */\nexport const CODEBASE_MEMORY_FILE_THRESHOLD = 2000;\nexport const CODEBASE_MEMORY_MONOREPO_FILE_THRESHOLD = 800;\n\n/**\n * Applies conservative, deterministic policy on top of `ProjectSignals`. This is the only place\n * that turns an observed fact into a product suggestion — `ProjectSignals` stays fact-only so it\n * can be tested independently of pack names or capability policy.\n *\n * Never enables anything and never touches the filesystem: the caller decides what, if anything,\n * to do with the result.\n */\nexport function recommendCapabilities(\n signals: ProjectSignals,\n options: RecommendCapabilitiesOptions = {},\n): RecommendationResult {\n const packs = recommendPacks(signals);\n const configuredPacks = options.configuredPacks ?? [];\n const activePacks = new Set([...packs.map((pack) => pack.name), ...configuredPacks]);\n const capabilities = recommendOptionalCapabilities(signals, activePacks, configuredPacks);\n\n return { packs, capabilities };\n}\n\nfunction recommendPacks(signals: ProjectSignals): readonly Recommendation[] {\n const packs: Recommendation[] = [];\n\n const softwareReasons = [\n ...(signals.packageJson.present ? [\"package.json\"] : []),\n ...(signals.rust.detected ? [\"Cargo.toml\"] : []),\n ];\n\n if (softwareReasons.length > 0) {\n packs.push(\n packRecommendation(\"technical\", \"high\", [\n `${softwareReasons.join(\" and \")} detected — baseline engineering practices apply to any software project.`,\n ]),\n );\n }\n\n const typescriptReasons = [\n ...(signals.typescript.dependency !== undefined\n ? [dependencyReason(\"TypeScript\", signals.typescript.dependency)]\n : []),\n ...(signals.typescript.tsconfig ? [\"tsconfig.json detected.\"] : []),\n ];\n\n if (typescriptReasons.length > 0) {\n packs.push(packRecommendation(\"typescript\", \"high\", typescriptReasons));\n }\n\n if (signals.rust.detected) {\n packs.push(packRecommendation(\"rust\", \"high\", rustReasons(signals)));\n }\n\n if (signals.angular !== undefined) {\n packs.push(\n packRecommendation(\"angular\", \"high\", [dependencyReason(\"@angular/core\", signals.angular)]),\n );\n }\n\n const testingMatches = dedupeMatches([...signals.testFrameworks, ...signals.browserTesting]);\n\n if (testingMatches.length > 0) {\n packs.push(\n packRecommendation(\n \"testing\",\n \"high\",\n testingMatches.map((match) => dependencyReason(match.dependency, match)),\n ),\n );\n }\n\n const devopsReasons = [\n ...(signals.containers.dockerfile ? [\"Dockerfile detected.\"] : []),\n ...(signals.containers.compose ? [\"Container compose file detected.\"] : []),\n ...(signals.ci.githubActions ? [\"GitHub Actions workflow detected (.github/workflows).\"] : []),\n ];\n\n if (devopsReasons.length > 0) {\n packs.push(packRecommendation(\"devops\", \"high\", devopsReasons));\n }\n\n if (signals.observability.length > 0) {\n packs.push(\n packRecommendation(\n \"observability\",\n \"high\",\n signals.observability.map((match) => dependencyReason(match.dependency, match)),\n ),\n );\n }\n\n if (signals.dataTooling.length > 0) {\n packs.push(\n packRecommendation(\n \"data\",\n \"high\",\n signals.dataTooling.map((match) => dependencyReason(match.dependency, match)),\n ),\n );\n }\n\n if (signals.accessibilityTooling.length > 0) {\n packs.push(\n packRecommendation(\n \"accessibility\",\n \"high\",\n signals.accessibilityTooling.map((match) => dependencyReason(match.dependency, match)),\n ),\n );\n }\n\n return packs;\n}\n\nfunction rustReasons(signals: ProjectSignals): readonly string[] {\n const { workspace, cargoLock, toolchainFile } = signals.rust;\n\n return [\n \"Cargo.toml detected.\",\n ...(workspace ? [\"Cargo workspace (workspace Cargo.toml).\"] : []),\n ...(cargoLock ? [\"Cargo.lock detected.\"] : []),\n ...(toolchainFile !== undefined ? [`${toolchainFile} detected.`] : []),\n ];\n}\n\nfunction recommendOptionalCapabilities(\n signals: ProjectSignals,\n activePacks: ReadonlySet<string>,\n configuredPacks: readonly string[],\n): readonly Recommendation[] {\n const capabilities: Recommendation[] = [];\n\n const playwrightMatch = signals.browserTesting.find(\n (match) => match.dependency === \"@playwright/test\",\n );\n\n if (activePacks.has(\"testing\") && playwrightMatch !== undefined) {\n capabilities.push(\n capabilityRecommendation(\"playwright\", \"high\", [\n \"Playwright is already part of this project; browser MCP may be useful for interactive browser work.\",\n ]),\n );\n }\n\n const sentryMatch = signals.observability.find((match) =>\n match.dependency.startsWith(\"@sentry/\"),\n );\n\n if (sentryMatch !== undefined) {\n capabilities.push(\n capabilityRecommendation(\"sentry\", \"high\", [\"Sentry is already configured as a dependency.\"]),\n );\n }\n\n const supabaseMatch = signals.dataTooling.find((match) =>\n match.dependency.startsWith(\"@supabase/\"),\n );\n\n if (supabaseMatch !== undefined) {\n capabilities.push(\n capabilityRecommendation(\"supabase\", \"high\", [\n \"Supabase is already configured as a dependency.\",\n ]),\n );\n }\n\n if (configuredPacks.includes(\"efficiency\") && signals.localTools.rtkAvailable) {\n capabilities.push(\n capabilityRecommendation(\"rtk\", \"high\", [\"RTK is already installed locally.\"]),\n );\n }\n\n const sizeThreshold = signals.monorepo.detected\n ? CODEBASE_MEMORY_MONOREPO_FILE_THRESHOLD\n : CODEBASE_MEMORY_FILE_THRESHOLD;\n\n if (signals.repositorySize.filesScanned >= sizeThreshold || signals.repositorySize.capped) {\n capabilities.push(\n capabilityRecommendation(\"codebase-memory\", \"medium\", [repositorySizeReason(signals)]),\n );\n }\n\n return capabilities;\n}\n\nfunction repositorySizeReason(signals: ProjectSignals): string {\n const { filesScanned, capped } = signals.repositorySize;\n const scope = signals.monorepo.detected ? \" across this monorepo\" : \"\";\n const scanNote = capped\n ? `at least ${filesScanned} source files (the scan was capped before finishing)`\n : `${filesScanned} source files`;\n\n return (\n `Heuristic: found ${scanNote}${scope}. A persistent codebase-memory MCP may reduce repeated ` +\n \"full-tree reads on a repository this size — this is an approximate signal, not an exact token \" +\n \"measurement.\"\n );\n}\n\nfunction packRecommendation(\n name: string,\n confidence: RecommendationConfidence,\n reasons: readonly string[],\n): Recommendation {\n return { kind: \"pack\", name, confidence, reasons };\n}\n\n/** Provenance comes from the pack registry itself — never a second, hand-maintained capability map. */\nfunction capabilityRecommendation(\n name: string,\n confidence: RecommendationConfidence,\n reasons: readonly string[],\n): Recommendation {\n return {\n kind: \"capability\",\n name,\n confidence,\n reasons,\n contributedBy: packsDeclaringOptionalCapability(name),\n };\n}\n\nfunction packsDeclaringOptionalCapability(name: string): readonly string[] {\n const packs: string[] = [];\n\n for (const pack of builtInPackRegistry.values()) {\n const declares =\n pack.mcpServers.some((server) => server.name === name && server.activation === \"optional\") ||\n pack.tools.some((tool) => tool.name === name && tool.activation === \"optional\") ||\n pack.hooks.some((hook) => hook.name === name && hook.activation === \"optional\");\n\n if (declares) {\n packs.push(pack.name);\n }\n }\n\n return packs;\n}\n\nfunction dependencyReason(label: string, match: TechnologyMatch): string {\n return label === match.dependency\n ? `Detected ${match.dependency} in ${match.field}.`\n : `Detected ${label} (${match.dependency}) in ${match.field}.`;\n}\n\nfunction dedupeMatches(matches: readonly TechnologyMatch[]): readonly TechnologyMatch[] {\n const seen = new Set<string>();\n const result: TechnologyMatch[] = [];\n\n for (const match of matches) {\n if (!seen.has(match.dependency)) {\n seen.add(match.dependency);\n result.push(match);\n }\n }\n\n return result;\n}\n","import type { ProjectMetadata, ProjectRelation } from \"./config/schema.js\";\nimport { AgentyxError } from \"./errors.js\";\n\nexport class ProjectGraphNotConfiguredError extends AgentyxError {\n constructor() {\n super(\n \"project_graph_not_configured\",\n \"Project Graph requires a project object in .agentyx.json.\",\n );\n this.name = \"ProjectGraphNotConfiguredError\";\n }\n}\n\nexport interface ProjectGraph {\n readonly project: ProjectMetadata;\n readonly relations: readonly ProjectRelation[];\n}\n\nexport function createProjectGraph(\n project: ProjectMetadata,\n relations: readonly ProjectRelation[],\n): ProjectGraph {\n return { project, relations: [...relations] };\n}\n\nexport function renderProjectGraphText(graph: ProjectGraph): string {\n const rows = graph.relations.map((relation, index) => {\n const branch = index === graph.relations.length - 1 ? \"└──\" : \"├──\";\n return `${branch} ${relation.type} [${relation.role}] → ${relation.name}`;\n });\n return [graph.project.name, ...rows].join(\"\\n\");\n}\n\nexport function renderProjectGraphJson(graph: ProjectGraph): string {\n return `${JSON.stringify(graph, null, 2)}\\n`;\n}\n\nexport function renderProjectGraphMermaid(graph: ProjectGraph): string {\n const current = mermaidId(graph.project.id);\n const rows = graph.relations.map(\n (relation) =>\n ` ${current}[\"${mermaidText(graph.project.name)}\"] -->|${mermaidText(`${relation.type}: ${relation.role}`)}| ${mermaidId(relation.id)}[\"${mermaidText(relation.name)}\"]`,\n );\n return [\"graph LR\", ...rows].join(\"\\n\");\n}\n\nexport function renderProjectGraphSvg(graph: ProjectGraph): string {\n const width = 720;\n const rowHeight = 92;\n const height = Math.max(180, 100 + graph.relations.length * rowHeight);\n const centerX = 360;\n const centerY = height / 2;\n const svg = [\n `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 ${width} ${height}\" role=\"img\" aria-labelledby=\"title desc\">`,\n `<title id=\"title\">${xml(graph.project.name)} project graph</title>`,\n `<desc id=\"desc\">Direct architectural relationships from ${xml(graph.project.name)}.</desc>`,\n '<defs><marker id=\"arrow\" markerWidth=\"10\" markerHeight=\"8\" refX=\"9\" refY=\"4\" orient=\"auto\"><path d=\"M0,0 L10,4 L0,8 z\" fill=\"#526579\"/></marker></defs>',\n ];\n graph.relations.forEach((relation, index) => {\n const y = 54 + index * rowHeight;\n const right = index % 2 === 0;\n const x = right ? 500 : 0;\n const edgeStart = right ? centerX + 128 : centerX - 128;\n const edgeEnd = right ? x : x + 220;\n svg.push(\n `<line x1=\"${edgeStart}\" y1=\"${centerY}\" x2=\"${edgeEnd}\" y2=\"${y + 24}\" stroke=\"#526579\" stroke-width=\"2\" marker-end=\"url(#arrow)\"/>`,\n );\n svg.push(\n `<text x=\"${right ? 494 : 226}\" y=\"${Math.round((centerY + y + 24) / 2) - 7}\" class=\"edge\">${xml(truncate(`${relation.type} · ${relation.role}`, 34))}</text>`,\n );\n svg.push(`<rect x=\"${x}\" y=\"${y}\" width=\"220\" height=\"48\" rx=\"10\" class=\"node\"/>`);\n svg.push(\n `<text x=\"${x + 110}\" y=\"${y + 30}\" class=\"label\">${xml(truncate(relation.name, 22))}</text>`,\n );\n });\n svg.push(\n `<rect x=\"${centerX - 128}\" y=\"${centerY - 34}\" width=\"256\" height=\"68\" rx=\"14\" class=\"current\"/>`,\n );\n svg.push(\n `<text x=\"${centerX}\" y=\"${centerY + 6}\" class=\"label\">${xml(truncate(graph.project.name, 30))}</text>`,\n );\n svg.push(\n \"<style>text{font-family:system-ui,sans-serif}.node{fill:#fff;stroke:#8da0b3;stroke-width:2}.current{fill:#e8f2ff;stroke:#2563a5;stroke-width:3}.label{text-anchor:middle;font-size:16px;font-weight:600;fill:#172536}.edge{text-anchor:middle;font-size:12px;fill:#34495e;paint-order:stroke;stroke:#fff;stroke-width:5px;stroke-linejoin:round}</style>\",\n );\n svg.push(\"</svg>\");\n return `${svg.join(\"\\n\")}\\n`;\n}\n\nexport function findProjectCapabilityOwners(graph: ProjectGraph, capability: string) {\n const owners = graph.relations.filter((relation) => relation.owns.includes(capability));\n return {\n capability,\n currentProject: graph.project.owns.includes(capability) ? graph.project : undefined,\n relatedProjects: owners,\n };\n}\n\nfunction xml(value: string): string {\n return value\n .replaceAll(\"&\", \"&amp;\")\n .replaceAll(\"<\", \"&lt;\")\n .replaceAll(\">\", \"&gt;\")\n .replaceAll('\"', \"&quot;\")\n .replaceAll(\"'\", \"&apos;\");\n}\n\nfunction mermaidText(value: string): string {\n return value\n .replaceAll(\"&\", \"&amp;\")\n .replaceAll(\"|\", \"&#124;\")\n .replaceAll(\"[\", \"&#91;\")\n .replaceAll(\"]\", \"&#93;\")\n .replaceAll('\"', \"&quot;\")\n .replaceAll(\"<\", \"&lt;\")\n .replaceAll(\">\", \"&gt;\");\n}\n\nfunction mermaidId(value: string): string {\n return `node_${Array.from(value)\n .map((char) => char.codePointAt(0)?.toString(16) ?? \"0\")\n .join(\"\")}`;\n}\n\nfunction truncate(value: string, limit: number): string {\n const characters = Array.from(value);\n return characters.length > limit ? `${characters.slice(0, limit - 1).join(\"\")}…` : value;\n}\n","import type { Dirent } from \"node:fs\";\nimport { readdir, readFile, realpath } from \"node:fs/promises\";\nimport { dirname, isAbsolute, join, relative, resolve, sep } from \"node:path\";\nimport { parseSkillMarkdown } from \"../skill/markdown.js\";\nimport { TrustedSourceLoadError } from \"./errors.js\";\nimport { getTrustedSourceDefinition } from \"./registry.js\";\nimport {\n type CodexPluginManifest,\n codexPluginManifestSchema,\n type TrustedSourceDefinition,\n type TrustedSourceReference,\n type TrustedSourceSkillSummary,\n} from \"./schema.js\";\n\nexport interface TrustedSourceInspection {\n readonly definition: TrustedSourceDefinition;\n readonly reference: TrustedSourceReference;\n readonly rootPath: string;\n readonly manifest: CodexPluginManifest;\n readonly skillsPath: string;\n readonly skills: readonly TrustedSourceSkillSummary[];\n readonly installable: boolean;\n readonly installNote: string;\n}\n\nexport async function inspectTrustedSource(\n projectPath: string,\n reference: TrustedSourceReference,\n): Promise<TrustedSourceInspection> {\n const definition = getTrustedSourceDefinition(reference);\n const projectDir = resolve(projectPath);\n const projectRealPath = await realpath(projectDir);\n const root = resolve(projectDir, reference.path);\n const rootRealPath = await realpathOrThrow(\n reference.name,\n root,\n \"the checkout path cannot be read\",\n );\n\n if (!isInside(rootRealPath, projectRealPath)) {\n throw new TrustedSourceLoadError(\n reference.name,\n \"the checkout path resolves outside the project\",\n );\n }\n\n const manifestPath = join(rootRealPath, definition.manifestPath);\n const manifest = await readManifest(reference.name, manifestPath);\n\n if (manifest.name !== definition.name) {\n throw new TrustedSourceLoadError(\n reference.name,\n `${definition.manifestPath} declares the name \"${manifest.name}\"`,\n );\n }\n\n if (manifest.repository !== definition.repository) {\n throw new TrustedSourceLoadError(\n reference.name,\n `${definition.manifestPath} declares repository \"${manifest.repository}\"`,\n );\n }\n\n const skillsPath = resolve(dirname(manifestPath), manifest.skills);\n\n if (!isInside(skillsPath, rootRealPath)) {\n throw new TrustedSourceLoadError(\n reference.name,\n \"the manifest skills path resolves outside the checkout\",\n );\n }\n\n const skillsRealPath = await realpathOrThrow(\n reference.name,\n skillsPath,\n \"the manifest skills path cannot be read\",\n );\n\n if (!isInside(skillsRealPath, rootRealPath)) {\n throw new TrustedSourceLoadError(\n reference.name,\n \"the manifest skills path resolves outside the checkout\",\n );\n }\n\n const skills = await inspectSkillSummaries(reference.name, skillsRealPath);\n const installable =\n definition.installStatus === \"installable\" && skills.every((skill) => !skill.hasResources);\n\n return {\n definition,\n reference,\n rootPath: rootRealPath,\n manifest,\n skillsPath: skillsRealPath,\n skills,\n installable,\n installNote: definition.installNote,\n };\n}\n\nasync function readManifest(sourceName: string, path: string): Promise<CodexPluginManifest> {\n let raw: string;\n\n try {\n raw = await readFile(path, \"utf8\");\n } catch (cause) {\n throw trustedSourceLoadError(sourceName, \"the plugin manifest cannot be read\", cause);\n }\n\n try {\n return codexPluginManifestSchema.parse(JSON.parse(raw));\n } catch (cause) {\n throw trustedSourceLoadError(sourceName, \"the plugin manifest is invalid\", cause);\n }\n}\n\nasync function inspectSkillSummaries(\n sourceName: string,\n skillsPath: string,\n): Promise<readonly TrustedSourceSkillSummary[]> {\n let entries: Dirent[];\n\n try {\n entries = await readdir(skillsPath, { withFileTypes: true });\n } catch (cause) {\n throw trustedSourceLoadError(sourceName, \"the plugin skills directory cannot be listed\", cause);\n }\n\n const skills: TrustedSourceSkillSummary[] = [];\n\n for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {\n if (!entry.isDirectory()) {\n continue;\n }\n\n const skillRoot = join(skillsPath, entry.name);\n const skillPath = join(skillRoot, \"SKILL.md\");\n let markdown: string;\n\n try {\n markdown = await readFile(skillPath, \"utf8\");\n } catch (cause) {\n if (cause instanceof Error && (cause as NodeJS.ErrnoException).code === \"ENOENT\") {\n continue;\n }\n\n throw trustedSourceLoadError(sourceName, `cannot read ${entry.name}/SKILL.md`, cause);\n }\n\n const skill = parseSkillMarkdown(markdown, skillPath);\n\n if (skill.name !== entry.name) {\n throw new TrustedSourceLoadError(\n sourceName,\n `${entry.name}/SKILL.md declares the name \"${skill.name}\"`,\n );\n }\n\n skills.push({\n name: skill.name,\n description: skill.description,\n hasResources: await hasResources(skillRoot),\n });\n }\n\n return skills;\n}\n\nasync function hasResources(skillRoot: string): Promise<boolean> {\n const entries = await readdir(skillRoot, { withFileTypes: true });\n\n return entries.some((entry) => entry.name !== \"SKILL.md\");\n}\n\nasync function realpathOrThrow(sourceName: string, path: string, reason: string): Promise<string> {\n try {\n return await realpath(path);\n } catch (cause) {\n throw trustedSourceLoadError(sourceName, reason, cause);\n }\n}\n\nfunction isInside(path: string, root: string): boolean {\n const pathFromRoot = relative(root, path);\n\n return (\n pathFromRoot === \"\" ||\n (!pathFromRoot.startsWith(`..${sep}`) && pathFromRoot !== \"..\" && !isAbsolute(pathFromRoot))\n );\n}\n\nfunction trustedSourceLoadError(\n sourceName: string,\n reason: string,\n cause: unknown,\n): TrustedSourceLoadError {\n return new TrustedSourceLoadError(\n sourceName,\n reason,\n cause instanceof Error ? { cause } : undefined,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAOA,IAAa,eAAb,cAAkC,MAAM;CACtC;CAEA,YAAY,MAAc,SAAiB,SAAwB;EACjE,MAAM,SAAS,OAAO;EACtB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