decklight 0.8.1 → 0.9.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/PLATFORM.md +666 -0
- package/README.md +224 -150
- package/SPEC.md +732 -886
- package/cli/agent-review.mjs +245 -0
- package/cli/agents.mjs +25 -5
- package/cli/associate.mjs +12 -12
- package/cli/audit.mjs +42 -10
- package/cli/banner.mjs +41 -17
- package/cli/bundle-audio.mjs +183 -0
- package/cli/bundle.mjs +383 -31
- package/cli/cast.mjs +7 -7
- package/cli/check.mjs +961 -0
- package/cli/clone-deck.mjs +179 -0
- package/cli/commands.mjs +345 -0
- package/cli/comments.mjs +64 -18
- package/cli/commit-flow.mjs +44 -19
- package/cli/commit-message.mjs +51 -74
- package/cli/commit-split.mjs +601 -0
- package/cli/deck-refs.mjs +59 -0
- package/cli/deck-routes.mjs +67 -0
- package/cli/deckfile.mjs +3 -5
- package/cli/decklight.mjs +68 -289
- package/cli/design-system-deps.mjs +209 -0
- package/cli/design-system-edit.mjs +194 -0
- package/cli/design-system-refs.mjs +409 -0
- package/cli/design-system.mjs +429 -0
- package/cli/doctor.mjs +115 -0
- package/cli/edit-git.mjs +353 -0
- package/cli/edit-handover.mjs +445 -0
- package/cli/edit-look.mjs +388 -0
- package/cli/edit-slides.mjs +683 -0
- package/cli/edit.mjs +2126 -842
- package/cli/enhance.mjs +483 -0
- package/cli/extension.mjs +10 -10
- package/cli/font-refs.mjs +273 -0
- package/cli/font.mjs +246 -0
- package/cli/git-tree.mjs +1 -1
- package/cli/git.mjs +65 -11
- package/cli/import.mjs +56 -10
- package/cli/init.mjs +400 -234
- package/cli/library.mjs +127 -0
- package/cli/loader.mjs +3 -1
- package/cli/marketplace.mjs +215 -21
- package/cli/narrate.mjs +176 -0
- package/cli/open-browser.mjs +63 -0
- package/cli/open.mjs +943 -0
- package/cli/pdf.mjs +41 -13
- package/cli/pkg.mjs +44 -2
- package/cli/plugin.mjs +43 -41
- package/cli/port-conflict.mjs +53 -23
- package/cli/pptx-export.mjs +57 -24
- package/cli/publish.mjs +8 -4
- package/cli/qr.mjs +1 -1
- package/cli/record.mjs +14 -12
- package/cli/remote.mjs +11 -11
- package/cli/restore.mjs +11 -4
- package/cli/review-ref.mjs +125 -0
- package/cli/review-remote.mjs +92 -48
- package/cli/review-routes.mjs +254 -0
- package/cli/review-store.mjs +47 -7
- package/cli/review-submit.mjs +47 -57
- package/cli/runtime-link.mjs +560 -0
- package/cli/serve.mjs +235 -44
- package/cli/setup.mjs +112 -0
- package/cli/sign.mjs +1 -1
- package/cli/skill-content.mjs +190 -33
- package/cli/skills.mjs +107 -24
- package/cli/start.mjs +110 -0
- package/cli/supervise.mjs +6 -6
- package/cli/theme-refs.mjs +515 -0
- package/cli/theme.mjs +181 -137
- package/cli/trust.mjs +83 -0
- package/cli/units.mjs +39 -42
- package/cli/update-check.mjs +1 -5
- package/cli/upgrade.mjs +194 -28
- package/cli/upstream.mjs +4 -3
- package/cli/util.mjs +4 -4
- package/cli/wizard.mjs +6 -6
- package/dist/build-info.json +1 -1
- package/dist/decklight.css +1126 -49
- package/dist/decklight.js +212 -115
- package/dist/decklight.js.map +4 -4
- package/docs/GLOSSARY.md +141 -0
- package/docs/architecture.svg +17 -17
- package/package.json +4 -2
- package/themes/README.md +9 -8
- package/themes/reveal-solarized.css +10 -0
- package/tools/args.mjs +20 -0
- package/tools/atomic-write.mjs +48 -0
- package/tools/brand-palette.mjs +717 -0
- package/tools/bridge.mjs +1 -1
- package/tools/build-groups.mjs +42 -0
- package/tools/color.mjs +48 -0
- package/tools/deck-html.mjs +396 -11
- package/tools/design-system-format.mjs +753 -0
- package/tools/elevenlabs-tts.mjs +110 -17
- package/tools/exec.mjs +1 -1
- package/tools/extension-check.mjs +31 -7
- package/tools/font-format.mjs +190 -0
- package/tools/font-stacks.mjs +24 -0
- package/tools/gemini-tts.mjs +3 -0
- package/tools/lipsync-config.mjs +103 -0
- package/tools/lipsync-engines.mjs +205 -2
- package/tools/lipsync-server.mjs +264 -41
- package/tools/lipsync.mjs +37 -18
- package/tools/local-voice.mjs +32 -42
- package/tools/narration-manifest.mjs +196 -0
- package/tools/narration-synth.mjs +416 -0
- package/tools/pptx.mjs +776 -19
- package/tools/publish-targets.mjs +1 -1
- package/tools/publish-voices.mjs +3 -3
- package/tools/recording-impact.mjs +7 -3
- package/tools/render-theme.mjs +33 -0
- package/tools/review-anchor.mjs +28 -12
- package/tools/semver.mjs +40 -0
- package/tools/sentences.mjs +180 -0
- package/tools/shot.mjs +14 -7
- package/tools/site-voices.mjs +232 -0
- package/tools/template-theme.mjs +1 -1
- package/tools/test-impact.mjs +17 -10
- package/tools/theme-check.mjs +30 -3
- package/tools/tts-cache.mjs +4 -3
- package/tools/tts-engines.mjs +38 -20
- package/tools/tts-setup.mjs +7 -7
- package/tools/video-options.mjs +34 -0
- package/tools/video.mjs +461 -48
- package/tools/voiceover-server.mjs +185 -104
- package/tools/voiceover.mjs +119 -261
- package/tools/zip.mjs +1 -1
- package/cli/dev.mjs +0 -623
- package/cli/present.mjs +0 -853
- package/cli/review.mjs +0 -361
- package/tools/publish-site-voices.mjs +0 -75
package/cli/comments.mjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
//
|
|
7
7
|
// decklight comments <deck.html> [--unresolved] [--all] [--import <file>] [--incoming]
|
|
8
8
|
//
|
|
9
|
-
// The author's side of
|
|
9
|
+
// The author's side of a review. Reads `<deck>.review.jsonl`, resolves
|
|
10
10
|
// every comment against the deck AS IT IS NOW, and prints it grouped by slide.
|
|
11
11
|
//
|
|
12
12
|
// Resolution is the whole job. A comment records the slide it was written on,
|
|
@@ -23,13 +23,56 @@ import { basename, dirname, relative, resolve } from 'node:path';
|
|
|
23
23
|
import { argReader, isMain } from '../tools/args.mjs';
|
|
24
24
|
import { sectionBodies, sectionInner, slideText, slideHeading } from '../tools/deck-html.mjs';
|
|
25
25
|
import { fingerprint, resolveAnchor, VERDICT_NOTE, foldReview } from '../tools/review-anchor.mjs';
|
|
26
|
-
import { reviewPathFor, parseReview, serializeRecord, mergeById } from './review-store.mjs';
|
|
26
|
+
import { reviewPathFor, parseReview, serializeRecord, mergeById, slugUser } from './review-store.mjs';
|
|
27
|
+
import { reviewState } from './review-ref.mjs';
|
|
28
|
+
import { reviewerIdentity } from './review-routes.mjs';
|
|
27
29
|
import { reviewsWaiting } from './review-remote.mjs';
|
|
28
30
|
import { findDeck } from './history.mjs';
|
|
29
|
-
import { gitAvailable, inGitRepo, gitAutocommit, oneline, git } from './git.mjs';
|
|
31
|
+
import { gitAvailable, inGitRepo, gitAutocommit, oneline, git, ensureReviewAttribute } from './git.mjs';
|
|
30
32
|
import { deckAt } from './restore.mjs';
|
|
31
33
|
|
|
34
|
+
const SUBMIT_USAGE = `usage: decklight comments submit <deck.html> [--pr] [--remote origin] [--dry-run]
|
|
35
|
+
push the comments you left to a branch of their own, for the author to read
|
|
36
|
+
|
|
37
|
+
the branch is review/<you>-<today>, and a second submit the same day lands on
|
|
38
|
+
the branch already there — a morning of reviewing is one branch, one PR
|
|
39
|
+
|
|
40
|
+
--pr also open a pull request (needs gh, signed in)
|
|
41
|
+
--remote NAME which remote to push to [origin]
|
|
42
|
+
--dry-run build the commit and stop before pushing anything
|
|
43
|
+
|
|
44
|
+
this pushes ONE FILE: the comments. Your branch, your working tree and your
|
|
45
|
+
index are never touched, and none of your own commits come along.
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* `decklight comments submit <deck>` — the reviewer's return path. Thin on
|
|
50
|
+
* purpose: everything that could be got wrong lives in cli/review-submit.mjs,
|
|
51
|
+
* where it is testable without a process. Here rather than a command of its
|
|
52
|
+
* own because it is the other half of comments: the same store, the same
|
|
53
|
+
* reviewer, and a person who typed one will look for the other here.
|
|
54
|
+
*/
|
|
55
|
+
async function submitSubcommand(args, { out = process.stdout } = {}) {
|
|
56
|
+
if (args.includes('--help') || args.includes('-h') || !args.filter((a) => !a.startsWith('-')).length) {
|
|
57
|
+
out.write(SUBMIT_USAGE);
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
const { opt } = argReader(args);
|
|
61
|
+
const deckArg = args.find((a) => !a.startsWith('-') && a !== opt('--remote'));
|
|
62
|
+
const deckPath = resolve(process.cwd(), deckArg);
|
|
63
|
+
if (!existsSync(deckPath)) { process.stderr.write(`decklight comments submit: no such deck: ${deckArg}\n`); return 1; }
|
|
64
|
+
const { submitReview } = await import('./review-submit.mjs');
|
|
65
|
+
try {
|
|
66
|
+
submitReview(deckPath, { out, pr: args.includes('--pr'), remote: opt('--remote', 'origin'), dryRun: args.includes('--dry-run') });
|
|
67
|
+
return 0;
|
|
68
|
+
} catch (e) {
|
|
69
|
+
process.stderr.write(`decklight comments submit: ${String(e?.message ?? e)}\n`);
|
|
70
|
+
return 1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
32
74
|
const HELP = `usage: decklight comments <deck.html> [--unresolved] [--all] [--import <file>] [--incoming]
|
|
75
|
+
decklight comments submit <deck.html> [--pr] [--remote origin] [--dry-run]
|
|
33
76
|
what reviewers said, resolved against the deck as it is now
|
|
34
77
|
|
|
35
78
|
--unresolved only the ones nobody has closed off
|
|
@@ -38,14 +81,14 @@ const HELP = `usage: decklight comments <deck.html> [--unresolved] [--all] [--im
|
|
|
38
81
|
already there, and commit it — the return path for a reviewer
|
|
39
82
|
who was sent the deck and has no clone
|
|
40
83
|
--incoming ask the remote what reviews are WAITING — the branches
|
|
41
|
-
\`decklight
|
|
84
|
+
\`decklight comments submit\` pushed that you have not merged
|
|
42
85
|
(--remote NAME to ask a remote other than origin)
|
|
43
86
|
--at ID show what the slide SAID when comment ID was written, beside
|
|
44
87
|
what it says now — the point of recording which commit a
|
|
45
88
|
comment was made against
|
|
46
89
|
|
|
47
90
|
comments live in <deck>.review.jsonl beside the deck; reviewers write them
|
|
48
|
-
with: decklight
|
|
91
|
+
with: decklight <deck.html> --no-trust (then M)
|
|
49
92
|
`;
|
|
50
93
|
|
|
51
94
|
/**
|
|
@@ -150,14 +193,13 @@ async function listIncoming(deckPath, { remote, name, out, err }) {
|
|
|
150
193
|
if (r.state === 'ok') {
|
|
151
194
|
for (const v of r.reviews) {
|
|
152
195
|
out.write(`${v.branch} ${v.comments} comment${v.comments === 1 ? '' : 's'}`
|
|
153
|
-
+ `${v.replies ? ` (+${v.replies} repl${v.replies === 1 ? 'y' : 'ies'})` : ''}`
|
|
154
196
|
+ `${v.unreadable ? ` (${v.unreadable} unreadable line${v.unreadable === 1 ? '' : 's'})` : ''}`
|
|
155
197
|
+ ` · ${v.who}${v.at ? ` · ${ago(v.at)}` : ''}\n`);
|
|
156
198
|
}
|
|
157
199
|
// The deck is the doorway: M shows these comments and T takes a review
|
|
158
200
|
// in. Plain git still works — merging the branch brings the sidecar
|
|
159
201
|
// through the union merge — for whoever prefers the terminal end to end.
|
|
160
|
-
out.write(`\ntake them in: decklight
|
|
202
|
+
out.write(`\ntake them in: decklight ${name} then M in the deck`
|
|
161
203
|
+ ` (or: git merge ${remote}/${r.reviews[0].branch})\n`);
|
|
162
204
|
return 0;
|
|
163
205
|
}
|
|
@@ -172,6 +214,9 @@ async function listIncoming(deckPath, { remote, name, out, err }) {
|
|
|
172
214
|
}
|
|
173
215
|
|
|
174
216
|
export function commentsMain(argv = process.argv.slice(2), { out = process.stdout, err = process.stderr } = {}) {
|
|
217
|
+
// `comments submit <deck>` is the reviewer's return path: the one-shot that
|
|
218
|
+
// pushes what is already written, dispatched here as the other half of comments
|
|
219
|
+
if (argv[0] === 'submit') return submitSubcommand(argv.slice(1), { out });
|
|
175
220
|
const { opt } = argReader(argv);
|
|
176
221
|
if (argv.includes('--help') || argv.includes('-h')) { out.write(HELP); return 0; }
|
|
177
222
|
|
|
@@ -230,7 +275,8 @@ export function commentsMain(argv = process.argv.slice(2), { out = process.stdou
|
|
|
230
275
|
out.write(`${basename(from)} → ${storeName}: ${added} new`
|
|
231
276
|
+ `${incoming.records.length - added ? `, ${incoming.records.length - added} already here` : ''}\n`);
|
|
232
277
|
if (gitAvailable(deckDir) && inGitRepo(deckDir)) {
|
|
233
|
-
const
|
|
278
|
+
const attr = ensureReviewAttribute(deckDir);
|
|
279
|
+
const ok = gitAutocommit(storePath, deckDir, `review: import ${added} comment(s) on ${name}`, { also: attr ? [attr] : [] });
|
|
234
280
|
out.write(ok ? ' committed\n' : ' not committed — nothing changed on disk\n');
|
|
235
281
|
}
|
|
236
282
|
out.write(` read them with: decklight comments ${relative(cwd, deckPath) || name}\n`);
|
|
@@ -244,10 +290,14 @@ export function commentsMain(argv = process.argv.slice(2), { out = process.stdou
|
|
|
244
290
|
// changed since" without being able to say HOW, and "how" is usually the
|
|
245
291
|
// whole question — a reviewer objecting to a sentence that is no longer
|
|
246
292
|
// there has either been answered already or been misread.
|
|
293
|
+
// Every reader from here folds the ONE review state (REVIEW, review-ref.mjs):
|
|
294
|
+
// the sidecar beside the deck and this user's own local review branches.
|
|
295
|
+
const state = () => reviewState(deckPath, slugUser(reviewerIdentity(deckDir)));
|
|
247
296
|
const atArg = opt('--at');
|
|
248
297
|
if (atArg !== undefined) {
|
|
249
|
-
|
|
250
|
-
|
|
298
|
+
const st = state();
|
|
299
|
+
if (!st.fileExists && !st.branches.length) { err.write(`decklight comments: ${name} has no comments\n`); return 1; }
|
|
300
|
+
const { records } = st;
|
|
251
301
|
const c = foldReview(records).find((x) => x.id === atArg);
|
|
252
302
|
if (!c) { err.write(`decklight comments: no comment [${atArg}] on ${name}\n`); return 1; }
|
|
253
303
|
if (!c.deck) {
|
|
@@ -290,14 +340,15 @@ export function commentsMain(argv = process.argv.slice(2), { out = process.stdou
|
|
|
290
340
|
}
|
|
291
341
|
|
|
292
342
|
// ── the listing ─────────────────────────────────────────────────────────
|
|
293
|
-
|
|
343
|
+
const st = state();
|
|
344
|
+
if (!st.fileExists && !st.branches.length) {
|
|
294
345
|
// Not an error: no comments is the state every deck starts in, and the
|
|
295
346
|
// useful answer is how somebody would leave one.
|
|
296
347
|
out.write(`${name} — no comments yet\n`);
|
|
297
|
-
out.write(` a reviewer leaves them with: decklight
|
|
348
|
+
out.write(` a reviewer leaves them with: decklight ${relative(cwd, deckPath) || name} --no-trust (then M)\n`);
|
|
298
349
|
return 0;
|
|
299
350
|
}
|
|
300
|
-
const { records, skipped } =
|
|
351
|
+
const { records, skipped } = st;
|
|
301
352
|
const slides = indexDeckFile(read(deckPath));
|
|
302
353
|
const all = foldReview(records);
|
|
303
354
|
const wantAll = argv.includes('--all');
|
|
@@ -351,11 +402,6 @@ export function commentsMain(argv = process.argv.slice(2), { out = process.stdou
|
|
|
351
402
|
out.write(`${indent}${who}${c.at ? ` · ${ago(c.at)}` : ''}${against(c)}`
|
|
352
403
|
+ `${c.resolved ? ' ✓ resolved' : ''} [${c.id}]\n`);
|
|
353
404
|
for (const line of String(c.body ?? '').split('\n')) out.write(`${indent} ${line}\n`);
|
|
354
|
-
for (const r of c.replies ?? []) {
|
|
355
|
-
const rw = r.by ? r.by.replace(/\s*<[^>]*>$/, '') : 'someone';
|
|
356
|
-
out.write(`${indent} ↳ ${rw}${r.at ? ` · ${ago(r.at)}` : ''}\n`);
|
|
357
|
-
for (const line of String(r.body ?? '').split('\n')) out.write(`${indent} ${line}\n`);
|
|
358
|
-
}
|
|
359
405
|
out.write('\n');
|
|
360
406
|
};
|
|
361
407
|
|
package/cli/commit-flow.mjs
CHANGED
|
@@ -57,30 +57,55 @@ export const NAG_AFTER_LINES = 40;
|
|
|
57
57
|
/**
|
|
58
58
|
* How much of the deck differs from HEAD, and whether anything does.
|
|
59
59
|
*
|
|
60
|
-
* `--numstat` over the deck
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
60
|
+
* `--numstat` over the deck and what `also` names (the review sidecar, which
|
|
61
|
+
* rides the deck's commits in write mode), because those are the only things
|
|
62
|
+
* decklight commits and the only things it is entitled to describe. A
|
|
63
|
+
* repository holding somebody's whole project reports its own state through
|
|
64
|
+
* git; this reports the deck's.
|
|
64
65
|
*
|
|
65
66
|
* A deck with no HEAD to compare against (the very first commit has not
|
|
66
67
|
* happened) counts as dirty with unknown size: there is something to commit,
|
|
67
68
|
* and no numstat can say how much.
|
|
68
69
|
*/
|
|
69
|
-
export function deckDirty(cwd, deckRel, { run = boundedGit } = {}) {
|
|
70
|
+
export function deckDirty(cwd, deckRel, { run = boundedGit, also = [] } = {}) {
|
|
71
|
+
let rels = [deckRel, ...also.filter(Boolean)];
|
|
70
72
|
let out;
|
|
71
|
-
try { out = run(['diff', '--numstat', 'HEAD', '--',
|
|
72
|
-
catch {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
//
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
73
|
+
try { out = run(['diff', '--numstat', 'HEAD', '--', ...rels], cwd); }
|
|
74
|
+
catch {
|
|
75
|
+
// Either there is no HEAD yet, or one of the EXTRA paths is one git will
|
|
76
|
+
// not take (outside the repository, a form it does not recognise). The
|
|
77
|
+
// deck alone tells the two apart: a deck git can diff has a HEAD.
|
|
78
|
+
if (rels.length > 1) {
|
|
79
|
+
rels = [deckRel];
|
|
80
|
+
try { out = run(['diff', '--numstat', 'HEAD', '--', deckRel], cwd); }
|
|
81
|
+
catch { return { dirty: true, lines: 0, firstCommit: true }; }
|
|
82
|
+
} else return { dirty: true, lines: 0, firstCommit: true };
|
|
81
83
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
let lines = 0;
|
|
85
|
+
const files = [];
|
|
86
|
+
for (const line of (out ?? '').split('\n').filter(Boolean)) {
|
|
87
|
+
const [add, del, file] = line.split('\t');
|
|
88
|
+
lines += (Number(add) || 0) + (Number(del) || 0);
|
|
89
|
+
if (file) files.push(file);
|
|
90
|
+
}
|
|
91
|
+
// `files` says WHICH of them changed, in the order asked, so the card can
|
|
92
|
+
// say "1 line in talk.review.jsonl" rather than naming the deck for a
|
|
93
|
+
// resolve the author pressed R for.
|
|
94
|
+
if (files.length) return { dirty: true, lines, files: rels.filter((r) => files.includes(r)) };
|
|
95
|
+
// Nothing against HEAD — but an untracked file has no diff either, and it
|
|
96
|
+
// is the most uncommitted a file can be. The deck untracked is the deck
|
|
97
|
+
// uncommitted; a sidecar untracked counts only if it is there to commit.
|
|
98
|
+
const untracked = [];
|
|
99
|
+
try { run(['ls-files', '--error-unmatch', '--', deckRel], cwd); }
|
|
100
|
+
catch { untracked.push(deckRel); }
|
|
101
|
+
if (!untracked.length) {
|
|
102
|
+
for (const rel of also.filter(Boolean)) {
|
|
103
|
+
let there = '';
|
|
104
|
+
try { there = run(['ls-files', '--others', '--exclude-standard', '--', rel], cwd); } catch { /* not ours to say */ }
|
|
105
|
+
if (there) untracked.push(rel);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return untracked.length ? { dirty: true, lines: 0, untracked: true, files: untracked } : { dirty: false, lines: 0 };
|
|
84
109
|
}
|
|
85
110
|
|
|
86
111
|
/**
|
|
@@ -107,7 +132,7 @@ export function snapshotWip(cwd, deckPath, deckRel, { exec = execFileSync, timeo
|
|
|
107
132
|
//
|
|
108
133
|
// EVERY call is bounded. This runs on a timer, on the server's event loop,
|
|
109
134
|
// and `execFileSync` blocks it for as long as the child takes — so a git that
|
|
110
|
-
// never returns does not cost a snapshot, it costs the whole
|
|
135
|
+
// never returns does not cost a snapshot, it costs the whole edit server:
|
|
111
136
|
// still listening, answering nothing, until somebody kills it. That is not a
|
|
112
137
|
// hypothetical. `git hash-object -w --stdin` was found wedged for eight hours
|
|
113
138
|
// with the server dead behind it, and because a `file://` deck probes the
|
|
@@ -150,7 +175,7 @@ export function nagText({ lines = 0, sinceMs = 0 } = {}) {
|
|
|
150
175
|
return `${size} uncommitted${mins >= 1 ? ` · ${age}` : ''}`;
|
|
151
176
|
}
|
|
152
177
|
|
|
153
|
-
/** The line
|
|
178
|
+
/** The line `open` prints when the snapshot is what stands behind the nag. */
|
|
154
179
|
export function wipLine(deckRel) {
|
|
155
180
|
return ` git: committing ${deckRel} when you say so — a silent snapshot rides on`
|
|
156
181
|
+ ` ${WIP_REF.replace('refs/', '')} in between (git show decklight/wip:${deckRel})`;
|
package/cli/commit-message.mjs
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
|
|
31
31
|
import { execFile } from 'node:child_process';
|
|
32
32
|
import { readFileSync } from 'node:fs';
|
|
33
|
-
import { basename, relative } from 'node:path';
|
|
33
|
+
import { basename, relative, resolve as resolvePath } from 'node:path';
|
|
34
34
|
import { agentAsk } from './agents.mjs';
|
|
35
35
|
import { commitSubject, git } from './git.mjs';
|
|
36
36
|
|
|
@@ -263,7 +263,7 @@ export function amendSubject(cwd, sha, subject, { run = git } = {}) {
|
|
|
263
263
|
}
|
|
264
264
|
|
|
265
265
|
/** Run the agent and resolve its stdout, or null. Never rejects. */
|
|
266
|
-
function ask(cmd, cwd, timeoutMs) {
|
|
266
|
+
export function ask(cmd, cwd, timeoutMs) {
|
|
267
267
|
return new Promise((resolve) => {
|
|
268
268
|
let done = false;
|
|
269
269
|
const finish = (v) => { if (!done) { done = true; resolve(v); } };
|
|
@@ -345,7 +345,7 @@ export async function describeCommit({
|
|
|
345
345
|
|
|
346
346
|
/**
|
|
347
347
|
* A subject for work that is NOT COMMITTED YET — what the commit overlay's
|
|
348
|
-
* "write
|
|
348
|
+
* "write them for me" button asks for.
|
|
349
349
|
*
|
|
350
350
|
* The same prompt, the same read-only argv, the same cap and the same stated
|
|
351
351
|
* truncation as `describeCommit`; three things differ, and each is because
|
|
@@ -366,17 +366,33 @@ export async function describeCommit({
|
|
|
366
366
|
export async function describeWorking({
|
|
367
367
|
cwd, deckPath, deckRel, template, agent = null,
|
|
368
368
|
env = process.env, timeoutMs = ASK_TIMEOUT_MS, run = git, exec = ask,
|
|
369
|
-
resolve = agentAsk, read = null,
|
|
369
|
+
resolve = agentAsk, read = null, also = [],
|
|
370
370
|
} = {}) {
|
|
371
371
|
const deck = basename(deckPath);
|
|
372
|
-
const cmd = resolve(agent, 'x', { env });
|
|
373
|
-
if (!cmd) return null;
|
|
374
372
|
const rel = deckRel || relative(cwd, deckPath) || deck;
|
|
375
373
|
|
|
376
374
|
let out_;
|
|
377
375
|
try { out_ = run(['diff', '--unified=1', 'HEAD', '--', rel], cwd) ?? ''; }
|
|
378
376
|
catch { return null; }
|
|
379
|
-
if (!out_.trim())
|
|
377
|
+
if (!out_.trim()) {
|
|
378
|
+
// The deck did not change. The review sidecar may have (REVIEW: it rides
|
|
379
|
+
// the deck's commits), and its lines are records, not prose: the subject
|
|
380
|
+
// is derived from them, with no agent in the loop, because "resolve
|
|
381
|
+
// Ana's comment on slide 2" is a fact and not a thing to make up.
|
|
382
|
+
for (const other of also.filter(Boolean)) {
|
|
383
|
+
let side = '';
|
|
384
|
+
try { side = run(['diff', '--unified=0', 'HEAD', '--', other], cwd) ?? ''; } catch { side = ''; }
|
|
385
|
+
if (!side.trim()) {
|
|
386
|
+
try { side = run(['ls-files', '--others', '--exclude-standard', '--', other], cwd) ? (read ?? readFileSync)(resolvePath(cwd, other), 'utf8').split('\n').map((l) => `+${l}`).join('\n') : ''; }
|
|
387
|
+
catch { side = ''; }
|
|
388
|
+
}
|
|
389
|
+
const subject = reviewSubject(side);
|
|
390
|
+
if (subject) return subject;
|
|
391
|
+
}
|
|
392
|
+
return null;
|
|
393
|
+
}
|
|
394
|
+
const cmd = resolve(agent, 'x', { env });
|
|
395
|
+
if (!cmd) return null;
|
|
380
396
|
const truncated = out_.length > MAX_DIFF;
|
|
381
397
|
const diff = truncated ? out_.slice(0, MAX_DIFF) : out_;
|
|
382
398
|
|
|
@@ -399,6 +415,34 @@ export async function describeWorking({
|
|
|
399
415
|
return subject === template ? null : subject;
|
|
400
416
|
}
|
|
401
417
|
|
|
418
|
+
/**
|
|
419
|
+
* A subject for a change that is only review records: the added lines of the
|
|
420
|
+
* sidecar's diff, read as records. One comment names its slide; several, or
|
|
421
|
+
* a mix, are counted. Null when nothing was added.
|
|
422
|
+
*/
|
|
423
|
+
export function reviewSubject(diff) {
|
|
424
|
+
const added = [];
|
|
425
|
+
for (const line of String(diff ?? '').split('\n')) {
|
|
426
|
+
if (!line.startsWith('+') || line.startsWith('+++')) continue;
|
|
427
|
+
try { added.push(JSON.parse(line.slice(1))); } catch { /* a half line is not a record */ }
|
|
428
|
+
}
|
|
429
|
+
if (!added.length) return null;
|
|
430
|
+
const comments = added.filter((r) => !r.op && r.id);
|
|
431
|
+
const ops = added.filter((r) => r.op);
|
|
432
|
+
const count = (n, what) => `${n} ${what}${n === 1 ? '' : 's'}`;
|
|
433
|
+
if (comments.length === 1 && !ops.length) return `review: a comment on slide ${comments[0].slide}`;
|
|
434
|
+
if (!comments.length && ops.length) {
|
|
435
|
+
const kinds = [...new Set(ops.map((r) => r.op))];
|
|
436
|
+
if (kinds.length === 1) {
|
|
437
|
+
const verb = { resolve: 'resolve', reopen: 'reopen', delete: 'delete', anchor: 'move' }[kinds[0]] ?? kinds[0];
|
|
438
|
+
return `review: ${verb} ${count(ops.length, 'comment')}`;
|
|
439
|
+
}
|
|
440
|
+
return `review: ${count(ops.length, 'change')} to comments`;
|
|
441
|
+
}
|
|
442
|
+
if (comments.length && !ops.length) return `review: ${count(comments.length, 'comment')}`;
|
|
443
|
+
return `review: ${count(comments.length, 'comment')}, ${count(ops.length, 'change')}`;
|
|
444
|
+
}
|
|
445
|
+
|
|
402
446
|
/** The startup line: what is on, who does it, and what leaves the machine. */
|
|
403
447
|
export function messagesLine(agentName) {
|
|
404
448
|
return agentName
|
|
@@ -406,70 +450,3 @@ export function messagesLine(agentName) {
|
|
|
406
450
|
: 'git: --commit-messages needs an agent on PATH — subjects stay generic';
|
|
407
451
|
}
|
|
408
452
|
|
|
409
|
-
/**
|
|
410
|
-
* Where the answer lives: git's own config, in the repository it is about.
|
|
411
|
-
*
|
|
412
|
-
* The setting only means anything when there IS a repository — it describes
|
|
413
|
-
* what happens to that repository's commits — so git config is where it
|
|
414
|
-
* belongs rather than a file decklight invents. It is per-repo, it survives,
|
|
415
|
-
* and it is inspectable and reversible with the tool the user already knows:
|
|
416
|
-
* `git config decklight.commit-messages false`.
|
|
417
|
-
*/
|
|
418
|
-
export const PREF_KEY = 'decklight.commit-messages';
|
|
419
|
-
|
|
420
|
-
/**
|
|
421
|
-
* The stored answer: true, false, or null when nobody has been asked yet.
|
|
422
|
-
*
|
|
423
|
-
* `git config --get` EXITS 1 for a key that is not set, and `git()` throws on a
|
|
424
|
-
* non-zero exit — so the unset case, which is every first run, arrives here as
|
|
425
|
-
* an exception rather than an empty string. Unreadable and unset are the same
|
|
426
|
-
* answer: nobody has said, so ask (or stay off).
|
|
427
|
-
*/
|
|
428
|
-
export function storedPref(cwd, { run = git } = {}) {
|
|
429
|
-
let v = '';
|
|
430
|
-
try { v = (run(['config', '--get', PREF_KEY], cwd) ?? '').trim(); } catch { return null; }
|
|
431
|
-
return v === 'true' ? true : v === 'false' ? false : null;
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
/**
|
|
435
|
-
* Remember the answer, so the next session does not ask again.
|
|
436
|
-
*
|
|
437
|
-
* Never fatal: this is a convenience, and a repository that refuses the write
|
|
438
|
-
* (a read-only config, a worktree in a strange state) should cost the user a
|
|
439
|
-
* repeated question, not a failed startup.
|
|
440
|
-
*/
|
|
441
|
-
export function rememberPref(cwd, on, { run = git } = {}) {
|
|
442
|
-
try { run(['config', PREF_KEY, on ? 'true' : 'false'], cwd); return true; } catch { return false; }
|
|
443
|
-
}
|
|
444
|
-
|
|
445
|
-
/**
|
|
446
|
-
* Whether to ask, and what the answer already is.
|
|
447
|
-
*
|
|
448
|
-
* Asked ONCE, at the moment a repository is created — the same moment the
|
|
449
|
-
* autocommit itself is offered, because that is when the commits this governs
|
|
450
|
-
* come into existence. An existing repository is never interrupted to be asked
|
|
451
|
-
* a new question; it uses the flag.
|
|
452
|
-
*
|
|
453
|
-
* The default is YES, and that is a defensible default only because it is a
|
|
454
|
-
* QUESTION. The permission is still explicitly given by a person who was told
|
|
455
|
-
* what leaves the machine — decklight still never infers it from what happens
|
|
456
|
-
* to be on PATH, which is the rule `lipsync --veo` follows. So: no agent
|
|
457
|
-
* installed, or no TTY to answer, means no question and no feature.
|
|
458
|
-
*/
|
|
459
|
-
export function planCommitMessages({
|
|
460
|
-
args = [], tty = false, agents = 0, creatingRepo = false, stored = null,
|
|
461
|
-
} = {}) {
|
|
462
|
-
if (args.includes('--no-commit-messages')) return { action: 'off' };
|
|
463
|
-
if (args.includes('--commit-messages')) return { action: 'on' };
|
|
464
|
-
if (stored !== null) return { action: stored ? 'on' : 'off' };
|
|
465
|
-
// Nothing to drive it, nothing to write the subjects with: the feature is
|
|
466
|
-
// unavailable, and offering it would be offering a switch wired to nothing.
|
|
467
|
-
if (!agents) return { action: 'skip' };
|
|
468
|
-
if (!creatingRepo) return { action: 'skip' };
|
|
469
|
-
return { action: tty ? 'ask' : 'skip' };
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
/** The question, worded so the cost is on screen before the answer is given. */
|
|
473
|
-
export const ASK_MESSAGES =
|
|
474
|
-
' let an agent write your commit subjects instead of "autosave"?'
|
|
475
|
-
+ ' (sends the deck\'s diffs to it) [Y/n] ';
|