@rse/claudex 0.9.23 → 1.0.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/AGENTS.md CHANGED
@@ -21,98 +21,21 @@ The project is written in TypeScript and built via the `stx` task runner (config
21
21
 
22
22
  There are no tests in this repository.
23
23
 
24
- The compiled `claudex.js` is the published entry point (`bin.claudex` in `package.json`); the
25
- POSIX-sh `claudex` script next to it is a thin launcher that `exec node claudex.js "$@"`.
26
- A second tiny shell script `claude` simply `exec claudex "$@"` (prepending `$CLAUDEX_BASEDIR`
27
- to `$PATH` if set), so users can transparently substitute `claudex` for `claude`.
24
+ The compiled `claudex.js` is the published entry point (`bin.claudex`
25
+ in `package.json`); the POSIX-sh `claudex` script next to it is a thin
26
+ launcher that `exec node claudex.js "$@"`. A second tiny shell script
27
+ `claude` simply `exec claudex "$@"` (prepending `$CLAUDEX_BASEDIR` to
28
+ `$PATH` if set), so users can transparently substitute `claudex` for
29
+ `claude`.
28
30
 
29
31
  ## Architecture
30
32
 
31
- The entire program is a single file, `claudex.ts`. Dispatch is driven by `commander` in
32
- `main()`, which defines a small command surface:
33
+ The entire program is a single file, `claudex.ts`. Dispatch is driven
34
+ by `commander` in `main()`, which defines a small command surface.
35
+ `claudex` re-invokes itself extensively (tmux `bind-key` strings,
36
+ container `docker exec` strings, sub-action chaining). Self-invocation
37
+ uses `node claudex.js` directly via `selfPathJS = <basedir>/claudex.js`
38
+ plus `process.execPath`, not the POSIX-sh `claudex` launcher &mdash;
39
+ this avoids a shell layer and keeps argv handling consistent across
40
+ platforms.
33
41
 
34
- ### Top-level invocation (default action: run Claude Code)
35
-
36
- `claudex [-C] [-T [session]] [-R] [-A] [<claude-args>...]` &mdash; the default action runs
37
- Claude Code, optionally wrapped by Capsula and/or tmux, optionally recolored, optionally
38
- ASE-augmented. Top-level flags:
39
-
40
- - `-C, --capsula` &mdash; run inside a per-user/per-session Capsula Docker container
41
- (`capsula-${USER}-debian-claude-${session}`).
42
- - `-T, --tmux [session]` &mdash; wrap in a tmux session (auto-detected name, or explicit
43
- `[session]`). Session name is auto-detected by walking up to find `AGENTS.md` /
44
- `CLAUDE.md`; otherwise the cwd basename is used.
45
- - `-R, --recolor` &mdash; pipe Claude Code through `ansi-recolor` using `ansi-recolor.conf`.
46
- - `-A, --ase` &mdash; enable ASE statusline and auto-derive `ASE_TERM_WIDTH` /
47
- `ASE_TERM_COLORS` from the TTY for ASE diagram rendering.
48
-
49
- Top-level `-h/--help` is intercepted before commander, passed through to `claude --help`,
50
- and then the claudeX extension flags are appended to the help output.
51
-
52
- In the default action the `claude` invocation:
53
-
54
- - Prepends `$HOME/.local/bin` to `$PATH` (where `claude` is installed by the official installer).
55
- - Injects a generated `--settings` JSON (telemetry/auto-update/bug/error-reporting disabled,
56
- spinner verbs replaced; with `-A` adds an `ase statusline` command; with `-T` enables
57
- experimental agent teams + `teammateMode: tmux` + `tmuxSplitPanes`).
58
- - If `CLAUDE_MODEL=ollama:[//host[:port]]/<model>[?context=,capabilities=]` is set, rewrites
59
- `ANTHROPIC_*` env vars (base URL, auth token "ollama", default Haiku/Opus/Sonnet model,
60
- capabilities, auto-compact window) to point at a local Ollama server.
61
-
62
- ### Subcommands
63
-
64
- - `install` &mdash; install host-side deps (tmux, lazygit, git, node, ansi-recolor,
65
- typescript-language-server, claude) via the platform's package manager (winget/choco on
66
- Windows, MacPorts/Homebrew on macOS, apt/apk on Linux), OR the in-container deps when
67
- `-C` is passed (Debian apt + Node.js + claude installer + the `claude` wrapper into
68
- `/usr/bin/claude`).
69
- - `update` &mdash; update those same components.
70
- - `internal <util> [args...]` &mdash; internal sub-dispatch, used by re-entrant
71
- self-invocation (tmux bind-keys, container `docker exec` strings, etc.). Utilities:
72
- - `internal tmux <tmux-args>` &mdash; spawn `tmux -f <generated-conf>` using `tmux.conf`
73
- with `@CLAUDEX@` substituted to `node /path/to/claudex.js` and `@CLAUDEX_FLAGS_PASSTHROUGH@`
74
- substituted to the propagated pass-through flags. Bind-keys: `c`/`|`/`-` (new claude
75
- pane), `g` (lazygit popup), `b` (bash/shell popup), `q` (ASE task-edit popup).
76
- - `internal shell [args...]` &mdash; spawn an interactive login shell
77
- (`$SHELL -l ...` on POSIX; PowerShell or `$ComSpec` on Windows).
78
- - `internal ase-task-edit` &mdash; read `#{@ase_task_id}` from the current tmux pane and
79
- run `ase task edit <tid>`.
80
- - `internal lazygit [args...]` &mdash; spawn `lazygit -ucf lazygit.yaml`, optionally
81
- wrapped by `ansi-recolor` when `-R` is in effect.
82
- - `internal capsula [args...]` &mdash; spawn `capsula -c claude -t debian -P linux/arm64`
83
- with the curated env-var allowlist (`TERM`, `HOME`, `CLAUDE_MODEL`, `CLAUDEX`),
84
- dotfile mount list (`.bashrc`, `.gitconfig`, `.ssh/*`, `.vimrc`, `.tmux.conf`,
85
- `.claude*`, `.dotfiles/*`, etc.), `.env`-file null-mounts (walked up from cwd), and
86
- `-b basedir`.
87
-
88
- ### Self-invocation
89
-
90
- `claudex` re-invokes itself extensively (tmux `bind-key` strings, container `docker exec`
91
- strings, sub-action chaining). Self-invocation uses `node claudex.js` directly via
92
- `selfPathJS = <basedir>/claudex.js` plus `process.execPath`, not the POSIX-sh `claudex`
93
- launcher &mdash; this avoids a shell layer and keeps argv handling consistent across
94
- platforms. Inside tmux bind-key strings the same `node /path/to/claudex.js` form is
95
- substituted into `tmux.conf` via the `@CLAUDEX@` placeholder.
96
-
97
- ### Flag propagation
98
-
99
- The pass-through flags `-R` and `-A` are propagated to spawned tmux panes via the
100
- `CLAUDEX_FLAGS_PASSTHROUGH` env var so new claude panes inherit the user's choice.
101
- `-C` and `-T` are deliberately NOT propagated (they are consumed at the outer layer to
102
- avoid recursive container/tmux nesting).
103
-
104
- The `CLAUDEX_FLAGS` env var lets users set default top-level flags (`-R`/`-C`/`-T`/`-A`);
105
- they are merged with command-line flags (env first, command-line second; already-present
106
- flags are not duplicated). This merge is skipped for the `internal` sub-dispatch.
107
-
108
- ### Sandbox detection
109
-
110
- Inside the Capsula container, `ENVIRONMENT=capsula` is set; commands that must not run
111
- in-container (`install`/`update` non-capsula path, the default action with `-C` or `-T`,
112
- and `internal capsula`) check this and `fatal()` early.
113
-
114
- ### Claude Code version pruning
115
-
116
- After a successful install/update, `pruneClaudeVersions()` removes all but the currently
117
- active version under `~/.local/share/claude/versions` (active version is detected by
118
- running the installed `claude --version`).
package/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@
2
2
  ChangeLog
