create-pmos 0.426.0 → 0.427.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/package.json +13 -13
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/changelog.json +12 -0
- package/workspace/guide/claude-proposes.md +3 -1
- package/workspace/lib/context-use.js +54 -0
- package/workspace/lib/routes-live.js +3 -1
- package/workspace/lib/transcript-read.js +9 -2
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-home.css +7 -0
- package/workspace/public/pm/cozy-live-pill.css +1 -0
- package/workspace/public/pm/cozy-live-pill.js +2 -1
- package/workspace/public/pm/cozy-today.css +3 -0
- package/workspace/public/pm/cozy.css +6 -0
- package/workspace/public/pm/ctx-wedge.js +45 -0
- package/workspace/public/pm/home-app.js +15 -2
- package/workspace/public/pm/home-chat.js +7 -2
- package/workspace/public/pm/home-data.js +2 -1
- package/workspace/public/pm/home-today.js +8 -2
- package/workspace/public/pm/live-model.js +1 -1
- package/workspace/server.js +28 -0
- package/workspace/test-lists/batch13-context-use.json +5 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.427.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -32,6 +32,18 @@
|
|
|
32
32
|
"audit"
|
|
33
33
|
],
|
|
34
34
|
"pmosChanges": [
|
|
35
|
+
{
|
|
36
|
+
"v": "0.427.0",
|
|
37
|
+
"at": "2026-10-27T04:17:38.420Z",
|
|
38
|
+
"f": 2,
|
|
39
|
+
"prs": [
|
|
40
|
+
{
|
|
41
|
+
"n": 1069,
|
|
42
|
+
"t": "How full each session's context is, and Claude proposes Compact (batch 13 item 8)",
|
|
43
|
+
"s": "How full each session's context is, and Claude proposes Compact (batch 13 item 8)"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
35
47
|
{
|
|
36
48
|
"v": "0.426.0",
|
|
37
49
|
"at": "2026-10-27T04:01:13.323Z",
|
|
@@ -259,18 +271,6 @@
|
|
|
259
271
|
"s": "Read another product's initiative from its own board; its heading no longer moves Home"
|
|
260
272
|
}
|
|
261
273
|
]
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
"v": "0.407.0",
|
|
265
|
-
"at": "2026-10-24T11:09:31.378Z",
|
|
266
|
-
"f": 2,
|
|
267
|
-
"prs": [
|
|
268
|
-
{
|
|
269
|
-
"n": 1037,
|
|
270
|
-
"t": "The list stays put; an initiative, program or product opens as a page in the Viewer",
|
|
271
|
-
"s": "The list stays put; an initiative, program or product opens as a page in the Viewer"
|
|
272
|
-
}
|
|
273
|
-
]
|
|
274
274
|
}
|
|
275
275
|
]
|
|
276
276
|
}
|
package/payload/KIT-VERSION
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Eval calibration log"
|
|
4
4
|
description: "Append-only record of every PM override of an evaluator verdict."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-27T04:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-27T04:17:35Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Health budgets"
|
|
4
4
|
description: "Closed registry of health-budget anchors (D59), edited only by the PM."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-27T04:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-27T04:17:35Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Reference
|
|
3
3
|
title: "Discoveries and friction log"
|
|
4
4
|
description: "Append-only record of what runs discovered and where the process rubbed."
|
|
5
|
-
generated: {by: process:create-pmos, at: "2026-10-27T04:
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-10-27T04:17:35Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.427.0",
|
|
4
|
+
"at": "2026-10-27T04:17:38.420Z",
|
|
5
|
+
"f": 2,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1069,
|
|
9
|
+
"t": "How full each session's context is, and Claude proposes Compact (batch 13 item 8)",
|
|
10
|
+
"s": "How full each session's context is, and Claude proposes Compact (batch 13 item 8)"
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
},
|
|
2
14
|
{
|
|
3
15
|
"v": "0.426.0",
|
|
4
16
|
"at": "2026-10-27T04:01:13.323Z",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Guide
|
|
3
3
|
title: "Claude proposes: the one ✦ on each initiative"
|
|
4
4
|
description: "What Claude finds when you add an initiative that already lives elsewhere, the new dates, done and tidy names it proposes for late tasks, the clean-up of the work that is not in an initiative, how you keep or drop them in the Viewer, Undo, and the pmos propose commands."
|
|
5
|
-
timestamp: 2026-10-
|
|
5
|
+
timestamp: 2026-10-27
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Claude proposes: the one ✦ on each initiative
|
|
@@ -49,4 +49,6 @@ Press the ✦ to open "Claude proposes" in the Viewer. The groups come in this o
|
|
|
49
49
|
|
|
50
50
|
In the pill menu on an initiative's row, a session that is idle and safe to close is light blue. Its line starts with ✦ and says why, and its ✓ closes it. An idle session that is not safe has no ✦ and no ✓. Its line says what holds it, such as "3 files not committed".
|
|
51
51
|
|
|
52
|
+
Each session shows how full its context window is, as a small pie in the pill list, the chat header, the phone top bar and the Live pill. The pie shows from 50% (grey). It turns amber from 70% and red from 90%. Hover it to see the tokens used, such as "156k of 200k used · last turn 10:12". The window is 1M when the session runs a 1M model, else 200k. From 70%, when it is your turn, Claude proposes Compact: the row's ✦ line says so, and its ✓ types /compact into the session. The chat shows the same offer as a chip. A session that is safe to close shows that ✦ instead. ✕ hides the Compact offer until the context is 10 points fuller.
|
|
53
|
+
|
|
52
54
|
✓ in the header keeps everything shown. Each proposal has its own ✓ and ✕, and ⌄ shows its rows. ✕ on a row leaves it out of that group for good, with Undo on the row. One toast says what was placed, with Undo. History lists each approval with its own Undo. An initiative that was started stays when you undo: close it on the Board.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const os = require('os');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
/* context-use.js — how full a session's context window is, and whether Claude proposes to compact it (batch 13 item 8, canvas XctxA1Desk).
|
|
6
|
+
*
|
|
7
|
+
* of(seen, hints) → { used, window, pct, level, at } | null
|
|
8
|
+
* seen = transcript-read's `context`: { used, peak, at } of the newest real (not subagent) model turn, or null
|
|
9
|
+
* hints = model ids that can name the window: the model PMOS started the session with, the CLI's own setting
|
|
10
|
+
* advise(ctx, shown) → 'compact' | null
|
|
11
|
+
* cliHints(root, home?) → the model the CLI itself is set to: `model` in ~/.claude and <root>/.claude settings, and ANTHROPIC_MODEL
|
|
12
|
+
* The words under the wedge ("116k of 200k used · last turn 10:12") are drawn by pm/ctx-wedge.js, in the PM's own clock.
|
|
13
|
+
*
|
|
14
|
+
* THE NUMBER is what the next turn starts from: the newest reply's input + cache-read + cache-write tokens (what the model was sent) plus
|
|
15
|
+
* its output. It is not a running total, so it drops after a compact. THE WINDOW is 1M when a hint names a [1m] model or a turn already
|
|
16
|
+
* went past 200k, else 200k (the CLI's default). With no turn read, or an agent that is not Claude, there is nothing: no %, no advice.
|
|
17
|
+
* Advice only on the PM's turn (a session that works is never told to compact), and only from 70%. */
|
|
18
|
+
|
|
19
|
+
const BASE = 200000;
|
|
20
|
+
const LONG = 1000000;
|
|
21
|
+
const LEVELS = [[90, 'crit'], [70, 'warn'], [50, 'quiet']];
|
|
22
|
+
|
|
23
|
+
const isLong = (m) => /\[1m\]/i.test(String(m || ''));
|
|
24
|
+
|
|
25
|
+
function of(seen, hints = []) {
|
|
26
|
+
if (!seen || !(seen.used > 0)) return null;
|
|
27
|
+
const window = hints.some(isLong) || (seen.peak || 0) > BASE ? LONG : BASE;
|
|
28
|
+
const pct = Math.min(100, Math.floor((seen.used / window) * 100)); // floor: 69.6% is not yet 70%
|
|
29
|
+
const lv = LEVELS.find(([n]) => pct >= n);
|
|
30
|
+
return { used: seen.used, window, pct, level: lv ? lv[1] : null, at: seen.at || null };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function advise(ctx, shown) {
|
|
34
|
+
if (!ctx || ctx.pct == null || ctx.pct < 70) return null;
|
|
35
|
+
return shown === 'needs' || shown === 'quiet' ? 'compact' : null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* The CLI's own model setting. A session PMOS started with no model choice runs the CLI's default, and that setting is what can make it a
|
|
39
|
+
* [1m] model. Read again only when a settings file changes (sessionList runs on every broadcast). */
|
|
40
|
+
const memo = new Map(); // file → { stamp, model }
|
|
41
|
+
function modelIn(file) {
|
|
42
|
+
let stamp = null; try { const st = fs.statSync(file); stamp = st.size + ':' + st.mtimeMs; } catch { return null; }
|
|
43
|
+
const m = memo.get(file); if (m && m.stamp === stamp) return m.model;
|
|
44
|
+
let model = null; try { const j = JSON.parse(fs.readFileSync(file, 'utf8')); model = typeof j.model === 'string' ? j.model : null; } catch { model = null; }
|
|
45
|
+
memo.set(file, { stamp, model });
|
|
46
|
+
return model;
|
|
47
|
+
}
|
|
48
|
+
function cliHints(root, home = os.homedir()) {
|
|
49
|
+
const files = [path.join(home, '.claude', 'settings.json')];
|
|
50
|
+
if (root) files.push(path.join(String(root), '.claude', 'settings.json'), path.join(String(root), '.claude', 'settings.local.json'));
|
|
51
|
+
return files.map(modelIn).concat(process.env.ANTHROPIC_MODEL || null).filter(Boolean);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
module.exports = { of, advise, cliHints, BASE, LONG };
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* GET /api/live → { ok, sessions: [row], titles: { [initiative id]: title } }
|
|
5
5
|
* row = the /api/sessions fields the pill needs: id, ws, name, auto_name, name_by, agent, origin, automatic, shown, created,
|
|
6
|
-
* lastOutputAt, touched_at, exited_at, auto_ended, outcome { ok } | null, initiative, hx { title, turn } | null
|
|
6
|
+
* lastOutputAt, touched_at, exited_at, auto_ended, outcome { ok } | null, initiative, hx { title, turn } | null,
|
|
7
|
+
* ctx { used, window, pct, level, at } | null
|
|
7
8
|
* titles = the initiatives those sessions work on, by id, from each workspace's records (kept 60 s per workspace)
|
|
8
9
|
*
|
|
9
10
|
* Read-only. The pill shows on every page, so it reads this small answer every 10 s rather than the whole of /api/sessions; the
|
|
@@ -32,6 +33,7 @@ function rowOf(s) {
|
|
|
32
33
|
touched_at: s.touched_at || null, exited_at: s.exited_at || null, auto_ended: !!s.auto_ended,
|
|
33
34
|
outcome: s.outcome ? { ok: s.outcome.ok !== false } : null, initiative: s.initiative || null,
|
|
34
35
|
hx: s.hx ? { title: s.hx.title || null, turn: s.hx.turn || null } : null,
|
|
36
|
+
ctx: s.ctx ? { used: s.ctx.used, window: s.ctx.window, pct: s.ctx.pct, level: s.ctx.level, at: s.ctx.at } : null, // the context pie (batch 13 item 8)
|
|
35
37
|
};
|
|
36
38
|
}
|
|
37
39
|
|
|
@@ -220,6 +220,7 @@ function prettyTool(name) {
|
|
|
220
220
|
function newHarnessAcc() {
|
|
221
221
|
return { model: null, effort: null, turns: 0, title: null, skills: null,
|
|
222
222
|
toolCounts: {}, toolTotal: 0, tok: { input: 0, output: 0, cacheRead: 0, cacheCreate: 0 }, sawUsage: false,
|
|
223
|
+
ctx: null, peak: 0, // the newest real turn's { used, at } and the largest one seen (lib/context-use.js)
|
|
223
224
|
// For the open-call signal (R2): pair tool_use → tool_result by id in one pass. The NEWEST
|
|
224
225
|
// tool_use with no matching result is the call in flight; its record timestamp dates it. This is
|
|
225
226
|
// the same "written before its result exists" property the append-only transcript guarantees.
|
|
@@ -286,6 +287,11 @@ function feedHarness(acc, raw, clean) {
|
|
|
286
287
|
acc.tok.output += u.output_tokens || 0;
|
|
287
288
|
acc.tok.cacheRead += u.cache_read_input_tokens || 0;
|
|
288
289
|
acc.tok.cacheCreate += u.cache_creation_input_tokens || 0;
|
|
290
|
+
// context use (batch 13 item 8): the NEWEST real turn's size, not the sum. A subagent's turn has its own context and is left out.
|
|
291
|
+
if (m.model && m.model !== SYNTHETIC && !r.isSidechain) {
|
|
292
|
+
const used = (u.input_tokens || 0) + (u.cache_read_input_tokens || 0) + (u.cache_creation_input_tokens || 0) + (u.output_tokens || 0);
|
|
293
|
+
if (used > 0) { acc.ctx = { used, at: r.timestamp || null }; if (used > acc.peak) acc.peak = used; }
|
|
294
|
+
}
|
|
289
295
|
}
|
|
290
296
|
for (const c of (m.content || [])) {
|
|
291
297
|
if (c && c.type === 'tool_use' && c.name) {
|
|
@@ -300,7 +306,7 @@ function feedHarness(acc, raw, clean) {
|
|
|
300
306
|
|
|
301
307
|
function harnessOf(acc) {
|
|
302
308
|
const out = { model: acc.model, effort: acc.effort, turns: acc.turns, tokens: null, tools: null, skills: acc.skills,
|
|
303
|
-
title: acc.title, openCall: null, turn: null, missing: {} };
|
|
309
|
+
title: acc.title, openCall: null, turn: null, context: acc.ctx ? { ...acc.ctx, peak: acc.peak } : null, missing: {} };
|
|
304
310
|
|
|
305
311
|
// The newest tool_use with no matching tool_result is the call in flight (R2). Map preserves
|
|
306
312
|
// insertion (chronological) order, so the last unresolved entry is the newest.
|
|
@@ -326,6 +332,7 @@ function harnessOf(acc) {
|
|
|
326
332
|
// Tokens are reported as ABSOLUTE counts and never as a percentage: the context window size
|
|
327
333
|
// is not in the record, and autocompaction makes the running total move backward. A percentage
|
|
328
334
|
// of an unknown denominator is not a quantity — that refusal predates this module and stands.
|
|
335
|
+
// `context` is absolute too; lib/context-use.js gives it a % only when it can name the window.
|
|
329
336
|
if (acc.sawUsage) out.tokens = { ...acc.tok };
|
|
330
337
|
else out.missing.tokens = 'the transcript records no token usage yet';
|
|
331
338
|
if (!out.skills) out.missing.skills = 'the CLI listed no skills for this session';
|
|
@@ -381,7 +388,7 @@ function readHarness(file, clean = (x) => x, cache = null) {
|
|
|
381
388
|
} catch {
|
|
382
389
|
if (cache) { cache.file = null; cache.acc = null; cache.offset = 0; }
|
|
383
390
|
return { model: null, effort: null, turns: 0, tokens: null, tools: null, skills: null,
|
|
384
|
-
title: null, openCall: null, turn: null, missing: { all: "can't read the harness — the transcript could not be read" } };
|
|
391
|
+
title: null, openCall: null, turn: null, context: null, missing: { all: "can't read the harness — the transcript could not be read" } };
|
|
385
392
|
}
|
|
386
393
|
return harnessOf(acc);
|
|
387
394
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.427.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.427.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xterm/addon-fit": "^0.11.0",
|
package/workspace/package.json
CHANGED
|
@@ -756,3 +756,10 @@ form.hm-box textarea { min-height: 48px; border: 0; background: none; resize: no
|
|
|
756
756
|
/* a milestone task's small grey ◇ after its name (feedback batch 11 item 3) */
|
|
757
757
|
.hm-rt.ms { flex-direction: row; align-items: center; gap: 6px; }
|
|
758
758
|
.hv-ms { flex: none; display: inline-flex; color: var(--cz-ink3); }
|
|
759
|
+
/* the chat header's context pie and Claude's ✦ Compact in the offer chip (batch 13 item 8) */
|
|
760
|
+
.hm-ch .cz-ctx { margin-left: auto; margin-right: 6px; }
|
|
761
|
+
.hm-sugc.cpt { white-space: normal; }
|
|
762
|
+
.hm-sugs { font-style: normal; color: var(--cz-blueink); }
|
|
763
|
+
.hm-sugw { color: var(--cz-ink2); font-weight: 700; min-width: 0; }
|
|
764
|
+
.hm-sugx.ok { color: var(--cz-blueink); }
|
|
765
|
+
#hmTopTitle .cz-ctx { margin-left: 8px; vertical-align: -2px; }
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
.lv-t small { display: block; font-size: 12.5px; font-weight: 600; color: var(--cz-ink3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
35
35
|
.lv-tm { font-size: 12.5px; font-weight: 700; color: var(--cz-ink3); white-space: nowrap; font-variant-numeric: tabular-nums; flex: none; }
|
|
36
36
|
.cz-live .lv-tm { font-size: 13px; }
|
|
37
|
+
.lv-row .cz-ctx { margin: 0 8px 0 4px; } /* the context pie before the time (batch 13 item 8; drawn by ctx-wedge.js, styled in cozy.css) */
|
|
37
38
|
.lv-tm.rec { color: var(--cz-red); }
|
|
38
39
|
.lv-tm.stop { color: var(--cz-late); }
|
|
39
40
|
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
import { onRecording } from './rec-state.js';
|
|
18
18
|
import { ownTab, bring } from './rec-tab-core.js';
|
|
19
19
|
import { liveItems, keepOrder, pillLabel, rowLabel, clock, elapsed } from './live-model.js';
|
|
20
|
+
import { wedgeHtml } from './ctx-wedge.js'; // the same context pie as Home's rows, before the time (batch 13 item 8)
|
|
20
21
|
|
|
21
22
|
const esc = (v) => String(v == null ? '' : v).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]);
|
|
22
23
|
const SHEET = new URL('./cozy-live-pill.css', import.meta.url).href;
|
|
@@ -60,7 +61,7 @@ export function mountLivePill(doc = document, opts = {}) {
|
|
|
60
61
|
const was = L.marks.get(x.id), once = L.open && was && was !== x.mark;
|
|
61
62
|
return `<a class="lv-row${x.open ? ' cur' : ''}" href="${esc(x.href)}" data-lv="${esc(x.id)}" aria-label="${esc(rowLabel(x))}" aria-keyshortcuts="${i + 1}">`
|
|
62
63
|
+ `<span class="lv-mk">${x.kind === 'rec' ? `<i class="lv-m rec${x.paused ? ' paused' : ''}"></i>` : markHtml(x.mark, once)}</span>`
|
|
63
|
-
+ `<span class="lv-t">${esc(x.name)}<small>${esc(x.sub)}</small></span
|
|
64
|
+
+ `<span class="lv-t">${esc(x.name)}<small>${esc(x.sub)}</small></span>${wedgeHtml(x.ctx)}`
|
|
64
65
|
+ `<span class="lv-tm${x.kind === 'rec' && !x.paused ? ' rec' : x.mark === 'stop' ? ' stop' : ''}">${esc(x.time)}</span></a>`;
|
|
65
66
|
}).join('');
|
|
66
67
|
}
|
|
@@ -443,3 +443,6 @@ body.cz-home .hv-r.sp-on + .hv-r::before { display: none; }
|
|
|
443
443
|
.hv-card .hv-r.two .hm-rm { min-height: 58px; }
|
|
444
444
|
}
|
|
445
445
|
body.cz-home .hm-hd.hv-bar { padding: 0; }
|
|
446
|
+
|
|
447
|
+
/* A session's context (batch 13 item 8, XctxA1Desk): the pie sits at the row's end. Claude's ✦ Compact uses item 7's ✦ and ✓ (.hm-sv, .hm-cls) */
|
|
448
|
+
.hm-rm .cz-ctx { margin: 0 6px 0 8px; }
|
|
@@ -190,6 +190,12 @@ body.cz { margin: 0; font-family: var(--cz-sans); color: var(--cz-ink); backgrou
|
|
|
190
190
|
.cz-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; position: relative; }
|
|
191
191
|
.cz-dot.you { background: var(--cz-blue); } .cz-dot.late { background: var(--cz-dot-late); } .cz-dot.risk { background: var(--cz-dot-risk); }
|
|
192
192
|
.cz-dot.red { background: var(--cz-dot-red); } .cz-dot.ok { background: var(--cz-dot-ok); } .cz-dot.q { background: var(--cz-dot-q); }
|
|
193
|
+
/* How full a session's context is (batch 13 item 8, XctxA1Desk): a small pie at the row's end, from 50%. Grey, amber from 70%, red from 90%
|
|
194
|
+
* with the critical pulse. A pie, not a ring: the hollow ring already means running. pm/ctx-wedge.js draws it. */
|
|
195
|
+
.cz-ctx { --c: var(--cz-ink3); width: 14px; height: 14px; border-radius: 50%; flex: none; display: inline-block; position: relative; background: conic-gradient(var(--c) var(--p, 0%), var(--cz-well2) 0); }
|
|
196
|
+
.cz-ctx.warn { --c: var(--cz-dot-risk); } .cz-ctx.crit { --c: var(--cz-dot-red); }
|
|
197
|
+
.cz-ctx.p50 { --p: 50%; } .cz-ctx.p55 { --p: 55%; } .cz-ctx.p60 { --p: 60%; } .cz-ctx.p65 { --p: 65%; } .cz-ctx.p70 { --p: 70%; } .cz-ctx.p75 { --p: 75%; } .cz-ctx.p80 { --p: 80%; } .cz-ctx.p85 { --p: 85%; } .cz-ctx.p90 { --p: 90%; } .cz-ctx.p95 { --p: 95%; } .cz-ctx.p100 { --p: 100%; }
|
|
198
|
+
.cz-ctx.crit::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: var(--c); animation: cz-crit 1.6s ease-out infinite; }
|
|
193
199
|
|
|
194
200
|
/* ── Motion signals importance only, by level. Nothing else moves. ── */
|
|
195
201
|
.cz-dot.m-info::after, .cz-dot.m-warn::after, .cz-dot.m-crit::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: inherit; }
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* ctx-wedge.js — how full a session's context is, as Home, the chat header and the Live pill draw it (batch 13 item 8, canvas XctxA1Desk).
|
|
2
|
+
*
|
|
3
|
+
* A session row from /api/sessions carries `ctx` (lib/context-use.js): { used, window, pct, level, at, advise }. Under 50% nothing shows
|
|
4
|
+
* (zero is silence). From 50% a small pie at the row's end; amber from 70%, red with the critical pulse from 90%. Hover or a long press
|
|
5
|
+
* says "116k of 200k used · last turn 10:12". `advise: 'compact'` is Claude's ✦ proposal: the row's quiet line says so and ✓ types /compact.
|
|
6
|
+
* Safe to close (item 7) outranks it: a row keeps one ✦. */
|
|
7
|
+
|
|
8
|
+
const esc = (x) => String(x == null ? '' : x).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
9
|
+
const k = (n) => (n >= 1e6 ? (n / 1e6).toFixed(n % 1e6 ? 1 : 0) + 'M' : Math.round(n / 1000) + 'k');
|
|
10
|
+
const hm = (iso) => { const d = new Date(iso); return isNaN(d) ? '' : String(d.getHours()).padStart(2, '0') + ':' + String(d.getMinutes()).padStart(2, '0'); };
|
|
11
|
+
|
|
12
|
+
/** "116k of 200k used · last turn 10:12" */
|
|
13
|
+
export function ctxLine(c) {
|
|
14
|
+
if (!c || !(c.used > 0)) return '';
|
|
15
|
+
const head = c.window ? `${k(c.used)} of ${k(c.window)} used` : `${k(c.used)} used`;
|
|
16
|
+
const t = c.at ? hm(c.at) : '';
|
|
17
|
+
return t ? `${head} · last turn ${t}` : head;
|
|
18
|
+
}
|
|
19
|
+
/** The pie, or '' under 50% or with no window. */
|
|
20
|
+
export function wedgeHtml(c) {
|
|
21
|
+
if (!c || c.pct == null || c.pct < 50) return '';
|
|
22
|
+
const say = `Context ${c.pct}% full: ${ctxLine(c)}`;
|
|
23
|
+
// the fill is a class in 5-point steps (cozy.css .cz-ctx.p50 … .p100): no inline style (conformance R28-1)
|
|
24
|
+
const step = Math.min(100, Math.floor(c.pct / 5) * 5);
|
|
25
|
+
return `<span class="cz-ctx p${step}${c.level === 'warn' || c.level === 'crit' ? ' ' + c.level : ''}" role="img" aria-label="${esc(say)}" title="${esc(ctxLine(c))}"></span>`;
|
|
26
|
+
}
|
|
27
|
+
/* ✕ on the proposal (and ✓, until the compact lands) hides it until the session is 10 points fuller; a pie that shrank starts again.
|
|
28
|
+
* Kept in this browser only. */
|
|
29
|
+
const HID = 'cz-ctx-x:';
|
|
30
|
+
const hidAt = (sid) => { try { const v = Number(localStorage.getItem(HID + sid)); return v > 0 ? v : 0; } catch { return 0; } };
|
|
31
|
+
export function hideOffer(sid, pct) { try { localStorage.setItem(HID + sid, String(pct || 0)); } catch { /* a private window: it shows again */ } }
|
|
32
|
+
/** Claude proposes to compact it: the words of the ✦ line, else null. `closes`: the row already proposes closing (item 7), which wins. */
|
|
33
|
+
export function compactOffer(c, closes = false, sid = '') {
|
|
34
|
+
if (closes || !c || c.advise !== 'compact') return null;
|
|
35
|
+
const h = sid ? hidAt(sid) : 0;
|
|
36
|
+
if (h && c.pct < h) { try { localStorage.removeItem(HID + sid); } catch { /* nothing kept */ } } // it shrank: it was compacted, start again
|
|
37
|
+
else if (h && c.pct < h + 10) return null;
|
|
38
|
+
return c.pct >= 90 ? `${c.pct}% full. Compact now, or new turns may lose the start of this chat` : `${c.pct}% full. Compact it before the next task`;
|
|
39
|
+
}
|
|
40
|
+
/** The ✓ that accepts it: types /compact into that session (POST /api/session/compact). */
|
|
41
|
+
export function compactBtnHtml(sid, pct) {
|
|
42
|
+
const say = `Compact this session; Claude says its context is ${pct}% full`;
|
|
43
|
+
// the same ✓ as item 7's close (.hm-cls): one look for "accept what Claude proposes" on a row
|
|
44
|
+
return `<button type="button" class="ut-ib hv-ib hm-cls" data-hm-compact="${esc(sid)}" aria-label="${esc(say)}" title="Compact this session (types /compact)"><svg aria-hidden="true" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M5 12l5 5 9-10"/></svg></button>`;
|
|
45
|
+
}
|
|
@@ -44,6 +44,7 @@ import { mountRecRow, clockOf as recClock } from './home-rec-row.js';
|
|
|
44
44
|
import { mountSesName } from './home-ses-name.js'; // session names A: tap the session's name to rename it (canvas XmsNames)
|
|
45
45
|
import * as SM from './split-merge.js'; // split one initiative in two, or merge two: Claude suggests, the PM approves (batch 11 item 14)
|
|
46
46
|
import * as PM from './prog-move.js'; // move an initiative out of its program, or to another (canvas LpA1More, LpA2Other, LpA4Phone)
|
|
47
|
+
import * as CW from './ctx-wedge.js'; // how full a session's context is, and Claude's ✦ Compact (batch 13 item 8, XctxA1Desk)
|
|
47
48
|
import * as PO from './prog-order.js'; // a program's order on Home: the grip, hold-then-drag on a phone, ✦ Claude's order from the dates (canvas RoAPhone)
|
|
48
49
|
import * as LPV from './loose-props.js'; // Claude's clean-up of "Not in an initiative": the ✦ on its header and the Viewer (batch 13 item 3)
|
|
49
50
|
import { initiativeRename, taskRename } from './rename-press.js'; // tap the title to rename (canvas RnATask, RnASaved) // the pinned recording row above it (XvARecHome)
|
|
@@ -488,7 +489,7 @@ function drawTop() {
|
|
|
488
489
|
// is back + that name only, no second line (XmsNames, XcbOptions)
|
|
489
490
|
const ses = cur.ses ? S.D.sessions.find((x) => x.id === cur.ses) : null;
|
|
490
491
|
const title = ses ? H.nameOf(ses) : cur.title;
|
|
491
|
-
const th = ses && isPhone() ? SN.titleHtml(ses.id, title) : esc(title || '');
|
|
492
|
+
const th = ses && isPhone() ? SN.titleHtml(ses.id, title) + CW.wedgeHtml(ses.ctx) : esc(title || ''); // its context pie after the name (XctxA2Phones)
|
|
492
493
|
const tb = $('#hmTopTitle'); if (tb.__h !== th) { tb.__h = th; tb.innerHTML = th; }
|
|
493
494
|
$('#hmTopSub').textContent = '';
|
|
494
495
|
$('#hmNeedsN').textContent = !S.ready ? 'Reading' : n ? n + (n === 1 ? ' next step' : ' next steps') : 'Today';
|
|
@@ -516,6 +517,10 @@ const chat = mountChat($('#hmChat'), {
|
|
|
516
517
|
unqueue: (sid, at) => { pmPost('/api/home-desk/queue-drop', { session: sid, at }); if (S.D.desk && S.D.desk.queued && S.D.desk.queued[sid]) S.D.desk.queued[sid] = S.D.desk.queued[sid].filter((x) => x.at !== at); },
|
|
517
518
|
onScope: (b) => menu(b, scopeItems(), 'Where this goes'),
|
|
518
519
|
suggestLink: (t, first) => suggestLink(t, first),
|
|
520
|
+
// Claude's ✦ Compact in the chat's offer chip (batch 13 item 8): only when the link chip has nothing to say
|
|
521
|
+
compactOffer: (sid) => { const s = S.D.sessions.find((x) => x.id === sid); const w = s && CW.compactOffer(s.ctx, !!(s.close_ok && s.close_ok.safe), sid); return w ? { text: w, pct: s.ctx.pct } : null; },
|
|
522
|
+
compact: (sid) => compact(sid),
|
|
523
|
+
dismissCompact: (sid, pct) => CW.hideOffer(sid, pct),
|
|
519
524
|
linkTo: (sid, ini) => link(sid, ini),
|
|
520
525
|
dismissLink: (sid) => { try { localStorage.setItem('cz-linksug-x:' + sid, '1'); } catch { /* a private window: it shows again next time */ } },
|
|
521
526
|
onLink: (b, t) => menu(b, H.boardRows(S.D).map((r) => ({ label: r.title, sub: r.stage, go: () => link(t.sid, r.id) })), 'Link it to an initiative'),
|
|
@@ -538,7 +543,7 @@ function chatHead(t) {
|
|
|
538
543
|
if (t.prog) return { row: r, title: t.title, scope: t.prog.title, prog: true };
|
|
539
544
|
const title = r && r.kind !== 'ini' ? r.name : t.title;
|
|
540
545
|
// session names A: an open session's name is the rename press (or the field while it is renamed)
|
|
541
|
-
if (t.ses) { const s = S.D.sessions.find((x) => x.id === t.ses); if (s) return { ...chatHeadOf(t, r, H.nameOf(s)), titleHtml: SN.titleHtml(s.id, H.nameOf(s), 'hm-chb') }; }
|
|
546
|
+
if (t.ses) { const s = S.D.sessions.find((x) => x.id === t.ses); if (s) return { ...chatHeadOf(t, r, H.nameOf(s)), titleHtml: SN.titleHtml(s.id, H.nameOf(s), 'hm-chb'), ctx: s.ctx || null }; }
|
|
542
547
|
return chatHeadOf(t, r, title);
|
|
543
548
|
}
|
|
544
549
|
function chatHeadOf(t, r, title) {
|
|
@@ -1457,6 +1462,7 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
|
|
|
1457
1462
|
if (d.hmSes) { sesPill(d.hmSes === S.ses ? null : d.hmSes); return; } // an initiative's pill: what sits in it, under it (a sheet on a phone)
|
|
1458
1463
|
if ('hmSesx' in d) { sesPill(null); return; }
|
|
1459
1464
|
if (d.hmSesnew) { sesPill(null, false); newIn(d.hmSesnew); return; }
|
|
1465
|
+
if (d.hmCompact) { compact(d.hmCompact); return; } // ✓ on Claude's ✦ Compact (batch 13 item 8): the pill's list stays open
|
|
1460
1466
|
if (S.ses && !b.closest('.hv-spp, .hv-sps')) sesPill(null, false); // a press anywhere else in the list closes it
|
|
1461
1467
|
if (d.hmSel) { if (S.ses) sesPill(null, false); if (S.day) S.day = false; select(d.hmSel); return; }
|
|
1462
1468
|
if ('hrMentions' in d) { if (S.day) S.day = false; S.sel = 'mentions'; drawList(); MEN.openMentions(menCtx()); return; }
|
|
@@ -1492,6 +1498,13 @@ $('#hmList').onclick = (e) => { // delegated: every press on the list is a <bu
|
|
|
1492
1498
|
if (d.hmRecopen) { if (!(ownTab() && bring(tabUrl(d.hmRecopen, { ws: WS || '' })))) openMeeting({ note: d.hmRecopen }); return; }
|
|
1493
1499
|
};
|
|
1494
1500
|
$('#hmList').addEventListener('keydown', (e) => { if (e.key === 'Escape' && e.target.id === 'hmCap' && S.cap) { e.stopPropagation(); S.cap = false; drawList(); } else if (e.key === 'Escape' && S.day) { e.stopPropagation(); day(false); } });
|
|
1501
|
+
/** Claude's ✦ Compact, accepted (batch 13 item 8): type /compact into that session. Its pie shrinks after the session's next reply. */
|
|
1502
|
+
async function compact(sid) {
|
|
1503
|
+
const s = S.D.sessions.find((x) => x.id === sid);
|
|
1504
|
+
const r = await pmPost('/api/session/compact', { id: sid });
|
|
1505
|
+
if (r && r.ok && s && s.ctx) { CW.hideOffer(sid, s.ctx.pct); drawList(); } // the ✦ stays away until the session's next reply moves the pie
|
|
1506
|
+
toast(r && r.ok ? 'Compacting “' + (s ? H.nameOf(s) : 'the session') + '”. Its context shrinks when it answers.' : (r && r.error) || 'Nothing was typed.');
|
|
1507
|
+
}
|
|
1495
1508
|
/** Open (id) or close (null) the list behind an initiative's pill (batch 12 item 6). Closing gives the focus back to the pill, unless the
|
|
1496
1509
|
* press that closed it goes somewhere else (back false). */
|
|
1497
1510
|
function sesPill(id, back = true) {
|
|
@@ -159,8 +159,11 @@ export function mountChat(el, host) {
|
|
|
159
159
|
// A loose chat that reads like one initiative gets one quiet chip at its top: "Looks like <initiative> · Link it ×" (XvALinkSuggest).
|
|
160
160
|
function drawSug() {
|
|
161
161
|
const t = C.t, g = t && t.scope && t.scope.loose && t.sid && host.suggestLink ? host.suggestLink(t, firstUser()) : null;
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
// with nothing to link, the same chip carries Claude's ✦ Compact from 70% on the PM's turn (batch 13 item 8, XctxA1Desk): ✓ types /compact
|
|
163
|
+
const cp = !g && sid() && host.compactOffer ? host.compactOffer(sid()) : null;
|
|
164
|
+
sug.hidden = !g && !cp; C.sug = g; C.cpt = cp;
|
|
165
|
+
put(sug, g ? `<span class="hm-sugc">Looks like <b>${esc(g.title)}</b><button type="button" class="hm-sugl" data-hm-sug="link">Link it</button><button type="button" class="hm-sugx" data-hm-sug="x" aria-label="Not this one" title="Not this one">${SVG(XX, 13)}</button></span>`
|
|
166
|
+
: cp ? `<span class="hm-sugc cpt"><i class="hm-sugs" aria-hidden="true">✦</i><span class="hm-sugw">${esc(cp.text)}</span><button type="button" class="hm-sugx ok" data-hm-cpt="ok" aria-label="Compact this session" title="Compact (types /compact)">${SVG(OK, 13)}</button><button type="button" class="hm-sugx" data-hm-cpt="x" aria-label="Not now" title="Not now">${SVG(XX, 13)}</button></span>` : '');
|
|
164
167
|
}
|
|
165
168
|
function draw() {
|
|
166
169
|
const t = C.t; if (!t) return;
|
|
@@ -438,6 +441,8 @@ export function mountChat(el, host) {
|
|
|
438
441
|
return;
|
|
439
442
|
}
|
|
440
443
|
const b = e.target.closest('button, [data-file], [data-att], [data-ctx]'); if (!b || !el.contains(b)) return;
|
|
444
|
+
// ✓ types /compact (and hides the ✦ until the pie moves); ✕ hides it until the session is 10 points fuller
|
|
445
|
+
if (b.dataset.hmCpt && C.cpt) { if (b.dataset.hmCpt === 'ok') host.compact(sid()); else host.dismissCompact(sid(), C.cpt.pct); C.cpt = null; sug.hidden = true; put(sug, ''); return; }
|
|
441
446
|
if (b.dataset.hmSug && C.sug) { const g = C.sug; if (b.dataset.hmSug === 'link') host.linkTo(C.t.sid, g.id); else { host.dismissLink(C.t.sid); drawSug(); } return; }
|
|
442
447
|
const d = b.dataset;
|
|
443
448
|
const ic = b.closest('.hm-icard'), card = C.t && C.t.intro && C.t.intro.card;
|
|
@@ -73,7 +73,8 @@ export function sessionRow(s, roles) {
|
|
|
73
73
|
const name = nameOf(s);
|
|
74
74
|
return { id: 's:' + s.id, kind: 'session', sid: s.id, key: keyOfSession(s), ini: iniOfSession(s), name, state: st, initial: role.initial, role,
|
|
75
75
|
hint: role.name, icon: 'chat', created: s.created || '', prog: s.progress && s.progress.n > 0 ? s.progress : null,
|
|
76
|
-
...(s.close_ok && st === 'quiet' ? { close: s.close_ok } : {})
|
|
76
|
+
...(s.close_ok && st === 'quiet' ? { close: s.close_ok } : {}), // idle 30 min: { safe, say } (batch 13 item 7, lib/idle-close.js)
|
|
77
|
+
ctx: s.ctx || null }; // how full its context is, and Claude's ✦ Compact (batch 13 item 8; pm/ctx-wedge.js) // the state is the dot beside the row, not a word (testing fixes)
|
|
77
78
|
}
|
|
78
79
|
/** The sessions as Home reads them. A session PMOS started (a skill, a background job) reads 'needs' as soon as its prompt is done:
|
|
79
80
|
* its turn ending asks nothing of the PM, so it is a finished run, quiet, and never a row that waits on the PM (testing fixes).
|
|
@@ -15,6 +15,7 @@ import { whenOf } from './home-list.js';
|
|
|
15
15
|
import { chipHtml } from './cozy-pick.js'; // the one product picker Home, Board and Insights share (batch 12 item 5)
|
|
16
16
|
import { ringHtml } from './home-line.js';
|
|
17
17
|
import { gripHtml, sugHtml } from './prog-order.js'; // a program's order: the grip and ✦ (canvas RoADrag, RoAPhone)
|
|
18
|
+
import * as CW from './ctx-wedge.js'; // how full a session's context is: the pie, and Claude's ✦ Compact (batch 13 item 8, XctxA1Desk)
|
|
18
19
|
|
|
19
20
|
export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
20
21
|
export const P = {
|
|
@@ -63,8 +64,13 @@ export function rowHtml(r, o) {
|
|
|
63
64
|
const end = !sel ? '' : r.kind === 'session' && r.sid ? `<button type="button" class="ut-ib hm-x" data-hm-end="${esc(r.id)}" aria-label="End ${esc(r.name)}" title="End this session">${svg(P.x, 14)}</button>`
|
|
64
65
|
: r.kind === 'need' && r.row && r.row.kind !== 'source' ? `<button type="button" class="ut-ib hm-x" data-hm-end="${esc(r.id)}" aria-label="Put off ${esc(r.name)} until tomorrow" title="Put off until tomorrow">${svg(P.x, 14)}</button>` : '';
|
|
65
66
|
const link = r.link && r.kind === 'loose-rec' ? '<span class="hv-st">Link it</span>' : '';
|
|
67
|
+
// a session's context (batch 13 item 8): the pie from 50%; in the pill's list, from 70% on the PM's turn, Claude's ✦ Compact and its ✓, drawn
|
|
68
|
+
// as item 7's ✦ close is. Safe to close (item 7) outranks it: one ✦ per row.
|
|
69
|
+
const cx = r.kind === 'session' ? r.ctx : null;
|
|
70
|
+
const offer = cx && o.sub ? CW.compactOffer(cx, !!(o.safe || (r.close && r.close.safe)), r.sid) : null;
|
|
71
|
+
const sv = o.safe || offer ? '<i class="hm-sv" aria-hidden="true">✦</i>' : '';
|
|
66
72
|
return `<div class="${cls}" data-id="${esc(r.id)}">${lead}<button type="button" class="hm-rm" data-hm-sel="${esc(r.id)}"${sel ? ' aria-current="true"' : ''}${r.hint ? ` title="${esc(r.hint)}"` : ''}>${lead ? '' : markHtml(r)}`
|
|
67
|
-
+ `<span class="hm-rt${r.ms ? ' ms' : ''}"><b>${esc(r.name)}</b>${r.ms ? MS : ''}${o.sub ? `<em>${
|
|
73
|
+
+ `<span class="hm-rt${r.ms ? ' ms' : ''}"><b>${esc(r.name)}</b>${r.ms ? MS : ''}${o.sub ? `<em>${sv}${esc(offer || o.sub)}</em>` : ''}</span>${o.sub ? '' : clock(r.when || whenOf(r))}${CW.wedgeHtml(cx)}${link}</button>${end}${offer ? CW.compactBtnHtml(r.sid, cx.pct) : o.act || ''}</div>`;
|
|
68
74
|
}
|
|
69
75
|
/** The chat's header line on a desktop (HvACDesk .ch): the open row's mark, its title and the chip of where it sits (the initiative's stage
|
|
70
76
|
* track and name, or the program's tile and name). h: { row, title, scope, at, stage, prog }. A chip that repeats the title is left out, and
|
|
@@ -78,7 +84,7 @@ export function chatHeadHtml(h) {
|
|
|
78
84
|
const chip = same ? '' : `<span class="hm-chs" title="In ${esc(h.scope)}">${h.prog ? svg(P.layers, 13) : track(h.at == null ? -1 : h.at, h.stage || '', h.steps)}<span>${esc(h.scope)}</span></span>`;
|
|
79
85
|
// session names A: an open session's name comes as the rename press (or the field), drawn by home-ses-name.js
|
|
80
86
|
const name = h.titleHtml ? `<span class="hm-chn">${h.titleHtml}</span>` : `<b class="hm-chb">${esc(h.title)}</b>`;
|
|
81
|
-
return `${mk}${same ? lead : ''}${name}${same && !h.prog ? track(h.at == null ? -1 : h.at, h.stage || '', h.steps) : ''}${chip}`;
|
|
87
|
+
return `${mk}${same ? lead : ''}${name}${same && !h.prog ? track(h.at == null ? -1 : h.at, h.stage || '', h.steps) : ''}${chip}${CW.wedgeHtml(h.ctx || (r && r.kind === 'session' ? r.ctx : null))}`;
|
|
82
88
|
}
|
|
83
89
|
/* ── what sits in an initiative: the pill on its row (batch 12 item 6, canvas HsA1Desk, HsA2Phone, HsA3Sheet) ──
|
|
84
90
|
* Sessions, next steps and today's meetings no longer nest under the initiative (Wawan, 2026-10-26: Home grew too long). The row keeps one
|
|
@@ -72,7 +72,7 @@ export function liveItems(sessions, o = {}) {
|
|
|
72
72
|
const at = ms(s.touched_at) || ms(s.created);
|
|
73
73
|
const ini = iniOf(s);
|
|
74
74
|
rows.push({ id: 's:' + s.id, kind: 'ses', sid: s.id, mark, name: nameOf(s), sub: mark === 'stop' ? 'Stopped · restart it' : ini ? titles[ini] || ini : 'Not in an initiative',
|
|
75
|
-
at, time: ago(now - at), href: '/premium.html?session=' + encodeURIComponent(s.id), open: !!o.open && o.open === s.id });
|
|
75
|
+
at, time: ago(now - at), href: '/premium.html?session=' + encodeURIComponent(s.id), open: !!o.open && o.open === s.id, ctx: s.ctx || null });
|
|
76
76
|
}
|
|
77
77
|
rows.sort((a, b) => b.at - a.at || (a.id < b.id ? -1 : 1));
|
|
78
78
|
return out.concat(rows).slice(0, max);
|
package/workspace/server.js
CHANGED
|
@@ -126,6 +126,7 @@ const consoleState = require('./lib/console-state'); // read-only console surf
|
|
|
126
126
|
const boardCache = require('./lib/board-cache'); // the workflow board, cached + derived off the event loop (R4)
|
|
127
127
|
const fmParse = require('./lib/file-mode-parse'); // canonical file-mode parsers, shared with metrics.py (D64 D)
|
|
128
128
|
const skillsReg = require('./lib/skills-registry'); // discovered and generated skills: quarantine, provenance, local approval (D76)
|
|
129
|
+
const contextUse = require('./lib/context-use'); // how full a session's context is, and Claude's ✦ Compact proposal (batch 13 item 8)
|
|
129
130
|
const modelLib = require('./lib/models'); // tier routing — one code path, shared with the agents' CLI (D75)
|
|
130
131
|
const memoryLib = require('./lib/memory'); // curated repository memory — one ledger code path, shared with the agents' CLI (D72)
|
|
131
132
|
const audit = require('./lib/audit'); // the workflow audit — the sweep the agents' CLI runs, read-only here (D77)
|
|
@@ -3453,6 +3454,14 @@ function sessionProgress(s, shown) {
|
|
|
3453
3454
|
return steps && steps.length ? { done: steps.filter((x) => x.state === 'done').length, n: steps.length } : null;
|
|
3454
3455
|
} catch { return null; }
|
|
3455
3456
|
}
|
|
3457
|
+
/** How full the session's context is (lib/context-use.js). The window comes from the model PMOS started or switched it to, else the CLI's
|
|
3458
|
+
* own setting. advise: 'compact' when Claude proposes it (70%+, the PM's turn), else null. */
|
|
3459
|
+
function sessionCtx(s, hx, shown) {
|
|
3460
|
+
if (!hx || !hx.context || s.state === 'exited') return null;
|
|
3461
|
+
const m = s.model || {};
|
|
3462
|
+
const c = contextUse.of(hx.context, [m.switched && m.switched.model, m.model].concat(contextUse.cliHints(s.root)));
|
|
3463
|
+
return c ? { ...c, advise: contextUse.advise(c, shown) } : null;
|
|
3464
|
+
}
|
|
3456
3465
|
function sessionList() {
|
|
3457
3466
|
const now = Date.now();
|
|
3458
3467
|
// ONE profiles read per broadcast, not one per session: the line is a formatter over the
|
|
@@ -3496,6 +3505,8 @@ function sessionList() {
|
|
|
3496
3505
|
shown: sessionState.presented(d.state, hx && hx.turn), quietMs: d.quietMs,
|
|
3497
3506
|
// the chat progress line's Home ring (XcbOptions B, case 8): { done, n } of the goal's points or the session's own steps, else null
|
|
3498
3507
|
progress: sessionProgress(s, sessionState.presented(d.state, hx && hx.turn)),
|
|
3508
|
+
// context use (batch 13 item 8, XctxA1Desk): { used, window, pct, level, at, advise } of the newest turn, else null
|
|
3509
|
+
ctx: sessionCtx(s, hx, sessionState.presented(d.state, hx && hx.turn)),
|
|
3499
3510
|
// The rendered word for that state — computed HERE rather than in each client, because it is
|
|
3500
3511
|
// the same join (`sessionState.label`) with the same clock, and a client re-deriving it was
|
|
3501
3512
|
// already producing a second, slightly different sentence for one session.
|
|
@@ -7706,6 +7717,23 @@ async function handleRequest(req, res) {
|
|
|
7706
7717
|
if (!mc.core.attachOutcome(w.root, body.id, { outcome: body.outcome, applied_tier: body.tier })) return json(res, { ok: false, error: 'an id from a routed prompt and an outcome of ' + mc.core.OUTCOMES.join(', ') + ' are needed (and the decisions ledger opted in)' }, 400);
|
|
7707
7718
|
return json(res, { ok: true });
|
|
7708
7719
|
}
|
|
7720
|
+
if (p === '/api/session/compact' && req.method === 'POST') {
|
|
7721
|
+
// batch 13 item 8 — the PM's ✓ on Claude's ✦ Compact proposal: type the harness's own `/compact` into the pane. On the PM's press only,
|
|
7722
|
+
// only for a running Claude session, and only on the PM's turn: a compact typed while it works would land in the middle of a turn.
|
|
7723
|
+
let body = {}; try { body = JSON.parse((await readBody(req)) || '{}'); } catch { return json(res, { ok: false, error: 'invalid JSON body' }, 400); }
|
|
7724
|
+
const s = sessions.get(String(body.id || ''));
|
|
7725
|
+
if (!s) return json(res, { ok: false, error: 'no such session' }, 404);
|
|
7726
|
+
if (!s.pty || s.state === 'exited') return json(res, { ok: false, error: 'that session is not running — there is nothing to compact' }, 400);
|
|
7727
|
+
if (s.agent !== 'claude') return json(res, { ok: false, error: `'${s.agent}' has no compact command PMOS has checked — nothing was typed` }, 400);
|
|
7728
|
+
const hx = transcriptHarness(s);
|
|
7729
|
+
const shown = sessionState.presented(harness.deriveState(s.state, s.lastOutputAt, Date.now()).state, hx && hx.turn);
|
|
7730
|
+
if (shown !== 'needs' && shown !== 'quiet') return json(res, { ok: false, error: 'it is working — compact it when its turn ends' }, 409);
|
|
7731
|
+
try { s.pty.write('/compact\r'); }
|
|
7732
|
+
catch (e) { return json(res, { ok: false, error: 'could not write to the session — ' + String((e && e.message) || e).slice(0, 100) }, 500); }
|
|
7733
|
+
touchSession(s);
|
|
7734
|
+
pushSessions();
|
|
7735
|
+
return json(res, { ok: true, note: 'typed /compact into the pane' });
|
|
7736
|
+
}
|
|
7709
7737
|
if (p === '/api/session/model' && req.method === 'POST') {
|
|
7710
7738
|
// D75 — switch the model of a RUNNING Claude session, on the PM's press only. It types the harness's own
|
|
7711
7739
|
// `/model <model>` command into the pane; effort is not changed by it. Never automatic, never for a binary
|