sprag-cli 3.129.1 → 3.131.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/docs/TEAM.ko.md CHANGED
@@ -169,7 +169,7 @@ https://sprag.io/team/ 에서 등록된 오너나 어드민이 이메일 코드
169
169
 
170
170
  여러 팀을 한 번에 만들려면 "+ 새 팀"을 누르고 "여러 팀 한 번에 만들기"를 펼친 뒤 한 줄에 팀 이름을 하나씩 붙여 넣습니다. 한 번에 50개까지 만들 수 있습니다. 빈 줄과 조직에 이미 있는 이름, 목록에 두 번 나온 이름, 80자를 넘는 이름은 건너뛰고 따로 알려 줍니다. 만들다가 하나가 실패하면 그 이름에서 멈추고 아직 만들지 못한 이름은 다시 실행할 수 있도록 입력란에 남겨 둡니다. 팀 목록과 타운 탭의 "가입 명령어 내보내기"를 누르면 팀마다 한 줄씩 담긴 CSV를 받습니다. 열은 `team`, `team_id`, `invite_token`, `join_command`(`npm i -g sprag-cli@latest && sprag team join <토큰>`), `shell_profile`(`export SPRAG_TEAM_TOKEN=<토큰>`), `managed_settings`(관리형 설정 JSON)입니다. 일괄 생성이 끝나면 방금 만든 팀만 내보내는 버튼도 나옵니다. 이 파일에는 목록에 있는 모든 팀의 초대 토큰이 들어 있으므로 각 줄은 해당 팀에만 전달하고, 파일이 새어 나가면 그 팀의 토큰을 교체하십시오.
171
171
 
172
- 대시보드 맨 위의 기간 선택(7일, 30일, 90일, 이번 달, 지난 달, 직접 선택)이 멤버 표, 사용량 차트, 프롬프트 사용량 탭의 기간을 정합니다. 기본값은 최근 30일이고, 내 컴퓨터의 달력 날짜를 쓰며 종료일도 포함합니다. 최대 365일까지 고를 수 있습니다. 고른 기간은 주소(`?from=2026-10-01&to=2026-10-18`)에 남으므로 새로고침하거나 링크를 공유해도 같은 기간이 보입니다. sprag.io/ops/ 슈퍼유저 콘솔에도 같은 선택이 있어 조직 표, 조직 머리말, 조직의 프롬프트 사용량에 적용됩니다.
172
+ 대시보드 맨 위의 기간 선택(7일, 30일, 90일, 이번 달, 지난 달, 직접 선택)이 멤버 표, 사용량 차트, 프롬프트 사용량 탭의 기간을 정합니다. 기본값은 이번 달(1일부터 오늘까지)로 멤버 타운, statusline 순위와 같습니다. 내 컴퓨터의 달력 날짜를 쓰며 종료일도 포함합니다. 최대 365일까지 고를 수 있습니다. 고른 기간은 주소(`?from=2026-10-01&to=2026-10-18`)에 남으므로 새로고침하거나 링크를 공유해도 같은 기간이 보입니다. sprag.io/ops/ 슈퍼유저 콘솔에도 같은 선택이 있어 조직 표, 조직 머리말, 조직의 프롬프트 사용량에 적용됩니다.
173
173
 
174
174
  ### 좌석 현황
175
175
 
package/docs/TEAM.md CHANGED
@@ -150,7 +150,7 @@ sprag team town --no-open # prints the link only
150
150
 
151
151
  The command asks the team server for a link with `town_view_link` (it sends your member key and nothing else) and opens `https://sprag.io/town/#t=<token>`. The token is valid for 12 hours and the command prints the expiry in your local time. Asking for links too often is refused for a while ("too many town links"). The token sits in the part of the address after `#`, so the web server never receives it, and the page removes it from the address bar after reading it. When it expires, or after you leave the team, the page asks you to run the command again. `SPRAG_TOWN_URL` points the link at another page (for local tests).
152
152
 
153
- The page opens on this month (Asia/Seoul calendar month start to today). A period picker in the page head switches between this month, last month and the last 7, 30 or 90 days. The page sends the range to `town_view(p_token, p_from, p_to)`, which applies the same validation as the dashboard (both dates or neither, from not after to, at most 366 days), and the choice is kept for that tab only.
153
+ The page opens on this month (Asia/Seoul calendar month start to today). A period picker in the page head switches between this month, last month, the last 7, 30 or 90 days, and custom dates (a start and an end date, at most 365 days). The page sends the range to `town_view(p_token, p_from, p_to)`, which applies the same validation as the dashboard (both dates or neither, from not after to, at most 366 days), and the choice is kept for that tab only.
154
154
 
155
155
  What the town shows:
156
156
 
@@ -191,7 +191,7 @@ https://sprag.io/team/ is where a registered owner or admin signs in with an ema
191
191
 
192
192
  To create several teams at once, open "+ New team", then "Create several teams at once", and paste one team name per line (up to 50 per run). Blank lines, names already in the organization, names listed twice and names over 80 characters are skipped and listed. If one creation fails, the run stops there and the names not yet created stay in the box for another run. "Export join commands" (under the Teams list and on the Town tab) downloads a CSV with one row per team: `team`, `team_id`, `invite_token`, `join_command` (`npm i -g sprag-cli@latest && sprag team join <token>`), `shell_profile` (`export SPRAG_TEAM_TOKEN=<token>`) and `managed_settings` (the managed settings JSON). After a bulk run, a button exports only the teams it created. The file holds every listed team's invite token, so share each row only with that team, and rotate a team's token if the file leaks.
193
193
 
