pi-plus-sdk 0.0.0-stage → 0.1.2
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 +9 -0
- package/README.md +57 -2
- package/api.d.ts +44 -0
- package/api.js +1678 -0
- package/core/export-html/template.css +1076 -0
- package/core/export-html/template.html +55 -0
- package/core/export-html/template.js +1902 -0
- package/core/export-html/vendor/highlight.min.js +1213 -0
- package/core/export-html/vendor/marked.min.js +78 -0
- package/modes/interactive/assets/clankolas.png +0 -0
- package/modes/interactive/theme/dark.json +91 -0
- package/modes/interactive/theme/light.json +90 -0
- package/modes/interactive/theme/theme-schema.json +361 -0
- package/package.json +39 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- Initial **`pi-plus-sdk`** npm artifact (published from this package): the programmatic pi-plus entry, split out of the `pi-plus` package so library hosts embed pi in-process with zero CLI logic. `import { createPlusAgentSession, createPlusUIContext, plusSdkExtensionFactories } from "pi-plus-sdk"` gives a host application (e.g. a desktop app) the compaction/context/reasoning overrides (baked in at bundle time by the shared redirect plugin) plus the nine non-TUI pi-plus extensions (subagent, tasks, memory, plan, ask-user, hooks, context-guard, /cd, /init). `createPlusAgentSession()` composes the upstream `createAgentSession` with a `DefaultResourceLoader` carrying those factories, reloads it, and binds extensions once (emitting `session_start`); hosts pass dialog handlers via the `ui` option to get working `ask_user` questions (select/confirm/input bridged to native UI), or omit it for a headless session. The staged package has an `exports` map (deep imports closed off), ships a hand-authored `api.d.ts` re-exporting `@earendil-works/pi-coding-agent` types (added as an exact-pinned dependency for type resolution only; the runtime stays self-contained), and has no bin. Hosts without a pi CLI on PATH should pass `excludeTools: ["subagent"]`: the subagent tool launches a pi subprocess and could otherwise relaunch the host app itself.
|
|
8
|
+
- The `/init` extension (shared core, `packages/plus/src/extensions/init/`) is registered by `plusSdkExtensionFactories` too: the `/init` command creates or improves `PI.md` at the cwd root and `PI.md` is auto-loaded into every agent run via the system prompt's context files.
|
|
9
|
+
- The SDK build redirects the upstream `main.ts` to a stub that throws — the CLI entry graph (startup UI, session picker, auth command, …) stays out of `api.js`, and calling `main()` is a clear error instead of silently running un-layered upstream pi. The re-exported `parseArgs`/`SettingsSelectorComponent` resolve to upstream pi (no pipi help text or CLI settings rows leak into the library surface).
|
package/README.md
CHANGED
|
@@ -1,3 +1,58 @@
|
|
|
1
|
-
#
|
|
1
|
+
# plus-api
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Builds the **`pi-plus-sdk`** npm package: pi with the pi-plus override layer as an
|
|
4
|
+
embeddable library, for hosts that run pi in-process (e.g. a desktop app) instead of
|
|
5
|
+
running the `pipi` CLI. The CLI counterpart is [`../plus-cli`](../plus-cli) (the
|
|
6
|
+
`pi-plus` package); the shared override core is [`../plus`](../plus).
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```js
|
|
11
|
+
import { createPlusAgentSession } from "pi-plus-sdk";
|
|
12
|
+
|
|
13
|
+
const { session } = await createPlusAgentSession({
|
|
14
|
+
cwd: projectDir,
|
|
15
|
+
ui: {
|
|
16
|
+
select: async (title, options) => showPicker(title, options),
|
|
17
|
+
confirm: async (title, message) => showConfirm(title, message),
|
|
18
|
+
input: async (title, placeholder) => showInput(title, placeholder),
|
|
19
|
+
},
|
|
20
|
+
// Hosts without a pi CLI on PATH should exclude the subagent tool: it
|
|
21
|
+
// launches a pi subprocess and could otherwise relaunch the host app.
|
|
22
|
+
excludeTools: ["subagent"],
|
|
23
|
+
});
|
|
24
|
+
await session.prompt("Review this repository");
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- The full pi-plus layer is included: the compaction/context/reasoning overrides are
|
|
28
|
+
baked into `api.js` by the shared bundle-time redirect plugin, and the nine
|
|
29
|
+
non-TUI pi-plus extensions (subagent, tasks, memory, plan, ask-user, hooks,
|
|
30
|
+
context-guard, `/cd`, `/init`) are registered exactly as the CLI wrapper registers them. No CLI
|
|
31
|
+
logic ships in this artifact: no hub dispatch, no completion, no pipi help text,
|
|
32
|
+
no banner/vim/tab-title/plain-tools.
|
|
33
|
+
- `createPlusAgentSession()` extends the upstream `createAgentSession` (re-exported,
|
|
34
|
+
with the whole upstream SDK surface) and always binds extensions once — do not call
|
|
35
|
+
`session.bindExtensions()` yourself. Pass `ui` dialog handlers to get working
|
|
36
|
+
`ask_user` questions (bound with mode `"rpc"`, so the tool falls back to sequential
|
|
37
|
+
select/input/confirm dialogs bridged to your UI); omit `ui` for a headless session.
|
|
38
|
+
- The staged `package.json` has an `exports` map, so deep imports are not reachable;
|
|
39
|
+
`api.d.ts` re-exports the `@earendil-works/pi-coding-agent` types (exact-pinned
|
|
40
|
+
dependency, type resolution only — the runtime is self-contained).
|
|
41
|
+
- `main` is re-exported from the upstream barrel but redirects to a stub that throws:
|
|
42
|
+
the CLI entry is not part of the SDK. Likewise `parseArgs`/`Args` and
|
|
43
|
+
`SettingsSelectorComponent` are upstream pi's versions, not the pipi-branded CLI
|
|
44
|
+
wrappers.
|
|
45
|
+
|
|
46
|
+
## Building the artifact
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npm run build:offline # at the repo root, first
|
|
50
|
+
npm run build # in packages/plus-api
|
|
51
|
+
npm publish --access public --ignore-scripts # in packages/plus-api/dist/npm
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Tests
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npx vitest run # from packages/plus-api
|
|
58
|
+
```
|
package/api.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public type contract for the "pi-plus" npm package's programmatic entry
|
|
3
|
+
* (api.js). Hand-authored mirror of src/api.ts: the runtime is fully
|
|
4
|
+
* self-contained in api.js (built from this repo with the pi-plus override
|
|
5
|
+
* layer baked in), so this file only needs to re-export the upstream SDK
|
|
6
|
+
* types and declare the pi-plus additions. A vitest drift guard
|
|
7
|
+
* (test/api.test.ts) asserts every runtime export of src/api.ts appears here.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export * from "@earendil-works/pi-coding-agent";
|
|
11
|
+
|
|
12
|
+
import type {
|
|
13
|
+
CreateAgentSessionOptions,
|
|
14
|
+
CreateAgentSessionResult,
|
|
15
|
+
ExtensionCommandContextActions,
|
|
16
|
+
ExtensionError,
|
|
17
|
+
ExtensionUIContext,
|
|
18
|
+
InlineExtension,
|
|
19
|
+
} from "@earendil-works/pi-coding-agent";
|
|
20
|
+
|
|
21
|
+
export declare const plusSdkExtensionFactories: InlineExtension[];
|
|
22
|
+
|
|
23
|
+
export interface PlusUIDialogHandlers {
|
|
24
|
+
select(title: string, options: string[]): Promise<string | undefined>;
|
|
25
|
+
confirm(title: string, message: string): Promise<boolean>;
|
|
26
|
+
input(title: string, placeholder?: string): Promise<string | undefined>;
|
|
27
|
+
editor?(title: string, prefill?: string): Promise<string | undefined>;
|
|
28
|
+
notify?(message: string, type?: "info" | "warning" | "error"): void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export declare function createPlusUIContext(handlers: PlusUIDialogHandlers): ExtensionUIContext;
|
|
32
|
+
|
|
33
|
+
export interface CreatePlusAgentSessionOptions extends CreateAgentSessionOptions {
|
|
34
|
+
extensionFactories?: InlineExtension[];
|
|
35
|
+
ui?: PlusUIDialogHandlers;
|
|
36
|
+
commandContextActions?: ExtensionCommandContextActions;
|
|
37
|
+
abortHandler?: () => void;
|
|
38
|
+
shutdownHandler?: () => void;
|
|
39
|
+
onError?: (error: ExtensionError) => void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export declare function createPlusAgentSession(
|
|
43
|
+
options?: CreatePlusAgentSessionOptions,
|
|
44
|
+
): Promise<CreateAgentSessionResult>;
|