@rse/claudex 0.9.24 → 1.0.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/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,20 @@
2
2
  ChangeLog
3
3
  =========
4
4
 
5
+ 1.0.1 (2026-05-10)
6
+ ------------------
7
+
8
+ - BUGFIX: ignore flags in CLAUDEX\_FLAGS for the native Claude Code commands
9
+
10
+ 1.0.0 (2026-05-10)
11
+ ------------------
12
+
13
+ - IMPROVEMENT: install also ASE (@rse/ase)
14
+ - IMPROVEMENT: add "claude stats" functionality, based on CodeBurn tool
15
+ - CLEANUP: provide ASE specific Tmux config only under global option -A
16
+ - CLEANUP: refactoring for using the global options in all internal commands
17
+ - CLEANUP: update AGENTS.md file to reflect all changes to claudex.ts
18
+
5
19
  0.9.24 (2026-05-10)
6
20
  -------------------
7
21
 
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,9 +514,16 @@ 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");
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
+ }
482
527
  if (isPsmux()) {
483
528
  /* psmux does not honor the reverse ANSI sequence in at least the statusline
484
529
  and not some expansions in the pane border format */
@@ -493,7 +538,7 @@ const actionInternalTmux = (args) => {
493
538
  "set-hook -g -u after-split-window\n" +
494
539
  "bind-key g display-popup -E -w 95% -h 95% -T \"─◀( ⧉ Version Control (lazygit) )▶\" claudex internal lazygit\n" +
495
540
  "bind-key s display-popup -E -w 95% -h 95% -T \"─◀( ⧉ Shell )▶\" claudex internal shell\n" +
496
- "bind-key q display-popup -E -w 95% -h 95% -T \"─◀( ⧉ Task Edit (ase task edit) )▶\" claudex internal ase-task-edit\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" : "");
497
542
  }
498
543
  conf = conf.replace(/@USER@/g, USER);
499
544
  const confFile = path.join(os.tmpdir(), `claudex-tmux-${process.pid}.conf`);
@@ -523,7 +568,7 @@ const actionInternalTmux = (args) => {
523
568
  return process.exit(r.exitCode ?? 0);
524
569
  };
525
570
  /* action: internal "shell" -- spawn an interactive login shell */
