pantheon-opencode 1.3.6 → 1.4.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/opencode.json +2 -1
- package/package.json +1 -1
- package/scripts/install/opencode.mjs +2 -0
- package/scripts/sync-tui.mjs +148 -0
- package/src/mcp/mcp_codemap_module.py +185 -0
- package/src/mcp/memory_mcp_server.py +91 -3
- package/src/pantheon/command-normalizer.ts +101 -0
- package/src/pantheon/context-sandbox.ts +273 -0
- package/src/pantheon/delegation-notify.ts +97 -0
- package/src/pantheon/delegation.ts +10 -0
- package/src/pantheon/tui-version-check.ts +72 -0
- package/src/plugin.ts +76 -2
- package/src/plugins/tui/dist/tui.d.ts +18 -3
- package/src/plugins/tui/dist/tui.d.ts.map +1 -1
- package/src/plugins/tui/dist/tui.js +42 -10
- package/src/plugins/tui/dist/tui.tsx +69 -17
- package/src/plugins/tui/package.json +1 -1
- package/src/plugins/tui/src/index.tsx +69 -17
- package/src/skills/codemap/SKILL.md +7 -0
- package/src/skills/context-compression/SKILL.md +39 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tui.d.ts","names":[],"sources":["../src/index.tsx"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"tui.d.ts","names":[],"sources":["../src/index.tsx"],"mappings":";;KAy6BY;;EAEV;;EAEA;;;;EAIA;;EAEA;EACA;;EASA;;EAEA;EACA;EACA;;EAEA;;;;EAIA;;;;;;;;;;;iBAsBc,wBACd,aACA,oBACA,qBACC;;;;;;iBAkHmB,sBAAsB,cAAc,QAAQ;;;;;;;;iBAwC5C,yBAAyB,eAAe,QAAQ;;;;;;;;iBAWtD,sBACd;EAAS;EAAoB;eAC7B;;;;;;iBAYc,YAAY;;;iBAMZ,WAAW;;;;iBAOX,yBAAyB,GAAG,iBAAiB,GAAG;;;;;iBAWhD,sBACd,cAAc,mBACd,sBACA,cACA,4BACC;;cASU;;;;cAKA;;;;;;;;;iBAUG,mBACd,OAAO,iBACP,aACA,uBACC;;;iBAWa,WAAW;;;iBAcX,kBAAkB,OAAO,iBAAiB;;;KAQ9C;iBAQI,mBAAmB,OAAO,kBAAkB;iBAc5C,wBAAwB,OAAO;;iBAoB/B,uBAAuB;;;;;;;iBAWvB,4BACd,mBAAmB,mBACnB,eAAe,wBACd;;KAmFS;EACV;EACA;EACA;EACA;EACA;EACA;IACE;IACA,QAAQ;IACR;IACA;IACA;MAAS;MAAgB;;;;;KAKjB;;EAEV;;EAEA;;EAEA;EACA;;EAEA;EACA;;EAEA;;EAEA;EACA;EACA;EACA;;EAEA;;;KAIU;EACV;EACA;EACA;EACA;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA;;;;;iBAac,wBACd,MAAM,oBACN,eACC;;;iBA+Ea,yBACd,KAAK,YAAY,sBACjB,MAAM,oBACN;;;iBA+Fc,sBACd,KAAK,YAAY,sBACjB;;;;;;iBAiBc,2BACd;EAAqB;EAAa;iBAClC,YAAY,uDACX;;;;;iBA2Ba,sBACd,KAAK,YAAY,sBACjB,gBAAgB,sBAChB;;;iBAWc,kBAAkB,MAAM,sBAAsB;;;;;;iBAqB9C,uBACd,eAAe,uBACf,aAAa,oBACZ;;;;;;;;;iBA8Da,iBAAiB,cAAc;;;;KAOnC;;EAEV;EACA;;IAEE;MAAU;;;IAEV;MAAU;QAAY;QAAe,SAAS;;;;;;;;;;iBASlC,wBAAwB,SAAS;;;;;;;;iBAmBjC,gBAAgB;EAAgB;IAAQ;;;;;;;iBASxC,kBAAkB;EAAkC;IAAQ;;;;KAKhE;;EAEV;;EAEA;;;EAGA;;;EAGA;EACA;IACE;IACA;;;;;;;iBAQY,mBAAmB;;;;;iBASnB,cAAc,OAAO;;;;;;;;;;;;;;iBAiBrB,4BACd,mBAAmB,mCACnB,aAAa,mBACb,eACC;;;;;;iBA0Ca,4BACd;EAAS,YAAY,cAAc,SAAS;eAC5C;;;;;KAiLU;EACV,KAAK,YAAY;;EAEjB;;EAEA;;cAucI,QAAQ;EAAoB"}
|
|
@@ -120,8 +120,14 @@ async function resolvePresetForTui(env, cwd) {
|
|
|
120
120
|
}
|
|
121
121
|
async function detectVersion(api) {
|
|
122
122
|
try {
|
|
123
|
-
const
|
|
124
|
-
|
|
123
|
+
const pkgContent = await readFile(fileURLToPath(new URL("../../package.json", import.meta.url)), "utf8");
|
|
124
|
+
const pkg = JSON.parse(pkgContent);
|
|
125
|
+
if (pkg.version) return pkg.version;
|
|
126
|
+
} catch {}
|
|
127
|
+
try {
|
|
128
|
+
const pkgContent = await readFile(fileURLToPath(new URL("../../../../package.json", import.meta.url)), "utf8");
|
|
129
|
+
const pkg = JSON.parse(pkgContent);
|
|
130
|
+
if (pkg.version) return pkg.version;
|
|
125
131
|
} catch {}
|
|
126
132
|
try {
|
|
127
133
|
const wt = api.state.path?.worktree ?? "";
|
|
@@ -765,7 +771,8 @@ function parseDelegationMarkdown(raw, fileAlias, sessionID = "") {
|
|
|
765
771
|
const startedAt = started !== void 0 ? Date.parse(started) : NaN;
|
|
766
772
|
if (agent === void 0 || state === void 0 || Number.isNaN(startedAt)) return null;
|
|
767
773
|
const normalized = state.toLowerCase();
|
|
768
|
-
if (normalized
|
|
774
|
+
if (normalized === "running") return null;
|
|
775
|
+
if (normalized !== "completed" && normalized !== "error" && normalized !== "startup_failed" && normalized !== "startup_unknown" && normalized !== "cancelled") return null;
|
|
769
776
|
const finalizedAt = finalized !== void 0 ? Date.parse(finalized) : NaN;
|
|
770
777
|
return {
|
|
771
778
|
alias: title ?? (fileAlias !== void 0 ? stripMdSuffix(fileAlias) : "unknown"),
|
|
@@ -861,8 +868,8 @@ function tuiLogPath(projectRoot) {
|
|
|
861
868
|
* falling back to startedAt, descending). Shared by the md reader and
|
|
862
869
|
* mergeDelegationSources. */
|
|
863
870
|
function compareDelegationEntries(a, b) {
|
|
864
|
-
const aRun = a.state === "running" ? 1 : 0;
|
|
865
|
-
const bRun = b.state === "running" ? 1 : 0;
|
|
871
|
+
const aRun = a.state === "running" || a.state === "stale-running" ? 1 : 0;
|
|
872
|
+
const bRun = b.state === "running" || b.state === "stale-running" ? 1 : 0;
|
|
866
873
|
if (aRun !== bRun) return bRun - aRun;
|
|
867
874
|
return (b.updatedAt ?? b.startedAt) - (a.updatedAt ?? a.startedAt);
|
|
868
875
|
}
|
|
@@ -870,11 +877,34 @@ function compareDelegationEntries(a, b) {
|
|
|
870
877
|
* recent terminal reports (capped). Pure — so the history-only panel (no
|
|
871
878
|
* sessionID) is testable without the TUI runtime. The header count uses the
|
|
872
879
|
* same "running + recentes" list. */
|
|
873
|
-
function visibleDelegationList(all, maxTerminal = 8) {
|
|
874
|
-
const running = all.filter((d) => d.state === "running");
|
|
880
|
+
function visibleDelegationList(all, maxTerminal = 8, now = Date.now(), staleThresholdMs = 1800 * 1e3) {
|
|
881
|
+
const running = all.filter((d) => d.state === "running").map((d) => markStaleIfRunning(d, now, staleThresholdMs));
|
|
875
882
|
const terminal = all.filter((d) => d.state !== "running").slice(0, maxTerminal);
|
|
876
883
|
return [...running, ...terminal];
|
|
877
884
|
}
|
|
885
|
+
/** Default stale-running threshold: 30 minutes. */
|
|
886
|
+
const STALE_RUNNING_THRESHOLD_MS = 1800 * 1e3;
|
|
887
|
+
/** Idle silence window: if no updatedAt change in this window, the entry is
|
|
888
|
+
* considered stale. Combined with the stale-running threshold to produce the
|
|
889
|
+
* display-only `stale-running` state. */
|
|
890
|
+
const IDLE_SILENCE_MS = 60 * 1e3;
|
|
891
|
+
/**
|
|
892
|
+
* Mark a running entry as `stale-running` if it has been running longer than
|
|
893
|
+
* the threshold AND has no recent activity (no `updatedAt` change in the last
|
|
894
|
+
* `IDLE_SILENCE_MS`). This is DISPLAY-ONLY — the board state is unchanged.
|
|
895
|
+
*
|
|
896
|
+
* A `stale-running` entry renders with a warning indicator but the underlying
|
|
897
|
+
* delegation is still treated as running by the backend.
|
|
898
|
+
*/
|
|
899
|
+
function markStaleIfRunning(entry, now, thresholdMs = STALE_RUNNING_THRESHOLD_MS) {
|
|
900
|
+
if (entry.state !== "running") return entry;
|
|
901
|
+
if (now - entry.startedAt < thresholdMs) return entry;
|
|
902
|
+
if (entry.updatedAt !== null && now - entry.updatedAt < 6e4) return entry;
|
|
903
|
+
return {
|
|
904
|
+
...entry,
|
|
905
|
+
state: "stale-running"
|
|
906
|
+
};
|
|
907
|
+
}
|
|
878
908
|
/** Compact elapsed-time label: "5m 12s", "1h 30m", "2d 4h" — ticks every
|
|
879
909
|
* second for running jobs. */
|
|
880
910
|
function fmtElapsed(ms) {
|
|
@@ -891,7 +921,7 @@ function fmtElapsed(ms) {
|
|
|
891
921
|
/** Elapsed label for one entry: running → ticks `now - startedAt`, terminal
|
|
892
922
|
* → fixed `updatedAt - startedAt` (em dash when no finalized timestamp). */
|
|
893
923
|
function delegationElapsed(entry, now) {
|
|
894
|
-
if (entry.state === "running") return fmtElapsed(now - entry.startedAt);
|
|
924
|
+
if (entry.state === "running" || entry.state === "stale-running") return fmtElapsed(now - entry.startedAt);
|
|
895
925
|
return entry.updatedAt !== null ? fmtElapsed(entry.updatedAt - entry.startedAt) : "—";
|
|
896
926
|
}
|
|
897
927
|
/** The activity labels shown by the animated row. Keeping this pure makes the
|
|
@@ -1318,7 +1348,7 @@ function childrenToDelegationEntries(children, md, now = Date.now()) {
|
|
|
1318
1348
|
agent: mdEntry?.agent ?? child.agent ?? "agent",
|
|
1319
1349
|
state,
|
|
1320
1350
|
startedAt: mdEntry?.startedAt ?? child.time?.created ?? now,
|
|
1321
|
-
updatedAt: mdEntry?.updatedAt ?? (state === "running" ? null : child.time?.updated ?? null),
|
|
1351
|
+
updatedAt: mdEntry?.updatedAt ?? (state === "running" || state === "stale-running" ? null : child.time?.updated ?? null),
|
|
1322
1352
|
timedOut: mdEntry?.timedOut ?? false,
|
|
1323
1353
|
description: mdEntry !== void 0 && mdEntry.description !== "" ? mdEntry.description : child.title ?? "",
|
|
1324
1354
|
source: mdEntry !== void 0 ? "md" : "children-only"
|
|
@@ -1399,6 +1429,7 @@ function DelegationRow(props) {
|
|
|
1399
1429
|
const t = theme();
|
|
1400
1430
|
switch (props.job.state) {
|
|
1401
1431
|
case "running": return t.warning;
|
|
1432
|
+
case "stale-running": return t.error;
|
|
1402
1433
|
case "completed": return t.success;
|
|
1403
1434
|
case "error": return t.error;
|
|
1404
1435
|
default: return t.textMuted;
|
|
@@ -1406,6 +1437,7 @@ function DelegationRow(props) {
|
|
|
1406
1437
|
});
|
|
1407
1438
|
const marker = createMemo(() => {
|
|
1408
1439
|
if (props.job.state === "running") return `${delegationSpinnerFrame(props.animationNow)} `;
|
|
1440
|
+
if (props.job.state === "stale-running") return "⚠ ";
|
|
1409
1441
|
switch (props.job.state) {
|
|
1410
1442
|
case "completed": return "✓ ";
|
|
1411
1443
|
case "error": return "✕ ";
|
|
@@ -1842,6 +1874,6 @@ const plugin = {
|
|
|
1842
1874
|
tui
|
|
1843
1875
|
};
|
|
1844
1876
|
//#endregion
|
|
1845
|
-
export { buildChildrenPath, childStatusToState, childrenToDelegationEntries, collectDelegationToolParts, compareDelegationEntries, plugin as default, delegationActivity, delegationActivityLabel, delegationElapsed, delegationSpinnerFrame, delegationTag, fmtElapsed, isValidSessionId, mergeChildDelegationSources, mergeDelegationSources, navigateToDelegationSession, panelLogDir, parseDelegationMarkdown, parseDelegationToolPart, readAllDelegationEntries, readDelegationEntries, reduceDelegationToolPart, removeDelegationEntry, resolveCurrentSessionID, resolveDelegationsDir, safeSessionPath, seedLiveDelegationMap, toDelegationEntry, tuiLogPath, visibleDelegationList };
|
|
1877
|
+
export { IDLE_SILENCE_MS, STALE_RUNNING_THRESHOLD_MS, buildChildrenPath, childStatusToState, childrenToDelegationEntries, collectDelegationToolParts, compareDelegationEntries, plugin as default, delegationActivity, delegationActivityLabel, delegationElapsed, delegationSpinnerFrame, delegationTag, fmtElapsed, isValidSessionId, markStaleIfRunning, mergeChildDelegationSources, mergeDelegationSources, navigateToDelegationSession, panelLogDir, parseDelegationMarkdown, parseDelegationToolPart, readAllDelegationEntries, readDelegationEntries, reduceDelegationToolPart, removeDelegationEntry, resolveCurrentSessionID, resolveDelegationsDir, safeSessionPath, seedLiveDelegationMap, toDelegationEntry, tuiLogPath, visibleDelegationList };
|
|
1846
1878
|
|
|
1847
1879
|
//# sourceMappingURL=tui.js.map
|
|
@@ -154,25 +154,29 @@ async function resolvePresetForTui(
|
|
|
154
154
|
* Se falhar, retorna null e a View omite a versão.
|
|
155
155
|
*
|
|
156
156
|
* Try order:
|
|
157
|
+
* 0a. pantheon-tui/package.json (installed: dist/tui.js → 2 níveis)
|
|
158
|
+
* 0b. pantheon/package.json (dev: src/plugins/tui/dist/tui.tsx → 4 níveis)
|
|
157
159
|
* 1. api.client.file.read package.json
|
|
158
160
|
* 2. git describe --tags
|
|
159
161
|
* 3. opencode --version
|
|
160
162
|
* 4. null */
|
|
161
163
|
|
|
162
164
|
async function detectVersion(api: TuiPluginApi): Promise<string | null> {
|
|
163
|
-
// Try
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
// Try 0a: installed location (2 levels: dist/tui.js → pantheon-tui/package.json)
|
|
166
|
+
try {
|
|
167
|
+
const pkgUrl = new URL('../../package.json', import.meta.url)
|
|
168
|
+
const pkgContent = await readFile(fileURLToPath(pkgUrl), 'utf8')
|
|
169
|
+
const pkg = JSON.parse(pkgContent)
|
|
170
|
+
if (pkg.version) return pkg.version
|
|
171
|
+
} catch {}
|
|
172
|
+
|
|
173
|
+
// Try 0b: dev location (4 levels: src/plugins/tui/dist/tui.tsx → package.json)
|
|
168
174
|
try {
|
|
169
175
|
const pkgUrl = new URL('../../../../package.json', import.meta.url)
|
|
170
176
|
const pkgContent = await readFile(fileURLToPath(pkgUrl), 'utf8')
|
|
171
|
-
const
|
|
172
|
-
if (
|
|
173
|
-
} catch {
|
|
174
|
-
/* fall through */
|
|
175
|
-
}
|
|
177
|
+
const pkg = JSON.parse(pkgContent)
|
|
178
|
+
if (pkg.version) return pkg.version
|
|
179
|
+
} catch {}
|
|
176
180
|
|
|
177
181
|
// Try 1: package.json do projeto (via worktree path)
|
|
178
182
|
try {
|
|
@@ -942,7 +946,14 @@ export type DelegationEntry = {
|
|
|
942
946
|
taskID?: string
|
|
943
947
|
/** Agent name, e.g. "apollo". */
|
|
944
948
|
agent: string
|
|
945
|
-
state:
|
|
949
|
+
state:
|
|
950
|
+
| 'running'
|
|
951
|
+
| 'completed'
|
|
952
|
+
| 'error'
|
|
953
|
+
| 'startup_failed'
|
|
954
|
+
| 'startup_unknown'
|
|
955
|
+
| 'cancelled'
|
|
956
|
+
| 'stale-running'
|
|
946
957
|
/** Epoch ms of the `Started` header. */
|
|
947
958
|
startedAt: number
|
|
948
959
|
/** Epoch ms of the `Finalized` header — null while still running. */
|
|
@@ -1048,8 +1059,10 @@ export function parseDelegationMarkdown(
|
|
|
1048
1059
|
const startedAt = started !== undefined ? Date.parse(started) : NaN
|
|
1049
1060
|
if (agent === undefined || state === undefined || Number.isNaN(startedAt)) return null
|
|
1050
1061
|
const normalized = state.toLowerCase()
|
|
1062
|
+
// Running state should only come from live channels, never from persisted
|
|
1063
|
+
// reports. A stale "running" MD artifact contaminates the panel — skip it.
|
|
1064
|
+
if (normalized === 'running') return null
|
|
1051
1065
|
if (
|
|
1052
|
-
normalized !== 'running' &&
|
|
1053
1066
|
normalized !== 'completed' &&
|
|
1054
1067
|
normalized !== 'error' &&
|
|
1055
1068
|
normalized !== 'startup_failed' &&
|
|
@@ -1171,8 +1184,8 @@ export function tuiLogPath(projectRoot: string): string {
|
|
|
1171
1184
|
* falling back to startedAt, descending). Shared by the md reader and
|
|
1172
1185
|
* mergeDelegationSources. */
|
|
1173
1186
|
export function compareDelegationEntries(a: DelegationEntry, b: DelegationEntry): number {
|
|
1174
|
-
const aRun = a.state === 'running' ? 1 : 0
|
|
1175
|
-
const bRun = b.state === 'running' ? 1 : 0
|
|
1187
|
+
const aRun = a.state === 'running' || a.state === 'stale-running' ? 1 : 0
|
|
1188
|
+
const bRun = b.state === 'running' || b.state === 'stale-running' ? 1 : 0
|
|
1176
1189
|
if (aRun !== bRun) return bRun - aRun
|
|
1177
1190
|
return (b.updatedAt ?? b.startedAt) - (a.updatedAt ?? a.startedAt)
|
|
1178
1191
|
}
|
|
@@ -1184,12 +1197,45 @@ export function compareDelegationEntries(a: DelegationEntry, b: DelegationEntry)
|
|
|
1184
1197
|
export function visibleDelegationList(
|
|
1185
1198
|
all: readonly DelegationEntry[],
|
|
1186
1199
|
maxTerminal = 8,
|
|
1200
|
+
now = Date.now(),
|
|
1201
|
+
staleThresholdMs = 30 * 60 * 1000, // 30 minutes
|
|
1187
1202
|
): DelegationEntry[] {
|
|
1188
|
-
const running = all
|
|
1203
|
+
const running = all
|
|
1204
|
+
.filter((d) => d.state === 'running')
|
|
1205
|
+
.map((d) => markStaleIfRunning(d, now, staleThresholdMs))
|
|
1189
1206
|
const terminal = all.filter((d) => d.state !== 'running').slice(0, maxTerminal)
|
|
1190
1207
|
return [...running, ...terminal]
|
|
1191
1208
|
}
|
|
1192
1209
|
|
|
1210
|
+
/** Default stale-running threshold: 30 minutes. */
|
|
1211
|
+
export const STALE_RUNNING_THRESHOLD_MS = 30 * 60 * 1000
|
|
1212
|
+
|
|
1213
|
+
/** Idle silence window: if no updatedAt change in this window, the entry is
|
|
1214
|
+
* considered stale. Combined with the stale-running threshold to produce the
|
|
1215
|
+
* display-only `stale-running` state. */
|
|
1216
|
+
export const IDLE_SILENCE_MS = 60 * 1000
|
|
1217
|
+
|
|
1218
|
+
/**
|
|
1219
|
+
* Mark a running entry as `stale-running` if it has been running longer than
|
|
1220
|
+
* the threshold AND has no recent activity (no `updatedAt` change in the last
|
|
1221
|
+
* `IDLE_SILENCE_MS`). This is DISPLAY-ONLY — the board state is unchanged.
|
|
1222
|
+
*
|
|
1223
|
+
* A `stale-running` entry renders with a warning indicator but the underlying
|
|
1224
|
+
* delegation is still treated as running by the backend.
|
|
1225
|
+
*/
|
|
1226
|
+
export function markStaleIfRunning(
|
|
1227
|
+
entry: DelegationEntry,
|
|
1228
|
+
now: number,
|
|
1229
|
+
thresholdMs = STALE_RUNNING_THRESHOLD_MS,
|
|
1230
|
+
): DelegationEntry {
|
|
1231
|
+
if (entry.state !== 'running') return entry
|
|
1232
|
+
const elapsed = now - entry.startedAt
|
|
1233
|
+
if (elapsed < thresholdMs) return entry
|
|
1234
|
+
// If updatedAt exists and is recent, entry is still active — not stale.
|
|
1235
|
+
if (entry.updatedAt !== null && now - entry.updatedAt < IDLE_SILENCE_MS) return entry
|
|
1236
|
+
return { ...entry, state: 'stale-running' as const }
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1193
1239
|
/** Compact elapsed-time label: "5m 12s", "1h 30m", "2d 4h" — ticks every
|
|
1194
1240
|
* second for running jobs. */
|
|
1195
1241
|
export function fmtElapsed(ms: number): string {
|
|
@@ -1207,7 +1253,8 @@ export function fmtElapsed(ms: number): string {
|
|
|
1207
1253
|
/** Elapsed label for one entry: running → ticks `now - startedAt`, terminal
|
|
1208
1254
|
* → fixed `updatedAt - startedAt` (em dash when no finalized timestamp). */
|
|
1209
1255
|
export function delegationElapsed(entry: DelegationEntry, now: number): string {
|
|
1210
|
-
if (entry.state === 'running'
|
|
1256
|
+
if (entry.state === 'running' || entry.state === 'stale-running')
|
|
1257
|
+
return fmtElapsed(now - entry.startedAt)
|
|
1211
1258
|
return entry.updatedAt !== null ? fmtElapsed(entry.updatedAt - entry.startedAt) : '\u2014'
|
|
1212
1259
|
}
|
|
1213
1260
|
|
|
@@ -1874,7 +1921,9 @@ export function childrenToDelegationEntries(
|
|
|
1874
1921
|
agent: mdEntry?.agent ?? child.agent ?? 'agent',
|
|
1875
1922
|
state,
|
|
1876
1923
|
startedAt: mdEntry?.startedAt ?? child.time?.created ?? now,
|
|
1877
|
-
updatedAt:
|
|
1924
|
+
updatedAt:
|
|
1925
|
+
mdEntry?.updatedAt ??
|
|
1926
|
+
(state === 'running' || state === 'stale-running' ? null : (child.time?.updated ?? null)),
|
|
1878
1927
|
timedOut: mdEntry?.timedOut ?? false,
|
|
1879
1928
|
description:
|
|
1880
1929
|
mdEntry !== undefined && mdEntry.description !== ''
|
|
@@ -2008,6 +2057,8 @@ function DelegationRow(props: {
|
|
|
2008
2057
|
switch (props.job.state) {
|
|
2009
2058
|
case 'running':
|
|
2010
2059
|
return t.warning
|
|
2060
|
+
case 'stale-running':
|
|
2061
|
+
return t.error // warning color for stale delegations
|
|
2011
2062
|
case 'completed':
|
|
2012
2063
|
return t.success
|
|
2013
2064
|
case 'error':
|
|
@@ -2019,6 +2070,7 @@ function DelegationRow(props: {
|
|
|
2019
2070
|
|
|
2020
2071
|
const marker = createMemo(() => {
|
|
2021
2072
|
if (props.job.state === 'running') return `${delegationSpinnerFrame(props.animationNow)} `
|
|
2073
|
+
if (props.job.state === 'stale-running') return '\u26a0 ' // warning triangle
|
|
2022
2074
|
switch (props.job.state) {
|
|
2023
2075
|
case 'completed':
|
|
2024
2076
|
return '\u2713 '
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pantheon-tui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.0",
|
|
5
5
|
"description": "Pantheon TUI plugin — sidebar (version, preset, sessions, real-time delegations) + AI subscription usage gauges incl. OpenCode Go/Zen dollar limits (vendored, MIT)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"exports": {
|
|
@@ -154,25 +154,29 @@ async function resolvePresetForTui(
|
|
|
154
154
|
* Se falhar, retorna null e a View omite a versão.
|
|
155
155
|
*
|
|
156
156
|
* Try order:
|
|
157
|
+
* 0a. pantheon-tui/package.json (installed: dist/tui.js → 2 níveis)
|
|
158
|
+
* 0b. pantheon/package.json (dev: src/plugins/tui/dist/tui.tsx → 4 níveis)
|
|
157
159
|
* 1. api.client.file.read package.json
|
|
158
160
|
* 2. git describe --tags
|
|
159
161
|
* 3. opencode --version
|
|
160
162
|
* 4. null */
|
|
161
163
|
|
|
162
164
|
async function detectVersion(api: TuiPluginApi): Promise<string | null> {
|
|
163
|
-
// Try
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
// Try 0a: installed location (2 levels: dist/tui.js → pantheon-tui/package.json)
|
|
166
|
+
try {
|
|
167
|
+
const pkgUrl = new URL('../../package.json', import.meta.url)
|
|
168
|
+
const pkgContent = await readFile(fileURLToPath(pkgUrl), 'utf8')
|
|
169
|
+
const pkg = JSON.parse(pkgContent)
|
|
170
|
+
if (pkg.version) return pkg.version
|
|
171
|
+
} catch {}
|
|
172
|
+
|
|
173
|
+
// Try 0b: dev location (4 levels: src/plugins/tui/dist/tui.tsx → package.json)
|
|
168
174
|
try {
|
|
169
175
|
const pkgUrl = new URL('../../../../package.json', import.meta.url)
|
|
170
176
|
const pkgContent = await readFile(fileURLToPath(pkgUrl), 'utf8')
|
|
171
|
-
const
|
|
172
|
-
if (
|
|
173
|
-
} catch {
|
|
174
|
-
/* fall through */
|
|
175
|
-
}
|
|
177
|
+
const pkg = JSON.parse(pkgContent)
|
|
178
|
+
if (pkg.version) return pkg.version
|
|
179
|
+
} catch {}
|
|
176
180
|
|
|
177
181
|
// Try 1: package.json do projeto (via worktree path)
|
|
178
182
|
try {
|
|
@@ -942,7 +946,14 @@ export type DelegationEntry = {
|
|
|
942
946
|
taskID?: string
|
|
943
947
|
/** Agent name, e.g. "apollo". */
|
|
944
948
|
agent: string
|
|
945
|
-
state:
|
|
949
|
+
state:
|
|
950
|
+
| 'running'
|
|
951
|
+
| 'completed'
|
|
952
|
+
| 'error'
|
|
953
|
+
| 'startup_failed'
|
|
954
|
+
| 'startup_unknown'
|
|
955
|
+
| 'cancelled'
|
|
956
|
+
| 'stale-running'
|
|
946
957
|
/** Epoch ms of the `Started` header. */
|
|
947
958
|
startedAt: number
|
|
948
959
|
/** Epoch ms of the `Finalized` header — null while still running. */
|
|
@@ -1048,8 +1059,10 @@ export function parseDelegationMarkdown(
|
|
|
1048
1059
|
const startedAt = started !== undefined ? Date.parse(started) : NaN
|
|
1049
1060
|
if (agent === undefined || state === undefined || Number.isNaN(startedAt)) return null
|
|
1050
1061
|
const normalized = state.toLowerCase()
|
|
1062
|
+
// Running state should only come from live channels, never from persisted
|
|
1063
|
+
// reports. A stale "running" MD artifact contaminates the panel — skip it.
|
|
1064
|
+
if (normalized === 'running') return null
|
|
1051
1065
|
if (
|
|
1052
|
-
normalized !== 'running' &&
|
|
1053
1066
|
normalized !== 'completed' &&
|
|
1054
1067
|
normalized !== 'error' &&
|
|
1055
1068
|
normalized !== 'startup_failed' &&
|
|
@@ -1171,8 +1184,8 @@ export function tuiLogPath(projectRoot: string): string {
|
|
|
1171
1184
|
* falling back to startedAt, descending). Shared by the md reader and
|
|
1172
1185
|
* mergeDelegationSources. */
|
|
1173
1186
|
export function compareDelegationEntries(a: DelegationEntry, b: DelegationEntry): number {
|
|
1174
|
-
const aRun = a.state === 'running' ? 1 : 0
|
|
1175
|
-
const bRun = b.state === 'running' ? 1 : 0
|
|
1187
|
+
const aRun = a.state === 'running' || a.state === 'stale-running' ? 1 : 0
|
|
1188
|
+
const bRun = b.state === 'running' || b.state === 'stale-running' ? 1 : 0
|
|
1176
1189
|
if (aRun !== bRun) return bRun - aRun
|
|
1177
1190
|
return (b.updatedAt ?? b.startedAt) - (a.updatedAt ?? a.startedAt)
|
|
1178
1191
|
}
|
|
@@ -1184,12 +1197,45 @@ export function compareDelegationEntries(a: DelegationEntry, b: DelegationEntry)
|
|
|
1184
1197
|
export function visibleDelegationList(
|
|
1185
1198
|
all: readonly DelegationEntry[],
|
|
1186
1199
|
maxTerminal = 8,
|
|
1200
|
+
now = Date.now(),
|
|
1201
|
+
staleThresholdMs = 30 * 60 * 1000, // 30 minutes
|
|
1187
1202
|
): DelegationEntry[] {
|
|
1188
|
-
const running = all
|
|
1203
|
+
const running = all
|
|
1204
|
+
.filter((d) => d.state === 'running')
|
|
1205
|
+
.map((d) => markStaleIfRunning(d, now, staleThresholdMs))
|
|
1189
1206
|
const terminal = all.filter((d) => d.state !== 'running').slice(0, maxTerminal)
|
|
1190
1207
|
return [...running, ...terminal]
|
|
1191
1208
|
}
|
|
1192
1209
|
|
|
1210
|
+
/** Default stale-running threshold: 30 minutes. */
|
|
1211
|
+
export const STALE_RUNNING_THRESHOLD_MS = 30 * 60 * 1000
|
|
1212
|
+
|
|
1213
|
+
/** Idle silence window: if no updatedAt change in this window, the entry is
|
|
1214
|
+
* considered stale. Combined with the stale-running threshold to produce the
|
|
1215
|
+
* display-only `stale-running` state. */
|
|
1216
|
+
export const IDLE_SILENCE_MS = 60 * 1000
|
|
1217
|
+
|
|
1218
|
+
/**
|
|
1219
|
+
* Mark a running entry as `stale-running` if it has been running longer than
|
|
1220
|
+
* the threshold AND has no recent activity (no `updatedAt` change in the last
|
|
1221
|
+
* `IDLE_SILENCE_MS`). This is DISPLAY-ONLY — the board state is unchanged.
|
|
1222
|
+
*
|
|
1223
|
+
* A `stale-running` entry renders with a warning indicator but the underlying
|
|
1224
|
+
* delegation is still treated as running by the backend.
|
|
1225
|
+
*/
|
|
1226
|
+
export function markStaleIfRunning(
|
|
1227
|
+
entry: DelegationEntry,
|
|
1228
|
+
now: number,
|
|
1229
|
+
thresholdMs = STALE_RUNNING_THRESHOLD_MS,
|
|
1230
|
+
): DelegationEntry {
|
|
1231
|
+
if (entry.state !== 'running') return entry
|
|
1232
|
+
const elapsed = now - entry.startedAt
|
|
1233
|
+
if (elapsed < thresholdMs) return entry
|
|
1234
|
+
// If updatedAt exists and is recent, entry is still active — not stale.
|
|
1235
|
+
if (entry.updatedAt !== null && now - entry.updatedAt < IDLE_SILENCE_MS) return entry
|
|
1236
|
+
return { ...entry, state: 'stale-running' as const }
|
|
1237
|
+
}
|
|
1238
|
+
|
|
1193
1239
|
/** Compact elapsed-time label: "5m 12s", "1h 30m", "2d 4h" — ticks every
|
|
1194
1240
|
* second for running jobs. */
|
|
1195
1241
|
export function fmtElapsed(ms: number): string {
|
|
@@ -1207,7 +1253,8 @@ export function fmtElapsed(ms: number): string {
|
|
|
1207
1253
|
/** Elapsed label for one entry: running → ticks `now - startedAt`, terminal
|
|
1208
1254
|
* → fixed `updatedAt - startedAt` (em dash when no finalized timestamp). */
|
|
1209
1255
|
export function delegationElapsed(entry: DelegationEntry, now: number): string {
|
|
1210
|
-
if (entry.state === 'running'
|
|
1256
|
+
if (entry.state === 'running' || entry.state === 'stale-running')
|
|
1257
|
+
return fmtElapsed(now - entry.startedAt)
|
|
1211
1258
|
return entry.updatedAt !== null ? fmtElapsed(entry.updatedAt - entry.startedAt) : '\u2014'
|
|
1212
1259
|
}
|
|
1213
1260
|
|
|
@@ -1874,7 +1921,9 @@ export function childrenToDelegationEntries(
|
|
|
1874
1921
|
agent: mdEntry?.agent ?? child.agent ?? 'agent',
|
|
1875
1922
|
state,
|
|
1876
1923
|
startedAt: mdEntry?.startedAt ?? child.time?.created ?? now,
|
|
1877
|
-
updatedAt:
|
|
1924
|
+
updatedAt:
|
|
1925
|
+
mdEntry?.updatedAt ??
|
|
1926
|
+
(state === 'running' || state === 'stale-running' ? null : (child.time?.updated ?? null)),
|
|
1878
1927
|
timedOut: mdEntry?.timedOut ?? false,
|
|
1879
1928
|
description:
|
|
1880
1929
|
mdEntry !== undefined && mdEntry.description !== ''
|
|
@@ -2008,6 +2057,8 @@ function DelegationRow(props: {
|
|
|
2008
2057
|
switch (props.job.state) {
|
|
2009
2058
|
case 'running':
|
|
2010
2059
|
return t.warning
|
|
2060
|
+
case 'stale-running':
|
|
2061
|
+
return t.error // warning color for stale delegations
|
|
2011
2062
|
case 'completed':
|
|
2012
2063
|
return t.success
|
|
2013
2064
|
case 'error':
|
|
@@ -2019,6 +2070,7 @@ function DelegationRow(props: {
|
|
|
2019
2070
|
|
|
2020
2071
|
const marker = createMemo(() => {
|
|
2021
2072
|
if (props.job.state === 'running') return `${delegationSpinnerFrame(props.animationNow)} `
|
|
2073
|
+
if (props.job.state === 'stale-running') return '\u26a0 ' // warning triangle
|
|
2022
2074
|
switch (props.job.state) {
|
|
2023
2075
|
case 'completed':
|
|
2024
2076
|
return '\u2713 '
|
|
@@ -45,3 +45,10 @@ Generate a hierarchical map of the codebase to understand its structure, key mod
|
|
|
45
45
|
- Focus on structure, not implementation details
|
|
46
46
|
- Max 3 levels deep unless a module is critical
|
|
47
47
|
- Return to agent: "Codemap generated. Send to @athena for planning."
|
|
48
|
+
|
|
49
|
+
## Integração @apollo
|
|
50
|
+
Antes de glob/grep manual, tente `code_query`:
|
|
51
|
+
- `code_query("MyClass")` → busca FTS5 por entidade
|
|
52
|
+
- Fallback para glob/grep se não indexado ou query vazia
|
|
53
|
+
- `code_index("src/")` para indexação incremental (hash-based, skip se não mudou, force=true para re-index)
|
|
54
|
+
- `code_neighbors(entity_id, depth=2)` para grafo de imports/calls
|
|
@@ -859,3 +859,42 @@ When `01-active-context.md` exceeds 100 lines:
|
|
|
859
859
|
- `skills/wisdom-accumulation/SKILL.md` — learning extraction
|
|
860
860
|
- `skills/memory-bank/SKILL.md` — memory bank maintenance
|
|
861
861
|
- `instructions/backend-standards.instructions.md` — zeus scoring reference
|
|
862
|
+
|
|
863
|
+
---
|
|
864
|
+
|
|
865
|
+
## 19. Tool Output Sandboxing (v2 P0 — Plugin Hook, 0 MCPs)
|
|
866
|
+
|
|
867
|
+
Camada P0 do Deepwork Plan "Context Window Optimization" (council 2026-08-25, 3/3 High): truncamento simples via `tool.execute.after`, sem tiktoken/LLM em v1 (YAGNI).
|
|
868
|
+
|
|
869
|
+
**Módulo:** `src/pantheon/context-sandbox.ts` (~120 LOC) — `sandboxOutput(tool, output)` + `createContextSandbox(config)`
|
|
870
|
+
|
|
871
|
+
**Limites (defaults sensatos, cobrem 80% do problema):**
|
|
872
|
+
|
|
873
|
+
| Tool | Limite | Ação no excesso |
|
|
874
|
+
|------|--------|-----------------|
|
|
875
|
+
| read | 200 linhas | Primeiras 50 + `[TRUNCATED: N lines]` + últimas 10 |
|
|
876
|
+
| grep | 20 resultados | Top 10 + `[Showing 10 of N matches]` |
|
|
877
|
+
| glob | 50 arquivos | Top 20 + `[showing 20 of N files]` |
|
|
878
|
+
| webfetch | 5000 chars | Primeiros 2000 + `[Content truncated]` |
|
|
879
|
+
|
|
880
|
+
**Integração (ordem fixa — 0-overhead extra):** `tool.execute.after` → `sandboxHandler` (trunca) → `readEnhancer` (hashline tags). Sandbox sempre antes de compression: outputs já chegam enxutos ao context window; compress-inline (L1) só atua sobre o que sobrou. Custo <1ms por call, 0 novos processos.
|
|
881
|
+
|
|
882
|
+
**Config opcional em `opencode.json` (fail-open — defaults quando ausente):**
|
|
883
|
+
```json
|
|
884
|
+
{
|
|
885
|
+
"context_sandbox": {
|
|
886
|
+
"enabled": true,
|
|
887
|
+
"limits": {
|
|
888
|
+
"read": { "maxLines": 200, "keepHead": 50, "keepTail": 10 },
|
|
889
|
+
"grep": { "maxResults": 20, "keepTop": 10 },
|
|
890
|
+
"glob": { "maxFiles": 50, "keepTop": 20 },
|
|
891
|
+
"webfetch": { "maxChars": 5000, "keepHead": 2000 }
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
```
|
|
896
|
+
Desabilitar: `"enabled": false` (plugin vira no-op, sem throw).
|
|
897
|
+
|
|
898
|
+
**Session Memory (P1 — já existe, só conectado):** `pantheon-persistence` KV com TTL 4h já fornece `context_save`/`context_get`. Auto-save antes de compactar (`experimental.session.compacting` → `buildCompactionContext` + `todoPreserver.capture`) e recovery pós-compactação (`session.compacted` → `todoPreserver.onCompacted` + `reassertAfterCompaction`) preservam estado sem novo MCP. Testado em `delegation-compaction.test.ts` + `todo-preserve.test.ts`.
|
|
899
|
+
|
|
900
|
+
**Fora de escopo v1 (YAGNI):** tiktoken counting, LLM summarization, budget dashboard — só se medição provar necessidade.
|