@diegopetrucci/pi-extensions 0.1.74 → 0.1.78
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/LICENSE +2 -0
- package/README.md +17 -12
- package/extensions/agent-workflow-audit/README.md +1 -1
- package/extensions/agent-workflow-audit/index.ts +1631 -1009
- package/extensions/agent-workflow-audit/package.json +1 -1
- package/extensions/annotate-git-diff/README.md +3 -1
- package/extensions/annotate-git-diff/clipboard.ts +109 -100
- package/extensions/annotate-git-diff/git.ts +846 -768
- package/extensions/annotate-git-diff/glimpseui.d.ts +87 -78
- package/extensions/annotate-git-diff/index.ts +712 -671
- package/extensions/annotate-git-diff/package.json +1 -1
- package/extensions/annotate-git-diff/prompt.ts +45 -45
- package/extensions/annotate-git-diff/quiet-glimpse.ts +161 -155
- package/extensions/annotate-git-diff/review-server.ts +337 -311
- package/extensions/annotate-git-diff/types.ts +132 -132
- package/extensions/annotate-git-diff/ui.ts +27 -27
- package/extensions/annotate-git-diff/watch.ts +74 -74
- package/extensions/annotate-git-diff/web/app.js +1947 -1884
- package/extensions/annotate-git-diff/web/index.html +5 -6
- package/extensions/annotate-last-message/README.md +1 -1
- package/extensions/annotate-last-message/glimpseui.d.ts +87 -78
- package/extensions/annotate-last-message/index.ts +210 -206
- package/extensions/annotate-last-message/package.json +1 -1
- package/extensions/annotate-last-message/prompt.ts +87 -66
- package/extensions/annotate-last-message/quiet-glimpse.ts +161 -155
- package/extensions/annotate-last-message/session.ts +94 -89
- package/extensions/annotate-last-message/theme.ts +199 -193
- package/extensions/annotate-last-message/types.ts +23 -23
- package/extensions/annotate-last-message/ui.ts +27 -25
- package/extensions/annotate-last-message/web/app.js +4 -7
- package/extensions/annotate-last-message/web/index.html +3 -3
- package/extensions/annotate-last-message/web/md-renderer.js +1 -1
- package/extensions/brrr/README.md +1 -1
- package/extensions/brrr/index.ts +213 -191
- package/extensions/brrr/package.json +1 -1
- package/extensions/claude-fast/README.md +5 -79
- package/extensions/claude-fast/index.ts +31 -289
- package/extensions/claude-fast/package.json +2 -3
- package/extensions/code-reviewer/README.md +6 -6
- package/extensions/code-reviewer/index.ts +1825 -1373
- package/extensions/code-reviewer/package.json +1 -1
- package/extensions/confirm-destructive/README.md +1 -1
- package/extensions/confirm-destructive/index.ts +50 -52
- package/extensions/confirm-destructive/package.json +1 -1
- package/extensions/context-cap/README.md +9 -9
- package/extensions/context-cap/index.ts +313 -305
- package/extensions/context-cap/package.json +2 -2
- package/extensions/context-inspector/index.ts +1211 -1064
- package/extensions/context-inspector/package.json +1 -1
- package/extensions/contrarian/README.md +4 -3
- package/extensions/contrarian/index.ts +1863 -1737
- package/extensions/contrarian/package.json +1 -1
- package/extensions/dirty-repo-guard/index.ts +37 -41
- package/extensions/dirty-repo-guard/package.json +1 -1
- package/extensions/dynamic-context-pruning/README.md +11 -43
- package/extensions/dynamic-context-pruning/index.ts +2131 -2105
- package/extensions/dynamic-context-pruning/package.json +1 -1
- package/extensions/fast/README.md +52 -14
- package/extensions/fast/index.ts +513 -317
- package/extensions/fast/package.json +1 -1
- package/extensions/git-footer/README.md +1 -1
- package/extensions/git-footer/index.ts +458 -411
- package/extensions/git-footer/package.json +2 -3
- package/extensions/gnosis/index.ts +180 -130
- package/extensions/gnosis/package.json +1 -1
- package/extensions/inline-bash/index.ts +87 -103
- package/extensions/inline-bash/package.json +1 -1
- package/extensions/librarian/README.md +1 -1
- package/extensions/librarian/index.ts +1877 -1419
- package/extensions/librarian/package.json +1 -1
- package/extensions/minimal-footer/README.md +5 -5
- package/extensions/minimal-footer/index.ts +987 -1012
- package/extensions/minimal-footer/minimal-footer.example.json +1 -1
- package/extensions/minimal-footer/openai-usage.ts +195 -190
- package/extensions/minimal-footer/package.json +1 -1
- package/extensions/notify/index.ts +222 -230
- package/extensions/notify/package.json +1 -1
- package/extensions/openai-fast/README.md +5 -73
- package/extensions/openai-fast/index.ts +32 -272
- package/extensions/openai-fast/package.json +2 -3
- package/extensions/oracle/README.md +4 -3
- package/extensions/oracle/index.ts +1740 -1627
- package/extensions/oracle/package.json +1 -1
- package/extensions/permission-gate/README.md +3 -0
- package/extensions/permission-gate/index.ts +785 -612
- package/extensions/permission-gate/package.json +1 -1
- package/extensions/permission-gate/powershell-safety.ts +840 -793
- package/extensions/project-mcp-json/.pi-fleet-tested-version +1 -0
- package/extensions/project-mcp-json/README.md +199 -0
- package/extensions/project-mcp-json/config.ts +564 -0
- package/extensions/project-mcp-json/index.ts +119 -0
- package/extensions/project-mcp-json/package.json +38 -0
- package/extensions/quiet-tools/.pi-fleet-tested-version +1 -1
- package/extensions/quiet-tools/README.md +30 -19
- package/extensions/quiet-tools/index.ts +376 -291
- package/extensions/quiet-tools/package.json +2 -2
- package/extensions/review/README.md +2 -2
- package/extensions/review/index.ts +1745 -1872
- package/extensions/review/package.json +1 -1
- package/extensions/todo/index.ts +280 -280
- package/extensions/todo/package.json +1 -1
- package/extensions/triage-comments/README.md +6 -4
- package/extensions/triage-comments/index.ts +2620 -1888
- package/extensions/triage-comments/package.json +1 -1
- package/package.json +9 -6
- package/assets/social-preview.png +0 -0
- package/extensions/claude-fast/claude-fast.example.json +0 -4
- package/extensions/openai-fast/openai-fast.example.json +0 -4
|
@@ -7,7 +7,7 @@ This is adapted from the original `confirm-destructive.ts` example in [`earendil
|
|
|
7
7
|
## What it checks
|
|
8
8
|
|
|
9
9
|
- clearing the current session
|
|
10
|
-
- switching sessions when the
|
|
10
|
+
- switching sessions when a user message is newer than the last assistant (or a user message with no assistant)
|
|
11
11
|
- forking from an entry
|
|
12
12
|
|
|
13
13
|
## Install
|
|
@@ -5,70 +5,68 @@
|
|
|
5
5
|
* Demonstrates how to cancel session events using the before_* events.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import type {
|
|
8
|
+
import type {
|
|
9
|
+
ExtensionAPI,
|
|
10
|
+
SessionBeforeSwitchEvent,
|
|
11
|
+
SessionEntry,
|
|
12
|
+
} from "@earendil-works/pi-coding-agent";
|
|
9
13
|
|
|
10
14
|
function hasUnsavedUserWork(entries: SessionEntry[]): boolean {
|
|
11
|
-
|
|
15
|
+
for (let index = entries.length - 1; index >= 0; index -= 1) {
|
|
16
|
+
const entry = entries[index];
|
|
17
|
+
if (entry.type !== "message") continue;
|
|
18
|
+
if (entry.message.role === "assistant") return false;
|
|
19
|
+
if (entry.message.role === "user") return true;
|
|
20
|
+
}
|
|
12
21
|
|
|
13
|
-
|
|
14
|
-
const entry = entries[index];
|
|
15
|
-
if (entry.type !== "message") continue;
|
|
16
|
-
if (entry.message.role === "assistant") {
|
|
17
|
-
sawAssistant = true;
|
|
18
|
-
break;
|
|
19
|
-
}
|
|
20
|
-
if (entry.message.role === "user") return true;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (sawAssistant) return false;
|
|
24
|
-
return entries.some((entry) => entry.type === "message" && entry.message.role === "user");
|
|
22
|
+
return false;
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
export default function (pi: ExtensionAPI) {
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
pi.on("session_before_switch", async (event: SessionBeforeSwitchEvent, ctx) => {
|
|
27
|
+
if (!ctx.hasUI) return;
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
if (event.reason === "new") {
|
|
30
|
+
const confirmed = await ctx.ui.confirm(
|
|
31
|
+
"Clear session?",
|
|
32
|
+
"This will delete all messages in the current session.",
|
|
33
|
+
);
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
if (!confirmed) {
|
|
36
|
+
ctx.ui.notify("Clear cancelled", "info");
|
|
37
|
+
return { cancel: true };
|
|
38
|
+
}
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
// reason === "resume" - check if there are unsaved changes (user messages newer than the last assistant response)
|
|
43
|
+
const entries = ctx.sessionManager.getEntries();
|
|
44
|
+
const hasUnsavedWork = hasUnsavedUserWork(entries);
|
|
47
45
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
if (hasUnsavedWork) {
|
|
47
|
+
const confirmed = await ctx.ui.confirm(
|
|
48
|
+
"Switch session?",
|
|
49
|
+
"You have messages in the current session. Switch anyway?",
|
|
50
|
+
);
|
|
53
51
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
if (!confirmed) {
|
|
53
|
+
ctx.ui.notify("Switch cancelled", "info");
|
|
54
|
+
return { cancel: true };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
60
58
|
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
pi.on("session_before_fork", async (event, ctx) => {
|
|
60
|
+
if (!ctx.hasUI) return;
|
|
63
61
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
62
|
+
const choice = await ctx.ui.select(`Fork from entry ${event.entryId.slice(0, 8)}?`, [
|
|
63
|
+
"Yes, create fork",
|
|
64
|
+
"No, stay in current session",
|
|
65
|
+
]);
|
|
68
66
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
67
|
+
if (choice !== "Yes, create fork") {
|
|
68
|
+
ctx.ui.notify("Fork cancelled", "info");
|
|
69
|
+
return { cancel: true };
|
|
70
|
+
}
|
|
71
|
+
});
|
|
74
72
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# context-cap
|
|
2
2
|
|
|
3
|
-
A pi extension that treats large-context models as having an effective
|
|
3
|
+
A pi extension that treats large-context models as having an effective 300k-token context window, so pi's built-in auto-compaction starts earlier, and avoids the dumb zone.
|
|
4
4
|
|
|
5
5
|
By default, pi auto-compacts when:
|
|
6
6
|
|
|
@@ -11,10 +11,10 @@ contextTokens > model.contextWindow - reserveTokens
|
|
|
11
11
|
This extension changes the active model's in-memory `contextWindow` to:
|
|
12
12
|
|
|
13
13
|
```text
|
|
14
|
-
min(originalContextWindow,
|
|
14
|
+
min(originalContextWindow, 300000)
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
With pi's default `reserveTokens` of 16,384, models larger than
|
|
17
|
+
With pi's default `reserveTokens` of 16,384, models larger than 300k will proactively compact around 283,616 tokens.
|
|
18
18
|
|
|
19
19
|
## Commands
|
|
20
20
|
|
|
@@ -65,21 +65,21 @@ Then reload pi:
|
|
|
65
65
|
|
|
66
66
|
### Settings guard and alternative
|
|
67
67
|
|
|
68
|
-
- On Pi hosts exposing `getSettings()`, the extension
|
|
69
|
-
- Pi's provider request path also derives an output-token budget from the effective window (`contextWindow - contextTokens - 4096`, with any provider-specific clamp applied afterward). The cap can therefore reduce response or thinking-token budgets near the limit, in addition to causing earlier compaction; Pi's overflow handling may also treat a request above
|
|
70
|
-
- As a session-scoped alternative, configure Pi's own `compaction.modelOverrides` instead of this extension. The exact key is `provider/model-id`; to match this extension's default
|
|
68
|
+
- On Pi hosts exposing `getSettings()`, the extension skips the cap whenever `compaction.modelOverrides` contains the active model's key (`provider/model-id`), whatever fields that entry sets; it does not read `reserveTokens` from the override. Otherwise it uses `compaction.reserveTokens`, then the default `16,384`, and skips the cap when that value is at least `300,000` (which would make the threshold zero or negative). Hosts without `getSettings()` use the older cap behavior without this guard.
|
|
69
|
+
- Pi's provider request path also derives an output-token budget from the effective window (`contextWindow - contextTokens - 4096`, with any provider-specific clamp applied afterward). The cap can therefore reduce response or thinking-token budgets near the limit, in addition to causing earlier compaction; Pi's overflow handling may also treat a request above 300k as overflow and retry after compaction. Use `/context-cap off` when you need the full model window temporarily.
|
|
70
|
+
- As a session-scoped alternative, configure Pi's own `compaction.modelOverrides` instead of this extension. The exact key is `provider/model-id`; to match this extension's default 300k threshold for a model with original window `W`, let `R` be the configured `reserveTokens` value (default `16,384`) and use:
|
|
71
71
|
|
|
72
72
|
```text
|
|
73
|
-
reserveTokens = W -
|
|
73
|
+
reserveTokens = W - 300000 + R
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
For example, with the default `R`, a 1,000,000-token model uses `
|
|
76
|
+
For example, with the default `R`, a 1,000,000-token model uses `716384`, yielding the same `283616` threshold as `300000 - 16384`:
|
|
77
77
|
|
|
78
78
|
```json
|
|
79
79
|
{
|
|
80
80
|
"compaction": {
|
|
81
81
|
"modelOverrides": {
|
|
82
|
-
"provider/model-id": { "reserveTokens":
|
|
82
|
+
"provider/model-id": { "reserveTokens": 716384 }
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
}
|