@bugabinga/pi-ext-diff-review 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/PLAN.md +770 -0
- package/README.md +16 -0
- package/args.ts +101 -0
- package/assets/workflow_suite.gif +0 -0
- package/browser/assets/JetBrainsMonoNuguCode.LICENSE +96 -0
- package/browser/assets/JetBrainsMonoNuguCode.woff2 +0 -0
- package/browser/index.html +119 -0
- package/browser/index.ts +1184 -0
- package/browser/shadow-css.ts +179 -0
- package/browser/style.css +772 -0
- package/browser/theme.ts +49 -0
- package/bun.lock +407 -0
- package/bundle.ts +75 -0
- package/constants.ts +14 -0
- package/format.ts +74 -0
- package/git.ts +299 -0
- package/index.ts +157 -0
- package/open-browser.ts +39 -0
- package/package.json +24 -0
- package/scripts/browser-regression.ts +206 -0
- package/scripts/build-browser.ts +56 -0
- package/scripts/smoke-browser.ts +268 -0
- package/server.ts +361 -0
- package/session-state.ts +37 -0
- package/types.ts +130 -0
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# diff-review
|
|
2
|
+
|
|
3
|
+
Browser-based git diff review bridge for Pi.
|
|
4
|
+
|
|
5
|
+
Opens a local browser UI for reviewing diffs and sending findings back to Pi.
|
|
6
|
+
|
|
7
|
+
## Commands
|
|
8
|
+
|
|
9
|
+
- `/diff-review`
|
|
10
|
+
- `/diff-review-cancel`
|
|
11
|
+
|
|
12
|
+
## Demo
|
|
13
|
+
|
|
14
|
+
<!-- demo:workflow_suite:start -->
|
|
15
|
+

