@agentyx/core 0.1.1 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["formatIssues"],"sources":["../src/errors.ts","../src/config/errors.ts","../src/mcp/schema.ts","../src/skill/schema.ts","../src/stack/schema.ts","../src/config/schema.ts","../src/config/json-schema.ts","../src/config/loader.ts","../src/mcp/errors.ts","../src/mcp/registry.ts","../src/mcp/built-in.ts","../src/optimization/profile.ts","../src/stack/errors.ts","../src/stack/registry.ts","../src/stack/resolver.ts","../src/mcp/resolver.ts","../src/assets.ts","../src/skill/errors.ts","../src/skill/markdown.ts","../src/skill/registry.ts","../src/skill/built-in.ts","../src/skill/resolver.ts","../src/config/resolver.ts","../src/meta.ts","../src/project/detector.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\";\nimport { AgentyxError } from \"../errors.js\";\n\n/** A single configuration problem, addressed by its location in the document. */\nexport interface AgentyxConfigIssue {\n /** Dotted path to the offending value, or `(root)` for the document itself. */\n readonly path: string;\n readonly message: string;\n}\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 = toConfigIssues(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\nfunction toConfigIssues(error: ZodError): readonly AgentyxConfigIssue[] {\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 { z } from \"zod\";\n\nexport const MCP_CAPABILITY_LEVELS = [\"essential\", \"recommended\", \"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\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});\n\nconst explicitMcpServerReferenceSchema = z.strictObject({\n name: mcpServerNameSchema.describe(\"MCP server identifier.\"),\n level: mcpCapabilityLevelSchema\n .describe(\"How important this MCP capability is to the declaring stack.\")\n .default(\"recommended\"),\n});\n\nexport const mcpServerReferenceSchema = z\n .union([mcpServerNameSchema, explicitMcpServerReferenceSchema])\n .transform((value) =>\n typeof value === \"string\"\n ? {\n name: value,\n level: \"recommended\" as const,\n }\n : value,\n )\n .pipe(\n z.strictObject({\n name: mcpServerNameSchema.describe(\"MCP server identifier.\"),\n level: mcpCapabilityLevelSchema.describe(\n \"How important this MCP capability is to the declaring stack.\",\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 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\";\nimport { mcpServerReferenceSchema } from \"../mcp/schema.js\";\nimport { skillNameSchema } from \"../skill/schema.js\";\n\n/**\n * Stack names are plain identifiers. They are intentionally not constrained to\n * a closed list so that external registries can contribute stacks later.\n */\nexport const stackNameSchema = z.string().min(1, \"Stack names must be non-empty strings.\");\n\n/**\n * A stack describes a development environment that can build on other stacks\n * and contribute provider-agnostic capabilities to them.\n */\nexport const stackDefinitionSchema = z.strictObject({\n name: stackNameSchema.describe(\"Unique stack identifier.\"),\n description: z\n .string()\n .min(1, \"Stack descriptions must be non-empty when provided.\")\n .describe(\"Short human-readable summary of the stack.\")\n .optional(),\n extends: z\n .array(stackNameSchema)\n .describe(\"Stacks this stack builds on, in dependency-first order.\")\n .default([]),\n skills: z\n .array(skillNameSchema)\n .describe(\"Skills this stack contributes, in declaration order.\")\n .default([]),\n mcpServers: z\n .array(mcpServerReferenceSchema)\n .describe(\"MCP servers this stack contributes, in declaration order.\")\n .default([]),\n});\n\n/** A validated stack definition, with defaults always present. */\nexport type StackDefinition = z.infer<typeof stackDefinitionSchema>;\n\n/** The shape accepted when authoring a stack definition. */\nexport type StackDefinitionInput = z.input<typeof stackDefinitionSchema>;\n","import { z } from \"zod\";\nimport { stackNameSchema } from \"../stack/schema.js\";\n\n/** How much autonomy the generated environment should grant an agent. */\nexport const AGENTYX_PROFILES = [\"lean\", \"balanced\", \"autonomous\"] as const;\n\nexport const agentyxProfileSchema = z.enum(AGENTYX_PROFILES, {\n error: `Profile must be one of: ${AGENTYX_PROFILES.join(\", \")}.`,\n});\n\nexport type AgentyxProfile = z.infer<typeof agentyxProfileSchema>;\n\n/** Applied when a configuration omits `profile`. */\nexport const DEFAULT_AGENTYX_PROFILE: AgentyxProfile = \"balanced\";\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\n/** The `.agentyx.json` project configuration. */\nexport const agentyxConfigSchema = z.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 extends: z.array(stackNameSchema).describe(\"Stacks this project builds on.\").default([]),\n profile: agentyxProfileSchema\n .describe(\"How much autonomy the generated environment grants.\")\n .default(DEFAULT_AGENTYX_PROFILE),\n targets: z\n .array(agentyxTargetSchema)\n .describe(\"Coding-agent providers this project targets.\")\n .default([]),\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>;\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 = \"https://agentyx.dev/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 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 stack \"${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}\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 };\n }),\n get,\n };\n}\n","import { createMcpServerRegistry, type McpServerSource } from \"./registry.js\";\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 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 command: \"npx\",\n args: [\"@playwright/mcp@latest\"],\n }),\n },\n];\n\nexport const builtInMcpServerRegistry = createMcpServerRegistry(builtInMcpServerSources);\n\nexport const builtInMcpServerNames: readonly string[] = builtInMcpServerRegistry.names;\n","import type { AgentyxProfile } from \"../config/schema.js\";\nimport type { McpCapabilityLevel } from \"../mcp/schema.js\";\n\nexport interface OptimizationProfileDefinition {\n readonly name: AgentyxProfile;\n readonly goal: string;\n readonly mcpLevels: readonly McpCapabilityLevel[];\n readonly notes: readonly string[];\n}\n\nexport const optimizationProfiles: readonly OptimizationProfileDefinition[] = [\n {\n name: \"lean\",\n goal: \"Minimum context and tool overhead.\",\n mcpLevels: [\"essential\"],\n notes: [\n \"Installs all resolved Skills.\",\n \"Keeps MCP exposure to essential capabilities.\",\n \"Prefers local CLI or native tools when they cover the same workflow.\",\n ],\n },\n {\n name: \"balanced\",\n goal: \"Good default developer experience with conservative autonomy.\",\n mcpLevels: [\"essential\", \"recommended\"],\n notes: [\"Installs all resolved Skills.\", \"Includes default and recommended MCP capabilities.\"],\n },\n {\n name: \"autonomous\",\n goal: \"Maximum agent capability from declared stack capabilities.\",\n mcpLevels: [\"essential\", \"recommended\", \"optional\"],\n notes: [\n \"Installs all resolved Skills.\",\n \"Includes optional MCP capabilities declared by the selected stacks.\",\n ],\n },\n];\n\nexport const optimizationProfileNames: readonly AgentyxProfile[] = optimizationProfiles.map(\n (profile) => profile.name,\n);\n\nexport function getOptimizationProfile(name: AgentyxProfile): OptimizationProfileDefinition {\n const profile = optimizationProfiles.find((candidate) => candidate.name === name);\n\n if (profile === undefined) {\n throw new Error(`Unknown optimization profile: ${name}`);\n }\n\n return profile;\n}\n\nexport function isMcpLevelEnabled(profile: AgentyxProfile, level: McpCapabilityLevel): boolean {\n return getOptimizationProfile(profile).mcpLevels.includes(level);\n}\n","import { AgentyxError } from \"../errors.js\";\n\n/**\n * Raised when a requested or inherited stack is not present in the registry.\n *\n * The offending name is exposed as `stackName`; `stack` stays the JS stack\n * trace inherited from `Error`.\n */\nexport class UnknownStackError extends AgentyxError {\n readonly stackName: string;\n readonly requiredBy: string | undefined;\n readonly knownStacks: readonly string[];\n\n constructor(stackName: string, requiredBy: string | undefined, knownStacks: readonly string[]) {\n const origin = requiredBy === undefined ? \"\" : ` (required by \"${requiredBy}\")`;\n const known = knownStacks.length > 0 ? [...knownStacks].sort().join(\", \") : \"none\";\n\n super(\"unknown_stack\", `Unknown stack \"${stackName}\"${origin}. Known stacks: ${known}.`);\n this.name = \"UnknownStackError\";\n this.stackName = stackName;\n this.requiredBy = requiredBy;\n this.knownStacks = knownStacks;\n }\n}\n\n/** Raised when stack inheritance forms a cycle. */\nexport class CircularStackDependencyError extends AgentyxError {\n /** The cycle path, starting and ending with the same stack. */\n readonly cycle: readonly string[];\n\n constructor(cycle: readonly string[]) {\n super(\"circular_stack_dependency\", `Circular stack dependency: ${cycle.join(\" -> \")}.`);\n this.name = \"CircularStackDependencyError\";\n this.cycle = cycle;\n }\n}\n\n/** Raised when a registry is built from definitions that reuse a stack name. */\nexport class DuplicateStackError extends AgentyxError {\n readonly stackName: string;\n\n constructor(stackName: string) {\n super(\"duplicate_stack\", `Duplicate stack definition: \"${stackName}\".`);\n this.name = \"DuplicateStackError\";\n this.stackName = stackName;\n }\n}\n","import { DuplicateStackError } from \"./errors.js\";\nimport {\n type StackDefinition,\n type StackDefinitionInput,\n stackDefinitionSchema,\n} from \"./schema.js\";\n\n/**\n * A registry is a name lookup over stack 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 StackRegistry = ReadonlyMap<string, StackDefinition>;\n\n/** Validates definitions and indexes them by name. */\nexport function createStackRegistry(definitions: Iterable<StackDefinitionInput>): StackRegistry {\n const registry = new Map<string, StackDefinition>();\n\n for (const definition of definitions) {\n const stack = stackDefinitionSchema.parse(definition);\n\n if (registry.has(stack.name)) {\n throw new DuplicateStackError(stack.name);\n }\n\n registry.set(stack.name, stack);\n }\n\n return registry;\n}\n\n/**\n * The stacks Agentyx ships with, expressed as data. Relationships live here, not\n * in the resolver.\n */\nexport const builtInStacks: readonly StackDefinitionInput[] = [\n {\n name: \"core\",\n description: \"Baseline development environment shared by every Agentyx stack.\",\n skills: [\"planning\", \"systematic-debugging\", \"verification\"],\n },\n {\n name: \"typescript\",\n description: \"TypeScript development environment.\",\n extends: [\"core\"],\n skills: [\"typescript-modern\"],\n },\n {\n name: \"angular\",\n description: \"Modern Angular development environment.\",\n extends: [\"typescript\"],\n skills: [\"angular-modern\"],\n mcpServers: [{ name: \"context7\", level: \"recommended\" }],\n },\n];\n\n/** The registry used by default when no explicit registry is supplied. */\nexport const builtInStackRegistry: StackRegistry = createStackRegistry(builtInStacks);\n","import { CircularStackDependencyError, UnknownStackError } from \"./errors.js\";\nimport { builtInStackRegistry, type StackRegistry } from \"./registry.js\";\n\n/**\n * Expands the requested stacks into the full inheritance chain.\n *\n * The result is dependency-first, de-duplicated and deterministic: stacks are\n * visited in the order they are requested, and each stack's parents are visited\n * in declaration order before the stack itself.\n *\n * @throws {UnknownStackError} when a requested or inherited stack is missing.\n * @throws {CircularStackDependencyError} when inheritance forms a cycle.\n */\nexport function resolveStacks(\n requestedStacks: readonly string[],\n registry: StackRegistry = builtInStackRegistry,\n): string[] {\n const resolved: string[] = [];\n const settled = new Set<string>();\n const path: string[] = [];\n\n const visit = (name: string, requiredBy: string | undefined): void => {\n if (settled.has(name)) {\n return;\n }\n\n const cycleStart = path.indexOf(name);\n\n if (cycleStart !== -1) {\n throw new CircularStackDependencyError([...path.slice(cycleStart), name]);\n }\n\n const definition = registry.get(name);\n\n if (definition === undefined) {\n throw new UnknownStackError(name, requiredBy, [...registry.keys()]);\n }\n\n path.push(name);\n\n for (const parent of definition.extends) {\n visit(parent, name);\n }\n\n path.pop();\n settled.add(name);\n resolved.push(name);\n };\n\n for (const name of requestedStacks) {\n visit(name, undefined);\n }\n\n return resolved;\n}\n","import type { AgentyxProfile } from \"../config/schema.js\";\nimport { DEFAULT_AGENTYX_PROFILE } from \"../config/schema.js\";\nimport { isMcpLevelEnabled } from \"../optimization/profile.js\";\nimport { builtInStackRegistry, type StackRegistry } from \"../stack/registry.js\";\nimport { resolveStacks } from \"../stack/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 collectStackMcpServerReferences(\n resolvedStacks: readonly string[],\n stackRegistry: StackRegistry,\n mcpRegistry: McpServerRegistry,\n): McpServerReference[] {\n const servers: McpServerReference[] = [];\n const seen = new Set<string>();\n\n for (const stackName of resolvedStacks) {\n for (const server of stackRegistry.get(stackName)?.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, stackName, 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 profile: AgentyxProfile,\n): string[] {\n return servers\n .filter((server) => isMcpLevelEnabled(profile, server.level))\n .map((server) => server.name);\n}\n\nexport function collectStackMcpServers(\n resolvedStacks: readonly string[],\n stackRegistry: StackRegistry,\n mcpRegistry: McpServerRegistry,\n profile: AgentyxProfile = DEFAULT_AGENTYX_PROFILE,\n): string[] {\n return filterEffectiveMcpServers(\n collectStackMcpServerReferences(resolvedStacks, stackRegistry, mcpRegistry),\n profile,\n );\n}\n\nexport function resolveStackMcpServerReferences(\n requestedStacks: readonly string[],\n stackRegistry: StackRegistry = builtInStackRegistry,\n mcpRegistry: McpServerRegistry = builtInMcpServerRegistry,\n): McpServerReference[] {\n return collectStackMcpServerReferences(\n resolveStacks(requestedStacks, stackRegistry),\n stackRegistry,\n mcpRegistry,\n );\n}\n\nexport function resolveStackMcpServers(\n requestedStacks: readonly string[],\n stackRegistry: StackRegistry = builtInStackRegistry,\n mcpRegistry: McpServerRegistry = builtInMcpServerRegistry,\n profile: AgentyxProfile = DEFAULT_AGENTYX_PROFILE,\n): string[] {\n return collectStackMcpServers(\n resolveStacks(requestedStacks, stackRegistry),\n stackRegistry,\n mcpRegistry,\n profile,\n );\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));\n","import type { ZodError } from \"zod\";\nimport { AgentyxError } from \"../errors.js\";\n\n/**\n * Raised when a stack references a skill the registry does not know.\n *\n * The offending name is exposed as `skillName`; `stack` stays the JS stack\n * trace inherited from `Error`.\n */\nexport class UnknownSkillError extends AgentyxError {\n readonly skillName: string;\n /** The stack 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 stack \"${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 stack resolution validate references without reading any body.\n */\nexport const builtInSkillNames = [\n \"planning\",\n \"systematic-debugging\",\n \"verification\",\n \"typescript-modern\",\n \"angular-modern\",\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 { builtInStackRegistry, type StackRegistry } from \"../stack/registry.js\";\nimport { resolveStacks } from \"../stack/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 stack 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 stack references a skill the registry lacks.\n */\nexport function collectStackSkills(\n resolvedStacks: readonly string[],\n stackRegistry: StackRegistry,\n skillRegistry: SkillRegistry,\n): string[] {\n const skills: string[] = [];\n const seen = new Set<string>();\n\n for (const stackName of resolvedStacks) {\n for (const skillName of stackRegistry.get(stackName)?.skills ?? []) {\n if (seen.has(skillName)) {\n continue;\n }\n\n if (!skillRegistry.has(skillName)) {\n throw new UnknownSkillError(skillName, stackName, skillRegistry.names);\n }\n\n seen.add(skillName);\n skills.push(skillName);\n }\n }\n\n return skills;\n}\n\n/**\n * Expands the requested stacks and returns the skills they contribute.\n *\n * The result follows the resolved stack order, then each stack'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 {UnknownStackError} when a requested or inherited stack is missing.\n * @throws {CircularStackDependencyError} when stack inheritance forms a cycle.\n * @throws {UnknownSkillError} when a stack references a skill the registry lacks.\n */\nexport function resolveStackSkills(\n requestedStacks: readonly string[],\n stackRegistry: StackRegistry = builtInStackRegistry,\n skillRegistry: SkillRegistry = builtInSkillRegistry,\n): string[] {\n return collectStackSkills(\n resolveStacks(requestedStacks, stackRegistry),\n stackRegistry,\n skillRegistry,\n );\n}\n","import { builtInMcpServerRegistry } from \"../mcp/built-in.js\";\nimport type { McpServerRegistry } from \"../mcp/registry.js\";\nimport { collectStackMcpServerReferences, filterEffectiveMcpServers } from \"../mcp/resolver.js\";\nimport type { McpServerReference } from \"../mcp/schema.js\";\nimport { builtInSkillRegistry } from \"../skill/built-in.js\";\nimport type { SkillRegistry } from \"../skill/registry.js\";\nimport { collectStackSkills } from \"../skill/resolver.js\";\nimport { builtInStackRegistry, type StackRegistry } from \"../stack/registry.js\";\nimport { resolveStacks } from \"../stack/resolver.js\";\nimport type { AgentyxConfig, AgentyxProfile } from \"./schema.js\";\n\n/** A project configuration with its stack inheritance expanded. */\nexport interface ResolvedAgentyxConfig {\n /** The stacks the project asked for, in configuration order. */\n readonly requestedStacks: readonly string[];\n /** The full inheritance chain, dependency-first and de-duplicated. */\n readonly resolvedStacks: readonly string[];\n /**\n * Skill identifiers contributed by the resolved stacks, 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 profile: AgentyxProfile;\n readonly targets: readonly string[];\n}\n\n/**\n * Combines a validated project configuration with stack and skill resolution.\n * The input is never mutated.\n *\n * @throws {UnknownStackError} when a configured stack is missing.\n * @throws {CircularStackDependencyError} when inheritance forms a cycle.\n * @throws {UnknownSkillError} when a stack references an unknown skill.\n */\nexport function resolveAgentyxConfig(\n config: AgentyxConfig,\n registry: StackRegistry = builtInStackRegistry,\n skillRegistry: SkillRegistry = builtInSkillRegistry,\n mcpRegistry: McpServerRegistry = builtInMcpServerRegistry,\n): ResolvedAgentyxConfig {\n const requestedStacks = [...config.extends];\n const resolvedStacks = resolveStacks(requestedStacks, registry);\n const declaredMcpServers = collectStackMcpServerReferences(resolvedStacks, registry, mcpRegistry);\n\n return {\n requestedStacks,\n resolvedStacks,\n skills: collectStackSkills(resolvedStacks, registry, skillRegistry),\n declaredMcpServers,\n mcpServers: filterEffectiveMcpServers(declaredMcpServers, config.profile),\n profile: config.profile,\n targets: [...config.targets],\n };\n}\n","export const agentyxCoreName = \"agentyx-core\";\n\nexport function getCoreStatus(): string {\n return \"ready\";\n}\n","import { access, readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport type { AgentyxConfigInput, AgentyxProfile } from \"../config/schema.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 error: string | undefined;\n}\n\nexport interface ProjectDetection {\n readonly projectDir: string;\n readonly packageJson: ProjectPackageJsonDetection;\n readonly packageManager: PackageManagerDetection;\n readonly detectedStacks: readonly string[];\n readonly recommendedStack: string | undefined;\n}\n\ninterface PackageJson {\n readonly name?: unknown;\n readonly packageManager?: 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\nexport async function detectProject(projectDir: string): Promise<ProjectDetection> {\n const packageJsonPath = join(projectDir, \"package.json\");\n const packageJson = await readPackageJson(packageJsonPath);\n const packageManager = await detectPackageManager(projectDir, packageJson.data);\n const detectedStacks = await detectStacks(projectDir, packageJson.data);\n\n return {\n projectDir,\n packageJson: {\n present: packageJson.present,\n valid: packageJson.valid,\n path: packageJsonPath,\n name: getString(packageJson.data?.name),\n packageManager: getString(packageJson.data?.packageManager),\n error: packageJson.error,\n },\n packageManager,\n detectedStacks,\n recommendedStack: recommendStack(detectedStacks),\n };\n}\n\nexport function buildAgentyxConfig(input: {\n readonly stack: string;\n readonly profile: AgentyxProfile;\n readonly targets: readonly string[];\n}): AgentyxConfigInput {\n return {\n extends: [input.stack],\n profile: input.profile,\n targets: [...input.targets],\n };\n}\n\nexport function formatAgentyxConfig(config: AgentyxConfigInput): string {\n return `${JSON.stringify(config, null, 2)}\\n`;\n}\n\nfunction recommendStack(detectedStacks: readonly string[]): string | undefined {\n if (detectedStacks.includes(\"angular\")) {\n return \"angular\";\n }\n\n if (detectedStacks.includes(\"typescript\")) {\n return \"typescript\";\n }\n\n return undefined;\n}\n\nasync function detectStacks(\n projectDir: string,\n packageJson: PackageJson | undefined,\n): Promise<readonly string[]> {\n const stacks: string[] = [];\n const dependencies = collectDependencies(packageJson);\n const hasAngular = dependencies.has(\"@angular/core\");\n const hasTypeScript =\n dependencies.has(\"typescript\") || (await exists(join(projectDir, \"tsconfig.json\")));\n\n if (hasTypeScript || hasAngular) {\n stacks.push(\"typescript\");\n }\n\n if (hasAngular) {\n stacks.push(\"angular\");\n }\n\n return stacks;\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 collectDependencies(packageJson: PackageJson | undefined): ReadonlySet<string> {\n const dependencies = new Set<string>();\n\n for (const field of [\n packageJson?.dependencies,\n packageJson?.devDependencies,\n packageJson?.peerDependencies,\n packageJson?.optionalDependencies,\n ]) {\n if (isRecord(field)) {\n for (const name of Object.keys(field)) {\n dependencies.add(name);\n }\n }\n }\n\n return dependencies;\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 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"],"mappings":";;;;;;;;;;;;;AAOA,IAAa,eAAb,cAAkC,MAAM;CACtC;CAEA,YAAY,MAAc,SAAiB,SAAwB;EACjE,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;EACZ,KAAK,OAAO;CACd;AACF;;;;ACJA,IAAa,6BAAb,cAAgD,aAAa;CAC3D;CAEA,YAAY,UAAkB,SAAwB;EACpD,MAAM,4BAA4B,yCAAyC,YAAY,OAAO;EAC9F,KAAK,OAAO;EACZ,KAAK,WAAW;CAClB;AACF;;AAGA,IAAa,0BAAb,cAA6C,aAAa;CACxD;CAEA,YAAY,UAAkB,QAAgB,SAAwB;EACpE,MAAM,8BAA8B,GAAG,SAAS,sBAAsB,UAAU,OAAO;EACvF,KAAK,OAAO;EACZ,KAAK,WAAW;CACl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,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,eAAe,OAAO,MAAgC;CACpD,IAAI;EACF,MAAM,OAAO,IAAI;EACjB,OAAO;CACT,SAAS,OAAO;EACd,IAAI,WAAW,KAAK,GAClB,OAAO;EAGT,MAAM;CACR;AACF;AAEA,SAAS,WAAW,OAAyB;CAC3C,OAAO,iBAAiB,SAAU,MAAgC,SAAS;AAC7E"}
1
+ {"version":3,"file":"index.mjs","names":["formatIssues"],"sources":["../src/errors.ts","../src/config/errors.ts","../src/mcp/schema.ts","../src/skill/schema.ts","../src/tool/schema.ts","../src/pack/schema.ts","../src/config/schema.ts","../src/config/json-schema.ts","../src/config/loader.ts","../src/mcp/errors.ts","../src/mcp/registry.ts","../src/mcp/built-in.ts","../src/pack/errors.ts","../src/pack/registry.ts","../src/pack/resolver.ts","../src/mcp/resolver.ts","../src/assets.ts","../src/skill/errors.ts","../src/skill/markdown.ts","../src/skill/registry.ts","../src/skill/built-in.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/meta.ts","../src/project/detector.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\";\nimport { AgentyxError } from \"../errors.js\";\n\n/** A single configuration problem, addressed by its location in the document. */\nexport interface AgentyxConfigIssue {\n /** Dotted path to the offending value, or `(root)` for the document itself. */\n readonly path: string;\n readonly message: string;\n}\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 = toConfigIssues(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\nfunction toConfigIssues(error: ZodError): readonly AgentyxConfigIssue[] {\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 { 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\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});\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 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 { 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});\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 { packNameSchema } from \"../pack/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/** The `.agentyx.json` project configuration. */\nexport const agentyxConfigSchema = z.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});\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>;\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 = \"https://agentyx.dev/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 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}\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 };\n }),\n get,\n };\n}\n","import { createMcpServerRegistry, type McpServerSource } from \"./registry.js\";\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 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 command: \"npx\",\n args: [\"@playwright/mcp@latest\"],\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 command: \"codebase-memory-mcp\",\n }),\n },\n];\n\nexport const builtInMcpServerRegistry = createMcpServerRegistry(builtInMcpServerSources);\n\nexport const builtInMcpServerNames: readonly string[] = builtInMcpServerRegistry.names;\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 },\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\n/** The registry used by default when no explicit registry is supplied. */\nexport const builtInPackRegistry: PackRegistry = createPackRegistry(builtInPacks);\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 { 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 { 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));\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] 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 { 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 { 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 pack inheritance expanded. */\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 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 {CircularPackDependencyError} when inheritance forms a cycle.\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): 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 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 ];\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: collectPackSkills(resolvedPacks, registry, skillRegistry),\n declaredMcpServers,\n mcpServers: filterEffectiveMcpServers(declaredMcpServers, config.enable),\n declaredTools,\n tools: filterEffectiveTools(declaredTools, config.enable),\n enabled: [...config.enable],\n targets: [...config.targets],\n };\n}\n","export const agentyxCoreName = \"agentyx-core\";\n\nexport function getCoreStatus(): string {\n return \"ready\";\n}\n","import { access, readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport type { AgentyxConfigInput } from \"../config/schema.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 error: string | undefined;\n}\n\nexport interface ProjectDetection {\n readonly projectDir: string;\n readonly packageJson: ProjectPackageJsonDetection;\n readonly packageManager: PackageManagerDetection;\n readonly detectedPacks: readonly string[];\n readonly recommendedPacks: readonly string[];\n}\n\ninterface PackageJson {\n readonly name?: unknown;\n readonly packageManager?: 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\nexport async function detectProject(projectDir: string): Promise<ProjectDetection> {\n const packageJsonPath = join(projectDir, \"package.json\");\n const packageJson = await readPackageJson(packageJsonPath);\n const packageManager = await detectPackageManager(projectDir, packageJson.data);\n const detectedPacks = await detectPacks(projectDir, packageJson.data);\n\n return {\n projectDir,\n packageJson: {\n present: packageJson.present,\n valid: packageJson.valid,\n path: packageJsonPath,\n name: getString(packageJson.data?.name),\n packageManager: getString(packageJson.data?.packageManager),\n error: packageJson.error,\n },\n packageManager,\n detectedPacks,\n recommendedPacks: recommendPacks(detectedPacks),\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\nfunction recommendPacks(detectedPacks: readonly string[]): readonly string[] {\n if (detectedPacks.includes(\"angular\")) {\n return [\"technical\", \"typescript\", \"angular\"];\n }\n\n if (detectedPacks.includes(\"typescript\")) {\n return [\"technical\", \"typescript\"];\n }\n\n return [\"technical\"];\n}\n\nasync function detectPacks(\n projectDir: string,\n packageJson: PackageJson | undefined,\n): Promise<readonly string[]> {\n const packs: string[] = [];\n const dependencies = collectDependencies(packageJson);\n const hasAngular = dependencies.has(\"@angular/core\");\n const hasTypeScript =\n dependencies.has(\"typescript\") || (await exists(join(projectDir, \"tsconfig.json\")));\n\n if (hasTypeScript || hasAngular) {\n packs.push(\"typescript\");\n }\n\n if (hasAngular) {\n packs.push(\"angular\");\n }\n\n return packs;\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 collectDependencies(packageJson: PackageJson | undefined): ReadonlySet<string> {\n const dependencies = new Set<string>();\n\n for (const field of [\n packageJson?.dependencies,\n packageJson?.devDependencies,\n packageJson?.peerDependencies,\n packageJson?.optionalDependencies,\n ]) {\n if (isRecord(field)) {\n for (const name of Object.keys(field)) {\n dependencies.add(name);\n }\n }\n }\n\n return dependencies;\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 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"],"mappings":";;;;;;;;;;;;;AAOA,IAAa,eAAb,cAAkC,MAAM;CACtC;CAEA,YAAY,MAAc,SAAiB,SAAwB;EACjE,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;EACZ,KAAK,OAAO;CACd;AACF;;;;ACJA,IAAa,6BAAb,cAAgD,aAAa;CAC3D;CAEA,YAAY,UAAkB,SAAwB;EACpD,MAAM,4BAA4B,yCAAyC,YAAY,OAAO;EAC9F,KAAK,OAAO;EACZ,KAAK,WAAW;CAClB;AACF;;AAGA,IAAa,0BAAb,cAA6C,aAAa;CACxD;CAEA,YAAY,UAAkB,QAAgB,SAAwB;EACpE,MAAM,8BAA8B,GAAG,SAAS,sBAAsB,UAAU,OAAO;EACvF,KAAK,OAAO;EACZ,KAAK,WAAW;CAClB;AACF;;AAGA,IAAa,+BAAb,cAAkD,aAAa;CAC7D;;CAEA;CAEA,YAAY,OAAiB,UAAmB;EAC9C,MAAM,SAAS,eAAe,KAAK;EACnC,MAAM,WAAW,aAAa,KAAA,IAAY,KAAK,OAAO;EACtD,MAAM,UAAU,OAAO,KAAK,UAAU,OAAO,MAAM,KAAK,IAAI,MAA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I,IAAY;CAErC,KAAK,MAAM,SAAS;EAClB,aAAa;EACb,aAAa;EACb,aAAa;EACb,aAAa;CACf,GACE,IAAI,SAAS,KAAK,GAChB,KAAK,MAAM,QAAQ,OAAO,KAAK,KAAK,GAClC,aAAa,IAAI,IAAI;CAK3B,OAAO;AACT;AAEA,SAAS,wBAAwB,OAA2D;CAC1F,MAAM,OAAO,OAAO,MAAM,GAAG,CAAC,CAAC;CAE/B,OAAO,iBAAiB,SAAS,IAA0B,IACtD,OACD,KAAA;AACN;AAEA,SAAS,UAAU,OAAoC;CACrD,OAAO,OAAO,UAAU,WAAW,QAAQ,KAAA;AAC7C;AAEA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,eAAe,OAAO,MAAgC;CACpD,IAAI;EACF,MAAM,OAAO,IAAI;EACjB,OAAO;CACT,SAAS,OAAO;EACd,IAAI,WAAW,KAAK,GAClB,OAAO;EAGT,MAAM;CACR;AACF;AAEA,SAAS,WAAW,OAAyB;CAC3C,OAAO,iBAAiB,SAAU,MAAgC,SAAS;AAC7E"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentyx/core",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Shared domain foundations for Agentyx: configuration model, stack resolution and skills.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -10,20 +10,24 @@
10
10
  "minLength": 1,
11
11
  "description": "Optional path or URL to the Agentyx JSON Schema."
12
12
  },
