@rvagg/marginalia 0.1.1 → 0.2.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/README.md +20 -13
- package/dist/anchor.test.js +81 -0
- package/dist/anchor.test.js.map +1 -0
- package/dist/file-order.test.js +23 -0
- package/dist/file-order.test.js.map +1 -0
- package/dist/file-tree.test.js +18 -0
- package/dist/file-tree.test.js.map +1 -0
- package/dist/http.js +56 -10
- package/dist/http.js.map +1 -1
- package/dist/http.test.js +75 -1
- package/dist/http.test.js.map +1 -1
- package/dist/mcp.js +8 -2
- package/dist/mcp.js.map +1 -1
- package/dist/mcp.test.js +42 -0
- package/dist/mcp.test.js.map +1 -1
- package/dist/server.js +5 -1
- package/dist/server.js.map +1 -1
- package/dist/threads.js +35 -0
- package/dist/threads.js.map +1 -0
- package/dist/threads.test.js +27 -0
- package/dist/threads.test.js.map +1 -0
- package/marginalia.png +0 -0
- package/package.json +1 -1
- package/ui/anchor.d.ts +12 -0
- package/ui/anchor.js +80 -0
- package/ui/app.js +936 -314
- package/ui/diff2html-theme.css +55 -40
- package/ui/file-order.d.ts +4 -0
- package/ui/file-order.js +26 -0
- package/ui/file-tree.d.ts +6 -0
- package/ui/file-tree.js +32 -0
- package/ui/index.html +38 -17
- package/ui/style.css +404 -143
package/ui/diff2html-theme.css
CHANGED
|
@@ -18,15 +18,19 @@
|
|
|
18
18
|
.d2h-file-header {
|
|
19
19
|
background: var(--mg-surface) !important;
|
|
20
20
|
border-bottom: 1px solid var(--mg-border) !important;
|
|
21
|
-
padding: 8px
|
|
21
|
+
padding: 6px 8px !important;
|
|
22
22
|
height: auto !important;
|
|
23
|
+
border-radius: 6px 6px 0 0 !important;
|
|
23
24
|
position: sticky !important;
|
|
24
25
|
top: 0 !important;
|
|
25
26
|
z-index: 2 !important;
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
.d2h-file-name-wrapper { background: transparent !important; font-size: 13px !important; }
|
|
29
|
-
|
|
29
|
+
.d2h-file-name-wrapper { background: transparent !important; font-size: 13px !important; align-items: center !important; }
|
|
30
|
+
/* GitHub's header shows neither a file icon nor a change badge. */
|
|
31
|
+
.d2h-file-name-wrapper > .d2h-icon, .d2h-file-name-wrapper .d2h-tag { display: none !important; }
|
|
32
|
+
.d2h-file-name { color: var(--mg-text) !important; font-family: var(--mg-mono) !important; font-size: 12px !important; margin-left: 4px !important; flex: 0 1 auto !important; min-width: 0 !important; }
|
|
33
|
+
.d2h-file-name-wrapper { min-width: 0 !important; }
|
|
30
34
|
.d2h-file-stats { font-size: 12px !important; }
|
|
31
35
|
.d2h-file-collapse { display: none !important; }
|
|
32
36
|
.d2h-file-diff { border: none !important; overflow: hidden !important; }
|
|
@@ -43,82 +47,93 @@
|
|
|
43
47
|
|
|
44
48
|
/* --- Line numbers: static table-cell instead of absolute --- */
|
|
45
49
|
|
|
50
|
+
/* diff2html's rtl gutter would put the new number first: GitHub puts old first. */
|
|
46
51
|
.d2h-code-linenumber {
|
|
52
|
+
direction: ltr !important;
|
|
47
53
|
position: static !important;
|
|
48
54
|
display: table-cell !important;
|
|
49
55
|
width: 1% !important;
|
|
50
56
|
white-space: nowrap !important;
|
|
51
57
|
vertical-align: top !important;
|
|
52
58
|
cursor: pointer !important;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
padding: 0 4px !important;
|
|
59
|
+
border: none !important;
|
|
60
|
+
padding: 0 !important;
|
|
56
61
|
font-size: 0 !important;
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
.line-num1, .line-num2 {
|
|
60
65
|
display: inline-block !important;
|
|
61
|
-
|
|
62
|
-
width:
|
|
63
|
-
text-align:
|
|
66
|
+
box-sizing: border-box !important;
|
|
67
|
+
width: 40px !important;
|
|
68
|
+
text-align: center !important;
|
|
64
69
|
float: none !important;
|
|
65
70
|
font-size: 12px !important;
|
|
66
|
-
line-height:
|
|
67
|
-
padding: 0
|
|
71
|
+
line-height: 20px !important;
|
|
72
|
+
padding: 0 !important;
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
/* --- Code line --- */
|
|
71
76
|
|
|
72
|
-
|
|
73
|
-
.d2h-code-line
|
|
74
|
-
.d2h-code-line-
|
|
77
|
+
/* Flex keeps the +/- prefix fixed while long code wraps beside it. */
|
|
78
|
+
.d2h-code-line { display: flex !important; padding: 0 !important; width: 100% !important; box-sizing: border-box !important; }
|
|
79
|
+
.d2h-code-line-prefix { flex: 0 0 20px !important; box-sizing: border-box !important; padding: 0 0 0 8px !important; line-height: 20px !important; }
|
|
80
|
+
.d2h-code-line-ctn { flex: 1 1 auto !important; min-width: 0 !important; font-family: var(--mg-mono) !important; font-size: 12px !important; line-height: 20px !important; padding: 0 8px 0 0 !important; white-space: pre-wrap !important; overflow-wrap: anywhere !important; }
|
|
81
|
+
td.d2h-info .d2h-code-line { padding-left: 20px !important; white-space: pre-wrap !important; overflow-wrap: anywhere !important; }
|
|
75
82
|
[data-theme="light"] .d2h-code-line-ctn { color: var(--mg-text) !important; }
|
|
76
83
|
|
|
77
|
-
/* --- Row colours: GitHub
|
|
84
|
+
/* --- Row colours: GitHub's palette ---
|
|
85
|
+
diff2html marks the cell, the line and its text alike; tint only the
|
|
86
|
+
cell, since dark mode's translucent tints would otherwise stack. */
|
|
78
87
|
|
|
79
|
-
|
|
80
|
-
.d2h-del { background: var(--mg-diff-del-line-bg) !important; }
|
|
81
|
-
.d2h-del .d2h-code-linenumber { background: var(--mg-diff-del-gutter-bg) !important; color: var(--mg-diff-line-number-color) !important; }
|
|
82
|
-
.d2h-del .d2h-code-line, .d2h-del .d2h-code-line-ctn { background: var(--mg-diff-del-line-bg) !important; }
|
|
88
|
+
.d2h-code-line, .d2h-code-line-ctn, .d2h-code-line-prefix { background: transparent !important; }
|
|
83
89
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
.d2h-
|
|
87
|
-
.d2h-
|
|
90
|
+
.d2h-code-linenumber { background: var(--mg-bg) !important; color: var(--mg-diff-line-number-color) !important; }
|
|
91
|
+
|
|
92
|
+
td.d2h-del { background: var(--mg-diff-del-line-bg) !important; }
|
|
93
|
+
td.d2h-code-linenumber.d2h-del { background: var(--mg-diff-del-gutter-bg) !important; color: var(--mg-diff-changed-number-color) !important; }
|
|
94
|
+
|
|
95
|
+
td.d2h-ins { background: var(--mg-diff-ins-line-bg) !important; }
|
|
96
|
+
td.d2h-code-linenumber.d2h-ins { background: var(--mg-diff-ins-gutter-bg) !important; color: var(--mg-diff-changed-number-color) !important; }
|
|
97
|
+
|
|
98
|
+
td.d2h-info { background: var(--mg-diff-hunk-bg) !important; }
|
|
99
|
+
td.d2h-code-linenumber.d2h-info { background: var(--mg-diff-hunk-gutter-bg) !important; }
|
|
100
|
+
.d2h-info .d2h-code-line, .d2h-info .d2h-code-line-ctn { color: var(--mg-diff-hunk-text) !important; }
|
|
88
101
|
|
|
89
102
|
/* Character-level highlights within changed lines */
|
|
90
|
-
.d2h-
|
|
103
|
+
.d2h-code-line-ctn del {
|
|
91
104
|
background: var(--mg-diff-del-word-bg) !important;
|
|
92
105
|
text-decoration: none !important;
|
|
93
106
|
border-radius: 2px;
|
|
94
107
|
}
|
|
95
108
|
|
|
96
|
-
.d2h-
|
|
109
|
+
.d2h-code-line-ctn ins {
|
|
97
110
|
background: var(--mg-diff-ins-word-bg) !important;
|
|
98
111
|
text-decoration: none !important;
|
|
99
112
|
border-radius: 2px;
|
|
100
113
|
}
|
|
101
114
|
|
|
102
|
-
/*
|
|
103
|
-
.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
.d2h-
|
|
107
|
-
.d2h-
|
|
108
|
-
.d2h-
|
|
115
|
+
/* --- Syntax: GitHub's current token colours ---
|
|
116
|
+
highlight.js's github themes carry GitHub's older palette. */
|
|
117
|
+
|
|
118
|
+
.d2h-code-line-ctn .hljs-keyword, .d2h-code-line-ctn .hljs-doctag, .d2h-code-line-ctn .hljs-template-tag,
|
|
119
|
+
.d2h-code-line-ctn .hljs-template-variable, .d2h-code-line-ctn .hljs-type, .d2h-code-line-ctn .hljs-variable.language_ { color: var(--mg-syntax-keyword); }
|
|
120
|
+
.d2h-code-line-ctn .hljs-title, .d2h-code-line-ctn .hljs-title.class_, .d2h-code-line-ctn .hljs-title.function_ { color: var(--mg-syntax-function); }
|
|
121
|
+
.d2h-code-line-ctn .hljs-attr, .d2h-code-line-ctn .hljs-attribute, .d2h-code-line-ctn .hljs-literal, .d2h-code-line-ctn .hljs-meta,
|
|
122
|
+
.d2h-code-line-ctn .hljs-number, .d2h-code-line-ctn .hljs-operator, .d2h-code-line-ctn .hljs-variable,
|
|
123
|
+
.d2h-code-line-ctn .hljs-selector-attr, .d2h-code-line-ctn .hljs-selector-class, .d2h-code-line-ctn .hljs-selector-id,
|
|
124
|
+
.d2h-code-line-ctn .hljs-section { color: var(--mg-syntax-constant); }
|
|
125
|
+
.d2h-code-line-ctn .hljs-string, .d2h-code-line-ctn .hljs-regexp, .d2h-code-line-ctn .hljs-meta .hljs-string { color: var(--mg-syntax-string); }
|
|
126
|
+
.d2h-code-line-ctn .hljs-built_in, .d2h-code-line-ctn .hljs-symbol, .d2h-code-line-ctn .hljs-bullet { color: var(--mg-syntax-variable); }
|
|
127
|
+
.d2h-code-line-ctn .hljs-comment, .d2h-code-line-ctn .hljs-code, .d2h-code-line-ctn .hljs-formula { color: var(--mg-syntax-comment); }
|
|
128
|
+
.d2h-code-line-ctn .hljs-name, .d2h-code-line-ctn .hljs-quote, .d2h-code-line-ctn .hljs-selector-tag,
|
|
129
|
+
.d2h-code-line-ctn .hljs-selector-pseudo { color: var(--mg-syntax-tag); }
|
|
130
|
+
.d2h-code-line-ctn .hljs-subst { color: var(--mg-text); }
|
|
109
131
|
|
|
110
132
|
/* --- Tags --- */
|
|
111
133
|
|
|
112
134
|
.d2h-tag { background: var(--mg-bg) !important; }
|
|
113
135
|
|
|
114
|
-
/* --- Dark mode diff colours --- */
|
|
115
|
-
|
|
116
|
-
[data-theme="dark"] .d2h-info { background: rgba(56, 139, 253, 0.1) !important; }
|
|
117
|
-
[data-theme="dark"] .d2h-info .d2h-code-linenumber { background: rgba(56, 139, 253, 0.1) !important; }
|
|
118
|
-
[data-theme="dark"] .d2h-info .d2h-code-line, [data-theme="dark"] .d2h-info .d2h-code-line-ctn { background: rgba(56, 139, 253, 0.1) !important; color: var(--mg-text-muted) !important; }
|
|
119
|
-
|
|
120
136
|
/* --- Viewed / collapsed --- */
|
|
121
137
|
|
|
122
138
|
.d2h-file-wrapper.mg-collapsed .d2h-file-diff { display: none !important; }
|
|
123
|
-
.d2h-file-wrapper.mg-collapsed {
|
|
124
|
-
.d2h-file-wrapper.mg-collapsed .d2h-file-header { border-bottom: none !important; }
|
|
139
|
+
.d2h-file-wrapper.mg-collapsed .d2h-file-header { border-bottom: none !important; border-radius: 6px !important; }
|
package/ui/file-order.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Orders a diff's files as GitHub's file tree lists them: at each level,
|
|
2
|
+
// directories before files, then by name.
|
|
3
|
+
|
|
4
|
+
const collator = new Intl.Collator(undefined, { sensitivity: 'base' })
|
|
5
|
+
|
|
6
|
+
export function compareTreePaths(a, b) {
|
|
7
|
+
const as = a.split('/')
|
|
8
|
+
const bs = b.split('/')
|
|
9
|
+
for (let i = 0; i < Math.min(as.length, bs.length); i++) {
|
|
10
|
+
if (as[i] === bs[i]) continue
|
|
11
|
+
const aIsDir = i < as.length - 1
|
|
12
|
+
const bIsDir = i < bs.length - 1
|
|
13
|
+
if (aIsDir !== bIsDir) return aIsDir ? -1 : 1
|
|
14
|
+
return collator.compare(as[i], bs[i]) || (as[i] < bs[i] ? -1 : 1)
|
|
15
|
+
}
|
|
16
|
+
return as.length - bs.length
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function sortFileDiffs(diffText) {
|
|
20
|
+
const start = diffText.search(/^diff --git /m)
|
|
21
|
+
if (start < 0) return diffText
|
|
22
|
+
const files = diffText.slice(start).split(/(?=^diff --git )/m)
|
|
23
|
+
const path = (chunk) => chunk.match(/^diff --git a\/.+? b\/(.+)$/m)?.[1] ?? ''
|
|
24
|
+
files.sort((x, y) => compareTreePaths(path(x), path(y)))
|
|
25
|
+
return diffText.slice(0, start) + files.join('')
|
|
26
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type TreeNode =
|
|
2
|
+
| { type: 'dir', name: string, path: string, children: TreeNode[] }
|
|
3
|
+
| { type: 'file', name: string, path: string }
|
|
4
|
+
|
|
5
|
+
/** Groups paths into a tree in GitHub's order, merging single-directory chains. */
|
|
6
|
+
export function buildTree(paths: string[]): TreeNode[]
|
package/ui/file-tree.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { compareTreePaths } from './file-order.js'
|
|
2
|
+
|
|
3
|
+
// Builds the file tree GitHub shows beside a diff: directories before files,
|
|
4
|
+
// and a directory holding only one directory merged with it ("src/lib").
|
|
5
|
+
export function buildTree(paths) {
|
|
6
|
+
const root = { type: 'dir', name: '', path: '', children: [] }
|
|
7
|
+
for (const path of [...paths].sort(compareTreePaths)) {
|
|
8
|
+
const parts = path.split('/')
|
|
9
|
+
let dir = root
|
|
10
|
+
for (let i = 0; i < parts.length - 1; i++) {
|
|
11
|
+
const dirPath = parts.slice(0, i + 1).join('/')
|
|
12
|
+
let next = dir.children.find(c => c.type === 'dir' && c.path === dirPath)
|
|
13
|
+
if (!next) {
|
|
14
|
+
next = { type: 'dir', name: parts[i], path: dirPath, children: [] }
|
|
15
|
+
dir.children.push(next)
|
|
16
|
+
}
|
|
17
|
+
dir = next
|
|
18
|
+
}
|
|
19
|
+
dir.children.push({ type: 'file', name: parts.at(-1), path })
|
|
20
|
+
}
|
|
21
|
+
root.children = root.children.map(compact)
|
|
22
|
+
return root.children
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function compact(node) {
|
|
26
|
+
if (node.type === 'file') return node
|
|
27
|
+
while (node.children.length === 1 && node.children[0].type === 'dir') {
|
|
28
|
+
const only = node.children[0]
|
|
29
|
+
node = { ...only, name: `${node.name}/${only.name}` }
|
|
30
|
+
}
|
|
31
|
+
return { ...node, children: node.children.map(compact) }
|
|
32
|
+
}
|
package/ui/index.html
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
<body>
|
|
15
15
|
|
|
16
16
|
<header id="header">
|
|
17
|
+
<button id="tree-toggle" class="mg-icon-btn" title="Show file tree" aria-pressed="false"></button>
|
|
17
18
|
<span class="brand">marginalia</span>
|
|
18
19
|
<span class="sep">·</span>
|
|
19
20
|
<span id="project-dir"></span>
|
|
@@ -21,23 +22,45 @@
|
|
|
21
22
|
<button id="base-pick" title="Choose a base">▾</button>
|
|
22
23
|
<datalist id="base-suggestions"></datalist>
|
|
23
24
|
<span class="sep">·</span>
|
|
24
|
-
<button id="file-count" title="Toggle file list"></button>
|
|
25
|
-
<span class="sep">·</span>
|
|
26
25
|
<span id="status">connecting...</span>
|
|
26
|
+
<button id="minimize-toggle" class="mg-icon-btn" title="Minimize comments" aria-pressed="false"></button>
|
|
27
|
+
<button id="comments-toggle" title="Comments" aria-pressed="false"><span id="comments-count"></span></button>
|
|
27
28
|
<button id="theme-toggle" title="Toggle dark mode"></button>
|
|
28
29
|
</header>
|
|
29
30
|
|
|
30
|
-
<div id="
|
|
31
|
-
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
</
|
|
31
|
+
<div id="workspace">
|
|
32
|
+
<aside id="file-tree" class="hidden" aria-label="Files">
|
|
33
|
+
<div class="mg-tree-header">
|
|
34
|
+
<strong>Files</strong> <span id="tree-count" class="mg-counter"></span>
|
|
35
|
+
</div>
|
|
36
|
+
<label class="mg-tree-filter">
|
|
37
|
+
<span class="mg-tree-filter-icon"></span>
|
|
38
|
+
<input id="tree-filter" type="search" placeholder="Filter files" spellcheck="false" autocomplete="off">
|
|
39
|
+
</label>
|
|
40
|
+
<ul id="tree-list" role="tree"></ul>
|
|
41
|
+
</aside>
|
|
42
|
+
<main id="diff-container">
|
|
43
|
+
<div id="loading-state">
|
|
44
|
+
<div class="spinner"></div>
|
|
45
|
+
<p>Connecting...</p>
|
|
46
|
+
</div>
|
|
47
|
+
<div id="empty-state" class="hidden">
|
|
48
|
+
<p>No changes detected. Edit some files and they will appear here.</p>
|
|
49
|
+
</div>
|
|
50
|
+
</main>
|
|
51
|
+
<aside id="comments-panel" class="hidden" aria-label="Comments">
|
|
52
|
+
<div class="mg-panel-header">
|
|
53
|
+
<strong>Comments</strong>
|
|
54
|
+
<button id="comments-close" class="mg-icon-btn" title="Close comments" aria-label="Close comments"></button>
|
|
55
|
+
</div>
|
|
56
|
+
<div class="mg-panel-tabs">
|
|
57
|
+
<button type="button" class="mg-segment" data-filter="all">All <span class="mg-counter"></span></button>
|
|
58
|
+
<button type="button" class="mg-segment" data-filter="unresolved">Unresolved <span class="mg-counter"></span></button>
|
|
59
|
+
</div>
|
|
60
|
+
<div class="mg-panel-summary"></div>
|
|
61
|
+
<div id="comments-list"></div>
|
|
62
|
+
</aside>
|
|
63
|
+
</div>
|
|
41
64
|
|
|
42
65
|
<div id="permission-bar" class="hidden">
|
|
43
66
|
<span id="permission-text"></span>
|
|
@@ -47,17 +70,15 @@
|
|
|
47
70
|
|
|
48
71
|
<footer id="chat-footer">
|
|
49
72
|
<div id="chat-toggle">
|
|
50
|
-
<
|
|
51
|
-
<input type="text" id="general-input" placeholder="general comment...">
|
|
73
|
+
<input type="text" id="general-input" placeholder="General comment">
|
|
52
74
|
<button id="general-send" class="small">Send</button>
|
|
53
75
|
</div>
|
|
54
|
-
<div id="chat-history" class="hidden"></div>
|
|
55
76
|
</footer>
|
|
56
77
|
|
|
57
78
|
<script src="https://cdn.jsdelivr.net/npm/diff2html@3/bundles/js/diff2html.min.js"></script>
|
|
58
79
|
<script src="https://cdn.jsdelivr.net/npm/diff2html@3/bundles/js/diff2html-ui.min.js"></script>
|
|
59
80
|
<script src="https://cdn.jsdelivr.net/npm/marked@17/lib/marked.umd.js"></script>
|
|
60
|
-
<script src="/app.js"></script>
|
|
81
|
+
<script type="module" src="/app.js"></script>
|
|
61
82
|
|
|
62
83
|
</body>
|
|
63
84
|
</html>
|