@yunhozz/arc 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/MANIFEST.sha256 CHANGED
@@ -1,4 +1,4 @@
1
- 340466f7f35b27c3662501e76a931e20afe81986f40c77c27d0828a507ac485c README.md
1
+ ab523ae70028fbebf995e84f304acf097fa26d217cbcea254d9c1dc13c4e04d6 README.md
2
2
  d41edeb8c6631dee30c67c705d4edad977aa1631627ec9de59c013f8990f4018 bin/arc-upgrade.mjs
3
3
  484d9b2002ce542c87589bb719d644d3762706aad28a6ee010024875f8cc00e2 bin/arc.mjs
4
4
  3a4addbe83e8d0c397f16b886b4cf7ba1557707d3dae5dd4db590da58309bd24 claude/agents/arc-implementer.md
@@ -219,19 +219,19 @@ c35ab2affcc64d05b00011c7a00840faa481e594b7d95f53b322dfe6bd2e1110 lib/tui/setup.
219
219
  05d087b85cd08a9207d8ae36abe00651a94c7a2f3af67140bdd3740acb914f2b lib/watch/discover-codex.mjs
220
220
  bfc12c581ab12b973ed5eb40d3450df187f988496559239e816bba3da500c1c1 lib/watch/dispatch.mjs
221
221
  fb2b985c2e33726a5fd98b835b365c7b67b438fdeb6e03d6cf4f000089ead0fe lib/watch/git.mjs
222
- 274b286286dca5ac17c0882007d0712a0fd5ee9826f7d45b940a570ce1ad770f lib/watch/index.mjs
222
+ 3bb15bd6ffb6c3e83641ade0da62cf7c6932daf6b07f32709a3d3dcabe2b5319 lib/watch/index.mjs
223
223
  2707c6a3825a368650e7333f7e72eae841f21b95afcb7f3918a35ed4caf190cf lib/watch/labels.mjs
224
- 99321ff7dbdfe850fc83823b9b74f90a4bed144a648cf50f6ed656c28c048989 lib/watch/model.mjs
225
- c34cffcf6ef380019a11b14bcfc95ce971e60b12811f0242738dbe8285a5195f lib/watch/normalize-claude.mjs
226
- e7a15f5de9d5c33a235e87d8065e543d28616a30e548419c51964b46d61b60b1 lib/watch/normalize-codex.mjs
224
+ 63b89cbf95696b13370c14d8443641b0373393ceabb8a59bec1b5cdaf4e82f52 lib/watch/model.mjs
225
+ 0e9418d95020f19822067b81c0292a59f677a71a9f46415f6771b5a3a2c7001b lib/watch/normalize-claude.mjs
226
+ b6a2cf6f227ff2b3fa7295ce2c97f5e4632cb3eb473fd3b8ebc6c0699c1ce5bc lib/watch/normalize-codex.mjs
227
227
  4037619af1c19c058179d8567d301ce1cdba4ac82c79f63436fb17de4fe7f45d lib/watch/policy.mjs
228
- daf4b51582436e16162e5360f0103bd5014ca63191cbcd4675f1f4f5163e12a3 lib/watch/render.mjs
229
- 69df107b5d685137fb1632e6b5946810016891660230ed45b3a927b95a7e9b42 lib/watch/scope.mjs
228
+ cbc8a4aae777e24453412e6b55f6148db5a1f65c74f256b4f06f8006d1a980bd lib/watch/render.mjs
229
+ b875cdf21e0057855f48d7e26ef4ad58e48239b23a2b1d27a6dc296d0b330234 lib/watch/scope.mjs
230
230
  23f4aaa18d1492de117d3d24fa755e3c5486d72e9d0f8c4834736095de53e078 lib/watch/tail.mjs
231
- ce287a9991d012d42dbfa4fdf79e4f7004973c6c9fe7294c99926d64e6ffbe5f lib/watch/watcher.mjs
231
+ 5d07fc41edfef103ce0e7796b7287aab86ae0aa05102512e04c983598b1ac2f8 lib/watch/watcher.mjs
232
232
  ff9c33c8b3c2bd466d54ffbe4c7139ccd87c79c7de34a6c4cde92e9f6e9b42d2 native/binding.c
233
233
  205bedc1dee1a9ffa58124c6e21256a1f0cbe24f06f7c8d7cb0b99524cfab9d0 native/binding.gyp
234
- ff9e9c639b85d2aea3ad02ebd0a271010ca149f2915082776fd9a8feae198f6e package.json
234
+ 002c53e428dfc38f973033e2e190156236298d9aee7ab5c772b6dbf542b160e6 package.json
235
235
  208c65cfde244d39ce45c3cf1b0acb128f04d21199b6b3fb5466e62db5b64af9 prebuilds/darwin-arm64/arc_safe_fs.node
