@bastani/atomic 0.9.4-alpha.8 → 0.9.4-alpha.9

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 (108) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/builtin/cursor/package.json +2 -2
  3. package/dist/builtin/intercom/package.json +1 -1
  4. package/dist/builtin/mcp/package.json +1 -1
  5. package/dist/builtin/subagents/CHANGELOG.md +7 -0
  6. package/dist/builtin/subagents/agents/code-simplifier.md +2 -2
  7. package/dist/builtin/subagents/agents/codebase-analyzer.md +2 -2
  8. package/dist/builtin/subagents/agents/codebase-locator.md +2 -2
  9. package/dist/builtin/subagents/agents/codebase-online-researcher.md +2 -2
  10. package/dist/builtin/subagents/agents/codebase-pattern-finder.md +2 -2
  11. package/dist/builtin/subagents/agents/codebase-research-analyzer.md +2 -2
  12. package/dist/builtin/subagents/agents/codebase-research-locator.md +2 -2
  13. package/dist/builtin/subagents/agents/debugger.md +1 -1
  14. package/dist/builtin/subagents/agents/worker.md +2 -2
  15. package/dist/builtin/subagents/package.json +1 -1
  16. package/dist/builtin/web-access/package.json +1 -1
  17. package/dist/builtin/workflows/CHANGELOG.md +8 -0
  18. package/dist/builtin/workflows/builtin/deep-research-codebase-utils.ts +24 -29
  19. package/dist/builtin/workflows/builtin/goal-runner.ts +13 -37
  20. package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +6 -9
  21. package/dist/builtin/workflows/builtin/ralph-models.ts +58 -115
  22. package/dist/builtin/workflows/package.json +1 -1
  23. package/dist/bun/cli.d.ts.map +1 -1
  24. package/dist/bun/cli.js +3 -2
  25. package/dist/bun/cli.js.map +1 -1
  26. package/dist/cli.d.ts.map +1 -1
  27. package/dist/cli.js +15 -5
  28. package/dist/cli.js.map +1 -1
  29. package/dist/config.d.ts +10 -3
  30. package/dist/config.d.ts.map +1 -1
  31. package/dist/config.js +18 -1
  32. package/dist/config.js.map +1 -1
  33. package/dist/core/agent-session-events.d.ts.map +1 -1
  34. package/dist/core/agent-session-events.js +14 -8
  35. package/dist/core/agent-session-events.js.map +1 -1
  36. package/dist/core/agent-session-export.d.ts.map +1 -1
  37. package/dist/core/agent-session-export.js +4 -2
  38. package/dist/core/agent-session-export.js.map +1 -1
  39. package/dist/core/agent-session-extension-bindings.d.ts +3 -1
  40. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  41. package/dist/core/agent-session-extension-bindings.js +7 -4
  42. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  43. package/dist/core/agent-session-methods.d.ts +4 -1
  44. package/dist/core/agent-session-methods.d.ts.map +1 -1
  45. package/dist/core/agent-session-methods.js.map +1 -1
  46. package/dist/core/agent-session-retry.d.ts +2 -0
  47. package/dist/core/agent-session-retry.d.ts.map +1 -1
  48. package/dist/core/agent-session-retry.js +66 -7
  49. package/dist/core/agent-session-retry.js.map +1 -1
  50. package/dist/core/copilot-model-static-fallbacks.d.ts +43 -0
  51. package/dist/core/copilot-model-static-fallbacks.d.ts.map +1 -0
  52. package/dist/core/copilot-model-static-fallbacks.js +50 -0
  53. package/dist/core/copilot-model-static-fallbacks.js.map +1 -0
  54. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  55. package/dist/core/extensions/loader-virtual-modules.js +64 -11
  56. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  57. package/dist/core/model-registry-builtins.d.ts.map +1 -1
  58. package/dist/core/model-registry-builtins.js +9 -1
  59. package/dist/core/model-registry-builtins.js.map +1 -1
  60. package/dist/core/resource-loader-reload.d.ts.map +1 -1
  61. package/dist/core/resource-loader-reload.js +4 -2
  62. package/dist/core/resource-loader-reload.js.map +1 -1
  63. package/dist/core/resource-loader-types.d.ts +6 -0
  64. package/dist/core/resource-loader-types.d.ts.map +1 -1
  65. package/dist/core/resource-loader-types.js.map +1 -1
  66. package/dist/core/tools/bash-pty-native.d.ts.map +1 -1
  67. package/dist/core/tools/bash-pty-native.js +2 -2
  68. package/dist/core/tools/bash-pty-native.js.map +1 -1
  69. package/dist/core/tools/search-native.d.ts.map +1 -1
  70. package/dist/core/tools/search-native.js +2 -2
  71. package/dist/core/tools/search-native.js.map +1 -1
  72. package/dist/main.d.ts.map +1 -1
  73. package/dist/main.js +56 -32
  74. package/dist/main.js.map +1 -1
  75. package/dist/modes/interactive/interactive-deferred-startup.d.ts +2 -0
  76. package/dist/modes/interactive/interactive-deferred-startup.d.ts.map +1 -0
  77. package/dist/modes/interactive/interactive-deferred-startup.js +59 -0
  78. package/dist/modes/interactive/interactive-deferred-startup.js.map +1 -0
  79. package/dist/modes/interactive/interactive-mode-base.d.ts +2 -0
  80. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  81. package/dist/modes/interactive/interactive-mode-base.js +4 -0
  82. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  83. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
  84. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  85. package/dist/modes/interactive/interactive-mode-deps.js +1 -1
  86. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  87. package/dist/modes/interactive/interactive-mode-surface.d.ts +2 -0
  88. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  89. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  90. package/dist/modes/interactive/interactive-mode-types.d.ts +2 -0
  91. package/dist/modes/interactive/interactive-mode-types.d.ts.map +1 -1
  92. package/dist/modes/interactive/interactive-mode-types.js.map +1 -1
  93. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  94. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  95. package/dist/modes/interactive/interactive-mode.js +1 -0
  96. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  97. package/dist/modes/interactive/interactive-session-runtime.d.ts.map +1 -1
  98. package/dist/modes/interactive/interactive-session-runtime.js +4 -2
  99. package/dist/modes/interactive/interactive-session-runtime.js.map +1 -1
  100. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  101. package/dist/modes/interactive/interactive-startup.js +11 -1
  102. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  103. package/dist/utils/module-require.d.ts +11 -0
  104. package/dist/utils/module-require.d.ts.map +1 -0
  105. package/dist/utils/module-require.js +16 -0
  106. package/dist/utils/module-require.js.map +1 -0
  107. package/npm-shrinkwrap.json +23 -23
  108. package/package.json +5 -3
@@ -1,33 +1,42 @@
1
1
  import { reviewDecisionSchema } from "./ralph-core.js";
2
2
 
3
+ // Model chains are curated from Atomic's agentic-coding benchmark
4
+ // (pass@1 / avg $ per task, 2026-07-02):
5
+ // - Placement principle: REVIEWERS get best-in-class verification quality
6
+ // (fable-5:xhigh 70%/$13.41 leads reviewer-A and the goal reviewer);
7
+ // EVERY OTHER stage gets the best measured performance-per-dollar
8
+ // (gpt-5.5:xhigh 67%/$7.23 for hard stages, gpt-5.5:medium 54%/$2.75 for
9
+ // workhorse stages, gpt-5.5:low $1.20 for retrieval).
10
+ // - Pareto frontier: gpt-5.5 low ($1.20/27%) → gpt-5.5 medium ($2.75/54%) →
11
+ // fable-5 low ($3.76/60%) → gpt-5.5 high ($5.10/64%) → fable-5 medium
12
+ // ($6.09/65%) → gpt-5.5 xhigh ($7.23/67%) → fable-5 high ($9.18/69%) →
13
+ // fable-5 xhigh ($13.41/70%).
14
+ // - Dropped as strictly dominated: claude-sonnet-5 (40-54% at $4-26, up to
15
+ // 268 steps), claude-sonnet-4.6 (30%/$5.52), gemini-3.1-pro (12%/$9.48),
16
+ // gemini-3.5-flash (37%/$7.34, 276k output tokens).
17
+ // - claude-opus-4.8 rides at :high — its value point (52%/$4.28); :xhigh
18
+ // doubles the cost for +2pts.
19
+ // - glm-5.2 is reviewer-C's diversity primary only (third model family
20
+ // decorrelates review errors); elsewhere it is a budget fallback. Note:
21
+ // GLM-5.2 has only two real reasoning tiers — its thinkingLevelMap collapses
22
+ // minimal/low/medium/high to "high" and xhigh to "max" — so chains only use
23
+ // :high (budget tier, 36%/$2.84) or :xhigh (best tier, 44%/$3.92); the
24
+ // openrouter/z-ai mirror maps :xhigh exclusively, so it is always :xhigh.
25
+
3
26
  export const promptEngineerModelConfig = {
4
- model: "anthropic/claude-fable-5:high",
27
+ model: "openai-codex/gpt-5.5:xhigh",
5
28
  fallbackModels: [
6
- "openai-codex/gpt-5.5:xhigh",
7
29
  "github-copilot/gpt-5.5:xhigh",
8
30
  "openai/gpt-5.5:xhigh",
9
- "github-copilot/claude-opus-4.8 (1m):xhigh",
10
- "anthropic/claude-opus-4-8:xhigh",
31
+ "anthropic/claude-fable-5:xhigh",
32
+ "github-copilot/claude-opus-4.8 (1m):high",
33
+ "anthropic/claude-opus-4-8:high",
11
34
  "zai/glm-5.2:xhigh",
12
35
  "zai-coding-cn/glm-5.2:xhigh",
13
- "github-copilot/claude-sonnet-5 (1m):high",
14
- "anthropic/claude-sonnet-5:high",
15
- "github-copilot/claude-sonnet-4.6 (1m):high",
16
- "anthropic/claude-sonnet-4-6:high",
17
- "github-copilot/gemini-3.5-flash (1m):high",
18
- "google/gemini-3.5-flash:high",
19
- "google-vertex/gemini-3.5-flash:high",
20
- "github-copilot/gemini-3.1-pro-preview (1m):high",
21
- "google/gemini-3.1-pro-preview:high",
22
- "google-vertex/gemini-3.1-pro-preview:high",
23
- "openrouter/anthropic/claude-fable-5:high",
24
36
  "openrouter/openai/gpt-5.5:xhigh",
25
- "openrouter/anthropic/claude-opus-4-8:xhigh",
26
- "openrouter/z-ai/glm-5.2:xhigh",
27
- "openrouter/anthropic/claude-sonnet-5:high",
28
- "openrouter/anthropic/claude-sonnet-4-6:high",
29
- "openrouter/google/gemini-3.5-flash:high",
30
- "openrouter/google/gemini-3.1-pro-preview:high"
37
+ "openrouter/anthropic/claude-fable-5:xhigh",
38
+ "openrouter/anthropic/claude-opus-4-8:high",
39
+ "openrouter/z-ai/glm-5.2:xhigh"
31
40
  ],
32
41
  excludedTools: ["ask_user_question"],
33
42
  };