3
3
  =========
4
4
 
5
+ 1.0.0 (2026-05-10)
6
+ ------------------
7
+
8
+ - IMPROVEMENT: install also ASE (@rse/ase)
9
+ - IMPROVEMENT: add "claude stats" functionality, based on CodeBurn tool
10
+ - CLEANUP: provide ASE specific Tmux config only under global option -A
11
+ - CLEANUP: refactoring for using the global options in all internal commands
12
+ - CLEANUP: update AGENTS.md file to reflect all changes to claudex.ts
13
+
14
+ 0.9.24 (2026-05-10)
15
+ -------------------
16
+
17
+ - BUGFIX: further Windows workarounds related to tmux configuration
18
+ - CLEANUP: make ESLint happy
19
+ - REFACTOR: simplify `tmux.conf` patching by overwriting entries
20
+
5
21
  0.9.23 (2026-05-10)
6
22
  -------------------
7
23
 
package/claudex.js CHANGED
@@ -268,6 +268,10 @@ const actionInstall = async (capsula) => {
268
268
  await self("internal", "capsula", "sudo", "-E", "npm", "install", "-y", "-g", "ansi-recolor");
269
269
  info("install TypeScript LS");
270
270
  await self("internal", "capsula", "sudo", "-E", "npm", "install", "-y", "-g", "typescript-language-server");
271
+ info("install CodeBurn");
272
+ await self("internal", "capsula", "sudo", "-E", "npm", "install", "-y", "-g", "codeburn");
273
+ info("install ASE");
274
+ await self("internal", "capsula", "sudo", "-E", "npm", "install", "-y", "-g", "@rse/ase");
271
275
  info("install Claude wrapper");
272
276
  await self("internal", "capsula", "sudo", "install", "-c", "-m", "755", `${basedir}/claude`, "/usr/bin/claude");
273
277
  /* prune obsolete versions only after successful install */
@@ -349,6 +353,24 @@ const actionInstall = async (capsula) => {
349
353
  "linux:*": "sudo npm install -g typescript-language-server"
350
354
  }
351
355
  });