13
- "extends": {
13
+ "packs": {
14
14
  "default": [],
15
15
  "type": "array",
16
16
  "items": {
17
17
  "type": "string",
18
18
  "minLength": 1
19
19
  },
20
- "description": "Stacks this project builds on."
20
+ "description": "Capability packs this project selects."
21
21
  },
22
- "profile": {
23
- "default": "balanced",
24
- "type": "string",
25
- "enum": ["lean", "balanced", "autonomous"],
26
- "description": "How much autonomy the generated environment grants."
22
+ "enable": {
23
+ "default": [],
24
+ "type": "array",
25
+ "items": {
26
+ "type": "string",
27
+ "minLength": 1,
28
+ "pattern": "^[a-z0-9]+(?:-[a-z0-9]+)*$"
29
+ },
30
+ "description": "Optional capabilities to activate by explicit identifier."
27
31
  },
28
32
  "targets": {
29
33
  "default": [],
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: angular-architecture
3
+ description: Structure Angular features with clear boundaries, DI, OnPush, and accessibility.
4
+ ---
5
+
6
+ # Angular architecture
7
+
8
+ Keep Angular structure feature-oriented and explicit.
9
+
10
+ ## Boundaries
11
+
12
+ Group components, services, routes, and tests around features. Put state where it is owned: local
13
+ component state stays local, shared state belongs in a focused service, and global services should
14
+ be rare.
15
+
16
+ ## Components and DI
17
+
18
+ Use services and dependency injection for reusable behavior and integration boundaries. Prefer
19
+ presentational/container separation only when it clarifies ownership or testing.
20
+
21
+ ## Rendering
22
+
23
+ Design for `OnPush` and zoneless-compatible updates: signals, async pipe, explicit events, and clear
24
+ change notifications. Avoid code that depends on zone patching side effects.
25
+
26
+ ## Accessibility
27
+
28
+ Preserve semantic HTML, labels, keyboard access, focus management, and ARIA only where semantics
29
+ need help.
@@ -1,47 +1,29 @@
1
1
  ---
2
2
  name: angular-modern
3
- description: Modern Angular conventions - standalone, signals, inject(), OnPush, zoneless.
3
+ description: Use current Angular APIs for standalone components, control flow, inputs, outputs, and DI.
4
4
  ---
5
5
 
6
6
  # Modern Angular
7
7
 
8
- Write new code with the current APIs. Reach for a legacy pattern only when there is no modern
9
- equivalent.
8
+ Write new Angular code with current APIs. Reach for legacy patterns only when maintaining existing
9
+ code that still depends on them.
10
10
 
11
11
  ## Components
12
12
 
13
- Components, directives, and pipes are standalone: declare what a template needs in `imports` and do
14
- not add an `NgModule` for new code. Set `changeDetection: ChangeDetectionStrategy.OnPush` on every
15
- component.
13
+ Use standalone components, directives, and pipes. Declare template dependencies in `imports` and do
14
+ not introduce an `NgModule` for new feature code.
16
15
 
17
- Keep components small — template, local state, and the wiring between them. Logic worth testing on
18
- its own belongs in a service or a plain function, not behind a component fixture.
16
+ ## Inputs and outputs
19
17
 
20
- ## State
21
-
22
- Use signals for component state. Derive with `computed()` rather than recomputing in the template
23
- or syncing fields by hand, and keep `effect()` for genuine side effects — never for writing state
24
- that a `computed()` could express.
25
-
26
- Declare inputs with `input()` and `input.required()`, outputs with `output()`, and two-way bindings
27
- with `model()`. Query the view with the signal APIs, `viewChild()` and `contentChild()`.
28
-
29
- RxJS still fits streams of events over time; bridge with `toSignal()` and `toObservable()` at the
30
- edges instead of mixing both styles in one component.
18
+ Use `input()`, `input.required()`, `output()`, and `model()` where they fit. Keep inputs explicit
19
+ and outputs event-like.
31
20
 
32
21
  ## Injection
33
22
 
34
- Call `inject()` in field initialisers instead of taking constructor parameters. It composes inside
35
- plain functions and reads better with `readonly` fields.
23
+ Use `inject()` in field initializers or framework-supported injection contexts. This keeps
24
+ constructors small and makes dependencies visible near their use.
36
25
 
37
26
  ## Templates
38
27
 
39
- Use built-in control flow — `@if`, `@for`, `@switch`, `@defer` — not `*ngIf` and `*ngFor`, and give
40
- every `@for` a `track` expression. Read signals directly in the template; the binding tracks them
41
- for you.
42
-
43
- ## Zoneless
44
-
45
- Do not rely on `zone.js` patching. Drive updates through signals, avoid reaching for
46
- `ChangeDetectorRef.detectChanges()` or `NgZone.run()`, and never trigger change detection as a side
47
- effect.
28
+ Use built-in control flow: `@if`, `@for`, `@switch`, and `@defer`. Give `@for` a stable `track`
29
+ expression. Prefer current migration paths when modernizing existing templates.
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: angular-signals
3
+ description: Use Angular signals for local synchronous state and derived values.
4
+ ---
5
+
6
+ # Angular signals
7
+
8
+ Use signals when state is synchronous and read by templates or nearby code.
9
+
10
+ ## State
11
+
12
+ Create writable state with `signal()`. Derive values with `computed()` instead of syncing fields by
13
+ hand. Keep `effect()` for side effects such as logging, persistence, or imperative integration.
14
+
15
+ ## Boundaries
16
+
17
+ Use signal inputs, queries, and model APIs where they fit new Angular code. Bridge RxJS at the edge
18
+ with Angular interop helpers when a stream must feed signal state.
19
+
20
+ ## RxJS
21
+
22
+ Do not replace every observable with a signal. RxJS remains appropriate for async streams, event
23
+ composition, cancellation, retries, and multicasting.
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: angular-testing
3
+ description: Test Angular behavior with appropriate unit, component, and E2E boundaries.
4
+ ---
5
+
6
+ # Angular testing
7
+
8
+ Test behavior users and callers rely on.
9
+
10
+ ## Scope
11
+
12
+ Use plain unit tests for pure functions and services. Use component tests for rendered behavior,
13
+ inputs, outputs, and template interaction. Use E2E tests for routing, browser integration, and
14
+ critical user flows.
15
+
16
+ ## Coupling
17
+
18
+ Avoid tests that depend on private fields, incidental component internals, or exact template
19
+ structure unless that structure is the behavior. Prefer user-visible queries and meaningful state.
20
+
21
+ ## Modern APIs
22
+
23
+ Use current Angular testing helpers and migrations for standalone components, router tests, and
24
+ signals. Keep setup small so failures point at behavior, not ceremony.
@@ -0,0 +1,29 @@
1
+ ---
2
+ name: api-design
3
+ description: Design small explicit APIs with stable contracts and useful errors.
4
+ ---
5
+
6
+ # API design
7
+
8
+ Treat every public function, command flag, file format, and exported type as a contract.
9
+
10
+ ## Surface
11
+
12
+ Expose the smallest surface that solves the current need. Keep helpers private until a real caller
13
+ appears. Avoid making implementation details part of the contract.
14
+
15
+ ## Behavior
16
+
17
+ Make inputs, outputs, ordering, defaults, and failure modes predictable. If behavior is conditional,
18
+ name the condition directly instead of hiding it behind a vague option.
19
+
20
+ ## Compatibility
21
+
22
+ When changing an existing contract, look for callers, tests, generated artifacts, and docs. Decide
23
+ whether compatibility matters for the version you are working on, then migrate the whole surface
24
+ consistently.
25
+
26
+ ## Errors
27
+
28
+ Errors are part of the API. Give expected failures stable types or codes, clear messages, and enough
29
+ context for the caller to recover.