|
|
16
|
+
<!-- demo:workflow_suite:end -->
|
package/args.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { ReviewSource } from "./types.js";
|
|
2
|
+
|
|
3
|
+
export type DiffReviewArgs = {
|
|
4
|
+
staged: boolean;
|
|
5
|
+
base?: string;
|
|
6
|
+
files?: string[];
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function parseArgs(input: string): DiffReviewArgs {
|
|
10
|
+
const tokens = tokenize(input);
|
|
11
|
+
const args: DiffReviewArgs = { staged: false };
|
|
12
|
+
|
|
13
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
14
|
+
const token = tokens[i];
|
|
15
|
+
if (token === "--staged") {
|
|
16
|
+
args.staged = true;
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (token === "--base") {
|
|
20
|
+
const value = tokens[++i];
|
|
21
|
+
if (!value) throw new Error("--base requires a ref");
|
|
22
|
+
args.base = value;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
if (token.startsWith("--base=")) {
|
|
26
|
+
args.base = token.slice("--base=".length);
|
|
27
|
+
if (!args.base) throw new Error("--base requires a ref");
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (token === "--files") {
|
|
31
|
+
const value = tokens[++i];
|
|
32
|
+
if (!value) throw new Error("--files requires a comma-separated list");
|
|
33
|
+
args.files = parseFiles(value);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (token.startsWith("--files=")) {
|
|
37
|
+
args.files = parseFiles(token.slice("--files=".length));
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
throw new Error(`Unknown argument: ${token}`);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (args.staged && args.base) throw new Error("--staged and --base are mutually exclusive");
|
|
44
|
+
return args;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function sourceFromArgs(args: DiffReviewArgs): ReviewSource {
|
|
48
|
+
if (args.base) return { kind: "base", base: args.base, ...(args.files && { files: args.files }) };
|
|
49
|
+
if (args.staged) return { kind: "staged", ...(args.files && { files: args.files }) };
|
|
50
|
+
return { kind: "working-tree", ...(args.files && { files: args.files }) };
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function parseFiles(value: string): string[] {
|
|
54
|
+
const files = value.split(",").map((file) => file.trim()).filter(Boolean);
|
|
55
|
+
if (files.length === 0) throw new Error("--files requires at least one path");
|
|
56
|
+
for (const file of files) validatePathFilter(file);
|
|
57
|
+
return files;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function validatePathFilter(path: string) {
|
|
61
|
+
if (path.startsWith("/") || /^[a-zA-Z]:[\\/]/.test(path)) throw new Error(`Path must be relative: ${path}`);
|
|
62
|
+
if (path.split(/[\\/]+/).includes("..")) throw new Error(`Path cannot contain '..': ${path}`);
|
|
63
|
+
if (path.includes("\0")) throw new Error("Path cannot contain NUL");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function tokenize(input: string): string[] {
|
|
67
|
+
const tokens: string[] = [];
|
|
68
|
+
let current = "";
|
|
69
|
+
let quote: '"' | "'" | undefined;
|
|
70
|
+
let escaping = false;
|
|
71
|
+
|
|
72
|
+
for (const ch of input.trim()) {
|
|
73
|
+
if (escaping) {
|
|
74
|
+
current += ch;
|
|
75
|
+
escaping = false;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
if (ch === "\\" && quote !== "'") {
|
|
79
|
+
escaping = true;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
if ((ch === '"' || ch === "'") && !quote) {
|
|
83
|
+
quote = ch;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (ch === quote) {
|
|
87
|
+
quote = undefined;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (/\s/.test(ch) && !quote) {
|
|
91
|
+
if (current) tokens.push(current);
|
|
92
|
+
current = "";
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
current += ch;
|
|
96
|
+
}
|
|
97
|
+
if (escaping) current += "\\";
|
|
98
|
+
if (quote) throw new Error("Unclosed quote in arguments");
|
|
99
|
+
if (current) tokens.push(current);
|
|
100
|
+
return tokens;
|
|
101
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
JetBrains Mono Nugu Code Font
|
|
2
|
+
Copyright 2020 The JetBrains Mono Project Authors (https://github.com/JetBrains/JetBrainsMono)
|
|
3
|
+
Portions Copyright 2014-2024 Ryan L McIntyre (Nerd Fonts, https://github.com/ryanoasis/nerd-fonts)
|
|
4
|
+
|
|
5
|
+
This font is a patched derivative of JetBrains Mono with Nerd Font icon glyphs
|
|
6
|
+
added, then subset to only the glyphs needed for code review display ("Nugu Code").
|
|
7
|
+
|
|
8
|
+
Licensed under the SIL Open Font License, Version 1.1.
|
|
9
|
+
See the full license text below.
|
|
10
|
+
|
|
11
|
+
-----------------------------------------------------------
|
|
12
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
13
|
+
-----------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
PREAMBLE
|
|
16
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
17
|
+
development of collaborative font projects, to support the font creation
|
|
18
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
19
|
+
open framework in which fonts may be shared and improved in partnership
|
|
20
|
+
with others.
|
|
21
|
+
|
|
22
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
23
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
24
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
25
|
+
redistributed and/or sold with any software provided that any reserved
|
|
26
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
27
|
+
however, cannot be released under any other type of license. The
|
|
28
|
+
requirement for fonts to remain under this license does not apply
|
|
29
|
+
to any document created using the fonts or their derivatives.
|
|
30
|
+
|
|
31
|
+
DEFINITIONS
|
|
32
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
33
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
34
|
+
include source files, build scripts and documentation.
|
|
35
|
+
|
|
36
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
37
|
+
copyright statement(s).
|
|
38
|
+
|
|
39
|
+
"Original Version" refers to the collection of Font Software components as
|
|
40
|
+
distributed by the Copyright Holder(s).
|
|
41
|
+
|
|
42
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
43
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
44
|
+
Original Version, by changing formats or by porting the Font Software to
|
|
45
|
+
a new environment.
|
|
46
|
+
|
|
47
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
48
|
+
writer or other person who contributed to the Font Software.
|
|
49
|
+
|
|
50
|
+
PERMISSION & CONDITIONS
|
|
51
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
52
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
53
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
54
|
+
Software, subject to the following conditions:
|
|
55
|
+
|
|
56
|
+
1) Neither the Font Software nor any of its individual components,
|
|
57
|
+
in Original or Modified Versions, may be sold by itself.
|
|
58
|
+
|
|
59
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
60
|
+
redistributed and/or sold with any software, provided that each copy
|
|
61
|
+
contains the above copyright notice and this license. These can be
|
|
62
|
+
included either as stand-alone text files, human-readable headers or
|
|
63
|
+
in the appropriate machine-readable metadata fields within text or
|
|
64
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
65
|
+
|
|
66
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
67
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
68
|
+
Copyright Holder. This restriction only applies to the primary font name
|
|
69
|
+
as presented to the users.
|
|
70
|
+
|
|
71
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the
|
|
72
|
+
Font Software shall not be used to promote, endorse or advertise any
|
|
73
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
74
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
75
|
+
permission.
|
|
76
|
+
|
|
77
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
78
|
+
must be distributed entirely under this license, and must not be
|
|
79
|
+
distributed under any other license. The requirement for fonts to
|
|
80
|
+
remain under this license does not apply to any document created
|
|
81
|
+
using the fonts or their derivatives.
|
|
82
|
+
|
|
83
|
+
TERMINATION
|
|
84
|
+
This license becomes null and void if any of the above conditions are
|
|
85
|
+
not met.
|
|
86
|
+
|
|
87
|
+
DISCLAIMER
|
|
88
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
89
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
90
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
91
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
92
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
93
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
94
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
95
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
96
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>Pi Diff Review</title>
|
|
7
|
+
<link rel="icon" href="data:," />
|
|
8
|
+
<script>
|
|
9
|
+
(() => {
|
|
10
|
+
const mode = localStorage.getItem("diff-review-theme") || "system";
|
|
11
|
+
const systemLight = matchMedia("(prefers-color-scheme: light)").matches;
|
|
12
|
+
document.documentElement.dataset.themeMode = mode;
|
|
13
|
+
document.documentElement.dataset.theme = mode === "system" ? (systemLight ? "light" : "dark") : mode;
|
|
14
|
+
})();
|
|
15
|
+
</script>
|
|
16
|
+
<link rel="stylesheet" href="/static/app.css" />
|
|
17
|
+
</head>
|
|
18
|
+
<body>
|
|
19
|
+
<div id="app">
|
|
20
|
+
<aside id="sidebar">
|
|
21
|
+
<div class="brand">
|
|
22
|
+
<div>
|
|
23
|
+
<h1>Diff Review</h1>
|
|
24
|
+
<div class="subtitle">Pi × Pierre</div>
|
|
25
|
+
</div>
|
|
26
|
+
<label class="theme-label" aria-label="Theme mode">
|
|
27
|
+
<span class="theme-icon" aria-hidden="true">◐</span>
|
|
28
|
+
<select id="theme-mode" aria-label="Theme mode">
|
|
29
|
+
<option value="system" selected>system</option>
|
|
30
|
+
<option value="dark">dark</option>
|
|
31
|
+
<option value="light">light</option>
|
|
32
|
+
</select>
|
|
33
|
+
</label>
|
|
34
|
+
</div>
|
|
35
|
+
<div id="meta"></div>
|
|
36
|
+
<div id="tree"></div>
|
|
37
|
+
</aside>
|
|
38
|
+
|
|
39
|
+
<div id="left-splitter" class="splitter" role="separator" aria-label="Resize file tree" aria-orientation="vertical">
|
|
40
|
+
<button id="toggle-left" class="pane-toggle" type="button" aria-label="Collapse file tree">‹</button>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<main id="main">
|
|
44
|
+
<header id="topbar">
|
|
45
|
+
<div>
|
|
46
|
+
<div class="topbar-title">Review changed lines</div>
|
|
47
|
+
<div id="summary">Select a changed line to add a finding.</div>
|
|
48
|
+
</div>
|
|
49
|
+
<div class="topbar-actions">
|
|
50
|
+
<div id="search-wrap" class="search-wrap">
|
|
51
|
+
<input id="search" type="text" role="searchbox" placeholder="Search code…" autocomplete="off" spellcheck="false" aria-label="Search code in diff" />
|
|
52
|
+
<button id="search-clear" class="search-clear" type="button" aria-label="Clear code search">×</button>
|
|
53
|
+
<span id="search-badge" class="search-badge" hidden></span>
|
|
54
|
+
<div id="search-results" class="search-results" hidden></div>
|
|
55
|
+
</div>
|
|
56
|
+
<div id="finding-count" class="count-pill">0 findings</div>
|
|
57
|
+
</div>
|
|
58
|
+
</header>
|
|
59
|
+
<div id="diffs"></div>
|
|
60
|
+
<section id="inline-finding" class="inline-finding" aria-label="New finding" hidden>
|
|
61
|
+
<div class="inline-head">
|
|
62
|
+
<div>
|
|
63
|
+
<div class="inline-title">New finding</div>
|
|
64
|
+
<div id="selection" class="selection-empty">Click an added or deleted line.</div>
|
|
65
|
+
</div>
|
|
66
|
+
<button id="inline-cancel" class="inline-close" type="button" aria-label="Close finding input">×</button>
|
|
67
|
+
</div>
|
|
68
|
+
<div class="field-row">
|
|
69
|
+
<label>Severity
|
|
70
|
+
<select id="severity">
|
|
71
|
+
<option value="high">🔥 high</option>
|
|
72
|
+
<option value="medium" selected>😒 medium</option>
|
|
73
|
+
<option value="low">🦟 low</option>
|
|
74
|
+
</select>
|
|
75
|
+
<div class="field-subtitle" id="severity-sub">suspicious little gremlin</div>
|
|
76
|
+
</label>
|
|
77
|
+
<label>Category
|
|
78
|
+
<select id="category">
|
|
79
|
+
<option value="bug" selected>🐛 bug</option>
|
|
80
|
+
<option value="style">💅 style</option>
|
|
81
|
+
<option value="perf">🐌 perf</option>
|
|
82
|
+
<option value="question">🤨 question</option>
|
|
83
|
+
</select>
|
|
84
|
+
<div class="field-subtitle" id="category-sub">exquisite disaster</div>
|
|
85
|
+
</label>
|
|
86
|
+
</div>
|
|
87
|
+
<label>Finding
|
|
88
|
+
<textarea id="comment" rows="5" placeholder="Describe the issue or question for this line"></textarea>
|
|
89
|
+
</label>
|
|
90
|
+
<button id="add" disabled>Add finding</button>
|
|
91
|
+
</section>
|
|
92
|
+
</main>
|
|
93
|
+
|
|
94
|
+
<div id="right-splitter" class="splitter" role="separator" aria-label="Resize review panel" aria-orientation="vertical">
|
|
95
|
+
<button id="toggle-right" class="pane-toggle" type="button" aria-label="Collapse review panel">›</button>
|
|
96
|
+
</div>
|
|
97
|
+
|
|
98
|
+
<aside id="drawer">
|
|
99
|
+
<section class="card findings-card">
|
|
100
|
+
<div class="card-title findings-title"><span>Collected findings</span><span id="drawer-count">0</span></div>
|
|
101
|
+
<div id="findings" class="empty-list">No findings yet.</div>
|
|
102
|
+
</section>
|
|
103
|
+
|
|
104
|
+
<section class="card">
|
|
105
|
+
<div class="card-title">Review notes</div>
|
|
106
|
+
<textarea id="notes" rows="4" placeholder="Optional context for the whole review"></textarea>
|
|
107
|
+
</section>
|
|
108
|
+
|
|
109
|
+
<footer class="actions">
|
|
110
|
+
<button id="cancel">Cancel</button>
|
|
111
|
+
<button id="submit">Send to Pi</button>
|
|
112
|
+
</footer>
|
|
113
|
+
</aside>
|
|
114
|
+
|
|
115
|
+
<div id="status" role="status" aria-live="polite">Ready</div>
|
|
116
|
+
</div>
|
|
117
|
+
<script type="module" src="/static/app.js"></script>
|
|
118
|
+
</body>
|
|
119
|
+
</html>
|