@bastani/atomic-acp 0.0.3 → 0.0.4
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 +2 -0
- package/dist/index.js +51 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -60,6 +60,8 @@ npm install -g @bastani/atomic-acp
|
|
|
60
60
|
|
|
61
61
|
To run from source instead, clone this repository and run `npm install && npm run build`. The entry point is `dist/index.js`.
|
|
62
62
|
|
|
63
|
+
`atomic-acp --version` prints the installed version and `atomic-acp --help` lists the options. With no options, `atomic-acp` waits for an ACP client on stdio. Any other option before `--` makes it exit with an error.
|
|
64
|
+
|
|
63
65
|
### Add it to Zed
|
|
64
66
|
|
|
65
67
|
Open Zed's `settings.json` and add an agent server:
|
package/dist/index.js
CHANGED
|
@@ -304,8 +304,8 @@ function parseAtomicExtraArgs(argv, env) {
|
|
|
304
304
|
}
|
|
305
305
|
fromEnv.push(...parsed.map((arg) => validateAtomicArg(arg, "ATOMIC_ACP_ATOMIC_ARGS")));
|
|
306
306
|
}
|
|
307
|
-
const
|
|
308
|
-
const fromArgv =
|
|
307
|
+
const separator = argv.indexOf("--", 2);
|
|
308
|
+
const fromArgv = separator < 0 ? [] : argv.slice(separator + 1).map((arg) => validateAtomicArg(arg, "arguments after --"));
|
|
309
309
|
return [...fromEnv, ...fromArgv];
|
|
310
310
|
}
|
|
311
311
|
|
|
@@ -3878,10 +3878,56 @@ function readNearestPackageJson(metaUrl) {
|
|
|
3878
3878
|
return { name: "atomic-acp", version: "0.0.0" };
|
|
3879
3879
|
}
|
|
3880
3880
|
|
|
3881
|
+
// src/cli.ts
|
|
3882
|
+
var USAGE = `Usage: atomic-acp [options] [-- <atomic args...>]
|
|
3883
|
+
|
|
3884
|
+
Runs the Atomic ACP adapter over stdio. ACP clients such as Zed start it for you.
|
|
3885
|
+
|
|
3886
|
+
Options:
|
|
3887
|
+
--terminal-login Open Atomic in this terminal to log in to a provider
|
|
3888
|
+
-h, --help Show this help and exit
|
|
3889
|
+
-v, --version Show the version and exit
|
|
3890
|
+
|
|
3891
|
+
Arguments after -- are passed to every \`atomic --mode rpc\` process.
|
|
3892
|
+
`;
|
|
3893
|
+
var FLAGS = {
|
|
3894
|
+
"-h": "help",
|
|
3895
|
+
"--help": "help",
|
|
3896
|
+
"-v": "version",
|
|
3897
|
+
"--version": "version",
|
|
3898
|
+
"--terminal-login": "terminal-login"
|
|
3899
|
+
};
|
|
3900
|
+
var PRECEDENCE = ["help", "version", "terminal-login"];
|
|
3901
|
+
function parseCliArgs(argv) {
|
|
3902
|
+
const separator = argv.indexOf("--", 2);
|
|
3903
|
+
const adapterArgs = separator < 0 ? argv.slice(2) : argv.slice(2, separator);
|
|
3904
|
+
const commands = /* @__PURE__ */ new Set();
|
|
3905
|
+
for (const arg of adapterArgs) {
|
|
3906
|
+
if (!arg.startsWith("-")) continue;
|
|
3907
|
+
const command = FLAGS[arg];
|
|
3908
|
+
if (!command) return { error: `unknown option '${arg}'` };
|
|
3909
|
+
commands.add(command);
|
|
3910
|
+
}
|
|
3911
|
+
return { command: PRECEDENCE.find((command) => commands.has(command)) ?? "serve" };
|
|
3912
|
+
}
|
|
3913
|
+
|
|
3881
3914
|
// src/index.ts
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3915
|
+
async function writeAndExit(stream2, text, code) {
|
|
3916
|
+
await new Promise((resolve3) => stream2.write(text, () => resolve3()));
|
|
3917
|
+
process.exit(code);
|
|
3918
|
+
}
|
|
3919
|
+
var cli = parseCliArgs(process.argv);
|
|
3920
|
+
if ("error" in cli) {
|
|
3921
|
+
await writeAndExit(process.stderr, `atomic-acp: ${cli.error}
|
|
3922
|
+
Run 'atomic-acp --help' for usage.
|
|
3923
|
+
`, 2);
|
|
3924
|
+
} else if (cli.command === "help") {
|
|
3925
|
+
await writeAndExit(process.stdout, USAGE, 0);
|
|
3926
|
+
} else if (cli.command === "version") {
|
|
3927
|
+
await writeAndExit(process.stdout, `atomic-acp ${readNearestPackageJson(import.meta.url).version ?? "0.0.0"}
|
|
3928
|
+
`, 0);
|
|
3929
|
+
}
|
|
3930
|
+
if ("command" in cli && cli.command === "terminal-login") {
|
|
3885
3931
|
const { spawnSync: spawnSync2 } = await import("child_process");
|
|
3886
3932
|
const cmd = getAtomicCommand(process.env.ATOMIC_ACP_ATOMIC_COMMAND);
|
|
3887
3933
|
const res = spawnSync2(cmd, [], {
|