@fleetagent/pi-coding-agent 0.0.4 → 0.0.6
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 +48 -0
- package/README.md +28 -5
- package/dist/cli/args.d.ts +2 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +9 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/core/agent-session.d.ts +4 -3
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +44 -8
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/diagnostics.d.ts +1 -1
- package/dist/core/diagnostics.d.ts.map +1 -1
- package/dist/core/diagnostics.js.map +1 -1
- package/dist/core/extensions/runner.d.ts +4 -0
- package/dist/core/extensions/runner.d.ts.map +1 -1
- package/dist/core/extensions/runner.js +5 -1
- package/dist/core/extensions/runner.js.map +1 -1
- package/dist/core/extensions/types.d.ts +2 -1
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/package-manager.d.ts +1 -0
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +130 -12
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/resource-loader.d.ts +30 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +94 -0
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/rules.d.ts +57 -0
- package/dist/core/rules.d.ts.map +1 -0
- package/dist/core/rules.js +384 -0
- package/dist/core/rules.js.map +1 -0
- package/dist/core/settings-manager.d.ts +5 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +14 -0
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/system-prompt.d.ts +3 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +11 -3
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +6 -2
- package/dist/core/tools/read.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +3 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts +1 -1
- package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/config-selector.js +12 -3
- package/dist/modes/interactive/components/config-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +1 -1
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +34 -4
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +14 -1
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +34 -11
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +18 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +17 -2
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/extensions.md +9 -8
- package/docs/index.md +3 -2
- package/docs/packages.md +6 -4
- package/docs/quickstart.md +1 -1
- package/docs/rpc.md +4 -2
- package/docs/rules.md +102 -0
- package/docs/sdk.md +1 -1
- package/docs/settings.md +3 -2
- package/docs/usage.md +4 -2
- package/examples/extensions/README.md +1 -1
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/dynamic-resources/RULES.md +8 -0
- package/examples/extensions/dynamic-resources/index.ts +1 -0
- package/examples/extensions/reload-runtime.ts +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package.json +1 -1
- package/examples/sdk/12-full-control.ts +1 -0
- package/examples/sdk/README.md +1 -1
- package/npm-shrinkwrap.json +12 -12
- package/package.json +4 -4
package/docs/rules.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# Rules
|
|
2
|
+
|
|
3
|
+
Rules are on-demand, mandatory instruction files. Use them for constraints and policies that must apply when the current task or files match the rule description.
|
|
4
|
+
|
|
5
|
+
Rules use progressive disclosure like skills: pi lists available rules in the system prompt, and the agent loads the full file only when applicable.
|
|
6
|
+
|
|
7
|
+
## Locations
|
|
8
|
+
|
|
9
|
+
Pi loads rules from:
|
|
10
|
+
|
|
11
|
+
- Global:
|
|
12
|
+
- `~/.pi/agent/rules/`
|
|
13
|
+
- `~/.agents/rules/`
|
|
14
|
+
- Project:
|
|
15
|
+
- `.pi/rules/`
|
|
16
|
+
- `.agents/rules/` in `cwd` and ancestor directories (up to git repo root, or filesystem root when not in a repo)
|
|
17
|
+
- Packages: `rules/` directories or `pi.rules` entries in `package.json`
|
|
18
|
+
- Settings: `rules` array with files or directories
|
|
19
|
+
- CLI: `--rule <path>` (repeatable, additive even with `--no-rules`)
|
|
20
|
+
|
|
21
|
+
Discovery rules:
|
|
22
|
+
|
|
23
|
+
- In `~/.pi/agent/rules/` and `.pi/rules/`, direct root `.md` files are discovered as individual rules
|
|
24
|
+
- In all rule locations, directories containing `RULES.md` are discovered recursively
|
|
25
|
+
- In `~/.agents/rules/` and project `.agents/rules/`, root `.md` files are ignored
|
|
26
|
+
|
|
27
|
+
Disable discovery with `--no-rules` (explicit `--rule` paths still load).
|
|
28
|
+
|
|
29
|
+
## How Rules Work
|
|
30
|
+
|
|
31
|
+
1. At startup, pi scans rule locations and extracts names and descriptions
|
|
32
|
+
2. The system prompt includes available rules in XML format
|
|
33
|
+
3. When a task or file matches, the agent uses `read` to load the full `RULES.md`
|
|
34
|
+
4. Applicable rules are mandatory and constrain normal behavior and skills
|
|
35
|
+
|
|
36
|
+
Only descriptions are always in context. Full instructions load on demand.
|
|
37
|
+
|
|
38
|
+
## Rule Commands
|
|
39
|
+
|
|
40
|
+
Rules register as `/rule:name` commands when skill commands are enabled:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
/rule:typescript # Load the rule
|
|
44
|
+
/rule:naming-conventions use for new files
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Arguments after the command are appended to the rule content as user text.
|
|
48
|
+
|
|
49
|
+
## Rule Structure
|
|
50
|
+
|
|
51
|
+
A rule is a directory with a `RULES.md` file. Everything else is freeform.
|
|
52
|
+
|
|
53
|
+
```text
|
|
54
|
+
typescript/
|
|
55
|
+
├── RULES.md
|
|
56
|
+
└── references/
|
|
57
|
+
└── examples.md
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### RULES.md Format
|
|
61
|
+
|
|
62
|
+
```markdown
|
|
63
|
+
---
|
|
64
|
+
name: typescript
|
|
65
|
+
description: Mandatory TypeScript rules. Load before editing *.ts or *.tsx files.
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
# TypeScript Rules
|
|
69
|
+
|
|
70
|
+
- No `any` unless absolutely necessary.
|
|
71
|
+
- Use top-level imports only.
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Use relative paths from the rule directory:
|
|
75
|
+
|
|
76
|
+
```markdown
|
|
77
|
+
See [examples](references/examples.md).
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Frontmatter
|
|
81
|
+
|
|
82
|
+
| Field | Required | Description |
|
|
83
|
+
|-------|----------|-------------|
|
|
84
|
+
| `name` | Yes | Max 64 chars. Lowercase a-z, 0-9, hyphens. Falls back to parent directory name. |
|
|
85
|
+
| `description` | Yes | Max 1024 chars. Defines when the rule applies. |
|
|
86
|
+
| `disable-model-invocation` | No | When `true`, the rule is hidden from the system prompt. Users must use `/rule:name`. |
|
|
87
|
+
|
|
88
|
+
## Description Best Practices
|
|
89
|
+
|
|
90
|
+
The description determines when the agent loads the rule. Write applicability, not capability.
|
|
91
|
+
|
|
92
|
+
Good:
|
|
93
|
+
|
|
94
|
+
```yaml
|
|
95
|
+
description: Mandatory TypeScript rules. Load before editing *.ts or *.tsx files.
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Poor:
|
|
99
|
+
|
|
100
|
+
```yaml
|
|
101
|
+
description: TypeScript help.
|
|
102
|
+
```
|
package/docs/sdk.md
CHANGED
|
@@ -164,7 +164,7 @@ await pi.createAgentSession();
|
|
|
164
164
|
|
|
165
165
|
### Resource loading
|
|
166
166
|
|
|
167
|
-
Use `DefaultResourceLoader` to override or discover extensions, skills, prompt templates, themes, and context files.
|
|
167
|
+
Use `DefaultResourceLoader` to override or discover extensions, skills, rules, prompt templates, themes, and context files.
|
|
168
168
|
|
|
169
169
|
```typescript
|
|
170
170
|
const loader = new DefaultResourceLoader({
|
package/docs/settings.md
CHANGED
|
@@ -187,7 +187,7 @@ When multiple sources specify a session directory, precedence is `--session-dir`
|
|
|
187
187
|
|
|
188
188
|
### Resources
|
|
189
189
|
|
|
190
|
-
These settings define where to load extensions, skills, prompts, and themes from.
|
|
190
|
+
These settings define where to load extensions, skills, rules, prompts, and themes from.
|
|
191
191
|
|
|
192
192
|
Paths in `~/.pi/agent/settings.json` resolve relative to `~/.pi/agent`. Paths in `.pi/settings.json` resolve relative to `.pi`. Absolute paths and `~` are supported.
|
|
193
193
|
|
|
@@ -196,9 +196,10 @@ Paths in `~/.pi/agent/settings.json` resolve relative to `~/.pi/agent`. Paths in
|
|
|
196
196
|
| `packages` | array | `[]` | npm/git packages to load resources from |
|
|
197
197
|
| `extensions` | string[] | `[]` | Local extension file paths or directories |
|
|
198
198
|
| `skills` | string[] | `[]` | Local skill file paths or directories |
|
|
199
|
+
| `rules` | string[] | `[]` | Local rule file paths or directories |
|
|
199
200
|
| `prompts` | string[] | `[]` | Local prompt template paths or directories |
|
|
200
201
|
| `themes` | string[] | `[]` | Local theme file paths or directories |
|
|
201
|
-
| `enableSkillCommands` | boolean | `true` | Register skills as `/skill:name` commands |
|
|
202
|
+
| `enableSkillCommands` | boolean | `true` | Register skills and rules as `/skill:name` and `/rule:name` commands |
|
|
202
203
|
|
|
203
204
|
Arrays support glob patterns and exclusions. Use `!pattern` to exclude. Use `+path` to force-include an exact path and `-path` to force-exclude an exact path.
|
|
204
205
|
|
package/docs/usage.md
CHANGED
|
@@ -50,7 +50,7 @@ Type `/` in the editor to open command completion. Extensions can register custo
|
|
|
50
50
|
| `/copy` | Copy last assistant message to clipboard |
|
|
51
51
|
| `/export [file]` | Export session to HTML |
|
|
52
52
|
| `/share` | Upload as private GitHub gist with shareable HTML link |
|
|
53
|
-
| `/reload` | Reload keybindings, extensions, skills, prompts, and context files |
|
|
53
|
+
| `/reload` | Reload keybindings, extensions, skills, rules, prompts, and context files |
|
|
54
54
|
| `/hotkeys` | Show all keyboard shortcuts |
|
|
55
55
|
| `/changelog` | Display version history |
|
|
56
56
|
| `/quit` | Quit pi |
|
|
@@ -197,6 +197,8 @@ Built-in tools: `read`, `bash`, `edit`, `write`, `grep`, `find`, `ls`.
|
|
|
197
197
|
| `--no-extensions` | Disable extension discovery |
|
|
198
198
|
| `--skill <path>` | Load a skill; repeatable |
|
|
199
199
|
| `--no-skills` | Disable skill discovery |
|
|
200
|
+
| `--rule <path>` | Load a rule; repeatable |
|
|
201
|
+
| `--no-rules` | Disable rule discovery |
|
|
200
202
|
| `--prompt-template <path>` | Load a prompt template; repeatable |
|
|
201
203
|
| `--no-prompt-templates` | Disable prompt template discovery |
|
|
202
204
|
| `--theme <path>` | Load a theme; repeatable |
|
|
@@ -272,7 +274,7 @@ pi --tools read,grep,find,ls -p "Review the code"
|
|
|
272
274
|
|
|
273
275
|
## Design Principles
|
|
274
276
|
|
|
275
|
-
Pi keeps the core small and pushes workflow-specific behavior into extensions, skills, prompt templates, and packages.
|
|
277
|
+
Pi keeps the core small and pushes workflow-specific behavior into extensions, skills, rules, prompt templates, and packages.
|
|
276
278
|
|
|
277
279
|
It intentionally does not include built-in MCP, sub-agents, permission popups, plan mode, to-dos, or background bash. You can build or install those workflows as extensions or packages, or use external tools such as containers and tmux.
|
|
278
280
|
|
|
@@ -102,7 +102,7 @@ cp permission-gate.ts ~/.pi/agent/extensions/
|
|
|
102
102
|
|
|
103
103
|
| Extension | Description |
|
|
104
104
|
|-----------|-------------|
|
|
105
|
-
| `dynamic-resources/` | Loads skills, prompts, and themes using `resources_discover` |
|
|
105
|
+
| `dynamic-resources/` | Loads skills, rules, prompts, and themes using `resources_discover` |
|
|
106
106
|
|
|
107
107
|
### Messages & Communication
|
|
108
108
|
|
|
@@ -8,6 +8,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
8
8
|
pi.on("resources_discover", () => {
|
|
9
9
|
return {
|
|
10
10
|
skillPaths: [join(baseDir, "SKILL.md")],
|
|
11
|
+
rulePaths: [join(baseDir, "RULES.md")],
|
|
11
12
|
promptPaths: [join(baseDir, "dynamic.md")],
|
|
12
13
|
themePaths: [join(baseDir, "dynamic.json")],
|
|
13
14
|
};
|
|
@@ -12,7 +12,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
12
12
|
// Command entrypoint for reload.
|
|
13
13
|
// Treat reload as terminal for this handler.
|
|
14
14
|
pi.registerCommand("reload-runtime", {
|
|
15
|
-
description: "Reload extensions, skills, prompts, and themes",
|
|
15
|
+
description: "Reload extensions, skills, rules, prompts, and themes",
|
|
16
16
|
handler: async (_args, ctx) => {
|
|
17
17
|
await ctx.reload();
|
|
18
18
|
return;
|
|
@@ -24,7 +24,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
24
24
|
pi.registerTool({
|
|
25
25
|
name: "reload_runtime",
|
|
26
26
|
label: "Reload Runtime",
|
|
27
|
-
description: "Reload extensions, skills, prompts, and themes",
|
|
27
|
+
description: "Reload extensions, skills, rules, prompts, and themes",
|
|
28
28
|
parameters: Type.Object({}),
|
|
29
29
|
async execute() {
|
|
30
30
|
pi.sendUserMessage("/reload-runtime", { deliverAs: "followUp" });
|
|
@@ -40,6 +40,7 @@ const cwd = process.cwd();
|
|
|
40
40
|
const resourceLoader: ResourceLoader = {
|
|
41
41
|
getExtensions: () => ({ extensions: [], errors: [], runtime: createExtensionRuntime() }),
|
|
42
42
|
getSkills: () => ({ skills: [], diagnostics: [] }),
|
|
43
|
+
getRules: () => ({ rules: [], diagnostics: [] }),
|
|
43
44
|
getPrompts: () => ({ prompts: [], diagnostics: [] }),
|
|
44
45
|
getThemes: () => ({ themes: [], diagnostics: [] }),
|
|
45
46
|
getAgentsFiles: () => ({ agentsFiles: [] }),
|
package/examples/sdk/README.md
CHANGED
|
@@ -88,7 +88,7 @@ Most one-off session options can be passed directly to `PiAgent.create()`:
|
|
|
88
88
|
| `tools` | `[
|
|
89
89
|
"read", "bash", "edit", "write"]` built-ins | Allowlist tool names across built-in, extension, and custom tools |
|
|
90
90
|
| `customTools` | `[]` | Additional tool definitions |
|
|
91
|
-
| `resourceLoader` | DefaultResourceLoader | Resource loader for extensions, skills, prompts, themes |
|
|
91
|
+
| `resourceLoader` | DefaultResourceLoader | Resource loader for extensions, skills, rules, prompts, themes |
|
|
92
92
|
| `settingsManager` | SettingsManager.create(cwd, agentDir) | Settings source |
|
|
93
93
|
| `resolveSessionOptions` | undefined | Per-session override hook for model, tools, and diagnostics |
|
|
94
94
|
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fleetagent/pi-coding-agent",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@fleetagent/pi-coding-agent",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.6",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@fleetagent/pi-agent-core": "^0.0.
|
|
13
|
-
"@fleetagent/pi-ai": "^0.0.
|
|
14
|
-
"@fleetagent/pi-tui": "^0.0.
|
|
12
|
+
"@fleetagent/pi-agent-core": "^0.0.6",
|
|
13
|
+
"@fleetagent/pi-ai": "^0.0.6",
|
|
14
|
+
"@fleetagent/pi-tui": "^0.0.6",
|
|
15
15
|
"@silvia-odwyer/photon-node": "0.3.4",
|
|
16
16
|
"chalk": "5.6.2",
|
|
17
17
|
"cross-spawn": "7.0.6",
|
|
@@ -473,11 +473,11 @@
|
|
|
473
473
|
}
|
|
474
474
|
},
|
|
475
475
|
"node_modules/@fleetagent/pi-agent-core": {
|
|
476
|
-
"version": "0.0.
|
|
477
|
-
"resolved": "https://registry.npmjs.org/@fleetagent/pi-agent-core/-/pi-agent-core-0.0.
|
|
476
|
+
"version": "0.0.6",
|
|
477
|
+
"resolved": "https://registry.npmjs.org/@fleetagent/pi-agent-core/-/pi-agent-core-0.0.6.tgz",
|
|
478
478
|
"license": "MIT",
|
|
479
479
|
"dependencies": {
|
|
480
|
-
"@fleetagent/pi-ai": "^0.0.
|
|
480
|
+
"@fleetagent/pi-ai": "^0.0.6",
|
|
481
481
|
"ignore": "7.0.5",
|
|
482
482
|
"typebox": "1.1.38",
|
|
483
483
|
"yaml": "2.9.0"
|
|
@@ -487,8 +487,8 @@
|
|
|
487
487
|
}
|
|
488
488
|
},
|
|
489
489
|
"node_modules/@fleetagent/pi-ai": {
|
|
490
|
-
"version": "0.0.
|
|
491
|
-
"resolved": "https://registry.npmjs.org/@fleetagent/pi-ai/-/pi-ai-0.0.
|
|
490
|
+
"version": "0.0.6",
|
|
491
|
+
"resolved": "https://registry.npmjs.org/@fleetagent/pi-ai/-/pi-ai-0.0.6.tgz",
|
|
492
492
|
"license": "MIT",
|
|
493
493
|
"dependencies": {
|
|
494
494
|
"@anthropic-ai/sdk": "0.91.1",
|
|
@@ -509,8 +509,8 @@
|
|
|
509
509
|
}
|
|
510
510
|
},
|
|
511
511
|
"node_modules/@fleetagent/pi-tui": {
|
|
512
|
-
"version": "0.0.
|
|
513
|
-
"resolved": "https://registry.npmjs.org/@fleetagent/pi-tui/-/pi-tui-0.0.
|
|
512
|
+
"version": "0.0.6",
|
|
513
|
+
"resolved": "https://registry.npmjs.org/@fleetagent/pi-tui/-/pi-tui-0.0.6.tgz",
|
|
514
514
|
"license": "MIT",
|
|
515
515
|
"dependencies": {
|
|
516
516
|
"get-east-asian-width": "1.6.0",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fleetagent/pi-coding-agent",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"piConfig": {
|
|
@@ -39,9 +39,9 @@
|
|
|
39
39
|
"prepublishOnly": "npm run clean && npm run build && npm run shrinkwrap"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@fleetagent/pi-agent-core": "^0.0.
|
|
43
|
-
"@fleetagent/pi-ai": "^0.0.
|
|
44
|
-
"@fleetagent/pi-tui": "^0.0.
|
|
42
|
+
"@fleetagent/pi-agent-core": "^0.0.6",
|
|
43
|
+
"@fleetagent/pi-ai": "^0.0.6",
|
|
44
|
+
"@fleetagent/pi-tui": "^0.0.6",
|
|
45
45
|
"@silvia-odwyer/photon-node": "0.3.4",
|
|
46
46
|
"chalk": "5.6.2",
|
|
47
47
|
"cross-spawn": "7.0.6",
|