@usepipr/runtime 0.2.0 → 0.2.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 +42 -0
- package/dist/{commands-BajlHf13.mjs → commands-Cj8p5IQF.mjs} +65 -13
- package/dist/commands-Cj8p5IQF.mjs.map +1 -0
- package/dist/commands-Zzy2vNDo.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/internal/testing.mjs +1 -1
- package/package.json +8 -8
- package/dist/commands-BajlHf13.mjs.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# @usepipr/runtime
|
|
2
|
+
|
|
3
|
+
`@usepipr/runtime` owns Pipr's config loading, Action and local command
|
|
4
|
+
execution, Diff Manifest creation, Pi execution, review validation, and
|
|
5
|
+
publication planning.
|
|
6
|
+
|
|
7
|
+
## Technical Notes
|
|
8
|
+
|
|
9
|
+
- The package root exports command APIs for init, Action runs, dry runs,
|
|
10
|
+
config checks, plan inspection, and local review.
|
|
11
|
+
- `./runtime-tools-extension` is the static Pi runtime tools extension loaded
|
|
12
|
+
during condensed Diff Manifest runs.
|
|
13
|
+
- `./internal/testing` is an unsupported test surface for Pipr's private e2e
|
|
14
|
+
harness.
|
|
15
|
+
- The build emits ESM and declaration files to `dist`.
|
|
16
|
+
|
|
17
|
+
## Source Map
|
|
18
|
+
|
|
19
|
+
| Path | Responsibility |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| `src/action` | CLI and GitHub Action command orchestration |
|
|
22
|
+
| `src/config` | `.pipr/config.ts` loading, init files, recipes, and SDK stubs |
|
|
23
|
+
| `src/diff` | Diff Manifest parsing, projection, ranges, and path filters |
|
|
24
|
+
| `src/pi` | Pi subprocess contract, runtime tools, and provider wiring |
|
|
25
|
+
| `src/review` | Task execution, agent prompts, validation, comments, and publication plans |
|
|
26
|
+
| `src/hosts` | Code host adapters for GitHub and local runs |
|
|
27
|
+
|
|
28
|
+
## Commands
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
bun run --cwd packages/runtime test:config-init
|
|
32
|
+
bun run --cwd packages/runtime test:config-loader
|
|
33
|
+
bun run --cwd packages/runtime test:core
|
|
34
|
+
bun run --cwd packages/runtime check
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Docs
|
|
38
|
+
|
|
39
|
+
- [Runtime Guide](https://pipr.run/docs/guide/runtime)
|
|
40
|
+
- [Comments and Findings](https://pipr.run/docs/guide/comments)
|
|
41
|
+
- [Architecture](https://pipr.run/docs/reference/architecture)
|
|
42
|
+
- [Trust and Security](https://pipr.run/docs/guide/trust-security)
|
|
@@ -415,6 +415,7 @@ const starterTsconfig = `{
|
|
|
415
415
|
"compilerOptions": {
|
|
416
416
|
"strict": true,
|
|
417
417
|
"noEmit": true,
|
|
418
|
+
"skipLibCheck": true,
|
|
418
419
|
"target": "ES2022",
|
|
419
420
|
"module": "ESNext",
|
|
420
421
|
"moduleResolution": "Bundler"
|
|
@@ -494,6 +495,7 @@ async function typecheckTypescriptConfigWithApi(configDir, tsconfigPath) {
|
|
|
494
495
|
const configPath = path.join(configDir, "config.ts");
|
|
495
496
|
const program = ts.createProgram([configPath, ...parsed.fileNames], {
|
|
496
497
|
...parsed.options,
|
|
498
|
+
skipLibCheck: true,
|
|
497
499
|
typeRoots: [...new Set([...parsed.options.typeRoots ?? [], ...bundledTypeRoots])],
|
|
498
500
|
types: [...new Set([...parsed.options.types ?? [], ...bundledTypeRoots.length ? ["bun"] : []])]
|
|
499
501
|
});
|
|
@@ -865,7 +867,7 @@ export default definePipr((pipr) => {
|
|
|
865
867
|
maintainability, and test coverage.
|
|
866
868
|
Return only actionable findings that target valid diff ranges.
|
|
867
869
|
\`,
|
|
868
|
-
timeout: "
|
|
870
|
+
timeout: "10m",
|
|
869
871
|
comment: (result, context) => ({
|
|
870
872
|
main:
|
|
871
873
|
context.platform.id === "local"
|
|
@@ -1801,8 +1803,8 @@ function isOfficialInitRecipeId(recipe) {
|
|
|
1801
1803
|
//#endregion
|
|
1802
1804
|
//#region src/config/init.ts
|
|
1803
1805
|
const supportedOfficialInitAdapters = ["github"];
|
|
1804
|
-
const defaultWorkflowActionRef = "somus/pipr@v0.2.
|
|
1805
|
-
const defaultSdkVersion = "0.2.
|
|
1806
|
+
const defaultWorkflowActionRef = "somus/pipr@v0.2.1";
|
|
1807
|
+
const defaultSdkVersion = "0.2.1";
|
|
1806
1808
|
const defaultTypesBunVersion = "1.3.14";
|
|
1807
1809
|
function resolveOfficialInitAdapters(adapters) {
|
|
1808
1810
|
if (adapters === void 0) return [...supportedOfficialInitAdapters];
|
|
@@ -3578,7 +3580,8 @@ function resolveProvider(config, providerId) {
|
|
|
3578
3580
|
return provider;
|
|
3579
3581
|
}
|
|
3580
3582
|
function createAgentRunContext(runtime) {
|
|
3581
|
-
const runId =
|
|
3583
|
+
const runId = runtime.runId ?? runtime.taskContext?.run.id;
|
|
3584
|
+
if (!runId) throw new Error("runId is required for stable review run identity");
|
|
3582
3585
|
const repositorySlugParts = runtime.event.repository.slug.split("/");
|
|
3583
3586
|
const repository = {
|
|
3584
3587
|
root: runtime.workspace,
|
|
@@ -3850,7 +3853,7 @@ function buildRepairPrompt(options) {
|
|
|
3850
3853
|
}
|
|
3851
3854
|
//#endregion
|
|
3852
3855
|
//#region package.json
|
|
3853
|
-
var version = "0.2.
|
|
3856
|
+
var version = "0.2.1";
|
|
3854
3857
|
//#endregion
|
|
3855
3858
|
//#region src/review/prior-state.ts
|
|
3856
3859
|
const mainCommentMarker = "pipr:main-comment";
|
|
@@ -4284,6 +4287,30 @@ function buildCommentPublishingPlan(options) {
|
|
|
4284
4287
|
};
|
|
4285
4288
|
}
|
|
4286
4289
|
//#endregion
|
|
4290
|
+
//#region src/review/run-identity.ts
|
|
4291
|
+
function stableReviewRunId(options) {
|
|
4292
|
+
return `pipr-${new Bun.CryptoHasher("sha256").update(JSON.stringify({
|
|
4293
|
+
platform: options.event.platform.id,
|
|
4294
|
+
repository: options.event.repository.slug,
|
|
4295
|
+
changeNumber: options.event.change.number,
|
|
4296
|
+
baseSha: options.event.change.base.sha,
|
|
4297
|
+
headSha: options.event.change.head.sha,
|
|
4298
|
+
trustedConfigHash: options.trustedConfigHash,
|
|
4299
|
+
trustedConfigSha: options.trustedConfigSha,
|
|
4300
|
+
selectedTasks: options.selectedTasks,
|
|
4301
|
+
command: options.commandInvocation ? {
|
|
4302
|
+
name: options.commandInvocation.name,
|
|
4303
|
+
line: options.commandInvocation.line,
|
|
4304
|
+
arguments: sortedCommandArguments(options.commandInvocation.arguments),
|
|
4305
|
+
sourceCommentId: options.commandInvocation.sourceCommentId
|
|
4306
|
+
} : void 0,
|
|
4307
|
+
verifier: options.verifierInvocation
|
|
4308
|
+
})).digest("hex").slice(0, 24)}`;
|
|
4309
|
+
}
|
|
4310
|
+
function sortedCommandArguments(arguments_) {
|
|
4311
|
+
return Object.fromEntries(Object.entries(arguments_).sort(([left], [right]) => left < right ? -1 : left > right ? 1 : 0));
|
|
4312
|
+
}
|
|
4313
|
+
//#endregion
|
|
4287
4314
|
//#region src/review/verifier.ts
|
|
4288
4315
|
const verifierFindingSchema = z.strictObject({
|
|
4289
4316
|
id: z.string().min(1),
|
|
@@ -4348,6 +4375,7 @@ async function runInternalVerifier(options) {
|
|
|
4348
4375
|
env: options.env,
|
|
4349
4376
|
piExecutable: options.piExecutable,
|
|
4350
4377
|
piRunner: options.piRunner,
|
|
4378
|
+
runId: options.runId,
|
|
4351
4379
|
log: options.log
|
|
4352
4380
|
}
|
|
4353
4381
|
});
|
|
@@ -4364,6 +4392,7 @@ async function runInternalVerifier(options) {
|
|
|
4364
4392
|
function verifierInput(options, prior, candidates) {
|
|
4365
4393
|
return {
|
|
4366
4394
|
manifest: options.diffManifest,
|
|
4395
|
+
runId: options.runId,
|
|
4367
4396
|
mode: options.mode.kind,
|
|
4368
4397
|
reviewedHeadSha: prior.reviewedHeadSha,
|
|
4369
4398
|
currentHeadSha: options.event.change.head.sha,
|
|
@@ -4671,13 +4700,21 @@ async function runTaskRuntime(options) {
|
|
|
4671
4700
|
selectedTasks,
|
|
4672
4701
|
taskCount: tasks.length
|
|
4673
4702
|
});
|
|
4703
|
+
const runId = stableReviewRunId({
|
|
4704
|
+
event: options.event,
|
|
4705
|
+
selectedTasks,
|
|
4706
|
+
trustedConfigSha: options.trustedConfigSha,
|
|
4707
|
+
trustedConfigHash: options.trustedConfigHash,
|
|
4708
|
+
commandInvocation: options.commandInvocation
|
|
4709
|
+
});
|
|
4674
4710
|
const loadedPriorReviewState = options.priorReviewState ?? await options.loadPriorReviewState?.();
|
|
4675
4711
|
const priorMainComment = options.priorMainComment ?? await options.loadPriorMainComment?.();
|
|
4676
4712
|
const priorReviewState = priorReviewStateForSelectedTasks(loadedPriorReviewState, selectedTasks);
|
|
4677
4713
|
const runtimeOptions = {
|
|
4678
4714
|
...options,
|
|
4679
4715
|
priorReviewState,
|
|
4680
|
-
priorMainComment
|
|
4716
|
+
priorMainComment,
|
|
4717
|
+
runId
|
|
4681
4718
|
};
|
|
4682
4719
|
const manifestCache = /* @__PURE__ */ new Map();
|
|
4683
4720
|
const taskResults = await Promise.all(tasks.map(async (task, taskOrder) => {
|
|
@@ -4759,7 +4796,8 @@ async function runTaskRuntime(options) {
|
|
|
4759
4796
|
config,
|
|
4760
4797
|
provider,
|
|
4761
4798
|
diffManifest,
|
|
4762
|
-
priorReviewState
|
|
4799
|
+
priorReviewState,
|
|
4800
|
+
runId
|
|
4763
4801
|
});
|
|
4764
4802
|
const publishing = buildCommentPublishingPlan({
|
|
4765
4803
|
event: options.event,
|
|
@@ -4836,14 +4874,15 @@ async function runSynchronizeVerifier(options) {
|
|
|
4836
4874
|
diffManifest: options.diffManifest,
|
|
4837
4875
|
priorReviewState: options.priorReviewState,
|
|
4838
4876
|
threadContexts: await options.options.loadInlineThreadContexts?.() ?? [],
|
|
4839
|
-
mode: { kind: "synchronize" }
|
|
4877
|
+
mode: { kind: "synchronize" },
|
|
4878
|
+
runId: options.runId
|
|
4840
4879
|
});
|
|
4841
4880
|
}
|
|
4842
4881
|
function createTaskContext(options) {
|
|
4843
4882
|
const repositorySlugParts = options.event.repository.slug.split("/");
|
|
4844
4883
|
let taskContext;
|
|
4845
4884
|
taskContext = {
|
|
4846
|
-
run: { id:
|
|
4885
|
+
run: { id: options.runId },
|
|
4847
4886
|
repository: {
|
|
4848
4887
|
root: options.workspace,
|
|
4849
4888
|
owner: repositorySlugParts.length > 1 ? repositorySlugParts[0] : void 0,
|
|
@@ -4896,7 +4935,8 @@ function createTaskContext(options) {
|
|
|
4896
4935
|
runOptions,
|
|
4897
4936
|
runtime: {
|
|
4898
4937
|
...options,
|
|
4899
|
-
taskContext
|
|
4938
|
+
taskContext,
|
|
4939
|
+
runId: options.runId
|
|
4900
4940
|
}
|
|
4901
4941
|
});
|
|
4902
4942
|
options.output.providerModels.push(...result.providerModels);
|
|
@@ -6778,7 +6818,8 @@ async function dispatchIssueCommentCommand(options, adapter, prepared, log) {
|
|
|
6778
6818
|
commandInvocation: {
|
|
6779
6819
|
name: parsedResolution.invocation.commandName,
|
|
6780
6820
|
line: parsedResolution.invocation.line,
|
|
6781
|
-
arguments: parsedResolution.invocation.arguments
|
|
6821
|
+
arguments: parsedResolution.invocation.arguments,
|
|
6822
|
+
sourceCommentId: prepared.comment.commentId
|
|
6782
6823
|
},
|
|
6783
6824
|
log
|
|
6784
6825
|
}),
|
|
@@ -7022,7 +7063,18 @@ async function runReviewCommentVerifier(options, adapter, prepared, log) {
|
|
|
7022
7063
|
actor: reply.actor
|
|
7023
7064
|
},
|
|
7024
7065
|
respondWhenStillValid: config.publication.autoResolve.userReplies.respondWhenStillValid
|
|
7025
|
-
}
|
|
7066
|
+
},
|
|
7067
|
+
runId: stableReviewRunId({
|
|
7068
|
+
event,
|
|
7069
|
+
selectedTasks: ["pipr-internal-verifier"],
|
|
7070
|
+
trustedConfigSha: trustedRuntime.trustedConfigSha,
|
|
7071
|
+
trustedConfigHash: trustedRuntime.trustedConfigHash,
|
|
7072
|
+
verifierInvocation: {
|
|
7073
|
+
mode: "user-reply",
|
|
7074
|
+
commentId: reply.commentId,
|
|
7075
|
+
parentCommentId: reply.parentCommentId
|
|
7076
|
+
}
|
|
7077
|
+
})
|
|
7026
7078
|
});
|
|
7027
7079
|
}
|
|
7028
7080
|
function runnableReviewCommentReply(reply) {
|
|
@@ -7197,4 +7249,4 @@ async function runActionCommandWithDependencies(options) {
|
|
|
7197
7249
|
//#endregion
|
|
7198
7250
|
export { runInspectCommand as a, PublicationError as c, supportedOfficialInitRecipes as d, piBuiltinToolNames as f, piThinkingLevels as h, runInitCommand as i, supportedOfficialInitAdapters as l, piRequiredCliFlags as m, runActionCommandWithDependencies as n, runLocalReviewCommand as o, piReadOnlyToolNames as p, runDryRunCommand as r, runValidateCommand as s, runActionCommand as t, listOfficialInitRecipes as u };
|
|
7199
7251
|
|
|
7200
|
-
//# sourceMappingURL=commands-
|
|
7252
|
+
//# sourceMappingURL=commands-Cj8p5IQF.mjs.map
|