@usepipr/sdk 0.3.8 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,7 +6,7 @@ publication settings.
6
6
 
7
7
  This is the package user configs import directly.
8
8
 
9
- ## Technical Notes
9
+ ## Technical notes
10
10
 
11
11
  - The package root exports `definePipr`, `definePlugin`, `z`, schemas, prompt
12
12
  helpers, review parsers, and public config, task, diff, schema, and agent
@@ -15,7 +15,7 @@ This is the package user configs import directly.
15
15
  import from the package root.
16
16
  - The build emits ESM and declaration files to `dist`.
17
17
 
18
- ## Local Checks
18
+ ## Local checks
19
19
 
20
20
  ```bash
21
21
  bun run --cwd packages/sdk check
@@ -24,5 +24,5 @@ bun run --cwd packages/sdk build
24
24
 
25
25
  ## Docs
26
26
 
27
- - [Pipr SDK Reference](https://pipr.run/docs/reference/sdk-reference)
27
+ - [Pipr SDK reference](https://pipr.run/docs/reference/sdk-reference)
28
28
  - [Configuration](https://pipr.run/docs/guide/configuration)
@@ -47,6 +47,10 @@ function renderPromptValue(value) {
47
47
  return JSON.stringify(value, null, 2);
48
48
  }
49
49
  //#endregion
50
- export { commandPatternParts as a, isOptionalCommandPatternPart as c, assertSupportedCommandRestCapture as i, tokenizeCommandPattern as l, builtinReadOnlyToolBrand as n, isCommandCaptureToken as o, configFactoryBrand as r, isCommandRestCaptureToken as s, renderPromptValue as t, unsupportedCommandRestCaptureError as u };
50
+ //#region src/types/config.ts
51
+ const defaultMaxStoredFindings = 50;
52
+ const maxStoredFindingsLimit = 100;
53
+ //#endregion
54
+ export { configFactoryBrand as a, isCommandCaptureToken as c, tokenizeCommandPattern as d, unsupportedCommandRestCaptureError as f, builtinReadOnlyToolBrand as i, isCommandRestCaptureToken as l, maxStoredFindingsLimit as n, assertSupportedCommandRestCapture as o, renderPromptValue as r, commandPatternParts as s, defaultMaxStoredFindings as t, isOptionalCommandPatternPart as u };
51
55
 
52
- //# sourceMappingURL=prompt-render-BWiLG-qu.mjs.map
56
+ //# sourceMappingURL=config-Ct0Qfa_b.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-Ct0Qfa_b.mjs","names":[],"sources":["../src/command-grammar.ts","../src/internal-contract.ts","../src/prompt-render.ts","../src/types/config.ts"],"sourcesContent":["export function commandPatternParts(pattern: string): string[] {\n return pattern.match(/\\[[^\\]]+\\]|[^\\s]+/g) ?? [];\n}\n\nexport function tokenizeCommandPattern(value: string): string[] {\n return value.trim().split(/\\s+/).filter(Boolean);\n}\n\nexport function unsupportedCommandRestCaptureError(pattern: string): string | undefined {\n const parts = commandPatternParts(pattern);\n for (const [index, part] of parts.entries()) {\n if (isOptionalCommandPatternPart(part)) {\n const optionalRest = tokenizeCommandPattern(part.slice(1, -1)).find(\n isCommandRestCaptureToken,\n );\n if (optionalRest) {\n return finalRequiredRestCaptureMessage(optionalRest);\n }\n continue;\n }\n if (isCommandRestCaptureToken(part) && index !== parts.length - 1) {\n return finalRequiredRestCaptureMessage(part);\n }\n }\n return undefined;\n}\n\nexport function assertSupportedCommandRestCapture(pattern: string): void {\n const error = unsupportedCommandRestCaptureError(pattern);\n if (error) {\n throw new Error(error);\n }\n}\n\nexport function isOptionalCommandPatternPart(value: string): boolean {\n return value.startsWith(\"[\") && value.endsWith(\"]\");\n}\n\nexport function isCommandCaptureToken(value: string): boolean {\n return /^<[a-z0-9-]+(\\.\\.\\.)?>$/.test(value);\n}\n\nexport function isCommandRestCaptureToken(value: string): boolean {\n return /^<[a-z0-9-]+\\.\\.\\.>$/.test(value);\n}\n\nfunction finalRequiredRestCaptureMessage(token: string): string {\n return `Rest capture '${token}' must be the final required command pattern token`;\n}\n","import type { RuntimePlan } from \"./runtime-contract.js\";\n\nexport const configFactoryBrand = Symbol.for(\"pipr.config.factory\");\nexport const builtinReadOnlyToolBrand = Symbol.for(\"pipr.builtin.readOnlyTool\");\n\nexport type ConfigFactoryValue = {\n readonly kind: \"pipr.config-factory\";\n};\n\nexport type InternalPiprConfigFactory = ConfigFactoryValue & {\n readonly [configFactoryBrand]: true;\n build(): RuntimePlan;\n};\n","import type { PromptText, PromptValue } from \"./index.js\";\n\n/** Renders a prompt source/value into plain text for Pi prompts. */\nexport function renderPromptValue(value: PromptValue): string {\n if (value === undefined || value === null) {\n return \"\";\n }\n if (typeof value === \"string\") {\n return value;\n }\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n return String(value);\n }\n if (typeof value === \"object\" && value !== null && Reflect.get(value, \"kind\") === \"pipr.prompt\") {\n return (value as PromptText).value;\n }\n return JSON.stringify(value, null, 2);\n}\n","import type { RuntimeLimits } from \"./manifest.js\";\n\nexport const defaultMaxStoredFindings = 50;\nexport const maxStoredFindingsLimit = 100;\n\n/** Repository permission levels used to authorize pipr commands. */\nexport type RepositoryPermission = \"read\" | \"triage\" | \"write\" | \"maintain\" | \"admin\";\n\n/** Pull request lifecycle actions that can trigger change-request tasks. */\nexport type ChangeRequestAction = \"opened\" | \"updated\" | \"reopened\" | \"ready\" | \"closed\";\n\n/** Duration accepted by timeout options, either seconds as a number or a suffixed string. */\nexport type DurationInput = number | `${number}s` | `${number}m` | `${number}h`;\n\n/** Reference to a secret that pipr resolves from the runtime environment. */\nexport type SecretRef = {\n readonly kind: \"pipr.secret\";\n readonly name: string;\n};\n\n/** Options for declaring a secret by environment variable name. */\nexport type SecretOptions = {\n name: string;\n};\n\n/** Options for registering a model provider and model id. */\nexport type ModelOptions = {\n id?: string;\n provider: string;\n model: string;\n apiKey?: SecretRef;\n options?: Record<string, unknown>;\n};\n\n/** Registered model profile that can be used by reviewers and agents. */\nexport type ModelProfile = {\n readonly kind: \"pipr.model\";\n readonly id: string;\n readonly provider: string;\n readonly model: string;\n readonly apiKey?: SecretRef;\n readonly options?: Record<string, unknown>;\n};\n\n/** Aggregate check-run options for a Pipr review run. */\nexport type AggregateCheckOptions =\n | false\n | {\n enabled?: boolean;\n name?: string;\n };\n\n/** Check-run settings for a pipr config. */\nexport type ChecksOptions = {\n aggregate?: AggregateCheckOptions;\n};\n\n/** Actor policy for auto-resolving inline review threads from user replies. */\nexport type AutoResolveAllowedActors = \"author-or-write\" | \"write\" | \"any\";\n\n/** Options controlling auto-resolve behavior for user replies. */\nexport type AutoResolveUserRepliesOptions = {\n enabled?: boolean;\n respondWhenStillValid?: boolean;\n allowedActors?: AutoResolveAllowedActors;\n};\n\n/** Options controlling automatic stale-finding resolution. */\nexport type AutoResolveOptions =\n | false\n | {\n enabled?: boolean;\n model?: ModelProfile;\n instructions?: string;\n synchronize?: boolean;\n userReplies?: boolean | AutoResolveUserRepliesOptions;\n };\n\n/** Review publication settings. */\nexport type PublicationOptions = {\n maxInlineComments?: number;\n maxStoredFindings?: number;\n autoResolve?: AutoResolveOptions;\n showHeader?: boolean;\n showFooter?: boolean;\n showStats?: boolean;\n};\n\n/** Top-level pipr config settings. */\nexport type PiprConfigOptions = {\n publication?: PublicationOptions;\n checks?: ChecksOptions;\n limits?: RuntimeLimits;\n};\n"],"mappings":";AAAA,SAAgB,oBAAoB,SAA2B;CAC7D,OAAO,QAAQ,MAAM,oBAAoB,KAAK,CAAC;AACjD;AAEA,SAAgB,uBAAuB,OAAyB;CAC9D,OAAO,MAAM,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO;AACjD;AAEA,SAAgB,mCAAmC,SAAqC;CACtF,MAAM,QAAQ,oBAAoB,OAAO;CACzC,KAAK,MAAM,CAAC,OAAO,SAAS,MAAM,QAAQ,GAAG;EAC3C,IAAI,6BAA6B,IAAI,GAAG;GACtC,MAAM,eAAe,uBAAuB,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,KAC7D,yBACF;GACA,IAAI,cACF,OAAO,gCAAgC,YAAY;GAErD;EACF;EACA,IAAI,0BAA0B,IAAI,KAAK,UAAU,MAAM,SAAS,GAC9D,OAAO,gCAAgC,IAAI;CAE/C;AAEF;AAEA,SAAgB,kCAAkC,SAAuB;CACvE,MAAM,QAAQ,mCAAmC,OAAO;CACxD,IAAI,OACF,MAAM,IAAI,MAAM,KAAK;AAEzB;AAEA,SAAgB,6BAA6B,OAAwB;CACnE,OAAO,MAAM,WAAW,GAAG,KAAK,MAAM,SAAS,GAAG;AACpD;AAEA,SAAgB,sBAAsB,OAAwB;CAC5D,OAAO,0BAA0B,KAAK,KAAK;AAC7C;AAEA,SAAgB,0BAA0B,OAAwB;CAChE,OAAO,uBAAuB,KAAK,KAAK;AAC1C;AAEA,SAAS,gCAAgC,OAAuB;CAC9D,OAAO,iBAAiB,MAAM;AAChC;;;AC9CA,MAAa,qBAAqB,OAAO,IAAI,qBAAqB;AAClE,MAAa,2BAA2B,OAAO,IAAI,2BAA2B;;;;ACA9E,SAAgB,kBAAkB,OAA4B;CAC5D,IAAI,UAAU,KAAA,KAAa,UAAU,MACnC,OAAO;CAET,IAAI,OAAO,UAAU,UACnB,OAAO;CAET,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,WAChD,OAAO,OAAO,KAAK;CAErB,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,QAAQ,IAAI,OAAO,MAAM,MAAM,eAChF,OAAQ,MAAqB;CAE/B,OAAO,KAAK,UAAU,OAAO,MAAM,CAAC;AACtC;;;ACfA,MAAa,2BAA2B;AACxC,MAAa,yBAAyB"}
@@ -64,15 +64,15 @@ type ReviewResult = {
64
64
  declare const reviewSummarySchema: ZodSchema<ReviewSummary>;
65
65
  /** Zod schema for one inline review finding. */
66
66
  declare const reviewFindingSchema: ZodSchema<ReviewFinding>;
67
- /** Zod schema for pipr's core pull request review result. */
67
+ /** Zod schema for Pipr's core change request review result. */
68
68
  declare const reviewResultSchema: ZodSchema<ReviewResult>;
69
- /** Parses model output for pipr's main pull request review schema. */
69
+ /** Parses model output for Pipr's main change request review schema. */
70
70
  declare function parseReviewResult(value: unknown): ReviewResult;
71
71
  /** Parses a review summary value. */
72
72
  declare function parseReviewSummary(value: unknown): ReviewSummary;
73
73
  /** Parses one inline review finding. */
74
74
  declare function parseReviewFinding(value: unknown): ReviewFinding;
75
- /** Returns a small valid example for the main pull request review schema. */
75
+ /** Returns a small valid example for the main change request review schema. */
76
76
  declare function reviewSchemaExample(): ReviewResult;
77
77
  //#endregion
78
78
  //#region src/types/manifest.d.ts
@@ -81,7 +81,7 @@ type PathFilter = {
81
81
  include?: string[];
82
82
  exclude?: string[];
83
83
  };
84
- /** Side of a pull request diff that a commentable range belongs to. */
84
+ /** Side of a change request diff that a commentable range belongs to. */
85
85
  type ReviewSide = "RIGHT" | "LEFT";
86
86
  /** Kind of line span represented by a Diff Manifest commentable range. */
87
87
  type RangeKind = "added" | "deleted" | "context" | "mixed";
@@ -154,6 +154,8 @@ type RuntimeLimits = {
154
154
  };
155
155
  //#endregion
156
156
  //#region src/types/config.d.ts
157
+ declare const defaultMaxStoredFindings = 50;
158
+ declare const maxStoredFindingsLimit = 100;
157
159
  /** Repository permission levels used to authorize pipr commands. */
158
160
  type RepositoryPermission = "read" | "triage" | "write" | "maintain" | "admin";
159
161
  /** Pull request lifecycle actions that can trigger change-request tasks. */
@@ -214,6 +216,7 @@ type AutoResolveOptions = false | {
214
216
  /** Review publication settings. */
215
217
  type PublicationOptions = {
216
218
  maxInlineComments?: number;
219
+ maxStoredFindings?: number;
217
220
  autoResolve?: AutoResolveOptions;
218
221
  showHeader?: boolean;
219
222
  showFooter?: boolean;
@@ -432,7 +435,7 @@ type ToolRunOptions<Input> = {
432
435
  ctx: TaskContext;
433
436
  signal?: AbortSignal;
434
437
  };
435
- /** Definition used to register a task for pull request actions. */
438
+ /** Definition used to register a task for change request actions. */
436
439
  type ChangeRequestRegistrationOptions<Input> = {
437
440
  actions: readonly ChangeRequestAction[];
438
441
  task: Task<Input>;
@@ -568,5 +571,5 @@ declare function jsonSchema<T>(definition: JsonSchemaDefinition): Schema<T>;
568
571
  /** Built-in schemas available as reusable agent output contracts. */
569
572
  declare const schemas: BuiltinSchemaCatalog;
570
573
  //#endregion
571
- export { AutoResolveUserRepliesOptions as $, Task as A, reviewSummarySchema as At, AgentExtension as B, PriorReview as C, ReviewSummary as Ct, ReviewRecipeOptions as D, reviewFindingSchema as Dt, ReviewEntrypoints as E, parseReviewSummary as Et, ToolRunOptions as F, JsonValue as Ft, JsonPromptOptions as G, AgentTool as H, defaultReviewActions as I, Schema as It, PromptText as J, Markdown as K, defaultReviewEntrypoints as L, SchemaDefinition as Lt, TaskContext as M, JsonPrimitive as Mt, TaskDefinition as N, JsonSchema as Nt, Reviewer as O, reviewResultSchema as Ot, TaskHandler as P, JsonSchemaDefinition as Pt, AutoResolveOptions as Q, Agent as R, SchemaParseResult as Rt, PriorInlineFinding as S, ReviewResult as St, ReviewCommentContext as T, parseReviewResult as Tt, BuiltinSchemaCatalog as U, AgentPromptContext as V, BuiltinToolCatalog as W, AggregateCheckOptions as X, PromptValue as Y, AutoResolveAllowedActors as Z, PiRunner as _, PathFilter as _t, md as a, PiprConfigOptions as at, PlatformInfo as b, RuntimeLimits as bt, ChangeRequestContext as c, SecretOptions as ct, CheckHandle as d, DiffHunk as dt, ChangeRequestAction as et, CommandContext as f, DiffManifest as ft, DefaultReviewInput as g, FileStatus as gt, CommentValue as h, DiffManifestOptions as ht, schemas as i, ModelProfile as it, TaskCheckOptions as j, JsonObject as jt, ReviewerOptions as k, reviewSchemaExample as kt, ChangeRequestInfo as l, SecretRef as lt, CommandRegistrationOptions as m, DiffManifestLimits as mt, jsonSchema as n, DurationInput as nt, definePipr as o, PublicationOptions as ot, CommandOptions as p, DiffManifestFile as pt, PromptSource as q, schema as r, ModelOptions as rt, definePlugin as s, RepositoryPermission as st, z$1 as t, ChecksOptions as tt, ChangeRequestRegistrationOptions as u, CommentableRange as ut, PiprBuilder as v, RangeKind as vt, RepositoryInfo as w, parseReviewFinding as wt, PluginToolDefinition as x, ReviewFinding as xt, PiprPlugin as y, ReviewSide as yt, AgentDefinition as z, ZodSchema as zt };
572
- //# sourceMappingURL=index-Cdy9nsaD.d.mts.map
574
+ export { AutoResolveUserRepliesOptions as $, Task as A, reviewResultSchema as At, AgentExtension as B, SchemaParseResult as Bt, PriorReview as C, ReviewFinding as Ct, ReviewRecipeOptions as D, parseReviewResult as Dt, ReviewEntrypoints as E, parseReviewFinding as Et, ToolRunOptions as F, JsonSchema as Ft, JsonPromptOptions as G, AgentTool as H, defaultReviewActions as I, JsonSchemaDefinition as It, PromptText as J, Markdown as K, defaultReviewEntrypoints as L, JsonValue as Lt, TaskContext as M, reviewSummarySchema as Mt, TaskDefinition as N, JsonObject as Nt, Reviewer as O, parseReviewSummary as Ot, TaskHandler as P, JsonPrimitive as Pt, AutoResolveOptions as Q, Agent as R, Schema as Rt, PriorInlineFinding as S, RuntimeLimits as St, ReviewCommentContext as T, ReviewSummary as Tt, BuiltinSchemaCatalog as U, AgentPromptContext as V, ZodSchema as Vt, BuiltinToolCatalog as W, AggregateCheckOptions as X, PromptValue as Y, AutoResolveAllowedActors as Z, PiRunner as _, DiffManifestOptions as _t, md as a, PiprConfigOptions as at, PlatformInfo as b, RangeKind as bt, ChangeRequestContext as c, SecretOptions as ct, CheckHandle as d, maxStoredFindingsLimit as dt, ChangeRequestAction as et, CommandContext as f, CommentableRange as ft, DefaultReviewInput as g, DiffManifestLimits as gt, CommentValue as h, DiffManifestFile as ht, schemas as i, ModelProfile as it, TaskCheckOptions as j, reviewSchemaExample as jt, ReviewerOptions as k, reviewFindingSchema as kt, ChangeRequestInfo as l, SecretRef as lt, CommandRegistrationOptions as m, DiffManifest as mt, jsonSchema as n, DurationInput as nt, definePipr as o, PublicationOptions as ot, CommandOptions as p, DiffHunk as pt, PromptSource as q, schema as r, ModelOptions as rt, definePlugin as s, RepositoryPermission as st, z$1 as t, ChecksOptions as tt, ChangeRequestRegistrationOptions as u, defaultMaxStoredFindings as ut, PiprBuilder as v, FileStatus as vt, RepositoryInfo as w, ReviewResult as wt, PluginToolDefinition as x, ReviewSide as xt, PiprPlugin as y, PathFilter as yt, AgentDefinition as z, SchemaDefinition as zt };
575
+ //# sourceMappingURL=index-D_XmBHeL.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-D_XmBHeL.d.mts","names":[],"sources":["../src/types/schema.ts","../src/review-contract.ts","../src/types/manifest.ts","../src/types/config.ts","../src/types/prompt.ts","../src/types/agent.ts","../src/types/task.ts","../src/builder.ts","../src/prompt.ts","../src/schema.ts"],"mappings":";;;KAGY;;KAEA,YAAY,gBAAgB,cAAc;;KAE1C;GAAgB,cAAc;;;KAE9B,aAAa;;KAGb,kBAAkB;EAAO;EAAe,MAAM;;EAAQ;EAAgB,OAAO;;;KAG7E,OAAO;WACR;WACA;WACA,aAAa;EACtB,MAAM,iBAAiB;EACvB,UAAU,iBAAiB,kBAAkB;;;KAInC,UAAU,KAAK,EAAE,QAAQ;;KAGzB,iBAAiB;EAC3B;EACA,QAAQ,UAAU;;;KAIR;EACV;EACA,QAAQ;;;;;KC/BE;EACV;EACA;;;KAIU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;;KAIU;EACV,SAAS;EACT,gBAAgB;;;cAOL,qBAAqB,UAAU;;cAM/B,qBAAqB,UAAU;;cAW/B,oBAAoB,UAAU;;iBAM3B,kBAAkB,iBAAiB;;iBAKnC,mBAAmB,iBAAiB;;iBAKpC,mBAAmB,iBAAiB;;iBAKpC,uBAAuB;;;;KCnE3B;EACV;EACA;;;KAIU;;KAGA;;KAGA;;KAGA;EACV;EACA;EACA,MAAM;EACN;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;EACA;;;KAIU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;;KAIU;EACV;EACA;EACA,QAAQ;EACR;EACA;EACA;EACA,OAAO;EACP,mBAAmB;EACnB;EACA;EACA;;;KAIU;EACV;EACA;EACA;EACA,OAAO;;;KAIG;EACV;EACA;EACA;EACA,QAAQ;;;KAIE;EACV;EACA;EACA;EACA;EACA;;;KAIU;EACV;EACA,eAAe;;;;cClFJ;cACA;;KAGD;;KAGA;;KAGA;;KAGA;WACD;WACA;;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d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as AutoResolveUserRepliesOptions, A as Task, At as reviewSummarySchema, B as AgentExtension, C as PriorReview, Ct as ReviewSummary, D as ReviewRecipeOptions, Dt as reviewFindingSchema, E as ReviewEntrypoints, Et as parseReviewSummary, F as ToolRunOptions, Ft as JsonValue, G as JsonPromptOptions, H as AgentTool, I as defaultReviewActions, It as Schema, J as PromptText, K as Markdown, L as defaultReviewEntrypoints, Lt as SchemaDefinition, M as TaskContext, Mt as JsonPrimitive, N as TaskDefinition, Nt as JsonSchema, O as Reviewer, Ot as reviewResultSchema, P as TaskHandler, Pt as JsonSchemaDefinition, Q as AutoResolveOptions, R as Agent, Rt as SchemaParseResult, S as PriorInlineFinding, St as ReviewResult, T as ReviewCommentContext, Tt as parseReviewResult, U as BuiltinSchemaCatalog, V as AgentPromptContext, W as BuiltinToolCatalog, X as AggregateCheckOptions, Y as PromptValue, Z as AutoResolveAllowedActors, _ as PiRunner, _t as PathFilter, a as md, at as PiprConfigOptions, b as PlatformInfo, bt as RuntimeLimits, c as ChangeRequestContext, ct as SecretOptions, d as CheckHandle, dt as DiffHunk, et as ChangeRequestAction, f as CommandContext, ft as DiffManifest, g as DefaultReviewInput, gt as FileStatus, h as CommentValue, ht as DiffManifestOptions, i as schemas, it as ModelProfile, j as TaskCheckOptions, jt as JsonObject, k as ReviewerOptions, kt as reviewSchemaExample, l as ChangeRequestInfo, lt as SecretRef, m as CommandRegistrationOptions, mt as DiffManifestLimits, n as jsonSchema, nt as DurationInput, o as definePipr, ot as PublicationOptions, p as CommandOptions, pt as DiffManifestFile, q as PromptSource, r as schema, rt as ModelOptions, s as definePlugin, st as RepositoryPermission, t as z, tt as ChecksOptions, u as ChangeRequestRegistrationOptions, ut as CommentableRange, v as PiprBuilder, vt as RangeKind, w as RepositoryInfo, wt as parseReviewFinding, x as PluginToolDefinition, xt as ReviewFinding, y as PiprPlugin, yt as ReviewSide, z as AgentDefinition, zt as ZodSchema } from "./index-Cdy9nsaD.mjs";
1
+ import { $ as AutoResolveUserRepliesOptions, A as Task, At as reviewResultSchema, B as AgentExtension, Bt as SchemaParseResult, C as PriorReview, Ct as ReviewFinding, D as ReviewRecipeOptions, Dt as parseReviewResult, E as ReviewEntrypoints, Et as parseReviewFinding, F as ToolRunOptions, Ft as JsonSchema, G as JsonPromptOptions, H as AgentTool, I as defaultReviewActions, It as JsonSchemaDefinition, J as PromptText, K as Markdown, L as defaultReviewEntrypoints, Lt as JsonValue, M as TaskContext, Mt as reviewSummarySchema, N as TaskDefinition, Nt as JsonObject, O as Reviewer, Ot as parseReviewSummary, P as TaskHandler, Pt as JsonPrimitive, Q as AutoResolveOptions, R as Agent, Rt as Schema, S as PriorInlineFinding, St as RuntimeLimits, T as ReviewCommentContext, Tt as ReviewSummary, U as BuiltinSchemaCatalog, V as AgentPromptContext, Vt as ZodSchema, W as BuiltinToolCatalog, X as AggregateCheckOptions, Y as PromptValue, Z as AutoResolveAllowedActors, _ as PiRunner, _t as DiffManifestOptions, a as md, at as PiprConfigOptions, b as PlatformInfo, bt as RangeKind, c as ChangeRequestContext, ct as SecretOptions, d as CheckHandle, et as ChangeRequestAction, f as CommandContext, ft as CommentableRange, g as DefaultReviewInput, gt as DiffManifestLimits, h as CommentValue, ht as DiffManifestFile, i as schemas, it as ModelProfile, j as TaskCheckOptions, jt as reviewSchemaExample, k as ReviewerOptions, kt as reviewFindingSchema, l as ChangeRequestInfo, lt as SecretRef, m as CommandRegistrationOptions, mt as DiffManifest, n as jsonSchema, nt as DurationInput, o as definePipr, ot as PublicationOptions, p as CommandOptions, pt as DiffHunk, q as PromptSource, r as schema, rt as ModelOptions, s as definePlugin, st as RepositoryPermission, t as z, tt as ChecksOptions, u as ChangeRequestRegistrationOptions, v as PiprBuilder, vt as FileStatus, w as RepositoryInfo, wt as ReviewResult, x as PluginToolDefinition, xt as ReviewSide, y as PiprPlugin, yt as PathFilter, z as AgentDefinition, zt as SchemaDefinition } from "./index-D_XmBHeL.mjs";
2
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 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 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 ReviewRecipeOptions, type ReviewResult, type ReviewSide, type ReviewSummary, type Reviewer, type ReviewerOptions, 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, parseReviewFinding, parseReviewResult, parseReviewSummary, reviewFindingSchema, reviewResultSchema, reviewSchemaExample, reviewSummarySchema, schema, schemas, z };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as assertSupportedCommandRestCapture, n as builtinReadOnlyToolBrand, r as configFactoryBrand, t as renderPromptValue } from "./prompt-render-BWiLG-qu.mjs";
1
+ import { a as configFactoryBrand, i as builtinReadOnlyToolBrand, o as assertSupportedCommandRestCapture, r as renderPromptValue } from "./config-Ct0Qfa_b.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. */
@@ -36,12 +36,12 @@ const reviewFindingSchema = z$1.strictObject({
36
36
  endLine: positiveIntegerSchema,
37
37
  suggestedFix: nonEmptyStringSchema.optional()
38
38
  });
39
- /** Zod schema for pipr's core pull request review result. */
39
+ /** Zod schema for Pipr's core change request review result. */
40
40
  const reviewResultSchema = z$1.strictObject({
41
41
  summary: reviewSummarySchema,
42
42
  inlineFindings: z$1.array(reviewFindingSchema)
43
43
  });
44
- /** Parses model output for pipr's main pull request review schema. */
44
+ /** Parses model output for Pipr's main change request review schema. */
45
45
  function parseReviewResult(value) {
46
46
  return reviewResultSchema.parse(value);
47
47
  }
@@ -53,12 +53,12 @@ function parseReviewSummary(value) {
53
53
  function parseReviewFinding(value) {
54
54
  return reviewFindingSchema.parse(value);
55
55
  }
56
- /** Returns a small valid example for the main pull request review schema. */
56
+ /** Returns a small valid example for the main change request review schema. */
57
57
  function reviewSchemaExample() {
58
58
  return {
59
59
  summary: {
60
60
  title: "Optional concise review title.",
61
- body: "Concise pull request review summary."
61
+ body: "Concise change request review summary."
62
62
  },
63
63
  inlineFindings: [{
64
64
  body: "Specific issue and why it matters.",
@@ -358,6 +358,7 @@ const autoResolveOptionsSchema = z$1.union([z$1.literal(false), z$1.strictObject
358
358
  })]);
359
359
  const publicationOptionsSchema = z$1.strictObject({
360
360
  maxInlineComments: z$1.number().int().min(0).max(50).optional(),
361
+ maxStoredFindings: z$1.number().int().min(0).max(100).optional(),
361
362
  autoResolve: autoResolveOptionsSchema.optional(),
362
363
  showHeader: z$1.boolean().optional(),
363
364
  showFooter: z$1.boolean().optional(),
@@ -520,14 +521,9 @@ function reviewCommandEntrypoint(options) {
520
521
  }
521
522
  function mergePublicationConfig(target, next) {
522
523
  if (!next) return;
523
- if (next.maxInlineComments !== void 0) {
524
- if (target.maxInlineComments !== void 0 && target.maxInlineComments !== next.maxInlineComments) throw new Error("pipr.config publication.maxInlineComments conflicts with existing value");
525
- target.maxInlineComments = next.maxInlineComments;
526
- }
527
- if (next.autoResolve !== void 0) {
528
- if (target.autoResolve !== void 0 && stableJson(target.autoResolve) !== stableJson(next.autoResolve)) throw new Error("pipr.config publication.autoResolve conflicts with existing value");
529
- target.autoResolve = next.autoResolve;
530
- }
524
+ target.maxInlineComments = mergeConfigField("publication.maxInlineComments", target.maxInlineComments, next.maxInlineComments);
525
+ target.maxStoredFindings = mergeConfigField("publication.maxStoredFindings", target.maxStoredFindings, next.maxStoredFindings);
526
+ target.autoResolve = mergeConfigField("publication.autoResolve", target.autoResolve, next.autoResolve);
531
527
  target.showHeader = mergeConfigField("publication.showHeader", target.showHeader, next.showHeader);
532
528
  target.showFooter = mergeConfigField("publication.showFooter", target.showFooter, next.showFooter);
533
529
  target.showStats = mergeConfigField("publication.showStats", target.showStats, next.showStats);
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["z","z","coreReviewResultSchema","coreReviewSummarySchema","z"],"sources":["../src/prompt.ts","../src/review-contract.ts","../src/schema.ts","../src/types/task.ts","../src/builder.ts"],"sourcesContent":["import type { Markdown } from \"./types/prompt.js\";\n\n/** Creates trimmed Markdown from a template literal with common indentation removed. */\nexport function md(strings: TemplateStringsArray, ...values: unknown[]): Markdown {\n let text = \"\";\n for (let index = 0; index < strings.length; index += 1) {\n text += strings[index] ?? \"\";\n if (index < values.length) {\n text += String(values[index] ?? \"\");\n }\n }\n return stripCommonIndent(text).trim();\n}\n\n/** Removes common leading indentation from multiline text. */\nexport function stripCommonIndent(value: string): string {\n const lines = value.replaceAll(\"\\t\", \" \").split(/\\r?\\n/);\n const nonEmpty = lines.filter((line) => line.trim().length > 0);\n const indent = Math.min(...nonEmpty.map((line) => line.match(/^ */)?.[0].length ?? 0));\n return lines.map((line) => line.slice(indent)).join(\"\\n\");\n}\n","import { z } from \"zod\";\nimport type { ZodSchema } from \"./types/schema.js\";\n\n/** Markdown summary produced by a reviewer for the main review comment. */\nexport type ReviewSummary = {\n title?: string;\n body: string;\n};\n\n/** One inline review finding targeting a Diff Manifest commentable range. */\nexport type ReviewFinding = {\n body: string;\n path: string;\n rangeId: string;\n side: \"RIGHT\" | \"LEFT\";\n startLine: number;\n endLine: number;\n suggestedFix?: string;\n};\n\n/** Core structured review result accepted by pipr review publication. */\nexport type ReviewResult = {\n summary: ReviewSummary;\n inlineFindings: ReviewFinding[];\n};\n\nconst nonEmptyStringSchema = z.string().min(1);\nconst positiveIntegerSchema = z.number().int().positive();\n\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 pull 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 pull 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 pull request review schema. */\nexport function reviewSchemaExample(): ReviewResult {\n return {\n summary: {\n title: \"Optional concise review title.\",\n body: \"Concise pull request review summary.\",\n },\n inlineFindings: [\n {\n body: \"Specific issue and why it matters.\",\n path: \"src/example.ts\",\n rangeId: \"rng_example\",\n side: \"RIGHT\",\n startLine: 1,\n endLine: 1,\n suggestedFix: \"return safeValue;\",\n },\n ],\n };\n}\n","import { z } from \"zod\";\nimport type { ReviewResult, ReviewSummary } from \"./review-contract.js\";\nimport {\n reviewResultSchema as coreReviewResultSchema,\n reviewSummarySchema as coreReviewSummarySchema,\n} from \"./review-contract.js\";\nimport type { BuiltinSchemaCatalog } from \"./types/agent.js\";\nimport type {\n JsonSchema,\n JsonSchemaDefinition,\n Schema,\n SchemaDefinition,\n ZodSchema,\n} from \"./types/schema.js\";\n\nconst coreReviewOutputSchemaId = \"core/pr-review\";\n\n/** Defines a typed schema from a Zod schema. */\nexport function schema<T>(definition: SchemaDefinition<T>): Schema<T> {\n if (!definition || typeof definition.id !== \"string\") {\n throw new Error(\"pipr.schema requires { id, schema }\");\n }\n assertUserSchemaId(definition.id);\n return createZodSchema(definition.id, definition.schema);\n}\n\n/** Defines a typed schema from JSON Schema. The generic type is caller supplied. */\nexport function jsonSchema<T>(definition: JsonSchemaDefinition): Schema<T> {\n if (!definition || typeof definition.id !== \"string\") {\n throw new Error(\"pipr.jsonSchema requires { id, schema }\");\n }\n assertUserSchemaId(definition.id);\n const zodSchema = z.fromJSONSchema(definition.schema);\n return createSchema(definition.id, (value) => zodSchema.parse(value) as T, definition.schema);\n}\n\n/** Built-in schemas available as reusable agent output contracts. */\nexport const schemas: BuiltinSchemaCatalog = {\n review: createZodSchema<ReviewResult>(coreReviewOutputSchemaId, coreReviewResultSchema),\n summary: createZodSchema<ReviewSummary>(\"core/summary\", coreReviewSummarySchema),\n};\n\nfunction createSchema<T>(\n id: string,\n parseValue: (value: unknown) => T,\n schemaJson?: JsonSchema,\n): Schema<T> {\n return {\n kind: \"pipr.schema\",\n id,\n jsonSchema: schemaJson,\n parse(value) {\n return parseValue(value);\n },\n safeParse(value) {\n try {\n return { success: true, data: parseValue(value) };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error : new Error(String(error)),\n };\n }\n },\n };\n}\n\nfunction createZodSchema<T>(id: string, zodSchema: ZodSchema<T>): Schema<T> {\n return createSchema(id, (value) => zodSchema.parse(value), jsonSchemaFromZod(id, zodSchema));\n}\n\nfunction assertUserSchemaId(id: string): void {\n if (id.startsWith(\"core/\")) {\n throw new Error(`Schema id '${id}' uses the reserved core/ namespace`);\n }\n}\n\nfunction jsonSchemaFromZod<T>(id: string, schemaDefinition: ZodSchema<T>): JsonSchema {\n try {\n return z.toJSONSchema(schemaDefinition) as JsonSchema;\n } catch (error) {\n const detail = error instanceof Error ? error.message : String(error);\n throw new Error(\n `Schema '${id}' could not be converted to JSON Schema. Use JSON-Schema-representable Zod or pipr.jsonSchema<T>(). ${detail}`,\n );\n }\n}\n","import type { ReviewFinding, ReviewResult } from \"../review-contract.js\";\nimport type {\n Agent,\n AgentDefinition,\n AgentPromptContext,\n AgentTool,\n BuiltinSchemaCatalog,\n BuiltinToolCatalog,\n} from \"./agent.js\";\nimport type {\n ChangeRequestAction,\n DurationInput,\n ModelOptions,\n ModelProfile,\n PiprConfigOptions,\n RepositoryPermission,\n SecretOptions,\n SecretRef,\n} from \"./config.js\";\nimport type { DiffManifest, DiffManifestOptions, PathFilter } from \"./manifest.js\";\nimport type {\n JsonPromptOptions,\n Markdown,\n PromptSource,\n PromptText,\n PromptValue,\n} from \"./prompt.js\";\nimport type { JsonSchemaDefinition, Schema, SchemaDefinition } from \"./schema.js\";\n\n/** Final review comment value produced by a task or review recipe. */\nexport type CommentValue =\n | Markdown\n | {\n main?: Markdown;\n inlineFindings?: readonly ReviewFinding[];\n };\n\n/** Prior inline finding persisted by earlier pipr review state. */\nexport type PriorInlineFinding = {\n id: string;\n status: \"open\" | \"resolved\";\n path: string;\n rangeId: string;\n side: \"RIGHT\" | \"LEFT\";\n startLine: number;\n endLine: number;\n};\n\n/** Prior pipr review state available to tasks through `ctx.review.prior()`. */\nexport type PriorReview = {\n main?: Markdown;\n reviewedHeadSha?: string;\n inlineFindings: readonly PriorInlineFinding[];\n};\n\n/** Function run by a task entrypoint. */\nexport type TaskHandler<Input> = (context: TaskContext, input: Input) => void | Promise<void>;\n\n/** Check-run publication options for one task. */\nexport type TaskCheckOptions =\n | false\n | {\n enabled?: boolean;\n name?: string;\n required?: boolean;\n };\n\n/** Definition used to register a task. */\nexport type TaskDefinition<Input> = {\n name: string;\n check?: TaskCheckOptions;\n local?: false;\n run: TaskHandler<Input>;\n};\n\n/** Registered task that can be selected by change-request and command entrypoints. */\nexport type Task<Input = void> = {\n readonly kind: \"pipr.task\";\n readonly name: string;\n readonly check?: TaskCheckOptions;\n readonly local?: false;\n readonly handler: TaskHandler<Input>;\n};\n\n/** Options shared by command registrations. */\nexport type CommandOptions<Input> = {\n permission?: RepositoryPermission;\n description?: string;\n parse?: (arguments_: Record<string, string>) => Input;\n};\n\n/** Definition used to register an `@pipr` command. */\nexport type CommandRegistrationOptions<Input> = CommandOptions<Input> & {\n pattern: string;\n task: Task<Input>;\n};\n\n/** Options for creating a reusable reviewer agent. */\nexport type ReviewerOptions = {\n name?: string;\n model: ModelProfile;\n fallbacks?: ModelProfile[];\n instructions: PromptSource;\n prompt?: (\n input: DefaultReviewInput,\n context: AgentPromptContext,\n ) => PromptSource | Promise<PromptSource>;\n tools?: readonly AgentTool[];\n timeout?: DurationInput;\n};\n\n/** Reviewer agent that emits pipr's core review result. */\nexport type Reviewer = Agent<DefaultReviewInput, ReviewResult>;\n\n/** Entrypoints created by `pipr.review`. */\nexport type ReviewEntrypoints = {\n changeRequest?: readonly ChangeRequestAction[] | false;\n command?:\n | string\n | false\n | {\n pattern?: string;\n permission?: RepositoryPermission;\n description?: string;\n };\n};\n\n/** Default change-request actions used by `pipr.review`. */\nexport const defaultReviewActions = [\n \"opened\",\n \"updated\",\n \"reopened\",\n \"ready\",\n] as const satisfies readonly ChangeRequestAction[];\n\n/** Default change-request and command entrypoints used by `pipr.review`. */\nexport const defaultReviewEntrypoints = {\n changeRequest: defaultReviewActions,\n command: { pattern: \"@pipr review\", permission: \"write\" },\n} as const satisfies ReviewEntrypoints;\n\ntype ReviewRecipeEntrypointOptions = {\n id: string;\n entrypoints?: ReviewEntrypoints;\n comment?:\n | CommentValue\n | ((\n result: ReviewResult,\n context: ReviewCommentContext,\n ) => CommentValue | Promise<CommentValue>);\n check?: TaskCheckOptions;\n timeout?: DurationInput;\n paths?: PathFilter;\n};\n\n/** Options for `pipr.review`, pipr's default review recipe. */\nexport type ReviewRecipeOptions =\n | (ReviewRecipeEntrypointOptions & { reviewer: Reviewer })\n | (ReviewRecipeEntrypointOptions & ReviewerOptions & { reviewer?: undefined });\n\n/** Default input passed to a reviewer created by `pipr.review`. */\nexport type DefaultReviewInput = {\n manifest: DiffManifest;\n change: ChangeRequestInfo;\n};\n\n/** Context passed to a custom review comment renderer. */\nexport type ReviewCommentContext = {\n review: { id: string };\n repository: RepositoryInfo;\n change: ChangeRequestContext;\n platform: PlatformInfo;\n};\n\n/** Plugin installer returned by `definePlugin`. */\nexport type PiprPlugin<Handle> = {\n setup(builder: PiprBuilder): Handle;\n};\n\n/** Definition for a custom tool registered by config or plugins. */\nexport type PluginToolDefinition<Input, Output> = {\n name: string;\n description: string;\n input: Schema<Input>;\n output: Schema<Output>;\n run(options: ToolRunOptions<Input>): Output | Promise<Output>;\n toModelOutput?(output: Output): PromptValue;\n};\n\n/** Runtime input passed to a tool implementation. */\nexport type ToolRunOptions<Input> = {\n input: Input;\n ctx: TaskContext;\n signal?: AbortSignal;\n};\n\n/** Definition used to register a task for pull request actions. */\nexport type ChangeRequestRegistrationOptions<Input> = {\n actions: readonly ChangeRequestAction[];\n task: Task<Input>;\n};\n\n/** Handle for reporting task check status from inside a task. */\nexport type CheckHandle = {\n pass(summary?: string): void;\n fail(summary?: string): void;\n neutral(summary?: string): void;\n};\n\n/** Builder API available inside `definePipr`. */\nexport type PiprBuilder = {\n readonly tools: BuiltinToolCatalog;\n readonly schemas: BuiltinSchemaCatalog;\n readonly on: {\n changeRequest<Input = void>(options: ChangeRequestRegistrationOptions<Input>): void;\n };\n secret(options: SecretOptions): SecretRef;\n model(options: ModelOptions): ModelProfile;\n agent<Input, Output>(definition: AgentDefinition<Input, Output>): Agent<Input, Output>;\n task<Input = void>(definition: TaskDefinition<Input>): Task<Input>;\n reviewer(options: ReviewerOptions): Reviewer;\n review(options: ReviewRecipeOptions): void;\n config(options: PiprConfigOptions): void;\n command<Input = void>(options: CommandRegistrationOptions<Input>): void;\n use<Handle>(plugin: PiprPlugin<Handle>): Handle;\n tool<Input, Output>(definition: PluginToolDefinition<Input, Output>): AgentTool<Input, Output>;\n schema<T>(definition: SchemaDefinition<T>): Schema<T>;\n jsonSchema<T>(definition: JsonSchemaDefinition): Schema<T>;\n prompt(strings: TemplateStringsArray, ...values: PromptValue[]): PromptText;\n section(title: string, value: PromptValue): PromptText;\n json(value: unknown, options?: JsonPromptOptions): PromptText;\n};\n\n/** Repository metadata available to tasks and agents. */\nexport type RepositoryInfo = {\n root: string;\n owner?: string;\n name: string;\n defaultBranch?: string;\n remoteUrl?: string;\n};\n\n/** Pull request or change-request metadata available to tasks and agents. */\nexport type ChangeRequestInfo = {\n number?: number;\n title: string;\n description: string;\n url?: string;\n author?: { login: string };\n base: { ref?: string; sha: string };\n head: { ref?: string; sha: string };\n isFork?: boolean;\n};\n\n/** Code hosting platform metadata. */\nexport type PlatformInfo = {\n id: string;\n};\n\n/** Change-request context available inside tasks. */\nexport type ChangeRequestContext = ChangeRequestInfo & {\n diffManifest(options?: DiffManifestOptions): Promise<DiffManifest>;\n changedFiles(): Promise<Array<{ path: string; previousPath?: string; status: string }>>;\n currentHeadSha(): Promise<string>;\n};\n\n/** Runner for invoking Pi agents from tasks. */\nexport type PiRunner = {\n run<Input, Output>(\n agent: Agent<Input, Output>,\n input: Input,\n options?: {\n model?: ModelProfile;\n fallbacks?: ModelProfile[];\n instructions?: PromptSource;\n timeout?: DurationInput;\n paths?: PathFilter;\n },\n ): Promise<Output>;\n};\n\n/** Command context available inside command-triggered tasks. */\nexport type CommandContext = {\n readonly name: string;\n readonly line: string;\n readonly arguments: Record<string, string>;\n reply(markdown: Markdown): Promise<void>;\n};\n\n/** Context object passed to task handlers. */\nexport type TaskContext = {\n /** Stable id for the selected Review Run, not the process attempt. */\n readonly run: { id: string };\n readonly repository: RepositoryInfo;\n readonly change: ChangeRequestContext;\n readonly platform: PlatformInfo;\n readonly pi: PiRunner;\n readonly command?: CommandContext;\n secret(secret: SecretRef): string;\n readonly review: {\n prior(): Promise<PriorReview>;\n };\n readonly check: CheckHandle;\n comment(value: CommentValue): Promise<void>;\n readonly log: {\n info(message: string): void;\n warn(message: string): void;\n error(message: string): void;\n };\n};\n","import { z } from \"zod\";\nimport { assertSupportedCommandRestCapture } from \"./command-grammar.js\";\nimport {\n builtinReadOnlyToolBrand,\n configFactoryBrand,\n type InternalPiprConfigFactory,\n} from \"./internal-contract.js\";\nimport { stripCommonIndent } from \"./prompt.js\";\nimport { renderPromptValue } from \"./prompt-render.js\";\nimport type { ReviewResult } from \"./review-contract.js\";\nimport type { RuntimePlan } from \"./runtime-contract.js\";\nimport { jsonSchema, schema, schemas } from \"./schema.js\";\nimport type { Agent, AgentDefinition, AgentTool, BuiltinToolCatalog } from \"./types/agent.js\";\nimport type {\n AggregateCheckOptions,\n AutoResolveOptions,\n AutoResolveUserRepliesOptions,\n ChangeRequestAction,\n ChecksOptions,\n ModelProfile,\n PiprConfigOptions,\n PublicationOptions,\n} from \"./types/config.js\";\nimport type { DiffManifestLimits, RuntimeLimits } from \"./types/manifest.js\";\nimport type { Markdown } from \"./types/prompt.js\";\nimport type {\n CommandOptions,\n CommentValue,\n DefaultReviewInput,\n PiprBuilder,\n PiprPlugin,\n Reviewer,\n ReviewerOptions,\n ReviewRecipeOptions,\n Task,\n} from \"./types/task.js\";\nimport { defaultReviewActions, defaultReviewEntrypoints } from \"./types/task.js\";\n\n/** Defines a synchronous pipr configuration factory. */\nexport function definePipr(configure: (pipr: PiprBuilder) => void): {\n readonly kind: \"pipr.config-factory\";\n} {\n const factory = {\n kind: \"pipr.config-factory\",\n [configFactoryBrand]: true,\n build() {\n const builder = createBuilder();\n const result = configure(builder.api);\n if (\n typeof result === \"object\" &&\n result !== null &&\n typeof Reflect.get(result, \"then\") === \"function\"\n ) {\n throw new Error(\"definePipr configuration callback must be synchronous\");\n }\n return builder.plan();\n },\n } satisfies InternalPiprConfigFactory;\n return factory;\n}\n\n/** Defines a typed pipr plugin installer. */\nexport function definePlugin<Handle>(setup: (builder: PiprBuilder) => Handle): PiprPlugin<Handle> {\n return { setup };\n}\n\nfunction createBuilder(): { api: PiprBuilder; plan(): RuntimePlan } {\n const models: ModelProfile[] = [];\n const agents: Agent[] = [];\n const tasks: Task<unknown>[] = [];\n const changeRequestTriggers: RuntimePlan[\"changeRequestTriggers\"] = [];\n const commands: RuntimePlan[\"commands\"] = [];\n const tools: AgentTool[] = [];\n const publication: RuntimePlan[\"publication\"] = {};\n let checks: ChecksOptions | undefined;\n let limits: RuntimeLimits | undefined;\n\n const api: PiprBuilder = {\n tools: {\n readOnly: [\n {\n kind: \"pipr.tool\",\n name: \"readOnly\",\n [builtinReadOnlyToolBrand]: true,\n } as AgentTool,\n ],\n } satisfies BuiltinToolCatalog,\n schemas,\n on: {\n changeRequest(options) {\n if (!Array.isArray(options.actions) || !options.task) {\n throw new Error(\"pipr.on.changeRequest requires { actions, task }\");\n }\n changeRequestTriggers.push({\n actions: [...options.actions],\n task: options.task as Task<unknown>,\n });\n },\n },\n secret(options) {\n if (!options || typeof options.name !== \"string\") {\n throw new Error(\"pipr.secret requires { name }\");\n }\n if (!/^[A-Z_][A-Z0-9_]*$/.test(options.name)) {\n throw new Error(`Secret '${options.name}' must be an environment variable name`);\n }\n return { kind: \"pipr.secret\", name: options.name };\n },\n model(options) {\n if (!options || typeof options.provider !== \"string\" || typeof options.model !== \"string\") {\n throw new Error(\"pipr.model requires { provider, model }\");\n }\n if (!options.provider || !options.model) {\n throw new Error(\"pipr.model requires provider and model\");\n }\n const id = options.id ?? `${options.provider}/${options.model}`;\n const profile: ModelProfile = {\n kind: \"pipr.model\",\n id,\n provider: options.provider,\n model: options.model,\n apiKey: options.apiKey,\n options: options.options,\n };\n models.push(profile);\n return profile;\n },\n agent(definition) {\n const agent = createAgent(definition);\n agents.push(agent);\n return agent;\n },\n task(definition) {\n if (!definition.name || typeof definition.run !== \"function\") {\n throw new Error(\"pipr.task requires { name, run }\");\n }\n const task = {\n kind: \"pipr.task\" as const,\n name: definition.name,\n check: definition.check,\n ...(definition.local === false ? { local: false as const } : {}),\n handler: definition.run,\n };\n tasks.push(task as Task<unknown>);\n return task;\n },\n reviewer(options) {\n return createReviewer(api, options);\n },\n review(options) {\n assertKnownReviewRecipeOptions(options);\n registerReviewRecipe(api, options);\n },\n config(options) {\n assertKnownPiprConfigOptions(options);\n mergePublicationConfig(publication, options.publication);\n checks = mergeConfigField(\"checks\", checks, options.checks);\n limits = mergeLimits(limits, options.limits);\n },\n command(options) {\n if (typeof options.pattern !== \"string\" || !options.task) {\n throw new Error(\"pipr.command requires { pattern, task }\");\n }\n const pattern = options.pattern;\n const tokens = pattern.trim().split(/\\s+/).filter(Boolean);\n if (tokens.length === 0) {\n throw new Error(\"Command pattern must not be empty\");\n }\n if (tokens[0] !== \"@pipr\") {\n throw new Error(`Command pattern '${pattern}' must start with @pipr`);\n }\n assertSupportedCommandRestCapture(pattern);\n commands.push({\n pattern,\n permission: options.permission ?? \"write\",\n description: options.description,\n parse: options.parse as ((arguments_: Record<string, string>) => unknown) | undefined,\n task: options.task as Task<unknown>,\n });\n },\n use(plugin) {\n return plugin.setup(api);\n },\n tool(definition) {\n if (definition.name === \"readOnly\") {\n throw new Error(\"Tool name 'readOnly' is reserved for pipr built-in tools\");\n }\n const run = definition.run;\n if (!run) {\n throw new Error(`Tool '${definition.name}' must define run`);\n }\n const tool = {\n kind: \"pipr.tool\" as const,\n ...definition,\n run,\n };\n tools.push(tool);\n return tool;\n },\n schema,\n jsonSchema,\n prompt(strings, ...values) {\n let text = \"\";\n for (let index = 0; index < strings.length; index += 1) {\n text += strings[index] ?? \"\";\n if (index < values.length) {\n text += renderPromptValue(values[index]);\n }\n }\n return {\n kind: \"pipr.prompt\",\n value: stripCommonIndent(text).trim(),\n };\n },\n section(title, value) {\n const rendered = renderPromptValue(value);\n return {\n kind: \"pipr.prompt\",\n value: `## ${title}\\n\\n${rendered}`,\n };\n },\n json(value, options) {\n const text = JSON.stringify(value, null, options?.pretty === false ? 0 : 2);\n if (options?.maxCharacters !== undefined && text.length > options.maxCharacters) {\n throw new Error(`JSON prompt value exceeded ${options.maxCharacters} characters`);\n }\n return { kind: \"pipr.prompt\", value: text };\n },\n };\n\n return {\n api,\n plan() {\n assertUnique(\n tasks.map((task) => task.name),\n \"task\",\n );\n assertUnique(\n commands.map((command) => command.pattern),\n \"command\",\n );\n assertModelIdentity(models);\n return {\n models,\n agents,\n tasks,\n changeRequestTriggers,\n commands,\n tools,\n publication,\n checks,\n limits,\n };\n },\n };\n}\n\nfunction registerReviewRecipe(api: PiprBuilder, options: ReviewRecipeOptions): void {\n const id = options.id;\n const agent = options.reviewer ?? createReviewer(api, reviewRecipeReviewerOptions(options, id));\n\n const task = createReviewRecipeTask(api, id, agent, options);\n registerReviewRecipeEntrypoints(api, task, options);\n}\n\nconst reviewRecipeOptionKeys = new Set([\n \"id\",\n \"entrypoints\",\n \"comment\",\n \"check\",\n \"timeout\",\n \"paths\",\n \"reviewer\",\n \"name\",\n \"model\",\n \"fallbacks\",\n \"instructions\",\n \"prompt\",\n \"tools\",\n]);\n\nconst reviewRecipeEntrypointKeys = new Set([\"changeRequest\", \"command\"]);\n\nconst modelProfileConfigSchema: z.ZodType<ModelProfile> = z.custom<ModelProfile>(\n (value) =>\n typeof value === \"object\" &&\n value !== null &&\n (value as { kind?: unknown }).kind === \"pipr.model\" &&\n typeof (value as { id?: unknown }).id === \"string\" &&\n typeof (value as { provider?: unknown }).provider === \"string\" &&\n typeof (value as { model?: unknown }).model === \"string\",\n);\n\nconst autoResolveUserRepliesOptionsSchema: z.ZodType<AutoResolveUserRepliesOptions> =\n z.strictObject({\n enabled: z.boolean().optional(),\n respondWhenStillValid: z.boolean().optional(),\n allowedActors: z.enum([\"author-or-write\", \"write\", \"any\"]).optional(),\n });\n\nconst autoResolveOptionsSchema: z.ZodType<AutoResolveOptions> = z.union([\n z.literal(false),\n z.strictObject({\n enabled: z.boolean().optional(),\n model: modelProfileConfigSchema.optional(),\n instructions: z.string().min(1).max(4000).optional(),\n synchronize: z.boolean().optional(),\n userReplies: z.union([z.boolean(), autoResolveUserRepliesOptionsSchema]).optional(),\n }),\n]);\n\nconst publicationOptionsSchema: z.ZodType<PublicationOptions> = z.strictObject({\n maxInlineComments: z.number().int().min(0).max(50).optional(),\n autoResolve: autoResolveOptionsSchema.optional(),\n showHeader: z.boolean().optional(),\n showFooter: z.boolean().optional(),\n showStats: z.boolean().optional(),\n});\n\nconst aggregateCheckOptionsSchema: z.ZodType<AggregateCheckOptions> = z.union([\n z.literal(false),\n z.strictObject({\n enabled: z.boolean().optional(),\n name: z.string().min(1).optional(),\n }),\n]);\n\nconst checksOptionsSchema: z.ZodType<ChecksOptions> = z.strictObject({\n aggregate: aggregateCheckOptionsSchema.optional(),\n});\n\nconst diffManifestLimitsSchema: z.ZodType<DiffManifestLimits> = z.strictObject({\n fullMaxBytes: z.number().int().positive().optional(),\n fullMaxEstimatedTokens: z.number().int().positive().optional(),\n condensedMaxBytes: z.number().int().positive().optional(),\n condensedMaxEstimatedTokens: z.number().int().positive().optional(),\n toolResponseMaxBytes: z.number().int().positive().optional(),\n});\n\nconst runtimeLimitsSchema: z.ZodType<RuntimeLimits> = z.strictObject({\n timeoutSeconds: z.number().int().positive().max(3600).optional(),\n diffManifest: diffManifestLimitsSchema.optional(),\n});\n\nconst piprConfigOptionsSchema: z.ZodType<PiprConfigOptions> = z.strictObject({\n publication: publicationOptionsSchema.optional(),\n checks: checksOptionsSchema.optional(),\n limits: runtimeLimitsSchema.optional(),\n});\n\nfunction assertKnownReviewRecipeOptions(options: ReviewRecipeOptions): void {\n const unknownKeys = Object.keys(options).filter((key) => !reviewRecipeOptionKeys.has(key));\n if (unknownKeys.length > 0) {\n throw new Error(`pipr.review received unsupported option fields: ${unknownKeys.join(\", \")}.`);\n }\n\n const entrypoints = options.entrypoints;\n if (entrypoints && typeof entrypoints === \"object\") {\n const unknownEntrypointKeys = Object.keys(entrypoints).filter(\n (key) => !reviewRecipeEntrypointKeys.has(key),\n );\n if (unknownEntrypointKeys.length > 0) {\n throw new Error(\n `pipr.review entrypoints received unsupported fields: ${unknownEntrypointKeys.join(\", \")}.`,\n );\n }\n }\n}\n\nfunction assertKnownPiprConfigOptions(options: unknown): asserts options is PiprConfigOptions {\n const parsed = piprConfigOptionsSchema.safeParse(options);\n if (!parsed.success) {\n throw new Error(formatPiprConfigOptionsError(parsed.error));\n }\n}\n\nfunction formatPiprConfigOptionsError(error: z.ZodError): string {\n const unsupportedFields = firstUnsupportedConfigFields(error.issues, []);\n if (unsupportedFields) {\n return `${piprConfigLabel(unsupportedFields.path)} received unsupported option fields: ${unsupportedFields.keys.join(\n \", \",\n )}`;\n }\n return `pipr.config received invalid option value: ${z.prettifyError(error)}`;\n}\n\nfunction firstUnsupportedConfigFields(\n issues: readonly z.ZodIssue[],\n parentPath: readonly PropertyKey[],\n): { path: PropertyKey[]; keys: string[] } | undefined {\n for (const issue of issues) {\n const path = [...parentPath, ...issue.path];\n if (issue.code === \"unrecognized_keys\") {\n return { path, keys: issue.keys };\n }\n if (issue.code === \"invalid_union\") {\n for (const branchIssues of issue.errors) {\n const unsupportedFields = firstUnsupportedConfigFields(branchIssues, path);\n if (unsupportedFields) {\n return unsupportedFields;\n }\n }\n }\n }\n return undefined;\n}\n\nfunction piprConfigLabel(pathSegments: PropertyKey[]): string {\n const path = pathSegments.join(\".\");\n return path ? `pipr.config ${path}` : \"pipr.config\";\n}\n\nfunction reviewRecipeReviewerOptions(options: ReviewerOptions, name: string): ReviewerOptions {\n if (!options.model || !options.instructions) {\n throw new Error(\"pipr.review requires model and instructions when reviewer is not provided\");\n }\n return {\n name,\n model: options.model,\n fallbacks: options.fallbacks,\n instructions: options.instructions,\n prompt: options.prompt,\n tools: options.tools,\n timeout: options.timeout,\n };\n}\n\nfunction createReviewer(api: PiprBuilder, options: ReviewerOptions): Reviewer {\n return api.agent<DefaultReviewInput, ReviewResult>({\n name: options.name ?? \"reviewer\",\n model: options.model,\n fallbacks: options.fallbacks,\n instructions: options.instructions,\n tools: options.tools ?? api.tools.readOnly,\n output: api.schemas.review,\n timeout: options.timeout,\n prompt:\n options.prompt ??\n (() =>\n api.prompt`\n Review this change.\n `),\n });\n}\n\nfunction createReviewRecipeTask(\n api: PiprBuilder,\n id: string,\n agent: Agent<DefaultReviewInput, ReviewResult>,\n options: ReviewRecipeOptions,\n): Task {\n return api.task({\n name: id,\n check: options.check,\n async run(context) {\n const manifest = await context.change.diffManifest({\n compressed: true,\n paths: options.paths,\n });\n if (options.paths && manifest.files.length === 0) {\n context.check.neutral(\"No changed files matched this review's path scope.\");\n await context.comment({ main: \"No changed files matched this review's path scope.\" });\n return;\n }\n const result = await context.pi.run(\n agent,\n { manifest, change: context.change },\n {\n timeout: options.timeout,\n paths: options.paths,\n },\n );\n const source =\n typeof options.comment === \"function\"\n ? await options.comment(result, {\n review: { id },\n repository: context.repository,\n change: context.change,\n platform: context.platform,\n })\n : (options.comment ?? defaultReviewComment(result));\n await context.comment(source);\n },\n });\n}\n\nfunction defaultReviewComment(result: ReviewResult): CommentValue {\n return {\n main: defaultReviewMarkdown(result),\n inlineFindings: result.inlineFindings,\n };\n}\n\nfunction defaultReviewMarkdown(result: ReviewResult): Markdown {\n const findings =\n result.inlineFindings.length === 0\n ? \"No inline findings.\"\n : result.inlineFindings.map((finding) => `- ${finding.body}`).join(\"\\n\");\n return `## Summary\\n\\n${result.summary.body}\\n\\n## Findings\\n\\n${findings}`;\n}\n\nfunction registerReviewRecipeEntrypoints(\n api: PiprBuilder,\n task: Task,\n options: ReviewRecipeOptions,\n): void {\n const changeRequest = reviewChangeRequestEntrypoint(options);\n if (changeRequest) {\n api.on.changeRequest({ actions: changeRequest, task });\n }\n const command = reviewCommandEntrypoint(options);\n if (command) {\n api.command({ pattern: command.pattern, ...command.options, task });\n }\n}\n\nfunction reviewChangeRequestEntrypoint(\n options: ReviewRecipeOptions,\n): readonly ChangeRequestAction[] | undefined {\n const entrypoint = options.entrypoints?.changeRequest;\n return entrypoint === false ? undefined : (entrypoint ?? defaultReviewActions);\n}\n\nfunction reviewCommandEntrypoint(options: ReviewRecipeOptions):\n | {\n pattern: string;\n options: CommandOptions<unknown>;\n }\n | undefined {\n const entrypoint = options.entrypoints?.command;\n if (entrypoint === false) {\n return undefined;\n }\n if (typeof entrypoint === \"object\") {\n return {\n pattern: entrypoint.pattern ?? defaultReviewEntrypoints.command.pattern,\n options: {\n permission: entrypoint.permission ?? defaultReviewEntrypoints.command.permission,\n description: entrypoint.description,\n },\n };\n }\n return {\n pattern: entrypoint ?? defaultReviewEntrypoints.command.pattern,\n options: { permission: defaultReviewEntrypoints.command.permission },\n };\n}\n\nfunction mergePublicationConfig(\n target: RuntimePlan[\"publication\"],\n next: PublicationOptions | undefined,\n): void {\n if (!next) {\n return;\n }\n if (next.maxInlineComments !== undefined) {\n if (\n target.maxInlineComments !== undefined &&\n target.maxInlineComments !== next.maxInlineComments\n ) {\n throw new Error(\"pipr.config publication.maxInlineComments conflicts with existing value\");\n }\n target.maxInlineComments = next.maxInlineComments;\n }\n if (next.autoResolve !== undefined) {\n if (\n target.autoResolve !== undefined &&\n stableJson(target.autoResolve) !== stableJson(next.autoResolve)\n ) {\n throw new Error(\"pipr.config publication.autoResolve conflicts with existing value\");\n }\n target.autoResolve = next.autoResolve;\n }\n target.showHeader = mergeConfigField(\n \"publication.showHeader\",\n target.showHeader,\n next.showHeader,\n );\n target.showFooter = mergeConfigField(\n \"publication.showFooter\",\n target.showFooter,\n next.showFooter,\n );\n target.showStats = mergeConfigField(\"publication.showStats\", target.showStats, next.showStats);\n}\n\nfunction mergeConfigField<T>(\n name: string,\n current: T | undefined,\n next: T | undefined,\n): T | undefined {\n if (next === undefined) {\n return current;\n }\n if (current !== undefined && stableJson(current) !== stableJson(next)) {\n throw new Error(`pipr.config ${name} conflicts with existing value`);\n }\n return next;\n}\n\nfunction mergeLimits(current: RuntimeLimits | undefined, next: RuntimeLimits | undefined) {\n if (!next) {\n return current;\n }\n assertRuntimeLimitConflicts(current, next);\n return {\n ...current,\n ...next,\n diffManifest:\n (next.diffManifest ?? current?.diffManifest)\n ? { ...current?.diffManifest, ...next.diffManifest }\n : undefined,\n };\n}\n\nfunction assertRuntimeLimitConflicts(\n current: RuntimeLimits | undefined,\n next: RuntimeLimits,\n): void {\n const currentRecord = current as Record<string, unknown> | undefined;\n for (const [key, value] of Object.entries(next)) {\n if (key === \"diffManifest\") {\n continue;\n }\n if (\n value !== undefined &&\n currentRecord?.[key] !== undefined &&\n stableJson(currentRecord[key]) !== stableJson(value)\n ) {\n throw new Error(`pipr.config limits.${key} conflicts with existing value`);\n }\n }\n assertDiffManifestLimitConflicts(current, next);\n}\n\nfunction assertDiffManifestLimitConflicts(\n current: RuntimeLimits | undefined,\n next: RuntimeLimits,\n): void {\n if (current?.diffManifest && next.diffManifest) {\n for (const [key, value] of Object.entries(next.diffManifest)) {\n if (\n value !== undefined &&\n (current.diffManifest as Record<string, unknown>)[key] !== undefined &&\n (current.diffManifest as Record<string, unknown>)[key] !== value\n ) {\n throw new Error(`pipr.config limits.diffManifest.${key} conflicts with existing value`);\n }\n }\n }\n}\n\nfunction createAgent<Input, Output>(\n definition: AgentDefinition<Input, Output>,\n): Agent<Input, Output> {\n return {\n kind: \"pipr.agent\",\n name: definition.name,\n definition,\n extend(patch) {\n return createAgent({\n ...definition,\n ...patch,\n instructions:\n patch.instructions === undefined\n ? definition.instructions\n : {\n kind: \"pipr.prompt\",\n value:\n `${renderPromptValue(definition.instructions)}\\n\\n${renderPromptValue(patch.instructions)}`.trim(),\n },\n });\n },\n };\n}\n\nfunction assertUnique(values: string[], label: string): void {\n const seen = new Set<string>();\n for (const value of values) {\n if (seen.has(value)) {\n throw new Error(`Duplicate ${label} '${value}'`);\n }\n seen.add(value);\n }\n}\n\nfunction assertModelIdentity(models: ModelProfile[]): void {\n assertNoDuplicateModelConfigs(models);\n assertUniqueModelIds(models);\n assertProviderModelAliasesDisambiguated(models);\n}\n\nfunction assertNoDuplicateModelConfigs(models: ModelProfile[]): void {\n const effectiveConfigs = new Map<string, string>();\n for (const model of models) {\n const effectiveConfig = stableJson({\n provider: model.provider,\n model: model.model,\n apiKeyEnv: model.apiKey?.name,\n options: model.options,\n });\n const existingConfigId = effectiveConfigs.get(effectiveConfig);\n if (existingConfigId) {\n throw new Error(\n `Duplicate model config for '${model.id}'. Reuse model '${existingConfigId}' instead.`,\n );\n }\n effectiveConfigs.set(effectiveConfig, model.id);\n }\n}\n\nfunction assertUniqueModelIds(models: ModelProfile[]): void {\n const ids = new Set<string>();\n for (const model of models) {\n if (ids.has(model.id)) {\n const providerModel = `${model.provider}/${model.model}`;\n throw new Error(\n model.id === providerModel\n ? `Model '${providerModel}' is configured more than once with different options. Add an explicit id.`\n : `Duplicate model id '${model.id}'`,\n );\n }\n ids.add(model.id);\n }\n}\n\nfunction assertProviderModelAliasesDisambiguated(models: ModelProfile[]): void {\n const providerModels = new Map<string, string>();\n for (const model of models) {\n const providerModel = `${model.provider}/${model.model}`;\n const existingProviderModelId = providerModels.get(providerModel);\n if (\n existingProviderModelId &&\n (model.id === providerModel || existingProviderModelId === providerModel)\n ) {\n throw new Error(\n `Model '${providerModel}' is configured more than once with different options. Add an explicit id.`,\n );\n }\n providerModels.set(providerModel, model.id);\n }\n}\n\nfunction stableJson(value: unknown): string {\n return JSON.stringify(stableJsonValue(value));\n}\n\nfunction stableJsonValue(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(stableJsonValue);\n }\n if (typeof value === \"object\" && value !== null) {\n return Object.fromEntries(\n Object.entries(value as Record<string, unknown>)\n .filter(([, item]) => item !== undefined)\n .toSorted(([left], [right]) => left.localeCompare(right))\n .map(([key, item]) => [key, stableJsonValue(item)]),\n );\n }\n return value;\n}\n"],"mappings":";;;;AAGA,SAAgB,GAAG,SAA+B,GAAG,QAA6B;CAChF,IAAI,OAAO;CACX,KAAK,IAAI,QAAQ,GAAG,QAAQ,QAAQ,QAAQ,SAAS,GAAG;EACtD,QAAQ,QAAQ,UAAU;EAC1B,IAAI,QAAQ,OAAO,QACjB,QAAQ,OAAO,OAAO,UAAU,EAAE;CAEtC;CACA,OAAO,kBAAkB,IAAI,CAAC,CAAC,KAAK;AACtC;;AAGA,SAAgB,kBAAkB,OAAuB;CACvD,MAAM,QAAQ,MAAM,WAAW,KAAM,IAAI,CAAC,CAAC,MAAM,OAAO;CACxD,MAAM,WAAW,MAAM,QAAQ,SAAS,KAAK,KAAK,CAAC,CAAC,SAAS,CAAC;CAC9D,MAAM,SAAS,KAAK,IAAI,GAAG,SAAS,KAAK,SAAS,KAAK,MAAM,KAAK,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC;CACrF,OAAO,MAAM,KAAK,SAAS,KAAK,MAAM,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI;AAC1D;;;ACMA,MAAM,uBAAuBA,IAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AAC7C,MAAM,wBAAwBA,IAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;;AAGxD,MAAa,sBAAgDA,IAAE,aAAa;CAC1E,OAAO,qBAAqB,SAAS;CACrC,MAAM;AACR,CAAC;;AAGD,MAAa,sBAAgDA,IAAE,aAAa;CAC1E,MAAM;CACN,MAAM;CACN,SAAS;CACT,MAAMA,IAAE,KAAK,CAAC,SAAS,MAAM,CAAC;CAC9B,WAAW;CACX,SAAS;CACT,cAAc,qBAAqB,SAAS;AAC9C,CAAC;;AAGD,MAAa,qBAA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,iCAAiB,IAAI,IAAoB;CAC/C,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,gBAAgB,GAAG,MAAM,SAAS,GAAG,MAAM;EACjD,MAAM,0BAA0B,eAAe,IAAI,aAAa;EAChE,IACE,4BACC,MAAM,OAAO,iBAAiB,4BAA4B,gBAE3D,MAAM,IAAI,MACR,UAAU,cAAc,2EAC1B;EAEF,eAAe,IAAI,eAAe,MAAM,EAAE;CAC5C;AACF;AAEA,SAAS,WAAW,OAAwB;CAC1C,OAAO,KAAK,UAAU,gBAAgB,KAAK,CAAC;AAC9C;AAEA,SAAS,gBAAgB,OAAyB;CAChD,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,IAAI,eAAe;CAElC,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO,OAAO,YACZ,OAAO,QAAQ,KAAgC,CAAC,CAC7C,QAAQ,GAAG,UAAU,SAAS,KAAA,CAAS,CAAC,CACxC,UAAU,CAAC,OAAO,CAAC,WAAW,KAAK,cAAc,KAAK,CAAC,CAAC,CACxD,KAAK,CAAC,KAAK,UAAU,CAAC,KAAK,gBAAgB,IAAI,CAAC,CAAC,CACtD;CAEF,OAAO;AACT"}
1
+ {"version":3,"file":"index.mjs","names":["z","z","coreReviewResultSchema","coreReviewSummarySchema","z"],"sources":["../src/prompt.ts","../src/review-contract.ts","../src/schema.ts","../src/types/task.ts","../src/builder.ts"],"sourcesContent":["import type { Markdown } from \"./types/prompt.js\";\n\n/** Creates trimmed Markdown from a template literal with common indentation removed. */\nexport function md(strings: TemplateStringsArray, ...values: unknown[]): Markdown {\n let text = \"\";\n for (let index = 0; index < strings.length; index += 1) {\n text += strings[index] ?? \"\";\n if (index < values.length) {\n text += String(values[index] ?? \"\");\n }\n }\n return stripCommonIndent(text).trim();\n}\n\n/** Removes common leading indentation from multiline text. */\nexport function stripCommonIndent(value: string): string {\n const lines = value.replaceAll(\"\\t\", \" \").split(/\\r?\\n/);\n const nonEmpty = lines.filter((line) => line.trim().length > 0);\n const indent = Math.min(...nonEmpty.map((line) => line.match(/^ */)?.[0].length ?? 0));\n return lines.map((line) => line.slice(indent)).join(\"\\n\");\n}\n","import { z } from \"zod\";\nimport type { ZodSchema } from \"./types/schema.js\";\n\n/** Markdown summary produced by a reviewer for the main review comment. */\nexport type ReviewSummary = {\n title?: string;\n body: string;\n};\n\n/** One inline review finding targeting a Diff Manifest commentable range. */\nexport type ReviewFinding = {\n body: string;\n path: string;\n rangeId: string;\n side: \"RIGHT\" | \"LEFT\";\n startLine: number;\n endLine: number;\n suggestedFix?: string;\n};\n\n/** Core structured review result accepted by pipr review publication. */\nexport type ReviewResult = {\n summary: ReviewSummary;\n inlineFindings: ReviewFinding[];\n};\n\nconst nonEmptyStringSchema = z.string().min(1);\nconst positiveIntegerSchema = z.number().int().positive();\n\n/** Zod schema for a review summary. */\nexport const reviewSummarySchema: ZodSchema<ReviewSummary> = z.strictObject({\n title: nonEmptyStringSchema.optional(),\n body: nonEmptyStringSchema,\n});\n\n/** Zod schema for one inline review finding. */\nexport const reviewFindingSchema: ZodSchema<ReviewFinding> = z.strictObject({\n body: nonEmptyStringSchema,\n path: nonEmptyStringSchema,\n rangeId: nonEmptyStringSchema,\n side: z.enum([\"RIGHT\", \"LEFT\"]),\n startLine: positiveIntegerSchema,\n endLine: positiveIntegerSchema,\n suggestedFix: nonEmptyStringSchema.optional(),\n});\n\n/** Zod schema for Pipr's core change request review result. */\nexport const reviewResultSchema: ZodSchema<ReviewResult> = z.strictObject({\n summary: reviewSummarySchema,\n inlineFindings: z.array(reviewFindingSchema),\n});\n\n/** Parses model output for Pipr's main change request review schema. */\nexport function parseReviewResult(value: unknown): ReviewResult {\n return reviewResultSchema.parse(value) as ReviewResult;\n}\n\n/** Parses a review summary value. */\nexport function parseReviewSummary(value: unknown): ReviewSummary {\n return reviewSummarySchema.parse(value);\n}\n\n/** Parses one inline review finding. */\nexport function parseReviewFinding(value: unknown): ReviewFinding {\n return reviewFindingSchema.parse(value) as ReviewFinding;\n}\n\n/** Returns a small valid example for the main change request review schema. */\nexport function reviewSchemaExample(): ReviewResult {\n return {\n summary: {\n title: \"Optional concise review title.\",\n body: \"Concise change request review summary.\",\n },\n inlineFindings: [\n {\n body: \"Specific issue and why it matters.\",\n path: \"src/example.ts\",\n rangeId: \"rng_example\",\n side: \"RIGHT\",\n startLine: 1,\n endLine: 1,\n suggestedFix: \"return safeValue;\",\n },\n ],\n };\n}\n","import { z } from \"zod\";\nimport type { ReviewResult, ReviewSummary } from \"./review-contract.js\";\nimport {\n reviewResultSchema as coreReviewResultSchema,\n reviewSummarySchema as coreReviewSummarySchema,\n} from \"./review-contract.js\";\nimport type { BuiltinSchemaCatalog } from \"./types/agent.js\";\nimport type {\n JsonSchema,\n JsonSchemaDefinition,\n Schema,\n SchemaDefinition,\n ZodSchema,\n} from \"./types/schema.js\";\n\nconst coreReviewOutputSchemaId = \"core/pr-review\";\n\n/** Defines a typed schema from a Zod schema. */\nexport function schema<T>(definition: SchemaDefinition<T>): Schema<T> {\n if (!definition || typeof definition.id !== \"string\") {\n throw new Error(\"pipr.schema requires { id, schema }\");\n }\n assertUserSchemaId(definition.id);\n return createZodSchema(definition.id, definition.schema);\n}\n\n/** Defines a typed schema from JSON Schema. The generic type is caller supplied. */\nexport function jsonSchema<T>(definition: JsonSchemaDefinition): Schema<T> {\n if (!definition || typeof definition.id !== \"string\") {\n throw new Error(\"pipr.jsonSchema requires { id, schema }\");\n }\n assertUserSchemaId(definition.id);\n const zodSchema = z.fromJSONSchema(definition.schema);\n return createSchema(definition.id, (value) => zodSchema.parse(value) as T, definition.schema);\n}\n\n/** Built-in schemas available as reusable agent output contracts. */\nexport const schemas: BuiltinSchemaCatalog = {\n review: createZodSchema<ReviewResult>(coreReviewOutputSchemaId, coreReviewResultSchema),\n summary: createZodSchema<ReviewSummary>(\"core/summary\", coreReviewSummarySchema),\n};\n\nfunction createSchema<T>(\n id: string,\n parseValue: (value: unknown) => T,\n schemaJson?: JsonSchema,\n): Schema<T> {\n return {\n kind: \"pipr.schema\",\n id,\n jsonSchema: schemaJson,\n parse(value) {\n return parseValue(value);\n },\n safeParse(value) {\n try {\n return { success: true, data: parseValue(value) };\n } catch (error) {\n return {\n success: false,\n error: error instanceof Error ? error : new Error(String(error)),\n };\n }\n },\n };\n}\n\nfunction createZodSchema<T>(id: string, zodSchema: ZodSchema<T>): Schema<T> {\n return createSchema(id, (value) => zodSchema.parse(value), jsonSchemaFromZod(id, zodSchema));\n}\n\nfunction assertUserSchemaId(id: string): void {\n if (id.startsWith(\"core/\")) {\n throw new Error(`Schema id '${id}' uses the reserved core/ namespace`);\n }\n}\n\nfunction jsonSchemaFromZod<T>(id: string, schemaDefinition: ZodSchema<T>): JsonSchema {\n try {\n return z.toJSONSchema(schemaDefinition) as JsonSchema;\n } catch (error) {\n const detail = error instanceof Error ? error.message : String(error);\n throw new Error(\n `Schema '${id}' could not be converted to JSON Schema. Use JSON-Schema-representable Zod or pipr.jsonSchema<T>(). ${detail}`,\n );\n }\n}\n","import type { ReviewFinding, ReviewResult } from \"../review-contract.js\";\nimport type {\n Agent,\n AgentDefinition,\n AgentPromptContext,\n AgentTool,\n BuiltinSchemaCatalog,\n BuiltinToolCatalog,\n} from \"./agent.js\";\nimport type {\n ChangeRequestAction,\n DurationInput,\n ModelOptions,\n ModelProfile,\n PiprConfigOptions,\n RepositoryPermission,\n SecretOptions,\n SecretRef,\n} from \"./config.js\";\nimport type { DiffManifest, DiffManifestOptions, PathFilter } from \"./manifest.js\";\nimport type {\n JsonPromptOptions,\n Markdown,\n PromptSource,\n PromptText,\n PromptValue,\n} from \"./prompt.js\";\nimport type { JsonSchemaDefinition, Schema, SchemaDefinition } from \"./schema.js\";\n\n/** Final review comment value produced by a task or review recipe. */\nexport type CommentValue =\n | Markdown\n | {\n main?: Markdown;\n inlineFindings?: readonly ReviewFinding[];\n };\n\n/** Prior inline finding persisted by earlier pipr review state. */\nexport type PriorInlineFinding = {\n id: string;\n status: \"open\" | \"resolved\";\n path: string;\n rangeId: string;\n side: \"RIGHT\" | \"LEFT\";\n startLine: number;\n endLine: number;\n};\n\n/** Prior pipr review state available to tasks through `ctx.review.prior()`. */\nexport type PriorReview = {\n main?: Markdown;\n reviewedHeadSha?: string;\n inlineFindings: readonly PriorInlineFinding[];\n};\n\n/** Function run by a task entrypoint. */\nexport type TaskHandler<Input> = (context: TaskContext, input: Input) => void | Promise<void>;\n\n/** Check-run publication options for one task. */\nexport type TaskCheckOptions =\n | false\n | {\n enabled?: boolean;\n name?: string;\n required?: boolean;\n };\n\n/** Definition used to register a task. */\nexport type TaskDefinition<Input> = {\n name: string;\n check?: TaskCheckOptions;\n local?: false;\n run: TaskHandler<Input>;\n};\n\n/** Registered task that can be selected by change-request and command entrypoints. */\nexport type Task<Input = void> = {\n readonly kind: \"pipr.task\";\n readonly name: string;\n readonly check?: TaskCheckOptions;\n readonly local?: false;\n readonly handler: TaskHandler<Input>;\n};\n\n/** Options shared by command registrations. */\nexport type CommandOptions<Input> = {\n permission?: RepositoryPermission;\n description?: string;\n parse?: (arguments_: Record<string, string>) => Input;\n};\n\n/** Definition used to register an `@pipr` command. */\nexport type CommandRegistrationOptions<Input> = CommandOptions<Input> & {\n pattern: string;\n task: Task<Input>;\n};\n\n/** Options for creating a reusable reviewer agent. */\nexport type ReviewerOptions = {\n name?: string;\n model: ModelProfile;\n fallbacks?: ModelProfile[];\n instructions: PromptSource;\n prompt?: (\n input: DefaultReviewInput,\n context: AgentPromptContext,\n ) => PromptSource | Promise<PromptSource>;\n tools?: readonly AgentTool[];\n timeout?: DurationInput;\n};\n\n/** Reviewer agent that emits pipr's core review result. */\nexport type Reviewer = Agent<DefaultReviewInput, ReviewResult>;\n\n/** Entrypoints created by `pipr.review`. */\nexport type ReviewEntrypoints = {\n changeRequest?: readonly ChangeRequestAction[] | false;\n command?:\n | string\n | false\n | {\n pattern?: string;\n permission?: RepositoryPermission;\n description?: string;\n };\n};\n\n/** Default change-request actions used by `pipr.review`. */\nexport const defaultReviewActions = [\n \"opened\",\n \"updated\",\n \"reopened\",\n \"ready\",\n] as const satisfies readonly ChangeRequestAction[];\n\n/** Default change-request and command entrypoints used by `pipr.review`. */\nexport const defaultReviewEntrypoints = {\n changeRequest: defaultReviewActions,\n command: { pattern: \"@pipr review\", permission: \"write\" },\n} as const satisfies ReviewEntrypoints;\n\ntype ReviewRecipeEntrypointOptions = {\n id: string;\n entrypoints?: ReviewEntrypoints;\n comment?:\n | CommentValue\n | ((\n result: ReviewResult,\n context: ReviewCommentContext,\n ) => CommentValue | Promise<CommentValue>);\n check?: TaskCheckOptions;\n timeout?: DurationInput;\n paths?: PathFilter;\n};\n\n/** Options for `pipr.review`, pipr's default review recipe. */\nexport type ReviewRecipeOptions =\n | (ReviewRecipeEntrypointOptions & { reviewer: Reviewer })\n | (ReviewRecipeEntrypointOptions & ReviewerOptions & { reviewer?: undefined });\n\n/** Default input passed to a reviewer created by `pipr.review`. */\nexport type DefaultReviewInput = {\n manifest: DiffManifest;\n change: ChangeRequestInfo;\n};\n\n/** Context passed to a custom review comment renderer. */\nexport type ReviewCommentContext = {\n review: { id: string };\n repository: RepositoryInfo;\n change: ChangeRequestContext;\n platform: PlatformInfo;\n};\n\n/** Plugin installer returned by `definePlugin`. */\nexport type PiprPlugin<Handle> = {\n setup(builder: PiprBuilder): Handle;\n};\n\n/** Definition for a custom tool registered by config or plugins. */\nexport type PluginToolDefinition<Input, Output> = {\n name: string;\n description: string;\n input: Schema<Input>;\n output: Schema<Output>;\n run(options: ToolRunOptions<Input>): Output | Promise<Output>;\n toModelOutput?(output: Output): PromptValue;\n};\n\n/** Runtime input passed to a tool implementation. */\nexport type ToolRunOptions<Input> = {\n input: Input;\n ctx: TaskContext;\n signal?: AbortSignal;\n};\n\n/** Definition used to register a task for change request actions. */\nexport type ChangeRequestRegistrationOptions<Input> = {\n actions: readonly ChangeRequestAction[];\n task: Task<Input>;\n};\n\n/** Handle for reporting task check status from inside a task. */\nexport type CheckHandle = {\n pass(summary?: string): void;\n fail(summary?: string): void;\n neutral(summary?: string): void;\n};\n\n/** Builder API available inside `definePipr`. */\nexport type PiprBuilder = {\n readonly tools: BuiltinToolCatalog;\n readonly schemas: BuiltinSchemaCatalog;\n readonly on: {\n changeRequest<Input = void>(options: ChangeRequestRegistrationOptions<Input>): void;\n };\n secret(options: SecretOptions): SecretRef;\n model(options: ModelOptions): ModelProfile;\n agent<Input, Output>(definition: AgentDefinition<Input, Output>): Agent<Input, Output>;\n task<Input = void>(definition: TaskDefinition<Input>): Task<Input>;\n reviewer(options: ReviewerOptions): Reviewer;\n review(options: ReviewRecipeOptions): void;\n config(options: PiprConfigOptions): void;\n command<Input = void>(options: CommandRegistrationOptions<Input>): void;\n use<Handle>(plugin: PiprPlugin<Handle>): Handle;\n tool<Input, Output>(definition: PluginToolDefinition<Input, Output>): AgentTool<Input, Output>;\n schema<T>(definition: SchemaDefinition<T>): Schema<T>;\n jsonSchema<T>(definition: JsonSchemaDefinition): Schema<T>;\n prompt(strings: TemplateStringsArray, ...values: PromptValue[]): PromptText;\n section(title: string, value: PromptValue): PromptText;\n json(value: unknown, options?: JsonPromptOptions): PromptText;\n};\n\n/** Repository metadata available to tasks and agents. */\nexport type RepositoryInfo = {\n root: string;\n owner?: string;\n name: string;\n defaultBranch?: string;\n remoteUrl?: string;\n};\n\n/** Pull request or change-request metadata available to tasks and agents. */\nexport type ChangeRequestInfo = {\n number?: number;\n title: string;\n description: string;\n url?: string;\n author?: { login: string };\n base: { ref?: string; sha: string };\n head: { ref?: string; sha: string };\n isFork?: boolean;\n};\n\n/** Code hosting platform metadata. */\nexport type PlatformInfo = {\n id: string;\n};\n\n/** Change-request context available inside tasks. */\nexport type ChangeRequestContext = ChangeRequestInfo & {\n diffManifest(options?: DiffManifestOptions): Promise<DiffManifest>;\n changedFiles(): Promise<Array<{ path: string; previousPath?: string; status: string }>>;\n currentHeadSha(): Promise<string>;\n};\n\n/** Runner for invoking Pi agents from tasks. */\nexport type PiRunner = {\n run<Input, Output>(\n agent: Agent<Input, Output>,\n input: Input,\n options?: {\n model?: ModelProfile;\n fallbacks?: ModelProfile[];\n instructions?: PromptSource;\n timeout?: DurationInput;\n paths?: PathFilter;\n },\n ): Promise<Output>;\n};\n\n/** Command context available inside command-triggered tasks. */\nexport type CommandContext = {\n readonly name: string;\n readonly line: string;\n readonly arguments: Record<string, string>;\n reply(markdown: Markdown): Promise<void>;\n};\n\n/** Context object passed to task handlers. */\nexport type TaskContext = {\n /** Stable id for the selected Review Run, not the process attempt. */\n readonly run: { id: string };\n readonly repository: RepositoryInfo;\n readonly change: ChangeRequestContext;\n readonly platform: PlatformInfo;\n readonly pi: PiRunner;\n readonly command?: CommandContext;\n secret(secret: SecretRef): string;\n readonly review: {\n prior(): Promise<PriorReview>;\n };\n readonly check: CheckHandle;\n comment(value: CommentValue): Promise<void>;\n readonly log: {\n info(message: string): void;\n warn(message: string): void;\n error(message: string): void;\n };\n};\n","import { z } from \"zod\";\nimport { assertSupportedCommandRestCapture } from \"./command-grammar.js\";\nimport {\n builtinReadOnlyToolBrand,\n configFactoryBrand,\n type InternalPiprConfigFactory,\n} from \"./internal-contract.js\";\nimport { stripCommonIndent } from \"./prompt.js\";\nimport { renderPromptValue } from \"./prompt-render.js\";\nimport type { ReviewResult } from \"./review-contract.js\";\nimport type { RuntimePlan } from \"./runtime-contract.js\";\nimport { jsonSchema, schema, schemas } from \"./schema.js\";\nimport type { Agent, AgentDefinition, AgentTool, BuiltinToolCatalog } from \"./types/agent.js\";\nimport type {\n AggregateCheckOptions,\n AutoResolveOptions,\n AutoResolveUserRepliesOptions,\n ChangeRequestAction,\n ChecksOptions,\n ModelProfile,\n PiprConfigOptions,\n PublicationOptions,\n} from \"./types/config.js\";\nimport { maxStoredFindingsLimit } from \"./types/config.js\";\nimport type { DiffManifestLimits, RuntimeLimits } from \"./types/manifest.js\";\nimport type { Markdown } from \"./types/prompt.js\";\nimport type {\n CommandOptions,\n CommentValue,\n DefaultReviewInput,\n PiprBuilder,\n PiprPlugin,\n Reviewer,\n ReviewerOptions,\n ReviewRecipeOptions,\n Task,\n} from \"./types/task.js\";\nimport { defaultReviewActions, defaultReviewEntrypoints } from \"./types/task.js\";\n\n/** Defines a synchronous pipr configuration factory. */\nexport function definePipr(configure: (pipr: PiprBuilder) => void): {\n readonly kind: \"pipr.config-factory\";\n} {\n const factory = {\n kind: \"pipr.config-factory\",\n [configFactoryBrand]: true,\n build() {\n const builder = createBuilder();\n const result = configure(builder.api);\n if (\n typeof result === \"object\" &&\n result !== null &&\n typeof Reflect.get(result, \"then\") === \"function\"\n ) {\n throw new Error(\"definePipr configuration callback must be synchronous\");\n }\n return builder.plan();\n },\n } satisfies InternalPiprConfigFactory;\n return factory;\n}\n\n/** Defines a typed pipr plugin installer. */\nexport function definePlugin<Handle>(setup: (builder: PiprBuilder) => Handle): PiprPlugin<Handle> {\n return { setup };\n}\n\nfunction createBuilder(): { api: PiprBuilder; plan(): RuntimePlan } {\n const models: ModelProfile[] = [];\n const agents: Agent[] = [];\n const tasks: Task<unknown>[] = [];\n const changeRequestTriggers: RuntimePlan[\"changeRequestTriggers\"] = [];\n const commands: RuntimePlan[\"commands\"] = [];\n const tools: AgentTool[] = [];\n const publication: RuntimePlan[\"publication\"] = {};\n let checks: ChecksOptions | undefined;\n let limits: RuntimeLimits | undefined;\n\n const api: PiprBuilder = {\n tools: {\n readOnly: [\n {\n kind: \"pipr.tool\",\n name: \"readOnly\",\n [builtinReadOnlyToolBrand]: true,\n } as AgentTool,\n ],\n } satisfies BuiltinToolCatalog,\n schemas,\n on: {\n changeRequest(options) {\n if (!Array.isArray(options.actions) || !options.task) {\n throw new Error(\"pipr.on.changeRequest requires { actions, task }\");\n }\n changeRequestTriggers.push({\n actions: [...options.actions],\n task: options.task as Task<unknown>,\n });\n },\n },\n secret(options) {\n if (!options || typeof options.name !== \"string\") {\n throw new Error(\"pipr.secret requires { name }\");\n }\n if (!/^[A-Z_][A-Z0-9_]*$/.test(options.name)) {\n throw new Error(`Secret '${options.name}' must be an environment variable name`);\n }\n return { kind: \"pipr.secret\", name: options.name };\n },\n model(options) {\n if (!options || typeof options.provider !== \"string\" || typeof options.model !== \"string\") {\n throw new Error(\"pipr.model requires { provider, model }\");\n }\n if (!options.provider || !options.model) {\n throw new Error(\"pipr.model requires provider and model\");\n }\n const id = options.id ?? `${options.provider}/${options.model}`;\n const profile: ModelProfile = {\n kind: \"pipr.model\",\n id,\n provider: options.provider,\n model: options.model,\n apiKey: options.apiKey,\n options: options.options,\n };\n models.push(profile);\n return profile;\n },\n agent(definition) {\n const agent = createAgent(definition);\n agents.push(agent);\n return agent;\n },\n task(definition) {\n if (!definition.name || typeof definition.run !== \"function\") {\n throw new Error(\"pipr.task requires { name, run }\");\n }\n const task = {\n kind: \"pipr.task\" as const,\n name: definition.name,\n check: definition.check,\n ...(definition.local === false ? { local: false as const } : {}),\n handler: definition.run,\n };\n tasks.push(task as Task<unknown>);\n return task;\n },\n reviewer(options) {\n return createReviewer(api, options);\n },\n review(options) {\n assertKnownReviewRecipeOptions(options);\n registerReviewRecipe(api, options);\n },\n config(options) {\n assertKnownPiprConfigOptions(options);\n mergePublicationConfig(publication, options.publication);\n checks = mergeConfigField(\"checks\", checks, options.checks);\n limits = mergeLimits(limits, options.limits);\n },\n command(options) {\n if (typeof options.pattern !== \"string\" || !options.task) {\n throw new Error(\"pipr.command requires { pattern, task }\");\n }\n const pattern = options.pattern;\n const tokens = pattern.trim().split(/\\s+/).filter(Boolean);\n if (tokens.length === 0) {\n throw new Error(\"Command pattern must not be empty\");\n }\n if (tokens[0] !== \"@pipr\") {\n throw new Error(`Command pattern '${pattern}' must start with @pipr`);\n }\n assertSupportedCommandRestCapture(pattern);\n commands.push({\n pattern,\n permission: options.permission ?? \"write\",\n description: options.description,\n parse: options.parse as ((arguments_: Record<string, string>) => unknown) | undefined,\n task: options.task as Task<unknown>,\n });\n },\n use(plugin) {\n return plugin.setup(api);\n },\n tool(definition) {\n if (definition.name === \"readOnly\") {\n throw new Error(\"Tool name 'readOnly' is reserved for pipr built-in tools\");\n }\n const run = definition.run;\n if (!run) {\n throw new Error(`Tool '${definition.name}' must define run`);\n }\n const tool = {\n kind: \"pipr.tool\" as const,\n ...definition,\n run,\n };\n tools.push(tool);\n return tool;\n },\n schema,\n jsonSchema,\n prompt(strings, ...values) {\n let text = \"\";\n for (let index = 0; index < strings.length; index += 1) {\n text += strings[index] ?? \"\";\n if (index < values.length) {\n text += renderPromptValue(values[index]);\n }\n }\n return {\n kind: \"pipr.prompt\",\n value: stripCommonIndent(text).trim(),\n };\n },\n section(title, value) {\n const rendered = renderPromptValue(value);\n return {\n kind: \"pipr.prompt\",\n value: `## ${title}\\n\\n${rendered}`,\n };\n },\n json(value, options) {\n const text = JSON.stringify(value, null, options?.pretty === false ? 0 : 2);\n if (options?.maxCharacters !== undefined && text.length > options.maxCharacters) {\n throw new Error(`JSON prompt value exceeded ${options.maxCharacters} characters`);\n }\n return { kind: \"pipr.prompt\", value: text };\n },\n };\n\n return {\n api,\n plan() {\n assertUnique(\n tasks.map((task) => task.name),\n \"task\",\n );\n assertUnique(\n commands.map((command) => command.pattern),\n \"command\",\n );\n assertModelIdentity(models);\n return {\n models,\n agents,\n tasks,\n changeRequestTriggers,\n commands,\n tools,\n publication,\n checks,\n limits,\n };\n },\n };\n}\n\nfunction registerReviewRecipe(api: PiprBuilder, options: ReviewRecipeOptions): void {\n const id = options.id;\n const agent = options.reviewer ?? createReviewer(api, reviewRecipeReviewerOptions(options, id));\n\n const task = createReviewRecipeTask(api, id, agent, options);\n registerReviewRecipeEntrypoints(api, task, options);\n}\n\nconst reviewRecipeOptionKeys = new Set([\n \"id\",\n \"entrypoints\",\n \"comment\",\n \"check\",\n \"timeout\",\n \"paths\",\n \"reviewer\",\n \"name\",\n \"model\",\n \"fallbacks\",\n \"instructions\",\n \"prompt\",\n \"tools\",\n]);\n\nconst reviewRecipeEntrypointKeys = new Set([\"changeRequest\", \"command\"]);\n\nconst modelProfileConfigSchema: z.ZodType<ModelProfile> = z.custom<ModelProfile>(\n (value) =>\n typeof value === \"object\" &&\n value !== null &&\n (value as { kind?: unknown }).kind === \"pipr.model\" &&\n typeof (value as { id?: unknown }).id === \"string\" &&\n typeof (value as { provider?: unknown }).provider === \"string\" &&\n typeof (value as { model?: unknown }).model === \"string\",\n);\n\nconst autoResolveUserRepliesOptionsSchema: z.ZodType<AutoResolveUserRepliesOptions> =\n z.strictObject({\n enabled: z.boolean().optional(),\n respondWhenStillValid: z.boolean().optional(),\n allowedActors: z.enum([\"author-or-write\", \"write\", \"any\"]).optional(),\n });\n\nconst autoResolveOptionsSchema: z.ZodType<AutoResolveOptions> = z.union([\n z.literal(false),\n z.strictObject({\n enabled: z.boolean().optional(),\n model: modelProfileConfigSchema.optional(),\n instructions: z.string().min(1).max(4000).optional(),\n synchronize: z.boolean().optional(),\n userReplies: z.union([z.boolean(), autoResolveUserRepliesOptionsSchema]).optional(),\n }),\n]);\n\nconst publicationOptionsSchema: z.ZodType<PublicationOptions> = z.strictObject({\n maxInlineComments: z.number().int().min(0).max(50).optional(),\n maxStoredFindings: z.number().int().min(0).max(maxStoredFindingsLimit).optional(),\n autoResolve: autoResolveOptionsSchema.optional(),\n showHeader: z.boolean().optional(),\n showFooter: z.boolean().optional(),\n showStats: z.boolean().optional(),\n});\n\nconst aggregateCheckOptionsSchema: z.ZodType<AggregateCheckOptions> = z.union([\n z.literal(false),\n z.strictObject({\n enabled: z.boolean().optional(),\n name: z.string().min(1).optional(),\n }),\n]);\n\nconst checksOptionsSchema: z.ZodType<ChecksOptions> = z.strictObject({\n aggregate: aggregateCheckOptionsSchema.optional(),\n});\n\nconst diffManifestLimitsSchema: z.ZodType<DiffManifestLimits> = z.strictObject({\n fullMaxBytes: z.number().int().positive().optional(),\n fullMaxEstimatedTokens: z.number().int().positive().optional(),\n condensedMaxBytes: z.number().int().positive().optional(),\n condensedMaxEstimatedTokens: z.number().int().positive().optional(),\n toolResponseMaxBytes: z.number().int().positive().optional(),\n});\n\nconst runtimeLimitsSchema: z.ZodType<RuntimeLimits> = z.strictObject({\n timeoutSeconds: z.number().int().positive().max(3600).optional(),\n diffManifest: diffManifestLimitsSchema.optional(),\n});\n\nconst piprConfigOptionsSchema: z.ZodType<PiprConfigOptions> = z.strictObject({\n publication: publicationOptionsSchema.optional(),\n checks: checksOptionsSchema.optional(),\n limits: runtimeLimitsSchema.optional(),\n});\n\nfunction assertKnownReviewRecipeOptions(options: ReviewRecipeOptions): void {\n const unknownKeys = Object.keys(options).filter((key) => !reviewRecipeOptionKeys.has(key));\n if (unknownKeys.length > 0) {\n throw new Error(`pipr.review received unsupported option fields: ${unknownKeys.join(\", \")}.`);\n }\n\n const entrypoints = options.entrypoints;\n if (entrypoints && typeof entrypoints === \"object\") {\n const unknownEntrypointKeys = Object.keys(entrypoints).filter(\n (key) => !reviewRecipeEntrypointKeys.has(key),\n );\n if (unknownEntrypointKeys.length > 0) {\n throw new Error(\n `pipr.review entrypoints received unsupported fields: ${unknownEntrypointKeys.join(\", \")}.`,\n );\n }\n }\n}\n\nfunction assertKnownPiprConfigOptions(options: unknown): asserts options is PiprConfigOptions {\n const parsed = piprConfigOptionsSchema.safeParse(options);\n if (!parsed.success) {\n throw new Error(formatPiprConfigOptionsError(parsed.error));\n }\n}\n\nfunction formatPiprConfigOptionsError(error: z.ZodError): string {\n const unsupportedFields = firstUnsupportedConfigFields(error.issues, []);\n if (unsupportedFields) {\n return `${piprConfigLabel(unsupportedFields.path)} received unsupported option fields: ${unsupportedFields.keys.join(\n \", \",\n )}`;\n }\n return `pipr.config received invalid option value: ${z.prettifyError(error)}`;\n}\n\nfunction firstUnsupportedConfigFields(\n issues: readonly z.ZodIssue[],\n parentPath: readonly PropertyKey[],\n): { path: PropertyKey[]; keys: string[] } | undefined {\n for (const issue of issues) {\n const path = [...parentPath, ...issue.path];\n if (issue.code === \"unrecognized_keys\") {\n return { path, keys: issue.keys };\n }\n if (issue.code === \"invalid_union\") {\n for (const branchIssues of issue.errors) {\n const unsupportedFields = firstUnsupportedConfigFields(branchIssues, path);\n if (unsupportedFields) {\n return unsupportedFields;\n }\n }\n }\n }\n return undefined;\n}\n\nfunction piprConfigLabel(pathSegments: PropertyKey[]): string {\n const path = pathSegments.join(\".\");\n return path ? `pipr.config ${path}` : \"pipr.config\";\n}\n\nfunction reviewRecipeReviewerOptions(options: ReviewerOptions, name: string): ReviewerOptions {\n if (!options.model || !options.instructions) {\n throw new Error(\"pipr.review requires model and instructions when reviewer is not provided\");\n }\n return {\n name,\n model: options.model,\n fallbacks: options.fallbacks,\n instructions: options.instructions,\n prompt: options.prompt,\n tools: options.tools,\n timeout: options.timeout,\n };\n}\n\nfunction createReviewer(api: PiprBuilder, options: ReviewerOptions): Reviewer {\n return api.agent<DefaultReviewInput, ReviewResult>({\n name: options.name ?? \"reviewer\",\n model: options.model,\n fallbacks: options.fallbacks,\n instructions: options.instructions,\n tools: options.tools ?? api.tools.readOnly,\n output: api.schemas.review,\n timeout: options.timeout,\n prompt:\n options.prompt ??\n (() =>\n api.prompt`\n Review this change.\n `),\n });\n}\n\nfunction createReviewRecipeTask(\n api: PiprBuilder,\n id: string,\n agent: Agent<DefaultReviewInput, ReviewResult>,\n options: ReviewRecipeOptions,\n): Task {\n return api.task({\n name: id,\n check: options.check,\n async run(context) {\n const manifest = await context.change.diffManifest({\n compressed: true,\n paths: options.paths,\n });\n if (options.paths && manifest.files.length === 0) {\n context.check.neutral(\"No changed files matched this review's path scope.\");\n await context.comment({ main: \"No changed files matched this review's path scope.\" });\n return;\n }\n const result = await context.pi.run(\n agent,\n { manifest, change: context.change },\n {\n timeout: options.timeout,\n paths: options.paths,\n },\n );\n const source =\n typeof options.comment === \"function\"\n ? await options.comment(result, {\n review: { id },\n repository: context.repository,\n change: context.change,\n platform: context.platform,\n })\n : (options.comment ?? defaultReviewComment(result));\n await context.comment(source);\n },\n });\n}\n\nfunction defaultReviewComment(result: ReviewResult): CommentValue {\n return {\n main: defaultReviewMarkdown(result),\n inlineFindings: result.inlineFindings,\n };\n}\n\nfunction defaultReviewMarkdown(result: ReviewResult): Markdown {\n const findings =\n result.inlineFindings.length === 0\n ? \"No inline findings.\"\n : result.inlineFindings.map((finding) => `- ${finding.body}`).join(\"\\n\");\n return `## Summary\\n\\n${result.summary.body}\\n\\n## Findings\\n\\n${findings}`;\n}\n\nfunction registerReviewRecipeEntrypoints(\n api: PiprBuilder,\n task: Task,\n options: ReviewRecipeOptions,\n): void {\n const changeRequest = reviewChangeRequestEntrypoint(options);\n if (changeRequest) {\n api.on.changeRequest({ actions: changeRequest, task });\n }\n const command = reviewCommandEntrypoint(options);\n if (command) {\n api.command({ pattern: command.pattern, ...command.options, task });\n }\n}\n\nfunction reviewChangeRequestEntrypoint(\n options: ReviewRecipeOptions,\n): readonly ChangeRequestAction[] | undefined {\n const entrypoint = options.entrypoints?.changeRequest;\n return entrypoint === false ? undefined : (entrypoint ?? defaultReviewActions);\n}\n\nfunction reviewCommandEntrypoint(options: ReviewRecipeOptions):\n | {\n pattern: string;\n options: CommandOptions<unknown>;\n }\n | undefined {\n const entrypoint = options.entrypoints?.command;\n if (entrypoint === false) {\n return undefined;\n }\n if (typeof entrypoint === \"object\") {\n return {\n pattern: entrypoint.pattern ?? defaultReviewEntrypoints.command.pattern,\n options: {\n permission: entrypoint.permission ?? defaultReviewEntrypoints.command.permission,\n description: entrypoint.description,\n },\n };\n }\n return {\n pattern: entrypoint ?? defaultReviewEntrypoints.command.pattern,\n options: { permission: defaultReviewEntrypoints.command.permission },\n };\n}\n\nfunction mergePublicationConfig(\n target: RuntimePlan[\"publication\"],\n next: PublicationOptions | undefined,\n): void {\n if (!next) {\n return;\n }\n target.maxInlineComments = mergeConfigField(\n \"publication.maxInlineComments\",\n target.maxInlineComments,\n next.maxInlineComments,\n );\n target.maxStoredFindings = mergeConfigField(\n \"publication.maxStoredFindings\",\n target.maxStoredFindings,\n next.maxStoredFindings,\n );\n target.autoResolve = mergeConfigField(\n \"publication.autoResolve\",\n target.autoResolve,\n next.autoResolve,\n );\n target.showHeader = mergeConfigField(\n \"publication.showHeader\",\n target.showHeader,\n next.showHeader,\n );\n target.showFooter = mergeConfigField(\n \"publication.showFooter\",\n target.showFooter,\n next.showFooter,\n );\n target.showStats = mergeConfigField(\"publication.showStats\", target.showStats, next.showStats);\n}\n\nfunction mergeConfigField<T>(\n name: string,\n current: T | undefined,\n next: T | undefined,\n): T | undefined {\n if (next === undefined) {\n return current;\n }\n if (current !== undefined && stableJson(current) !== stableJson(next)) {\n throw new Error(`pipr.config ${name} conflicts with existing value`);\n }\n return next;\n}\n\nfunction mergeLimits(current: RuntimeLimits | undefined, next: RuntimeLimits | undefined) {\n if (!next) {\n return current;\n }\n assertRuntimeLimitConflicts(current, next);\n return {\n ...current,\n ...next,\n diffManifest:\n (next.diffManifest ?? current?.diffManifest)\n ? { ...current?.diffManifest, ...next.diffManifest }\n : undefined,\n };\n}\n\nfunction assertRuntimeLimitConflicts(\n current: RuntimeLimits | undefined,\n next: RuntimeLimits,\n): void {\n const currentRecord = current as Record<string, unknown> | undefined;\n for (const [key, value] of Object.entries(next)) {\n if (key === \"diffManifest\") {\n continue;\n }\n if (\n value !== undefined &&\n currentRecord?.[key] !== undefined &&\n stableJson(currentRecord[key]) !== stableJson(value)\n ) {\n throw new Error(`pipr.config limits.${key} conflicts with existing value`);\n }\n }\n assertDiffManifestLimitConflicts(current, next);\n}\n\nfunction assertDiffManifestLimitConflicts(\n current: RuntimeLimits | undefined,\n next: RuntimeLimits,\n): void {\n if (current?.diffManifest && next.diffManifest) {\n for (const [key, value] of Object.entries(next.diffManifest)) {\n if (\n value !== undefined &&\n (current.diffManifest as Record<string, unknown>)[key] !== undefined &&\n (current.diffManifest as Record<string, unknown>)[key] !== value\n ) {\n throw new Error(`pipr.config limits.diffManifest.${key} conflicts with existing value`);\n }\n }\n }\n}\n\nfunction createAgent<Input, Output>(\n definition: AgentDefinition<Input, Output>,\n): Agent<Input, Output> {\n return {\n kind: \"pipr.agent\",\n name: definition.name,\n definition,\n extend(patch) {\n return createAgent({\n ...definition,\n ...patch,\n instructions:\n patch.instructions === undefined\n ? definition.instructions\n : {\n kind: \"pipr.prompt\",\n value:\n `${renderPromptValue(definition.instructions)}\\n\\n${renderPromptValue(patch.instructions)}`.trim(),\n },\n });\n },\n };\n}\n\nfunction assertUnique(values: string[], label: string): void {\n const seen = new Set<string>();\n for (const value of values) {\n if (seen.has(value)) {\n throw new Error(`Duplicate ${label} '${value}'`);\n }\n seen.add(value);\n }\n}\n\nfunction assertModelIdentity(models: ModelProfile[]): void {\n assertNoDuplicateModelConfigs(models);\n assertUniqueModelIds(models);\n assertProviderModelAliasesDisambiguated(models);\n}\n\nfunction assertNoDuplicateModelConfigs(models: ModelProfile[]): void {\n const effectiveConfigs = new Map<string, string>();\n for (const model of models) {\n const effectiveConfig = stableJson({\n provider: model.provider,\n model: model.model,\n apiKeyEnv: model.apiKey?.name,\n options: model.options,\n });\n const existingConfigId = effectiveConfigs.get(effectiveConfig);\n if (existingConfigId) {\n throw new Error(\n `Duplicate model config for '${model.id}'. Reuse model '${existingConfigId}' instead.`,\n );\n }\n effectiveConfigs.set(effectiveConfig, model.id);\n }\n}\n\nfunction assertUniqueModelIds(models: ModelProfile[]): void {\n const ids = new Set<string>();\n for (const model of models) {\n if (ids.has(model.id)) {\n const providerModel = `${model.provider}/${model.model}`;\n throw new Error(\n model.id === providerModel\n ? `Model '${providerModel}' is configured more than once with different options. Add an explicit id.`\n : `Duplicate model id '${model.id}'`,\n );\n }\n ids.add(model.id);\n }\n}\n\nfunction assertProviderModelAliasesDisambiguated(models: ModelProfile[]): void {\n const providerModels = new Map<string, string>();\n for (const model of models) {\n const providerModel = `${model.provider}/${model.model}`;\n const existingProviderModelId = providerModels.get(providerModel);\n if (\n existingProviderModelId &&\n (model.id === providerModel || existingProviderModelId === providerModel)\n ) {\n throw new Error(\n `Model '${providerModel}' is configured more than once with different options. Add an explicit id.`,\n );\n }\n providerModels.set(providerModel, model.id);\n }\n}\n\nfunction stableJson(value: unknown): string {\n return JSON.stringify(stableJsonValue(value));\n}\n\nfunction stableJsonValue(value: unknown): unknown {\n if (Array.isArray(value)) {\n return value.map(stableJsonValue);\n }\n if (typeof value === \"object\" && value !== null) {\n return Object.fromEntries(\n Object.entries(value as Record<string, unknown>)\n .filter(([, item]) => item !== undefined)\n .toSorted(([left], [right]) => left.localeCompare(right))\n .map(([key, item]) => [key, stableJsonValue(item)]),\n );\n }\n return value;\n}\n"],"mappings":";;;;AAGA,SAAgB,GAAG,SAA+B,GAAG,QAA6B;CAChF,IAAI,OAAO;CACX,KAAK,IAAI,QAAQ,GAAG,QAAQ,QAAQ,QAAQ,SAAS,GAAG;EACtD,QAAQ,QAAQ,UAAU;EAC1B,IAAI,QAAQ,OAAO,QACjB,QAAQ,OAAO,OAAO,UAAU,EAAE;CAEtC;CACA,OAAO,kBAAkB,IAAI,CAAC,CAAC,KAAK;AACtC;;AAGA,SAAgB,kBAAkB,OAAuB;CACvD,MAAM,QAAQ,MAAM,WAAW,KAAM,IAAI,CAAC,CAAC,MAAM,OAAO;CACxD,MAAM,WAAW,MAAM,QAAQ,SAAS,KAAK,KAAK,CAAC,CAAC,SAAS,CAAC;CAC9D,MAAM,SAAS,KAAK,IAAI,GAAG,SAAS,KAAK,SAAS,KAAK,MAAM,KAAK,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,CAAC;CACrF,OAAO,MAAM,KAAK,SAAS,KAAK,MAAM,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI;AAC1D;;;ACMA,MAAM,uBAAuBA,IAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AAC7C,MAAM,wBAAwBA,IAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;;AAGxD,MAAa,sBAAgDA,IAAE,aAAa;CAC1E,OAAO,qBAAqB,SAAS;CACrC,MAAM;AACR,CAAC;;AAGD,MAAa,sBAAgDA,IAAE,aAAa;CAC1E,MAAM;CACN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EACA,IAAI,IAAI,MAAM,EAAE;CAClB;AACF;AAEA,SAAS,wCAAwC,QAA8B;CAC7E,MAAM,iCAAiB,IAAI,IAAoB;CAC/C,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,gBAAgB,GAAG,MAAM,SAAS,GAAG,MAAM;EACjD,MAAM,0BAA0B,eAAe,IAAI,aAAa;EAChE,IACE,4BACC,MAAM,OAAO,iBAAiB,4BAA4B,gBAE3D,MAAM,IAAI,MACR,UAAU,cAAc,2EAC1B;EAEF,eAAe,IAAI,eAAe,MAAM,EAAE;CAC5C;AACF;AAEA,SAAS,WAAW,OAAwB;CAC1C,OAAO,KAAK,UAAU,gBAAgB,KAAK,CAAC;AAC9C;AAEA,SAAS,gBAAgB,OAAyB;CAChD,IAAI,MAAM,QAAQ,KAAK,GACrB,OAAO,MAAM,IAAI,eAAe;CAElC,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO,OAAO,YACZ,OAAO,QAAQ,KAAgC,CAAC,CAC7C,QAAQ,GAAG,UAAU,SAAS,KAAA,CAAS,CAAC,CACxC,UAAU,CAAC,OAAO,CAAC,WAAW,KAAK,cAAc,KAAK,CAAC,CAAC,CACxD,KAAK,CAAC,KAAK,UAAU,CAAC,KAAK,gBAAgB,IAAI,CAAC,CAAC,CACtD;CAEF,OAAO;AACT"}
@@ -1,4 +1,4 @@
1
- import { A as Task, H as AgentTool, R as Agent, Y as PromptValue, bt as RuntimeLimits, et as ChangeRequestAction, it as ModelProfile, ot as PublicationOptions, st as RepositoryPermission, tt as ChecksOptions } from "./index-Cdy9nsaD.mjs";
1
+ import { A as Task, H as AgentTool, R as Agent, St as RuntimeLimits, Y as PromptValue, dt as maxStoredFindingsLimit, et as ChangeRequestAction, it as ModelProfile, ot as PublicationOptions, st as RepositoryPermission, tt as ChecksOptions, ut as defaultMaxStoredFindings } from "./index-D_XmBHeL.mjs";
2
2
  //#region src/runtime-contract.d.ts
