@usepipr/sdk 0.4.3 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/config-CpCLnuAf.mjs +118 -0
- package/dist/config-CpCLnuAf.mjs.map +1 -0
- package/dist/{index-D_XmBHeL.d.mts → index-Bdey1nho.d.mts} +191 -60
- package/dist/index-Bdey1nho.d.mts.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +326 -71
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.mts +35 -8
- package/dist/internal.d.mts.map +1 -1
- package/dist/internal.mjs +2 -2
- package/dist/internal.mjs.map +1 -1
- package/package.json +3 -2
- package/dist/config-Ct0Qfa_b.mjs +0 -56
- package/dist/config-Ct0Qfa_b.mjs.map +0 -1
- package/dist/index-D_XmBHeL.d.mts.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 pipr contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
//#region src/command-grammar.ts
|
|
2
|
+
function commandPatternParts(pattern) {
|
|
3
|
+
return pattern.match(/\[[^\]]+\]|[^\s]+/g) ?? [];
|
|
4
|
+
}
|
|
5
|
+
function tokenizeCommandPattern(value) {
|
|
6
|
+
return value.trim().split(/\s+/).filter(Boolean);
|
|
7
|
+
}
|
|
8
|
+
function unsupportedCommandRestCaptureError(pattern) {
|
|
9
|
+
const parts = commandPatternParts(pattern);
|
|
10
|
+
for (const [index, part] of parts.entries()) {
|
|
11
|
+
if (isOptionalCommandPatternPart(part)) {
|
|
12
|
+
const optionalRest = tokenizeCommandPattern(part.slice(1, -1)).find(isCommandRestCaptureToken);
|
|
13
|
+
if (optionalRest) return finalRequiredRestCaptureMessage(optionalRest);
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (isCommandRestCaptureToken(part) && index !== parts.length - 1) return finalRequiredRestCaptureMessage(part);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function assertSupportedCommandRestCapture(pattern) {
|
|
20
|
+
const error = unsupportedCommandRestCaptureError(pattern);
|
|
21
|
+
if (error) throw new Error(error);
|
|
22
|
+
}
|
|
23
|
+
function isOptionalCommandPatternPart(value) {
|
|
24
|
+
return value.startsWith("[") && value.endsWith("]");
|
|
25
|
+
}
|
|
26
|
+
function isCommandCaptureToken(value) {
|
|
27
|
+
return /^<[a-z0-9-]+(\.\.\.)?>$/.test(value);
|
|
28
|
+
}
|
|
29
|
+
function isCommandRestCaptureToken(value) {
|
|
30
|
+
return /^<[a-z0-9-]+\.\.\.>$/.test(value);
|
|
31
|
+
}
|
|
32
|
+
function finalRequiredRestCaptureMessage(token) {
|
|
33
|
+
return `Rest capture '${token}' must be the final required command pattern token`;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/internal-contract.ts
|
|
37
|
+
const configFactoryBrand = Symbol.for("pipr.config.factory");
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/prompt-json.ts
|
|
40
|
+
const promptJsonSerializationError = "Prompt value must be JSON-serializable";
|
|
41
|
+
const unsupportedJsonCollectionTypes = [
|
|
42
|
+
Map,
|
|
43
|
+
Set,
|
|
44
|
+
WeakMap,
|
|
45
|
+
WeakSet
|
|
46
|
+
];
|
|
47
|
+
/** Serializes one prompt JSON value without silently dropping unsupported data. */
|
|
48
|
+
function serializePromptJson(value, pretty) {
|
|
49
|
+
try {
|
|
50
|
+
assertJsonSerializable(value, /* @__PURE__ */ new Set());
|
|
51
|
+
const rendered = JSON.stringify(value, strictJsonReplacer, pretty ? 2 : 0);
|
|
52
|
+
if (rendered === void 0) throw new Error(promptJsonSerializationError);
|
|
53
|
+
return rendered;
|
|
54
|
+
} catch {
|
|
55
|
+
throw new Error(promptJsonSerializationError);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function assertJsonSerializable(value, ancestors) {
|
|
59
|
+
assertJsonPrimitive(value);
|
|
60
|
+
if (typeof value !== "object" || value === null) return;
|
|
61
|
+
if (ancestors.has(value)) throw new Error(promptJsonSerializationError);
|
|
62
|
+
assertJsonObjectShape(value);
|
|
63
|
+
ancestors.add(value);
|
|
64
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
65
|
+
if (!Object.prototype.propertyIsEnumerable.call(value, key)) continue;
|
|
66
|
+
if (typeof key === "symbol") throw new Error(promptJsonSerializationError);
|
|
67
|
+
assertJsonSerializable(Reflect.get(value, key), ancestors);
|
|
68
|
+
}
|
|
69
|
+
ancestors.delete(value);
|
|
70
|
+
}
|
|
71
|
+
function assertJsonObjectShape(value) {
|
|
72
|
+
if (unsupportedJsonCollectionTypes.some((Collection) => value instanceof Collection)) throw new Error(promptJsonSerializationError);
|
|
73
|
+
if (Array.isArray(value) && Object.keys(value).some((key) => !isSerializedArrayIndex(value, key))) throw new Error(promptJsonSerializationError);
|
|
74
|
+
}
|
|
75
|
+
function isSerializedArrayIndex(value, key) {
|
|
76
|
+
const index = Number(key);
|
|
77
|
+
return Number.isInteger(index) && index >= 0 && String(index) === key && index < value.length;
|
|
78
|
+
}
|
|
79
|
+
function strictJsonReplacer(_key, value) {
|
|
80
|
+
assertJsonPrimitive(value);
|
|
81
|
+
if (typeof value === "object" && value !== null) {
|
|
82
|
+
assertJsonObjectShape(value);
|
|
83
|
+
if (Object.getOwnPropertySymbols(value).some((key) => Object.prototype.propertyIsEnumerable.call(value, key))) throw new Error(promptJsonSerializationError);
|
|
84
|
+
}
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
function assertJsonPrimitive(value) {
|
|
88
|
+
const type = typeof value;
|
|
89
|
+
if (type === "undefined" || type === "function" || type === "symbol" || type === "bigint") throw new Error(promptJsonSerializationError);
|
|
90
|
+
if (type === "number" && !Number.isFinite(value)) throw new Error(promptJsonSerializationError);
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/prompt-render.ts
|
|
94
|
+
/** Renders a prompt source/value into plain text for Pi prompts. */
|
|
95
|
+
function renderPromptValue(value) {
|
|
96
|
+
if (value === void 0 || value === null) return "";
|
|
97
|
+
if (typeof value === "string") return value;
|
|
98
|
+
if (typeof value === "number") return serializePromptJson(value, false);
|
|
99
|
+
if (typeof value === "boolean") return String(value);
|
|
100
|
+
if (typeof value === "object" && value !== null && Reflect.get(value, "kind") === "pipr.prompt") return value.value;
|
|
101
|
+
return serializePromptJson(value, true);
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/types/config.ts
|
|
105
|
+
const defaultMaxStoredFindings = 50;
|
|
106
|
+
const maxStoredFindingsLimit = 100;
|
|
107
|
+
const modelThinkingLevels = [
|
|
108
|
+
"off",
|
|
109
|
+
"minimal",
|
|
110
|
+
"low",
|
|
111
|
+
"medium",
|
|
112
|
+
"high",
|
|
113
|
+
"xhigh"
|
|
114
|
+
];
|
|
115
|
+
//#endregion
|
|
116
|
+
export { serializePromptJson as a, commandPatternParts as c, isOptionalCommandPatternPart as d, tokenizeCommandPattern as f, renderPromptValue as i, isCommandCaptureToken as l, maxStoredFindingsLimit as n, configFactoryBrand as o, unsupportedCommandRestCaptureError as p, modelThinkingLevels as r, assertSupportedCommandRestCapture as s, defaultMaxStoredFindings as t, isCommandRestCaptureToken as u };
|
|
117
|
+
|
|
118
|
+
//# sourceMappingURL=config-CpCLnuAf.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-CpCLnuAf.mjs","names":[],"sources":["../src/command-grammar.ts","../src/internal-contract.ts","../src/prompt-json.ts","../src/prompt-render.ts","../src/types/config.ts"],"sourcesContent":["export function commandPatternParts(pattern: string): string[] {\n return pattern.match(/\\[[^\\]]+\\]|[^\\s]+/g) ?? [];\n}\n\nexport function tokenizeCommandPattern(value: string): string[] {\n return value.trim().split(/\\s+/).filter(Boolean);\n}\n\nexport function unsupportedCommandRestCaptureError(pattern: string): string | undefined {\n const parts = commandPatternParts(pattern);\n for (const [index, part] of parts.entries()) {\n if (isOptionalCommandPatternPart(part)) {\n const optionalRest = tokenizeCommandPattern(part.slice(1, -1)).find(\n isCommandRestCaptureToken,\n );\n if (optionalRest) {\n return finalRequiredRestCaptureMessage(optionalRest);\n }\n continue;\n }\n if (isCommandRestCaptureToken(part) && index !== parts.length - 1) {\n return finalRequiredRestCaptureMessage(part);\n }\n }\n return undefined;\n}\n\nexport function assertSupportedCommandRestCapture(pattern: string): void {\n const error = unsupportedCommandRestCaptureError(pattern);\n if (error) {\n throw new Error(error);\n }\n}\n\nexport function isOptionalCommandPatternPart(value: string): boolean {\n return value.startsWith(\"[\") && value.endsWith(\"]\");\n}\n\nexport function isCommandCaptureToken(value: string): boolean {\n return /^<[a-z0-9-]+(\\.\\.\\.)?>$/.test(value);\n}\n\nexport function isCommandRestCaptureToken(value: string): boolean {\n return /^<[a-z0-9-]+\\.\\.\\.>$/.test(value);\n}\n\nfunction finalRequiredRestCaptureMessage(token: string): string {\n return `Rest capture '${token}' must be the final required command pattern token`;\n}\n","import type { RuntimePlan } from \"./runtime-contract.js\";\n\nexport const configFactoryBrand = Symbol.for(\"pipr.config.factory\");\n\nexport type ConfigFactoryValue = {\n readonly kind: \"pipr.config-factory\";\n};\n\nexport type InternalPiprConfigFactory = ConfigFactoryValue & {\n readonly [configFactoryBrand]: true;\n build(): RuntimePlan;\n};\n","const promptJsonSerializationError = \"Prompt value must be JSON-serializable\";\nconst unsupportedJsonCollectionTypes = [Map, Set, WeakMap, WeakSet] as const;\n\n/** Serializes one prompt JSON value without silently dropping unsupported data. */\nexport function serializePromptJson(value: unknown, pretty: boolean): string {\n try {\n assertJsonSerializable(value, new Set<object>());\n const rendered = JSON.stringify(value, strictJsonReplacer, pretty ? 2 : 0);\n if (rendered === undefined) {\n throw new Error(promptJsonSerializationError);\n }\n return rendered;\n } catch {\n throw new Error(promptJsonSerializationError);\n }\n}\n\nfunction assertJsonSerializable(value: unknown, ancestors: Set<object>): void {\n assertJsonPrimitive(value);\n if (typeof value !== \"object\" || value === null) {\n return;\n }\n if (ancestors.has(value)) {\n throw new Error(promptJsonSerializationError);\n }\n assertJsonObjectShape(value);\n ancestors.add(value);\n for (const key of Reflect.ownKeys(value)) {\n if (!Object.prototype.propertyIsEnumerable.call(value, key)) {\n continue;\n }\n if (typeof key === \"symbol\") {\n throw new Error(promptJsonSerializationError);\n }\n assertJsonSerializable(Reflect.get(value, key), ancestors);\n }\n ancestors.delete(value);\n}\n\nfunction assertJsonObjectShape(value: object): void {\n if (unsupportedJsonCollectionTypes.some((Collection) => value instanceof Collection)) {\n throw new Error(promptJsonSerializationError);\n }\n if (\n Array.isArray(value) &&\n Object.keys(value).some((key) => !isSerializedArrayIndex(value, key))\n ) {\n throw new Error(promptJsonSerializationError);\n }\n}\n\nfunction isSerializedArrayIndex(value: unknown[], key: string): boolean {\n const index = Number(key);\n return Number.isInteger(index) && index >= 0 && String(index) === key && index < value.length;\n}\n\nfunction strictJsonReplacer(_key: string, value: unknown): unknown {\n assertJsonPrimitive(value);\n if (typeof value === \"object\" && value !== null) {\n assertJsonObjectShape(value);\n if (\n Object.getOwnPropertySymbols(value).some((key) =>\n Object.prototype.propertyIsEnumerable.call(value, key),\n )\n ) {\n throw new Error(promptJsonSerializationError);\n }\n }\n return value;\n}\n\nfunction assertJsonPrimitive(value: unknown): void {\n const type = typeof value;\n if (type === \"undefined\" || type === \"function\" || type === \"symbol\" || type === \"bigint\") {\n throw new Error(promptJsonSerializationError);\n }\n if (type === \"number\" && !Number.isFinite(value)) {\n throw new Error(promptJsonSerializationError);\n }\n}\n","import type { PromptText, PromptValue } from \"./index.js\";\nimport { serializePromptJson } from \"./prompt-json.js\";\n\n/** Renders a prompt source/value into plain text for Pi prompts. */\nexport function renderPromptValue(value: PromptValue): string {\n if (value === undefined || value === null) {\n return \"\";\n }\n if (typeof value === \"string\") {\n return value;\n }\n if (typeof value === \"number\") {\n return serializePromptJson(value, false);\n }\n if (typeof value === \"boolean\") {\n return String(value);\n }\n if (typeof value === \"object\" && value !== null && Reflect.get(value, \"kind\") === \"pipr.prompt\") {\n return (value as PromptText).value;\n }\n return serializePromptJson(value, true);\n}\n","import type { RuntimeLimits } from \"./manifest.js\";\n\nexport const defaultMaxStoredFindings = 50;\nexport const maxStoredFindingsLimit = 100;\nexport const modelThinkingLevels = [\"off\", \"minimal\", \"low\", \"medium\", \"high\", \"xhigh\"] as const;\nexport type ModelThinkingLevel = (typeof modelThinkingLevels)[number];\n\n/** Repository permission levels used to authorize pipr commands. */\nexport type RepositoryPermission = \"read\" | \"triage\" | \"write\" | \"maintain\" | \"admin\";\n\n/** Pull request lifecycle actions that can trigger change-request tasks. */\nexport type ChangeRequestAction = \"opened\" | \"updated\" | \"reopened\" | \"ready\" | \"closed\";\n\n/** Duration accepted by timeout options, either seconds as a number or a suffixed string. */\nexport type DurationInput = number | `${number}s` | `${number}m` | `${number}h`;\n\n/** Reference to a secret that pipr resolves from the runtime environment. */\nexport type SecretRef = {\n readonly kind: \"pipr.secret\";\n readonly name: string;\n};\n\n/** Options for declaring a secret by environment variable name. */\nexport type SecretOptions = {\n name: string;\n};\n\n/** Options for registering a model provider and model id. */\nexport type ModelOptions = {\n id?: string;\n provider: string;\n model: string;\n apiKey?: SecretRef;\n thinking?: ModelThinkingLevel;\n};\n\n/** Registered model profile that can be used by reviewers and agents. */\nexport type ModelProfile = {\n readonly kind: \"pipr.model\";\n readonly id: string;\n readonly provider: string;\n readonly model: string;\n readonly apiKey?: SecretRef;\n readonly thinking?: ModelThinkingLevel;\n};\n\n/** Aggregate check-run options for a Pipr review run. */\nexport type AggregateCheckOptions =\n | false\n | {\n enabled?: boolean;\n name?: string;\n };\n\n/** Check-run settings for a pipr config. */\nexport type ChecksOptions = {\n aggregate?: AggregateCheckOptions;\n};\n\n/** Actor policy for auto-resolving inline review threads from user replies. */\nexport type AutoResolveAllowedActors = \"author-or-write\" | \"write\" | \"any\";\n\n/** Options controlling auto-resolve behavior for user replies. */\nexport type AutoResolveUserRepliesOptions = {\n enabled?: boolean;\n respondWhenStillValid?: boolean;\n allowedActors?: AutoResolveAllowedActors;\n};\n\n/** Options controlling automatic stale-finding resolution. */\nexport type AutoResolveOptions =\n | false\n | {\n enabled?: boolean;\n model?: ModelProfile;\n instructions?: string;\n synchronize?: boolean;\n userReplies?: boolean | AutoResolveUserRepliesOptions;\n };\n\n/** Review publication settings. */\nexport type PublicationOptions = {\n maxInlineComments?: number;\n maxStoredFindings?: number;\n autoResolve?: AutoResolveOptions;\n showHeader?: boolean;\n showFooter?: boolean;\n showStats?: boolean;\n};\n\n/** Top-level pipr config settings. */\nexport type PiprConfigOptions = {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AC,CAAC,MAAM,QACxC,OAAO,UAAU,qBAAqB,KAAK,OAAO,GAAG,CACvD,GAEA,MAAM,IAAI,MAAM,4BAA4B;CAEhD;CACA,OAAO;AACT;AAEA,SAAS,oBAAoB,OAAsB;CACjD,MAAM,OAAO,OAAO;CACpB,IAAI,SAAS,eAAe,SAAS,cAAc,SAAS,YAAY,SAAS,UAC/E,MAAM,IAAI,MAAM,4BAA4B;CAE9C,IAAI,SAAS,YAAY,CAAC,OAAO,SAAS,KAAK,GAC7C,MAAM,IAAI,MAAM,4BAA4B;AAEhD;;;;AC3EA,SAAgB,kBAAkB,OAA4B;CAC5D,IAAI,UAAU,KAAA,KAAa,UAAU,MACnC,OAAO;CAET,IAAI,OAAO,UAAU,UACnB,OAAO;CAET,IAAI,OAAO,UAAU,UACnB,OAAO,oBAAoB,OAAO,KAAK;CAEzC,IAAI,OAAO,UAAU,WACnB,OAAO,OAAO,KAAK;CAErB,IAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,QAAQ,IAAI,OAAO,MAAM,MAAM,eAChF,OAAQ,MAAqB;CAE/B,OAAO,oBAAoB,OAAO,IAAI;AACxC;;;ACnBA,MAAa,2BAA2B;AACxC,MAAa,yBAAyB;AACtC,MAAa,sBAAsB;CAAC;CAAO;CAAW;CAAO;CAAU;CAAQ;AAAO"}
|
|
@@ -55,19 +55,26 @@ type ReviewFinding = {
|
|
|
55
55
|
endLine: number;
|
|
56
56
|
suggestedFix?: string;
|
|
57
57
|
};
|
|
58
|
+
/** Core structured collection of inline findings produced by a review agent. */
|
|
59
|
+
type ReviewFindingsResult = {
|
|
60
|
+
inlineFindings: ReviewFinding[];
|
|
61
|
+
};
|
|
58
62
|
/** Core structured review result accepted by pipr review publication. */
|
|
59
|
-
type ReviewResult = {
|
|
63
|
+
type ReviewResult = ReviewFindingsResult & {
|
|
60
64
|
summary: ReviewSummary;
|
|
61
|
-
inlineFindings: ReviewFinding[];
|
|
62
65
|
};
|
|
63
66
|
/** Zod schema for a review summary. */
|
|
64
67
|
declare const reviewSummarySchema: ZodSchema<ReviewSummary>;
|
|
65
68
|
/** Zod schema for one inline review finding. */
|
|
66
69
|
declare const reviewFindingSchema: ZodSchema<ReviewFinding>;
|
|
70
|
+
/** Zod schema for Pipr's core inline-finding result. */
|
|
71
|
+
declare const reviewFindingsResultSchema: ZodSchema<ReviewFindingsResult>;
|
|
67
72
|
/** Zod schema for Pipr's core change request review result. */
|
|
68
73
|
declare const reviewResultSchema: ZodSchema<ReviewResult>;
|
|
69
74
|
/** Parses model output for Pipr's main change request review schema. */
|
|
70
75
|
declare function parseReviewResult(value: unknown): ReviewResult;
|
|
76
|
+
/** Parses model output for Pipr's inline-finding schema. */
|
|
77
|
+
declare function parseReviewFindingsResult(value: unknown): ReviewFindingsResult;
|
|
71
78
|
/** Parses a review summary value. */
|
|
72
79
|
declare function parseReviewSummary(value: unknown): ReviewSummary;
|
|
73
80
|
/** Parses one inline review finding. */
|
|
@@ -75,11 +82,113 @@ declare function parseReviewFinding(value: unknown): ReviewFinding;
|
|
|
75
82
|
/** Returns a small valid example for the main change request review schema. */
|
|
76
83
|
declare function reviewSchemaExample(): ReviewResult;
|
|
77
84
|
//#endregion
|
|
85
|
+
//#region src/result.d.ts
|
|
86
|
+
declare const piprRunTriggers: readonly ["change-request", "command", "verifier", "local"];
|
|
87
|
+
type PiprRunTrigger = (typeof piprRunTriggers)[number];
|
|
88
|
+
type PiprRunContext = {
|
|
89
|
+
readonly id: string;
|
|
90
|
+
readonly trigger: PiprRunTrigger;
|
|
91
|
+
};
|
|
92
|
+
type PiprRunSummary = PiprRunContext & {
|
|
93
|
+
baseSha: string;
|
|
94
|
+
headSha: string;
|
|
95
|
+
tasks: string[];
|
|
96
|
+
durationMs: number;
|
|
97
|
+
models: string[];
|
|
98
|
+
agentRuns: number;
|
|
99
|
+
inputTokens: number;
|
|
100
|
+
outputTokens: number;
|
|
101
|
+
costUsd: number;
|
|
102
|
+
usageStatus: "complete" | "partial" | "unavailable";
|
|
103
|
+
};
|
|
104
|
+
type InlineCommentCounts = {
|
|
105
|
+
posted: number;
|
|
106
|
+
skipped: number;
|
|
107
|
+
failed: number;
|
|
108
|
+
};
|
|
109
|
+
type ReviewPublication = {
|
|
110
|
+
state: "disabled";
|
|
111
|
+
} | {
|
|
112
|
+
state: "completed";
|
|
113
|
+
mainComment: {
|
|
114
|
+
action: "created" | "updated";
|
|
115
|
+
};
|
|
116
|
+
inlineComments: InlineCommentCounts;
|
|
117
|
+
inlinePublicationErrorCount: number;
|
|
118
|
+
inlineResolutionErrorCount: number;
|
|
119
|
+
};
|
|
120
|
+
type PiprResult = {
|
|
121
|
+
formatVersion: 2;
|
|
122
|
+
kind: "review";
|
|
123
|
+
run: PiprRunSummary;
|
|
124
|
+
mainComment: string;
|
|
125
|
+
inlineFindings: ReviewFinding[];
|
|
126
|
+
droppedFindings: Array<{
|
|
127
|
+
finding: ReviewFinding;
|
|
128
|
+
reason: string;
|
|
129
|
+
}>;
|
|
130
|
+
taskChecks: Array<{
|
|
131
|
+
taskName: string;
|
|
132
|
+
conclusion: "success" | "failure" | "neutral";
|
|
133
|
+
summary?: string;
|
|
134
|
+
}>;
|
|
135
|
+
repairAttempted: boolean;
|
|
136
|
+
publication: ReviewPublication;
|
|
137
|
+
} | {
|
|
138
|
+
formatVersion: 2;
|
|
139
|
+
kind: "skipped";
|
|
140
|
+
reason: string;
|
|
141
|
+
} | {
|
|
142
|
+
formatVersion: 2;
|
|
143
|
+
kind: "ignored";
|
|
144
|
+
reason: string;
|
|
145
|
+
} | {
|
|
146
|
+
formatVersion: 2;
|
|
147
|
+
kind: "dry-run";
|
|
148
|
+
} | {
|
|
149
|
+
formatVersion: 2;
|
|
150
|
+
kind: "command-help";
|
|
151
|
+
reason: string;
|
|
152
|
+
mainComment: string;
|
|
153
|
+
} | {
|
|
154
|
+
formatVersion: 2;
|
|
155
|
+
kind: "command-response";
|
|
156
|
+
run: PiprRunSummary;
|
|
157
|
+
mainComment: string;
|
|
158
|
+
publication: {
|
|
159
|
+
state: "completed";
|
|
160
|
+
action: "created" | "updated";
|
|
161
|
+
};
|
|
162
|
+
} | {
|
|
163
|
+
formatVersion: 2;
|
|
164
|
+
kind: "verifier";
|
|
165
|
+
run: PiprRunSummary;
|
|
166
|
+
publication: {
|
|
167
|
+
state: "completed";
|
|
168
|
+
inlineResolutionErrorCount: number;
|
|
169
|
+
};
|
|
170
|
+
} | {
|
|
171
|
+
formatVersion: 2;
|
|
172
|
+
kind: "publication-error";
|
|
173
|
+
message: string;
|
|
174
|
+
publication?: {
|
|
175
|
+
inlineComments: InlineCommentCounts;
|
|
176
|
+
inlinePublicationErrorCount: number;
|
|
177
|
+
inlineResolutionErrorCount: number;
|
|
178
|
+
};
|
|
179
|
+
} | {
|
|
180
|
+
formatVersion: 2;
|
|
181
|
+
kind: "error";
|
|
182
|
+
message: string;
|
|
183
|
+
};
|
|
184
|
+
declare const piprResultSchema: z.ZodType<PiprResult>;
|
|
185
|
+
declare function parsePiprResult(value: unknown): PiprResult;
|
|
186
|
+
//#endregion
|
|
78
187
|
//#region src/types/manifest.d.ts
|
|
79
188
|
/** Include/exclude path filter for scoped reviews and Diff Manifest projection. */
|
|
80
189
|
type PathFilter = {
|
|
81
|
-
include?: string[];
|
|
82
|
-
exclude?: string[];
|
|
190
|
+
include?: readonly string[];
|
|
191
|
+
exclude?: readonly string[];
|
|
83
192
|
};
|
|
84
193
|
/** Side of a change request diff that a commentable range belongs to. */
|
|
85
194
|
type ReviewSide = "RIGHT" | "LEFT";
|
|
@@ -87,6 +196,12 @@ type ReviewSide = "RIGHT" | "LEFT";
|
|
|
87
196
|
type RangeKind = "added" | "deleted" | "context" | "mixed";
|
|
88
197
|
/** File lifecycle status in a Diff Manifest. */
|
|
89
198
|
type FileStatus = "added" | "modified" | "removed" | "renamed";
|
|
199
|
+
/** One changed file returned without its Diff Manifest hunks and ranges. */
|
|
200
|
+
type ChangedFile = {
|
|
201
|
+
readonly path: string;
|
|
202
|
+
readonly previousPath?: string;
|
|
203
|
+
readonly status: FileStatus;
|
|
204
|
+
};
|
|
90
205
|
/** Commentable line range that can anchor an Inline Review Comment. */
|
|
91
206
|
type CommentableRange = {
|
|
92
207
|
id: string;
|
|
@@ -119,10 +234,10 @@ type DiffManifestFile = {
|
|
|
119
234
|
language?: string;
|
|
120
235
|
additions: number;
|
|
121
236
|
deletions: number;
|
|
122
|
-
hunks: DiffHunk[];
|
|
123
|
-
commentableRanges: CommentableRange[];
|
|
124
|
-
signals?: string[];
|
|
125
|
-
changedSymbols?: string[];
|
|
237
|
+
hunks: readonly DiffHunk[];
|
|
238
|
+
commentableRanges: readonly CommentableRange[];
|
|
239
|
+
signals?: readonly string[];
|
|
240
|
+
changedSymbols?: readonly string[];
|
|
126
241
|
excludedReason?: string;
|
|
127
242
|
};
|
|
128
243
|
/** Diff Manifest exposed to reviewers and tasks. */
|
|
@@ -130,7 +245,7 @@ type DiffManifest = {
|
|
|
130
245
|
baseSha: string;
|
|
131
246
|
headSha: string;
|
|
132
247
|
mergeBaseSha: string;
|
|
133
|
-
files: DiffManifestFile[];
|
|
248
|
+
files: readonly DiffManifestFile[];
|
|
134
249
|
};
|
|
135
250
|
/** Options for projecting a Diff Manifest for task or prompt use. */
|
|
136
251
|
type DiffManifestOptions = {
|
|
@@ -141,6 +256,7 @@ type DiffManifestOptions = {
|
|
|
141
256
|
};
|
|
142
257
|
/** Size limits for Diff Manifest prompt and runtime-tool payloads. */
|
|
143
258
|
type DiffManifestLimits = {
|
|
259
|
+
maxShards?: number;
|
|
144
260
|
fullMaxBytes?: number;
|
|
145
261
|
fullMaxEstimatedTokens?: number;
|
|
146
262
|
condensedMaxBytes?: number;
|
|
@@ -150,12 +266,15 @@ type DiffManifestLimits = {
|
|
|
150
266
|
/** Runtime limits for a pipr config. */
|
|
151
267
|
type RuntimeLimits = {
|
|
152
268
|
timeoutSeconds?: number;
|
|
269
|
+
maxAgentRuns?: number;
|
|
153
270
|
diffManifest?: DiffManifestLimits;
|
|
154
271
|
};
|
|
155
272
|
//#endregion
|
|
156
273
|
//#region src/types/config.d.ts
|
|
157
274
|
declare const defaultMaxStoredFindings = 50;
|
|
158
275
|
declare const maxStoredFindingsLimit = 100;
|
|
276
|
+
declare const modelThinkingLevels: readonly ["off", "minimal", "low", "medium", "high", "xhigh"];
|
|
277
|
+
type ModelThinkingLevel = (typeof modelThinkingLevels)[number];
|
|
159
278
|
/** Repository permission levels used to authorize pipr commands. */
|
|
160
279
|
type RepositoryPermission = "read" | "triage" | "write" | "maintain" | "admin";
|
|
161
280
|
/** Pull request lifecycle actions that can trigger change-request tasks. */
|
|
@@ -177,7 +296,7 @@ type ModelOptions = {
|
|
|
177
296
|
provider: string;
|
|
178
297
|
model: string;
|
|
179
298
|
apiKey?: SecretRef;
|
|
180
|
-
|
|
299
|
+
thinking?: ModelThinkingLevel;
|
|
181
300
|
};
|
|
182
301
|
/** Registered model profile that can be used by reviewers and agents. */
|
|
183
302
|
type ModelProfile = {
|
|
@@ -186,7 +305,7 @@ type ModelProfile = {
|
|
|
186
305
|
readonly provider: string;
|
|
187
306
|
readonly model: string;
|
|
188
307
|
readonly apiKey?: SecretRef;
|
|
189
|
-
readonly
|
|
308
|
+
readonly thinking?: ModelThinkingLevel;
|
|
190
309
|
};
|
|
191
310
|
/** Aggregate check-run options for a Pipr review run. */
|
|
192
311
|
type AggregateCheckOptions = false | {
|
|
@@ -254,22 +373,20 @@ type BuiltinToolCatalog = {
|
|
|
254
373
|
};
|
|
255
374
|
/** Built-in schema catalog exposed on the pipr builder. */
|
|
256
375
|
type BuiltinSchemaCatalog = {
|
|
376
|
+
readonly inlineFindings: Schema<ReviewFindingsResult>;
|
|
257
377
|
readonly review: Schema<ReviewResult>;
|
|
258
378
|
readonly summary: Schema<ReviewSummary>;
|
|
259
379
|
};
|
|
260
|
-
|
|
380
|
+
declare const agentToolHandleBrand: unique symbol;
|
|
381
|
+
/** Opaque tool handle available to Pi agents. */
|
|
261
382
|
type AgentTool<Input = unknown, Output = unknown> = {
|
|
262
383
|
readonly kind: "pipr.tool";
|
|
263
384
|
readonly name: string;
|
|
264
|
-
readonly
|
|
265
|
-
readonly input?: Schema<Input>;
|
|
266
|
-
readonly output?: Schema<Output>;
|
|
267
|
-
run?(options: ToolRunOptions<Input>): Output | Promise<Output>;
|
|
268
|
-
toModelOutput?(output: Output): PromptValue;
|
|
385
|
+
readonly [agentToolHandleBrand]: readonly [Input, Output];
|
|
269
386
|
};
|
|
270
387
|
/** Context passed to an agent prompt function. */
|
|
271
388
|
type AgentPromptContext = {
|
|
272
|
-
|
|
389
|
+
run: PiprRunContext;
|
|
273
390
|
repository: RepositoryInfo;
|
|
274
391
|
change: ChangeRequestInfo;
|
|
275
392
|
platform: PlatformInfo;
|
|
@@ -278,7 +395,7 @@ type AgentPromptContext = {
|
|
|
278
395
|
type AgentDefinition<Input, Output> = {
|
|
279
396
|
name?: string;
|
|
280
397
|
model?: ModelProfile;
|
|
281
|
-
fallbacks?: ModelProfile[];
|
|
398
|
+
fallbacks?: readonly ModelProfile[];
|
|
282
399
|
instructions: PromptSource;
|
|
283
400
|
prompt(input: Input, context: AgentPromptContext): PromptSource | Promise<PromptSource>;
|
|
284
401
|
output: Schema<Output>;
|
|
@@ -293,19 +410,23 @@ type AgentDefinition<Input, Output> = {
|
|
|
293
410
|
type AgentExtension<Input, Output> = Partial<AgentDefinition<Input, Output>> & {
|
|
294
411
|
instructions?: PromptSource;
|
|
295
412
|
};
|
|
296
|
-
|
|
413
|
+
declare const agentHandleBrand: unique symbol;
|
|
414
|
+
/** Opaque registered Pi agent with typed input and output. */
|
|
297
415
|
type Agent<Input = unknown, Output = unknown> = {
|
|
298
416
|
readonly kind: "pipr.agent";
|
|
299
417
|
readonly name?: string;
|
|
300
|
-
readonly
|
|
418
|
+
readonly [agentHandleBrand]: (input: Input) => Output;
|
|
301
419
|
extend(patch: AgentExtension<Input, Output>): Agent<Input, Output>;
|
|
302
420
|
};
|
|
303
421
|
//#endregion
|
|
304
422
|
//#region src/types/task.d.ts
|
|
305
423
|
/** Final review comment value produced by a task or review recipe. */
|
|
306
424
|
type CommentValue = Markdown | {
|
|
307
|
-
main
|
|
425
|
+
main: Markdown;
|
|
308
426
|
inlineFindings?: readonly ReviewFinding[];
|
|
427
|
+
} | {
|
|
428
|
+
main?: never;
|
|
429
|
+
inlineFindings: readonly ReviewFinding[];
|
|
309
430
|
};
|
|
310
431
|
/** Prior inline finding persisted by earlier pipr review state. */
|
|
311
432
|
type PriorInlineFinding = {
|
|
@@ -338,13 +459,12 @@ type TaskDefinition<Input> = {
|
|
|
338
459
|
local?: false;
|
|
339
460
|
run: TaskHandler<Input>;
|
|
340
461
|
};
|
|
341
|
-
|
|
462
|
+
declare const taskHandleBrand: unique symbol;
|
|
463
|
+
/** Opaque registered task handle selected by change-request and command entrypoints. */
|
|
342
464
|
type Task<Input = void> = {
|
|
343
465
|
readonly kind: "pipr.task";
|
|
344
466
|
readonly name: string;
|
|
345
|
-
readonly
|
|
346
|
-
readonly local?: false;
|
|
347
|
-
readonly handler: TaskHandler<Input>;
|
|
467
|
+
readonly [taskHandleBrand]: (input: Input) => Input;
|
|
348
468
|
};
|
|
349
469
|
/** Options shared by command registrations. */
|
|
350
470
|
type CommandOptions<Input> = {
|
|
@@ -357,18 +477,11 @@ type CommandRegistrationOptions<Input> = CommandOptions<Input> & {
|
|
|
357
477
|
pattern: string;
|
|
358
478
|
task: Task<Input>;
|
|
359
479
|
};
|
|
360
|
-
/**
|
|
361
|
-
type
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
fallbacks?: ModelProfile[];
|
|
365
|
-
instructions: PromptSource;
|
|
366
|
-
prompt?: (input: DefaultReviewInput, context: AgentPromptContext) => PromptSource | Promise<PromptSource>;
|
|
367
|
-
tools?: readonly AgentTool[];
|
|
368
|
-
timeout?: DurationInput;
|
|
480
|
+
/** Role-specific policy for the two agents created by `pipr.review`. */
|
|
481
|
+
type ReviewInstructions = {
|
|
482
|
+
findings: PromptSource;
|
|
483
|
+
summary: PromptSource;
|
|
369
484
|
};
|
|
370
|
-
/** Reviewer agent that emits pipr's core review result. */
|
|
371
|
-
type Reviewer = Agent<DefaultReviewInput, ReviewResult>;
|
|
372
485
|
/** Entrypoints created by `pipr.review`. */
|
|
373
486
|
type ReviewEntrypoints = {
|
|
374
487
|
changeRequest?: readonly ChangeRequestAction[] | false;
|
|
@@ -390,6 +503,10 @@ declare const defaultReviewEntrypoints: {
|
|
|
390
503
|
};
|
|
391
504
|
type ReviewRecipeEntrypointOptions = {
|
|
392
505
|
id: string;
|
|
506
|
+
model: ModelProfile;
|
|
507
|
+
fallbacks?: readonly ModelProfile[];
|
|
508
|
+
instructions: ReviewInstructions;
|
|
509
|
+
tools?: readonly AgentTool[];
|
|
393
510
|
entrypoints?: ReviewEntrypoints;
|
|
394
511
|
comment?: CommentValue | ((result: ReviewResult, context: ReviewCommentContext) => CommentValue | Promise<CommentValue>);
|
|
395
512
|
check?: TaskCheckOptions;
|
|
@@ -397,21 +514,42 @@ type ReviewRecipeEntrypointOptions = {
|
|
|
397
514
|
paths?: PathFilter;
|
|
398
515
|
};
|
|
399
516
|
/** Options for `pipr.review`, pipr's default review recipe. */
|
|
400
|
-
type ReviewRecipeOptions =
|
|
401
|
-
reviewer: Reviewer;
|
|
402
|
-
}) | (ReviewRecipeEntrypointOptions & ReviewerOptions & {
|
|
403
|
-
reviewer?: undefined;
|
|
404
|
-
});
|
|
517
|
+
type ReviewRecipeOptions = ReviewRecipeEntrypointOptions;
|
|
405
518
|
/** Default input passed to a reviewer created by `pipr.review`. */
|
|
406
519
|
type DefaultReviewInput = {
|
|
407
520
|
manifest: DiffManifest;
|
|
408
521
|
change: ChangeRequestInfo;
|
|
409
522
|
};
|
|
523
|
+
/** Bounded Diff Manifest projection passed to the summary agent created by `pipr.review`. */
|
|
524
|
+
type DefaultReviewSummaryManifest = {
|
|
525
|
+
baseSha: string;
|
|
526
|
+
headSha: string;
|
|
527
|
+
mergeBaseSha: string;
|
|
528
|
+
fileCount: number;
|
|
529
|
+
omittedFileCount: number;
|
|
530
|
+
files: readonly {
|
|
531
|
+
path: string;
|
|
532
|
+
previousPath?: string;
|
|
533
|
+
status: DiffManifest["files"][number]["status"];
|
|
534
|
+
language?: string;
|
|
535
|
+
additions: number;
|
|
536
|
+
deletions: number;
|
|
537
|
+
changedSymbols?: readonly string[];
|
|
538
|
+
excludedReason?: string;
|
|
539
|
+
}[];
|
|
540
|
+
};
|
|
541
|
+
/** Input passed to the summary agent created by `pipr.review`. */
|
|
542
|
+
type DefaultReviewSummaryInput = {
|
|
543
|
+
manifestSummary: DefaultReviewSummaryManifest;
|
|
544
|
+
change: ChangeRequestInfo;
|
|
545
|
+
inlineFindings: readonly ReviewFinding[];
|
|
546
|
+
};
|
|
410
547
|
/** Context passed to a custom review comment renderer. */
|
|
411
548
|
type ReviewCommentContext = {
|
|
412
549
|
review: {
|
|
413
550
|
id: string;
|
|
414
551
|
};
|
|
552
|
+
run: PiprRunContext;
|
|
415
553
|
repository: RepositoryInfo;
|
|
416
554
|
change: ChangeRequestContext;
|
|
417
555
|
platform: PlatformInfo;
|
|
@@ -435,10 +573,10 @@ type ToolRunOptions<Input> = {
|
|
|
435
573
|
ctx: TaskContext;
|
|
436
574
|
signal?: AbortSignal;
|
|
437
575
|
};
|
|
438
|
-
/** Definition used to register
|
|
439
|
-
type ChangeRequestRegistrationOptions
|
|
576
|
+
/** Definition used to register an inputless task for change request actions. */
|
|
577
|
+
type ChangeRequestRegistrationOptions = {
|
|
440
578
|
actions: readonly ChangeRequestAction[];
|
|
441
|
-
task: Task<
|
|
579
|
+
task: Task<void>;
|
|
442
580
|
};
|
|
443
581
|
/** Handle for reporting task check status from inside a task. */
|
|
444
582
|
type CheckHandle = {
|
|
@@ -451,13 +589,12 @@ type PiprBuilder = {
|
|
|
451
589
|
readonly tools: BuiltinToolCatalog;
|
|
452
590
|
readonly schemas: BuiltinSchemaCatalog;
|
|
453
591
|
readonly on: {
|
|
454
|
-
changeRequest
|
|
592
|
+
changeRequest(options: ChangeRequestRegistrationOptions): void;
|
|
455
593
|
};
|
|
456
594
|
secret(options: SecretOptions): SecretRef;
|
|
457
595
|
model(options: ModelOptions): ModelProfile;
|
|
458
596
|
agent<Input, Output>(definition: AgentDefinition<Input, Output>): Agent<Input, Output>;
|
|
459
597
|
task<Input = void>(definition: TaskDefinition<Input>): Task<Input>;
|
|
460
|
-
reviewer(options: ReviewerOptions): Reviewer;
|
|
461
598
|
review(options: ReviewRecipeOptions): void;
|
|
462
599
|
config(options: PiprConfigOptions): void;
|
|
463
600
|
command<Input = void>(options: CommandRegistrationOptions<Input>): void;
|
|
@@ -503,21 +640,17 @@ type PlatformInfo = {
|
|
|
503
640
|
/** Change-request context available inside tasks. */
|
|
504
641
|
type ChangeRequestContext = ChangeRequestInfo & {
|
|
505
642
|
diffManifest(options?: DiffManifestOptions): Promise<DiffManifest>;
|
|
506
|
-
changedFiles(): Promise<
|
|
507
|
-
path: string;
|
|
508
|
-
previousPath?: string;
|
|
509
|
-
status: string;
|
|
510
|
-
}>>;
|
|
511
|
-
currentHeadSha(): Promise<string>;
|
|
643
|
+
changedFiles(): Promise<readonly ChangedFile[]>;
|
|
512
644
|
};
|
|
513
645
|
/** Runner for invoking Pi agents from tasks. */
|
|
514
646
|
type PiRunner = {
|
|
515
647
|
run<Input, Output>(agent: Agent<Input, Output>, input: Input, options?: {
|
|
516
648
|
model?: ModelProfile;
|
|
517
|
-
fallbacks?: ModelProfile[];
|
|
649
|
+
fallbacks?: readonly ModelProfile[];
|
|
518
650
|
instructions?: PromptSource;
|
|
519
651
|
timeout?: DurationInput;
|
|
520
652
|
paths?: PathFilter;
|
|
653
|
+
maxShards?: number;
|
|
521
654
|
}): Promise<Output>;
|
|
522
655
|
};
|
|
523
656
|
/** Command context available inside command-triggered tasks. */
|
|
@@ -529,10 +662,8 @@ type CommandContext = {
|
|
|
529
662
|
};
|
|
530
663
|
/** Context object passed to task handlers. */
|
|
531
664
|
type TaskContext = {
|
|
532
|
-
/** Stable
|
|
533
|
-
readonly run:
|
|
534
|
-
id: string;
|
|
535
|
-
};
|
|
665
|
+
/** Stable identity and trigger for the selected Review Run, not the process attempt. */
|
|
666
|
+
readonly run: PiprRunContext;
|
|
536
667
|
readonly repository: RepositoryInfo;
|
|
537
668
|
readonly change: ChangeRequestContext;
|
|
538
669
|
readonly platform: PlatformInfo;
|
|
@@ -571,5 +702,5 @@ declare function jsonSchema<T>(definition: JsonSchemaDefinition): Schema<T>;
|
|
|
571
702
|
/** Built-in schemas available as reusable agent output contracts. */
|
|
572
703
|
declare const schemas: BuiltinSchemaCatalog;
|
|
573
704
|
//#endregion
|
|
574
|
-
export {
|
|
575
|
-
//# sourceMappingURL=index-
|
|
705
|
+
export { AutoResolveOptions as $, SchemaParseResult as $t, ReviewRecipeOptions as A, PiprRunTrigger as At, AgentDefinition as B, parseReviewSummary as Bt, PluginToolDefinition as C, PathFilter as Ct, ReviewCommentContext as D, PiprResult as Dt, RepositoryInfo as E, RuntimeLimits as Et, TaskHandler as F, ReviewResult as Ft, BuiltinToolCatalog as G, reviewSummarySchema as Gt, AgentPromptContext as H, reviewFindingsResultSchema as Ht, ToolRunOptions as I, ReviewSummary as It, PromptSource as J, JsonSchema as Jt, JsonPromptOptions as K, JsonObject as Kt, defaultReviewActions as L, parseReviewFinding as Lt, TaskCheckOptions as M, piprResultSchema as Mt, TaskContext as N, ReviewFinding as Nt, ReviewEntrypoints as O, PiprRunContext as Ot, TaskDefinition as P, ReviewFindingsResult as Pt, AutoResolveAllowedActors as Q, SchemaDefinition as Qt, defaultReviewEntrypoints as R, parseReviewFindingsResult as Rt, PlatformInfo as S, FileStatus as St, PriorReview as T, ReviewSide as Tt, AgentTool as U, reviewResultSchema as Ut, AgentExtension as V, reviewFindingSchema as Vt, BuiltinSchemaCatalog as W, reviewSchemaExample as Wt, PromptValue as X, JsonValue as Xt, PromptText as Y, JsonSchemaDefinition as Yt, AggregateCheckOptions as Z, Schema as Zt, DefaultReviewSummaryInput as _, DiffHunk as _t, md as a, ModelProfile as at, PiprBuilder as b, DiffManifestLimits as bt, ChangeRequestContext as c, PublicationOptions as ct, CheckHandle as d, SecretRef as dt, ZodSchema as en, AutoResolveUserRepliesOptions as et, CommandContext as f, defaultMaxStoredFindings as ft, DefaultReviewInput as g, CommentableRange as gt, CommentValue as h, ChangedFile as ht, schemas as i, ModelOptions as it, Task as j, parsePiprResult as jt, ReviewInstructions as k, PiprRunSummary as kt, ChangeRequestInfo as l, RepositoryPermission as lt, CommandRegistrationOptions as m, modelThinkingLevels as mt, jsonSchema as n, ChecksOptions as nt, definePipr as o, ModelThinkingLevel as ot, CommandOptions as p, maxStoredFindingsLimit as pt, Markdown as q, JsonPrimitive as qt, schema as r, DurationInput as rt, definePlugin as s, PiprConfigOptions as st, z$1 as t, ChangeRequestAction as tt, ChangeRequestRegistrationOptions as u, SecretOptions as ut, DefaultReviewSummaryManifest as v, DiffManifest as vt, PriorInlineFinding as w, RangeKind as wt, PiprPlugin as x, DiffManifestOptions as xt, PiRunner as y, DiffManifestFile as yt, Agent as z, parseReviewResult as zt };
|
|
706
|
+
//# sourceMappingURL=index-Bdey1nho.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-Bdey1nho.d.mts","names":[],"sources":["../src/types/schema.ts","../src/review-contract.ts","../src/result.ts","../src/types/manifest.ts","../src/types/config.ts","../src/types/prompt.ts","../src/types/agent.ts","../src/types/task.ts","../src/builder.ts","../src/prompt.ts","../src/schema.ts"],"mappings":";;;KAGY;;KAEA,YAAY,gBAAgB,cAAc;;KAE1C;GAAgB,cAAc;;;KAE9B,aAAa;;KAGb,kBAAkB;EAAO;EAAe,MAAM;;EAAQ;EAAgB,OAAO;;;KAG7E,OAAO;WACR;WACA;WACA,aAAa;EACtB,MAAM,iBAAiB;EACvB,UAAU,iBAAiB,kBAAkB;;;KAInC,UAAU,KAAK,EAAE,QAAQ;;KAGzB,iBAAiB;EAC3B;EACA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