@bastani/atomic 0.8.3-0 → 0.8.4-0
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 +33 -17
- package/README.md +3 -3
- package/dist/builtin/intercom/index.ts +1 -1
- package/dist/builtin/intercom/package.json +1 -5
- package/dist/builtin/intercom/ui/compose.ts +1 -1
- package/dist/builtin/intercom/ui/inline-message.ts +1 -1
- package/dist/builtin/intercom/ui/session-list.ts +1 -1
- package/dist/builtin/mcp/commands.ts +1 -1
- package/dist/builtin/mcp/direct-tools.ts +1 -1
- package/dist/builtin/mcp/index.ts +1 -1
- package/dist/builtin/mcp/init.ts +1 -1
- package/dist/builtin/mcp/package.json +1 -5
- package/dist/builtin/mcp/proxy-modes.ts +1 -1
- package/dist/builtin/mcp/sampling-handler.ts +1 -1
- package/dist/builtin/mcp/state.ts +1 -1
- package/dist/builtin/mcp/tool-result-renderer.ts +1 -1
- package/dist/builtin/mcp/utils.ts +1 -1
- package/dist/builtin/subagents/CHANGELOG.md +3 -3
- package/dist/builtin/subagents/package.json +1 -5
- package/dist/builtin/subagents/src/agents/agent-management.ts +1 -1
- package/dist/builtin/subagents/src/extension/control-notices.ts +1 -1
- package/dist/builtin/subagents/src/extension/index.ts +1 -1
- package/dist/builtin/subagents/src/runs/background/async-execution.ts +1 -1
- package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +1 -1
- package/dist/builtin/subagents/src/runs/background/notify.ts +1 -1
- package/dist/builtin/subagents/src/runs/foreground/chain-clarify.ts +1 -1
- package/dist/builtin/subagents/src/runs/foreground/chain-execution.ts +1 -1
- package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +1 -1
- package/dist/builtin/subagents/src/runs/shared/pi-spawn.ts +20 -17
- package/dist/builtin/subagents/src/runs/shared/subagent-prompt-runtime.ts +1 -1
- package/dist/builtin/subagents/src/shared/fork-context.ts +1 -1
- package/dist/builtin/subagents/src/shared/types.ts +1 -1
- package/dist/builtin/subagents/src/slash/slash-bridge.ts +1 -1
- package/dist/builtin/subagents/src/slash/slash-commands.ts +1 -1
- package/dist/builtin/subagents/src/tui/render-helpers.ts +1 -1
- package/dist/builtin/subagents/src/tui/render.ts +1 -1
- package/dist/builtin/web-access/index.ts +1 -1
- package/dist/builtin/web-access/package.json +1 -5
- package/dist/builtin/web-access/storage.ts +1 -1
- package/dist/builtin/web-access/summary-review.ts +1 -1
- package/dist/builtin/workflows/package.json +1 -5
- package/dist/builtin/workflows/src/extension/index.ts +1 -1
- package/dist/builtin/workflows/src/extension/wiring.ts +10 -10
- package/dist/builtin/workflows/src/runs/foreground/stage-control-registry.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/stage-runner.ts +1 -1
- package/dist/builtin/workflows/src/runs/shared/model-fallback.ts +1 -1
- package/dist/builtin/workflows/src/runs/shared/workflow-runner.ts +1 -1
- package/dist/builtin/workflows/src/shared/types.ts +1 -1
- package/dist/builtin/workflows/src/tui/graph-theme.ts +2 -2
- package/dist/builtin/workflows/src/tui/overlay-adapter.ts +1 -1
- package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +1 -1
- package/dist/core/agent-session.d.ts +1 -0
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +9 -0
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +0 -4
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/types.d.ts +2 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +29 -12
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/system-prompt.d.ts +10 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +80 -8
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +2 -2
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/utils/tools-manager.d.ts.map +1 -1
- package/dist/utils/tools-manager.js +35 -9
- package/dist/utils/tools-manager.js.map +1 -1
- package/docs/compaction.md +2 -2
- package/docs/custom-provider.md +2 -2
- package/docs/extensions.md +17 -17
- package/docs/index.md +1 -1
- package/docs/packages.md +1 -1
- package/docs/quickstart.md +1 -1
- package/docs/rpc.md +1 -1
- package/docs/sdk.md +22 -22
- package/docs/session-format.md +1 -1
- package/docs/termux.md +1 -1
- package/docs/tui.md +6 -6
- package/examples/extensions/README.md +1 -1
- package/examples/extensions/auto-commit-on-exit.ts +1 -1
- package/examples/extensions/bash-spawn-hook.ts +2 -2
- package/examples/extensions/bookmark.ts +1 -1
- package/examples/extensions/border-status-editor.ts +1 -1
- package/examples/extensions/built-in-tool-renderer.ts +2 -2
- package/examples/extensions/claude-rules.ts +1 -1
- package/examples/extensions/commands.ts +1 -1
- package/examples/extensions/confirm-destructive.ts +1 -1
- package/examples/extensions/custom-compaction.ts +2 -2
- package/examples/extensions/custom-footer.ts +1 -1
- package/examples/extensions/custom-header.ts +2 -2
- package/examples/extensions/custom-provider-anthropic/index.ts +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/index.ts +1 -1
- package/examples/extensions/dirty-repo-guard.ts +1 -1
- package/examples/extensions/doom-overlay/index.ts +1 -1
- package/examples/extensions/dynamic-resources/index.ts +1 -1
- package/examples/extensions/dynamic-tools.ts +1 -1
- package/examples/extensions/event-bus.ts +1 -1
- package/examples/extensions/file-trigger.ts +1 -1
- package/examples/extensions/git-checkpoint.ts +1 -1
- package/examples/extensions/github-issue-autocomplete.ts +1 -1
- package/examples/extensions/handoff.ts +2 -2
- package/examples/extensions/hello.ts +1 -1
- package/examples/extensions/hidden-thinking-label.ts +1 -1
- package/examples/extensions/inline-bash.ts +1 -1
- package/examples/extensions/input-transform.ts +1 -1
- package/examples/extensions/interactive-shell.ts +1 -1
- package/examples/extensions/mac-system-theme.ts +1 -1
- package/examples/extensions/message-renderer.ts +1 -1
- package/examples/extensions/minimal-mode.ts +2 -2
- package/examples/extensions/modal-editor.ts +1 -1
- package/examples/extensions/model-status.ts +1 -1
- package/examples/extensions/notify.ts +1 -1
- package/examples/extensions/overlay-qa-tests.ts +1 -1
- package/examples/extensions/overlay-test.ts +1 -1
- package/examples/extensions/permission-gate.ts +1 -1
- package/examples/extensions/pirate.ts +1 -1
- package/examples/extensions/plan-mode/index.ts +1 -1
- package/examples/extensions/preset.ts +2 -2
- package/examples/extensions/prompt-customizer.ts +1 -1
- package/examples/extensions/protected-paths.ts +1 -1
- package/examples/extensions/provider-payload.ts +1 -1
- package/examples/extensions/qna.ts +2 -2
- package/examples/extensions/question.ts +1 -1
- package/examples/extensions/questionnaire.ts +1 -1
- package/examples/extensions/rainbow-editor.ts +1 -1
- package/examples/extensions/reload-runtime.ts +1 -1
- package/examples/extensions/rpc-demo.ts +1 -1
- package/examples/extensions/sandbox/index.ts +2 -2
- package/examples/extensions/send-user-message.ts +1 -1
- package/examples/extensions/session-name.ts +1 -1
- package/examples/extensions/shutdown-command.ts +1 -1
- package/examples/extensions/snake.ts +1 -1
- package/examples/extensions/space-invaders.ts +1 -1
- package/examples/extensions/ssh.ts +2 -2
- package/examples/extensions/status-line.ts +1 -1
- package/examples/extensions/structured-output.ts +1 -1
- package/examples/extensions/subagent/agents.ts +1 -1
- package/examples/extensions/subagent/index.ts +1 -1
- package/examples/extensions/summarize.ts +2 -2
- package/examples/extensions/system-prompt-header.ts +1 -1
- package/examples/extensions/tic-tac-toe.ts +1 -1
- package/examples/extensions/timed-confirm.ts +1 -1
- package/examples/extensions/titlebar-spinner.ts +1 -1
- package/examples/extensions/todo.ts +1 -1
- package/examples/extensions/tool-override.ts +1 -1
- package/examples/extensions/tools.ts +2 -2
- package/examples/extensions/trigger-compact.ts +1 -1
- package/examples/extensions/truncated-tool.ts +2 -2
- package/examples/extensions/widget-placement.ts +1 -1
- package/examples/extensions/with-deps/index.ts +1 -1
- package/examples/extensions/working-indicator.ts +1 -1
- package/examples/extensions/working-message-test.ts +1 -1
- package/examples/sdk/01-minimal.ts +1 -1
- package/examples/sdk/02-custom-model.ts +1 -1
- package/examples/sdk/03-custom-prompt.ts +1 -1
- package/examples/sdk/04-skills.ts +1 -1
- package/examples/sdk/05-tools.ts +1 -1
- package/examples/sdk/06-extensions.ts +2 -2
- package/examples/sdk/07-context-files.ts +1 -1
- package/examples/sdk/08-prompt-templates.ts +1 -1
- package/examples/sdk/09-api-keys-and-oauth.ts +1 -1
- package/examples/sdk/10-settings.ts +1 -1
- package/examples/sdk/11-sessions.ts +1 -1
- package/examples/sdk/12-full-control.ts +1 -1
- package/examples/sdk/13-session-runtime.ts +1 -1
- package/examples/sdk/README.md +1 -1
- package/package.json +1 -1
package/docs/sdk.md
CHANGED
|
@@ -16,7 +16,7 @@ See [examples/sdk/](../examples/sdk/) for working examples from minimal to full
|
|
|
16
16
|
## Quick Start
|
|
17
17
|
|
|
18
18
|
```typescript
|
|
19
|
-
import { AuthStorage, createAgentSession, ModelRegistry, SessionManager } from "@
|
|
19
|
+
import { AuthStorage, createAgentSession, ModelRegistry, SessionManager } from "@bastani/atomic";
|
|
20
20
|
|
|
21
21
|
// Set up credential storage and model registry
|
|
22
22
|
const authStorage = AuthStorage.create();
|
|
@@ -40,7 +40,7 @@ await session.prompt("What files are in the current directory?");
|
|
|
40
40
|
## Installation
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
npm install @
|
|
43
|
+
npm install @bastani/atomic
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
The SDK is included in the main package. No separate installation needed.
|
|
@@ -54,7 +54,7 @@ The main factory function for a single `AgentSession`.
|
|
|
54
54
|
`createAgentSession()` uses a `ResourceLoader` to supply extensions, skills, prompt templates, themes, and context files. If you do not provide one, it uses `DefaultResourceLoader` with standard discovery.
|
|
55
55
|
|
|
56
56
|
```typescript
|
|
57
|
-
import { createAgentSession, SessionManager } from "@
|
|
57
|
+
import { createAgentSession, SessionManager } from "@bastani/atomic";
|
|
58
58
|
|
|
59
59
|
// Minimal: defaults with DefaultResourceLoader
|
|
60
60
|
const { session } = await createAgentSession();
|
|
@@ -132,7 +132,7 @@ import {
|
|
|
132
132
|
createAgentSessionServices,
|
|
133
133
|
getAgentDir,
|
|
134
134
|
SessionManager,
|
|
135
|
-
} from "@
|
|
135
|
+
} from "@bastani/atomic";
|
|
136
136
|
|
|
137
137
|
const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionManager, sessionStartEvent }) => {
|
|
138
138
|
const services = await createAgentSessionServices({ cwd });
|
|
@@ -369,7 +369,7 @@ When you pass a custom `ResourceLoader`, `cwd` and `agentDir` no longer control
|
|
|
369
369
|
|
|
370
370
|
```typescript
|
|
371
371
|
import { getModel } from "@earendil-works/pi-ai";
|
|
372
|
-
import { AuthStorage, ModelRegistry } from "@
|
|
372
|
+
import { AuthStorage, ModelRegistry } from "@bastani/atomic";
|
|
373
373
|
|
|
374
374
|
const authStorage = AuthStorage.create();
|
|
375
375
|
const modelRegistry = ModelRegistry.create(authStorage);
|
|
@@ -416,7 +416,7 @@ API key resolution priority (handled by AuthStorage):
|
|
|
416
416
|
4. Fallback resolver (for custom provider keys from `models.json`)
|
|
417
417
|
|
|
418
418
|
```typescript
|
|
419
|
-
import { AuthStorage, ModelRegistry } from "@
|
|
419
|
+
import { AuthStorage, ModelRegistry } from "@bastani/atomic";
|
|
420
420
|
|
|
421
421
|
// Default: uses ~/.pi/agent/auth.json and ~/.pi/agent/models.json
|
|
422
422
|
const authStorage = AuthStorage.create();
|
|
@@ -452,7 +452,7 @@ const simpleRegistry = ModelRegistry.inMemory(authStorage);
|
|
|
452
452
|
Use a `ResourceLoader` to override the system prompt:
|
|
453
453
|
|
|
454
454
|
```typescript
|
|
455
|
-
import { createAgentSession, DefaultResourceLoader } from "@
|
|
455
|
+
import { createAgentSession, DefaultResourceLoader } from "@bastani/atomic";
|
|
456
456
|
|
|
457
457
|
const loader = new DefaultResourceLoader({
|
|
458
458
|
systemPromptOverride: () => "You are a helpful assistant.",
|
|
@@ -474,7 +474,7 @@ Specify which built-in tools to enable:
|
|
|
474
474
|
- `noTools: "builtin"` disables default built-ins while keeping extension and custom tools enabled
|
|
475
475
|
|
|
476
476
|
```typescript
|
|
477
|
-
import { createAgentSession } from "@
|
|
477
|
+
import { createAgentSession } from "@bastani/atomic";
|
|
478
478
|
|
|
479
479
|
// Read-only mode
|
|
480
480
|
const { session } = await createAgentSession({
|
|
@@ -492,7 +492,7 @@ const { session } = await createAgentSession({
|
|
|
492
492
|
When you pass a custom `cwd`, `createAgentSession()` builds selected built-in tools for that cwd.
|
|
493
493
|
|
|
494
494
|
```typescript
|
|
495
|
-
import { createAgentSession, SessionManager } from "@
|
|
495
|
+
import { createAgentSession, SessionManager } from "@bastani/atomic";
|
|
496
496
|
|
|
497
497
|
const cwd = "/path/to/project";
|
|
498
498
|
|
|
@@ -516,7 +516,7 @@ const { session } = await createAgentSession({
|
|
|
516
516
|
|
|
517
517
|
```typescript
|
|
518
518
|
import { Type } from "typebox";
|
|
519
|
-
import { createAgentSession, defineTool } from "@
|
|
519
|
+
import { createAgentSession, defineTool } from "@bastani/atomic";
|
|
520
520
|
|
|
521
521
|
// Inline custom tool
|
|
522
522
|
const myTool = defineTool({
|
|
@@ -551,7 +551,7 @@ If you pass `tools`, include each custom or extension tool name you want enabled
|
|
|
551
551
|
Extensions are loaded by the `ResourceLoader`. `DefaultResourceLoader` discovers extensions from `~/.pi/agent/extensions/`, `.pi/extensions/`, and settings.json extension sources.
|
|
552
552
|
|
|
553
553
|
```typescript
|
|
554
|
-
import { createAgentSession, DefaultResourceLoader } from "@
|
|
554
|
+
import { createAgentSession, DefaultResourceLoader } from "@bastani/atomic";
|
|
555
555
|
|
|
556
556
|
const loader = new DefaultResourceLoader({
|
|
557
557
|
additionalExtensionPaths: ["/path/to/my-extension.ts"],
|
|
@@ -573,7 +573,7 @@ Extensions can register tools, subscribe to events, add commands, and more. See
|
|
|
573
573
|
**Event Bus:** Extensions can communicate via `pi.events`. Pass a shared `eventBus` to `DefaultResourceLoader` if you need to emit or listen from outside:
|
|
574
574
|
|
|
575
575
|
```typescript
|
|
576
|
-
import { createEventBus, DefaultResourceLoader } from "@
|
|
576
|
+
import { createEventBus, DefaultResourceLoader } from "@bastani/atomic";
|
|
577
577
|
|
|
578
578
|
const eventBus = createEventBus();
|
|
579
579
|
const loader = new DefaultResourceLoader({
|
|
@@ -593,7 +593,7 @@ import {
|
|
|
593
593
|
createAgentSession,
|
|
594
594
|
DefaultResourceLoader,
|
|
595
595
|
type Skill,
|
|
596
|
-
} from "@
|
|
596
|
+
} from "@bastani/atomic";
|
|
597
597
|
|
|
598
598
|
const customSkill: Skill = {
|
|
599
599
|
name: "my-skill",
|
|
@@ -619,7 +619,7 @@ const { session } = await createAgentSession({ resourceLoader: loader });
|
|
|
619
619
|
### Context Files
|
|
620
620
|
|
|
621
621
|
```typescript
|
|
622
|
-
import { createAgentSession, DefaultResourceLoader } from "@
|
|
622
|
+
import { createAgentSession, DefaultResourceLoader } from "@bastani/atomic";
|
|
623
623
|
|
|
624
624
|
const loader = new DefaultResourceLoader({
|
|
625
625
|
agentsFilesOverride: (current) => ({
|
|
@@ -643,7 +643,7 @@ import {
|
|
|
643
643
|
createAgentSession,
|
|
644
644
|
DefaultResourceLoader,
|
|
645
645
|
type PromptTemplate,
|
|
646
|
-
} from "@
|
|
646
|
+
} from "@bastani/atomic";
|
|
647
647
|
|
|
648
648
|
const customCommand: PromptTemplate = {
|
|
649
649
|
name: "deploy",
|
|
@@ -678,7 +678,7 @@ import {
|
|
|
678
678
|
createAgentSessionServices,
|
|
679
679
|
getAgentDir,
|
|
680
680
|
SessionManager,
|
|
681
|
-
} from "@
|
|
681
|
+
} from "@bastani/atomic";
|
|
682
682
|
|
|
683
683
|
// In-memory (no persistence)
|
|
684
684
|
const { session } = await createAgentSession({
|
|
@@ -772,7 +772,7 @@ sm.createBranchedSession(leafId); // Extract path to new file
|
|
|
772
772
|
### Settings Management
|
|
773
773
|
|
|
774
774
|
```typescript
|
|
775
|
-
import { createAgentSession, SettingsManager, SessionManager } from "@
|
|
775
|
+
import { createAgentSession, SettingsManager, SessionManager } from "@bastani/atomic";
|
|
776
776
|
|
|
777
777
|
// Default: loads from files (global + project merged)
|
|
778
778
|
const { session } = await createAgentSession({
|
|
@@ -828,7 +828,7 @@ Use `DefaultResourceLoader` to discover extensions, skills, prompts, themes, and
|
|
|
828
828
|
import {
|
|
829
829
|
DefaultResourceLoader,
|
|
830
830
|
getAgentDir,
|
|
831
|
-
} from "@
|
|
831
|
+
} from "@bastani/atomic";
|
|
832
832
|
|
|
833
833
|
const loader = new DefaultResourceLoader({
|
|
834
834
|
cwd,
|
|
@@ -879,7 +879,7 @@ import {
|
|
|
879
879
|
ModelRegistry,
|
|
880
880
|
SessionManager,
|
|
881
881
|
SettingsManager,
|
|
882
|
-
} from "@
|
|
882
|
+
} from "@bastani/atomic";
|
|
883
883
|
|
|
884
884
|
// Set up auth storage (custom location)
|
|
885
885
|
const authStorage = AuthStorage.create("/custom/agent/auth.json");
|
|
@@ -964,7 +964,7 @@ import {
|
|
|
964
964
|
getAgentDir,
|
|
965
965
|
InteractiveMode,
|
|
966
966
|
SessionManager,
|
|
967
|
-
} from "@
|
|
967
|
+
} from "@bastani/atomic";
|
|
968
968
|
|
|
969
969
|
const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionManager, sessionStartEvent }) => {
|
|
970
970
|
const services = await createAgentSessionServices({ cwd });
|
|
@@ -1004,7 +1004,7 @@ import {
|
|
|
1004
1004
|
getAgentDir,
|
|
1005
1005
|
runPrintMode,
|
|
1006
1006
|
SessionManager,
|
|
1007
|
-
} from "@
|
|
1007
|
+
} from "@bastani/atomic";
|
|
1008
1008
|
|
|
1009
1009
|
const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionManager, sessionStartEvent }) => {
|
|
1010
1010
|
const services = await createAgentSessionServices({ cwd });
|
|
@@ -1041,7 +1041,7 @@ import {
|
|
|
1041
1041
|
getAgentDir,
|
|
1042
1042
|
runRpcMode,
|
|
1043
1043
|
SessionManager,
|
|
1044
|
-
} from "@
|
|
1044
|
+
} from "@bastani/atomic";
|
|
1045
1045
|
|
|
1046
1046
|
const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionManager, sessionStartEvent }) => {
|
|
1047
1047
|
const services = await createAgentSessionServices({ cwd });
|
package/docs/session-format.md
CHANGED
|
@@ -34,7 +34,7 @@ Source on GitHub ([pi-mono](https://github.com/earendil-works/pi-mono)):
|
|
|
34
34
|
- [`packages/ai/src/types.ts`](https://github.com/earendil-works/pi-mono/blob/main/packages/ai/src/types.ts) - Base message types (UserMessage, AssistantMessage, ToolResultMessage)
|
|
35
35
|
- [`packages/agent/src/types.ts`](https://github.com/earendil-works/pi-mono/blob/main/packages/agent/src/types.ts) - AgentMessage union type
|
|
36
36
|
|
|
37
|
-
For TypeScript definitions in your project, inspect `node_modules/@
|
|
37
|
+
For TypeScript definitions in your project, inspect `node_modules/@bastani/atomic/dist/` and `node_modules/@earendil-works/pi-ai/dist/`.
|
|
38
38
|
|
|
39
39
|
## Message Types
|
|
40
40
|
|
package/docs/termux.md
CHANGED
package/docs/tui.md
CHANGED
|
@@ -425,7 +425,7 @@ renderResult(result, options, theme, context) {
|
|
|
425
425
|
**For Markdown**, use `getMarkdownTheme()`:
|
|
426
426
|
|
|
427
427
|
```typescript
|
|
428
|
-
import { getMarkdownTheme } from "@
|
|
428
|
+
import { getMarkdownTheme } from "@bastani/atomic";
|
|
429
429
|
import { Markdown } from "@earendil-works/pi-tui";
|
|
430
430
|
|
|
431
431
|
renderResult(result, options, theme, context) {
|
|
@@ -590,8 +590,8 @@ These patterns cover the most common UI needs in extensions. **Copy these patter
|
|
|
590
590
|
For letting users pick from a list of options. Use `SelectList` from `@earendil-works/pi-tui` with `DynamicBorder` for framing.
|
|
591
591
|
|
|
592
592
|
```typescript
|
|
593
|
-
import type { ExtensionAPI } from "@
|
|
594
|
-
import { DynamicBorder } from "@
|
|
593
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
594
|
+
import { DynamicBorder } from "@bastani/atomic";
|
|
595
595
|
import { Container, type SelectItem, SelectList, Text } from "@earendil-works/pi-tui";
|
|
596
596
|
|
|
597
597
|
pi.registerCommand("pick", {
|
|
@@ -650,7 +650,7 @@ pi.registerCommand("pick", {
|
|
|
650
650
|
For operations that take time and should be cancellable. `BorderedLoader` shows a spinner and handles escape to cancel.
|
|
651
651
|
|
|
652
652
|
```typescript
|
|
653
|
-
import { BorderedLoader } from "@
|
|
653
|
+
import { BorderedLoader } from "@bastani/atomic";
|
|
654
654
|
|
|
655
655
|
pi.registerCommand("fetch", {
|
|
656
656
|
handler: async (_args, ctx) => {
|
|
@@ -682,7 +682,7 @@ pi.registerCommand("fetch", {
|
|
|
682
682
|
For toggling multiple settings. Use `SettingsList` from `@earendil-works/pi-tui` with `getSettingsListTheme()`.
|
|
683
683
|
|
|
684
684
|
```typescript
|
|
685
|
-
import { getSettingsListTheme } from "@
|
|
685
|
+
import { getSettingsListTheme } from "@bastani/atomic";
|
|
686
686
|
import { Container, type SettingItem, SettingsList, Text } from "@earendil-works/pi-tui";
|
|
687
687
|
|
|
688
688
|
pi.registerCommand("settings", {
|
|
@@ -822,7 +822,7 @@ Token stats available via `ctx.sessionManager.getBranch()` and `ctx.model`.
|
|
|
822
822
|
Replace the main input editor with a custom implementation. Useful for modal editing (vim), different keybindings (emacs), or specialized input handling.
|
|
823
823
|
|
|
824
824
|
```typescript
|
|
825
|
-
import { CustomEditor, type ExtensionAPI } from "@
|
|
825
|
+
import { CustomEditor, type ExtensionAPI } from "@bastani/atomic";
|
|
826
826
|
import { matchesKey, truncateToWidth } from "@earendil-works/pi-tui";
|
|
827
827
|
|
|
828
828
|
type Mode = "normal" | "insert";
|
|
@@ -137,7 +137,7 @@ cp permission-gate.ts ~/.pi/agent/extensions/
|
|
|
137
137
|
See [docs/extensions.md](../../docs/extensions.md) for full documentation.
|
|
138
138
|
|
|
139
139
|
```typescript
|
|
140
|
-
import type { ExtensionAPI } from "@
|
|
140
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
141
141
|
import { Type } from "typebox";
|
|
142
142
|
|
|
143
143
|
export default function (pi: ExtensionAPI) {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Uses the last assistant message to generate a commit message.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { ExtensionAPI } from "@
|
|
8
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
9
9
|
|
|
10
10
|
export default function (pi: ExtensionAPI) {
|
|
11
11
|
pi.on("session_shutdown", async (_event, ctx) => {
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* pi -e ./bash-spawn-hook.ts
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { ExtensionAPI } from "@
|
|
11
|
-
import { createBashTool } from "@
|
|
10
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
11
|
+
import { createBashTool } from "@bastani/atomic";
|
|
12
12
|
|
|
13
13
|
export default function (pi: ExtensionAPI) {
|
|
14
14
|
const cwd = process.cwd();
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Usage: /bookmark [label] - bookmark the last assistant message
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { ExtensionAPI } from "@
|
|
10
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
11
11
|
|
|
12
12
|
export default function (pi: ExtensionAPI) {
|
|
13
13
|
pi.registerCommand("bookmark", {
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
type ExtensionAPI,
|
|
4
4
|
type ExtensionContext,
|
|
5
5
|
type KeybindingsManager,
|
|
6
|
-
} from "@
|
|
6
|
+
} from "@bastani/atomic";
|
|
7
7
|
import type { Component, EditorTheme, TUI } from "@earendil-works/pi-tui";
|
|
8
8
|
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
9
9
|
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
* pi -e ./built-in-tool-renderer.ts
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
import type { BashToolDetails, EditToolDetails, ExtensionAPI, ReadToolDetails } from "@
|
|
29
|
-
import { createBashTool, createEditTool, createReadTool, createWriteTool } from "@
|
|
28
|
+
import type { BashToolDetails, EditToolDetails, ExtensionAPI, ReadToolDetails } from "@bastani/atomic";
|
|
29
|
+
import { createBashTool, createEditTool, createReadTool, createWriteTool } from "@bastani/atomic";
|
|
30
30
|
import { Text } from "@earendil-works/pi-tui";
|
|
31
31
|
|
|
32
32
|
export default function (pi: ExtensionAPI) {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
import * as fs from "node:fs";
|
|
21
21
|
import * as path from "node:path";
|
|
22
|
-
import type { ExtensionAPI } from "@
|
|
22
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Recursively find all .md files in a directory
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* 3. Use /commands extensions to filter by source
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import type { ExtensionAPI, SlashCommandInfo } from "@
|
|
13
|
+
import type { ExtensionAPI, SlashCommandInfo } from "@bastani/atomic";
|
|
14
14
|
|
|
15
15
|
export default function commandsExtension(pi: ExtensionAPI) {
|
|
16
16
|
pi.registerCommand("commands", {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Demonstrates how to cancel session events using the before_* events.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { ExtensionAPI, SessionBeforeSwitchEvent, SessionMessageEntry } from "@
|
|
8
|
+
import type { ExtensionAPI, SessionBeforeSwitchEvent, SessionMessageEntry } from "@bastani/atomic";
|
|
9
9
|
|
|
10
10
|
export default function (pi: ExtensionAPI) {
|
|
11
11
|
pi.on("session_before_switch", async (event: SessionBeforeSwitchEvent, ctx) => {
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
import { complete } from "@earendil-works/pi-ai";
|
|
17
|
-
import type { ExtensionAPI } from "@
|
|
18
|
-
import { convertToLlm, serializeConversation } from "@
|
|
17
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
18
|
+
import { convertToLlm, serializeConversation } from "@bastani/atomic";
|
|
19
19
|
|
|
20
20
|
export default function (pi: ExtensionAPI) {
|
|
21
21
|
pi.on("session_before_compact", async (event, ctx) => {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import type { AssistantMessage } from "@earendil-works/pi-ai";
|
|
12
|
-
import type { ExtensionAPI } from "@
|
|
12
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
13
13
|
import { truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
14
14
|
|
|
15
15
|
export default function (pi: ExtensionAPI) {
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* (logo + keybinding hints) with a custom component showing the pi mascot.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { ExtensionAPI, Theme } from "@
|
|
9
|
-
import { VERSION } from "@
|
|
8
|
+
import type { ExtensionAPI, Theme } from "@bastani/atomic";
|
|
9
|
+
import { VERSION } from "@bastani/atomic";
|
|
10
10
|
|
|
11
11
|
// --- PI MASCOT ---
|
|
12
12
|
// Based on pi_mascot.ts - the pi agent character
|
|
@@ -43,7 +43,7 @@ import {
|
|
|
43
43
|
type ToolCall,
|
|
44
44
|
type ToolResultMessage,
|
|
45
45
|
} from "@earendil-works/pi-ai";
|
|
46
|
-
import type { ExtensionAPI } from "@
|
|
46
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
47
47
|
|
|
48
48
|
// =============================================================================
|
|
49
49
|
// OAuth Implementation (copied from packages/ai/src/utils/oauth/anthropic.ts)
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
streamSimpleAnthropic,
|
|
22
22
|
streamSimpleOpenAIResponses,
|
|
23
23
|
} from "@earendil-works/pi-ai";
|
|
24
|
-
import type { ExtensionAPI } from "@
|
|
24
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
25
25
|
|
|
26
26
|
// =============================================================================
|
|
27
27
|
// Constants
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Useful to ensure work is committed before switching context.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { ExtensionAPI, ExtensionContext } from "@
|
|
8
|
+
import type { ExtensionAPI, ExtensionContext } from "@bastani/atomic";
|
|
9
9
|
|
|
10
10
|
async function checkDirtyRepo(
|
|
11
11
|
pi: ExtensionAPI,
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* This demonstrates that overlays can handle real-time game rendering at 35 FPS.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import type { ExtensionAPI } from "@
|
|
12
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
13
13
|
import { DoomOverlayComponent } from "./doom-component.js";
|
|
14
14
|
import { DoomEngine } from "./doom-engine.js";
|
|
15
15
|
import { ensureWadFile } from "./wad-finder.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { dirname, join } from "node:path";
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
|
-
import type { ExtensionAPI } from "@
|
|
3
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
4
4
|
|
|
5
5
|
const baseDir = dirname(fileURLToPath(import.meta.url));
|
|
6
6
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - Registers additional tools at runtime via /add-echo-tool <name>
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { ExtensionAPI } from "@
|
|
10
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
11
11
|
import { Type } from "typebox";
|
|
12
12
|
|
|
13
13
|
const ECHO_PARAMS = Type.Object({
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Usage: /emit [event-name] [data] - emit an event on the bus
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { ExtensionAPI, ExtensionContext } from "@
|
|
10
|
+
import type { ExtensionAPI, ExtensionContext } from "@bastani/atomic";
|
|
11
11
|
|
|
12
12
|
export default function (pi: ExtensionAPI) {
|
|
13
13
|
// Store ctx for use in event handler
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
import * as fs from "node:fs";
|
|
12
|
-
import type { ExtensionAPI } from "@
|
|
12
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
13
13
|
|
|
14
14
|
export default function (pi: ExtensionAPI) {
|
|
15
15
|
pi.on("session_start", async (_event, ctx) => {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* When forking, offers to restore code to that point in history.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type { ExtensionAPI } from "@
|
|
8
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
9
9
|
|
|
10
10
|
export default function (pi: ExtensionAPI) {
|
|
11
11
|
const checkpoints = new Map<string, string>();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Requires GitHub CLI (`gh`) and a GitHub repository checkout.
|
|
2
2
|
// Preloads the latest open issues once per session, then filters them locally for fast `#...` completion.
|
|
3
3
|
|
|
4
|
-
import type { ExtensionAPI } from "@
|
|
4
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
5
5
|
import {
|
|
6
6
|
type AutocompleteItem,
|
|
7
7
|
type AutocompleteProvider,
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
import type { AgentMessage } from "@earendil-works/pi-agent-core";
|
|
16
16
|
import { complete, type Message } from "@earendil-works/pi-ai";
|
|
17
|
-
import type { ExtensionAPI, SessionEntry } from "@
|
|
18
|
-
import { BorderedLoader, convertToLlm, serializeConversation } from "@
|
|
17
|
+
import type { ExtensionAPI, SessionEntry } from "@bastani/atomic";
|
|
18
|
+
import { BorderedLoader, convertToLlm, serializeConversation } from "@bastani/atomic";
|
|
19
19
|
|
|
20
20
|
const SYSTEM_PROMPT = `You are a context transfer assistant. Given a conversation history and the user's goal for a new thread, generate a focused prompt that:
|
|
21
21
|
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* /thinking-label Reset to the default label
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
import type { ExtensionAPI, ExtensionContext } from "@
|
|
21
|
+
import type { ExtensionAPI, ExtensionContext } from "@bastani/atomic";
|
|
22
22
|
|
|
23
23
|
const DEFAULT_LABEL = "Pondering...";
|
|
24
24
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* Note: Regular !command syntax (whole-line bash) is preserved and works as before.
|
|
16
16
|
*/
|
|
17
|
-
import type { ExtensionAPI } from "@
|
|
17
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
18
18
|
|
|
19
19
|
export default function (pi: ExtensionAPI) {
|
|
20
20
|
const PATTERN = /!\{([^}]+)\}/g;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* ping → "pong" (instant, no LLM)
|
|
10
10
|
* time → current time (instant, no LLM)
|
|
11
11
|
*/
|
|
12
|
-
import type { ExtensionAPI } from "@
|
|
12
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
13
13
|
|
|
14
14
|
export default function (pi: ExtensionAPI) {
|
|
15
15
|
pi.on("input", async (event, ctx) => {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
23
|
import { spawnSync } from "node:child_process";
|
|
24
|
-
import type { ExtensionAPI } from "@
|
|
24
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
25
25
|
|
|
26
26
|
// Default interactive commands - editors, pagers, git ops, TUIs
|
|
27
27
|
const DEFAULT_INTERACTIVE_COMMANDS = [
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Usage: /status [message] - sends a status message with custom rendering
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { ExtensionAPI } from "@
|
|
10
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
11
11
|
import { Box, Text } from "@earendil-works/pi-tui";
|
|
12
12
|
|
|
13
13
|
export default function (pi: ExtensionAPI) {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* Then use ctrl+o to toggle between minimal (collapsed) and full (expanded) views.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import type { ExtensionAPI } from "@
|
|
19
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
20
20
|
import {
|
|
21
21
|
createBashTool,
|
|
22
22
|
createEditTool,
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
createLsTool,
|
|
26
26
|
createReadTool,
|
|
27
27
|
createWriteTool,
|
|
28
|
-
} from "@
|
|
28
|
+
} from "@bastani/atomic";
|
|
29
29
|
import { Text } from "@earendil-works/pi-tui";
|
|
30
30
|
import { homedir } from "os";
|
|
31
31
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* - ctrl+c, ctrl+d, etc. work in both modes
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { CustomEditor, type ExtensionAPI } from "@
|
|
12
|
+
import { CustomEditor, type ExtensionAPI } from "@bastani/atomic";
|
|
13
13
|
import { matchesKey, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
14
14
|
|
|
15
15
|
// Normal mode key mappings: key -> escape sequence (or null for mode switch)
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Usage: pi -e ./model-status.ts
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import type { ExtensionAPI } from "@
|
|
10
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
11
11
|
|
|
12
12
|
export default function (pi: ExtensionAPI) {
|
|
13
13
|
pi.on("model_select", async (event, ctx) => {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* - Windows toast: Windows Terminal (WSL)
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type { ExtensionAPI } from "@
|
|
11
|
+
import type { ExtensionAPI } from "@bastani/atomic";
|
|
12
12
|
|
|
13
13
|
function windowsToastScript(title: string, body: string): string {
|
|
14
14
|
const type = "Windows.UI.Notifications";
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* /overlay-streaming - Multiple input panels with simulated streaming (Tab to cycle focus)
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import type { ExtensionAPI, ExtensionCommandContext, Theme } from "@
|
|
22
|
+
import type { ExtensionAPI, ExtensionCommandContext, Theme } from "@bastani/atomic";
|
|
23
23
|
import type { Component, OverlayAnchor, OverlayHandle, OverlayOptions, TUI } from "@earendil-works/pi-tui";
|
|
24
24
|
import { matchesKey, truncateToWidth, visibleWidth } from "@earendil-works/pi-tui";
|
|
25
25
|
import { spawn } from "child_process";
|