@litfamily/litgravity 0.1.4 → 0.1.6

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/lib/install.mjs CHANGED
@@ -3,6 +3,7 @@ import { writeFileAtomic, realExistingAncestor } from './safe-write.mjs';
3
3
  import { agyVersion, validatePlugin } from './agy.mjs';
4
4
  import { destState, stageTo, packageVersion, PLUGIN_DIR, readManifest } from './bundle.mjs';
5
5
  import { assertSafeWritePath } from './guard.mjs';
6
+ import { applyRuleFile, planRuleFile, writeAgentFileMode } from './agent-file.mjs';
6
7
  import { planStatusLine, applyStatusLine } from './statusline.mjs';
7
8
  import { firstLine } from '../plugin/lib/host-exec.mjs';
8
9
 
@@ -63,12 +64,14 @@ export async function install({ env = process.env, flags = {}, interactive = fal
63
64
  }
64
65
  }
65
66
 
67
+ let agentPlan = planRuleFile({ p, version, env, flags, scope });
66
68
  const other = destination(p, scope === 'user' ? 'project' : 'user');
67
69
  const otherState = destState(other);
68
70
  print('');
69
71
  print('Plan');
70
72
  print(` scope ${scope}${scope === 'project' ? ` (${cwd})` : ' (every project on this machine)'}`);
71
73
  print(` plugin ${dest}${st.state === 'owned' ? ` (replaces LitGravity ${st.version})` : ''}`);
74
+ print(` agent file ${agentPlan.detail}`);
72
75
  print(` receipt ${p.receipt}`);
73
76
  print(` validate agy plugin validate on the packaged plugin, then on the installed copy`);
74
77
  if (hud) print(` status line ${hud.action === 'already' ? 'already set' : `${hud.detail} (backup in ${p.backups})`}`);
