@usepipr/sdk 0.4.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/config-CpCLnuAf.mjs +118 -0
- package/dist/config-CpCLnuAf.mjs.map +1 -0
- package/dist/{index-D_XmBHeL.d.mts → index-Bdey1nho.d.mts} +191 -60
- package/dist/index-Bdey1nho.d.mts.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +326 -71
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.mts +35 -8
- package/dist/internal.d.mts.map +1 -1
- package/dist/internal.mjs +2 -2
- package/dist/internal.mjs.map +1 -1
- package/package.json +3 -2
- package/dist/config-Ct0Qfa_b.mjs +0 -56
- package/dist/config-Ct0Qfa_b.mjs.map +0 -1
- package/dist/index-D_XmBHeL.d.mts.map +0 -1
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["z","z","coreReviewResultSchema","coreReviewSummarySchema","z"],"sources":["../src/prompt.ts","../src/review-contract.ts","../src/schema.ts","../src/types/task.ts","../src/builder.ts"],"sourcesContent":["import type { Markdown } from \"./types/prompt.js\";\n\n/** Creates trimmed Markdown from a template literal with common indentation removed. */\nexport function md(strings: TemplateStringsArray, ...values: unknown[]): Markdown {\n let text = \"\";\n for (let index = 0; index < strings.length; index += 1) {\n text += strings[index] ?? \"\";\n if (index < values.length) {\n text += String(values[index] ?? \"\");\n }\n }\n return stripCommonIndent(text).trim();\n}\n\n/** Removes common leading indentation from multiline text. */\nexport function stripCommonIndent(value: string): string {\n const lines = value.replaceAll(\"\\t\", \" \").split(/\\r?\\n/);\n const nonEmpty = lines.filter((line) => line.trim().length > 0);\n const indent = Math.min(...nonEmpty.map((line) => line.match(/^ */)?.[0].length ?? 0));\n return lines.map((line) => line.slice(indent)).join(\"\\n\");\n}\n","import { z } from \"zod\";\nimport type { ZodSchema } from \"./types/schema.js\";\n\n/** Markdown summary produced by a reviewer for the main review comment. */\nexport type ReviewSummary = {\n title?: string;\n body: string;\n};\n\n/** One inline review finding targeting a Diff Manifest commentable range. */\nexport type ReviewFinding = {\n body: string;\n path: string;\n rangeId: string;\n side: \"RIGHT\" | \"LEFT\";\n startLine: number;\n endLine: number;\n suggestedFix?: string;\n};\n\n/** Core structured review result accepted by pipr review publication. */\nexport type ReviewResult = {\n summary: ReviewSummary;\n inlineFindings: ReviewFinding[];\n};\n\nconst nonEmptyStringSchema = z.string().min(1);\nconst positiveIntegerSchema = z.number().int().positive();\n/** Zod schema for a review summary. */\nexport const reviewSummarySchema: ZodSchema<ReviewSummary> = z.strictObject({\n title: nonEmptyStringSchema.optional(),\n body: nonEmptyStringSchema,\n});\n\n/** Zod schema for one inline review finding. */\nexport const reviewFindingSchema: ZodSchema<ReviewFinding> = z.strictObject({\n body: nonEmptyStringSchema,\n path: nonEmptyStringSchema,\n rangeId: nonEmptyStringSchema,\n side: z.enum([\"RIGHT\", \"LEFT\"]),\n startLine: positiveIntegerSchema,\n endLine: positiveIntegerSchema,\n suggestedFix: nonEmptyStringSchema.optional(),\n});\n\n/** Zod schema for Pipr's core change request review result. */\nexport const reviewResultSchema: ZodSchema<ReviewResult> = z.strictObject({\n summary: reviewSummarySchema,\n inlineFindings: z.array(reviewFindingSchema),\n});\n\n/** Parses model output for Pipr's main change request review schema. */\nexport function parseReviewResult(value: unknown): ReviewResult {\n return reviewResultSchema.parse(value) as ReviewResult;\n}\n\n/** Parses a review summary value. */\nexport function parseReviewSummary(value: unknown): ReviewSummary {\n return reviewSummarySchema.parse(value);\n}\n\n/** Parses one inline review finding. */\nexport function parseReviewFinding(value: unknown): ReviewFinding {\n return reviewFindingSchema.parse(value) as ReviewFinding;\n}\n\n/** Returns a small valid example for the main change request review schema. */\nexport function reviewSchemaExample(): ReviewResult {\n return {\n summary: {\n title: \"Optional concise review title.\",\n body: \"Concise change request review summary.\",\n },\n inlineFindings: [\n {\n body: \"Specific issue and why it matters.\",\n path: \"src/example.ts\",\n rangeId: \"rng_example\",\n side: \"RIGHT\",\n startLine: 1,\n endLine: 1,\n suggestedFix: \"return safeValue;\",\n },\n ],\n };\n}\n","import { z } from \"zod\";\nimport type { ReviewResult, ReviewSummary } from \"./review-contract.js\";\nimport {\n reviewResultSchema as coreReviewResultSchema,\n reviewSummarySchema as coreReviewSummarySchema,\n} from \"./review-contract.js\";\nimport type { BuiltinSchemaCatalog } from \"./types/agent.js\";\nimport type {\n JsonSchema,\n JsonSchemaDefinition,\n Schema,\n SchemaDefinition,\n ZodSchema,\n} from \"./types/schema.js\";\n\nconst coreReviewOutputSchemaId = \"core/pr-review\";\n\n/** Defines a typed schema from a Zod schema. */\nexport function schema<T>(definition: SchemaDefinition<T>): Schema<T> {\n if (!definition || typeof definition.id !== \"string\") {\n throw new Error(\"pipr.schema requires { id, schema }\");\n }\n assertUserSchemaId(definition.id);\n return createZodSchema(definition.id, definition.schema);\n}\n\n/** Defines a typed schema from JSON Schema. The generic type is caller supplied. */\nexport function jsonSchema<T>(definition: JsonSchemaDefinition): Schema<T> {\n if (!definition || typeof definition.id !== \"string\") {\n throw new Error(\"pipr.jsonSchema requires { id, schema }\");\n }\n assertUserSchemaId(definition.id);\n const zodSchema = z.fromJSONSchema(definition.schema);\n return createSchema(definition.id, (value) => zodSchema.parse(value) as T, definition.schema);\n}\n\n/** Built-in schemas available as reusable agent output contracts. */\nexport const schemas: BuiltinSchemaCatalog = {\n review: createZodSchema<ReviewResult>(coreReviewOutputSchemaId, coreReviewResultSchema),\n summary: createZodSchema<ReviewSummary>(\"core/summary\", coreReviewSummarySchema),\n};\n\nfunction createSchema<T>(\n id: string,\n parseValue: (value: unknown) => T,\n schemaJson?: JsonSchema,\n): Schema<T> {\n return {\n kind: \"pipr.schema\",\n id,\n jsonSchema: schemaJson,\n parse(value) {\n return parseValue(value);\n },\n safeParse(value) {\n try {\n return { success: true, data: parseValue(value) };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error : new Error(String(error)),\n };\n }\n },\n };\n}\n\nfunction createZodSchema<T>(id: string, zodSchema: ZodSchema<T>): Schema<T> {\n return createSchema(id, (value) => zodSchema.parse(value), jsonSchemaFromZod(id, zodSchema));\n}\n\nfunction assertUserSchemaId(id: string): void {\n if (id.startsWith(\"core/\")) {\n throw new Error(`Schema id '${id}' uses the reserved core/ namespace`);\n }\n}\n\nfunction jsonSchemaFromZod<T>(id: string, schemaDefinition: ZodSchema<T>): JsonSchema {\n try {\n return z.toJSONSchema(schemaDefinition) as JsonSchema;\n } catch (error) {\n const detail = error instanceof Error ? error.message : String(error);\n throw new Error(\n `Schema '${id}' could not be converted to JSON Schema. Use JSON-Schema-representable Zod or pipr.jsonSchema<T>(). ${detail}`,\n );\n }\n}\n","import type { ReviewFinding, ReviewResult } from \"../review-contract.js\";\nimport type {\n Agent,\n AgentDefinition,\n AgentPromptContext,\n AgentTool,\n BuiltinSchemaCatalog,\n BuiltinToolCatalog,\n} from \"./agent.js\";\nimport type {\n ChangeRequestAction,\n DurationInput,\n ModelOptions,\n ModelProfile,\n PiprConfigOptions,\n RepositoryPermission,\n SecretOptions,\n SecretRef,\n} from \"./config.js\";\nimport type { DiffManifest, DiffManifestOptions, PathFilter } from \"./manifest.js\";\nimport type {\n JsonPromptOptions,\n Markdown,\n PromptSource,\n PromptText,\n PromptValue,\n} from \"./prompt.js\";\nimport type { JsonSchemaDefinition, Schema, SchemaDefinition } from \"./schema.js\";\n\n/** Final review comment value produced by a task or review recipe. */\nexport type CommentValue =\n | Markdown\n | {\n main?: Markdown;\n inlineFindings?: readonly ReviewFinding[];\n };\n\n/** Prior inline finding persisted by earlier pipr review state. */\nexport type PriorInlineFinding = {\n id: string;\n status: \"open\" | \"resolved\";\n path: string;\n rangeId: string;\n side: \"RIGHT\" | \"LEFT\";\n startLine: number;\n endLine: number;\n};\n\n/** Prior pipr review state available to tasks through `ctx.review.prior()`. */\nexport type PriorReview = {\n main?: Markdown;\n reviewedHeadSha?: string;\n inlineFindings: readonly PriorInlineFinding[];\n};\n\n/** Function run by a task entrypoint. */\nexport type TaskHandler<Input> = (context: TaskContext, input: Input) => void | Promise<void>;\n\n/** Check-run publication options for one task. */\nexport type TaskCheckOptions =\n | false\n | {\n enabled?: boolean;\n name?: string;\n required?: boolean;\n };\n\n/** Definition used to register a task. */\nexport type TaskDefinition<Input> = {\n name: string;\n check?: TaskCheckOptions;\n local?: false;\n run: TaskHandler<Input>;\n};\n\n/** Registered task that can be selected by change-request and command entrypoints. */\nexport type Task<Input = void> = {\n readonly kind: \"pipr.task\";\n readonly name: string;\n readonly check?: TaskCheckOptions;\n readonly local?: false;\n readonly handler: TaskHandler<Input>;\n};\n\n/** Options shared by command registrations. */\nexport type CommandOptions<Input> = {\n permission?: RepositoryPermission;\n description?: string;\n parse?: (arguments_: Record<string, string>) => Input;\n};\n\n/** Definition used to register an `@pipr` command. */\nexport type CommandRegistrationOptions<Input> = CommandOptions<Input> & {\n pattern: string;\n task: Task<Input>;\n};\n\n/** Options for creating a reusable reviewer agent. */\nexport type ReviewerOptions = {\n name?: string;\n model: ModelProfile;\n fallbacks?: ModelProfile[];\n instructions: PromptSource;\n prompt?: (\n input: DefaultReviewInput,\n context: AgentPromptContext,\n ) => PromptSource | Promise<PromptSource>;\n tools?: readonly AgentTool[];\n timeout?: DurationInput;\n};\n\n/** Reviewer agent that emits pipr's core review result. */\nexport type Reviewer = Agent<DefaultReviewInput, ReviewResult>;\n\n/** Entrypoints created by `pipr.review`. */\nexport type ReviewEntrypoints = {\n changeRequest?: readonly ChangeRequestAction[] | false;\n command?:\n | string\n | false\n | {\n pattern?: string;\n permission?: RepositoryPermission;\n description?: string;\n };\n};\n\n/** Default change-request actions used by `pipr.review`. */\nexport const defaultReviewActions = [\n \"opened\",\n \"updated\",\n \"reopened\",\n \"ready\",\n] as const satisfies readonly ChangeRequestAction[];\n\n/** Default change-request and command entrypoints used by `pipr.review`. */\nexport const defaultReviewEntrypoints = {\n changeRequest: defaultReviewActions,\n command: { pattern: \"@pipr review\", permission: \"write\" },\n} as const satisfies ReviewEntrypoints;\n\ntype ReviewRecipeEntrypointOptions = {\n id: string;\n entrypoints?: ReviewEntrypoints;\n comment?:\n | CommentValue\n | ((\n result: ReviewResult,\n context: ReviewCommentContext,\n ) => CommentValue | Promise<CommentValue>);\n check?: TaskCheckOptions;\n timeout?: DurationInput;\n paths?: PathFilter;\n};\n\n/** Options for `pipr.review`, pipr's default review recipe. */\nexport type ReviewRecipeOptions =\n | (ReviewRecipeEntrypointOptions & { reviewer: Reviewer })\n | (ReviewRecipeEntrypointOptions & ReviewerOptions & { reviewer?: undefined });\n\n/** Default input passed to a reviewer created by `pipr.review`. */\nexport type DefaultReviewInput = {\n manifest: DiffManifest;\n change: ChangeRequestInfo;\n};\n\n/** Context passed to a custom review comment renderer. */\nexport type ReviewCommentContext = {\n review: { id: string };\n repository: RepositoryInfo;\n change: ChangeRequestContext;\n platform: PlatformInfo;\n};\n\n/** Plugin installer returned by `definePlugin`. */\nexport type PiprPlugin<Handle> = {\n setup(builder: PiprBuilder): Handle;\n};\n\n/** Definition for a custom tool registered by config or plugins. */\nexport type PluginToolDefinition<Input, Output> = {\n name: string;\n description: string;\n input: Schema<Input>;\n output: Schema<Output>;\n run(options: ToolRunOptions<Input>): Output | Promise<Output>;\n toModelOutput?(output: Output): PromptValue;\n};\n\n/** Runtime input passed to a tool implementation. */\nexport type ToolRunOptions<Input> = {\n input: Input;\n ctx: TaskContext;\n signal?: AbortSignal;\n};\n\n/** Definition used to register a task for change request actions. */\nexport type ChangeRequestRegistrationOptions<Input> = {\n actions: readonly ChangeRequestAction[];\n task: Task<Input>;\n};\n\n/** Handle for reporting task check status from inside a task. */\nexport type CheckHandle = {\n pass(summary?: string): void;\n fail(summary?: string): void;\n neutral(summary?: string): void;\n};\n\n/** Builder API available inside `definePipr`. */\nexport type PiprBuilder = {\n readonly tools: BuiltinToolCatalog;\n readonly schemas: BuiltinSchemaCatalog;\n readonly on: {\n changeRequest<Input = void>(options: ChangeRequestRegistrationOptions<Input>): void;\n };\n secret(options: SecretOptions): SecretRef;\n model(options: ModelOptions): ModelProfile;\n agent<Input, Output>(definition: AgentDefinition<Input, Output>): Agent<Input, Output>;\n task<Input = void>(definition: TaskDefinition<Input>): Task<Input>;\n reviewer(options: ReviewerOptions): Reviewer;\n review(options: ReviewRecipeOptions): void;\n config(options: PiprConfigOptions): void;\n command<Input = void>(options: CommandRegistrationOptions<Input>): void;\n use<Handle>(plugin: PiprPlugin<Handle>): Handle;\n tool<Input, Output>(definition: PluginToolDefinition<Input, Output>): AgentTool<Input, Output>;\n schema<T>(definition: SchemaDefinition<T>): Schema<T>;\n jsonSchema<T>(definition: JsonSchemaDefinition): Schema<T>;\n prompt(strings: TemplateStringsArray, ...values: PromptValue[]): PromptText;\n section(title: string, value: PromptValue): PromptText;\n json(value: unknown, options?: JsonPromptOptions): PromptText;\n};\n\n/** Repository metadata available to tasks and agents. */\nexport type RepositoryInfo = {\n root: string;\n owner?: string;\n name: string;\n defaultBranch?: string;\n remoteUrl?: string;\n};\n\n/** Pull request or change-request metadata available to tasks and agents. */\nexport type ChangeRequestInfo = {\n number?: number;\n title: string;\n description: string;\n url?: string;\n author?: { login: string };\n base: { ref?: string; sha: string };\n head: { ref?: string; sha: string };\n isFork?: boolean;\n};\n\n/** Code hosting platform metadata. */\nexport type PlatformInfo = {\n id: string;\n};\n\n/** Change-request context available inside tasks. */\nexport type ChangeRequestContext = ChangeRequestInfo & {\n diffManifest(options?: DiffManifestOptions): Promise<DiffManifest>;\n changedFiles(): Promise<Array<{ path: string; previousPath?: string; status: string }>>;\n currentHeadSha(): Promise<string>;\n};\n\n/** Runner for invoking Pi agents from tasks. */\nexport type PiRunner = {\n run<Input, Output>(\n agent: Agent<Input, Output>,\n input: Input,\n options?: {\n model?: ModelProfile;\n fallbacks?: ModelProfile[];\n instructions?: PromptSource;\n timeout?: DurationInput;\n paths?: PathFilter;\n },\n ): Promise<Output>;\n};\n\n/** Command context available inside command-triggered tasks. */\nexport type CommandContext = {\n readonly name: string;\n readonly line: string;\n readonly arguments: Record<string, string>;\n reply(markdown: Markdown): Promise<void>;\n};\n\n/** Context object passed to task handlers. */\nexport type TaskContext = {\n /** Stable id for the selected Review Run, not the process attempt. */\n readonly run: { id: string };\n readonly repository: RepositoryInfo;\n readonly change: ChangeRequestContext;\n readonly platform: PlatformInfo;\n readonly pi: PiRunner;\n readonly command?: CommandContext;\n secret(secret: SecretRef): string;\n readonly review: {\n prior(): Promise<PriorReview>;\n };\n readonly check: CheckHandle;\n comment(value: CommentValue): Promise<void>;\n readonly log: {\n info(message: string): void;\n warn(message: string): void;\n error(message: string): void;\n };\n};\n","import { z } from \"zod\";\nimport { assertSupportedCommandRestCapture } from \"./command-grammar.js\";\nimport {\n builtinReadOnlyToolBrand,\n configFactoryBrand,\n type InternalPiprConfigFactory,\n} from \"./internal-contract.js\";\nimport { stripCommonIndent } from \"./prompt.js\";\nimport { renderPromptValue } from \"./prompt-render.js\";\nimport type { ReviewResult } from \"./review-contract.js\";\nimport type { RuntimePlan } from \"./runtime-contract.js\";\nimport { jsonSchema, schema, schemas } from \"./schema.js\";\nimport type { Agent, AgentDefinition, AgentTool, BuiltinToolCatalog } from \"./types/agent.js\";\nimport type {\n AggregateCheckOptions,\n AutoResolveOptions,\n AutoResolveUserRepliesOptions,\n ChangeRequestAction,\n ChecksOptions,\n ModelProfile,\n PiprConfigOptions,\n PublicationOptions,\n} from \"./types/config.js\";\nimport { maxStoredFindingsLimit } from \"./types/config.js\";\nimport type { DiffManifestLimits, RuntimeLimits } from \"./types/manifest.js\";\nimport type { Markdown } from \"./types/prompt.js\";\nimport type {\n CommandOptions,\n CommentValue,\n DefaultReviewInput,\n PiprBuilder,\n PiprPlugin,\n Reviewer,\n ReviewerOptions,\n ReviewRecipeOptions,\n Task,\n} from \"./types/task.js\";\nimport { defaultReviewActions, defaultReviewEntrypoints } from \"./types/task.js\";\n\n/** Defines a synchronous pipr configuration factory. */\nexport function definePipr(configure: (pipr: PiprBuilder) => void): {\n readonly kind: \"pipr.config-factory\";\n} {\n const factory = {\n kind: \"pipr.config-factory\",\n [configFactoryBrand]: true,\n build() {\n const builder = createBuilder();\n const result = configure(builder.api);\n if (\n typeof result === \"object\" &&\n result !== null &&\n typeof Reflect.get(result, \"then\") === \"function\"\n ) {\n throw new Error(\"definePipr configuration callback must be synchronous\");\n }\n return builder.plan();\n },\n } satisfies InternalPiprConfigFactory;\n return factory;\n}\n\n/** Defines a typed pipr plugin installer. */\nexport function definePlugin<Handle>(setup: (builder: PiprBuilder) => Handle): PiprPlugin<Handle> {\n return { setup };\n}\n\nfunction createBuilder(): { api: PiprBuilder; plan(): RuntimePlan } {\n const models: ModelProfile[] = [];\n const agents: Agent[] = [];\n const tasks: Task<unknown>[] = [];\n const changeRequestTriggers: RuntimePlan[\"changeRequestTriggers\"] = [];\n const commands: RuntimePlan[\"commands\"] = [];\n const tools: AgentTool[] = [];\n const publication: RuntimePlan[\"publication\"] = {};\n let checks: ChecksOptions | undefined;\n let limits: RuntimeLimits | undefined;\n\n const api: PiprBuilder = {\n tools: {\n readOnly: [\n {\n kind: \"pipr.tool\",\n name: \"readOnly\",\n [builtinReadOnlyToolBrand]: true,\n } as AgentTool,\n ],\n } satisfies BuiltinToolCatalog,\n schemas,\n on: {\n changeRequest(options) {\n if (!Array.isArray(options.actions) || !options.task) {\n throw new Error(\"pipr.on.changeRequest requires { actions, task }\");\n }\n changeRequestTriggers.push({\n actions: [...options.actions],\n task: options.task as Task<unknown>,\n });\n },\n },\n secret(options) {\n if (!options || typeof options.name !== \"string\") {\n throw new Error(\"pipr.secret requires { name }\");\n }\n if (!/^[A-Z_][A-Z0-9_]*$/.test(options.name)) {\n throw new Error(`Secret '${options.name}' must be an environment variable name`);\n }\n return { kind: \"pipr.secret\", name: options.name };\n },\n model(options) {\n if (!options || typeof options.provider !== \"string\" || typeof options.model !== \"string\") {\n throw new Error(\"pipr.model requires { provider, model }\");\n }\n if (!options.provider || !options.model) {\n throw new Error(\"pipr.model requires provider and model\");\n }\n const id = options.id ?? `${options.provider}/${options.model}`;\n const profile: ModelProfile = {\n kind: \"pipr.model\",\n id,\n provider: options.provider,\n model: options.model,\n apiKey: options.apiKey,\n options: options.options,\n };\n models.push(profile);\n return profile;\n },\n agent(definition) {\n const agent = createAgent(definition);\n agents.push(agent);\n return agent;\n },\n task(definition) {\n if (!definition.name || typeof definition.run !== \"function\") {\n throw new Error(\"pipr.task requires { name, run }\");\n }\n const task = {\n kind: \"pipr.task\" as const,\n name: definition.name,\n check: definition.check,\n ...(definition.local === false ? { local: false as const } : {}),\n handler: definition.run,\n };\n tasks.push(task as Task<unknown>);\n return task;\n },\n reviewer(options) {\n return createReviewer(api, options);\n },\n review(options) {\n assertKnownReviewRecipeOptions(options);\n registerReviewRecipe(api, options);\n },\n config(options) {\n assertKnownPiprConfigOptions(options);\n mergePublicationConfig(publication, options.publication);\n checks = mergeConfigField(\"checks\", checks, options.checks);\n limits = mergeLimits(limits, options.limits);\n },\n command(options) {\n if (typeof options.pattern !== \"string\" || !options.task) {\n throw new Error(\"pipr.command requires { pattern, task }\");\n }\n const pattern = options.pattern;\n const tokens = pattern.trim().split(/\\s+/).filter(Boolean);\n if (tokens.length === 0) {\n throw new Error(\"Command pattern must not be empty\");\n }\n if (tokens[0] !== \"@pipr\") {\n throw new Error(`Command pattern '${pattern}' must start with @pipr`);\n }\n assertSupportedCommandRestCapture(pattern);\n commands.push({\n pattern,\n permission: options.permission ?? \"write\",\n description: options.description,\n parse: options.parse as ((arguments_: Record<string, string>) => unknown) | undefined,\n task: options.task as Task<unknown>,\n });\n },\n use(plugin) {\n return plugin.setup(api);\n },\n tool(definition) {\n if (definition.name === \"readOnly\") {\n throw new Error(\"Tool name 'readOnly' is reserved for pipr built-in tools\");\n }\n const run = definition.run;\n if (!run) {\n throw new Error(`Tool '${definition.name}' must define run`);\n }\n const tool = {\n kind: \"pipr.tool\" as const,\n ...definition,\n run,\n };\n tools.push(tool);\n return tool;\n },\n schema,\n jsonSchema,\n prompt(strings, ...values) {\n let text = \"\";\n for (let index = 0; index < strings.length; index += 1) {\n text += strings[index] ?? \"\";\n if (index < values.length) {\n text += renderPromptValue(values[index]);\n }\n }\n return {\n kind: \"pipr.prompt\",\n value: stripCommonIndent(text).trim(),\n };\n },\n section(title, value) {\n const rendered = renderPromptValue(value);\n return {\n kind: \"pipr.prompt\",\n value: `## ${title}\\n\\n${rendered}`,\n };\n },\n json(value, options) {\n const text = JSON.stringify(value, null, options?.pretty === false ? 0 : 2);\n if (options?.maxCharacters !== undefined && text.length > options.maxCharacters) {\n throw new Error(`JSON prompt value exceeded ${options.maxCharacters} characters`);\n }\n return { kind: \"pipr.prompt\", value: text };\n },\n };\n\n return {\n api,\n plan() {\n assertUnique(\n tasks.map((task) => task.name),\n \"task\",\n );\n assertUnique(\n commands.map((command) => command.pattern),\n \"command\",\n );\n assertModelIdentity(models);\n return {\n models,\n agents,\n tasks,\n changeRequestTriggers,\n commands,\n tools,\n publication,\n checks,\n limits,\n };\n },\n };\n}\n\nfunction registerReviewRecipe(api: PiprBuilder, options: ReviewRecipeOptions): void {\n const id = options.id;\n const agent = options.reviewer ?? createReviewer(api, reviewRecipeReviewerOptions(options, id));\n\n const task = createReviewRecipeTask(api, id, agent, options);\n registerReviewRecipeEntrypoints(api, task, options);\n}\n\nconst reviewRecipeOptionKeys = new Set([\n \"id\",\n \"entrypoints\",\n \"comment\",\n \"check\",\n \"timeout\",\n \"paths\",\n \"reviewer\",\n \"name\",\n \"model\",\n \"fallbacks\",\n \"instructions\",\n \"prompt\",\n \"tools\",\n]);\n\nconst reviewRecipeEntrypointKeys = new Set([\"changeRequest\", \"command\"]);\n\nconst modelProfileConfigSchema: z.ZodType<ModelProfile> = z.custom<ModelProfile>(\n (value) =>\n typeof value === \"object\" &&\n value !== null &&\n (value as { kind?: unknown }).kind === \"pipr.model\" &&\n typeof (value as { id?: unknown }).id === \"string\" &&\n typeof (value as { provider?: unknown }).provider === \"string\" &&\n typeof (value as { model?: unknown }).model === \"string\",\n);\n\nconst autoResolveUserRepliesOptionsSchema: z.ZodType<AutoResolveUserRepliesOptions> =\n z.strictObject({\n enabled: z.boolean().optional(),\n respondWhenStillValid: z.boolean().optional(),\n allowedActors: z.enum([\"author-or-write\", \"write\", \"any\"]).optional(),\n });\n\nconst autoResolveOptionsSchema: z.ZodType<AutoResolveOptions> = z.union([\n z.literal(false),\n z.strictObject({\n enabled: z.boolean().optional(),\n model: modelProfileConfigSchema.optional(),\n instructions: z.string().min(1).max(4000).optional(),\n synchronize: z.boolean().optional(),\n userReplies: z.union([z.boolean(), autoResolveUserRepliesOptionsSchema]).optional(),\n }),\n]);\n\nconst publicationOptionsSchema: z.ZodType<PublicationOptions> = z.strictObject({\n maxInlineComments: z.number().int().min(0).max(50).optional(),\n maxStoredFindings: z.number().int().min(0).max(maxStoredFindingsLimit).optional(),\n autoResolve: autoResolveOptionsSchema.optional(),\n showHeader: z.boolean().optional(),\n showFooter: z.boolean().optional(),\n showStats: z.boolean().optional(),\n});\n\nconst aggregateCheckOptionsSchema: z.ZodType<AggregateCheckOptions> = z.union([\n z.literal(false),\n z.strictObject({\n enabled: z.boolean().optional(),\n name: z.string().min(1).optional(),\n }),\n]);\n\nconst checksOptionsSchema: z.ZodType<ChecksOptions> = z.strictObject({\n aggregate: aggregateCheckOptionsSchema.optional(),\n});\n\nconst diffManifestLimitsSchema: z.ZodType<DiffManifestLimits> = z.strictObject({\n fullMaxBytes: z.number().int().positive().optional(),\n fullMaxEstimatedTokens: z.number().int().positive().optional(),\n condensedMaxBytes: z.number().int().positive().optional(),\n condensedMaxEstimatedTokens: z.number().int().positive().optional(),\n toolResponseMaxBytes: z.number().int().positive().optional(),\n});\n\nconst runtimeLimitsSchema: z.ZodType<RuntimeLimits> = z.strictObject({\n timeoutSeconds: z.number().int().positive().max(3600).optional(),\n diffManifest: diffManifestLimitsSchema.optional(),\n});\n\nconst piprConfigOptionsSchema: z.ZodType<PiprConfigOptions> = z.strictObject({\n publication: publicationOptionsSchema.optional(),\n checks: checksOptionsSchema.optional(),\n limits: runtimeLimitsSchema.optional(),\n});\n\nfunction assertKnownReviewRecipeOptions(options: ReviewRecipeOptions): void {\n const unknownKeys = Object.keys(options).filter((key) => !reviewRecipeOptionKeys.has(key));\n if (unknownKeys.length > 0) {\n throw new Error(`pipr.review received unsupported option fields: ${unknownKeys.join(\", \")}.`);\n }\n\n const entrypoints = options.entrypoints;\n if (entrypoints && typeof entrypoints === \"object\") {\n const unknownEntrypointKeys = Object.keys(entrypoints).filter(\n (key) => !reviewRecipeEntrypointKeys.has(key),\n );\n if (unknownEntrypointKeys.length > 0) {\n throw new Error(\n `pipr.review entrypoints received unsupported fields: ${unknownEntrypointKeys.join(\", \")}.`,\n );\n }\n }\n}\n\nfunction assertKnownPiprConfigOptions(options: unknown): asserts options is PiprConfigOptions {\n const parsed = piprConfigOptionsSchema.safeParse(options);\n if (!parsed.success) {\n throw new Error(formatPiprConfigOptionsError(parsed.error));\n }\n}\n\nfunction formatPiprConfigOptionsError(error: z.ZodError): string {\n const unsupportedFields = firstUnsupportedConfigFields(error.issues, []);\n if (unsupportedFields) {\n return `${piprConfigLabel(unsupportedFields.path)} received unsupported option fields: ${unsupportedFields.keys.join(\n \", \",\n )}`;\n }\n return `pipr.config received invalid option value: ${z.prettifyError(error)}`;\n}\n\nfunction firstUnsupportedConfigFields(\n issues: readonly z.ZodIssue[],\n parentPath: readonly PropertyKey[],\n): { path: PropertyKey[]; keys: string[] } | undefined {\n for (const issue of issues) {\n const path = [...parentPath, ...issue.path];\n if (issue.code === \"unrecognized_keys\") {\n return { path, keys: issue.keys };\n }\n if (issue.code === \"invalid_union\") {\n for (const branchIssues of issue.errors) {\n const unsupportedFields = firstUnsupportedConfigFields(branchIssues, path);\n if (unsupportedFields) {\n return unsupportedFields;\n }\n }\n }\n }\n return undefined;\n}\n\nfunction piprConfigLabel(pathSegments: PropertyKey[]): string {\n const path = pathSegments.join(\".\");\n return path ? `pipr.config ${path}` : \"pipr.config\";\n}\n\nfunction reviewRecipeReviewerOptions(options: ReviewerOptions, name: string): ReviewerOptions {\n if (!options.model || !options.instructions) {\n throw new Error(\"pipr.review requires model and instructions when reviewer is not provided\");\n }\n return {\n name,\n model: options.model,\n fallbacks: options.fallbacks,\n instructions: options.instructions,\n prompt: options.prompt,\n tools: options.tools,\n timeout: options.timeout,\n };\n}\n\nfunction createReviewer(api: PiprBuilder, options: ReviewerOptions): Reviewer {\n return api.agent<DefaultReviewInput, ReviewResult>({\n name: options.name ?? \"reviewer\",\n model: options.model,\n fallbacks: options.fallbacks,\n instructions: options.instructions,\n tools: options.tools ?? api.tools.readOnly,\n output: api.schemas.review,\n timeout: options.timeout,\n prompt:\n options.prompt ??\n (() =>\n api.prompt`\n Review this change.\n `),\n });\n}\n\nfunction createReviewRecipeTask(\n api: PiprBuilder,\n id: string,\n agent: Agent<DefaultReviewInput, ReviewResult>,\n options: ReviewRecipeOptions,\n): Task {\n return api.task({\n name: id,\n check: options.check,\n async run(context) {\n const manifest = await context.change.diffManifest({\n compressed: true,\n paths: options.paths,\n });\n if (options.paths && manifest.files.length === 0) {\n context.check.neutral(\"No changed files matched this review's path scope.\");\n await context.comment({ main: \"No changed files matched this review's path scope.\" });\n return;\n }\n const result = await context.pi.run(\n agent,\n { manifest, change: context.change },\n {\n timeout: options.timeout,\n paths: options.paths,\n },\n );\n const source =\n typeof options.comment === \"function\"\n ? await options.comment(result, {\n review: { id },\n repository: context.repository,\n change: context.change,\n platform: context.platform,\n })\n : (options.comment ?? defaultReviewComment(result));\n await context.comment(source);\n },\n });\n}\n\nfunction defaultReviewComment(result: ReviewResult): CommentValue {\n return {\n main: defaultReviewMarkdown(result),\n inlineFindings: result.inlineFindings,\n };\n}\n\nfunction defaultReviewMarkdown(result: ReviewResult): Markdown {\n const findings =\n result.inlineFindings.length === 0\n ? \"No inline findings.\"\n : result.inlineFindings.map((finding) => `- ${finding.body}`).join(\"\\n\");\n return `## Summary\\n\\n${result.summary.body}\\n\\n## Findings\\n\\n${findings}`;\n}\n\nfunction registerReviewRecipeEntrypoints(\n api: PiprBuilder,\n task: Task,\n options: ReviewRecipeOptions,\n): void {\n const changeRequest = reviewChangeRequestEntrypoint(options);\n if (changeRequest) {\n api.on.changeRequest({ actions: changeRequest, task });\n }\n const command = reviewCommandEntrypoint(options);\n if (command) {\n api.command({ pattern: command.pattern, ...command.options, task });\n }\n}\n\nfunction reviewChangeRequestEntrypoint(\n options: ReviewRecipeOptions,\n): readonly ChangeRequestAction[] | undefined {\n const entrypoint = options.entrypoints?.changeRequest;\n return entrypoint === false ? undefined : (entrypoint ?? defaultReviewActions);\n}\n\nfunction reviewCommandEntrypoint(options: ReviewRecipeOptions):\n | {\n pattern: string;\n options: CommandOptions<unknown>;\n }\n | undefined {\n const entrypoint = options.entrypoints?.command;\n if (entrypoint === false) {\n return undefined;\n }\n if (typeof entrypoint === \"object\") {\n return {\n pattern: entrypoint.pattern ?? defaultReviewEntrypoints.command.pattern,\n options: {\n permission: entrypoint.permission ?? defaultReviewEntrypoints.command.permission,\n description: entrypoint.description,\n },\n };\n }\n return {\n pattern: entrypoint ?? defaultReviewEntrypoints.command.pattern,\n options: { permission: defaultReviewEntrypoints.command.permission },\n };\n}\n\nfunction mergePublicationConfig(\n target: RuntimePlan[\"publication\"],\n next: PublicationOptions | undefined,\n): void {\n if (!next) {\n return;\n }\n target.maxInlineComments = mergeConfigField(\n \"publication.maxInlineComments\",\n target.maxInlineComments,\n next.maxInlineComments,\n );\n target.maxStoredFindings = mergeConfigField(\n \"publication.maxStoredFindings\",\n target.maxStoredFindings,\n next.maxStoredFindings,\n );\n target.autoResolve = mergeConfigField(\n \"publication.autoResolve\",\n target.autoResolve,\n next.autoResolve,\n );\n target.showHeader = mergeConfigField(\n \"publication.showHeader\",\n target.showHeader,\n next.showHeader,\n );\n target.showFooter = mergeConfigField(\n \"publication.showFooter\",\n target.showFooter,\n next.showFooter,\n );\n target.showStats = mergeConfigField(\"publication.showStats\", target.showStats, next.showStats);\n}\n\nfunction mergeConfigField<T>(\n name: string,\n current: T | undefined,\n next: T | undefined,\n): T | undefined {\n if (next === undefined) {\n return current;\n }\n if (current !== undefined && stableJson(current) !== stableJson(next)) {\n throw new Error(`pipr.config ${name} conflicts with existing value`);\n }\n return next;\n}\n\nfunction mergeLimits(current: RuntimeLimits | undefined, next: RuntimeLimits | undefined) {\n if (!next) {\n return current;\n }\n assertRuntimeLimitConflicts(current, next);\n return {\n ...current,\n ...next,\n diffManifest:\n (next.diffManifest ?? current?.diffManifest)\n ? { ...current?.diffManifest, ...next.diffManifest }\n : undefined,\n };\n}\n\nfunction assertRuntimeLimitConflicts(\n current: RuntimeLimits | undefined,\n next: RuntimeLimits,\n): void {\n const currentRecord = current as Record<string, unknown> | undefined;\n for (const [key, value] of Object.entries(next)) {\n if (key === \"diffManifest\") {\n continue;\n }\n if (\n value !== undefined &&\n currentRecord?.[key] !== undefined &&\n stableJson(currentRecord[key]) !== stableJson(value)\n ) {\n throw new Error(`pipr.config limits.${key} conflicts with existing value`);\n }\n }\n assertDiffManifestLimitConflicts(current, next);\n}\n\nfunction assertDiffManifestLimitConflicts(\n current: RuntimeLimits | undefined,\n next: RuntimeLimits,\n): void {\n if (current?.diffManifest && next.diffManifest) {\n for (const [key, value] of Object.entries(next.diffManifest)) {\n if (\n value !== undefined &&\n (current.diffManifest as Record<string, unknown>)[key] !== undefined &&\n (current.diffManifest as Record<string, unknown>)[key] !== value\n ) {\n throw new Error(`pipr.config limits.diffManifest.${key} conflicts with existing value`);\n }\n }\n }\n}\n\nfunction createAgent<Input, Output>(\n definition: AgentDefinition<Input, Output>,\n): Agent<Input, Output> {\n return {\n kind: \"pipr.agent\",\n name: definition.name,\n definition,\n extend(patch) {\n return createAgent({\n ...definition,\n ...patch,\n instructions:\n patch.instructions === undefined\n ? definition.instructions\n : {\n kind: \"pipr.prompt\",\n value:\n `${renderPromptValue(definition.instructions)}\\n\\n${renderPromptValue(patch.instructions)}`.trim(),\n },\n });\n },\n };\n}\n\nfunction assertUnique(values: string[], label: string): void {\n const seen = new Set<string>();\n for (const value of values) {\n if (seen.has(value)) {\n throw new Error(`Duplicate ${label} '${value}'`);\n }\n seen.add(value);\n }\n}\n\nfunction assertModelIdentity(models: ModelProfile[]): void {\n assertNoDuplicateModelConfigs(models);\n assertUniqueModelIds(models);\n assertProviderModelAliasesDisambiguated(models);\n}\n\nfunction assertNoDuplicateModelConfigs(models: ModelProfile[]): void {\n const effectiveConfigs = new Map<string, string>();\n for (const model of models) {\n const effectiveConfig = stableJson({\n provider: model.provider,\n model: model.model,\n apiKeyEnv: model.apiKey?.name,\n options: model.options,\n });\n const existingConfigId = effectiveConfigs.get(effectiveConfig);\n if (existingConfigId) {\n throw new Error(\n `Duplicate model config for '${model.id}'. Reuse model '${existingConfigId}' instead.`,\n );\n }\n effectiveConfigs.set(effectiveConfig, model.id);\n }\n}\n\nfunction assertUniqueModelIds(models: ModelProfile[]): void {\n const ids = new Set<string>();\n for (const model of models) {\n if (ids.has(model.id)) {\n const providerModel = `${model.provider}/${model.model}`;\n throw new Error(\n model.id === providerModel\n ? `Model '${providerModel}' is configured more than once with different options. Add an explicit id.`\n : `Duplicate model id '${model.id}'`,\n );\n }\n ids.add(model.id);\n }\n}\n\nfunction assertProviderModelAliasesDisambiguated(models: ModelProfile[]): void {\n const providerModels = new Map<string, string>();\n for (const model of models) {\n const providerModel = `${model.provider}/${model.model}`;\n const existingProviderModelId = providerModels.get(providerModel);\n if (\n existingProviderModelId &&\n (model.id === providerModel || existingProviderModelId === providerModel)\n ) {\n throw new Error(\n `Model '${providerModel}' is configured more than once with different options. Add an explicit id.`,\n );\n }\n providerModels.set(providerModel, model.id);\n }\n}\n\nfunction stableJson(value: unknown): string {\n return JSON.stringify(stableJsonValue(value));\n}\n\nfunction stableJsonValue(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(stableJsonValue);\n }\n if (typeof value === \"object\" && value !== null) {\n return Object.fromEntries(\n Object.entries(value as Record<string, unknown>)\n .filter(([, item]) => item !== undefined)\n .toSorted(([left], [right]) => left.localeCompare(right))\n .map(([key, item]) => [key, stableJsonValue(item)]),\n );\n }\n return value;\n}\n"],"mappings":";;;;AAGA,SAAgB,GAAG,SAA+B,GAAG,QAA6B;CAChF,IAAI,OAAO;CACX,KAAK,IAAI,QAAQ,GAAG,QAAQ,QAAQ,QAAQ,SAAS,GAAG;EACtD,QAAQ,QAAQ,UAAU;EAC1B,IAAI,QAAQ,OAAO,QACjB,QAAQ,OAAO,OAAO,UAAU,EAAE;CAEtC;CACA,OAAO,kBAAkB,IAAI,CAAC,CAAC,KAAK;AACtC;;AAGA,SAAgB,kBAAkB,OAAuB;CACvD,MAAM,QAAQ,MAAM,WAAW,KAAM,IAAI,CAAC,CAAC,MAAM,OAAO;CACxD,MAAM,WAAW,MAAM,QAAQ,SAAS,KAAK,KAAK,CAAC,CAAC,SAAS,CAAC;CAC9D,MAAM,SAAS,KAAK,IAAI,GAAG,SAAS,KAAK,SAAS,KAAK,MAAM,KAAK,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC;CACrF,OAAO,MAAM,KAAK,SAAS,KAAK,MAAM,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI;AAC1D;;;ACMA,MAAM,uBAAuBA,IAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AAC7C,MAAM,wBAAwBA,IAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;;AAExD,MAAa,sBAAgDA,IAAE,aAAa;CAC1E,OAAO,qBAAqB,SAAS;CACrC,MAAM;AACR,CAAC;;AAGD,MAAa,sBAAgDA,IAAE,aAAa;CAC1E,MAAM;CACN,MAAM;CACN,SAAS;CACT,MAAMA,IAAE,KAAK,CAAC,SAAS,MAAM,CAAC;CAC9B,WAAW;CACX,SAAS;CACT,cAAc,qBAAqB,SAAS;AAC9C,CAAC;;AAGD,MAAa,qBA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M,gBAAgB,GAAG,MAAM,SAAS,GAAG,MAAM;EACjD,MAAM,0BAA0B,eAAe,IAAI,aAAa;EAChE,IACE,4BACC,MAAM,OAAO,iBAAiB,4BAA4B,gBAE3D,MAAM,IAAI,MACR,UAAU,cAAc,2EAC1B;EAEF,eAAe,IAAI,eAAe,MAAM,EAAE;CAC5C;AACF;AAEA,SAAS,WAAW,OAAwB;CAC1C,OAAO,KAAK,UAAU,gBAAgB,KAAK,CAAC;AAC9C;AAEA,SAAS,gBAAgB,OAAyB;CAChD,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,IAAI,eAAe;CAElC,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO,OAAO,YACZ,OAAO,QAAQ,KAAgC,CAAC,CAC7C,QAAQ,GAAG,UAAU,SAAS,KAAA,CAAS,CAAC,CACxC,UAAU,CAAC,OAAO,CAAC,WAAW,KAAK,cAAc,KAAK,CAAC,CAAC,CACxD,KAAK,CAAC,KAAK,UAAU,CAAC,KAAK,gBAAgB,IAAI,CAAC,CAAC,CACtD;CAEF,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["z","z","coreReviewFindingsResultSchema","coreReviewResultSchema","coreReviewSummarySchema","z","z","schemas"],"sources":["../src/prompt.ts","../src/runtime-handles.ts","../src/review-contract.ts","../src/schema.ts","../src/types/task.ts","../src/builder.ts","../src/result.ts"],"sourcesContent":["import type { Markdown } from \"./types/prompt.js\";\n\n/** Creates trimmed Markdown from a template literal with common indentation removed. */\nexport function md(strings: TemplateStringsArray, ...values: unknown[]): Markdown {\n let text = \"\";\n for (let index = 0; index < strings.length; index += 1) {\n text += strings[index] ?? \"\";\n if (index < values.length) {\n text += String(values[index] ?? \"\");\n }\n }\n return stripCommonIndent(text).trim();\n}\n\n/** Removes common leading indentation from multiline text. */\nexport function stripCommonIndent(value: string): string {\n const lines = value.replaceAll(\"\\t\", \" \").split(/\\r?\\n/);\n const nonEmpty = lines.filter((line) => line.trim().length > 0);\n const indent = Math.min(...nonEmpty.map((line) => line.match(/^ */)?.[0].length ?? 0));\n return lines.map((line) => line.slice(indent)).join(\"\\n\");\n}\n","import { renderPromptValue } from \"./prompt-render.js\";\nimport type {\n RuntimeAgent,\n RuntimeAgentDefinition,\n RuntimeAgentTool,\n RuntimeTask,\n} from \"./runtime-contract.js\";\nimport type { Agent, AgentDefinition, AgentTool } from \"./types/agent.js\";\nimport type { PluginToolDefinition, Task, TaskDefinition } from \"./types/task.js\";\n\nconst taskRecords = new WeakMap<object, RuntimeTask>();\nconst agentRecords = new WeakMap<object, RuntimeAgent>();\nconst toolRecords = new WeakMap<object, RuntimeAgentTool>();\n\nexport function createTaskHandle<Input>(definition: TaskDefinition<Input>): {\n handle: Task<Input>;\n record: RuntimeTask;\n} {\n const handle = { kind: \"pipr.task\", name: definition.name } as Task<Input>;\n const record: RuntimeTask = {\n name: definition.name,\n check: definition.check,\n ...(definition.local === false ? { local: false } : {}),\n handler: definition.run as RuntimeTask[\"handler\"],\n };\n taskRecords.set(handle, record);\n return { handle, record };\n}\n\nexport function runtimeTaskForHandle<Input>(task: Task<Input>): RuntimeTask {\n const record = taskRecords.get(task);\n if (!record) {\n throw new Error(\"Expected a task handle created by pipr.task\");\n }\n return record;\n}\n\nexport function createAgentHandle<Input, Output>(\n definition: AgentDefinition<Input, Output>,\n): { handle: Agent<Input, Output>; record: RuntimeAgent } {\n const handle = {\n kind: \"pipr.agent\",\n name: definition.name,\n extend(patch) {\n return createAgentHandle({\n ...definition,\n ...patch,\n instructions:\n patch.instructions === undefined\n ? definition.instructions\n : {\n kind: \"pipr.prompt\",\n value:\n `${renderPromptValue(definition.instructions)}\\n\\n${renderPromptValue(patch.instructions)}`.trim(),\n },\n }).handle;\n },\n } as Agent<Input, Output>;\n const record: RuntimeAgent = {\n name: definition.name,\n definition: runtimeAgentDefinition(definition),\n };\n agentRecords.set(handle, record);\n return { handle, record };\n}\n\nexport function runtimeAgentForHandle<Input, Output>(agent: Agent<Input, Output>): RuntimeAgent {\n const record = agentRecords.get(agent);\n if (!record) {\n throw new Error(\"Expected an agent handle created by pipr.agent\");\n }\n return record;\n}\n\nexport function createToolHandle<Input, Output>(\n definition: PluginToolDefinition<Input, Output>,\n): { handle: AgentTool<Input, Output>; record: RuntimeAgentTool } {\n const handle = { kind: \"pipr.tool\", name: definition.name } as AgentTool<Input, Output>;\n const record = {\n name: definition.name,\n description: definition.description,\n input: definition.input,\n output: definition.output,\n run: definition.run,\n toModelOutput: definition.toModelOutput,\n } as RuntimeAgentTool;\n toolRecords.set(handle, record);\n return { handle, record };\n}\n\nexport function createBuiltinReadOnlyToolHandle(): {\n handle: AgentTool;\n record: RuntimeAgentTool;\n} {\n const handle = { kind: \"pipr.tool\", name: \"readOnly\" } as AgentTool;\n const record = { name: \"readOnly\", builtinReadOnly: true } satisfies RuntimeAgentTool;\n toolRecords.set(handle, record);\n return { handle, record };\n}\n\nfunction runtimeToolForHandle(tool: AgentTool): RuntimeAgentTool {\n const record = toolRecords.get(tool);\n if (!record) {\n throw new Error(\"Expected a tool handle created by pipr.tool\");\n }\n return record;\n}\n\nfunction runtimeAgentDefinition<Input, Output>(\n definition: AgentDefinition<Input, Output>,\n): RuntimeAgentDefinition {\n return {\n ...definition,\n prompt: definition.prompt as RuntimeAgentDefinition[\"prompt\"],\n output: definition.output as RuntimeAgentDefinition[\"output\"],\n tools: definition.tools?.map(runtimeToolForHandle),\n };\n}\n","import { z } from \"zod\";\nimport type { ZodSchema } from \"./types/schema.js\";\n\n/** Markdown summary produced by a reviewer for the main review comment. */\nexport type ReviewSummary = {\n title?: string;\n body: string;\n};\n\n/** One inline review finding targeting a Diff Manifest commentable range. */\nexport type ReviewFinding = {\n body: string;\n path: string;\n rangeId: string;\n side: \"RIGHT\" | \"LEFT\";\n startLine: number;\n endLine: number;\n suggestedFix?: string;\n};\n\n/** Core structured collection of inline findings produced by a review agent. */\nexport type ReviewFindingsResult = {\n inlineFindings: ReviewFinding[];\n};\n\n/** Core structured review result accepted by pipr review publication. */\nexport type ReviewResult = ReviewFindingsResult & {\n summary: ReviewSummary;\n};\n\nconst nonEmptyStringSchema = z.string().min(1);\nconst positiveIntegerSchema = z.number().int().positive();\n/** Zod schema for a review summary. */\nexport const reviewSummarySchema: ZodSchema<ReviewSummary> = z.strictObject({\n title: nonEmptyStringSchema.optional(),\n body: nonEmptyStringSchema,\n});\n\n/** Zod schema for one inline review finding. */\nexport const reviewFindingSchema: ZodSchema<ReviewFinding> = z.strictObject({\n body: nonEmptyStringSchema,\n path: nonEmptyStringSchema,\n rangeId: nonEmptyStringSchema,\n side: z.enum([\"RIGHT\", \"LEFT\"]),\n startLine: positiveIntegerSchema,\n endLine: positiveIntegerSchema,\n suggestedFix: nonEmptyStringSchema.optional(),\n});\n\n/** Zod schema for Pipr's core inline-finding result. */\nexport const reviewFindingsResultSchema: ZodSchema<ReviewFindingsResult> = z.strictObject({\n inlineFindings: z.array(reviewFindingSchema),\n});\n\n/** Zod schema for Pipr's core change request review result. */\nexport const reviewResultSchema: ZodSchema<ReviewResult> = z.strictObject({\n summary: reviewSummarySchema,\n inlineFindings: z.array(reviewFindingSchema),\n});\n\n/** Parses model output for Pipr's main change request review schema. */\nexport function parseReviewResult(value: unknown): ReviewResult {\n return reviewResultSchema.parse(value) as ReviewResult;\n}\n\n/** Parses model output for Pipr's inline-finding schema. */\nexport function parseReviewFindingsResult(value: unknown): ReviewFindingsResult {\n return reviewFindingsResultSchema.parse(value) as ReviewFindingsResult;\n}\n\n/** Parses a review summary value. */\nexport function parseReviewSummary(value: unknown): ReviewSummary {\n return reviewSummarySchema.parse(value);\n}\n\n/** Parses one inline review finding. */\nexport function parseReviewFinding(value: unknown): ReviewFinding {\n return reviewFindingSchema.parse(value) as ReviewFinding;\n}\n\n/** Returns a small valid example for the main change request review schema. */\nexport function reviewSchemaExample(): ReviewResult {\n return {\n summary: {\n title: \"Optional concise review title.\",\n body: \"Concise change request review summary.\",\n },\n inlineFindings: [\n {\n body: \"Specific issue and why it matters.\",\n path: \"src/example.ts\",\n rangeId: \"rng_example\",\n side: \"RIGHT\",\n startLine: 1,\n endLine: 1,\n suggestedFix: \"return safeValue;\",\n },\n ],\n };\n}\n","import { z } from \"zod\";\nimport type { ReviewFindingsResult, ReviewResult, ReviewSummary } from \"./review-contract.js\";\nimport {\n reviewFindingsResultSchema as coreReviewFindingsResultSchema,\n reviewResultSchema as coreReviewResultSchema,\n reviewSummarySchema as coreReviewSummarySchema,\n} from \"./review-contract.js\";\nimport type { BuiltinSchemaCatalog } from \"./types/agent.js\";\nimport type {\n JsonSchema,\n JsonSchemaDefinition,\n Schema,\n SchemaDefinition,\n ZodSchema,\n} from \"./types/schema.js\";\n\nconst coreReviewOutputSchemaId = \"core/pr-review\";\n\n/** Defines a typed schema from a Zod schema. */\nexport function schema<T>(definition: SchemaDefinition<T>): Schema<T> {\n if (!definition || typeof definition.id !== \"string\") {\n throw new Error(\"pipr.schema requires { id, schema }\");\n }\n assertUserSchemaId(definition.id);\n return createZodSchema(definition.id, definition.schema);\n}\n\n/** Defines a typed schema from JSON Schema. The generic type is caller supplied. */\nexport function jsonSchema<T>(definition: JsonSchemaDefinition): Schema<T> {\n if (!definition || typeof definition.id !== \"string\") {\n throw new Error(\"pipr.jsonSchema requires { id, schema }\");\n }\n assertUserSchemaId(definition.id);\n const zodSchema = z.fromJSONSchema(definition.schema);\n return createSchema(definition.id, (value) => zodSchema.parse(value) as T, definition.schema);\n}\n\n/** Built-in schemas available as reusable agent output contracts. */\nexport const schemas: BuiltinSchemaCatalog = {\n inlineFindings: createZodSchema<ReviewFindingsResult>(\n \"core/inline-findings\",\n coreReviewFindingsResultSchema,\n ),\n review: createZodSchema<ReviewResult>(coreReviewOutputSchemaId, coreReviewResultSchema),\n summary: createZodSchema<ReviewSummary>(\"core/summary\", coreReviewSummarySchema),\n};\n\nfunction createSchema<T>(\n id: string,\n parseValue: (value: unknown) => T,\n schemaJson?: JsonSchema,\n): Schema<T> {\n return {\n kind: \"pipr.schema\",\n id,\n jsonSchema: schemaJson,\n parse(value) {\n return parseValue(value);\n },\n safeParse(value) {\n try {\n return { success: true, data: parseValue(value) };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error : new Error(String(error)),\n };\n }\n },\n };\n}\n\nfunction createZodSchema<T>(id: string, zodSchema: ZodSchema<T>): Schema<T> {\n return createSchema(id, (value) => zodSchema.parse(value), jsonSchemaFromZod(id, zodSchema));\n}\n\nfunction assertUserSchemaId(id: string): void {\n if (id.startsWith(\"core/\")) {\n throw new Error(`Schema id '${id}' uses the reserved core/ namespace`);\n }\n}\n\nfunction jsonSchemaFromZod<T>(id: string, schemaDefinition: ZodSchema<T>): JsonSchema {\n try {\n return z.toJSONSchema(schemaDefinition) as JsonSchema;\n } catch (error) {\n const detail = error instanceof Error ? error.message : String(error);\n throw new Error(\n `Schema '${id}' could not be converted to JSON Schema. Use JSON-Schema-representable Zod or pipr.jsonSchema<T>(). ${detail}`,\n );\n }\n}\n","import type { PiprRunContext } from \"../result.js\";\nimport type { ReviewFinding, ReviewResult } from \"../review-contract.js\";\nimport type {\n Agent,\n AgentDefinition,\n AgentTool,\n BuiltinSchemaCatalog,\n BuiltinToolCatalog,\n} from \"./agent.js\";\nimport type {\n ChangeRequestAction,\n DurationInput,\n ModelOptions,\n ModelProfile,\n PiprConfigOptions,\n RepositoryPermission,\n SecretOptions,\n SecretRef,\n} from \"./config.js\";\nimport type { ChangedFile, DiffManifest, DiffManifestOptions, PathFilter } from \"./manifest.js\";\nimport type {\n JsonPromptOptions,\n Markdown,\n PromptSource,\n PromptText,\n PromptValue,\n} from \"./prompt.js\";\nimport type { JsonSchemaDefinition, Schema, SchemaDefinition } from \"./schema.js\";\n\n/** Final review comment value produced by a task or review recipe. */\nexport type CommentValue =\n | Markdown\n | {\n main: Markdown;\n inlineFindings?: readonly ReviewFinding[];\n }\n | {\n main?: never;\n inlineFindings: readonly ReviewFinding[];\n };\n\n/** Prior inline finding persisted by earlier pipr review state. */\nexport type PriorInlineFinding = {\n id: string;\n status: \"open\" | \"resolved\";\n path: string;\n rangeId: string;\n side: \"RIGHT\" | \"LEFT\";\n startLine: number;\n endLine: number;\n};\n\n/** Prior pipr review state available to tasks through `ctx.review.prior()`. */\nexport type PriorReview = {\n main?: Markdown;\n reviewedHeadSha?: string;\n inlineFindings: readonly PriorInlineFinding[];\n};\n\n/** Function run by a task entrypoint. */\nexport type TaskHandler<Input> = (context: TaskContext, input: Input) => void | Promise<void>;\n\n/** Check-run publication options for one task. */\nexport type TaskCheckOptions =\n | false\n | {\n enabled?: boolean;\n name?: string;\n required?: boolean;\n };\n\n/** Definition used to register a task. */\nexport type TaskDefinition<Input> = {\n name: string;\n check?: TaskCheckOptions;\n local?: false;\n run: TaskHandler<Input>;\n};\n\ndeclare const taskHandleBrand: unique symbol;\n\n/** Opaque registered task handle selected by change-request and command entrypoints. */\nexport type Task<Input = void> = {\n readonly kind: \"pipr.task\";\n readonly name: string;\n readonly [taskHandleBrand]: (input: Input) => Input;\n};\n\n/** Options shared by command registrations. */\nexport type CommandOptions<Input> = {\n permission?: RepositoryPermission;\n description?: string;\n parse?: (arguments_: Record<string, string>) => Input;\n};\n\n/** Definition used to register an `@pipr` command. */\nexport type CommandRegistrationOptions<Input> = CommandOptions<Input> & {\n pattern: string;\n task: Task<Input>;\n};\n\n/** Role-specific policy for the two agents created by `pipr.review`. */\nexport type ReviewInstructions = {\n findings: PromptSource;\n summary: PromptSource;\n};\n\n/** Entrypoints created by `pipr.review`. */\nexport type ReviewEntrypoints = {\n changeRequest?: readonly ChangeRequestAction[] | false;\n command?:\n | string\n | false\n | {\n pattern?: string;\n permission?: RepositoryPermission;\n description?: string;\n };\n};\n\n/** Default change-request actions used by `pipr.review`. */\nexport const defaultReviewActions = [\n \"opened\",\n \"updated\",\n \"reopened\",\n \"ready\",\n] as const satisfies readonly ChangeRequestAction[];\n\n/** Default change-request and command entrypoints used by `pipr.review`. */\nexport const defaultReviewEntrypoints = {\n changeRequest: defaultReviewActions,\n command: { pattern: \"@pipr review\", permission: \"write\" },\n} as const satisfies ReviewEntrypoints;\n\ntype ReviewRecipeEntrypointOptions = {\n id: string;\n model: ModelProfile;\n fallbacks?: readonly ModelProfile[];\n instructions: ReviewInstructions;\n tools?: readonly AgentTool[];\n entrypoints?: ReviewEntrypoints;\n comment?:\n | CommentValue\n | ((\n result: ReviewResult,\n context: ReviewCommentContext,\n ) => CommentValue | Promise<CommentValue>);\n check?: TaskCheckOptions;\n timeout?: DurationInput;\n paths?: PathFilter;\n};\n\n/** Options for `pipr.review`, pipr's default review recipe. */\nexport type ReviewRecipeOptions = ReviewRecipeEntrypointOptions;\n\n/** Default input passed to a reviewer created by `pipr.review`. */\nexport type DefaultReviewInput = {\n manifest: DiffManifest;\n change: ChangeRequestInfo;\n};\n\n/** Bounded Diff Manifest projection passed to the summary agent created by `pipr.review`. */\nexport type DefaultReviewSummaryManifest = {\n baseSha: string;\n headSha: string;\n mergeBaseSha: string;\n fileCount: number;\n omittedFileCount: number;\n files: readonly {\n path: string;\n previousPath?: string;\n status: DiffManifest[\"files\"][number][\"status\"];\n language?: string;\n additions: number;\n deletions: number;\n changedSymbols?: readonly string[];\n excludedReason?: string;\n }[];\n};\n\n/** Input passed to the summary agent created by `pipr.review`. */\nexport type DefaultReviewSummaryInput = {\n manifestSummary: DefaultReviewSummaryManifest;\n change: ChangeRequestInfo;\n inlineFindings: readonly ReviewFinding[];\n};\n\n/** Context passed to a custom review comment renderer. */\nexport type ReviewCommentContext = {\n review: { id: string };\n run: PiprRunContext;\n repository: RepositoryInfo;\n change: ChangeRequestContext;\n platform: PlatformInfo;\n};\n\n/** Plugin installer returned by `definePlugin`. */\nexport type PiprPlugin<Handle> = {\n setup(builder: PiprBuilder): Handle;\n};\n\n/** Definition for a custom tool registered by config or plugins. */\nexport type PluginToolDefinition<Input, Output> = {\n name: string;\n description: string;\n input: Schema<Input>;\n output: Schema<Output>;\n run(options: ToolRunOptions<Input>): Output | Promise<Output>;\n toModelOutput?(output: Output): PromptValue;\n};\n\n/** Runtime input passed to a tool implementation. */\nexport type ToolRunOptions<Input> = {\n input: Input;\n ctx: TaskContext;\n signal?: AbortSignal;\n};\n\n/** Definition used to register an inputless task for change request actions. */\nexport type ChangeRequestRegistrationOptions = {\n actions: readonly ChangeRequestAction[];\n task: Task<void>;\n};\n\n/** Handle for reporting task check status from inside a task. */\nexport type CheckHandle = {\n pass(summary?: string): void;\n fail(summary?: string): void;\n neutral(summary?: string): void;\n};\n\n/** Builder API available inside `definePipr`. */\nexport type PiprBuilder = {\n readonly tools: BuiltinToolCatalog;\n readonly schemas: BuiltinSchemaCatalog;\n readonly on: {\n changeRequest(options: ChangeRequestRegistrationOptions): void;\n };\n secret(options: SecretOptions): SecretRef;\n model(options: ModelOptions): ModelProfile;\n agent<Input, Output>(definition: AgentDefinition<Input, Output>): Agent<Input, Output>;\n task<Input = void>(definition: TaskDefinition<Input>): Task<Input>;\n review(options: ReviewRecipeOptions): void;\n config(options: PiprConfigOptions): void;\n command<Input = void>(options: CommandRegistrationOptions<Input>): void;\n use<Handle>(plugin: PiprPlugin<Handle>): Handle;\n tool<Input, Output>(definition: PluginToolDefinition<Input, Output>): AgentTool<Input, Output>;\n schema<T>(definition: SchemaDefinition<T>): Schema<T>;\n jsonSchema<T>(definition: JsonSchemaDefinition): Schema<T>;\n prompt(strings: TemplateStringsArray, ...values: PromptValue[]): PromptText;\n section(title: string, value: PromptValue): PromptText;\n json(value: unknown, options?: JsonPromptOptions): PromptText;\n};\n\n/** Repository metadata available to tasks and agents. */\nexport type RepositoryInfo = {\n root: string;\n owner?: string;\n name: string;\n defaultBranch?: string;\n remoteUrl?: string;\n};\n\n/** Pull request or change-request metadata available to tasks and agents. */\nexport type ChangeRequestInfo = {\n number?: number;\n title: string;\n description: string;\n url?: string;\n author?: { login: string };\n base: { ref?: string; sha: string };\n head: { ref?: string; sha: string };\n isFork?: boolean;\n};\n\n/** Code hosting platform metadata. */\nexport type PlatformInfo = {\n id: string;\n};\n\n/** Change-request context available inside tasks. */\nexport type ChangeRequestContext = ChangeRequestInfo & {\n diffManifest(options?: DiffManifestOptions): Promise<DiffManifest>;\n changedFiles(): Promise<readonly ChangedFile[]>;\n};\n\n/** Runner for invoking Pi agents from tasks. */\nexport type PiRunner = {\n run<Input, Output>(\n agent: Agent<Input, Output>,\n input: Input,\n options?: {\n model?: ModelProfile;\n fallbacks?: readonly ModelProfile[];\n instructions?: PromptSource;\n timeout?: DurationInput;\n paths?: PathFilter;\n maxShards?: number;\n },\n ): Promise<Output>;\n};\n\n/** Command context available inside command-triggered tasks. */\nexport type CommandContext = {\n readonly name: string;\n readonly line: string;\n readonly arguments: Record<string, string>;\n reply(markdown: Markdown): Promise<void>;\n};\n\n/** Context object passed to task handlers. */\nexport type TaskContext = {\n /** Stable identity and trigger for the selected Review Run, not the process attempt. */\n readonly run: PiprRunContext;\n readonly repository: RepositoryInfo;\n readonly change: ChangeRequestContext;\n readonly platform: PlatformInfo;\n readonly pi: PiRunner;\n readonly command?: CommandContext;\n secret(secret: SecretRef): string;\n readonly review: {\n prior(): Promise<PriorReview>;\n };\n readonly check: CheckHandle;\n comment(value: CommentValue): Promise<void>;\n readonly log: {\n info(message: string): void;\n warn(message: string): void;\n error(message: string): void;\n };\n};\n","import { z } from \"zod\";\nimport { assertSupportedCommandRestCapture } from \"./command-grammar.js\";\nimport { configFactoryBrand, type InternalPiprConfigFactory } from \"./internal-contract.js\";\nimport { stripCommonIndent } from \"./prompt.js\";\nimport { serializePromptJson } from \"./prompt-json.js\";\nimport { renderPromptValue } from \"./prompt-render.js\";\nimport type { ReviewFindingsResult, ReviewResult, ReviewSummary } from \"./review-contract.js\";\nimport type {\n RuntimeAgent,\n RuntimeAgentTool,\n RuntimePlan,\n RuntimeTask,\n} from \"./runtime-contract.js\";\nimport {\n createAgentHandle,\n createBuiltinReadOnlyToolHandle,\n createTaskHandle,\n createToolHandle,\n runtimeAgentForHandle,\n runtimeTaskForHandle,\n} from \"./runtime-handles.js\";\nimport { jsonSchema, schema, schemas } from \"./schema.js\";\nimport type { Agent, BuiltinToolCatalog } from \"./types/agent.js\";\nimport type {\n AggregateCheckOptions,\n AutoResolveOptions,\n AutoResolveUserRepliesOptions,\n ChangeRequestAction,\n ChecksOptions,\n ModelProfile,\n PiprConfigOptions,\n PublicationOptions,\n} from \"./types/config.js\";\nimport { maxStoredFindingsLimit, modelThinkingLevels } from \"./types/config.js\";\nimport type { DiffManifestLimits, RuntimeLimits } from \"./types/manifest.js\";\nimport type { Markdown } from \"./types/prompt.js\";\nimport type {\n CommandOptions,\n CommentValue,\n DefaultReviewInput,\n DefaultReviewSummaryInput,\n PiprBuilder,\n PiprPlugin,\n ReviewRecipeOptions,\n Task,\n} from \"./types/task.js\";\nimport { defaultReviewActions, defaultReviewEntrypoints } from \"./types/task.js\";\n\n/** Defines a synchronous pipr configuration factory. */\nexport function definePipr(configure: (pipr: PiprBuilder) => void): {\n readonly kind: \"pipr.config-factory\";\n} {\n const factory = {\n kind: \"pipr.config-factory\",\n [configFactoryBrand]: true,\n build() {\n const builder = createBuilder();\n const result = configure(builder.api);\n if (\n typeof result === \"object\" &&\n result !== null &&\n typeof Reflect.get(result, \"then\") === \"function\"\n ) {\n throw new Error(\"definePipr configuration callback must be synchronous\");\n }\n return builder.plan();\n },\n } satisfies InternalPiprConfigFactory;\n return factory;\n}\n\n/** Defines a typed pipr plugin installer. */\nexport function definePlugin<Handle>(setup: (builder: PiprBuilder) => Handle): PiprPlugin<Handle> {\n return { setup };\n}\n\nfunction createBuilder(): { api: PiprBuilder; plan(): RuntimePlan } {\n const models: ModelProfile[] = [];\n const agents: RuntimeAgent[] = [];\n const tasks: RuntimeTask[] = [];\n const changeRequestTriggers: RuntimePlan[\"changeRequestTriggers\"] = [];\n const commands: RuntimePlan[\"commands\"] = [];\n const tools: RuntimeAgentTool[] = [];\n const publication: RuntimePlan[\"publication\"] = {};\n const readOnlyTool = createBuiltinReadOnlyToolHandle();\n let checks: ChecksOptions | undefined;\n let limits: RuntimeLimits | undefined;\n\n const api: PiprBuilder = {\n tools: {\n readOnly: [readOnlyTool.handle],\n } satisfies BuiltinToolCatalog,\n schemas,\n on: {\n changeRequest(options) {\n if (!Array.isArray(options.actions) || !options.task) {\n throw new Error(\"pipr.on.changeRequest requires { actions, task }\");\n }\n changeRequestTriggers.push({\n actions: [...options.actions],\n task: runtimeTaskForHandle(options.task),\n });\n },\n },\n secret(options) {\n if (!options || typeof options.name !== \"string\") {\n throw new Error(\"pipr.secret requires { name }\");\n }\n if (!/^[A-Z_][A-Z0-9_]*$/.test(options.name)) {\n throw new Error(`Secret '${options.name}' must be an environment variable name`);\n }\n return { kind: \"pipr.secret\", name: options.name };\n },\n model(options) {\n if (!options || typeof options.provider !== \"string\" || typeof options.model !== \"string\") {\n throw new Error(\"pipr.model requires { provider, model }\");\n }\n if (!options.provider || !options.model) {\n throw new Error(\"pipr.model requires provider and model\");\n }\n if (options.thinking !== undefined && !modelThinkingLevels.includes(options.thinking)) {\n throw new Error(`pipr.model received unsupported thinking level '${options.thinking}'`);\n }\n const id = options.id ?? `${options.provider}/${options.model}`;\n const profile: ModelProfile = {\n kind: \"pipr.model\",\n id,\n provider: options.provider,\n model: options.model,\n apiKey: options.apiKey,\n thinking: options.thinking,\n };\n models.push(profile);\n return profile;\n },\n agent(definition) {\n const agent = createAgentHandle(definition);\n agents.push(agent.record);\n return agent.handle;\n },\n task(definition) {\n if (!definition.name || typeof definition.run !== \"function\") {\n throw new Error(\"pipr.task requires { name, run }\");\n }\n const task = createTaskHandle(definition);\n tasks.push(task.record);\n return task.handle;\n },\n review(options) {\n assertKnownReviewRecipeOptions(options);\n if (!options.model || !models.includes(options.model)) {\n throw new Error(\"pipr.review requires a registered model.\");\n }\n registerReviewRecipe(api, options);\n },\n config(options) {\n assertKnownPiprConfigOptions(options);\n mergePublicationConfig(publication, options.publication);\n checks = mergeConfigField(\"checks\", checks, options.checks);\n limits = mergeLimits(limits, options.limits);\n },\n command(options) {\n if (typeof options.pattern !== \"string\" || !options.task) {\n throw new Error(\"pipr.command requires { pattern, task }\");\n }\n const pattern = options.pattern;\n const tokens = pattern.trim().split(/\\s+/).filter(Boolean);\n if (tokens.length === 0) {\n throw new Error(\"Command pattern must not be empty\");\n }\n if (tokens[0] !== \"@pipr\") {\n throw new Error(`Command pattern '${pattern}' must start with @pipr`);\n }\n assertSupportedCommandRestCapture(pattern);\n commands.push({\n pattern,\n permission: options.permission ?? \"write\",\n description: options.description,\n parse: options.parse as ((arguments_: Record<string, string>) => unknown) | undefined,\n task: runtimeTaskForHandle(options.task),\n });\n },\n use(plugin) {\n return plugin.setup(api);\n },\n tool(definition) {\n if (definition.name === \"readOnly\") {\n throw new Error(\"Tool name 'readOnly' is reserved for pipr built-in tools\");\n }\n const run = definition.run;\n if (!run) {\n throw new Error(`Tool '${definition.name}' must define run`);\n }\n const tool = createToolHandle({ ...definition, run });\n tools.push(tool.record);\n return tool.handle;\n },\n schema,\n jsonSchema,\n prompt(strings, ...values) {\n let text = \"\";\n for (let index = 0; index < strings.length; index += 1) {\n text += strings[index] ?? \"\";\n if (index < values.length) {\n text += renderPromptValue(values[index]);\n }\n }\n return {\n kind: \"pipr.prompt\",\n value: stripCommonIndent(text).trim(),\n };\n },\n section(title, value) {\n const rendered = renderPromptValue(value);\n return {\n kind: \"pipr.prompt\",\n value: `## ${title}\\n\\n${rendered}`,\n };\n },\n json(value, options) {\n const text = serializePromptJson(value, options?.pretty !== false);\n if (options?.maxCharacters !== undefined && text.length > options.maxCharacters) {\n throw new Error(`JSON prompt value exceeded ${options.maxCharacters} characters`);\n }\n return { kind: \"pipr.prompt\", value: text };\n },\n };\n\n return {\n api,\n plan() {\n assertUnique(\n tasks.map((task) => task.name),\n \"task\",\n );\n assertUnique(\n commands.map((command) => command.pattern),\n \"command\",\n );\n assertModelIdentity(models);\n return {\n resolveAgent: runtimeAgentForHandle,\n models,\n agents,\n tasks,\n changeRequestTriggers,\n commands,\n tools,\n publication,\n checks,\n limits,\n };\n },\n };\n}\n\nfunction registerReviewRecipe(api: PiprBuilder, options: ReviewRecipeOptions): void {\n const id = options.id;\n const findingsAgent = createReviewFindingsAgent(api, options);\n const summaryAgent = createReviewSummaryAgent(api, options);\n const task = createReviewRecipeTask(api, id, findingsAgent, summaryAgent, options);\n registerReviewRecipeEntrypoints(api, task, options);\n}\n\nconst reviewRecipeOptionKeys = new Set([\n \"id\",\n \"entrypoints\",\n \"comment\",\n \"check\",\n \"timeout\",\n \"paths\",\n \"model\",\n \"fallbacks\",\n \"instructions\",\n \"tools\",\n]);\n\nconst reviewRecipeEntrypointKeys = new Set([\"changeRequest\", \"command\"]);\n\nconst modelProfileConfigSchema: z.ZodType<ModelProfile> = z.custom<ModelProfile>(\n (value) =>\n typeof value === \"object\" &&\n value !== null &&\n (value as { kind?: unknown }).kind === \"pipr.model\" &&\n typeof (value as { id?: unknown }).id === \"string\" &&\n typeof (value as { provider?: unknown }).provider === \"string\" &&\n typeof (value as { model?: unknown }).model === \"string\",\n);\n\nconst autoResolveUserRepliesOptionsSchema: z.ZodType<AutoResolveUserRepliesOptions> =\n z.strictObject({\n enabled: z.boolean().optional(),\n respondWhenStillValid: z.boolean().optional(),\n allowedActors: z.enum([\"author-or-write\", \"write\", \"any\"]).optional(),\n });\n\nconst autoResolveOptionsSchema: z.ZodType<AutoResolveOptions> = z.union([\n z.literal(false),\n z.strictObject({\n enabled: z.boolean().optional(),\n model: modelProfileConfigSchema.optional(),\n instructions: z.string().min(1).max(4000).optional(),\n synchronize: z.boolean().optional(),\n userReplies: z.union([z.boolean(), autoResolveUserRepliesOptionsSchema]).optional(),\n }),\n]);\n\nconst publicationOptionsSchema: z.ZodType<PublicationOptions> = z.strictObject({\n maxInlineComments: z.number().int().min(0).max(50).optional(),\n maxStoredFindings: z.number().int().min(0).max(maxStoredFindingsLimit).optional(),\n autoResolve: autoResolveOptionsSchema.optional(),\n showHeader: z.boolean().optional(),\n showFooter: z.boolean().optional(),\n showStats: z.boolean().optional(),\n});\n\nconst aggregateCheckOptionsSchema: z.ZodType<AggregateCheckOptions> = z.union([\n z.literal(false),\n z.strictObject({\n enabled: z.boolean().optional(),\n name: z.string().min(1).optional(),\n }),\n]);\n\nconst checksOptionsSchema: z.ZodType<ChecksOptions> = z.strictObject({\n aggregate: aggregateCheckOptionsSchema.optional(),\n});\n\nconst diffManifestLimitsSchema: z.ZodType<DiffManifestLimits> = z.strictObject({\n maxShards: z.number().int().positive().optional(),\n fullMaxBytes: z.number().int().positive().optional(),\n fullMaxEstimatedTokens: z.number().int().positive().optional(),\n condensedMaxBytes: z.number().int().positive().optional(),\n condensedMaxEstimatedTokens: z.number().int().positive().optional(),\n toolResponseMaxBytes: z.number().int().positive().optional(),\n});\n\nconst runtimeLimitsSchema: z.ZodType<RuntimeLimits> = z.strictObject({\n timeoutSeconds: z.number().int().positive().max(3600).optional(),\n maxAgentRuns: z.number().int().positive().optional(),\n diffManifest: diffManifestLimitsSchema.optional(),\n});\n\nconst piprConfigOptionsSchema: z.ZodType<PiprConfigOptions> = z.strictObject({\n publication: publicationOptionsSchema.optional(),\n checks: checksOptionsSchema.optional(),\n limits: runtimeLimitsSchema.optional(),\n});\n\nfunction assertKnownReviewRecipeOptions(options: ReviewRecipeOptions): void {\n const unknownKeys = Object.keys(options).filter((key) => !reviewRecipeOptionKeys.has(key));\n if (unknownKeys.length > 0) {\n throw new Error(`pipr.review received unsupported option fields: ${unknownKeys.join(\", \")}.`);\n }\n\n const instructions = options.instructions as\n | { findings?: unknown; summary?: unknown }\n | undefined;\n if (\n !instructions ||\n typeof instructions !== \"object\" ||\n !isPromptSource(instructions.findings) ||\n !isPromptSource(instructions.summary)\n ) {\n throw new Error(\"pipr.review instructions require both findings and summary.\");\n }\n\n const entrypoints = options.entrypoints;\n if (entrypoints && typeof entrypoints === \"object\") {\n const unknownEntrypointKeys = Object.keys(entrypoints).filter(\n (key) => !reviewRecipeEntrypointKeys.has(key),\n );\n if (unknownEntrypointKeys.length > 0) {\n throw new Error(\n `pipr.review entrypoints received unsupported fields: ${unknownEntrypointKeys.join(\", \")}.`,\n );\n }\n }\n}\n\nfunction isPromptSource(value: unknown): boolean {\n return (\n (typeof value === \"string\" && value.length > 0) || (typeof value === \"object\" && value !== null)\n );\n}\n\nfunction assertKnownPiprConfigOptions(options: unknown): asserts options is PiprConfigOptions {\n const parsed = piprConfigOptionsSchema.safeParse(options);\n if (!parsed.success) {\n throw new Error(formatPiprConfigOptionsError(parsed.error));\n }\n}\n\nfunction formatPiprConfigOptionsError(error: z.ZodError): string {\n const unsupportedFields = firstUnsupportedConfigFields(error.issues, []);\n if (unsupportedFields) {\n return `${piprConfigLabel(unsupportedFields.path)} received unsupported option fields: ${unsupportedFields.keys.join(\n \", \",\n )}`;\n }\n return `pipr.config received invalid option value: ${z.prettifyError(error)}`;\n}\n\nfunction firstUnsupportedConfigFields(\n issues: readonly z.ZodIssue[],\n parentPath: readonly PropertyKey[],\n): { path: PropertyKey[]; keys: string[] } | undefined {\n for (const issue of issues) {\n const path = [...parentPath, ...issue.path];\n if (issue.code === \"unrecognized_keys\") {\n return { path, keys: issue.keys };\n }\n if (issue.code === \"invalid_union\") {\n for (const branchIssues of issue.errors) {\n const unsupportedFields = firstUnsupportedConfigFields(branchIssues, path);\n if (unsupportedFields) {\n return unsupportedFields;\n }\n }\n }\n }\n return undefined;\n}\n\nfunction piprConfigLabel(pathSegments: PropertyKey[]): string {\n const path = pathSegments.join(\".\");\n return path ? `pipr.config ${path}` : \"pipr.config\";\n}\n\nfunction createReviewFindingsAgent(\n api: PiprBuilder,\n options: ReviewRecipeOptions,\n): Agent<DefaultReviewInput, ReviewFindingsResult> {\n return api.agent<DefaultReviewInput, ReviewFindingsResult>({\n name: `${options.id}-findings`,\n model: options.model,\n fallbacks: options.fallbacks,\n instructions: options.instructions.findings,\n tools: options.tools ?? api.tools.readOnly,\n output: api.schemas.inlineFindings,\n timeout: options.timeout,\n prompt: () => api.prompt`Review this change for actionable inline findings.`,\n });\n}\n\nfunction createReviewSummaryAgent(\n api: PiprBuilder,\n options: ReviewRecipeOptions,\n): Agent<DefaultReviewSummaryInput, ReviewSummary> {\n return api.agent<DefaultReviewSummaryInput, ReviewSummary>({\n name: `${options.id}-summary`,\n model: options.model,\n fallbacks: options.fallbacks,\n instructions: options.instructions.summary,\n tools: options.tools ?? api.tools.readOnly,\n output: api.schemas.summary,\n timeout: options.timeout,\n prompt: ({ inlineFindings, manifestSummary }) =>\n api.prompt`\n Summarize this change using the merged inline findings as evidence.\n\n ${api.section(\"Scoped compressed manifest\", api.json(manifestSummary, { maxCharacters: 60_000 }))}\n\n ${api.section(\"Merged inline findings\", api.json(inlineFindings, { maxCharacters: 60_000 }))}\n `,\n });\n}\n\nfunction createReviewRecipeTask(\n api: PiprBuilder,\n id: string,\n findingsAgent: Agent<DefaultReviewInput, ReviewFindingsResult>,\n summaryAgent: Agent<DefaultReviewSummaryInput, ReviewSummary>,\n options: ReviewRecipeOptions,\n): Task {\n return api.task({\n name: id,\n check: options.check,\n async run(context) {\n const manifest = await context.change.diffManifest({\n compressed: true,\n paths: options.paths,\n });\n if (options.paths && manifest.files.length === 0) {\n context.check.neutral(\"No changed files matched this review's path scope.\");\n await context.comment({ main: \"No changed files matched this review's path scope.\" });\n return;\n }\n const findings = await context.pi.run(\n findingsAgent,\n { manifest, change: context.change },\n {\n timeout: options.timeout,\n paths: options.paths,\n },\n );\n const summary = await context.pi.run(\n summaryAgent,\n {\n manifestSummary: defaultReviewSummaryManifest(manifest),\n change: context.change,\n inlineFindings: findings.inlineFindings,\n },\n {\n timeout: options.timeout,\n paths: options.paths,\n },\n );\n const result: ReviewResult = {\n summary,\n inlineFindings: findings.inlineFindings,\n };\n const source =\n typeof options.comment === \"function\"\n ? await options.comment(result, {\n review: { id },\n run: context.run,\n repository: context.repository,\n change: context.change,\n platform: context.platform,\n })\n : (options.comment ?? defaultReviewComment(result));\n await context.comment(source);\n },\n });\n}\n\nfunction defaultReviewSummaryManifest(\n manifest: DefaultReviewInput[\"manifest\"],\n): DefaultReviewSummaryInput[\"manifestSummary\"] {\n const maxSerializedFileCharacters = 40_000;\n const files: DefaultReviewSummaryInput[\"manifestSummary\"][\"files\"][number][] = [];\n let serializedFileCharacters = 0;\n\n for (const file of manifest.files) {\n const projected = {\n path: file.path.slice(0, 1_000),\n ...(file.previousPath ? { previousPath: file.previousPath.slice(0, 1_000) } : {}),\n status: file.status,\n ...(file.language ? { language: file.language.slice(0, 100) } : {}),\n additions: file.additions,\n deletions: file.deletions,\n ...(file.changedSymbols?.length\n ? {\n changedSymbols: file.changedSymbols.slice(0, 20).map((symbol) => symbol.slice(0, 200)),\n }\n : {}),\n ...(file.excludedReason ? { excludedReason: file.excludedReason.slice(0, 500) } : {}),\n };\n const projectedCharacters = JSON.stringify(projected).length;\n if (serializedFileCharacters + projectedCharacters > maxSerializedFileCharacters) {\n continue;\n }\n files.push(projected);\n serializedFileCharacters += projectedCharacters;\n }\n\n return {\n baseSha: manifest.baseSha,\n headSha: manifest.headSha,\n mergeBaseSha: manifest.mergeBaseSha,\n fileCount: manifest.files.length,\n omittedFileCount: manifest.files.length - files.length,\n files,\n };\n}\n\nfunction defaultReviewComment(result: ReviewResult): CommentValue {\n return {\n main: defaultReviewMarkdown(result),\n inlineFindings: result.inlineFindings,\n };\n}\n\nfunction defaultReviewMarkdown(result: ReviewResult): Markdown {\n const findings =\n result.inlineFindings.length === 0\n ? \"No inline findings.\"\n : result.inlineFindings.map((finding) => `- ${finding.body}`).join(\"\\n\");\n return `## Summary\\n\\n${result.summary.body}\\n\\n## Findings\\n\\n${findings}`;\n}\n\nfunction registerReviewRecipeEntrypoints(\n api: PiprBuilder,\n task: Task,\n options: ReviewRecipeOptions,\n): void {\n const changeRequest = reviewChangeRequestEntrypoint(options);\n if (changeRequest) {\n api.on.changeRequest({ actions: changeRequest, task });\n }\n const command = reviewCommandEntrypoint(options);\n if (command) {\n api.command({ pattern: command.pattern, ...command.options, task });\n }\n}\n\nfunction reviewChangeRequestEntrypoint(\n options: ReviewRecipeOptions,\n): readonly ChangeRequestAction[] | undefined {\n const entrypoint = options.entrypoints?.changeRequest;\n return entrypoint === false ? undefined : (entrypoint ?? defaultReviewActions);\n}\n\nfunction reviewCommandEntrypoint(options: ReviewRecipeOptions):\n | {\n pattern: string;\n options: CommandOptions<void>;\n }\n | undefined {\n const entrypoint = options.entrypoints?.command;\n if (entrypoint === false) {\n return undefined;\n }\n if (typeof entrypoint === \"object\") {\n return {\n pattern: entrypoint.pattern ?? defaultReviewEntrypoints.command.pattern,\n options: {\n permission: entrypoint.permission ?? defaultReviewEntrypoints.command.permission,\n description: entrypoint.description,\n },\n };\n }\n return {\n pattern: entrypoint ?? defaultReviewEntrypoints.command.pattern,\n options: { permission: defaultReviewEntrypoints.command.permission },\n };\n}\n\nfunction mergePublicationConfig(\n target: RuntimePlan[\"publication\"],\n next: PublicationOptions | undefined,\n): void {\n if (!next) {\n return;\n }\n target.maxInlineComments = mergeConfigField(\n \"publication.maxInlineComments\",\n target.maxInlineComments,\n next.maxInlineComments,\n );\n target.maxStoredFindings = mergeConfigField(\n \"publication.maxStoredFindings\",\n target.maxStoredFindings,\n next.maxStoredFindings,\n );\n target.autoResolve = mergeConfigField(\n \"publication.autoResolve\",\n target.autoResolve,\n next.autoResolve,\n );\n target.showHeader = mergeConfigField(\n \"publication.showHeader\",\n target.showHeader,\n next.showHeader,\n );\n target.showFooter = mergeConfigField(\n \"publication.showFooter\",\n target.showFooter,\n next.showFooter,\n );\n target.showStats = mergeConfigField(\"publication.showStats\", target.showStats, next.showStats);\n}\n\nfunction mergeConfigField<T>(\n name: string,\n current: T | undefined,\n next: T | undefined,\n): T | undefined {\n if (next === undefined) {\n return current;\n }\n if (current !== undefined && stableJson(current) !== stableJson(next)) {\n throw new Error(`pipr.config ${name} conflicts with existing value`);\n }\n return next;\n}\n\nfunction mergeLimits(current: RuntimeLimits | undefined, next: RuntimeLimits | undefined) {\n if (!next) {\n return current;\n }\n assertRuntimeLimitConflicts(current, next);\n return {\n ...current,\n ...next,\n diffManifest:\n (next.diffManifest ?? current?.diffManifest)\n ? { ...current?.diffManifest, ...next.diffManifest }\n : undefined,\n };\n}\n\nfunction assertRuntimeLimitConflicts(\n current: RuntimeLimits | undefined,\n next: RuntimeLimits,\n): void {\n const currentRecord = current as Record<string, unknown> | undefined;\n for (const [key, value] of Object.entries(next)) {\n if (key === \"diffManifest\") {\n continue;\n }\n if (\n value !== undefined &&\n currentRecord?.[key] !== undefined &&\n stableJson(currentRecord[key]) !== stableJson(value)\n ) {\n throw new Error(`pipr.config limits.${key} conflicts with existing value`);\n }\n }\n assertDiffManifestLimitConflicts(current, next);\n}\n\nfunction assertDiffManifestLimitConflicts(\n current: RuntimeLimits | undefined,\n next: RuntimeLimits,\n): void {\n if (current?.diffManifest && next.diffManifest) {\n for (const [key, value] of Object.entries(next.diffManifest)) {\n if (\n value !== undefined &&\n (current.diffManifest as Record<string, unknown>)[key] !== undefined &&\n (current.diffManifest as Record<string, unknown>)[key] !== value\n ) {\n throw new Error(`pipr.config limits.diffManifest.${key} conflicts with existing value`);\n }\n }\n }\n}\n\nfunction assertUnique(values: string[], label: string): void {\n const seen = new Set<string>();\n for (const value of values) {\n if (seen.has(value)) {\n throw new Error(`Duplicate ${label} '${value}'`);\n }\n seen.add(value);\n }\n}\n\nfunction assertModelIdentity(models: ModelProfile[]): void {\n assertNoDuplicateModelConfigs(models);\n assertUniqueModelIds(models);\n assertProviderModelAliasesDisambiguated(models);\n}\n\nfunction assertNoDuplicateModelConfigs(models: ModelProfile[]): void {\n const effectiveConfigs = new Map<string, string>();\n for (const model of models) {\n const effectiveConfig = stableJson({\n provider: model.provider,\n model: model.model,\n apiKeyEnv: model.apiKey?.name,\n thinking: model.thinking,\n });\n const existingConfigId = effectiveConfigs.get(effectiveConfig);\n if (existingConfigId) {\n throw new Error(\n `Duplicate model config for '${model.id}'. Reuse model '${existingConfigId}' instead.`,\n );\n }\n effectiveConfigs.set(effectiveConfig, model.id);\n }\n}\n\nfunction assertUniqueModelIds(models: ModelProfile[]): void {\n const ids = new Set<string>();\n for (const model of models) {\n if (ids.has(model.id)) {\n const providerModel = `${model.provider}/${model.model}`;\n throw new Error(\n model.id === providerModel\n ? `Model '${providerModel}' is configured more than once with different options. Add an explicit id.`\n : `Duplicate model id '${model.id}'`,\n );\n }\n ids.add(model.id);\n }\n}\n\nfunction assertProviderModelAliasesDisambiguated(models: ModelProfile[]): void {\n const providerModels = new Map<string, string>();\n for (const model of models) {\n const providerModel = `${model.provider}/${model.model}`;\n const existingProviderModelId = providerModels.get(providerModel);\n if (\n existingProviderModelId &&\n (model.id === providerModel || existingProviderModelId === providerModel)\n ) {\n throw new Error(\n `Model '${providerModel}' is configured more than once with different options. Add an explicit id.`,\n );\n }\n providerModels.set(providerModel, model.id);\n }\n}\n\nfunction stableJson(value: unknown): string {\n return JSON.stringify(stableJsonValue(value));\n}\n\nfunction stableJsonValue(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(stableJsonValue);\n }\n if (typeof value === \"object\" && value !== null) {\n return Object.fromEntries(\n Object.entries(value as Record<string, unknown>)\n .filter(([, item]) => item !== undefined)\n .toSorted(([left], [right]) => left.localeCompare(right))\n .map(([key, item]) => [key, stableJsonValue(item)]),\n );\n }\n return value;\n}\n","import { z } from \"zod\";\nimport { type ReviewFinding, reviewFindingSchema } from \"./review-contract.js\";\n\nconst piprRunTriggers = [\"change-request\", \"command\", \"verifier\", \"local\"] as const;\n\nexport type PiprRunTrigger = (typeof piprRunTriggers)[number];\n\nexport type PiprRunContext = {\n readonly id: string;\n readonly trigger: PiprRunTrigger;\n};\n\nexport type PiprRunSummary = PiprRunContext & {\n baseSha: string;\n headSha: string;\n tasks: string[];\n durationMs: number;\n models: string[];\n agentRuns: number;\n inputTokens: number;\n outputTokens: number;\n costUsd: number;\n usageStatus: \"complete\" | \"partial\" | \"unavailable\";\n};\n\ntype InlineCommentCounts = { posted: number; skipped: number; failed: number };\ntype ReviewPublication =\n | { state: \"disabled\" }\n | {\n state: \"completed\";\n mainComment: { action: \"created\" | \"updated\" };\n inlineComments: InlineCommentCounts;\n inlinePublicationErrorCount: number;\n inlineResolutionErrorCount: number;\n };\n\nexport type PiprResult =\n | {\n formatVersion: 2;\n kind: \"review\";\n run: PiprRunSummary;\n mainComment: string;\n inlineFindings: ReviewFinding[];\n droppedFindings: Array<{ finding: ReviewFinding; reason: string }>;\n taskChecks: Array<{\n taskName: string;\n conclusion: \"success\" | \"failure\" | \"neutral\";\n summary?: string;\n }>;\n repairAttempted: boolean;\n publication: ReviewPublication;\n }\n | { formatVersion: 2; kind: \"skipped\"; reason: string }\n | { formatVersion: 2; kind: \"ignored\"; reason: string }\n | { formatVersion: 2; kind: \"dry-run\" }\n | { formatVersion: 2; kind: \"command-help\"; reason: string; mainComment: string }\n | {\n formatVersion: 2;\n kind: \"command-response\";\n run: PiprRunSummary;\n mainComment: string;\n publication: { state: \"completed\"; action: \"created\" | \"updated\" };\n }\n | {\n formatVersion: 2;\n kind: \"verifier\";\n run: PiprRunSummary;\n publication: { state: \"completed\"; inlineResolutionErrorCount: number };\n }\n | {\n formatVersion: 2;\n kind: \"publication-error\";\n message: string;\n publication?: {\n inlineComments: InlineCommentCounts;\n inlinePublicationErrorCount: number;\n inlineResolutionErrorCount: number;\n };\n }\n | { formatVersion: 2; kind: \"error\"; message: string };\n\nconst text = z.string().min(1);\nconst count = z.number().int().nonnegative();\nconst header = { formatVersion: z.literal(2) };\nconst runSummarySchema = z.strictObject({\n id: text.max(200),\n trigger: z.enum(piprRunTriggers),\n baseSha: text.max(200),\n headSha: text.max(200),\n tasks: z.array(text.max(200)).max(200),\n durationMs: count,\n models: z.array(text.max(200)).max(20),\n agentRuns: count,\n inputTokens: count,\n outputTokens: count,\n costUsd: z.number().nonnegative().finite(),\n usageStatus: z.enum([\"complete\", \"partial\", \"unavailable\"]),\n});\nconst inlineCountsSchema = z.strictObject({ posted: count, skipped: count, failed: count });\nconst publicationCountsSchema = z.strictObject({\n inlineComments: inlineCountsSchema,\n inlinePublicationErrorCount: count,\n inlineResolutionErrorCount: count,\n});\nconst reviewPublicationSchema = z.discriminatedUnion(\"state\", [\n z.strictObject({ state: z.literal(\"disabled\") }),\n z.strictObject({\n state: z.literal(\"completed\"),\n mainComment: z.strictObject({ action: z.enum([\"created\", \"updated\"]) }),\n ...publicationCountsSchema.shape,\n }),\n]);\nconst schemas = [\n z.strictObject({\n ...header,\n kind: z.literal(\"review\"),\n run: runSummarySchema,\n mainComment: z.string(),\n inlineFindings: z.array(reviewFindingSchema),\n droppedFindings: z.array(z.strictObject({ finding: reviewFindingSchema, reason: text })),\n taskChecks: z.array(\n z.strictObject({\n taskName: text,\n conclusion: z.enum([\"success\", \"failure\", \"neutral\"]),\n summary: text.optional(),\n }),\n ),\n repairAttempted: z.boolean(),\n publication: reviewPublicationSchema,\n }),\n z.strictObject({ ...header, kind: z.literal(\"skipped\"), reason: text }),\n z.strictObject({ ...header, kind: z.literal(\"ignored\"), reason: text }),\n z.strictObject({ ...header, kind: z.literal(\"dry-run\") }),\n z.strictObject({\n ...header,\n kind: z.literal(\"command-help\"),\n reason: text,\n mainComment: z.string(),\n }),\n z.strictObject({\n ...header,\n kind: z.literal(\"command-response\"),\n run: runSummarySchema,\n mainComment: z.string(),\n publication: z.strictObject({\n state: z.literal(\"completed\"),\n action: z.enum([\"created\", \"updated\"]),\n }),\n }),\n z.strictObject({\n ...header,\n kind: z.literal(\"verifier\"),\n run: runSummarySchema,\n publication: z.strictObject({\n state: z.literal(\"completed\"),\n inlineResolutionErrorCount: count,\n }),\n }),\n z.strictObject({\n ...header,\n kind: z.literal(\"publication-error\"),\n message: text,\n publication: publicationCountsSchema.optional(),\n }),\n z.strictObject({ ...header, kind: z.literal(\"error\"), message: text }),\n] as const;\n\nexport const piprResultSchema: z.ZodType<PiprResult> = z.discriminatedUnion(\"kind\", schemas);\n\nexport function parsePiprResult(value: unknown): PiprResult {\n return piprResultSchema.parse(value);\n}\n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EACb,GAAG;EACH,MAAMA,IAAE,QAAQ,kBAAkB;EAClC,KAAK;EACL,aAAaA,IAAE,OAAO;EACtB,aAAaA,IAAE,aAAa;GAC1B,OAAOA,IAAE,QAAQ,WAAW;GAC5B,QAAQA,IAAE,KAAK,CAAC,WAAW,SAAS,CAAC;EACvC,CAAC;CACH,CAAC;CACDA,IAAE,aAAa;EACb,GAAG;EACH,MAAMA,IAAE,QAAQ,UAAU;EAC1B,KAAK;EACL,aAAaA,IAAE,aAAa;GAC1B,OAAOA,IAAE,QAAQ,WAAW;GAC5B,4BAA4B;EAC9B,CAAC;CACH,CAAC;CACDA,IAAE,aAAa;EACb,GAAG;EACH,MAAMA,IAAE,QAAQ,mBAAmB;EACnC,SAAS;EACT,aAAa,wBAAwB,SAAS;CAChD,CAAC;CACDA,IAAE,aAAa;EAAE,GAAG;EAAQ,MAAMA,IAAE,QAAQ,OAAO;EAAG,SAAS;CAAK,CAAC;AACvE;AAEA,MAAa,mBAA0CA,IAAE,mBAAmB,QAAQC,SAAO;AAE3F,SAAgB,gBAAgB,OAA4B;CAC1D,OAAO,iBAAiB,MAAM,KAAK;AACrC"}
|
package/dist/internal.d.mts
CHANGED
|
@@ -1,22 +1,49 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as AgentDefinition, C as PluginToolDefinition, Et as RuntimeLimits, M as TaskCheckOptions, N as TaskContext, X as PromptValue, at as ModelProfile, ct as PublicationOptions, ft as defaultMaxStoredFindings, lt as RepositoryPermission, nt as ChecksOptions, pt as maxStoredFindingsLimit, tt as ChangeRequestAction, z as Agent } from "./index-Bdey1nho.mjs";
|
|
2
2
|
//#region src/runtime-contract.d.ts
|
|
3
|
+
/** Type-erased executable task stored in a runtime plan. */
|
|
4
|
+
type RuntimeTask = {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly check?: TaskCheckOptions;
|
|
7
|
+
readonly local?: false;
|
|
8
|
+
readonly handler: (context: TaskContext, input: unknown) => void | Promise<void>;
|
|
9
|
+
};
|
|
10
|
+
/** Type-erased executable custom or built-in tool stored in a runtime plan. */
|
|
11
|
+
type RuntimeAgentTool = {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly description?: string;
|
|
14
|
+
readonly input?: PluginToolDefinition<unknown, unknown>["input"];
|
|
15
|
+
readonly output?: PluginToolDefinition<unknown, unknown>["output"];
|
|
16
|
+
readonly run?: PluginToolDefinition<unknown, unknown>["run"];
|
|
17
|
+
readonly toModelOutput?: PluginToolDefinition<unknown, unknown>["toModelOutput"];
|
|
18
|
+
readonly builtinReadOnly?: true;
|
|
19
|
+
};
|
|
20
|
+
/** Type-erased executable agent definition stored in a runtime plan. */
|
|
21
|
+
type RuntimeAgentDefinition = Omit<AgentDefinition<unknown, unknown>, "tools"> & {
|
|
22
|
+
tools?: readonly RuntimeAgentTool[];
|
|
23
|
+
};
|
|
24
|
+
/** Type-erased executable agent stored in a runtime plan. */
|
|
25
|
+
type RuntimeAgent = {
|
|
26
|
+
readonly name?: string;
|
|
27
|
+
readonly definition: RuntimeAgentDefinition;
|
|
28
|
+
};
|
|
3
29
|
/** Runtime plan produced from user configuration. */
|
|
4
30
|
type RuntimePlan = {
|
|
31
|
+
resolveAgent<Input, Output>(agent: Agent<Input, Output>): RuntimeAgent;
|
|
5
32
|
models: ModelProfile[];
|
|
6
|
-
agents:
|
|
7
|
-
tasks:
|
|
33
|
+
agents: RuntimeAgent[];
|
|
34
|
+
tasks: RuntimeTask[];
|
|
8
35
|
changeRequestTriggers: Array<{
|
|
9
36
|
actions: ChangeRequestAction[];
|
|
10
|
-
task:
|
|
37
|
+
task: RuntimeTask;
|
|
11
38
|
}>;
|
|
12
39
|
commands: Array<{
|
|
13
40
|
pattern: string;
|
|
14
41
|
permission: RepositoryPermission;
|
|
15
42
|
description?: string;
|
|
16
43
|
parse?: (arguments_: Record<string, string>) => unknown;
|
|
17
|
-
task:
|
|
44
|
+
task: RuntimeTask;
|
|
18
45
|
}>;
|
|
19
|
-
tools:
|
|
46
|
+
tools: RuntimeAgentTool[];
|
|
20
47
|
publication: PublicationOptions;
|
|
21
48
|
checks?: ChecksOptions;
|
|
22
49
|
limits?: RuntimeLimits;
|
|
@@ -54,11 +81,11 @@ declare function embeddedSdkDeclaration(modules: SdkDeclarationModule[]): string
|
|
|
54
81
|
/** Stable identifier for Pipr's built-in change request review output schema. */
|
|
55
82
|
declare const reviewOutputSchemaId = "core/pr-review";
|
|
56
83
|
/** Returns whether a tool is one of pipr's built-in read-only tools. */
|
|
57
|
-
declare function isBuiltinReadOnlyTool(tool:
|
|
84
|
+
declare function isBuiltinReadOnlyTool(tool: RuntimeAgentTool): boolean;
|
|
58
85
|
/** Checks that an unknown value is a pipr configuration factory. */
|
|
59
86
|
declare function isPiprConfigFactory(value: unknown): value is ConfigFactoryValue;
|
|
60
87
|
/** Builds a runtime plan from a pipr configuration factory. */
|
|
61
88
|
declare function buildPiprPlan(factory: unknown): RuntimePlan;
|
|
62
89
|
//#endregion
|
|
63
|
-
export { type RuntimePlan, type SdkDeclarationModule, assertSupportedCommandRestCapture, buildPiprPlan, commandPatternParts, defaultMaxStoredFindings, embeddedSdkDeclaration, isBuiltinReadOnlyTool, isCommandCaptureToken, isCommandRestCaptureToken, isOptionalCommandPatternPart, isPiprConfigFactory, maxStoredFindingsLimit, readSdkDeclarationSourceWithChunk, renderPromptValue, reviewOutputSchemaId, tokenizeCommandPattern, unsupportedCommandRestCaptureError };
|
|
90
|
+
export { type RuntimeAgent, type RuntimeAgentDefinition, type RuntimeAgentTool, type RuntimePlan, type RuntimeTask, type SdkDeclarationModule, assertSupportedCommandRestCapture, buildPiprPlan, commandPatternParts, defaultMaxStoredFindings, embeddedSdkDeclaration, isBuiltinReadOnlyTool, isCommandCaptureToken, isCommandRestCaptureToken, isOptionalCommandPatternPart, isPiprConfigFactory, maxStoredFindingsLimit, readSdkDeclarationSourceWithChunk, renderPromptValue, reviewOutputSchemaId, tokenizeCommandPattern, unsupportedCommandRestCaptureError };
|
|
64
91
|
//# sourceMappingURL=internal.d.mts.map
|
package/dist/internal.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.mts","names":[],"sources":["../src/runtime-contract.ts","../src/internal-contract.ts","../src/command-grammar.ts","../src/prompt-render.ts","../src/standalone-declaration.ts","../src/internal.ts"],"mappings":";;;KAYY;EACV,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,uBAAuB;IAAQ,SAAS;IAAuB,MAAM;;EACrE,UAAU;IACR;IACA,YAAY;IACZ;IACA,SAAS,YAAY;IACrB,MAAM;;EAER,OAAO;EACP,aAAa;EACb,SAAS;EACT,SAAS;;;;
|
|
1
|
+
{"version":3,"file":"internal.d.mts","names":[],"sources":["../src/runtime-contract.ts","../src/internal-contract.ts","../src/command-grammar.ts","../src/prompt-render.ts","../src/standalone-declaration.ts","../src/internal.ts"],"mappings":";;;KAYY;WACD;WACA,QAAQ;WACR;WACA,UAAU,SAAS,aAAa,0BAA0B;;;KAIzD;WACD;WACA;WACA,QAAQ;WACR,SAAS;WACT,MAAM;WACN,gBAAgB;WAChB;;;KAIC,yBAAyB,KAAK;EACxC,iBAAiB;;;KAIP;WACD;WACA,YAAY;;;KAIX;EACV,aAAa,OAAO,QAAQ,OAAO,MAAM,OAAO,UAAU;EAC1D,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,uBAAuB;IAAQ,SAAS;IAAuB,MAAM;;EACrE,UAAU;IACR;IACA,YAAY;IACZ;IACA,SAAS,YAAY;IACrB,MAAM;;EAER,OAAO;EACP,aAAa;EACb,SAAS;EACT,SAAS;;;;KCtDC;WACD;;;;iBCLK,oBAAoB;iBAIpB,uBAAuB;iBAIvB,mCAAmC;iBAmBnC,kCAAkC;iBAOlC,6BAA6B;iBAI7B,sBAAsB;iBAItB,0BAA0B;;;;iBCtC1B,kBAAkB,OAAO;;;KCF7B;EACV;EACA;;iBAGoB,kCACpB;EAAU;GACV,0BACC;iBAgBa,uBAAuB,SAAS;;;;cCSnC;;iBAGG,sBAAsB,MAAM;;iBAK5B,oBAAoB,iBAAiB,SAAS;;iBAU9C,cAAc,mBAAmB"}
|
package/dist/internal.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as commandPatternParts, d as isOptionalCommandPatternPart, f as tokenizeCommandPattern, i as renderPromptValue, l as isCommandCaptureToken, n as maxStoredFindingsLimit, o as configFactoryBrand, p as unsupportedCommandRestCaptureError, s as assertSupportedCommandRestCapture, t as defaultMaxStoredFindings, u as isCommandRestCaptureToken } from "./config-CpCLnuAf.mjs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
//#region src/standalone-declaration.ts
|
|
4
4
|
async function readSdkDeclarationSourceWithChunk(module, declarationPath) {
|
|
@@ -73,7 +73,7 @@ function zodShimDeclaration() {
|
|
|
73
73
|
const reviewOutputSchemaId = "core/pr-review";
|
|
74
74
|
/** Returns whether a tool is one of pipr's built-in read-only tools. */
|
|
75
75
|
function isBuiltinReadOnlyTool(tool) {
|
|
76
|
-
return
|
|
76
|
+
return tool.builtinReadOnly === true;
|
|
77
77
|
}
|
|
78
78
|
/** Checks that an unknown value is a pipr configuration factory. */
|
|
79
79
|
function isPiprConfigFactory(value) {
|
package/dist/internal.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.mjs","names":[],"sources":["../src/standalone-declaration.ts","../src/internal.ts"],"sourcesContent":["import path from \"node:path\";\n\nexport type SdkDeclarationModule = {\n moduleName: string;\n source: string;\n};\n\nexport async function readSdkDeclarationSourceWithChunk(\n module: { moduleName: string },\n declarationPath: string,\n): Promise<string> {\n const source = await Bun.file(declarationPath).text();\n if (module.moduleName !== \"@usepipr/sdk\") {\n return source;\n }\n const chunkFileName = source.match(/from \"\\.\\/(?<chunk>index-[A-Za-z0-9_-]+)\\.mjs\"/)?.groups\n ?.chunk;\n if (!chunkFileName) {\n return source;\n }\n const chunkPath = path.join(path.dirname(declarationPath), `${chunkFileName}.d.mts`);\n const chunk = await Bun.file(chunkPath).text();\n const declarations = chunk.replace(/^export \\{.*\\};$/gm, \"\");\n return `${declarations}\\n${source}`;\n}\n\nexport function embeddedSdkDeclaration(modules: SdkDeclarationModule[]): string {\n const declaration = [\n \"// biome-ignore-all format: generated from @usepipr/sdk declarations\",\n \"// biome-ignore-all assist/source/organizeImports: generated from @usepipr/sdk declarations\",\n ...modules.map(declarationModuleBlock),\n \"\",\n ].join(\"\\n\");\n if (declaration.includes('from \"zod\"') || declaration.includes(\"z.ZodType\")) {\n throw new Error(\"embedded SDK declaration must be standalone and must not import zod\");\n }\n return declaration;\n}\n\nfunction declarationModuleBlock(module: SdkDeclarationModule): string {\n return [`declare module \"${module.moduleName}\" {`, declarationSource(module).trim(), \"}\"].join(\n \"\\n\",\n );\n}\n\nfunction declarationSource(module: SdkDeclarationModule): string {\n const source = module.source\n .replace(/^declare /gm, \"\")\n .replace(/^import \\{ (?:z|z, z as z\\$1|z as z\\$1) \\} from \"zod\";$/gm, zodShimDeclaration())\n .replaceAll(\"z$1.\", \"z.\")\n .replaceAll(\"z.ZodType\", \"ZodType\")\n .replaceAll('from \"./index.js\"', 'from \"@usepipr/sdk\"')\n .replaceAll('from \"./index.mjs\"', 'from \"@usepipr/sdk\"')\n .replace(/from \"\\.\\/index-[^\"]+\\.mjs\"/g, 'from \"@usepipr/sdk\"')\n .replace(/^import .* from \"@usepipr\\/sdk\";$/gm, \"\")\n .replace(/^\\/\\/# sourceMappingURL=.*$/gm, \"\");\n return module.moduleName === \"@usepipr/sdk\"\n ? source\n : source\n .replace(\n /^export type \\{(?<exports>.*)\\};$/gm,\n 'export type {$<exports>} from \"@usepipr/sdk\";',\n )\n .replace(/^export \\{(?<exports>.*)\\};$/gm, 'export {$<exports>} from \"@usepipr/sdk\";');\n}\n\nfunction zodShimDeclaration(): string {\n return [\n \"type ZodInfer<T> = T extends { parse(value: unknown): infer Output } ? Output : never;\",\n \"type ZodType<T = unknown, Optional extends boolean = false> = {\",\n \" readonly _piprOptional: Optional;\",\n \" parse(value: unknown): T;\",\n \" optional(): ZodType<T | undefined, true>;\",\n \" min(value: number): ZodType<T, Optional>;\",\n \" max(value: number): ZodType<T, Optional>;\",\n \" int(): ZodType<T, Optional>;\",\n \" positive(): ZodType<T, Optional>;\",\n \" finite(): ZodType<T, Optional>;\",\n \"};\",\n \"type ZodAny = ZodType<unknown, boolean>;\",\n \"type ZodOptionalKeys<T extends Record<string, ZodAny>> = { [K in keyof T]: T[K] extends ZodType<unknown, true> ? K : never }[keyof T];\",\n \"type ZodObjectOutput<T extends Record<string, ZodAny>> = { [K in Exclude<keyof T, ZodOptionalKeys<T>>]: ZodInfer<T[K]> } & { [K in ZodOptionalKeys<T>]?: ZodInfer<T[K]> };\",\n \"const z: {\",\n \" string(): ZodType<string>;\",\n \" number(): ZodType<number>;\",\n \" boolean(): ZodType<boolean>;\",\n \" null(): ZodType<null>;\",\n \" unknown(): ZodType<unknown>;\",\n \" any(): ZodType<unknown>;\",\n \" literal<T extends string | number | boolean | null>(value: T): ZodType<T>;\",\n \" enum<const T extends readonly [string, ...string[]]>(values: T): ZodType<T[number]>;\",\n \" array<T extends ZodAny>(schema: T): ZodType<Array<ZodInfer<T>>>;\",\n \" record<T extends ZodAny>(key: ZodType<string>, value: T): ZodType<Record<string, ZodInfer<T>>>;\",\n \" strictObject<T extends Record<string, ZodAny>>(shape: T): ZodType<ZodObjectOutput<T>>;\",\n \" object<T extends Record<string, ZodAny>>(shape: T): ZodType<ZodObjectOutput<T>>;\",\n \" looseObject<T extends Record<string, ZodAny>>(shape: T): ZodType<ZodObjectOutput<T> & Record<string, unknown>>;\",\n \" union<const T extends readonly [ZodAny, ZodAny, ...ZodAny[]]>(schemas: T): ZodType<ZodInfer<T[number]>>;\",\n \" json(): ZodType<JsonValue>;\",\n \" fromJSONSchema(schema: JsonSchema): ZodType<unknown>;\",\n \" toJSONSchema(schema: ZodAny): JsonSchema;\",\n \"};\",\n ].join(\"\\n\");\n}\n","import {\n
|
|
1
|
+
{"version":3,"file":"internal.mjs","names":[],"sources":["../src/standalone-declaration.ts","../src/internal.ts"],"sourcesContent":["import path from \"node:path\";\n\nexport type SdkDeclarationModule = {\n moduleName: string;\n source: string;\n};\n\nexport async function readSdkDeclarationSourceWithChunk(\n module: { moduleName: string },\n declarationPath: string,\n): Promise<string> {\n const source = await Bun.file(declarationPath).text();\n if (module.moduleName !== \"@usepipr/sdk\") {\n return source;\n }\n const chunkFileName = source.match(/from \"\\.\\/(?<chunk>index-[A-Za-z0-9_-]+)\\.mjs\"/)?.groups\n ?.chunk;\n if (!chunkFileName) {\n return source;\n }\n const chunkPath = path.join(path.dirname(declarationPath), `${chunkFileName}.d.mts`);\n const chunk = await Bun.file(chunkPath).text();\n const declarations = chunk.replace(/^export \\{.*\\};$/gm, \"\");\n return `${declarations}\\n${source}`;\n}\n\nexport function embeddedSdkDeclaration(modules: SdkDeclarationModule[]): string {\n const declaration = [\n \"// biome-ignore-all format: generated from @usepipr/sdk declarations\",\n \"// biome-ignore-all assist/source/organizeImports: generated from @usepipr/sdk declarations\",\n ...modules.map(declarationModuleBlock),\n \"\",\n ].join(\"\\n\");\n if (declaration.includes('from \"zod\"') || declaration.includes(\"z.ZodType\")) {\n throw new Error(\"embedded SDK declaration must be standalone and must not import zod\");\n }\n return declaration;\n}\n\nfunction declarationModuleBlock(module: SdkDeclarationModule): string {\n return [`declare module \"${module.moduleName}\" {`, declarationSource(module).trim(), \"}\"].join(\n \"\\n\",\n );\n}\n\nfunction declarationSource(module: SdkDeclarationModule): string {\n const source = module.source\n .replace(/^declare /gm, \"\")\n .replace(/^import \\{ (?:z|z, z as z\\$1|z as z\\$1) \\} from \"zod\";$/gm, zodShimDeclaration())\n .replaceAll(\"z$1.\", \"z.\")\n .replaceAll(\"z.ZodType\", \"ZodType\")\n .replaceAll('from \"./index.js\"', 'from \"@usepipr/sdk\"')\n .replaceAll('from \"./index.mjs\"', 'from \"@usepipr/sdk\"')\n .replace(/from \"\\.\\/index-[^\"]+\\.mjs\"/g, 'from \"@usepipr/sdk\"')\n .replace(/^import .* from \"@usepipr\\/sdk\";$/gm, \"\")\n .replace(/^\\/\\/# sourceMappingURL=.*$/gm, \"\");\n return module.moduleName === \"@usepipr/sdk\"\n ? source\n : source\n .replace(\n /^export type \\{(?<exports>.*)\\};$/gm,\n 'export type {$<exports>} from \"@usepipr/sdk\";',\n )\n .replace(/^export \\{(?<exports>.*)\\};$/gm, 'export {$<exports>} from \"@usepipr/sdk\";');\n}\n\nfunction zodShimDeclaration(): string {\n return [\n \"type ZodInfer<T> = T extends { parse(value: unknown): infer Output } ? Output : never;\",\n \"type ZodType<T = unknown, Optional extends boolean = false> = {\",\n \" readonly _piprOptional: Optional;\",\n \" parse(value: unknown): T;\",\n \" optional(): ZodType<T | undefined, true>;\",\n \" min(value: number): ZodType<T, Optional>;\",\n \" max(value: number): ZodType<T, Optional>;\",\n \" int(): ZodType<T, Optional>;\",\n \" positive(): ZodType<T, Optional>;\",\n \" finite(): ZodType<T, Optional>;\",\n \"};\",\n \"type ZodAny = ZodType<unknown, boolean>;\",\n \"type ZodOptionalKeys<T extends Record<string, ZodAny>> = { [K in keyof T]: T[K] extends ZodType<unknown, true> ? K : never }[keyof T];\",\n \"type ZodObjectOutput<T extends Record<string, ZodAny>> = { [K in Exclude<keyof T, ZodOptionalKeys<T>>]: ZodInfer<T[K]> } & { [K in ZodOptionalKeys<T>]?: ZodInfer<T[K]> };\",\n \"const z: {\",\n \" string(): ZodType<string>;\",\n \" number(): ZodType<number>;\",\n \" boolean(): ZodType<boolean>;\",\n \" null(): ZodType<null>;\",\n \" unknown(): ZodType<unknown>;\",\n \" any(): ZodType<unknown>;\",\n \" literal<T extends string | number | boolean | null>(value: T): ZodType<T>;\",\n \" enum<const T extends readonly [string, ...string[]]>(values: T): ZodType<T[number]>;\",\n \" array<T extends ZodAny>(schema: T): ZodType<Array<ZodInfer<T>>>;\",\n \" record<T extends ZodAny>(key: ZodType<string>, value: T): ZodType<Record<string, ZodInfer<T>>>;\",\n \" strictObject<T extends Record<string, ZodAny>>(shape: T): ZodType<ZodObjectOutput<T>>;\",\n \" object<T extends Record<string, ZodAny>>(shape: T): ZodType<ZodObjectOutput<T>>;\",\n \" looseObject<T extends Record<string, ZodAny>>(shape: T): ZodType<ZodObjectOutput<T> & Record<string, unknown>>;\",\n \" union<const T extends readonly [ZodAny, ZodAny, ...ZodAny[]]>(schemas: T): ZodType<ZodInfer<T[number]>>;\",\n \" json(): ZodType<JsonValue>;\",\n \" fromJSONSchema(schema: JsonSchema): ZodType<unknown>;\",\n \" toJSONSchema(schema: ZodAny): JsonSchema;\",\n \"};\",\n ].join(\"\\n\");\n}\n","import {\n type ConfigFactoryValue,\n configFactoryBrand,\n type InternalPiprConfigFactory,\n} from \"./internal-contract.js\";\nimport type { RuntimeAgentTool } from \"./runtime-contract.js\";\n\nexport type {\n RuntimeAgent,\n RuntimeAgentDefinition,\n RuntimeAgentTool,\n RuntimePlan,\n RuntimeTask,\n} from \"./runtime-contract.js\";\nexport { defaultMaxStoredFindings, maxStoredFindingsLimit } from \"./types/config.js\";\n\nimport type { RuntimePlan } from \"./runtime-contract.js\";\n\nexport {\n assertSupportedCommandRestCapture,\n commandPatternParts,\n isCommandCaptureToken,\n isCommandRestCaptureToken,\n isOptionalCommandPatternPart,\n tokenizeCommandPattern,\n unsupportedCommandRestCaptureError,\n} from \"./command-grammar.js\";\nexport { renderPromptValue } from \"./prompt-render.js\";\nexport type { SdkDeclarationModule } from \"./standalone-declaration.js\";\nexport {\n embeddedSdkDeclaration,\n readSdkDeclarationSourceWithChunk,\n} from \"./standalone-declaration.js\";\n\n/** Stable identifier for Pipr's built-in change request review output schema. */\nexport const reviewOutputSchemaId = \"core/pr-review\";\n\n/** Returns whether a tool is one of pipr's built-in read-only tools. */\nexport function isBuiltinReadOnlyTool(tool: RuntimeAgentTool): boolean {\n return tool.builtinReadOnly === true;\n}\n\n/** Checks that an unknown value is a pipr configuration factory. */\nexport function isPiprConfigFactory(value: unknown): value is ConfigFactoryValue {\n return (\n typeof value === \"object\" &&\n value !== null &&\n Reflect.get(value, \"kind\") === \"pipr.config-factory\" &&\n Reflect.get(value, configFactoryBrand) === true\n );\n}\n\n/** Builds a runtime plan from a pipr configuration factory. */\nexport function buildPiprPlan(factory: unknown): RuntimePlan {\n if (!isInternalPiprConfigFactory(factory)) {\n throw new Error(\"Expected a pipr configuration factory\");\n }\n return factory.build();\n}\n\nfunction isInternalPiprConfigFactory(value: unknown): value is InternalPiprConfigFactory {\n return isPiprConfigFactory(value) && typeof Reflect.get(value, \"build\") === \"function\";\n}\n"],"mappings":";;;AAOA,eAAsB,kCACpB,QACA,iBACiB;CACjB,MAAM,SAAS,MAAM,IAAI,KAAK,eAAe,CAAC,CAAC,KAAK;CACpD,IAAI,OAAO,eAAe,gBACxB,OAAO;CAET,MAAM,gBAAgB,OAAO,MAAM,gDAAgD,CAAC,EAAE,QAClF;CACJ,IAAI,CAAC,eACH,OAAO;CAET,MAAM,YAAY,KAAK,KAAK,KAAK,QAAQ,eAAe,GAAG,GAAG,cAAc,OAAO;CAGnF,OAAO,IADc,MADD,IAAI,KAAK,SAAS,CAAC,CAAC,KAAK,EAAA,CAClB,QAAQ,sBAAsB,EACpC,EAAE,IAAI;AAC7B;AAEA,SAAgB,uBAAuB,SAAyC;CAC9E,MAAM,cAAc;EAClB;EACA;EACA,GAAG,QAAQ,IAAI,sBAAsB;EACrC;CACF,CAAC,CAAC,KAAK,IAAI;CACX,IAAI,YAAY,SAAS,cAAY,KAAK,YAAY,SAAS,WAAW,GACxE,MAAM,IAAI,MAAM,qEAAqE;CAEvF,OAAO;AACT;AAEA,SAAS,uBAAuB,QAAsC;CACpE,OAAO;EAAC,mBAAmB,OAAO,WAAW;EAAM,kBAAkB,MAAM,CAAC,CAAC,KAAK;EAAG;CAAG,CAAC,CAAC,KACxF,IACF;AACF;AAEA,SAAS,kBAAkB,QAAsC;CAC/D,MAAM,SAAS,OA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0.6.0",
|
|
4
4
|
"description": "TypeScript configuration SDK for Pipr code host review automation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"access": "public"
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
|
-
"dist"
|
|
20
|
+
"dist",
|
|
21
|
+
"LICENSE"
|
|
21
22
|
],
|
|
22
23
|
"sideEffects": false,
|
|
23
24
|
"main": "./dist/index.mjs",
|
package/dist/config-Ct0Qfa_b.mjs
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
//#region src/command-grammar.ts
|
|
2
|
-
function commandPatternParts(pattern) {
|
|
3
|
-
return pattern.match(/\[[^\]]+\]|[^\s]+/g) ?? [];
|
|
4
|
-
}
|
|
5
|
-
function tokenizeCommandPattern(value) {
|
|
6
|
-
return value.trim().split(/\s+/).filter(Boolean);
|
|
7
|
-
}
|
|
8
|
-
function unsupportedCommandRestCaptureError(pattern) {
|
|
9
|
-
const parts = commandPatternParts(pattern);
|
|
10
|
-
for (const [index, part] of parts.entries()) {
|
|
11
|
-
if (isOptionalCommandPatternPart(part)) {
|
|
12
|
-
const optionalRest = tokenizeCommandPattern(part.slice(1, -1)).find(isCommandRestCaptureToken);
|
|
13
|
-
if (optionalRest) return finalRequiredRestCaptureMessage(optionalRest);
|
|
14
|
-
continue;
|
|
15
|
-
}
|
|
16
|
-
if (isCommandRestCaptureToken(part) && index !== parts.length - 1) return finalRequiredRestCaptureMessage(part);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function assertSupportedCommandRestCapture(pattern) {
|
|
20
|
-
const error = unsupportedCommandRestCaptureError(pattern);
|
|
21
|
-
if (error) throw new Error(error);
|
|
22
|
-
}
|
|
23
|
-
function isOptionalCommandPatternPart(value) {
|
|
24
|
-
return value.startsWith("[") && value.endsWith("]");
|
|
25
|
-
}
|
|
26
|
-
function isCommandCaptureToken(value) {
|
|
27
|
-
return /^<[a-z0-9-]+(\.\.\.)?>$/.test(value);
|
|
28
|
-
}
|
|
29
|
-
function isCommandRestCaptureToken(value) {
|
|
30
|
-
return /^<[a-z0-9-]+\.\.\.>$/.test(value);
|
|
31
|
-
}
|
|
32
|
-
function finalRequiredRestCaptureMessage(token) {
|
|
33
|
-
return `Rest capture '${token}' must be the final required command pattern token`;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
//#region src/internal-contract.ts
|
|
37
|
-
const configFactoryBrand = Symbol.for("pipr.config.factory");
|
|
38
|
-
const builtinReadOnlyToolBrand = Symbol.for("pipr.builtin.readOnlyTool");
|
|
39
|
-
//#endregion
|
|
40
|
-
//#region src/prompt-render.ts
|
|
41
|
-
/** Renders a prompt source/value into plain text for Pi prompts. */
|
|
42
|
-
function renderPromptValue(value) {
|
|
43
|
-
if (value === void 0 || value === null) return "";
|
|
44
|
-
if (typeof value === "string") return value;
|
|
45
|
-
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
46
|
-
if (typeof value === "object" && value !== null && Reflect.get(value, "kind") === "pipr.prompt") return value.value;
|
|
47
|
-
return JSON.stringify(value, null, 2);
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
50
|
-
//#region src/types/config.ts
|
|
51
|
-
const defaultMaxStoredFindings = 50;
|
|
52
|
-
const maxStoredFindingsLimit = 100;
|
|
53
|
-
//#endregion
|
|
54
|
-
export { configFactoryBrand as a, isCommandCaptureToken as c, tokenizeCommandPattern as d, unsupportedCommandRestCaptureError as f, builtinReadOnlyToolBrand as i, isCommandRestCaptureToken as l, maxStoredFindingsLimit as n, assertSupportedCommandRestCapture as o, renderPromptValue as r, commandPatternParts as s, defaultMaxStoredFindings as t, isOptionalCommandPatternPart as u };
|
|
55
|
-
|
|
56
|
-
//# sourceMappingURL=config-Ct0Qfa_b.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-Ct0Qfa_b.mjs","names":[],"sources":["../src/command-grammar.ts","../src/internal-contract.ts","../src/prompt-render.ts","../src/types/config.ts"],"sourcesContent":["export function commandPatternParts(pattern: string): string[] {\n return pattern.match(/\\[[^\\]]+\\]|[^\\s]+/g) ?? [];\n}\n\nexport function tokenizeCommandPattern(value: string): string[] {\n return value.trim().split(/\\s+/).filter(Boolean);\n}\n\nexport function unsupportedCommandRestCaptureError(pattern: string): string | undefined {\n const parts = commandPatternParts(pattern);\n for (const [index, part] of parts.entries()) {\n if (isOptionalCommandPatternPart(part)) {\n const optionalRest = tokenizeCommandPattern(part.slice(1, -1)).find(\n isCommandRestCaptureToken,\n );\n if (optionalRest) {\n return finalRequiredRestCaptureMessage(optionalRest);\n }\n continue;\n }\n if (isCommandRestCaptureToken(part) && index !== parts.length - 1) {\n return finalRequiredRestCaptureMessage(part);\n }\n }\n return undefined;\n}\n\nexport function assertSupportedCommandRestCapture(pattern: string): void {\n const error = unsupportedCommandRestCaptureError(pattern);\n if (error) {\n throw new Error(error);\n }\n}\n\nexport function isOptionalCommandPatternPart(value: string): boolean {\n return value.startsWith(\"[\") && value.endsWith(\"]\");\n}\n\nexport function isCommandCaptureToken(value: string): boolean {\n return /^<[a-z0-9-]+(\\.\\.\\.)?>$/.test(value);\n}\n\nexport function isCommandRestCaptureToken(value: string): boolean {\n return /^<[a-z0-9-]+\\.\\.\\.>$/.test(value);\n}\n\nfunction finalRequiredRestCaptureMessage(token: string): string {\n return `Rest capture '${token}' must be the final required command pattern token`;\n}\n","import type { RuntimePlan } from \"./runtime-contract.js\";\n\nexport const configFactoryBrand = Symbol.for(\"pipr.config.factory\");\nexport const builtinReadOnlyToolBrand = Symbol.for(\"pipr.builtin.readOnlyTool\");\n\nexport type ConfigFactoryValue = {\n readonly kind: \"pipr.config-factory\";\n};\n\nexport type InternalPiprConfigFactory = ConfigFactoryValue & {\n readonly [configFactoryBrand]: true;\n build(): RuntimePlan;\n};\n","import type { PromptText, PromptValue } from \"./index.js\";\n\n/** Renders a prompt source/value into plain text for Pi prompts. */\nexport function renderPromptValue(value: PromptValue): string {\n if (value === undefined || value === null) {\n return \"\";\n }\n if (typeof value === \"string\") {\n return value;\n }\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n return String(value);\n }\n if (typeof value === \"object\" && value !== null && Reflect.get(value, \"kind\") === \"pipr.prompt\") {\n return (value as PromptText).value;\n }\n return JSON.stringify(value, null, 2);\n}\n","import type { RuntimeLimits } from \"./manifest.js\";\n\nexport const defaultMaxStoredFindings = 50;\nexport const maxStoredFindingsLimit = 100;\n\n/** Repository permission levels used to authorize pipr commands. */\nexport type RepositoryPermission = \"read\" | \"triage\" | \"write\" | \"maintain\" | \"admin\";\n\n/** Pull request lifecycle actions that can trigger change-request tasks. */\nexport type ChangeRequestAction = \"opened\" | \"updated\" | \"reopened\" | \"ready\" | \"closed\";\n\n/** Duration accepted by timeout options, either seconds as a number or a suffixed string. */\nexport type DurationInput = number | `${number}s` | `${number}m` | `${number}h`;\n\n/** Reference to a secret that pipr resolves from the runtime environment. */\nexport type SecretRef = {\n readonly kind: \"pipr.secret\";\n readonly name: string;\n};\n\n/** Options for declaring a secret by environment variable name. */\nexport type SecretOptions = {\n name: string;\n};\n\n/** Options for registering a model provider and model id. */\nexport type ModelOptions = {\n id?: string;\n provider: string;\n model: string;\n apiKey?: SecretRef;\n options?: Record<string, unknown>;\n};\n\n/** Registered model profile that can be used by reviewers and agents. */\nexport type ModelProfile = {\n readonly kind: \"pipr.model\";\n readonly id: string;\n readonly provider: string;\n readonly model: string;\n readonly apiKey?: SecretRef;\n readonly options?: Record<string, unknown>;\n};\n\n/** Aggregate check-run options for a Pipr review run. */\nexport type AggregateCheckOptions =\n | false\n | {\n enabled?: boolean;\n name?: string;\n };\n\n/** Check-run settings for a pipr config. */\nexport type ChecksOptions = {\n aggregate?: AggregateCheckOptions;\n};\n\n/** Actor policy for auto-resolving inline review threads from user replies. */\nexport type AutoResolveAllowedActors = \"author-or-write\" | \"write\" | \"any\";\n\n/** Options controlling auto-resolve behavior for user replies. */\nexport type AutoResolveUserRepliesOptions = {\n enabled?: boolean;\n respondWhenStillValid?: boolean;\n allowedActors?: AutoResolveAllowedActors;\n};\n\n/** Options controlling automatic stale-finding resolution. */\nexport type AutoResolveOptions =\n | false\n | {\n enabled?: boolean;\n model?: ModelProfile;\n instructions?: string;\n synchronize?: boolean;\n userReplies?: boolean | AutoResolveUserRepliesOptions;\n };\n\n/** Review publication settings. */\nexport type PublicationOptions = {\n maxInlineComments?: number;\n maxStoredFindings?: number;\n autoResolve?: AutoResolveOptions;\n showHeader?: boolean;\n showFooter?: boolean;\n showStats?: boolean;\n};\n\n/** Top-level pipr config settings. */\nexport type PiprConfigOptions = {\n publication?: PublicationOptions;\n checks?: ChecksOptions;\n limits?: RuntimeLimits;\n};\n"],"mappings":";AAAA,SAAgB,oBAAoB,SAA2B;CAC7D,OAAO,QAAQ,MAAM,oBAAoB,KAAK,CAAC;AACjD;AAEA,SAAgB,uBAAuB,OAAyB;CAC9D,OAAO,MAAM,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO;AACjD;AAEA,SAAgB,mCAAmC,SAAqC;CACtF,MAAM,QAAQ,oBAAoB,OAAO;CACzC,KAAK,MAAM,CAAC,OAAO,SAAS,MAAM,QAAQ,GAAG;EAC3C,IAAI,6BAA6B,IAAI,GAAG;GACtC,MAAM,eAAe,uBAAuB,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,KAC7D,yBACF;GACA,IAAI,cACF,OAAO,gCAAgC,YAAY;GAErD;EACF;EACA,IAAI,0BAA0B,IAAI,KAAK,UAAU,MAAM,SAAS,GAC9D,OAAO,gCAAgC,IAAI;CAE/C;AAEF;AAEA,SAAgB,kCAAkC,SAAuB;CACvE,MAAM,QAAQ,mCAAmC,OAAO;CACxD,IAAI,OACF,MAAM,IAAI,MAAM,KAAK;AAEzB;AAEA,SAAgB,6BAA6B,OAAwB;CACnE,OAAO,MAAM,WAAW,GAAG,KAAK,MAAM,SAAS,GAAG;AACpD;AAEA,SAAgB,sBAAsB,OAAwB;CAC5D,OAAO,0BAA0B,KAAK,KAAK;AAC7C;AAEA,SAAgB,0BAA0B,OAAwB;CAChE,OAAO,uBAAuB,KAAK,KAAK;AAC1C;AAEA,SAAS,gCAAgC,OAAuB;CAC9D,OAAO,iBAAiB,MAAM;AAChC;;;AC9CA,MAAa,qBAAqB,OAAO,IAAI,qBAAqB;AAClE,MAAa,2BAA2B,OAAO,IAAI,2BAA2B;;;;ACA9E,SAAgB,kBAAkB,OAA4B;CAC5D,IAAI,UAAU,KAAA,KAAa,UAAU,MACnC,OAAO;CAET,IAAI,OAAO,UAAU,UACnB,OAAO;CAET,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,WAChD,OAAO,OAAO,KAAK;CAErB,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,QAAQ,IAAI,OAAO,MAAM,MAAM,eAChF,OAAQ,MAAqB;CAE/B,OAAO,KAAK,UAAU,OAAO,MAAM,CAAC;AACtC;;;ACfA,MAAa,2BAA2B;AACxC,MAAa,yBAAyB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-D_XmBHeL.d.mts","names":[],"sources":["../src/types/schema.ts","../src/review-contract.ts","../src/types/manifest.ts","../src/types/config.ts","../src/types/prompt.ts","../src/types/agent.ts","../src/types/task.ts","../src/builder.ts","../src/prompt.ts","../src/schema.ts"],"mappings":";;;KAGY;;KAEA,YAAY,gBAAgB,cAAc;;KAE1C;GAAgB,cAAc;;;KAE9B,aAAa;;KAGb,kBAAkB;EAAO;EAAe,MAAM;;EAAQ;EAAgB,OAAO;;;KAG7E,OAAO;WACR;WACA;WACA,aAAa;EACtB,MAAM,iBAAiB;EACvB,UAAU,iBAAiB,kBAAkB;;;KAInC,UAAU,KAAK,EAAE,QAAQ;;KAGzB,iBAAiB;EAC3B;EACA,QAAQ,UAAU;;;KAIR;EACV;EACA,QAAQ;;;;;KC/BE;EACV;EACA;;;KAIU;EACV;EACA;EACA;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