@usepipr/sdk 0.5.0 → 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/dist/{config-STm6gTIf.mjs → config-CpCLnuAf.mjs} +10 -2
- package/dist/{config-STm6gTIf.mjs.map → config-CpCLnuAf.mjs.map} +1 -1
- package/dist/{index-D9q-ZDr-.d.mts → index-Bdey1nho.d.mts} +56 -24
- package/dist/index-Bdey1nho.d.mts.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +83 -29
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.mts +1 -1
- package/dist/internal.mjs +1 -1
- package/package.json +1 -1
- package/dist/index-D9q-ZDr-.d.mts.map +0 -1
|
@@ -104,7 +104,15 @@ function renderPromptValue(value) {
|
|
|
104
104
|
//#region src/types/config.ts
|
|
105
105
|
const defaultMaxStoredFindings = 50;
|
|
106
106
|
const maxStoredFindingsLimit = 100;
|
|
107
|
+
const modelThinkingLevels = [
|
|
108
|
+
"off",
|
|
109
|
+
"minimal",
|
|
110
|
+
"low",
|
|
111
|
+
"medium",
|
|
112
|
+
"high",
|
|
113
|
+
"xhigh"
|
|
114
|
+
];
|
|
107
115
|
//#endregion
|
|
108
|
-
export {
|
|
116
|
+
export { serializePromptJson as a, commandPatternParts as c, isOptionalCommandPatternPart as d, tokenizeCommandPattern as f, renderPromptValue as i, isCommandCaptureToken as l, maxStoredFindingsLimit as n, configFactoryBrand as o, unsupportedCommandRestCaptureError as p, modelThinkingLevels as r, assertSupportedCommandRestCapture as s, defaultMaxStoredFindings as t, isCommandRestCaptureToken as u };
|
|
109
117
|
|
|
110
|
-
//# sourceMappingURL=config-
|
|
118
|
+
//# sourceMappingURL=config-CpCLnuAf.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-STm6gTIf.mjs","names":[],"sources":["../src/command-grammar.ts","../src/internal-contract.ts","../src/prompt-json.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\");\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","const promptJsonSerializationError = \"Prompt value must be JSON-serializable\";\nconst unsupportedJsonCollectionTypes = [Map, Set, WeakMap, WeakSet] as const;\n\n/** Serializes one prompt JSON value without silently dropping unsupported data. */\nexport function serializePromptJson(value: unknown, pretty: boolean): string {\n try {\n assertJsonSerializable(value, new Set<object>());\n const rendered = JSON.stringify(value, strictJsonReplacer, pretty ? 2 : 0);\n if (rendered === undefined) {\n throw new Error(promptJsonSerializationError);\n }\n return rendered;\n } catch {\n throw new Error(promptJsonSerializationError);\n }\n}\n\nfunction assertJsonSerializable(value: unknown, ancestors: Set<object>): void {\n assertJsonPrimitive(value);\n if (typeof value !== \"object\" || value === null) {\n return;\n }\n if (ancestors.has(value)) {\n throw new Error(promptJsonSerializationError);\n }\n assertJsonObjectShape(value);\n ancestors.add(value);\n for (const key of Reflect.ownKeys(value)) {\n if (!Object.prototype.propertyIsEnumerable.call(value, key)) {\n continue;\n }\n if (typeof key === \"symbol\") {\n throw new Error(promptJsonSerializationError);\n }\n assertJsonSerializable(Reflect.get(value, key), ancestors);\n }\n ancestors.delete(value);\n}\n\nfunction assertJsonObjectShape(value: object): void {\n if (unsupportedJsonCollectionTypes.some((Collection) => value instanceof Collection)) {\n throw new Error(promptJsonSerializationError);\n }\n if (\n Array.isArray(value) &&\n Object.keys(value).some((key) => !isSerializedArrayIndex(value, key))\n ) {\n throw new Error(promptJsonSerializationError);\n }\n}\n\nfunction isSerializedArrayIndex(value: unknown[], key: string): boolean {\n const index = Number(key);\n return Number.isInteger(index) && index >= 0 && String(index) === key && index < value.length;\n}\n\nfunction strictJsonReplacer(_key: string, value: unknown): unknown {\n assertJsonPrimitive(value);\n if (typeof value === \"object\" && value !== null) {\n assertJsonObjectShape(value);\n if (\n Object.getOwnPropertySymbols(value).some((key) =>\n Object.prototype.propertyIsEnumerable.call(value, key),\n )\n ) {\n throw new Error(promptJsonSerializationError);\n }\n }\n return value;\n}\n\nfunction assertJsonPrimitive(value: unknown): void {\n const type = typeof value;\n if (type === \"undefined\" || type === \"function\" || type === \"symbol\" || type === \"bigint\") {\n throw new Error(promptJsonSerializationError);\n }\n if (type === \"number\" && !Number.isFinite(value)) {\n throw new Error(promptJsonSerializationError);\n }\n}\n","import type { PromptText, PromptValue } from \"./index.js\";\nimport { serializePromptJson } from \"./prompt-json.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\") {\n return serializePromptJson(value, false);\n }\n if (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 serializePromptJson(value, true);\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,MA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a,2BAA2B;AACxC,MAAa,yBAAyB"}
|
|
1
|
+
{"version":3,"file":"config-CpCLnuAf.mjs","names":[],"sources":["../src/command-grammar.ts","../src/internal-contract.ts","../src/prompt-json.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\");\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","const promptJsonSerializationError = \"Prompt value must be JSON-serializable\";\nconst unsupportedJsonCollectionTypes = [Map, Set, WeakMap, WeakSet] as const;\n\n/** Serializes one prompt JSON value without silently dropping unsupported data. */\nexport function serializePromptJson(value: unknown, pretty: boolean): string {\n try {\n assertJsonSerializable(value, new Set<object>());\n const rendered = JSON.stringify(value, strictJsonReplacer, pretty ? 2 : 0);\n if (rendered === undefined) {\n throw new Error(promptJsonSerializationError);\n }\n return rendered;\n } catch {\n throw new Error(promptJsonSerializationError);\n }\n}\n\nfunction assertJsonSerializable(value: unknown, ancestors: Set<object>): void {\n assertJsonPrimitive(value);\n if (typeof value !== \"object\" || value === null) {\n return;\n }\n if (ancestors.has(value)) {\n throw new Error(promptJsonSerializationError);\n }\n assertJsonObjectShape(value);\n ancestors.add(value);\n for (const key of Reflect.ownKeys(value)) {\n if (!Object.prototype.propertyIsEnumerable.call(value, key)) {\n continue;\n }\n if (typeof key === \"symbol\") {\n throw new Error(promptJsonSerializationError);\n }\n assertJsonSerializable(Reflect.get(value, key), ancestors);\n }\n ancestors.delete(value);\n}\n\nfunction assertJsonObjectShape(value: object): void {\n if (unsupportedJsonCollectionTypes.some((Collection) => value instanceof Collection)) {\n throw new Error(promptJsonSerializationError);\n }\n if (\n Array.isArray(value) &&\n Object.keys(value).some((key) => !isSerializedArrayIndex(value, key))\n ) {\n throw new Error(promptJsonSerializationError);\n }\n}\n\nfunction isSerializedArrayIndex(value: unknown[], key: string): boolean {\n const index = Number(key);\n return Number.isInteger(index) && index >= 0 && String(index) === key && index < value.length;\n}\n\nfunction strictJsonReplacer(_key: string, value: unknown): unknown {\n assertJsonPrimitive(value);\n if (typeof value === \"object\" && value !== null) {\n assertJsonObjectShape(value);\n if (\n Object.getOwnPropertySymbols(value).some((key) =>\n Object.prototype.propertyIsEnumerable.call(value, key),\n )\n ) {\n throw new Error(promptJsonSerializationError);\n }\n }\n return value;\n}\n\nfunction assertJsonPrimitive(value: unknown): void {\n const type = typeof value;\n if (type === \"undefined\" || type === \"function\" || type === \"symbol\" || type === \"bigint\") {\n throw new Error(promptJsonSerializationError);\n }\n if (type === \"number\" && !Number.isFinite(value)) {\n throw new Error(promptJsonSerializationError);\n }\n}\n","import type { PromptText, PromptValue } from \"./index.js\";\nimport { serializePromptJson } from \"./prompt-json.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\") {\n return serializePromptJson(value, false);\n }\n if (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 serializePromptJson(value, true);\n}\n","import type { RuntimeLimits } from \"./manifest.js\";\n\nexport const defaultMaxStoredFindings = 50;\nexport const maxStoredFindingsLimit = 100;\nexport const modelThinkingLevels = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\"] as const;\nexport type ModelThinkingLevel = (typeof modelThinkingLevels)[number];\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 thinking?: ModelThinkingLevel;\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 thinking?: ModelThinkingLevel;\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,C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B,OAAO;CAET,IAAI,OAAO,UAAU,UACnB,OAAO,oBAAoB,OAAO,KAAK;CAEzC,IAAI,OAAO,UAAU,WACnB,OAAO,OAAO,KAAK;CAErB,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,QAAQ,IAAI,OAAO,MAAM,MAAM,eAChF,OAAQ,MAAqB;CAE/B,OAAO,oBAAoB,OAAO,IAAI;AACxC;;;ACnBA,MAAa,2BAA2B;AACxC,MAAa,yBAAyB;AACtC,MAAa,sBAAsB;CAAC;CAAO;CAAW;CAAO;CAAU;CAAQ;AAAO"}
|
|
@@ -55,19 +55,26 @@ type ReviewFinding = {
|
|
|
55
55
|
endLine: number;
|
|
56
56
|
suggestedFix?: string;
|
|
57
57
|
};
|
|
58
|
+
/** Core structured collection of inline findings produced by a review agent. */
|
|
59
|
+
type ReviewFindingsResult = {
|
|
60
|
+
inlineFindings: ReviewFinding[];
|
|
61
|
+
};
|
|
58
62
|
/** Core structured review result accepted by pipr review publication. */
|
|
59
|
-
type ReviewResult = {
|
|
63
|
+
type ReviewResult = ReviewFindingsResult & {
|
|
60
64
|
summary: ReviewSummary;
|
|
61
|
-
inlineFindings: ReviewFinding[];
|
|
62
65
|
};
|
|
63
66
|
/** Zod schema for a review summary. */
|
|
64
67
|
declare const reviewSummarySchema: ZodSchema<ReviewSummary>;
|
|
65
68
|
/** Zod schema for one inline review finding. */
|
|
66
69
|
declare const reviewFindingSchema: ZodSchema<ReviewFinding>;
|
|
70
|
+
/** Zod schema for Pipr's core inline-finding result. */
|
|
71
|
+
declare const reviewFindingsResultSchema: ZodSchema<ReviewFindingsResult>;
|
|
67
72
|
/** Zod schema for Pipr's core change request review result. */
|
|
68
73
|
declare const reviewResultSchema: ZodSchema<ReviewResult>;
|
|
69
74
|
/** Parses model output for Pipr's main change request review schema. */
|
|
70
75
|
declare function parseReviewResult(value: unknown): ReviewResult;
|
|
76
|
+
/** Parses model output for Pipr's inline-finding schema. */
|
|
77
|
+
declare function parseReviewFindingsResult(value: unknown): ReviewFindingsResult;
|
|
71
78
|
/** Parses a review summary value. */
|
|
72
79
|
declare function parseReviewSummary(value: unknown): ReviewSummary;
|
|
73
80
|
/** Parses one inline review finding. */
|
|
@@ -249,6 +256,7 @@ type DiffManifestOptions = {
|
|
|
249
256
|
};
|
|
250
257
|
/** Size limits for Diff Manifest prompt and runtime-tool payloads. */
|
|
251
258
|
type DiffManifestLimits = {
|
|
259
|
+
maxShards?: number;
|
|
252
260
|
fullMaxBytes?: number;
|
|
253
261
|
fullMaxEstimatedTokens?: number;
|
|
254
262
|
condensedMaxBytes?: number;
|
|
@@ -258,12 +266,15 @@ type DiffManifestLimits = {
|
|
|
258
266
|
/** Runtime limits for a pipr config. */
|
|
259
267
|
type RuntimeLimits = {
|
|
260
268
|
timeoutSeconds?: number;
|
|
269
|
+
maxAgentRuns?: number;
|
|
261
270
|
diffManifest?: DiffManifestLimits;
|
|
262
271
|
};
|
|
263
272
|
//#endregion
|
|
264
273
|
//#region src/types/config.d.ts
|
|
265
274
|
declare const defaultMaxStoredFindings = 50;
|
|
266
275
|
declare const maxStoredFindingsLimit = 100;
|
|
276
|
+
declare const modelThinkingLevels: readonly ["off", "minimal", "low", "medium", "high", "xhigh"];
|
|
277
|
+
type ModelThinkingLevel = (typeof modelThinkingLevels)[number];
|
|
267
278
|
/** Repository permission levels used to authorize pipr commands. */
|
|
268
279
|
type RepositoryPermission = "read" | "triage" | "write" | "maintain" | "admin";
|
|
269
280
|
/** Pull request lifecycle actions that can trigger change-request tasks. */
|
|
@@ -285,7 +296,7 @@ type ModelOptions = {
|
|
|
285
296
|
provider: string;
|
|
286
297
|
model: string;
|
|
287
298
|
apiKey?: SecretRef;
|
|
288
|
-
|
|
299
|
+
thinking?: ModelThinkingLevel;
|
|
289
300
|
};
|
|
290
301
|
/** Registered model profile that can be used by reviewers and agents. */
|
|
291
302
|
type ModelProfile = {
|
|
@@ -294,7 +305,7 @@ type ModelProfile = {
|
|
|
294
305
|
readonly provider: string;
|
|
295
306
|
readonly model: string;
|
|
296
307
|
readonly apiKey?: SecretRef;
|
|
297
|
-
readonly
|
|
308
|
+
readonly thinking?: ModelThinkingLevel;
|
|
298
309
|
};
|
|
299
310
|
/** Aggregate check-run options for a Pipr review run. */
|
|
300
311
|
type AggregateCheckOptions = false | {
|
|
@@ -362,6 +373,7 @@ type BuiltinToolCatalog = {
|
|
|
362
373
|
};
|
|
363
374
|
/** Built-in schema catalog exposed on the pipr builder. */
|
|
364
375
|
type BuiltinSchemaCatalog = {
|
|
376
|
+
readonly inlineFindings: Schema<ReviewFindingsResult>;
|
|
365
377
|
readonly review: Schema<ReviewResult>;
|
|
366
378
|
readonly summary: Schema<ReviewSummary>;
|
|
367
379
|
};
|
|
@@ -410,8 +422,11 @@ type Agent<Input = unknown, Output = unknown> = {
|
|
|
410
422
|
//#region src/types/task.d.ts
|
|
411
423
|
/** Final review comment value produced by a task or review recipe. */
|
|
412
424
|
type CommentValue = Markdown | {
|
|
413
|
-
main
|
|
425
|
+
main: Markdown;
|
|
414
426
|
inlineFindings?: readonly ReviewFinding[];
|
|
427
|
+
} | {
|
|
428
|
+
main?: never;
|
|
429
|
+
inlineFindings: readonly ReviewFinding[];
|
|
415
430
|
};
|
|
416
431
|
/** Prior inline finding persisted by earlier pipr review state. */
|
|
417
432
|
type PriorInlineFinding = {
|
|
@@ -462,18 +477,11 @@ type CommandRegistrationOptions<Input> = CommandOptions<Input> & {
|
|
|
462
477
|
pattern: string;
|
|
463
478
|
task: Task<Input>;
|
|
464
479
|
};
|
|
465
|
-
/**
|
|
466
|
-
type
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
fallbacks?: readonly ModelProfile[];
|
|
470
|
-
instructions: PromptSource;
|
|
471
|
-
prompt?: (input: DefaultReviewInput, context: AgentPromptContext) => PromptSource | Promise<PromptSource>;
|
|
472
|
-
tools?: readonly AgentTool[];
|
|
473
|
-
timeout?: DurationInput;
|
|
480
|
+
/** Role-specific policy for the two agents created by `pipr.review`. */
|
|
481
|
+
type ReviewInstructions = {
|
|
482
|
+
findings: PromptSource;
|
|
483
|
+
summary: PromptSource;
|
|
474
484
|
};
|
|
475
|
-
/** Reviewer agent that emits pipr's core review result. */
|
|
476
|
-
type Reviewer = Agent<DefaultReviewInput, ReviewResult>;
|
|
477
485
|
/** Entrypoints created by `pipr.review`. */
|
|
478
486
|
type ReviewEntrypoints = {
|
|
479
487
|
changeRequest?: readonly ChangeRequestAction[] | false;
|
|
@@ -495,6 +503,10 @@ declare const defaultReviewEntrypoints: {
|
|
|
495
503
|
};
|
|
496
504
|
type ReviewRecipeEntrypointOptions = {
|
|
497
505
|
id: string;
|
|
506
|
+
model: ModelProfile;
|
|
507
|
+
fallbacks?: readonly ModelProfile[];
|
|
508
|
+
instructions: ReviewInstructions;
|
|
509
|
+
tools?: readonly AgentTool[];
|
|
498
510
|
entrypoints?: ReviewEntrypoints;
|
|
499
511
|
comment?: CommentValue | ((result: ReviewResult, context: ReviewCommentContext) => CommentValue | Promise<CommentValue>);
|
|
500
512
|
check?: TaskCheckOptions;
|
|
@@ -502,16 +514,36 @@ type ReviewRecipeEntrypointOptions = {
|
|
|
502
514
|
paths?: PathFilter;
|
|
503
515
|
};
|
|
504
516
|
/** Options for `pipr.review`, pipr's default review recipe. */
|
|
505
|
-
type ReviewRecipeOptions =
|
|
506
|
-
reviewer: Reviewer;
|
|
507
|
-
}) | (ReviewRecipeEntrypointOptions & ReviewerOptions & {
|
|
508
|
-
reviewer?: undefined;
|
|
509
|
-
});
|
|
517
|
+
type ReviewRecipeOptions = ReviewRecipeEntrypointOptions;
|
|
510
518
|
/** Default input passed to a reviewer created by `pipr.review`. */
|
|
511
519
|
type DefaultReviewInput = {
|
|
512
520
|
manifest: DiffManifest;
|
|
513
521
|
change: ChangeRequestInfo;
|
|
514
522
|
};
|
|
523
|
+
/** Bounded Diff Manifest projection passed to the summary agent created by `pipr.review`. */
|
|
524
|
+
type DefaultReviewSummaryManifest = {
|
|
525
|
+
baseSha: string;
|
|
526
|
+
headSha: string;
|
|
527
|
+
mergeBaseSha: string;
|
|
528
|
+
fileCount: number;
|
|
529
|
+
omittedFileCount: number;
|
|
530
|
+
files: readonly {
|
|
531
|
+
path: string;
|
|
532
|
+
previousPath?: string;
|
|
533
|
+
status: DiffManifest["files"][number]["status"];
|
|
534
|
+
language?: string;
|
|
535
|
+
additions: number;
|
|
536
|
+
deletions: number;
|
|
537
|
+
changedSymbols?: readonly string[];
|
|
538
|
+
excludedReason?: string;
|
|
539
|
+
}[];
|
|
540
|
+
};
|
|
541
|
+
/** Input passed to the summary agent created by `pipr.review`. */
|
|
542
|
+
type DefaultReviewSummaryInput = {
|
|
543
|
+
manifestSummary: DefaultReviewSummaryManifest;
|
|
544
|
+
change: ChangeRequestInfo;
|
|
545
|
+
inlineFindings: readonly ReviewFinding[];
|
|
546
|
+
};
|
|
515
547
|
/** Context passed to a custom review comment renderer. */
|
|
516
548
|
type ReviewCommentContext = {
|
|
517
549
|
review: {
|
|
@@ -563,7 +595,6 @@ type PiprBuilder = {
|
|
|
563
595
|
model(options: ModelOptions): ModelProfile;
|
|
564
596
|
agent<Input, Output>(definition: AgentDefinition<Input, Output>): Agent<Input, Output>;
|
|
565
597
|
task<Input = void>(definition: TaskDefinition<Input>): Task<Input>;
|
|
566
|
-
reviewer(options: ReviewerOptions): Reviewer;
|
|
567
598
|
review(options: ReviewRecipeOptions): void;
|
|
568
599
|
config(options: PiprConfigOptions): void;
|
|
569
600
|
command<Input = void>(options: CommandRegistrationOptions<Input>): void;
|
|
@@ -619,6 +650,7 @@ type PiRunner = {
|
|
|
619
650
|
instructions?: PromptSource;
|
|
620
651
|
timeout?: DurationInput;
|
|
621
652
|
paths?: PathFilter;
|
|
653
|
+
maxShards?: number;
|
|
622
654
|
}): Promise<Output>;
|
|
623
655
|
};
|
|
624
656
|
/** Command context available inside command-triggered tasks. */
|
|
@@ -670,5 +702,5 @@ declare function jsonSchema<T>(definition: JsonSchemaDefinition): Schema<T>;
|
|
|
670
702
|
/** Built-in schemas available as reusable agent output contracts. */
|
|
671
703
|
declare const schemas: BuiltinSchemaCatalog;
|
|
672
704
|
//#endregion
|
|
673
|
-
export {
|
|
674
|
-
//# sourceMappingURL=index-
|
|
705
|
+
export { AutoResolveOptions as $, SchemaParseResult as $t, ReviewRecipeOptions as A, PiprRunTrigger as At, AgentDefinition as B, parseReviewSummary as Bt, PluginToolDefinition as C, PathFilter as Ct, ReviewCommentContext as D, PiprResult as Dt, RepositoryInfo as E, RuntimeLimits as Et, TaskHandler as F, ReviewResult as Ft, BuiltinToolCatalog as G, reviewSummarySchema as Gt, AgentPromptContext as H, reviewFindingsResultSchema as Ht, ToolRunOptions as I, ReviewSummary as It, PromptSource as J, JsonSchema as Jt, JsonPromptOptions as K, JsonObject as Kt, defaultReviewActions as L, parseReviewFinding as Lt, TaskCheckOptions as M, piprResultSchema as Mt, TaskContext as N, ReviewFinding as Nt, ReviewEntrypoints as O, PiprRunContext as Ot, TaskDefinition as P, ReviewFindingsResult as Pt, AutoResolveAllowedActors as Q, SchemaDefinition as Qt, defaultReviewEntrypoints as R, parseReviewFindingsResult as Rt, PlatformInfo as S, FileStatus as St, PriorReview as T, ReviewSide as Tt, AgentTool as U, reviewResultSchema as Ut, AgentExtension as V, reviewFindingSchema as Vt, BuiltinSchemaCatalog as W, reviewSchemaExample as Wt, PromptValue as X, JsonValue as Xt, PromptText as Y, JsonSchemaDefinition as Yt, AggregateCheckOptions as Z, Schema as Zt, DefaultReviewSummaryInput as _, DiffHunk as _t, md as a, ModelProfile as at, PiprBuilder as b, DiffManifestLimits as bt, ChangeRequestContext as c, PublicationOptions as ct, CheckHandle as d, SecretRef as dt, ZodSchema as en, AutoResolveUserRepliesOptions as et, CommandContext as f, defaultMaxStoredFindings as ft, DefaultReviewInput as g, CommentableRange as gt, CommentValue as h, ChangedFile as ht, schemas as i, ModelOptions as it, Task as j, parsePiprResult as jt, ReviewInstructions as k, PiprRunSummary as kt, ChangeRequestInfo as l, RepositoryPermission as lt, CommandRegistrationOptions as m, modelThinkingLevels as mt, jsonSchema as n, ChecksOptions as nt, definePipr as o, ModelThinkingLevel as ot, CommandOptions as p, maxStoredFindingsLimit as pt, Markdown as q, JsonPrimitive as qt, schema as r, DurationInput as rt, definePlugin as s, PiprConfigOptions as st, z$1 as t, ChangeRequestAction as tt, ChangeRequestRegistrationOptions as u, SecretOptions as ut, DefaultReviewSummaryManifest as v, DiffManifest as vt, PriorInlineFinding as w, RangeKind as wt, PiprPlugin as x, DiffManifestOptions as xt, PiRunner as y, DiffManifestFile as yt, Agent as z, parseReviewResult as zt };
|
|
706
|
+
//# sourceMappingURL=index-Bdey1nho.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-Bdey1nho.d.mts","names":[],"sources":["../src/types/schema.ts","../src/review-contract.ts","../src/result.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;EACA;EACA;EACA;EACA;;;KAIU;EACV,gBAAgB;;;KAIN,eAAe;EACzB,SAAS;;;cAME,qBAAqB,UAAU;;cAM/B,qBAAqB,UAAU;;cAW/B,4BAA4B,UAAU;;cAKtC,oBAAoB,UAAU;;iBAM3B,kBAAkB,iBAAiB;;iBAKnC,0BAA0B,iBAAiB;;iBAK3C,mBAAmB,iBAAi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AAK,OAAO,QAAQ,YAAY,qBAAqB,OAAO,UAAU,UAAU,OAAO;EACvF,OAAO,GAAG,YAAY,iBAAiB,KAAK,OAAO;EACnD,WAAW,GAAG,YAAY,uBAAuB,OAAO;EACxD,OAAO,SAAS,yBAAyB,QAAQ,gBAAgB;EACjE,QAAQ,eAAe,OAAO,cAAc;EAC5C,KAAK,gBAAgB,UAAU,oBAAoB;;;KAIzC;EACV;EACA;EACA;EACA;EACA;;;KAIU;EACV;EACA;EACA;EACA;EACA;IAAW;;EACX;IAAQ;IAAc;;EACtB;IAAQ;IAAc;;EACtB;;;KAIU;EACV;;;KAIU,uBAAuB;EACjC,aAAa,UAAU,sBAAsB,QAAQ;EACrD,gBAAgB,iBAAiB;;;KAIvB;EACV,IAAI,OAAO,QACT,OAAO,MAAM,OAAO,SACpB,OAAO,OACP;IACE,QAAQ;IACR,qBAAqB;IACrB,eAAe;IACf,UAAU;IACV,QAAQ;IACR;MAED,QAAQ;;;KAID;WACD;WACA;WACA,WAAW;EACpB,MAAM,UAAU,WAAW;;;KAIjB;;WAED,KAAK;WACL,YAAY;WACZ,QAAQ;WACR,UAAU;WACV,IAAI;WACJ,UAAU;EACnB,OAAO,QAAQ;WACN;IACP,SAAS,QAAQ;;WAEV,OAAO;EAChB,QAAQ,OAAO,eAAe;WACrB;IACP,KAAK;IACL,KAAK;IACL,MAAM;;;;;;iBCvRM,WAAW,YAAY,MAAM;WAClC;;;iBAsBK,aAAa,QAAQ,QAAQ,SAAS,gBAAgB,SAAS,WAAW;;;;iBCrE1E,GAAG,SAAS,yBAAyB,oBAAoB;;;;iBCgBzD,OAAO,GAAG,YAAY,iBAAiB,KAAK,OAAO;;iBASnD,WAAW,GAAG,YAAY,uBAAuB,OAAO;;cAU3D,SAAS"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
export { type Agent, type AgentDefinition, type AgentExtension, type AgentPromptContext, type AgentTool, type AggregateCheckOptions, type AutoResolveAllowedActors, type AutoResolveOptions, type AutoResolveUserRepliesOptions, type BuiltinSchemaCatalog, type BuiltinToolCatalog, type ChangeRequestAction, type ChangeRequestContext, type ChangeRequestInfo, type ChangeRequestRegistrationOptions, type ChangedFile, type CheckHandle, type ChecksOptions, type CommandContext, type CommandOptions, type CommandRegistrationOptions, type CommentValue, type CommentableRange, type DefaultReviewInput, type DiffHunk, type DiffManifest, type DiffManifestFile, type DiffManifestLimits, type DiffManifestOptions, type DurationInput, type FileStatus, type JsonObject, type JsonPrimitive, type JsonPromptOptions, type JsonSchema, type JsonSchemaDefinition, type JsonValue, type Markdown, type ModelOptions, type ModelProfile, type PathFilter, type PiRunner, type PiprBuilder, type PiprConfigOptions, type PiprPlugin, type PiprResult, type PiprRunContext, type PiprRunSummary, type PiprRunTrigger, type PlatformInfo, type PluginToolDefinition, type PriorInlineFinding, type PriorReview, type PromptSource, type PromptText, type PromptValue, type PublicationOptions, type RangeKind, type RepositoryInfo, type RepositoryPermission, type ReviewCommentContext, type ReviewEntrypoints, type ReviewFinding, type
|
|
1
|
+
import { $ as AutoResolveOptions, $t as SchemaParseResult, A as ReviewRecipeOptions, At as PiprRunTrigger, B as AgentDefinition, Bt as parseReviewSummary, C as PluginToolDefinition, Ct as PathFilter, D as ReviewCommentContext, Dt as PiprResult, E as RepositoryInfo, Et as RuntimeLimits, F as TaskHandler, Ft as ReviewResult, G as BuiltinToolCatalog, Gt as reviewSummarySchema, H as AgentPromptContext, Ht as reviewFindingsResultSchema, I as ToolRunOptions, It as ReviewSummary, J as PromptSource, Jt as JsonSchema, K as JsonPromptOptions, Kt as JsonObject, L as defaultReviewActions, Lt as parseReviewFinding, M as TaskCheckOptions, Mt as piprResultSchema, N as TaskContext, Nt as ReviewFinding, O as ReviewEntrypoints, Ot as PiprRunContext, P as TaskDefinition, Pt as ReviewFindingsResult, Q as AutoResolveAllowedActors, Qt as SchemaDefinition, R as defaultReviewEntrypoints, Rt as parseReviewFindingsResult, S as PlatformInfo, St as FileStatus, T as PriorReview, Tt as ReviewSide, U as AgentTool, Ut as reviewResultSchema, V as AgentExtension, Vt as reviewFindingSchema, W as BuiltinSchemaCatalog, Wt as reviewSchemaExample, X as PromptValue, Xt as JsonValue, Y as PromptText, Yt as JsonSchemaDefinition, Z as AggregateCheckOptions, Zt as Schema, _ as DefaultReviewSummaryInput, _t as DiffHunk, a as md, at as ModelProfile, b as PiprBuilder, bt as DiffManifestLimits, c as ChangeRequestContext, ct as PublicationOptions, d as CheckHandle, dt as SecretRef, en as ZodSchema, et as AutoResolveUserRepliesOptions, f as CommandContext, g as DefaultReviewInput, gt as CommentableRange, h as CommentValue, ht as ChangedFile, i as schemas, it as ModelOptions, j as Task, jt as parsePiprResult, k as ReviewInstructions, kt as PiprRunSummary, l as ChangeRequestInfo, lt as RepositoryPermission, m as CommandRegistrationOptions, mt as modelThinkingLevels, n as jsonSchema, nt as ChecksOptions, o as definePipr, ot as ModelThinkingLevel, p as CommandOptions, q as Markdown, qt as JsonPrimitive, r as schema, rt as DurationInput, s as definePlugin, st as PiprConfigOptions, t as z, tt as ChangeRequestAction, u as ChangeRequestRegistrationOptions, ut as SecretOptions, v as DefaultReviewSummaryManifest, vt as DiffManifest, w as PriorInlineFinding, wt as RangeKind, x as PiprPlugin, xt as DiffManifestOptions, y as PiRunner, yt as DiffManifestFile, z as Agent, zt as parseReviewResult } from "./index-Bdey1nho.mjs";
|
|
2
|
+
export { type Agent, type AgentDefinition, type AgentExtension, type AgentPromptContext, type AgentTool, type AggregateCheckOptions, type AutoResolveAllowedActors, type AutoResolveOptions, type AutoResolveUserRepliesOptions, type BuiltinSchemaCatalog, type BuiltinToolCatalog, type ChangeRequestAction, type ChangeRequestContext, type ChangeRequestInfo, type ChangeRequestRegistrationOptions, type ChangedFile, type CheckHandle, type ChecksOptions, type CommandContext, type CommandOptions, type CommandRegistrationOptions, type CommentValue, type CommentableRange, type DefaultReviewInput, type DefaultReviewSummaryInput, type DefaultReviewSummaryManifest, type DiffHunk, type DiffManifest, type DiffManifestFile, type DiffManifestLimits, type DiffManifestOptions, type DurationInput, type FileStatus, type JsonObject, type JsonPrimitive, type JsonPromptOptions, type JsonSchema, type JsonSchemaDefinition, type JsonValue, type Markdown, type ModelOptions, type ModelProfile, type ModelThinkingLevel, type PathFilter, type PiRunner, type PiprBuilder, type PiprConfigOptions, type PiprPlugin, type PiprResult, type PiprRunContext, type PiprRunSummary, type PiprRunTrigger, type PlatformInfo, type PluginToolDefinition, type PriorInlineFinding, type PriorReview, type PromptSource, type PromptText, type PromptValue, type PublicationOptions, type RangeKind, type RepositoryInfo, type RepositoryPermission, type ReviewCommentContext, type ReviewEntrypoints, type ReviewFinding, type ReviewFindingsResult, type ReviewInstructions, type ReviewRecipeOptions, type ReviewResult, type ReviewSide, type ReviewSummary, type RuntimeLimits, type Schema, type SchemaDefinition, type SchemaParseResult, type SecretOptions, type SecretRef, type Task, type TaskCheckOptions, type TaskContext, type TaskDefinition, type TaskHandler, type ToolRunOptions, type ZodSchema, defaultReviewActions, defaultReviewEntrypoints, definePipr, definePlugin, jsonSchema, md, modelThinkingLevels, parsePiprResult, parseReviewFinding, parseReviewFindingsResult, parseReviewResult, parseReviewSummary, piprResultSchema, reviewFindingSchema, reviewFindingsResultSchema, reviewResultSchema, reviewSchemaExample, reviewSummarySchema, schema, schemas, z };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as serializePromptJson, i as renderPromptValue, o as configFactoryBrand, r as modelThinkingLevels, s as assertSupportedCommandRestCapture } from "./config-CpCLnuAf.mjs";
|
|
2
2
|
import { z, z as z$1 } from "zod";
|
|
3
3
|
//#region src/prompt.ts
|
|
4
4
|
/** Creates trimmed Markdown from a template literal with common indentation removed. */
|
|
@@ -140,6 +140,8 @@ const reviewFindingSchema = z$1.strictObject({
|
|
|
140
140
|
endLine: positiveIntegerSchema,
|
|
141
141
|
suggestedFix: nonEmptyStringSchema.optional()
|
|
142
142
|
});
|
|
143
|
+
/** Zod schema for Pipr's core inline-finding result. */
|
|
144
|
+
const reviewFindingsResultSchema = z$1.strictObject({ inlineFindings: z$1.array(reviewFindingSchema) });
|
|
143
145
|
/** Zod schema for Pipr's core change request review result. */
|
|
144
146
|
const reviewResultSchema = z$1.strictObject({
|
|
145
147
|
summary: reviewSummarySchema,
|
|
@@ -149,6 +151,10 @@ const reviewResultSchema = z$1.strictObject({
|
|
|
149
151
|
function parseReviewResult(value) {
|
|
150
152
|
return reviewResultSchema.parse(value);
|
|
151
153
|
}
|
|
154
|
+
/** Parses model output for Pipr's inline-finding schema. */
|
|
155
|
+
function parseReviewFindingsResult(value) {
|
|
156
|
+
return reviewFindingsResultSchema.parse(value);
|
|
157
|
+
}
|
|
152
158
|
/** Parses a review summary value. */
|
|
153
159
|
function parseReviewSummary(value) {
|
|
154
160
|
return reviewSummarySchema.parse(value);
|
|
@@ -193,6 +199,7 @@ function jsonSchema(definition) {
|
|
|
193
199
|
}
|
|
194
200
|
/** Built-in schemas available as reusable agent output contracts. */
|
|
195
201
|
const schemas = {
|
|
202
|
+
inlineFindings: createZodSchema("core/inline-findings", reviewFindingsResultSchema),
|
|
196
203
|
review: createZodSchema(coreReviewOutputSchemaId, reviewResultSchema),
|
|
197
204
|
summary: createZodSchema("core/summary", reviewSummarySchema)
|
|
198
205
|
};
|
|
@@ -301,13 +308,14 @@ function createBuilder() {
|
|
|
301
308
|
model(options) {
|
|
302
309
|
if (!options || typeof options.provider !== "string" || typeof options.model !== "string") throw new Error("pipr.model requires { provider, model }");
|
|
303
310
|
if (!options.provider || !options.model) throw new Error("pipr.model requires provider and model");
|
|
311
|
+
if (options.thinking !== void 0 && !modelThinkingLevels.includes(options.thinking)) throw new Error(`pipr.model received unsupported thinking level '${options.thinking}'`);
|
|
304
312
|
const profile = {
|
|
305
313
|
kind: "pipr.model",
|
|
306
314
|
id: options.id ?? `${options.provider}/${options.model}`,
|
|
307
315
|
provider: options.provider,
|
|
308
316
|
model: options.model,
|
|
309
317
|
apiKey: options.apiKey,
|
|
310
|
-
|
|
318
|
+
thinking: options.thinking
|
|
311
319
|
};
|
|
312
320
|
models.push(profile);
|
|
313
321
|
return profile;
|
|
@@ -323,11 +331,9 @@ function createBuilder() {
|
|
|
323
331
|
tasks.push(task.record);
|
|
324
332
|
return task.handle;
|
|
325
333
|
},
|
|
326
|
-
reviewer(options) {
|
|
327
|
-
return createReviewer(api, options);
|
|
328
|
-
},
|
|
329
334
|
review(options) {
|
|
330
335
|
assertKnownReviewRecipeOptions(options);
|
|
336
|
+
if (!options.model || !models.includes(options.model)) throw new Error("pipr.review requires a registered model.");
|
|
331
337
|
registerReviewRecipe(api, options);
|
|
332
338
|
},
|
|
333
339
|
config(options) {
|
|
@@ -416,7 +422,7 @@ function createBuilder() {
|
|
|
416
422
|
}
|
|
417
423
|
function registerReviewRecipe(api, options) {
|
|
418
424
|
const id = options.id;
|
|
419
|
-
registerReviewRecipeEntrypoints(api, createReviewRecipeTask(api, id, options
|
|
425
|
+
registerReviewRecipeEntrypoints(api, createReviewRecipeTask(api, id, createReviewFindingsAgent(api, options), createReviewSummaryAgent(api, options), options), options);
|
|
420
426
|
}
|
|
421
427
|
const reviewRecipeOptionKeys = /* @__PURE__ */ new Set([
|
|
422
428
|
"id",
|
|
@@ -425,12 +431,9 @@ const reviewRecipeOptionKeys = /* @__PURE__ */ new Set([
|
|
|
425
431
|
"check",
|
|
426
432
|
"timeout",
|
|
427
433
|
"paths",
|
|
428
|
-
"reviewer",
|
|
429
|
-
"name",
|
|
430
434
|
"model",
|
|
431
435
|
"fallbacks",
|
|
432
436
|
"instructions",
|
|
433
|
-
"prompt",
|
|
434
437
|
"tools"
|
|
435
438
|
]);
|
|
436
439
|
const reviewRecipeEntrypointKeys = /* @__PURE__ */ new Set(["changeRequest", "command"]);
|
|
@@ -465,6 +468,7 @@ const aggregateCheckOptionsSchema = z$1.union([z$1.literal(false), z$1.strictObj
|
|
|
465
468
|
})]);
|
|
466
469
|
const checksOptionsSchema = z$1.strictObject({ aggregate: aggregateCheckOptionsSchema.optional() });
|
|
467
470
|
const diffManifestLimitsSchema = z$1.strictObject({
|
|
471
|
+
maxShards: z$1.number().int().positive().optional(),
|
|
468
472
|
fullMaxBytes: z$1.number().int().positive().optional(),
|
|
469
473
|
fullMaxEstimatedTokens: z$1.number().int().positive().optional(),
|
|
470
474
|
condensedMaxBytes: z$1.number().int().positive().optional(),
|
|
@@ -473,6 +477,7 @@ const diffManifestLimitsSchema = z$1.strictObject({
|
|
|
473
477
|
});
|
|
474
478
|
const runtimeLimitsSchema = z$1.strictObject({
|
|
475
479
|
timeoutSeconds: z$1.number().int().positive().max(3600).optional(),
|
|
480
|
+
maxAgentRuns: z$1.number().int().positive().optional(),
|
|
476
481
|
diffManifest: diffManifestLimitsSchema.optional()
|
|
477
482
|
});
|
|
478
483
|
const piprConfigOptionsSchema = z$1.strictObject({
|
|
@@ -483,12 +488,17 @@ const piprConfigOptionsSchema = z$1.strictObject({
|
|
|
483
488
|
function assertKnownReviewRecipeOptions(options) {
|
|
484
489
|
const unknownKeys = Object.keys(options).filter((key) => !reviewRecipeOptionKeys.has(key));
|
|
485
490
|
if (unknownKeys.length > 0) throw new Error(`pipr.review received unsupported option fields: ${unknownKeys.join(", ")}.`);
|
|
491
|
+
const instructions = options.instructions;
|
|
492
|
+
if (!instructions || typeof instructions !== "object" || !isPromptSource(instructions.findings) || !isPromptSource(instructions.summary)) throw new Error("pipr.review instructions require both findings and summary.");
|
|
486
493
|
const entrypoints = options.entrypoints;
|
|
487
494
|
if (entrypoints && typeof entrypoints === "object") {
|
|
488
495
|
const unknownEntrypointKeys = Object.keys(entrypoints).filter((key) => !reviewRecipeEntrypointKeys.has(key));
|
|
489
496
|
if (unknownEntrypointKeys.length > 0) throw new Error(`pipr.review entrypoints received unsupported fields: ${unknownEntrypointKeys.join(", ")}.`);
|
|
490
497
|
}
|
|
491
498
|
}
|
|
499
|
+
function isPromptSource(value) {
|
|
500
|
+
return typeof value === "string" && value.length > 0 || typeof value === "object" && value !== null;
|
|
501
|
+
}
|
|
492
502
|
function assertKnownPiprConfigOptions(options) {
|
|
493
503
|
const parsed = piprConfigOptionsSchema.safeParse(options);
|
|
494
504
|
if (!parsed.success) throw new Error(formatPiprConfigOptionsError(parsed.error));
|
|
@@ -515,33 +525,37 @@ function piprConfigLabel(pathSegments) {
|
|
|
515
525
|
const path = pathSegments.join(".");
|
|
516
526
|
return path ? `pipr.config ${path}` : "pipr.config";
|
|
517
527
|
}
|
|
518
|
-
function
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
name,
|
|
528
|
+
function createReviewFindingsAgent(api, options) {
|
|
529
|
+
return api.agent({
|
|
530
|
+
name: `${options.id}-findings`,
|
|
522
531
|
model: options.model,
|
|
523
532
|
fallbacks: options.fallbacks,
|
|
524
|
-
instructions: options.instructions,
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
timeout: options.timeout
|
|
528
|
-
|
|
533
|
+
instructions: options.instructions.findings,
|
|
534
|
+
tools: options.tools ?? api.tools.readOnly,
|
|
535
|
+
output: api.schemas.inlineFindings,
|
|
536
|
+
timeout: options.timeout,
|
|
537
|
+
prompt: () => api.prompt`Review this change for actionable inline findings.`
|
|
538
|
+
});
|
|
529
539
|
}
|
|
530
|
-
function
|
|
540
|
+
function createReviewSummaryAgent(api, options) {
|
|
531
541
|
return api.agent({
|
|
532
|
-
name: options.
|
|
542
|
+
name: `${options.id}-summary`,
|
|
533
543
|
model: options.model,
|
|
534
544
|
fallbacks: options.fallbacks,
|
|
535
|
-
instructions: options.instructions,
|
|
545
|
+
instructions: options.instructions.summary,
|
|
536
546
|
tools: options.tools ?? api.tools.readOnly,
|
|
537
|
-
output: api.schemas.
|
|
547
|
+
output: api.schemas.summary,
|
|
538
548
|
timeout: options.timeout,
|
|
539
|
-
prompt:
|
|
540
|
-
|
|
541
|
-
|
|
549
|
+
prompt: ({ inlineFindings, manifestSummary }) => api.prompt`
|
|
550
|
+
Summarize this change using the merged inline findings as evidence.
|
|
551
|
+
|
|
552
|
+
${api.section("Scoped compressed manifest", api.json(manifestSummary, { maxCharacters: 6e4 }))}
|
|
553
|
+
|
|
554
|
+
${api.section("Merged inline findings", api.json(inlineFindings, { maxCharacters: 6e4 }))}
|
|
555
|
+
`
|
|
542
556
|
});
|
|
543
557
|
}
|
|
544
|
-
function createReviewRecipeTask(api, id,
|
|
558
|
+
function createReviewRecipeTask(api, id, findingsAgent, summaryAgent, options) {
|
|
545
559
|
return api.task({
|
|
546
560
|
name: id,
|
|
547
561
|
check: options.check,
|
|
@@ -555,13 +569,24 @@ function createReviewRecipeTask(api, id, agent, options) {
|
|
|
555
569
|
await context.comment({ main: "No changed files matched this review's path scope." });
|
|
556
570
|
return;
|
|
557
571
|
}
|
|
558
|
-
const
|
|
572
|
+
const findings = await context.pi.run(findingsAgent, {
|
|
559
573
|
manifest,
|
|
560
574
|
change: context.change
|
|
561
575
|
}, {
|
|
562
576
|
timeout: options.timeout,
|
|
563
577
|
paths: options.paths
|
|
564
578
|
});
|
|
579
|
+
const result = {
|
|
580
|
+
summary: await context.pi.run(summaryAgent, {
|
|
581
|
+
manifestSummary: defaultReviewSummaryManifest(manifest),
|
|
582
|
+
change: context.change,
|
|
583
|
+
inlineFindings: findings.inlineFindings
|
|
584
|
+
}, {
|
|
585
|
+
timeout: options.timeout,
|
|
586
|
+
paths: options.paths
|
|
587
|
+
}),
|
|
588
|
+
inlineFindings: findings.inlineFindings
|
|
589
|
+
};
|
|
565
590
|
const source = typeof options.comment === "function" ? await options.comment(result, {
|
|
566
591
|
review: { id },
|
|
567
592
|
run: context.run,
|
|
@@ -573,6 +598,35 @@ function createReviewRecipeTask(api, id, agent, options) {
|
|
|
573
598
|
}
|
|
574
599
|
});
|
|
575
600
|
}
|
|
601
|
+
function defaultReviewSummaryManifest(manifest) {
|
|
602
|
+
const maxSerializedFileCharacters = 4e4;
|
|
603
|
+
const files = [];
|
|
604
|
+
let serializedFileCharacters = 0;
|
|
605
|
+
for (const file of manifest.files) {
|
|
606
|
+
const projected = {
|
|
607
|
+
path: file.path.slice(0, 1e3),
|
|
608
|
+
...file.previousPath ? { previousPath: file.previousPath.slice(0, 1e3) } : {},
|
|
609
|
+
status: file.status,
|
|
610
|
+
...file.language ? { language: file.language.slice(0, 100) } : {},
|
|
611
|
+
additions: file.additions,
|
|
612
|
+
deletions: file.deletions,
|
|
613
|
+
...file.changedSymbols?.length ? { changedSymbols: file.changedSymbols.slice(0, 20).map((symbol) => symbol.slice(0, 200)) } : {},
|
|
614
|
+
...file.excludedReason ? { excludedReason: file.excludedReason.slice(0, 500) } : {}
|
|
615
|
+
};
|
|
616
|
+
const projectedCharacters = JSON.stringify(projected).length;
|
|
617
|
+
if (serializedFileCharacters + projectedCharacters > maxSerializedFileCharacters) continue;
|
|
618
|
+
files.push(projected);
|
|
619
|
+
serializedFileCharacters += projectedCharacters;
|
|
620
|
+
}
|
|
621
|
+
return {
|
|
622
|
+
baseSha: manifest.baseSha,
|
|
623
|
+
headSha: manifest.headSha,
|
|
624
|
+
mergeBaseSha: manifest.mergeBaseSha,
|
|
625
|
+
fileCount: manifest.files.length,
|
|
626
|
+
omittedFileCount: manifest.files.length - files.length,
|
|
627
|
+
files
|
|
628
|
+
};
|
|
629
|
+
}
|
|
576
630
|
function defaultReviewComment(result) {
|
|
577
631
|
return {
|
|
578
632
|
main: defaultReviewMarkdown(result),
|
|
@@ -673,7 +727,7 @@ function assertNoDuplicateModelConfigs(models) {
|
|
|
673
727
|
provider: model.provider,
|
|
674
728
|
model: model.model,
|
|
675
729
|
apiKeyEnv: model.apiKey?.name,
|
|
676
|
-
|
|
730
|
+
thinking: model.thinking
|
|
677
731
|
});
|
|
678
732
|
const existingConfigId = effectiveConfigs.get(effectiveConfig);
|
|
679
733
|
if (existingConfigId) throw new Error(`Duplicate model config for '${model.id}'. Reuse model '${existingConfigId}' instead.`);
|
|
@@ -830,6 +884,6 @@ function parsePiprResult(value) {
|
|
|
830
884
|
return piprResultSchema.parse(value);
|
|
831
885
|
}
|
|
832
886
|
//#endregion
|
|
833
|
-
export { defaultReviewActions, defaultReviewEntrypoints, definePipr, definePlugin, jsonSchema, md, parsePiprResult, parseReviewFinding, parseReviewResult, parseReviewSummary, piprResultSchema, reviewFindingSchema, reviewResultSchema, reviewSchemaExample, reviewSummarySchema, schema, schemas, z };
|
|
887
|
+
export { defaultReviewActions, defaultReviewEntrypoints, definePipr, definePlugin, jsonSchema, md, modelThinkingLevels, parsePiprResult, parseReviewFinding, parseReviewFindingsResult, parseReviewResult, parseReviewSummary, piprResultSchema, reviewFindingSchema, reviewFindingsResultSchema, reviewResultSchema, reviewSchemaExample, reviewSummarySchema, schema, schemas, z };
|
|
834
888
|
|
|
835
889
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["z","z","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 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 { PiprRunContext } from \"../result.js\";\nimport 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 { 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/** 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/** Options for creating a reusable reviewer agent. */\nexport type ReviewerOptions = {\n name?: string;\n model: ModelProfile;\n fallbacks?: readonly 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 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 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<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 },\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 { ReviewResult } 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 } 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: 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 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 = 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 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: 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 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 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 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 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","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"],"mappings":";;;;AAGA,SAAgB,GAAG,SAA+B,GAAG,Q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ACtEA,IAAE,aAAa;EAAE,GAAG;EAAQ,MAAMA,IAAE,QAAQ,SAAS;EAAG,QAAQ;CAAK,CAAC;CACtEA,IAAE,aAAa;EAAE,GAAG;EAAQ,MAAMA,IAAE,QAAQ,SAAS;CAAE,CAAC;CACxDA,IAAE,aAAa;EACb,GAAG;EACH,MAAMA,IAAE,QAAQ,cAAc;EAC9B,QAAQ;EACR,aAAaA,IAAE,OAAO;CACxB,CAAC;CACDA,IAAE,aAAa;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"}
|
|
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"],"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;;;ACVA,MAAM,8BAAc,IAAI,QAA6B;AACrD,MAAM,+BAAe,IAAI,QAA8B;AACvD,MAAM,8BAAc,IAAI,QAAkC;AAE1D,SAAgB,iBAAwB,YAGtC;CACA,MAAM,SAAS;EAAE,MAAM;EAAa,MAAM,WAAW;CAAK;CAC1D,MAAM,SAAsB;EAC1B,MAAM,WAAW;EACjB,OAAO,WAAW;EAClB,GAAI,WA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;EAAG,QAAQ;CAAK,CAAC;CACtEA,IAAE,aAAa;EAAE,GAAG;EAAQ,MAAMA,IAAE,QAAQ,SAAS;EAAG,QAAQ;CAAK,CAAC;CACtEA,IAAE,aAAa;EAAE,GAAG;EAAQ,MAAMA,IAAE,QAAQ,SAAS;CAAE,CAAC;CACxDA,IAAE,aAAa;EACb,GAAG;EACH,MAAMA,IAAE,QAAQ,cAAc;EAC9B,QAAQ;EACR,aAAaA,IAAE,OAAO;CACxB,CAAC;CACDA,IAAE,aAAa;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,4 +1,4 @@
|
|
|
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
3
|
/** Type-erased executable task stored in a runtime plan. */
|
|
4
4
|
type RuntimeTask = {
|
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) {
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-D9q-ZDr-.d.mts","names":[],"sources":["../src/types/schema.ts","../src/review-contract.ts","../src/result.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;EACA;EACA;EACA;EACA;;;KAIU;EACV,SAAS;EACT,gBAAgB;;;cAML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