pi-plus-sdk 0.1.1 → 0.1.3
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 +2 -1
- package/README.md +11 -4
- package/api.d.ts +53 -0
- package/api.js +171 -144
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,5 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
### Added
|
|
6
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
|
|
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.
|
|
8
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
|
@@ -25,11 +25,18 @@ await session.prompt("Review this repository");
|
|
|
25
25
|
```
|
|
26
26
|
|
|
27
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
|
|
28
|
+
baked into `api.js` by the shared bundle-time redirect plugin, and the nine
|
|
29
29
|
non-TUI pi-plus extensions (subagent, tasks, memory, plan, ask-user, hooks,
|
|
30
|
-
context-guard) are registered exactly as the CLI wrapper registers them. No CLI
|
|
31
|
-
logic ships in this artifact: no hub dispatch
|
|
32
|
-
no banner/vim/tab-title/plain-tools
|
|
30
|
+
context-guard, `/cd`, `/init`) are registered exactly as the CLI wrapper registers them. No CLI
|
|
31
|
+
logic ships in this artifact: no hub command dispatch (`pipi profile ...`), no
|
|
32
|
+
completion, no pipi help text, no banner/vim/tab-title/plain-tools.
|
|
33
|
+
- Profile management ships as a library: the curated `@earendil-works/pi-hub`
|
|
34
|
+
surface is re-exported (`src/profiles.ts`) — `loadProfiles/findProfile/
|
|
35
|
+
addProfile/updateProfile/removeProfile/renameProfile/setDefaultProfile/
|
|
36
|
+
clearDefaultProfile/getDefaultProfileName` for `~/.pi/profiles.json`, and
|
|
37
|
+
`materializeProfile/removeProfileDir/profileDirFor/AGENT_DIR/
|
|
38
|
+
syncProfilePackagesToSource` for the per-profile agent dirs. Hosts get the
|
|
39
|
+
exact contract the `pipi` CLI dispatches instead of reimplementing it.
|
|
33
40
|
- `createPlusAgentSession()` extends the upstream `createAgentSession` (re-exported,
|
|
34
41
|
with the whole upstream SDK surface) and always binds extensions once — do not call
|
|
35
42
|
`session.bindExtensions()` yourself. Pass `ui` dialog handlers to get working
|
package/api.d.ts
CHANGED
|
@@ -42,3 +42,56 @@ export interface CreatePlusAgentSessionOptions extends CreateAgentSessionOptions
|
|
|
42
42
|
export declare function createPlusAgentSession(
|
|
43
43
|
options?: CreatePlusAgentSessionOptions,
|
|
44
44
|
): Promise<CreateAgentSessionResult>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Profile management: the curated @earendil-works/pi-hub surface bundled into
|
|
48
|
+
* api.js (profiles.json CRUD + per-profile materialized agent dirs). Types are
|
|
49
|
+
* declared inline because pi-hub is not a dependency of this package — keep
|
|
50
|
+
* them in sync with packages/hub/src/types.ts.
|
|
51
|
+
*/
|
|
52
|
+
export interface Profile {
|
|
53
|
+
provider?: string;
|
|
54
|
+
model?: string;
|
|
55
|
+
models?: string[];
|
|
56
|
+
thinking?: string;
|
|
57
|
+
token?: string;
|
|
58
|
+
url?: string;
|
|
59
|
+
/** Arbitrary settings.json overrides, merged over the source agent settings.
|
|
60
|
+
* A null value deletes the key from the materialized settings.json. */
|
|
61
|
+
settings?: Record<string, unknown>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface ProfilesData {
|
|
65
|
+
profiles: Record<string, Profile>;
|
|
66
|
+
default?: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface AgentSettingsData {
|
|
70
|
+
defaultProvider?: string;
|
|
71
|
+
defaultModel?: string;
|
|
72
|
+
defaultThinkingLevel?: string;
|
|
73
|
+
skills?: unknown;
|
|
74
|
+
[key: string]: unknown;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export declare const THINKING_LEVELS: string[];
|
|
78
|
+
|
|
79
|
+
/** Marker stored in `profiles.json` `default` meaning "no profile, run plain pi". */
|
|
80
|
+
export declare const BUILT_IN_DEFAULT: "__builtin__";
|
|
81
|
+
|
|
82
|
+
/** Source agent dir (PI_CODING_AGENT_DIR or ~/.pi/agent): profiles without an applied profile. */
|
|
83
|
+
export declare const AGENT_DIR: string;
|
|
84
|
+
|
|
85
|
+
export declare function loadProfiles(): ProfilesData;
|
|
86
|
+
export declare function findProfile(name: string): Profile | undefined;
|
|
87
|
+
export declare function getDefaultProfileName(): string | undefined;
|
|
88
|
+
export declare function setDefaultProfile(name: string): void;
|
|
89
|
+
export declare function clearDefaultProfile(): void;
|
|
90
|
+
export declare function addProfile(name: string, profile: Profile): void;
|
|
91
|
+
export declare function updateProfile(name: string, profile: Profile): void;
|
|
92
|
+
export declare function removeProfile(name: string): void;
|
|
93
|
+
export declare function renameProfile(oldName: string, newName: string): void;
|
|
94
|
+
export declare function profileDirFor(name: string): string;
|
|
95
|
+
export declare function materializeProfile(name: string, profile: Profile): string;
|
|
96
|
+
export declare function removeProfileDir(name: string): void;
|
|
97
|
+
export declare function syncProfilePackagesToSource(profileDir: string): boolean;
|