@yunhozz/arc 0.5.0 → 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.
Files changed (57) hide show
  1. package/MANIFEST.sha256 +45 -51
  2. package/README.md +99 -33
  3. package/claude/agents/arc-implementer.md +1 -1
  4. package/claude/skill/SKILL.md +1 -1
  5. package/claude/skill/models.toml +6 -6
  6. package/claude/skill/references/coordination.md +0 -4
  7. package/claude/skill/references/handoff-prep.md +1 -1
  8. package/claude/skill/references/verification.md +4 -9
  9. package/codex/skill/SKILL.md +1 -1
  10. package/codex/skill/models.toml +6 -6
  11. package/codex/skill/references/coordination.md +0 -4
  12. package/codex/skill/references/handoff-prep.md +1 -1
  13. package/codex/skill/references/verification.md +4 -9
  14. package/gemini/agents/arc-implementer.md +2 -2
  15. package/gemini/agents/arc-planner.md +1 -1
  16. package/gemini/agents/arc-qa.md +1 -1
  17. package/gemini/agents/arc-scouter.md +1 -1
  18. package/gemini/skill/SKILL.md +1 -1
  19. package/gemini/skill/models.toml +5 -5
  20. package/gemini/skill/references/coordination.md +0 -4
  21. package/gemini/skill/references/handoff-prep.md +1 -1
  22. package/gemini/skill/references/verification.md +4 -9
  23. package/grok/agents/arc-implementer.md +1 -1
  24. package/grok/skill/SKILL.md +1 -1
  25. package/grok/skill/references/coordination.md +0 -4
  26. package/grok/skill/references/handoff-prep.md +1 -1
  27. package/grok/skill/references/verification.md +4 -9
  28. package/lib/installer/runtime-assets.mjs +1 -5
  29. package/lib/installer/targets.mjs +3 -1
  30. package/lib/management/operations.mjs +4 -4
  31. package/lib/prompts/agent-fragments.json +3 -3
  32. package/lib/runtime/local-cli.mjs +9 -2
  33. package/lib/runtime/role-dispatch-policy.mjs +5 -2
  34. package/lib/tui/app.mjs +36 -11
  35. package/lib/tui/interface.mjs +2 -2
  36. package/lib/tui/render.mjs +4 -2
  37. package/lib/tui/terminal.mjs +5 -3
  38. package/lib/watch/brief.mjs +44 -0
  39. package/lib/watch/dispatch.mjs +44 -6
  40. package/lib/watch/index.mjs +107 -22
  41. package/lib/watch/markdown.mjs +42 -9
  42. package/lib/watch/model.mjs +1 -0
  43. package/lib/watch/render.mjs +3 -2
  44. package/lib/watch/scope.mjs +125 -0
  45. package/lib/watch/watcher.mjs +149 -82
  46. package/lib/watch/worktree-menu.mjs +64 -0
  47. package/package.json +1 -1
  48. package/shared/skill/runtime/local-cli.mjs +9 -2
  49. package/shared/skill/runtime/role-dispatch-policy.mjs +5 -2
  50. package/lib/runtime/final-verify.mjs +0 -2158
  51. package/lib/runtime/node-test-reporter.mjs +0 -81
  52. package/lib/runtime/test-results.mjs +0 -736
  53. package/lib/runtime/verify-cli.mjs +0 -60
  54. package/shared/skill/runtime/final-verify.mjs +0 -2158
  55. package/shared/skill/runtime/node-test-reporter.mjs +0 -81
  56. package/shared/skill/runtime/test-results.mjs +0 -736
  57. package/shared/skill/runtime/verify-cli.mjs +0 -60
@@ -2,15 +2,17 @@ import {displayWidth, wrapLineRanges} from './text-width.mjs';
2
2
 
3
3
  const reset = '\x1b[0m';