194
- A date range control at the top of the dashboard (7d, 30d, 90d, This month, Last month or Custom) sets the period for the members table, the Usage chart and the prompt usage tab. It defaults to the last 30 days, uses your local calendar days with the end date included, and allows 365 days at most. The choice is kept in the page address (`?from=2026-10-01&to=2026-10-18`), so a reload or a shared link shows the same period. The superuser console at /ops/ has the same control for the organization table, the organization header and its prompt usage.
194
+ A date range control at the top of the dashboard (7d, 30d, 90d, This month, Last month or Custom) sets the period for the members table, the Usage chart and the prompt usage tab. It defaults to this month (the 1st through today), the same period as the member town and the statusline standing, uses your local calendar days with the end date included, and allows 365 days at most. The choice is kept in the page address (`?from=2026-10-01&to=2026-10-18`), so a reload or a shared link shows the same period. The superuser console at /ops/ has the same control for the organization table, the organization header and its prompt usage.
195
195
 
196
196
  ### The seat roster
197
197
 
@@ -99,6 +99,36 @@ export function statuslinePayload(input: {
99
99
  return payload
100
100
  }
101
101
 
102
+ /**
103
+ * The argv with `--columns <n>` added, so sprag fits its chips to the band and
104
+ * wraps them at chip boundaries instead of the band wrapping them mid-chip. A
105
+ * command that already names its width, or an unknown width, is left as it is.
106
+ */
107
+ export function withColumns(argv: string[], columns: number | undefined): string[] {
108
+ if (!columns || !Number.isFinite(columns) || columns < 20) return argv
109
+ if (argv.includes('--columns')) return argv
110
+ return [...argv, '--columns', String(Math.floor(columns))]
111
+ }
112
+
113
+ // First engine whose Box takes overflowX="scroll" and whose Text takes
114
+ // wrap="clip". Older engines check a tree's props by name and value and skip a
115
+ // hook whose tree has one they do not know, so the band would vanish there.
116
+ export const CLIP_MIN_VERSION = '2.1.326'
117
+
118
+ /** Whether a release version (`2.1.326`, `2.1.330-dev`) is at least `min`. */
119
+ export function atLeast(version: string | undefined, min: string): boolean {
120
+ const parse = (v: string) => /^(\d+)\.(\d+)\.(\d+)/.exec(v)?.slice(1).map(Number)
121
+ const a = version ? parse(version) : undefined
122
+ const b = parse(min)
123
+ if (!a || !b) return false
124
+ for (let i = 0; i < 3; i++) {
125
+ const x = a[i] ?? 0
126
+ const y = b[i] ?? 0
127
+ if (x !== y) return x > y
128
+ }
129
+ return true
130
+ }
131
+
102
132
  /** Output with stray ANSI escapes removed and blank lines dropped. */
103
133
  export function cleanOutput(text: string): string[] {
104
134
  return text
@@ -111,6 +141,19 @@ export function cleanOutput(text: string): string[] {
111
141
 
112
142
  let isRunning = false
113
143
  let timer: { cancel: () => void } | undefined
144
+ // The band's width as the last draw saw it; the next run fits the text to it
145
+ let bandColumns: number | undefined
146
+ // Whether this engine takes the clip props; read once, after a reload again
147
+ let canClip: Promise<boolean> | undefined
148
+
149
+ /** Whether the engine is CLIP_MIN_VERSION or later. An engine that cannot say counts as older. */
150
+ function engineCanClip($: EngineInterface): Promise<boolean> {
151
+ canClip ??= $.session
152
+ .version()
153
+ .then(v => atLeast(v.base ?? v.version, CLIP_MIN_VERSION))
154
+ .catch(() => false)
155
+ return canClip
156
+ }
114
157
 
115
158
  /** Runs the statusline once and stores its text; any failure leaves the last text as it was. */
116
159
  async function refresh($: EngineInterface): Promise<void> {
@@ -125,7 +168,7 @@ async function refresh($: EngineInterface): Promise<void> {
125
168
  $.session.usage(),
126
169
  $.settings.read(),
127
170
  ])
128
- const run = await $.process.run(statuslineArgv(settings), {
171
+ const run = await $.process.run(withColumns(statuslineArgv(settings), bandColumns), {
129
172
  stdin: JSON.stringify(statuslinePayload({ sessionId, cwd, model, usage })),
130
173
  timeoutMs: RUN_TIMEOUT_MS,
131
174
  })
@@ -158,15 +201,27 @@ export const register: Register = on => {
158
201
 
159
202
  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
160
203
  if (e.surface !== 'desktop' || e.props.hasSurvey) return next(e)
204
+ // A new width refits the text now rather than at the next tick
205
+ const columns = e.props.bodyColumns
206
+ if (typeof columns === 'number' && columns !== bandColumns) {
207
+ bandColumns = columns
208
+ void refresh($)
209
+ }
161
210
  const shown = (await read($, lines)).slice(0, Math.max(0, e.props.maxRows))
162
211
  if (!shown.length) return next(e)
163
212
 
164
213
  const { Box, Text } = $.ui.resolve(e)
214
+ // On an engine that has them, a line wider than the band stays on its row
215
+ // and scrolls sideways instead of wrapping in the middle of a chip. They go
216
+ // in as spreads so the module still type-checks against older engine types.
217
+ const clip = await engineCanClip($)
218
+ const boxProps = clip ? { overflowX: 'scroll' as const } : {}
219
+ const textProps = clip ? { wrap: 'clip' as const } : {}
165
220
  // One statusline line per row; a Box lays its children out in a row unless told otherwise
166
221
  return (
167
- <Box flexDirection="column">
222
+ <Box flexDirection="column" {...boxProps}>
168
223
  {shown.map((line, i) => (
169
- <Text key={`line-${i}`} dimColor>
224
+ <Text key={`line-${i}`} dimColor {...textProps}>
170
225
  {line}
171
226
  </Text>
172
227
  ))}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sprag-cli",
3
- "version": "3.129.1",
3
+ "version": "3.131.0",
4
4
  "description": "The delegation layer for Claude Code and Codex: each task goes to the model and effort that fits it, down to cheaper models for lookups and up to higher effort when a cheaper run would miss, backed by public replay cases, with a live statusline and team rules for Pro and Enterprise.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Which Claude Code is running this hook or command, read without spawning it.
3
+ *
4
+ * Measured on Claude Code 2.1.319: the SessionStart and UserPromptSubmit hook
5
+ * processes carry AI_AGENT=claude-code_2-1-319_harness, and the Bash tool's
6
+ * children carry claude-code_2-1-319_agent. The Claude process's own
7
+ * environment does not have it, so the value exists only in hook and tool
8
+ * children. That is enough here, because the callers are hooks and CLI
9
+ * commands that a session runs. `claude --version` is deliberately not used: it
10
+ * would slow the hook path and make tests depend on the machine.
11
+ *
12
+ * Why the version matters: before 2.1.326 a session did not find an agent file
13
+ * first created while it was running ("Fixed a first skill, command or agent
14
+ * created during a session not being found right away").
15
+ */
16
+
17
+ import { isNewer } from './update-check.js';
18
+
19
+ export const AGENTS_LIVE_MIN_VERSION = '2.1.326';
20
+
21
+ const AI_AGENT_RE = /^claude-code_(\d+)-(\d+)-(\d+)(?:_|$)/;
22
+
23
+ /** Claude Code version from AI_AGENT ("claude-code_2-1-319_harness" -> "2.1.319"), or null. */
24
+ export function sessionClaudeVersion(env = process.env) {
25
+ const hit = AI_AGENT_RE.exec(String((env && env.AI_AGENT) || '').trim());
26
+ return hit ? `${hit[1]}.${hit[2]}.${hit[3]}` : null;
27
+ }
28
+
29
+ /**
30
+ * True when this Claude Code finds an agent first created mid-session; false
31
+ * when it is older; null when the version is unknown (callers treat null like
32
+ * false, so an old Claude Code is never assumed to be new).
33
+ */
34
+ export function agentsLoadMidSession(version) {
35
+ if (!version) return null;
36
+ if (!/^\d+\.\d+\.\d+$/.test(String(version))) return null;
37
+ return version === AGENTS_LIVE_MIN_VERSION || isNewer(version, AGENTS_LIVE_MIN_VERSION);
38
+ }
@@ -30,7 +30,7 @@ export async function codexProviderKey(provider, { execute = run } = {}) {
30
30
  let key = provider.key;
31
31
  if (!key && typeof provider.command === 'string') {
32
32
  try {
33
- const result = await execute(provider.command, provider.args, { encoding: 'utf8', timeout: 10000, maxBuffer: 64 * 1024 });
33
+ const result = await execute(provider.command, provider.args, { encoding: 'utf8', timeout: 10000, maxBuffer: 64 * 1024, windowsHide: true });
34
34
  key = result.stdout.trim().split(/\r?\n/).filter(Boolean).pop();
35
35
  } catch { throw new Error('Codex provider authentication helper failed'); }
36
36
  }
@@ -18,7 +18,7 @@ export function codexDelegationDiagnostics({ home = codexUserDir(), model = code
18
18
  (profile?.features?.multi_agent ?? cfg.features?.multi_agent) === false;
19
19
  } catch (e) { if (e.code !== 'ENOENT') result.errors.push('Cannot parse user config.'); }
20
20
  const run = (args) => exec('codex', args, { encoding: 'utf8', timeout: 5000, maxBuffer: 20 * 1024 * 1024,
21
- env: { ...process.env, CODEX_HOME: home }, stdio: ['ignore', 'pipe', 'pipe'] });
21
+ env: { ...process.env, CODEX_HOME: home }, stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true });
22
22
  try { result.version = run(['--version']).trim().slice(0, 100); } catch { result.errors.push('Codex version unavailable.'); }
23
23
  try {
24
24
  for (const line of run(['features', 'list']).split('\n')) {
@@ -190,6 +190,7 @@ async function agentsCommand(action, lang) {
190
190
  const r = action === 'on' ? da.syncDelegationAgents() : da.removeDelegationAgents();
191
191
  await rerender();
192
192
  report(r);
193
+ if (r.createdDir) console.log(da.firstInstallCliLine({ lang: ko ? 'ko' : 'en' }));
193
194
  console.log(action === 'on'
194
195
  ? (ko ? '위임 전용 에이전트를 켰습니다. 래칫 문구가 에이전트 이름으로 다시 만들어졌습니다.' : 'Delegation agents are on. The ratchet wording was re-rendered with the agent names.')
195
196
  : (ko ? '위임 전용 에이전트를 껐습니다. 래칫 문구가 model 지정 방식으로 다시 만들어졌습니다.' : 'Delegation agents are off. The ratchet wording was re-rendered with plain model tiers.'));
@@ -53,10 +53,10 @@ function metadata(version) {
53
53
 
54
54
  function tryGhCli(title, body) {
55
55
  try {
56
- const auth = spawnSync('gh', ['auth', 'status'], { encoding: 'utf8', timeout: 10_000 });
56
+ const auth = spawnSync('gh', ['auth', 'status'], { encoding: 'utf8', timeout: 10_000, windowsHide: true });
57
57
  if (auth.status !== 0) return null;
58
58
  const res = spawnSync('gh', ['issue', 'create', '-R', REPO, '--title', title, '--body', body],
59
- { encoding: 'utf8', timeout: 30_000 });
59
+ { encoding: 'utf8', timeout: 30_000, windowsHide: true });
60
60
  if (res.status !== 0) { debug('feedback:gh', res.stderr); return null; }
61
61
  const url = String(res.stdout).trim().split('\n').pop();
62
62
  return { transport: 'gh', url };
@@ -420,11 +420,13 @@ export async function run({ hasFlag }) {
420
420
  // Presets now live in ratchet-preset.md. Moving the ones older versions
421
421
  // appended to ratchet.md comes first, so they are not offered again below.
422
422
  try {
423
- const d = (await import('../delegation-agents.js')).syncDelegationAgents();
423
+ const da = await import('../delegation-agents.js');
424
+ const d = da.syncDelegationAgents();
424
425
  if (d.written.length) {
425
426
  console.log(lang === 'ko'
426
427
  ? ` agents: 위임 전용 에이전트 ${d.written.length}개를 ~/.claude/agents 에 설치했습니다 (MCP 도구 없음).`
427
428
  : ` agents: installed ${d.written.length} delegation-only agent(s) in ~/.claude/agents (no MCP tools).`);
429
+ if (d.createdDir) console.log(da.firstInstallCliLine({ lang }));
428
430
  }
429
431
  } catch (e) {
430
432
  debug('install:delegation-agents', e);
@@ -327,7 +327,14 @@ export async function run({ args, hasFlag, numArg }) {
327
327
  // session start; this one uses whatever was already cached.
328
328
  try { (await import('../preset-sync.js')).spawnPresetSyncIfDue(); } catch (e) { debug('route-scan:preset-sync', e); }
329
329
  // Agent files come first so the ratchet-model.md rendered next names them.
330
- try { (await import('../delegation-agents.js')).syncDelegationAgents(); } catch (e) { debug('route-scan:delegation-agents', e); }
330
+ let agentsFirstBlock = null;
331
+ let agentsSync = null;
332
+ let da = null;
333
+ try {
334
+ da = await import('../delegation-agents.js');
335
+ agentsSync = da.syncDelegationAgents();
336
+ } catch (e) { debug('route-scan:delegation-agents', e); }
337
+ try { if (da && agentsSync) agentsFirstBlock = da.firstInstallNotice(agentsSync, { lang }); } catch (e) { debug('route-scan:agents-first', e); }
331
338
  // The session's project is passed so its rule-less file follows the
332
339
  // routing switch as well (see syncAllFiles).
333
340
  try {
@@ -449,6 +456,7 @@ export async function run({ args, hasFlag, numArg }) {
449
456
  if (updateBlock) console.log(updateBlock);
450
457
  if (monthlyResetBlock) console.log(monthlyResetBlock);
451
458
  if (driftBlock) console.log(driftBlock);
459
+ if (agentsFirstBlock) console.log(agentsFirstBlock);
452
460
  if (seedBlock) console.log(seedBlock);
453
461
  if (doc2mdBlock) console.log(doc2mdBlock);
454
462
  if (koreanBlock) console.log(koreanBlock);
@@ -460,6 +468,7 @@ export async function run({ args, hasFlag, numArg }) {
460
468
  if (updateBlock) console.log(updateBlock);
461
469
  if (monthlyResetBlock) console.log(monthlyResetBlock);
462
470
  if (driftBlock) console.log(driftBlock);
471
+ if (agentsFirstBlock) console.log(agentsFirstBlock);
463
472
  if (seedBlock) console.log(seedBlock);
464
473
  if (doc2mdBlock) console.log(doc2mdBlock);
465
474
  // This text is injected straight into the model's context, so it must
@@ -233,7 +233,7 @@ function openInBrowser(url) {
233
233
  const cmd = process.platform === 'darwin' ? 'open' : win ? 'cmd' : 'xdg-open';
234
234
  const args = win ? ['/c', 'start', '', url] : [url];
235
235
  try {
236
- const child = spawn(cmd, args, { detached: true, stdio: 'ignore' });
236
+ const child = spawn(cmd, args, { detached: true, stdio: 'ignore', windowsHide: true });
237
237
  child.on('error', () => {});
238
238
  child.unref();
239
239
  } catch { /* no opener on this machine */ }
@@ -23,7 +23,7 @@ function runCommand(cmd) {
23
23
  // Shell form: the upgrade command is a fixed string we composed ourselves
24
24
  // (no user input reaches it), and `npm install -g` needs the user's PATH
25
25
  // resolution to find the same npm that installed us.
26
- const child = spawn(cmd, { shell: true, stdio: 'inherit' });
26
+ const child = spawn(cmd, { shell: true, stdio: 'inherit', windowsHide: true });
27
27
  child.on('close', (code) => resolve(code === null ? 1 : code));
28
28
  child.on('error', () => resolve(1));
29
29
  });
@@ -40,7 +40,7 @@ import { parseJsonText } from './json-text.js';
40
40
  export const MODEL_SETTINGS_MIN_VERSION = '2.1.288';
41
41
 
42
42
  /** Installed Claude Code version (`2.1.302`), or null when it cannot be read. */
43
- export function claudeCodeVersion({ run = () => execFileSync('claude', ['--version'], { encoding: 'utf8', timeout: 3000, stdio: ['ignore', 'pipe', 'ignore'] }) } = {}) {
43
+ export function claudeCodeVersion({ run = () => execFileSync('claude', ['--version'], { encoding: 'utf8', timeout: 3000, stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true }) } = {}) {
44
44
  try {
45
45
  const m = String(run()).match(/(\d+\.\d+\.\d+)/);
46
46
  return m ? m[1] : null;
@@ -204,7 +204,7 @@ const isOwned = (file) => { try { return firstLine(file) === COWORK_MARKER; } ca
204
204
  // ---------- git exclude ----------
205
205
 
206
206
  const git = (dir, args) => execFileSync('git', ['-C', dir, ...args], {
207
- timeout: 3000, stdio: ['ignore', 'pipe', 'ignore'], encoding: 'utf8',
207
+ timeout: 3000, stdio: ['ignore', 'pipe', 'ignore'], encoding: 'utf8', windowsHide: true,
208
208
  }).trim();
209
209
 
210
210
  function addGitExclude(dir) {
@@ -17,6 +17,7 @@ import { join } from 'node:path';
17
17
  import { claudeUserDir } from './paths.js';
18
18
  import { loadConfig, saveConfig } from './config.js';
19
19
  import { agentDefinitions, cliVersion, presetSource } from './presets-source.js';
20
+ import { AGENTS_LIVE_MIN_VERSION, agentsLoadMidSession, sessionClaudeVersion } from './claude-version.js';
20
21
 
21
22
  export const OWNER_MARK = 'sprag:delegation-agent';
22
23
  const MARK_LINE = `# managed by sprag (${OWNER_MARK}); edits are overwritten`;
@@ -100,16 +101,19 @@ export function removeDelegationAgents() {
100
101
  if (f && isOwned(f.text)) { unlinkSync(p); removed.push(name); }
101
102
  } catch { /* one file failing does not stop the rest */ }
102
103
  }
103
- return { written: [], unchanged: [], skipped: [], removed };
104
+ return { written: [], unchanged: [], skipped: [], removed, createdDir: false };
104
105
  }
105
106
 
106
107
  export function syncDelegationAgents({ agent = 'claude' } = {}) {
107
- const res = { written: [], unchanged: [], skipped: [], removed: [] };
108
+ const res = { written: [], unchanged: [], skipped: [], removed: [], createdDir: false };
108
109
  if (agent === 'codex') return res;
109
110
  try {
110
111
  if (loadConfig().delegationAgents === false) return removeDelegationAgents();
111
112
  } catch { /* an unreadable config means the default, on */ }
112
113
  const defs = definitions();
114
+ // Remembered before the loop: a Claude Code older than 2.1.326 does not see
115
+ // an agents folder that first appears mid-session (see claude-version.js).
116
+ const dirExisted = existsSync(agentsDir());
113
117
  for (const def of defs) {
114
118
  try {
115
119
  const p = fileOf(def.name);
@@ -134,9 +138,44 @@ export function syncDelegationAgents({ agent = 'claude' } = {}) {
134
138
  try { unlinkSync(fileOf(name)); res.removed.push(name); } catch { /* left for the next sync */ }
135
139
  }
136
140
  }
141
+ res.createdDir = !dirExisted && res.written.length > 0;
137
142
  return res;
138
143
  }
139
144
 
145
+ /**
146
+ * Session-start notice for the first install of the agent files. Only a Claude
147
+ * Code older than AGENTS_LIVE_MIN_VERSION (or one whose version is unknown)
148
+ * needs it: it cannot find an agent created mid-session, so the model is told
149
+ * to delegate through general-purpose for this one session. Returns null when
150
+ * the folder was not just created or the running version finds the agents.
151
+ */
152
+ export function firstInstallNotice(result, { lang = 'ko', env = process.env } = {}) {
153
+ if (!result || !result.createdDir || !Array.isArray(result.written) || result.written.length === 0) return null;
154
+ if (agentsLoadMidSession(sessionClaudeVersion(env)) === true) return null;
155
+ const names = result.written.join(', ');
156
+ const n = result.written.length;
157
+ return lang === 'ko'
158
+ ? `✇ [sprag agents] 이번 세션을 시작하면서 위임 전용 에이전트 ${n}개(${names})를 처음 설치했습니다. Claude Code ${AGENTS_LIVE_MIN_VERSION} 미만은 세션 도중 처음 생긴 에이전트를 찾지 못하므로 이 세션에서는 이 이름으로 위임하지 말고 general-purpose에 model 인자(haiku, sonnet, opus)를 넘기십시오. 다음 세션부터는 에이전트 이름으로 위임합니다.`
159
+ : `✇ [sprag agents] This session start installed ${n} delegation-only agent(s) for the first time (${names}). Claude Code before ${AGENTS_LIVE_MIN_VERSION} does not find an agent first created mid-session, so in this session do not delegate by these names: use general-purpose with a model argument (haiku, sonnet, opus). From the next session on, delegate by agent name.`;
160
+ }
161
+
162
+ /**
163
+ * The line `sprag install` and `delegate agents on` print after the first
164
+ * install of the agent files: whether a session already running can use them.
165
+ * One copy here so the two commands cannot drift apart.
166
+ */
167
+ export function firstInstallCliLine({ lang = 'ko', env = process.env } = {}) {
168
+ const version = sessionClaudeVersion(env);
169
+ if (agentsLoadMidSession(version) === true) {
170
+ return lang === 'ko'
171
+ ? ` 실행 중인 Claude Code 세션에서도 바로 쓸 수 있습니다(Claude Code ${version}).`
172
+ : ` Running Claude Code sessions can use them right away (Claude Code ${version}).`;
173
+ }
174
+ return lang === 'ko'
175
+ ? ` 실행 중인 Claude Code 세션이 바로 찾으려면 ${AGENTS_LIVE_MIN_VERSION} 이상이어야 합니다. 그보다 오래된 버전은 새 세션부터 씁니다.`
176
+ : ` A running Claude Code session finds them right away only on ${AGENTS_LIVE_MIN_VERSION} or later; older versions pick them up from the next session.`;
177
+ }
178
+
140
179
  export function delegationAgentStatus() {
141
180
  let enabled = true;
142
181
  try { enabled = loadConfig().delegationAgents !== false; } catch { /* default on */ }
package/src/doc2md.cjs CHANGED
@@ -478,6 +478,7 @@ function spawnFigConvert(fig2md, filePath) {
478
478
  encoding: 'utf8',
479
479
  timeout: CONVERT_TIMEOUT_MS,
480
480
  maxBuffer: MAX_MARKDOWN_BYTES * 4,
481
+ windowsHide: true,
481
482
  });
482
483
  if (run.error && run.error.code === 'ETIMEDOUT') return { ok: false, reason: 'timeout' };
483
484
  if (run.status !== 0) {
@@ -31,7 +31,7 @@ import { modelFamily } from '../savings-ledger.js';
31
31
  import { shareLegend } from '../model-share.js';
32
32
  import { STAR_URL } from '../star-note.js';
33
33
  import { GRADES, speciesLabel } from '../office-species.js';
34
- import { scorePctOf, nextOf, nextGradeUp, floorPct } from '../team-standing.js';
34
+ import { scorePctOf, nextOf, nextGradeUp, floorPct, rankMonthLabel } from '../team-standing.js';
35
35
  import { cellWidth } from '../cell-width.js';
36
36
 
37
37
  // The 8-color ANSI defaults (RED=31, GREEN=32, YELLOW=33…) read as garish
@@ -403,7 +403,9 @@ const TEAM_STANDING_MAX_AGE_MS = 24 * 60 * 60 * 1000;
403
403
  /**
404
404
  * Team chip: the member id, the organization and, once the server has told us,
405
405
  * the overall-score rank and the animal that member is in the team's virtual
406
- * office (`member-1a2b3c4d acmeco overall score #3 of 12 🦊 Fox`). Renders only
406
+ * office (`member-1a2b3c4d acmeco overall score #3 of 12 🦊 Fox`; when the
407
+ * standing covers one calendar month the month leads the rank: `acmeco Nov
408
+ * overall score #3 of 12 🦊 Fox`, `acmeco 11월 종합 점수 12명 중 3위 🦊 여우`). Renders only
407
409
  * for a joined machine. A missing, unknown or day-old standing leaves just the
408
410
  * member label (and the organization, when known). The office page calls the
409
411
  * ranked figure the overall score (spend rank, delegation rank, prompt rank). Gray like the other identity chips; the emoji brings its own colour.
@@ -423,7 +425,9 @@ function buildTeamSeg(team, c, mode = 'icon', now = Date.now()) {
423
425
  const inTeam = ranked && Number.isInteger(st.teamRank) && Number.isInteger(st.teamRanked)
424
426
  && st.teamRank >= 1 && st.teamRanked >= st.teamRank && st.teamRanked < st.ranked && typeof team.team === 'string' && team.team;
425
427
  const teamPlace = inTeam ? (team.lang === 'ko' ? `, ${team.team} 팀 ${st.teamRanked}명 중 ${st.teamRank}위` : `, team ${team.team} #${st.teamRank} of ${st.teamRanked}`) : '';
426
- const place = ranked ? (team.lang === 'ko' ? ` 종합 점수 ${st.ranked}명 중 ${st.rank}위${teamPlace}` : ` overall score #${st.rank} of ${st.ranked}${teamPlace}`) : '';
428
+ const month = ranked ? rankMonthLabel(st, team.lang) : null;
429
+ const monthPre = month ? ` ${month}` : '';
430
+ const place = ranked ? (team.lang === 'ko' ? `${monthPre} 종합 점수 ${st.ranked}명 중 ${st.rank}위${teamPlace}` : `${monthPre} overall score #${st.rank} of ${st.ranked}${teamPlace}`) : '';
427
431
  const org = typeof team.org === 'string' && team.org ? ` ${team.org}` : '';
428
432
  // The plan leads (`Pro`, `Enterprise`): the chip describes a licensed team, so
429
433
  // the license is the first thing it says, and the standing follows.
@@ -443,6 +447,8 @@ function buildTeamSeg(team, c, mode = 'icon', now = Date.now()) {
443
447
  * that has not joined; the chip above stands in on the single-line layouts.
444
448
  * icon: "👥 Pro · acmeco · DEV-OPS · member-1a2b3c4d | 🦊 여우 ▰▰▰▰▰▰▰▰▰▱▱▱ 75% → 🐆 치타 77% | 종합 3/12위 · 팀 1/4위 · 사용량 2/12위 · 위임률 5/12위"
445
449
  * text: "Pro · acmeco · DEV-OPS · member-1a2b3c4d | Fox 75% → Cheetah 77% | overall #3/12 · team #1/4 · spend #2/12 · delegation #5/12"
450
+ * When the standing covers one calendar month, only the overall entry carries
451
+ * the month: "11월 종합 3/12위" / "Nov overall #3/12" (crown 👑 stays in front).
446
452
  * Text mode draws no gauge, as the other gauges do not. An older server sends no
447
453
  * axis ranks, and the second group then holds the overall rank (and the team's).
448
454
  */
@@ -497,7 +503,8 @@ function buildTeamLine(team, c, isIcon, g, mode = 'icon', now = Date.now(), colo
497
503
  && st.teamRank >= 1 && st.teamRanked >= st.teamRank && st.teamRanked < st.ranked;
498
504
  const has = (v) => Number.isFinite(v);
499
505
  const rk = (koName, enName, r, n) => (ko ? `${koName} ${r}/${n}위` : `${enName} #${r}/${n}`);
500
- const ranks = [`${st.crown && emoji ? '👑 ' : ''}${rk('종합', 'overall', st.rank, st.ranked)}`];
506
+ const month = rankMonthLabel(st, team.lang);
507
+ const ranks = [`${st.crown && emoji ? '👑 ' : ''}${rk(month ? `${month} 종합` : '종합', month ? `${month} overall` : 'overall', st.rank, st.ranked)}`];
501
508
  if (inTeam) ranks.push(rk('팀', 'team', st.teamRank, st.teamRanked));
502
509
  if (has(st.spendRank)) ranks.push(rk('사용량', 'spend', st.spendRank, st.ranked));
503
510
  if (has(st.dlgRank)) ranks.push(rk('위임률', 'delegation', st.dlgRank, st.ranked));
@@ -104,6 +104,7 @@ export function keyFromApiKeyHelper(cwd = process.cwd()) {
104
104
  timeout: HELPER_TIMEOUT_MS,
105
105
  stdio: ['ignore', 'pipe', 'ignore'],
106
106
  env: { ...process.env, APIKEY_HELPER_NONINTERACTIVE: '1' },
107
+ windowsHide: true,
107
108
  });
108
109
  // 진행 로그를 함께 출력하는 헬퍼가 있으므로 마지막 비어 있지 않은 줄을 취합니다.
109
110
  const token = out.trim().split(/\r?\n/).filter(Boolean).pop();
package/src/handoff.js CHANGED
@@ -37,6 +37,7 @@ function safeGit(cmd, cwd) {
37
37
  cwd,
38
38
  encoding: 'utf8',
39
39
  stdio: ['ignore', 'pipe', 'ignore'],
40
+ windowsHide: true,
40
41
  }).trim();
41
42
  } catch {
42
43
  return '';
@@ -89,7 +89,7 @@ export function koreanLocaleDetected({ env = process.env, platform = process.pla
89
89
  // locale is the only reliable signal there.
90
90
  const { execFileSync } = require('node:child_process');
91
91
  const out = execFileSync('defaults', ['read', '-g', 'AppleLocale'], {
92
- encoding: 'utf8', timeout: 2000, stdio: ['ignore', 'pipe', 'ignore'],
92
+ encoding: 'utf8', timeout: 2000, stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true,
93
93
  }).trim();
94
94
  if (/^ko(_|-|$)/i.test(out)) return true;
95
95
  } catch { /* `defaults` missing or slow — treat as "not detected" */ }
@@ -95,7 +95,7 @@ export function scanSettingsFile(path) {
95
95
  /** Run git without a shell. Returns the exit status, or null when git cannot answer (missing, timed out). */
96
96
  function gitStatus(args, cwd) {
97
97
  try {
98
- execFileSync('git', args, { cwd, stdio: 'ignore', timeout: GIT_TIMEOUT_MS });
98
+ execFileSync('git', args, { cwd, stdio: 'ignore', timeout: GIT_TIMEOUT_MS, windowsHide: true });
99
99
  return 0;
100
100
  } catch (e) {
101
101
  return typeof e.status === 'number' ? e.status : null;
@@ -3,14 +3,16 @@
3
3
  * standing in the organization's virtual office, what moving up takes, and the
4
4
  * field guide of species to climb through.
5
5
  *
6
- * The statusline chip says `Pro member-1a2b3c4d acmeco 종합 점수 12명 중 3위
7
- * 🦊 여우` and no more. This answers the questions that chip raises: how many
8
- * people stand ahead, whether the rank is earned by spending more tokens or by
9
- * using them better, which species is next and what the whole ladder looks
10
- * like. The score adds the spend rank and the delegation-share rank (and the
11
- * prompt-count rank where prompt capture is on), so the spend rank rises with
12
- * more tokens and the delegation rank rises by handing a larger share of the
13
- * same spend to cheaper models. The species follow the score's percentile
6
+ * The statusline chip says `Pro member-1a2b3c4d acmeco 11월 종합 점수 12명 중
7
+ * 3위 🦊 여우` and no more (the standing covers the current calendar month, so
8
+ * the month leads the rank). This answers the questions that chip raises: how
9
+ * many people stand ahead, whether the rank is earned by spending more tokens
10
+ * or by using them better, which species is next and what the whole ladder
11
+ * looks like. The score adds the spend rank and the delegation-share rank (and
12
+ * the prompt-count rank where prompt capture is on), so the spend rank rises
13
+ * with more tokens and the delegation rank rises with the share of savings
14
+ * that delegation brings, counted since the machine joined (saved ÷ (spend +
15
+ * saved)). The species follow the score's percentile
14
16
  * (GRADES in office-species.js), and the six species from the wolf up also
15
17
  * need the delegation share at or above the company median.
16
18
  *
@@ -95,6 +97,30 @@ export function nextOf(st, sr = scorePctOf(st)) {
95
97
  return { grade: up.key, pass: Math.max(0, Math.ceil((up.minSr - sr) / span * (st.ranked - 1) - 1e-6)), needDlg: up.needDlg && !dlgOk };
96
98
  }
97
99
 
100
+ const MONTHS_EN = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
101
+
102
+ /**
103
+ * The month the standing covers when its period is one calendar month so far:
104
+ * `rangeFrom` is the 1st of a month and `rangeTo` a valid date in that same
105
+ * year and month. Korean `11월`, English `Nov` (a fixed table, no locale
106
+ * dependency). Null for any other period (a rolling window such as
107
+ * 2026-10-09..2026-11-07), a missing field or an impossible month.
108
+ * @param {{ rangeFrom?: string|null, rangeTo?: string|null }|null|undefined} st
109
+ * @param {'ko'|'en'} [lang]
110
+ * @returns {string|null}
111
+ */
112
+ export function rankMonthLabel(st, lang = 'en') {
113
+ if (!st || typeof st !== 'object') return null;
114
+ const from = typeof st.rangeFrom === 'string' ? /^(\d{4})-(\d{2})-01$/.exec(st.rangeFrom) : null;
115
+ const to = typeof st.rangeTo === 'string' ? /^(\d{4})-(\d{2})-(\d{2})$/.exec(st.rangeTo) : null;
116
+ if (!from || !to) return null;
117
+ const month = Number(from[2]);
118
+ if (month < 1 || month > 12 || from[1] !== to[1] || from[2] !== to[2]) return null;
119
+ const day = Number(to[3]);
120
+ if (day < 1 || day > new Date(Date.UTC(Number(to[1]), month, 0)).getUTCDate()) return null;
121
+ return lang === 'ko' ? `${month}월` : MONTHS_EN[month - 1];
122
+ }
123
+
98
124
  /**
99
125
  * @param {object|null|undefined} st team.json `standing`
100
126
  * @param {{ lang?: 'ko'|'en', org?: string|null }} [opts]
@@ -124,9 +150,10 @@ export function standingGuideLines(st, { lang = 'en', org = null, team = null }
124
150
  return lines;
125
151
  }
126
152
 
153
+ const month = rankMonthLabel(st, lang);
127
154
  lines.push(ko
128
- ? `순위: ${where}종합 점수 ${st.ranked}명 중 ${st.rank}위${teamPlace} · ${animal}${period}`
129
- : `Standing: ${where}overall score #${st.rank} of ${st.ranked}${teamPlace} · ${animal}${period}`);
155
+ ? `순위: ${where}${month ? `${month} ` : ''}종합 점수 ${st.ranked}명 중 ${st.rank}위${teamPlace} · ${animal}${period}`
156
+ : `Standing: ${where}${month ? `${month} ` : ''}overall score #${st.rank} of ${st.ranked}${teamPlace} · ${animal}${period}`);
130
157
 
131
158
  // Where that rank puts you: the people ahead, or the crown.
132
159
  if (st.crown) {
@@ -159,8 +186,8 @@ export function standingGuideLines(st, { lang = 'en', org = null, team = null }
159
186
  : ' The overall score adds the spend rank (62.5%) and the delegation-share rank (37.5%). An Enterprise organization with prompt capture on uses 50%, 30% and 20%, with the prompt-count rank as the third.');
160
187
  }
161
188
  lines.push(ko
162
- ? ` 지출 순위는 토큰을 더 써야 오르고 위임 비율 순위는 같은 지출에서 싼 모델에 맡기는 몫을 늘려야 오릅니다. ${speciesLabel('wolf', 'ko', { emoji: false })} 이상 여섯 종은 위임 비율이 회사 중앙값 이상이어야 합니다.`
163
- : ` The spend rank rises with more tokens; the delegation rank rises by handing a larger share of the same spend to cheaper models. The six species from ${speciesLabel('wolf', 'en', { emoji: false })} up also need a delegation share at or above the company median.`);
189
+ ? ` 지출 순위는 토큰을 더 써야 오르고 위임 비율 순위는 위임이 낸 절감의 몫이 커져야 오릅니다. 이 몫은 설치한 뒤부터 센 절감액 ÷ (지출 + 절감액)입니다. ${speciesLabel('wolf', 'ko', { emoji: false })} 이상 여섯 종은 위임 비율이 회사 중앙값 이상이어야 합니다.`
190
+ : ` The spend rank rises with more tokens; the delegation rank rises with the share of savings that delegation brings, counted since this machine joined (saved ÷ (spend + saved)). The six species from ${speciesLabel('wolf', 'en', { emoji: false })} up also need a delegation share at or above the company median.`);
164
191
 
165
192
  // The caller's own figures, when the server sent them.
166
193
  if (has(st.dlg) || has(st.spent) || has(st.scorePct)) {
package/src/team-sync.js CHANGED
@@ -715,7 +715,7 @@ const DARWIN_TO_MACOS = { 20: '11', 21: '12', 22: '13', 23: '14', 24: '15', 25:
715
715
 
716
716
  export function deviceInfo({
717
717
  platform = process.platform, release = osRelease(),
718
- exec = (cmd, args) => execFileSync(cmd, args, { timeout: 2000, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }),
718
+ exec = (cmd, args) => execFileSync(cmd, args, { timeout: 2000, encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true }),
719
719
  readText = (f) => readFileSync(f, 'utf8'),
720
720
  } = {}) {
721
721
  let os = String(platform);
@@ -80,7 +80,7 @@ async function* zstdLines(filePath) {
80
80
 
81
81
  // Node before 22.15 has no zstd in zlib; the binary is the only way to read these files there.
82
82
  async function* zstdBinaryLines(filePath) {
83
- const child = spawn('zstd', ['-dc', '--', filePath], { stdio: ['ignore', 'pipe', 'ignore'] });
83
+ const child = spawn('zstd', ['-dc', '--', filePath], { stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true });
84
84
  // Registered before any await, so a very fast exit cannot slip past it.
85
85
  const closed = new Promise((resolve) => child.once('close', (code) => resolve(code)));
86
86
  // A missing binary reports through 'error', not through stdout, so settle that first.