356
+ info("install CodeBurn");
357
+ ensureTool("codeburn", {
358
+ hint: "https://www.npmjs.com/package/codeburn",
359
+ install: {
360
+ "windows:*": "npm install -g codeburn",
361
+ "macos:*": "sudo npm install -g codeburn",
362
+ "linux:*": "sudo npm install -g codeburn"
363
+ }
364
+ });
365
+ info("install ASE");
366
+ ensureTool("ase", {
367
+ hint: "https://ase.tools",
368
+ install: {
369
+ "windows:*": "npm install -g @rse/ase",
370
+ "macos:*": "sudo npm install -g @rse/ase",
371
+ "linux:*": "sudo npm install -g @rse/ase"
372
+ }
373
+ });
352
374
  info("install Claude Code");
353
375
  if (process.platform !== "win32") {
354
376
  /* run installation script */
@@ -397,6 +419,10 @@ const actionUpdate = async (capsula) => {
397
419
  await self("internal", "capsula", "sudo", "-E", "npm", "install", "-y", "-g", "ansi-recolor");
398
420
  info("update TypeScript LS");
399
421
  await self("internal", "capsula", "sudo", "-E", "npm", "install", "-y", "-g", "typescript-language-server");
422
+ info("update CodeBurn");
423
+ await self("internal", "capsula", "sudo", "-E", "npm", "install", "-y", "-g", "codeburn");
424
+ info("update ASE");
425
+ await self("internal", "capsula", "sudo", "-E", "npm", "install", "-y", "-g", "@rse/ase");
400
426
  info("update Claude wrapper");
401
427
  await self("internal", "capsula", "sudo", "install", "-c", "-m", "755", `${basedir}/claude`, "/usr/bin/claude");
402
428
  }
@@ -449,6 +475,18 @@ const actionUpdate = async (capsula) => {
449
475
  "macos:*": "sudo npm install -g typescript-language-server",
450
476
  "linux:*": "sudo npm install -g typescript-language-server"
451
477
  });
478
+ info("update CodeBurn");
479
+ executeCommand({
480
+ "windows:*": "npm install -g codeburn",
481
+ "macos:*": "sudo npm install -g codeburn",
482
+ "linux:*": "sudo npm install -g codeburn"
483
+ });
484
+ info("update ASE");
485
+ executeCommand({
486
+ "windows:*": "npm install -g @rse/ase",
487
+ "macos:*": "sudo npm install -g @rse/ase",
488
+ "linux:*": "sudo npm install -g @rse/ase"
489
+ });
452
490
  info("update Claude Code");