3
3
  /** Runtime plan produced from user configuration. */
4
4
  type RuntimePlan = {
@@ -51,7 +51,7 @@ declare function readSdkDeclarationSourceWithChunk(module: {
51
51
  declare function embeddedSdkDeclaration(modules: SdkDeclarationModule[]): string;
52
52
  //#endregion
53
53
  //#region src/internal.d.ts
54
- /** Stable identifier for pipr's built-in pull request review output schema. */
54
+ /** Stable identifier for Pipr's built-in change request review output schema. */
55
55
  declare const reviewOutputSchemaId = "core/pr-review";
56
56
  /** Returns whether a tool is one of pipr's built-in read-only tools. */
57
57
  declare function isBuiltinReadOnlyTool(tool: AgentTool): boolean;
@@ -60,5 +60,5 @@ declare function isPiprConfigFactory(value: unknown): value is ConfigFactoryValu
60
60
  /** Builds a runtime plan from a pipr configuration factory. */
61
61
  declare function buildPiprPlan(factory: unknown): RuntimePlan;
62
62
  //#endregion
63
- export { type RuntimePlan, type SdkDeclarationModule, assertSupportedCommandRestCapture, buildPiprPlan, commandPatternParts, embeddedSdkDeclaration, isBuiltinReadOnlyTool, isCommandCaptureToken, isCommandRestCaptureToken, isOptionalCommandPatternPart, isPiprConfigFactory, readSdkDeclarationSourceWithChunk, renderPromptValue, reviewOutputSchemaId, tokenizeCommandPattern, unsupportedCommandRestCaptureError };
63
+ export { type RuntimePlan, type SdkDeclarationModule, assertSupportedCommandRestCapture, buildPiprPlan, commandPatternParts, defaultMaxStoredFindings, embeddedSdkDeclaration, isBuiltinReadOnlyTool, isCommandCaptureToken, isCommandRestCaptureToken, isOptionalCommandPatternPart, isPiprConfigFactory, maxStoredFindingsLimit, readSdkDeclarationSourceWithChunk, renderPromptValue, reviewOutputSchemaId, tokenizeCommandPattern, unsupportedCommandRestCaptureError };
64
64
  //# sourceMappingURL=internal.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.mts","names":[],"sources":["../src/runtime-contract.ts","../src/internal-contract.ts","../src/command-grammar.ts","../src/prompt-render.ts","../src/standalone-declaration.ts","../src/internal.ts"],"mappings":";;;KAYY;EACV,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,uBAAuB;IAAQ,SAAS;IAAuB,MAAM;;EACrE,UAAU;IACR;IACA,YAAY;IACZ;IACA,SAAS,YAAY;IACrB,MAAM;;EAER,OAAO;EACP,aAAa;EACb,SAAS;EACT,SAAS;;;;KCtBC;WACD;;;;iBCNK,oBAAoB;iBAIpB,uBAAuB;iBAIvB,mCAAmC;iBAmBnC,kCAAkC;iBAOlC,6BAA6B;iBAI7B,sBAAsB;iBAItB,0BAA0B;;;;iBCvC1B,kBAAkB,OAAO;;;KCD7B;EACV;EACA;;iBAGoB,kCACpB;EAAU;GACV,0BACC;iBAgBa,uBAAuB,SAAS;;;;cCGnC;;iBAGG,sBAAsB,MAAM;;iBAK5B,oBAAoB,iBAAiB,SAAS;;iBAU9C,cAAc,mBAAmB"}
1
+ {"version":3,"file":"internal.d.mts","names":[],"sources":["../src/runtime-contract.ts","../src/internal-contract.ts","../src/command-grammar.ts","../src/prompt-render.ts","../src/standalone-declaration.ts","../src/internal.ts"],"mappings":";;;KAYY;EACV,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,uBAAuB;IAAQ,SAAS;IAAuB,MAAM;;EACrE,UAAU;IACR;IACA,YAAY;IACZ;IACA,SAAS,YAAY;IACrB,MAAM;;EAER,OAAO;EACP,aAAa;EACb,SAAS;EACT,SAAS;;;;KCtBC;WACD;;;;iBCNK,oBAAoB;iBAIpB,uBAAuB;iBAIvB,mCAAmC;iBAmBnC,kCAAkC;iBAOlC,6BAA6B;iBAI7B,sBAAsB;iBAItB,0BAA0B;;;;iBCvC1B,kBAAkB,OAAO;;;KCD7B;EACV;EACA;;iBAGoB,kCACpB;EAAU;GACV,0BACC;iBAgBa,uBAAuB,SAAS;;;;cCInC;;iBAGG,sBAAsB,MAAM;;iBAK5B,oBAAoB,iBAAiB,SAAS;;iBAU9C,cAAc,mBAAmB"}
package/dist/internal.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as commandPatternParts, c as isOptionalCommandPatternPart, i as assertSupportedCommandRestCapture, l as tokenizeCommandPattern, n as builtinReadOnlyToolBrand, o as isCommandCaptureToken, r as configFactoryBrand, s as isCommandRestCaptureToken, t as renderPromptValue, u as unsupportedCommandRestCaptureError } from "./prompt-render-BWiLG-qu.mjs";
1
+ import { a as configFactoryBrand, c as isCommandCaptureToken, d as tokenizeCommandPattern, f as unsupportedCommandRestCaptureError, i as builtinReadOnlyToolBrand, l as isCommandRestCaptureToken, n as maxStoredFindingsLimit, o as assertSupportedCommandRestCapture, r as renderPromptValue, s as commandPatternParts, t as defaultMaxStoredFindings, u as isOptionalCommandPatternPart } from "./config-Ct0Qfa_b.mjs";
2
2
  import path from "node:path";
3
3
  //#region src/standalone-declaration.ts
4
4
  async function readSdkDeclarationSourceWithChunk(module, declarationPath) {
@@ -69,7 +69,7 @@ function zodShimDeclaration() {
69
69
  }
70
70
  //#endregion
71
71
  //#region src/internal.ts
72
- /** Stable identifier for pipr's built-in pull request review output schema. */
72
+ /** Stable identifier for Pipr's built-in change request review output schema. */
73
73
  const reviewOutputSchemaId = "core/pr-review";
74
74
  /** Returns whether a tool is one of pipr's built-in read-only tools. */
75
75
  function isBuiltinReadOnlyTool(tool) {
@@ -88,6 +88,6 @@ function isInternalPiprConfigFactory(value) {
88
88
  return isPiprConfigFactory(value) && typeof Reflect.get(value, "build") === "function";
89
89
  }
90
90
  //#endregion
91
- export { assertSupportedCommandRestCapture, buildPiprPlan, commandPatternParts, embeddedSdkDeclaration, isBuiltinReadOnlyTool, isCommandCaptureToken, isCommandRestCaptureToken, isOptionalCommandPatternPart, isPiprConfigFactory, readSdkDeclarationSourceWithChunk, renderPromptValue, reviewOutputSchemaId, tokenizeCommandPattern, unsupportedCommandRestCaptureError };
91
+ export { assertSupportedCommandRestCapture, buildPiprPlan, commandPatternParts, defaultMaxStoredFindings, embeddedSdkDeclaration, isBuiltinReadOnlyTool, isCommandCaptureToken, isCommandRestCaptureToken, isOptionalCommandPatternPart, isPiprConfigFactory, maxStoredFindingsLimit, readSdkDeclarationSourceWithChunk, renderPromptValue, reviewOutputSchemaId, tokenizeCommandPattern, unsupportedCommandRestCaptureError };
92
92
 
93
93
  //# sourceMappingURL=internal.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"internal.mjs","names":[],"sources":["../src/standalone-declaration.ts","../src/internal.ts"],"sourcesContent":["import path from \"node:path\";\n\nexport type SdkDeclarationModule = {\n moduleName: string;\n source: string;\n};\n\nexport async function readSdkDeclarationSourceWithChunk(\n module: { moduleName: string },\n declarationPath: string,\n): Promise<string> {\n const source = await Bun.file(declarationPath).text();\n if (module.moduleName !== \"@usepipr/sdk\") {\n return source;\n }\n const chunkFileName = source.match(/from \"\\.\\/(?<chunk>index-[A-Za-z0-9_-]+)\\.mjs\"/)?.groups\n ?.chunk;\n if (!chunkFileName) {\n return source;\n }\n const chunkPath = path.join(path.dirname(declarationPath), `${chunkFileName}.d.mts`);\n const chunk = await Bun.file(chunkPath).text();\n const declarations = chunk.replace(/^export \\{.*\\};$/gm, \"\");\n return `${declarations}\\n${source}`;\n}\n\nexport function embeddedSdkDeclaration(modules: SdkDeclarationModule[]): string {\n const declaration = [\n \"// biome-ignore-all format: generated from @usepipr/sdk declarations\",\n \"// biome-ignore-all assist/source/organizeImports: generated from @usepipr/sdk declarations\",\n ...modules.map(declarationModuleBlock),\n \"\",\n ].join(\"\\n\");\n if (declaration.includes('from \"zod\"') || declaration.includes(\"z.ZodType\")) {\n throw new Error(\"embedded SDK declaration must be standalone and must not import zod\");\n }\n return declaration;\n}\n\nfunction declarationModuleBlock(module: SdkDeclarationModule): string {\n return [`declare module \"${module.moduleName}\" {`, declarationSource(module).trim(), \"}\"].join(\n \"\\n\",\n );\n}\n\nfunction declarationSource(module: SdkDeclarationModule): string {\n const source = module.source\n .replace(/^declare /gm, \"\")\n .replace(/^import \\{ (?:z|z, z as z\\$1|z as z\\$1) \\} from \"zod\";$/gm, zodShimDeclaration())\n .replaceAll(\"z$1.\", \"z.\")\n .replaceAll(\"z.ZodType\", \"ZodType\")\n .replaceAll('from \"./index.js\"', 'from \"@usepipr/sdk\"')\n .replaceAll('from \"./index.mjs\"', 'from \"@usepipr/sdk\"')\n .replace(/from \"\\.\\/index-[^\"]+\\.mjs\"/g, 'from \"@usepipr/sdk\"')\n .replace(/^import .* from \"@usepipr\\/sdk\";$/gm, \"\")\n .replace(/^\\/\\/# sourceMappingURL=.*$/gm, \"\");\n return module.moduleName === \"@usepipr/sdk\"\n ? source\n : source\n .replace(\n /^export type \\{(?<exports>.*)\\};$/gm,\n 'export type {$<exports>} from \"@usepipr/sdk\";',\n )\n .replace(/^export \\{(?<exports>.*)\\};$/gm, 'export {$<exports>} from \"@usepipr/sdk\";');\n}\n\nfunction zodShimDeclaration(): string {\n return [\n \"type ZodInfer<T> = T extends { parse(value: unknown): infer Output } ? Output : never;\",\n \"type ZodType<T = unknown, Optional extends boolean = false> = {\",\n \" readonly _piprOptional: Optional;\",\n \" parse(value: unknown): T;\",\n \" optional(): ZodType<T | undefined, true>;\",\n \" min(value: number): ZodType<T, Optional>;\",\n \" max(value: number): ZodType<T, Optional>;\",\n \" int(): ZodType<T, Optional>;\",\n \" positive(): ZodType<T, Optional>;\",\n \" finite(): ZodType<T, Optional>;\",\n \"};\",\n \"type ZodAny = ZodType<unknown, boolean>;\",\n \"type ZodOptionalKeys<T extends Record<string, ZodAny>> = { [K in keyof T]: T[K] extends ZodType<unknown, true> ? K : never }[keyof T];\",\n \"type ZodObjectOutput<T extends Record<string, ZodAny>> = { [K in Exclude<keyof T, ZodOptionalKeys<T>>]: ZodInfer<T[K]> } & { [K in ZodOptionalKeys<T>]?: ZodInfer<T[K]> };\",\n \"const z: {\",\n \" string(): ZodType<string>;\",\n \" number(): ZodType<number>;\",\n \" boolean(): ZodType<boolean>;\",\n \" null(): ZodType<null>;\",\n \" unknown(): ZodType<unknown>;\",\n \" any(): ZodType<unknown>;\",\n \" literal<T extends string | number | boolean | null>(value: T): ZodType<T>;\",\n \" enum<const T extends readonly [string, ...string[]]>(values: T): ZodType<T[number]>;\",\n \" array<T extends ZodAny>(schema: T): ZodType<Array<ZodInfer<T>>>;\",\n \" record<T extends ZodAny>(key: ZodType<string>, value: T): ZodType<Record<string, ZodInfer<T>>>;\",\n \" strictObject<T extends Record<string, ZodAny>>(shape: T): ZodType<ZodObjectOutput<T>>;\",\n \" object<T extends Record<string, ZodAny>>(shape: T): ZodType<ZodObjectOutput<T>>;\",\n \" looseObject<T extends Record<string, ZodAny>>(shape: T): ZodType<ZodObjectOutput<T> & Record<string, unknown>>;\",\n \" union<const T extends readonly [ZodAny, ZodAny, ...ZodAny[]]>(schemas: T): ZodType<ZodInfer<T[number]>>;\",\n \" json(): ZodType<JsonValue>;\",\n \" fromJSONSchema(schema: JsonSchema): ZodType<unknown>;\",\n \" toJSONSchema(schema: ZodAny): JsonSchema;\",\n \"};\",\n ].join(\"\\n\");\n}\n","import {\n builtinReadOnlyToolBrand,\n type ConfigFactoryValue,\n configFactoryBrand,\n type InternalPiprConfigFactory,\n} from \"./internal-contract.js\";\nimport type { AgentTool } from \"./types/agent.js\";\n\nexport type { RuntimePlan } from \"./runtime-contract.js\";\n\nimport type { RuntimePlan } from \"./runtime-contract.js\";\n\nexport {\n assertSupportedCommandRestCapture,\n commandPatternParts,\n isCommandCaptureToken,\n isCommandRestCaptureToken,\n isOptionalCommandPatternPart,\n tokenizeCommandPattern,\n unsupportedCommandRestCaptureError,\n} from \"./command-grammar.js\";\nexport { renderPromptValue } from \"./prompt-render.js\";\nexport type { SdkDeclarationModule } from \"./standalone-declaration.js\";\nexport {\n embeddedSdkDeclaration,\n readSdkDeclarationSourceWithChunk,\n} from \"./standalone-declaration.js\";\n\n/** Stable identifier for pipr's built-in pull request review output schema. */\nexport const reviewOutputSchemaId = \"core/pr-review\";\n\n/** Returns whether a tool is one of pipr's built-in read-only tools. */\nexport function isBuiltinReadOnlyTool(tool: AgentTool): boolean {\n return Reflect.get(tool, builtinReadOnlyToolBrand) === true;\n}\n\n/** Checks that an unknown value is a pipr configuration factory. */\nexport function isPiprConfigFactory(value: unknown): value is ConfigFactoryValue {\n return (\n typeof value === \"object\" &&\n value !== null &&\n Reflect.get(value, \"kind\") === \"pipr.config-factory\" &&\n Reflect.get(value, configFactoryBrand) === true\n );\n}\n\n/** Builds a runtime plan from a pipr configuration factory. */\nexport function buildPiprPlan(factory: unknown): RuntimePlan {\n if (!isInternalPiprConfigFactory(factory)) {\n throw new Error(\"Expected a pipr configuration factory\");\n }\n return factory.build();\n}\n\nfunction isInternalPiprConfigFactory(value: unknown): value is InternalPiprConfigFactory {\n return isPiprConfigFactory(value) && typeof Reflect.get(value, \"build\") === \"function\";\n}\n"],"mappings":";;;AAOA,eAAsB,kCACpB,QACA,iBACiB;CACjB,MAAM,SAAS,MAAM,IAAI,KAAK,eAAe,CAAC,CAAC,KAAK;CACpD,IAAI,OAAO,eAAe,gBACxB,OAAO;CAET,MAAM,gBAAgB,OAAO,MAAM,gDAAgD,CAAC,EAAE,QAClF;CACJ,IAAI,CAAC,eACH,OAAO;CAET,MAAM,YAAY,KAAK,KAAK,KAAK,QAAQ,eAAe,GAAG,GAAG,cAAc,OAAO;CAGnF,OAAO,IADc,MADD,IAAI,KAAK,SAAS,CAAC,CAAC,KAAK,EAAA,CAClB,QAAQ,sBAAsB,EACpC,EAAE,IAAI;AAC7B;AAEA,SAAgB,uBAAuB,SAAyC;CAC9E,MAAM,cAAc;EAClB;EACA;EACA,GAAG,QAAQ,IAAI,sBAAsB;EACrC;CACF,CAAC,CAAC,KAAK,IAAI;CACX,IAAI,YAAY,SAAS,cAAY,KAAK,YAAY,SAAS,WAAW,GACxE,MAAM,IAAI,MAAM,qEAAqE;CAEvF,OAAO;AACT;AAEA,SAAS,uBAAuB,QAAsC;CACpE,OAAO;EAAC,mBAAmB,OAAO,WAAW;EAAM,kBAAkB,MAAM,CAAC,CAAC,KAAK;EAAG;CAAG,CAAC,CAAC,KACxF,IACF;AACF;AAEA,SAAS,kBAAkB,QAAsC;CAC/D,MAAM,SAAS,OAAO,OACnB,QAAQ,eAAe,EAAE,CAAC,CAC1B,QAAQ,6DAA6D,mBAAmB,CAAC,CAAC,CAC1F,WAAW,QAAQ,IAAI,CAAC,CACxB,WAAW,aAAa,SAAS,CAAC,CAClC,WAAW,uBAAqB,uBAAqB,CAAC,CACtD,WAAW,wBAAsB,uBAAqB,CAAC,CACvD,QAAQ,gCAAgC,uBAAqB,CAAC,CAC9D,QAAQ,uCAAuC,EAAE,CAAC,CAClD,QAAQ,iCAAiC,EAAE;CAC9C,OAAO,OAAO,eAAe,iBACzB,SACA,OACG,QACC,uCACA,iDACF,CAAC,CACA,QAAQ,kCAAkC,4CAA0C;AAC7F;AAEA,SAAS,qBAA6B;CACpC,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;AACb;;;;ACzEA,MAAa,uBAAuB;;AAGpC,SAAgB,sBAAsB,MAA0B;CAC9D,OAAO,QAAQ,IAAI,MAAM,wBAAwB,MAAM;AACzD;;AAGA,SAAgB,oBAAoB,OAA6C;CAC/E,OACE,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,IAAI,OAAO,MAAM,MAAM,yBAC/B,QAAQ,IAAI,OAAO,kBAAkB,MAAM;AAE/C;;AAGA,SAAgB,cAAc,SAA+B;CAC3D,IAAI,CAAC,4BAA4B,OAAO,GACtC,MAAM,IAAI,MAAM,uCAAuC;CAEzD,OAAO,QAAQ,MAAM;AACvB;AAEA,SAAS,4BAA4B,OAAoD;CACvF,OAAO,oBAAoB,KAAK,KAAK,OAAO,QAAQ,IAAI,OAAO,OAAO,MAAM;AAC9E"}
1
+ {"version":3,"file":"internal.mjs","names":[],"sources":["../src/standalone-declaration.ts","../src/internal.ts"],"sourcesContent":["import path from \"node:path\";\n\nexport type SdkDeclarationModule = {\n moduleName: string;\n source: string;\n};\n\nexport async function readSdkDeclarationSourceWithChunk(\n module: { moduleName: string },\n declarationPath: string,\n): Promise<string> {\n const source = await Bun.file(declarationPath).text();\n if (module.moduleName !== \"@usepipr/sdk\") {\n return source;\n }\n const chunkFileName = source.match(/from \"\\.\\/(?<chunk>index-[A-Za-z0-9_-]+)\\.mjs\"/)?.groups\n ?.chunk;\n if (!chunkFileName) {\n return source;\n }\n const chunkPath = path.join(path.dirname(declarationPath), `${chunkFileName}.d.mts`);\n const chunk = await Bun.file(chunkPath).text();\n const declarations = chunk.replace(/^export \\{.*\\};$/gm, \"\");\n return `${declarations}\\n${source}`;\n}\n\nexport function embeddedSdkDeclaration(modules: SdkDeclarationModule[]): string {\n const declaration = [\n \"// biome-ignore-all format: generated from @usepipr/sdk declarations\",\n \"// biome-ignore-all assist/source/organizeImports: generated from @usepipr/sdk declarations\",\n ...modules.map(declarationModuleBlock),\n \"\",\n ].join(\"\\n\");\n if (declaration.includes('from \"zod\"') || declaration.includes(\"z.ZodType\")) {\n throw new Error(\"embedded SDK declaration must be standalone and must not import zod\");\n }\n return declaration;\n}\n\nfunction declarationModuleBlock(module: SdkDeclarationModule): string {\n return [`declare module \"${module.moduleName}\" {`, declarationSource(module).trim(), \"}\"].join(\n \"\\n\",\n );\n}\n\nfunction declarationSource(module: SdkDeclarationModule): string {\n const source = module.source\n .replace(/^declare /gm, \"\")\n .replace(/^import \\{ (?:z|z, z as z\\$1|z as z\\$1) \\} from \"zod\";$/gm, zodShimDeclaration())\n .replaceAll(\"z$1.\", \"z.\")\n .replaceAll(\"z.ZodType\", \"ZodType\")\n .replaceAll('from \"./index.js\"', 'from \"@usepipr/sdk\"')\n .replaceAll('from \"./index.mjs\"', 'from \"@usepipr/sdk\"')\n .replace(/from \"\\.\\/index-[^\"]+\\.mjs\"/g, 'from \"@usepipr/sdk\"')\n .replace(/^import .* from \"@usepipr\\/sdk\";$/gm, \"\")\n .replace(/^\\/\\/# sourceMappingURL=.*$/gm, \"\");\n return module.moduleName === \"@usepipr/sdk\"\n ? source\n : source\n .replace(\n /^export type \\{(?<exports>.*)\\};$/gm,\n 'export type {$<exports>} from \"@usepipr/sdk\";',\n )\n .replace(/^export \\{(?<exports>.*)\\};$/gm, 'export {$<exports>} from \"@usepipr/sdk\";');\n}\n\nfunction zodShimDeclaration(): string {\n return [\n \"type ZodInfer<T> = T extends { parse(value: unknown): infer Output } ? Output : never;\",\n \"type ZodType<T = unknown, Optional extends boolean = false> = {\",\n \" readonly _piprOptional: Optional;\",\n \" parse(value: unknown): T;\",\n \" optional(): ZodType<T | undefined, true>;\",\n \" min(value: number): ZodType<T, Optional>;\",\n \" max(value: number): ZodType<T, Optional>;\",\n \" int(): ZodType<T, Optional>;\",\n \" positive(): ZodType<T, Optional>;\",\n \" finite(): ZodType<T, Optional>;\",\n \"};\",\n \"type ZodAny = ZodType<unknown, boolean>;\",\n \"type ZodOptionalKeys<T extends Record<string, ZodAny>> = { [K in keyof T]: T[K] extends ZodType<unknown, true> ? K : never }[keyof T];\",\n \"type ZodObjectOutput<T extends Record<string, ZodAny>> = { [K in Exclude<keyof T, ZodOptionalKeys<T>>]: ZodInfer<T[K]> } & { [K in ZodOptionalKeys<T>]?: ZodInfer<T[K]> };\",\n \"const z: {\",\n \" string(): ZodType<string>;\",\n \" number(): ZodType<number>;\",\n \" boolean(): ZodType<boolean>;\",\n \" null(): ZodType<null>;\",\n \" unknown(): ZodType<unknown>;\",\n \" any(): ZodType<unknown>;\",\n \" literal<T extends string | number | boolean | null>(value: T): ZodType<T>;\",\n \" enum<const T extends readonly [string, ...string[]]>(values: T): ZodType<T[number]>;\",\n \" array<T extends ZodAny>(schema: T): ZodType<Array<ZodInfer<T>>>;\",\n \" record<T extends ZodAny>(key: ZodType<string>, value: T): ZodType<Record<string, ZodInfer<T>>>;\",\n \" strictObject<T extends Record<string, ZodAny>>(shape: T): ZodType<ZodObjectOutput<T>>;\",\n \" object<T extends Record<string, ZodAny>>(shape: T): ZodType<ZodObjectOutput<T>>;\",\n \" looseObject<T extends Record<string, ZodAny>>(shape: T): ZodType<ZodObjectOutput<T> & Record<string, unknown>>;\",\n \" union<const T extends readonly [ZodAny, ZodAny, ...ZodAny[]]>(schemas: T): ZodType<ZodInfer<T[number]>>;\",\n \" json(): ZodType<JsonValue>;\",\n \" fromJSONSchema(schema: JsonSchema): ZodType<unknown>;\",\n \" toJSONSchema(schema: ZodAny): JsonSchema;\",\n \"};\",\n ].join(\"\\n\");\n}\n","import {\n builtinReadOnlyToolBrand,\n type ConfigFactoryValue,\n configFactoryBrand,\n type InternalPiprConfigFactory,\n} from \"./internal-contract.js\";\nimport type { AgentTool } from \"./types/agent.js\";\n\nexport type { RuntimePlan } from \"./runtime-contract.js\";\nexport { defaultMaxStoredFindings, maxStoredFindingsLimit } from \"./types/config.js\";\n\nimport type { RuntimePlan } from \"./runtime-contract.js\";\n\nexport {\n assertSupportedCommandRestCapture,\n commandPatternParts,\n isCommandCaptureToken,\n isCommandRestCaptureToken,\n isOptionalCommandPatternPart,\n tokenizeCommandPattern,\n unsupportedCommandRestCaptureError,\n} from \"./command-grammar.js\";\nexport { renderPromptValue } from \"./prompt-render.js\";\nexport type { SdkDeclarationModule } from \"./standalone-declaration.js\";\nexport {\n embeddedSdkDeclaration,\n readSdkDeclarationSourceWithChunk,\n} from \"./standalone-declaration.js\";\n\n/** Stable identifier for Pipr's built-in change request review output schema. */\nexport const reviewOutputSchemaId = \"core/pr-review\";\n\n/** Returns whether a tool is one of pipr's built-in read-only tools. */\nexport function isBuiltinReadOnlyTool(tool: AgentTool): boolean {\n return Reflect.get(tool, builtinReadOnlyToolBrand) === true;\n}\n\n/** Checks that an unknown value is a pipr configuration factory. */\nexport function isPiprConfigFactory(value: unknown): value is ConfigFactoryValue {\n return (\n typeof value === \"object\" &&\n value !== null &&\n Reflect.get(value, \"kind\") === \"pipr.config-factory\" &&\n Reflect.get(value, configFactoryBrand) === true\n );\n}\n\n/** Builds a runtime plan from a pipr configuration factory. */\nexport function buildPiprPlan(factory: unknown): RuntimePlan {\n if (!isInternalPiprConfigFactory(factory)) {\n throw new Error(\"Expected a pipr configuration factory\");\n }\n return factory.build();\n}\n\nfunction isInternalPiprConfigFactory(value: unknown): value is InternalPiprConfigFactory {\n return isPiprConfigFactory(value) && typeof Reflect.get(value, \"build\") === \"function\";\n}\n"],"mappings":";;;AAOA,eAAsB,kCACpB,QACA,iBACiB;CACjB,MAAM,SAAS,MAAM,IAAI,KAAK,eAAe,CAAC,CAAC,KAAK;CACpD,IAAI,OAAO,eAAe,gBACxB,OAAO;CAET,MAAM,gBAAgB,OAAO,MAAM,gDAAgD,CAAC,EAAE,QAClF;CACJ,IAAI,CAAC,eACH,OAAO;CAET,MAAM,YAAY,KAAK,KAAK,KAAK,QAAQ,eAAe,GAAG,GAAG,cAAc,OAAO;CAGnF,OAAO,IADc,MADD,IAAI,KAAK,SAAS,CAAC,CAAC,KAAK,EAAA,CAClB,QAAQ,sBAAsB,EACpC,EAAE,IAAI;AAC7B;AAEA,SAAgB,uBAAuB,SAAyC;CAC9E,MAAM,cAAc;EAClB;EACA;EACA,GAAG,QAAQ,IAAI,sBAAsB;EACrC;CACF,CAAC,CAAC,KAAK,IAAI;CACX,IAAI,YAAY,SAAS,cAAY,KAAK,YAAY,SAAS,WAAW,GACxE,MAAM,IAAI,MAAM,qEAAqE;CAEvF,OAAO;AACT;AAEA,SAAS,uBAAuB,QAAsC;CACpE,OAAO;EAAC,mBAAmB,OAAO,WAAW;EAAM,kBAAkB,MAAM,CAAC,CAAC,KAAK;EAAG;CAAG,CAAC,CAAC,KACxF,IACF;AACF;AAEA,SAAS,kBAAkB,QAAsC;CAC/D,MAAM,SAAS,OAAO,OACnB,QAAQ,eAAe,EAAE,CAAC,CAC1B,QAAQ,6DAA6D,mBAAmB,CAAC,CAAC,CAC1F,WAAW,QAAQ,IAAI,CAAC,CACxB,WAAW,aAAa,SAAS,CAAC,CAClC,WAAW,uBAAqB,uBAAqB,CAAC,CACtD,WAAW,wBAAsB,uBAAqB,CAAC,CACvD,QAAQ,gCAAgC,uBAAqB,CAAC,CAC9D,QAAQ,uCAAuC,EAAE,CAAC,CAClD,QAAQ,iCAAiC,EAAE;CAC9C,OAAO,OAAO,eAAe,iBACzB,SACA,OACG,QACC,uCACA,iDACF,CAAC,CACA,QAAQ,kCAAkC,4CAA0C;AAC7F;AAEA,SAAS,qBAA6B;CACpC,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,CAAC,KAAK,IAAI;AACb;;;;ACxEA,MAAa,uBAAuB;;AAGpC,SAAgB,sBAAsB,MAA0B;CAC9D,OAAO,QAAQ,IAAI,MAAM,wBAAwB,MAAM;AACzD;;AAGA,SAAgB,oBAAoB,OAA6C;CAC/E,OACE,OAAO,UAAU,YACjB,UAAU,QACV,QAAQ,IAAI,OAAO,MAAM,MAAM,yBAC/B,QAAQ,IAAI,OAAO,kBAAkB,MAAM;AAE/C;;AAGA,SAAgB,cAAc,SAA+B;CAC3D,IAAI,CAAC,4BAA4B,OAAO,GACtC,MAAM,IAAI,MAAM,uCAAuC;CAEzD,OAAO,QAAQ,MAAM;AACvB;AAEA,SAAS,4BAA4B,OAAoD;CACvF,OAAO,oBAAoB,KAAK,KAAK,OAAO,QAAQ,IAAI,OAAO,OAAO,MAAM;AAC9E"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@usepipr/sdk",
3
- "version": "0.3.8",
4
- "description": "TypeScript configuration SDK for pipr pull request review automation",
3
+ "version": "0.4.1",
4
+ "description": "TypeScript configuration SDK for Pipr code host review automation",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-Cdy9nsaD.d.mts","names":[],"sources":["../src/types/schema.ts","../src/review-contract.ts","../src/types/manifest.ts","../src/types/config.ts","../src/types/prompt.ts","../src/types/agent.ts","../src/types/task.ts","../src/builder.ts","../src/prompt.ts","../src/schema.ts"],"mappings":";;;KAGY;;KAEA,YAAY,gBAAgB,cAAc;;KAE1C;GAAgB,cAAc;;;KAE9B,aAAa;;KAGb,kBAAkB;EAAO;EAAe,MAAM;;EAAQ;EAAgB,OAAO;;;KAG7E,OAAO;WACR;WACA;WACA,aAAa;EACtB,MAAM,iBAAiB;EACvB,UAAU,iBAAiB,kBAAkB;;;KAInC,UAAU,KAAK,EAAE,QAAQ;;KAGzB,iBAAiB;EAC3B;EACA,QAAQ,UAAU;;;KAIR;EACV;EACA,QAAQ;;;;;KC/BE;EACV;EACA;;;KAIU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;;KAIU;EACV,SAAS;EACT,gBAAgB;;;cAOL,qBAAqB,UAAU;;cAM/B,qBAAqB,UAAU;;cAW/B,oBAAoB,UAAU;;iBAM3B,kBAAkB,iBAAiB;;iBAKnC,mBAAmB,iBAAiB;;iBAKpC,mBAAmB,iBAAiB;;iBAKpC,uBAAuB;;;;KCnE3B;EACV;EACA;;;KAIU;;KAGA;;KAGA;;KAGA;EACV;EACA;EACA,MAAM;EACN;EACA;EACA,MAAM;EACN;EACA;EACA;EACA;EACA;;;KAIU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;;KAIU;EACV;EACA;EACA,QAAQ;EACR;EACA;EACA;EACA,OAAO;EACP,mBAAmB;EACnB;EACA;EACA;;;KAIU;EACV;EACA;EACA;EACA,OAAO;;;KAIG;EACV;EACA;EACA;EACA,QAAQ;;;KAIE;EACV;EACA;EACA;EACA;EACA;;;KAIU;EACV;EACA,eAAe;;;;;KCjFL;;KAGA;;KAGA;;KAGA;WACD;WACA;;;KAIC;EACV;;;KAIU;EACV;EACA;EACA;EACA,SAAS;EACT,UAAU;;;KAIA;WACD;WACA;WACA;WACA;WACA,SAAS;WACT,UA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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,QAAQ;IAAQ;IAAc;IAAuB;;EACrE,kBAAkB;;;KAIR;EACV,IAAI,OAAO,QACT,OAAO,MAAM,OAAO,SACpB,OAAO,OACP;IACE,QAAQ;IACR,YAAY;IACZ,eAAe;IACf,UAAU;IACV,QAAQ;MAET,QAAQ;;;KAID;WACD;WACA;WACA,WAAW;EACpB,MAAM,UAAU,WAAW;;;KAIjB;;WAED;IAAO;;WACP,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;;;;;;iBC5QM,WAAW,YAAY,MAAM;WAClC;;;iBAsBK,aAAa,QAAQ,QAAQ,SAAS,gBAAgB,SAAS,WAAW;;;;iBC3D1E,GAAG,SAAS,yBAAyB,oBAAoB;;;;iBCezD,OAAO,GAAG,YAAY,iBAAiB,KAAK,OAAO;;iBASnD,WAAW,GAAG,YAAY,uBAAuB,OAAO;;cAU3D,SAAS"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"prompt-render-BWiLG-qu.mjs","names":[],"sources":["../src/command-grammar.ts","../src/internal-contract.ts","../src/prompt-render.ts"],"sourcesContent":["export function commandPatternParts(pattern: string): string[] {\n return pattern.match(/\\[[^\\]]+\\]|[^\\s]+/g) ?? [];\n}\n\nexport function tokenizeCommandPattern(value: string): string[] {\n return value.trim().split(/\\s+/).filter(Boolean);\n}\n\nexport function unsupportedCommandRestCaptureError(pattern: string): string | undefined {\n const parts = commandPatternParts(pattern);\n for (const [index, part] of parts.entries()) {\n if (isOptionalCommandPatternPart(part)) {\n const optionalRest = tokenizeCommandPattern(part.slice(1, -1)).find(\n isCommandRestCaptureToken,\n );\n if (optionalRest) {\n return finalRequiredRestCaptureMessage(optionalRest);\n }\n continue;\n }\n if (isCommandRestCaptureToken(part) && index !== parts.length - 1) {\n return finalRequiredRestCaptureMessage(part);\n }\n }\n return undefined;\n}\n\nexport function assertSupportedCommandRestCapture(pattern: string): void {\n const error = unsupportedCommandRestCaptureError(pattern);\n if (error) {\n throw new Error(error);\n }\n}\n\nexport function isOptionalCommandPatternPart(value: string): boolean {\n return value.startsWith(\"[\") && value.endsWith(\"]\");\n}\n\nexport function isCommandCaptureToken(value: string): boolean {\n return /^<[a-z0-9-]+(\\.\\.\\.)?>$/.test(value);\n}\n\nexport function isCommandRestCaptureToken(value: string): boolean {\n return /^<[a-z0-9-]+\\.\\.\\.>$/.test(value);\n}\n\nfunction finalRequiredRestCaptureMessage(token: string): string {\n return `Rest capture '${token}' must be the final required command pattern token`;\n}\n","import type { RuntimePlan } from \"./runtime-contract.js\";\n\nexport const configFactoryBrand = Symbol.for(\"pipr.config.factory\");\nexport const builtinReadOnlyToolBrand = Symbol.for(\"pipr.builtin.readOnlyTool\");\n\nexport type ConfigFactoryValue = {\n readonly kind: \"pipr.config-factory\";\n};\n\nexport type InternalPiprConfigFactory = ConfigFactoryValue & {\n readonly [configFactoryBrand]: true;\n build(): RuntimePlan;\n};\n","import type { PromptText, PromptValue } from \"./index.js\";\n\n/** Renders a prompt source/value into plain text for Pi prompts. */\nexport function renderPromptValue(value: PromptValue): string {\n if (value === undefined || value === null) {\n return \"\";\n }\n if (typeof value === \"string\") {\n return value;\n }\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n return String(value);\n }\n if (typeof value === \"object\" && value !== null && Reflect.get(value, \"kind\") === \"pipr.prompt\") {\n return (value as PromptText).value;\n }\n return JSON.stringify(value, null, 2);\n}\n"],"mappings":";AAAA,SAAgB,oBAAoB,SAA2B;CAC7D,OAAO,QAAQ,MAAM,oBAAoB,KAAK,CAAC;AACjD;AAEA,SAAgB,uBAAuB,OAAyB;CAC9D,OAAO,MAAM,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,OAAO,OAAO;AACjD;AAEA,SAAgB,mCAAmC,SAAqC;CACtF,MAAM,QAAQ,oBAAoB,OAAO;CACzC,KAAK,MAAM,CAAC,OAAO,SAAS,MAAM,QAAQ,GAAG;EAC3C,IAAI,6BAA6B,IAAI,GAAG;GACtC,MAAM,eAAe,uBAAuB,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC,CAAC,KAC7D,yBACF;GACA,IAAI,cACF,OAAO,gCAAgC,YAAY;GAErD;EACF;EACA,IAAI,0BAA0B,IAAI,KAAK,UAAU,MAAM,SAAS,GAC9D,OAAO,gCAAgC,IAAI;CAE/C;AAEF;AAEA,SAAgB,kCAAkC,SAAuB;CACvE,MAAM,QAAQ,mCAAmC,OAAO;CACxD,IAAI,OACF,MAAM,IAAI,MAAM,KAAK;AAEzB;AAEA,SAAgB,6BAA6B,OAAwB;CACnE,OAAO,MAAM,WAAW,GAAG,KAAK,MAAM,SAAS,GAAG;AACpD;AAEA,SAAgB,sBAAsB,OAAwB;CAC5D,OAAO,0BAA0B,KAAK,KAAK;AAC7C;AAEA,SAAgB,0BAA0B,OAAwB;CAChE,OAAO,uBAAuB,KAAK,KAAK;AAC1C;AAEA,SAAS,gCAAgC,OAAuB;CAC9D,OAAO,iBAAiB,MAAM;AAChC;;;AC9CA,MAAa,qBAAqB,OAAO,IAAI,qBAAqB;AAClE,MAAa,2BAA2B,OAAO,IAAI,2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