@bakapiano/ccsm 0.20.2 → 0.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/server.js CHANGED
@@ -222,7 +222,7 @@ function pickCli(cfg, requestedId) {
222
222
  // 'direct' — pty.spawn(command, args). Real .exe / absolute paths only.
223
223
  // Won't find pwsh aliases / functions.
224
224
  // 'pwsh' — wrap in `pwsh.exe -NoLogo -NoExit -Command "& { cmd args }"`.
225
- // Loads $PROFILE → pwsh aliases / functions (`ccp`, `cxp`) work.
225
+ // Loads $PROFILE → pwsh aliases / functions work.
226
226
  // Falls back to powershell.exe (5.x) if pwsh.exe absent.
227
227
  // 'cmd' — wrap in `cmd.exe /d /s /c "cmd args"`. Resolves doskey aliases
228
228
  // and PATH-only names without pwsh dependency.
@@ -291,15 +291,32 @@ function spawnCliSession({ cli, cwd, sessionId, meta, extraArgs = [] }) {
291
291
  // extraArgs into the single quoted command string — otherwise extraArgs
292
292
  // would become args to the shell itself, not the wrapped command.
293
293
  // Re-resolve here when extraArgs is present so the quoting is correct.
294
+ // Force a session-scoped theme=auto for claude so its syntax/diff colours
295
+ // follow the ccsm terminal background (which we report via OSC 10/11 in
296
+ // TerminalView). claude's DEFAULT theme is *dark*, whose near-white tokens
297
+ // (comments, f-string interpolations, call names) vanish on our light
298
+ // terminal — the "字体颜色和背景重复" bug. --settings is session-scoped, so
299
+ // the user's global ~/.claude/settings.json is left untouched, and ccsm
300
+ // sessions Just Work on a fresh machine without anyone running /theme auto.
301
+ // (Injected here as an integration arg, like --session-id — not via the
302
+ // user-editable cli.args, so it reaches existing configs too.)
303
+ // Skip the injection entirely if the user already put their own --settings
304
+ // in cli.args — claude deep-merges multiple --settings (verified: later ones
305
+ // win per-key), so ours would silently override a theme they set on purpose.
306
+ // Respect the user's explicit choice instead.
307
+ const userHasSettings = (cli.args || []).some(
308
+ (a) => a === '--settings' || String(a).startsWith('--settings='));
309
+ const baseArgs = [...(cli.args || [])];
310
+ if (cli.type === 'claude' && !userHasSettings) baseArgs.push('--settings', '{"theme":"auto"}');
294
311
  const resolved = resolveCommand(
295
312
  cli.command,
296
- [...(cli.args || []), ...extraArgs],
313
+ [...baseArgs, ...extraArgs],
297
314
  cli.shell || 'direct',
298
315
  );
299
316
  const { exe, prefixArgs, fallbackExe, consumesUserArgs } = resolved;
300
317
  const args = consumesUserArgs
301
318
  ? prefixArgs
302
- : [...prefixArgs, ...(cli.args || []), ...extraArgs];
319
+ : [...prefixArgs, ...baseArgs, ...extraArgs];
303
320
  // Merge user-scope PATH from registry into the env we hand the PTY.
304
321
  // spawnEnv() also strips duplicate path-case keys so our override
305
322
  // doesn't get shadowed by the inherited `Path` from process.env.