@phi-code-admin/phi-code 0.85.0 → 0.86.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 +40 -0
- package/README.md +92 -123
- package/config/routing.example.json +129 -0
- package/config/routing.schema.json +58 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +1 -1
- package/dist/cli/args.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +6 -6
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +1 -1
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +2 -2
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +9 -8
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/utils/pi-user-agent.d.ts.map +1 -1
- package/dist/utils/pi-user-agent.js +4 -1
- package/dist/utils/pi-user-agent.js.map +1 -1
- package/docs/compaction.md +11 -11
- package/docs/custom-provider.md +4 -4
- package/docs/development.md +2 -2
- package/docs/extensions.md +47 -47
- package/docs/fork-policy.md +63 -0
- package/docs/index.md +7 -7
- package/docs/json.md +3 -3
- package/docs/keybindings.md +5 -5
- package/docs/models.md +6 -6
- package/docs/packages.md +37 -37
- package/docs/prompt-templates.md +4 -4
- package/docs/providers.md +9 -9
- package/docs/quickstart.md +25 -25
- package/docs/rpc.md +3 -3
- package/docs/sdk.md +34 -34
- package/docs/session-format.md +4 -4
- package/docs/sessions.md +11 -11
- package/docs/settings.md +9 -9
- package/docs/shell-aliases.md +2 -2
- package/docs/skills.md +9 -9
- package/docs/terminal-setup.md +7 -7
- package/docs/termux.md +6 -6
- package/docs/themes.md +9 -9
- package/docs/tmux.md +3 -3
- package/docs/tui.md +8 -8
- package/docs/usage.md +39 -39
- package/docs/windows.md +2 -2
- package/extensions/phi/agents.ts +5 -113
- package/extensions/phi/orchestrator.ts +6 -38
- package/extensions/phi/providers/agent-def.ts +128 -0
- package/extensions/phi/skill-loader.ts +5 -5
- package/package.json +2 -1
package/docs/sdk.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
>
|
|
1
|
+
> phi can help you use the SDK. Ask it to build an integration for your use case.
|
|
2
2
|
|
|
3
3
|
# SDK
|
|
4
4
|
|
|
5
|
-
The SDK provides programmatic access to
|
|
5
|
+
The SDK provides programmatic access to phi's agent capabilities. Use it to embed phi in other applications, build custom interfaces, or integrate with automated workflows.
|
|
6
6
|
|
|
7
7
|
**Example use cases:**
|
|
8
8
|
- Build a custom UI (web, desktop, mobile)
|
|
@@ -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 "@phi-code-admin/phi-code";
|
|
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 @phi-code-admin/phi-code
|
|
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 } from "@
|
|
57
|
+
import { createAgentSession } from "@phi-code-admin/phi-code";
|
|
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 "@phi-code-admin/phi-code";
|
|
136
136
|
|
|
137
137
|
const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionManager, sessionStartEvent }) => {
|
|
138
138
|
const services = await createAgentSessionServices({ cwd });
|
|
@@ -338,23 +338,23 @@ const { session } = await createAgentSession({
|
|
|
338
338
|
cwd: process.cwd(), // default
|
|
339
339
|
|
|
340
340
|
// Global config directory
|
|
341
|
-
agentDir: "~/.
|
|
341
|
+
agentDir: "~/.phi/agent", // default (expands ~)
|
|
342
342
|
});
|
|
343
343
|
```
|
|
344
344
|
|
|
345
345
|
`cwd` is used by `DefaultResourceLoader` for:
|
|
346
|
-
- Project extensions (`.
|
|
346
|
+
- Project extensions (`.phi/extensions/`)
|
|
347
347
|
- Project skills:
|
|
348
|
-
- `.
|
|
348
|
+
- `.phi/skills/`
|
|
349
349
|
- `.agents/skills/` in `cwd` and ancestor directories (up to git repo root, or filesystem root when not in a repo)
|
|
350
|
-
- Project prompts (`.
|
|
350
|
+
- Project prompts (`.phi/prompts/`)
|
|
351
351
|
- Context files (`AGENTS.md` walking up from cwd)
|
|
352
352
|
- Session directory naming
|
|
353
353
|
|
|
354
354
|
`agentDir` is used by `DefaultResourceLoader` for:
|
|
355
355
|
- Global extensions (`extensions/`)
|
|
356
356
|
- Global skills:
|
|
357
|
-
- `skills/` under `agentDir` (for example `~/.
|
|
357
|
+
- `skills/` under `agentDir` (for example `~/.phi/agent/skills/`)
|
|
358
358
|
- `~/.agents/skills/`
|
|
359
359
|
- Global prompts (`prompts/`)
|
|
360
360
|
- Global context file (`AGENTS.md`)
|
|
@@ -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 "@phi-code-admin/phi-code";
|
|
373
373
|
|
|
374
374
|
const authStorage = AuthStorage.create();
|
|
375
375
|
const modelRegistry = ModelRegistry.create(authStorage);
|
|
@@ -416,9 +416,9 @@ 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 "@phi-code-admin/phi-code";
|
|
420
420
|
|
|
421
|
-
// Default: uses ~/.
|
|
421
|
+
// Default: uses ~/.phi/agent/auth.json and ~/.phi/agent/models.json
|
|
422
422
|
const authStorage = AuthStorage.create();
|
|
423
423
|
const modelRegistry = ModelRegistry.create(authStorage);
|
|
424
424
|
|
|
@@ -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 "@phi-code-admin/phi-code";
|
|
456
456
|
|
|
457
457
|
const loader = new DefaultResourceLoader({
|
|
458
458
|
systemPromptOverride: () => "You are a helpful assistant.",
|
|
@@ -472,7 +472,7 @@ import {
|
|
|
472
472
|
readOnlyTools, // read, grep, find, ls
|
|
473
473
|
readTool, bashTool, editTool, writeTool,
|
|
474
474
|
grepTool, findTool, lsTool,
|
|
475
|
-
} from "@
|
|
475
|
+
} from "@phi-code-admin/phi-code";
|
|
476
476
|
|
|
477
477
|
// Use built-in tool set
|
|
478
478
|
const { session } = await createAgentSession({
|
|
@@ -500,7 +500,7 @@ import {
|
|
|
500
500
|
createGrepTool,
|
|
501
501
|
createFindTool,
|
|
502
502
|
createLsTool,
|
|
503
|
-
} from "@
|
|
503
|
+
} from "@phi-code-admin/phi-code";
|
|
504
504
|
|
|
505
505
|
const cwd = "/path/to/project";
|
|
506
506
|
|
|
@@ -518,7 +518,7 @@ const { session } = await createAgentSession({
|
|
|
518
518
|
```
|
|
519
519
|
|
|
520
520
|
**When you don't need factories:**
|
|
521
|
-
- If you omit `tools`,
|
|
521
|
+
- If you omit `tools`, phi automatically creates them with the correct `cwd`
|
|
522
522
|
- If you use `process.cwd()` as your `cwd`, the pre-built instances work fine
|
|
523
523
|
|
|
524
524
|
**When you must use factories:**
|
|
@@ -530,7 +530,7 @@ const { session } = await createAgentSession({
|
|
|
530
530
|
|
|
531
531
|
```typescript
|
|
532
532
|
import { Type } from "typebox";
|
|
533
|
-
import { createAgentSession, defineTool } from "@
|
|
533
|
+
import { createAgentSession, defineTool } from "@phi-code-admin/phi-code";
|
|
534
534
|
|
|
535
535
|
// Inline custom tool
|
|
536
536
|
const myTool = defineTool({
|
|
@@ -560,10 +560,10 @@ Custom tools passed via `customTools` are combined with extension-registered too
|
|
|
560
560
|
|
|
561
561
|
### Extensions
|
|
562
562
|
|
|
563
|
-
Extensions are loaded by the `ResourceLoader`. `DefaultResourceLoader` discovers extensions from `~/.
|
|
563
|
+
Extensions are loaded by the `ResourceLoader`. `DefaultResourceLoader` discovers extensions from `~/.phi/agent/extensions/`, `.phi/extensions/`, and settings.json extension sources.
|
|
564
564
|
|
|
565
565
|
```typescript
|
|
566
|
-
import { createAgentSession, DefaultResourceLoader } from "@
|
|
566
|
+
import { createAgentSession, DefaultResourceLoader } from "@phi-code-admin/phi-code";
|
|
567
567
|
|
|
568
568
|
const loader = new DefaultResourceLoader({
|
|
569
569
|
additionalExtensionPaths: ["/path/to/my-extension.ts"],
|
|
@@ -585,7 +585,7 @@ Extensions can register tools, subscribe to events, add commands, and more. See
|
|
|
585
585
|
**Event Bus:** Extensions can communicate via `pi.events`. Pass a shared `eventBus` to `DefaultResourceLoader` if you need to emit or listen from outside:
|
|
586
586
|
|
|
587
587
|
```typescript
|
|
588
|
-
import { createEventBus, DefaultResourceLoader } from "@
|
|
588
|
+
import { createEventBus, DefaultResourceLoader } from "@phi-code-admin/phi-code";
|
|
589
589
|
|
|
590
590
|
const eventBus = createEventBus();
|
|
591
591
|
const loader = new DefaultResourceLoader({
|
|
@@ -605,7 +605,7 @@ import {
|
|
|
605
605
|
createAgentSession,
|
|
606
606
|
DefaultResourceLoader,
|
|
607
607
|
type Skill,
|
|
608
|
-
} from "@
|
|
608
|
+
} from "@phi-code-admin/phi-code";
|
|
609
609
|
|
|
610
610
|
const customSkill: Skill = {
|
|
611
611
|
name: "my-skill",
|
|
@@ -631,7 +631,7 @@ const { session } = await createAgentSession({ resourceLoader: loader });
|
|
|
631
631
|
### Context Files
|
|
632
632
|
|
|
633
633
|
```typescript
|
|
634
|
-
import { createAgentSession, DefaultResourceLoader } from "@
|
|
634
|
+
import { createAgentSession, DefaultResourceLoader } from "@phi-code-admin/phi-code";
|
|
635
635
|
|
|
636
636
|
const loader = new DefaultResourceLoader({
|
|
637
637
|
agentsFilesOverride: (current) => ({
|
|
@@ -655,7 +655,7 @@ import {
|
|
|
655
655
|
createAgentSession,
|
|
656
656
|
DefaultResourceLoader,
|
|
657
657
|
type PromptTemplate,
|
|
658
|
-
} from "@
|
|
658
|
+
} from "@phi-code-admin/phi-code";
|
|
659
659
|
|
|
660
660
|
const customCommand: PromptTemplate = {
|
|
661
661
|
name: "deploy",
|
|
@@ -690,7 +690,7 @@ import {
|
|
|
690
690
|
createAgentSessionServices,
|
|
691
691
|
getAgentDir,
|
|
692
692
|
SessionManager,
|
|
693
|
-
} from "@
|
|
693
|
+
} from "@phi-code-admin/phi-code";
|
|
694
694
|
|
|
695
695
|
// In-memory (no persistence)
|
|
696
696
|
const { session } = await createAgentSession({
|
|
@@ -784,7 +784,7 @@ sm.createBranchedSession(leafId); // Extract path to new file
|
|
|
784
784
|
### Settings Management
|
|
785
785
|
|
|
786
786
|
```typescript
|
|
787
|
-
import { createAgentSession, SettingsManager, SessionManager } from "@
|
|
787
|
+
import { createAgentSession, SettingsManager, SessionManager } from "@phi-code-admin/phi-code";
|
|
788
788
|
|
|
789
789
|
// Default: loads from files (global + project merged)
|
|
790
790
|
const { session } = await createAgentSession({
|
|
@@ -818,7 +818,7 @@ const { session } = await createAgentSession({
|
|
|
818
818
|
**Project-specific settings:**
|
|
819
819
|
|
|
820
820
|
Settings load from two locations and merge:
|
|
821
|
-
1. Global: `~/.
|
|
821
|
+
1. Global: `~/.phi/agent/settings.json`
|
|
822
822
|
2. Project: `<cwd>/.pi/settings.json`
|
|
823
823
|
|
|
824
824
|
Project overrides global. Nested objects merge keys. Setters modify global settings by default.
|
|
@@ -840,7 +840,7 @@ Use `DefaultResourceLoader` to discover extensions, skills, prompts, themes, and
|
|
|
840
840
|
import {
|
|
841
841
|
DefaultResourceLoader,
|
|
842
842
|
getAgentDir,
|
|
843
|
-
} from "@
|
|
843
|
+
} from "@phi-code-admin/phi-code";
|
|
844
844
|
|
|
845
845
|
const loader = new DefaultResourceLoader({
|
|
846
846
|
cwd,
|
|
@@ -893,7 +893,7 @@ import {
|
|
|
893
893
|
readTool,
|
|
894
894
|
SessionManager,
|
|
895
895
|
SettingsManager,
|
|
896
|
-
} from "@
|
|
896
|
+
} from "@phi-code-admin/phi-code";
|
|
897
897
|
|
|
898
898
|
// Set up auth storage (custom location)
|
|
899
899
|
const authStorage = AuthStorage.create("/custom/agent/auth.json");
|
|
@@ -978,7 +978,7 @@ import {
|
|
|
978
978
|
getAgentDir,
|
|
979
979
|
InteractiveMode,
|
|
980
980
|
SessionManager,
|
|
981
|
-
} from "@
|
|
981
|
+
} from "@phi-code-admin/phi-code";
|
|
982
982
|
|
|
983
983
|
const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionManager, sessionStartEvent }) => {
|
|
984
984
|
const services = await createAgentSessionServices({ cwd });
|
|
@@ -1018,7 +1018,7 @@ import {
|
|
|
1018
1018
|
getAgentDir,
|
|
1019
1019
|
runPrintMode,
|
|
1020
1020
|
SessionManager,
|
|
1021
|
-
} from "@
|
|
1021
|
+
} from "@phi-code-admin/phi-code";
|
|
1022
1022
|
|
|
1023
1023
|
const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionManager, sessionStartEvent }) => {
|
|
1024
1024
|
const services = await createAgentSessionServices({ cwd });
|
|
@@ -1055,7 +1055,7 @@ import {
|
|
|
1055
1055
|
getAgentDir,
|
|
1056
1056
|
runRpcMode,
|
|
1057
1057
|
SessionManager,
|
|
1058
|
-
} from "@
|
|
1058
|
+
} from "@phi-code-admin/phi-code";
|
|
1059
1059
|
|
|
1060
1060
|
const createRuntime: CreateAgentSessionRuntimeFactory = async ({ cwd, sessionManager, sessionStartEvent }) => {
|
|
1061
1061
|
const services = await createAgentSessionServices({ cwd });
|
|
@@ -1081,7 +1081,7 @@ See [RPC documentation](rpc.md) for the JSON protocol.
|
|
|
1081
1081
|
For subprocess-based integration without building with the SDK, use the CLI directly:
|
|
1082
1082
|
|
|
1083
1083
|
```bash
|
|
1084
|
-
|
|
1084
|
+
phi --mode rpc --no-session
|
|
1085
1085
|
```
|
|
1086
1086
|
|
|
1087
1087
|
See [RPC documentation](rpc.md) for the JSON protocol.
|
package/docs/session-format.md
CHANGED
|
@@ -5,16 +5,16 @@ Sessions are stored as JSONL (JSON Lines) files. Each line is a JSON object with
|
|
|
5
5
|
## File Location
|
|
6
6
|
|
|
7
7
|
```
|
|
8
|
-
~/.
|
|
8
|
+
~/.phi/agent/sessions/--<path>--/<timestamp>_<uuid>.jsonl
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
Where `<path>` is the working directory with `/` replaced by `-`.
|
|
12
12
|
|
|
13
13
|
## Deleting Sessions
|
|
14
14
|
|
|
15
|
-
Sessions can be removed by deleting their `.jsonl` files under `~/.
|
|
15
|
+
Sessions can be removed by deleting their `.jsonl` files under `~/.phi/agent/sessions/`.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
phi also supports deleting sessions interactively from `/resume` (select a session and press `Ctrl+D`, then confirm). When available, phi uses the `trash` CLI to avoid permanent deletion.
|
|
18
18
|
|
|
19
19
|
## Session Version
|
|
20
20
|
|
|
@@ -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/@phi-code-admin/phi-code/dist/` and `node_modules/@earendil-works/pi-ai/dist/`.
|
|
38
38
|
|
|
39
39
|
## Message Types
|
|
40
40
|
|
package/docs/sessions.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
# Sessions
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
phi saves conversations as sessions so you can continue work, branch from earlier turns, and revisit previous paths.
|
|
4
4
|
|
|
5
5
|
## Session Storage
|
|
6
6
|
|
|
7
|
-
Sessions auto-save to `~/.
|
|
7
|
+
Sessions auto-save to `~/.phi/agent/sessions/`, organized by working directory. Each session is a JSONL file with a tree structure.
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
phi -c # Continue most recent session
|
|
11
|
+
phi -r # Browse and select from past sessions
|
|
12
|
+
phi --no-session # Ephemeral mode; do not save
|
|
13
|
+
phi --session <path|id> # Use a specific session file or partial session ID
|
|
14
|
+
phi --fork <path|id> # Fork a session file or partial session ID into a new session
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
Use `/session` in interactive mode to see the current session file, session ID, message count, tokens, and cost.
|
|
@@ -35,7 +35,7 @@ For the JSONL file format and SessionManager API, see [Session Format](session-f
|
|
|
35
35
|
|
|
36
36
|
## Resuming and Deleting Sessions
|
|
37
37
|
|
|
38
|
-
`/resume` opens an interactive session picker for the current project. `
|
|
38
|
+
`/resume` opens an interactive session picker for the current project. `phi -r` opens the same picker at startup.
|
|
39
39
|
|
|
40
40
|
In the picker you can:
|
|
41
41
|
|
|
@@ -46,7 +46,7 @@ In the picker you can:
|
|
|
46
46
|
- rename with Ctrl+R
|
|
47
47
|
- delete with Ctrl+D, then confirm
|
|
48
48
|
|
|
49
|
-
When available,
|
|
49
|
+
When available, phi uses the `trash` CLI for deletion instead of permanently removing files.
|
|
50
50
|
|
|
51
51
|
## Naming Sessions
|
|
52
52
|
|
|
@@ -56,7 +56,7 @@ Use `/name <name>` to set a human-readable session name:
|
|
|
56
56
|
/name Refactor auth module
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
-
Named sessions are easier to find in `/resume` and `
|
|
59
|
+
Named sessions are easier to find in `/resume` and `phi -r`.
|
|
60
60
|
|
|
61
61
|
## Branching with `/tree`
|
|
62
62
|
|
|
@@ -120,7 +120,7 @@ Use `/tree` when you want to keep alternatives together. Use `/fork` or `/clone`
|
|
|
120
120
|
|
|
121
121
|
## Branch Summaries
|
|
122
122
|
|
|
123
|
-
When `/tree` switches away from one branch to another,
|
|
123
|
+
When `/tree` switches away from one branch to another, phi can summarize the abandoned branch and attach that summary at the new position. This preserves important context from the path you left without replaying the whole branch.
|
|
124
124
|
|
|
125
125
|
When prompted, choose one of:
|
|
126
126
|
|
package/docs/settings.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Settings
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
phi uses JSON settings files with project settings overriding global settings.
|
|
4
4
|
|
|
5
5
|
| Location | Scope |
|
|
6
6
|
|----------|-------|
|
|
7
|
-
| `~/.
|
|
8
|
-
| `.
|
|
7
|
+
| `~/.phi/agent/settings.json` | Global (all projects) |
|
|
8
|
+
| `.phi/settings.json` | Project (current directory) |
|
|
9
9
|
|
|
10
10
|
Edit directly or use `/settings` for common options.
|
|
11
11
|
|
|
@@ -164,10 +164,10 @@ Normally the package manager's global modules location is queried using `root -g
|
|
|
164
164
|
| `sessionDir` | string | - | Directory where session files are stored. Accepts absolute or relative paths, plus `~`. |
|
|
165
165
|
|
|
166
166
|
```json
|
|
167
|
-
{ "sessionDir": ".
|
|
167
|
+
{ "sessionDir": ".phi/sessions" }
|
|
168
168
|
```
|
|
169
169
|
|
|
170
|
-
When multiple sources specify a session directory, precedence is `--session-dir`, `
|
|
170
|
+
When multiple sources specify a session directory, precedence is `--session-dir`, `PHI_CODING_AGENT_SESSION_DIR`, then `sessionDir` in settings.json.
|
|
171
171
|
|
|
172
172
|
### Model Cycling
|
|
173
173
|
|
|
@@ -191,7 +191,7 @@ When multiple sources specify a session directory, precedence is `--session-dir`
|
|
|
191
191
|
|
|
192
192
|
These settings define where to load extensions, skills, prompts, and themes from.
|
|
193
193
|
|
|
194
|
-
Paths in `~/.
|
|
194
|
+
Paths in `~/.phi/agent/settings.json` resolve relative to `~/.phi/agent`. Paths in `.phi/settings.json` resolve relative to `.pi`. Absolute paths and `~` are supported.
|
|
195
195
|
|
|
196
196
|
| Setting | Type | Default | Description |
|
|
197
197
|
|---------|------|---------|-------------|
|
|
@@ -257,16 +257,16 @@ See [packages.md](packages.md) for package management details.
|
|
|
257
257
|
|
|
258
258
|
## Project Overrides
|
|
259
259
|
|
|
260
|
-
Project settings (`.
|
|
260
|
+
Project settings (`.phi/settings.json`) override global settings. Nested objects are merged:
|
|
261
261
|
|
|
262
262
|
```json
|
|
263
|
-
// ~/.
|
|
263
|
+
// ~/.phi/agent/settings.json (global)
|
|
264
264
|
{
|
|
265
265
|
"theme": "dark",
|
|
266
266
|
"compaction": { "enabled": true, "reserveTokens": 16384 }
|
|
267
267
|
}
|
|
268
268
|
|
|
269
|
-
// .
|
|
269
|
+
// .phi/settings.json (project)
|
|
270
270
|
{
|
|
271
271
|
"compaction": { "reserveTokens": 8192 }
|
|
272
272
|
}
|
package/docs/shell-aliases.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Shell Aliases
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
phi runs bash in non-interactive mode (`bash -c`), which doesn't expand aliases by default.
|
|
4
4
|
|
|
5
|
-
To enable your shell aliases, add to `~/.
|
|
5
|
+
To enable your shell aliases, add to `~/.phi/agent/settings.json`:
|
|
6
6
|
|
|
7
7
|
```json
|
|
8
8
|
{
|
package/docs/skills.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
>
|
|
1
|
+
> phi can create skills. Ask it to build one for your use case.
|
|
2
2
|
|
|
3
3
|
# Skills
|
|
4
4
|
|
|
5
5
|
Skills are self-contained capability packages that the agent loads on-demand. A skill provides specialized workflows, setup instructions, helper scripts, and reference documentation for specific tasks.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
phi implements the [Agent Skills standard](https://agentskills.io/specification), warning about violations but remaining lenient.
|
|
8
8
|
|
|
9
9
|
## Table of Contents
|
|
10
10
|
|
|
@@ -21,20 +21,20 @@ Pi implements the [Agent Skills standard](https://agentskills.io/specification),
|
|
|
21
21
|
|
|
22
22
|
> **Security:** Skills can instruct the model to perform any action and may include executable code the model invokes. Review skill content before use.
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
phi loads skills from:
|
|
25
25
|
|
|
26
26
|
- Global:
|
|
27
|
-
- `~/.
|
|
27
|
+
- `~/.phi/agent/skills/`
|
|
28
28
|
- `~/.agents/skills/`
|
|
29
29
|
- Project:
|
|
30
|
-
- `.
|
|
30
|
+
- `.phi/skills/`
|
|
31
31
|
- `.agents/skills/` in `cwd` and ancestor directories (up to git repo root, or filesystem root when not in a repo)
|
|
32
32
|
- Packages: `skills/` directories or `pi.skills` entries in `package.json`
|
|
33
33
|
- Settings: `skills` array with files or directories
|
|
34
34
|
- CLI: `--skill <path>` (repeatable, additive even with `--no-skills`)
|
|
35
35
|
|
|
36
36
|
Discovery rules:
|
|
37
|
-
- In `~/.
|
|
37
|
+
- In `~/.phi/agent/skills/` and `.phi/skills/`, direct root `.md` files are discovered as individual skills
|
|
38
38
|
- In all skill locations, directories containing `SKILL.md` are discovered recursively
|
|
39
39
|
- In `~/.agents/skills/` and project `.agents/skills/`, root `.md` files are ignored
|
|
40
40
|
|
|
@@ -53,7 +53,7 @@ To use skills from Claude Code or OpenAI Codex, add their directories to setting
|
|
|
53
53
|
}
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
For project-level Claude Code skills, add to `.
|
|
56
|
+
For project-level Claude Code skills, add to `.phi/settings.json`:
|
|
57
57
|
|
|
58
58
|
```json
|
|
59
59
|
{
|
|
@@ -63,7 +63,7 @@ For project-level Claude Code skills, add to `.pi/settings.json`:
|
|
|
63
63
|
|
|
64
64
|
## How Skills Work
|
|
65
65
|
|
|
66
|
-
1. At startup,
|
|
66
|
+
1. At startup, phi scans skill locations and extracts names and descriptions
|
|
67
67
|
2. The system prompt includes available skills in XML format per the [specification](https://agentskills.io/integrate-skills)
|
|
68
68
|
3. When a task matches, the agent uses `read` to load the full SKILL.md (models don't always do this; use prompting or `/skill:name` to force it)
|
|
69
69
|
4. The agent follows the instructions, using relative paths to reference scripts and assets
|
|
@@ -175,7 +175,7 @@ description: Helps with PDFs.
|
|
|
175
175
|
|
|
176
176
|
## Validation
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
phi validates skills against the Agent Skills standard. Most issues produce warnings but still load the skill:
|
|
179
179
|
|
|
180
180
|
- Name doesn't match parent directory
|
|
181
181
|
- Name exceeds 64 characters or contains invalid characters
|
package/docs/terminal-setup.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Terminal Setup
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
phi uses the [Kitty keyboard protocol](https://sw.kovidgoyal.net/kitty/keyboard-protocol/) for reliable modifier key detection. Most modern terminals support this protocol, but some require configuration.
|
|
4
4
|
|
|
5
5
|
## Kitty, iTerm2
|
|
6
6
|
|
|
@@ -20,11 +20,11 @@ Older Claude Code versions may have added this Ghostty mapping:
|
|
|
20
20
|
keybind = shift+enter=text:\n
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
That mapping sends a raw linefeed byte. Inside
|
|
23
|
+
That mapping sends a raw linefeed byte. Inside phi, that is indistinguishable from `Ctrl+J`, so tmux and phi no longer see a real `shift+enter` key event.
|
|
24
24
|
|
|
25
25
|
If Claude Code 2.x or newer is the only reason you added that mapping, you can remove it, unless you want to use Claude Code in tmux, where it still requires that Ghostty mapping.
|
|
26
26
|
|
|
27
|
-
If you want `Shift+Enter` to keep working in tmux via that remap, add `ctrl+j` to your
|
|
27
|
+
If you want `Shift+Enter` to keep working in tmux via that remap, add `ctrl+j` to your phi `newLine` keybinding in `~/.phi/agent/keybindings.json`:
|
|
28
28
|
|
|
29
29
|
```json
|
|
30
30
|
{
|
|
@@ -63,7 +63,7 @@ Add to `keybindings.json` to enable `Shift+Enter` for multi-line input:
|
|
|
63
63
|
|
|
64
64
|
## Windows Terminal
|
|
65
65
|
|
|
66
|
-
Add to `settings.json` (Ctrl+Shift+, or Settings → Open JSON file) to forward the modified Enter keys
|
|
66
|
+
Add to `settings.json` (Ctrl+Shift+, or Settings → Open JSON file) to forward the modified Enter keys phi uses:
|
|
67
67
|
|
|
68
68
|
```json
|
|
69
69
|
{
|
|
@@ -81,8 +81,8 @@ Add to `settings.json` (Ctrl+Shift+, or Settings → Open JSON file) to forward
|
|
|
81
81
|
```
|
|
82
82
|
|
|
83
83
|
- `Shift+Enter` inserts a new line.
|
|
84
|
-
- Windows Terminal binds `Alt+Enter` to fullscreen by default. That prevents
|
|
85
|
-
- Remapping `Alt+Enter` to `sendInput` forwards the real key chord to
|
|
84
|
+
- Windows Terminal binds `Alt+Enter` to fullscreen by default. That prevents phi from receiving `Alt+Enter` for follow-up queueing.
|
|
85
|
+
- Remapping `Alt+Enter` to `sendInput` forwards the real key chord to phi instead.
|
|
86
86
|
|
|
87
87
|
If you already have an `actions` array, add the objects to it. If the old fullscreen behavior persists, fully close and reopen Windows Terminal.
|
|
88
88
|
|
|
@@ -101,6 +101,6 @@ For the best experience, use a terminal that supports the Kitty keyboard protoco
|
|
|
101
101
|
|
|
102
102
|
The built-in terminal has limited escape sequence support. Shift+Enter cannot be distinguished from Enter in IntelliJ's terminal.
|
|
103
103
|
|
|
104
|
-
If you want the hardware cursor visible, set `PI_HARDWARE_CURSOR=1` before running
|
|
104
|
+
If you want the hardware cursor visible, set `PI_HARDWARE_CURSOR=1` before running phi (disabled by default for compatibility).
|
|
105
105
|
|
|
106
106
|
Consider using a dedicated terminal emulator for the best experience.
|
package/docs/termux.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Termux (Android) Setup
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
phi runs on Android via [Termux](https://termux.dev/), a terminal emulator and Linux environment for Android.
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
@@ -16,13 +16,13 @@ pkg update && pkg upgrade
|
|
|
16
16
|
# Install dependencies
|
|
17
17
|
pkg install nodejs termux-api git
|
|
18
18
|
|
|
19
|
-
# Install
|
|
20
|
-
npm install -g @
|
|
19
|
+
# Install phi
|
|
20
|
+
npm install -g @phi-code-admin/phi-code
|
|
21
21
|
|
|
22
22
|
# Create config directory
|
|
23
|
-
mkdir -p ~/.
|
|
23
|
+
mkdir -p ~/.phi/agent
|
|
24
24
|
|
|
25
|
-
# Run
|
|
25
|
+
# Run phi
|
|
26
26
|
pi
|
|
27
27
|
```
|
|
28
28
|
|
|
@@ -34,7 +34,7 @@ Image clipboard is not supported on Termux (the `ctrl+v` image paste feature wil
|
|
|
34
34
|
|
|
35
35
|
## Example AGENTS.md for Termux
|
|
36
36
|
|
|
37
|
-
Create `~/.
|
|
37
|
+
Create `~/.phi/agent/AGENTS.md` to help the agent understand the Termux environment:
|
|
38
38
|
|
|
39
39
|
```markdown
|
|
40
40
|
# Agent Environment: Termux on Android
|
package/docs/themes.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
>
|
|
1
|
+
> phi can create themes. Ask it to build one for your setup.
|
|
2
2
|
|
|
3
3
|
# Themes
|
|
4
4
|
|
|
@@ -16,11 +16,11 @@ Themes are JSON files that define colors for the TUI.
|
|
|
16
16
|
|
|
17
17
|
## Locations
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
phi loads themes from:
|
|
20
20
|
|
|
21
21
|
- Built-in: `dark`, `light`
|
|
22
|
-
- Global: `~/.
|
|
23
|
-
- Project: `.
|
|
22
|
+
- Global: `~/.phi/agent/themes/*.json`
|
|
23
|
+
- Project: `.phi/themes/*.json`
|
|
24
24
|
- Packages: `themes/` directories or `pi.themes` entries in `package.json`
|
|
25
25
|
- Settings: `themes` array with files or directories
|
|
26
26
|
- CLI: `--theme <path>` (repeatable)
|
|
@@ -37,15 +37,15 @@ Select a theme via `/settings` or in `settings.json`:
|
|
|
37
37
|
}
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
On first run,
|
|
40
|
+
On first run, phi detects your terminal background and defaults to `dark` or `light`.
|
|
41
41
|
|
|
42
42
|
## Creating a Custom Theme
|
|
43
43
|
|
|
44
44
|
1. Create a theme file:
|
|
45
45
|
|
|
46
46
|
```bash
|
|
47
|
-
mkdir -p ~/.
|
|
48
|
-
vim ~/.
|
|
47
|
+
mkdir -p ~/.phi/agent/themes
|
|
48
|
+
vim ~/.phi/agent/themes/my-theme.json
|
|
49
49
|
```
|
|
50
50
|
|
|
51
51
|
2. Define the theme with all required colors (see [Color Tokens](#color-tokens)):
|
|
@@ -116,7 +116,7 @@ vim ~/.pi/agent/themes/my-theme.json
|
|
|
116
116
|
|
|
117
117
|
3. Select the theme via `/settings`.
|
|
118
118
|
|
|
119
|
-
**Hot reload:** When you edit the currently active custom theme file,
|
|
119
|
+
**Hot reload:** When you edit the currently active custom theme file, phi reloads it automatically for immediate visual feedback.
|
|
120
120
|
|
|
121
121
|
## Theme Format
|
|
122
122
|
|
|
@@ -268,7 +268,7 @@ Four formats are supported:
|
|
|
268
268
|
|
|
269
269
|
### Terminal Compatibility
|
|
270
270
|
|
|
271
|
-
|
|
271
|
+
phi uses 24-bit RGB colors. Most modern terminals support this (iTerm2, Kitty, WezTerm, Windows Terminal, VS Code). For older terminals with only 256-color support, phi falls back to the nearest approximation.
|
|
272
272
|
|
|
273
273
|
Check truecolor support:
|
|
274
274
|
|
package/docs/tmux.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# tmux Setup
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
phi works inside tmux, but tmux strips modifier information from certain keys by default. Without configuration, `Shift+Enter` and `Ctrl+Enter` are usually indistinguishable from plain `Enter`.
|
|
4
4
|
|
|
5
5
|
## Recommended Configuration
|
|
6
6
|
|
|
@@ -18,7 +18,7 @@ tmux kill-server
|
|
|
18
18
|
tmux
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
phi requests extended key reporting automatically when Kitty keyboard protocol is not available. With `extended-keys-format csi-u`, tmux forwards modified keys in CSI-u format, which is the most reliable configuration.
|
|
22
22
|
|
|
23
23
|
## Why `csi-u` Is Recommended
|
|
24
24
|
|
|
@@ -40,7 +40,7 @@ With `extended-keys-format csi-u`, the same keys are forwarded as:
|
|
|
40
40
|
- `Ctrl+D` → `\x1b[100;5u`
|
|
41
41
|
- `Ctrl+Enter` → `\x1b[13;5u`
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
phi supports both formats, but `csi-u` is the recommended tmux setup.
|
|
44
44
|
|
|
45
45
|
## What This Fixes
|
|
46
46
|
|