@bastani/atomic-acp 0.0.18 → 0.0.20
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/README.md +95 -60
- package/dist/index.js +60 -49
- package/dist/index.js.map +1 -1
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
<h1 align="center">atomic-acp</h1>
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
<b>Use the <a href="https://github.com/bastani-inc/atomic">Atomic</a> coding agent
|
|
4
|
+
<b>Use the <a href="https://github.com/bastani-inc/atomic">Atomic</a> coding agent in Zed and other editors that support the Agent Client Protocol.</b>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
7
|
<p align="center">
|
|
8
|
-
<a href="#
|
|
8
|
+
<a href="#install"><b>Install →</b></a>
|
|
9
9
|
·
|
|
10
|
-
<a href="#what-
|
|
10
|
+
<a href="#what-you-get">What you get</a>
|
|
11
11
|
·
|
|
12
12
|
<a href="#subagents-and-background-work">Subagents</a>
|
|
13
13
|
·
|
|
@@ -26,28 +26,55 @@
|
|
|
26
26
|
|
|
27
27
|
## How it works
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
`atomic-acp` connects your code editor to Atomic using the [Agent Client Protocol (ACP)](https://agentclientprotocol.com/), a standard way for editors to talk to coding agents. For each chat thread, `atomic-acp` starts a background Atomic process (`atomic --mode rpc`) and translates messages back and forth between Atomic and your editor.
|
|
30
30
|
|
|
31
31
|
```text
|
|
32
|
-
|
|
32
|
+
Editor (such as Zed) <-> atomic-acp <-> Atomic (atomic --mode rpc)
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
Atomic reads files, edits code and runs commands on your machine,
|
|
35
|
+
Atomic reads files, edits code, and runs shell commands directly on your machine, just as it does in a terminal. Only open folders you trust.
|
|
36
36
|
|
|
37
|
-
##
|
|
37
|
+
## Install
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
`atomic-acp` needs Node.js 20 or newer. It does not install Atomic for you. Instead, it runs whichever `atomic` command is available on your `PATH`, so install Atomic 0.10.0 or newer first.
|
|
40
|
+
|
|
41
|
+
**Recommended: standalone Atomic installer.** Atomic brings its own runtime, so Atomic itself does not depend on your Node.js version:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# macOS and Linux
|
|
45
|
+
curl -fsSL https://raw.githubusercontent.com/bastani-inc/atomic/main/install.sh | sh
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```powershell
|
|
49
|
+
# Windows PowerShell
|
|
50
|
+
irm https://raw.githubusercontent.com/bastani-inc/atomic/main/install.ps1 | iex
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Alternative: install Atomic with npm.** The npm package requires Node.js 24.20 or newer:
|
|
40
54
|
|
|
41
55
|
```bash
|
|
42
|
-
npm install -g @bastani/atomic
|
|
43
|
-
atomic # sign in, then quit
|
|
56
|
+
npm install -g @bastani/atomic
|
|
44
57
|
```
|
|
45
58
|
|
|
46
|
-
|
|
59
|
+
Next, install the adapter and sign in to Atomic once:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npm install -g @bastani/atomic-acp
|
|
63
|
+
atomic # sign in to a model provider, then quit
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
To point the adapter at a specific Atomic binary instead of the one on your `PATH`, set `ATOMIC_ACP_ATOMIC_COMMAND` to its path. Run `atomic-acp --help` to see all command-line options.
|
|
67
|
+
|
|
68
|
+
### Update
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
atomic update # update Atomic itself
|
|
72
|
+
npm install -g @bastani/atomic-acp@latest # update this adapter
|
|
73
|
+
```
|
|
47
74
|
|
|
48
75
|
### Add it to Zed
|
|
49
76
|
|
|
50
|
-
|
|
77
|
+
Add this entry to Zed's `settings.json`:
|
|
51
78
|
|
|
52
79
|
```json
|
|
53
80
|
{
|
|
@@ -62,78 +89,80 @@ In Zed's `settings.json`:
|
|
|
62
89
|
}
|
|
63
90
|
```
|
|
64
91
|
|
|
65
|
-
Open the agent panel,
|
|
92
|
+
Open the agent panel in Zed, choose **Atomic**, and start a thread.
|
|
66
93
|
|
|
67
|
-
|
|
94
|
+
If Atomic is not signed in to a model provider yet, Zed shows an **Authenticate** banner that opens Atomic in a terminal so you can sign in. Running `atomic-acp --terminal-login` does the same thing.
|
|
68
95
|
|
|
69
|
-
|
|
96
|
+
If you prefer not to install the adapter globally, use `"command": "npx"` with `"args": ["-y", "@bastani/atomic-acp"]`.
|
|
70
97
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
-
|
|
74
|
-
-
|
|
75
|
-
-
|
|
76
|
-
-
|
|
77
|
-
-
|
|
78
|
-
-
|
|
98
|
+
## What you get
|
|
99
|
+
|
|
100
|
+
- Replies and reasoning stream into the chat thread as Atomic writes them.
|
|
101
|
+
- Tool calls show their status and the files they touch. File edits show a diff, and shell commands show their output.
|
|
102
|
+
- Each editor thread maps to a real Atomic session. Threads appear in your editor's history and in `atomic --resume`, keep their title, and survive an adapter restart. Deleting a thread deletes its Atomic session.
|
|
103
|
+
- The editor's model and thinking pickers show the options available in your Atomic setup. The context meter shows how full the conversation window is.
|
|
104
|
+
- Your Atomic prompt templates, skills (`/skill:name`), and extension commands appear in the slash menu.
|
|
105
|
+
- When Atomic asks you to choose an option, confirm an action, or type an answer, the editor shows a form. Multi-question prompts appear together in one form, including multi-select questions.
|
|
106
|
+
- External tool servers (MCP servers) configured in your editor are forwarded to that thread's Atomic session, with tools named `mcp__<server>__<tool>`. Local command servers and HTTP servers work; legacy SSE servers are skipped. `atomic-acp` never edits your Atomic MCP config file, and any server with the same name in your Atomic config takes priority.
|
|
107
|
+
- If Atomic exits unexpectedly in the middle of a reply, the message reports why it failed. Your next message restarts Atomic on the same session.
|
|
79
108
|
|
|
80
109
|
## Subagents and background work
|
|
81
110
|
|
|
82
|
-
Atomic
|
|
111
|
+
Atomic can hand off larger tasks to [subagents](https://docs.bastani.ai/orchestration) and background shell commands. Your editor shows each one as a tool call.
|
|
83
112
|
|
|
84
|
-
- A
|
|
85
|
-
- When background
|
|
86
|
-
- Cancelling a
|
|
87
|
-
-
|
|
113
|
+
- A reply finishes as soon as Atomic finishes its turn, even if subagents or background commands are still running. Atomic does not report background work over its background protocol, so `atomic-acp` cannot wait for it automatically. If you want the reply to stay open until a background task finishes, ask the agent to wait for it.
|
|
114
|
+
- When a background task finishes, Atomic handles its result in a new turn that streams into the thread automatically. A message you send while that turn is running joins it.
|
|
115
|
+
- Cancelling a reply stops the current turn and drops any messages queued behind it, just like pressing Esc in Atomic. Subagents and background commands keep running until you ask the agent to stop them.
|
|
116
|
+
- Switching to another thread, deleting a thread, or reopening a thread with different MCP servers stops its Atomic process. Any active reply ends as cancelled, and its subagents stop with the process.
|
|
88
117
|
|
|
89
118
|
## Slash commands
|
|
90
119
|
|
|
91
|
-
|
|
120
|
+
In addition to your Atomic prompts, skills, and extension commands, `atomic-acp` provides:
|
|
92
121
|
|
|
93
|
-
| Command | What it does
|
|
94
|
-
| ------------------------------ |
|
|
95
|
-
| `/compact [instructions]` |
|
|
96
|
-
| `/autocompact on\|off\|toggle` | Turn automatic compaction on or off
|
|
97
|
-
| `/session` |
|
|
98
|
-
| `/name <name>` | Rename the session
|
|
99
|
-
| `/export` |
|
|
100
|
-
| `/steering`, `/follow-up` |
|
|
101
|
-
| `/changelog` | Show Atomic
|
|
122
|
+
| Command | What it does |
|
|
123
|
+
| ------------------------------ | ------------------------------------------------------ |
|
|
124
|
+
| `/compact [instructions]` | Summarize older messages to free up context space |
|
|
125
|
+
| `/autocompact on\|off\|toggle` | Turn automatic compaction on or off |
|
|
126
|
+
| `/session` | Show the session ID, token counts, messages, and cost |
|
|
127
|
+
| `/name <name>` | Rename the session |
|
|
128
|
+
| `/export` | Save the session as an HTML file in the project folder |
|
|
129
|
+
| `/steering`, `/follow-up` | View or change how queued messages are delivered |
|
|
130
|
+
| `/changelog` | Show the changelog for your installed version of Atomic |
|
|
102
131
|
|
|
103
|
-
Use
|
|
132
|
+
Use your editor's pickers instead of `/model` and `/thinking`. Start a new thread instead of `/clear`.
|
|
104
133
|
|
|
105
134
|
## Configuration
|
|
106
135
|
|
|
107
|
-
Set these
|
|
136
|
+
Set any of these environment variables inside the `env` block of your editor's agent server entry:
|
|
108
137
|
|
|
109
|
-
| Variable | Default |
|
|
110
|
-
| ------------------------------------ | -------- |
|
|
111
|
-
| `ATOMIC_ACP_ATOMIC_COMMAND` | `atomic` |
|
|
112
|
-
| `ATOMIC_ACP_ATOMIC_ARGS` | unset | JSON array of extra
|
|
113
|
-
| `ATOMIC_ACP_HEADLESS` | unset | `1`
|
|
114
|
-
| `ATOMIC_ACP_ENABLE_EMBEDDED_CONTEXT` | unset | `true`
|
|
115
|
-
| `ATOMIC_ACP_DIR` | unset |
|
|
138
|
+
| Variable | Default | What it does |
|
|
139
|
+
| ------------------------------------ | -------- | --------------------------------------------------------------------------- |
|
|
140
|
+
| `ATOMIC_ACP_ATOMIC_COMMAND` | `atomic` | Command name or full path of the Atomic executable |
|
|
141
|
+
| `ATOMIC_ACP_ATOMIC_ARGS` | unset | JSON array of extra flags passed to every Atomic process |
|
|
142
|
+
| `ATOMIC_ACP_HEADLESS` | unset | Set to `1` for automated runs where nobody is present to answer questions |
|
|
143
|
+
| `ATOMIC_ACP_ENABLE_EMBEDDED_CONTEXT` | unset | Set to `true` to let the editor attach full file contents inside prompts |
|
|
144
|
+
| `ATOMIC_ACP_DIR` | unset | Folder for the adapter's own session map (see below) |
|
|
116
145
|
|
|
117
|
-
|
|
146
|
+
You can also pass extra Atomic flags after `--`, for example `"args": ["--", "--model", "openai/gpt-6.1-sol"]`. The adapter rejects flags that it controls itself, such as `--mode` and session flags.
|
|
118
147
|
|
|
119
|
-
|
|
148
|
+
All other settings, including logins, models, skills, extensions, and session storage, come from your normal Atomic configuration.
|
|
120
149
|
|
|
121
150
|
### The adapter's own state
|
|
122
151
|
|
|
123
|
-
|
|
152
|
+
`atomic-acp` stores one file of its own, `session-map.json`, which records which project folder each thread belongs to so threads can be listed and reopened. By default it lives in `~/.atomic/atomic-acp`, or in `ATOMIC_ACP_DIR` when set. The folder is created on first use and is readable only by your user account.
|
|
124
153
|
|
|
125
|
-
Set `ATOMIC_ACP_DIR` when Atomic runs
|
|
154
|
+
Set `ATOMIC_ACP_DIR` when Atomic runs inside a sandbox with its own private agent folder (`ATOMIC_CODING_AGENT_DIR`) and your home `~/.atomic` folder is read-only. Without it, starting a thread fails because `session-map.json` cannot be written. Keep using the same `ATOMIC_ACP_DIR` across restarts so saved threads can still be reopened.
|
|
126
155
|
|
|
127
|
-
###
|
|
156
|
+
### Automated runs without a user
|
|
128
157
|
|
|
129
|
-
|
|
158
|
+
When `ATOMIC_ACP_HEADLESS=1` is set, prompts that ask for human input return immediately instead of waiting. Question tools tell the model that no person is available, and interactive dialogs are cancelled.
|
|
130
159
|
|
|
131
160
|
## Limitations
|
|
132
161
|
|
|
133
|
-
-
|
|
134
|
-
- Atomic reads,
|
|
135
|
-
- Messages sent while Atomic is busy
|
|
136
|
-
- Zed is the tested
|
|
162
|
+
- Interactive question forms require an editor that supports ACP form prompts. In editors without form support, `ask_user_question` cannot be answered.
|
|
163
|
+
- Atomic reads files, edits files, and runs commands directly on the machine rather than going through your editor's file or terminal APIs.
|
|
164
|
+
- Messages sent while Atomic is busy wait in a queue and run one at a time.
|
|
165
|
+
- Zed is the tested editor. Other ACP-compatible editors should work, though some updates may display differently.
|
|
137
166
|
|
|
138
167
|
## Development
|
|
139
168
|
|
|
@@ -145,13 +174,19 @@ npm run lint
|
|
|
145
174
|
npm run build
|
|
146
175
|
```
|
|
147
176
|
|
|
148
|
-
`src/acp/`
|
|
177
|
+
`src/acp/` handles the editor-facing ACP protocol, and `src/atomic-rpc/` manages the Atomic child process. The `npm run smoke:*` scripts talk to a live, signed-in Atomic and spend model tokens, so `npm test` does not run them.
|
|
149
178
|
|
|
150
179
|
## Releasing
|
|
151
180
|
|
|
152
|
-
|
|
181
|
+
1. Open a pull request that updates `version` in `package.json` and whose final commit title is `Release X.Y.Z` (or `Release X.Y.Z-alpha.N` for a prerelease).
|
|
182
|
+
2. Merge it with a squash or rebase merge. A standard merge commit is titled `Merge pull request ...` and does not trigger a release. For a squash merge, set the commit title to `Release X.Y.Z` (GitHub's ` (#N)` suffix is accepted).
|
|
183
|
+
3. The [tag-release workflow](.github/workflows/tag-release.yml) tags the commit and starts the [publish workflow](.github/workflows/publish.yml), which verifies the tag, runs the test suite, and publishes to npm with [trusted publishing](https://docs.npmjs.com/trusted-publishers). Stable versions publish under the `latest` tag and alphas under `next`.
|
|
184
|
+
|
|
185
|
+
If a publish run fails after the tag is created, re-run it from `main`:
|
|
153
186
|
|
|
154
|
-
|
|
187
|
+
```bash
|
|
188
|
+
gh workflow run publish.yml --ref main -f tag=X.Y.Z
|
|
189
|
+
```
|
|
155
190
|
|
|
156
191
|
## Credits
|
|
157
192
|
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { ndJsonStream } from "@agentclientprotocol/sdk";
|
|
|
6
6
|
// src/acp/agent.ts
|
|
7
7
|
import { spawnSync } from "child_process";
|
|
8
8
|
import { existsSync as existsSync3, readdirSync as readdirSync2, readFileSync as readFileSync5, realpathSync, statSync as statSync2 } from "fs";
|
|
9
|
-
import { basename as
|
|
9
|
+
import { basename as basename3, dirname as dirname3, isAbsolute as isAbsolute2, join as join6 } from "path";
|
|
10
10
|
import {
|
|
11
11
|
agent,
|
|
12
12
|
methods as methods3,
|
|
@@ -95,6 +95,19 @@ function withExcludedTool(extraArgs, tool) {
|
|
|
95
95
|
return [...args, "--exclude-tools", tool];
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
// src/atomic-rpc/install.ts
|
|
99
|
+
import { basename, dirname, join } from "path";
|
|
100
|
+
var ATOMIC_INSTALL_HINT = "Install it with `curl -fsSL https://raw.githubusercontent.com/bastani-inc/atomic/main/install.sh | sh` (Windows: `install.ps1`) or `npm install -g @bastani/atomic`, or ensure `atomic` is on your PATH";
|
|
101
|
+
var ATOMIC_UPDATE_COMMAND = "atomic update";
|
|
102
|
+
function atomicChangelogCandidates(realPath) {
|
|
103
|
+
const dir = dirname(realPath);
|
|
104
|
+
const parent = dirname(dir);
|
|
105
|
+
const candidates = [join(dir, "CHANGELOG.md")];
|
|
106
|
+
if (basename(dir).toLowerCase() === "bin") candidates.push(join(parent, "current", "CHANGELOG.md"));
|
|
107
|
+
candidates.push(join(parent, "CHANGELOG.md"));
|
|
108
|
+
return candidates;
|
|
109
|
+
}
|
|
110
|
+
|
|
98
111
|
// src/atomic-rpc/process.ts
|
|
99
112
|
import { spawn } from "child_process";
|
|
100
113
|
import crossSpawn from "cross-spawn";
|
|
@@ -104,7 +117,7 @@ import { randomBytes } from "crypto";
|
|
|
104
117
|
import { chmodSync, mkdtempSync, rmSync, writeFileSync } from "fs";
|
|
105
118
|
import { rm } from "fs/promises";
|
|
106
119
|
import { tmpdir } from "os";
|
|
107
|
-
import { join } from "path";
|
|
120
|
+
import { join as join2 } from "path";
|
|
108
121
|
var RETRYABLE_RM_CODES = /* @__PURE__ */ new Set(["EBUSY", "EPERM", "ENOTEMPTY", "EMFILE", "ENFILE"]);
|
|
109
122
|
var RM_RETRY_DELAYS_MS = [50, 100, 200, 400, 800, 1600];
|
|
110
123
|
var liveDirs = /* @__PURE__ */ new Set();
|
|
@@ -165,12 +178,12 @@ function writeAdapterExtension(options, cleanup = {}) {
|
|
|
165
178
|
const { servers, env } = referenceSecretValues(options.mcpServers ?? {});
|
|
166
179
|
const askReason = options.askUserQuestionUnavailable;
|
|
167
180
|
if (Object.keys(servers).length === 0 && askReason === void 0) return void 0;
|
|
168
|
-
const dir = mkdtempSync(
|
|
181
|
+
const dir = mkdtempSync(join2(tmpdir(), "atomic-acp-ext-"));
|
|
169
182
|
liveDirs.add(dir);
|
|
170
183
|
installExitHook();
|
|
171
184
|
try {
|
|
172
185
|
chmodSync(dir, 448);
|
|
173
|
-
const path =
|
|
186
|
+
const path = join2(dir, "atomic-acp.mjs");
|
|
174
187
|
const source = [
|
|
175
188
|
`const servers = ${JSON.stringify(servers)}`,
|
|
176
189
|
`const askUserQuestionUnavailable = ${JSON.stringify(askReason ?? null)}`,
|
|
@@ -327,7 +340,7 @@ var AtomicRpcProcess = class _AtomicRpcProcess {
|
|
|
327
340
|
const code = typeof e?.code === "string" ? e.code : void 0;
|
|
328
341
|
if (code === "ENOENT") {
|
|
329
342
|
throw new AtomicRpcSpawnError(
|
|
330
|
-
`Could not start Atomic: executable not found (command: ${cmd}). Atomic needs to be installed before it can run in ACP clients.
|
|
343
|
+
`Could not start Atomic: executable not found (command: ${cmd}). Atomic needs to be installed before it can run in ACP clients. ${ATOMIC_INSTALL_HINT}. Then try again.`,
|
|
331
344
|
{ code, cause: e }
|
|
332
345
|
);
|
|
333
346
|
}
|
|
@@ -697,7 +710,7 @@ function parseAtomicSessionList(data) {
|
|
|
697
710
|
// src/acp/atomic-settings.ts
|
|
698
711
|
import { existsSync, readFileSync } from "fs";
|
|
699
712
|
import { homedir } from "os";
|
|
700
|
-
import { join as
|
|
713
|
+
import { join as join3, resolve } from "path";
|
|
701
714
|
function isObject(x) {
|
|
702
715
|
return Boolean(x) && typeof x === "object" && !Array.isArray(x);
|
|
703
716
|
}
|
|
@@ -744,12 +757,12 @@ function getSettingsWithLocations(cwd) {
|
|
|
744
757
|
{
|
|
745
758
|
location: "user",
|
|
746
759
|
baseDirs: agentDirs,
|
|
747
|
-
settings: readMergedJsonFiles(agentDirs.map((dir) =>
|
|
760
|
+
settings: readMergedJsonFiles(agentDirs.map((dir) => join3(dir, "settings.json")))
|
|
748
761
|
},
|
|
749
762
|
{
|
|
750
763
|
location: "project",
|
|
751
764
|
baseDirs: projectDirs,
|
|
752
|
-
settings: readMergedJsonFiles(projectDirs.map((dir) =>
|
|
765
|
+
settings: readMergedJsonFiles(projectDirs.map((dir) => join3(dir, "settings.json")))
|
|
753
766
|
}
|
|
754
767
|
];
|
|
755
768
|
}
|
|
@@ -759,7 +772,7 @@ function getMergedSettings(cwd) {
|
|
|
759
772
|
}
|
|
760
773
|
function expandHomePath(value) {
|
|
761
774
|
if (value === "~") return homedir();
|
|
762
|
-
if (value.startsWith("~/")) return
|
|
775
|
+
if (value.startsWith("~/")) return join3(homedir(), value.slice(2));
|
|
763
776
|
return value;
|
|
764
777
|
}
|
|
765
778
|
function resolveAtomicPath(value, relativeBase = process.cwd()) {
|
|
@@ -779,12 +792,12 @@ function readMergedResourceSettings(cwd) {
|
|
|
779
792
|
}
|
|
780
793
|
function getAgentDir() {
|
|
781
794
|
const override = getFirstDefinedEnv(["ATOMIC_CODING_AGENT_DIR", "PI_CODING_AGENT_DIR"])?.trim();
|
|
782
|
-
return override ? resolveAtomicPath(override) :
|
|
795
|
+
return override ? resolveAtomicPath(override) : join3(homedir(), ".atomic", "agent");
|
|
783
796
|
}
|
|
784
797
|
function getAgentDirs() {
|
|
785
798
|
const primary = getAgentDir();
|
|
786
799
|
if (hasAgentDirOverride()) return [primary];
|
|
787
|
-
const legacy =
|
|
800
|
+
const legacy = join3(homedir(), ".pi", "agent");
|
|
788
801
|
return legacy === primary ? [primary] : [primary, legacy];
|
|
789
802
|
}
|
|
790
803
|
function getProjectConfigDirs(cwd) {
|
|
@@ -1119,7 +1132,7 @@ import { methods as methods2, RequestError as RequestError3 } from "@agentclient
|
|
|
1119
1132
|
|
|
1120
1133
|
// src/acp/slash-commands.ts
|
|
1121
1134
|
import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2, statSync } from "fs";
|
|
1122
|
-
import { basename, join as
|
|
1135
|
+
import { basename as basename2, join as join4 } from "path";
|
|
1123
1136
|
function parseFrontmatter(content) {
|
|
1124
1137
|
const frontmatter = {};
|
|
1125
1138
|
if (!content.startsWith("---")) return { frontmatter, content };
|
|
@@ -1144,7 +1157,7 @@ function describeContent(content, frontmatter, sourceStr) {
|
|
|
1144
1157
|
}
|
|
1145
1158
|
return description ? `${description} ${sourceStr}` : sourceStr;
|
|
1146
1159
|
}
|
|
1147
|
-
function loadCommandFromFile(path, sourceStr, name =
|
|
1160
|
+
function loadCommandFromFile(path, sourceStr, name = basename2(path, ".md")) {
|
|
1148
1161
|
try {
|
|
1149
1162
|
const rawContent = readFileSync2(path, "utf-8");
|
|
1150
1163
|
const { frontmatter, content } = parseFrontmatter(rawContent);
|
|
@@ -1166,7 +1179,7 @@ function loadCommandsFromDir(dir, source, subdir = "") {
|
|
|
1166
1179
|
const entries = readdirSync(dir, { withFileTypes: true });
|
|
1167
1180
|
for (const entry of entries) {
|
|
1168
1181
|
if (!entry.isFile() || !entry.name.endsWith(".md")) continue;
|
|
1169
|
-
const fullPath =
|
|
1182
|
+
const fullPath = join4(dir, entry.name);
|
|
1170
1183
|
const sourceStr = source === "path" ? "(path)" : source === "user" ? subdir ? `(user:${subdir})` : "(user)" : subdir ? `(project:${subdir})` : "(project)";
|
|
1171
1184
|
const command = loadCommandFromFile(fullPath, sourceStr);
|
|
1172
1185
|
if (command) commands.push(command);
|
|
@@ -1217,8 +1230,8 @@ function loadSlashCommands(cwd) {
|
|
|
1217
1230
|
commands.push(...loadCommandsFromSettingPath(resolved, entry.location));
|
|
1218
1231
|
}
|
|
1219
1232
|
}
|
|
1220
|
-
const projectDirs = getProjectConfigDirs(cwd).map((configDir) =>
|
|
1221
|
-
const userDirs = getAgentDirs().map((agentDir) =>
|
|
1233
|
+
const projectDirs = getProjectConfigDirs(cwd).map((configDir) => join4(configDir, "prompts"));
|
|
1234
|
+
const userDirs = getAgentDirs().map((agentDir) => join4(agentDir, "prompts"));
|
|
1222
1235
|
for (const projectDir of projectDirs) commands.push(...loadCommandsFromDir(projectDir, "project"));
|
|
1223
1236
|
for (const userDir of userDirs) commands.push(...loadCommandsFromDir(userDir, "user"));
|
|
1224
1237
|
return filterExcluded(commands, excludedPaths);
|
|
@@ -2244,22 +2257,22 @@ function toToolKind(toolName) {
|
|
|
2244
2257
|
|
|
2245
2258
|
// src/acp/session-store.ts
|
|
2246
2259
|
import { mkdirSync, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "fs";
|
|
2247
|
-
import { dirname } from "path";
|
|
2260
|
+
import { dirname as dirname2 } from "path";
|
|
2248
2261
|
|
|
2249
2262
|
// src/acp/paths.ts
|
|
2250
2263
|
import { homedir as homedir2 } from "os";
|
|
2251
|
-
import { join as
|
|
2264
|
+
import { join as join5 } from "path";
|
|
2252
2265
|
function getAtomicAcpDir(env = process.env) {
|
|
2253
2266
|
const override = env.ATOMIC_ACP_DIR?.trim();
|
|
2254
|
-
return override ? resolveAtomicPath(override) :
|
|
2267
|
+
return override ? resolveAtomicPath(override) : join5(homedir2(), ".atomic", "atomic-acp");
|
|
2255
2268
|
}
|
|
2256
2269
|
function getAtomicAcpSessionMapPath(env = process.env) {
|
|
2257
|
-
return
|
|
2270
|
+
return join5(getAtomicAcpDir(env), "session-map.json");
|
|
2258
2271
|
}
|
|
2259
2272
|
|
|
2260
2273
|
// src/acp/session-store.ts
|
|
2261
2274
|
function ensureParentDir(path) {
|
|
2262
|
-
mkdirSync(
|
|
2275
|
+
mkdirSync(dirname2(path), { recursive: true, mode: 448 });
|
|
2263
2276
|
}
|
|
2264
2277
|
function loadFile(path) {
|
|
2265
2278
|
try {
|
|
@@ -2850,20 +2863,16 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
2850
2863
|
if (cmd === "changelog") {
|
|
2851
2864
|
const findChangelog = () => {
|
|
2852
2865
|
try {
|
|
2853
|
-
const
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
const pkgRoot = dirname2(dirname2(resolved));
|
|
2857
|
-
const p = join5(pkgRoot, "CHANGELOG.md");
|
|
2858
|
-
if (existsSync3(p)) return p;
|
|
2859
|
-
}
|
|
2866
|
+
const resolved = resolveAtomicRealPath();
|
|
2867
|
+
const found = resolved && atomicChangelogCandidates(resolved).find((p) => existsSync3(p));
|
|
2868
|
+
if (found) return found;
|
|
2860
2869
|
} catch {
|
|
2861
2870
|
}
|
|
2862
2871
|
try {
|
|
2863
2872
|
const npmRoot = spawnSync("npm", ["root", "-g"], { encoding: "utf-8" });
|
|
2864
2873
|
const root = String(npmRoot.stdout ?? "").trim();
|
|
2865
2874
|
if (root) {
|
|
2866
|
-
const p =
|
|
2875
|
+
const p = join6(root, "@bastani", "atomic", "CHANGELOG.md");
|
|
2867
2876
|
if (existsSync3(p)) return p;
|
|
2868
2877
|
}
|
|
2869
2878
|
} catch {
|
|
@@ -2924,7 +2933,7 @@ ${JSON.stringify(stats, null, 2)}`;
|
|
|
2924
2933
|
return { stopReason: "end_turn" };
|
|
2925
2934
|
}
|
|
2926
2935
|
const safeSessionId = session.sessionId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
2927
|
-
const outputPath =
|
|
2936
|
+
const outputPath = join6(session.cwd, `atomic-session-${safeSessionId}.html`);
|
|
2928
2937
|
let resultPath;
|
|
2929
2938
|
try {
|
|
2930
2939
|
const result = await session.proc.exportHtml(outputPath);
|
|
@@ -3396,6 +3405,10 @@ function resolveAtomicExecutablePath() {
|
|
|
3396
3405
|
const which = spawnSync(whichCmd, [cmd], { encoding: "utf-8" });
|
|
3397
3406
|
return String(which.stdout ?? "").split(/\r?\n/)[0]?.trim() || null;
|
|
3398
3407
|
}
|
|
3408
|
+
function resolveAtomicRealPath() {
|
|
3409
|
+
const atomicPath = resolveAtomicExecutablePath();
|
|
3410
|
+
return atomicPath ? realpathSync(atomicPath) : null;
|
|
3411
|
+
}
|
|
3399
3412
|
function getAtomicVersionOutput() {
|
|
3400
3413
|
const cmd = getAtomicCommand(process.env.ATOMIC_ACP_ATOMIC_COMMAND);
|
|
3401
3414
|
const atomicVersion = spawnSync(cmd, ["--version"], {
|
|
@@ -3415,7 +3428,7 @@ function buildUpdateNotice() {
|
|
|
3415
3428
|
const latest = String(latestRes.stdout ?? "").trim().replace(/^v/i, "");
|
|
3416
3429
|
if (!latest || !isSemver(latest)) return null;
|
|
3417
3430
|
if (compareSemver(latest, installed) <= 0) return null;
|
|
3418
|
-
return `New version available: v${latest} (installed v${installed}). Run:
|
|
3431
|
+
return `New version available: v${latest} (installed v${installed}). Run: \`${ATOMIC_UPDATE_COMMAND}\``;
|
|
3419
3432
|
} catch {
|
|
3420
3433
|
return null;
|
|
3421
3434
|
}
|
|
@@ -3440,14 +3453,14 @@ function buildStartupInfo(opts) {
|
|
|
3440
3453
|
md.push("");
|
|
3441
3454
|
};
|
|
3442
3455
|
const contextItems = [];
|
|
3443
|
-
const contextPath =
|
|
3456
|
+
const contextPath = join6(opts.cwd, "AGENTS.md");
|
|
3444
3457
|
if (existsSync3(contextPath)) contextItems.push(contextPath);
|
|
3445
3458
|
addSection("Context", contextItems);
|
|
3446
3459
|
const skillsItems = [];
|
|
3447
3460
|
const pushSkillFromRoot = (root) => {
|
|
3448
3461
|
try {
|
|
3449
3462
|
for (const e of readdirSync2(root)) {
|
|
3450
|
-
const p =
|
|
3463
|
+
const p = join6(root, e);
|
|
3451
3464
|
try {
|
|
3452
3465
|
const st = statSync2(p);
|
|
3453
3466
|
if (st.isFile() && e.toLowerCase().endsWith(".md")) {
|
|
@@ -3467,7 +3480,7 @@ function buildStartupInfo(opts) {
|
|
|
3467
3480
|
}
|
|
3468
3481
|
for (const name of entries) {
|
|
3469
3482
|
if (name === "node_modules" || name === ".git") continue;
|
|
3470
|
-
const p =
|
|
3483
|
+
const p = join6(dir, name);
|
|
3471
3484
|
let st;
|
|
3472
3485
|
try {
|
|
3473
3486
|
st = statSync2(p);
|
|
@@ -3484,30 +3497,30 @@ function buildStartupInfo(opts) {
|
|
|
3484
3497
|
} catch {
|
|
3485
3498
|
}
|
|
3486
3499
|
};
|
|
3487
|
-
const globalSkillsDir =
|
|
3500
|
+
const globalSkillsDir = join6(getAgentDir(), "skills");
|
|
3488
3501
|
pushSkillFromRoot(globalSkillsDir);
|
|
3489
|
-
const legacyAgentsSkillsDir =
|
|
3502
|
+
const legacyAgentsSkillsDir = join6(process.env.HOME ?? "", ".agents", "skills");
|
|
3490
3503
|
pushSkillFromRoot(legacyAgentsSkillsDir);
|
|
3491
|
-
const projectSkillsDir =
|
|
3504
|
+
const projectSkillsDir = join6(opts.cwd, ".atomic", "skills");
|
|
3492
3505
|
pushSkillFromRoot(projectSkillsDir);
|
|
3493
3506
|
addSection("Skills", skillsItems);
|
|
3494
3507
|
const promptsItems = [];
|
|
3495
3508
|
const agentDir = getAgentDir();
|
|
3496
|
-
const promptsDir =
|
|
3509
|
+
const promptsDir = join6(agentDir, "prompts");
|
|
3497
3510
|
try {
|
|
3498
3511
|
const prompts = readdirSync2(promptsDir).filter((f) => f.endsWith(".md"));
|
|
3499
|
-
for (const f of prompts) promptsItems.push(`/${
|
|
3512
|
+
for (const f of prompts) promptsItems.push(`/${basename3(f, ".md")}`);
|
|
3500
3513
|
} catch {
|
|
3501
3514
|
}
|
|
3502
3515
|
addSection("Prompts", promptsItems);
|
|
3503
3516
|
const extItems = [];
|
|
3504
|
-
const extDir =
|
|
3517
|
+
const extDir = join6(agentDir, "extensions");
|
|
3505
3518
|
try {
|
|
3506
3519
|
const exts = readdirSync2(extDir).filter((f) => f.endsWith(".ts") || f.endsWith(".js"));
|
|
3507
|
-
for (const f of exts) extItems.push(
|
|
3520
|
+
for (const f of exts) extItems.push(join6(extDir, f));
|
|
3508
3521
|
} catch {
|
|
3509
3522
|
}
|
|
3510
|
-
for (const settingsPath of [
|
|
3523
|
+
for (const settingsPath of [join6(agentDir, "settings.json"), join6(opts.cwd, ".atomic", "settings.json")]) {
|
|
3511
3524
|
try {
|
|
3512
3525
|
const settings = JSON.parse(readFileSync5(settingsPath, "utf-8"));
|
|
3513
3526
|
const packages = Array.isArray(settings.packages) ? settings.packages : [];
|
|
@@ -3531,14 +3544,14 @@ function buildStartupInfo(opts) {
|
|
|
3531
3544
|
}
|
|
3532
3545
|
function readNearestPackageJson(metaUrl) {
|
|
3533
3546
|
try {
|
|
3534
|
-
let dir =
|
|
3547
|
+
let dir = dirname3(fileURLToPath(metaUrl));
|
|
3535
3548
|
for (let i = 0; i < 6; i++) {
|
|
3536
|
-
const p =
|
|
3549
|
+
const p = join6(dir, "package.json");
|
|
3537
3550
|
if (existsSync3(p)) {
|
|
3538
3551
|
const json = JSON.parse(readFileSync5(p, "utf-8"));
|
|
3539
3552
|
return { name: json?.name, version: json?.version };
|
|
3540
3553
|
}
|
|
3541
|
-
dir =
|
|
3554
|
+
dir = dirname3(dir);
|
|
3542
3555
|
}
|
|
3543
3556
|
} catch {
|
|
3544
3557
|
}
|
|
@@ -3603,10 +3616,8 @@ if ("command" in cli && cli.command === "terminal-login") {
|
|
|
3603
3616
|
shell: shouldUseShellForAtomicCommand(cmd)
|
|
3604
3617
|
});
|
|
3605
3618
|
if (res.error && res.error.code === "ENOENT") {
|
|
3606
|
-
process.stderr.write(
|
|
3607
|
-
|
|
3608
|
-
`
|
|
3609
|
-
);
|
|
3619
|
+
process.stderr.write(`atomic-acp: could not start Atomic (command not found: ${cmd}). ${ATOMIC_INSTALL_HINT}.
|
|
3620
|
+
`);
|
|
3610
3621
|
process.exit(1);
|
|
3611
3622
|
}
|
|
3612
3623
|
process.exit(typeof res.status === "number" ? res.status : 1);
|