4
4
  const inline = /(?<!`)`(?<code>[^`]+)`(?!`)|\[(?<label>[^\[\]]+)\]\((?<url>[^\s()]+)\)|(?<delimiter>(?<!\*)\*\*|(?<![\p{L}\p{N}_*])\*)(?![\s*])(?<emphasis>[^*]*?)(?<!\s)\k<delimiter>(?!\*)/gu;
5
+ const boxInline = new RegExp(/\\(?<escaped>[\\*`\[])/.source + '|' + inline.source, inline.flags);
5
6
  const fenceMarker = /^ *(`{3,}|~{3,})(.*)$/;
6
7
  const pipeStart = /^ *\|/;
7
8
 
8
- function inlineSpans(text) {
9
+ function inlineSpans(text, pattern = inline) {
9
10
  const spans = [];
10
11
  let start = 0;
11
- for (const {index, 0:token, groups:{code, label, url, delimiter, emphasis}} of text.matchAll(inline)) {
12
+ for (const {index, 0:token, groups:{code, label, url, delimiter, emphasis, escaped}} of text.matchAll(pattern)) {
12
13
  if (index > start) spans.push({text:text.slice(start, index)});
13
- if (code !== undefined) spans.push({text:code, style:'38;5;180'});
14
+ if (escaped !== undefined) spans.push({text:escaped});
15
+ else if (code !== undefined) spans.push({text:code, style:'38;5;180'});
14
16
  else if (label !== undefined) spans.push({text:`${label} (${url})`});
15
17
  else spans.push({text:emphasis, style:delimiter === '**' ? '1' : '3'});
16
18
  start = index + token.length;
@@ -34,15 +36,17 @@ function renderLine(spans, {width, baseCode, blockStyle, prefix = '', preserveWh
34
36
  return ranges.map(({from, to, overflows}, index) => {
35
37
  let line = index ? ' '.repeat(prefix.length) : prefix;
36
38
  let active = blockCode;
37
- if (line) line = `\x1b[${active}m${line}`;
38
- if (overflows) return `${line || `\x1b[${active}m`}�${reset}`;
39
+ if (line && baseCode) line = `\x1b[${active}m${line}`;
40
+ if (overflows) return baseCode ? `${line || `\x1b[${active}m`}�${reset}` : `${line}�`;
39
41
  while (from < to && spanIndex < spans.length) {
40
42
  const span = spans[spanIndex];
41
43
  const spanEnd = spanStart + span.text.length;
42
44
  if (spanEnd > from) {
43
45
  const code = span.style ? `${blockCode};${span.style}` : blockCode;
44
- if (!line) line = `\x1b[${code}m`;
45
- else if (active !== code) line += `\x1b[0;${code}m`;
46
+ if (baseCode) {
47
+ if (!line) line = `\x1b[${code}m`;
48
+ else if (active !== code) line += `\x1b[0;${code}m`;
49
+ }
46
50
  line += span.text.slice(Math.max(from - spanStart, 0), to - spanStart);
47
51
  active = code;
48
52
  }
@@ -50,10 +54,39 @@ function renderLine(spans, {width, baseCode, blockStyle, prefix = '', preserveWh
50
54
  spanStart = spanEnd;
51
55
  spanIndex++;
52
56
  }
53
- return line ? `${line}${reset}` : '';
57
+ return line && baseCode ? `${line}${reset}` : line;
54
58
  });
55
59
  }
56
60
 
61
+ export function renderBox(lines, {width, baseCode}) {
62
+ if (width < 5) return [];
63
+ const rows = lines.map(line => {
64
+ const prefix = /^\*\*([^*]+)\*\* /.exec(line);
65
+ return prefix
66
+ ? {label:prefix[1], spans:inlineSpans(line.slice(prefix[0].length), boxInline)}
67
+ : {label:'', spans:inlineSpans(line, boxInline)};
68
+ });
69
+ const labelWidth = Math.max(0, ...rows.map(row => displayWidth(row.label)));
70
+ const natural = Math.max(1, ...rows.map(({label,spans}) =>
71
+ (label ? labelWidth + 2 : 0) + displayWidth(spans.map(span => span.text).join(''))));
72
+ const contentWidth = Math.min(natural, width - 4);
73
+ const paint = (text, code) => code ? `\x1b[${code}m${text}${reset}` : text;
74
+ const border = (left, right) => paint(left + '─'.repeat(contentWidth + 2) + right, baseCode);
75
+ const body = rows.flatMap(({label,spans}) => {
76
+ const alignLabel = label && contentWidth - labelWidth - 2 >= 2;
77
+ const prefixWidth = alignLabel ? labelWidth + 2 : 0;
78
+ const value = !alignLabel && label ? [{text:label,style:'1'},{text:' '},...spans] : spans;
79
+ return renderLine(value, {width:contentWidth - prefixWidth, baseCode:baseCode && '0'}).map((line, index) => {
80
+ const prefix = alignLabel && !index
81
+ ? paint(label, baseCode && '1') + ' '.repeat(prefixWidth - displayWidth(label))
82
+ : ' '.repeat(prefixWidth);
83
+ const pad = contentWidth - prefixWidth - displayWidth(line.replace(/\x1b\[[0-9;]*m/g, ''));
84
+ return `${paint('│',baseCode)} ${prefix}${line}${' '.repeat(pad + 1)}${paint('│',baseCode)}`;
85
+ });
86
+ });
87
+ return [border('┌', '┐'), ...body, border('└', '┘')];
88
+ }
89
+
57
90
  function splitTableRow(line) {
58
91
  if (!line?.includes('|')) return;
59
92
  const row = line.trim();
@@ -140,7 +173,7 @@ function renderCards([header, ...rows], {width, baseCode}) {
140
173
 
141
174
  function renderTable({header, rows, alignments}, options) {
142
175
  const {baseCode, width} = options;
143
- const cells = [header, ...rows].map(row => row.map(inlineSpans));
176
+ const cells = [header, ...rows].map(row => row.map(cell => inlineSpans(cell)));
144
177
  const natural = header.map(() => 1);
145
178
  for (const row of cells) {
146
179
  for (const [col, spans] of row.entries()) {
@@ -15,6 +15,7 @@ export const WATCH_LIMITS = Object.freeze({
15
15
  claudeCwdWaitMs:10000, codexMetaBytes:4194304, lookbackDays:7,
16
16
  cwdProbeBytes:65536, maxKnown:512,
17
17
  jsonTextMax:1000, wrapMinBody:20, toolCacheMax:512, defaultTail:20,
18
+ earlierPage:20, earlierMax:2000, worktreePickerMax:20,
18
19
  maxTail:1000, widthMin:40, widthMax:2000, ttyWidthMin:60, nonTtyWidth:200,
19
20
  gitTimeoutMs:10000, spinnerIdleMs:300000,
20
21
  shellScanDelayMs:1000, shellScanMinIntervalMs:3000, shellScansPerTick:2,
@@ -94,12 +94,13 @@ export function renderHuman(event, {width, color, verbose, wrap = false}) {
94
94
 
95
95
  const paths = fullLine && !message ? (event.paths ?? []).map(file => sanitizeText(displayPath(file,event.root))).filter(Boolean) : [];
96
96
  const listPaths = paths.length >= 2;
97
+ const pathLines = listPaths ? paths.map(file => '• ' + file) : paths;
97
98
  const bodyLines = message ? (text ? text.split('\n') : []) : fullLine
98
- ? [sanitizeText(event.text), ...paths.map(file => listPaths ? '- ' + file : file)].filter(Boolean) : [];
99
+ ? [sanitizeText(event.text), ...pathLines].filter(Boolean) : [];
99
100
  if (roleName && bodyLines.length) bodyLines.unshift(roleName);
100
101
  const lines = canWrap ? bodyLines.flatMap((line,i) =>
101
102
  listPaths && paths.length && i >= bodyLines.length - paths.length
102
- ? wrapLine(line.slice(2),avail-2).map((piece,j) => (j ? ' ' : '- ') + piece)
103
+ ? wrapLine(line.slice(2),avail-2).map((piece,j) => (j ? ' ' : '• ') + piece)
103
104
  : wrapLine(line,avail)) : bodyLines;
104
105
  const bodyText = paintLine => lines.map((line,i) => !line ? '' : (i ? indent : '') + paintLine(line,i)).join('\n');
105
106
  const plain = fullLine ? (message && !lines.length ? prefix.trimEnd() : prefix + bodyText(line => line)) : clipCodePoints(prefix + text, width).text;
@@ -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
+ }