@yunhozz/arc 0.4.6 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MANIFEST.sha256 +89 -76
- package/README.md +35 -51
- package/claude/agents/arc-implementer.md +2 -2
- package/claude/agents/arc-planner.md +1 -1
- package/claude/agents/arc-qa.md +1 -1
- package/claude/agents/arc-reviewer.md +1 -1
- package/claude/agents/arc-scouter.md +1 -1
- package/claude/skill/models.toml +7 -7
- package/claude/skill/references/coordination.md +6 -2
- package/claude/skill/references/handoff-prep.md +5 -0
- package/claude/skill/references/handoff.md +2 -2
- package/claude/skill/references/planning.md +2 -2
- package/claude/skill/references/verification.md +21 -3
- package/claude/skill/references/worktree-creation.md +2 -2
- package/codex/agents/arc-implementer.toml +1 -1
- package/codex/agents/arc-planner.toml +1 -1
- package/codex/agents/arc-qa.toml +1 -1
- package/codex/agents/arc-reviewer.toml +1 -1
- package/codex/agents/arc-scouter.toml +1 -1
- package/codex/skill/models.toml +5 -5
- package/codex/skill/references/coordination.md +6 -2
- package/codex/skill/references/handoff-prep.md +5 -0
- package/codex/skill/references/handoff.md +2 -2
- package/codex/skill/references/planning.md +2 -2
- package/codex/skill/references/verification.md +20 -2
- package/gemini/agents/arc-implementer.md +3 -3
- package/gemini/agents/arc-planner.md +2 -2
- package/gemini/agents/arc-qa.md +2 -2
- package/gemini/agents/arc-reviewer.md +2 -2
- package/gemini/agents/arc-scouter.md +2 -2
- package/gemini/skill/models.toml +6 -6
- package/gemini/skill/references/coordination.md +7 -3
- package/gemini/skill/references/handoff-prep.md +5 -0
- package/gemini/skill/references/handoff.md +2 -2
- package/gemini/skill/references/planning.md +2 -2
- package/gemini/skill/references/verification.md +21 -3
- package/gemini/skill/references/worktree-creation.md +2 -2
- package/grok/agents/arc-implementer.md +2 -2
- package/grok/agents/arc-planner.md +1 -1
- package/grok/agents/arc-qa.md +1 -1
- package/grok/agents/arc-reviewer.md +1 -1
- package/grok/agents/arc-scouter.md +1 -1
- package/grok/skill/references/coordination.md +6 -2
- package/grok/skill/references/handoff-prep.md +5 -0
- package/grok/skill/references/handoff.md +2 -2
- package/grok/skill/references/planning.md +2 -2
- package/grok/skill/references/verification.md +21 -3
- package/grok/skill/references/worktree-creation.md +2 -2
- package/lib/cli/postinstall.mjs +1 -1
- package/lib/cli/root.mjs +1 -1
- package/lib/installer/runtime-assets.mjs +5 -1
- package/lib/management/reapply.mjs +117 -0
- package/lib/management/update.mjs +59 -5
- package/lib/models/catalog-gemini.mjs +4 -1
- package/lib/models/gemini-models.json +4 -0
- package/lib/npm/upgrade.mjs +6 -2
- package/lib/policy/role-policy.json +1 -1
- package/lib/prompts/agent-fragments.json +5 -5
- package/lib/runtime/final-verify.mjs +2158 -0
- package/lib/runtime/node-test-reporter.mjs +81 -0
- package/lib/runtime/platform-registry.mjs +1 -1
- package/lib/runtime/role-bridge.mjs +10 -1
- package/lib/runtime/role-dispatch-policy.mjs +4 -0
- package/lib/runtime/role-observe.mjs +192 -14
- package/lib/runtime/role-supervisor.mjs +268 -23
- package/lib/runtime/test-results.mjs +736 -0
- package/lib/runtime/verify-cli.mjs +60 -0
- package/lib/tui/app.mjs +7 -41
- package/lib/tui/interface.mjs +40 -0
- package/lib/tui/render.mjs +1 -1
- package/lib/tui/setup.mjs +27 -16
- package/lib/watch/args.mjs +12 -27
- package/lib/watch/dispatch.mjs +2 -2
- package/lib/watch/index.mjs +38 -26
- package/lib/watch/markdown.mjs +232 -0
- package/lib/watch/menu.mjs +54 -0
- package/lib/watch/model.mjs +7 -3
- package/lib/watch/render.mjs +28 -67
- package/lib/watch/scope.mjs +1 -5
- package/lib/watch/status-line.mjs +2 -4
- package/lib/watch/text-width.mjs +43 -0
- package/lib/watch/watcher.mjs +17 -36
- package/package.json +1 -1
- package/shared/skill/runtime/final-verify.mjs +2158 -0
- package/shared/skill/runtime/node-test-reporter.mjs +81 -0
- package/shared/skill/runtime/platform-registry.mjs +1 -1
- package/shared/skill/runtime/role-bridge.mjs +10 -1
- package/shared/skill/runtime/role-dispatch-policy.mjs +4 -0
- package/shared/skill/runtime/role-observe.mjs +192 -14
- package/shared/skill/runtime/role-policy.json +1 -1
- package/shared/skill/runtime/role-supervisor.mjs +268 -23
- package/shared/skill/runtime/test-results.mjs +736 -0
- package/shared/skill/runtime/verify-cli.mjs +60 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import {fileURLToPath} from 'node:url';
|
|
4
|
+
import {validateWorkflowId} from './scope.mjs';
|
|
5
|
+
import {dispatchVerify, VerifyError, VERIFY_COMMANDS} from './final-verify.mjs';
|
|
6
|
+
|
|
7
|
+
export async function runVerifyCommand(args, io = {}) {
|
|
8
|
+
const output = io.output ?? process.stdout;
|
|
9
|
+
let workflowId = null;
|
|
10
|
+
let result;
|
|
11
|
+
let exit;
|
|
12
|
+
try {
|
|
13
|
+
const [command, ...rest] = args;
|
|
14
|
+
const env = io.env ?? process.env;
|
|
15
|
+
if (VERIFY_COMMANDS.includes(command) && Object.hasOwn(env, 'ARC_BRIDGE_CHILD')) {
|
|
16
|
+
throw new VerifyError('bridge_child');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let cwd;
|
|
20
|
+
let input;
|
|
21
|
+
try {
|
|
22
|
+
if (!VERIFY_COMMANDS.includes(command)) throw Error('Expected verify command');
|
|
23
|
+
const options = {};
|
|
24
|
+
for (let i = 0; i < rest.length; i += 2) {
|
|
25
|
+
const key = rest[i];
|
|
26
|
+
if (!['--cwd', '--workflow', '--input'].includes(key) || Object.hasOwn(options, key) || typeof rest[i+1] !== 'string') {
|
|
27
|
+
throw Error('Invalid verify option');
|
|
28
|
+
}
|
|
29
|
+
options[key] = rest[i+1];
|
|
30
|
+
}
|
|
31
|
+
workflowId = validateWorkflowId(options['--workflow']);
|
|
32
|
+
cwd = options['--cwd'];
|
|
33
|
+
if (typeof cwd !== 'string' || !path.isAbsolute(cwd) || path.normalize(cwd) !== cwd || cwd.includes('\0')) {
|
|
34
|
+
throw Error('Absolute workspace required');
|
|
35
|
+
}
|
|
36
|
+
if (options['--input'] !== '-') throw Error('Verify commands require --input -');
|
|
37
|
+
} catch (error) {
|
|
38
|
+
throw new VerifyError('invalid_request', 'deny', {message: error.message});
|
|
39
|
+
}
|
|
40
|
+
const text = io.input ?? fs.readFileSync(0, 'utf8');
|
|
41
|
+
try {
|
|
42
|
+
input = JSON.parse(text);
|
|
43
|
+
} catch {
|
|
44
|
+
throw new VerifyError('invalid_request', 'deny', {message: 'Expected JSON input'});
|
|
45
|
+
}
|
|
46
|
+
result = await dispatchVerify(command, {cwd, workflowId, input, env});
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (error instanceof VerifyError) result = error.result;
|
|
49
|
+
else {
|
|
50
|
+
exit = 1;
|
|
51
|
+
result = {decision: 'hold', code: 'verify_error', message: error.message};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
output.write(JSON.stringify({workflowId, ...result}) + '\n');
|
|
55
|
+
return exit ?? {allow: 0, deny: 2, hold: 3}[result.decision];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (process.argv[1] && fs.realpathSync(process.argv[1], {throwIfNoEntry: false}) === fileURLToPath(import.meta.url)) {
|
|
59
|
+
process.exitCode = await runVerifyCommand(process.argv.slice(2));
|
|
60
|
+
}
|
package/lib/tui/app.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {readFileSync} from 'node:fs';
|
|
2
2
|
import {createTerminalSession} from './terminal.mjs';
|
|
3
|
-
import {escapeTerminalText,cellWidth,
|
|
3
|
+
import {escapeTerminalText,cellWidth,fitChoiceRow} from './render.mjs';
|
|
4
|
+
import {createTuiInterface} from './interface.mjs';
|
|
5
|
+
export {createTuiInterface};
|
|
4
6
|
import {createManagementContext,prepareOperation,executeOperation,forceFinishBlockingDispatches,readCompositeConfig,currentInstallState} from '../management/operations.mjs';
|
|
5
7
|
import {collectStatus} from '../management/status.mjs';
|
|
6
8
|
import {runInstallFlow,loadRoleDefaults,roleDisplayName} from './setup.mjs';
|
|
@@ -9,50 +11,14 @@ import {statusInfo,statusVersion} from './mode.mjs';
|
|
|
9
11
|
import {installerRegistryOf,platformLabel} from '../platforms/index.mjs';
|
|
10
12
|
const packageVersion=JSON.parse(readFileSync(new URL('../../package.json',import.meta.url),'utf8')).version;
|
|
11
13
|
const home=[{id:'install',label:'Configure'},{id:'status',label:'Status'},{id:'uninstall',label:'Uninstall'},{id:'exit',label:'Exit'}];
|
|
12
|
-
function goHome(){throw Object.assign(Error('Return home'),{code:'ARC_TUI_HOME'});}
|
|
13
|
-
function interrupted(){return Object.assign(Error('Session interrupted'),{code:'ARC_CANCELLED'});}
|
|
14
|
-
export function createTuiInterface(session,{input,controller}={}){
|
|
15
|
-
async function event(){const e=await session.nextEvent();if(e.name==='interrupt')throw interrupted();if(e.name==='eof')throw Object.assign(Error('Session closed'),{code:'ARC_TUI_EOF'});if(e.name==='error')throw e.error;return e;}
|
|
16
|
-
async function menu(title,rows,{selected=0,info=[],infoTones,notice=[],fitRows=false,backRow=false,actionKinds,backLabel='back',wordmark=false,version,renderBody,onHorizontal,refreshMs,hint='menu'}={}){
|
|
17
|
-
const actions=backRow?[...rows,'Back']:rows,kinds=rows.map((_,index)=>actionKinds?.[index]);if(backRow)kinds.push('cancel');
|
|
18
|
-
selected=actions.length?Math.max(0,Math.min(selected,actions.length-1)):0;
|
|
19
|
-
const animate=wordmark&&session.frameMs>0,pulse=typeof onHorizontal==='function'&&session.motion===true,tickMs=animate||pulse?session.frameMs:refreshMs;
|
|
20
|
-
let pending,settled,wake,timer,blink=true,frame=0,blinkElapsed=0,repainting=false;
|
|
21
|
-
try{while(true){
|
|
22
|
-
const viewport=session.viewport(),display=actions,displayIndex=selected,information=[],tones=[],spans=[];
|
|
23
|
-
const details=typeof info==='function'?info({selected,...viewport}):info;
|
|
24
|
-
for(const [index,row] of details.entries()){const wrapped=wrapDetailRow(row,viewport.columns),tone=infoTones?.[index],states=tone==='status'?statusSpans(row):tone==='platform-status'?platformStatusSpans(row):[];for(const [line,{text,from,to,prefix}] of wrapped.entries()){information.push(text);tones.push(line&&tone==='diagnostic'?'diagnostic-cont':tone);spans.push(states.filter(span=>span.from<to&&span.to>from).map(span=>({...span,from:Math.max(span.from,from)-from+prefix,to:Math.min(span.to,to)-from+prefix})));}}
|
|
25
|
-
while(information.at(-1)===''){information.pop();tones.pop();}if(information.length){information.push('');tones.push(undefined);}
|
|
26
|
-
const notices=typeof notice==='function'?notice({selected,...viewport}):notice,noticeRows=wrapDetailRows(notices,viewport.columns);while(noticeRows.at(-1)==='')noticeRows.pop();
|
|
27
|
-
const capacity=Math.max(1,viewport.rows-(wordmark?wordmarkRows(viewport):1)-information.length-noticeRows.length-4),offset=Math.max(0,Math.min(displayIndex-capacity+1,display.length-capacity)),visible=display.slice(offset,offset+capacity).map(row=>fitRows?fitChoiceRow(row,viewport.columns):row);
|
|
28
|
-
const screen={title,wordmark,version,frame,notices,rows:[...information,...visible],selected:actions.length?information.length+displayIndex-offset:undefined,hint:navigationHint(hint,{backLabel,horizontal:typeof onHorizontal==='function'}),...(display.length>capacity?{position:(offset+1)+'-'+Math.min(offset+capacity,display.length)+'/'+display.length}:{})};
|
|
29
|
-
if(infoTones){screen.rowTones=[...tones,...visible.map(()=>undefined)];screen.rowStatusSpans=spans;}
|
|
30
|
-
if(backRow||actionKinds)screen.rowKinds=[...information.map(()=>undefined),...kinds.slice(offset,offset+capacity)];
|
|
31
|
-
const body=renderBody?.({selected,blink,frame,...viewport});if(body){delete screen.rowTones;delete screen.rowStatusSpans;delete screen.rowKinds;if(body.rowKinds)screen.rowKinds=body.rowKinds;screen.rows=body.rows;screen.selected=body.selected;screen.showSelection=body.showSelection;screen.compactFooter=body.compactFooter;if(Object.hasOwn(body,'notices'))screen.notices=body.notices;if(Object.hasOwn(body,'position'))screen.position=body.position;}
|
|
32
|
-
const rendered=(repainting?(session.repaint??session.render):session.render).call(session,screen);pending??=event().then(e=>{settled={e};wake?.();},error=>{settled={error};wake?.();});
|
|
33
|
-
if(tickMs>0){if(!settled)await new Promise(resolve=>{wake=resolve;timer=setTimeout(resolve,tickMs);});clearTimeout(timer);timer=undefined;wake=undefined;if(!settled){if(animate||pulse)frame++;if(refreshMs>0){blinkElapsed+=tickMs;while(blinkElapsed>=refreshMs){blink=!blink;blinkElapsed-=refreshMs;}}repainting=true;continue;}}else await pending;
|
|
34
|
-
if(Object.hasOwn(settled,'error'))throw settled.error;const e=settled.e;pending=undefined;settled=undefined;repainting=false;
|
|
35
|
-
if(e.name==='up'&&actions.length)selected=(selected+actions.length-1)%actions.length;else if(e.name==='down'&&actions.length)selected=(selected+1)%actions.length;else if((e.name==='left'||e.name==='right')&&onHorizontal)onHorizontal({direction:e.name,selected,...viewport});else if(e.name==='escape'){if(backLabel==='exit')return null;goHome();}else if(e.name==='enter'&&actions.length&&rendered.selectionEnabled!==false)return backRow&&selected===rows.length?null:selected;
|
|
36
|
-
}}finally{if(timer!==undefined)clearTimeout(timer);}
|
|
37
|
-
}
|
|
38
|
-
async function text(title,initial=''){let value=initial,selected=2;while(true){const rendered=session.render({title,mode:'text',rows:[value,'','Save','Back',''],rowKinds:[undefined,undefined,'confirm','cancel',undefined],selected,hint:navigationHint('text')});const e=await event();if(e.name==='text'||e.name==='paste')value+=e.text;else if(e.name==='backspace')value=[...value].slice(0,-1).join('');else if(e.name==='up'||e.name==='down')selected=selected===2?3:2;else if(e.name==='escape')goHome();else if(e.name==='enter'&&rendered.selectionEnabled!==false)return selected===2?value:null;}}
|
|
39
|
-
async function page(title,rows){
|
|
40
|
-
let offset=0;
|
|
41
|
-
while(true){const viewport=session.viewport(),wrapped=wrapDetailRows(rows,viewport.columns),size=Math.max(1,viewport.rows-4),last=Math.max(0,wrapped.length-size);
|
|
42
|
-
offset=Math.min(offset,last);const slice=wrapped.slice(offset,offset+size);
|
|
43
|
-
session.render({title,mode:'page',rows:slice,position:`Rows ${offset+1}-${Math.min(offset+size,wrapped.length)} of ${wrapped.length}`,hint:navigationHint('page')});const e=await event();
|
|
44
|
-
if(e.name==='down')offset=Math.min(last,offset+1);else if(e.name==='up')offset=Math.max(0,offset-1);else if(e.name==='escape')goHome();else if(e.name==='enter')return true;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async function busy(action){let frame=0,timer;const screen={title:'Working',mode:'busy',rows:[],hint:navigationHint('busy'),frame};session.render(screen);session.setBusy(true);const wasFlowing=input?.readableFlowing;const abort=()=>{if(!controller?.signal.aborted)controller?.abort();},onData=chunk=>{if(String(chunk).includes('\x03')||String(chunk).includes('\x04'))abort();};input?.on('data',onData);input?.prependListener('end',abort);input?.prependListener('close',abort);try{if(input?.readableEnded||input?.destroyed){abort();throw interrupted();}if(controller?.signal.aborted)throw interrupted();if(session.frameMs>0)timer=setInterval(()=>{try{(session.repaint??session.render).call(session,{...screen,frame:++frame});}catch{clearInterval(timer);}},session.frameMs);const result=await (session.frameMs>0?Promise.resolve().then(action):action());if(controller?.signal.aborted){if(typeof result?.code!=='number')throw interrupted();return{...result,code:130,interrupted:true};}return result;}catch(error){if(controller?.signal.aborted&&(['ARC_CANCELLED','ARC_NPM_CANCELLED','ARC_ACQUISITION_CANCELLED','ARC_INSTALL_CANCELLED','ABORT_ERR'].includes(error?.code)||error?.name==='AbortError'))throw interrupted();throw error;}finally{clearInterval(timer);input?.removeListener('data',onData);input?.removeListener('end',abort);input?.removeListener('close',abort);if(wasFlowing!==true)input?.pause?.();session.setBusy(false);session.discardInput();}}
|
|
48
|
-
return{menu,text,page,busy};
|
|
49
|
-
}
|
|
50
14
|
export function resultRows(result,registry=installerRegistryOf(),{version}={}){
|
|
51
15
|
version=result.version??version;
|
|
52
16
|
const clean=text=>text.replace(/; rollback: [^\r\n]*/g,''),label=platform=>platformLabel(platform,registry),errorLine=error=>clean(error.message.split(/[\r\n]/)[0]);
|
|
53
17
|
const residualRows=new Set();
|
|
54
18
|
const removed=result.code===0&&['removed','absent'].includes(result.cli?.status);
|
|
55
|
-
|
|
19
|
+
const platformOf=item=>item.platform??item.target?.platform??'Target',installed=result.code===0?(result.results??[]).filter(item=>item.status==='installed'&&!item.error):[];
|
|
20
|
+
const applied=installed.length?['🎉 Setup ran successfully! Please restart ARC to check.','Apply to: '+installed.map(item=>label(platformOf(item))).join(', ')]:[];
|
|
21
|
+
return[...(result.messages??[]).map(s=>clean(s.trim())),...[result.stdout,result.stderr].flatMap(text=>text?text.trimEnd().split(/\r?\n/).map(clean):[]),...(result.results??[]).flatMap(item=>{const platform=platformOf(item);return[...(removed&&item.status==='uninstalled'?[]:installed.includes(item)?(item===installed[0]?applied:[]):[item.status==='installed'?`ARC${version==null?'':' '+version} installed for ${label(platform)}.`:item.status==='uninstalled'?`Removed from ${label(platform)}.`:`${platform}: ${item.status}`]),...(item.residualPaths??[]).map(p=>'Residual path: '+p),...(item.error?['Error: '+errorLine(item.error)]:[])];}),...(removed?[result.cli.status==='removed'?'Removed ARC and CLI.':'Removed ARC.']:result.cli?['CLI: '+result.cli.status,...(result.cli.error?['CLI error: '+errorLine(result.cli.error)]:[])]:[]),...(result.error?['Error: '+errorLine(result.error)]:[]),...(result.code!==0?['Exit code: '+result.code]:[]),...(result.exitSession?[result.cli?'CLI removal ended this session.':'CLI replacement ended this session.']:[])].filter(row=>{if(!row.startsWith('Residual path: '))return true;if(residualRows.has(row))return false;residualRows.add(row);return true;});
|
|
56
22
|
}
|
|
57
23
|
function formatElapsed(ms){
|
|
58
24
|
const minutes=Math.floor(ms/60000),hours=Math.floor(minutes/60),days=Math.floor(hours/24);
|
|
@@ -109,7 +75,7 @@ export async function runTui(options={}){
|
|
|
109
75
|
}
|
|
110
76
|
}
|
|
111
77
|
if(code===0&&['install','preset','switch','composite'].includes(prepared.kind))for(const key of Object.keys(draft))delete draft[key];
|
|
112
|
-
const rows=prepared.kind==='update'&&code===0?[
|
|
78
|
+
const rows=prepared.kind==='update'&&code===0?['🎉 Update ran successfully! Please restart ARC to check.']:resultRows(result,registry,{version:packageVersion});
|
|
113
79
|
if(code===130||result.exitSession){finalReport=rows;if(result.exitSession)session.render({title:'Result',rows:finalReport,hint:'Session ended'});return true;}
|
|
114
80
|
await ui.page('Result',rows);return false;
|
|
115
81
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {navigationHint,statusSpans,platformStatusSpans,wrapDetailRow,wrapDetailRows,wordmarkRows,fitChoiceRow} from './render.mjs';
|
|
2
|
+
|
|
3
|
+
function goHome(){throw Object.assign(Error('Return home'),{code:'ARC_TUI_HOME'});}
|
|
4
|
+
function interrupted(){return Object.assign(Error('Session interrupted'),{code:'ARC_CANCELLED'});}
|
|
5
|
+
export function createTuiInterface(session,{input,controller}={}){
|
|
6
|
+
async function event(){const e=await session.nextEvent();if(e.name==='interrupt')throw interrupted();if(e.name==='eof')throw Object.assign(Error('Session closed'),{code:'ARC_TUI_EOF'});if(e.name==='error')throw e.error;return e;}
|
|
7
|
+
async function menu(title,rows,{selected=0,info=[],infoTones,notice=[],fitRows=false,backRow=false,actionKinds,backLabel='back',wordmark=false,version,renderBody,onHorizontal,refreshMs,hint='menu'}={}){
|
|
8
|
+
const actions=backRow?[...rows,'Back']:rows,kinds=rows.map((_,index)=>actionKinds?.[index]);if(backRow)kinds.push('cancel');
|
|
9
|
+
selected=actions.length?Math.max(0,Math.min(selected,actions.length-1)):0;
|
|
10
|
+
const animate=wordmark&&session.frameMs>0,pulse=typeof onHorizontal==='function'&&session.motion===true,tickMs=animate||pulse?session.frameMs:refreshMs;
|
|
11
|
+
let pending,settled,wake,timer,blink=true,frame=0,blinkElapsed=0,repainting=false;
|
|
12
|
+
try{while(true){
|
|
13
|
+
const viewport=session.viewport(),display=actions,displayIndex=selected,information=[],tones=[],spans=[];
|
|
14
|
+
const details=typeof info==='function'?info({selected,...viewport}):info;
|
|
15
|
+
for(const [index,row] of details.entries()){const wrapped=wrapDetailRow(row,viewport.columns),tone=infoTones?.[index],states=tone==='status'?statusSpans(row):tone==='platform-status'?platformStatusSpans(row):[];for(const [line,{text,from,to,prefix}] of wrapped.entries()){information.push(text);tones.push(line&&tone==='diagnostic'?'diagnostic-cont':tone);spans.push(states.filter(span=>span.from<to&&span.to>from).map(span=>({...span,from:Math.max(span.from,from)-from+prefix,to:Math.min(span.to,to)-from+prefix})));}}
|
|
16
|
+
while(information.at(-1)===''){information.pop();tones.pop();}if(information.length){information.push('');tones.push(undefined);}
|
|
17
|
+
const notices=typeof notice==='function'?notice({selected,...viewport}):notice,noticeRows=wrapDetailRows(notices,viewport.columns);while(noticeRows.at(-1)==='')noticeRows.pop();
|
|
18
|
+
const capacity=Math.max(1,viewport.rows-(wordmark?wordmarkRows(viewport):1)-information.length-noticeRows.length-4),offset=Math.max(0,Math.min(displayIndex-capacity+1,display.length-capacity)),visible=display.slice(offset,offset+capacity).map(row=>fitRows?fitChoiceRow(row,viewport.columns):row);
|
|
19
|
+
const screen={title,wordmark,version,frame,notices,rows:[...information,...visible],selected:actions.length?information.length+displayIndex-offset:undefined,hint:navigationHint(hint,{backLabel,horizontal:typeof onHorizontal==='function'}),...(display.length>capacity?{position:(offset+1)+'-'+Math.min(offset+capacity,display.length)+'/'+display.length}:{})};
|
|
20
|
+
if(infoTones){screen.rowTones=[...tones,...visible.map(()=>undefined)];screen.rowStatusSpans=spans;}
|
|
21
|
+
if(backRow||actionKinds)screen.rowKinds=[...information.map(()=>undefined),...kinds.slice(offset,offset+capacity)];
|
|
22
|
+
const body=renderBody?.({selected,blink,frame,...viewport});if(body){delete screen.rowTones;delete screen.rowStatusSpans;delete screen.rowKinds;if(body.rowKinds)screen.rowKinds=body.rowKinds;screen.rows=body.rows;screen.selected=body.selected;screen.showSelection=body.showSelection;screen.compactFooter=body.compactFooter;if(Object.hasOwn(body,'notices'))screen.notices=body.notices;if(Object.hasOwn(body,'position'))screen.position=body.position;}
|
|
23
|
+
const rendered=(repainting?(session.repaint??session.render):session.render).call(session,screen);pending??=event().then(e=>{settled={e};wake?.();},error=>{settled={error};wake?.();});
|
|
24
|
+
if(tickMs>0){if(!settled)await new Promise(resolve=>{wake=resolve;timer=setTimeout(resolve,tickMs);});clearTimeout(timer);timer=undefined;wake=undefined;if(!settled){if(animate||pulse)frame++;if(refreshMs>0){blinkElapsed+=tickMs;while(blinkElapsed>=refreshMs){blink=!blink;blinkElapsed-=refreshMs;}}repainting=true;continue;}}else await pending;
|
|
25
|
+
if(Object.hasOwn(settled,'error'))throw settled.error;const e=settled.e;pending=undefined;settled=undefined;repainting=false;
|
|
26
|
+
if(e.name==='up'&&actions.length)selected=(selected+actions.length-1)%actions.length;else if(e.name==='down'&&actions.length)selected=(selected+1)%actions.length;else if((e.name==='left'||e.name==='right')&&onHorizontal)onHorizontal({direction:e.name,selected,...viewport});else if(e.name==='escape'){if(backLabel==='exit')return null;goHome();}else if(e.name==='enter'&&actions.length&&rendered.selectionEnabled!==false)return backRow&&selected===rows.length?null:selected;
|
|
27
|
+
}}finally{if(timer!==undefined)clearTimeout(timer);}
|
|
28
|
+
}
|
|
29
|
+
async function text(title,initial=''){let value=initial,selected=2;while(true){const rendered=session.render({title,mode:'text',rows:[value,'','Save','Back',''],rowKinds:[undefined,undefined,'confirm','cancel',undefined],selected,hint:navigationHint('text')});const e=await event();if(e.name==='text'||e.name==='paste')value+=e.text;else if(e.name==='backspace')value=[...value].slice(0,-1).join('');else if(e.name==='up'||e.name==='down')selected=selected===2?3:2;else if(e.name==='escape')goHome();else if(e.name==='enter'&&rendered.selectionEnabled!==false)return selected===2?value:null;}}
|
|
30
|
+
async function page(title,rows){
|
|
31
|
+
let offset=0;
|
|
32
|
+
while(true){const viewport=session.viewport(),wrapped=wrapDetailRows(rows,viewport.columns),size=Math.max(1,viewport.rows-4),last=Math.max(0,wrapped.length-size);
|
|
33
|
+
offset=Math.min(offset,last);const slice=wrapped.slice(offset,offset+size);
|
|
34
|
+
session.render({title,mode:'page',rows:slice,position:`Rows ${offset+1}-${Math.min(offset+size,wrapped.length)} of ${wrapped.length}`,hint:navigationHint('page')});const e=await event();
|
|
35
|
+
if(e.name==='down')offset=Math.min(last,offset+1);else if(e.name==='up')offset=Math.max(0,offset-1);else if(e.name==='escape')goHome();else if(e.name==='enter')return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
async function busy(action){let frame=0,timer;const screen={title:'Working',mode:'busy',rows:[],hint:navigationHint('busy'),frame};session.render(screen);session.setBusy(true);const wasFlowing=input?.readableFlowing;const abort=()=>{if(!controller?.signal.aborted)controller?.abort();},onData=chunk=>{if(String(chunk).includes('\x03')||String(chunk).includes('\x04'))abort();};input?.on('data',onData);input?.prependListener('end',abort);input?.prependListener('close',abort);try{if(input?.readableEnded||input?.destroyed){abort();throw interrupted();}if(controller?.signal.aborted)throw interrupted();if(session.frameMs>0)timer=setInterval(()=>{try{(session.repaint??session.render).call(session,{...screen,frame:++frame});}catch{clearInterval(timer);}},session.frameMs);const result=await (session.frameMs>0?Promise.resolve().then(action):action());if(controller?.signal.aborted){if(typeof result?.code!=='number')throw interrupted();return{...result,code:130,interrupted:true};}return result;}catch(error){if(controller?.signal.aborted&&(['ARC_CANCELLED','ARC_NPM_CANCELLED','ARC_ACQUISITION_CANCELLED','ARC_INSTALL_CANCELLED','ABORT_ERR'].includes(error?.code)||error?.name==='AbortError'))throw interrupted();throw error;}finally{clearInterval(timer);input?.removeListener('data',onData);input?.removeListener('end',abort);input?.removeListener('close',abort);if(wasFlowing!==true)input?.pause?.();session.setBusy(false);session.discardInput();}}
|
|
39
|
+
return{menu,text,page,busy};
|
|
40
|
+
}
|
package/lib/tui/render.mjs
CHANGED
|
@@ -13,7 +13,7 @@ export function navigationHint(mode='menu',{backLabel='back',horizontal=false}={
|
|
|
13
13
|
if(mode==='text')return'↑/↓: Select · Type/Paste Input · Backspace Delete · Enter Continue · Esc Home';
|
|
14
14
|
if(mode==='busy')return'Ctrl+C Interrupt';
|
|
15
15
|
if(mode==='page')return'↑/↓: Scroll · Enter Back · Esc Home';
|
|
16
|
-
if(mode==='checklist')return'↑/↓: Select · Enter Toggle · Esc Home';
|
|
16
|
+
if(mode==='checklist')return'↑/↓: Select · Enter Toggle · Esc '+(backLabel==='exit'?'Exit':'Home');
|
|
17
17
|
return'↑/↓: Select · '+(horizontal?'←/→: Change · ':'')+'Enter Continue · Esc '+(backLabel==='exit'?'Exit':'Home');
|
|
18
18
|
}
|
|
19
19
|
export function arrowValue(text,frame,active){return active&&Math.floor(frame/5)%2===1?' <'+text+'> ':'< '+text+' >';}
|
package/lib/tui/setup.mjs
CHANGED
|
@@ -54,6 +54,28 @@ export function installPrepareOptions(plan,draft,catalog){
|
|
|
54
54
|
return {kind:'install',target:'composite',platforms:plan.platforms,config,settings};
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
export async function initializeInstallDraft({draft,installState,currentConfig,loadRoleDefaults,initialTarget,registry}){
|
|
58
|
+
if(!draft.roles){
|
|
59
|
+
if(installState.mode==='composite'&¤tConfig){
|
|
60
|
+
draft.roles=structuredClone(currentConfig.roles);
|
|
61
|
+
draft.hosts??=[...installState.platforms];
|
|
62
|
+
}else{
|
|
63
|
+
const initial=initialTarget(),source=await loadRoleDefaults(initial),field=registry.getPlatform(initial).runtime.models.effortField;
|
|
64
|
+
draft.roles=Object.fromEntries(ROLES.map(role=>[role,{platform:initial,model:source[role].model,effort:source[role][field]}]));
|
|
65
|
+
draft.hosts??=[initial];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
draft.hosts??=[...new Set(Object.values(draft.roles).map(role=>role.platform))];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export async function loadInstallCatalog(id,{loadCatalog,registry}){
|
|
72
|
+
try{
|
|
73
|
+
const result=await loadCatalog(id),catalog=result?.catalog,runtime=registry.getPlatform(id).runtime;
|
|
74
|
+
if(result?.status==='ready'&&catalog?.platform===id&&Array.isArray(catalog.pairs)&&catalog.pairs.length&&catalog.pairs.every(pair=>runtime.routing.validatePair(pair.model,pair.effort)))return result;
|
|
75
|
+
}catch{}
|
|
76
|
+
return {status:'catalog_error',code:'catalog_error'};
|
|
77
|
+
}
|
|
78
|
+
|
|
57
79
|
export async function editHosts({ui,hosts,rolePlatforms,availabilityOf,registry=DEFAULT_INSTALLER_REGISTRY}){
|
|
58
80
|
const ids=registry.byDisplayOrder().map(descriptor=>descriptor.runtime.id),locked=new Set(rolePlatforms),checked=new Set([...hosts,...rolePlatforms]);
|
|
59
81
|
const labels=ids.map(id=>platformLabel(id,registry)),labelWidths=labels.map(label=>[...label].reduce((width,character)=>width+cellWidth(character),0)),suffixColumn=Math.max(0,...labelWidths)+2;
|
|
@@ -93,12 +115,7 @@ export async function runInstallFlow({ui,statuses,draft,installState,currentConf
|
|
|
93
115
|
};
|
|
94
116
|
const catalogFor=async id=>{
|
|
95
117
|
if(catalogs.has(id))return catalogs.get(id);
|
|
96
|
-
|
|
97
|
-
try{
|
|
98
|
-
result=await loadCatalog(id);
|
|
99
|
-
const catalog=result?.catalog,runtime=registry.getPlatform(id).runtime;
|
|
100
|
-
if(result?.status!=='ready'||catalog?.platform!==id||!Array.isArray(catalog.pairs)||!catalog.pairs.length||catalog.pairs.some(pair=>!runtime.routing.validatePair(pair.model,pair.effort)))result={status:'catalog_error',code:'catalog_error'};
|
|
101
|
-
}catch{result={status:'catalog_error',code:'catalog_error'};}
|
|
118
|
+
const result=await loadInstallCatalog(id,{loadCatalog,registry});
|
|
102
119
|
catalogs.set(id,result);
|
|
103
120
|
for(const usage of ['role','host','standalone'])availabilityOf(id,usage);
|
|
104
121
|
return result;
|
|
@@ -108,16 +125,10 @@ export async function runInstallFlow({ui,statuses,draft,installState,currentConf
|
|
|
108
125
|
if(!defaultsCache.has(id))defaultsCache.set(id,await defaults(id));
|
|
109
126
|
return defaultsCache.get(id);
|
|
110
127
|
};
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const source=await defaultsFor(initial),field=registry.getPlatform(initial).runtime.models.effortField;
|
|
116
|
-
draft.roles=Object.fromEntries(ROLES.map(role=>[role,{platform:initial,model:source[role].model,effort:source[role][field]}]));
|
|
117
|
-
draft.hosts??=[initial];
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
draft.hosts??=[...new Set(Object.values(draft.roles).map(role=>role.platform))];
|
|
128
|
+
await initializeInstallDraft({
|
|
129
|
+
draft,installState,currentConfig,loadRoleDefaults:defaultsFor,registry,
|
|
130
|
+
initialTarget:()=>ids.find(id=>statusOf(id)?.state==='installed')??ids.find(id=>availabilityOf(id).selectable)??ids[0],
|
|
131
|
+
});
|
|
121
132
|
let selected=0;
|
|
122
133
|
while(true){
|
|
123
134
|
const plan=deriveInstallPlan({roles:draft.roles,hosts:draft.hosts,current:installState,registry});
|
package/lib/watch/args.mjs
CHANGED
|
@@ -1,43 +1,28 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
1
|
import {WATCH_LIMITS as L} from './model.mjs';
|
|
3
2
|
|
|
4
3
|
export function parseWatchArgs(argv) {
|
|
5
|
-
const options = {
|
|
6
|
-
const seen = new Set(), values = ['
|
|
4
|
+
const options = {tail:L.defaultTail,verbose:false,json:false,width:null,help:false};
|
|
5
|
+
const seen = new Set(), values = ['tail','width'];
|
|
7
6
|
const fail = message => ({ok:false,message});
|
|
8
7
|
for (let i = 0; i < argv.length; i++) {
|
|
9
8
|
const match = /^--([a-z]+)(?:=(.*))?$/.exec(argv[i]);
|
|
10
|
-
if (!match) return fail(
|
|
9
|
+
if (!match) return fail('Unsupported argument: '+argv[i]);
|
|
11
10
|
const [, name, inline] = match;
|
|
12
|
-
if (!
|
|
13
|
-
if (seen.has(name)) return fail(
|
|
11
|
+
if (!Object.hasOwn(options,name)) return fail('Unknown option: --'+name);
|
|
12
|
+
if (seen.has(name)) return fail('Duplicate option: --'+name);
|
|
14
13
|
seen.add(name);
|
|
15
14
|
if (!values.includes(name)) {
|
|
16
|
-
if (inline !== undefined) return fail(
|
|
17
|
-
|
|
15
|
+
if (inline !== undefined) return fail('--'+name+' does not take a value');
|
|
16
|
+
options[name] = true;
|
|
18
17
|
continue;
|
|
19
18
|
}
|
|
20
19
|
const value = inline ?? argv[++i];
|
|
21
|
-
if (value === undefined || value === '' || value.startsWith('--')) return fail(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
options[name] = n;
|
|
26
|
-
} else if (name === 'platform') {
|
|
27
|
-
if (!['codex','claude'].includes(value)) return fail('--platform must be codex or claude');
|
|
28
|
-
options.platforms = [value];
|
|
29
|
-
} else if (name === 'session') {
|
|
30
|
-
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(value)) return fail('Invalid session id');
|
|
31
|
-
options.session = value;
|
|
32
|
-
} else {
|
|
33
|
-
try {
|
|
34
|
-
if (!fs.statSync(value).isDirectory()) return fail('--cwd must name an existing directory');
|
|
35
|
-
options.dir = fs.realpathSync(value);
|
|
36
|
-
} catch { return fail('--cwd must name an existing directory'); }
|
|
20
|
+
if (value === undefined || value === '' || value.startsWith('--')) return fail('Missing value for --'+name);
|
|
21
|
+
const n = Number(value), min = name === 'tail' ? 0 : L.widthMin, max = name === 'tail' ? L.maxTail : L.widthMax;
|
|
22
|
+
if (!/^\d+$/.test(value) || !Number.isSafeInteger(n) || n < min || n > max) {
|
|
23
|
+
return fail('--'+name+' must be an integer from '+min+' to '+max);
|
|
37
24
|
}
|
|
25
|
+
options[name] = n;
|
|
38
26
|
}
|
|
39
|
-
const modes = ['cwd','all','session'].filter(name => seen.has(name));
|
|
40
|
-
if (modes.length > 1) return fail('--cwd, --all and --session are mutually exclusive');
|
|
41
|
-
if (modes.length) options.mode = modes[0];
|
|
42
27
|
return {ok:true,options};
|
|
43
28
|
}
|
package/lib/watch/dispatch.mjs
CHANGED
|
@@ -79,7 +79,7 @@ export function createDispatchIndex({storeDir} = {}) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
return {
|
|
82
|
-
async scan({gitCommonDirs
|
|
82
|
+
async scan({gitCommonDirs}) {
|
|
83
83
|
const currentLeases = storeDir ? await readLeases() : new Map(), artifacts = new Map();
|
|
84
84
|
for (const gcd of gitCommonDirs) {
|
|
85
85
|
const workflows = path.join(gcd, 'arc', 'workflows');
|
|
@@ -113,7 +113,7 @@ export function createDispatchIndex({storeDir} = {}) {
|
|
|
113
113
|
const updates = [];
|
|
114
114
|
for (const [id, ref] of refs) {
|
|
115
115
|
const artifact = artifacts.get(id), lease = currentLeases.get(id), value = lease ?? artifact?.record;
|
|
116
|
-
ref.inScope = Boolean(artifact
|
|
116
|
+
ref.inScope = Boolean(artifact);
|
|
117
117
|
ref.artifactDir = artifact?.dir ?? null;
|
|
118
118
|
ref.cwd = artifact?.cwd ?? null;
|
|
119
119
|
if (!lease && !artifact) continue;
|
package/lib/watch/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import os from 'node:os';
|
|
2
|
-
import path from 'node:path';
|
|
3
2
|
import {parseWatchArgs} from './args.mjs';
|
|
4
3
|
import {resolveConfigHome} from '../runtime/local-cli.mjs';
|
|
5
4
|
import {DEFAULT_PLATFORM_REGISTRY} from '../runtime/platform-registry.mjs';
|
|
@@ -13,13 +12,10 @@ import {WATCH_LIMITS as L} from './model.mjs';
|
|
|
13
12
|
export {parseWatchArgs};
|
|
14
13
|
export const WATCH_HELP = `Usage: arc watch [options]
|
|
15
14
|
|
|
16
|
-
Follow
|
|
15
|
+
Follow session activity of supported platforms in one read-only stream.
|
|
17
16
|
|
|
18
|
-
Scope
|
|
19
|
-
|
|
20
|
-
--all Watch sessions from every directory
|
|
21
|
-
--session <id> Follow one session or ARC dispatch and its subagents
|
|
22
|
-
--platform <name> codex or claude (default: both)
|
|
17
|
+
Scope:
|
|
18
|
+
Check the platforms to watch in the menu; all supported platforms are checked by default. Every selection watches the current Git worktree, or the current directory outside Git. Requires an interactive terminal.
|
|
23
19
|
|
|
24
20
|
Output:
|
|
25
21
|
--tail <n> First show the last <n> events from recently active sessions (default 20, 0 = new only)
|
|
@@ -30,36 +26,52 @@ Output:
|
|
|
30
26
|
|
|
31
27
|
Events are scoped by each session's working directory at that point; a session that moves into another worktree appears in that worktree's watch.
|
|
32
28
|
Skills and plugin tools in use are shown as SKILL and PLUGIN lines.
|
|
33
|
-
User
|
|
29
|
+
User messages, agent messages, prompts and file paths are shown in full; other events use one line.
|
|
30
|
+
PROMPT is an agent-generated prompt sent to a child session (kind "prompt" in JSON).
|
|
31
|
+
Color TTY output renders Markdown in AGENT and PROMPT messages. NO_COLOR, piped output and --json keep the Markdown source text.
|
|
34
32
|
Tool and command outputs are never shown; common secret patterns are masked.
|
|
35
33
|
A status block on the last lines shows the watched path and, while a turn is in progress, a spinner (TTY only).
|
|
36
|
-
Codex Desktop sessions are not included.
|
|
37
|
-
Claude bridge Scouter, Planner and Reviewer on a Codex host need per-call escalation approval (otherwise host_sandbox_blocked) and appear once they run; Claude bridge Implementer and QA stay held.
|
|
38
34
|
Press Ctrl-L to clear the screen (TTY only) and Ctrl-C to stop.`;
|
|
39
35
|
|
|
40
36
|
export async function runWatch(argv, io = {}) {
|
|
41
37
|
const input = io.input ?? process.stdin;
|
|
42
38
|
const output = io.output ?? process.stdout, error = io.error ?? process.stderr;
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
const args = argv.map((arg, i) => {
|
|
46
|
-
if (arg.startsWith('--cwd=') && arg.length > 6) return '--cwd=' + path.resolve(cwd, arg.slice(6));
|
|
47
|
-
if (i > 0 && argv[i-1] === '--cwd' && arg && !arg.startsWith('--')) return path.resolve(cwd, arg);
|
|
48
|
-
return arg;
|
|
49
|
-
});
|
|
50
|
-
const parsed = parseWatchArgs(args);
|
|
51
|
-
if (!parsed.ok) { error.write(`Error: ${parsed.message}. Run arc watch --help for usage.\n`); return 2; }
|
|
39
|
+
const parsed = parseWatchArgs(argv);
|
|
40
|
+
if (!parsed.ok) { error.write('Error: '+parsed.message+'. Run arc watch --help for usage.\n'); return 2; }
|
|
52
41
|
const options = parsed.options;
|
|
53
42
|
if (options.help) { output.write(WATCH_HELP + '\n'); return 0; }
|
|
54
43
|
if (io.signal?.aborted) return 0;
|
|
55
|
-
|
|
44
|
+
if (!(input.isTTY && output.isTTY)) {
|
|
45
|
+
error.write('Error: arc watch needs an interactive terminal to choose platforms.\n');
|
|
46
|
+
return 2;
|
|
47
|
+
}
|
|
48
|
+
const registry = io.registry ?? DEFAULT_PLATFORM_REGISTRY;
|
|
49
|
+
const choose = io.choosePlatforms ?? (await import('./menu.mjs')).chooseWatchPlatforms;
|
|
50
|
+
let platforms;
|
|
51
|
+
try {
|
|
52
|
+
platforms = await choose({input,output,env:io.env,signals:io.process,registry});
|
|
53
|
+
} catch (cause) {
|
|
54
|
+
if (cause.code === 'ARC_CANCELLED') return 130;
|
|
55
|
+
throw cause;
|
|
56
|
+
}
|
|
57
|
+
if (platforms === null) return 0;
|
|
58
|
+
return followWatch(options,{...io,input,output,error,registry,platforms});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export async function followWatch(options, io = {}) {
|
|
62
|
+
if (io.signal?.aborted) return 0;
|
|
63
|
+
const input = io.input ?? process.stdin;
|
|
64
|
+
const output = io.output ?? process.stdout, error = io.error ?? process.stderr;
|
|
65
|
+
const cwd = io.cwd ?? process.cwd(), env = io.env ?? process.env;
|
|
56
66
|
const registry = io.registry ?? DEFAULT_PLATFORM_REGISTRY;
|
|
67
|
+
const userHome = io.userHome ?? os.homedir(), disabled = [];
|
|
68
|
+
const homes = Object.fromEntries(registry.byAnchorOrder().map(({id}) => [id,null]));
|
|
57
69
|
for (const {id:platform} of registry.byAnchorOrder()) {
|
|
58
70
|
try { homes[platform] = resolveConfigHome(platform, {userHome,env,cwd,runtimePlatforms:registry}); }
|
|
59
|
-
catch (cause) { if (
|
|
71
|
+
catch (cause) { if (io.platforms.includes(platform)) disabled.push(`${platform} disabled: ${cause.message}`); }
|
|
60
72
|
}
|
|
61
|
-
|
|
62
|
-
if (!
|
|
73
|
+
const platforms = io.platforms.filter(platform => homes[platform] !== null);
|
|
74
|
+
if (!platforms.length) { error.write('Error: no usable watch source.\n'); return 1; }
|
|
63
75
|
const now = io.now ?? Date.now, git = io.git ?? createGitRunner({env});
|
|
64
76
|
const proc = io.process ?? process, schedule = io.setInterval ?? setInterval, unschedule = io.clearInterval ?? clearInterval;
|
|
65
77
|
let width, watcher, timer, stopped = false, active;
|
|
@@ -67,7 +79,7 @@ export async function runWatch(argv, io = {}) {
|
|
|
67
79
|
const color = Boolean(output.isTTY && !options.json && !env.NO_COLOR);
|
|
68
80
|
const blockEnabled = Boolean(output.isTTY && !options.json);
|
|
69
81
|
const fancy = color && env.TERM !== 'dumb';
|
|
70
|
-
const label = watchLocationLabel({
|
|
82
|
+
const label = watchLocationLabel({dir:cwd,home:userHome});
|
|
71
83
|
const keysEnabled = Boolean(input.isTTY && output.isTTY && !options.json && typeof input.setRawMode === 'function');
|
|
72
84
|
const frames = ['⠋','⠙','⠹','⠸','⠼','⠴','⠦','⠧','⠇','⠏'];
|
|
73
85
|
let drawnLines = 0, frame = 0, tick = 0;
|
|
@@ -149,9 +161,9 @@ export async function runWatch(argv, io = {}) {
|
|
|
149
161
|
input.resume();
|
|
150
162
|
input.on('data', onKey);
|
|
151
163
|
}
|
|
152
|
-
const scope = await resolveScope({
|
|
164
|
+
const scope = await resolveScope({dir:cwd,git});
|
|
153
165
|
if (stopped) return;
|
|
154
|
-
watcher = createWatcher({options,homes:{...homes,user:userHome},scope,git,now,registry});
|
|
166
|
+
watcher = createWatcher({options:{...options,platforms},homes:{...homes,user:userHome},scope,git,now,registry});
|
|
155
167
|
for (const text of disabled) {
|
|
156
168
|
const ts = new Date(now()).toISOString();
|
|
157
169
|
write([{v:1,ts,observedAt:ts,source:'watch',kind:'notice',label:'watch',text}]);
|