@iceinvein/agent-skills 0.1.24 → 0.1.26
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 +1 -0
- package/package.json +1 -1
- package/skills/magpie/README.md +16 -1
- package/skills/magpie/bin/magpie.ts +60 -2
- package/skills/magpie/fixtures/example-pr/diff.patch +86 -0
- package/skills/magpie/fixtures/example-pr/findings.final.json +137 -0
- package/skills/magpie/fixtures/example-pr/post-status.json +5 -0
- package/skills/magpie/fixtures/example-pr/pr.json +21 -0
- package/skills/magpie/fixtures/fake-gh.sh +10 -1
- package/skills/magpie/package.json +1 -1
- package/skills/magpie/scripts/__tests__/cli.test.ts +119 -0
- package/skills/magpie/scripts/__tests__/diff-utils.test.ts +106 -0
- package/skills/magpie/scripts/__tests__/file-tree.test.ts +97 -0
- package/skills/magpie/scripts/__tests__/gh.test.ts +8 -0
- package/skills/magpie/scripts/__tests__/helper.test.ts +63 -0
- package/skills/magpie/scripts/__tests__/pipeline-e2e.test.ts +10 -0
- package/skills/magpie/scripts/__tests__/post-cmd.test.ts +90 -1
- package/skills/magpie/scripts/__tests__/preview-cmd.test.ts +210 -0
- package/skills/magpie/scripts/__tests__/refresh.test.ts +2 -2
- package/skills/magpie/scripts/__tests__/render-action-bar.test.ts +66 -0
- package/skills/magpie/scripts/__tests__/render-annotation.test.ts +67 -0
- package/skills/magpie/scripts/__tests__/render-cmd.test.ts +46 -0
- package/skills/magpie/scripts/__tests__/render-diff.test.ts +84 -0
- package/skills/magpie/scripts/__tests__/render-file-tree.test.ts +54 -0
- package/skills/magpie/scripts/__tests__/render-findings.test.ts +104 -182
- package/skills/magpie/scripts/__tests__/render-issues-list.test.ts +67 -0
- package/skills/magpie/scripts/__tests__/render-progress.test.ts +86 -0
- package/skills/magpie/scripts/__tests__/server.test.ts +54 -0
- package/skills/magpie/scripts/__tests__/types.test.ts +48 -3
- package/skills/magpie/scripts/diff-utils.ts +129 -0
- package/skills/magpie/scripts/file-tree.ts +74 -0
- package/skills/magpie/scripts/gh.ts +1 -0
- package/skills/magpie/scripts/helper.js +402 -192
- package/skills/magpie/scripts/post-cmd.ts +202 -0
- package/skills/magpie/scripts/preview-cmd.ts +300 -0
- package/skills/magpie/scripts/refresh.ts +16 -1
- package/skills/magpie/scripts/render-action-bar.ts +51 -0
- package/skills/magpie/scripts/render-annotation.ts +96 -0
- package/skills/magpie/scripts/render-cmd.ts +24 -1
- package/skills/magpie/scripts/render-diff.ts +125 -0
- package/skills/magpie/scripts/render-file-tree.ts +86 -0
- package/skills/magpie/scripts/render-findings.ts +165 -196
- package/skills/magpie/scripts/render-issues-list.ts +78 -0
- package/skills/magpie/scripts/render-progress.ts +74 -32
- package/skills/magpie/scripts/server.ts +43 -0
- package/skills/magpie/scripts/types.ts +13 -0
- package/skills/magpie/skill.json +4 -2
- package/skills/magpie/templates/styles.css +1288 -629
|
@@ -13,6 +13,28 @@ const STAGES = [
|
|
|
13
13
|
export type StageId = (typeof STAGES)[number]
|
|
14
14
|
export type StageStatus = 'pending' | 'running' | 'done' | 'error' | 'skipped'
|
|
15
15
|
|
|
16
|
+
const STAGE_HINT: Record<StageId, string> = {
|
|
17
|
+
setup: 'fetch PR and diff',
|
|
18
|
+
context: 'index symbols',
|
|
19
|
+
specialists: 'five reviewers in parallel',
|
|
20
|
+
dedupe: 'merge overlaps',
|
|
21
|
+
critic: 'keep the high-signal ones',
|
|
22
|
+
'peer-review': 'second opinion via codex',
|
|
23
|
+
report: 'render this page',
|
|
24
|
+
post: 'comment on the PR',
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const STAGE_NOW_DOING: Record<StageId, string> = {
|
|
28
|
+
setup: 'Fetching the PR and diff',
|
|
29
|
+
context: 'Indexing repo symbols',
|
|
30
|
+
specialists: 'Five reviewers reading the diff in parallel',
|
|
31
|
+
dedupe: 'Merging overlapping findings',
|
|
32
|
+
critic: 'Keeping only the high-signal ones',
|
|
33
|
+
'peer-review': 'Asking a second opinion via codex',
|
|
34
|
+
report: 'Composing the report page',
|
|
35
|
+
post: 'Ready to post; switch tabs to pick findings',
|
|
36
|
+
}
|
|
37
|
+
|
|
16
38
|
export type RenderProgressInput = {
|
|
17
39
|
prNumber: number
|
|
18
40
|
headSha: string
|
|
@@ -21,7 +43,7 @@ export type RenderProgressInput = {
|
|
|
21
43
|
specialistCounts: Record<string, number>
|
|
22
44
|
}
|
|
23
45
|
|
|
24
|
-
function
|
|
46
|
+
function esc(s: string): string {
|
|
25
47
|
return s.replace(/[&<>"']/g, (c) => {
|
|
26
48
|
const m: Record<string, string> = {
|
|
27
49
|
'&': '&',
|
|
@@ -30,27 +52,18 @@ function escapeHtml(s: string): string {
|
|
|
30
52
|
'"': '"',
|
|
31
53
|
"'": ''',
|
|
32
54
|
}
|
|
33
|
-
return m[c]
|
|
55
|
+
return m[c] ?? c
|
|
34
56
|
})
|
|
35
57
|
}
|
|
36
58
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
running: '
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function pipelineHtml(stages: Record<StageId, StageStatus>): string {
|
|
46
|
-
const steps = STAGES.map((s) => {
|
|
47
|
-
const status = stages[s] ?? 'pending'
|
|
48
|
-
return `<div class="step ${status}" data-stage="${s}">
|
|
49
|
-
<span class="dot" aria-hidden="true">${STEP_GLYPH[status]}</span>
|
|
50
|
-
<span class="name">${s}</span>
|
|
51
|
-
</div>`
|
|
52
|
-
}).join('')
|
|
53
|
-
return `<div class="pipeline" role="list">${steps}</div>`
|
|
59
|
+
function current(stages: Record<StageId, StageStatus>): { id: StageId; status: StageStatus } {
|
|
60
|
+
const running = STAGES.find((s) => stages[s] === 'running')
|
|
61
|
+
if (running) return { id: running, status: 'running' }
|
|
62
|
+
const errored = STAGES.find((s) => stages[s] === 'error')
|
|
63
|
+
if (errored) return { id: errored, status: 'error' }
|
|
64
|
+
const pending = STAGES.find((s) => stages[s] === 'pending')
|
|
65
|
+
if (pending) return { id: pending, status: 'pending' }
|
|
66
|
+
return { id: 'post', status: stages.post ?? 'done' }
|
|
54
67
|
}
|
|
55
68
|
|
|
56
69
|
function specialistsLine(counts: Record<string, number>): string {
|
|
@@ -60,11 +73,37 @@ function specialistsLine(counts: Record<string, number>): string {
|
|
|
60
73
|
}
|
|
61
74
|
const total = entries.reduce((acc, [, n]) => acc + n, 0)
|
|
62
75
|
const parts = entries
|
|
63
|
-
.map(([k, v]) => `<span class="part">${
|
|
76
|
+
.map(([k, v]) => `<span class="part">${esc(k)} <span class="count">${v}</span></span>`)
|
|
64
77
|
.join('<span class="sep">·</span>')
|
|
65
78
|
return `<p class="specialists-line"><span class="count">${total}</span> finding${total === 1 ? '' : 's'} <span class="sep">·</span> ${parts}</p>`
|
|
66
79
|
}
|
|
67
80
|
|
|
81
|
+
function progressPane(input: RenderProgressInput): string {
|
|
82
|
+
const cur = current(input.stages)
|
|
83
|
+
let lead: string
|
|
84
|
+
if (cur.status === 'running') {
|
|
85
|
+
lead = STAGE_NOW_DOING[cur.id]
|
|
86
|
+
} else if (cur.status === 'error') {
|
|
87
|
+
lead = `${STAGE_NOW_DOING[cur.id]} stalled`
|
|
88
|
+
} else if (cur.status === 'pending') {
|
|
89
|
+
lead = `Paused before ${cur.id}`
|
|
90
|
+
} else {
|
|
91
|
+
lead = 'All eight stages complete'
|
|
92
|
+
}
|
|
93
|
+
const doneCount = STAGES.filter((s) => input.stages[s] === 'done').length
|
|
94
|
+
const stagesHtml = STAGES.map((s) => {
|
|
95
|
+
const status = input.stages[s] ?? 'pending'
|
|
96
|
+
return `<li class="step ${status}" data-stage="${s}"><span class="dot"></span><span class="name">${s}</span><span class="hint">${esc(STAGE_HINT[s])}</span></li>`
|
|
97
|
+
}).join('')
|
|
98
|
+
return `<section class="progress-pane" data-role="progress-pane">
|
|
99
|
+
<p class="now-doing">${esc(lead)}.</p>
|
|
100
|
+
<ol class="pipeline" style="--done-count: ${doneCount}">${stagesHtml}</ol>
|
|
101
|
+
${specialistsLine(input.specialistCounts)}
|
|
102
|
+
</section>`
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const BRAND_MARK_SVG = `<svg class="brand-mark" viewBox="0 0 24 24" aria-hidden="true" fill="none"><path d="M3 17.5 C 6.5 7.5, 13 6, 17.5 11 L 21 16.5" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/><path d="M11.5 12.5 L 21 16.5" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/><circle class="magpie-eye" cx="6.5" cy="13.5" r="1.1"/></svg>`
|
|
106
|
+
|
|
68
107
|
const ARCHIVED_BANNER = `<div class="archived-banner" role="note"><strong>Archived view.</strong> Live server is gone; this is a snapshot.</div>`
|
|
69
108
|
|
|
70
109
|
export function renderProgressHtml(input: RenderProgressInput): string {
|
|
@@ -76,19 +115,22 @@ export function renderProgressHtml(input: RenderProgressInput): string {
|
|
|
76
115
|
<title>magpie #${input.prNumber}</title>
|
|
77
116
|
<link rel="stylesheet" href="data:text/css;base64,STYLES_INLINE">
|
|
78
117
|
</head>
|
|
79
|
-
<body>
|
|
118
|
+
<body data-page="progress" data-view="files">
|
|
80
119
|
${ARCHIVED_BANNER}
|
|
81
|
-
<
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
120
|
+
<header class="pr-header">
|
|
121
|
+
<div class="brand">${BRAND_MARK_SVG}<span class="brand-text">magpie</span></div>
|
|
122
|
+
<div class="pr-meta"><span class="pr-number">PR #${input.prNumber}</span><span class="pr-branch">${esc(input.branch)}</span><code>${esc(input.headSha.slice(0, 12))}</code></div>
|
|
123
|
+
<div class="header-spacer"></div>
|
|
124
|
+
<div class="segmented" data-role="tabs">
|
|
125
|
+
<button type="button" aria-pressed="true" disabled>Files</button>
|
|
126
|
+
<button type="button" aria-pressed="false" disabled>All Issues</button>
|
|
127
|
+
</div>
|
|
128
|
+
</header>
|
|
129
|
+
<main class="page-main">
|
|
130
|
+
<div class="view files-view">
|
|
131
|
+
<aside class="file-rail empty"><p class="empty-hint">Files appear once setup completes.</p></aside>
|
|
132
|
+
<div class="diff-pane">${progressPane(input)}</div>
|
|
133
|
+
</div>
|
|
92
134
|
</main>
|
|
93
135
|
<script>HELPER_INLINE</script>
|
|
94
136
|
</body>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { appendFile, readdir, readFile, stat, unlink, writeFile } from 'node:fs/promises'
|
|
2
2
|
import { join } from 'node:path'
|
|
3
|
+
import { postFindingsAsReview } from './post-cmd.ts'
|
|
3
4
|
|
|
4
5
|
export type ServerHandle = {
|
|
5
6
|
url: string
|
|
@@ -108,6 +109,48 @@ export async function startServer(input: StartServerInput): Promise<ServerHandle
|
|
|
108
109
|
)
|
|
109
110
|
}
|
|
110
111
|
}
|
|
112
|
+
if (req.method === 'POST' && url.pathname === '/api/post-review') {
|
|
113
|
+
try {
|
|
114
|
+
const body = (await req.json()) as { findingIds?: unknown }
|
|
115
|
+
if (!Array.isArray(body?.findingIds)) {
|
|
116
|
+
return new Response(JSON.stringify({ error: 'findingIds must be an array' }), {
|
|
117
|
+
status: 400,
|
|
118
|
+
headers: { 'content-type': 'application/json' },
|
|
119
|
+
})
|
|
120
|
+
}
|
|
121
|
+
const ids = (body.findingIds as unknown[]).filter(
|
|
122
|
+
(x): x is string => typeof x === 'string',
|
|
123
|
+
)
|
|
124
|
+
if (ids.length === 0) {
|
|
125
|
+
return new Response(JSON.stringify({ error: 'no string ids in findingIds' }), {
|
|
126
|
+
status: 400,
|
|
127
|
+
headers: { 'content-type': 'application/json' },
|
|
128
|
+
})
|
|
129
|
+
}
|
|
130
|
+
const prJson = JSON.parse(await readFile(join(runDir, 'pr.json'), 'utf8')) as {
|
|
131
|
+
number: number
|
|
132
|
+
headRefOid: string
|
|
133
|
+
}
|
|
134
|
+
const result = await postFindingsAsReview({
|
|
135
|
+
runDir,
|
|
136
|
+
findingIds: ids,
|
|
137
|
+
prNumber: prJson.number,
|
|
138
|
+
headSha: prJson.headRefOid,
|
|
139
|
+
dryRun: process.env.MAGPIE_DRY_RUN_POST === '1',
|
|
140
|
+
})
|
|
141
|
+
const status =
|
|
142
|
+
result.reviewId == null && process.env.MAGPIE_DRY_RUN_POST !== '1' ? 502 : 200
|
|
143
|
+
return new Response(JSON.stringify(result), {
|
|
144
|
+
status,
|
|
145
|
+
headers: { 'content-type': 'application/json' },
|
|
146
|
+
})
|
|
147
|
+
} catch (err) {
|
|
148
|
+
return new Response(JSON.stringify({ error: String(err) }), {
|
|
149
|
+
status: 500,
|
|
150
|
+
headers: { 'content-type': 'application/json' },
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
}
|
|
111
154
|
if (req.method === 'GET' && url.pathname === '/helper.js') {
|
|
112
155
|
const src = await readFile(HELPER_PATH, 'utf8')
|
|
113
156
|
return new Response(src, { headers: { 'Content-Type': 'application/javascript' } })
|
|
@@ -104,3 +104,16 @@ export function parseFinding(raw: unknown): ReviewFinding {
|
|
|
104
104
|
mergedFrom: Array.isArray(r.mergedFrom) ? (r.mergedFrom as MergedFromEntry[]) : undefined,
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
+
|
|
108
|
+
export type PostStatusEntry = 'posted' | { status: 'failed'; message: string }
|
|
109
|
+
export type PostStatusMap = Record<string, PostStatusEntry>
|
|
110
|
+
|
|
111
|
+
export type PrFileEntry = {
|
|
112
|
+
path: string
|
|
113
|
+
additions: number
|
|
114
|
+
deletions: number
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function isSuggestion(f: ReviewFinding): boolean {
|
|
118
|
+
return f.risk.action === 'consider' || f.risk.action === 'optional'
|
|
119
|
+
}
|
package/skills/magpie/skill.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magpie",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Interactive PR review pipeline. Runs five parallel specialist subagents (security, bugs, performance, code-smells, architecture), dedupes findings, applies a critic rubric, peer-reviews via codex exec, and serves an interactive HTML report for selecting findings to post via gh. Bundles a Bun CLI installed separately via the skill's install.sh. Use when the user asks to review a GitHub pull request.",
|
|
5
5
|
"author": "iceinvein",
|
|
6
6
|
"type": "prompt",
|
|
7
|
-
"tools": [
|
|
7
|
+
"tools": [
|
|
8
|
+
"claude"
|
|
9
|
+
],
|
|
8
10
|
"files": {
|
|
9
11
|
"prompt": "SKILL.md"
|
|
10
12
|
},
|