pi-adaptive-thinking 0.0.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/README.md +85 -0
- package/dist/config-loader.d.ts +16 -0
- package/dist/config.d.ts +18 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2896 -0
- package/dist/thinking-levels.d.ts +5 -0
- package/package.json +78 -0
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# pi-adaptive-thinking
|
|
4
|
+
|
|
5
|
+
Bring adaptive reasoning-effort control to Pi agents.
|
|
6
|
+
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
`pi-adaptive-thinking` is a Pi extension that lets the agent change Pi's thinking level through a tool named `set_reasoning_effort`.
|
|
10
|
+
|
|
11
|
+
It mirrors the user-facing behavior of `opencode-adaptive-thinking` while using Pi-native APIs: `pi.getThinkingLevel()`, `pi.setThinkingLevel()`, and `thinking_level_select`.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pi install npm:pi-adaptive-thinking
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
For local development:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm install
|
|
23
|
+
pnpm build
|
|
24
|
+
pi -e ./dist/index.js
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Behavior
|
|
28
|
+
|
|
29
|
+
The extension registers a tool with these parameters:
|
|
30
|
+
|
|
31
|
+
- `level`: one of the valid Pi thinking levels for the current model.
|
|
32
|
+
- `persist`: optional boolean, default `false`.
|
|
33
|
+
|
|
34
|
+
Temporary changes:
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{ "level": "high", "persist": false }
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
This changes reasoning effort for the current agent turn and restores the prior/baseline level when the turn ends.
|
|
41
|
+
|
|
42
|
+
Persistent changes:
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{ "level": "low", "persist": true }
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
This changes the session baseline until another persistent change is made or the user changes thinking level manually.
|
|
49
|
+
|
|
50
|
+
## Configuration
|
|
51
|
+
|
|
52
|
+
Configuration files are loaded in this order:
|
|
53
|
+
|
|
54
|
+
1. Project: `.pi/adaptive-thinking.json`
|
|
55
|
+
2. Global: `~/.pi/agent/adaptive-thinking.json`
|
|
56
|
+
3. Built-in defaults
|
|
57
|
+
|
|
58
|
+
Project configuration takes precedence over global configuration.
|
|
59
|
+
|
|
60
|
+
```json
|
|
61
|
+
{
|
|
62
|
+
"enabled": true,
|
|
63
|
+
"quiet": false,
|
|
64
|
+
"toolName": "set_reasoning_effort",
|
|
65
|
+
"toolDescription": "Set your reasoning effort",
|
|
66
|
+
"systemPrompt": "You MUST manage reasoning effort actively. Lower it before trivial or routine turns; raise it for ambiguity, debugging, risky changes, or multi-step synthesis. Reassess at turn start, after meaningful new evidence, and when the task shifts. NEVER leave the current level unchanged by inertia, and NEVER reply to a trivial turn before considering a downshift."
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Development
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
pnpm install
|
|
74
|
+
pnpm format:check
|
|
75
|
+
pnpm lint
|
|
76
|
+
pnpm typecheck
|
|
77
|
+
pnpm test
|
|
78
|
+
pnpm build
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Run all checks:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pnpm verify
|
|
85
|
+
```
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type AdaptiveThinkingConfig } from "./config.js";
|
|
2
|
+
export type { AdaptiveThinkingConfig } from "./config.js";
|
|
3
|
+
export type LoadConfigOptions = {
|
|
4
|
+
cwd: string;
|
|
5
|
+
homeDir?: string;
|
|
6
|
+
};
|
|
7
|
+
export type LoadConfigResult = {
|
|
8
|
+
success: true;
|
|
9
|
+
config: AdaptiveThinkingConfig;
|
|
10
|
+
source?: string;
|
|
11
|
+
} | {
|
|
12
|
+
success: false;
|
|
13
|
+
source: string;
|
|
14
|
+
error: Error;
|
|
15
|
+
};
|
|
16
|
+
export declare const loadConfig: ({ cwd, homeDir, }: LoadConfigOptions) => Promise<LoadConfigResult>;
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Type, type Static } from "typebox";
|
|
2
|
+
export declare const defaultSystemPrompt: string;
|
|
3
|
+
export declare const configDefaults: {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
quiet: boolean;
|
|
6
|
+
toolName: string;
|
|
7
|
+
toolDescription: string;
|
|
8
|
+
systemPrompt: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const ConfigSchema: Type.TObject<{
|
|
11
|
+
enabled: Type.TBoolean;
|
|
12
|
+
quiet: Type.TBoolean;
|
|
13
|
+
toolName: Type.TString;
|
|
14
|
+
toolDescription: Type.TString;
|
|
15
|
+
systemPrompt: Type.TString;
|
|
16
|
+
}>;
|
|
17
|
+
export type AdaptiveThinkingConfig = Static<typeof ConfigSchema>;
|
|
18
|
+
export declare const parseConfig: (input: unknown) => AdaptiveThinkingConfig;
|
package/dist/index.d.ts
ADDED