@warren-dean/code-kit 0.26.0 → 0.26.2
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +17 -0
- package/hooks/lib/next.mjs +7 -0
- package/hooks/lib/plan.mjs +110 -14
- package/hooks/lib/storymap.mjs +54 -17
- package/hooks/lib/timeline.mjs +77 -44
- package/hooks/mod/board.mjs +44 -58
- package/hooks/mod/characters.mjs +96 -174
- package/hooks/mod/register.mjs +9 -2
- package/hooks/mod/surface/character.mjs +1 -1
- package/package.json +1 -1
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"name": "code-kit",
|
|
10
10
|
"source": "./",
|
|
11
11
|
"description": "Keeps AI coding agents inside your project's rules, from idea to merged code: spec design, lanes, layer rules, protected paths with an approval log, spec-check and design gates, proof-before-finish checks, dispatch, review, build status and CI verification, configured per project from its docs",
|
|
12
|
-
"version": "0.26.
|
|
12
|
+
"version": "0.26.2",
|
|
13
13
|
"category": "development",
|
|
14
14
|
"tags": ["guardrails", "architecture", "lanes", "layers", "spec-driven", "ci", "multi-agent"],
|
|
15
15
|
"license": "MIT"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "code-kit",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.2",
|
|
4
4
|
"description": "Keeps AI coding agents inside your project's rules, from idea to merged code: spec design, lanes, layer rules, protected paths with an approval log, spec-check and design gates, proof-before-finish checks, dispatch, review, build status and CI verification, configured per project from its docs",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Warren Langeveldt"
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
What changed in each release of code-kit, newest first. Versions follow the plugin manifest and the npm package `@warren-dean/code-kit`. Each release is also on [GitHub Releases](https://github.com/warrendeanlangeveldt/code-kit/releases).
|
|
4
4
|
|
|
5
|
+
## 0.26.2 (2026-10-26)
|
|
6
|
+
|
|
7
|
+
The lanes pane tells the truth about what's being built, and is easier to read.
|
|
8
|
+
|
|
9
|
+
- A lane no longer says "building" when nothing is building it. A story whose branch had merged, but whose line in the plan hadn't moved on, read as in progress forever and held its lane, so nothing new was sent to it. Now a story is in progress only while an agent's claim names it or you have its branch checked out. One whose work has merged counts as done, and `code-kit next` lists the plan lines that are out of date. One whose agent stopped before its first commit is ready again, and `next` sends it to a fresh agent and says why.
|
|
10
|
+
- In a project with a long history, the plan's git reads no longer come back empty.
|
|
11
|
+
- The lane characters are smaller, 8 by 8 pixels (four rows), and every pose is redrawn. A resting lane shows a "z".
|
|
12
|
+
- The keys line shows each key once (`j: down · k: up · ⏎: open · f: filter · l: journal`), and a lane's action buttons no longer show their key twice.
|
|
13
|
+
|
|
14
|
+
## 0.26.1 (2026-10-26)
|
|
15
|
+
|
|
16
|
+
`/lanes` opens in large projects again.
|
|
17
|
+
|
|
18
|
+
- In a project with hundreds of stories, `/lanes` failed to open: reading the project's state made a git call or more per story, and took longer than the 30 seconds Claude Code gives a mod's command. `code-kit status`, `timeline`, `journal` and `trail` now read every branch in a few git calls, and answer in a couple of seconds however many stories there are.
|
|
19
|
+
- A read that doesn't answer in time no longer stops the pane opening: the pane shows everything else.
|
|
20
|
+
- A story's start on the lanes' timelines is now when its branch was made, not the time of the commit it branched from.
|
|
21
|
+
|
|
5
22
|
## 0.26.0 (2026-10-26)
|
|
6
23
|
|
|
7
24
|
The lanes pane is redesigned around what needs you, a lane's work survives its agent stopping, and merged work reaches the remote.
|
package/hooks/lib/next.mjs
CHANGED
|
@@ -265,6 +265,13 @@ export function nextStep(root, base) {
|
|
|
265
265
|
`The plan's status lines are out of date for ${status.drift.map((d) => d.story).join(', ')}.`,
|
|
266
266
|
);
|
|
267
267
|
|
|
268
|
+
// A lane's story whose agent stopped before its first commit is ready again, for a fresh agent.
|
|
269
|
+
const stopped = status.stories.filter((s) => s.stopped).map((s) => s.id);
|
|
270
|
+
if (stopped.length)
|
|
271
|
+
attention.push(
|
|
272
|
+
`${stopped.join(', ')} ${stopped.length === 1 ? 'has its branch but no commits, and no agent on it' : 'have their branches but no commits, and no agent on them'}: ${stopped.length === 1 ? 'it goes' : 'they go'} to a fresh agent, on the same branch.`,
|
|
273
|
+
);
|
|
274
|
+
|
|
268
275
|
// A branch already in the merge queue has passed its review: it isn't reviewed again.
|
|
269
276
|
const queued = waiting(readQueue(root)).map((e) => e.branch);
|
|
270
277
|
const ids = (state) =>
|
package/hooks/lib/plan.mjs
CHANGED
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
// `**Requirements:** none` marks a story that delivers no requirement, such as a spike.
|
|
7
7
|
import { execFileSync } from 'node:child_process';
|
|
8
8
|
import { existsSync, readdirSync, readFileSync, statSync } from 'node:fs';
|
|
9
|
-
import { join } from 'node:path';
|
|
9
|
+
import { isAbsolute, join } from 'node:path';
|
|
10
|
+
import { laneClaims } from './laneclaims.mjs';
|
|
10
11
|
import { waitingStories } from './questions.mjs';
|
|
11
12
|
import { sentBack } from './reviews.mjs';
|
|
13
|
+
import { WORKTREES_DIR } from './worktrees.mjs';
|
|
12
14
|
|
|
13
15
|
export const REQUIREMENT = /\b(?!ST-)([A-Z][A-Z0-9]*-\d+)\b/g;
|
|
14
16
|
const STORY_HEADING = /^###\s+(ST-\d+)\b\s*(.*)$/;
|
|
@@ -155,17 +157,65 @@ const git = (root, ...args) => {
|
|
|
155
157
|
return execFileSync('git', ['-C', root, ...args], {
|
|
156
158
|
encoding: 'utf8',
|
|
157
159
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
160
|
+
// A long-lived project's log runs to megabytes.
|
|
161
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
158
162
|
}).trim();
|
|
159
163
|
} catch {
|
|
160
164
|
return null;
|
|
161
165
|
}
|
|
162
166
|
};
|
|
163
167
|
|
|
168
|
+
/**
|
|
169
|
+
* Every local and origin branch in one read: { ref: { sha, ahead } }, `ahead` the commits it has that
|
|
170
|
+
* `base` hasn't. A project with hundreds of stories has hundreds of branches, and a git call each
|
|
171
|
+
* outlasts the mod's 30 seconds. Git before 2.41 can't count them in the same read: `ahead` is then
|
|
172
|
+
* null, and counted for each branch as it's asked for.
|
|
173
|
+
*/
|
|
174
|
+
export function branchRefs(root, base) {
|
|
175
|
+
const read = (format) =>
|
|
176
|
+
git(root, 'for-each-ref', `--format=${format}`, 'refs/heads', 'refs/remotes/origin');
|
|
177
|
+
const counted = read(`%(refname)%09%(objectname)%09%(ahead-behind:${base})`);
|
|
178
|
+
const out = counted ?? read('%(refname)%09%(objectname)') ?? '';
|
|
179
|
+
const refs = {};
|
|
180
|
+
for (const line of out.split('\n').filter(Boolean)) {
|
|
181
|
+
const [ref, sha, aheadBehind] = line.split('\t');
|
|
182
|
+
refs[ref] = { sha, ahead: counted === null ? null : Number(aheadBehind.split(' ')[0]) };
|
|
183
|
+
}
|
|
184
|
+
return refs;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* How each local branch was made, from its reflog's oldest entry: (branch) => { sha, at } (the commit
|
|
189
|
+
* it was made at, and when, in milliseconds), or null once the reflog is gone. Read from the file git
|
|
190
|
+
* keeps it in, or from git where there's no file (a reftable repository).
|
|
191
|
+
*/
|
|
192
|
+
export function branchMaking(root) {
|
|
193
|
+
const common = git(root, 'rev-parse', '--git-common-dir');
|
|
194
|
+
const dir = common ? (isAbsolute(common) ? common : join(root, common)) : null;
|
|
195
|
+
return (branch) => {
|
|
196
|
+
if (!dir) return null;
|
|
197
|
+
try {
|
|
198
|
+
const first = readFileSync(join(dir, 'logs/refs/heads', branch), 'utf8').split('\n')[0];
|
|
199
|
+
const [head] = first.split('\t');
|
|
200
|
+
const sha = head.split(' ')[1];
|
|
201
|
+
const at = head.match(/> (\d+) [+-]\d{4}$/)?.[1];
|
|
202
|
+
return sha && at ? { sha, at: Number(at) * 1000 } : null;
|
|
203
|
+
} catch {
|
|
204
|
+
const oldest = (
|
|
205
|
+
git(root, 'reflog', 'show', '--date=unix', '--format=%H %gd', `refs/heads/${branch}`) ?? ''
|
|
206
|
+
)
|
|
207
|
+
.split('\n')
|
|
208
|
+
.filter(Boolean)
|
|
209
|
+
.at(-1)
|
|
210
|
+
?.match(/^([0-9a-f]+) .*@\{(\d+)\}$/);
|
|
211
|
+
return oldest ? { sha: oldest[1], at: Number(oldest[2]) * 1000 } : null;
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
164
216
|
/** The ref of a branch, local first, then on origin; null when neither exists. */
|
|
165
|
-
function branchRef(
|
|
166
|
-
|
|
167
|
-
if (git(root, 'rev-parse', '--verify', '--quiet', ref) !== null) return ref;
|
|
168
|
-
return null;
|
|
217
|
+
function branchRef(refs, branch) {
|
|
218
|
+
return [`refs/heads/${branch}`, `refs/remotes/origin/${branch}`].find((r) => refs[r]) ?? null;
|
|
169
219
|
}
|
|
170
220
|
|
|
171
221
|
/** Worktree path of each checked-out branch: { branch: path }. */
|
|
@@ -184,33 +234,79 @@ function worktrees(root) {
|
|
|
184
234
|
/**
|
|
185
235
|
* Where each story is. The plan's `done` stands (the lead marks it after merging, and merged
|
|
186
236
|
* branches are often deleted or squashed). Otherwise git decides: a branch with commits not in
|
|
187
|
-
* `base` is in review
|
|
188
|
-
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
237
|
+
* `base` is in review. A branch still at the commit a review sent back is `sent back`, waiting for
|
|
238
|
+
* its lane's fix. Without a branch, the plan's status stands. A story is `blocked` while a story it
|
|
239
|
+
* depends on isn't done, whatever its branch holds; a todo story whose dependencies are done is `ready`.
|
|
240
|
+
* A story with an open question for the person that holds it (`code-kit ask --blocks`) is `waiting on
|
|
241
|
+
* you`.
|
|
242
|
+
*
|
|
243
|
+
* A branch level with the base is in progress while something builds it: a live claim of its lane (an
|
|
244
|
+
* agent at work on it, SCHED-1), or the branch checked out where a person works (the main checkout, or a
|
|
245
|
+
* worktree of theirs). With nothing on it, it's done when its commits merged (the plan had it in review,
|
|
246
|
+
* the branch moved since it was made, or with no reflog, the base names the story or merged the branch),
|
|
247
|
+
* whatever the plan says yet. A lane's branch that never moved is `stopped`: its agent stopped before its
|
|
248
|
+
* first commit, and the story is ready again (or blocked) for a fresh agent, so its lane isn't held by
|
|
249
|
+
* nothing. A branch only on origin may be a teammate's, and stays in progress unless the base holds it.
|
|
192
250
|
*/
|
|
193
251
|
export function storyStates(root, stories, base) {
|
|
194
252
|
const trees = worktrees(root);
|
|
195
253
|
const backs = sentBack(root);
|
|
254
|
+
const refs = branchRefs(root, base);
|
|
255
|
+
const live = new Set(
|
|
256
|
+
laneClaims(root)
|
|
257
|
+
.filter((c) => !c.stale)
|
|
258
|
+
.map((c) => `${c.lane}|${c.story ?? ''}`),
|
|
259
|
+
);
|
|
260
|
+
// What the base already holds: the stories its commits name, and the story branches merged into it.
|
|
261
|
+
const onBase = { stories: new Set(), branches: new Set() };
|
|
262
|
+
for (const m of (git(root, 'log', base, '--format=%B%x1e') ?? '').matchAll(
|
|
263
|
+
/(?:^|[^A-Za-z0-9-])(ST-\d+)(?!\d)|([A-Za-z0-9_.-]+\/st-\d+)(?![\w-])/gim,
|
|
264
|
+
))
|
|
265
|
+
if (m[1]) onBase.stories.add(m[1]);
|
|
266
|
+
else onBase.branches.add(m[2].toLowerCase());
|
|
267
|
+
const making = branchMaking(root);
|
|
268
|
+
const merged = (story, branch) =>
|
|
269
|
+
onBase.stories.has(story.id) || onBase.branches.has(branch.toLowerCase());
|
|
270
|
+
const agentTree = (path) => path?.split('\\').join('/').includes(`/${WORKTREES_DIR}/`);
|
|
271
|
+
const builtBy = (story, branch) =>
|
|
272
|
+
live.has(`${story.lane}|${story.id}`) ||
|
|
273
|
+
live.has(`${story.lane}|`) ||
|
|
274
|
+
(trees[branch] !== undefined && !agentTree(trees[branch]));
|
|
196
275
|
const states = stories.map((story) => {
|
|
197
276
|
const branch = storyBranch(story);
|
|
198
|
-
const ref = story.lane ? branchRef(
|
|
199
|
-
const ahead = ref
|
|
277
|
+
const ref = story.lane ? branchRef(refs, branch) : null;
|
|
278
|
+
const ahead = !ref
|
|
279
|
+
? 0
|
|
280
|
+
: (refs[ref].ahead ?? Number(git(root, 'rev-list', '--count', `${base}..${ref}`) ?? 0));
|
|
200
281
|
let state = story.status;
|
|
282
|
+
let stopped = false;
|
|
201
283
|
if (ref && story.status !== 'done') {
|
|
202
|
-
const head = backs[branch] ?
|
|
284
|
+
const head = backs[branch] ? refs[ref].sha : null;
|
|
203
285
|
if (head && head === backs[branch].sha) state = 'sent back';
|
|
204
286
|
else if (ahead > 0) state = 'review';
|
|
205
|
-
else
|
|
287
|
+
else if (story.status === 'review') state = 'done';
|
|
288
|
+
else if (builtBy(story, branch)) state = 'in progress';
|
|
289
|
+
else {
|
|
290
|
+
// Level with the base, and nothing on it: its commits merged (the plan may not say so yet), or
|
|
291
|
+
// none was made. A local branch's reflog says which: it moved from the commit it was made at only
|
|
292
|
+
// by being committed to. Without one, the base's own log says whether it holds the story's work.
|
|
293
|
+
const made = ref.startsWith('refs/heads/') ? making(branch) : null;
|
|
294
|
+
if (made ? made.sha !== refs[ref].sha : merged(story, branch)) state = 'done';
|
|
295
|
+
else if (made && ![LEAD, DESIGN].includes(story.lane)) {
|
|
296
|
+
state = 'todo';
|
|
297
|
+
stopped = true;
|
|
298
|
+
} else state = 'in progress';
|
|
299
|
+
}
|
|
206
300
|
}
|
|
207
301
|
return {
|
|
208
302
|
...story,
|
|
209
303
|
branch,
|
|
210
304
|
branchExists: Boolean(ref),
|
|
305
|
+
ref,
|
|
211
306
|
ahead,
|
|
212
307
|
worktree: trees[branch] ?? null,
|
|
213
308
|
state,
|
|
309
|
+
stopped,
|
|
214
310
|
waitingOn: [],
|
|
215
311
|
};
|
|
216
312
|
});
|
package/hooks/lib/storymap.mjs
CHANGED
|
@@ -12,7 +12,7 @@ const git = (root, ...args) => {
|
|
|
12
12
|
return execFileSync('git', ['-C', root, ...args], {
|
|
13
13
|
encoding: 'utf8',
|
|
14
14
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
15
|
-
maxBuffer:
|
|
15
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
16
16
|
});
|
|
17
17
|
} catch {
|
|
18
18
|
return '';
|
|
@@ -23,28 +23,64 @@ const git = (root, ...args) => {
|
|
|
23
23
|
const KIT = /^(\.claude|\.ctx|\.github)\//;
|
|
24
24
|
const isCode = (rel) => CODE.test(rel) && !KIT.test(rel);
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Every story's files from one pass over the history: { id: Set of files }, from the commits on any
|
|
28
|
+
* branch whose message names it, as `storyFiles` finds them one story at a time. A project with hundreds
|
|
29
|
+
* of stories outlasts the mod's 30 seconds with a `git log --all` each.
|
|
30
|
+
*/
|
|
31
|
+
export function namedFiles(root) {
|
|
32
|
+
const byStory = {};
|
|
33
|
+
const log = git(root, 'log', '--all', '--no-merges', '--format=%x1e%B%x1f', '--name-only');
|
|
34
|
+
for (const commit of log.split('\x1e')) {
|
|
35
|
+
const end = commit.indexOf('\x1f');
|
|
36
|
+
if (end < 0) continue;
|
|
37
|
+
// As storyFiles' grep: "ST-1" mustn't match "ST-12", nor "XST-1".
|
|
38
|
+
const ids = new Set(
|
|
39
|
+
[...commit.slice(0, end).matchAll(/(?:^|[^A-Za-z0-9-])(ST-\d+)(?!\d)/gm)].map((m) => m[1]),
|
|
40
|
+
);
|
|
41
|
+
if (!ids.size) continue;
|
|
42
|
+
const files = commit
|
|
43
|
+
.slice(end + 1)
|
|
44
|
+
.split('\n')
|
|
45
|
+
.filter(Boolean);
|
|
46
|
+
for (const id of ids) {
|
|
47
|
+
byStory[id] ??= new Set();
|
|
48
|
+
for (const f of files) byStory[id].add(f);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return byStory;
|
|
52
|
+
}
|
|
53
|
+
|
|
26
54
|
/**
|
|
27
55
|
* The code files a story changed: those in commits whose message names it (on any branch, so a merged
|
|
28
56
|
* story still has its files) and, while its branch is open, its diff against the base. Only files that
|
|
29
|
-
* still exist, in path order.
|
|
57
|
+
* still exist, in path order. `named` is `namedFiles`', where the caller reads every story.
|
|
30
58
|
*/
|
|
31
|
-
export function storyFiles(root, story, from) {
|
|
59
|
+
export function storyFiles(root, story, from, named = null) {
|
|
32
60
|
const found = new Set();
|
|
33
61
|
const id = story.id;
|
|
34
|
-
const log =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
62
|
+
const log = named
|
|
63
|
+
? [...(named[id] ?? [])].join('\n')
|
|
64
|
+
: git(
|
|
65
|
+
root,
|
|
66
|
+
'log',
|
|
67
|
+
'--all',
|
|
68
|
+
'--no-merges',
|
|
69
|
+
'-E',
|
|
70
|
+
// POSIX ERE has no \b: "ST-1" mustn't match "ST-12".
|
|
71
|
+
`--grep=(^|[^A-Za-z0-9-])${id}([^0-9]|$)`,
|
|
72
|
+
'--format=',
|
|
73
|
+
'--name-only',
|
|
74
|
+
);
|
|
45
75
|
for (const f of log.split('\n')) if (f) found.add(f);
|
|
46
|
-
|
|
47
|
-
|
|
76
|
+
// A branch the base already holds has nothing of its own to diff.
|
|
77
|
+
if (story.branchExists && story.branch && story.ahead !== 0)
|
|
78
|
+
for (const f of git(
|
|
79
|
+
root,
|
|
80
|
+
'diff',
|
|
81
|
+
'--name-only',
|
|
82
|
+
`${from}...${story.ref ?? story.branch}`,
|
|
83
|
+
).split('\n'))
|
|
48
84
|
if (f) found.add(f);
|
|
49
85
|
return [...found].filter((f) => isCode(f) && existsSync(join(root, f))).sort();
|
|
50
86
|
}
|
|
@@ -133,8 +169,9 @@ export function storyMap(root, story, config, from) {
|
|
|
133
169
|
*/
|
|
134
170
|
export function trail(root, status, from) {
|
|
135
171
|
const byStory = new Map();
|
|
172
|
+
const named = namedFiles(root);
|
|
136
173
|
const filesOf = (s) => {
|
|
137
|
-
if (!byStory.has(s.id)) byStory.set(s.id, storyFiles(root, s, from));
|
|
174
|
+
if (!byStory.has(s.id)) byStory.set(s.id, storyFiles(root, s, from, named));
|
|
138
175
|
return byStory.get(s.id);
|
|
139
176
|
};
|
|
140
177
|
return status.requirements
|
package/hooks/lib/timeline.mjs
CHANGED
|
@@ -2,11 +2,43 @@
|
|
|
2
2
|
// records: when its branch was made, its commits, its merge into the base, its send-backs and the
|
|
3
3
|
// approvals its commits logged. The mod draws these as a bar per lane on a shared time axis.
|
|
4
4
|
import { execFileSync } from 'node:child_process';
|
|
5
|
+
import { branchMaking } from './plan.mjs';
|
|
5
6
|
import { APPROVAL_LOG } from './rules.mjs';
|
|
6
7
|
import { sendBacks } from './reviews.mjs';
|
|
7
8
|
|
|
8
9
|
const escape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
9
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Each object asked for, read by one `git cat-file --batch`: { name: text }, a missing one left out.
|
|
13
|
+
* One process for every branch's approval log, where a `git show` each outlasts the mod's 30 seconds.
|
|
14
|
+
*/
|
|
15
|
+
export function readObjects(root, names) {
|
|
16
|
+
if (!names.length) return {};
|
|
17
|
+
let out;
|
|
18
|
+
try {
|
|
19
|
+
out = execFileSync('git', ['-C', root, 'cat-file', '--batch'], {
|
|
20
|
+
input: `${names.join('\n')}\n`,
|
|
21
|
+
stdio: ['pipe', 'pipe', 'ignore'],
|
|
22
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
23
|
+
});
|
|
24
|
+
} catch {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
const found = {};
|
|
28
|
+
let at = 0;
|
|
29
|
+
for (const name of names) {
|
|
30
|
+
const eol = out.indexOf(10, at);
|
|
31
|
+
if (eol < 0) break;
|
|
32
|
+
const header = out.subarray(at, eol).toString('utf8').split(' ');
|
|
33
|
+
at = eol + 1;
|
|
34
|
+
if (header[1] === 'missing' || header.length < 3) continue;
|
|
35
|
+
const size = Number(header[2]);
|
|
36
|
+
found[name] = out.subarray(at, at + size).toString('utf8');
|
|
37
|
+
at += size + 1;
|
|
38
|
+
}
|
|
39
|
+
return found;
|
|
40
|
+
}
|
|
41
|
+
|
|
10
42
|
/**
|
|
11
43
|
* For each story with a branch, or done: { id, lane, branch, state, started, lastCommit, merged,
|
|
12
44
|
* sentBack: [ms], approvals: [{ at, names }] }, times in milliseconds or null.
|
|
@@ -29,49 +61,50 @@ export function storyTimes(root, stories, base) {
|
|
|
29
61
|
return { at: Number(t) * 1000, subject: subject.join('\t') };
|
|
30
62
|
});
|
|
31
63
|
const backs = sendBacks(root);
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
64
|
+
const onBase = new Set(lines(git('show', `${base}:${APPROVAL_LOG}`)));
|
|
65
|
+
const shown = stories.filter((s) => s.branchExists || s.state === 'done');
|
|
66
|
+
const refOf = (s) => s.ref ?? `refs/heads/${s.branch}`;
|
|
67
|
+
const logs = readObjects(
|
|
68
|
+
root,
|
|
69
|
+
shown.filter((s) => s.branchExists).map((s) => `${refOf(s)}:${APPROVAL_LOG}`),
|
|
70
|
+
);
|
|
71
|
+
const making = branchMaking(root);
|
|
72
|
+
return shown.map((s) => {
|
|
73
|
+
const b = s.branch;
|
|
74
|
+
// A branch only on origin has no reflog here.
|
|
75
|
+
const local = s.branchExists && refOf(s).startsWith('refs/heads/');
|
|
76
|
+
const made = local ? (making(b)?.at ?? null) : null;
|
|
77
|
+
// Only a branch ahead of the base has commits of its own.
|
|
78
|
+
const commits =
|
|
79
|
+
s.branchExists && s.ahead !== 0
|
|
80
|
+
? lines(git('log', '--format=%ct', `${base}..${refOf(s)}`)).map((t) => Number(t) * 1000)
|
|
41
81
|
: [];
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
: null,
|
|
71
|
-
lastCommit: commits.length ? Math.max(...commits) : null,
|
|
72
|
-
merged,
|
|
73
|
-
sentBack: backs.filter((x) => x.branch === b).map((x) => Date.parse(x.at)),
|
|
74
|
-
approvals,
|
|
75
|
-
};
|
|
76
|
-
});
|
|
82
|
+
const named = new RegExp(`(^|[\\s'"])${escape(b)}($|[\\s'"])`);
|
|
83
|
+
const merged = merges.find((m) => named.test(m.subject))?.at ?? null;
|
|
84
|
+
const approvals = s.branchExists
|
|
85
|
+
? lines(logs[`${refOf(s)}:${APPROVAL_LOG}`] ?? '')
|
|
86
|
+
.filter((l) => !onBase.has(l))
|
|
87
|
+
.flatMap((l) => {
|
|
88
|
+
try {
|
|
89
|
+
const e = JSON.parse(l);
|
|
90
|
+
return e.grantedAt || e.at
|
|
91
|
+
? [{ at: Date.parse(e.grantedAt ?? e.at), names: [e.approval].filter(Boolean) }]
|
|
92
|
+
: [];
|
|
93
|
+
} catch {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
: [];
|
|
98
|
+
return {
|
|
99
|
+
id: s.id,
|
|
100
|
+
lane: s.lane,
|
|
101
|
+
branch: b,
|
|
102
|
+
state: s.state,
|
|
103
|
+
started: made ? made : commits.length ? Math.min(...commits) : null,
|
|
104
|
+
lastCommit: commits.length ? Math.max(...commits) : null,
|
|
105
|
+
merged,
|
|
106
|
+
sentBack: backs.filter((x) => x.branch === b).map((x) => Date.parse(x.at)),
|
|
107
|
+
approvals,
|
|
108
|
+
};
|
|
109
|
+
});
|
|
77
110
|
}
|
package/hooks/mod/board.mjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// built right?), Queue and Log, each with a status line first and no room taken when it has nothing to
|
|
4
4
|
// say; the full views opened from a story or a command; three layouts. Pure functions from what the
|
|
5
5
|
// mod already holds to elements, so they're tested with node at every width (UI-13).
|
|
6
|
-
import { charactersOf, characterFrame, characterSvg, POSES, workOf } from './characters.mjs';
|
|
6
|
+
import { SIZE, charactersOf, characterFrame, characterSvg, POSES, workOf } from './characters.mjs';
|
|
7
7
|
import { BAR, rasterCells, runs, timelineSvg } from './art.mjs';
|
|
8
8
|
import { goalOf } from './mission.mjs';
|
|
9
9
|
import { CELL, cellOf, laneActions, laneStories, storyToOpen } from './panes.mjs';
|
|
@@ -370,8 +370,8 @@ export function poseFor(lane, { live = null, waiting = false, stalled = false, q
|
|
|
370
370
|
export const layoutOf = (placement, columns) =>
|
|
371
371
|
placement === 'inline' ? 'inline' : columns >= 110 ? 'wide' : 'docked';
|
|
372
372
|
|
|
373
|
-
/** The rows a lane card takes:
|
|
374
|
-
export const CARD_ROWS =
|
|
373
|
+
/** The rows a lane card takes: its five lines of words (the character's four beside them), and its border. */
|
|
374
|
+
export const CARD_ROWS = 7;
|
|
375
375
|
/** The columns a lane card takes where cards sit side by side: its character, its words, its frame. */
|
|
376
376
|
export const CARD_COLUMNS = 44;
|
|
377
377
|
/** The fewest columns a card is drawn in. */
|
|
@@ -473,7 +473,10 @@ export function keysFor(sel, { acts = [], view = null, loop = null, story = fals
|
|
|
473
473
|
...(view === 'trail' ? [{ key: '←→', label: 'requirement' }] : []),
|
|
474
474
|
{ key: 'esc', label: 'back' },
|
|
475
475
|
];
|
|
476
|
-
const keys = [
|
|
476
|
+
const keys = [
|
|
477
|
+
{ key: 'j', label: 'down' },
|
|
478
|
+
{ key: 'k', label: 'up' },
|
|
479
|
+
];
|
|
477
480
|
if (sel) keys.push({ key: '⏎', label: 'open' });
|
|
478
481
|
if (sel?.kind === 'lane' && story) {
|
|
479
482
|
keys.push({ key: 't', label: 'trail' }, { key: 'c', label: 'map' });
|
|
@@ -547,14 +550,19 @@ export function board(view, els, on) {
|
|
|
547
550
|
const still = (name, pose) => {
|
|
548
551
|
const grid = characterFrame(pose, 0, looks[name], { motion: 'off' });
|
|
549
552
|
if (surface === 'terminal' && els.Raster)
|
|
550
|
-
return els.Raster({
|
|
553
|
+
return els.Raster({
|
|
554
|
+
key: `char-${name}`,
|
|
555
|
+
columns: SIZE,
|
|
556
|
+
rows: SIZE / 2,
|
|
557
|
+
cells: rasterCells(grid),
|
|
558
|
+
});
|
|
551
559
|
if (els.Svg)
|
|
552
560
|
return els.Svg({
|
|
553
561
|
key: `char-${name}`,
|
|
554
562
|
source: characterSvg(pose, looks[name], { motion: 'off' }),
|
|
555
563
|
alt: `${name}: ${POSES[pose]?.words ?? pose}`,
|
|
556
|
-
width:
|
|
557
|
-
height:
|
|
564
|
+
width: SIZE * 3,
|
|
565
|
+
height: SIZE * 3,
|
|
558
566
|
});
|
|
559
567
|
return text(POSES[pose]?.glyph ?? '·');
|
|
560
568
|
};
|
|
@@ -566,16 +574,16 @@ export function board(view, els, on) {
|
|
|
566
574
|
key: `char-${name}`,
|
|
567
575
|
module: './surface/character.mjs',
|
|
568
576
|
props: { look: looks[name], pose, move, motion },
|
|
569
|
-
width:
|
|
570
|
-
height:
|
|
577
|
+
width: SIZE,
|
|
578
|
+
height: SIZE / 2,
|
|
571
579
|
});
|
|
572
580
|
if (surface === 'desktop' && els.Svg && motion !== 'off' && !faulted)
|
|
573
581
|
return els.Svg({
|
|
574
582
|
key: `char-${name}-${move?.key ?? pose}`,
|
|
575
583
|
source: characterSvg(move ? move.kind : pose, looks[name]),
|
|
576
584
|
alt: `${name}: ${POSES[move?.kind ?? pose]?.words ?? pose}`,
|
|
577
|
-
width:
|
|
578
|
-
height:
|
|
585
|
+
width: SIZE * 3,
|
|
586
|
+
height: SIZE * 3,
|
|
579
587
|
});
|
|
580
588
|
return still(name, pose);
|
|
581
589
|
};
|
|
@@ -832,7 +840,7 @@ export function board(view, els, on) {
|
|
|
832
840
|
: []),
|
|
833
841
|
];
|
|
834
842
|
};
|
|
835
|
-
const cardRoom = Math.max(4, (layout === 'docked' ? columns : CARD_COLUMNS) -
|
|
843
|
+
const cardRoom = Math.max(4, (layout === 'docked' ? columns : CARD_COLUMNS) - (SIZE + 7));
|
|
836
844
|
const chips = (l, story) =>
|
|
837
845
|
mapChips(view.maps?.[story?.id], view.trouble?.[l.name]).map((c, i) =>
|
|
838
846
|
text(c.layer, {
|
|
@@ -1036,7 +1044,8 @@ export function board(view, els, on) {
|
|
|
1036
1044
|
...acts.map((a) =>
|
|
1037
1045
|
Button({
|
|
1038
1046
|
key: `act-${a.id}`,
|
|
1039
|
-
|
|
1047
|
+
// Drawn as "w: Watch": the hotkey shows once, before the word.
|
|
1048
|
+
label: a.label,
|
|
1040
1049
|
...(ACT_KEY[a.id] ? { hotkey: ACT_KEY[a.id] } : {}),
|
|
1041
1050
|
plain: true,
|
|
1042
1051
|
onPress: () => on.onLane(a.id, l),
|
|
@@ -1335,54 +1344,31 @@ export function board(view, els, on) {
|
|
|
1335
1344
|
loop,
|
|
1336
1345
|
story: Boolean(selectedLane && storyOf(selectedLane)),
|
|
1337
1346
|
});
|
|
1347
|
+
// A key the pane answers itself is a Button, drawn as its hotkey and word; the rest are words alike.
|
|
1348
|
+
const bound = {
|
|
1349
|
+
j: ['move-next', () => on.onMove(1)],
|
|
1350
|
+
k: ['move-prev', () => on.onMove(-1)],
|
|
1351
|
+
f: ['filter-focus', () => on.onFocusSearch()],
|
|
1352
|
+
l: ['open-journal', () => on.onView('journal')],
|
|
1353
|
+
};
|
|
1338
1354
|
const keysLine = Box({
|
|
1339
1355
|
key: 'keys',
|
|
1340
1356
|
flexDirection: 'row',
|
|
1341
1357
|
columnGap: 1,
|
|
1342
1358
|
flexWrap: 'wrap',
|
|
1343
|
-
children: [
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
}),
|
|
1352
|
-
Button({
|
|
1353
|
-
key: 'move-prev',
|
|
1354
|
-
label: 'k',
|
|
1355
|
-
hotkey: 'k',
|
|
1356
|
-
plain: true,
|
|
1357
|
-
dimColor: true,
|
|
1358
|
-
onPress: () => on.onMove(-1),
|
|
1359
|
-
}),
|
|
1360
|
-
Button({
|
|
1361
|
-
key: 'filter-focus',
|
|
1362
|
-
label: 'f',
|
|
1363
|
-
hotkey: 'f',
|
|
1364
|
-
plain: true,
|
|
1365
|
-
dimColor: true,
|
|
1366
|
-
onPress: () => on.onFocusSearch(),
|
|
1367
|
-
}),
|
|
1368
|
-
Button({
|
|
1369
|
-
key: 'open-journal',
|
|
1370
|
-
label: 'l',
|
|
1371
|
-
hotkey: 'l',
|
|
1372
|
-
plain: true,
|
|
1373
|
-
dimColor: true,
|
|
1374
|
-
onPress: () => on.onView('journal'),
|
|
1375
|
-
}),
|
|
1376
|
-
Box({
|
|
1377
|
-
flexShrink: 1,
|
|
1378
|
-
children: [
|
|
1379
|
-
text(keys.map((k) => `${k.key} ${k.label}`).join(' · '), {
|
|
1359
|
+
children: keys.flatMap((k, i) => [
|
|
1360
|
+
...(i ? [text('·', { key: `keys-dot-${i}`, dimColor: true })] : []),
|
|
1361
|
+
bound[k.key]
|
|
1362
|
+
? Button({
|
|
1363
|
+
key: bound[k.key][0],
|
|
1364
|
+
label: k.label,
|
|
1365
|
+
hotkey: k.key,
|
|
1366
|
+
plain: true,
|
|
1380
1367
|
dimColor: true,
|
|
1381
|
-
|
|
1382
|
-
})
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
],
|
|
1368
|
+
onPress: bound[k.key][1],
|
|
1369
|
+
})
|
|
1370
|
+
: text(`${k.key}: ${k.label}`, { key: `keys-${k.key}`, dimColor: true }),
|
|
1371
|
+
]),
|
|
1386
1372
|
});
|
|
1387
1373
|
|
|
1388
1374
|
// --- the layouts (UI-10) ---
|
|
@@ -1666,8 +1652,8 @@ export function sheetView(lanes, els, { surface = 'terminal', motion = 'while-ac
|
|
|
1666
1652
|
key: `sheet-${name}-${pose}`,
|
|
1667
1653
|
source: characterSvg(pose, looks[name], { motion }),
|
|
1668
1654
|
alt: `${name}: ${POSES[pose].words}`,
|
|
1669
|
-
width:
|
|
1670
|
-
height:
|
|
1655
|
+
width: SIZE * 3,
|
|
1656
|
+
height: SIZE * 3,
|
|
1671
1657
|
});
|
|
1672
1658
|
return text(POSES[pose].glyph);
|
|
1673
1659
|
};
|
|
@@ -1724,7 +1710,7 @@ export function viewFrame(
|
|
|
1724
1710
|
children: [
|
|
1725
1711
|
...(head ? [viewHead(title, els, on)] : []),
|
|
1726
1712
|
...(Array.isArray(body) ? body : [body]),
|
|
1727
|
-
text(keys.map((k) => `${k.key} ${k.label}`).join(' · '), { dimColor: true }),
|
|
1713
|
+
text(keys.map((k) => `${k.key}: ${k.label}`).join(' · '), { dimColor: true }),
|
|
1728
1714
|
],
|
|
1729
1715
|
});
|
|
1730
1716
|
}
|
package/hooks/mod/characters.mjs
CHANGED
|
@@ -1,76 +1,24 @@
|
|
|
1
|
-
// The lane agents' characters, redrawn (docs/specs/27-the-mod-redesigned.md, UI-11):
|
|
1
|
+
// The lane agents' characters, redrawn (docs/specs/27-the-mod-redesigned.md, UI-11): 8 by 8
|
|
2
2
|
// pixels, each lane its own shape as well as its tint so lanes read apart without colour, the lead's
|
|
3
3
|
// crowned. A pose is the agent's state or the kind of work it's doing; a move is a one-off at an
|
|
4
4
|
// event. Every frame is composed from layers (a head by shape, a face, a body, a prop), so each
|
|
5
5
|
// shape gets every pose. Pure: the mod draws the grids as half-block cells or SVG.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
/** Pixels a side: four terminal rows of half-blocks, eight columns. */
|
|
8
|
+
export const SIZE = 8;
|
|
8
9
|
|
|
9
|
-
/**
|
|
10
|
+
/**
|
|
11
|
+
* Each head, rows 0 to 3, the face in columns 1 to 5 (row 0 what's on top of it): H the tint, D its
|
|
12
|
+
* shade, K gold.
|
|
13
|
+
*/
|
|
10
14
|
const HEADS = {
|
|
11
|
-
crown: [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
'....HHHH....',
|
|
19
|
-
],
|
|
20
|
-
antenna: [
|
|
21
|
-
'......K.....',
|
|
22
|
-
'......D.....',
|
|
23
|
-
'...HHHHHH...',
|
|
24
|
-
'...HHHHHH...',
|
|
25
|
-
'...HHHHHH...',
|
|
26
|
-
'...HHHHHH...',
|
|
27
|
-
'...HHHHHH...',
|
|
28
|
-
],
|
|
29
|
-
cat: [
|
|
30
|
-
'............',
|
|
31
|
-
'...D....D...',
|
|
32
|
-
'...HD..DH...',
|
|
33
|
-
'...HHHHHH...',
|
|
34
|
-
'...HHHHHH...',
|
|
35
|
-
'...HHHHHH...',
|
|
36
|
-
'....HHHH....',
|
|
37
|
-
],
|
|
38
|
-
cap: [
|
|
39
|
-
'............',
|
|
40
|
-
'...DDDDDD...',
|
|
41
|
-
'...DDDDDDDD.',
|
|
42
|
-
'...HHHHHH...',
|
|
43
|
-
'...HHHHHH...',
|
|
44
|
-
'...HHHHHH...',
|
|
45
|
-
'....HHHH....',
|
|
46
|
-
],
|
|
47
|
-
bunny: [
|
|
48
|
-
'....D..D....',
|
|
49
|
-
'....D..D....',
|
|
50
|
-
'....HHHH....',
|
|
51
|
-
'...HHHHHH...',
|
|
52
|
-
'...HHHHHH...',
|
|
53
|
-
'...HHHHHH...',
|
|
54
|
-
'....HHHH....',
|
|
55
|
-
],
|
|
56
|
-
bolts: [
|
|
57
|
-
'............',
|
|
58
|
-
'............',
|
|
59
|
-
'...HHHHHH...',
|
|
60
|
-
'..DHHHHHHD..',
|
|
61
|
-
'..DHHHHHHD..',
|
|
62
|
-
'...HHHHHH...',
|
|
63
|
-
'...DDDDDD...',
|
|
64
|
-
],
|
|
65
|
-
wizard: [
|
|
66
|
-
'.....DD.....',
|
|
67
|
-
'....DDDD....',
|
|
68
|
-
'..DDDDDDDD..',
|
|
69
|
-
'...HHHHHH...',
|
|
70
|
-
'...HHHHHH...',
|
|
71
|
-
'...HHHHHH...',
|
|
72
|
-
'....HHHH....',
|
|
73
|
-
],
|
|
15
|
+
crown: ['.K.K.K..', '.KKKKK..', '.HHHHH..', '.HHHHH..'],
|
|
16
|
+
antenna: ['...K....', '.HHHHH..', '.HHHHH..', '.HHHHH..'],
|
|
17
|
+
cat: ['.D...D..', '.DHHHD..', '.HHHHH..', '.HHHHH..'],
|
|
18
|
+
cap: ['.DDDD...', '.DDDDDD.', '.HHHHH..', '.HHHHH..'],
|
|
19
|
+
bunny: ['..D.D...', '..D.D...', '.HHHHH..', '.HHHHH..'],
|
|
20
|
+
bolts: ['........', '.HHHHH..', 'DHHHHHD.', '.DDDDD..'],
|
|
21
|
+
wizard: ['...D....', 'DDDDDDD.', '.HHHHH..', '.HHHHH..'],
|
|
74
22
|
};
|
|
75
23
|
/** The lanes' shapes, tints and marks: six shapes first, then a mark on each, so lanes differ without colour. */
|
|
76
24
|
const SHAPES = ['antenna', 'cat', 'cap', 'bunny', 'bolts', 'wizard'];
|
|
@@ -129,8 +77,9 @@ export function characterOf(lane, lanes) {
|
|
|
129
77
|
return charactersOf(lanes.includes(lane) ? lanes : [...lanes, lane])[lane];
|
|
130
78
|
}
|
|
131
79
|
|
|
132
|
-
/** The body, rows
|
|
133
|
-
const BODY = ['
|
|
80
|
+
/** The body, rows 4 to 7: a neck, arms out in columns 1 and 5, legs. */
|
|
81
|
+
const BODY = ['..DDD...', '.HHHHH..', '..HHH...', '..H.H...'];
|
|
82
|
+
const BODY_TOP = 4;
|
|
134
83
|
|
|
135
84
|
/** Each pose and move: its frames, how long each shows, and whether it loops. */
|
|
136
85
|
export const POSES = {
|
|
@@ -174,118 +123,95 @@ const put = (grid, points, ch) => {
|
|
|
174
123
|
};
|
|
175
124
|
const clear = (grid, points) => put(grid, points, '.');
|
|
176
125
|
|
|
177
|
-
/** The eyes and mouth: where the eyes look, and the face's mood. */
|
|
126
|
+
/** The eyes and mouth: where the eyes look, and the face's mood. Eyes sit in columns 2 and 4. */
|
|
178
127
|
function face(grid, kind, dx = 0, dy = 0) {
|
|
179
128
|
const at = (points) => points.map(([y, x]) => [y + dy, x + dx]);
|
|
180
129
|
const eyes = {
|
|
181
130
|
open: [
|
|
182
|
-
[
|
|
183
|
-
[
|
|
131
|
+
[2, 2],
|
|
132
|
+
[2, 4],
|
|
184
133
|
],
|
|
185
134
|
down: [
|
|
186
|
-
[
|
|
187
|
-
[
|
|
135
|
+
[3, 2],
|
|
136
|
+
[3, 4],
|
|
188
137
|
],
|
|
189
138
|
up: [
|
|
190
|
-
[
|
|
191
|
-
[
|
|
139
|
+
[2, 1],
|
|
140
|
+
[2, 3],
|
|
192
141
|
],
|
|
193
142
|
scan: [
|
|
194
|
-
[
|
|
195
|
-
[
|
|
143
|
+
[3, 3],
|
|
144
|
+
[3, 5],
|
|
196
145
|
],
|
|
197
146
|
};
|
|
198
|
-
if (kind === 'closed') return put(grid, at(eyes.
|
|
147
|
+
if (kind === 'closed') return put(grid, at(eyes.down), 'L');
|
|
199
148
|
if (kind === 'crossed') return put(grid, at(eyes.open), 'X');
|
|
200
149
|
put(grid, at(eyes[kind] ?? eyes.open), 'E');
|
|
201
|
-
if (kind === 'happy')
|
|
202
|
-
put(
|
|
203
|
-
grid,
|
|
204
|
-
at([
|
|
205
|
-
[5, 5],
|
|
206
|
-
[5, 6],
|
|
207
|
-
]),
|
|
208
|
-
'E',
|
|
209
|
-
);
|
|
150
|
+
if (kind === 'happy') put(grid, at([[3, 3]]), 'E');
|
|
210
151
|
if (kind === 'oops') {
|
|
211
|
-
put(grid, at([[
|
|
212
|
-
put(grid, at([[
|
|
152
|
+
put(grid, at([[3, 3]]), 'E');
|
|
153
|
+
put(grid, at([[1, 6]]), 'B');
|
|
213
154
|
}
|
|
214
155
|
}
|
|
215
156
|
|
|
216
157
|
/** A lane's mark, worn in every pose: glasses round the eyes, a scarf at the neck, a belt. */
|
|
217
158
|
function wear(grid, mark, mood, dx = 0, dy = 0) {
|
|
218
159
|
const at = (points) => points.map(([y, x]) => [y + dy, x + dx]);
|
|
219
|
-
const eyes = mood === 'down' || mood === 'scan'
|
|
220
|
-
if (mark === 'glasses')
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
at([
|
|
224
|
-
[eyes, 3],
|
|
225
|
-
[eyes, 5],
|
|
226
|
-
[eyes, 6],
|
|
227
|
-
[eyes, 8],
|
|
228
|
-
]),
|
|
229
|
-
'P',
|
|
230
|
-
);
|
|
231
|
-
if (mark === 'scarf') put(grid, at([3, 4, 5, 6, 7, 8].map((x) => [7, x])), 'S');
|
|
232
|
-
if (mark === 'belt') put(grid, at([4, 5, 6, 7].map((x) => [9, x])), 'P');
|
|
160
|
+
const eyes = mood === 'down' || mood === 'scan' || mood === 'closed' ? 3 : 2;
|
|
161
|
+
if (mark === 'glasses') put(grid, at([1, 3, 5].map((x) => [eyes, x])), 'P');
|
|
162
|
+
if (mark === 'scarf') put(grid, at([1, 2, 3, 4, 5].map((x) => [4, x])), 'S');
|
|
163
|
+
if (mark === 'belt') put(grid, at([2, 3, 4].map((x) => [6, x])), 'P');
|
|
233
164
|
}
|
|
234
165
|
|
|
235
|
-
/** A frame as a grid of letters, before colour. */
|
|
166
|
+
/** A frame as a grid of letters, before colour. Props sit in columns 6 and 7. */
|
|
236
167
|
function compose({ shape, mark = null }, pose, frame) {
|
|
237
168
|
const g = blank();
|
|
238
169
|
const head = HEADS[shape] ?? HEADS.antenna;
|
|
239
170
|
const whole = (dx, dy, mood, body = BODY) => {
|
|
240
171
|
paint(g, head, { dx, dy });
|
|
241
|
-
paint(g, body, { top:
|
|
172
|
+
paint(g, body, { top: BODY_TOP, dx, dy });
|
|
242
173
|
face(g, mood, dx, dy);
|
|
243
174
|
wear(g, mark, mood, dx, dy);
|
|
244
175
|
};
|
|
245
176
|
const f = frame % (POSES[pose]?.frames ?? 1);
|
|
246
177
|
switch (pose) {
|
|
247
178
|
case 'writing': {
|
|
248
|
-
// At a sheet of paper on the right, the pencil moving and
|
|
179
|
+
// At a sheet of paper on the right, the pencil moving and a line filling.
|
|
249
180
|
whole(0, 0, 'down');
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
const tip = [9, 10, 11, 10][f];
|
|
253
|
-
put(g, [[9, tip]], 'K');
|
|
254
|
-
put(g, [[8, Math.min(11, tip + 1)]], 'P');
|
|
181
|
+
paint(g, ['WW', 'WW'], { top: 6, dx: 6 });
|
|
182
|
+
put(g, [[5, [6, 7, 7, 6][f]]], 'K');
|
|
255
183
|
put(
|
|
256
184
|
g,
|
|
257
185
|
[
|
|
258
|
-
[
|
|
259
|
-
[
|
|
260
|
-
|
|
261
|
-
].slice(0, f),
|
|
186
|
+
[6, 6],
|
|
187
|
+
[6, 7],
|
|
188
|
+
].slice(0, [0, 0, 1, 2][f]),
|
|
262
189
|
'E',
|
|
263
190
|
);
|
|
264
191
|
break;
|
|
265
192
|
}
|
|
266
193
|
case 'running': {
|
|
267
|
-
// Turning a crank on the
|
|
268
|
-
|
|
269
|
-
whole(0, bob, 'open');
|
|
194
|
+
// Turning a crank on the right, its bar spinning a quarter a frame, bobbing as it works.
|
|
195
|
+
whole(0, f % 2, 'open');
|
|
270
196
|
const spin = [
|
|
271
197
|
['.P.', '.K.', '.P.'],
|
|
272
198
|
['..P', '.K.', 'P..'],
|
|
273
199
|
['...', 'PKP', '...'],
|
|
274
200
|
['P..', '.K.', '..P'],
|
|
275
201
|
];
|
|
276
|
-
paint(g, spin[f], { top:
|
|
202
|
+
paint(g, spin[f], { top: 4, dx: 5 });
|
|
277
203
|
break;
|
|
278
204
|
}
|
|
279
205
|
case 'reading': {
|
|
280
206
|
// A book held open, eyes down, a page turning.
|
|
281
207
|
whole(0, 0, f === 1 ? 'scan' : 'down');
|
|
282
|
-
paint(g, ['
|
|
208
|
+
paint(g, ['WWDWW', 'WWDWW'], { top: 5, dx: 1 });
|
|
283
209
|
if (f === 2)
|
|
284
210
|
put(
|
|
285
211
|
g,
|
|
286
212
|
[
|
|
287
|
-
[
|
|
288
|
-
[
|
|
213
|
+
[4, 4],
|
|
214
|
+
[4, 5],
|
|
289
215
|
],
|
|
290
216
|
'W',
|
|
291
217
|
);
|
|
@@ -293,8 +219,8 @@ function compose({ shape, mark = null }, pose, frame) {
|
|
|
293
219
|
put(
|
|
294
220
|
g,
|
|
295
221
|
[
|
|
296
|
-
[
|
|
297
|
-
[
|
|
222
|
+
[4, 1],
|
|
223
|
+
[4, 2],
|
|
298
224
|
],
|
|
299
225
|
'W',
|
|
300
226
|
);
|
|
@@ -303,47 +229,39 @@ function compose({ shape, mark = null }, pose, frame) {
|
|
|
303
229
|
case 'thinking': {
|
|
304
230
|
// A hand to the chin, eyes up, a thought rising.
|
|
305
231
|
whole(0, 0, 'up');
|
|
306
|
-
|
|
307
|
-
put(
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
[
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
if (f >= 3) paint(g, ['SSS', 'SSS'], { top: 0, dx: 9 });
|
|
232
|
+
put(g, [[4, 5]], 'H');
|
|
233
|
+
if (f >= 1) put(g, [[2, 6]], 'S');
|
|
234
|
+
if (f >= 2) put(g, [[1, 7]], 'S');
|
|
235
|
+
if (f >= 3)
|
|
236
|
+
put(
|
|
237
|
+
g,
|
|
238
|
+
[
|
|
239
|
+
[0, 6],
|
|
240
|
+
[0, 7],
|
|
241
|
+
],
|
|
242
|
+
'S',
|
|
243
|
+
);
|
|
319
244
|
break;
|
|
320
245
|
}
|
|
321
246
|
case 'waiting': {
|
|
322
|
-
// A raised
|
|
247
|
+
// A hand raised.
|
|
323
248
|
whole(0, 0, 'open');
|
|
324
|
-
clear(g, [[
|
|
249
|
+
clear(g, [[5, 5]]);
|
|
325
250
|
put(
|
|
326
251
|
g,
|
|
327
|
-
[
|
|
328
|
-
[8, 9],
|
|
329
|
-
[7, 9],
|
|
330
|
-
[6, 9],
|
|
331
|
-
[5, 9],
|
|
332
|
-
[4, 9],
|
|
333
|
-
],
|
|
252
|
+
[1, 2, 3, 4].map((y) => [y, 6]),
|
|
334
253
|
'H',
|
|
335
254
|
);
|
|
336
255
|
break;
|
|
337
256
|
}
|
|
338
257
|
case 'quiet': {
|
|
339
|
-
// Still, looking on, a trailing
|
|
258
|
+
// Still, looking on, a trailing pair of dots.
|
|
340
259
|
whole(0, 0, 'open');
|
|
341
260
|
put(
|
|
342
261
|
g,
|
|
343
262
|
[
|
|
344
|
-
[1,
|
|
345
|
-
[1,
|
|
346
|
-
[1, 11],
|
|
263
|
+
[1, 6],
|
|
264
|
+
[1, 7],
|
|
347
265
|
],
|
|
348
266
|
'S',
|
|
349
267
|
);
|
|
@@ -351,27 +269,34 @@ function compose({ shape, mark = null }, pose, frame) {
|
|
|
351
269
|
}
|
|
352
270
|
case 'stalled': {
|
|
353
271
|
// Slumped: the head dropped and tilted, eyes crossed.
|
|
354
|
-
paint(g, BODY, { top:
|
|
272
|
+
paint(g, BODY, { top: BODY_TOP });
|
|
355
273
|
paint(g, head, { dx: 1, dy: 1 });
|
|
356
274
|
face(g, 'crossed', 1, 1);
|
|
357
275
|
wear(g, mark, 'open', 1, 1);
|
|
358
276
|
break;
|
|
359
277
|
}
|
|
360
278
|
case 'resting': {
|
|
361
|
-
//
|
|
279
|
+
// Asleep: eyes shut, and a z rising.
|
|
362
280
|
whole(0, 0, 'closed');
|
|
363
|
-
|
|
281
|
+
put(
|
|
282
|
+
g,
|
|
283
|
+
[
|
|
284
|
+
[2, 6],
|
|
285
|
+
[0, 7],
|
|
286
|
+
],
|
|
287
|
+
'S',
|
|
288
|
+
);
|
|
364
289
|
break;
|
|
365
290
|
}
|
|
366
291
|
case 'arriving': {
|
|
367
292
|
// Dropping into the lane.
|
|
368
|
-
whole(0, [-
|
|
293
|
+
whole(0, [-6, -3, -1, 0][f], 'open');
|
|
369
294
|
if (f < 2)
|
|
370
295
|
put(
|
|
371
296
|
g,
|
|
372
297
|
[
|
|
373
|
-
[0,
|
|
374
|
-
[0,
|
|
298
|
+
[0, 0],
|
|
299
|
+
[0, 6],
|
|
375
300
|
],
|
|
376
301
|
'S',
|
|
377
302
|
);
|
|
@@ -382,17 +307,16 @@ function compose({ shape, mark = null }, pose, frame) {
|
|
|
382
307
|
whole(0, 0, f === 3 ? 'happy' : 'open');
|
|
383
308
|
const paper = [
|
|
384
309
|
[
|
|
385
|
-
[
|
|
386
|
-
[
|
|
310
|
+
[5, 6],
|
|
311
|
+
[5, 7],
|
|
387
312
|
],
|
|
388
313
|
[
|
|
389
|
-
[
|
|
390
|
-
[
|
|
314
|
+
[3, 6],
|
|
315
|
+
[3, 7],
|
|
391
316
|
],
|
|
392
|
-
[[
|
|
317
|
+
[[1, 7]],
|
|
393
318
|
[],
|
|
394
319
|
][f];
|
|
395
|
-
if (f < 2) put(g, [[8, 9]], 'H');
|
|
396
320
|
put(g, paper, 'W');
|
|
397
321
|
break;
|
|
398
322
|
}
|
|
@@ -403,18 +327,16 @@ function compose({ shape, mark = null }, pose, frame) {
|
|
|
403
327
|
}
|
|
404
328
|
case 'merged': {
|
|
405
329
|
// A cheer: arms up, a jump, sparkles.
|
|
406
|
-
const up = [0, -
|
|
407
|
-
const body = BODY.map((r, i) => (i === 1
|
|
330
|
+
const up = [0, -1, -1, 0][f];
|
|
331
|
+
const body = BODY.map((r, i) => (i === 1 ? '..HHH...' : r));
|
|
408
332
|
whole(0, up, 'happy', body);
|
|
409
333
|
put(
|
|
410
334
|
g,
|
|
411
335
|
[
|
|
412
|
-
[
|
|
413
|
-
[
|
|
414
|
-
[
|
|
415
|
-
[
|
|
416
|
-
[6 + up, 9],
|
|
417
|
-
[5 + up, 9],
|
|
336
|
+
[4 + up, 0],
|
|
337
|
+
[3 + up, 0],
|
|
338
|
+
[4 + up, 6],
|
|
339
|
+
[3 + up, 6],
|
|
418
340
|
],
|
|
419
341
|
'H',
|
|
420
342
|
);
|
|
@@ -422,12 +344,12 @@ function compose({ shape, mark = null }, pose, frame) {
|
|
|
422
344
|
g,
|
|
423
345
|
f % 2
|
|
424
346
|
? [
|
|
425
|
-
[0,
|
|
426
|
-
[
|
|
347
|
+
[0, 0],
|
|
348
|
+
[1, 7],
|
|
427
349
|
]
|
|
428
350
|
: [
|
|
429
351
|
[1, 0],
|
|
430
|
-
[0,
|
|
352
|
+
[0, 7],
|
|
431
353
|
],
|
|
432
354
|
'K',
|
|
433
355
|
);
|
|
@@ -445,7 +367,7 @@ const shade = (rgb, by) =>
|
|
|
445
367
|
Math.round((rgb & 0xff) * by);
|
|
446
368
|
|
|
447
369
|
/**
|
|
448
|
-
* A pose's frame as a grid of colours (null for none),
|
|
370
|
+
* A pose's frame as a grid of colours (null for none), SIZE by SIZE. Resting is drawn dimmed. With
|
|
449
371
|
* motion off, a loop shows its first frame and a move its last.
|
|
450
372
|
*/
|
|
451
373
|
export function characterFrame(pose, frame, character, { motion = 'while-active' } = {}) {
|
package/hooks/mod/register.mjs
CHANGED
|
@@ -297,9 +297,16 @@ export function register(on) {
|
|
|
297
297
|
// The held call's answer, for the `code-kit hold` it waits in.
|
|
298
298
|
const answerHeld = (id, answer) =>
|
|
299
299
|
$.process.run(['node', cli, 'hold', id, '--answer', answer], { cwd });
|
|
300
|
+
// A read that fails or outlasts its time is null, like one that can't say: one slow read never
|
|
301
|
+
// takes the band or the pane down with it.
|
|
300
302
|
const json = async (...args) => {
|
|
301
|
-
const ran = await $.process.run(['node', cli, ...args, '--json'], { cwd })
|
|
302
|
-
|
|
303
|
+
const ran = await $.process.run(['node', cli, ...args, '--json'], { cwd }).catch((err) => {
|
|
304
|
+
$.ui.log(`code-kit: \`code-kit ${args[0]}\` didn't answer: ${err?.message ?? err}`, {
|
|
305
|
+
to: 'debug',
|
|
306
|
+
});
|
|
307
|
+
return null;
|
|
308
|
+
});
|
|
309
|
+
return ran?.exitCode === 0 ? parseJson(ran.stdout) : null;
|
|
303
310
|
};
|
|
304
311
|
// What a CLI run said, in a line: why it refused, for a notice.
|
|
305
312
|
const firstLine = (ran) => (ran.stderr || ran.stdout).trim().split('\n')[0];
|
|
@@ -9,7 +9,7 @@ const hex = (rgb) => `#${rgb.toString(16).padStart(6, '0')}`;
|
|
|
9
9
|
/** Each instance's timer and frame, by its surface (the same object across its calls). */
|
|
10
10
|
const running = new WeakMap();
|
|
11
11
|
|
|
12
|
-
/** A
|
|
12
|
+
/** A character's grid as half-block rows, two pixels a cell: a run of cells sharing colours is one Text. */
|
|
13
13
|
export function halfBlocks(grid, { Box, Text }) {
|
|
14
14
|
const rows = [];
|
|
15
15
|
for (let y = 0; y < grid.length; y += 2) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warren-dean/code-kit",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.2",
|
|
4
4
|
"description": "Keeps AI coding agents inside your project's rules: lanes, layer rules, protected paths and proof before finish, enforced by Claude Code hooks and in CI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Warren Langeveldt",
|