codemax-cli 0.0.0-stage → 0.1.3

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.
Files changed (56) hide show
  1. package/LICENSE +661 -0
  2. package/NOTICE +27 -0
  3. package/README.md +163 -2
  4. package/TRADEMARKS.md +27 -0
  5. package/bin/codemax +2 -0
  6. package/bin/codemax.cjs +78 -0
  7. package/package.json +72 -4
  8. package/src/adapters/claude.ts +43 -0
  9. package/src/adapters/codex.ts +101 -0
  10. package/src/adapters/detect.ts +16 -0
  11. package/src/adapters/index.ts +21 -0
  12. package/src/adapters/simple.ts +89 -0
  13. package/src/adapters/types.ts +87 -0
  14. package/src/chat/app.ts +1934 -0
  15. package/src/chat/logo.ts +37 -0
  16. package/src/chat/markdown.ts +77 -0
  17. package/src/chat/palette.ts +179 -0
  18. package/src/chat/permission.ts +111 -0
  19. package/src/chat/theme.ts +158 -0
  20. package/src/chat/transcript.ts +342 -0
  21. package/src/cli.ts +254 -0
  22. package/src/config.ts +114 -0
  23. package/src/core/awake.ts +345 -0
  24. package/src/core/brief.ts +314 -0
  25. package/src/core/budget.ts +42 -0
  26. package/src/core/checkpoint.ts +139 -0
  27. package/src/core/doctor.ts +67 -0
  28. package/src/core/files.ts +62 -0
  29. package/src/core/git.ts +36 -0
  30. package/src/core/hotkey.ts +75 -0
  31. package/src/core/journal.ts +215 -0
  32. package/src/core/ledger.ts +153 -0
  33. package/src/core/menu.ts +134 -0
  34. package/src/core/orchestrator.ts +352 -0
  35. package/src/core/paths.ts +30 -0
  36. package/src/core/prices-live.ts +123 -0
  37. package/src/core/pricing.ts +162 -0
  38. package/src/core/pty.ts +99 -0
  39. package/src/core/quota.ts +55 -0
  40. package/src/core/review.ts +67 -0
  41. package/src/core/spawn.ts +20 -0
  42. package/src/core/terminal.ts +51 -0
  43. package/src/core/update.ts +90 -0
  44. package/src/core/usage.ts +116 -0
  45. package/src/engines/acp.ts +419 -0
  46. package/src/engines/codex.ts +330 -0
  47. package/src/engines/env.ts +17 -0
  48. package/src/engines/errors.ts +47 -0
  49. package/src/engines/index.ts +154 -0
  50. package/src/engines/types.ts +131 -0
  51. package/src/transcripts/claude-usage.ts +63 -0
  52. package/src/transcripts/claude.ts +69 -0
  53. package/src/transcripts/codex.ts +74 -0
  54. package/src/tui/app.ts +377 -0
  55. package/src/tui/menu.ts +126 -0
  56. package/src/tui/pane.ts +79 -0
@@ -0,0 +1,87 @@
1
+ export type AgentId = "claude" | "codex" | "opencode" | "cursor" | "grok" | "gemini" | "copilot" | "fake";
2
+
3
+ export interface SessionRef {
4
+ agent: AgentId;
5
+ /** Vendor session / thread id. */
6
+ id: string;
7
+ /** Absolute path of the vendor transcript, when known. */
8
+ transcriptPath?: string;
9
+ cwd: string;
10
+ startedAt: number;
11
+ lastUsedAt: number;
12
+ }
13
+
14
+ export interface Turn {
15
+ ts: number;
16
+ agent: AgentId;
17
+ sessionId: string;
18
+ role: "user" | "assistant";
19
+ text: string;
20
+ /** Tool names used in this assistant turn, deduped. */
21
+ tools?: string[];
22
+ }
23
+
24
+ export interface QuotaStatus {
25
+ agent: AgentId;
26
+ /** 0..100 of the primary window consumed, when the vendor exposes it. */
27
+ usedPercent?: number;
28
+ resetsAt?: number;
29
+ /** True when the vendor has told us we are out of quota. */
30
+ exhausted: boolean;
31
+ source: "probe" | "output" | "manual";
32
+ detail?: string;
33
+ at: number;
34
+ /** Output-text detections are guesses: they expire instead of sticking. */
35
+ expiresAt?: number;
36
+ }
37
+
38
+ export interface LaunchOptions {
39
+ cwd: string;
40
+ /** Resume this vendor session instead of starting a new one. */
41
+ resume?: SessionRef;
42
+ /** Initial prompt to seed the session with (the handoff brief). */
43
+ prompt?: string;
44
+ /** Pre-generated session id when the vendor lets us choose one. */
45
+ sessionId?: string;
46
+ extraArgs?: string[];
47
+ }
48
+
49
+ export interface LaunchSpec {
50
+ cmd: string[];
51
+ env?: Record<string, string>;
52
+ /**
53
+ * True when `prompt` was consumed by `cmd` (positional arg). False means
54
+ * the orchestrator must type the prompt into the PTY once the TUI is ready.
55
+ */
56
+ promptConsumed: boolean;
57
+ }
58
+
59
+ export interface DetectResult {
60
+ installed: boolean;
61
+ path?: string;
62
+ version?: string;
63
+ }
64
+
65
+ export interface Adapter {
66
+ id: AgentId;
67
+ name: string;
68
+ bin: string;
69
+ detect(): Promise<DetectResult>;
70
+ launch(opts: LaunchOptions): LaunchSpec;
71
+ /** Choose a session id up front when the vendor supports it. */
72
+ newSessionId?(): string;
73
+ /** Find the vendor session created by a launch at `startedAt` in `cwd`. */
74
+ locateSession(opts: { cwd: string; startedAt: number; sessionId?: string }): Promise<SessionRef | null>;
75
+ /** Parse the vendor transcript into normalized turns. Null when unsupported. */
76
+ readTranscript?(ref: SessionRef): Promise<Turn[]>;
77
+ /** Proactive quota probe (vendor-specific files or APIs). */
78
+ probeQuota?(ref: SessionRef | null): Promise<QuotaStatus | null>;
79
+ /** Regexes matched against ANSI-stripped TUI output. */
80
+ quotaPatterns: RegExp[];
81
+ /**
82
+ * Env vars that make the CLI bill a pay-per-token API key instead of the
83
+ * user's subscription login. Always stripped at launch: codemax is
84
+ * subscriptions-only.
85
+ */
86
+ apiKeyEnv: string[];
87
+ }