526
- const actionInternalShell = (args) => {
571
+ const actionInternalShell = (_opts, args) => {
527
572
  if (process.platform === "win32") {
528
573
  const shell = process.env.SHELL ?? process.env.ComSpec ?? "powershell";
529
574
  const name = path.basename(shell).toLowerCase().replace(/\.exe$/, "");
@@ -543,7 +588,7 @@ const actionInternalShell = (args) => {
543
588
  }
544
589
  };
545
590
  /* action: internal "ase-task-edit" -- edit the ASE task associated with the current tmux pane */
546
- const actionInternalAseTaskEdit = async () => {
591
+ const actionInternalAseTaskEdit = async (_opts) => {
547
592
  ensureTool("ase");
548
593
  let tid = "";
549
594
  const r1 = execaSync("tmux", ["display-message", "-p", "#{@ase_task_id}"], { reject: false });
@@ -556,11 +601,11 @@ const actionInternalAseTaskEdit = async () => {
556
601
  }
557
602
  };
558
603
  /* action: internal "lazygit" -- spawn lazygit (optionally recolored) */
559
- const actionInternalLazygit = (recolor, args) => {
604
+ const actionInternalLazygit = (opts, args) => {
560
605
  ensureTool("git");
561
606
  ensureTool("lazygit");
562
607
  const env = { ...process.env, TERM: "xterm-color" };
563
- if (recolor) {
608
+ if (opts.recolor) {
564
609
  ensureTool("ansi-recolor");
565
610
  return execInherit("ansi-recolor", [
566
611
  "-c", path.join(basedir, "ansi-recolor.conf"),
@@ -577,7 +622,7 @@ const actionInternalLazygit = (recolor, args) => {
577
622
  ], { env });
578
623
  };
579
624
  /* action: internal "capsula" -- enter/start a Capsula container with the curated env-var/dotfile setup */
580
- const actionInternalCapsula = (args) => {
625
+ const actionInternalCapsula = (_opts, args) => {
581
626
  /* sanity check environment */
582
627
  ensureTool("capsula");
583
628
  if (ENVIRONMENT === "capsula")
@@ -654,7 +699,7 @@ const actionInternalCapsula = (args) => {
654
699
  Windows tmux) that mishandle quoting when a command is passed via "tmux
655
700
  new-session" as multiple trailing argv items: we instead pass the whole
656
701
  command as a single env-var value. */
657
- const actionInternalExec = () => {
702
+ const actionInternalExec = (_opts) => {
658
703
  const cmdline = process.env.CLAUDEX_INTERNAL_EXEC ?? "";
659
704
  if (cmdline === "")
660
705
  fatal("CLAUDEX_INTERNAL_EXEC environment variable is empty or unset");
@@ -671,17 +716,22 @@ const actionInternalExec = () => {
671
716
  const [file, ...rest] = argv;
672
717
  return execInherit(file, rest);
673
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
+ };
674
724
  /* action: internal sub-dispatch (tmux, shell, ase-task-edit, lazygit, capsula, exec) */
675
725
  const actionInternal = async (opts, args) => {
676
726
  const util = args[0];
677
727
  const rest = args.slice(1);
678
728
  switch (util) {
679
- case "tmux": return actionInternalTmux(rest);
680
- case "shell": return actionInternalShell(rest);
681
- case "ase-task-edit": return actionInternalAseTaskEdit();
682
- case "lazygit": return actionInternalLazygit(opts.recolor === true, rest);
683
- case "capsula": return actionInternalCapsula(rest);
684
- 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);
685
735
  default:
686
736
  fatal(`invalid internal command "${util ?? ""}"`);
687
737
  }
@@ -732,7 +782,7 @@ const actionDefault = (opts, args) => {
732
782
  `CLAUDEX_FLAGS=${shQ.quote([claudexFlags])} ` +
733
783
  `sudo -E -u ${shQ.quote([USER])} ` +
734
784
  `${shQ.quote([process.execPath, selfPathJS])} ` +
735
- `internal tmux new-session -A -s ${shQ.quote([session])}`
785
+ `${opts.ase ? "-A " : ""}internal tmux new-session -A -s ${shQ.quote([session])}`
736
786
  ]);
737
787
  }
738
788
  else {
@@ -741,7 +791,8 @@ const actionDefault = (opts, args) => {
741
791
  selfPathJS, "internal", "capsula",
742
792
  "-e", `CLAUDEX_FLAGS=${claudexFlags}`,
743
793
  "-e", `CLAUDEX_INTERNAL_EXEC=${inPane}`,
744
- "-C", container, process.execPath, selfPathJS, "internal", "tmux",
794
+ "-C", container, process.execPath, selfPathJS,
795
+ ...(opts.ase ? ["-A"] : []), "internal", "tmux",
745
796
  "new-session", "-A", "-s", session, "-n", "claude",
746
797
  "claudex", "internal", "exec"
747
798
  ]);
@@ -751,7 +802,7 @@ const actionDefault = (opts, args) => {
751
802
  /* enter/start plain tmux */
752
803
  return execInherit(process.execPath, [
753
804
  selfPathJS,
754
- "internal", "tmux",
805
+ ...(opts.ase ? ["-A"] : []), "internal", "tmux",
755
806
  "new-session", "-A", "-s", session, "-n", "claude",
756
807
  "claudex", "internal", "exec"
757
808
  ], {
@@ -953,6 +1004,7 @@ const actionHelp = () => {
953
1004
  "claudeX extension subcommands (honored before claude):\n" +
954
1005
  " install install host-side or in-container dependencies\n" +
955
1006
  " update update host-side or in-container dependencies\n" +
1007
+ " stats show Claude Code usage statistics\n" +
956
1008
  " internal … internal command dispatcher (internal use only)\n");
957
1009
  process.exit(0);
958
1010
  };
@@ -969,7 +1021,12 @@ const main = async () => {
969
1021
  const topArgs = process.argv.slice(2);
970
1022
  const subcmd = topArgs.find((a) => !a.startsWith("-")) ?? "";
971
1023
  const envFlags = (process.env.CLAUDEX_FLAGS ?? "").trim();
972
- if (envFlags !== "" && subcmd !== "internal") {
1024
+ const claudeNativeSubcmds = [
1025
+ "agents", "auth", "auto-mode", "doctor", "mcp",
1026
+ "plugin", "plugins", "project", "setup-token", "ultrareview"
1027
+ ];
1028
+ const isClaudeNative = claudeNativeSubcmds.includes(subcmd);
1029
+ if (envFlags !== "" && subcmd !== "internal" && !isClaudeNative) {
973
1030
  const aliases = {
974
1031
  "-R": "--recolor", "--recolor": "-R",
975
1032
  "-C": "--capsula", "--capsula": "-C",
@@ -1035,6 +1092,16 @@ const main = async () => {
1035
1092
  const capsula = cmd.parent?.opts().capsula === true;
1036
1093
  await actionUpdate(capsula);
1037
1094
  });
1095
+ /* dispatch "stats" sub-command */
1096
+ program
1097
+ .command("stats")
1098
+ .description("show Claude Code usage statistics")
1099
+ .helpOption("-h, --help", "display help for command")
1100
+ .allowUnknownOption()
1101
+ .argument("[args...]", "additional arguments passed to codeburn")
1102
+ .action(async (args) => {
1103
+ await actionStats(args);
1104
+ });
1038
1105
  /* dispatch "internal" sub-command */
1039
1106
  program
1040
1107
  .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,9 +593,16 @@ 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")
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
+ }
553
606
  if (isPsmux()) {
554
607
  /* psmux does not honor the reverse ANSI sequence in at least the statusline
555
608
  and not some expansions in the pane border format */
@@ -564,7 +617,7 @@ const actionInternalTmux = (args: string[]): never => {
564
617
  "set-hook -g -u after-split-window\n" +
565
618
  "bind-key g display-popup -E -w 95% -h 95% -T \"─◀( ⧉ Version Control (lazygit) )▶\" claudex internal lazygit\n" +
566
619
  "bind-key s display-popup -E -w 95% -h 95% -T \"─◀( ⧉ Shell )▶\" claudex internal shell\n" +
567
- "bind-key q display-popup -E -w 95% -h 95% -T \"─◀( ⧉ Task Edit (ase task edit) )▶\" claudex internal ase-task-edit\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" : "")
568
621
  }
569
622
  conf = conf.replace(/@USER@/g, USER)
570
623
  const confFile = path.join(os.tmpdir(), `claudex-tmux-${process.pid}.conf`)
@@ -593,7 +646,7 @@ const actionInternalTmux = (args: string[]): never => {
593
646
  }
594
647
 
595
648
  /* action: internal "shell" -- spawn an interactive login shell */
596
- const actionInternalShell = (args: string[]): never => {
649
+ const actionInternalShell = (_opts: TopOpts, args: string[]): never => {
597
650
  if (process.platform === "win32") {
598
651
  const shell = process.env.SHELL ?? process.env.ComSpec ?? "powershell"
599
652
  const name = path.basename(shell).toLowerCase().replace(/\.exe$/, "")
@@ -614,7 +667,7 @@ const actionInternalShell = (args: string[]): never => {
614
667
  }
615
668
 
616
669
  /* action: internal "ase-task-edit" -- edit the ASE task associated with the current tmux pane */
617
- const actionInternalAseTaskEdit = async (): Promise<void> => {
670
+ const actionInternalAseTaskEdit = async (_opts: TopOpts): Promise<void> => {
618
671
  ensureTool("ase")
619
672
  let tid = ""
620
673
  const r1 = execaSync("tmux", [ "display-message", "-p", "#{@ase_task_id}" ], { reject: false })
@@ -628,11 +681,11 @@ const actionInternalAseTaskEdit = async (): Promise<void> => {
628
681
  }
629
682
 
630
683
  /* action: internal "lazygit" -- spawn lazygit (optionally recolored) */
631
- const actionInternalLazygit = (recolor: boolean, args: string[]): never => {
684
+ const actionInternalLazygit = (opts: TopOpts, args: string[]): never => {
632
685
  ensureTool("git")
633
686
  ensureTool("lazygit")
634
687
  const env: Env = { ...process.env, TERM: "xterm-color" }
635
- if (recolor) {
688
+ if (opts.recolor) {
636
689
  ensureTool("ansi-recolor")
637
690
  return execInherit("ansi-recolor", [
638
691
  "-c", path.join(basedir, "ansi-recolor.conf"),
@@ -650,7 +703,7 @@ const actionInternalLazygit = (recolor: boolean, args: string[]): never => {
650
703
  }
651
704
 
652
705
  /* action: internal "capsula" -- enter/start a Capsula container with the curated env-var/dotfile setup */
653
- const actionInternalCapsula = (args: string[]): never => {
706
+ const actionInternalCapsula = (_opts: TopOpts, args: string[]): never => {
654
707
  /* sanity check environment */
655
708
  ensureTool("capsula")
656
709
  if (ENVIRONMENT === "capsula")
@@ -732,7 +785,7 @@ const actionInternalCapsula = (args: string[]): never => {
732
785
  Windows tmux) that mishandle quoting when a command is passed via "tmux
733
786
  new-session" as multiple trailing argv items: we instead pass the whole
734
787
  command as a single env-var value. */
735
- const actionInternalExec = (): never => {
788
+ const actionInternalExec = (_opts: TopOpts): never => {
736
789
  const cmdline = process.env.CLAUDEX_INTERNAL_EXEC ?? ""
737
790
  if (cmdline === "")
738
791
  fatal("CLAUDEX_INTERNAL_EXEC environment variable is empty or unset")
@@ -750,17 +803,23 @@ const actionInternalExec = (): never => {
750
803
  return execInherit(file, rest)
751
804
  }
752
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
+
753
812
  /* action: internal sub-dispatch (tmux, shell, ase-task-edit, lazygit, capsula, exec) */
754
813
  const actionInternal = async (opts: TopOpts, args: string[]): Promise<void> => {
755
814
  const util = args[0]
756
815
  const rest = args.slice(1)
757
816
  switch (util) {
758
- case "tmux": return actionInternalTmux(rest)
759
- case "shell": return actionInternalShell(rest)
760
- case "ase-task-edit": return actionInternalAseTaskEdit()
761
- case "lazygit": return actionInternalLazygit(opts.recolor === true, rest)
762
- case "capsula": return actionInternalCapsula(rest)
763
- 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)
764
823
  default:
765
824
  fatal(`invalid internal command "${util ?? ""}"`)
766
825
  }
@@ -818,7 +877,7 @@ const actionDefault = (opts: TopOpts, args: string[]): never => {
818
877
  `CLAUDEX_FLAGS=${shQ.quote([ claudexFlags ])} ` +
819
878
  `sudo -E -u ${shQ.quote([ USER ])} ` +
820
879
  `${shQ.quote([ process.execPath, selfPathJS ])} ` +
821
- `internal tmux new-session -A -s ${shQ.quote([ session ])}`
880
+ `${opts.ase ? "-A " : ""}internal tmux new-session -A -s ${shQ.quote([ session ])}`
822
881
  ])
823
882
  }
824
883
  else {
@@ -827,7 +886,8 @@ const actionDefault = (opts: TopOpts, args: string[]): never => {
827
886
  selfPathJS, "internal", "capsula",
828
887
  "-e", `CLAUDEX_FLAGS=${claudexFlags}`,
829
888
  "-e", `CLAUDEX_INTERNAL_EXEC=${inPane}`,
830
- "-C", container, process.execPath, selfPathJS, "internal", "tmux",
889
+ "-C", container, process.execPath, selfPathJS,
890
+ ...(opts.ase ? [ "-A" ] : []), "internal", "tmux",
831
891
  "new-session", "-A", "-s", session, "-n", "claude",
832
892
  "claudex", "internal", "exec"
833
893
  ])
@@ -837,7 +897,7 @@ const actionDefault = (opts: TopOpts, args: string[]): never => {
837
897
  /* enter/start plain tmux */
838
898
  return execInherit(process.execPath, [
839
899
  selfPathJS,
840
- "internal", "tmux",
900
+ ...(opts.ase ? [ "-A" ] : []), "internal", "tmux",
841
901
  "new-session", "-A", "-s", session, "-n", "claude",
842
902
  "claudex", "internal", "exec"
843
903
  ], {
@@ -1047,6 +1107,7 @@ const actionHelp = (): never => {
1047
1107
  "claudeX extension subcommands (honored before claude):\n" +
1048
1108
  " install install host-side or in-container dependencies\n" +
1049
1109
  " update update host-side or in-container dependencies\n" +
1110
+ " stats show Claude Code usage statistics\n" +
1050
1111
  " internal … internal command dispatcher (internal use only)\n"
1051
1112
  )
1052
1113
  process.exit(0)
@@ -1065,7 +1126,12 @@ const main = async (): Promise<void> => {
1065
1126
  const topArgs = process.argv.slice(2)
1066
1127
  const subcmd = topArgs.find((a) => !a.startsWith("-")) ?? ""
1067
1128
  const envFlags = (process.env.CLAUDEX_FLAGS ?? "").trim()
1068
- if (envFlags !== "" && subcmd !== "internal") {
1129
+ const claudeNativeSubcmds = [
1130
+ "agents", "auth", "auto-mode", "doctor", "mcp",
1131
+ "plugin", "plugins", "project", "setup-token", "ultrareview"
1132
+ ]
1133
+ const isClaudeNative = claudeNativeSubcmds.includes(subcmd)
1134
+ if (envFlags !== "" && subcmd !== "internal" && !isClaudeNative) {
1069
1135
  const aliases: Record<string, string> = {
1070
1136
  "-R": "--recolor", "--recolor": "-R",
1071
1137
  "-C": "--capsula", "--capsula": "-C",
@@ -1136,6 +1202,17 @@ const main = async (): Promise<void> => {
1136
1202
  await actionUpdate(capsula)
1137
1203
  })
1138
1204
 
1205
+ /* dispatch "stats" sub-command */
1206
+ program
1207
+ .command("stats")
1208
+ .description("show Claude Code usage statistics")
1209
+ .helpOption("-h, --help", "display help for command")
1210
+ .allowUnknownOption()
1211
+ .argument("[args...]", "additional arguments passed to codeburn")
1212
+ .action(async (args: string[]) => {
1213
+ await actionStats(args)
1214
+ })
1215
+
1139
1216
  /* dispatch "internal" sub-command */
1140
1217
  program
1141
1218
  .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.24",
4
+ "version": "1.0.1",
5
5
  "description": "Claude Code eXtended",
6
6
  "type": "module",
7
7
  "keywords": [ "claude", "code", "extension", "wrapper" ],
package/tmux.conf CHANGED
@@ -201,7 +201,4 @@ bind-key | split-window -c "#{pane_current_path}" -h "claudex"
201
201
  bind-key - split-window -c "#{pane_current_path}" -v "claudex"
202
202
  bind-key g display-popup -E -w 95% -h 95% -T "─◀#[reverse] ⧉ Version Control (lazygit) #[noreverse]▶" claudex internal lazygit
203
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 "
207
204