453
491
  if (process.platform !== "win32") {
454
492
  ensureTool("bash");
@@ -476,21 +514,33 @@ const actionUpdate = async (capsula) => {
476
514
  (e.g. "-R") are propagated to those panes via the CLAUDEX_FLAGS env var
477
515
  (set by actionDefault when entering tmux mode), which the env-merge in
478
516
  main() picks up. */
479
- const actionInternalTmux = (args) => {
517
+ const actionInternalTmux = (opts, args) => {
480
518
  ensureTool("tmux");
481
519
  let conf = fs.readFileSync(path.join(basedir, "tmux.conf"), "utf8");
482
- conf = conf.replace(/@USER@/g, USER);
520
+ if (opts.ase) {
521
+ /* ASE-specific bind-keys (only when "-A" is in effect) */
522
+ conf +=
523
+ "bind-key q display-popup -E -w 95% -h 95% -T \"─◀#[reverse] ⧉ Task Edit (ase task edit) #[noreverse]▶\" claudex internal ase-task-edit\n" +
524
+ "bind-key t send-keys \"/ase:ase-meta-task \"\n" +
525
+ "bind-key p send-keys \"/ase:ase-meta-persona \"\n";
526
+ }
483
527
  if (isPsmux()) {
484
528
  /* psmux does not honor the reverse ANSI sequence in at least the statusline
485
- and no expansions at all in the pane border format */
486
- conf = conf.replace(/fg=default,bg=default,reverse/, "bg=black,fg=color15")
487
- .replaceAll(/(status.*?)fg=blue,reverse/g, "$1bg=blue,fg=color15")
488
- .replaceAll(/(status.*?)fg=blue/g, "$1bg=blue,fg=color15")
489
- .replaceAll(/(status.*?)fg=red/g, "$1bg=red,fg=color15")
490
- .replaceAll(/(status.*?)fg=default/g, "$1bg=black,fg=color15")
491
- .replaceAll(/#\[reverse\]/g, "")
492
- .replaceAll(/#\[noreverse\]/g, "");
529
+ and not some expansions in the pane border format */
530
+ conf +=
531
+ "set-option -g status-style bg=black,fg=color15\n" +
532
+ "set-option -g status-left \" claudeX #[bg=blue,fg=color15] ※ @USER@ #[bg=black,fg=color15] #{?session_attached,#[bg=red,fg=color15] ⚑ #{session_name} #[bg=black,fg=color15],}\"\n" +
533
+ "set-option -g window-status-current-style bg=red,fg=color15\n" +
534
+ "set-option -g window-status-bell-style bg=blue,fg=color15\n" +
535
+ "set-option -g window-status-activity-style bg=blue,fg=color15\n" +
536
+ "set-option -g message-style bg=blue,fg=color15\n" +
537
+ "set-hook -g -u pane-exited\n" +
538
+ "set-hook -g -u after-split-window\n" +
539
+ "bind-key g display-popup -E -w 95% -h 95% -T \"─◀( ⧉ Version Control (lazygit) )▶\" claudex internal lazygit\n" +
540
+ "bind-key s display-popup -E -w 95% -h 95% -T \"─◀( ⧉ Shell )▶\" claudex internal shell\n" +
541
+ (opts.ase ? "bind-key q display-popup -E -w 95% -h 95% -T \"─◀( ⧉ Task Edit (ase task edit) )▶\" claudex internal ase-task-edit\n" : "");
493
542
  }
543
+ conf = conf.replace(/@USER@/g, USER);
494
544
  const confFile = path.join(os.tmpdir(), `claudex-tmux-${process.pid}.conf`);
495
545
  fs.writeFileSync(confFile, conf, { mode: 0o600 });
496
546
  /* ensure the temp config is removed on normal exit AND on signal-driven
@@ -518,7 +568,7 @@ const actionInternalTmux = (args) => {
518
568
  return process.exit(r.exitCode ?? 0);
519
569
  };
520
570
  /* action: internal "shell" -- spawn an interactive login shell */
521
- const actionInternalShell = (args) => {
571
+ const actionInternalShell = (_opts, args) => {
522
572
  if (process.platform === "win32") {
523
573
  const shell = process.env.SHELL ?? process.env.ComSpec ?? "powershell";
524
574
  const name = path.basename(shell).toLowerCase().replace(/\.exe$/, "");
@@ -538,7 +588,7 @@ const actionInternalShell = (args) => {
538
588
  }
539
589
  };
540
590
  /* action: internal "ase-task-edit" -- edit the ASE task associated with the current tmux pane */
541
- const actionInternalAseTaskEdit = async () => {
591
+ const actionInternalAseTaskEdit = async (_opts) => {
542
592
  ensureTool("ase");
543
593
  let tid = "";
544
594
  const r1 = execaSync("tmux", ["display-message", "-p", "#{@ase_task_id}"], { reject: false });
@@ -551,11 +601,11 @@ const actionInternalAseTaskEdit = async () => {
551
601
  }
552
602
  };
553
603
  /* action: internal "lazygit" -- spawn lazygit (optionally recolored) */
554
- const actionInternalLazygit = (recolor, args) => {
604
+ const actionInternalLazygit = (opts, args) => {
555
605
  ensureTool("git");
556
606
  ensureTool("lazygit");
557
607
  const env = { ...process.env, TERM: "xterm-color" };
558
- if (recolor) {
608
+ if (opts.recolor) {
559
609
  ensureTool("ansi-recolor");
560
610
  return execInherit("ansi-recolor", [
561
611
  "-c", path.join(basedir, "ansi-recolor.conf"),
@@ -572,7 +622,7 @@ const actionInternalLazygit = (recolor, args) => {
572
622
  ], { env });
573
623
  };
574
624
  /* action: internal "capsula" -- enter/start a Capsula container with the curated env-var/dotfile setup */
575
- const actionInternalCapsula = (args) => {
625
+ const actionInternalCapsula = (_opts, args) => {
576
626
  /* sanity check environment */
577
627
  ensureTool("capsula");
578
628
  if (ENVIRONMENT === "capsula")
@@ -649,7 +699,7 @@ const actionInternalCapsula = (args) => {
649
699
  Windows tmux) that mishandle quoting when a command is passed via "tmux
650
700
  new-session" as multiple trailing argv items: we instead pass the whole
651
701
  command as a single env-var value. */
652
- const actionInternalExec = () => {
702
+ const actionInternalExec = (_opts) => {
653
703
  const cmdline = process.env.CLAUDEX_INTERNAL_EXEC ?? "";
654
704
  if (cmdline === "")
655
705
  fatal("CLAUDEX_INTERNAL_EXEC environment variable is empty or unset");
@@ -666,17 +716,22 @@ const actionInternalExec = () => {
666
716
  const [file, ...rest] = argv;
667
717
  return execInherit(file, rest);
668
718
  };
719
+ /* action: "stats" -- show Claude Code usage statistics via codeburn */
720
+ const actionStats = async (args) => {
721
+ ensureTool("codeburn", { hint: "run \"claudex install\" or \"claudex update\" first" });
722
+ return execInherit("codeburn", ["report", "--provider", "claude", "--period", "30days", ...args]);
723
+ };
669
724
  /* action: internal sub-dispatch (tmux, shell, ase-task-edit, lazygit, capsula, exec) */
670
725
  const actionInternal = async (opts, args) => {
671
726
  const util = args[0];
672
727
  const rest = args.slice(1);
673
728
  switch (util) {
674
- case "tmux": return actionInternalTmux(rest);
675
- case "shell": return actionInternalShell(rest);
676
- case "ase-task-edit": return actionInternalAseTaskEdit();
677
- case "lazygit": return actionInternalLazygit(opts.recolor === true, rest);
678
- case "capsula": return actionInternalCapsula(rest);
679
- case "exec": return actionInternalExec();
729
+ case "tmux": return actionInternalTmux(opts, rest);
730
+ case "shell": return actionInternalShell(opts, rest);
731
+ case "ase-task-edit": return actionInternalAseTaskEdit(opts);
732
+ case "lazygit": return actionInternalLazygit(opts, rest);
733
+ case "capsula": return actionInternalCapsula(opts, rest);
734
+ case "exec": return actionInternalExec(opts);
680
735
  default:
681
736
  fatal(`invalid internal command "${util ?? ""}"`);
682
737
  }
@@ -727,7 +782,7 @@ const actionDefault = (opts, args) => {
727
782
  `CLAUDEX_FLAGS=${shQ.quote([claudexFlags])} ` +
728
783
  `sudo -E -u ${shQ.quote([USER])} ` +
729
784
  `${shQ.quote([process.execPath, selfPathJS])} ` +
730
- `internal tmux new-session -A -s ${shQ.quote([session])}`
785
+ `${opts.ase ? "-A " : ""}internal tmux new-session -A -s ${shQ.quote([session])}`
731
786
  ]);
732
787
  }
733
788
  else {
@@ -736,7 +791,8 @@ const actionDefault = (opts, args) => {
736
791
  selfPathJS, "internal", "capsula",
737
792
  "-e", `CLAUDEX_FLAGS=${claudexFlags}`,
738
793
  "-e", `CLAUDEX_INTERNAL_EXEC=${inPane}`,
739
- "-C", container, process.execPath, selfPathJS, "internal", "tmux",
794
+ "-C", container, process.execPath, selfPathJS,
795
+ ...(opts.ase ? ["-A"] : []), "internal", "tmux",
740
796
  "new-session", "-A", "-s", session, "-n", "claude",
741
797
  "claudex", "internal", "exec"
742
798
  ]);
@@ -746,7 +802,7 @@ const actionDefault = (opts, args) => {
746
802
  /* enter/start plain tmux */
747
803
  return execInherit(process.execPath, [
748
804
  selfPathJS,
749
- "internal", "tmux",
805
+ ...(opts.ase ? ["-A"] : []), "internal", "tmux",
750
806
  "new-session", "-A", "-s", session, "-n", "claude",
751
807
  "claudex", "internal", "exec"
752
808
  ], {
@@ -948,6 +1004,7 @@ const actionHelp = () => {
948
1004
  "claudeX extension subcommands (honored before claude):\n" +
949
1005
  " install install host-side or in-container dependencies\n" +
950
1006
  " update update host-side or in-container dependencies\n" +
1007
+ " stats show Claude Code usage statistics\n" +
951
1008
  " internal … internal command dispatcher (internal use only)\n");
952
1009
  process.exit(0);
953
1010
  };
@@ -1030,6 +1087,16 @@ const main = async () => {
1030
1087
  const capsula = cmd.parent?.opts().capsula === true;
1031
1088
  await actionUpdate(capsula);
1032
1089
  });
1090
+ /* dispatch "stats" sub-command */
1091
+ program
1092
+ .command("stats")
1093
+ .description("show Claude Code usage statistics")
1094
+ .helpOption("-h, --help", "display help for command")
1095
+ .allowUnknownOption()
1096
+ .argument("[args...]", "additional arguments passed to codeburn")
1097
+ .action(async (args) => {
1098
+ await actionStats(args);
1099
+ });
1033
1100
  /* dispatch "internal" sub-command */
1034
1101
  program
1035
1102
  .command("internal")
package/claudex.ts CHANGED
@@ -310,6 +310,12 @@ const actionInstall = async (capsula: boolean): Promise<void> => {
310
310
  info("install TypeScript LS")
311
311
  await self("internal", "capsula", "sudo", "-E", "npm", "install", "-y", "-g", "typescript-language-server")
312
312
 
313
+ info("install CodeBurn")
314
+ await self("internal", "capsula", "sudo", "-E", "npm", "install", "-y", "-g", "codeburn")
315
+
316
+ info("install ASE")
317
+ await self("internal", "capsula", "sudo", "-E", "npm", "install", "-y", "-g", "@rse/ase")
318
+
313
319
  info("install Claude wrapper")
314
320
  await self("internal", "capsula", "sudo", "install", "-c", "-m", "755", `${basedir}/claude`, "/usr/bin/claude")
315
321
 
@@ -401,6 +407,26 @@ const actionInstall = async (capsula: boolean): Promise<void> => {
401
407
  }
402
408
  })
403
409
 
410
+ info("install CodeBurn")
411
+ ensureTool("codeburn", {
412
+ hint: "https://www.npmjs.com/package/codeburn",
413
+ install: {
414
+ "windows:*": "npm install -g codeburn",
415
+ "macos:*": "sudo npm install -g codeburn",
416
+ "linux:*": "sudo npm install -g codeburn"
417
+ }
418
+ })
419
+
420
+ info("install ASE")
421
+ ensureTool("ase", {
422
+ hint: "https://ase.tools",
423
+ install: {
424
+ "windows:*": "npm install -g @rse/ase",
425
+ "macos:*": "sudo npm install -g @rse/ase",
426
+ "linux:*": "sudo npm install -g @rse/ase"
427
+ }
428
+ })
429
+
404
430
  info("install Claude Code")
405
431
  if (process.platform !== "win32") {
406
432
  /* run installation script */
@@ -459,6 +485,12 @@ const actionUpdate = async (capsula: boolean): Promise<void> => {
459
485
  info("update TypeScript LS")
460
486
  await self("internal", "capsula", "sudo", "-E", "npm", "install", "-y", "-g", "typescript-language-server")
461
487
 
488
+ info("update CodeBurn")
489
+ await self("internal", "capsula", "sudo", "-E", "npm", "install", "-y", "-g", "codeburn")
490
+
491
+ info("update ASE")
492
+ await self("internal", "capsula", "sudo", "-E", "npm", "install", "-y", "-g", "@rse/ase")
493
+
462
494
  info("update Claude wrapper")
463
495
  await self("internal", "capsula", "sudo", "install", "-c", "-m", "755", `${basedir}/claude`, "/usr/bin/claude")
464
496
  }
@@ -517,6 +549,20 @@ const actionUpdate = async (capsula: boolean): Promise<void> => {
517
549
  "linux:*": "sudo npm install -g typescript-language-server"
518
550
  })
519
551
 
552
+ info("update CodeBurn")
553
+ executeCommand({
554
+ "windows:*": "npm install -g codeburn",
555
+ "macos:*": "sudo npm install -g codeburn",
556
+ "linux:*": "sudo npm install -g codeburn"
557
+ })
558
+
559
+ info("update ASE")
560
+ executeCommand({
561
+ "windows:*": "npm install -g @rse/ase",
562
+ "macos:*": "sudo npm install -g @rse/ase",
563
+ "linux:*": "sudo npm install -g @rse/ase"
564
+ })
565
+
520
566
  info("update Claude Code")
521
567
  if (process.platform !== "win32") {
522
568
  ensureTool("bash")
@@ -547,21 +593,33 @@ const actionUpdate = async (capsula: boolean): Promise<void> => {
547
593
  (e.g. "-R") are propagated to those panes via the CLAUDEX_FLAGS env var
548
594
  (set by actionDefault when entering tmux mode), which the env-merge in
549
595
  main() picks up. */
550
- const actionInternalTmux = (args: string[]): never => {
596
+ const actionInternalTmux = (opts: TopOpts, args: string[]): never => {
551
597
  ensureTool("tmux")
552
598
  let conf = fs.readFileSync(path.join(basedir, "tmux.conf"), "utf8")
553
- conf = conf.replace(/@USER@/g, USER)
599
+ if (opts.ase) {
600
+ /* ASE-specific bind-keys (only when "-A" is in effect) */
601
+ conf +=
602
+ "bind-key q display-popup -E -w 95% -h 95% -T \"─◀#[reverse] ⧉ Task Edit (ase task edit) #[noreverse]▶\" claudex internal ase-task-edit\n" +
603
+ "bind-key t send-keys \"/ase:ase-meta-task \"\n" +
604
+ "bind-key p send-keys \"/ase:ase-meta-persona \"\n"
605
+ }
554
606
  if (isPsmux()) {
555
607
  /* psmux does not honor the reverse ANSI sequence in at least the statusline
556
- and no expansions at all in the pane border format */
557
- conf = conf.replace(/fg=default,bg=default,reverse/, "bg=black,fg=color15")
558
- .replaceAll(/(status.*?)fg=blue,reverse/g, "$1bg=blue,fg=color15")
559
- .replaceAll(/(status.*?)fg=blue/g, "$1bg=blue,fg=color15")
560
- .replaceAll(/(status.*?)fg=red/g, "$1bg=red,fg=color15")
561
- .replaceAll(/(status.*?)fg=default/g, "$1bg=black,fg=color15")
562
- .replaceAll(/#\[reverse\]/g, "")
563
- .replaceAll(/#\[noreverse\]/g, "")
608
+ and not some expansions in the pane border format */
609
+ conf +=
610
+ "set-option -g status-style bg=black,fg=color15\n" +
611
+ "set-option -g status-left \" claudeX #[bg=blue,fg=color15] ※ @USER@ #[bg=black,fg=color15] #{?session_attached,#[bg=red,fg=color15] ⚑ #{session_name} #[bg=black,fg=color15],}\"\n" +
612
+ "set-option -g window-status-current-style bg=red,fg=color15\n" +
613
+ "set-option -g window-status-bell-style bg=blue,fg=color15\n" +
614
+ "set-option -g window-status-activity-style bg=blue,fg=color15\n" +
615
+ "set-option -g message-style bg=blue,fg=color15\n" +
616
+ "set-hook -g -u pane-exited\n" +
617
+ "set-hook -g -u after-split-window\n" +
618
+ "bind-key g display-popup -E -w 95% -h 95% -T \"─◀( ⧉ Version Control (lazygit) )▶\" claudex internal lazygit\n" +
619
+ "bind-key s display-popup -E -w 95% -h 95% -T \"─◀( ⧉ Shell )▶\" claudex internal shell\n" +
620
+ (opts.ase ? "bind-key q display-popup -E -w 95% -h 95% -T \"─◀( ⧉ Task Edit (ase task edit) )▶\" claudex internal ase-task-edit\n" : "")
564
621
  }
622
+ conf = conf.replace(/@USER@/g, USER)
565
623
  const confFile = path.join(os.tmpdir(), `claudex-tmux-${process.pid}.conf`)
566
624
  fs.writeFileSync(confFile, conf, { mode: 0o600 })
567
625
  /* ensure the temp config is removed on normal exit AND on signal-driven
@@ -588,7 +646,7 @@ const actionInternalTmux = (args: string[]): never => {
588
646
  }
589
647
 
590
648
  /* action: internal "shell" -- spawn an interactive login shell */
591
- const actionInternalShell = (args: string[]): never => {
649
+ const actionInternalShell = (_opts: TopOpts, args: string[]): never => {
592
650
  if (process.platform === "win32") {
593
651
  const shell = process.env.SHELL ?? process.env.ComSpec ?? "powershell"
594
652
  const name = path.basename(shell).toLowerCase().replace(/\.exe$/, "")
@@ -609,7 +667,7 @@ const actionInternalShell = (args: string[]): never => {
609
667
  }
610
668
 
611
669
  /* action: internal "ase-task-edit" -- edit the ASE task associated with the current tmux pane */
612
- const actionInternalAseTaskEdit = async (): Promise<void> => {
670
+ const actionInternalAseTaskEdit = async (_opts: TopOpts): Promise<void> => {
613
671
  ensureTool("ase")
614
672
  let tid = ""
615
673
  const r1 = execaSync("tmux", [ "display-message", "-p", "#{@ase_task_id}" ], { reject: false })
@@ -623,11 +681,11 @@ const actionInternalAseTaskEdit = async (): Promise<void> => {
623
681
  }
624
682
 
625
683
  /* action: internal "lazygit" -- spawn lazygit (optionally recolored) */
626
- const actionInternalLazygit = (recolor: boolean, args: string[]): never => {
684
+ const actionInternalLazygit = (opts: TopOpts, args: string[]): never => {
627
685
  ensureTool("git")
628
686
  ensureTool("lazygit")
629
687
  const env: Env = { ...process.env, TERM: "xterm-color" }
630
- if (recolor) {
688
+ if (opts.recolor) {
631
689
  ensureTool("ansi-recolor")
632
690
  return execInherit("ansi-recolor", [
633
691
  "-c", path.join(basedir, "ansi-recolor.conf"),
@@ -645,7 +703,7 @@ const actionInternalLazygit = (recolor: boolean, args: string[]): never => {
645
703
  }
646
704
 
647
705
  /* action: internal "capsula" -- enter/start a Capsula container with the curated env-var/dotfile setup */
648
- const actionInternalCapsula = (args: string[]): never => {
706
+ const actionInternalCapsula = (_opts: TopOpts, args: string[]): never => {
649
707
  /* sanity check environment */
650
708
  ensureTool("capsula")
651
709
  if (ENVIRONMENT === "capsula")
@@ -727,7 +785,7 @@ const actionInternalCapsula = (args: string[]): never => {
727
785
  Windows tmux) that mishandle quoting when a command is passed via "tmux
728
786
  new-session" as multiple trailing argv items: we instead pass the whole
729
787
  command as a single env-var value. */
730
- const actionInternalExec = (): never => {
788
+ const actionInternalExec = (_opts: TopOpts): never => {
731
789
  const cmdline = process.env.CLAUDEX_INTERNAL_EXEC ?? ""
732
790
  if (cmdline === "")
733
791
  fatal("CLAUDEX_INTERNAL_EXEC environment variable is empty or unset")
@@ -745,17 +803,23 @@ const actionInternalExec = (): never => {
745
803
  return execInherit(file, rest)
746
804
  }
747
805
 
806
+ /* action: "stats" -- show Claude Code usage statistics via codeburn */
807
+ const actionStats = async (args: string[]): Promise<never> => {
808
+ ensureTool("codeburn", { hint: "run \"claudex install\" or \"claudex update\" first" })
809
+ return execInherit("codeburn", [ "report", "--provider", "claude", "--period", "30days", ...args ])
810
+ }
811
+
748
812
  /* action: internal sub-dispatch (tmux, shell, ase-task-edit, lazygit, capsula, exec) */
749
813
  const actionInternal = async (opts: TopOpts, args: string[]): Promise<void> => {
750
814
  const util = args[0]
751
815
  const rest = args.slice(1)
752
816
  switch (util) {
753
- case "tmux": return actionInternalTmux(rest)
754
- case "shell": return actionInternalShell(rest)
755
- case "ase-task-edit": return actionInternalAseTaskEdit()
756
- case "lazygit": return actionInternalLazygit(opts.recolor === true, rest)
757
- case "capsula": return actionInternalCapsula(rest)
758
- case "exec": return actionInternalExec()
817
+ case "tmux": return actionInternalTmux(opts, rest)
818
+ case "shell": return actionInternalShell(opts, rest)
819
+ case "ase-task-edit": return actionInternalAseTaskEdit(opts)
820
+ case "lazygit": return actionInternalLazygit(opts, rest)
821
+ case "capsula": return actionInternalCapsula(opts, rest)
822
+ case "exec": return actionInternalExec(opts)
759
823
  default:
760
824
  fatal(`invalid internal command "${util ?? ""}"`)
761
825
  }
@@ -813,7 +877,7 @@ const actionDefault = (opts: TopOpts, args: string[]): never => {
813
877
  `CLAUDEX_FLAGS=${shQ.quote([ claudexFlags ])} ` +
814
878
  `sudo -E -u ${shQ.quote([ USER ])} ` +
815
879
  `${shQ.quote([ process.execPath, selfPathJS ])} ` +
816
- `internal tmux new-session -A -s ${shQ.quote([ session ])}`
880
+ `${opts.ase ? "-A " : ""}internal tmux new-session -A -s ${shQ.quote([ session ])}`
817
881
  ])
818
882
  }
819
883
  else {
@@ -822,7 +886,8 @@ const actionDefault = (opts: TopOpts, args: string[]): never => {
822
886
  selfPathJS, "internal", "capsula",
823
887
  "-e", `CLAUDEX_FLAGS=${claudexFlags}`,
824
888
  "-e", `CLAUDEX_INTERNAL_EXEC=${inPane}`,
825
- "-C", container, process.execPath, selfPathJS, "internal", "tmux",
889
+ "-C", container, process.execPath, selfPathJS,
890
+ ...(opts.ase ? [ "-A" ] : []), "internal", "tmux",
826
891
  "new-session", "-A", "-s", session, "-n", "claude",
827
892
  "claudex", "internal", "exec"
828
893
  ])
@@ -832,7 +897,7 @@ const actionDefault = (opts: TopOpts, args: string[]): never => {
832
897
  /* enter/start plain tmux */
833
898
  return execInherit(process.execPath, [
834
899
  selfPathJS,
835
- "internal", "tmux",
900
+ ...(opts.ase ? [ "-A" ] : []), "internal", "tmux",
836
901
  "new-session", "-A", "-s", session, "-n", "claude",
837
902
  "claudex", "internal", "exec"
838
903
  ], {
@@ -1042,6 +1107,7 @@ const actionHelp = (): never => {
1042
1107
  "claudeX extension subcommands (honored before claude):\n" +
1043
1108
  " install install host-side or in-container dependencies\n" +
1044
1109
  " update update host-side or in-container dependencies\n" +
1110
+ " stats show Claude Code usage statistics\n" +
1045
1111
  " internal … internal command dispatcher (internal use only)\n"
1046
1112
  )
1047
1113
  process.exit(0)
@@ -1131,6 +1197,17 @@ const main = async (): Promise<void> => {
1131
1197
  await actionUpdate(capsula)
1132
1198
  })
1133
1199
 
1200
+ /* dispatch "stats" sub-command */
1201
+ program
1202
+ .command("stats")
1203
+ .description("show Claude Code usage statistics")
1204
+ .helpOption("-h, --help", "display help for command")
1205
+ .allowUnknownOption()
1206
+ .argument("[args...]", "additional arguments passed to codeburn")
1207
+ .action(async (args: string[]) => {
1208
+ await actionStats(args)
1209
+ })
1210
+
1134
1211
  /* dispatch "internal" sub-command */
1135
1212
  program
1136
1213
  .command("internal")
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rse/claudex",
3
3
  "publishConfig": { "access": "public" },
4
- "version": "0.9.23",
4
+ "version": "1.0.0",
5
5
  "description": "Claude Code eXtended",
6
6
  "type": "module",
7
7
  "keywords": [ "claude", "code", "extension", "wrapper" ],
package/tmux.conf CHANGED
@@ -199,9 +199,6 @@ set-option -as terminal-overrides ',*:Tc:sitm=\E[3m:ritm=\E[23m'
199
199
  bind-key c new-window -c "#{pane_current_path}" -n claude "claudex"
200
200
  bind-key | split-window -c "#{pane_current_path}" -h "claudex"
201
201
  bind-key - split-window -c "#{pane_current_path}" -v "claudex"
202
- bind-key g display-popup -E -w 95% -h 95% -T "─◀#[reverse] ⧉ Version Control (lazygit) #[noreverse]▶" "claudex internal lazygit"
203
- bind-key s display-popup -E -w 95% -h 95% -T "─◀#[reverse] ⧉ Shell #[noreverse]▶" "claudex internal shell"
204
- bind-key q display-popup -E -w 95% -h 95% -T "─◀#[reverse] ⧉ Task Edit (ase task edit) #[noreverse]▶" "claudex internal ase-task-edit"
205
- bind-key t send-keys "/ase:ase-meta-task "
206
- bind-key p send-keys "/ase:ase-meta-persona "
202
+ bind-key g display-popup -E -w 95% -h 95% -T "─◀#[reverse] ⧉ Version Control (lazygit) #[noreverse]▶" claudex internal lazygit
203
+ bind-key s display-popup -E -w 95% -h 95% -T "─◀#[reverse] ⧉ Shell #[noreverse]▶" claudex internal shell
207
204