@henryqw/pi-herdr 0.2.0 → 0.3.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/README.md +6 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Run Herdr CLI commands from Node through one thin client. Callers keep orchestration and command-specific checks.
|
|
4
4
|
|
|
5
|
+
## Why
|
|
6
|
+
|
|
7
|
+
- **Created for**: Calling Herdr CLI commands from Node without duplicating wrapper logic across extensions that each needed `exec`, `run`, and JSON parsing.
|
|
8
|
+
- **Advantage**: One thin client keeps orchestration local while the Herdr CLI stays the single source of truth for commands and response shapes.
|
|
9
|
+
|
|
5
10
|
## Install
|
|
6
11
|
|
|
7
12
|
```bash
|
|
@@ -13,8 +18,7 @@ npm install @henryqw/pi-herdr
|
|
|
13
18
|
```ts
|
|
14
19
|
import { createHerdrClient } from "@henryqw/pi-herdr";
|
|
15
20
|
|
|
16
|
-
const herdr = createHerdrClient((
|
|
17
|
-
pi.exec(command, [...args], options));
|
|
21
|
+
const herdr = createHerdrClient(pi.exec.bind(pi));
|
|
18
22
|
const response = await herdr.json(["agent", "list"], { cwd: ctx.cwd });
|
|
19
23
|
```
|
|
20
24
|
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ export interface HerdrExecResult {
|
|
|
4
4
|
stderr: string;
|
|
5
5
|
killed?: boolean;
|
|
6
6
|
}
|
|
7
|
-
|
|
7
|
+
/** Mutable-array executor, compatible with a bound `pi.exec`. Args are copied by createHerdrClient. */
|
|
8
|
+
export type HerdrExecutor<Options> = (command: string, args: string[], options: Options) => Promise<HerdrExecResult>;
|
|
8
9
|
export interface HerdrClient<Options> {
|
|
9
10
|
exec(args: readonly string[], options: Options): Promise<HerdrExecResult>;
|
|
10
11
|
run(args: readonly string[], options: Options): Promise<string>;
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export function createHerdrClient(execute) {
|
|
|
4
4
|
if (!Array.isArray(args) || args.some((arg) => typeof arg !== "string")) {
|
|
5
5
|
throw new TypeError("Herdr command arguments must be an array of strings");
|
|
6
6
|
}
|
|
7
|
-
return await execute("herdr", args, options);
|
|
7
|
+
return await execute("herdr", [...args], options);
|
|
8
8
|
};
|
|
9
9
|
const run = async (args, options) => {
|
|
10
10
|
const result = await exec(args, options);
|