@@ -37,27 +46,15 @@ export const researchModelConfig = {
37
46
  fallbackModels: [
38
47
  "github-copilot/gpt-5.5:medium",
39
48
  "openai/gpt-5.5:medium",
49
+ "anthropic/claude-fable-5:low",
40
50
  "github-copilot/claude-opus-4.8 (1m):medium",
41
51
  "anthropic/claude-opus-4-8:medium",
42
- "zai/glm-5.2:medium",
43
- "zai-coding-cn/glm-5.2:medium",
44
- "github-copilot/claude-sonnet-5 (1m):medium",
45
- "anthropic/claude-sonnet-5:medium",
46
- "github-copilot/claude-sonnet-4.6 (1m):medium",
47
- "anthropic/claude-sonnet-4-6:medium",
48
- "github-copilot/gemini-3.5-flash (1m):medium",
49
- "google/gemini-3.5-flash:medium",
50
- "google-vertex/gemini-3.5-flash:medium",
51
- "github-copilot/gemini-3.1-pro-preview (1m):medium",
52
- "google/gemini-3.1-pro-preview:medium",
53
- "google-vertex/gemini-3.1-pro-preview:medium",
52
+ "zai/glm-5.2:high",
53
+ "zai-coding-cn/glm-5.2:high",
54
54
  "openrouter/openai/gpt-5.5:medium",
55
+ "openrouter/anthropic/claude-fable-5:low",
55
56
  "openrouter/anthropic/claude-opus-4-8:medium",
56
- "openrouter/z-ai/glm-5.2:medium",
57
- "openrouter/anthropic/claude-sonnet-5:medium",
58
- "openrouter/anthropic/claude-sonnet-4-6:medium",
59
- "openrouter/google/gemini-3.5-flash:medium",
60
- "openrouter/google/gemini-3.1-pro-preview:medium"
57
+ "openrouter/z-ai/glm-5.2:xhigh"
61
58
  ],
62
59
  excludedTools: ["ask_user_question"],
63
60
  };
@@ -67,59 +64,33 @@ export const orchestratorModelConfig = {
67
64
  fallbackModels: [
68
65
  "github-copilot/gpt-5.5:medium",
69
66
  "openai/gpt-5.5:medium",
67
+ "anthropic/claude-fable-5:low",
70
68
  "github-copilot/claude-opus-4.8 (1m):medium",
71
69
  "anthropic/claude-opus-4-8:medium",
72
- "zai/glm-5.2:medium",
73
- "zai-coding-cn/glm-5.2:medium",
74
- "github-copilot/claude-sonnet-5 (1m):medium",
75
- "anthropic/claude-sonnet-5:medium",
76
- "github-copilot/claude-sonnet-4.6 (1m):medium",
77
- "anthropic/claude-sonnet-4-6:medium",
78
- "github-copilot/gemini-3.5-flash (1m):medium",
79
- "google/gemini-3.5-flash:medium",
80
- "google-vertex/gemini-3.5-flash:medium",
81
- "github-copilot/gemini-3.1-pro-preview (1m):medium",
82
- "google/gemini-3.1-pro-preview:medium",
83
- "google-vertex/gemini-3.1-pro-preview:medium",
70
+ "zai/glm-5.2:high",
71
+ "zai-coding-cn/glm-5.2:high",
84
72
  "openrouter/openai/gpt-5.5:medium",
73
+ "openrouter/anthropic/claude-fable-5:low",
85
74
  "openrouter/anthropic/claude-opus-4-8:medium",
86
- "openrouter/z-ai/glm-5.2:medium",
87
- "openrouter/anthropic/claude-sonnet-5:medium",
88
- "openrouter/anthropic/claude-sonnet-4-6:medium",
89
- "openrouter/google/gemini-3.5-flash:medium",
90
- "openrouter/google/gemini-3.1-pro-preview:medium"
75
+ "openrouter/z-ai/glm-5.2:xhigh"
91
76
  ],
92
77
  excludedTools: ["ask_user_question"],
93
78
  };
94
79
 