@@ -87,10 +90,22 @@ export async function install({ env = process.env, flags = {}, interactive = fal
87
90
  print('No files written: this shell has no terminal. Rerun with --yes to install.');
88
91
  return 0;
89
92
  }
93
+ if (agentPlan.action === 'refuse') {
94
+ print(`FAIL agent file ${agentPlan.state}: ${agentPlan.detail}`);
95
+ print('No files written.');
96
+ return 1;
97
+ }
90
98
  if (interactive && !flags.yes && ask && !(await ask(`Install LitGravity ${version} at ${scope} scope? [y/N] `))) {
91
99
  print('Nothing installed.');
92
100
  return 0;
93
101
  }
102
+ if (interactive && !flags.yes && ask && (agentPlan.action === 'create' || agentPlan.action === 'update')) {
103
+ if (!(await ask(`Add the LitGravity global rule for the Antigravity CLI at ${p.geminiRulesFile}? [y/N] `))) {
104
+ writeAgentFileMode(p.litgravityConfig, 'off');
105
+ agentPlan = { action: 'off', detail: 'off (declined; stored, so later installs skip it)' };
106
+ print('Agent file off: stored `off`, so later installs skip the rule file.');
107
+ }
108
+ }
94
109
 
95
110
  const source = validatePlugin(env, PLUGIN_DIR);
96
111
  if (!source.ok) {
@@ -113,6 +128,16 @@ export async function install({ env = process.env, flags = {}, interactive = fal
113
128
  return 1;
114
129
  }
115
130
  if (hud && ['add', 'replace'].includes(hud.action)) written.push(...applyStatusLine(p, dest, stamp()));
131
+ if (agentPlan.action === 'create' || agentPlan.action === 'update' || agentPlan.action === 'off') {
132
+ const applied = applyRuleFile({ p, version, action: agentPlan.action, env, flags, scope });
133
+ if (applied.status.startsWith('refused')) {
134
+ print(`FAIL agent file ${applied.status}: ${applied.detail}`);
135
+ print('The plugin copy above was left in place; move the rule file aside and run install again.');
136
+ return 1;
137
+ }
138
+ print(`agent file: ${applied.status} ${applied.path}`);
139
+ if (applied.status === 'created' || applied.status === 'updated') written.push(applied.path);
140
+ }
116
141
 
117
142
  writeFileAtomic(p.receipt, `${JSON.stringify({
118
143
  product: 'litgravity', version, scope, installedAt: new Date().toISOString(), host: `agy ${host}`, files: count, written,
package/lib/paths.mjs CHANGED
@@ -18,6 +18,12 @@ export function paths(env = process.env, cwd = process.cwd(), { platform = proce
18
18
  // user scope is the global customization root.
19
19
  userPlugin: join(home, '.gemini', 'config', 'plugins', 'litgravity'),
20
20
  projectPlugin: join(cwd, '.agents', 'plugins', 'litgravity'),
21
+ // The owned LitGravity rule file, read from agy's global rules folder. The rules folder is the
22
+ // cleaner route over a block in the shared GEMINI.md; the installer writes only this one file.
23
+ geminiRulesFile: join(home, '.gemini', 'config', 'rules', 'litgravity.md'),
24
+ // Install records for the rule file, and our own on/off setting.
25
+ agentFileRecord: join(data, 'agent-file.json'),
26
+ litgravityConfig: join(data, 'config.json'),
21
27
  // The status line is configured only here, at user level.
22
28
  agySettings: join(home, '.gemini', 'antigravity-cli', 'settings.json'),
23
29
  };
package/lib/uninstall.mjs CHANGED
@@ -2,6 +2,7 @@ import { rmSync, existsSync, readFileSync } from 'node:fs';
2
2
  import { paths, destination } from './paths.mjs';
3
3
  import { destState } from './bundle.mjs';
4
4
  import { assertSafeWritePath } from './guard.mjs';
5
+ import { removeRuleFile, willRemoveRuleFile } from './agent-file.mjs';
5
6
  import { removeStatusLine, isOurs, replacedStatusLine, stripBom } from './statusline.mjs';
6
7
 
7
8
  function ourStatusLine(p) {
@@ -34,6 +35,7 @@ export async function uninstall({ env = process.env, flags = {}, interactive = f
34
35
  }
35
36
  const hud = scopes.includes('user') && ourStatusLine(p);
36
37
  const previous = hud ? replacedStatusLine(p) : null;
38
+ if (scopes.includes('user')) print(` agent file remove the LitGravity rule file ${p.geminiRulesFile} when it is still the one we wrote`);
37
39
  if (hud) print(` status line ${previous ? `put back the status line LitGravity replaced (${String(previous.command ?? 'custom').slice(0, 60)})` : 'remove the LitGravity entry'} in ${p.agySettings}`);
38
40
  print(` kept ${p.backups} and ${p.receipt}`);
39
41
  if (flags.dryRun) {
@@ -44,7 +46,8 @@ export async function uninstall({ env = process.env, flags = {}, interactive = f
44
46
  print('Nothing removed: this shell has no terminal. Rerun with --yes.');
45
47
  return 0;
46
48
  }
47
- if (interactive && !flags.yes && ask && (plan.some((y) => y.remove) || hud) && !(await ask('Remove these LitGravity files? [y/N] '))) {
49
+ const agentRemove = scopes.includes('user') && willRemoveRuleFile(p);
50
+ if (interactive && !flags.yes && ask && (plan.some((y) => y.remove) || hud || agentRemove) && !(await ask('Remove these LitGravity files? [y/N] '))) {
48
51
  print('Nothing removed.');
49
52
  return 0;
50
53
  }
@@ -52,6 +55,11 @@ export async function uninstall({ env = process.env, flags = {}, interactive = f
52
55
  rmSync(assertSafeWritePath(x.dest), { recursive: true, force: true });
53
56
  print(`Removed ${x.dest}.`);
54
57
  }
58
+ if (scopes.includes('user')) {
59
+ const rule = removeRuleFile({ p, discardModified: flags.discardModified === true });
60
+ if (rule.status === 'removed') print(`agent file: removed ${rule.path}${rule.discarded ? ' (discarding edits)' : ''}.`);
61
+ else if (rule.status === 'kept') print(`agent file: kept ${rule.path} (${rule.detail}).`);
62
+ }
55
63
  const removed = hud ? removeStatusLine(p) : false;
56
64
  if (removed === 'restored') print('Restored the previous status line.');
57
65
  else if (removed) print('Removed the LitGravity status line.');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@litfamily/litgravity",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Installer for LitGravity: skills, hooks and agents that help Google's Antigravity CLI (agy) plan, build, check and hand off work.",
5
5
  "keywords": [
6
6
  "antigravity",
@@ -0,0 +1,5 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="512" height="512"
2
+ viewBox="0 0 512 512" role="img" aria-labelledby="title description">
3
+ <title id="title">LITFAMILY — Ignition icon</title>
4
+ <desc id="description">Original geometric LitFamily ignition symbol, bespoke angular lettering, and ordered vector halftone. Ember orange, signal lime, warm white, and carbon navy. All lettering is outlined; no raster images or external resources.</desc>
5
+ <rect x="0" y="0" width="512" height="512" fill="#080D14" /><g transform="translate(44 36) scale(.69)"><g id="family-symbol" transform="translate(20 30) scale(1)"><path d="M0 42H76V438H195L151 510H0Z" fill="#FF6337" /><path d="M133 220V142L271 0H311V77Z" fill="#F2EFDF" /><path d="M101 323L247 180V270L101 413Z" fill="#F2EFDF" /><path d="M270 99H571V121L527 165H204Z" fill="#FF6337" /><rect x="518" y="119" width="17" height="17" fill="#080D14" /><circle cx="417" cy="30" r="49" fill="#D7F75B" /><rect x="263" y="190" width="65" height="71" fill="#D7F75B" /><rect x="334" y="190" width="190" height="71" fill="#F2EFDF" /><rect x="334" y="295" width="72" height="215" fill="#F2EFDF" /><path d="M479 293L529 335H494L479 351Z" fill="#F2EFDF" /><rect x="-11" y="145" width="98" height="4" fill="#080D14" /><rect x="-17" y="145" width="10" height="4" fill="#D7F75B" /><rect x="94" y="145" width="17" height="4" fill="#D7F75B" /><rect x="114" y="145" width="10" height="4" fill="#D7F75B" /><rect x="353" y="460" width="72" height="3" fill="#080D14" /><rect x="413" y="460" width="41" height="3" fill="#FF6337" /><rect x="458" y="460" width="9" height="3" fill="#FF6337" /></g></g><path d="M52 448L460 448" fill="none" stroke="#354139" stroke-width="1" /><g aria-label="LF"><path d="M130 0V730H220V82H550V0Z" fill="#D7F75B" transform="translate(52.000 483) scale(0.020000 -0.020000)"/><path d="M95 0V730H525V648H183V406H499V324H185V0Z" fill="#D7F75B" transform="translate(66.000 483) scale(0.020000 -0.020000)"/></g><rect x="437" y="466" width="23" height="6" fill="#FF6337" /></svg>
@@ -64,6 +64,12 @@ const WORDS = {
64
64
  handoff: ({ file, next }) => `From ${file}: ${next}`,
65
65
  start: () => 'No conversation or plan in this window: say what to start',
66
66
  },
67
+ hold: {
68
+ wait: ({ lanes, plan }) => `Wait for ${lanes} ${lanes === 1 ? 'lane' : 'lanes'} to finish, then start ${plan}`,
69
+ waitLanes: ({ lanes }) => `Wait for ${lanes} ${lanes === 1 ? 'lane' : 'lanes'} to finish`,
70
+ answerPane: ({ pane }) => `Answer the lane waiting on you in pane ${pane}`,
71
+ },
72
+ holdGo: 'Do not type `go` until they finish.',
67
73
  goLine: (say) => `Type **\`${say}\`** to continue.`,
68
74
  noGo: 'Nothing runs on its own here: open that conversation, or say what to do.',
69
75
  unknownSources: (list) => `Not read: ${list}.`,
@@ -125,6 +131,12 @@ const WORDS = {
125
131
  handoff: ({ file, next }) => `${file}에서: ${next}`,
126
132
  start: () => '이 기간에 대화·계획이 없습니다. 시작할 일을 말해 주세요',
127
133
  },
134
+ hold: {
135
+ wait: ({ lanes, plan }) => `작업 중인 레인 ${lanes}개가 끝나면 ${plan} 시작`,
136
+ waitLanes: ({ lanes }) => `작업 중인 레인 ${lanes}개가 끝날 때까지 기다리기`,
137
+ answerPane: ({ pane }) => `${pane} 창에서 나를 기다리는 레인에 답하기`,
138
+ },
139
+ holdGo: '지금은 `go`는 입력하지 마세요.',
128
140
  goLine: (say) => `**\`${say}\`** 라고 입력하면 이어갑니다.`,
129
141
  noGo: '저절로 실행되는 단계는 아닙니다. 그 대화를 열거나 할 일을 말해 주세요.',
130
142
  unknownSources: (list) => `읽지 못함: ${list}.`,
@@ -198,6 +210,9 @@ const doneLine = (session, w) => {
198
210
  const nextOf = (session, data, w) => {
199
211
  if (session.status === 'waiting-on-user') {
200
212
  const paused = framesOf(session, data).find((f) => f.status === 'paused');
213
+ // This session's own card never offers its resume command while lanes work: the hold answers
214
+ // a lane that waits on the user, else waits for them.
215
+ if (paused && session.self && data.next?.held) return holdStep(data, data.next.held, w);
201
216
  if (paused) return w.resume(plain(paused.skill), plain(paused.stage));
202
217
  return w.answer(lastQuestion(session.result));
203
218
  }
@@ -243,7 +258,8 @@ const endedTable = (sessions, now, w) => {
243
258
 
244
259
  // When nothing can run on `go`, the box still recommends one step from what was read: a conversation
245
260
  // that waits on the user, a paused route, an open plan item (a live conversation's folder first), the
246
- // newest other active conversation, the newest ended one. It is shown, never recorded for `go`.
261
+ // newest other active conversation, the newest HANDOFF's open Next item, the newest ended one. It is
262
+ // shown, never recorded for `go`.
247
263
  const suggestion = (data, w) => {
248
264
  const sessions = data.sessions ?? [];
249
265
  const where = (session) => bare(placeOf(session));
@@ -261,13 +277,24 @@ const suggestion = (data, w) => {
261
277
  if (plan) return w.suggest.plan({ plan: plan.local ? plan.plan : `${basename(String(plan.worktree))}/${plan.plan}`, item: clipToWidth(bare(plan.current), 60) });
262
278
  const active = sessions.find((s) => s.status === 'active' && !s.self);
263
279
  if (active) return w.suggest.check({ id8: active.id8, goal: goal(active), where: where(active), doing: actionOf(active, bare) });
264
- const ended = sessions.find((s) => s.status === 'ended' && !s.self);
265
- if (ended) return w.suggest.pickUp({ id8: ended.id8, goal: goal(ended), where: where(ended) });
280
+ // The newest handoff's first open Next item: below every live signal, above an ended conversation.
266
281
  const handoff = (data.handoffs ?? []).find((h) => h.local && h.next);
267
282
  if (handoff) return w.suggest.handoff({ file: bare(handoff.file), next: bare(handoff.next) });
283
+ const ended = sessions.find((s) => s.status === 'ended' && !s.self);
284
+ if (ended) return w.suggest.pickUp({ id8: ended.id8, goal: goal(ended), where: where(ended) });
268
285
  return w.suggest.start();
269
286
  };
270
287
 
288
+ // A step held while other lanes work: answer the one waiting on the user, else wait for them.
289
+ // A held plan names the plan to start after; a held resume or continue only waits.
290
+ const holdStep = (data, held, w) => {
291
+ const waiting = (data.sessions ?? []).find((s) => s.status === 'waiting-on-user' && !s.self);
292
+ if (waiting) return suggestion(data, w);
293
+ if (data.lanes?.waitingPane) return w.hold.answerPane({ pane: data.lanes.waitingPane });
294
+ if (held.plan) return w.hold.wait({ lanes: held.lanes, plan: bare(held.plan) });
295
+ return w.hold.waitLanes({ lanes: held.lanes });
296
+ };
297
+
271
298
  const ROADMAP_COMMITS = 5;
272
299
  const roadmapLines = (data, w) => {
273
300
  const lines = [];
@@ -328,7 +355,10 @@ export const renderBrief = (data, { lang = 'en', width = 72, now = Date.parse(da
328
355
  const sessions = data.sessions ?? [];
329
356
  const summary = data.summary ?? { sessions: sessions.length, waitingOnUser: 0, active: 0 };
330
357
  const runs = data.next?.kind && data.next.kind !== 'none';
331
- const step = runs ? w.step[data.next.kind](Object.fromEntries(Object.entries(data.next.target ?? {}).map(([k, v]) => [k, bare(v)]))) : bare(suggestion(data, w));
358
+ const held = !runs && data.next?.held ? data.next.held : null;
359
+ const step = runs
360
+ ? w.step[data.next.kind](Object.fromEntries(Object.entries(data.next.target ?? {}).map(([k, v]) => [k, bare(v)])))
361
+ : bare(held ? holdStep(data, held, w) : suggestion(data, w));
332
362
  const out = [`## 🧭 ${[w.sessions(summary.sessions), w.waiting(summary.waitingOnUser), w.active(summary.active)].join(' · ')}`];
333
363
  out.push(...opener(data, step, w));
334
364
  out.push(`*${w.window(data.scope?.since ?? '7d', (data.scope?.worktrees ?? []).length || 1)}*`);
@@ -355,7 +385,7 @@ export const renderBrief = (data, { lang = 'en', width = 72, now = Date.parse(da
355
385
  if (runs && data.next.command) body.push(clipToWidth(data.next.command, width - 4));
356
386
  if (runs && data.next.say) body.push(`${w.type}: ${data.next.say}`);
357
387
  out.push('', box(w.recommended, body));
358
- out.push('', runs && data.next.say ? w.goLine(data.next.say) : w.noGo);
388
+ out.push('', held ? w.holdGo : runs && data.next.say ? w.goLine(data.next.say) : w.noGo);
359
389
 
360
390
  const unread = Object.entries(data.sources ?? {}).filter(([, v]) => v === 'unknown').map(([k]) => k);
361
391
  const tail = [unread.length ? w.unknownSources(unread.join(', ')) : null, data.roadmap?.plansSkipped ? w.plansSkipped(data.roadmap.plansSkipped) : null, data.budget?.exhausted ? w.older : null].filter(Boolean);
@@ -3,9 +3,9 @@
3
3
  // A source that is not there reads `unknown`; nothing is inferred.
4
4
 
5
5
  import { execFileSync } from 'node:child_process';
6
- import { closeSync, constants, fstatSync, lstatSync, openSync, readSync, readdirSync, statSync } from 'node:fs';
6
+ import { closeSync, constants, fstatSync, lstatSync, openSync, readSync, readdirSync, realpathSync, statSync } from 'node:fs';
7
7
  import { homedir } from 'node:os';
8
- import { basename, dirname, join, resolve } from 'node:path';
8
+ import { basename, dirname, join, resolve, sep } from 'node:path';
9
9
 
10
10
  import { planRows } from '../continuation.mjs';
11
11
  import { sessionPath, stateRoot } from '../common.mjs';
@@ -22,6 +22,8 @@ const DEFAULT_SINCE = '7d';
22
22
  const DEFAULT_MAX = 12;
23
23
  const NAME_MAX = 90;
24
24
  const PLAN_LIMIT = 8;
25
+ const HERDR_TIMEOUT_MS = 2000;
26
+ const PANE = /^[A-Za-z0-9._:-]{1,64}$/u;
25
27
 
26
28
  export const parseSince = (text) => {
27
29
  const match = /^(\d{1,4})([dhm])$/u.exec(String(text ?? ''));
@@ -116,28 +118,101 @@ const litgoalOf = (root, budget, redact) => {
116
118
  };
117
119
  };
118
120
 
119
- // The first item under a handoff's `## Next` heading, without its list marker, or null.
121
+ // An item already finished: ticked, struck through, marked ✅ or ✓, or carrying the word DONE or SHIPPED.
122
+ const isDoneItem = (item) => /^\[[xX]\]|^~~/u.test(item) || /[✅✓]/u.test(item) || /\b(?:DONE|SHIPPED)\b/u.test(item);
123
+
124
+ // The first open item under a handoff's `## Next` heading, without its list marker, or null.
120
125
  const nextOfHandoff = (text) => {
121
126
  const lines = text.split('\n');
122
127
  const at = lines.findIndex((l) => /^#{2,3}\s+Next\b/iu.test(l));
123
128
  if (at === -1) return null;
124
129
  for (const line of lines.slice(at + 1)) {
125
130
  if (/^#{1,6} /u.test(line)) return null;
126
- const item = line.replace(/^\s*(?:[-*+]|\d+[.)])\s+/u, '').replace(/^\s*-\s*\[[ xX]\]\s*/u, '').trim();
127
- if (item) return item;
131
+ const item = line.replace(/^\s*(?:[-*+]|\d+[.)])\s+/u, '').trim();
132
+ if (!item || isDoneItem(item)) continue;
133
+ return item.replace(/^\[ \]\s*/u, '').trim() || null;
128
134
  }
129
135
  return null;
130
136
  };
131
137
 
138
+ // Newest file first, so a dated handoff written today wins over an old root HANDOFF.md.
132
139
  const handoffsOf = (root, budget, redact, local) => (entries(root) ?? [])
133
140
  .filter((e) => e.isFile() && /^HANDOFF.*\.md$/u.test(e.name))
134
141
  .map((e) => {
142
+ let mtime = 0;
143
+ try { mtime = statSync(join(root, e.name)).mtimeMs; } catch { /* unreadable: oldest */ }
144
+ return { e, mtime };
145
+ })
146
+ .sort((a, b) => b.mtime - a.mtime || a.e.name.localeCompare(b.e.name))
147
+ .map(({ e }) => {
135
148
  const text = readSmallFile(join(root, e.name), budget) ?? '';
136
149
  const headings = text.split('\n').slice(0, 40).filter((l) => /^#{1,3} /u.test(l)).map((l) => clipToWidth(redact(l), 100));
137
150
  const next = nextOfHandoff(text);
138
151
  return { worktree: redact(root), file: e.name, headings, local, next: next ? clipToWidth(redact(next), 100) : null };
139
152
  });
140
153
 
154
+ const realOf = (path) => {
155
+ try { return realpathSync(path); } catch { return resolve(path); }
156
+ };
157
+ // Compares both spellings, so a herdr cwd under /var matches a root under /private/var, even for a path not yet made.
158
+ const insideAny = (path, roots) => {
159
+ if (typeof path !== 'string' || !path) return false;
160
+ const forms = new Set([resolve(path), realOf(path)]);
161
+ return roots.some((r) => [...forms].some((p) => p === r || p.startsWith(r.endsWith(sep) ? r : `${r}${sep}`)));
162
+ };
163
+
164
+ // herdr's agents that work on this repo, read only under HERDR_ENV=1: working or blocked (blocked waits on its user),
165
+ // in this herdr workspace or with a cwd inside one of the roots, never this pane. Any failure reads `unknown`.
166
+ const herdrLanes = (env, roots, sessionId, exec) => {
167
+ if (env.HERDR_ENV !== '1') return null;
168
+ let agents;
169
+ try {
170
+ agents = JSON.parse(exec('herdr', ['agent', 'list'], { timeout: HERDR_TIMEOUT_MS }))?.result?.agents;
171
+ } catch {
172
+ return { status: 'unknown', agents: [] };
173
+ }
174
+ if (!Array.isArray(agents)) return { status: 'unknown', agents: [] };
175
+ const realRoots = [...new Set(roots.flatMap((r) => [resolve(r), realOf(r)]))];
176
+ const ownPane = typeof env.HERDR_PANE_ID === 'string' ? env.HERDR_PANE_ID : null;
177
+ const list = agents.filter((a) => a && typeof a === 'object'
178
+ && ['working', 'blocked'].includes(a.agent_status)
179
+ && !(ownPane && a.pane_id === ownPane)
180
+ && !(sessionId && a.agent_session?.value === sessionId)
181
+ && ((typeof env.HERDR_WORKSPACE_ID === 'string' && env.HERDR_WORKSPACE_ID && a.workspace_id === env.HERDR_WORKSPACE_ID)
182
+ || insideAny(a.cwd, realRoots) || insideAny(a.foreground_cwd, realRoots)))
183
+ .map((a) => ({
184
+ pane: typeof a.pane_id === 'string' && PANE.test(a.pane_id) ? a.pane_id : null,
185
+ session: typeof a.agent_session?.value === 'string' ? a.agent_session.value : null,
186
+ waiting: a.agent_status === 'blocked',
187
+ }));
188
+ return { status: 'ok', agents: list };
189
+ };
190
+
191
+ // Other conversations of this workspace that work or wait on the user, plus herdr agents on this repo; one lane seen
192
+ // both ways (same conversation id or same pane) counts once.
193
+ const lanesOf = (sessions, liveRecords, herdr, sessionId) => {
194
+ const lanes = new Map();
195
+ for (const s of sessions) {
196
+ if (s.sessionId === sessionId || !['active', 'waiting-on-user'].includes(s.status)) continue;
197
+ lanes.set(s.sessionId, { pane: null, waiting: s.status === 'waiting-on-user' });
198
+ }
199
+ for (const r of liveRecords) {
200
+ if (r.id === sessionId) continue;
201
+ const known = lanes.get(r.id);
202
+ if (known) known.pane = known.pane ?? r.pane ?? null;
203
+ else if (r.state === 'alive') lanes.set(r.id, { pane: r.pane ?? null, waiting: false });
204
+ }
205
+ const panes = new Set([...lanes.values()].map((l) => l.pane).filter(Boolean));
206
+ let waitingPane = null;
207
+ for (const a of herdr?.agents ?? []) {
208
+ if ((a.session && lanes.has(a.session)) || (a.pane && panes.has(a.pane))) continue;
209
+ lanes.set(`herdr:${a.pane ?? lanes.size}`, { pane: a.pane, waiting: a.waiting });
210
+ if (a.waiting && a.pane && !waitingPane) waitingPane = a.pane;
211
+ }
212
+ const all = [...lanes.values()];
213
+ return { count: all.length, waiting: all.filter((l) => l.waiting).length, waitingPane };
214
+ };
215
+
141
216
  const branchOf = (root, exec) => {
142
217
  try {
143
218
  return exec('git', ['rev-parse', '--abbrev-ref', 'HEAD'], { cwd: root, timeout: GIT_TIMEOUT_MS }).trim() || null;
@@ -228,7 +303,8 @@ export const collectRewind = ({
228
303
  const handoffs = roots.flatMap((r) => handoffsOf(r, budget, redact, resolve(r) === start));
229
304
  const stackLists = stateDirs.map(({ dir }) => stacksOf(dir, budget, redact));
230
305
  const workflows = stackLists.every((v) => v === null) ? null : stackLists.flatMap((v) => v ?? []);
231
- const liveness = new Map(stateDirs.flatMap(({ dir }) => listLive(dir, now).map((r) => [r.id, r.state])));
306
+ const liveRecords = stateDirs.flatMap(({ dir }) => listLive(dir, now));
307
+ const liveness = new Map(liveRecords.map((r) => [r.id, r.state]));
232
308
  // A conversation whose start-work frame names a plan with every row ticked is done.
233
309
  const finishedPlans = new Set((plans ?? []).filter((p) => p.finished).map((p) => `${p.worktree}\u0000${p.plan}`));
234
310
  const finishedIn = (id, root) => (workflows ?? []).some((f) => f.sessionId === id && f.ref?.plan && finishedPlans.has(`${redact(root)}\u0000${f.ref.plan}`));
@@ -274,6 +350,8 @@ export const collectRewind = ({
274
350
  const orderedPlans = (plans ?? []).filter(recent).sort((a, b) => Number(b.local) - Number(a.local) || (b.mtime ?? 0) - (a.mtime ?? 0));
275
351
  const shownPlans = orderedPlans.slice(0, PLAN_LIMIT);
276
352
  const localGoals = (litgoal ?? []).filter((g) => g.local);
353
+ const herdr = herdrLanes(env, roots, sessionId, exec);
354
+ const lanes = lanesOf(sessions, liveRecords, herdr, sessionId);
277
355
  const roadmapItems = [...orderedPlans.filter((p) => p.local).map((p) => p.progress), ...localGoals.map((g) => g.progress)];
278
356
  const data = {
279
357
  version: 1,
@@ -286,6 +364,7 @@ export const collectRewind = ({
286
364
  handoffs: handoffs.length ? 'ok' : 'unknown',
287
365
  git: known(commits),
288
366
  workflowStack: known(workflows),
367
+ ...(herdr ? { herdr: herdr.status } : {}),
289
368
  },
290
369
  budget: { bytesRead: budget.used, limit: budget.limit, exhausted: budget.exhausted },
291
370
  summary: {
@@ -293,6 +372,7 @@ export const collectRewind = ({
293
372
  waitingOnUser: sessions.filter((s) => s.status === 'waiting-on-user').length,
294
373
  active: sessions.filter((s) => s.status === 'active').length,
295
374
  },
375
+ lanes,
296
376
  sessions: sessions.map(({ cwd: _cwd, lastMs: _lastMs, root: _root, sessionId: id, ...rest }) => ({ ...rest, self: Boolean(sessionId) && id === sessionId })),
297
377
  roadmap: {
298
378
  plans: shownPlans,
@@ -1,29 +1,35 @@
1
1
  // The one next step a lit-adhd brief offers, chosen by fixed priority over the collected records,
2
2
  // and the small record `go` later reads back within 30 minutes:
3
- // 1. this session's paused spine frame -> resume-frame (`lit continue`)
4
- // 2. this session's active start-work -> continue-work
5
- // 3. a single open plan with no work -> start-plan (`lit start plans/<plan>.md`)
6
- // 4. otherwise -> none
7
- // A start-work approval is typed as `lit approve` when the run asks for it; agy keeps no record of a
8
- // pending one for a brief to offer.
3
+ // 1. this session's paused spine frame -> resume-frame (`lit continue`, never while lanes work)
4
+ // 2. this session's active start-work -> continue-work (`go`, never while lanes work)
5
+ // 3. a single open plan with no work -> start-plan (held with the plan while lanes work)
6
+ // 4. lanes work here -> none, held (answer who waits, else wait for them)
7
+ // 5. otherwise -> none
8
+ // While another lane works, neither this session's paused frame nor its own run is offered: answering
9
+ // a lane that waits on the user is still offered, through the hold. Another conversation's run is
10
+ // never offered. PreInvocation re-checks the recorded step when `go` arrives. A start-work approval
11
+ // is typed as `lit approve` when the run asks for it; agy keeps no record of a pending one for a
12
+ // brief to offer.
9
13
 
10
14
  import { closeSync, constants, fstatSync, mkdirSync, openSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
11
15
  import { dirname, join } from 'node:path';
12
16
  import { safeId } from '../common.mjs';
13
17
 
14
18
  export const chooseNextStep = (data, sessionId) => {
19
+ const lanes = data.lanes?.count ?? 0;
15
20
  const ownStack = data.workflows.find((f) => f.sessionId === sessionId && f.role === 'spine' && f.status === 'paused');
16
- if (sessionId && ownStack) {
21
+ if (sessionId && ownStack && !lanes) {
17
22
  return { kind: 'resume-frame', target: { skill: ownStack.skill, stage: ownStack.stage, progress: ownStack.progress.gauge ?? `${ownStack.progress.done ?? 0} done` }, say: 'lit continue' };
18
23
  }
19
24
  const own = data.startWork.find((w) => w.status === 'active' && sessionId && w.sessionId === sessionId);
20
- if (own) return { kind: 'continue-work', target: { plan: own.plan }, say: 'go' };
25
+ if (own && !lanes) return { kind: 'continue-work', target: { plan: own.plan }, say: 'go' };
21
26
  const running = data.startWork.some((w) => ['active', 'paused'].includes(w.status));
22
27
  const open = data.roadmap.plans.filter((p) => p.local && p.progress.total !== null && p.progress.done < p.progress.total);
23
28
  if (!running && open.length === 1) {
29
+ if (lanes > 0) return { kind: 'none', target: null, held: { lanes, plan: open[0].plan } };
24
30
  return { kind: 'start-plan', target: { plan: open[0].plan }, say: 'go', command: `lit start ${open[0].plan}` };
25
31
  }
26
- return { kind: 'none', target: null };
32
+ return lanes > 0 ? { kind: 'none', target: null, held: { lanes } } : { kind: 'none', target: null };
27
33
  };
28
34
 
29
35
  export const nextStepPath = (root, conversationId) => {
@@ -1,8 +1,11 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+
1
4
  import { run, inject, readSession, writeSession, appendLedger, workspaceOf, safeId, stateRoot } from './lib/common.mjs';
2
5
  import { detectRoute } from './lib/routes.mjs';
3
6
  import { decide, resumablePlan, activation, continueNote, resumeNote } from './lib/reentry.mjs';
4
7
  import { lastUserRequest } from './lib/transcript.mjs';
5
- import { PAUSE_WORD } from './lib/continuation.mjs';
8
+ import { PAUSE_WORD, planRows } from './lib/continuation.mjs';
6
9
  import { saveSnapshot } from './lib/boundary.mjs';
7
10
  import { MOTION_ROUTE, armMotionTurn } from './lib/motion.mjs';
8
11
  import { applyStackEvent, readStack, writeStack } from './lib/workflow-stack.mjs';
@@ -43,6 +46,37 @@ function goActivation(step, conversationId) {
43
46
  }
44
47
  }
45
48
 
49
+ // The brief may be up to 30 minutes old: `go` acts only when its step still holds for this conversation. The stack
50
+ // file is this conversation's own, so a run found there is one it owns.
51
+ function stillHolds(step, workspace, conversationId) {
52
+ const frames = readStack(workspace, conversationId).frames;
53
+ switch (step.kind) {
54
+ case 'resume-frame':
55
+ return frames.some((f) => f.role === 'spine' && f.status === 'paused' && (!step.target?.skill || f.skill === step.target.skill));
56
+ case 'continue-work':
57
+ return frames.some((f) => f.skill === 'start-work' && f.status === 'active' && (!step.target?.plan || f.ref?.plan === step.target.plan));
58
+ case 'start-plan': {
59
+ const plan = step.target?.plan;
60
+ if (typeof plan !== 'string' || !/^plans\/[^/\\]+\.md$/u.test(plan)) return false;
61
+ if (frames.some((f) => f.skill === 'start-work')) return false;
62
+ try {
63
+ return planRows(readFileSync(join(workspace, plan), 'utf8')).some((r) => !r.done);
64
+ } catch {
65
+ return false;
66
+ }
67
+ }
68
+ default:
69
+ return false;
70
+ }
71
+ }
72
+
73
+ function staleGoText(step) {
74
+ const what = step.kind === 'start-plan' ? `start ${step.target?.plan ?? 'the plan'}`
75
+ : step.kind === 'continue-work' ? 'continue this conversation\'s start-work run'
76
+ : `resume the paused ${step.target?.skill ?? 'route'}`;
77
+ return `LitGravity: the user typed \`go\`, but the step the brief offered (${what}) no longer holds: the run finished, moved on or is not this conversation's. Start nothing. Say so in one line and suggest \`lit adhd\` for a fresh brief.`;
78
+ }
79
+
46
80
  function approveText(word) {
47
81
  if (word === 'approve') return 'LitGravity: the user typed `lit approve`. This is the typed approval for start-work. Proceed with the work.';
48
82
  return 'LitGravity: the user typed `lit deny`. This is a denial. Stop the work and explain what was denied.';
@@ -64,6 +98,10 @@ run((payload) => {
64
98
  // `go` / `ㄱㄱ` / `진행`: consume the next-step record the collector wrote within 30 minutes.
65
99
  if (isGoPrompt(request.text)) {
66
100
  const step = takeNextStep(root, safeId(payload.conversationId));
101
+ if (step && step.kind !== 'none' && !stillHolds(step, workspace, payload.conversationId)) {
102
+ appendLedger(payload, { kind: 'route', route: null, how: 'go-stale', step: step.kind });
103
+ return inject(staleGoText(step));
104
+ }
67
105
  if (step) {
68
106
  const text = goActivation(step, payload.conversationId);
69
107
  if (text) {
@@ -2,5 +2,6 @@
2
2
  "$schema": "https://antigravity.google/schemas/v1/plugin.json",
3
3
  "name": "litgravity",
4
4
  "description": "LitFamily workflows for the Antigravity CLI: bare lit activation, planning, evidence-bound execution, review, research, handoff and Korean prose care.",
5
- "version": "0.1.4"
5
+ "version": "0.1.6",
6
+ "logo": "assets/logo.svg"
6
7
  }
@@ -53,7 +53,7 @@ The collector draws the brief in Markdown (`plugin/hooks/lib/rewind/brief.mjs`),
53
53
  2. **Live cards, grouped by folder and branch.** Conversations that wait on the user, are active, idle or done get a `### 🌿 branch · folder` heading per group and one quoted card each: a status badge (🟠 waiting on you, 🟢 active, 💤 idle, ✅ done; see `references/status-taxonomy.md`) with why it waits, its `id8`, its route, how long ago it moved and `this conversation` / `이 대화`; the goal in bold; a real gauge with the next items, or the known facts after ⏳ (how long it ran, its last ask); ✅ what was written and committed, or before any write the tools it used most; ▶ what is next for it (answer its question, resume its paused route, its route stage, or its last tool call by base name, never a command line).
54
54
  3. **Ended conversations, one table row each** (`### ⚪ Ended · N`: id, where, goal, ago, done), at most eight and a count of the rest. Each row fits on one line at 120 columns: the age is its largest unit and done is a commit count or a file count.
55
55
  4. **Roadmap timeline** (`### 🗺️`, with this folder's gauge): ✓ commits with their dates and branch, ▶ the current item of each open plan changed inside the window, here or in another folder (with its folder name), ○ the items after it, then litgoal objectives. Plans are held to the window here too. Unfilled plan scaffolds and files without task rows are skipped and counted on the last line; another folder's finished plans and objectives are left out.
56
- 5. **One recommended next step** in a box (an untagged code fence), then one line. A step that runs on `go` shows its command and the word to type, and the line says "Type `go` to continue." When nothing runs on `go`, the box still recommends a real step from the records, in this order: a conversation waiting on the user, a paused route, an open plan item (a live conversation's folder first), the newest other active conversation, the newest ended one, the first item under `## Next` in this folder's `HANDOFF*.md`; the line then says nothing runs on its own.
56
+ 5. **One recommended next step** in a box (an untagged code fence), then one line. A step that runs on `go` shows its command and the word to type, and the line says "Type `go` to continue." When nothing runs on `go`, the box still recommends a real step from the records, in this order: a conversation waiting on the user, a paused route, an open plan item (a live conversation's folder first), the newest other active conversation, the first open item under `## Next` in this folder's newest `HANDOFF*.md` (items marked ✅, ✓, `[x]`, ~~struck~~, DONE or SHIPPED are skipped), the newest ended one; the line then says nothing runs on its own. When other lanes work, a plan start is held: the box says to answer the lane waiting on you or to wait for the N lanes, and the line says "Do not type `go` until they finish." (Korean: "지금은 `go`는 입력하지 마세요.").
57
57
 
58
58
  **Progress gauges (D9).** A gauge appears only when the collector provides both done and total as real integers: `[▉▉▉░░] 3/5`. When the total is unknown, the card shows known facts in words instead (`⏳ 2h 19m of work · last ask: …`). Never show `?/?`, `[???]`, `k/?` or any question-mark placeholder. The gauge is the progress; do not compute progress from prose like "about halfway".
59
59
 
@@ -124,12 +124,14 @@ Sessions waiting on the user come first, then active, idle, done and ended ones,
124
124
  1. This session's own paused spine frame: resume it. Say `lit continue`.
125
125
  2. A start-work paused at a boundary: show what it wants to reach. Say `lit approve` or `lit deny`. This is never automatic.
126
126
  3. This session's own active start-work: keep going. Say `go`.
127
- 4. Exactly one open plan in this worktree and no work running: start it. Say `go`, which runs `lit start plans/<plan>.md`.
127
+ 4. Exactly one open plan in this worktree and no work running: start it. Say `go`, which runs `lit start plans/<plan>.md`. When other lanes work (another conversation of this workspace that is running or waits on the user, or, under `HERDR_ENV=1`, a working or blocked herdr agent in this herdr workspace or this repo, read from `herdr agent list` with a 2 s limit and counted once), the step is `none` with `held`, and nothing runs on `go`.
128
128
  5. Otherwise `none`: say so.
129
129
 
130
+ Another conversation's run is never offered as `go`.
131
+
130
132
  ## Continuing with go
131
133
 
132
- After a brief, the user's `go` (also `lit go`, `ㄱㄱ`, `고`, `진행`, as the whole prompt) continues the step the brief offered, in the same session, within 30 minutes. The hook reads the next-step record the collector wrote for this session and acts on it: a paused frame resumes, an active work continues, a single open plan starts through the same typed-start path. A boundary approval still needs `lit approve`. Anything else typed after the brief is an ordinary prompt.
134
+ After a brief, the user's `go` (also `lit go`, `ㄱㄱ`, `고`, `진행`, as the whole prompt) continues the step the brief offered, in the same session, within 30 minutes. The hook reads the next-step record the collector wrote for this session and first re-checks it: the paused frame must still be paused, the start-work run still active on this conversation's stack, the plan still open with no run started. When the step no longer holds, `go` says so and starts nothing. Otherwise a paused frame resumes, an active work continues, a single open plan starts through the same typed-start path. A boundary approval still needs `lit approve`. Anything else typed after the brief is an ordinary prompt.
133
135
 
134
136
  ## Typed start-work approval
135
137
 
@@ -152,7 +152,7 @@ Stop at a blocked exit, at a gate failure you cannot fix within round 3, or when
152
152
  | 14 | BLOCKED_DEPS_NOT_PREWARMED | Run step 0, or give the user `npx @litfamily/litgravity runtime install motion` for a terminal. |
153
153
  | 15 | BLOCKED_FONT_FETCH | A cached font is missing or its sha256 differs; the same pre-warm command fixes it. |
154
154
  | 16 | BLOCKED_TREATMENT_INVALID | Fix the named field. |
155
- | 17 | STAGE_CONTRACT_ERROR | Fix the named element, API, raster, size or missing copy line. |
155
+ | 17 | STAGE_CONTRACT_ERROR | Fix the named element, API, raster, clip, size or missing copy line. |
156
156
  | 18 | STAGE_NONDETERMINISTIC | The page read something the clock does not drive; seed it or derive it from `t`. |
157
157
  | 19 | STAGE_NETWORK_REQUEST | Remove the named URL or connection; everything is local. |
158
158
  | 20 | SOUND_INVALID | The planned sound is missing, silent at the start or out of limits; fix it. |
@@ -187,7 +187,7 @@ function prepare({ out, env, log }) {
187
187
  const treatment = asBlocked(() => loadCoverTreatment(out));
188
188
  const stageDir = path.join(out, COVER_STAGE);
189
189
  if (!existsSync(path.join(stageDir, "index.html"))) throw new BlockedError(EXIT.STAGE_CONTRACT_ERROR, `STAGE_CONTRACT_ERROR: ${path.join(stageDir, "index.html")} is missing; write the cover page first (references/cover.md)`);
190
- const scan = scanStage(stageDir);
190
+ const scan = scanStage(stageDir, { clips: false });
191
191
  for (const w of scan.warnings) log(`warning: ${w}`);
192
192
  const { assets } = checkAssets({ out, treatment, rasters: scan.rasters, coverDir: COVER_STAGE });
193
193
  return { treatment, stageDir, assets, faces: stageFonts(env) };
@@ -160,6 +160,7 @@ export function formatStageReport({ gate, manifest, outputs, round, framesViewed
160
160
  `outputs: ${outputs.film} · ${outputs.preview} · ${outputs.poster} · ${outputs.still}${withheld ? " [WITHHELD: MO-C-03 flash audit failed; exports are diagnostics in withheld/, not deliverables]" : ""}`,
161
161
  `format / duration / fps: ${manifest.format} ${manifest.width}x${manifest.height}, ${manifest.durationSec} s (treatment ${manifest.treatmentDurationSec} s) @ ${manifest.fps} fps, ${manifest.frameCount} frames`,
162
162
  `renderer: ${manifest.renderer} (${manifest.rung ?? "software"} rung, stage flags: ${manifest.chromeFlags.join(" ")})`,
163
+ ...(manifest.clips?.length ? [`clips: ${manifest.clips.map((c) => `${c.id} ${c.frames} frames at ${c.fps} fps`).join(", ")} (keyed overlays, chosen from film time)`] : []),
163
164
  ...(manifest.plate ? [`plate: Blender ${manifest.plate.blender}, ${manifest.plate.engine} ${manifest.plate.device}, ${manifest.plate.samples} spp, ${manifest.plate.frames} frames at ${manifest.plate.fps} fps`] : []),
164
165
  `sound: ${manifest.sound?.mode ?? "none"}${manifest.sound?.label ? ` (${manifest.sound.label})` : ""}`,
165
166
  "",