236
236
  572887ac794d10a8b921d8168ea2328e31f05b45987611ff02c83114dba901af prebuilds/darwin-x64/arc_safe_fs.node
237
237
  2bb9443021f9d873712b26321de733eddd6794c45f0bc79e2d5dc98669196635 prebuilds/index.json
package/README.md CHANGED
@@ -36,23 +36,28 @@ The TUI requires terminal input and output. Public commands: `arc`, `arc watch`,
36
36
 
37
37
  ## Watch sessions
38
38
 
39
- `arc watch` follows Claude Code and Codex activity in a read-only stream; by default it includes every worktree of the current Git repository, or the current directory outside Git.
40
- User and agent messages are shown in full; other events use one line.
41
- Tool and command outputs are never shown; common secret patterns are masked, but masking is not complete.
42
- Codex Desktop sessions are excluded. Bridge roles on Codex hosts remain held as `host_sandbox_blocked` and appear once they run.
43
- Use `arc watch --help` for scope, platform, history and JSON options; press Ctrl-C to stop.
39
+ ![arc watch flow](docs/images/watch-flow.svg)
44
40
 
45
- ## Models and language
41
+ `arc watch` streams Claude Code and Codex activity read-only. Default scope: every worktree of the current Git repository, or the current directory outside Git.
42
+
43
+ - **Shown:** user and agent messages in full; other events on one line.
44
+ - **Hidden:** tool and command outputs. Common secret patterns are masked, but masking is not complete.
45
+ - **Excluded:** Codex Desktop sessions. Bridge roles on Codex hosts stay held as `host_sandbox_blocked` until they run.
46
46
 
47
- The Orchestrator uses the current conversation model. Specialist roles use the active role settings in [Codex](codex/skill/models.toml) or [Claude Code](claude/skill/models.toml). The TUI is in English; the selected response language applies to agents in new sessions.
47
+ Run `arc watch --help` for scope, platform, history and JSON options; press Ctrl-L to clear the screen and Ctrl-C to stop.
48
48
 
49
- In `Claude & Codex` under `Install / Update` and `Change Models`, the role editor opens immediately. Each role can use either platform and any model/effort pair in that platform's static catalog. New configurations assign Planner and Reviewer to Claude and the other roles to Codex, using installed active values or package defaults. All five roles may use the same platform. `Apply` publishes the configuration directly. Installation offers shared `Settings` for both platforms; `Global config` defaults to On.
49
+ ## Models and language
50
50
 
51
- Model and effort choices come from the packaged Codex and Claude catalogs, without a model-list API call or a separate API key. They are static candidates and do not establish that an account, CLI version, or provider can use a selection. A saved model and effort absent from the catalog remains visible and must be reselected before applying new settings. Codex authentication is checked by refreshing the login token through `codex app-server`; this needs network access and rotates the tokens in `CODEX_HOME/auth.json`. Claude authentication checks continue to use `claude auth status`.
51
+ ![Role models and platforms](docs/images/role-models.svg)
52
52
 
53
- The composite configuration separates saving and activation from role execution. Role execution support is reported per role and environment by `routing-status`: `claude-cli` hosts support native routes and Codex bridges, `codex-cli` hosts support native routes while every bridge is held as `host_sandbox_blocked` (G2; Claude bridge Implementer and QA on a Codex host are additionally held as `permission_scope_unverified` by G1), and on Codex Desktop and Claude Desktop Code sessions every role (native and bridge) is held as `environment_unverified` in this release (the manual checklist in `docs/harness-operation.md` is a list of manual checks for a future ARC update, not a way to release the hold). Applying a new profile requires a new session on that host, and the `cooperative-8` runtime requires running Install / Update again.
53
+ - **Orchestrator:** the current conversation model.
54
+ - **Specialist roles:** active settings in [Codex](codex/skill/models.toml) or [Claude Code](claude/skill/models.toml); edit them with `Change Models`.
55
+ - **Claude & Codex:** each role runs on either platform. New configurations put Planner and Reviewer on Claude and the rest on Codex. `Apply` publishes; start a new session to load new profiles.
56
+ - **Catalogs:** model and effort choices come from packaged catalogs, with no API key or model-list call; a choice is not proof that your account can use it.
57
+ - **Language:** the TUI is in English; the selected response language applies to agents in new sessions.
58
+ - **Execution support:** `claude-cli` hosts run native roles and Codex bridges. `codex-cli` hosts hold every bridge as `host_sandbox_blocked`; Claude bridge Implementer and QA roles on a Codex host are also held as `permission_scope_unverified`. On Desktop, every role (native and bridge) is held as `environment_unverified` pending a future ARC update. After upgrading to `cooperative-8`, run Install / Update again.
54
59
 
