@bastani/atomic 0.8.30-alpha.3 → 0.8.31-alpha.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/CHANGELOG.md +20 -0
- package/dist/builtin/cursor/CHANGELOG.md +7 -1
- package/dist/builtin/cursor/package.json +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/CHANGELOG.md +6 -0
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/subagents/CHANGELOG.md +6 -0
- package/dist/builtin/subagents/package.json +4 -4
- package/dist/builtin/web-access/CHANGELOG.md +6 -0
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +12 -0
- package/dist/builtin/workflows/builtin/deep-research-codebase.ts +1 -1
- package/dist/builtin/workflows/builtin/goal.ts +2 -2
- package/dist/builtin/workflows/builtin/open-claude-design.ts +1 -1
- package/dist/builtin/workflows/builtin/ralph.ts +61 -11
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +3 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner.ts +5 -0
- package/dist/builtin/workflows/src/runs/shared/model-fallback.ts +95 -8
- package/dist/builtin/workflows/src/shared/authoring-contract.d.ts +11 -0
- package/dist/cli/args.d.ts +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +20 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/list-models.d.ts.map +1 -1
- package/dist/cli/list-models.js +2 -1
- package/dist/cli/list-models.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +2 -0
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +2 -0
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session.d.ts +17 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +161 -18
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +20 -5
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/context-compaction.d.ts.map +1 -1
- package/dist/core/compaction/context-compaction.js +14 -3
- package/dist/core/compaction/context-compaction.js.map +1 -1
- package/dist/core/context-window.d.ts +29 -0
- package/dist/core/context-window.d.ts.map +1 -0
- package/dist/core/context-window.js +86 -0
- package/dist/core/context-window.js.map +1 -0
- package/dist/core/copilot-errors.d.ts +9 -0
- package/dist/core/copilot-errors.d.ts.map +1 -0
- package/dist/core/copilot-errors.js +32 -0
- package/dist/core/copilot-errors.js.map +1 -0
- package/dist/core/copilot-model-catalog.d.ts +132 -0
- package/dist/core/copilot-model-catalog.d.ts.map +1 -0
- package/dist/core/copilot-model-catalog.js +254 -0
- package/dist/core/copilot-model-catalog.js.map +1 -0
- package/dist/core/export-html/template.js +10 -1
- package/dist/core/extensions/types.d.ts +3 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/model-registry.d.ts +10 -0
- package/dist/core/model-registry.d.ts.map +1 -1
- package/dist/core/model-registry.js +107 -4
- package/dist/core/model-registry.js.map +1 -1
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +4 -0
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/provider-attribution.d.ts.map +1 -1
- package/dist/core/provider-attribution.js +17 -7
- package/dist/core/provider-attribution.js.map +1 -1
- package/dist/core/sdk.d.ts +8 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +47 -0
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts +8 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +19 -3
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-manager.d.ts +6 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +69 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +24 -1
- package/dist/main.js.map +1 -1
- package/dist/modes/index.d.ts +1 -1
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/components/context-window-selector.d.ts +53 -0
- package/dist/modes/interactive/components/context-window-selector.d.ts.map +1 -0
- package/dist/modes/interactive/components/context-window-selector.js +136 -0
- package/dist/modes/interactive/components/context-window-selector.js.map +1 -0
- package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/tree-selector.js +7 -0
- package/dist/modes/interactive/components/tree-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +5 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +91 -1
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +14 -2
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +23 -3
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +30 -1
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +23 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/custom-provider.md +4 -1
- package/docs/json.md +3 -1
- package/docs/models.md +78 -2
- package/docs/providers.md +3 -0
- package/docs/rpc.md +80 -1
- package/docs/sdk.md +23 -3
- package/docs/session-format.md +15 -1
- package/docs/sessions.md +1 -1
- package/docs/settings.md +7 -2
- package/docs/workflows.md +26 -4
- package/package.json +5 -5
package/docs/rpc.md
CHANGED
|
@@ -13,6 +13,7 @@ atomic --mode rpc [options]
|
|
|
13
13
|
Common options:
|
|
14
14
|
- `--provider <name>`: Set the LLM provider (anthropic, openai, google, etc.)
|
|
15
15
|
- `--model <pattern>`: Model pattern or ID (supports `provider/id` and optional `:<thinking>`)
|
|
16
|
+
- `--context-window <tokens>`: Select a supported context-window size for the startup model (`400k`, `1m`, or raw tokens)
|
|
16
17
|
- `--name <name>` / `-n <name>`: Set the session display name at startup
|
|
17
18
|
- `--no-session`: Disable session persistence
|
|
18
19
|
- `--session-dir <path>`: Custom session storage directory
|
|
@@ -190,7 +191,7 @@ Response:
|
|
|
190
191
|
}
|
|
191
192
|
```
|
|
192
193
|
|
|
193
|
-
The `model` field is a full [Model](#model) object or `null`. The `sessionName` field is the display name set via `set_session_name`, or omitted if not set.
|
|
194
|
+
The `model` field is a full [Model](#model) object or `null`. Its `contextWindow` is the active/effective token budget; selectable models may also include `defaultContextWindow` and `contextWindowOptions`. The `sessionName` field is the display name set via `set_session_name`, or omitted if not set.
|
|
194
195
|
|
|
195
196
|
#### get_messages
|
|
196
197
|
|
|
@@ -276,6 +277,66 @@ Response contains an array of full [Model](#model) objects:
|
|
|
276
277
|
}
|
|
277
278
|
```
|
|
278
279
|
|
|
280
|
+
### Context Window
|
|
281
|
+
|
|
282
|
+
#### get_available_context_windows
|
|
283
|
+
|
|
284
|
+
List the context-window token budgets supported by the current model and read the active/effective runtime selection.
|
|
285
|
+
|
|
286
|
+
```json
|
|
287
|
+
{"type": "get_available_context_windows"}
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Response:
|
|
291
|
+
```json
|
|
292
|
+
{
|
|
293
|
+
"type": "response",
|
|
294
|
+
"command": "get_available_context_windows",
|
|
295
|
+
"success": true,
|
|
296
|
+
"data": {
|
|
297
|
+
"contextWindows": [400000, 1000000],
|
|
298
|
+
"currentContextWindow": 400000,
|
|
299
|
+
"supportsSelection": true
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
- `contextWindows`: supported token budgets for the active model, sorted ascending.
|
|
305
|
+
- `currentContextWindow`: the active/effective token budget on `model.contextWindow`; omitted when no model is selected.
|
|
306
|
+
- `supportsSelection`: `true` when the active model exposes more than one supported budget.
|
|
307
|
+
|
|
308
|
+
#### set_context_window
|
|
309
|
+
|
|
310
|
+
Set the active context-window token budget for the current model at runtime.
|
|
311
|
+
|
|
312
|
+
```json
|
|
313
|
+
{"type": "set_context_window", "contextWindow": 1000000}
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
Compact string values are also accepted:
|
|
317
|
+
```json
|
|
318
|
+
{"type": "set_context_window", "contextWindow": "1m"}
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
Response:
|
|
322
|
+
```json
|
|
323
|
+
{"type": "response", "command": "set_context_window", "success": true}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
This command calls `AgentSession.setContextWindow(...)` without `{ persistDefault: true }`: it updates the active model, appends a `context_window_change` session entry and emits `context_window_changed` when the budget changes, but it does **not** write `defaultContextWindow` to settings. Use startup `--context-window` or an interactive settings selection when you intentionally want the existing persisted-default behavior.
|
|
327
|
+
|
|
328
|
+
Unsupported or malformed selections return the standard RPC error response:
|
|
329
|
+
```json
|
|
330
|
+
{
|
|
331
|
+
"type": "response",
|
|
332
|
+
"command": "set_context_window",
|
|
333
|
+
"success": false,
|
|
334
|
+
"error": "Context window 2m is not supported by custom/selectable-context. Supported values: 400k, 1m."
|
|
335
|
+
}
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
Larger provider context windows may consume more credits/cost. For allowlisted GitHub Copilot long-context models (including `github-copilot/gpt-5.5` and `github-copilot/gemini-3.1-pro-preview`), selecting `1m` raises Atomic's local budget and sends `X-GitHub-Api-Version: 2026-06-01`; GitHub applies the long-context billing tier server-side by prompt token count. That tier consumes more Copilot AI credits and requires Copilot long-context/usage-based billing entitlement, otherwise requests over GitHub's server cap are rejected with a friendly hint.
|
|
339
|
+
|
|
279
340
|
### Thinking
|
|
280
341
|
|
|
281
342
|
#### set_thinking_level
|
|
@@ -760,6 +821,7 @@ Events are streamed to stdout as JSON lines during agent operation. Events do NO
|
|
|
760
821
|
| `tool_execution_update` | Tool execution progress (streaming output) |
|
|
761
822
|
| `tool_execution_end` | Tool completes |
|
|
762
823
|
| `queue_update` | Pending steering/follow-up queue changed |
|
|
824
|
+
| `context_window_changed` | Active context-window token budget changed |
|
|
763
825
|
| `compaction_start` | Default Verbatim Compaction begins |
|
|
764
826
|
| `compaction_end` | Default Verbatim Compaction completes |
|
|
765
827
|
| `context_compaction_start` | Compatibility `context_compact` RPC begins |
|
|
@@ -911,6 +973,19 @@ Emitted whenever the pending steering or follow-up queue changes.
|
|
|
911
973
|
}
|
|
912
974
|
```
|
|
913
975
|
|
|
976
|
+
### context_window_changed
|
|
977
|
+
|
|
978
|
+
Emitted when the active context-window token budget changes through RPC `set_context_window`, `AgentSession.setContextWindow()` in an SDK-backed runtime, or because in-place tree navigation replayed a branch-scoped `context_window_change` entry. Navigation replay updates the active model for accurate budgeting and compaction but does not append another session entry or write `defaultContextWindow` to settings.
|
|
979
|
+
|
|
980
|
+
```json
|
|
981
|
+
{
|
|
982
|
+
"type": "context_window_changed",
|
|
983
|
+
"contextWindow": 1000000
|
|
984
|
+
}
|
|
985
|
+
```
|
|
986
|
+
|
|
987
|
+
Larger provider context windows may consume more credits/cost. Prefer the model default unless the additional repository/session context is useful for the current task. For allowlisted GitHub Copilot long-context models such as `github-copilot/gpt-5.5` and `github-copilot/gemini-3.1-pro-preview`, a `1m` selection raises Atomic's local budget and sends `X-GitHub-Api-Version: 2026-06-01`; GitHub applies the long-context billing tier server-side by prompt size, consumes more Copilot AI credits, and requires long-context/usage-based billing entitlement.
|
|
988
|
+
|
|
914
989
|
### compaction_start / compaction_end
|
|
915
990
|
|
|
916
991
|
Emitted when default Verbatim Compaction runs, whether manual or automatic. The result records deletion targets and stats rather than a generated summary.
|
|
@@ -1234,6 +1309,8 @@ Source files and installed definitions:
|
|
|
1234
1309
|
"reasoning": true,
|
|
1235
1310
|
"input": ["text", "image"],
|
|
1236
1311
|
"contextWindow": 200000,
|
|
1312
|
+
"defaultContextWindow": 200000,
|
|
1313
|
+
"contextWindowOptions": [200000, 1000000],
|
|
1237
1314
|
"maxTokens": 16384,
|
|
1238
1315
|
"cost": {
|
|
1239
1316
|
"input": 3.0,
|
|
@@ -1244,6 +1321,8 @@ Source files and installed definitions:
|
|
|
1244
1321
|
}
|
|
1245
1322
|
```
|
|
1246
1323
|
|
|
1324
|
+
`contextWindow` is the active/effective token budget used by Atomic's local budgeting, footer/stats, and compaction logic. `defaultContextWindow` is the model's scalar default before a session/runtime override, and `contextWindowOptions` lists selectable token budgets when the model supports more than one size. RPC clients can read/select the active runtime budget with `get_available_context_windows` and `set_context_window`; the runtime command does not persist `defaultContextWindow` to settings.
|
|
1325
|
+
|
|
1247
1326
|
### UserMessage
|
|
1248
1327
|
|
|
1249
1328
|
```json
|
package/docs/sdk.md
CHANGED
|
@@ -107,11 +107,14 @@ interface AgentSession {
|
|
|
107
107
|
sessionFile: string | undefined;
|
|
108
108
|
sessionId: string;
|
|
109
109
|
|
|
110
|
-
// Model control
|
|
110
|
+
// Model, thinking, and context-window control
|
|
111
111
|
setModel(model: Model): Promise<void>;
|
|
112
112
|
setThinkingLevel(level: ThinkingLevel): void;
|
|
113
|
+
setContextWindow(contextWindow: number, options?: { persistDefault?: boolean }): void;
|
|
113
114
|
cycleModel(): Promise<ModelCycleResult | undefined>;
|
|
114
115
|
cycleThinkingLevel(): ThinkingLevel | undefined;
|
|
116
|
+
getAvailableContextWindows(): number[];
|
|
117
|
+
supportsContextWindowSelection(): boolean;
|
|
115
118
|
|
|
116
119
|
// State access
|
|
117
120
|
agent: Agent;
|
|
@@ -121,7 +124,7 @@ interface AgentSession {
|
|
|
121
124
|
isStreaming: boolean;
|
|
122
125
|
|
|
123
126
|
// In-place tree navigation within the current session file
|
|
124
|
-
navigateTree(targetId: string, options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string }): Promise<{ editorText?: string; cancelled: boolean }>;
|
|
127
|
+
navigateTree(targetId: string, options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string }): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;
|
|
125
128
|
|
|
126
129
|
// Verbatim Compaction (deletion-only Context Compaction)
|
|
127
130
|
compact(): Promise<ContextCompactionResult>;
|
|
@@ -337,10 +340,13 @@ session.subscribe((event) => {
|
|
|
337
340
|
// event.toolResults: tool results from this turn
|
|
338
341
|
break;
|
|
339
342
|
|
|
340
|
-
// Session events (queue, compaction, retry)
|
|
343
|
+
// Session events (queue, context-window, compaction, retry)
|
|
341
344
|
case "queue_update":
|
|
342
345
|
console.log(event.steering, event.followUp);
|
|
343
346
|
break;
|
|
347
|
+
case "context_window_changed":
|
|
348
|
+
console.log(`Context window: ${event.contextWindow}`);
|
|
349
|
+
break;
|
|
344
350
|
case "compaction_start":
|
|
345
351
|
case "compaction_end":
|
|
346
352
|
case "auto_retry_start":
|
|
@@ -412,6 +418,8 @@ const available = await modelRegistry.getAvailable();
|
|
|
412
418
|
const { session } = await createAgentSession({
|
|
413
419
|
model: opus,
|
|
414
420
|
thinkingLevel: "medium", // off, minimal, low, medium, high, xhigh
|
|
421
|
+
contextWindow: 1_000_000, // optional; must be supported by the selected model unless non-strict fallback is acceptable
|
|
422
|
+
contextWindowStrict: true, // optional; return contextWindowError instead of warning/fallback when unsupported
|
|
415
423
|
|
|
416
424
|
// Models for cycling (CTRL+P in interactive mode)
|
|
417
425
|
scopedModels: [
|
|
@@ -429,6 +437,12 @@ If no model is provided:
|
|
|
429
437
|
2. Uses default from settings
|
|
430
438
|
3. Falls back to first available model
|
|
431
439
|
|
|
440
|
+
Context-window selection is independent from `thinkingLevel`. `contextWindow` accepts a raw token count such as `400_000` or `1_000_000`; the value must be present in the model's supported context windows (`model.contextWindowOptions` plus the scalar default). When a saved or settings default context window is unsupported for the selected model, `createAgentSession()` keeps the model default and returns `contextWindowWarning`. When you pass `contextWindowStrict: true`, an unsupported explicit selection is reported as `contextWindowError` so callers can fail before prompting. A successful explicit `contextWindow` startup option is journaled as a `context_window_change` entry even when it equals the scalar model default, so the user's explicit budget choice survives future settings changes and resume.
|
|
441
|
+
|
|
442
|
+
At runtime, use `session.getAvailableContextWindows()` to inspect supported values, `session.supportsContextWindowSelection()` to check whether more than one value is selectable, and `session.setContextWindow(tokens, { persistDefault })` to change the active model budget. `setContextWindow()` journals a `context_window_change` entry only when the active value changes. Passing `{ persistDefault: true }` also writes `defaultContextWindow` to settings. Tree navigation replays the target branch's `context_window_change` state into the active model without adding another journal entry or changing settings. Larger provider context windows may consume more credits/cost, so opt into larger values deliberately. For allowlisted GitHub Copilot long-context models (including `github-copilot/gpt-5.5` and `github-copilot/gemini-3.1-pro-preview`), selecting `1m` raises Atomic's local budget and sends `X-GitHub-Api-Version: 2026-06-01`; GitHub applies the long-context tier server-side by prompt token count, consumes more Copilot AI credits, and requires long-context/usage-based billing entitlement.
|
|
443
|
+
|
|
444
|
+
The package root exports the same context-window helpers and types used by the runtime: `parseContextWindowValue()`, `formatContextWindow()`, `validateContextWindowValue()`, `normalizeContextWindowOptions()`, `getModelDefaultContextWindow()`, `getSupportedContextWindows()`, `withContextWindowOptions()`, `selectContextWindow()`, `ContextWindowParseResult`, `ContextWindowSelection`, and `ContextWindowSelectionError`. Importing from `@bastani/atomic` also includes the `@earendil-works/pi-ai` `Model<Api>` augmentation for `contextWindowOptions` and `defaultContextWindow`, so SDK consumers can use the helper types without importing internal source paths.
|
|
445
|
+
|
|
432
446
|
> See [examples/sdk/02-custom-model.ts](https://github.com/bastani-inc/atomic/blob/main/packages/coding-agent/examples/sdk/02-custom-model.ts)
|
|
433
447
|
|
|
434
448
|
### API Keys and OAuth
|
|
@@ -991,6 +1005,12 @@ interface CreateAgentSessionResult {
|
|
|
991
1005
|
|
|
992
1006
|
// Warning if session model couldn't be restored
|
|
993
1007
|
modelFallbackMessage?: string;
|
|
1008
|
+
|
|
1009
|
+
// Warning if a saved/default context window could not be applied to the selected model
|
|
1010
|
+
contextWindowWarning?: string;
|
|
1011
|
+
|
|
1012
|
+
// Error if an explicit strict context-window selection is unsupported
|
|
1013
|
+
contextWindowError?: string;
|
|
994
1014
|
}
|
|
995
1015
|
|
|
996
1016
|
interface LoadExtensionsResult {
|
package/docs/session-format.md
CHANGED
|
@@ -216,6 +216,16 @@ Emitted when the user changes the thinking/reasoning level.
|
|
|
216
216
|
{"type":"thinking_level_change","id":"e5f6g7h8","parentId":"d4e5f6g7","timestamp":"2024-12-03T14:06:00.000Z","thinkingLevel":"high"}
|
|
217
217
|
```
|
|
218
218
|
|
|
219
|
+
### ContextWindowChangeEntry
|
|
220
|
+
|
|
221
|
+
Emitted when the user selects a supported context-window size for the active model. The value is a token count, independent of thinking/reasoning level. Explicit startup selections are journaled even when they equal the model's scalar default so the user's budget choice survives later settings changes and resume.
|
|
222
|
+
|
|
223
|
+
```json
|
|
224
|
+
{"type":"context_window_change","id":"f6g7h8i9","parentId":"e5f6g7h8","timestamp":"2024-12-03T14:07:00.000Z","contextWindow":1000000}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
`buildSessionContext()` replays the latest `context_window_change` on the active branch. In-place tree navigation also applies the branch's replayed context window to the active model without appending another `context_window_change` entry or writing `defaultContextWindow` to settings. If a historical value is no longer supported by the current model, session creation/navigation falls back to the model default the same way other context-window restore paths do.
|
|
228
|
+
|
|
219
229
|
### CompactionEntry
|
|
220
230
|
|
|
221
231
|
Retired summary-compaction entry. Atomic no longer produces this entry type, does not treat it as an active compaction boundary, and does not inject its generated summary into active LLM context. Historical JSONL files may still contain these lines for audit/export compatibility.
|
|
@@ -312,7 +322,7 @@ Entries form a tree:
|
|
|
312
322
|
`buildSessionContext()` walks from the current leaf to the root, producing the message list for the LLM:
|
|
313
323
|
|
|
314
324
|
1. Collects all entries on the active branch path
|
|
315
|
-
2. Extracts current model
|
|
325
|
+
2. Extracts current model, thinking level, and context-window settings
|
|
316
326
|
3. Applies every `ContextCompactionEntry` logical deletion on that path, filtering targeted entries/content blocks from active context while leaving retained content unchanged
|
|
317
327
|
4. Converts `BranchSummaryEntry` and `CustomMessageEntry` to appropriate message formats
|
|
318
328
|
5. Ignores retired `CompactionEntry` lines for active LLM context; they remain archival JSONL data only
|
|
@@ -358,6 +368,9 @@ for (const line of lines) {
|
|
|
358
368
|
case "thinking_level_change":
|
|
359
369
|
console.log(`[${entry.id}] Thinking: ${entry.thinkingLevel}`);
|
|
360
370
|
break;
|
|
371
|
+
case "context_window_change":
|
|
372
|
+
console.log(`[${entry.id}] Context window: ${entry.contextWindow}`);
|
|
373
|
+
break;
|
|
361
374
|
}
|
|
362
375
|
}
|
|
363
376
|
```
|
|
@@ -385,6 +398,7 @@ Key methods for working with sessions programmatically.
|
|
|
385
398
|
### Instance Methods - Appending (all return entry ID)
|
|
386
399
|
- `appendMessage(message)` - Add message
|
|
387
400
|
- `appendThinkingLevelChange(level)` - Record thinking change
|
|
401
|
+
- `appendContextWindowChange(contextWindow)` - Record context-window selection in tokens
|
|
388
402
|
- `appendModelChange(provider, modelId)` - Record model change
|
|
389
403
|
- `appendContextCompaction(deletedTargets, protectedEntryIds, stats, backupPath?)` - Add logical deletion compaction
|
|
390
404
|
- `appendCustomEntry(customType, data?)` - Extension state (not in context)
|
package/docs/sessions.md
CHANGED
|
@@ -142,6 +142,6 @@ See [Compaction](/compaction) for Verbatim Compaction, branch summarization inte
|
|
|
142
142
|
|
|
143
143
|
## Session Format
|
|
144
144
|
|
|
145
|
-
Session files are JSONL and contain message entries, model changes, thinking-level changes, labels, context compactions, branch summaries, extension entries, and retired legacy `type:"compaction"` records from older sessions.
|
|
145
|
+
Session files are JSONL and contain message entries, model changes, thinking-level changes, context-window changes, labels, context compactions, branch summaries, extension entries, and retired legacy `type:"compaction"` records from older sessions.
|
|
146
146
|
|
|
147
147
|
For parsers, extensions, SDK usage, and the full SessionManager API, see [Session Format](/session-format).
|
package/docs/settings.md
CHANGED
|
@@ -227,18 +227,22 @@ Normally the package manager's global modules location is queried using `root -g
|
|
|
227
227
|
|
|
228
228
|
When multiple sources specify a session directory, precedence is `--session-dir`, `ATOMIC_CODING_AGENT_SESSION_DIR`, then `sessionDir` in settings.json.
|
|
229
229
|
|
|
230
|
-
###
|
|
230
|
+
### Models
|
|
231
231
|
|
|
232
232
|
| Setting | Type | Default | Description |
|
|
233
233
|
|---------|------|---------|-------------|
|
|
234
234
|
| `enabledModels` | string[] | - | Model patterns for CTRL+P cycling (same format as `--models` CLI flag) |
|
|
235
|
+
| `defaultContextWindow` | number \| string | model default | Preferred context window for models that expose selectable context windows. Accepts raw token counts or compact labels such as `400k` and `1m`. Unsupported values are ignored with a warning for the active model. |
|
|
235
236
|
|
|
236
237
|
```json
|
|
237
238
|
{
|
|
238
|
-
"enabledModels": ["claude-*", "gpt-4o", "gemini-2*"]
|
|
239
|
+
"enabledModels": ["claude-*", "gpt-4o", "gemini-2*"],
|
|
240
|
+
"defaultContextWindow": "1m"
|
|
239
241
|
}
|
|
240
242
|
```
|
|
241
243
|
|
|
244
|
+
`defaultContextWindow` is independent of `defaultThinkingLevel`: selecting a larger context window does not change reasoning effort. Interactive users can also change the active model's budget through the `/model` selection flow, which prompts for a context window whenever the chosen model supports more than one window. Larger provider context windows can carry higher usage cost. For GitHub Copilot allowlisted long-context models (including `github-copilot/gpt-5.5` and `github-copilot/gemini-3.1-pro-preview`), selecting `1m` raises Atomic's local budget and sends `X-GitHub-Api-Version: 2026-06-01`; GitHub then applies the long-context tier server-side by prompt token count. That tier consumes more Copilot AI credits and requires Copilot long-context/usage-based billing entitlement, otherwise requests over the server cap are rejected with a friendly hint. Custom providers and explicit model overrides can still declare their own selectable `contextWindowOptions`.
|
|
245
|
+
|
|
242
246
|
### Markdown
|
|
243
247
|
|
|
244
248
|
| Setting | Type | Default | Description |
|
|
@@ -297,6 +301,7 @@ See [Atomic packages](/packages) for package management details.
|
|
|
297
301
|
"defaultProvider": "anthropic",
|
|
298
302
|
"defaultModel": "claude-sonnet-4-20250514",
|
|
299
303
|
"defaultThinkingLevel": "medium",
|
|
304
|
+
"defaultContextWindow": "400k",
|
|
300
305
|
"theme": "dark",
|
|
301
306
|
"compaction": {
|
|
302
307
|
"enabled": true,
|
package/docs/workflows.md
CHANGED
|
@@ -153,7 +153,7 @@ For the builtin result tables below, `deep-research-codebase`, `goal`, and `ralp
|
|
|
153
153
|
|---|---|---|
|
|
154
154
|
| `deep-research-codebase` | Scout + research-history chain → parallel specialist waves → aggregator. Indexes the whole repo and synthesizes findings. | Broad or cross-cutting research before you decide what to change. Prefer `/skill:research-codebase` for one subsystem. |
|
|
155
155
|
| `goal` | Persisted goal ledger → bounded worker turns → receipts → three-reviewer gate → deterministic reducer → final report. | Small-to-medium scope changes when you can identify the work surface, state the exact outcome, and name the validation that proves it is done — for example tests, lint/typecheck, docs builds, or observable behavior. |
|
|
156
|
-
| `ralph` | Prompt-engineering → codebase/online research → sub-agent orchestration → parallel review → optional final-stage PR handoff. | Larger migrations, broad refactors, and multi-package changes where you want Atomic to transform the prompt into a research question, research the codebase before implementing, delegate through sub-agents, review, iterate, and optionally allow only the final `pull-request` stage to attempt PR creation with `create_pr=true`. |
|
|
156
|
+
| `ralph` | Prompt-engineering → codebase/online research → sub-agent orchestration → multi-model parallel review → optional final-stage PR handoff. | Larger migrations, broad refactors, and multi-package changes where you want Atomic to transform the prompt into a research question, research the codebase before implementing, delegate through sub-agents, review, iterate, and optionally allow only the final `pull-request` stage to attempt PR creation with `create_pr=true`. |
|
|
157
157
|
| `open-claude-design` | Design-system onboarding → reference import → HTML generation → impeccable-driven refinement → quality gate → rich HTML handoff. Renders a live `preview.html` you can iterate against (opens through `browser` when available). | UI, page, component, theme, or design-token work that benefits from generation + critique loops. |
|
|
158
158
|
|
|
159
159
|
### `deep-research-codebase`
|
|
@@ -262,7 +262,7 @@ Run examples:
|
|
|
262
262
|
/workflow ralph prompt="Safely implement the API refactor" git_worktree_dir=../atomic-ralph-api-wt base_branch=main
|
|
263
263
|
```
|
|
264
264
|
|
|
265
|
-
Each `ralph` iteration starts by prompt-engineering the user prompt with `/skill:prompt-engineer Transform the following user prompt to a codebase and online research question which can be thoroughly explored: ...`, then researches that transformed question with `/skill:research-codebase ...` and writes the findings under `research/`. The orchestrator treats that research artifact as its primary implementation context, initializes/updates an OS-temp implementation notes file, delegates implementation through sub-agents, and asks
|
|
265
|
+
Each `ralph` iteration starts by prompt-engineering the user prompt with `/skill:prompt-engineer Transform the following user prompt to a codebase and online research question which can be thoroughly explored: ...`, then researches that transformed question with `/skill:research-codebase ...` and writes the findings under `research/`. The orchestrator treats that research artifact as its primary implementation context, initializes/updates an OS-temp implementation notes file while generating verifiable evidence for any claims it records in the notes and reviewer artifacts, delegates implementation through sub-agents, and asks three independent reviewers to inspect the patch directly against `base_branch`. The reviewer fan-out runs each reviewer on a different primary model family (with shared fallbacks) so the adversarial review gets cross-model coverage instead of three passes from one model. Ralph's orchestrator and reviewers are prompted to verify user-visible behavior end-to-end when practical, using browser-skilled subagents for web/frontend flows that may depend on backend/API behavior and tmux-skilled subagents for TUI or terminal-app scenarios. If reviewers find issues, the next prompt-engineering and research stages receive the review artifact path so follow-up research can address unresolved findings, and research stages fork from prior research session data when available. The loop stops only when all three reviewers independently approve (each finds no issues) or `max_loops` is reached, so a P0–P3 finding from any single reviewer keeps Ralph iterating instead of being out-voted by a majority quorum. By default Ralph does not start the final `pull-request` stage, and `pr_report` is omitted. Prompt text alone does not opt in. Pass `create_pr=true` only when you explicitly want the final `pull-request` stage to inspect provider credentials and attempt provider-appropriate PR/MR/review creation, such as GitHub `gh`, Azure Repos `az repos pr create`, or Sapling/Phabricator tooling; Ralph's own PR-creation instructions live in that final stage.
|
|
266
266
|
|
|
267
267
|
Set `git_worktree_dir` when you want Ralph's worker stages isolated in a reusable Git worktree. Relative paths resolve from the invoking repository root, existing same-repository worktree roots are reused, and missing paths are created from `base_branch`. Ralph preserves the invoking repo-relative cwd inside the worktree, so launching from `repo/packages/api` with `git_worktree_dir=../repo-wt` runs stages from `../repo-wt/packages/api`.
|
|
268
268
|
|
|
@@ -969,7 +969,7 @@ workflow({
|
|
|
969
969
|
})
|
|
970
970
|
```
|
|
971
971
|
|
|
972
|
-
Direct mode supports top-level/default options and per-task options such as `context`, `forkFromSessionFile`, `model`, `fallbackModels`, `thinkingLevel`, `tools`, `noTools`, `customTools`, `bashPolicy`, `mcp`, `output`, `outputMode`, `reads`, `worktree`, `gitWorktreeDir`, `baseBranch`, `maxOutput`, `artifacts`, `sessionDir`, `cwd`, and `agentDir`. Direct chains also support `chainName`, `chainDir`, and `failFast`.
|
|
972
|
+
Direct mode supports top-level/default options and per-task options such as `context`, `forkFromSessionFile`, `model`, `fallbackModels`, `thinkingLevel`, `contextWindow`, `tools`, `noTools`, `customTools`, `bashPolicy`, `mcp`, `output`, `outputMode`, `reads`, `worktree`, `gitWorktreeDir`, `baseBranch`, `maxOutput`, `artifacts`, `sessionDir`, `cwd`, and `agentDir`. Direct chains also support `chainName`, `chainDir`, and `failFast`.
|
|
973
973
|
|
|
974
974
|
For large fan-outs, prefer `outputMode: "file-only"` so the parent result contains compact file references instead of full output. Treat intercom payloads from async direct runs as user-visible workflow output.
|
|
975
975
|
|
|
@@ -1477,7 +1477,8 @@ Common task/stage options include:
|
|
|
1477
1477
|
- `prompt` or `task`
|
|
1478
1478
|
- `previous` for small handoff context; use artifact paths plus `reads` for large outputs, logs, research bundles, or reviewer payloads
|
|
1479
1479
|
- `context: "fresh" | "fork"`, `forkFromSessionFile`
|
|
1480
|
-
- `model`, `fallbackModels`, `thinkingLevel`, `scopedModels`, `modelRegistry` — `model` and each `fallbackModels` entry accept a `model_name:thinking_effort` reasoning suffix
|
|
1480
|
+
- `model`, `fallbackModels`, `thinkingLevel`, `scopedModels`, `modelRegistry` — `model` and each `fallbackModels` entry accept a `model_name:thinking_effort` reasoning suffix and an optional parenthesized context-window token such as `model (1m)` (see [Reasoning levels](#reasoning-levels) and [Context windows](#context-windows)); the standalone `thinkingLevel` is deprecated
|
|
1481
|
+
- `contextWindow`, `contextWindowStrict` — stage-wide context-window budget mapped to the SDK `createAgentSession` options of the same name (non-strict by default)
|
|
1481
1482
|
- `tools`, `noTools`, `customTools`, `mcp: { allow?: string[], deny?: string[] }`, `bashPolicy`
|
|
1482
1483
|
- `schema` for a structured final answer from this workflow item
|
|
1483
1484
|
- `output`, `outputMode`, `reads`, `worktree`, `gitWorktreeDir`, `baseBranch`, `maxOutput`, `artifacts`, `sessionDir`, `cwd`, `agentDir`
|
|
@@ -1554,6 +1555,27 @@ The standalone `thinkingLevel` stage option is deprecated. It still applies as a
|
|
|
1554
1555
|
|
|
1555
1556
|
This applies everywhere a stage accepts a model: direct `ctx.task`/`ctx.chain`/`ctx.parallel` options, `ctx.stage` options, builtin workflow stage definitions, and workflow parameters. `fallbackThinkingLevels` is an optional compatibility helper aligned by index to `fallbackModels`; it applies only to fallback entries that do not already carry a suffix. Each `WorkflowModelAttempt` reports the resolved model and the effective reasoning effort used for that attempt.
|
|
1556
1557
|
|
|
1558
|
+
### Context windows
|
|
1559
|
+
|
|
1560
|
+
A `model`/`fallbackModels` entry may also request a context-window budget with a parenthesized size token in the model-name portion — placed *before* the optional `:reasoning` suffix so it never collides with the reasoning level. This mirrors GitHub Copilot's `Claude Opus 4.8 (1M context)` model-name convention:
|
|
1561
|
+
|
|
1562
|
+
```ts
|
|
1563
|
+
await ctx.task("review", {
|
|
1564
|
+
task: "Review the diff",
|
|
1565
|
+
model: "anthropic/claude-fable-5:xhigh",
|
|
1566
|
+
// The copilot opus fallback runs at its largest advertised (long-context) window.
|
|
1567
|
+
fallbackModels: ["github-copilot/claude-opus-4.8 (1m):xhigh", "anthropic/claude-opus-4-8:xhigh"],
|
|
1568
|
+
});
|
|
1569
|
+
```
|
|
1570
|
+
|
|
1571
|
+
The token accepts the same compact sizes as the `--context-window` flag (`1m`, `936k`, `400k`, or a raw token count) and is resolved against that specific candidate model's advertised windows:
|
|
1572
|
+
|
|
1573
|
+
- an exact supported window is used as-is;
|
|
1574
|
+
- otherwise the largest supported window not exceeding the request is selected, so `(1m)` lands on a model's ~936K long-context tier;
|
|
1575
|
+
- when the model exposes no larger tier (or is unavailable), the request is dropped and the session keeps the model's default (short) window — a non-strict, automatic fallback.
|
|
1576
|
+
|
|
1577
|
+
The budget applies only to the candidate that carries the token; other primary and fallback models in the same chain are unaffected. A parenthesized token that is not a valid size (for example `(preview)`) is left attached to the model id rather than being treated as a context window. For stage-wide selection you can instead set the `contextWindow` (and `contextWindowStrict`) stage option, which maps to the SDK `createAgentSession` options of the same name.
|
|
1578
|
+
|
|
1557
1579
|
## Programmatic Usage
|
|
1558
1580
|
|
|
1559
1581
|
`@bastani/workflows` is an Atomic package extension. It registers:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bastani/atomic",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.31-alpha.1",
|
|
4
4
|
"description": "Atomic coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"atomicConfig": {
|
|
@@ -68,11 +68,11 @@
|
|
|
68
68
|
"prepublishOnly": "bun run clean && bun run build"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@bastani/atomic-natives": "0.8.
|
|
71
|
+
"@bastani/atomic-natives": "0.8.31-alpha.1",
|
|
72
72
|
"@bufbuild/protobuf": "^2.0.0",
|
|
73
|
-
"@earendil-works/pi-agent-core": "^0.79.
|
|
74
|
-
"@earendil-works/pi-ai": "^0.79.
|
|
75
|
-
"@earendil-works/pi-tui": "^0.79.
|
|
73
|
+
"@earendil-works/pi-agent-core": "^0.79.6",
|
|
74
|
+
"@earendil-works/pi-ai": "^0.79.6",
|
|
75
|
+
"@earendil-works/pi-tui": "^0.79.6",
|
|
76
76
|
"@modelcontextprotocol/ext-apps": "^1.7.2",
|
|
77
77
|
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
78
78
|
"@mozilla/readability": "^0.6.0",
|