pi-thread-engine 0.2.0 → 0.2.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/extensions/index.ts +2 -6
- package/package.json +8 -6
- package/src/core/registry.ts +8 -1
- package/src/dashboard.ts +1 -5
package/extensions/index.ts
CHANGED
|
@@ -34,7 +34,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
34
34
|
pi.on("session_start", async (_event, ctx) => {
|
|
35
35
|
for (const entry of ctx.sessionManager.getEntries()) {
|
|
36
36
|
if (entry.type === "custom" && entry.customType === "pi-threads-state") {
|
|
37
|
-
const data = entry.data as
|
|
37
|
+
const data = entry.data as { threads?: Thread[]; stories?: Story[]; timestamp?: number };
|
|
38
38
|
if (data?.threads) {
|
|
39
39
|
registry.restore(data.threads, data.stories ?? []);
|
|
40
40
|
}
|
|
@@ -88,10 +88,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
88
88
|
return tasks;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
function pad(s: string, n: number): string {
|
|
92
|
-
return s.length >= n ? s.slice(0, n) : s + " ".repeat(n - s.length);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
91
|
function stateIcon(state: string): string {
|
|
96
92
|
switch (state) {
|
|
97
93
|
case "running": return "⟳";
|
|
@@ -515,7 +511,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
515
511
|
? `Fusion: ${prompts[0]?.slice(0, 40)}`
|
|
516
512
|
: `${type}: ${taskPrompts.length} tasks`;
|
|
517
513
|
|
|
518
|
-
const thread = registry.create(type as
|
|
514
|
+
const thread = registry.create(type as ThreadType, label, taskPrompts, {
|
|
519
515
|
models,
|
|
520
516
|
cwd: ctx.cwd,
|
|
521
517
|
backend,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-thread-engine",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Thread engineering for pi — all 7 thread types, stories, fusion, zero-touch, TUI dashboard",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
"orchestration"
|
|
20
20
|
],
|
|
21
21
|
"pi": {
|
|
22
|
-
"extensions": [
|
|
22
|
+
"extensions": [
|
|
23
|
+
"./extensions/index.ts"
|
|
24
|
+
]
|
|
23
25
|
},
|
|
24
26
|
"files": [
|
|
25
27
|
"extensions/",
|
|
@@ -28,9 +30,9 @@
|
|
|
28
30
|
"PLAN.md"
|
|
29
31
|
],
|
|
30
32
|
"peerDependencies": {
|
|
31
|
-
"@mariozechner/pi-
|
|
32
|
-
"@mariozechner/pi-
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
33
|
+
"@mariozechner/pi-ai": "^0.56.0",
|
|
34
|
+
"@mariozechner/pi-coding-agent": "^0.56.0",
|
|
35
|
+
"@mariozechner/pi-tui": "^0.56.0",
|
|
36
|
+
"@sinclair/typebox": "^0.34.48"
|
|
35
37
|
}
|
|
36
38
|
}
|
package/src/core/registry.ts
CHANGED
|
@@ -47,7 +47,9 @@ export class ThreadRegistry {
|
|
|
47
47
|
for (const h of this.handlers) {
|
|
48
48
|
try {
|
|
49
49
|
h(event);
|
|
50
|
-
} catch {
|
|
50
|
+
} catch (e) {
|
|
51
|
+
console.error("[pi-threads] event handler error:", e);
|
|
52
|
+
}
|
|
51
53
|
}
|
|
52
54
|
}
|
|
53
55
|
|
|
@@ -213,9 +215,14 @@ export class ThreadRegistry {
|
|
|
213
215
|
restore(threads: Thread[], stories: Story[]) {
|
|
214
216
|
for (const t of threads) {
|
|
215
217
|
this.threads.set(t.id, t);
|
|
218
|
+
// Advance ID counter past restored IDs to avoid collisions
|
|
219
|
+
const num = parseInt(t.id.replace("t-", ""), 10);
|
|
220
|
+
if (!isNaN(num) && num >= nextThreadId) nextThreadId = num + 1;
|
|
216
221
|
}
|
|
217
222
|
for (const s of stories) {
|
|
218
223
|
this.stories.set(s.id, s);
|
|
224
|
+
const num = parseInt(s.id.replace("s-", ""), 10);
|
|
225
|
+
if (!isNaN(num) && num >= nextStoryId) nextStoryId = num + 1;
|
|
219
226
|
}
|
|
220
227
|
}
|
|
221
228
|
|
package/src/dashboard.ts
CHANGED
|
@@ -4,10 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Keys: ↑↓ navigate, Enter expand, k kill, r review, p prune, q/Esc close
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import { DynamicBorder } from "@mariozechner/pi-coding-agent";
|
|
7
|
+
import { matchesKey, Key, truncateToWidth } from "@mariozechner/pi-tui";
|
|
9
8
|
import type { ThreadRegistry } from "./core/registry.js";
|
|
10
|
-
import type { Thread, Story, ThreadSummary } from "./core/types.js";
|
|
11
9
|
|
|
12
10
|
export interface DashboardTheme {
|
|
13
11
|
fg: (color: string, text: string) => string;
|
|
@@ -32,7 +30,6 @@ export function createDashboard(
|
|
|
32
30
|
let expanded: string | null = null;
|
|
33
31
|
let rows: DashboardRow[] = [];
|
|
34
32
|
let cachedWidth: number | undefined;
|
|
35
|
-
let cachedLines: string[] | undefined;
|
|
36
33
|
|
|
37
34
|
function stateIcon(state: string): string {
|
|
38
35
|
switch (state) {
|
|
@@ -215,7 +212,6 @@ export function createDashboard(
|
|
|
215
212
|
|
|
216
213
|
invalidate() {
|
|
217
214
|
cachedWidth = undefined;
|
|
218
|
-
cachedLines = undefined;
|
|
219
215
|
},
|
|
220
216
|
};
|
|
221
217
|
|