pi-arsenal 0.1.1 → 0.1.2
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 +21 -21
- package/README.md +67 -69
- package/extensions/task-panel.ts +99 -99
- package/extensions/workspace-drawer.ts +27 -7
- package/lib/session-library.ts +142 -142
- package/package.json +36 -36
- package/themes/tokyo-night-terra.json +86 -86
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 SeiyunSky
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 SeiyunSky
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,69 +1,67 @@
|
|
|
1
|
-
# Pi Arsenal
|
|
2
|
-
|
|
3
|
-
<p align="center">
|
|
4
|
-
<img src="assets/pi-arsenal-banner.png" alt="Pi Arsenal red signal artwork" width="420">
|
|
5
|
-
</p>
|
|
6
|
-
|
|
7
|
-
> **
|
|
8
|
-
|
|
9
|
-
```text
|
|
10
|
-
╔══════════════════════════════════════════════╗
|
|
11
|
-
║ PI ARSENAL ║
|
|
12
|
-
║
|
|
13
|
-
╚══════════════════════════════════════════════╝
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
##
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
|
23
|
-
|
|
24
|
-
| **
|
|
25
|
-
| **
|
|
26
|
-
| **
|
|
27
|
-
| **
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
|
47
|
-
|
|
48
|
-
| `
|
|
49
|
-
| `/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
> Skill enable/disable moves complete skill folders between `~/.agents/skills` and `~/.agents/disabled-skills`. Nothing is deleted. Run `/reload` afterward.
|
|
1
|
+
# Pi Arsenal
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="assets/pi-arsenal-banner.png" alt="Pi Arsenal red signal artwork" width="420">
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
> **LOADOUT READY.** A terminal control deck for [Pi](https://github.com/earendil-works/pi): organize the workspace, deploy skills, inspect sessions, and review MCP tools without leaving the TUI.
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
╔══════════════════════════════════════════════╗
|
|
11
|
+
║ PI ARSENAL ║
|
|
12
|
+
║ WORKSPACE · SESSIONS · SKILLS · MCP ║
|
|
13
|
+
╚══════════════════════════════════════════════╝
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Modules
|
|
17
|
+
|
|
18
|
+
| Module | What it does |
|
|
19
|
+
|---|---|
|
|
20
|
+
| **Workspace Drawer** | Projects, files, computer browser, usage, Mermaid gallery, Session Library, optional Translation Studio, Skill Library, and MCP Server browser. |
|
|
21
|
+
| **Session Library** | Inspect sessions, rename them, add private descriptions, reload in the current window, and delete non-current sessions. |
|
|
22
|
+
| **Skill Library** | Browse enabled/disabled skills by folder; add private labels; enable/disable skills or folders; organize folders; prepare `/skill:<name>` commands. |
|
|
23
|
+
| **MCP Server Browser** | Read cached MCP servers and tools without displaying secrets. |
|
|
24
|
+
| **Task Panel** | Persistent task panel extension. |
|
|
25
|
+
| **Startup Splash** | Red/black terminal startup header. |
|
|
26
|
+
| **Tokyo Night Terra** | Included Pi theme. |
|
|
27
|
+
| **Translation Studio integration** | Shows `🌐 Translation Studio` when [`pi-translation-studio`](https://www.npmjs.com/package/pi-translation-studio) is installed; Pi Arsenal does not bundle translation logic. |
|
|
28
|
+
|
|
29
|
+
## Deploy
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pi install npm:pi-arsenal
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Then reload Pi:
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
/reload
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Commands
|
|
42
|
+
|
|
43
|
+
| Command | Action |
|
|
44
|
+
|---|---|
|
|
45
|
+
| `Alt+W` | Open the Workspace Drawer |
|
|
46
|
+
| `/workspace` | Open the Workspace Drawer when the terminal does not deliver `Alt+W` |
|
|
47
|
+
| `/sessions` | Open Session Library directly |
|
|
48
|
+
| `/translate` | Provided by the optional `pi-translation-studio` package |
|
|
49
|
+
| `/reload` | Apply changed skill discovery after enable/disable operations |
|
|
50
|
+
|
|
51
|
+
## Skill Loadout
|
|
52
|
+
|
|
53
|
+
Open the drawer, then:
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
Skill Library → Enabled skills / Disabled skills → folder → skill
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
For enabled skills, select **Use this skill now**. Pi Arsenal prepares the canonical command in the editor:
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
/skill:<canonical-name>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Add task details and submit when ready.
|
|
66
|
+
|
|
67
|
+
> Skill enable/disable moves complete skill folders between `~/.agents/skills` and `~/.agents/disabled-skills`. Nothing is deleted. Run `/reload` afterward.
|
package/extensions/task-panel.ts
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
import type { ExtensionAPI, ExtensionContext, SessionEntry } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { truncateToWidth } from "@earendil-works/pi-tui";
|
|
3
|
-
|
|
4
|
-
const WIDGET_ID = "sol-pi-task-panel";
|
|
5
|
-
const ONLINE_STATE_ENTRY = "sol-pi-online-context-state-v1";
|
|
6
|
-
const MAX_VISIBLE_STEPS = 10;
|
|
7
|
-
|
|
8
|
-
type PlanStatus = "pending" | "in_progress" | "completed";
|
|
9
|
-
|
|
10
|
-
type PlanStep = {
|
|
11
|
-
id: string;
|
|
12
|
-
goal: string;
|
|
13
|
-
status: PlanStatus;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
function parseSteps(value: unknown): PlanStep[] | undefined {
|
|
17
|
-
if (!Array.isArray(value) || value.length === 0) return;
|
|
18
|
-
const steps: PlanStep[] = [];
|
|
19
|
-
for (const item of value) {
|
|
20
|
-
if (typeof item !== "object" || item === null || Array.isArray(item)) return;
|
|
21
|
-
const step = item as Record<string, unknown>;
|
|
22
|
-
if (
|
|
23
|
-
typeof step.id !== "string" ||
|
|
24
|
-
typeof step.goal !== "string" ||
|
|
25
|
-
!(["pending", "in_progress", "completed"] as const).includes(step.status as PlanStatus)
|
|
26
|
-
) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
steps.push({ id: step.id, goal: step.goal, status: step.status as PlanStatus });
|
|
30
|
-
}
|
|
31
|
-
return steps;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function restoreSteps(entries: readonly SessionEntry[]): PlanStep[] {
|
|
35
|
-
for (let index = entries.length - 1; index >= 0; index--) {
|
|
36
|
-
const entry = entries[index];
|
|
37
|
-
if (entry?.type !== "custom" || entry.customType !== ONLINE_STATE_ENTRY) continue;
|
|
38
|
-
const data = entry.data as { plan?: unknown } | undefined;
|
|
39
|
-
return parseSteps(data?.plan) ?? [];
|
|
40
|
-
}
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export default function taskPanel(pi: ExtensionAPI) {
|
|
45
|
-
let steps: PlanStep[] = [];
|
|
46
|
-
|
|
47
|
-
function render(ctx: ExtensionContext): void {
|
|
48
|
-
if (ctx.mode !== "tui") return;
|
|
49
|
-
if (steps.length === 0) {
|
|
50
|
-
ctx.ui.setWidget(WIDGET_ID, undefined);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
ctx.ui.setWidget(WIDGET_ID, (_tui, theme) => ({
|
|
55
|
-
invalidate() {},
|
|
56
|
-
render(width: number): string[] {
|
|
57
|
-
const completed = steps.filter((step) => step.status === "completed").length;
|
|
58
|
-
const lines = [
|
|
59
|
-
truncateToWidth(
|
|
60
|
-
theme.fg("accent", theme.bold("Tasks")) + theme.fg("dim", ` ${completed}/${steps.length} completed`),
|
|
61
|
-
width,
|
|
62
|
-
),
|
|
63
|
-
];
|
|
64
|
-
|
|
65
|
-
for (const step of steps.slice(0, MAX_VISIBLE_STEPS)) {
|
|
66
|
-
const marker =
|
|
67
|
-
step.status === "completed"
|
|
68
|
-
? theme.fg("success", "✓")
|
|
69
|
-
: step.status === "in_progress"
|
|
70
|
-
? theme.fg("warning", "●")
|
|
71
|
-
: theme.fg("dim", "○");
|
|
72
|
-
const goal = step.status === "completed" ? theme.fg("muted", step.goal) : theme.fg("text", step.goal);
|
|
73
|
-
lines.push(truncateToWidth(` ${marker} ${goal}`, width));
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (steps.length > MAX_VISIBLE_STEPS) {
|
|
77
|
-
lines.push(theme.fg("dim", ` … ${steps.length - MAX_VISIBLE_STEPS} more`));
|
|
78
|
-
}
|
|
79
|
-
return lines;
|
|
80
|
-
},
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function restore(ctx: ExtensionContext): void {
|
|
85
|
-
steps = restoreSteps(ctx.sessionManager.getBranch());
|
|
86
|
-
render(ctx);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
pi.on("session_start", async (_event, ctx) => restore(ctx));
|
|
90
|
-
pi.on("session_tree", async (_event, ctx) => restore(ctx));
|
|
91
|
-
|
|
92
|
-
pi.on("tool_execution_start", async (event, ctx) => {
|
|
93
|
-
if (event.toolName !== "update_plan") return;
|
|
94
|
-
const next = parseSteps((event.args as { steps?: unknown } | undefined)?.steps);
|
|
95
|
-
if (!next) return;
|
|
96
|
-
steps = next;
|
|
97
|
-
render(ctx);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
1
|
+
import type { ExtensionAPI, ExtensionContext, SessionEntry } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { truncateToWidth } from "@earendil-works/pi-tui";
|
|
3
|
+
|
|
4
|
+
const WIDGET_ID = "sol-pi-task-panel";
|
|
5
|
+
const ONLINE_STATE_ENTRY = "sol-pi-online-context-state-v1";
|
|
6
|
+
const MAX_VISIBLE_STEPS = 10;
|
|
7
|
+
|
|
8
|
+
type PlanStatus = "pending" | "in_progress" | "completed";
|
|
9
|
+
|
|
10
|
+
type PlanStep = {
|
|
11
|
+
id: string;
|
|
12
|
+
goal: string;
|
|
13
|
+
status: PlanStatus;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function parseSteps(value: unknown): PlanStep[] | undefined {
|
|
17
|
+
if (!Array.isArray(value) || value.length === 0) return;
|
|
18
|
+
const steps: PlanStep[] = [];
|
|
19
|
+
for (const item of value) {
|
|
20
|
+
if (typeof item !== "object" || item === null || Array.isArray(item)) return;
|
|
21
|
+
const step = item as Record<string, unknown>;
|
|
22
|
+
if (
|
|
23
|
+
typeof step.id !== "string" ||
|
|
24
|
+
typeof step.goal !== "string" ||
|
|
25
|
+
!(["pending", "in_progress", "completed"] as const).includes(step.status as PlanStatus)
|
|
26
|
+
) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
steps.push({ id: step.id, goal: step.goal, status: step.status as PlanStatus });
|
|
30
|
+
}
|
|
31
|
+
return steps;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function restoreSteps(entries: readonly SessionEntry[]): PlanStep[] {
|
|
35
|
+
for (let index = entries.length - 1; index >= 0; index--) {
|
|
36
|
+
const entry = entries[index];
|
|
37
|
+
if (entry?.type !== "custom" || entry.customType !== ONLINE_STATE_ENTRY) continue;
|
|
38
|
+
const data = entry.data as { plan?: unknown } | undefined;
|
|
39
|
+
return parseSteps(data?.plan) ?? [];
|
|
40
|
+
}
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default function taskPanel(pi: ExtensionAPI) {
|
|
45
|
+
let steps: PlanStep[] = [];
|
|
46
|
+
|
|
47
|
+
function render(ctx: ExtensionContext): void {
|
|
48
|
+
if (ctx.mode !== "tui") return;
|
|
49
|
+
if (steps.length === 0) {
|
|
50
|
+
ctx.ui.setWidget(WIDGET_ID, undefined);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
ctx.ui.setWidget(WIDGET_ID, (_tui, theme) => ({
|
|
55
|
+
invalidate() {},
|
|
56
|
+
render(width: number): string[] {
|
|
57
|
+
const completed = steps.filter((step) => step.status === "completed").length;
|
|
58
|
+
const lines = [
|
|
59
|
+
truncateToWidth(
|
|
60
|
+
theme.fg("accent", theme.bold("Tasks")) + theme.fg("dim", ` ${completed}/${steps.length} completed`),
|
|
61
|
+
width,
|
|
62
|
+
),
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
for (const step of steps.slice(0, MAX_VISIBLE_STEPS)) {
|
|
66
|
+
const marker =
|
|
67
|
+
step.status === "completed"
|
|
68
|
+
? theme.fg("success", "✓")
|
|
69
|
+
: step.status === "in_progress"
|
|
70
|
+
? theme.fg("warning", "●")
|
|
71
|
+
: theme.fg("dim", "○");
|
|
72
|
+
const goal = step.status === "completed" ? theme.fg("muted", step.goal) : theme.fg("text", step.goal);
|
|
73
|
+
lines.push(truncateToWidth(` ${marker} ${goal}`, width));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (steps.length > MAX_VISIBLE_STEPS) {
|
|
77
|
+
lines.push(theme.fg("dim", ` … ${steps.length - MAX_VISIBLE_STEPS} more`));
|
|
78
|
+
}
|
|
79
|
+
return lines;
|
|
80
|
+
},
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function restore(ctx: ExtensionContext): void {
|
|
85
|
+
steps = restoreSteps(ctx.sessionManager.getBranch());
|
|
86
|
+
render(ctx);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
pi.on("session_start", async (_event, ctx) => restore(ctx));
|
|
90
|
+
pi.on("session_tree", async (_event, ctx) => restore(ctx));
|
|
91
|
+
|
|
92
|
+
pi.on("tool_execution_start", async (event, ctx) => {
|
|
93
|
+
if (event.toolName !== "update_plan") return;
|
|
94
|
+
const next = parseSteps((event.args as { steps?: unknown } | undefined)?.steps);
|
|
95
|
+
if (!next) return;
|
|
96
|
+
steps = next;
|
|
97
|
+
render(ctx);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
@@ -33,7 +33,13 @@ type McpTool = { name: string; description?: string };
|
|
|
33
33
|
type McpServer = { name: string; tools: McpTool[]; cachedAt?: number };
|
|
34
34
|
type ResourceLabels = { displayName?: string; note?: string };
|
|
35
35
|
type ResourceMetadata = { skills?: Record<string, ResourceLabels>; mcp?: Record<string, ResourceLabels> };
|
|
36
|
-
type
|
|
36
|
+
type TranslationStudioBridge = { version: 1; open(ctx: ExtensionCommandContext): Promise<void> };
|
|
37
|
+
type Result = { type: "close" } | { type: "workspace"; workspace: Workspace } | { type: "view-diagram"; diagram: Diagram } | { type: "sessions" | "translation" } | { type: "edit-label"; kind: "skills" | "mcp"; key: string; fallback: string; field: "displayName" | "note" } | { type: "use-skill"; canonicalName: string } | { type: "organize-skills" } | { type: "toggle-skill-folder"; enabled: boolean; relative: string };
|
|
38
|
+
const TRANSLATION_BRIDGE_KEY = Symbol.for("pi-translation-studio.bridge.v1");
|
|
39
|
+
const translationBridge = (): TranslationStudioBridge | undefined => {
|
|
40
|
+
const bridge = (globalThis as Record<symbol, unknown>)[TRANSLATION_BRIDGE_KEY] as TranslationStudioBridge | undefined;
|
|
41
|
+
return bridge?.version === 1 ? bridge : undefined;
|
|
42
|
+
};
|
|
37
43
|
|
|
38
44
|
type MermaidViewer = { server: Server; source: string; title: string; url: string };
|
|
39
45
|
let mermaidViewer: MermaidViewer | undefined;
|
|
@@ -256,7 +262,15 @@ class WorkspaceDrawer implements Focusable {
|
|
|
256
262
|
private mcpItems: McpServer[] | undefined;
|
|
257
263
|
private selectedMcp: McpServer | undefined;
|
|
258
264
|
|
|
259
|
-
constructor(private readonly ctx: ExtensionCommandContext, private readonly workspace: Workspace, private readonly workspaces: Workspace[], private readonly theme: Theme, private readonly done: (result: Result) => void, private readonly tui: { requestRender(): void }) {}
|
|
265
|
+
constructor(private readonly ctx: ExtensionCommandContext, private readonly workspace: Workspace, private readonly workspaces: Workspace[], private readonly theme: Theme, private readonly done: (result: Result) => void, private readonly tui: { requestRender(): void }, private readonly hasTranslationStudio: boolean) {}
|
|
266
|
+
|
|
267
|
+
private homeItems(): Array<{ label: string; view?: View; result?: "sessions" | "translation" }> {
|
|
268
|
+
return [
|
|
269
|
+
{ label: "📁 Projects", view: "projects" }, { label: "📄 Files", view: "files" }, { label: "🖥️ Browse computer…", view: "browser" }, { label: "💰 Usage & Cost", view: "usage" }, { label: "🗺️ Diagram Gallery", view: "diagrams" }, { label: "🕘 Session Library", result: "sessions" },
|
|
270
|
+
...(this.hasTranslationStudio ? [{ label: "🌐 Translation Studio", result: "translation" as const }] : []),
|
|
271
|
+
{ label: "✨ Skill Library", view: "skills" }, { label: "🔌 MCP Servers", view: "mcp" },
|
|
272
|
+
];
|
|
273
|
+
}
|
|
260
274
|
|
|
261
275
|
private open(view: View): void {
|
|
262
276
|
this.view = view;
|
|
@@ -320,14 +334,15 @@ class WorkspaceDrawer implements Focusable {
|
|
|
320
334
|
if (matchesKey(data, "s") && this.view === "browser" && this.browserPath) { this.setCurrentDirectory(); return; }
|
|
321
335
|
if (matchesKey(data, Key.up) || matchesKey(data, "k")) { this.selected = Math.max(0, this.selected - 1); return; }
|
|
322
336
|
if (matchesKey(data, Key.down) || matchesKey(data, "j")) {
|
|
323
|
-
const last = this.view === "projects" ? this.workspaces.length : this.view === "files" ? Math.max(0, (this.files?.length || 1) - 1) : this.view === "browser" ? Math.max(0, this.browserEntries.length - 1) : this.view === "diagrams" ? Math.max(0, (this.diagramItems?.length || 1) - 1) : this.view === "skills" ? 1 : this.view === "skill-list" ? this.skillEntryItems.length + (this.skillDirectory ? 1 : 0) : this.view === "skill-detail" ? (this.selectedSkill?.enabled ? 3 : 2) : this.view === "mcp" ? Math.max(0, (this.mcpItems?.length || 1) - 1) : this.view === "mcp-detail" ? Math.max(0, (this.selectedMcp?.tools.length || 1) - 1) : this.view === "usage" ? 0 :
|
|
337
|
+
const last = this.view === "projects" ? this.workspaces.length : this.view === "files" ? Math.max(0, (this.files?.length || 1) - 1) : this.view === "browser" ? Math.max(0, this.browserEntries.length - 1) : this.view === "diagrams" ? Math.max(0, (this.diagramItems?.length || 1) - 1) : this.view === "skills" ? 1 : this.view === "skill-list" ? this.skillEntryItems.length + (this.skillDirectory ? 1 : 0) : this.view === "skill-detail" ? (this.selectedSkill?.enabled ? 3 : 2) : this.view === "mcp" ? Math.max(0, (this.mcpItems?.length || 1) - 1) : this.view === "mcp-detail" ? Math.max(0, (this.selectedMcp?.tools.length || 1) - 1) : this.view === "usage" ? 0 : this.homeItems().length - 1;
|
|
324
338
|
this.selected = Math.min(last, this.selected + 1);
|
|
325
339
|
return;
|
|
326
340
|
}
|
|
327
341
|
if (!matchesKey(data, Key.enter) && !matchesKey(data, Key.right)) return;
|
|
328
342
|
if (this.view === "home") {
|
|
329
|
-
|
|
330
|
-
this.
|
|
343
|
+
const item = this.homeItems()[this.selected];
|
|
344
|
+
if (item?.result) this.done({ type: item.result });
|
|
345
|
+
else if (item?.view) this.open(item.view);
|
|
331
346
|
return;
|
|
332
347
|
}
|
|
333
348
|
if (this.view === "skills") { this.skillEnabled = this.selected === 0; this.skillDirectory = ""; this.open("skill-list"); return; }
|
|
@@ -373,7 +388,7 @@ class WorkspaceDrawer implements Focusable {
|
|
|
373
388
|
lines.push(row(` ${th.fg("accent", "◈")} ${th.bold(this.workspace.name)}`));
|
|
374
389
|
lines.push(row(` ${th.fg("dim", this.workspace.path)}`));
|
|
375
390
|
lines.push(row(""));
|
|
376
|
-
for (const [i,
|
|
391
|
+
for (const [i, item] of this.homeItems().entries()) lines.push(row(` ${marker(i)} ${th.fg("text", item.label)}`));
|
|
377
392
|
lines.push(row(""));
|
|
378
393
|
lines.push(row(th.fg("dim", "↑ ↓ select · Enter / → open · Esc / ← close")));
|
|
379
394
|
} else if (this.view === "projects") {
|
|
@@ -460,12 +475,17 @@ export default function workspaceDrawer(pi: ExtensionAPI) {
|
|
|
460
475
|
const open = async (ctx: ExtensionCommandContext): Promise<void> => {
|
|
461
476
|
if (ctx.mode !== "tui") return;
|
|
462
477
|
const current = active(ctx);
|
|
463
|
-
const result = await ctx.ui.custom<Result>((tui, theme, _keybindings, done) => new WorkspaceDrawer(ctx, current, configuredWorkspaces(ctx.cwd), theme, done, tui), {
|
|
478
|
+
const result = await ctx.ui.custom<Result>((tui, theme, _keybindings, done) => new WorkspaceDrawer(ctx, current, configuredWorkspaces(ctx.cwd), theme, done, tui, Boolean(translationBridge())), {
|
|
464
479
|
overlay: true,
|
|
465
480
|
overlayOptions: { anchor: "right-center", width: 54, maxHeight: "100%", margin: { top: 1, right: 1, bottom: 1 } },
|
|
466
481
|
});
|
|
467
482
|
if (result?.type === "workspace") { workspace = result.workspace; pi.appendEntry(STATE_TYPE, workspace); ctx.ui.notify(`Workspace: ${workspace.name}`, "info"); }
|
|
468
483
|
else if (result?.type === "sessions") await openSessionLibrary(pi, ctx);
|
|
484
|
+
else if (result?.type === "translation") {
|
|
485
|
+
const bridge = translationBridge();
|
|
486
|
+
if (bridge) await bridge.open(ctx);
|
|
487
|
+
else ctx.ui.notify("Install pi-translation-studio to enable Translation Studio.", "info");
|
|
488
|
+
}
|
|
469
489
|
else if (result?.type === "organize-skills") { await organizeSkillFolders(ctx); await open(ctx); }
|
|
470
490
|
else if (result?.type === "use-skill") { ctx.ui.setEditorText(`/skill:${result.canonicalName} `); ctx.ui.notify("Skill command is ready in the editor. Add details, then submit.", "info"); }
|
|
471
491
|
else if (result?.type === "toggle-skill-folder") {
|
package/lib/session-library.ts
CHANGED
|
@@ -1,142 +1,142 @@
|
|
|
1
|
-
import { existsSync, rmSync } from "node:fs";
|
|
2
|
-
import { SessionManager, type ExtensionAPI, type ExtensionCommandContext, type SessionInfo } from "@earendil-works/pi-coding-agent";
|
|
3
|
-
|
|
4
|
-
export const SESSION_DESCRIPTION_TYPE = "terra-session-description-v1";
|
|
5
|
-
export type SessionDescription = { text: string };
|
|
6
|
-
export type SessionStats = { user: number; assistant: number; toolCalls: number; toolResults: number; input: number; cacheRead: number; cacheWrite: number; output: number; hasUsage: boolean };
|
|
7
|
-
|
|
8
|
-
export function relativeTime(date: Date): string {
|
|
9
|
-
const seconds = Math.max(0, Math.floor((Date.now() - date.getTime()) / 1000));
|
|
10
|
-
if (seconds < 60) return "just now";
|
|
11
|
-
if (seconds < 3600) return `${Math.floor(seconds / 60)}m ago`;
|
|
12
|
-
if (seconds < 86400) return `${Math.floor(seconds / 3600)}h ago`;
|
|
13
|
-
return `${Math.floor(seconds / 86400)}d ago`;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function sessionTitle(session: SessionInfo): string {
|
|
17
|
-
return session.name?.trim() || session.firstMessage.trim().replace(/\s+/g, " ").slice(0, 56) || "Untitled session";
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function formatTokens(value: number): string {
|
|
21
|
-
return new Intl.NumberFormat("en-US").format(value);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export async function listSessions(): Promise<SessionInfo[]> {
|
|
25
|
-
return (await SessionManager.listAll()).sort((a, b) => b.modified.getTime() - a.modified.getTime());
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function descriptionOf(path: string): string {
|
|
29
|
-
try {
|
|
30
|
-
const entries = SessionManager.open(path).getEntries();
|
|
31
|
-
for (let i = entries.length - 1; i >= 0; i--) {
|
|
32
|
-
const entry = entries[i];
|
|
33
|
-
if (entry?.type !== "custom" || entry.customType !== SESSION_DESCRIPTION_TYPE) continue;
|
|
34
|
-
const data = entry.data as SessionDescription | undefined;
|
|
35
|
-
if (typeof data?.text === "string") return data.text;
|
|
36
|
-
}
|
|
37
|
-
} catch { /* A damaged historical session must not block the library. */ }
|
|
38
|
-
return "";
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function statisticsOf(path: string): SessionStats {
|
|
42
|
-
const stats: SessionStats = { user: 0, assistant: 0, toolCalls: 0, toolResults: 0, input: 0, cacheRead: 0, cacheWrite: 0, output: 0, hasUsage: false };
|
|
43
|
-
try {
|
|
44
|
-
for (const entry of SessionManager.open(path).getEntries()) {
|
|
45
|
-
if (entry.type !== "message") continue;
|
|
46
|
-
const message = entry.message;
|
|
47
|
-
if (message.role === "user") stats.user++;
|
|
48
|
-
else if (message.role === "toolResult") stats.toolResults++;
|
|
49
|
-
else if (message.role === "assistant") {
|
|
50
|
-
stats.assistant++;
|
|
51
|
-
stats.toolCalls += message.content.filter((part) => part.type === "toolCall").length;
|
|
52
|
-
const usage = message.usage;
|
|
53
|
-
if (usage) {
|
|
54
|
-
stats.hasUsage = true;
|
|
55
|
-
stats.input += usage.input || 0;
|
|
56
|
-
stats.cacheRead += usage.cacheRead || 0;
|
|
57
|
-
stats.cacheWrite += usage.cacheWrite || 0;
|
|
58
|
-
stats.output += usage.output || 0;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
} catch { /* Zeroes communicate that unreadable historical data has no usable stats. */ }
|
|
63
|
-
return stats;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function setSessionName(pi: ExtensionAPI, ctx: ExtensionCommandContext, path: string, current: boolean, name: string): void {
|
|
67
|
-
if (current) pi.setSessionName(name);
|
|
68
|
-
else SessionManager.open(path).appendSessionInfo(name);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export function setSessionDescription(pi: ExtensionAPI, ctx: ExtensionCommandContext, path: string, current: boolean, text: string): void {
|
|
72
|
-
const data = { text } satisfies SessionDescription;
|
|
73
|
-
if (current) pi.appendEntry(SESSION_DESCRIPTION_TYPE, data);
|
|
74
|
-
else SessionManager.open(path).appendCustomEntry(SESSION_DESCRIPTION_TYPE, data);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function deleteSession(path: string, activePath: string | undefined): boolean {
|
|
78
|
-
if (path === activePath || !path.endsWith(".jsonl") || !existsSync(path)) return false;
|
|
79
|
-
rmSync(path);
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function detailTitle(session: SessionInfo, current: boolean, description: string, stats: SessionStats): string {
|
|
84
|
-
const totalMessages = stats.user + stats.assistant + stats.toolResults;
|
|
85
|
-
const totalInput = stats.input + stats.cacheRead;
|
|
86
|
-
const totalTokens = totalInput + stats.output;
|
|
87
|
-
const cacheRate = totalInput ? ` (${((stats.cacheRead / totalInput) * 100).toFixed(1)}%)` : "";
|
|
88
|
-
const tokens = stats.hasUsage
|
|
89
|
-
? [`Input: ${formatTokens(totalInput)}`, ` Cached: ${formatTokens(stats.cacheRead)}${cacheRate}`, ` Uncached: ${formatTokens(stats.input)} (${formatTokens(stats.cacheWrite)} written to cache)`, `Output: ${formatTokens(stats.output)}`, `Total: ${formatTokens(totalTokens)}`]
|
|
90
|
-
: ["Usage data: —"];
|
|
91
|
-
return [current ? "Current session" : "Historical session", `Name: ${sessionTitle(session)}`, `Description: ${description || "—"}`, `Updated: ${relativeTime(session.modified)}`, `Workspace: ${session.cwd || "—"}`, "", "Messages", `Total: ${formatTokens(totalMessages)}`, `User: ${formatTokens(stats.user)}`, `Assistant: ${formatTokens(stats.assistant)}`, `Tools: ${formatTokens(stats.toolCalls)} calls, ${formatTokens(stats.toolResults)} results`, "", "Tokens", ...tokens].join("\n");
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export async function openSessionLibrary(pi: ExtensionAPI, ctx: ExtensionCommandContext): Promise<void> {
|
|
95
|
-
if (ctx.mode !== "tui") return;
|
|
96
|
-
while (true) {
|
|
97
|
-
const currentPath = ctx.sessionManager.getSessionFile();
|
|
98
|
-
const available = await listSessions();
|
|
99
|
-
if (!available.length) { ctx.ui.notify("No persisted Pi sessions found.", "info"); return; }
|
|
100
|
-
const options = available.map((session) => `${sessionTitle(session)} — ${relativeTime(session.modified)} · ${session.messageCount} messages${session.path === currentPath ? " ● current" : ""}`);
|
|
101
|
-
const choice = await ctx.ui.select("Session Library", [...options, "Cancel"]);
|
|
102
|
-
if (!choice || choice === "Cancel") return;
|
|
103
|
-
const session = available[options.indexOf(choice)];
|
|
104
|
-
if (!session) continue;
|
|
105
|
-
if (await manageSession(pi, ctx, session, currentPath) === "switch") return;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async function manageSession(pi: ExtensionAPI, ctx: ExtensionCommandContext, initial: SessionInfo, currentPath: string | undefined): Promise<"back" | "switch"> {
|
|
110
|
-
let session = initial;
|
|
111
|
-
while (true) {
|
|
112
|
-
const current = session.path === currentPath;
|
|
113
|
-
const description = descriptionOf(session.path);
|
|
114
|
-
const stats = statisticsOf(session.path);
|
|
115
|
-
const actions = current ? ["Edit name", "Edit description", "Back"] : ["Reload in this window", "Edit name", "Edit description", "Delete session", "Back"];
|
|
116
|
-
const selected = await ctx.ui.select(detailTitle(session, current, description, stats), actions);
|
|
117
|
-
if (!selected || selected === "Back") return "back";
|
|
118
|
-
if (selected === "Edit name") {
|
|
119
|
-
const next = await ctx.ui.input("Session name", session.name || sessionTitle(session));
|
|
120
|
-
if (next?.trim()) { setSessionName(pi, ctx, session.path, current, next.trim()); ctx.ui.notify("Session name saved.", "info"); session = (await listSessions()).find((item) => item.path === session.path) || session; }
|
|
121
|
-
continue;
|
|
122
|
-
}
|
|
123
|
-
if (selected === "Edit description") {
|
|
124
|
-
const next = await ctx.ui.editor("Session description", description);
|
|
125
|
-
if (next !== undefined) { setSessionDescription(pi, ctx, session.path, current, next.trim()); ctx.ui.notify("Session description saved.", "info"); }
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
if (selected === "Reload in this window") {
|
|
129
|
-
await ctx.waitForIdle();
|
|
130
|
-
const result = await ctx.switchSession(session.path, { withSession: async (replacement) => replacement.ui.notify(`Reloaded: ${sessionTitle(session)}`, "info") });
|
|
131
|
-
return result.cancelled ? "back" : "switch";
|
|
132
|
-
}
|
|
133
|
-
if (selected === "Delete session") {
|
|
134
|
-
if (session.path === ctx.sessionManager.getSessionFile()) { ctx.ui.notify("The active session cannot be deleted.", "warning"); continue; }
|
|
135
|
-
const approved = await ctx.ui.confirm("Delete session?", `Permanently delete “${sessionTitle(session)}”? This cannot be undone.`);
|
|
136
|
-
if (!approved) continue;
|
|
137
|
-
if (!deleteSession(session.path, ctx.sessionManager.getSessionFile())) { ctx.ui.notify("The active or unavailable session cannot be deleted.", "warning"); continue; }
|
|
138
|
-
ctx.ui.notify("Session deleted.", "info");
|
|
139
|
-
return "back";
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
1
|
+
import { existsSync, rmSync } from "node:fs";
|
|
2
|
+
import { SessionManager, type ExtensionAPI, type ExtensionCommandContext, type SessionInfo } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
|
|
4
|
+
export const SESSION_DESCRIPTION_TYPE = "terra-session-description-v1";
|
|
5
|
+
export type SessionDescription = { text: string };
|
|
6
|
+
export type SessionStats = { user: number; assistant: number; toolCalls: number; toolResults: number; input: number; cacheRead: number; cacheWrite: number; output: number; hasUsage: boolean };
|
|
7
|
+
|
|
8
|
+
export function relativeTime(date: Date): string {
|
|
9
|
+
const seconds = Math.max(0, Math.floor((Date.now() - date.getTime()) / 1000));
|
|
10
|
+
if (seconds < 60) return "just now";
|
|
11
|
+
if (seconds < 3600) return `${Math.floor(seconds / 60)}m ago`;
|
|
12
|
+
if (seconds < 86400) return `${Math.floor(seconds / 3600)}h ago`;
|
|
13
|
+
return `${Math.floor(seconds / 86400)}d ago`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function sessionTitle(session: SessionInfo): string {
|
|
17
|
+
return session.name?.trim() || session.firstMessage.trim().replace(/\s+/g, " ").slice(0, 56) || "Untitled session";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function formatTokens(value: number): string {
|
|
21
|
+
return new Intl.NumberFormat("en-US").format(value);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function listSessions(): Promise<SessionInfo[]> {
|
|
25
|
+
return (await SessionManager.listAll()).sort((a, b) => b.modified.getTime() - a.modified.getTime());
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function descriptionOf(path: string): string {
|
|
29
|
+
try {
|
|
30
|
+
const entries = SessionManager.open(path).getEntries();
|
|
31
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
32
|
+
const entry = entries[i];
|
|
33
|
+
if (entry?.type !== "custom" || entry.customType !== SESSION_DESCRIPTION_TYPE) continue;
|
|
34
|
+
const data = entry.data as SessionDescription | undefined;
|
|
35
|
+
if (typeof data?.text === "string") return data.text;
|
|
36
|
+
}
|
|
37
|
+
} catch { /* A damaged historical session must not block the library. */ }
|
|
38
|
+
return "";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function statisticsOf(path: string): SessionStats {
|
|
42
|
+
const stats: SessionStats = { user: 0, assistant: 0, toolCalls: 0, toolResults: 0, input: 0, cacheRead: 0, cacheWrite: 0, output: 0, hasUsage: false };
|
|
43
|
+
try {
|
|
44
|
+
for (const entry of SessionManager.open(path).getEntries()) {
|
|
45
|
+
if (entry.type !== "message") continue;
|
|
46
|
+
const message = entry.message;
|
|
47
|
+
if (message.role === "user") stats.user++;
|
|
48
|
+
else if (message.role === "toolResult") stats.toolResults++;
|
|
49
|
+
else if (message.role === "assistant") {
|
|
50
|
+
stats.assistant++;
|
|
51
|
+
stats.toolCalls += message.content.filter((part) => part.type === "toolCall").length;
|
|
52
|
+
const usage = message.usage;
|
|
53
|
+
if (usage) {
|
|
54
|
+
stats.hasUsage = true;
|
|
55
|
+
stats.input += usage.input || 0;
|
|
56
|
+
stats.cacheRead += usage.cacheRead || 0;
|
|
57
|
+
stats.cacheWrite += usage.cacheWrite || 0;
|
|
58
|
+
stats.output += usage.output || 0;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
} catch { /* Zeroes communicate that unreadable historical data has no usable stats. */ }
|
|
63
|
+
return stats;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function setSessionName(pi: ExtensionAPI, ctx: ExtensionCommandContext, path: string, current: boolean, name: string): void {
|
|
67
|
+
if (current) pi.setSessionName(name);
|
|
68
|
+
else SessionManager.open(path).appendSessionInfo(name);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function setSessionDescription(pi: ExtensionAPI, ctx: ExtensionCommandContext, path: string, current: boolean, text: string): void {
|
|
72
|
+
const data = { text } satisfies SessionDescription;
|
|
73
|
+
if (current) pi.appendEntry(SESSION_DESCRIPTION_TYPE, data);
|
|
74
|
+
else SessionManager.open(path).appendCustomEntry(SESSION_DESCRIPTION_TYPE, data);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function deleteSession(path: string, activePath: string | undefined): boolean {
|
|
78
|
+
if (path === activePath || !path.endsWith(".jsonl") || !existsSync(path)) return false;
|
|
79
|
+
rmSync(path);
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function detailTitle(session: SessionInfo, current: boolean, description: string, stats: SessionStats): string {
|
|
84
|
+
const totalMessages = stats.user + stats.assistant + stats.toolResults;
|
|
85
|
+
const totalInput = stats.input + stats.cacheRead;
|
|
86
|
+
const totalTokens = totalInput + stats.output;
|
|
87
|
+
const cacheRate = totalInput ? ` (${((stats.cacheRead / totalInput) * 100).toFixed(1)}%)` : "";
|
|
88
|
+
const tokens = stats.hasUsage
|
|
89
|
+
? [`Input: ${formatTokens(totalInput)}`, ` Cached: ${formatTokens(stats.cacheRead)}${cacheRate}`, ` Uncached: ${formatTokens(stats.input)} (${formatTokens(stats.cacheWrite)} written to cache)`, `Output: ${formatTokens(stats.output)}`, `Total: ${formatTokens(totalTokens)}`]
|
|
90
|
+
: ["Usage data: —"];
|
|
91
|
+
return [current ? "Current session" : "Historical session", `Name: ${sessionTitle(session)}`, `Description: ${description || "—"}`, `Updated: ${relativeTime(session.modified)}`, `Workspace: ${session.cwd || "—"}`, "", "Messages", `Total: ${formatTokens(totalMessages)}`, `User: ${formatTokens(stats.user)}`, `Assistant: ${formatTokens(stats.assistant)}`, `Tools: ${formatTokens(stats.toolCalls)} calls, ${formatTokens(stats.toolResults)} results`, "", "Tokens", ...tokens].join("\n");
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export async function openSessionLibrary(pi: ExtensionAPI, ctx: ExtensionCommandContext): Promise<void> {
|
|
95
|
+
if (ctx.mode !== "tui") return;
|
|
96
|
+
while (true) {
|
|
97
|
+
const currentPath = ctx.sessionManager.getSessionFile();
|
|
98
|
+
const available = await listSessions();
|
|
99
|
+
if (!available.length) { ctx.ui.notify("No persisted Pi sessions found.", "info"); return; }
|
|
100
|
+
const options = available.map((session) => `${sessionTitle(session)} — ${relativeTime(session.modified)} · ${session.messageCount} messages${session.path === currentPath ? " ● current" : ""}`);
|
|
101
|
+
const choice = await ctx.ui.select("Session Library", [...options, "Cancel"]);
|
|
102
|
+
if (!choice || choice === "Cancel") return;
|
|
103
|
+
const session = available[options.indexOf(choice)];
|
|
104
|
+
if (!session) continue;
|
|
105
|
+
if (await manageSession(pi, ctx, session, currentPath) === "switch") return;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
async function manageSession(pi: ExtensionAPI, ctx: ExtensionCommandContext, initial: SessionInfo, currentPath: string | undefined): Promise<"back" | "switch"> {
|
|
110
|
+
let session = initial;
|
|
111
|
+
while (true) {
|
|
112
|
+
const current = session.path === currentPath;
|
|
113
|
+
const description = descriptionOf(session.path);
|
|
114
|
+
const stats = statisticsOf(session.path);
|
|
115
|
+
const actions = current ? ["Edit name", "Edit description", "Back"] : ["Reload in this window", "Edit name", "Edit description", "Delete session", "Back"];
|
|
116
|
+
const selected = await ctx.ui.select(detailTitle(session, current, description, stats), actions);
|
|
117
|
+
if (!selected || selected === "Back") return "back";
|
|
118
|
+
if (selected === "Edit name") {
|
|
119
|
+
const next = await ctx.ui.input("Session name", session.name || sessionTitle(session));
|
|
120
|
+
if (next?.trim()) { setSessionName(pi, ctx, session.path, current, next.trim()); ctx.ui.notify("Session name saved.", "info"); session = (await listSessions()).find((item) => item.path === session.path) || session; }
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (selected === "Edit description") {
|
|
124
|
+
const next = await ctx.ui.editor("Session description", description);
|
|
125
|
+
if (next !== undefined) { setSessionDescription(pi, ctx, session.path, current, next.trim()); ctx.ui.notify("Session description saved.", "info"); }
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (selected === "Reload in this window") {
|
|
129
|
+
await ctx.waitForIdle();
|
|
130
|
+
const result = await ctx.switchSession(session.path, { withSession: async (replacement) => replacement.ui.notify(`Reloaded: ${sessionTitle(session)}`, "info") });
|
|
131
|
+
return result.cancelled ? "back" : "switch";
|
|
132
|
+
}
|
|
133
|
+
if (selected === "Delete session") {
|
|
134
|
+
if (session.path === ctx.sessionManager.getSessionFile()) { ctx.ui.notify("The active session cannot be deleted.", "warning"); continue; }
|
|
135
|
+
const approved = await ctx.ui.confirm("Delete session?", `Permanently delete “${sessionTitle(session)}”? This cannot be undone.`);
|
|
136
|
+
if (!approved) continue;
|
|
137
|
+
if (!deleteSession(session.path, ctx.sessionManager.getSessionFile())) { ctx.ui.notify("The active or unavailable session cannot be deleted.", "warning"); continue; }
|
|
138
|
+
ctx.ui.notify("Session deleted.", "info");
|
|
139
|
+
return "back";
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
package/package.json
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "pi-arsenal",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "A
|
|
5
|
-
"type": "module",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"keywords": [
|
|
8
|
-
"pi-package",
|
|
9
|
-
"pi",
|
|
10
|
-
"pi-coding-agent",
|
|
11
|
-
"tui",
|
|
12
|
-
"workspace",
|
|
13
|
-
"skills",
|
|
14
|
-
"sessions"
|
|
15
|
-
],
|
|
16
|
-
"files": [
|
|
17
|
-
"extensions",
|
|
18
|
-
"lib",
|
|
19
|
-
"themes",
|
|
20
|
-
"README.md",
|
|
21
|
-
"LICENSE"
|
|
22
|
-
],
|
|
23
|
-
"peerDependencies": {
|
|
24
|
-
"@earendil-works/pi-ai": "*",
|
|
25
|
-
"@earendil-works/pi-coding-agent": "*",
|
|
26
|
-
"@earendil-works/pi-tui": "*"
|
|
27
|
-
},
|
|
28
|
-
"pi": {
|
|
29
|
-
"extensions": ["./extensions"],
|
|
30
|
-
"themes": ["./themes"]
|
|
31
|
-
},
|
|
32
|
-
"repository": {
|
|
33
|
-
"type": "git",
|
|
34
|
-
"url": "git+https://github.com/SeiyunSky/Pi-Arsenal.git"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "pi-arsenal",
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "A terminal control deck for Pi: workspaces, sessions, skills, MCP, tasks, theme, and splash.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"pi-package",
|
|
9
|
+
"pi",
|
|
10
|
+
"pi-coding-agent",
|
|
11
|
+
"tui",
|
|
12
|
+
"workspace",
|
|
13
|
+
"skills",
|
|
14
|
+
"sessions"
|
|
15
|
+
],
|
|
16
|
+
"files": [
|
|
17
|
+
"extensions",
|
|
18
|
+
"lib",
|
|
19
|
+
"themes",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@earendil-works/pi-ai": "*",
|
|
25
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
26
|
+
"@earendil-works/pi-tui": "*"
|
|
27
|
+
},
|
|
28
|
+
"pi": {
|
|
29
|
+
"extensions": ["./extensions"],
|
|
30
|
+
"themes": ["./themes"]
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/SeiyunSky/Pi-Arsenal.git"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,86 +1,86 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json",
|
|
3
|
-
"name": "tokyo-night-terra",
|
|
4
|
-
"vars": {
|
|
5
|
-
"bg": "#1a1b2e",
|
|
6
|
-
"surface": "#24283b",
|
|
7
|
-
"surfaceRaised": "#2f354f",
|
|
8
|
-
"selection": "#33467c",
|
|
9
|
-
"border": "#3b4261",
|
|
10
|
-
"muted": "#7a83a6",
|
|
11
|
-
"dim": "#565f89",
|
|
12
|
-
"text": "#c0caf5",
|
|
13
|
-
"terra": "#bb9af7",
|
|
14
|
-
"blue": "#7aa2f7",
|
|
15
|
-
"cyan": "#7dcfff",
|
|
16
|
-
"teal": "#73daca",
|
|
17
|
-
"green": "#9ece6a",
|
|
18
|
-
"yellow": "#e0af68",
|
|
19
|
-
"orange": "#ff9e64",
|
|
20
|
-
"red": "#f7768e",
|
|
21
|
-
"magenta": "#c099ff"
|
|
22
|
-
},
|
|
23
|
-
"colors": {
|
|
24
|
-
"accent": "terra",
|
|
25
|
-
"border": "border",
|
|
26
|
-
"borderAccent": "terra",
|
|
27
|
-
"borderMuted": "dim",
|
|
28
|
-
"success": "green",
|
|
29
|
-
"error": "red",
|
|
30
|
-
"warning": "yellow",
|
|
31
|
-
"muted": "muted",
|
|
32
|
-
"dim": "dim",
|
|
33
|
-
"text": "text",
|
|
34
|
-
"thinkingText": "muted",
|
|
35
|
-
"selectedBg": "selection",
|
|
36
|
-
"scrollbarTrack": "surface",
|
|
37
|
-
"scrollbarThumb": "blue",
|
|
38
|
-
"searchMatchBg": "yellow",
|
|
39
|
-
"searchMatchText": "bg",
|
|
40
|
-
"userMessageBg": "#20243a",
|
|
41
|
-
"userMessageText": "text",
|
|
42
|
-
"customMessageBg": "#28243d",
|
|
43
|
-
"customMessageText": "text",
|
|
44
|
-
"customMessageLabel": "terra",
|
|
45
|
-
"toolPendingBg": "#20273d",
|
|
46
|
-
"toolSuccessBg": "#1f302f",
|
|
47
|
-
"toolErrorBg": "#382536",
|
|
48
|
-
"toolTitle": "cyan",
|
|
49
|
-
"toolOutput": "muted",
|
|
50
|
-
"mdHeading": "terra",
|
|
51
|
-
"mdLink": "blue",
|
|
52
|
-
"mdLinkUrl": "dim",
|
|
53
|
-
"mdCode": "teal",
|
|
54
|
-
"mdCodeBlock": "text",
|
|
55
|
-
"mdCodeBlockBorder": "border",
|
|
56
|
-
"mdQuote": "muted",
|
|
57
|
-
"mdQuoteBorder": "blue",
|
|
58
|
-
"mdHr": "border",
|
|
59
|
-
"mdListBullet": "cyan",
|
|
60
|
-
"toolDiffAdded": "green",
|
|
61
|
-
"toolDiffRemoved": "red",
|
|
62
|
-
"toolDiffContext": "muted",
|
|
63
|
-
"syntaxComment": "dim",
|
|
64
|
-
"syntaxKeyword": "terra",
|
|
65
|
-
"syntaxFunction": "blue",
|
|
66
|
-
"syntaxVariable": "text",
|
|
67
|
-
"syntaxString": "green",
|
|
68
|
-
"syntaxNumber": "orange",
|
|
69
|
-
"syntaxType": "cyan",
|
|
70
|
-
"syntaxOperator": "teal",
|
|
71
|
-
"syntaxPunctuation": "muted",
|
|
72
|
-
"thinkingOff": "dim",
|
|
73
|
-
"thinkingMinimal": "muted",
|
|
74
|
-
"thinkingLow": "blue",
|
|
75
|
-
"thinkingMedium": "cyan",
|
|
76
|
-
"thinkingHigh": "terra",
|
|
77
|
-
"thinkingXhigh": "magenta",
|
|
78
|
-
"thinkingMax": "red",
|
|
79
|
-
"bashMode": "green"
|
|
80
|
-
},
|
|
81
|
-
"export": {
|
|
82
|
-
"pageBg": "#1a1b2e",
|
|
83
|
-
"cardBg": "#24283b",
|
|
84
|
-
"infoBg": "#2f2a42"
|
|
85
|
-
}
|
|
86
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/earendil-works/pi/main/packages/coding-agent/src/modes/interactive/theme/theme-schema.json",
|
|
3
|
+
"name": "tokyo-night-terra",
|
|
4
|
+
"vars": {
|
|
5
|
+
"bg": "#1a1b2e",
|
|
6
|
+
"surface": "#24283b",
|
|
7
|
+
"surfaceRaised": "#2f354f",
|
|
8
|
+
"selection": "#33467c",
|
|
9
|
+
"border": "#3b4261",
|
|
10
|
+
"muted": "#7a83a6",
|
|
11
|
+
"dim": "#565f89",
|
|
12
|
+
"text": "#c0caf5",
|
|
13
|
+
"terra": "#bb9af7",
|
|
14
|
+
"blue": "#7aa2f7",
|
|
15
|
+
"cyan": "#7dcfff",
|
|
16
|
+
"teal": "#73daca",
|
|
17
|
+
"green": "#9ece6a",
|
|
18
|
+
"yellow": "#e0af68",
|
|
19
|
+
"orange": "#ff9e64",
|
|
20
|
+
"red": "#f7768e",
|
|
21
|
+
"magenta": "#c099ff"
|
|
22
|
+
},
|
|
23
|
+
"colors": {
|
|
24
|
+
"accent": "terra",
|
|
25
|
+
"border": "border",
|
|
26
|
+
"borderAccent": "terra",
|
|
27
|
+
"borderMuted": "dim",
|
|
28
|
+
"success": "green",
|
|
29
|
+
"error": "red",
|
|
30
|
+
"warning": "yellow",
|
|
31
|
+
"muted": "muted",
|
|
32
|
+
"dim": "dim",
|
|
33
|
+
"text": "text",
|
|
34
|
+
"thinkingText": "muted",
|
|
35
|
+
"selectedBg": "selection",
|
|
36
|
+
"scrollbarTrack": "surface",
|
|
37
|
+
"scrollbarThumb": "blue",
|
|
38
|
+
"searchMatchBg": "yellow",
|
|
39
|
+
"searchMatchText": "bg",
|
|
40
|
+
"userMessageBg": "#20243a",
|
|
41
|
+
"userMessageText": "text",
|
|
42
|
+
"customMessageBg": "#28243d",
|
|
43
|
+
"customMessageText": "text",
|
|
44
|
+
"customMessageLabel": "terra",
|
|
45
|
+
"toolPendingBg": "#20273d",
|
|
46
|
+
"toolSuccessBg": "#1f302f",
|
|
47
|
+
"toolErrorBg": "#382536",
|
|
48
|
+
"toolTitle": "cyan",
|
|
49
|
+
"toolOutput": "muted",
|
|
50
|
+
"mdHeading": "terra",
|
|
51
|
+
"mdLink": "blue",
|
|
52
|
+
"mdLinkUrl": "dim",
|
|
53
|
+
"mdCode": "teal",
|
|
54
|
+
"mdCodeBlock": "text",
|
|
55
|
+
"mdCodeBlockBorder": "border",
|
|
56
|
+
"mdQuote": "muted",
|
|
57
|
+
"mdQuoteBorder": "blue",
|
|
58
|
+
"mdHr": "border",
|
|
59
|
+
"mdListBullet": "cyan",
|
|
60
|
+
"toolDiffAdded": "green",
|
|
61
|
+
"toolDiffRemoved": "red",
|
|
62
|
+
"toolDiffContext": "muted",
|
|
63
|
+
"syntaxComment": "dim",
|
|
64
|
+
"syntaxKeyword": "terra",
|
|
65
|
+
"syntaxFunction": "blue",
|
|
66
|
+
"syntaxVariable": "text",
|
|
67
|
+
"syntaxString": "green",
|
|
68
|
+
"syntaxNumber": "orange",
|
|
69
|
+
"syntaxType": "cyan",
|
|
70
|
+
"syntaxOperator": "teal",
|
|
71
|
+
"syntaxPunctuation": "muted",
|
|
72
|
+
"thinkingOff": "dim",
|
|
73
|
+
"thinkingMinimal": "muted",
|
|
74
|
+
"thinkingLow": "blue",
|
|
75
|
+
"thinkingMedium": "cyan",
|
|
76
|
+
"thinkingHigh": "terra",
|
|
77
|
+
"thinkingXhigh": "magenta",
|
|
78
|
+
"thinkingMax": "red",
|
|
79
|
+
"bashMode": "green"
|
|
80
|
+
},
|
|
81
|
+
"export": {
|
|
82
|
+
"pageBg": "#1a1b2e",
|
|
83
|
+
"cardBg": "#24283b",
|
|
84
|
+
"infoBg": "#2f2a42"
|
|
85
|
+
}
|
|
86
|
+
}
|