95
80
  export const reviewerAModelConfig = {
96
- model: "anthropic/claude-fable-5:high",
81
+ model: "anthropic/claude-fable-5:xhigh",
97
82
  fallbackModels: [
98
- "github-copilot/claude-opus-4.8 (1m):xhigh",
99
- "anthropic/claude-opus-4-8:xhigh",
100
83
  "openai-codex/gpt-5.5:xhigh",
101
84
  "github-copilot/gpt-5.5:xhigh",
102
85
  "openai/gpt-5.5:xhigh",
86
+ "github-copilot/claude-opus-4.8 (1m):high",
87
+ "anthropic/claude-opus-4-8:high",
103
88
  "zai/glm-5.2:xhigh",
104
89
  "zai-coding-cn/glm-5.2:xhigh",
105
- "github-copilot/claude-sonnet-5 (1m):high",
106
- "anthropic/claude-sonnet-5:high",
107
- "github-copilot/claude-sonnet-4.6 (1m):high",
108
- "anthropic/claude-sonnet-4-6:high",
109
- "github-copilot/gemini-3.5-flash (1m):high",
110
- "google/gemini-3.5-flash:high",
111
- "google-vertex/gemini-3.5-flash:high",
112
- "github-copilot/gemini-3.1-pro-preview (1m):high",
113
- "google/gemini-3.1-pro-preview:high",
114
- "google-vertex/gemini-3.1-pro-preview:high",
115
- "openrouter/anthropic/claude-fable-5:high",
116
- "openrouter/anthropic/claude-opus-4-8:xhigh",
90
+ "openrouter/anthropic/claude-fable-5:xhigh",
117
91
  "openrouter/openai/gpt-5.5:xhigh",
118
- "openrouter/z-ai/glm-5.2:xhigh",
119
- "openrouter/anthropic/claude-sonnet-5:high",
120
- "openrouter/anthropic/claude-sonnet-4-6:high",
121
- "openrouter/google/gemini-3.5-flash:high",
122
- "openrouter/google/gemini-3.1-pro-preview:high"
92
+ "openrouter/anthropic/claude-opus-4-8:high",
93
+ "openrouter/z-ai/glm-5.2:xhigh"
123
94
  ],
124
95
  excludedTools: ["ask_user_question"],
125
96
  schema: reviewDecisionSchema,
@@ -130,29 +101,15 @@ export const reviewerBModelConfig = {
130
101
  fallbackModels: [
131
102
  "github-copilot/gpt-5.5:xhigh",
132
103
  "openai/gpt-5.5:xhigh",
133
- "anthropic/claude-fable-5:high",
134
- "github-copilot/claude-opus-4.8 (1m):xhigh",
135
- "anthropic/claude-opus-4-8:xhigh",
104
+ "anthropic/claude-fable-5:xhigh",
105
+ "github-copilot/claude-opus-4.8 (1m):high",
106
+ "anthropic/claude-opus-4-8:high",
136
107
  "zai/glm-5.2:xhigh",
137
108
  "zai-coding-cn/glm-5.2:xhigh",
138
- "github-copilot/claude-sonnet-5 (1m):high",
139
- "anthropic/claude-sonnet-5:high",
140
- "github-copilot/claude-sonnet-4.6 (1m):high",
141
- "anthropic/claude-sonnet-4-6:high",
142
- "github-copilot/gemini-3.5-flash (1m):high",
143
- "google/gemini-3.5-flash:high",
144
- "google-vertex/gemini-3.5-flash:high",
145
- "github-copilot/gemini-3.1-pro-preview (1m):high",
146
- "google/gemini-3.1-pro-preview:high",
147
- "google-vertex/gemini-3.1-pro-preview:high",
148
109
  "openrouter/openai/gpt-5.5:xhigh",
149
- "openrouter/anthropic/claude-fable-5:high",
150
- "openrouter/anthropic/claude-opus-4-8:xhigh",
151
- "openrouter/z-ai/glm-5.2:xhigh",
152
- "openrouter/anthropic/claude-sonnet-5:high",
153
- "openrouter/anthropic/claude-sonnet-4-6:high",
154
- "openrouter/google/gemini-3.5-flash:high",
155
- "openrouter/google/gemini-3.1-pro-preview:high"
110
+ "openrouter/anthropic/claude-fable-5:xhigh",
111
+ "openrouter/anthropic/claude-opus-4-8:high",
112
+ "openrouter/z-ai/glm-5.2:xhigh"
156
113
  ],
157
114
  excludedTools: ["ask_user_question"],
158
115
  schema: reviewDecisionSchema,
@@ -162,30 +119,16 @@ export const reviewerCModelConfig = {
162
119
  model: "zai/glm-5.2:xhigh",
163
120
  fallbackModels: [
164
121
  "zai-coding-cn/glm-5.2:xhigh",
165
- "github-copilot/gemini-3.5-flash (1m):high",
166
- "google/gemini-3.5-flash:high",
167
- "google-vertex/gemini-3.5-flash:high",
168
- "github-copilot/gemini-3.1-pro-preview (1m):high",
169
- "google/gemini-3.1-pro-preview:high",
170
- "google-vertex/gemini-3.1-pro-preview:high",
122
+ "openrouter/z-ai/glm-5.2:xhigh",
171
123
  "openai-codex/gpt-5.5:xhigh",
172
124
  "github-copilot/gpt-5.5:xhigh",
173
125
  "openai/gpt-5.5:xhigh",
174
- "anthropic/claude-fable-5:high",
175
- "github-copilot/claude-opus-4.8 (1m):xhigh",
176
- "anthropic/claude-opus-4-8:xhigh",
177
- "github-copilot/claude-sonnet-5 (1m):high",
178
- "anthropic/claude-sonnet-5:high",
179
- "github-copilot/claude-sonnet-4.6 (1m):high",
180
- "anthropic/claude-sonnet-4-6:high",
181
- "openrouter/anthropic/claude-fable-5:high",
182
- "openrouter/anthropic/claude-opus-4-8:xhigh",
183
- "openrouter/anthropic/claude-sonnet-5:high",
184
- "openrouter/anthropic/claude-sonnet-4-6:high",
126
+ "anthropic/claude-fable-5:xhigh",
127
+ "github-copilot/claude-opus-4.8 (1m):high",
128
+ "anthropic/claude-opus-4-8:high",
185
129
  "openrouter/openai/gpt-5.5:xhigh",
186
- "openrouter/z-ai/glm-5.2:xhigh",
187
- "openrouter/google/gemini-3.5-flash:high",
188
- "openrouter/google/gemini-3.1-pro-preview:high"
130
+ "openrouter/anthropic/claude-fable-5:xhigh",
131
+ "openrouter/anthropic/claude-opus-4-8:high"
189
132
  ],
190
133
  excludedTools: ["ask_user_question"],
191
134
  schema: reviewDecisionSchema,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bastani/workflows",
3
- "version": "0.9.4-alpha.8",
3
+ "version": "0.9.4-alpha.9",
4
4
  "private": true,
5
5
  "description": "Atomic extension for multi-stage workflow authoring and execution.",
6
6
  "contributors": [
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/bun/cli.ts"],"names":[],"mappings":"","sourcesContent":["#!/usr/bin/env node\nimport { APP_NAME } from \"../config.ts\";\n\nprocess.title = APP_NAME;\nprocess.emitWarning = (() => {}) as typeof process.emitWarning;\n\nimport { restoreSandboxEnv } from \"./restore-sandbox-env.ts\";\n\nrestoreSandboxEnv();\n\nawait import(\"./register-bedrock.ts\");\nawait import(\"../cli.ts\");\n"]}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/bun/cli.ts"],"names":[],"mappings":"","sourcesContent":["#!/usr/bin/env node\nimport { APP_NAME } from \"../config.ts\";\n\nprocess.title = APP_NAME;\nprocess.emitWarning = (() => {}) as typeof process.emitWarning;\n\nimport { restoreSandboxEnv } from \"./restore-sandbox-env.ts\";\n\nrestoreSandboxEnv();\n\n// No top-level await: the compiled binary is built with --bytecode (CJS),\n// which forbids TLA anywhere in the bundled graph.\nvoid import(\"./register-bedrock.ts\").then(() => import(\"../cli.ts\"));\n"]}
package/dist/bun/cli.js CHANGED
@@ -4,6 +4,7 @@ process.title = APP_NAME;
4
4
  process.emitWarning = (() => { });
5
5
  import { restoreSandboxEnv } from "./restore-sandbox-env.js";
6
6
  restoreSandboxEnv();
7
- await import("./register-bedrock.js");
8
- await import("../cli.js");
7
+ // No top-level await: the compiled binary is built with --bytecode (CJS),
8
+ // which forbids TLA anywhere in the bundled graph.
9
+ void import("./register-bedrock.js").then(() => import("../cli.js"));
9
10
  //# sourceMappingURL=cli.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/bun/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC;AACzB,OAAO,CAAC,WAAW,GAAG,CAAC,GAAG,EAAE,GAAE,CAAC,CAA+B,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,iBAAiB,EAAE,CAAC;AAEpB,MAAM,MAAM,CAAC,uBAAuB,CAAC,CAAC;AACtC,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { APP_NAME } from \"../config.ts\";\n\nprocess.title = APP_NAME;\nprocess.emitWarning = (() => {}) as typeof process.emitWarning;\n\nimport { restoreSandboxEnv } from \"./restore-sandbox-env.ts\";\n\nrestoreSandboxEnv();\n\nawait import(\"./register-bedrock.ts\");\nawait import(\"../cli.ts\");\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/bun/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC;AACzB,OAAO,CAAC,WAAW,GAAG,CAAC,GAAG,EAAE,GAAE,CAAC,CAA+B,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,iBAAiB,EAAE,CAAC;AAEpB,0EAA0E;AAC1E,mDAAmD;AACnD,KAAK,MAAM,CAAC,uBAAuB,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { APP_NAME } from \"../config.ts\";\n\nprocess.title = APP_NAME;\nprocess.emitWarning = (() => {}) as typeof process.emitWarning;\n\nimport { restoreSandboxEnv } from \"./restore-sandbox-env.ts\";\n\nrestoreSandboxEnv();\n\n// No top-level await: the compiled binary is built with --bytecode (CJS),\n// which forbids TLA anywhere in the bundled graph.\nvoid import(\"./register-bedrock.ts\").then(() => import(\"../cli.ts\"));\n"]}
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"","sourcesContent":["#!/usr/bin/env node\n/**\n * CLI entry point for the refactored coding agent.\n * Uses main.ts with AgentSession and new mode modules.\n *\n * Test with: npx tsx src/cli-new.ts [args...]\n */\nimport { configureHttpDispatcher } from \"./core/http-dispatcher.ts\";\nimport { APP_NAME } from \"./config.ts\";\nimport { main } from \"./main.ts\";\n\nprocess.title = APP_NAME;\nprocess.env[`${APP_NAME.toUpperCase()}_CODING_AGENT`] = \"true\";\nprocess.emitWarning = (() => {}) as typeof process.emitWarning;\n\nconfigureHttpDispatcher();\n\nmain(process.argv.slice(2));\n"]}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"","sourcesContent":["#!/usr/bin/env node\n/**\n * CLI entry point for the refactored coding agent.\n * Uses main.ts with AgentSession and new mode modules.\n *\n * Test with: npx tsx src/cli-new.ts [args...]\n *\n * Deliberately imports only config.ts statically: the full CLI module graph is\n * loaded dynamically so metadata fast paths (e.g. --version) skip it entirely.\n */\nimport { APP_NAME, VERSION } from \"./config.ts\";\n\nprocess.title = APP_NAME;\nprocess.env[`${APP_NAME.toUpperCase()}_CODING_AGENT`] = \"true\";\nprocess.emitWarning = (() => {}) as typeof process.emitWarning;\n\nconst args = process.argv.slice(2);\n\nif (args[0] === \"--version\" || args[0] === \"-v\") {\n\tconsole.log(VERSION);\n\tprocess.exit(0);\n}\n\n// No top-level await: the compiled binary is built with --bytecode (CJS),\n// which forbids TLA anywhere in the bundled graph.\nvoid Promise.all([import(\"./core/http-dispatcher.ts\"), import(\"./main.ts\")]).then(\n\t([{ configureHttpDispatcher }, { main }]) => {\n\t\tconfigureHttpDispatcher();\n\t\tmain(args);\n\t},\n);\n"]}
package/dist/cli.js CHANGED
@@ -4,13 +4,23 @@
4
4
  * Uses main.ts with AgentSession and new mode modules.
5
5
  *
6
6
  * Test with: npx tsx src/cli-new.ts [args...]
7
+ *
8
+ * Deliberately imports only config.ts statically: the full CLI module graph is
9
+ * loaded dynamically so metadata fast paths (e.g. --version) skip it entirely.
7
10
  */
8
- import { configureHttpDispatcher } from "./core/http-dispatcher.js";
9
- import { APP_NAME } from "./config.js";
10
- import { main } from "./main.js";
11
+ import { APP_NAME, VERSION } from "./config.js";
11
12
  process.title = APP_NAME;
12
13
  process.env[`${APP_NAME.toUpperCase()}_CODING_AGENT`] = "true";
13
14
  process.emitWarning = (() => { });
14
- configureHttpDispatcher();
15
- main(process.argv.slice(2));
15
+ const args = process.argv.slice(2);
16
+ if (args[0] === "--version" || args[0] === "-v") {
17
+ console.log(VERSION);
18
+ process.exit(0);
19
+ }
20
+ // No top-level await: the compiled binary is built with --bytecode (CJS),
21
+ // which forbids TLA anywhere in the bundled graph.
22
+ void Promise.all([import("./core/http-dispatcher.js"), import("./main.js")]).then(([{ configureHttpDispatcher }, { main }]) => {
23
+ configureHttpDispatcher();
24
+ main(args);
25
+ });
16
26
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AACH,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC;AACzB,OAAO,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,WAAW,EAAE,eAAe,CAAC,GAAG,MAAM,CAAC;AAC/D,OAAO,CAAC,WAAW,GAAG,CAAC,GAAG,EAAE,GAAE,CAAC,CAA+B,CAAC;AAE/D,uBAAuB,EAAE,CAAC;AAE1B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n/**\n * CLI entry point for the refactored coding agent.\n * Uses main.ts with AgentSession and new mode modules.\n *\n * Test with: npx tsx src/cli-new.ts [args...]\n */\nimport { configureHttpDispatcher } from \"./core/http-dispatcher.ts\";\nimport { APP_NAME } from \"./config.ts\";\nimport { main } from \"./main.ts\";\n\nprocess.title = APP_NAME;\nprocess.env[`${APP_NAME.toUpperCase()}_CODING_AGENT`] = \"true\";\nprocess.emitWarning = (() => {}) as typeof process.emitWarning;\n\nconfigureHttpDispatcher();\n\nmain(process.argv.slice(2));\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA;;;;;;;;GAQG;AACH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC;AACzB,OAAO,CAAC,GAAG,CAAC,GAAG,QAAQ,CAAC,WAAW,EAAE,eAAe,CAAC,GAAG,MAAM,CAAC;AAC/D,OAAO,CAAC,WAAW,GAAG,CAAC,GAAG,EAAE,GAAE,CAAC,CAA+B,CAAC;AAE/D,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEnC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;IACjD,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC;AAED,0EAA0E;AAC1E,mDAAmD;AACnD,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,2BAA2B,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAChF,CAAC,CAAC,EAAE,uBAAuB,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE;IAC3C,uBAAuB,EAAE,CAAC;IAC1B,IAAI,CAAC,IAAI,CAAC,CAAC;AACZ,CAAC,CACD,CAAC","sourcesContent":["#!/usr/bin/env node\n/**\n * CLI entry point for the refactored coding agent.\n * Uses main.ts with AgentSession and new mode modules.\n *\n * Test with: npx tsx src/cli-new.ts [args...]\n *\n * Deliberately imports only config.ts statically: the full CLI module graph is\n * loaded dynamically so metadata fast paths (e.g. --version) skip it entirely.\n */\nimport { APP_NAME, VERSION } from \"./config.ts\";\n\nprocess.title = APP_NAME;\nprocess.env[`${APP_NAME.toUpperCase()}_CODING_AGENT`] = \"true\";\nprocess.emitWarning = (() => {}) as typeof process.emitWarning;\n\nconst args = process.argv.slice(2);\n\nif (args[0] === \"--version\" || args[0] === \"-v\") {\n\tconsole.log(VERSION);\n\tprocess.exit(0);\n}\n\n// No top-level await: the compiled binary is built with --bytecode (CJS),\n// which forbids TLA anywhere in the bundled graph.\nvoid Promise.all([import(\"./core/http-dispatcher.ts\"), import(\"./main.ts\")]).then(\n\t([{ configureHttpDispatcher }, { main }]) => {\n\t\tconfigureHttpDispatcher();\n\t\tmain(args);\n\t},\n);\n"]}
package/dist/config.d.ts CHANGED
@@ -1,8 +1,10 @@
1
+ export declare const isBunBinary: boolean;
1
2
  /**
2
- * Detect if we're running as a Bun compiled binary.
3
- * Bun binaries have import.meta.url containing "$bunfs", "~BUN", or "%7EBUN" (Bun's virtual filesystem path)
3
+ * Detect if we're running from a single-file bundle produced by `bun run bundle:dev`.
4
+ * The bundle build inlines this env var via `--define`, so it is a compile-time
5
+ * constant there and undefined everywhere else.
4
6
  */
5
- export declare const isBunBinary: boolean;
7
+ export declare const isBundledBuild: boolean;
6
8
  /** Detect if Bun is the runtime (compiled binary or bun run) */
7
9
  export declare const isBunRuntime: boolean;
8
10
  export type { InstallMethod, SelfUpdateCommand } from "./config-self-update.ts";
@@ -115,6 +117,11 @@ export declare function getSettingsPath(): string;
115
117
  export declare function getToolsDir(): string;
116
118
  /** Get path to managed binaries directory (fd, rg) */
117
119
  export declare function getBinDir(): string;
120
+ /**
121
+ * Get path to the extension transpile cache directory (jiti fsCache).
122
+ * Scoped by version so release upgrades never read stale transpiled output.
123
+ */
124
+ export declare function getExtensionTranspileCacheDir(): string;
118
125
  /** Get path to prompt templates directory */
119
126
  export declare function getPromptsDir(): string;
120
127
  /** Get path to sessions directory */
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,eAAO,MAAM,WAAW,SACqF,CAAC;AAE9G,gEAAgE;AAChE,eAAO,MAAM,YAAY,SAAyB,CAAC;AAanD,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAWhF,wBAAgB,mBAAmB,IAAI,OAAO,yBAAyB,EAAE,aAAa,CAErF;AAED,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,EAAE,EACrB,iBAAiB,SAAc,GAC7B,OAAO,yBAAyB,EAAE,iBAAiB,GAAG,SAAS,CAEjE;AAED,wBAAgB,mCAAmC,CAClD,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,EAAE,EACrB,iBAAiB,SAAc,GAC7B,MAAM,CAER;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,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B,iBAAiB,IAAI,MAAM,CAE1C;AAED,qFAAqF;AACrF,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAOvC;AAED,yFAAyF;AACzF,wBAAgB,iBAAiB,IAAI,MAAM,EAAE,CAE5C;AAED,uFAAuF;AACvF,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAE1D;AAED,0DAA0D;AAC1D,wBAAgB,kBAAkB,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAElE;AAED,sDAAsD;AACtD,wBAAgB,mBAAmB,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAEnE;AAED,wDAAwD;AACxD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAElF;AAED,iDAAiD;AACjD,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,8BAA8B;AAC9B,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,4BAA4B;AAC5B,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,gCAAgC;AAChC,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,kCAAkC;AAClC,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,sDAAsD;AACtD,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED,6CAA6C;AAC7C,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,qCAAqC;AACrC,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,iCAAiC;AACjC,wBAAgB,eAAe,IAAI,MAAM,CAExC","sourcesContent":["import { existsSync, readFileSync } from \"fs\";\nimport { dirname, join, resolve } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport { getHomeDir, normalizePath } from \"./utils/paths.ts\";\n\n// =============================================================================\n// Package Detection\n// =============================================================================\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Detect if we're running as a Bun compiled binary.\n * Bun binaries have import.meta.url containing \"$bunfs\", \"~BUN\", or \"%7EBUN\" (Bun's virtual filesystem path)\n */\nexport const isBunBinary =\n\timport.meta.url.includes(\"$bunfs\") || import.meta.url.includes(\"~BUN\") || import.meta.url.includes(\"%7EBUN\");\n\n/** Detect if Bun is the runtime (compiled binary or bun run) */\nexport const isBunRuntime = !!process.versions.bun;\n\n// =============================================================================\n// Install Method Detection\n// =============================================================================\n\nimport {\n\tdetectInstallMethodForRuntime,\n\tgetSelfUpdateCommandForRuntime,\n\tgetSelfUpdateUnavailableInstructionForRuntime,\n\tgetUpdateInstructionForRuntime,\n\ttype SelfUpdateRuntime,\n} from \"./config-self-update.ts\";\nexport type { InstallMethod, SelfUpdateCommand } from \"./config-self-update.ts\";\n\nfunction selfUpdateRuntime(): SelfUpdateRuntime {\n\treturn {\n\t\tisBunBinary,\n\t\tisBunRuntime,\n\t\tmoduleDir: __dirname,\n\t\tgetPackageDir,\n\t};\n}\n\nexport function detectInstallMethod(): import(\"./config-self-update.ts\").InstallMethod {\n\treturn detectInstallMethodForRuntime(selfUpdateRuntime());\n}\n\nexport function getSelfUpdateCommand(\n\tpackageName: string,\n\tnpmCommand?: string[],\n\tupdatePackageName = packageName,\n): import(\"./config-self-update.ts\").SelfUpdateCommand | undefined {\n\treturn getSelfUpdateCommandForRuntime(selfUpdateRuntime(), packageName, npmCommand, updatePackageName);\n}\n\nexport function getSelfUpdateUnavailableInstruction(\n\tpackageName: string,\n\tnpmCommand?: string[],\n\tupdatePackageName = packageName,\n): string {\n\treturn getSelfUpdateUnavailableInstructionForRuntime(selfUpdateRuntime(), packageName, npmCommand, updatePackageName);\n}\n\nexport function getUpdateInstruction(packageName: string): string {\n\treturn getUpdateInstructionForRuntime(selfUpdateRuntime(), packageName);\n}\n\n// =============================================================================\n// Package Asset Paths (shipped with executable)\n// =============================================================================\n\n/**\n * Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md).\n * - For Bun binary: returns the directory containing the executable\n * - For Node.js (dist/): returns __dirname (the dist/ directory)\n * - For tsx (src/): returns parent directory (the package root)\n */\nexport function getPackageDir(): string {\n\t// Allow override via environment variable (useful for Nix/Guix where store paths tokenize poorly).\n\t// This runs before package.json app config is read, so the env var name is hardcoded.\n\tconst envDir = process.env.ATOMIC_PACKAGE_DIR ?? process.env.PI_PACKAGE_DIR;\n\tif (envDir) {\n\t\treturn normalizePath(envDir);\n\t}\n\n\tif (isBunBinary) {\n\t\t// Bun binary: process.execPath points to the compiled executable\n\t\treturn dirname(process.execPath);\n\t}\n\t// Node.js: walk up from __dirname until we find package.json\n\tlet dir = __dirname;\n\twhile (dir !== dirname(dir)) {\n\t\tif (existsSync(join(dir, \"package.json\"))) {\n\t\t\treturn dir;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\t// Fallback (shouldn't happen)\n\treturn __dirname;\n}\n\n/**\n * Get path to built-in themes directory (shipped with package)\n * - For Bun binary: theme/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/theme/\n * - For tsx (src/): src/modes/interactive/theme/\n */\nexport function getThemesDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(getPackageDir(), \"theme\");\n\t}\n\t// Theme is in modes/interactive/theme/ relative to src/ or dist/\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"modes\", \"interactive\", \"theme\");\n}\n\n/**\n * Get path to HTML export template directory (shipped with package)\n * - For Bun binary: export-html/ next to executable\n * - For Node.js (dist/): dist/core/export-html/\n * - For tsx (src/): src/core/export-html/\n */\nexport function getExportTemplateDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(getPackageDir(), \"export-html\");\n\t}\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"core\", \"export-html\");\n}\n\n/** Get path to package.json */\nexport function getPackageJsonPath(): string {\n\treturn join(getPackageDir(), \"package.json\");\n}\n\n/** Get path to README.md */\nexport function getReadmePath(): string {\n\treturn resolve(join(getPackageDir(), \"README.md\"));\n}\n\n/** Get path to docs directory */\nexport function getDocsPath(): string {\n\treturn resolve(join(getPackageDir(), \"docs\"));\n}\n\n/** Get path to examples directory */\nexport function getExamplesPath(): string {\n\treturn resolve(join(getPackageDir(), \"examples\"));\n}\n\n/** Get path to CHANGELOG.md */\nexport function getChangelogPath(): string {\n\treturn resolve(join(getPackageDir(), \"CHANGELOG.md\"));\n}\n\n/**\n * Get path to built-in interactive assets directory.\n * - For Bun binary: assets/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/assets/\n * - For tsx (src/): src/modes/interactive/assets/\n */\nexport function getInteractiveAssetsDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(getPackageDir(), \"assets\");\n\t}\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"modes\", \"interactive\", \"assets\");\n}\n\n/** Get path to a bundled interactive asset */\nexport function getBundledInteractiveAssetPath(name: string): string {\n\treturn join(getInteractiveAssetsDir(), name);\n}\n\n// =============================================================================\n// App Config (from package.json <appName>Config, with piConfig as a legacy shim)\n// =============================================================================\n\ninterface AppConfig {\n\tname?: string;\n\tconfigDir?: string;\n\tchangelogUrl?: string;\n}\n\ninterface PackageJson extends Record<string, unknown> {\n\tname?: string;\n\tversion?: string;\n\tpiConfig?: AppConfig;\n}\n\nlet pkg: PackageJson = {};\ntry {\n\tpkg = JSON.parse(readFileSync(getPackageJsonPath(), \"utf-8\")) as PackageJson;\n} catch (e: unknown) {\n\tconst err = e as NodeJS.ErrnoException;\n\tif (err.code !== \"ENOENT\") throw e;\n}\n\nfunction appNameFromPackageName(packageName: string | undefined): string | undefined {\n\tconst localName = packageName?.split(\"/\").pop()?.trim();\n\treturn localName && localName.length > 0 ? localName : undefined;\n}\n\nfunction readAppConfig(packageJson: PackageJson, appName: string | undefined): AppConfig | undefined {\n\tif (appName) {\n\t\tconst appConfig = packageJson[`${appName}Config`];\n\t\tif (appConfig && typeof appConfig === \"object\" && !Array.isArray(appConfig)) {\n\t\t\treturn appConfig as AppConfig;\n\t\t}\n\t}\n\treturn packageJson.piConfig;\n}\n\nexport const PACKAGE_NAME: string = pkg.name || \"@bastani/atomic\";\nconst packageAppName = appNameFromPackageName(PACKAGE_NAME);\nconst appConfig = readAppConfig(pkg, packageAppName);\nexport const APP_NAME: string = appConfig?.name || packageAppName || \"pi\";\nexport const APP_TITLE: string = appConfig?.name !== undefined || APP_NAME !== \"pi\" ? APP_NAME : \"π\";\nexport const CONFIG_DIR_NAME: string = appConfig?.configDir || (APP_NAME === \"pi\" ? \".pi\" : `.${APP_NAME}`);\nexport const LEGACY_CONFIG_DIR_NAME = \".pi\";\nexport const CONFIG_DIR_NAMES: readonly string[] =\n\tCONFIG_DIR_NAME === LEGACY_CONFIG_DIR_NAME ? [CONFIG_DIR_NAME] : [CONFIG_DIR_NAME, LEGACY_CONFIG_DIR_NAME];\nexport const VERSION: string = pkg.version || \"0.0.0\";\nexport const CHANGELOG_URL: string | undefined = appConfig?.changelogUrl?.trim() || undefined;\n\nconst ENV_PREFIX = APP_NAME.toUpperCase();\nexport const LEGACY_ENV_PREFIX = \"PI\";\n\n// e.g., ATOMIC_CODING_AGENT_DIR (with PI_CODING_AGENT_DIR as a compatibility alias)\nexport const ENV_AGENT_DIR = `${ENV_PREFIX}_CODING_AGENT_DIR`;\nexport const ENV_SESSION_DIR = `${ENV_PREFIX}_CODING_AGENT_SESSION_DIR`;\nexport const ENV_PACKAGE_DIR = `${ENV_PREFIX}_PACKAGE_DIR`;\nexport const ENV_OFFLINE = `${ENV_PREFIX}_OFFLINE`;\nexport const ENV_SKIP_VERSION_CHECK = `${ENV_PREFIX}_SKIP_VERSION_CHECK`;\nexport const ENV_STARTUP_BENCHMARK = `${ENV_PREFIX}_STARTUP_BENCHMARK`;\nexport const ENV_TELEMETRY = `${ENV_PREFIX}_TELEMETRY`;\nexport const ENV_SHARE_VIEWER_URL = `${ENV_PREFIX}_SHARE_VIEWER_URL`;\nexport const ENV_CLEAR_ON_SHRINK = `${ENV_PREFIX}_CLEAR_ON_SHRINK`;\nexport const ENV_HARDWARE_CURSOR = `${ENV_PREFIX}_HARDWARE_CURSOR`;\nexport const ENV_TIMING = `${ENV_PREFIX}_TIMING`;\nexport const ENV_CODEX_FAST_MODE = `${ENV_PREFIX}_CODEX_FAST_MODE`;\nexport const WORKFLOW_STAGE_SUBAGENT_GUARD_ENV = `${ENV_PREFIX}_WORKFLOW_STAGE_SUBAGENT_GUARD`;\n\nexport interface CodexFastModeEnvironmentSettings {\n\tchat?: boolean;\n\tworkflow?: boolean;\n}\n\nfunction parseCodexFastModeEnvBoolean(value: string | undefined): boolean | undefined {\n\tswitch (value?.trim().toLowerCase()) {\n\t\tcase \"1\":\n\t\tcase \"true\":\n\t\tcase \"enabled\":\n\t\tcase \"on\":\n\t\t\treturn true;\n\t\tcase \"0\":\n\t\tcase \"false\":\n\t\tcase \"disabled\":\n\t\tcase \"off\":\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nexport function serializeCodexFastModeEnvironmentSettings(settings: Required<CodexFastModeEnvironmentSettings>): string {\n\treturn `chat=${settings.chat ? \"1\" : \"0\"};workflow=${settings.workflow ? \"1\" : \"0\"}`;\n}\n\nexport function parseCodexFastModeEnvironmentSettings(value: string | undefined): CodexFastModeEnvironmentSettings | undefined {\n\tif (!value) return undefined;\n\tconst settings: CodexFastModeEnvironmentSettings = {};\n\tfor (const part of value.split(/[;,]/)) {\n\t\tconst separatorIndex = part.indexOf(\"=\");\n\t\tif (separatorIndex === -1) continue;\n\t\tconst key = part.slice(0, separatorIndex).trim();\n\t\tconst parsedValue = parseCodexFastModeEnvBoolean(part.slice(separatorIndex + 1));\n\t\tif (parsedValue === undefined) continue;\n\t\tif (key === \"chat\") settings.chat = parsedValue;\n\t\tif (key === \"workflow\") settings.workflow = parsedValue;\n\t}\n\treturn settings.chat !== undefined || settings.workflow !== undefined ? settings : undefined;\n}\n\nexport function getCodexFastModeEnvironmentSettings(): CodexFastModeEnvironmentSettings | undefined {\n\treturn parseCodexFastModeEnvironmentSettings(getEnvValue(ENV_CODEX_FAST_MODE));\n}\n\nexport function setCodexFastModeEnvironmentSettings(settings: Required<CodexFastModeEnvironmentSettings>): void {\n\tsetEnvValue(ENV_CODEX_FAST_MODE, serializeCodexFastModeEnvironmentSettings(settings));\n}\n\nexport function getEnvNames(name: string): string[] {\n\tif (ENV_PREFIX === LEGACY_ENV_PREFIX || !name.startsWith(`${ENV_PREFIX}_`)) return [name];\n\treturn [name, `${LEGACY_ENV_PREFIX}_${name.slice(ENV_PREFIX.length + 1)}`];\n}\n\nexport function getEnvValue(name: string): string | undefined {\n\tfor (const candidate of getEnvNames(name)) {\n\t\tconst value = process.env[candidate];\n\t\tif (value !== undefined) return value;\n\t}\n\treturn undefined;\n}\n\nexport function hasEnvValue(name: string): boolean {\n\treturn getEnvValue(name) !== undefined;\n}\n\nexport function setEnvValue(name: string, value: string): void {\n\tprocess.env[name] = value;\n}\n\nexport function expandTildePath(path: string): string {\n\treturn normalizePath(path);\n}\n\nconst DEFAULT_SHARE_VIEWER_URL = \"https://pi.dev/session/\";\n\n/** Get the share viewer URL for a gist ID */\nexport function getShareViewerUrl(gistId: string): string {\n\tconst baseUrl = getEnvValue(ENV_SHARE_VIEWER_URL) || DEFAULT_SHARE_VIEWER_URL;\n\treturn `${baseUrl}#${gistId}`;\n}\n\n// =============================================================================\n// User Config Paths (~/.atomic/agent/*)\n// =============================================================================\n\n/** Get the agent config directory (e.g., ~/.atomic/agent/) */\nexport function getAgentDir(): string {\n\tconst envDir = getEnvValue(ENV_AGENT_DIR);\n\tif (envDir) {\n\t\treturn expandTildePath(envDir);\n\t}\n\treturn join(getHomeDir(), CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get the legacy pi agent config directory (e.g., ~/.pi/agent/) */\nexport function getLegacyAgentDir(): string {\n\treturn join(getHomeDir(), LEGACY_CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get agent config directories in precedence order (primary first, then legacy). */\nexport function getAgentDirs(): string[] {\n\tconst primary = getAgentDir();\n\tif (hasEnvValue(ENV_AGENT_DIR) || CONFIG_DIR_NAME === LEGACY_CONFIG_DIR_NAME) {\n\t\treturn [primary];\n\t}\n\tconst legacy = getLegacyAgentDir();\n\treturn legacy === primary ? [primary] : [primary, legacy];\n}\n\n/** Get user config root directories in precedence order (primary first, then legacy). */\nexport function getUserConfigDirs(): string[] {\n\treturn CONFIG_DIR_NAMES.map((name) => join(getHomeDir(), name));\n}\n\n/** Get project config directories in precedence order (primary first, then legacy). */\nexport function getProjectConfigDirs(cwd: string): string[] {\n\treturn CONFIG_DIR_NAMES.map((name) => join(cwd, name));\n}\n\n/** Get a path inside every user config root directory. */\nexport function getUserConfigPaths(...segments: string[]): string[] {\n\treturn getUserConfigDirs().map((dir) => join(dir, ...segments));\n}\n\n/** Get a path inside every agent config directory. */\nexport function getAgentConfigPaths(...segments: string[]): string[] {\n\treturn getAgentDirs().map((dir) => join(dir, ...segments));\n}\n\n/** Get a path inside every project config directory. */\nexport function getProjectConfigPaths(cwd: string, ...segments: string[]): string[] {\n\treturn getProjectConfigDirs(cwd).map((dir) => join(dir, ...segments));\n}\n\n/** Get path to user's custom themes directory */\nexport function getCustomThemesDir(): string {\n\treturn join(getAgentDir(), \"themes\");\n}\n\n/** Get path to models.json */\nexport function getModelsPath(): string {\n\treturn join(getAgentDir(), \"models.json\");\n}\n\n/** Get path to auth.json */\nexport function getAuthPath(): string {\n\treturn join(getAgentDir(), \"auth.json\");\n}\n\n/** Get path to settings.json */\nexport function getSettingsPath(): string {\n\treturn join(getAgentDir(), \"settings.json\");\n}\n\n/** Get path to tools directory */\nexport function getToolsDir(): string {\n\treturn join(getAgentDir(), \"tools\");\n}\n\n/** Get path to managed binaries directory (fd, rg) */\nexport function getBinDir(): string {\n\treturn join(getAgentDir(), \"bin\");\n}\n\n/** Get path to prompt templates directory */\nexport function getPromptsDir(): string {\n\treturn join(getAgentDir(), \"prompts\");\n}\n\n/** Get path to sessions directory */\nexport function getSessionsDir(): string {\n\treturn join(getAgentDir(), \"sessions\");\n}\n\n/** Get path to debug log file */\nexport function getDebugLogPath(): string {\n\treturn join(getAgentDir(), `${APP_NAME}-debug.log`);\n}\n"]}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAoBA,eAAO,MAAM,WAAW,SAEvB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,SAA2C,CAAC;AAEvE,gEAAgE;AAChE,eAAO,MAAM,YAAY,SAAyB,CAAC;AAanD,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAWhF,wBAAgB,mBAAmB,IAAI,OAAO,yBAAyB,EAAE,aAAa,CAErF;AAED,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,EAAE,EACrB,iBAAiB,SAAc,GAC7B,OAAO,yBAAyB,EAAE,iBAAiB,GAAG,SAAS,CAEjE;AAED,wBAAgB,mCAAmC,CAClD,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,EAAE,EACrB,iBAAiB,SAAc,GAC7B,MAAM,CAER;AAED,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAEhE;AAMD;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAsBtC;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAQrC;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAO7C;AAED,+BAA+B;AAC/B,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,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;AAC1D,wBAAgB,kBAAkB,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAElE;AAED,sDAAsD;AACtD,wBAAgB,mBAAmB,CAAC,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAEnE;AAED,wDAAwD;AACxD,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAElF;AAED,iDAAiD;AACjD,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,8BAA8B;AAC9B,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,4BAA4B;AAC5B,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,gCAAgC;AAChC,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED,kCAAkC;AAClC,wBAAgB,WAAW,IAAI,MAAM,CAEpC;AAED,sDAAsD;AACtD,wBAAgB,SAAS,IAAI,MAAM,CAElC;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,IAAI,MAAM,CAEtD;AAED,6CAA6C;AAC7C,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED,qCAAqC;AACrC,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,iCAAiC;AACjC,wBAAgB,eAAe,IAAI,MAAM,CAExC","sourcesContent":["import { existsSync, readFileSync } from \"fs\";\nimport { dirname, join, resolve } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport { getHomeDir, normalizePath } from \"./utils/paths.ts\";\n\n// =============================================================================\n// Package Detection\n// =============================================================================\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Detect if we're running as a Bun compiled binary.\n * Bun binaries have import.meta.url containing \"$bunfs\", \"~BUN\", or \"%7EBUN\" (Bun's virtual filesystem path)\n */\nconst bunFsMarkers = [\"$bunfs\", \"~BUN\", \"%7EBUN\"];\n// Check process.argv[1] as well as import.meta.url: in a CJS (bytecode) bundle\n// import.meta.url is rewritten to the original source path, but argv[1] still\n// points into Bun's virtual filesystem.\nexport const isBunBinary = [import.meta.url, process.argv[1] ?? \"\"].some((candidate) =>\n\tbunFsMarkers.some((marker) => candidate.includes(marker)),\n);\n\n/**\n * Detect if we're running from a single-file bundle produced by `bun run bundle:dev`.\n * The bundle build inlines this env var via `--define`, so it is a compile-time\n * constant there and undefined everywhere else.\n */\nexport const isBundledBuild = process.env.ATOMIC_BUNDLED_BUILD === \"1\";\n\n/** Detect if Bun is the runtime (compiled binary or bun run) */\nexport const isBunRuntime = !!process.versions.bun;\n\n// =============================================================================\n// Install Method Detection\n// =============================================================================\n\nimport {\n\tdetectInstallMethodForRuntime,\n\tgetSelfUpdateCommandForRuntime,\n\tgetSelfUpdateUnavailableInstructionForRuntime,\n\tgetUpdateInstructionForRuntime,\n\ttype SelfUpdateRuntime,\n} from \"./config-self-update.ts\";\nexport type { InstallMethod, SelfUpdateCommand } from \"./config-self-update.ts\";\n\nfunction selfUpdateRuntime(): SelfUpdateRuntime {\n\treturn {\n\t\tisBunBinary,\n\t\tisBunRuntime,\n\t\tmoduleDir: __dirname,\n\t\tgetPackageDir,\n\t};\n}\n\nexport function detectInstallMethod(): import(\"./config-self-update.ts\").InstallMethod {\n\treturn detectInstallMethodForRuntime(selfUpdateRuntime());\n}\n\nexport function getSelfUpdateCommand(\n\tpackageName: string,\n\tnpmCommand?: string[],\n\tupdatePackageName = packageName,\n): import(\"./config-self-update.ts\").SelfUpdateCommand | undefined {\n\treturn getSelfUpdateCommandForRuntime(selfUpdateRuntime(), packageName, npmCommand, updatePackageName);\n}\n\nexport function getSelfUpdateUnavailableInstruction(\n\tpackageName: string,\n\tnpmCommand?: string[],\n\tupdatePackageName = packageName,\n): string {\n\treturn getSelfUpdateUnavailableInstructionForRuntime(selfUpdateRuntime(), packageName, npmCommand, updatePackageName);\n}\n\nexport function getUpdateInstruction(packageName: string): string {\n\treturn getUpdateInstructionForRuntime(selfUpdateRuntime(), packageName);\n}\n\n// =============================================================================\n// Package Asset Paths (shipped with executable)\n// =============================================================================\n\n/**\n * Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md).\n * - For Bun binary: returns the directory containing the executable\n * - For Node.js (dist/): returns __dirname (the dist/ directory)\n * - For tsx (src/): returns parent directory (the package root)\n */\nexport function getPackageDir(): string {\n\t// Allow override via environment variable (useful for Nix/Guix where store paths tokenize poorly).\n\t// This runs before package.json app config is read, so the env var name is hardcoded.\n\tconst envDir = process.env.ATOMIC_PACKAGE_DIR ?? process.env.PI_PACKAGE_DIR;\n\tif (envDir) {\n\t\treturn normalizePath(envDir);\n\t}\n\n\tif (isBunBinary) {\n\t\t// Bun binary: process.execPath points to the compiled executable\n\t\treturn dirname(process.execPath);\n\t}\n\t// Node.js: walk up from __dirname until we find package.json\n\tlet dir = __dirname;\n\twhile (dir !== dirname(dir)) {\n\t\tif (existsSync(join(dir, \"package.json\"))) {\n\t\t\treturn dir;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\t// Fallback (shouldn't happen)\n\treturn __dirname;\n}\n\n/**\n * Get path to built-in themes directory (shipped with package)\n * - For Bun binary: theme/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/theme/\n * - For tsx (src/): src/modes/interactive/theme/\n */\nexport function getThemesDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(getPackageDir(), \"theme\");\n\t}\n\t// Theme is in modes/interactive/theme/ relative to src/ or dist/\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"modes\", \"interactive\", \"theme\");\n}\n\n/**\n * Get path to HTML export template directory (shipped with package)\n * - For Bun binary: export-html/ next to executable\n * - For Node.js (dist/): dist/core/export-html/\n * - For tsx (src/): src/core/export-html/\n */\nexport function getExportTemplateDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(getPackageDir(), \"export-html\");\n\t}\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"core\", \"export-html\");\n}\n\n/** Get path to package.json */\nexport function getPackageJsonPath(): string {\n\treturn join(getPackageDir(), \"package.json\");\n}\n\n/** Get path to README.md */\nexport function getReadmePath(): string {\n\treturn resolve(join(getPackageDir(), \"README.md\"));\n}\n\n/** Get path to docs directory */\nexport function getDocsPath(): string {\n\treturn resolve(join(getPackageDir(), \"docs\"));\n}\n\n/** Get path to examples directory */\nexport function getExamplesPath(): string {\n\treturn resolve(join(getPackageDir(), \"examples\"));\n}\n\n/** Get path to CHANGELOG.md */\nexport function getChangelogPath(): string {\n\treturn resolve(join(getPackageDir(), \"CHANGELOG.md\"));\n}\n\n/**\n * Get path to built-in interactive assets directory.\n * - For Bun binary: assets/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/assets/\n * - For tsx (src/): src/modes/interactive/assets/\n */\nexport function getInteractiveAssetsDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(getPackageDir(), \"assets\");\n\t}\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"modes\", \"interactive\", \"assets\");\n}\n\n/** Get path to a bundled interactive asset */\nexport function getBundledInteractiveAssetPath(name: string): string {\n\treturn join(getInteractiveAssetsDir(), name);\n}\n\n// =============================================================================\n// App Config (from package.json <appName>Config, with piConfig as a legacy shim)\n// =============================================================================\n\ninterface AppConfig {\n\tname?: string;\n\tconfigDir?: string;\n\tchangelogUrl?: string;\n}\n\ninterface PackageJson extends Record<string, unknown> {\n\tname?: string;\n\tversion?: string;\n\tpiConfig?: AppConfig;\n}\n\nlet pkg: PackageJson = {};\ntry {\n\tpkg = JSON.parse(readFileSync(getPackageJsonPath(), \"utf-8\")) as PackageJson;\n} catch (e: unknown) {\n\tconst err = e as NodeJS.ErrnoException;\n\tif (err.code !== \"ENOENT\") throw e;\n}\n\nfunction appNameFromPackageName(packageName: string | undefined): string | undefined {\n\tconst localName = packageName?.split(\"/\").pop()?.trim();\n\treturn localName && localName.length > 0 ? localName : undefined;\n}\n\nfunction readAppConfig(packageJson: PackageJson, appName: string | undefined): AppConfig | undefined {\n\tif (appName) {\n\t\tconst appConfig = packageJson[`${appName}Config`];\n\t\tif (appConfig && typeof appConfig === \"object\" && !Array.isArray(appConfig)) {\n\t\t\treturn appConfig as AppConfig;\n\t\t}\n\t}\n\treturn packageJson.piConfig;\n}\n\nexport const PACKAGE_NAME: string = pkg.name || \"@bastani/atomic\";\nconst packageAppName = appNameFromPackageName(PACKAGE_NAME);\nconst appConfig = readAppConfig(pkg, packageAppName);\nexport const APP_NAME: string = appConfig?.name || packageAppName || \"pi\";\nexport const APP_TITLE: string = appConfig?.name !== undefined || APP_NAME !== \"pi\" ? APP_NAME : \"π\";\nexport const CONFIG_DIR_NAME: string = appConfig?.configDir || (APP_NAME === \"pi\" ? \".pi\" : `.${APP_NAME}`);\nexport const LEGACY_CONFIG_DIR_NAME = \".pi\";\nexport const CONFIG_DIR_NAMES: readonly string[] =\n\tCONFIG_DIR_NAME === LEGACY_CONFIG_DIR_NAME ? [CONFIG_DIR_NAME] : [CONFIG_DIR_NAME, LEGACY_CONFIG_DIR_NAME];\nexport const VERSION: string = pkg.version || \"0.0.0\";\nexport const CHANGELOG_URL: string | undefined = appConfig?.changelogUrl?.trim() || undefined;\n\nconst ENV_PREFIX = APP_NAME.toUpperCase();\nexport const LEGACY_ENV_PREFIX = \"PI\";\n\n// e.g., ATOMIC_CODING_AGENT_DIR (with PI_CODING_AGENT_DIR as a compatibility alias)\nexport const ENV_AGENT_DIR = `${ENV_PREFIX}_CODING_AGENT_DIR`;\nexport const ENV_SESSION_DIR = `${ENV_PREFIX}_CODING_AGENT_SESSION_DIR`;\nexport const ENV_PACKAGE_DIR = `${ENV_PREFIX}_PACKAGE_DIR`;\nexport const ENV_OFFLINE = `${ENV_PREFIX}_OFFLINE`;\nexport const ENV_SKIP_VERSION_CHECK = `${ENV_PREFIX}_SKIP_VERSION_CHECK`;\nexport const ENV_STARTUP_BENCHMARK = `${ENV_PREFIX}_STARTUP_BENCHMARK`;\nexport const ENV_TELEMETRY = `${ENV_PREFIX}_TELEMETRY`;\nexport const ENV_SHARE_VIEWER_URL = `${ENV_PREFIX}_SHARE_VIEWER_URL`;\nexport const ENV_CLEAR_ON_SHRINK = `${ENV_PREFIX}_CLEAR_ON_SHRINK`;\nexport const ENV_HARDWARE_CURSOR = `${ENV_PREFIX}_HARDWARE_CURSOR`;\nexport const ENV_TIMING = `${ENV_PREFIX}_TIMING`;\nexport const ENV_CODEX_FAST_MODE = `${ENV_PREFIX}_CODEX_FAST_MODE`;\nexport const WORKFLOW_STAGE_SUBAGENT_GUARD_ENV = `${ENV_PREFIX}_WORKFLOW_STAGE_SUBAGENT_GUARD`;\n\nexport interface CodexFastModeEnvironmentSettings {\n\tchat?: boolean;\n\tworkflow?: boolean;\n}\n\nfunction parseCodexFastModeEnvBoolean(value: string | undefined): boolean | undefined {\n\tswitch (value?.trim().toLowerCase()) {\n\t\tcase \"1\":\n\t\tcase \"true\":\n\t\tcase \"enabled\":\n\t\tcase \"on\":\n\t\t\treturn true;\n\t\tcase \"0\":\n\t\tcase \"false\":\n\t\tcase \"disabled\":\n\t\tcase \"off\":\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nexport function serializeCodexFastModeEnvironmentSettings(settings: Required<CodexFastModeEnvironmentSettings>): string {\n\treturn `chat=${settings.chat ? \"1\" : \"0\"};workflow=${settings.workflow ? \"1\" : \"0\"}`;\n}\n\nexport function parseCodexFastModeEnvironmentSettings(value: string | undefined): CodexFastModeEnvironmentSettings | undefined {\n\tif (!value) return undefined;\n\tconst settings: CodexFastModeEnvironmentSettings = {};\n\tfor (const part of value.split(/[;,]/)) {\n\t\tconst separatorIndex = part.indexOf(\"=\");\n\t\tif (separatorIndex === -1) continue;\n\t\tconst key = part.slice(0, separatorIndex).trim();\n\t\tconst parsedValue = parseCodexFastModeEnvBoolean(part.slice(separatorIndex + 1));\n\t\tif (parsedValue === undefined) continue;\n\t\tif (key === \"chat\") settings.chat = parsedValue;\n\t\tif (key === \"workflow\") settings.workflow = parsedValue;\n\t}\n\treturn settings.chat !== undefined || settings.workflow !== undefined ? settings : undefined;\n}\n\nexport function getCodexFastModeEnvironmentSettings(): CodexFastModeEnvironmentSettings | undefined {\n\treturn parseCodexFastModeEnvironmentSettings(getEnvValue(ENV_CODEX_FAST_MODE));\n}\n\nexport function setCodexFastModeEnvironmentSettings(settings: Required<CodexFastModeEnvironmentSettings>): void {\n\tsetEnvValue(ENV_CODEX_FAST_MODE, serializeCodexFastModeEnvironmentSettings(settings));\n}\n\nexport function getEnvNames(name: string): string[] {\n\tif (ENV_PREFIX === LEGACY_ENV_PREFIX || !name.startsWith(`${ENV_PREFIX}_`)) return [name];\n\treturn [name, `${LEGACY_ENV_PREFIX}_${name.slice(ENV_PREFIX.length + 1)}`];\n}\n\nexport function getEnvValue(name: string): string | undefined {\n\tfor (const candidate of getEnvNames(name)) {\n\t\tconst value = process.env[candidate];\n\t\tif (value !== undefined) return value;\n\t}\n\treturn undefined;\n}\n\nexport function hasEnvValue(name: string): boolean {\n\treturn getEnvValue(name) !== undefined;\n}\n\nexport function setEnvValue(name: string, value: string): void {\n\tprocess.env[name] = value;\n}\n\nexport function expandTildePath(path: string): string {\n\treturn normalizePath(path);\n}\n\nconst DEFAULT_SHARE_VIEWER_URL = \"https://pi.dev/session/\";\n\n/** Get the share viewer URL for a gist ID */\nexport function getShareViewerUrl(gistId: string): string {\n\tconst baseUrl = getEnvValue(ENV_SHARE_VIEWER_URL) || DEFAULT_SHARE_VIEWER_URL;\n\treturn `${baseUrl}#${gistId}`;\n}\n\n// =============================================================================\n// User Config Paths (~/.atomic/agent/*)\n// =============================================================================\n\n/** Get the agent config directory (e.g., ~/.atomic/agent/) */\nexport function getAgentDir(): string {\n\tconst envDir = getEnvValue(ENV_AGENT_DIR);\n\tif (envDir) {\n\t\treturn expandTildePath(envDir);\n\t}\n\treturn join(getHomeDir(), CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get the legacy pi agent config directory (e.g., ~/.pi/agent/) */\nexport function getLegacyAgentDir(): string {\n\treturn join(getHomeDir(), LEGACY_CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get agent config directories in precedence order (primary first, then legacy). */\nexport function getAgentDirs(): string[] {\n\tconst primary = getAgentDir();\n\tif (hasEnvValue(ENV_AGENT_DIR) || CONFIG_DIR_NAME === LEGACY_CONFIG_DIR_NAME) {\n\t\treturn [primary];\n\t}\n\tconst legacy = getLegacyAgentDir();\n\treturn legacy === primary ? [primary] : [primary, legacy];\n}\n\n/** Get user config root directories in precedence order (primary first, then legacy). */\nexport function getUserConfigDirs(): string[] {\n\treturn CONFIG_DIR_NAMES.map((name) => join(getHomeDir(), name));\n}\n\n/** Get project config directories in precedence order (primary first, then legacy). */\nexport function getProjectConfigDirs(cwd: string): string[] {\n\treturn CONFIG_DIR_NAMES.map((name) => join(cwd, name));\n}\n\n/** Get a path inside every user config root directory. */\nexport function getUserConfigPaths(...segments: string[]): string[] {\n\treturn getUserConfigDirs().map((dir) => join(dir, ...segments));\n}\n\n/** Get a path inside every agent config directory. */\nexport function getAgentConfigPaths(...segments: string[]): string[] {\n\treturn getAgentDirs().map((dir) => join(dir, ...segments));\n}\n\n/** Get a path inside every project config directory. */\nexport function getProjectConfigPaths(cwd: string, ...segments: string[]): string[] {\n\treturn getProjectConfigDirs(cwd).map((dir) => join(dir, ...segments));\n}\n\n/** Get path to user's custom themes directory */\nexport function getCustomThemesDir(): string {\n\treturn join(getAgentDir(), \"themes\");\n}\n\n/** Get path to models.json */\nexport function getModelsPath(): string {\n\treturn join(getAgentDir(), \"models.json\");\n}\n\n/** Get path to auth.json */\nexport function getAuthPath(): string {\n\treturn join(getAgentDir(), \"auth.json\");\n}\n\n/** Get path to settings.json */\nexport function getSettingsPath(): string {\n\treturn join(getAgentDir(), \"settings.json\");\n}\n\n/** Get path to tools directory */\nexport function getToolsDir(): string {\n\treturn join(getAgentDir(), \"tools\");\n}\n\n/** Get path to managed binaries directory (fd, rg) */\nexport function getBinDir(): string {\n\treturn join(getAgentDir(), \"bin\");\n}\n\n/**\n * Get path to the extension transpile cache directory (jiti fsCache).\n * Scoped by version so release upgrades never read stale transpiled output.\n */\nexport function getExtensionTranspileCacheDir(): string {\n\treturn join(getAgentDir(), \"cache\", \"jiti\", VERSION);\n}\n\n/** Get path to prompt templates directory */\nexport function getPromptsDir(): string {\n\treturn join(getAgentDir(), \"prompts\");\n}\n\n/** Get path to sessions directory */\nexport function getSessionsDir(): string {\n\treturn join(getAgentDir(), \"sessions\");\n}\n\n/** Get path to debug log file */\nexport function getDebugLogPath(): string {\n\treturn join(getAgentDir(), `${APP_NAME}-debug.log`);\n}\n"]}
package/dist/config.js CHANGED
@@ -11,7 +11,17 @@ const __dirname = dirname(__filename);
11
11
  * Detect if we're running as a Bun compiled binary.
