@code-yeongyu/senpi-codemode 2026.7.30 → 2026.7.31-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/CHANGELOG.md +39 -0
- package/package.json +3 -3
- package/src/extension/eval-status-ticker.ts +79 -0
- package/src/extension/eval-status.ts +36 -3
- package/src/index.ts +26 -12
- package/src/tool/detached-cell-manager.ts +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,45 @@
|
|
|
12
12
|
|
|
13
13
|
### Removed
|
|
14
14
|
|
|
15
|
+
## [2026.7.31-2] - 2026-07-31
|
|
16
|
+
|
|
17
|
+
### Breaking Changes
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- Include a live elapsed label in detached `eval` footer status. The ticker updates only when the rendered duration
|
|
24
|
+
changes and is disposed when the cell completes, fails, or is stopped.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
### Removed
|
|
29
|
+
|
|
30
|
+
## [2026.7.31] - 2026-07-31
|
|
31
|
+
|
|
32
|
+
### Breaking Changes
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
|
|
38
|
+
### Fixed
|
|
39
|
+
|
|
40
|
+
### Removed
|
|
41
|
+
|
|
42
|
+
## [2026.7.30-2] - 2026-07-30
|
|
43
|
+
|
|
44
|
+
### Breaking Changes
|
|
45
|
+
|
|
46
|
+
### Added
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
|
|
50
|
+
### Fixed
|
|
51
|
+
|
|
52
|
+
### Removed
|
|
53
|
+
|
|
15
54
|
## [2026.7.30] - 2026-07-30
|
|
16
55
|
|
|
17
56
|
### Breaking Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-yeongyu/senpi-codemode",
|
|
3
|
-
"version": "2026.7.
|
|
3
|
+
"version": "2026.7.31-2",
|
|
4
4
|
"description": "Source-only senpi extension package for codemode evaluation tools",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@babel/parser": "8.0.4",
|
|
33
|
-
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@^2026.7.
|
|
33
|
+
"@earendil-works/pi-ai": "npm:@code-yeongyu/senpi-ai@^2026.7.31-2",
|
|
34
34
|
"typebox": "1.3.8"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@code-yeongyu/senpi": "*"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@code-yeongyu/senpi": "2026.7.
|
|
40
|
+
"@code-yeongyu/senpi": "2026.7.31-2"
|
|
41
41
|
},
|
|
42
42
|
"keywords": [
|
|
43
43
|
"senpi",
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { EvalDetachedCellStatusEntry } from "../tool/detached-cell-manager.ts";
|
|
2
|
+
import { formatEvalCellStatus } from "./eval-status.ts";
|
|
3
|
+
|
|
4
|
+
/** Footer live-elapsed refresh cadence while at least one detached cell is running. */
|
|
5
|
+
export const EVAL_STATUS_TICK_INTERVAL_MS = 1000;
|
|
6
|
+
|
|
7
|
+
/** Receives the freshly formatted footer status text (undefined clears the status). */
|
|
8
|
+
export type EvalStatusRender = (status: string | undefined) => void;
|
|
9
|
+
|
|
10
|
+
export interface EvalStatusTickerOptions {
|
|
11
|
+
readonly render: EvalStatusRender;
|
|
12
|
+
/** Injectable clock for tests; defaults to Date.now. */
|
|
13
|
+
readonly now?: () => number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Drives a once-per-second footer refresh while detached eval cells are running so
|
|
18
|
+
* the "↗ py · … (Ns)" elapsed label advances live instead of freezing between
|
|
19
|
+
* cell-set transitions. Same shape as the terminal builtin's MonitorStatusTicker:
|
|
20
|
+
* the interval is unref'd, and ticks producing the already-rendered label are skipped.
|
|
21
|
+
*/
|
|
22
|
+
export class EvalStatusTicker {
|
|
23
|
+
private readonly render: EvalStatusRender;
|
|
24
|
+
private readonly now: () => number;
|
|
25
|
+
private intervalId: NodeJS.Timeout | undefined;
|
|
26
|
+
private entries: readonly EvalDetachedCellStatusEntry[] = [];
|
|
27
|
+
private lastRenderedStatus: string | undefined;
|
|
28
|
+
private hasRendered = false;
|
|
29
|
+
|
|
30
|
+
constructor(options: EvalStatusTickerOptions) {
|
|
31
|
+
this.render = options.render;
|
|
32
|
+
this.now = options.now ?? Date.now;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
get running(): boolean {
|
|
36
|
+
return this.intervalId !== undefined;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Point the ticker at the current detached-cell set, render once immediately,
|
|
41
|
+
* and start the interval while cells are live (or stop it when none remain).
|
|
42
|
+
*/
|
|
43
|
+
sync(entries: readonly EvalDetachedCellStatusEntry[]): void {
|
|
44
|
+
this.entries = entries;
|
|
45
|
+
this.hasRendered = false;
|
|
46
|
+
this.tick();
|
|
47
|
+
if (entries.length === 0) {
|
|
48
|
+
this.stopInterval();
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (this.intervalId !== undefined) return;
|
|
52
|
+
const handle = setInterval(() => this.tick(), EVAL_STATUS_TICK_INTERVAL_MS);
|
|
53
|
+
handle.unref();
|
|
54
|
+
this.intervalId = handle;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Stop the interval and drop the retained entries. */
|
|
58
|
+
stop(): void {
|
|
59
|
+
this.stopInterval();
|
|
60
|
+
this.entries = [];
|
|
61
|
+
this.lastRenderedStatus = undefined;
|
|
62
|
+
this.hasRendered = false;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private stopInterval(): void {
|
|
66
|
+
if (this.intervalId !== undefined) {
|
|
67
|
+
clearInterval(this.intervalId);
|
|
68
|
+
this.intervalId = undefined;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
private tick(): void {
|
|
73
|
+
const status = formatEvalCellStatus(this.entries, this.now());
|
|
74
|
+
if (this.hasRendered && status === this.lastRenderedStatus) return;
|
|
75
|
+
this.hasRendered = true;
|
|
76
|
+
this.lastRenderedStatus = status;
|
|
77
|
+
this.render(status);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -31,14 +31,47 @@ function labelOf(entry: EvalDetachedCellStatusEntry): string {
|
|
|
31
31
|
return entry.title === undefined || entry.title.length === 0 ? entry.cellId : entry.title;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Goal-style compact elapsed label (`5s`, `3m`, `2h 30m`, `1d 2h 3m`). Mirrors
|
|
36
|
+
* the monitor builtin's formatElapsedSeconds; kept local like the rest of the
|
|
37
|
+
* duplicated status-file helpers between the two packages.
|
|
38
|
+
*/
|
|
39
|
+
export function formatElapsedSeconds(value: number): string {
|
|
40
|
+
const seconds = Math.max(0, Math.trunc(value));
|
|
41
|
+
if (seconds < 60) return `${seconds}s`;
|
|
42
|
+
const minutes = Math.trunc(seconds / 60);
|
|
43
|
+
if (minutes < 60) return `${minutes}m`;
|
|
44
|
+
const hours = Math.trunc(minutes / 60);
|
|
45
|
+
const remainingMinutes = minutes % 60;
|
|
46
|
+
if (hours >= 24) {
|
|
47
|
+
const days = Math.trunc(hours / 24);
|
|
48
|
+
const remainingHours = hours % 24;
|
|
49
|
+
return `${days}d ${remainingHours}h ${remainingMinutes}m`;
|
|
50
|
+
}
|
|
51
|
+
if (remainingMinutes === 0) return `${hours}h`;
|
|
52
|
+
return `${hours}h ${remainingMinutes}m`;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Whole seconds since the oldest detached cell was created; never negative on clock skew. */
|
|
56
|
+
export function evalCellElapsedSeconds(entries: readonly EvalDetachedCellStatusEntry[], nowMs: number): number {
|
|
57
|
+
let oldest = Number.POSITIVE_INFINITY;
|
|
58
|
+
for (const entry of entries) oldest = Math.min(oldest, entry.startedAtMs);
|
|
59
|
+
if (!Number.isFinite(oldest)) return 0;
|
|
60
|
+
return Math.max(0, Math.round((nowMs - oldest) / 1000));
|
|
61
|
+
}
|
|
62
|
+
|
|
34
63
|
/** Brief footer text for the cells still running detached; undefined clears the status. */
|
|
35
|
-
export function formatEvalCellStatus(
|
|
64
|
+
export function formatEvalCellStatus(
|
|
65
|
+
entries: readonly EvalDetachedCellStatusEntry[],
|
|
66
|
+
nowMs: number,
|
|
67
|
+
): string | undefined {
|
|
36
68
|
const first = entries[0];
|
|
37
69
|
if (first === undefined) return undefined;
|
|
70
|
+
const suffix = ` (${formatElapsedSeconds(evalCellElapsedSeconds(entries, nowMs))})`;
|
|
38
71
|
if (entries.length === 1) {
|
|
39
72
|
const head = `${DETACHED_GLYPH} ${first.language} · `;
|
|
40
|
-
return head + truncateEnd(labelOf(first), MAX_STATUS_LENGTH - head.length);
|
|
73
|
+
return head + truncateEnd(labelOf(first), MAX_STATUS_LENGTH - head.length - suffix.length) + suffix;
|
|
41
74
|
}
|
|
42
75
|
const head = `${DETACHED_GLYPH} eval ${entries.length}: `;
|
|
43
|
-
return head + packLabels(entries.map(labelOf), MAX_STATUS_LENGTH - head.length);
|
|
76
|
+
return head + packLabels(entries.map(labelOf), MAX_STATUS_LENGTH - head.length - suffix.length) + suffix;
|
|
44
77
|
}
|
package/src/index.ts
CHANGED
|
@@ -5,7 +5,8 @@ import type { EvalSchemaToolInfo } from "./bridges/schema-bridge.ts";
|
|
|
5
5
|
import { type CompletionRequest, type CompletionResult, createCompletionHandler } from "./completion/handler.ts";
|
|
6
6
|
import { defaultCodemodeSettings } from "./config/settings.ts";
|
|
7
7
|
import { EvalNotifier } from "./extension/eval-notifier.ts";
|
|
8
|
-
import { EVAL_CELLS_STATUS_KEY
|
|
8
|
+
import { EVAL_CELLS_STATUS_KEY } from "./extension/eval-status.ts";
|
|
9
|
+
import { EvalStatusTicker } from "./extension/eval-status-ticker.ts";
|
|
9
10
|
import {
|
|
10
11
|
createExecuteTool,
|
|
11
12
|
createRuntime,
|
|
@@ -44,6 +45,8 @@ export interface SenpiCodemodeOptions {
|
|
|
44
45
|
options: CreateCodemodeSessionManagerOptions,
|
|
45
46
|
) => CodemodeSessionManager | Promise<CodemodeSessionManager>;
|
|
46
47
|
readonly complete?: (request: CompletionRequest, ctx: ExtensionContext) => Promise<CompletionResult>;
|
|
48
|
+
/** Injectable clock for detached-cell elapsed labels; defaults to Date.now. */
|
|
49
|
+
readonly now?: () => number;
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
export default function senpiCodemode(pi: CodemodeExtensionAPI, options: SenpiCodemodeOptions = {}): void {
|
|
@@ -59,17 +62,22 @@ export default function senpiCodemode(pi: CodemodeExtensionAPI, options: SenpiCo
|
|
|
59
62
|
getContext: () => activeContext,
|
|
60
63
|
getMode: () => "wake",
|
|
61
64
|
});
|
|
65
|
+
const statusTicker = new EvalStatusTicker({
|
|
66
|
+
...(options.now === undefined ? {} : { now: options.now }),
|
|
67
|
+
render: (status) => {
|
|
68
|
+
const ctx = activeContext;
|
|
69
|
+
if (ctx?.ui?.setStatus === undefined) return;
|
|
70
|
+
const theme = ctx.ui.theme;
|
|
71
|
+
ctx.ui.setStatus(
|
|
72
|
+
EVAL_CELLS_STATUS_KEY,
|
|
73
|
+
status === undefined || ctx.mode !== "tui" || theme === undefined
|
|
74
|
+
? status
|
|
75
|
+
: theme.bg("selectedBg", theme.fg("text", status)),
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
});
|
|
62
79
|
const showDetachedCells = (entries: readonly EvalDetachedCellStatusEntry[]): void => {
|
|
63
|
-
|
|
64
|
-
if (ctx?.ui?.setStatus === undefined) return;
|
|
65
|
-
const status = formatEvalCellStatus(entries);
|
|
66
|
-
const theme = ctx.ui.theme;
|
|
67
|
-
ctx.ui.setStatus(
|
|
68
|
-
EVAL_CELLS_STATUS_KEY,
|
|
69
|
-
status === undefined || ctx.mode !== "tui" || theme === undefined
|
|
70
|
-
? status
|
|
71
|
-
: theme.bg("selectedBg", theme.fg("text", status)),
|
|
72
|
-
);
|
|
80
|
+
statusTicker.sync(entries);
|
|
73
81
|
};
|
|
74
82
|
const registerEvalForRuntime = (
|
|
75
83
|
runtime: SessionRuntime,
|
|
@@ -101,6 +109,7 @@ export default function senpiCodemode(pi: CodemodeExtensionAPI, options: SenpiCo
|
|
|
101
109
|
activeRuntime = undefined;
|
|
102
110
|
activeModelId = undefined;
|
|
103
111
|
activeCells = undefined;
|
|
112
|
+
statusTicker.stop();
|
|
104
113
|
await cells?.dispose();
|
|
105
114
|
activeContext = undefined;
|
|
106
115
|
await manager.dispose();
|
|
@@ -114,7 +123,11 @@ export default function senpiCodemode(pi: CodemodeExtensionAPI, options: SenpiCo
|
|
|
114
123
|
listTools: () => pi.getAllTools(),
|
|
115
124
|
complete,
|
|
116
125
|
settings: defaultCodemodeSettings,
|
|
117
|
-
cellManager: new EvalDetachedCellManager({
|
|
126
|
+
cellManager: new EvalDetachedCellManager({
|
|
127
|
+
notifier,
|
|
128
|
+
onStatusChange: showDetachedCells,
|
|
129
|
+
...(options.now === undefined ? {} : { now: options.now }),
|
|
130
|
+
}),
|
|
118
131
|
executionTracker: manager,
|
|
119
132
|
renderers,
|
|
120
133
|
hostLine: hostLine(),
|
|
@@ -143,6 +156,7 @@ export default function senpiCodemode(pi: CodemodeExtensionAPI, options: SenpiCo
|
|
|
143
156
|
artifactsDir: runtime.artifactsDir,
|
|
144
157
|
notifier,
|
|
145
158
|
onStatusChange: showDetachedCells,
|
|
159
|
+
...(options.now === undefined ? {} : { now: options.now }),
|
|
146
160
|
});
|
|
147
161
|
activeCells = cellManager;
|
|
148
162
|
activeRuntime = runtime;
|
|
@@ -11,6 +11,7 @@ type ManagedCell = {
|
|
|
11
11
|
readonly cellId: string;
|
|
12
12
|
readonly input: EvalToolInput;
|
|
13
13
|
readonly spillPath: string | undefined;
|
|
14
|
+
readonly startedAtMs: number;
|
|
14
15
|
state: EvalDetachedCellState;
|
|
15
16
|
canDetach: boolean;
|
|
16
17
|
wasDetached: boolean;
|
|
@@ -46,6 +47,8 @@ export interface EvalDetachedCellStatusEntry {
|
|
|
46
47
|
readonly cellId: string;
|
|
47
48
|
readonly language: EvalLanguage;
|
|
48
49
|
readonly title?: string;
|
|
50
|
+
/** Epoch milliseconds when the cell was created; feeds the footer's live elapsed label. */
|
|
51
|
+
readonly startedAtMs: number;
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
export interface EvalDetachedCellManagerOptions {
|
|
@@ -53,6 +56,8 @@ export interface EvalDetachedCellManagerOptions {
|
|
|
53
56
|
readonly notifier?: EvalDetachedCellNotifier;
|
|
54
57
|
/** Called with every detached cell whenever that set changes; empty clears the status. */
|
|
55
58
|
readonly onStatusChange?: (entries: readonly EvalDetachedCellStatusEntry[]) => void;
|
|
59
|
+
/** Injectable clock for tests; defaults to Date.now. */
|
|
60
|
+
readonly now?: () => number;
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
/**
|
|
@@ -68,6 +73,7 @@ export class EvalDetachedCellManager {
|
|
|
68
73
|
readonly #onStatusChange: ((entries: readonly EvalDetachedCellStatusEntry[]) => void) | undefined;
|
|
69
74
|
readonly #cells = new Map<string, ManagedCell>();
|
|
70
75
|
readonly #detachedByLanguage = new Map<EvalLanguage, ManagedCell>();
|
|
76
|
+
readonly #now: () => number;
|
|
71
77
|
#notificationQueue: ManagedCell[] = [];
|
|
72
78
|
#notificationFlush: Promise<void> | undefined;
|
|
73
79
|
|
|
@@ -75,6 +81,7 @@ export class EvalDetachedCellManager {
|
|
|
75
81
|
this.#artifactsDir = options.artifactsDir;
|
|
76
82
|
this.#notifier = options.notifier;
|
|
77
83
|
this.#onStatusChange = options.onStatusChange;
|
|
84
|
+
this.#now = options.now ?? Date.now;
|
|
78
85
|
}
|
|
79
86
|
|
|
80
87
|
create(cellId: string, input: EvalToolInput): ManagedCell {
|
|
@@ -91,6 +98,7 @@ export class EvalDetachedCellManager {
|
|
|
91
98
|
cellId,
|
|
92
99
|
input,
|
|
93
100
|
spillPath,
|
|
101
|
+
startedAtMs: this.#now(),
|
|
94
102
|
state: "running",
|
|
95
103
|
canDetach: false,
|
|
96
104
|
wasDetached: false,
|
|
@@ -189,6 +197,7 @@ export class EvalDetachedCellManager {
|
|
|
189
197
|
[...this.#detachedByLanguage.values()].map((cell) => ({
|
|
190
198
|
cellId: cell.cellId,
|
|
191
199
|
language: cell.input.language,
|
|
200
|
+
startedAtMs: cell.startedAtMs,
|
|
192
201
|
...(cell.input.title === undefined ? {} : { title: cell.input.title }),
|
|
193
202
|
})),
|
|
194
203
|
);
|