@usepipr/cli 0.1.3 → 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
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# @usepipr/cli
|
|
2
|
+
|
|
3
|
+
`@usepipr/cli` provides the `pipr` binary. The CLI parses command flags and
|
|
4
|
+
delegates runtime behavior to `@usepipr/runtime`.
|
|
5
|
+
|
|
6
|
+
## Commands
|
|
7
|
+
|
|
8
|
+
The binary exposes these command groups:
|
|
9
|
+
|
|
10
|
+
- `pipr init`
|
|
11
|
+
- `pipr action`
|
|
12
|
+
- `pipr check`
|
|
13
|
+
- `pipr dry-run`
|
|
14
|
+
- `pipr inspect`
|
|
15
|
+
- `pipr review`
|
|
16
|
+
- `pipr skill`
|
|
17
|
+
|
|
18
|
+
Use the CLI reference for option details.
|
|
19
|
+
|
|
20
|
+
AI agents should start with:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pipr skill
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Technical Notes
|
|
27
|
+
|
|
28
|
+
- Package build emits `dist/main.mjs`.
|
|
29
|
+
- Release binary builds run through `packages/cli/build-release.ts`.
|
|
30
|
+
- The package publishes the `pipr` bin through npm and release artifacts through
|
|
31
|
+
GitHub Releases.
|
|
32
|
+
|
|
33
|
+
## Local Checks
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
bun run --cwd packages/cli check
|
|
37
|
+
bun run build:release:cli
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Docs
|
|
41
|
+
|
|
42
|
+
- [CLI Reference](https://pipr.run/docs/reference/cli)
|
|
43
|
+
- [Quickstart](https://pipr.run/docs/guide/quickstart)
|
|
44
|
+
- [Local Runs](https://pipr.run/docs/guide/local-runs)
|
package/dist/main.mjs
CHANGED
|
@@ -3,6 +3,218 @@ import { inspect } from "node:util";
|
|
|
3
3
|
import * as core from "@actions/core";
|
|
4
4
|
import { PublicationError, runActionCommand, runDryRunCommand, runInitCommand, runInspectCommand, runLocalReviewCommand, runValidateCommand, supportedOfficialInitAdapters, supportedOfficialInitRecipes } from "@usepipr/runtime";
|
|
5
5
|
import { Command } from "commander";
|
|
6
|
+
import { lstat, mkdir, mkdtemp, readdir, rename, rm } from "node:fs/promises";
|
|
7
|
+
import os from "node:os";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
//#region package.json
|
|
10
|
+
var version = "0.2.1";
|
|
11
|
+
//#endregion
|
|
12
|
+
//#region src/skill-catalog.ts
|
|
13
|
+
const bundledSkillName = "pipr-setup";
|
|
14
|
+
const bundledSkillFilePaths = new Set([
|
|
15
|
+
"SKILL.md",
|
|
16
|
+
"references/config-patterns.md",
|
|
17
|
+
"references/recipes.md"
|
|
18
|
+
]);
|
|
19
|
+
function singleBundledSkill(catalog) {
|
|
20
|
+
const [skill] = catalog.skills;
|
|
21
|
+
if (catalog.skills.length !== 1 || skill?.name !== "pipr-setup") throw new Error(`Expected exactly one bundled skill named '${bundledSkillName}', found: ${catalog.skills.map((item) => item.name).join(", ")}`);
|
|
22
|
+
return skill;
|
|
23
|
+
}
|
|
24
|
+
function containedSkillFilePath(root, relativePath) {
|
|
25
|
+
if (path.isAbsolute(relativePath)) throw new Error(`Bundled skill file path must be relative: ${relativePath}`);
|
|
26
|
+
const resolvedRoot = path.resolve(root);
|
|
27
|
+
const target = path.resolve(resolvedRoot, relativePath);
|
|
28
|
+
if (target !== resolvedRoot && !target.startsWith(`${resolvedRoot}${path.sep}`)) throw new Error(`Bundled skill file path escapes the skill directory: ${relativePath}`);
|
|
29
|
+
return target;
|
|
30
|
+
}
|
|
31
|
+
async function readBundledSkillCatalog(skillsRoot) {
|
|
32
|
+
const entries = await readdir(skillsRoot, { withFileTypes: true });
|
|
33
|
+
const catalog = { skills: (await Promise.all(entries.filter((entry) => entry.isDirectory()).map(async (entry) => {
|
|
34
|
+
const skillDir = path.join(skillsRoot, entry.name);
|
|
35
|
+
const files = await readSkillFiles(skillDir);
|
|
36
|
+
validateBundledSkillFiles(entry.name, files);
|
|
37
|
+
const skillMd = files.find((file) => file.path === "SKILL.md");
|
|
38
|
+
if (!skillMd) throw new Error(`${skillDir}: missing SKILL.md`);
|
|
39
|
+
return {
|
|
40
|
+
name: entry.name,
|
|
41
|
+
description: frontmatterDescription(skillMd.contents),
|
|
42
|
+
files
|
|
43
|
+
};
|
|
44
|
+
}))).sort((left, right) => left.name.localeCompare(right.name)) };
|
|
45
|
+
singleBundledSkill(catalog);
|
|
46
|
+
return catalog;
|
|
47
|
+
}
|
|
48
|
+
async function readSkillFiles(skillDir, prefix = "") {
|
|
49
|
+
const entries = await readdir(path.join(skillDir, prefix), { withFileTypes: true });
|
|
50
|
+
return (await Promise.all(entries.filter((entry) => !entry.name.startsWith(".")).sort((left, right) => left.name.localeCompare(right.name)).map(async (entry) => {
|
|
51
|
+
const relativePath = prefix ? path.join(prefix, entry.name) : entry.name;
|
|
52
|
+
if (entry.isDirectory()) return await readSkillFiles(skillDir, relativePath);
|
|
53
|
+
if (!entry.isFile()) return [];
|
|
54
|
+
const contents = await Bun.file(path.join(skillDir, relativePath)).text();
|
|
55
|
+
return [{
|
|
56
|
+
path: relativePath.split(path.sep).join("/"),
|
|
57
|
+
contents
|
|
58
|
+
}];
|
|
59
|
+
}))).flat();
|
|
60
|
+
}
|
|
61
|
+
function frontmatterDescription(contents) {
|
|
62
|
+
const description = (contents.match(/^---\n(?<body>[\s\S]*?)\n---/u)?.groups?.body)?.split("\n").find((line) => line.startsWith("description:"))?.replace(/^description:\s*/u, "").trim().replace(/^["']|["']$/gu, "");
|
|
63
|
+
if (!description) throw new Error("Bundled skill SKILL.md is missing a description");
|
|
64
|
+
return description;
|
|
65
|
+
}
|
|
66
|
+
function validateBundledSkillFiles(skillName, files) {
|
|
67
|
+
if (skillName !== "pipr-setup") return;
|
|
68
|
+
const found = new Set(files.map((file) => file.path));
|
|
69
|
+
const unexpected = [...found].filter((filePath) => !bundledSkillFilePaths.has(filePath));
|
|
70
|
+
const missing = [...bundledSkillFilePaths].filter((filePath) => !found.has(filePath));
|
|
71
|
+
if (unexpected.length > 0 || missing.length > 0) throw new Error(`${bundledSkillName} bundled files must match the release allowlist; unexpected: ${unexpected.join(", ") || "-"}; missing: ${missing.join(", ") || "-"}`);
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/skills.ts
|
|
75
|
+
let skillPromise;
|
|
76
|
+
async function resolveBundledSkill() {
|
|
77
|
+
skillPromise ??= loadBundledSkill();
|
|
78
|
+
return await skillPromise;
|
|
79
|
+
}
|
|
80
|
+
function formatBundledSkill(skill) {
|
|
81
|
+
const files = [...skill.files].sort(compareSkillFiles);
|
|
82
|
+
return [
|
|
83
|
+
`# ${skill.name}`,
|
|
84
|
+
"",
|
|
85
|
+
skill.description,
|
|
86
|
+
"",
|
|
87
|
+
...files.flatMap((file) => [
|
|
88
|
+
`----- BEGIN SKILL FILE: ${file.path} -----`,
|
|
89
|
+
file.contents.trimEnd(),
|
|
90
|
+
`----- END SKILL FILE: ${file.path} -----`,
|
|
91
|
+
""
|
|
92
|
+
])
|
|
93
|
+
].join("\n");
|
|
94
|
+
}
|
|
95
|
+
function compareSkillFiles(left, right) {
|
|
96
|
+
if (left.path === "SKILL.md") return -1;
|
|
97
|
+
if (right.path === "SKILL.md") return 1;
|
|
98
|
+
return left.path.localeCompare(right.path);
|
|
99
|
+
}
|
|
100
|
+
async function materializeBundledSkill() {
|
|
101
|
+
const skill = await resolveBundledSkill();
|
|
102
|
+
const versionDir = path.join(skillCacheRoot(), version);
|
|
103
|
+
const skillDir = path.join(versionDir, skill.name);
|
|
104
|
+
await mkdir(versionDir, { recursive: true });
|
|
105
|
+
const stagingDir = await mkdtemp(path.join(versionDir, `${bundledSkillName}-`));
|
|
106
|
+
try {
|
|
107
|
+
for (const file of skill.files) await writeSkillFile(stagingDir, file);
|
|
108
|
+
if (await skillDirectoryMatches(skillDir, skill.files)) {
|
|
109
|
+
await rm(stagingDir, {
|
|
110
|
+
recursive: true,
|
|
111
|
+
force: true
|
|
112
|
+
});
|
|
113
|
+
return skillDir;
|
|
114
|
+
}
|
|
115
|
+
await rm(skillDir, {
|
|
116
|
+
recursive: true,
|
|
117
|
+
force: true
|
|
118
|
+
});
|
|
119
|
+
await renameSkillDirectory(stagingDir, skillDir, skill.files);
|
|
120
|
+
} catch (error) {
|
|
121
|
+
await rm(stagingDir, {
|
|
122
|
+
recursive: true,
|
|
123
|
+
force: true
|
|
124
|
+
});
|
|
125
|
+
throw error;
|
|
126
|
+
}
|
|
127
|
+
return skillDir;
|
|
128
|
+
}
|
|
129
|
+
async function loadBundledSkill() {
|
|
130
|
+
return singleBundledSkill(embeddedSkillCatalog() ?? await loadFilesystemSkillCatalog());
|
|
131
|
+
}
|
|
132
|
+
async function loadFilesystemSkillCatalog() {
|
|
133
|
+
const attempts = await Promise.all(skillRootCandidates().map(readSkillCatalogAttempt));
|
|
134
|
+
const loaded = attempts.find((attempt) => "catalog" in attempt);
|
|
135
|
+
if (loaded) return loaded.catalog;
|
|
136
|
+
throw new Error(`Unable to load bundled Pipr skills.\n${attempts.map((attempt) => `${attempt.skillsRoot}: ${"error" in attempt ? attempt.error : "loaded"}`).join("\n")}`);
|
|
137
|
+
}
|
|
138
|
+
async function readSkillCatalogAttempt(skillsRoot) {
|
|
139
|
+
try {
|
|
140
|
+
return {
|
|
141
|
+
skillsRoot,
|
|
142
|
+
catalog: await readBundledSkillCatalog(skillsRoot)
|
|
143
|
+
};
|
|
144
|
+
} catch (error) {
|
|
145
|
+
return {
|
|
146
|
+
skillsRoot,
|
|
147
|
+
error: error instanceof Error ? error.message : String(error)
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function embeddedSkillCatalog() {
|
|
152
|
+
if (typeof PIPR_EMBEDDED_SKILLS !== "string" || PIPR_EMBEDDED_SKILLS.length === 0) return;
|
|
153
|
+
return JSON.parse(PIPR_EMBEDDED_SKILLS);
|
|
154
|
+
}
|
|
155
|
+
function skillRootCandidates() {
|
|
156
|
+
const here = import.meta.dirname;
|
|
157
|
+
return [path.join(here, "skills"), path.resolve(here, "../../../skills")];
|
|
158
|
+
}
|
|
159
|
+
async function writeSkillFile(skillDir, file) {
|
|
160
|
+
const target = containedSkillFilePath(skillDir, file.path);
|
|
161
|
+
await mkdir(path.dirname(target), { recursive: true });
|
|
162
|
+
await Bun.write(target, file.contents);
|
|
163
|
+
}
|
|
164
|
+
async function renameSkillDirectory(stagingDir, skillDir, files) {
|
|
165
|
+
try {
|
|
166
|
+
await rename(stagingDir, skillDir);
|
|
167
|
+
} catch (error) {
|
|
168
|
+
if (isExistingDirectoryError(error) && await skillDirectoryMatches(skillDir, files)) {
|
|
169
|
+
await rm(stagingDir, {
|
|
170
|
+
recursive: true,
|
|
171
|
+
force: true
|
|
172
|
+
});
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
async function skillDirectoryMatches(skillDir, files) {
|
|
179
|
+
try {
|
|
180
|
+
return await skillDirectoryPathsMatch(skillDir, files) && await skillDirectoryContentsMatch(skillDir, files);
|
|
181
|
+
} catch {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
async function skillDirectoryPathsMatch(skillDir, files) {
|
|
186
|
+
return samePaths(await listSkillDirectoryEntries(skillDir), files.map((file) => file.path).sort());
|
|
187
|
+
}
|
|
188
|
+
async function skillDirectoryContentsMatch(skillDir, files) {
|
|
189
|
+
for (const file of files) if (!await skillFileMatches(skillDir, file)) return false;
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
async function skillFileMatches(skillDir, file) {
|
|
193
|
+
const target = containedSkillFilePath(skillDir, file.path);
|
|
194
|
+
return (await lstat(target)).isFile() && await Bun.file(target).text() === file.contents;
|
|
195
|
+
}
|
|
196
|
+
async function listSkillDirectoryEntries(skillDir, prefix = "") {
|
|
197
|
+
const entries = await readdir(path.join(skillDir, prefix), { withFileTypes: true });
|
|
198
|
+
return (await Promise.all(entries.filter((entry) => !entry.name.startsWith(".")).map(async (entry) => {
|
|
199
|
+
const relativePath = prefix ? path.join(prefix, entry.name) : entry.name;
|
|
200
|
+
if (entry.isDirectory()) return await listSkillDirectoryEntries(skillDir, relativePath);
|
|
201
|
+
return [relativePath.split(path.sep).join("/")];
|
|
202
|
+
}))).flat().sort();
|
|
203
|
+
}
|
|
204
|
+
function samePaths(left, right) {
|
|
205
|
+
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
206
|
+
}
|
|
207
|
+
const existingDirectoryErrorCodes = new Set(["EEXIST", "ENOTEMPTY"]);
|
|
208
|
+
function isExistingDirectoryError(error) {
|
|
209
|
+
return existingDirectoryErrorCodes.has(error?.code ?? "");
|
|
210
|
+
}
|
|
211
|
+
function skillCacheRoot() {
|
|
212
|
+
const override = process.env.PIPR_SKILL_CACHE_DIR;
|
|
213
|
+
if (override && override.trim().length > 0) return path.resolve(override);
|
|
214
|
+
const cacheHome = process.env.XDG_CACHE_HOME || path.join(os.homedir(), ".cache");
|
|
215
|
+
return path.join(cacheHome, "pipr", "skills");
|
|
216
|
+
}
|
|
217
|
+
//#endregion
|
|
6
218
|
//#region src/main.ts
|
|
7
219
|
async function main() {
|
|
8
220
|
const program = createProgram();
|
|
@@ -15,14 +227,27 @@ async function main() {
|
|
|
15
227
|
function createProgram() {
|
|
16
228
|
const program = new Command();
|
|
17
229
|
program.name("pipr").showHelpAfterError();
|
|
18
|
-
program.
|
|
230
|
+
program.addHelpText("after", agentHelpText);
|
|
231
|
+
program.command("init").description("Create editable TypeScript config").option("--config-dir <dir>", "Config directory", ".pipr").option("--adapters <adapters>", `Adapters to initialize (${supportedOfficialInitAdapters.join(", ")}; use 'none' to skip adapter files)`).option("--recipe <recipe>", `Starter recipe (${supportedOfficialInitRecipes.join(", ")})`).option("--minimal", "Scaffold a single-file .pipr/config.ts without package.json").option("--force", "Overwrite existing pipr files").action(runInit);
|
|
19
232
|
program.command("action").description("Run inside GitHub Docker Action").option("--config-dir <dir>", "Config directory", ".pipr").action(runAction);
|
|
20
233
|
program.command("check").description("Type-load config and validate the runtime plan").option("--config-dir <dir>", "Config directory", ".pipr").option("--require-env", "Require configured provider env vars").action(runCheck);
|
|
21
234
|
program.command("dry-run").description("Load config and event without publishing").requiredOption("--event <path>", "GitHub event JSON path").option("--config-dir <dir>", "Config directory", ".pipr").action(runDryRun);
|
|
22
235
|
program.command("inspect").description("Print models, agents, tasks, commands, and tools").option("--config-dir <dir>", "Config directory", ".pipr").action(runInspect);
|
|
23
236
|
program.command("review").description("Run configured change-request review tasks locally without publishing").option("--base <sha>", "Base commit SHA").option("--head <sha>", "Head commit SHA or ref; omitted reviews the working tree").option("--config-dir <dir>", "Config directory", ".pipr").option("--pi-executable <path>", "Pi executable path").option("--json", "Print structured JSON output").action(runLocalReview);
|
|
237
|
+
program.command("skill").description("Print the bundled Pipr setup skill").action(runSkillGet).command("path").description("Materialize the bundled Pipr setup skill and print its directory path").action(runSkillPath);
|
|
24
238
|
return program;
|
|
25
239
|
}
|
|
240
|
+
const agentHelpText = `
|
|
241
|
+
|
|
242
|
+
Start here (for AI agents):
|
|
243
|
+
pipr skill
|
|
244
|
+
|
|
245
|
+
The Pipr setup skill ships with the CLI and is version-matched to this release.
|
|
246
|
+
Prefer it over guessing commands or config shape from memory.
|
|
247
|
+
|
|
248
|
+
skill Print the bundled setup skill and references
|
|
249
|
+
skill path Materialize the setup skill and print its directory path
|
|
250
|
+
`;
|
|
26
251
|
async function runAction(options) {
|
|
27
252
|
writeActionResult(await runActionCommand(actionOptions(options)));
|
|
28
253
|
}
|
|
@@ -39,25 +264,28 @@ function actionOptions(options) {
|
|
|
39
264
|
};
|
|
40
265
|
}
|
|
41
266
|
const githubActionsLogSink = {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
},
|
|
45
|
-
notice(message) {
|
|
46
|
-
core.notice(message);
|
|
47
|
-
},
|
|
48
|
-
warning(message) {
|
|
49
|
-
core.warning(message);
|
|
50
|
-
},
|
|
51
|
-
error(message) {
|
|
52
|
-
core.error(message);
|
|
53
|
-
},
|
|
54
|
-
debug(message) {
|
|
55
|
-
core.debug(message);
|
|
267
|
+
log(record) {
|
|
268
|
+
githubActionLogWriters[record.level](formatGitHubActionLogRecord(record));
|
|
56
269
|
},
|
|
57
270
|
async group(name, run) {
|
|
58
271
|
return await core.group(name, run);
|
|
59
272
|
}
|
|
60
273
|
};
|
|
274
|
+
const githubActionLogWriters = {
|
|
275
|
+
info: core.info,
|
|
276
|
+
notice: core.notice,
|
|
277
|
+
warning: core.warning,
|
|
278
|
+
error: core.error,
|
|
279
|
+
debug: core.debug
|
|
280
|
+
};
|
|
281
|
+
function formatGitHubActionLogRecord(record) {
|
|
282
|
+
const line = JSON.stringify({
|
|
283
|
+
level: record.level,
|
|
284
|
+
event: record.event,
|
|
285
|
+
...record.fields
|
|
286
|
+
});
|
|
287
|
+
return record.text === void 0 ? line : `${line}\n${record.text}`;
|
|
288
|
+
}
|
|
61
289
|
function writeActionResult(result) {
|
|
62
290
|
if (result.kind === "ignored") {
|
|
63
291
|
core.info(`pipr ignored event: ${result.reason}`);
|
|
@@ -65,35 +293,43 @@ function writeActionResult(result) {
|
|
|
65
293
|
}
|
|
66
294
|
writeLoadedActionResult(result);
|
|
67
295
|
}
|
|
68
|
-
const loadedActionResultWriters = {
|
|
69
|
-
"command-help": (result) => {
|
|
70
|
-
assertLoadedActionKind(result, "command-help");
|
|
71
|
-
writeCommandHelpActionResult(result);
|
|
72
|
-
},
|
|
73
|
-
"command-response": (result) => {
|
|
74
|
-
assertLoadedActionKind(result, "command-response");
|
|
75
|
-
writeCommandResponseActionResult(result);
|
|
76
|
-
},
|
|
77
|
-
"dry-run": (result) => {
|
|
78
|
-
assertLoadedActionKind(result, "dry-run");
|
|
79
|
-
writeDryRunActionResult(result);
|
|
80
|
-
},
|
|
81
|
-
review: (result) => {
|
|
82
|
-
assertLoadedActionKind(result, "review");
|
|
83
|
-
writeReviewActionResult(result);
|
|
84
|
-
},
|
|
85
|
-
verifier: (result) => {
|
|
86
|
-
assertLoadedActionKind(result, "verifier");
|
|
87
|
-
writeVerifierActionResult(result);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
296
|
function writeLoadedActionResult(result) {
|
|
91
297
|
core.info(`pipr loaded change #${result.event.change.number} for ${result.event.repository.slug}`);
|
|
92
298
|
core.info(`pipr config source: ${result.configSource}`);
|
|
93
|
-
|
|
299
|
+
if (result.kind === "dry-run") {
|
|
300
|
+
writeDryRunActionResult(result);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
writePublishedActionResult(result);
|
|
304
|
+
}
|
|
305
|
+
function writePublishedActionResult(result) {
|
|
306
|
+
if (result.kind === "command-help" || result.kind === "command-response") {
|
|
307
|
+
writeCommandActionResult(result);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
writeReviewWorkflowActionResult(result);
|
|
311
|
+
}
|
|
312
|
+
function writeCommandActionResult(result) {
|
|
313
|
+
switch (result.kind) {
|
|
314
|
+
case "command-help":
|
|
315
|
+
writeCommandHelpActionResult(result);
|
|
316
|
+
break;
|
|
317
|
+
case "command-response":
|
|
318
|
+
writeCommandResponseActionResult(result);
|
|
319
|
+
break;
|
|
320
|
+
default:
|
|
321
|
+
}
|
|
94
322
|
}
|
|
95
|
-
function
|
|
96
|
-
|
|
323
|
+
function writeReviewWorkflowActionResult(result) {
|
|
324
|
+
switch (result.kind) {
|
|
325
|
+
case "review":
|
|
326
|
+
writeReviewActionResult(result);
|
|
327
|
+
break;
|
|
328
|
+
case "verifier":
|
|
329
|
+
writeVerifierActionResult(result);
|
|
330
|
+
break;
|
|
331
|
+
default:
|
|
332
|
+
}
|
|
97
333
|
}
|
|
98
334
|
function writeDryRunActionResult(result) {
|
|
99
335
|
core.info("PIPR_DRY_RUN=1; stopping before review runtime, model, or GitHub publishing calls");
|
|
@@ -126,39 +362,16 @@ function warnInlineResolutionErrors(errors) {
|
|
|
126
362
|
for (const error of errors) core.warning(`pipr inline resolution failed: ${error}`);
|
|
127
363
|
}
|
|
128
364
|
async function runInit(options) {
|
|
129
|
-
const typeSupport = initTypeSupportMode(options);
|
|
130
365
|
const result = await runInitCommand({
|
|
131
366
|
rootDir: process.cwd(),
|
|
132
367
|
configDir: options.configDir,
|
|
133
368
|
force: options.force === true,
|
|
134
369
|
adapters: parseInitAdapters(options.adapters),
|
|
135
370
|
recipe: options.recipe,
|
|
136
|
-
|
|
371
|
+
minimal: options.minimal === true
|
|
137
372
|
});
|
|
138
373
|
console.log(`created ${result.created.length} file(s)` + (result.overwritten.length > 0 ? `; overwrote ${result.overwritten.length}` : ""));
|
|
139
|
-
|
|
140
|
-
function initTypeSupportMode(options) {
|
|
141
|
-
const invalidMessage = invalidTypeSupportMessage(options);
|
|
142
|
-
if (invalidMessage) throw new Error(invalidMessage);
|
|
143
|
-
if (options.typesOnly === true) return "only";
|
|
144
|
-
return options.types === false ? "skip" : "include";
|
|
145
|
-
}
|
|
146
|
-
const invalidTypeSupportRules = [
|
|
147
|
-
{
|
|
148
|
-
matches: (options) => options.typesOnly === true && options.types === false,
|
|
149
|
-
message: "--types-only cannot be combined with --no-types"
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
matches: (options) => options.typesOnly === true && options.recipe !== void 0,
|
|
153
|
-
message: "--types-only cannot be combined with --recipe"
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
matches: (options) => options.typesOnly === true && options.adapters !== void 0,
|
|
157
|
-
message: "--types-only cannot be combined with --adapters"
|
|
158
|
-
}
|
|
159
|
-
];
|
|
160
|
-
function invalidTypeSupportMessage(options) {
|
|
161
|
-
return invalidTypeSupportRules.find((rule) => rule.matches(options))?.message;
|
|
374
|
+
if (options.minimal === true) console.log("For editor types, install @usepipr/sdk at the repo root: npm install -D @usepipr/sdk");
|
|
162
375
|
}
|
|
163
376
|
function parseInitAdapters(adapters) {
|
|
164
377
|
return adapters?.split(",").map((adapter) => adapter.trim());
|
|
@@ -184,6 +397,12 @@ async function runInspect(options) {
|
|
|
184
397
|
colors: false
|
|
185
398
|
}));
|
|
186
399
|
}
|
|
400
|
+
async function runSkillGet() {
|
|
401
|
+
console.log(formatBundledSkill(await resolveBundledSkill()));
|
|
402
|
+
}
|
|
403
|
+
async function runSkillPath() {
|
|
404
|
+
console.log(await materializeBundledSkill());
|
|
405
|
+
}
|
|
187
406
|
async function runLocalReview(options) {
|
|
188
407
|
if (!options.base) throw new Error("pipr review requires --base <sha>");
|
|
189
408
|
writeLocalReviewResult(await runLocalReviewCommand({
|
|
@@ -209,50 +428,25 @@ const stderrTaskLog = {
|
|
|
209
428
|
}
|
|
210
429
|
};
|
|
211
430
|
const localConsoleLogSink = {
|
|
212
|
-
|
|
213
|
-
console.error(
|
|
214
|
-
},
|
|
215
|
-
notice(message) {
|
|
216
|
-
console.error(formatLocalLogMessage(message));
|
|
217
|
-
},
|
|
218
|
-
warning(message) {
|
|
219
|
-
console.error(formatLocalLogMessage(message));
|
|
220
|
-
},
|
|
221
|
-
error(message) {
|
|
222
|
-
console.error(formatLocalLogMessage(message));
|
|
223
|
-
},
|
|
224
|
-
debug(message) {
|
|
225
|
-
console.error(formatLocalLogMessage(message));
|
|
431
|
+
log(record) {
|
|
432
|
+
console.error(formatLocalLogRecord(record));
|
|
226
433
|
},
|
|
227
434
|
async group(_name, run) {
|
|
228
435
|
return await run();
|
|
229
436
|
}
|
|
230
437
|
};
|
|
231
|
-
function
|
|
232
|
-
const [
|
|
233
|
-
const
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
return rest.length === 0 ? formatted : [formatted, ...rest].join("\n");
|
|
238
|
-
}
|
|
239
|
-
function formatLocalLogPrefix(data) {
|
|
240
|
-
const level = typeof data.level === "string" ? data.level : "";
|
|
241
|
-
const event = typeof data.event === "string" ? data.event : "";
|
|
438
|
+
function formatLocalLogRecord(record) {
|
|
439
|
+
const fields = Object.entries(record.fields).map(([key, value]) => formatLocalLogField(key, value)).filter((field) => field !== void 0);
|
|
440
|
+
const formatted = [...formatLocalLogPrefix(record), ...fields].join(" ");
|
|
441
|
+
return record.text === void 0 ? formatted : `${formatted}\n${record.text}`;
|
|
442
|
+
}
|
|
443
|
+
function formatLocalLogPrefix(record) {
|
|
242
444
|
return [
|
|
243
445
|
"pipr",
|
|
244
|
-
localLogPlainLevels.has(level) ? "" : level,
|
|
245
|
-
event
|
|
446
|
+
localLogPlainLevels.has(record.level) ? "" : record.level,
|
|
447
|
+
record.event
|
|
246
448
|
].filter(Boolean);
|
|
247
449
|
}
|
|
248
|
-
function parseLocalLogLine(line) {
|
|
249
|
-
if (!line?.startsWith("{")) return;
|
|
250
|
-
try {
|
|
251
|
-
return JSON.parse(line);
|
|
252
|
-
} catch {
|
|
253
|
-
return;
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
450
|
const localLogNumberFields = {
|
|
257
451
|
additions: (value) => `+${value}`,
|
|
258
452
|
deletions: (value) => `-${value}`,
|
|
@@ -261,10 +455,9 @@ const localLogNumberFields = {
|
|
|
261
455
|
stderrBytes: (value) => `stderr=${value}B`,
|
|
262
456
|
stdoutBytes: (value) => `stdout=${value}B`
|
|
263
457
|
};
|
|
264
|
-
const localLogHiddenFields = new Set(["level", "event"]);
|
|
265
458
|
const localLogPlainLevels = new Set(["info", "notice"]);
|
|
266
459
|
function formatLocalLogField(key, value) {
|
|
267
|
-
if (
|
|
460
|
+
if (value == null) return;
|
|
268
461
|
return formatLocalLogFieldValue(key, value);
|
|
269
462
|
}
|
|
270
463
|
function formatLocalLogFieldValue(key, value) {
|
|
@@ -315,19 +508,9 @@ function stripMainCommentMarker(comment) {
|
|
|
315
508
|
return comment.split("\n").filter((line) => !line.startsWith("<!-- pipr:main-comment ")).join("\n").trimStart();
|
|
316
509
|
}
|
|
317
510
|
function localReviewJson(result) {
|
|
318
|
-
if (result.kind === "skipped") return {
|
|
319
|
-
kind: result.kind,
|
|
320
|
-
skipReason: result.skipReason,
|
|
321
|
-
mainComment: result.mainComment,
|
|
322
|
-
inlineFindings: result.inlineCommentDrafts,
|
|
323
|
-
droppedFindings: result.validated.droppedFindings,
|
|
324
|
-
taskChecks: result.taskChecks,
|
|
325
|
-
provider: result.provider,
|
|
326
|
-
providerModels: result.publicationPlan.metadata.providerModels ?? [result.provider.model],
|
|
327
|
-
repairAttempted: result.repairAttempted
|
|
328
|
-
};
|
|
329
511
|
return {
|
|
330
512
|
kind: result.kind,
|
|
513
|
+
...result.kind === "skipped" ? { skipReason: result.skipReason } : {},
|
|
331
514
|
mainComment: result.mainComment,
|
|
332
515
|
inlineFindings: result.inlineCommentDrafts,
|
|
333
516
|
droppedFindings: result.validated.droppedFindings,
|
package/dist/main.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.mjs","names":[],"sources":["../src/main.ts"],"sourcesContent":["#!/usr/bin/env bun\nimport { inspect } from \"node:util\";\nimport * as core from \"@actions/core\";\nimport {\n type ActionCommandResult,\n type ActionLogSink,\n type InitTypeSupportMode,\n PublicationError,\n runActionCommand,\n runDryRunCommand,\n runInitCommand,\n runInspectCommand,\n runLocalReviewCommand,\n runValidateCommand,\n supportedOfficialInitAdapters,\n supportedOfficialInitRecipes,\n} from \"@usepipr/runtime\";\nimport { Command } from \"commander\";\n\ntype ActionOptions = Parameters<typeof runActionCommand>[0];\n\ntype CliOptions = {\n configDir: string;\n event?: string;\n force?: boolean;\n adapters?: string;\n recipe?: string;\n types?: boolean;\n typesOnly?: boolean;\n requireEnv?: boolean;\n base?: string;\n head?: string;\n piExecutable?: string;\n json?: boolean;\n};\n\nasync function main(): Promise<void> {\n const program = createProgram();\n if (process.argv.length <= 2) {\n program.outputHelp();\n return;\n }\n await program.parseAsync(process.argv);\n}\n\nfunction createProgram(): Command {\n const program = new Command();\n program.name(\"pipr\").showHelpAfterError();\n\n program\n .command(\"init\")\n .description(\"Create editable TypeScript config\")\n .option(\"--config-dir <dir>\", \"Config directory\", \".pipr\")\n .option(\n \"--adapters <adapters>\",\n `Adapters to initialize (${supportedOfficialInitAdapters.join(\", \")}; use 'none' to skip adapter files)`,\n )\n .option(\"--recipe <recipe>\", `Starter recipe (${supportedOfficialInitRecipes.join(\", \")})`)\n .option(\"--no-types\", \"Skip local TypeScript support files\")\n .option(\"--types-only\", \"Add or refresh local TypeScript support files only\")\n .option(\"--force\", \"Overwrite existing pipr files\")\n .action(runInit);\n\n program\n .command(\"action\")\n .description(\"Run inside GitHub Docker Action\")\n .option(\"--config-dir <dir>\", \"Config directory\", \".pipr\")\n .action(runAction);\n\n program\n .command(\"check\")\n .description(\"Type-load config and validate the runtime plan\")\n .option(\"--config-dir <dir>\", \"Config directory\", \".pipr\")\n .option(\"--require-env\", \"Require configured provider env vars\")\n .action(runCheck);\n\n program\n .command(\"dry-run\")\n .description(\"Load config and event without publishing\")\n .requiredOption(\"--event <path>\", \"GitHub event JSON path\")\n .option(\"--config-dir <dir>\", \"Config directory\", \".pipr\")\n .action(runDryRun);\n\n program\n .command(\"inspect\")\n .description(\"Print models, agents, tasks, commands, and tools\")\n .option(\"--config-dir <dir>\", \"Config directory\", \".pipr\")\n .action(runInspect);\n\n program\n .command(\"review\")\n .description(\"Run configured change-request review tasks locally without publishing\")\n .option(\"--base <sha>\", \"Base commit SHA\")\n .option(\"--head <sha>\", \"Head commit SHA or ref; omitted reviews the working tree\")\n .option(\"--config-dir <dir>\", \"Config directory\", \".pipr\")\n .option(\"--pi-executable <path>\", \"Pi executable path\")\n .option(\"--json\", \"Print structured JSON output\")\n .action(runLocalReview);\n\n return program;\n}\n\nasync function runAction(options: CliOptions): Promise<void> {\n writeActionResult(await runActionCommand(actionOptions(options)));\n}\n\nfunction actionOptions(options: CliOptions): ActionOptions {\n const eventPath = process.env.GITHUB_EVENT_PATH;\n if (!eventPath) {\n throw new Error(\"GITHUB_EVENT_PATH is required for pipr action\");\n }\n return {\n rootDir: process.env.GITHUB_WORKSPACE ?? process.cwd(),\n configDir: process.env[\"INPUT_CONFIG-DIR\"] || options.configDir,\n env: process.env,\n eventPath,\n dryRun: process.env.PIPR_DRY_RUN === \"1\",\n logSink: githubActionsLogSink,\n };\n}\n\nconst githubActionsLogSink: ActionLogSink = {\n info(message) {\n core.info(message);\n },\n notice(message) {\n core.notice(message);\n },\n warning(message) {\n core.warning(message);\n },\n error(message) {\n core.error(message);\n },\n debug(message) {\n core.debug(message);\n },\n async group(name, run) {\n return await core.group(name, run);\n },\n};\n\nfunction writeActionResult(result: ActionCommandResult): void {\n if (result.kind === \"ignored\") {\n core.info(`pipr ignored event: ${result.reason}`);\n return;\n }\n writeLoadedActionResult(result);\n}\n\ntype LoadedActionResult = Exclude<ActionCommandResult, { kind: \"ignored\" }>;\ntype LoadedActionResultWriter = (result: LoadedActionResult) => void;\n\nconst loadedActionResultWriters = {\n \"command-help\": (result) => {\n assertLoadedActionKind(result, \"command-help\");\n writeCommandHelpActionResult(result);\n },\n \"command-response\": (result) => {\n assertLoadedActionKind(result, \"command-response\");\n writeCommandResponseActionResult(result);\n },\n \"dry-run\": (result) => {\n assertLoadedActionKind(result, \"dry-run\");\n writeDryRunActionResult(result);\n },\n review: (result) => {\n assertLoadedActionKind(result, \"review\");\n writeReviewActionResult(result);\n },\n verifier: (result) => {\n assertLoadedActionKind(result, \"verifier\");\n writeVerifierActionResult(result);\n },\n} satisfies Record<LoadedActionResult[\"kind\"], LoadedActionResultWriter>;\n\nfunction writeLoadedActionResult(result: LoadedActionResult): void {\n core.info(\n `pipr loaded change #${result.event.change.number} for ${result.event.repository.slug}`,\n );\n core.info(`pipr config source: ${result.configSource}`);\n loadedActionResultWriters[result.kind](result);\n}\n\nfunction assertLoadedActionKind<K extends LoadedActionResult[\"kind\"]>(\n result: LoadedActionResult,\n kind: K,\n): asserts result is Extract<LoadedActionResult, { kind: K }> {\n if (result.kind !== kind) {\n throw new Error(`Expected '${kind}' action result, got '${result.kind}'`);\n }\n}\n\nfunction writeDryRunActionResult(result: Extract<ActionCommandResult, { kind: \"dry-run\" }>): void {\n void result;\n core.info(\"PIPR_DRY_RUN=1; stopping before review runtime, model, or GitHub publishing calls\");\n}\n\nfunction writeCommandHelpActionResult(\n result: Extract<ActionCommandResult, { kind: \"command-help\" }>,\n): void {\n core.info(`pipr command help: ${result.reason}`);\n core.setOutput(\"main-comment\", result.body);\n}\n\nfunction writeCommandResponseActionResult(\n result: Extract<ActionCommandResult, { kind: \"command-response\" }>,\n): void {\n core.info(\n `pipr command '${result.command}' published response comment (${result.publication.action})`,\n );\n core.setOutput(\"main-comment\", result.response.body);\n core.setOutput(\"publication\", JSON.stringify(result.publication));\n}\n\nfunction writeVerifierActionResult(\n result: Extract<ActionCommandResult, { kind: \"verifier\" }>,\n): void {\n core.info(\n `pipr verifier processed review comment reply with ${result.errors.length} publication error(s)`,\n );\n warnInlineResolutionErrors(result.errors);\n core.setOutput(\"publication\", JSON.stringify({ inlineResolutionErrors: result.errors }));\n}\n\nfunction writeReviewActionResult(result: Extract<ActionCommandResult, { kind: \"review\" }>): void {\n core.info(\n `pipr review produced ${result.review.validated.validFindings.length} valid inline finding(s), ` +\n `${result.review.validated.droppedFindings.length} dropped finding(s)`,\n );\n core.info(\n `pipr published main comment (${result.publication.mainComment.action}) and ` +\n `${result.publication.inlineComments.posted} inline comment(s); ` +\n `${result.publication.inlineComments.skipped} skipped`,\n );\n warnInlineResolutionErrors(result.publication.metadata.inlineResolutionErrors);\n if (result.review.repairAttempted) {\n core.info(\"pipr repaired reviewer JSON once before validation\");\n }\n core.setOutput(\"main-comment\", result.review.mainComment);\n core.setOutput(\"inline-comments\", JSON.stringify(result.review.inlineCommentDrafts));\n core.setOutput(\"dropped-findings\", JSON.stringify(result.review.validated.droppedFindings));\n core.setOutput(\"publication\", JSON.stringify(result.publication));\n}\n\nfunction warnInlineResolutionErrors(errors: string[]): void {\n for (const error of errors) {\n core.warning(`pipr inline resolution failed: ${error}`);\n }\n}\n\nasync function runInit(options: CliOptions): Promise<void> {\n const typeSupport = initTypeSupportMode(options);\n const result = await runInitCommand({\n rootDir: process.cwd(),\n configDir: options.configDir,\n force: options.force === true,\n adapters: parseInitAdapters(options.adapters),\n recipe: options.recipe,\n typeSupport,\n });\n console.log(\n `created ${result.created.length} file(s)` +\n (result.overwritten.length > 0 ? `; overwrote ${result.overwritten.length}` : \"\"),\n );\n}\n\nfunction initTypeSupportMode(options: CliOptions): InitTypeSupportMode {\n const invalidMessage = invalidTypeSupportMessage(options);\n if (invalidMessage) {\n throw new Error(invalidMessage);\n }\n if (options.typesOnly === true) {\n return \"only\";\n }\n return options.types === false ? \"skip\" : \"include\";\n}\n\nconst invalidTypeSupportRules: Array<{\n matches(options: CliOptions): boolean;\n message: string;\n}> = [\n {\n matches: (options) => options.typesOnly === true && options.types === false,\n message: \"--types-only cannot be combined with --no-types\",\n },\n {\n matches: (options) => options.typesOnly === true && options.recipe !== undefined,\n message: \"--types-only cannot be combined with --recipe\",\n },\n {\n matches: (options) => options.typesOnly === true && options.adapters !== undefined,\n message: \"--types-only cannot be combined with --adapters\",\n },\n];\n\nfunction invalidTypeSupportMessage(options: CliOptions): string | undefined {\n return invalidTypeSupportRules.find((rule) => rule.matches(options))?.message;\n}\n\nfunction parseInitAdapters(adapters: string | undefined): string[] | undefined {\n return adapters?.split(\",\").map((adapter) => adapter.trim());\n}\n\nasync function runCheck(options: CliOptions): Promise<void> {\n const settings = await runValidateCommand({\n rootDir: process.cwd(),\n configDir: options.configDir,\n env: process.env,\n requireProviderEnv: options.requireEnv === true,\n });\n console.log(`valid: ${settings.source}`);\n for (const warning of settings.warnings) {\n console.log(`warning: ${warning}`);\n }\n}\n\nasync function runInspect(options: CliOptions): Promise<void> {\n const result = await runInspectCommand({\n rootDir: process.cwd(),\n configDir: options.configDir,\n env: process.env,\n });\n console.log(inspect(result, { depth: 8, colors: false }));\n}\n\nasync function runLocalReview(options: CliOptions): Promise<void> {\n if (!options.base) {\n throw new Error(\"pipr review requires --base <sha>\");\n }\n const result = await runLocalReviewCommand({\n rootDir: process.cwd(),\n configDir: options.configDir,\n env: process.env,\n baseSha: options.base,\n headSha: options.head,\n piExecutable: options.piExecutable,\n logSink: localConsoleLogSink,\n taskLog: stderrTaskLog,\n });\n writeLocalReviewResult(result, options.json === true);\n}\n\ntype LocalReviewResult = Awaited<ReturnType<typeof runLocalReviewCommand>>;\n\nconst stderrTaskLog = {\n info(message: string) {\n console.error(`[info] ${message}`);\n },\n warn(message: string) {\n console.error(`[warn] ${message}`);\n },\n error(message: string) {\n console.error(`[error] ${message}`);\n },\n};\n\nconst localConsoleLogSink: ActionLogSink = {\n info(message) {\n console.error(formatLocalLogMessage(message));\n },\n notice(message) {\n console.error(formatLocalLogMessage(message));\n },\n warning(message) {\n console.error(formatLocalLogMessage(message));\n },\n error(message) {\n console.error(formatLocalLogMessage(message));\n },\n debug(message) {\n console.error(formatLocalLogMessage(message));\n },\n async group(_name, run) {\n return await run();\n },\n};\n\nfunction formatLocalLogMessage(message: string): string {\n const [firstLine, ...rest] = message.split(\"\\n\");\n const data = parseLocalLogLine(firstLine);\n if (!data) {\n return message;\n }\n\n const fields = Object.entries(data)\n .map(([key, value]) => formatLocalLogField(key, value))\n .filter((field): field is string => field !== undefined);\n const prefix = formatLocalLogPrefix(data);\n const formatted = [...prefix, ...fields].join(\" \");\n return rest.length === 0 ? formatted : [formatted, ...rest].join(\"\\n\");\n}\n\nfunction formatLocalLogPrefix(data: Record<string, unknown>): string[] {\n const level = typeof data.level === \"string\" ? data.level : \"\";\n const event = typeof data.event === \"string\" ? data.event : \"\";\n return [\"pipr\", localLogPlainLevels.has(level) ? \"\" : level, event].filter(Boolean);\n}\n\nfunction parseLocalLogLine(line: string | undefined): Record<string, unknown> | undefined {\n if (!line?.startsWith(\"{\")) {\n return undefined;\n }\n try {\n return JSON.parse(line) as Record<string, unknown>;\n } catch {\n return undefined;\n }\n}\n\nconst localLogNumberFields: Record<string, (value: number) => string> = {\n additions: (value) => `+${value}`,\n deletions: (value) => `-${value}`,\n durationMs: (value) =>\n `duration=${value < 1000 ? `${value}ms` : `${(value / 1000).toFixed(1)}s`}`,\n promptBytes: (value) => `prompt=${value}B`,\n stderrBytes: (value) => `stderr=${value}B`,\n stdoutBytes: (value) => `stdout=${value}B`,\n};\n\nconst localLogHiddenFields = new Set([\"level\", \"event\"]);\nconst localLogPlainLevels = new Set([\"info\", \"notice\"]);\n\nfunction formatLocalLogField(key: string, value: unknown): string | undefined {\n if (localLogHiddenFields.has(key) || value == null) {\n return undefined;\n }\n\n return formatLocalLogFieldValue(key, value);\n}\n\nfunction formatLocalLogFieldValue(key: string, value: unknown): string {\n const formattedNumber =\n typeof value === \"number\" ? localLogNumberFields[key]?.(value) : undefined;\n return formattedNumber ?? `${key}=${formatLocalLogValue(value)}`;\n}\n\nconst localLogValueFormatters: Record<string, (value: unknown) => string> = {\n boolean: String,\n number: String,\n object: (value) =>\n Array.isArray(value)\n ? value.length === 0\n ? \"-\"\n : value.map(formatLocalLogValue).join(\",\")\n : JSON.stringify(value),\n string: (value) => {\n const text = String(value);\n return /\\s/.test(text) ? JSON.stringify(text) : text;\n },\n};\n\nfunction formatLocalLogValue(value: unknown): string {\n return (localLogValueFormatters[typeof value] ?? JSON.stringify)(value);\n}\n\nfunction writeLocalReviewResult(result: LocalReviewResult, json: boolean): void {\n if (json) {\n console.log(JSON.stringify(localReviewJson(result), null, 2));\n return;\n }\n if (result.kind === \"skipped\") {\n console.log(`skipped: ${result.skipReason ?? \"no task matched\"}`);\n return;\n }\n console.log(formatLocalReview(result));\n}\n\nfunction formatLocalReview(result: Extract<LocalReviewResult, { kind: \"review\" }>): string {\n const mainComment = stripMainCommentMarker(result.mainComment);\n const inlineFindings = result.inlineCommentDrafts.map((draft, index) => {\n const range =\n draft.startLine === draft.endLine\n ? `${draft.path}:${draft.startLine}`\n : `${draft.path}:${draft.startLine}-${draft.endLine}`;\n return [\n `${index + 1}. ${range}`,\n `Range: ${draft.finding.rangeId ?? \"-\"}`,\n draft.finding.body,\n ].join(\"\\n\");\n });\n return inlineFindings.length === 0\n ? mainComment\n : [mainComment.trimEnd(), \"\", \"## Inline Findings\", \"\", inlineFindings.join(\"\\n\\n\")].join(\"\\n\");\n}\n\nfunction stripMainCommentMarker(comment: string): string {\n return comment\n .split(\"\\n\")\n .filter((line) => !line.startsWith(\"<!-- pipr:main-comment \"))\n .join(\"\\n\")\n .trimStart();\n}\n\nfunction localReviewJson(result: LocalReviewResult) {\n if (result.kind === \"skipped\") {\n return {\n kind: result.kind,\n skipReason: result.skipReason,\n mainComment: result.mainComment,\n inlineFindings: result.inlineCommentDrafts,\n droppedFindings: result.validated.droppedFindings,\n taskChecks: result.taskChecks,\n provider: result.provider,\n providerModels: result.publicationPlan.metadata.providerModels ?? [result.provider.model],\n repairAttempted: result.repairAttempted,\n };\n }\n return {\n kind: result.kind,\n mainComment: result.mainComment,\n inlineFindings: result.inlineCommentDrafts,\n droppedFindings: result.validated.droppedFindings,\n taskChecks: result.taskChecks,\n provider: result.provider,\n providerModels: result.publicationPlan.metadata.providerModels ?? [result.provider.model],\n repairAttempted: result.repairAttempted,\n };\n}\n\nasync function runDryRun(options: CliOptions): Promise<void> {\n if (!options.event) {\n throw new Error(\"dry-run requires --event <path>\");\n }\n const result = await runDryRunCommand({\n rootDir: process.cwd(),\n configDir: options.configDir,\n env: process.env,\n eventPath: options.event,\n });\n console.log(\n inspect(\n {\n configSource: result.configSource,\n event: result.event,\n },\n { depth: 6, colors: false },\n ),\n );\n}\n\nmain().catch((error: unknown) => {\n if (error instanceof PublicationError && error.result) {\n core.setOutput(\"publication\", JSON.stringify(error.result));\n core.error(`pipr publication metadata: ${JSON.stringify(error.result)}`);\n }\n const message = error instanceof Error ? error.message : String(error);\n core.setFailed(message);\n process.exitCode = 1;\n});\n"],"mappings":";;;;;;AAoCA,eAAe,OAAsB;CACnC,MAAM,UAAU,cAAc;CAC9B,IAAI,QAAQ,KAAK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;AAEA,eAAe,UAAU,SAAoC;CAC3D,IAAI,CAAC,QAAQ,OACX,MAAM,IAAI,MAAM,iCAAiC;CAEnD,MAAM,SAAS,MAAM,iBAAiB;EACpC,SAAS,QAAQ,IAAI;EACrB,WAAW,QAAQ;EACnB,KAAK,QAAQ;EACb,WAAW,QAAQ;CACrB,CAAC;CACD,QAAQ,IACN,QACE;EACE,cAAc,OAAO;EACrB,OAAO,OAAO;CAChB,GACA;EAAE,OAAO;EAAG,QAAQ;CAAM,CAC5B,CACF;AACF;AAEA,KAAK,CAAC,CAAC,OAAO,UAAmB;CAC/B,IAAI,iBAAiB,oBAAoB,MAAM,QAAQ;EACrD,KAAK,UAAU,eAAe,KAAK,UAAU,MAAM,MAAM,CAAC;EAC1D,KAAK,MAAM,8BAA8B,KAAK,UAAU,MAAM,MAAM,GAAG;CACzE;CACA,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CACrE,KAAK,UAAU,OAAO;CACtB,QAAQ,WAAW;AACrB,CAAC"}
|
|
1
|
+
{"version":3,"file":"main.mjs","names":["cliPackage.version"],"sources":["../package.json","../src/skill-catalog.ts","../src/skills.ts","../src/main.ts"],"sourcesContent":["","import { readdir } from \"node:fs/promises\";\nimport path from \"node:path\";\n\nexport const bundledSkillName = \"pipr-setup\";\nconst bundledSkillFilePaths = new Set([\n \"SKILL.md\",\n \"references/config-patterns.md\",\n \"references/recipes.md\",\n]);\n\nexport type BundledSkillFile = {\n path: string;\n contents: string;\n};\n\nexport type BundledSkill = {\n name: string;\n description: string;\n files: BundledSkillFile[];\n};\n\nexport type BundledSkillCatalog = {\n skills: BundledSkill[];\n};\n\nexport function singleBundledSkill(catalog: BundledSkillCatalog): BundledSkill {\n const [skill] = catalog.skills;\n if (catalog.skills.length !== 1 || skill?.name !== bundledSkillName) {\n throw new Error(\n `Expected exactly one bundled skill named '${bundledSkillName}', found: ${catalog.skills\n .map((item) => item.name)\n .join(\", \")}`,\n );\n }\n return skill;\n}\n\nexport function containedSkillFilePath(root: string, relativePath: string): string {\n if (path.isAbsolute(relativePath)) {\n throw new Error(`Bundled skill file path must be relative: ${relativePath}`);\n }\n const resolvedRoot = path.resolve(root);\n const target = path.resolve(resolvedRoot, relativePath);\n if (target !== resolvedRoot && !target.startsWith(`${resolvedRoot}${path.sep}`)) {\n throw new Error(`Bundled skill file path escapes the skill directory: ${relativePath}`);\n }\n return target;\n}\n\nexport async function readBundledSkillCatalog(skillsRoot: string): Promise<BundledSkillCatalog> {\n const entries = await readdir(skillsRoot, { withFileTypes: true });\n const skills = await Promise.all(\n entries\n .filter((entry) => entry.isDirectory())\n .map(async (entry) => {\n const skillDir = path.join(skillsRoot, entry.name);\n const files = await readSkillFiles(skillDir);\n validateBundledSkillFiles(entry.name, files);\n const skillMd = files.find((file) => file.path === \"SKILL.md\");\n if (!skillMd) {\n throw new Error(`${skillDir}: missing SKILL.md`);\n }\n return {\n name: entry.name,\n description: frontmatterDescription(skillMd.contents),\n files,\n };\n }),\n );\n const catalog = { skills: skills.sort((left, right) => left.name.localeCompare(right.name)) };\n singleBundledSkill(catalog);\n return catalog;\n}\n\nasync function readSkillFiles(skillDir: string, prefix = \"\"): Promise<BundledSkillFile[]> {\n const entries = await readdir(path.join(skillDir, prefix), { withFileTypes: true });\n const files = await Promise.all(\n entries\n .filter((entry) => !entry.name.startsWith(\".\"))\n .sort((left, right) => left.name.localeCompare(right.name))\n .map(async (entry) => {\n const relativePath = prefix ? path.join(prefix, entry.name) : entry.name;\n if (entry.isDirectory()) {\n return await readSkillFiles(skillDir, relativePath);\n }\n if (!entry.isFile()) {\n return [];\n }\n const contents = await Bun.file(path.join(skillDir, relativePath)).text();\n return [{ path: relativePath.split(path.sep).join(\"/\"), contents }];\n }),\n );\n return files.flat();\n}\n\nfunction frontmatterDescription(contents: string): string {\n const frontmatter = contents.match(/^---\\n(?<body>[\\s\\S]*?)\\n---/u)?.groups?.body;\n const description = frontmatter\n ?.split(\"\\n\")\n .find((line) => line.startsWith(\"description:\"))\n ?.replace(/^description:\\s*/u, \"\")\n .trim()\n .replace(/^[\"']|[\"']$/gu, \"\");\n if (!description) {\n throw new Error(\"Bundled skill SKILL.md is missing a description\");\n }\n return description;\n}\n\nfunction validateBundledSkillFiles(skillName: string, files: BundledSkillFile[]): void {\n if (skillName !== bundledSkillName) {\n return;\n }\n const found = new Set(files.map((file) => file.path));\n const unexpected = [...found].filter((filePath) => !bundledSkillFilePaths.has(filePath));\n const missing = [...bundledSkillFilePaths].filter((filePath) => !found.has(filePath));\n if (unexpected.length > 0 || missing.length > 0) {\n throw new Error(\n `${bundledSkillName} bundled files must match the release allowlist; ` +\n `unexpected: ${unexpected.join(\", \") || \"-\"}; missing: ${missing.join(\", \") || \"-\"}`,\n );\n }\n}\n","import { lstat, mkdir, mkdtemp, readdir, rename, rm } from \"node:fs/promises\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport cliPackage from \"../package.json\" with { type: \"json\" };\nimport {\n type BundledSkill,\n type BundledSkillCatalog,\n type BundledSkillFile,\n bundledSkillName,\n containedSkillFilePath,\n readBundledSkillCatalog,\n singleBundledSkill,\n} from \"./skill-catalog.js\";\n\ndeclare const PIPR_EMBEDDED_SKILLS: string | undefined;\n\nlet skillPromise: Promise<BundledSkill> | undefined;\n\ntype SkillCatalogAttempt =\n | { catalog: BundledSkillCatalog; skillsRoot: string }\n | { error: string; skillsRoot: string };\n\nexport async function resolveBundledSkill(): Promise<BundledSkill> {\n skillPromise ??= loadBundledSkill();\n return await skillPromise;\n}\n\nexport function formatBundledSkill(skill: BundledSkill): string {\n const files = [...skill.files].sort(compareSkillFiles);\n return [\n `# ${skill.name}`,\n \"\",\n skill.description,\n \"\",\n ...files.flatMap((file) => [\n `----- BEGIN SKILL FILE: ${file.path} -----`,\n file.contents.trimEnd(),\n `----- END SKILL FILE: ${file.path} -----`,\n \"\",\n ]),\n ].join(\"\\n\");\n}\n\nfunction compareSkillFiles(left: BundledSkillFile, right: BundledSkillFile): number {\n if (left.path === \"SKILL.md\") {\n return -1;\n }\n if (right.path === \"SKILL.md\") {\n return 1;\n }\n return left.path.localeCompare(right.path);\n}\n\nexport async function materializeBundledSkill(): Promise<string> {\n const skill = await resolveBundledSkill();\n const versionDir = path.join(skillCacheRoot(), cliPackage.version);\n const skillDir = path.join(versionDir, skill.name);\n await mkdir(versionDir, { recursive: true });\n const stagingDir = await mkdtemp(path.join(versionDir, `${bundledSkillName}-`));\n try {\n for (const file of skill.files) {\n await writeSkillFile(stagingDir, file);\n }\n if (await skillDirectoryMatches(skillDir, skill.files)) {\n await rm(stagingDir, { recursive: true, force: true });\n return skillDir;\n }\n await rm(skillDir, { recursive: true, force: true });\n await renameSkillDirectory(stagingDir, skillDir, skill.files);\n } catch (error) {\n await rm(stagingDir, { recursive: true, force: true });\n throw error;\n }\n return skillDir;\n}\n\nasync function loadBundledSkill(): Promise<BundledSkill> {\n const embedded = embeddedSkillCatalog();\n return singleBundledSkill(embedded ?? (await loadFilesystemSkillCatalog()));\n}\n\nasync function loadFilesystemSkillCatalog(): Promise<BundledSkillCatalog> {\n const attempts = await Promise.all(skillRootCandidates().map(readSkillCatalogAttempt));\n const loaded = attempts.find(\n (attempt): attempt is Extract<SkillCatalogAttempt, { catalog: BundledSkillCatalog }> =>\n \"catalog\" in attempt,\n );\n if (loaded) {\n return loaded.catalog;\n }\n throw new Error(\n `Unable to load bundled Pipr skills.\\n${attempts\n .map((attempt) => `${attempt.skillsRoot}: ${\"error\" in attempt ? attempt.error : \"loaded\"}`)\n .join(\"\\n\")}`,\n );\n}\n\nasync function readSkillCatalogAttempt(skillsRoot: string): Promise<SkillCatalogAttempt> {\n try {\n return { skillsRoot, catalog: await readBundledSkillCatalog(skillsRoot) };\n } catch (error) {\n return { skillsRoot, error: error instanceof Error ? error.message : String(error) };\n }\n}\n\nfunction embeddedSkillCatalog(): BundledSkillCatalog | undefined {\n if (typeof PIPR_EMBEDDED_SKILLS !== \"string\" || PIPR_EMBEDDED_SKILLS.length === 0) {\n return undefined;\n }\n return JSON.parse(PIPR_EMBEDDED_SKILLS) as BundledSkillCatalog;\n}\n\nfunction skillRootCandidates(): string[] {\n const here = import.meta.dirname;\n return [path.join(here, \"skills\"), path.resolve(here, \"../../../skills\")];\n}\n\nasync function writeSkillFile(skillDir: string, file: BundledSkillFile): Promise<void> {\n const target = containedSkillFilePath(skillDir, file.path);\n await mkdir(path.dirname(target), { recursive: true });\n await Bun.write(target, file.contents);\n}\n\nasync function renameSkillDirectory(\n stagingDir: string,\n skillDir: string,\n files: BundledSkillFile[],\n): Promise<void> {\n try {\n await rename(stagingDir, skillDir);\n } catch (error) {\n if (isExistingDirectoryError(error) && (await skillDirectoryMatches(skillDir, files))) {\n await rm(stagingDir, { recursive: true, force: true });\n return;\n }\n throw error;\n }\n}\n\nasync function skillDirectoryMatches(\n skillDir: string,\n files: BundledSkillFile[],\n): Promise<boolean> {\n try {\n return (\n (await skillDirectoryPathsMatch(skillDir, files)) &&\n (await skillDirectoryContentsMatch(skillDir, files))\n );\n } catch {\n return false;\n }\n}\n\nasync function skillDirectoryPathsMatch(\n skillDir: string,\n files: BundledSkillFile[],\n): Promise<boolean> {\n return samePaths(\n await listSkillDirectoryEntries(skillDir),\n files.map((file) => file.path).sort(),\n );\n}\n\nasync function skillDirectoryContentsMatch(\n skillDir: string,\n files: BundledSkillFile[],\n): Promise<boolean> {\n for (const file of files) {\n if (!(await skillFileMatches(skillDir, file))) {\n return false;\n }\n }\n return true;\n}\n\nasync function skillFileMatches(skillDir: string, file: BundledSkillFile): Promise<boolean> {\n const target = containedSkillFilePath(skillDir, file.path);\n return (await lstat(target)).isFile() && (await Bun.file(target).text()) === file.contents;\n}\n\nasync function listSkillDirectoryEntries(skillDir: string, prefix = \"\"): Promise<string[]> {\n const entries = await readdir(path.join(skillDir, prefix), { withFileTypes: true });\n const paths = await Promise.all(\n entries\n .filter((entry) => !entry.name.startsWith(\".\"))\n .map(async (entry) => {\n const relativePath = prefix ? path.join(prefix, entry.name) : entry.name;\n if (entry.isDirectory()) {\n return await listSkillDirectoryEntries(skillDir, relativePath);\n }\n return [relativePath.split(path.sep).join(\"/\")];\n }),\n );\n return paths.flat().sort();\n}\n\nfunction samePaths(left: string[], right: string[]): boolean {\n return left.length === right.length && left.every((value, index) => value === right[index]);\n}\n\nconst existingDirectoryErrorCodes = new Set([\"EEXIST\", \"ENOTEMPTY\"]);\n\nfunction isExistingDirectoryError(error: unknown): boolean {\n return existingDirectoryErrorCodes.has((error as { code?: string } | undefined)?.code ?? \"\");\n}\n\nfunction skillCacheRoot(): string {\n const override = process.env.PIPR_SKILL_CACHE_DIR;\n if (override && override.trim().length > 0) {\n return path.resolve(override);\n }\n const cacheHome = process.env.XDG_CACHE_HOME || path.join(os.homedir(), \".cache\");\n return path.join(cacheHome, \"pipr\", \"skills\");\n}\n","#!/usr/bin/env bun\nimport { inspect } from \"node:util\";\nimport * as core from \"@actions/core\";\nimport {\n type ActionCommandResult,\n type ActionLogRecord,\n type ActionLogSink,\n PublicationError,\n runActionCommand,\n runDryRunCommand,\n runInitCommand,\n runInspectCommand,\n runLocalReviewCommand,\n runValidateCommand,\n supportedOfficialInitAdapters,\n supportedOfficialInitRecipes,\n} from \"@usepipr/runtime\";\nimport { Command } from \"commander\";\nimport { formatBundledSkill, materializeBundledSkill, resolveBundledSkill } from \"./skills.js\";\n\ntype ActionOptions = Parameters<typeof runActionCommand>[0];\n\ntype CliOptions = {\n configDir: string;\n event?: string;\n force?: boolean;\n adapters?: string;\n recipe?: string;\n minimal?: boolean;\n requireEnv?: boolean;\n base?: string;\n head?: string;\n piExecutable?: string;\n json?: boolean;\n};\n\nasync function main(): Promise<void> {\n const program = createProgram();\n if (process.argv.length <= 2) {\n program.outputHelp();\n return;\n }\n await program.parseAsync(process.argv);\n}\n\nfunction createProgram(): Command {\n const program = new Command();\n program.name(\"pipr\").showHelpAfterError();\n program.addHelpText(\"after\", agentHelpText);\n\n program\n .command(\"init\")\n .description(\"Create editable TypeScript config\")\n .option(\"--config-dir <dir>\", \"Config directory\", \".pipr\")\n .option(\n \"--adapters <adapters>\",\n `Adapters to initialize (${supportedOfficialInitAdapters.join(\", \")}; use 'none' to skip adapter files)`,\n )\n .option(\"--recipe <recipe>\", `Starter recipe (${supportedOfficialInitRecipes.join(\", \")})`)\n .option(\"--minimal\", \"Scaffold a single-file .pipr/config.ts without package.json\")\n .option(\"--force\", \"Overwrite existing pipr files\")\n .action(runInit);\n\n program\n .command(\"action\")\n .description(\"Run inside GitHub Docker Action\")\n .option(\"--config-dir <dir>\", \"Config directory\", \".pipr\")\n .action(runAction);\n\n program\n .command(\"check\")\n .description(\"Type-load config and validate the runtime plan\")\n .option(\"--config-dir <dir>\", \"Config directory\", \".pipr\")\n .option(\"--require-env\", \"Require configured provider env vars\")\n .action(runCheck);\n\n program\n .command(\"dry-run\")\n .description(\"Load config and event without publishing\")\n .requiredOption(\"--event <path>\", \"GitHub event JSON path\")\n .option(\"--config-dir <dir>\", \"Config directory\", \".pipr\")\n .action(runDryRun);\n\n program\n .command(\"inspect\")\n .description(\"Print models, agents, tasks, commands, and tools\")\n .option(\"--config-dir <dir>\", \"Config directory\", \".pipr\")\n .action(runInspect);\n\n program\n .command(\"review\")\n .description(\"Run configured change-request review tasks locally without publishing\")\n .option(\"--base <sha>\", \"Base commit SHA\")\n .option(\"--head <sha>\", \"Head commit SHA or ref; omitted reviews the working tree\")\n .option(\"--config-dir <dir>\", \"Config directory\", \".pipr\")\n .option(\"--pi-executable <path>\", \"Pi executable path\")\n .option(\"--json\", \"Print structured JSON output\")\n .action(runLocalReview);\n\n const skill = program\n .command(\"skill\")\n .description(\"Print the bundled Pipr setup skill\")\n .action(runSkillGet);\n skill\n .command(\"path\")\n .description(\"Materialize the bundled Pipr setup skill and print its directory path\")\n .action(runSkillPath);\n\n return program;\n}\n\nconst agentHelpText = `\n\nStart here (for AI agents):\n pipr skill\n\nThe Pipr setup skill ships with the CLI and is version-matched to this release.\nPrefer it over guessing commands or config shape from memory.\n\n skill Print the bundled setup skill and references\n skill path Materialize the setup skill and print its directory path\n`;\n\nasync function runAction(options: CliOptions): Promise<void> {\n writeActionResult(await runActionCommand(actionOptions(options)));\n}\n\nfunction actionOptions(options: CliOptions): ActionOptions {\n const eventPath = process.env.GITHUB_EVENT_PATH;\n if (!eventPath) {\n throw new Error(\"GITHUB_EVENT_PATH is required for pipr action\");\n }\n return {\n rootDir: process.env.GITHUB_WORKSPACE ?? process.cwd(),\n configDir: process.env[\"INPUT_CONFIG-DIR\"] || options.configDir,\n env: process.env,\n eventPath,\n dryRun: process.env.PIPR_DRY_RUN === \"1\",\n logSink: githubActionsLogSink,\n };\n}\n\nconst githubActionsLogSink: ActionLogSink = {\n log(record) {\n githubActionLogWriters[record.level](formatGitHubActionLogRecord(record));\n },\n async group(name, run) {\n return await core.group(name, run);\n },\n};\n\nconst githubActionLogWriters = {\n info: core.info,\n notice: core.notice,\n warning: core.warning,\n error: core.error,\n debug: core.debug,\n} satisfies Record<ActionLogRecord[\"level\"], (message: string) => void>;\n\nfunction formatGitHubActionLogRecord(record: ActionLogRecord): string {\n const line = JSON.stringify({\n level: record.level,\n event: record.event,\n ...record.fields,\n });\n return record.text === undefined ? line : `${line}\\n${record.text}`;\n}\n\nfunction writeActionResult(result: ActionCommandResult): void {\n if (result.kind === \"ignored\") {\n core.info(`pipr ignored event: ${result.reason}`);\n return;\n }\n writeLoadedActionResult(result);\n}\n\ntype LoadedActionResult = Exclude<ActionCommandResult, { kind: \"ignored\" }>;\ntype PublishedActionResult = Exclude<LoadedActionResult, { kind: \"dry-run\" }>;\ntype CommandActionResult = Extract<\n PublishedActionResult,\n { kind: \"command-help\" | \"command-response\" }\n>;\ntype ReviewWorkflowActionResult = Exclude<PublishedActionResult, CommandActionResult>;\n\nfunction writeLoadedActionResult(result: LoadedActionResult): void {\n core.info(\n `pipr loaded change #${result.event.change.number} for ${result.event.repository.slug}`,\n );\n core.info(`pipr config source: ${result.configSource}`);\n if (result.kind === \"dry-run\") {\n writeDryRunActionResult(result);\n return;\n }\n writePublishedActionResult(result);\n}\n\nfunction writePublishedActionResult(result: PublishedActionResult): void {\n if (result.kind === \"command-help\" || result.kind === \"command-response\") {\n writeCommandActionResult(result);\n return;\n }\n writeReviewWorkflowActionResult(result);\n}\n\nfunction writeCommandActionResult(result: CommandActionResult): void {\n switch (result.kind) {\n case \"command-help\":\n writeCommandHelpActionResult(result);\n break;\n case \"command-response\":\n writeCommandResponseActionResult(result);\n break;\n default:\n result satisfies never;\n }\n}\n\nfunction writeReviewWorkflowActionResult(result: ReviewWorkflowActionResult): void {\n switch (result.kind) {\n case \"review\":\n writeReviewActionResult(result);\n break;\n case \"verifier\":\n writeVerifierActionResult(result);\n break;\n default:\n result satisfies never;\n }\n}\n\nfunction writeDryRunActionResult(result: Extract<ActionCommandResult, { kind: \"dry-run\" }>): void {\n void result;\n core.info(\"PIPR_DRY_RUN=1; stopping before review runtime, model, or GitHub publishing calls\");\n}\n\nfunction writeCommandHelpActionResult(\n result: Extract<ActionCommandResult, { kind: \"command-help\" }>,\n): void {\n core.info(`pipr command help: ${result.reason}`);\n core.setOutput(\"main-comment\", result.body);\n}\n\nfunction writeCommandResponseActionResult(\n result: Extract<ActionCommandResult, { kind: \"command-response\" }>,\n): void {\n core.info(\n `pipr command '${result.command}' published response comment (${result.publication.action})`,\n );\n core.setOutput(\"main-comment\", result.response.body);\n core.setOutput(\"publication\", JSON.stringify(result.publication));\n}\n\nfunction writeVerifierActionResult(\n result: Extract<ActionCommandResult, { kind: \"verifier\" }>,\n): void {\n core.info(\n `pipr verifier processed review comment reply with ${result.errors.length} publication error(s)`,\n );\n warnInlineResolutionErrors(result.errors);\n core.setOutput(\"publication\", JSON.stringify({ inlineResolutionErrors: result.errors }));\n}\n\nfunction writeReviewActionResult(result: Extract<ActionCommandResult, { kind: \"review\" }>): void {\n core.info(\n `pipr review produced ${result.review.validated.validFindings.length} valid inline finding(s), ` +\n `${result.review.validated.droppedFindings.length} dropped finding(s)`,\n );\n core.info(\n `pipr published main comment (${result.publication.mainComment.action}) and ` +\n `${result.publication.inlineComments.posted} inline comment(s); ` +\n `${result.publication.inlineComments.skipped} skipped`,\n );\n warnInlineResolutionErrors(result.publication.metadata.inlineResolutionErrors);\n if (result.review.repairAttempted) {\n core.info(\"pipr repaired reviewer JSON once before validation\");\n }\n core.setOutput(\"main-comment\", result.review.mainComment);\n core.setOutput(\"inline-comments\", JSON.stringify(result.review.inlineCommentDrafts));\n core.setOutput(\"dropped-findings\", JSON.stringify(result.review.validated.droppedFindings));\n core.setOutput(\"publication\", JSON.stringify(result.publication));\n}\n\nfunction warnInlineResolutionErrors(errors: string[]): void {\n for (const error of errors) {\n core.warning(`pipr inline resolution failed: ${error}`);\n }\n}\n\nasync function runInit(options: CliOptions): Promise<void> {\n const result = await runInitCommand({\n rootDir: process.cwd(),\n configDir: options.configDir,\n force: options.force === true,\n adapters: parseInitAdapters(options.adapters),\n recipe: options.recipe,\n minimal: options.minimal === true,\n });\n console.log(\n `created ${result.created.length} file(s)` +\n (result.overwritten.length > 0 ? `; overwrote ${result.overwritten.length}` : \"\"),\n );\n if (options.minimal === true) {\n console.log(\n \"For editor types, install @usepipr/sdk at the repo root: npm install -D @usepipr/sdk\",\n );\n }\n}\n\nfunction parseInitAdapters(adapters: string | undefined): string[] | undefined {\n return adapters?.split(\",\").map((adapter) => adapter.trim());\n}\n\nasync function runCheck(options: CliOptions): Promise<void> {\n const settings = await runValidateCommand({\n rootDir: process.cwd(),\n configDir: options.configDir,\n env: process.env,\n requireProviderEnv: options.requireEnv === true,\n });\n console.log(`valid: ${settings.source}`);\n for (const warning of settings.warnings) {\n console.log(`warning: ${warning}`);\n }\n}\n\nasync function runInspect(options: CliOptions): Promise<void> {\n const result = await runInspectCommand({\n rootDir: process.cwd(),\n configDir: options.configDir,\n env: process.env,\n });\n console.log(inspect(result, { depth: 8, colors: false }));\n}\n\nasync function runSkillGet(): Promise<void> {\n console.log(formatBundledSkill(await resolveBundledSkill()));\n}\n\nasync function runSkillPath(): Promise<void> {\n console.log(await materializeBundledSkill());\n}\n\nasync function runLocalReview(options: CliOptions): Promise<void> {\n if (!options.base) {\n throw new Error(\"pipr review requires --base <sha>\");\n }\n const result = await runLocalReviewCommand({\n rootDir: process.cwd(),\n configDir: options.configDir,\n env: process.env,\n baseSha: options.base,\n headSha: options.head,\n piExecutable: options.piExecutable,\n logSink: localConsoleLogSink,\n taskLog: stderrTaskLog,\n });\n writeLocalReviewResult(result, options.json === true);\n}\n\ntype LocalReviewResult = Awaited<ReturnType<typeof runLocalReviewCommand>>;\n\nconst stderrTaskLog = {\n info(message: string) {\n console.error(`[info] ${message}`);\n },\n warn(message: string) {\n console.error(`[warn] ${message}`);\n },\n error(message: string) {\n console.error(`[error] ${message}`);\n },\n};\n\nconst localConsoleLogSink: ActionLogSink = {\n log(record) {\n console.error(formatLocalLogRecord(record));\n },\n async group(_name, run) {\n return await run();\n },\n};\n\nfunction formatLocalLogRecord(record: ActionLogRecord): string {\n const fields = Object.entries(record.fields)\n .map(([key, value]) => formatLocalLogField(key, value))\n .filter((field): field is string => field !== undefined);\n const prefix = formatLocalLogPrefix(record);\n const formatted = [...prefix, ...fields].join(\" \");\n return record.text === undefined ? formatted : `${formatted}\\n${record.text}`;\n}\n\nfunction formatLocalLogPrefix(record: ActionLogRecord): string[] {\n return [\"pipr\", localLogPlainLevels.has(record.level) ? \"\" : record.level, record.event].filter(\n Boolean,\n );\n}\n\nconst localLogNumberFields: Record<string, (value: number) => string> = {\n additions: (value) => `+${value}`,\n deletions: (value) => `-${value}`,\n durationMs: (value) =>\n `duration=${value < 1000 ? `${value}ms` : `${(value / 1000).toFixed(1)}s`}`,\n promptBytes: (value) => `prompt=${value}B`,\n stderrBytes: (value) => `stderr=${value}B`,\n stdoutBytes: (value) => `stdout=${value}B`,\n};\n\nconst localLogPlainLevels = new Set([\"info\", \"notice\"]);\n\nfunction formatLocalLogField(key: string, value: unknown): string | undefined {\n if (value == null) {\n return undefined;\n }\n\n return formatLocalLogFieldValue(key, value);\n}\n\nfunction formatLocalLogFieldValue(key: string, value: unknown): string {\n const formattedNumber =\n typeof value === \"number\" ? localLogNumberFields[key]?.(value) : undefined;\n return formattedNumber ?? `${key}=${formatLocalLogValue(value)}`;\n}\n\nconst localLogValueFormatters: Record<string, (value: unknown) => string> = {\n boolean: String,\n number: String,\n object: (value) =>\n Array.isArray(value)\n ? value.length === 0\n ? \"-\"\n : value.map(formatLocalLogValue).join(\",\")\n : JSON.stringify(value),\n string: (value) => {\n const text = String(value);\n return /\\s/.test(text) ? JSON.stringify(text) : text;\n },\n};\n\nfunction formatLocalLogValue(value: unknown): string {\n return (localLogValueFormatters[typeof value] ?? JSON.stringify)(value);\n}\n\nfunction writeLocalReviewResult(result: LocalReviewResult, json: boolean): void {\n if (json) {\n console.log(JSON.stringify(localReviewJson(result), null, 2));\n return;\n }\n if (result.kind === \"skipped\") {\n console.log(`skipped: ${result.skipReason ?? \"no task matched\"}`);\n return;\n }\n console.log(formatLocalReview(result));\n}\n\nfunction formatLocalReview(result: Extract<LocalReviewResult, { kind: \"review\" }>): string {\n const mainComment = stripMainCommentMarker(result.mainComment);\n const inlineFindings = result.inlineCommentDrafts.map((draft, index) => {\n const range =\n draft.startLine === draft.endLine\n ? `${draft.path}:${draft.startLine}`\n : `${draft.path}:${draft.startLine}-${draft.endLine}`;\n return [\n `${index + 1}. ${range}`,\n `Range: ${draft.finding.rangeId ?? \"-\"}`,\n draft.finding.body,\n ].join(\"\\n\");\n });\n return inlineFindings.length === 0\n ? mainComment\n : [mainComment.trimEnd(), \"\", \"## Inline Findings\", \"\", inlineFindings.join(\"\\n\\n\")].join(\"\\n\");\n}\n\nfunction stripMainCommentMarker(comment: string): string {\n return comment\n .split(\"\\n\")\n .filter((line) => !line.startsWith(\"<!-- pipr:main-comment \"))\n .join(\"\\n\")\n .trimStart();\n}\n\nfunction localReviewJson(result: LocalReviewResult) {\n return {\n kind: result.kind,\n ...(result.kind === \"skipped\" ? { skipReason: result.skipReason } : {}),\n mainComment: result.mainComment,\n inlineFindings: result.inlineCommentDrafts,\n droppedFindings: result.validated.droppedFindings,\n taskChecks: result.taskChecks,\n provider: result.provider,\n providerModels: result.publicationPlan.metadata.providerModels ?? [result.provider.model],\n repairAttempted: result.repairAttempted,\n };\n}\n\nasync function runDryRun(options: CliOptions): Promise<void> {\n if (!options.event) {\n throw new Error(\"dry-run requires --event <path>\");\n }\n const result = await runDryRunCommand({\n rootDir: process.cwd(),\n configDir: options.configDir,\n env: process.env,\n eventPath: options.event,\n });\n console.log(\n inspect(\n {\n configSource: result.configSource,\n event: result.event,\n },\n { depth: 6, colors: false },\n ),\n );\n}\n\nmain().catch((error: unknown) => {\n if (error instanceof PublicationError && error.result) {\n core.setOutput(\"publication\", JSON.stringify(error.result));\n core.error(`pipr publication metadata: ${JSON.stringify(error.result)}`);\n }\n const message = error instanceof Error ? error.message : String(error);\n core.setFailed(message);\n process.exitCode = 1;\n});\n"],"mappings":";;;;;;;;;;;;ACGA,MAAa,mBAAmB;AAChC,MAAM,wBAAwB,IAAI,IAAI;CACpC;CACA;CACA;AACF,CAAC;AAiBD,SAAgB,mBAAmB,SAA4C;CAC7E,MAAM,CAAC,SAAS,QAAQ;CACxB,IAAI,QAAQ,OAAO,WAAW,KAAK,OAAO,SAAA,cACxC,MAAM,IAAI,MACR,6CAA6C,iBAAiB,YAAY,QAAQ,OAC/E,KAAK,SAAS,KAAK,IAAI,CAAC,CACxB,KAAK,IAAI,GACd;CAEF,OAAO;AACT;AAEA,SAAgB,uBAAuB,MAAc,cAA8B;CACjF,IAAI,KAAK,WAAW,YAAY,GAC9B,MAAM,IAAI,MAAM,6CAA6C,cAAc;CAE7E,MAAM,eAAe,KAAK,QAAQ,IAAI;CACtC,MAAM,SAAS,KAAK,QAAQ,cAAc,YAAY;CACtD,IAAI,WAAW,gBAAgB,CAAC,OAAO,WAAW,GAAG,eAAe,KAAK,KAAK,GAC5E,MAAM,IAAI,MAAM,wDAAwD,cA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r through a short interview. Use when a user wants an agent to add Pipr to a repository, customize .pipr/config.ts, choose review recipes, wire GitHub Actions, or verify Pipr CLI setup.
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Pipr Setup
|
|
8
|
+
|
|
9
|
+
Use this skill to add Pipr to a repository and produce a custom Pipr Configuration, not just a stock `pipr init` output.
|
|
10
|
+
|
|
11
|
+
## Ground First
|
|
12
|
+
|
|
13
|
+
Inspect before asking:
|
|
14
|
+
|
|
15
|
+
- Repository instructions and existing AI agent guidance.
|
|
16
|
+
- Existing `.pipr/`, `.github/workflows/pipr.yml`, provider secret names or workflow mappings, and package manager files. Do not open `.env*` or other files that may contain raw secret values; ask for missing secret names instead.
|
|
17
|
+
- Project language, test layout, dependency manifests, generated files, docs, and CI workflows.
|
|
18
|
+
- Existing pull request review expectations in docs, templates, or contribution guides.
|
|
19
|
+
|
|
20
|
+
Completion criterion: you know whether this is a new setup or an edit, which files Pipr may touch, and which repo-specific review policies can be inferred without asking.
|
|
21
|
+
|
|
22
|
+
## Install Check
|
|
23
|
+
|
|
24
|
+
1. Run `command -v pipr` and verify with `pipr --help`. Do not rely on `pipr --version`.
|
|
25
|
+
2. If `pipr` is missing, detect the OS and architecture. On Linux and macOS x64 or arm64, ask before running the official release installer for a specific release tag. Do not execute installer scripts from a mutable branch such as `main`.
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
PIPR_VERSION="vX.Y.Z"
|
|
29
|
+
installer="$(mktemp)"
|
|
30
|
+
trap 'rm -f "$installer"' EXIT
|
|
31
|
+
curl -fsSL "https://raw.githubusercontent.com/somus/pipr/${PIPR_VERSION}/install.sh" -o "$installer"
|
|
32
|
+
PIPR_VERSION="$PIPR_VERSION" sh "$installer"
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Replace `vX.Y.Z` with the target release tag. Use the CLI release version when this skill came from `pipr skill`. For a separately installed skill, check Pipr releases and use the latest stable tag unless the user requests another version. The installer verifies release checksums and installs to `~/.local/bin` unless `PIPR_INSTALL_DIR` is set.
|
|
36
|
+
|
|
37
|
+
3. If the release installer does not support the host OS, use the npm fallback only when Bun is already installed. Reuse the same approved release version and ask before running `npm install -g @usepipr/cli@<version-without-v>`, then verify with `pipr --help`. The npm CLI package uses Bun.
|
|
38
|
+
4. For full default setup, check `command -v bun`. `pipr init` creates `.pipr/bun.lock` by running `bun install`. If Bun is missing, ask before installing Bun using the official Bun instructions for the user's OS. Do not silently switch to `--minimal`.
|
|
39
|
+
|
|
40
|
+
Completion criterion: a `pipr` command is available, and the user has approved any install command that changes their machine.
|
|
41
|
+
|
|
42
|
+
## Short Interview
|
|
43
|
+
|
|
44
|
+
Ask only for missing choices. Combine questions so the interview stays short.
|
|
45
|
+
|
|
46
|
+
- Setup surface: config directory, GitHub workflow generation, and whether existing Pipr files may be edited. Never use `pipr init --force` without explicit approval.
|
|
47
|
+
- Review goal: general review, bugs, security, quality gate, dependency risk, PR hygiene, diagnostics, briefing, changelog, interactive ask, CI triage, multi-agent review, or durable memory tools.
|
|
48
|
+
- Model policy: provider, model, secret env var names, fallback model, and whether local runs should require provider env vars.
|
|
49
|
+
- Trigger policy: automatic change request actions, `@pipr` commands, command permissions, local review behavior, and command-only workflows.
|
|
50
|
+
- Publication policy: inline comment cap, check runs, aggregate checks, required gates, auto-resolve behavior, and who may trigger verifier replies.
|
|
51
|
+
- Repo policy: path include/exclude scopes, generated or lockfile rules, test and docs expectations, package manager quirks, security-sensitive areas, and release-note conventions.
|
|
52
|
+
|
|
53
|
+
Completion criterion: recipe, model, secrets, triggers, publication behavior, and repo-specific review policy are explicit enough to write `.pipr/config.ts`.
|
|
54
|
+
|
|
55
|
+
## Build
|
|
56
|
+
|
|
57
|
+
Read [recipes.md](references/recipes.md) before selecting a starter recipe. Read [config-patterns.md](references/config-patterns.md) before writing custom task code.
|
|
58
|
+
|
|
59
|
+
For new setups:
|
|
60
|
+
|
|
61
|
+
- Choose the smallest matching recipe and run `pipr init --recipe <id>`.
|
|
62
|
+
- Add `--adapters none` only when the user does not want GitHub workflow files.
|
|
63
|
+
- Use `--minimal` only when the user chose a single-file config or Bun cannot be installed.
|
|
64
|
+
|
|
65
|
+
For existing setups:
|
|
66
|
+
|
|
67
|
+
- Edit the existing `.pipr/config.ts` and companion files instead of reinitializing.
|
|
68
|
+
- Preserve user-authored local imports, secrets, and workflow customizations unless the user approves a replacement.
|
|
69
|
+
|
|
70
|
+
While customizing:
|
|
71
|
+
|
|
72
|
+
- Keep config load synchronous. Runtime work belongs inside `pipr.task(...)`.
|
|
73
|
+
- Use `pipr.secret({ name })`; never write raw secret values.
|
|
74
|
+
- Prefer `pipr.review(...)` until the interview requires multiple Pi calls, command input, custom schemas, plugin tools, explicit checks, or main-comment-only output.
|
|
75
|
+
- For custom tasks, pass `{ manifest }` to `ctx.pi.run(...)`; do not interpolate the Diff Manifest into prompts yourself.
|
|
76
|
+
- Emit exactly one final output from each selected task: `ctx.comment(...)` or `ctx.command.reply(...)`.
|
|
77
|
+
|
|
78
|
+
Completion criterion: the generated or edited Pipr Configuration reflects every interview decision and avoids speculative workflows.
|
|
79
|
+
|
|
80
|
+
## Verify
|
|
81
|
+
|
|
82
|
+
Run the narrowest checks that prove the setup:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pipr inspect
|
|
86
|
+
pipr check
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Use `pipr check --require-env` only when the required provider env vars should already be present. Use `pipr review --base <ref>` only when the user has a safe local base ref, Pi is available, and provider secrets are intentionally exported.
|
|
90
|
+
|
|
91
|
+
For GitHub workflow or event behavior, inspect `.github/workflows/pipr.yml`; use `pipr dry-run --event <path>` only when a real event fixture is available.
|
|
92
|
+
|
|
93
|
+
Completion criterion: `pipr inspect` shows the expected models, agents, tasks, commands, tools, checks, and limits; `pipr check` succeeds or reports a blocker you can name exactly.
|
|
94
|
+
|
|
95
|
+
## Report
|
|
96
|
+
|
|
97
|
+
End with:
|
|
98
|
+
|
|
99
|
+
- Files created or changed.
|
|
100
|
+
- Recipe and major customizations.
|
|
101
|
+
- Required GitHub Actions secrets and local env vars by name only.
|
|
102
|
+
- Verification commands and results.
|
|
103
|
+
- Remaining manual steps, such as adding repository secrets or enabling branch protection.
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
# Pipr Config Patterns
|
|
2
|
+
|
|
3
|
+
Use these patterns when customizing `.pipr/config.ts`.
|
|
4
|
+
|
|
5
|
+
## CLI Commands
|
|
6
|
+
|
|
7
|
+
| Command | Use |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| `pipr init` | Create `.pipr/config.ts`, `.pipr/package.json`, `.pipr/bun.lock`, `.pipr/tsconfig.json`, `.pipr/.gitignore`, and the GitHub workflow. |
|
|
10
|
+
| `pipr init --minimal` | Create only `.pipr/config.ts`; editor types come from a repo-root `@usepipr/sdk` install. |
|
|
11
|
+
| `pipr inspect` | Print models, agents, tasks, commands, tools, publication settings, checks, and limits. |
|
|
12
|
+
| `pipr check` | Type-load config and validate the runtime plan. |
|
|
13
|
+
| `pipr check --require-env` | Also require configured provider env vars. |
|
|
14
|
+
| `pipr review --base <ref>` | Run change-request tasks locally without publishing comments. |
|
|
15
|
+
| `pipr dry-run --event <path>` | Load a GitHub event and config without model calls or publication. |
|
|
16
|
+
|
|
17
|
+
## Model And Review Basics
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { definePipr } from "@usepipr/sdk";
|
|
21
|
+
|
|
22
|
+
export default definePipr((pipr) => {
|
|
23
|
+
const model = pipr.model({
|
|
24
|
+
provider: "deepseek",
|
|
25
|
+
model: "deepseek-v4-pro",
|
|
26
|
+
apiKey: pipr.secret({ name: "DEEPSEEK_API_KEY" }),
|
|
27
|
+
options: { thinking: "high" },
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
pipr.config({ publication: { maxInlineComments: 5 } });
|
|
31
|
+
|
|
32
|
+
pipr.review({
|
|
33
|
+
id: "review",
|
|
34
|
+
model,
|
|
35
|
+
instructions: `
|
|
36
|
+
Review the pull request diff for correctness, security,
|
|
37
|
+
maintainability, and test coverage.
|
|
38
|
+
Return only actionable findings that target valid diff ranges.
|
|
39
|
+
`,
|
|
40
|
+
timeout: "10m",
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Use `id` on a model only when two model profiles share the same provider and model with different options.
|
|
46
|
+
|
|
47
|
+
## Entrypoints
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
pipr.review({
|
|
51
|
+
id: "review",
|
|
52
|
+
model,
|
|
53
|
+
instructions: "Review only actionable defects.",
|
|
54
|
+
entrypoints: {
|
|
55
|
+
changeRequest: ["opened", "updated", "reopened", "ready"],
|
|
56
|
+
command: { pattern: "@pipr review", permission: "write" },
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Supported public change request actions:
|
|
62
|
+
|
|
63
|
+
```text
|
|
64
|
+
opened | updated | reopened | ready | closed
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Command permissions:
|
|
68
|
+
|
|
69
|
+
```text
|
|
70
|
+
read < triage < write < maintain < admin
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Use a final rest capture for free-form command text:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
pipr.command({ pattern: "@pipr ask <question...>", permission: "read", task });
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Path Scopes
|
|
80
|
+
|
|
81
|
+
Use `paths` to filter the Diff Manifest and publishable Inline Review Comments:
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
pipr.review({
|
|
85
|
+
id: "runtime-review",
|
|
86
|
+
model,
|
|
87
|
+
instructions: "Review runtime changes only.",
|
|
88
|
+
paths: {
|
|
89
|
+
include: ["packages/runtime/**"],
|
|
90
|
+
exclude: ["**/*.test.ts"],
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
For custom tasks, pass the same path scope to `ctx.change.diffManifest(...)` and `ctx.pi.run(...)`.
|
|
96
|
+
|
|
97
|
+
## Custom Tasks
|
|
98
|
+
|
|
99
|
+
Use `pipr.agent`, `pipr.task`, and `pipr.on.changeRequest` when `pipr.review(...)` is too small.
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
const security = pipr.agent({
|
|
103
|
+
name: "security-reviewer",
|
|
104
|
+
model,
|
|
105
|
+
instructions: "Review only concrete security issues.",
|
|
106
|
+
output: pipr.schemas.review,
|
|
107
|
+
tools: pipr.tools.readOnly,
|
|
108
|
+
prompt: () => pipr.prompt`
|
|
109
|
+
${pipr.section("Policy", "Return only findings with a concrete attack path.")}
|
|
110
|
+
`,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const task = pipr.task({
|
|
114
|
+
name: "security-review",
|
|
115
|
+
check: { name: "security", required: true },
|
|
116
|
+
async run(ctx) {
|
|
117
|
+
const manifest = await ctx.change.diffManifest({ compressed: true });
|
|
118
|
+
const result = await ctx.pi.run(security, { manifest });
|
|
119
|
+
await ctx.comment({ main: result.summary.body, inlineFindings: result.inlineFindings });
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
pipr.on.changeRequest({ actions: ["opened", "updated"], task });
|
|
124
|
+
pipr.command({ pattern: "@pipr security", permission: "write", task });
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Task rules:
|
|
128
|
+
|
|
129
|
+
- Keep config registration synchronous.
|
|
130
|
+
- Let Pipr build the Diff Manifest and validate Inline Review Comments.
|
|
131
|
+
- Pass the Diff Manifest through the reserved `manifest` input key.
|
|
132
|
+
- Emit exactly one final output per selected task.
|
|
133
|
+
- Use `ctx.command.reply(...)` for command response workflows.
|
|
134
|
+
- Use `local: false` only for tasks that should never run through `pipr review`.
|
|
135
|
+
|
|
136
|
+
## Checks And Publication
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
pipr.config({
|
|
140
|
+
publication: {
|
|
141
|
+
maxInlineComments: 6,
|
|
142
|
+
autoResolve: {
|
|
143
|
+
enabled: true,
|
|
144
|
+
model,
|
|
145
|
+
instructions: "Resolve only when the changed code addresses the finding directly.",
|
|
146
|
+
synchronize: true,
|
|
147
|
+
userReplies: { enabled: true, allowedActors: "write" },
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
checks: {
|
|
151
|
+
aggregate: { enabled: true, name: "pipr quality gate" },
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Use required checks only when the user wants merge-gate behavior. Use comments for reviewer-facing detail.
|
|
157
|
+
|
|
158
|
+
## Secrets
|
|
159
|
+
|
|
160
|
+
Use only secret names in config:
|
|
161
|
+
|
|
162
|
+
```ts
|
|
163
|
+
apiKey: pipr.secret({ name: "DEEPSEEK_API_KEY" })
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Add matching GitHub Actions secret mappings in `.github/workflows/pipr.yml`. Never commit raw provider keys, local `.env` values, or personal credentials.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Pipr Recipe Selection
|
|
2
|
+
|
|
3
|
+
Choose the smallest recipe that matches the requested workflow, then customize `.pipr/config.ts`.
|
|
4
|
+
|
|
5
|
+
## Starter Recipes
|
|
6
|
+
|
|
7
|
+
| Recipe | Use When | Main Customization Points |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `default-review` | The user wants a bounded general pull request reviewer. | Review instructions, inline cap, command pattern, path scope. |
|
|
10
|
+
| `bug-hunter` | The user wants correctness defects, edge cases, races, regressions, and missing tests. | Excluded docs paths, fallback model, inline cap. |
|
|
11
|
+
| `security-sast` | The user wants concrete security findings with severity, category, and attack path. | Risk categories, required check policy, security path scopes. |
|
|
12
|
+
| `quality-gate` | The user wants a merge gate for blocking correctness, reliability, security, or test risks. | Required check name, fail criteria, auto-resolve policy. |
|
|
13
|
+
| `diff-diagnostics` | The workflow maps diagnostics into Pipr Inline Review Comments. | Diagnostic schema, path and range mapping, external diagnostic source. |
|
|
14
|
+
| `pr-hygiene` | The user wants tests, docs, lockfile, generated-file, and change-size hygiene. | Hygiene rules, required or advisory check, changed-file rules. |
|
|
15
|
+
| `dependency-risk` | Dependency manifests and lockfiles need supply-chain or upgrade-risk review. | Manifest patterns, migration notes, package manager expectations. |
|
|
16
|
+
| `ci-triage-command` | Maintainers want to paste CI logs into an `@pipr` command. | Command pattern, permission, log parsing expectations. |
|
|
17
|
+
| `multi-agent-review` | Specialists should review security, tests, and maintainability before aggregation. | Specialist list, timeout, cost controls, aggregation policy. |
|
|
18
|
+
| `plugin-tool-review` | Reviewer agents need custom tools or durable project memory. | Tool secrets, storage provider, safety rules for stored memory. |
|
|
19
|
+
| `pr-briefing` | The user wants a PR-Agent describe-style main comment. | Briefing sections, walkthrough format, changed-area taxonomy. |
|
|
20
|
+
| `interactive-ask` | Reviewers need a free-form `@pipr ask <question...>` command. | Command permission, prompt boundaries, prior review usage. |
|
|
21
|
+
| `changelog-draft` | Maintainers want release-note style command responses. | Changelog format, audience, release channels. |
|
|
22
|
+
|
|
23
|
+
## Selection Rules
|
|
24
|
+
|
|
25
|
+
- Start from `default-review` unless another row directly matches the user's main workflow.
|
|
26
|
+
- Prefer one custom task over multiple independent tasks when the final output should be one coherent Main Review Comment.
|
|
27
|
+
- Prefer command-only recipes when the user wants explicit maintainer-triggered analysis and no automatic review.
|
|
28
|
+
- Prefer `quality-gate` only when the user wants branch protection semantics. Otherwise keep checks advisory.
|
|
29
|
+
- Prefer `plugin-tool-review` only when the interview identifies durable context or external lookup tools that cannot fit in prompt instructions.
|
|
30
|
+
- Combine recipes by editing config, not by running `pipr init` repeatedly. `pipr init` is a starter, not a merger.
|
|
31
|
+
|
|
32
|
+
## Init Commands
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pipr init
|
|
36
|
+
pipr init --recipe security-sast
|
|
37
|
+
pipr init --recipe multi-agent-review --adapters none
|
|
38
|
+
pipr init --minimal
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Use `pipr init --force` only after the user explicitly approves replacing existing Pipr files.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usepipr/cli",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Command line interface for pipr pull request review automation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,18 +23,18 @@
|
|
|
23
23
|
"pipr": "./dist/main.mjs"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
|
-
"build": "tsdown src/main.ts --dts --format esm --out-dir dist",
|
|
26
|
+
"build": "tsdown src/main.ts --dts --format esm --out-dir dist && bun src/release/copy-skills.ts",
|
|
27
27
|
"typecheck": "tsc --noEmit",
|
|
28
28
|
"test": "bun test --timeout 30000",
|
|
29
|
-
"lint": "biome
|
|
30
|
-
"format:check": "biome
|
|
29
|
+
"lint": "biome lint src",
|
|
30
|
+
"format:check": "biome format src",
|
|
31
31
|
"prepack": "bun run build",
|
|
32
32
|
"check": "bun run lint && bun run typecheck && bun run test"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@actions/core": "3.0.1",
|
|
36
|
-
"@usepipr/runtime": "0.1
|
|
37
|
-
"@usepipr/sdk": "0.1
|
|
36
|
+
"@usepipr/runtime": "0.2.1",
|
|
37
|
+
"@usepipr/sdk": "0.2.1",
|
|
38
38
|
"commander": "15.0.0"
|
|
39
39
|
}
|
|
40
40
|
}
|