55
- Composite mode removes owned standalone `arc-*` profiles from both homes and keeps per-role `arc-routing-*` profiles. Selecting Codex or Claude shows a switch confirmation; after `Continue`, choosing `Apply` turns off composite mode, restores standalone profiles for installed platforms, and performs the selected operation.
60
+ Authentication checks, role execution support per environment, and switching between composite and single-platform modes: see [Harness operation](docs/harness-operation.md).
56
61
 
57
62
  ## Guides
58
63
 
@@ -28,11 +28,13 @@ Output:
28
28
 
29
29
  User and agent messages are shown in full; other events use one line.
30
30
  Tool and command outputs are never shown; common secret patterns are masked.
31
+ A spinner on the last line shows while a turn is in progress (TTY only).
31
32
  Codex Desktop sessions are not included.
32
33
  Bridge roles on a Codex host are currently held (host_sandbox_blocked) and appear once they run.
33
- Press Ctrl-C to stop.`;
34
+ Press Ctrl-L to clear the screen (TTY only) and Ctrl-C to stop.`;
34
35
 
35
36
  export async function runWatch(argv, io = {}) {
37
+ const input = io.input ?? process.stdin;
36
38
  const output = io.output ?? process.stdout, error = io.error ?? process.stderr;
37
39
  const cwd = io.cwd ?? process.cwd(), env = io.env ?? process.env;
38
40
  // Resolve relative --cwd without changing the process cwd shared by other callers.
@@ -56,13 +58,31 @@ export async function runWatch(argv, io = {}) {
56
58
  const now = io.now ?? Date.now, git = io.git ?? createGitRunner({env});
57
59
  const proc = io.process ?? process, schedule = io.setInterval ?? setInterval, unschedule = io.clearInterval ?? clearInterval;
58
60
  let width, watcher, timer, stopped = false, active;
61
+ const color = Boolean(output.isTTY && !options.json && !env.NO_COLOR);
62
+ const spinnerEnabled = Boolean(output.isTTY && !options.json);
63
+ const keysEnabled = Boolean(input.isTTY && output.isTTY && !options.json && typeof input.setRawMode === 'function');
64
+ const frames = ['⠋','⠙','⠹','⠸','⠼','⠴','⠦','⠧','⠇','⠏'];
65
+ let spinnerDrawn = false, frame = 0;
66
+ const eraseSpinner = () => {
67
+ if (!spinnerDrawn) return;
68
+ spinnerDrawn = false;
69
+ output.write('\r\x1b[2K');
70
+ };
59
71
  const resize = () => { width = options.width ?? (output.isTTY ? Math.max(L.ttyWidthMin, output.columns || L.ttyWidthMin) : L.nonTtyWidth); };
60
72
  resize();
61
73
  return new Promise(resolve => {
62
74
  const signals = ['SIGINT','SIGTERM','SIGHUP'];
75
+ let rawModeEnabled = false;
63
76
  const stop = (code = 0, cause) => {
64
77
  if (stopped) return;
65
78
  stopped = true;
79
+ if (rawModeEnabled) {
80
+ rawModeEnabled = false;
81
+ input.removeListener('data', onKey);
82
+ try { input.setRawMode(false); } catch {}
83
+ input.pause();
84
+ }
85
+ eraseSpinner();
66
86
  if (timer !== undefined) unschedule(timer);
67
87
  for (const signal of signals) proc.removeListener(signal, onSignal);
68
88
  io.signal?.removeEventListener('abort', onSignal);
@@ -78,11 +98,33 @@ export async function runWatch(argv, io = {}) {
78
98
  };
79
99
  const onSignal = () => stop();
80
100
  const onError = cause => stop(cause.code === 'EPIPE' ? 0 : 1, cause);
101
+ const drawSpinner = () => {
102
+ if (!stopped && spinnerEnabled && watcher?.busy?.()) {
103
+ const text = `${frames[frame]} working…`;
104
+ frame = (frame + 1) % frames.length;
105
+ spinnerDrawn = true;
106
+ output.write(color ? `\x1b[2m${text}\x1b[0m` : text);
107
+ }
108
+ };
109
+ const onKey = chunk => {
110
+ for (const byte of Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)) {
111
+ if (stopped) break;
112
+ if (byte === 0x03) stop();
113
+ else if (byte === 0x0c) {
114
+ output.write('\x1b[H\x1b[2J\x1b[3J');
115
+ spinnerDrawn = false;
116
+ drawSpinner();
117
+ }
118
+ }
119
+ };
81
120
  const write = events => {
121
+ if (stopped) return;
122
+ eraseSpinner();
82
123
  for (const event of events) {
83
124
  if (stopped) break;
84
- output.write((options.json ? renderJson(event) : renderHuman(event,{width,color:Boolean(output.isTTY && !options.json && !env.NO_COLOR),verbose:options.verbose})) + '\n');
125
+ output.write((options.json ? renderJson(event) : renderHuman(event,{width,color,verbose:options.verbose})) + '\n');
85
126
  }
127
+ drawSpinner();
86
128
  };
87
129
  for (const signal of signals) proc.on(signal, onSignal);
88
130
  output.on('error', onError);
@@ -90,6 +132,12 @@ export async function runWatch(argv, io = {}) {
90
132
  io.signal?.addEventListener('abort', onSignal, {once:true});
91
133
  let ticking = false;
92
134
  active = (async () => {
135
+ if (keysEnabled) {
136
+ rawModeEnabled = true;
137
+ input.setRawMode(true);
138
+ input.resume();
139
+ input.on('data', onKey);
140
+ }
93
141
  const scope = await resolveScope({mode:options.mode,dir:options.dir ?? cwd,session:options.session,git});
94
142
  if (stopped) return;
95
143
  watcher = createWatcher({options,homes,scope,git,now});
@@ -1,4 +1,4 @@
1
- export const WATCH_KINDS = Object.freeze(['session','settings','turn_start','turn_end','turn_failed','user','agent','reasoning','command','tool','tool_failed','file_change','spawn','approval','dispatch','error','other','notice']);
1
+ export const WATCH_KINDS = Object.freeze(['session','settings','turn_start','turn_end','turn_failed','user','agent','reasoning','command','tool','tool_failed','file_change','file_create','spawn','approval','dispatch','error','other','notice']);
2
2
  export const MESSAGE_KINDS = Object.freeze(['user','agent']);
3
3
  export const VERBOSE_KINDS = Object.freeze(['settings','turn_start','reasoning','other']);
4
4
  export const ROLE_NAMES = Object.freeze(['scouter','planner','implementer','qa','reviewer']);
@@ -11,7 +11,7 @@ export const WATCH_LIMITS = Object.freeze({
11
11
  claudeCwdWaitMs:10000, codexMetaBytes:4194304, lookbackDays:7,
12
12
  jsonTextMax:1000, agentNameMax:20, pathsMax:20, toolCacheMax:512, defaultTail:20,
13
13
  maxTail:1000, widthMin:40, widthMax:2000, ttyWidthMin:60, nonTtyWidth:200,
14
- gitTimeoutMs:10000,
14
+ gitTimeoutMs:10000, spinnerIdleMs:300000,
15
15
  });
16
16
 
17
17
  /**
@@ -31,7 +31,7 @@ export const WATCH_LIMITS = Object.freeze({
31
31
  * @property {'scouter'|'planner'|'implementer'|'qa'|'reviewer'|'orchestrator'} [role]
32
32
  * @property {string} [dispatchId]
33
33
  * @property {string} [workflowId]
34
- * @property {'session'|'settings'|'turn_start'|'turn_end'|'turn_failed'|'user'|'agent'|'reasoning'|'command'|'tool'|'tool_failed'|'file_change'|'spawn'|'approval'|'dispatch'|'error'|'other'|'notice'} kind
34
+ * @property {'session'|'settings'|'turn_start'|'turn_end'|'turn_failed'|'user'|'agent'|'reasoning'|'command'|'tool'|'tool_failed'|'file_change'|'file_create'|'spawn'|'approval'|'dispatch'|'error'|'other'|'notice'} kind
35
35
  * @property {string} [text] Sanitized, masked text; user/agent preserve newlines without a length cap. Other JSON text is capped at 1000 code points.
36
36
  * @property {boolean} [truncated]
37
37
  * @property {number} [exitCode]
@@ -4,7 +4,7 @@ const object = value => value !== null && typeof value === 'object' && !Array.is
4
4
  const string = value => typeof value === 'string';
5
5
 
6
6
  export function createClaudeState() {
7
- return {modelSeen:false, tools:new Map()};
7
+ return {modelSeen:false, tools:new Map(), writes:new Map()};
8
8
  }
9
9
 
10
10
  export function parseClaudeHead(obj) {
@@ -31,11 +31,12 @@ function userText(content) {
31
31
  return text.replace(/<(system-reminder|command-[\w-]+|local-command-[\w-]+|task-notification|bash-input|bash-stdout|bash-stderr)\b[^>]*>[\s\S]*?(?:<\/\1\s*>|$)/gi, '');
32
32
  }
33
33
 
34
- /** State contains only the first-model flag and a bounded tool-name cache. */
34
+ /** State contains the first-model flag and bounded tool-name and pending-Write caches. */
35
35
  export function normalizeClaudeLine(obj, state) {
36
36
  try {
37
37
  if (!object(obj) || !['user','assistant'].includes(obj.type) || !object(obj.message)) return [];
38
38
  if (!object(state) || !(state.tools instanceof Map)) return [];
39
+ if (!(state.writes instanceof Map)) state.writes = new Map();
39
40
  const events = [];
40
41
  const emit = (kind, fields={}) => {
41
42
  const event = {kind, ...fields};
@@ -53,14 +54,22 @@ export function normalizeClaudeLine(obj, state) {
53
54
  }
54
55
  // Results never contribute text, even when the line also has toolUseResult.
55
56
  for (const block of blocks) {
56
- if (block?.type === 'tool_result' && block.is_error === true) {
57
- const tool = state.tools.get(block.tool_use_id);
57
+ if (block?.type !== 'tool_result') continue;
58
+ const id = block.tool_use_id, pending = state.writes.has(id), path = state.writes.get(id);
59
+ state.writes.delete(id);
60
+ if (block.is_error === true) {
61
+ const tool = state.tools.get(id);
58
62
  emit('tool_failed', string(tool) ? {tool} : {});
63
+ } else if (pending) {
64
+ const result = obj.toolUseResult;
65
+ const paths = [...new Set([string(result?.filePath) ? result.filePath : path].filter(string))].slice(0,WATCH_LIMITS.pathsMax);
66
+ emit(result?.type === 'create' ? 'file_create' : 'file_change', {paths});
59
67
  }
60
68
  }
61
69
  if (!obj.isMeta && !Object.hasOwn(obj, 'toolUseResult')) {
62
70
  const text = userText(message.content);
63
- if (text.trim()) emit('user', {text});
71
+ if (/^\[Request interrupted by user(?: for tool use)?\]$/.test(text.trim())) emit('turn_end', {text:'interrupted by user'});
72
+ else if (text.trim()) emit('user', {text});
64
73
  }
65
74
  return events;
66
75
  }
@@ -81,7 +90,13 @@ export function normalizeClaudeLine(obj, state) {
81
90
  }
82
91
  const input = object(block.input) ? block.input : {};
83
92
  if (name === 'Bash') emit('command', string(input.command) ? {text:input.command} : {});
84
- else if (['Edit','MultiEdit','Write','NotebookEdit'].includes(name)) {
93
+ else if (name === 'Write') {
94
+ if (string(block.id)) {
95
+ state.writes.delete(block.id);
96
+ state.writes.set(block.id, string(input.file_path) ? input.file_path : undefined);
97
+ while (state.writes.size > WATCH_LIMITS.toolCacheMax) state.writes.delete(state.writes.keys().next().value);
98
+ }
99
+ } else if (['Edit','MultiEdit','NotebookEdit'].includes(name)) {
85
100
  emit('file_change', {paths:[...new Set([input.file_path,input.notebook_path].filter(string))].slice(0,WATCH_LIMITS.pathsMax)});
86
101
  } else if (['Agent','Task'].includes(name)) {
87
102
  const agent = string(input.subagent_type) ? input.subagent_type : '';
@@ -42,6 +42,24 @@ function changePaths(changes) {
42
42
  return [...new Set(strings(paths))].slice(0, WATCH_LIMITS.pathsMax);
43
43
  }
44
44
 
45
+ function splitChangePaths(changes) {
46
+ const added = [], changed = [];
47
+ const isAdd = change => object(change) && (change.type === 'add' || change.kind?.type === 'add' || Object.hasOwn(change,'add'));
48
+ if (Array.isArray(changes)) {
49
+ for (const change of changes) {
50
+ (isAdd(change) ? added : changed).push(change?.path, change?.file);
51
+ changed.push(change?.move_path);
52
+ }
53
+ } else if (object(changes)) {
54
+ for (const [path, change] of Object.entries(changes)) {
55
+ (isAdd(change) ? added : changed).push(path);
56
+ changed.push(change?.move_path);
57
+ }
58
+ }
59
+ const unique = paths => [...new Set(strings(paths))].slice(0,WATCH_LIMITS.pathsMax);
60
+ return {added:unique(added),changed:unique(changed)};
61
+ }
62
+
45
63
  /** Normalize one parsed rollout line; no I/O or transcript state. */
46
64
  export function normalizeCodexLine(obj) {
47
65
  try {
@@ -86,7 +104,11 @@ export function normalizeCodexLine(obj) {
86
104
  }
87
105
  case 'CommandExecution': return emit('command', {text:commandText(item.command), exitCode:Number.isFinite(item.exit_code) ? item.exit_code : undefined});
88
106
  case 'FileChange':
89
- case 'PatchApply': return emit('file_change', {paths:changePaths(item.changes)});
107
+ case 'PatchApply': {
108
+ const {added,changed} = splitChangePaths(item.changes);
109
+ if (!added.length) return emit('file_change', {paths:changePaths(item.changes)});
110
+ return [...emit('file_create', {paths:added}), ...(changed.length ? emit('file_change', {paths:changed}) : [])];
111
+ }
90
112
  case 'McpToolCall': return emit('tool', {tool:strings([item.server,item.tool]).join('.')});
91
113
  case 'Extension':
92
114
  return item.kind === 'web.search' ? emit('tool', {tool:'web.search', text:text(item.query)}) : emit('other', {text:`Extension:${text(item.kind) ?? ''}`});
@@ -1,11 +1,25 @@
1
+ import path from 'node:path';
1
2
  import {WATCH_LIMITS, MESSAGE_KINDS} from './model.mjs';
2
3
  import {sanitizeText, sanitizeMessage, clipCodePoints} from './policy.mjs';
4
+ import {realPath} from './scope.mjs';
3
5
 
4
6
  export const PLATFORM_COLORS = Object.freeze({codex:'36', claude:'38;5;208', other:'2'});
5
7
 
8
+ // Compare both the lexical root and its real path (e.g. /tmp and /private/tmp).
9
+ export function displayPath(file, root) {
10
+ if (!root || !path.isAbsolute(root) || !path.isAbsolute(file)) return file;
11
+ for (const base of [path.resolve(root), realPath(root)]) {
12
+ if (file === base || file.startsWith(base.endsWith(path.sep) ? base : base + path.sep)) {
13
+ const relative = path.relative(base,file).split(path.sep).join('/');
14
+ return path.basename(root) + (relative ? '/' + relative : '');
15
+ }
16
+ }
17
+ return file;
18
+ }
19
+
6
20
  export function tagColor(event) {
7
21
  if (event.kind === 'command') return event.exitCode == null || event.exitCode === 0 ? '38;5;242' : '31';
8
- return ({user:'1;35', agent:'32', file_change:'33', tool:'2', spawn:'38;5;141',
22
+ return ({user:'1;35', agent:'32', file_change:'33', file_create:'38;5;69', tool:'2', spawn:'38;5;141',
9
23
  dispatch:'38;5;137', approval:'1;4', turn_failed:'31', error:'31', tool_failed:'31'})[event.kind] ?? '2';
10
24
  }
11
25
 
@@ -23,7 +37,7 @@ export function kindTag(event) {
23
37
  if (event.kind === 'command') return event.exitCode == null ? 'CMD' : `CMD(${event.exitCode})`;
24
38
  return ({session:'SESSION', settings:'SETTINGS', turn_start:'TURN', turn_end:'END',
25
39
  turn_failed:'FAIL', user:'USER', agent:'AGENT', reasoning:'THINK', tool:'TOOL',
26
- tool_failed:'TOOL!', file_change:'EDIT', spawn:'SPAWN', approval:'APPROVE',
40
+ tool_failed:'TOOL!', file_change:'EDIT', file_create:'CREATE', spawn:'SPAWN', approval:'APPROVE',
27
41
  dispatch:'DISPATCH', error:'ERROR', other:'ITEM', notice:'NOTICE'})[event.kind] ?? 'ITEM';
28
42
  }
29
43
 
@@ -31,8 +45,8 @@ function eventText(event, verbose) {
31
45
  if (event.kind === 'tool' || event.kind === 'tool_failed') {
32
46
  return [event.tool, event.text].map(sanitizeText).filter(Boolean).join(' ');
33
47
  }
34
- if (event.kind === 'file_change') {
35
- return [event.text, ...(event.paths ?? [])].map(sanitizeText).filter(Boolean).join(' ');
48
+ if (event.kind === 'file_change' || event.kind === 'file_create') {
49
+ return [event.text, ...(event.paths ?? []).map(file => displayPath(file,event.root))].map(sanitizeText).filter(Boolean).join(' ');
36
50
  }
37
51
  if (event.kind !== 'dispatch') return sanitizeText(event.text);
38
52
  return sanitizeText([event.state, event.route, event.workflowId,
@@ -48,10 +62,11 @@ export function renderHuman(event, {width, color, verbose}) {
48
62
  const tag = sanitizeText(kindTag(event)).padEnd(8);
49
63
  const prefix = `${time} ${platform} ${tag} `;
50
64
  const message = MESSAGE_KINDS.includes(event.kind);
65
+ const fullLine = message || event.kind === 'file_change' || event.kind === 'file_create';
51
66
  const text = message ? sanitizeMessage(event.text) : eventText(event, verbose);
52
67
  const messageBody = text.split('\n').map((line, i) => !line ? '' : (i ? ' '.repeat([...prefix].length) : '') + line).join('\n');
53
- const plain = message ? (text ? prefix + messageBody : prefix.trimEnd()) : clipCodePoints(prefix + text, width).text;
54
- if (!color || (!message && [...prefix].length > width)) return plain;
68
+ const plain = message ? (text ? prefix + messageBody : prefix.trimEnd()) : fullLine ? prefix + text : clipCodePoints(prefix + text, width).text;
69
+ if (!color || (!fullLine && [...prefix].length > width)) return plain;
55
70
  const code = bodyColor(event);
56
71
  const paint = (value, code) => `\x1b[${code}m${value}\x1b[0m`;
57
72
  const platformColor = event.source === 'watch' ? PLATFORM_COLORS.other : PLATFORM_COLORS[event.platform] ?? PLATFORM_COLORS.other;
@@ -5,7 +5,7 @@ import {GIT_ALLOWED} from './git.mjs';
5
5
  const scopeCaches = new WeakMap();
6
6
 
7
7
  // Resolve the existing ancestor too: a transcript cwd can name a deleted child.
8
- function realPath(file) {
8
+ export function realPath(file) {
9
9
  let current = path.resolve(file);
10
10
  const suffix = [];
11
11
  for (;;) {
@@ -6,7 +6,7 @@ import {topLabel, childLabel, dispatchLabel, roleFromName} from './labels.mjs';
6
6
  import {normalizeCodexLine} from './normalize-codex.mjs';
7
7
  import {createClaudeState, normalizeClaudeLine, parseClaudeAgentMeta} from './normalize-claude.mjs';
8
8
  import {createTail, readTail, readHead} from './tail.mjs';
9
- import {refreshScope, inScope, claudeDirPrefixes} from './scope.mjs';
9
+ import {refreshScope, inScope, claudeDirPrefixes, realPath} from './scope.mjs';
10
10
  import {listCodexRollouts, readCodexMeta} from './discover-codex.mjs';
11
11
  import {createClaudeDiscovery, readClaudeHead} from './discover-claude.mjs';
12
12
  import {createDispatchIndex} from './dispatch.mjs';
@@ -24,6 +24,7 @@ export function createWatcher({options, homes, scope: initialScope, git, now, de
24
24
  const followed = new Map(), pending = new Map(), ignored = new Map(), detached = new Map();
25
25
  const seenAtStart = new Map(), heads = new Map(), metas = new Map(), agentMetas = new Map(), childLists = new Map();
26
26
  const compressed = new Set(), missingDispatch = new Set(), repos = new Map();
27
+ const rootsByCwd = new Map();
27
28
  const dispatch = dispatchIndex({codexHome:homes.codex});
28
29
  const claude = homes.claude ? claudeDiscovery({claudeHome:homes.claude}) : null;
29
30
  const stamp = () => new Date(now()).toISOString();
@@ -57,6 +58,7 @@ export function createWatcher({options, homes, scope: initialScope, git, now, de
57
58
  v:1, observedAt:stamp(), platform:row.platform,
58
59
  source:ref ? 'bridge' : parent ? 'subagent' : 'session',
59
60
  origin:row.origin, sessionId:row.id, label:label(row), cwd:row.cwd,
61
+ ...(row.root ? {root:row.root} : {}),
60
62
  ...(row.parentId ? {parentId:row.parentId,depth:row.depth ?? (parent?.depth ?? 0)+1} : {}),
61
63
  ...(ref ? {dispatchId:ref.dispatchId, ...(ref.workflowId ? {workflowId:ref.workflowId} : {}), ...(ref.role ? {role:ref.role} : {})} : {}),
62
64
  ...(!ref && roleFromName(row.agent?.agentRole ?? row.agent?.agentType) ? {role:roleFromName(row.agent.agentRole ?? row.agent.agentType)} : {}),
@@ -72,6 +74,8 @@ export function createWatcher({options, homes, scope: initialScope, git, now, de
72
74
  for (const line of lines) {
73
75
  const events = row.platform === 'codex' ? normalizeCodexLine(line) : normalizeClaudeLine(line,row.state);
74
76
  for (const e of events) {
77
+ if (['turn_end','turn_failed'].includes(e.kind)) row.active = false;
78
+ else if (['turn_start','user','agent','reasoning','command','tool','tool_failed','file_change','file_create','spawn','approval'].includes(e.kind)) row.active = true;
75
79
  if (!isVisible(e.kind,verbose) || (e.kind === 'notice' && !verbose)) continue;
76
80
  out.push(clean({...identity(row),...e,ts:e.ts ?? stamp(),...(e.kind === 'session' ? {text:sessionText(row)} : {})}));
77
81
  }
@@ -123,17 +127,32 @@ export function createWatcher({options, homes, scope: initialScope, git, now, de
123
127
  let history;
124
128
  try { history = previous ? {endOffset:previous.offset} : await readTail(row.file); }
125
129
  catch (error) { debug(out,`session file unreadable: ${row.id.slice(0,8)} (${error.code ?? 'error'})`); ignored.set(row.file,row.size); return; }
130
+ row.root = await sessionRoot(row.cwd);
126
131
  row.tail=createTail(row.file,{offset:previous?.offset ?? history.endOffset});
127
- row.state=createClaudeState(); row.held=[]; row.lastActivity=row.mtimeMs;
132
+ row.state=createClaudeState(); row.active=false; row.held=[]; row.lastActivity=row.mtimeMs;
128
133
  followed.set(row.id,row); pending.delete(row.file); detached.delete(row.file);
129
134
  if (!startup && !previous && !mapped(row) && (row.origin==='codex_exec'||row.platform==='claude') && now()-row.mtimeMs<=L.holdCreatedWithinMs) row.holdUntil=now()+L.holdMs;
130
135
  const showHistory = startup ? tailCount > 0 && now()-row.mtimeMs<=L.historyWindowMs : !previous;
136
+ const events=history.lines ? normalize(row,history.lines) : [];
131
137
  if (showHistory) {
132
- const events=normalize(row,history.lines);
133
138
  if (!events.some(e=>e.kind==='session')) events.unshift(clean({...identity(row),ts:events[0]?.ts??stamp(),kind:'session',text:sessionText(row)}));
134
139
  emit(row,events,out);
135
140
  }
136
141
  }
142
+ async function sessionRoot(cwd) {
143
+ if (!cwd) return undefined;
144
+ try {
145
+ const matches = (scope.roots ?? []).filter(root => inScope({kind:'dir',roots:[root]},cwd));
146
+ if (matches.length) return matches.sort((a,b) => Math.max(path.resolve(b).length,realPath(b).length) - Math.max(path.resolve(a).length,realPath(a).length))[0];
147
+ if (rootsByCwd.has(cwd)) return rootsByCwd.get(cwd);
148
+ let root = cwd;
149
+ try { root = (await git(cwd,GIT_ALLOWED[0]))?.trim() || cwd; }
150
+ catch { /* A missing repository still has a useful cwd root. */ }
151
+ if (rootsByCwd.size >= L.maxRepos) rootsByCwd.delete(rootsByCwd.keys().next().value);
152
+ rootsByCwd.set(cwd,root);
153
+ return root;
154
+ } catch { return cwd; }
155
+ }
137
156
  function rememberStart(item, startup) {
138
157
  if (startup) seenAtStart.set(item.file,{...item,offset:item.size});
139
158
  }
@@ -299,7 +318,7 @@ export function createWatcher({options, homes, scope: initialScope, git, now, de
299
318
  debug(out,`session file unreadable: ${row.id.slice(0,8)} (${error.code??'error'})`);continue;
300
319
  }
301
320
  if (result.gone) {followed.delete(id);debug(out,`session file removed: ${row.id.slice(0,8)}`);continue;}
302
- if (result.reset) {row.state=createClaudeState();debug(out,`session restarted from the beginning: ${row.id.slice(0,8)}`);}
321
+ if (result.reset) {row.state=createClaudeState();row.active=false;debug(out,`session restarted from the beginning: ${row.id.slice(0,8)}`);}
303
322
  if (result.overflowed && !row.overflowed) debug(out,`line over 4 MiB skipped in ${row.id.slice(0,8)}`);
304
323
  row.overflowed=result.overflowed;
305
324
  if (row.tail.offset!==row.size) row.lastActivity=now();
@@ -332,6 +351,7 @@ export function createWatcher({options, homes, scope: initialScope, git, now, de
332
351
  await poll(out);
333
352
  return markEmitted(sort(out));
334
353
  },
354
+ busy() {return [...followed.values()].some(row=>row.active && now()-row.lastActivity<=L.spinnerIdleMs);},
335
355
  async close() {closed=true;followed.clear();pending.clear();},
336
356
  };
337
357
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yunhozz/arc",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"