12
12
  * Bun binaries have import.meta.url containing "$bunfs", "~BUN", or "%7EBUN" (Bun's virtual filesystem path)
13
13
  */
14
- export const isBunBinary = import.meta.url.includes("$bunfs") || import.meta.url.includes("~BUN") || import.meta.url.includes("%7EBUN");
14
+ const bunFsMarkers = ["$bunfs", "~BUN", "%7EBUN"];
15
+ // Check process.argv[1] as well as import.meta.url: in a CJS (bytecode) bundle
16
+ // import.meta.url is rewritten to the original source path, but argv[1] still
17
+ // points into Bun's virtual filesystem.
18
+ export const isBunBinary = [import.meta.url, process.argv[1] ?? ""].some((candidate) => bunFsMarkers.some((marker) => candidate.includes(marker)));
19
+ /**
20
+ * Detect if we're running from a single-file bundle produced by `bun run bundle:dev`.
21
+ * The bundle build inlines this env var via `--define`, so it is a compile-time
22
+ * constant there and undefined everywhere else.
23
+ */
24
+ export const isBundledBuild = process.env.ATOMIC_BUNDLED_BUILD === "1";
15
25
  /** Detect if Bun is the runtime (compiled binary or bun run) */
16
26
  export const isBunRuntime = !!process.versions.bun;
17
27
  // =============================================================================
@@ -324,6 +334,13 @@ export function getToolsDir() {
324
334
  export function getBinDir() {
325
335
  return join(getAgentDir(), "bin");
326
336
  }
337
+ /**
338
+ * Get path to the extension transpile cache directory (jiti fsCache).
339
+ * Scoped by version so release upgrades never read stale transpiled output.
340
+ */
341
+ export function getExtensionTranspileCacheDir() {
342
+ return join(getAgentDir(), "cache", "jiti", VERSION);
343
+ }
327
344
  /** Get path to prompt templates directory */
328
345
  export function getPromptsDir() {
329
346
  return join(getAgentDir(), "prompts");