@yunhozz/arc 0.4.7 → 0.5.1
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/MANIFEST.sha256 +47 -45
- package/README.md +99 -33
- package/claude/agents/arc-implementer.md +1 -1
- package/claude/skill/SKILL.md +1 -1
- package/claude/skill/models.toml +9 -9
- package/claude/skill/references/handoff-prep.md +1 -1
- package/claude/skill/references/verification.md +4 -4
- package/codex/skill/SKILL.md +1 -1
- package/codex/skill/models.toml +9 -9
- package/codex/skill/references/handoff-prep.md +1 -1
- package/codex/skill/references/verification.md +4 -4
- package/gemini/agents/arc-implementer.md +2 -2
- package/gemini/agents/arc-planner.md +1 -1
- package/gemini/agents/arc-qa.md +1 -1
- package/gemini/agents/arc-reviewer.md +1 -1
- package/gemini/agents/arc-scouter.md +1 -1
- package/gemini/skill/SKILL.md +1 -1
- package/gemini/skill/models.toml +6 -6
- package/gemini/skill/references/handoff-prep.md +1 -1
- package/gemini/skill/references/verification.md +4 -4
- package/grok/agents/arc-implementer.md +1 -1
- package/grok/skill/SKILL.md +1 -1
- package/grok/skill/references/handoff-prep.md +1 -1
- package/grok/skill/references/verification.md +4 -4
- package/lib/cli/postinstall.mjs +1 -1
- package/lib/installer/targets.mjs +3 -1
- package/lib/management/operations.mjs +4 -4
- package/lib/models/catalog-gemini.mjs +4 -1
- package/lib/models/gemini-models.json +4 -0
- package/lib/prompts/agent-fragments.json +3 -3
- package/lib/runtime/local-cli.mjs +9 -2
- package/lib/runtime/platform-registry.mjs +1 -1
- package/lib/runtime/role-dispatch-policy.mjs +5 -2
- package/lib/tui/app.mjs +36 -9
- package/lib/tui/interface.mjs +2 -2
- package/lib/tui/render.mjs +5 -3
- package/lib/tui/terminal.mjs +5 -3
- package/lib/watch/brief.mjs +44 -0
- package/lib/watch/dispatch.mjs +44 -6
- package/lib/watch/index.mjs +107 -22
- package/lib/watch/markdown.mjs +42 -9
- package/lib/watch/menu.mjs +26 -15
- package/lib/watch/model.mjs +1 -0
- package/lib/watch/render.mjs +3 -2
- package/lib/watch/scope.mjs +125 -0
- package/lib/watch/watcher.mjs +149 -82
- package/lib/watch/worktree-menu.mjs +64 -0
- package/package.json +1 -1
- package/shared/skill/runtime/local-cli.mjs +9 -2
- package/shared/skill/runtime/platform-registry.mjs +1 -1
- package/shared/skill/runtime/role-dispatch-policy.mjs +5 -2
package/lib/watch/scope.mjs
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import {GIT_ALLOWED} from './git.mjs';
|
|
4
|
+
import {WATCH_LIMITS as L} from './model.mjs';
|
|
5
|
+
import {sanitizeText} from './policy.mjs';
|
|
6
|
+
import {watchLocationLabel} from './status-line.mjs';
|
|
7
|
+
import {displayWidth} from './text-width.mjs';
|
|
4
8
|
|
|
5
9
|
const scopeCaches = new WeakMap();
|
|
6
10
|
|
|
@@ -59,3 +63,124 @@ export function claudeDirPrefixes(scope) {
|
|
|
59
63
|
const roots = scope.kind === 'repo' ? [...scope.roots, ...scope.excludedRoots ?? []] : scope.roots;
|
|
60
64
|
return [...new Set(roots.flatMap(root => [normalizeSlug(root), normalizeSlug(realPath(root))]))];
|
|
61
65
|
}
|
|
66
|
+
|
|
67
|
+
export function parseWorktreeList(output) {
|
|
68
|
+
if (!output || !output.endsWith('\0\0')) throw Error('Invalid Git worktree list');
|
|
69
|
+
return output.slice(0,-2).split('\0\0').map(record => {
|
|
70
|
+
const [location,...fields] = record.split('\0');
|
|
71
|
+
const dir = location.slice(9);
|
|
72
|
+
if (!location.startsWith('worktree ') || !path.isAbsolute(dir)) throw Error('Invalid Git worktree entry');
|
|
73
|
+
return {
|
|
74
|
+
root:realPath(dir),
|
|
75
|
+
head:fields.find(field=>field.startsWith('HEAD '))?.slice(5),
|
|
76
|
+
branch:fields.find(field=>field.startsWith('branch '))?.slice(7).replace(/^refs\/heads\//,''),
|
|
77
|
+
detached:fields.includes('detached'),
|
|
78
|
+
locked:fields.some(field=>field==='locked'||field.startsWith('locked ')),
|
|
79
|
+
prunable:fields.some(field=>field==='prunable'||field.startsWith('prunable ')),
|
|
80
|
+
bare:fields.includes('bare'),
|
|
81
|
+
};
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function selectableWorktrees(list, {isDirectory = root => fs.statSync(root).isDirectory()} = {}) {
|
|
86
|
+
const worktrees = list.filter(({root,bare,prunable}) => {
|
|
87
|
+
if (bare || prunable) return false;
|
|
88
|
+
try { return isDirectory(root); } catch { return false; }
|
|
89
|
+
});
|
|
90
|
+
return {worktrees,mainRoot:list[0]?.bare ? null : list[0]?.root ?? null};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function pathForms(file) {
|
|
94
|
+
return [...new Set([realPath(file),path.resolve(file)])];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function matchingPaths(bases, locations) {
|
|
98
|
+
for (const base of bases) {
|
|
99
|
+
const prefix = base.endsWith(path.sep) ? base : base+path.sep;
|
|
100
|
+
for (const location of locations) {
|
|
101
|
+
if (location===base || location.startsWith(prefix)) return {base,location,relative:path.relative(base,location)};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function abbreviateWorktree(locations, home) {
|
|
107
|
+
const match = home && matchingPaths(pathForms(home),locations);
|
|
108
|
+
return match ? watchLocationLabel({dir:match.location,home:match.base}) : watchLocationLabel({dir:locations[0]});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function sameWorktree(root, other) {
|
|
112
|
+
return Boolean(other && (root===other || pathForms(root).some(form=>pathForms(other).includes(form))));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function worktreeDisplayPath(root, {mainRoot,home,width=Infinity}) {
|
|
116
|
+
const locations = pathForms(root);
|
|
117
|
+
const match = mainRoot && matchingPaths(pathForms(mainRoot),locations);
|
|
118
|
+
const label = match?.relative
|
|
119
|
+
? sanitizeText(path.basename(match.base)+path.sep+match.relative)
|
|
120
|
+
: abbreviateWorktree(locations,home);
|
|
121
|
+
if (displayWidth(label)<=width) return label;
|
|
122
|
+
const parts = label.split(path.sep);
|
|
123
|
+
const last = parts.at(-1) || label;
|
|
124
|
+
const candidates = [
|
|
125
|
+
[parts[0],'…',...parts.slice(-2)].join(path.sep),
|
|
126
|
+
[parts[0],'…',last].join(path.sep),
|
|
127
|
+
['…',last].join(path.sep),
|
|
128
|
+
];
|
|
129
|
+
const wholeSegments = candidates.find(candidate=>displayWidth(candidate)<=width);
|
|
130
|
+
if (wholeSegments) return wholeSegments;
|
|
131
|
+
const ellipsisWidth = displayWidth('…');
|
|
132
|
+
if (width<ellipsisWidth) return '';
|
|
133
|
+
let end = '', remaining = width-ellipsisWidth;
|
|
134
|
+
for (const character of [...last].reverse()) {
|
|
135
|
+
remaining -= displayWidth(character);
|
|
136
|
+
if (remaining<0) break;
|
|
137
|
+
end = character+end;
|
|
138
|
+
}
|
|
139
|
+
return '…'+end;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function worktreeBranch(worktree) {
|
|
143
|
+
return worktree.detached ? 'detached '+worktree.head?.slice(0,7) : worktree.branch;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export function scopeForWorktree(scope, worktrees, root, {home}) {
|
|
147
|
+
const locations = pathForms(root);
|
|
148
|
+
const trees = worktrees.map(tree=>({tree,forms:pathForms(tree.root)}));
|
|
149
|
+
const sameRoot = ({forms})=>forms.some(form=>locations.includes(form));
|
|
150
|
+
const chosen = trees.find(sameRoot)?.tree;
|
|
151
|
+
const canonical = locations[0];
|
|
152
|
+
return {...scope, roots:[canonical], excludedRoots:trees.filter(tree=>!sameRoot(tree)).map(({forms})=>forms[0]),
|
|
153
|
+
branch:chosen && worktreeBranch(chosen),display:abbreviateWorktree(locations,home),description:`Worktree ${canonical}`};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function groupActivity(worktrees, activity, {now}) {
|
|
157
|
+
const roots = worktrees.map(({root})=>({root,forms:pathForms(root)}));
|
|
158
|
+
const groups = new Map();
|
|
159
|
+
for (const {platform,mtimeMs,cwd} of activity) {
|
|
160
|
+
if (!cwd || now-mtimeMs>L.attachWindowMs) continue;
|
|
161
|
+
const locations = pathForms(cwd);
|
|
162
|
+
let root, distance = Infinity;
|
|
163
|
+
for (const candidate of roots) {
|
|
164
|
+
const match = matchingPaths(candidate.forms,locations);
|
|
165
|
+
if (!match) continue;
|
|
166
|
+
const levels = match.relative ? match.relative.split(path.sep).length : 0;
|
|
167
|
+
if (levels<distance) { root = candidate.root; distance = levels; }
|
|
168
|
+
}
|
|
169
|
+
if (!root) continue;
|
|
170
|
+
const group = groups.get(root) ?? {sessions:0,platforms:new Set(),lastActivity:mtimeMs};
|
|
171
|
+
group.sessions++;
|
|
172
|
+
group.platforms.add(platform);
|
|
173
|
+
group.lastActivity = Math.max(group.lastActivity,mtimeMs);
|
|
174
|
+
groups.set(root,group);
|
|
175
|
+
}
|
|
176
|
+
return groups;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export function orderWorktrees(worktrees, groups, {currentRoot,mainRoot,home}) {
|
|
180
|
+
const decorated = worktrees.map(tree=>({
|
|
181
|
+
tree,here:sameWorktree(tree.root,currentRoot),last:groups.get(tree.root)?.lastActivity ?? -Infinity,
|
|
182
|
+
display:worktreeDisplayPath(tree.root,{mainRoot,home}),
|
|
183
|
+
}));
|
|
184
|
+
decorated.sort((a,b)=>Number(b.here)-Number(a.here) || b.last-a.last || a.display.localeCompare(b.display,'en'));
|
|
185
|
+
return {shown:decorated.slice(0,L.worktreePickerMax).map(row=>row.tree),hidden:Math.max(0,decorated.length-L.worktreePickerMax)};
|
|
186
|
+
}
|
package/lib/watch/watcher.mjs
CHANGED
|
@@ -13,6 +13,7 @@ import {createDispatchIndex} from './dispatch.mjs';
|
|
|
13
13
|
import {resolveDispatchStore} from './anchor-store.mjs';
|
|
14
14
|
import {DEFAULT_PLATFORM_REGISTRY} from '../runtime/platform-registry.mjs';
|
|
15
15
|
import {GIT_ALLOWED} from './git.mjs';
|
|
16
|
+
import {watchLocationLabel} from './status-line.mjs';
|
|
16
17
|
|
|
17
18
|
/** Read-only, timer-free merger. The caller owns scheduling and output. */
|
|
18
19
|
export function createWatcher({options, homes, scope: initialScope, git, now, registry = DEFAULT_PLATFORM_REGISTRY, dependencies = {}}) {
|
|
@@ -20,8 +21,10 @@ export function createWatcher({options, homes, scope: initialScope, git, now, re
|
|
|
20
21
|
lstat = fsp.lstat, maxKnown = L.maxKnown, createClaudeDiscovery: claudeDiscovery = createClaudeDiscovery, createDispatchIndex: dispatchIndex = createDispatchIndex} = dependencies;
|
|
21
22
|
const platforms = options.platforms ?? registry.byDisplayOrder().filter(d => d.capabilities.watch.state==='verified').map(d => d.id);
|
|
22
23
|
const verbose = Boolean(options.verbose);
|
|
24
|
+
const probe = Boolean(options.probe);
|
|
23
25
|
const tailCount = options.tail ?? L.defaultTail;
|
|
24
26
|
let scope = initialScope, closed = false, started = false;
|
|
27
|
+
let earlierBacklog;
|
|
25
28
|
let lastDiscovery = -Infinity, lastRefresh = now(), capped = false;
|
|
26
29
|
const followed = new Map(), pending = new Map(), ignored = new Map(), detached = new Map();
|
|
27
30
|
const seenAtStart = new Map(), heads = new Map(), metas = new Map(), agentMetas = new Map(), childLists = new Map();
|
|
@@ -32,7 +35,62 @@ export function createWatcher({options, homes, scope: initialScope, git, now, re
|
|
|
32
35
|
let lastNestedRefresh = -Infinity;
|
|
33
36
|
let shellCursor = 0;
|
|
34
37
|
let dispatch;
|
|
35
|
-
|
|
38
|
+
let claude;
|
|
39
|
+
const TRANSCRIPT_HANDLERS = new Map([
|
|
40
|
+
['codex', {
|
|
41
|
+
lineCwd:codexLineCwd,createState:createCodexState,
|
|
42
|
+
normalize:(line,state,home)=>normalizeCodexLine(line,state,{codexHome:home,userHome:homes.user}),
|
|
43
|
+
shouldHold:origin=>origin==='codex_exec',
|
|
44
|
+
async discover({platform,home,startup,out,rows}) {
|
|
45
|
+
for (const item of await codexCandidates(platform,home,startup)) {
|
|
46
|
+
if (item.platform != null && item.platform!==platform) continue;
|
|
47
|
+
rememberStart({...item,platform},startup);
|
|
48
|
+
if (item.compressed) {
|
|
49
|
+
if (!compressed.has(item.file)) debug(out,`compressed session skipped: ${path.basename(item.file)}`);
|
|
50
|
+
compressed.add(item.file); continue;
|
|
51
|
+
}
|
|
52
|
+
if ([...followed.values()].some(row=>row.file===item.file)) continue;
|
|
53
|
+
if (skipHead(item,startup)) continue;
|
|
54
|
+
const meta=await cachedHead(metas,item,codexMeta);
|
|
55
|
+
if (!meta) continue;
|
|
56
|
+
const row={...item,id:meta.threadId,platform,origin:meta.originator,cwd:meta.cwd,version:meta.cliVersion,parentId:meta.parentId,depth:meta.depth,agent:{agentRole:meta.agentRole,nickname:meta.agentNickname}};
|
|
57
|
+
rememberKnown(row);rows.push(row);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
}],
|
|
61
|
+
['claude', {
|
|
62
|
+
lineCwd:claudeLineCwd,createState:createClaudeState,normalize:normalizeClaudeLine,
|
|
63
|
+
shouldHold:()=>true,
|
|
64
|
+
async discover({platform,home,startup,rows}) {
|
|
65
|
+
claude ??= claudeDiscovery({claudeHome:home});
|
|
66
|
+
const prefixes=startup || dispatch.list().some(ref=>ref.inScope) ? null : claudeDirPrefixes(scope);
|
|
67
|
+
const mains=await claude.scan({prefixes,now:now(),startup:false});
|
|
68
|
+
for (const item of mains) {
|
|
69
|
+
if (item.platform != null && item.platform!==platform) continue;
|
|
70
|
+
rememberStart(item,startup);
|
|
71
|
+
const children=await childrenFor(item,startup);
|
|
72
|
+
for (const child of children) rememberStart(child,startup);
|
|
73
|
+
if (skipHead(item,startup)) continue;
|
|
74
|
+
const head=await cachedHead(heads,item,claudeHead);
|
|
75
|
+
if (!head) {
|
|
76
|
+
const wait=pending.get(item.file) ?? {...item,until:now()+L.claudeCwdWaitMs,cwdWaiting:true};
|
|
77
|
+
if (now()<wait.until) pending.set(item.file,wait); else {pending.delete(item.file);ignored.set(item.file,item.size);}
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
pending.delete(item.file);
|
|
81
|
+
const main={...item,id:head.sessionId,platform,origin:head.entrypoint,cwd:head.cwd,version:head.version};
|
|
82
|
+
rememberKnown(main);
|
|
83
|
+
if (!followed.has(main.id)) rows.push(main);
|
|
84
|
+
for (const child of children) {
|
|
85
|
+
if (skipHead(child,startup)) continue;
|
|
86
|
+
const childHead=await cachedHead(heads,child,claudeHead);
|
|
87
|
+
const row={...child,id:`agent-${child.agentId}`,platform,origin:head.entrypoint,cwd:childHead?.cwd??head.cwd,version:childHead?.version??head.version,parentId:main.id,agent:{agentType:child.meta?.agentType}};
|
|
88
|
+
rememberKnown(row);rows.push(row);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
}],
|
|
93
|
+
]);
|
|
36
94
|
const stamp = () => new Date(now()).toISOString();
|
|
37
95
|
const notice = text => ({v:1,ts:stamp(),observedAt:stamp(),source:'watch',label:'watch',kind:'notice',text});
|
|
38
96
|
const debug = (out, text) => { if (verbose) out.push(notice(text)); };
|
|
@@ -53,13 +111,20 @@ export function createWatcher({options, homes, scope: initialScope, git, now, re
|
|
|
53
111
|
const ref = dispatch.bySession(row.id);
|
|
54
112
|
return ref && ref.inScope && (ref.cwd ? inScope(scope,ref.cwd) : cwdInScope(row.cwd)) ? ref : null;
|
|
55
113
|
}
|
|
114
|
+
const followedDispatchRow = ref => [...followed.values()].find(row=>ref.sessionIds.includes(row.id) && mapped(row)===ref);
|
|
115
|
+
function dispatchPlatforms(ref, followedRow) {
|
|
116
|
+
const target = ref.targetPlatform ?? followedRow?.platform
|
|
117
|
+
?? (ref.route==='native' ? ref.hostPlatform : undefined) ?? ref.childPlatform;
|
|
118
|
+
const display = homes[target]!=null && TRANSCRIPT_HANDLERS.has(target) ? target : ref.hostPlatform;
|
|
119
|
+
return {display,visible:display ? platforms.includes(display) : platforms.length>=2};
|
|
120
|
+
}
|
|
56
121
|
const selectedRoot = cwd => path.resolve(cwd)===scope.roots[0] || realPath(cwd)===scope.roots[0];
|
|
57
122
|
function cwdInScope(cwd) {
|
|
58
123
|
if (!cwd || !inScope(scope,cwd)) return false;
|
|
59
|
-
return scope.kind!=='repo' || selectedRoot(cwd) || nestedChecks.get(cwd)?.inside===true;
|
|
124
|
+
return probe || scope.kind!=='repo' || selectedRoot(cwd) || nestedChecks.get(cwd)?.inside===true;
|
|
60
125
|
}
|
|
61
126
|
async function verifyCwd(cwd, out) {
|
|
62
|
-
if (scope.kind!=='repo' || !cwd || !inScope(scope,cwd) || selectedRoot(cwd) || nestedChecks.has(cwd)) return;
|
|
127
|
+
if (probe || scope.kind!=='repo' || !cwd || !inScope(scope,cwd) || selectedRoot(cwd) || nestedChecks.has(cwd)) return;
|
|
63
128
|
if (now()-(nestedFailures.get(cwd)??-Infinity)<L.discoveryMs) return;
|
|
64
129
|
let result;
|
|
65
130
|
try { result=(await git(cwd,GIT_ALLOWED[0]))?.trim(); }
|
|
@@ -110,7 +175,7 @@ export function createWatcher({options, homes, scope: initialScope, git, now, re
|
|
|
110
175
|
async function ensureShellRoot(row, out) {
|
|
111
176
|
if (row.gitTop && !shellRoots.has(row.gitTop) && shellRoots.size < L.maxRepos) {
|
|
112
177
|
const state = {snapshot:null,pending:false,pendingSince:undefined,lastTriggerAt:-Infinity,
|
|
113
|
-
lastScanAt:-Infinity,
|
|
178
|
+
lastScanAt:-Infinity,claims:new Map(),candidates:new Map(),failures:0,off:false};
|
|
114
179
|
shellRoots.set(row.gitTop,state);
|
|
115
180
|
await scanRoot(row.gitTop,state,out);
|
|
116
181
|
}
|
|
@@ -141,10 +206,11 @@ export function createWatcher({options, homes, scope: initialScope, git, now, re
|
|
|
141
206
|
...(ref ? ['dispatch',ref.dispatchId,ref.workflowId] : [])].filter(Boolean).join(' ');
|
|
142
207
|
}
|
|
143
208
|
async function normalize(row, lines, live = false, out = []) {
|
|
209
|
+
const handler=TRANSCRIPT_HANDLERS.get(row.platform);
|
|
144
210
|
const events = [];
|
|
145
211
|
let sawInScope=false, firstSession;
|
|
146
212
|
for (const line of lines) {
|
|
147
|
-
const cwd=
|
|
213
|
+
const cwd=handler.lineCwd(line);
|
|
148
214
|
if (cwd) await setCwd(row,cwd,out);
|
|
149
215
|
await verifyCwd(row.cwd,out);
|
|
150
216
|
if (row.gitTop===undefined && gitTopByCwd.has(row.cwd)) {
|
|
@@ -155,10 +221,7 @@ export function createWatcher({options, homes, scope: initialScope, git, now, re
|
|
|
155
221
|
if (entering) events.push(clean({...identity(row),ts:line.timestamp??stamp(),kind:'session',text:sessionText(row)}));
|
|
156
222
|
if (row.inScopeNow===true && !inside) debug(out,`session ${row.id.slice(0,8)} left scope: cwd=${row.cwd}`);
|
|
157
223
|
row.inScopeNow=inside;
|
|
158
|
-
row.
|
|
159
|
-
const normalized = row.platform === 'codex'
|
|
160
|
-
? normalizeCodexLine(line,row.codexState,{codexHome:homes.codex,userHome:homes.user})
|
|
161
|
-
: normalizeClaudeLine(line,row.state);
|
|
224
|
+
const normalized=handler.normalize(line,row.state,homes[row.platform]);
|
|
162
225
|
if (inside) {
|
|
163
226
|
await ensureShellRoot(row,out); sawInScope=true;
|
|
164
227
|
const shell=shellRoots.get(row.gitTop);
|
|
@@ -201,16 +264,21 @@ export function createWatcher({options, homes, scope: initialScope, git, now, re
|
|
|
201
264
|
async function scanDispatch() {
|
|
202
265
|
return dispatch.scan({gitCommonDirs:scope.gitCommonDir ? [scope.gitCommonDir] : []});
|
|
203
266
|
}
|
|
204
|
-
function dispatchEvents(updates, startup, out) {
|
|
267
|
+
function dispatchEvents(updates, startup, out, skipped) {
|
|
205
268
|
for (const {ref,first} of updates) {
|
|
206
269
|
if (!dispatchInScope(ref)) continue;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
const
|
|
210
|
-
|
|
270
|
+
const hidden = startup && (tailCount === 0 || now()-Date.parse(ref.updatedAt) > L.historyWindowMs || !Number.isFinite(Date.parse(ref.updatedAt)));
|
|
271
|
+
if (hidden && !skipped) continue;
|
|
272
|
+
const followedRow = followedDispatchRow(ref);
|
|
273
|
+
const {display,visible} = dispatchPlatforms(ref,followedRow);
|
|
274
|
+
if (!visible) continue;
|
|
211
275
|
const e = {v:1,ts:ref.updatedAt ?? stamp(),observedAt:stamp(),source:'dispatch',label:dispatchLabel(ref.rawRole,ref.dispatchId),kind:'dispatch',dispatchId:ref.dispatchId};
|
|
212
276
|
for (const key of ['workflowId','role','state','reasons','route','hostPlatform']) if (ref[key] !== undefined && ref[key] !== null) e[key]=ref[key];
|
|
213
|
-
if (
|
|
277
|
+
if (display) e.platform=display;
|
|
278
|
+
if (hidden) {
|
|
279
|
+
skipped.push(e);
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
214
282
|
out.push(clean(e));
|
|
215
283
|
if (first && !followedRow && !missingDispatch.has(ref.dispatchId)) {
|
|
216
284
|
debug(out,`transcript not found for dispatch ${ref.dispatchId}`); missingDispatch.add(ref.dispatchId);
|
|
@@ -224,22 +292,28 @@ export function createWatcher({options, homes, scope: initialScope, git, now, re
|
|
|
224
292
|
if (chain.desktop) {ignored.set(row.file,row.size);return false;}
|
|
225
293
|
return chain.resolved && anyCwdInScope(row);
|
|
226
294
|
}
|
|
295
|
+
if (probe) return anyCwdInScope(row);
|
|
227
296
|
const ref = mapped(row);
|
|
228
297
|
return Boolean(ref) || anyCwdInScope(row);
|
|
229
298
|
}
|
|
230
|
-
async function attach(row, startup, out) {
|
|
299
|
+
async function attach(row, startup, out, skipped) {
|
|
300
|
+
if (probe) {
|
|
301
|
+
followed.set(row.id,row);
|
|
302
|
+
return;
|
|
303
|
+
}
|
|
231
304
|
const previous = detached.get(row.file) ?? (!startup && !pending.has(row.file) ? seenAtStart.get(row.file) : undefined);
|
|
232
305
|
let history;
|
|
233
306
|
try { history = previous ? {endOffset:previous.offset} : await readTail(row.file); }
|
|
234
307
|
catch (error) { debug(out,`session file unreadable: ${row.id.slice(0,8)} (${error.code ?? 'error'})`); ignored.set(row.file,row.size); return; }
|
|
235
308
|
row.headCwd=row.cwd;
|
|
236
309
|
row.tail=createTail(row.file,{offset:previous?.offset ?? history.endOffset});
|
|
237
|
-
|
|
310
|
+
const handler=TRANSCRIPT_HANDLERS.get(row.platform);
|
|
311
|
+
row.state=handler.createState(); row.active=false; row.held=[]; row.lastActivity=row.mtimeMs;
|
|
238
312
|
row.cwd=undefined;
|
|
239
313
|
await setCwd(row,previous?.cwd??row.headCwd,out);
|
|
240
314
|
await verifyCwd(row.cwd,out);
|
|
241
315
|
followed.set(row.id,row); pending.delete(row.file); detached.delete(row.file);
|
|
242
|
-
if (!startup && !previous && !row.parentId && !mapped(row) && (row.origin
|
|
316
|
+
if (!startup && !previous && !row.parentId && !mapped(row) && handler.shouldHold(row.origin) && now()-row.mtimeMs<=L.holdCreatedWithinMs) row.holdUntil=now()+L.holdMs;
|
|
243
317
|
const showHistory = startup ? tailCount > 0 && now()-row.mtimeMs<=L.historyWindowMs : !previous;
|
|
244
318
|
const {events,firstSession}=await normalize(row,history.lines??[],false,out);
|
|
245
319
|
if (showHistory) {
|
|
@@ -249,7 +323,7 @@ export function createWatcher({options, homes, scope: initialScope, git, now, re
|
|
|
249
323
|
if (initialSession) events.unshift(initialSession);
|
|
250
324
|
}
|
|
251
325
|
emit(row,events,out);
|
|
252
|
-
}
|
|
326
|
+
} else if (startup && skipped) skipped.push(...events);
|
|
253
327
|
if (row.inScopeNow===undefined) row.inScopeNow=lineGate(row);
|
|
254
328
|
if (lineGate(row)) await ensureShellRoot(row,out);
|
|
255
329
|
if (seenAtStart.has(row.file)) seenAtStart.get(row.file).cwd=row.cwd;
|
|
@@ -333,11 +407,11 @@ export function createWatcher({options, homes, scope: initialScope, git, now, re
|
|
|
333
407
|
&& seenAtStart.get(item.file)?.size === item.size && !pending.has(item.file)
|
|
334
408
|
&& ![...followed.values()].some(row=>row.file===item.file));
|
|
335
409
|
}
|
|
336
|
-
async function codexCandidates(startup) {
|
|
410
|
+
async function codexCandidates(platform, home, startup) {
|
|
337
411
|
if (!startup) {
|
|
338
|
-
const files = new Map((await listCodexRollouts({codexHome:
|
|
412
|
+
const files = new Map((await listCodexRollouts({codexHome:home,now:now(),startup:false})).map(item=>[item.file,item]));
|
|
339
413
|
for (const [file,item] of new Map([...seenAtStart,...detached])) {
|
|
340
|
-
if (item.platform
|
|
414
|
+
if (item.platform!==platform || files.has(file) || [...followed.values()].some(row=>row.file===file)) continue;
|
|
341
415
|
const stat = await details(file);
|
|
342
416
|
if (stat) files.set(file,{...item,...stat,file});
|
|
343
417
|
}
|
|
@@ -348,54 +422,17 @@ export function createWatcher({options, homes, scope: initialScope, git, now, re
|
|
|
348
422
|
for (let back=0;back<=L.lookbackDays;back+=2) {
|
|
349
423
|
const date = new Date(now());
|
|
350
424
|
date.setDate(date.getDate()-back);
|
|
351
|
-
for (const item of await listCodexRollouts({codexHome:
|
|
425
|
+
for (const item of await listCodexRollouts({codexHome:home,now:date.getTime(),startup:false})) files.set(item.file,item);
|
|
352
426
|
}
|
|
353
427
|
return [...files.values()];
|
|
354
428
|
}
|
|
355
|
-
async function discover(startup, out) {
|
|
429
|
+
async function discover(startup, out, skipped) {
|
|
356
430
|
const rows=[];
|
|
357
|
-
const updates = await scanDispatch();
|
|
431
|
+
const updates = probe ? [] : await scanDispatch();
|
|
358
432
|
for (const file of pending.keys()) if (!await details(file)) pending.delete(file);
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
if (item.compressed) {
|
|
363
|
-
if (!compressed.has(item.file)) debug(out,`compressed session skipped: ${path.basename(item.file)}`);
|
|
364
|
-
compressed.add(item.file); continue;
|
|
365
|
-
}
|
|
366
|
-
if ([...followed.values()].some(r=>r.file===item.file)) continue;
|
|
367
|
-
if (skipHead(item,startup)) continue;
|
|
368
|
-
const meta=await cachedHead(metas,item,codexMeta);
|
|
369
|
-
if (!meta) continue;
|
|
370
|
-
const row={...item,id:meta.threadId,platform:'codex',origin:meta.originator,cwd:meta.cwd,version:meta.cliVersion,parentId:meta.parentId,depth:meta.depth,agent:{agentRole:meta.agentRole,nickname:meta.agentNickname}};
|
|
371
|
-
rememberKnown(row);rows.push(row);
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
if (claude && platforms.includes('claude')) {
|
|
375
|
-
const prefixes=dispatch.list().some(ref=>ref.inScope)?null:claudeDirPrefixes(scope);
|
|
376
|
-
const mains=await claude.scan({prefixes:startup?null:prefixes,now:now(),startup:false});
|
|
377
|
-
for (const item of mains) {
|
|
378
|
-
rememberStart(item,startup);
|
|
379
|
-
const children=await childrenFor(item,startup);
|
|
380
|
-
for (const child of children) rememberStart(child,startup);
|
|
381
|
-
if (skipHead(item,startup)) continue;
|
|
382
|
-
const head=await cachedHead(heads,item,claudeHead);
|
|
383
|
-
if (!head) {
|
|
384
|
-
const wait=pending.get(item.file) ?? {...item,until:now()+L.claudeCwdWaitMs,cwdWaiting:true};
|
|
385
|
-
if (now()<wait.until) pending.set(item.file,wait); else {pending.delete(item.file);ignored.set(item.file,item.size);}
|
|
386
|
-
continue;
|
|
387
|
-
}
|
|
388
|
-
pending.delete(item.file);
|
|
389
|
-
const main={...item,id:head.sessionId,platform:'claude',origin:head.entrypoint,cwd:head.cwd,version:head.version};
|
|
390
|
-
rememberKnown(main);
|
|
391
|
-
if (!followed.has(main.id)) rows.push(main);
|
|
392
|
-
for (const child of children) {
|
|
393
|
-
if (skipHead(child,startup)) continue;
|
|
394
|
-
const childHead=await cachedHead(heads,child,claudeHead);
|
|
395
|
-
const row={...child,id:`agent-${child.agentId}`,platform:'claude',origin:head.entrypoint,cwd:childHead?.cwd??head.cwd,version:childHead?.version??head.version,parentId:main.id,agent:{agentType:child.meta?.agentType}};
|
|
396
|
-
rememberKnown(row);rows.push(row);
|
|
397
|
-
}
|
|
398
|
-
}
|
|
433
|
+
for (const [platform, handler] of TRANSCRIPT_HANDLERS) {
|
|
434
|
+
const home=homes[platform];
|
|
435
|
+
if (home && platforms.includes(platform)) await handler.discover({platform,home,startup,out,rows});
|
|
399
436
|
}
|
|
400
437
|
rows.sort((a,b)=>b.mtimeMs-a.mtimeMs||a.file.localeCompare(b.file));
|
|
401
438
|
let remaining=rows.filter(row=> {
|
|
@@ -407,7 +444,7 @@ export function createWatcher({options, homes, scope: initialScope, git, now, re
|
|
|
407
444
|
for (const row of remaining) {
|
|
408
445
|
const previous=detached.get(row.file) ?? seenAtStart.get(row.file);
|
|
409
446
|
if (startup || !previous || row.size>previous.size) {
|
|
410
|
-
const extract=row.platform
|
|
447
|
+
const extract=TRANSCRIPT_HANDLERS.get(row.platform).lineCwd;
|
|
411
448
|
row.latestCwd=await cachedHead(latestCwds,row,file=>readLatestCwd(file,extract));
|
|
412
449
|
}
|
|
413
450
|
rememberStart(row,startup);
|
|
@@ -420,16 +457,17 @@ export function createWatcher({options, homes, scope: initialScope, git, now, re
|
|
|
420
457
|
const next=[];
|
|
421
458
|
for(const row of remaining) {
|
|
422
459
|
if (!eligible(row)) {next.push(row);continue;}
|
|
423
|
-
if (followed.size>=L.maxFollowed) {
|
|
460
|
+
if (!probe && followed.size>=L.maxFollowed) {
|
|
424
461
|
const oldest=[...followed.values()].sort((a,b)=>a.mtimeMs-b.mtimeMs)[0];
|
|
425
462
|
if (!capped) {out.push(notice('following the newest 64 sessions; others are skipped'));capped=true;}
|
|
426
463
|
if (oldest.mtimeMs>=row.mtimeMs || row.parentId===oldest.id) continue;
|
|
427
464
|
followed.delete(oldest.id); detached.set(oldest.file,{file:oldest.file,platform:oldest.platform,offset:oldest.tail.offset,size:oldest.size,cwd:oldest.cwd});
|
|
428
465
|
}
|
|
429
|
-
await attach(row,startup,out);progress=true;
|
|
466
|
+
await attach(row,startup,out,skipped);progress=true;
|
|
430
467
|
}
|
|
431
468
|
remaining=next;
|
|
432
469
|
}
|
|
470
|
+
if (probe) return;
|
|
433
471
|
for (const row of remaining) {
|
|
434
472
|
const chain=ancestry(row);
|
|
435
473
|
const missingParent=!chain.resolved;
|
|
@@ -449,7 +487,7 @@ export function createWatcher({options, homes, scope: initialScope, git, now, re
|
|
|
449
487
|
}
|
|
450
488
|
emit(row,[],out);
|
|
451
489
|
}
|
|
452
|
-
dispatchEvents(updates,startup,out);
|
|
490
|
+
dispatchEvents(updates,startup,out,skipped);
|
|
453
491
|
lastDiscovery=now();
|
|
454
492
|
}
|
|
455
493
|
async function poll(out) {
|
|
@@ -462,7 +500,7 @@ export function createWatcher({options, homes, scope: initialScope, git, now, re
|
|
|
462
500
|
}
|
|
463
501
|
if (result.gone) {followed.delete(id);debug(out,`session file removed: ${row.id.slice(0,8)}`);continue;}
|
|
464
502
|
if (result.reset) {
|
|
465
|
-
row.state=
|
|
503
|
+
row.state=TRANSCRIPT_HANDLERS.get(row.platform).createState();row.active=false;
|
|
466
504
|
await setCwd(row,row.headCwd,out);row.inScopeNow=lineGate(row);
|
|
467
505
|
debug(out,`session restarted from the beginning: ${row.id.slice(0,8)}`);
|
|
468
506
|
}
|
|
@@ -519,16 +557,18 @@ export function createWatcher({options, homes, scope: initialScope, git, now, re
|
|
|
519
557
|
}
|
|
520
558
|
}
|
|
521
559
|
state.snapshot=snapshot;
|
|
522
|
-
const
|
|
523
|
-
if (
|
|
524
|
-
const
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
560
|
+
const changed=Object.entries(changes).filter(([,files])=>files.length);
|
|
561
|
+
if (changed.length) {
|
|
562
|
+
const candidate=[...state.candidates].filter(([id,value])=>followed.has(id) && value?.identity).sort((a,b)=>b[1].ts-a[1].ts)[0];
|
|
563
|
+
if (candidate) {
|
|
564
|
+
const events=changed.map(([kind,files])=>
|
|
565
|
+
clean({...candidate[1].identity,observedAt:stamp(),ts:stamp(),kind,paths:files.sort(),inferred:true}));
|
|
566
|
+
emit(followed.get(candidate[0]),events,out);
|
|
567
|
+
}
|
|
528
568
|
}
|
|
529
569
|
}
|
|
530
570
|
}
|
|
531
|
-
state.
|
|
571
|
+
state.lastScanAt=now();
|
|
532
572
|
state.pending=false; state.pendingSince=undefined; state.candidates.clear();
|
|
533
573
|
}
|
|
534
574
|
async function scanShell(out) {
|
|
@@ -550,6 +590,10 @@ export function createWatcher({options, homes, scope: initialScope, git, now, re
|
|
|
550
590
|
async start() {
|
|
551
591
|
if (started||closed) return [];
|
|
552
592
|
started=true;
|
|
593
|
+
if (probe) {
|
|
594
|
+
await discover(true,[]);
|
|
595
|
+
return [];
|
|
596
|
+
}
|
|
553
597
|
const store = await resolveDispatchStore({homes, registry});
|
|
554
598
|
// Keep observing the legacy path even when its first lease arrives after startup.
|
|
555
599
|
const storeDir = store.kind === 'none' && homes.codex && registry.isPlatformId('codex')
|
|
@@ -557,14 +601,32 @@ export function createWatcher({options, homes, scope: initialScope, git, now, re
|
|
|
557
601
|
dispatch = dispatchIndex({storeDir});
|
|
558
602
|
const description=`scope ${scope.roots[0]}`+(scope.kind==='repo'?` (${scope.roots.length} worktrees)`:'');
|
|
559
603
|
const out=[];
|
|
604
|
+
const skipped=options.earlier ? [] : undefined;
|
|
560
605
|
if (store.kind === 'ambiguous') out.push(notice('dispatch store ambiguous'));
|
|
561
|
-
await discover(true,out);
|
|
562
|
-
const
|
|
606
|
+
await discover(true,out,skipped);
|
|
607
|
+
const ordered=sort(out.filter(e=>e.source!=='watch'));
|
|
608
|
+
const history=ordered.slice(-tailCount || Infinity);
|
|
609
|
+
if (skipped) {
|
|
610
|
+
const hidden=skipped.concat(ordered.slice(0,ordered.length-history.length));
|
|
611
|
+
earlierBacklog=sort(hidden.filter(e=>e.source!=='watch')).slice(-L.earlierMax);
|
|
612
|
+
}
|
|
563
613
|
const diagnostics=out.filter(e=>e.source==='watch');
|
|
564
|
-
|
|
614
|
+
const brief = {
|
|
615
|
+
scope:scope.display ?? watchLocationLabel({dir:scope.roots[0],home:homes.user}),
|
|
616
|
+
...(scope.branch ? {branch:scope.branch} : {}),
|
|
617
|
+
platforms:registry.byDisplayOrder().filter(({id}) => platforms.includes(id)).map(({id}) => id),
|
|
618
|
+
};
|
|
619
|
+
const header = notice(`arc watch: ${description} · ${platforms.map(name => name.toUpperCase()).join('+')} · Ctrl-C to stop`);
|
|
620
|
+
return markEmitted([{...header,brief},...diagnostics,...(tailCount?history:[]),{...notice('live'),startup:'live'}]);
|
|
621
|
+
},
|
|
622
|
+
earlier(count) {
|
|
623
|
+
const size=Math.trunc(count);
|
|
624
|
+
if (!earlierBacklog?.length || !(size>0)) return {events:[],remaining:earlierBacklog?.length ?? 0};
|
|
625
|
+
const events=earlierBacklog.splice(Math.max(0,earlierBacklog.length-size)).map(clean);
|
|
626
|
+
return {events,remaining:earlierBacklog.length};
|
|
565
627
|
},
|
|
566
628
|
async tick() {
|
|
567
|
-
if (!started||closed) return [];
|
|
629
|
+
if (!started||closed||probe) return [];
|
|
568
630
|
const out=[];
|
|
569
631
|
if (now()-lastRefresh>=L.worktreeRefreshMs) {scope=await refreshScope(scope,git);lastRefresh=now();}
|
|
570
632
|
if (now()-lastDiscovery>=L.discoveryMs||pending.size||[...followed.values()].some(row=>row.holdUntil!==undefined)) await discover(false,out);
|
|
@@ -572,7 +634,12 @@ export function createWatcher({options, homes, scope: initialScope, git, now, re
|
|
|
572
634
|
await scanShell(out);
|
|
573
635
|
return markEmitted(sort(out));
|
|
574
636
|
},
|
|
637
|
+
listActivity() {
|
|
638
|
+
return [...followed.values()].map(row=>({
|
|
639
|
+
platform:row.platform,mtimeMs:row.mtimeMs,cwd:row.latestCwd ?? row.cwd,main:!row.parentId,
|
|
640
|
+
}));
|
|
641
|
+
},
|
|
575
642
|
busy() {return [...followed.values()].some(row=>row.active && (row.inScopeNow || mapped(row)) && now()-row.lastActivity<=L.spinnerIdleMs);},
|
|
576
|
-
async close() {closed=true;followed.clear();pending.clear();},
|
|
643
|
+
async close() {closed=true;followed.clear();pending.clear();earlierBacklog=undefined;},
|
|
577
644
|
};
|
|
578
645
|
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {DEFAULT_PLATFORM_REGISTRY} from '../runtime/platform-registry.mjs';
|
|
2
|
+
import {createTuiInterface} from '../tui/interface.mjs';
|
|
3
|
+
import {cellWidth, fitChoiceRow} from '../tui/render.mjs';
|
|
4
|
+
import {createTerminalSession} from '../tui/terminal.mjs';
|
|
5
|
+
import {WATCH_LIMITS as L} from './model.mjs';
|
|
6
|
+
import {sanitizeText} from './policy.mjs';
|
|
7
|
+
import {orderWorktrees, sameWorktree, worktreeBranch, worktreeDisplayPath} from './scope.mjs';
|
|
8
|
+
|
|
9
|
+
const columns = text => [...text].reduce((sum,character)=>sum+cellWidth(character),0);
|
|
10
|
+
const pad = (text,width) => text+' '.repeat(Math.max(0,width-columns(text)));
|
|
11
|
+
|
|
12
|
+
export function worktreeMenuRows(shown, groups, {
|
|
13
|
+
mainRoot,currentRoot,home,now,width=80,color,registry=DEFAULT_PLATFORM_REGISTRY,
|
|
14
|
+
}) {
|
|
15
|
+
const platforms = registry.byDisplayOrder().filter(row=>row.capabilities.watch.state==='verified');
|
|
16
|
+
const rows = shown.map(tree => {
|
|
17
|
+
const group = groups.get(tree.root);
|
|
18
|
+
const prefix = (sameWorktree(tree.root,currentRoot) ? 'here · ' : '')+(tree.locked ? 'locked · ' : '');
|
|
19
|
+
const branch = sanitizeText(worktreeBranch(tree));
|
|
20
|
+
if (!group) return {branch,activity:prefix+(color ? 'no recent activity' : '(no recent activity)'),tone:color ? 'dim' : undefined};
|
|
21
|
+
const elapsed = Math.max(0,now-group.lastActivity);
|
|
22
|
+
const relative = elapsed<60000 ? Math.floor(elapsed/1000)+'s' : Math.floor(elapsed/60000)+'m';
|
|
23
|
+
const names = platforms.filter(row=>group.platforms.has(row.id)).map(row=>row.label.toUpperCase()).join(', ');
|
|
24
|
+
const activity = prefix+(elapsed<=L.spinnerIdleMs ? '● ' : '')+`${relative} ago · ${group.sessions} session${group.sessions===1?'':'s'}`+
|
|
25
|
+
(names ? ' · '+names : '');
|
|
26
|
+
return {branch,activity};
|
|
27
|
+
});
|
|
28
|
+
const available = Math.max(0,width-7);
|
|
29
|
+
const naturalBranch = Math.max(0,...rows.map(row=>columns(row.branch)));
|
|
30
|
+
const naturalPath = Math.max(0,...shown.map(tree=>columns(worktreeDisplayPath(tree.root,{mainRoot,home}))));
|
|
31
|
+
const activityWidth = Math.max(0,...rows.map(row=>columns(row.activity)));
|
|
32
|
+
const pathBudget = Math.min(naturalPath,Math.max(12,available-naturalBranch-activityWidth));
|
|
33
|
+
const locations = shown.map(tree=>worktreeDisplayPath(tree.root,{mainRoot,home,width:pathBudget}));
|
|
34
|
+
// Align with the TUI's conservative cell widths when a path contains an ellipsis.
|
|
35
|
+
const pathWidth = Math.max(pathBudget,...locations.map(columns));
|
|
36
|
+
const branchWidth = Math.min(naturalBranch,Math.max(8,available-pathWidth-activityWidth));
|
|
37
|
+
return {rows:rows.map(({branch,activity},index)=>{
|
|
38
|
+
const location = locations[index];
|
|
39
|
+
return fitChoiceRow(pad(location,pathWidth)+' '+pad(fitChoiceRow(branch,branchWidth+3),branchWidth)+' '+activity,width);
|
|
40
|
+
}),tones:rows.map(row=>row.tone)};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function chooseWatchWorktree({
|
|
44
|
+
input,output,env=process.env,signals,worktrees,groups,mainRoot,currentRoot,home,now,
|
|
45
|
+
color=env.NO_COLOR===undefined && env.TERM!=='dumb',registry,createSession=createTerminalSession,
|
|
46
|
+
}) {
|
|
47
|
+
const {shown,hidden} = orderWorktrees(worktrees,groups,{currentRoot,mainRoot,home});
|
|
48
|
+
if (!shown.length) return null;
|
|
49
|
+
const session = createSession({input,output,env,signals});
|
|
50
|
+
try {
|
|
51
|
+
const ui = createTuiInterface(session,{input});
|
|
52
|
+
const {rows,tones} = worktreeMenuRows(shown,groups,{mainRoot,currentRoot,home,now,width:session.viewport().columns,color,registry});
|
|
53
|
+
const selected = await ui.menu('Which worktree to watch?',rows,{
|
|
54
|
+
backRow:true,backLabel:'exit',fitRows:true,
|
|
55
|
+
rowTones:tones,info:hidden ? [`${hidden} more worktrees not shown. Run arc watch inside a worktree to watch it.`] : [],
|
|
56
|
+
});
|
|
57
|
+
return selected===null ? null : shown[selected].root;
|
|
58
|
+
} catch (error) {
|
|
59
|
+
if (error.code==='ARC_TUI_EOF') return null;
|
|
60
|
+
throw error;
|
|
61
|
+
} finally {
|
|
62
|
+
session.dispose();
|
|
63
|
+
}
|
|
64
|
+
}
|
package/package.json
CHANGED
|
@@ -6,9 +6,16 @@ import {runtimeRegistryOf} from './platform-registry.mjs';
|
|
|
6
6
|
|
|
7
7
|
const environments = new WeakMap();
|
|
8
8
|
const authKinds = new WeakMap();
|
|
9
|
+
export function unknownPlatformMessage(platform, knownIds) {
|
|
10
|
+
const id = typeof platform === 'string'
|
|
11
|
+
? [...platform.replace(/[\p{Cc}\u2028\u2029]/gu, '')].slice(0, 256).join('')
|
|
12
|
+
: '(invalid)';
|
|
13
|
+
return `Unknown platform: ${id}. Known platforms: ${knownIds.join(', ')}`;
|
|
14
|
+
}
|
|
9
15
|
export function resolveConfigHome(platform, context = {}) {
|
|
10
|
-
const
|
|
11
|
-
|
|
16
|
+
const registry = runtimeRegistryOf(context);
|
|
17
|
+
const descriptor = registry.getPlatform(platform);
|
|
18
|
+
if (!descriptor) throw Error(unknownPlatformMessage(platform, registry.byDisplayOrder().map(({id}) => id)));
|
|
12
19
|
return descriptor.home.resolve(context);
|
|
13
20
|
}
|
|
14
21
|
export function resolveLocalCli(platform, { cwd, userHome, env = process.env, runtimePlatforms } = {}) {
|
|
@@ -109,7 +109,7 @@ export const DEFAULT_PLATFORM_REGISTRY = createPlatformRegistry([
|
|
|
109
109
|
{
|
|
110
110
|
id: 'gemini', label: 'Gemini', displayOrder: 2, anchorOrder: 2,
|
|
111
111
|
home: {env: 'GEMINI_CLI_HOME', resolve: context => resolveHome('gemini', context)},
|
|
112
|
-
cli: {command: 'gemini', supportedVersions:
|
|
112
|
+
cli: {command: 'gemini', supportedVersions: null},
|
|
113
113
|
auth: {kind: 'none'},
|
|
114
114
|
models: {effortField: 'effort'},
|
|
115
115
|
profile: {
|