create-pmos 0.338.0 → 0.340.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-pmos",
3
- "version": "0.338.0",
3
+ "version": "0.340.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,30 @@
32
32
  "audit"
33
33
  ],
34
34
  "pmosChanges": [
35
+ {
36
+ "v": "0.340.0",
37
+ "at": "2026-10-20T03:15:05.728Z",
38
+ "f": 2,
39
+ "prs": [
40
+ {
41
+ "n": 935,
42
+ "t": "A Briefing row when a /goal ends or needs the PM",
43
+ "s": "Each such goal adds one row to the Briefing list, built in the existing row pattern."
44
+ }
45
+ ]
46
+ },
47
+ {
48
+ "v": "0.339.0",
49
+ "at": "2026-10-20T03:01:53.405Z",
50
+ "f": 2,
51
+ "prs": [
52
+ {
53
+ "n": 934,
54
+ "t": "A started /goal keeps working until it is done",
55
+ "s": "Every chat panel session starts with a Claude Code Stop hook."
56
+ }
57
+ ]
58
+ },
35
59
  {
36
60
  "v": "0.338.0",
37
61
  "at": "2026-10-20T02:42:22.826Z",
@@ -282,30 +306,6 @@
282
306
  "s": "Any markdown file (a PRD, a new doc, a report cycle) opens as one page in a viewer tab beside the dialog: title, byline from the edit log, a properties table from the front matter, then panels, tables, task lists…"
283
307
  }
284
308
  ]
285
- },
286
- {
287
- "v": "0.320.0",
288
- "at": "2026-10-19T15:12:24.143Z",
289
- "f": 2,
290
- "prs": [
291
- {
292
- "n": 899,
293
- "t": "Premium dialog viewer with tabs",
294
- "s": "The right pane can open other items as tabs beside its own detail, with at most 4 extra tabs."
295
- }
296
- ]
297
- },
298
- {
299
- "v": "0.319.0",
300
- "at": "2026-10-19T14:50:54.311Z",
301
- "f": 2,
302
- "prs": [
303
- {
304
- "n": 897,
305
- "t": "My work has no Calendar card; the Briefing holds the calendar",
306
- "s": "My work has no calendar."
307
- }
308
- ]
309
309
  }
310
310
  ]
311
311
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@4bd533cc
1
+ kernel-source: pmos@a2c7742b
2
2
  assembled: 2026-10-20
3
3
  mode: vendor
@@ -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-20T02:42:19Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-20T03:15:03Z"}
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-20T02:42:19Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-20T03:15:03Z"}
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-20T02:42:19Z"}
5
+ generated: {by: process:create-pmos, at: "2026-10-20T03:15:03Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,28 @@
1
1
  [
2
+ {
3
+ "v": "0.340.0",
4
+ "at": "2026-10-20T03:15:05.728Z",
5
+ "f": 2,
6
+ "prs": [
7
+ {
8
+ "n": 935,
9
+ "t": "A Briefing row when a /goal ends or needs the PM",
10
+ "s": "Each such goal adds one row to the Briefing list, built in the existing row pattern."
11
+ }
12
+ ]
13
+ },
14
+ {
15
+ "v": "0.339.0",
16
+ "at": "2026-10-20T03:01:53.405Z",
17
+ "f": 2,
18
+ "prs": [
19
+ {
20
+ "n": 934,
21
+ "t": "A started /goal keeps working until it is done",
22
+ "s": "Every chat panel session starts with a Claude Code Stop hook."
23
+ }
24
+ ]
25
+ },
2
26
  {
3
27
  "v": "0.338.0",
4
28
  "at": "2026-10-20T02:42:22.826Z",
@@ -389,4 +389,9 @@ Type `/` in the box to see the commands: `/goal`, `/compact` and `/clear`. Use t
389
389
  - **The goal card** shows the goal, its done points, what Claude may do, what it serves, the deadline and the round limit. Nothing runs until you press **Start**. **Change something** lets you say what to change; **Cancel** drops the goal.
390
390
  - **Start** tells Claude to work on the goal until every done point is met. Merging follows your standing rule (merge once required CI is green). Claude asks before anything that is sent to other people.
391
391
 
392
- Start and Cancel need the page's launch nonce too. The goal is kept in `goal-runs.jsonl` in the state folder.
392
+ - **While it works**, a goal card under the conversation shows the round, each done point met or open, and the deadline. The points are Claude's own report, so the card says "unverified". Each time Claude would stop with a point still open, it is told to keep going.
393
+ - **It stops by itself** when Claude reports every point met (Done), when it needs you (Needs you: answer it in the box and it goes on), at the deadline, after the round limit (12 unless the goal says fewer), or after 3 rounds that met no new point. The card says which.
394
+ - **Stop the goal** presses Esc in the session and ends the goal.
395
+ - **In the Briefing**, a goal that is done, stopped or needs you is a row at the top of the list. Pressing it opens the goal's own conversation. The row goes when you write in that conversation, or after a week.
396
+
397
+ Start, Cancel and Stop need the page's launch nonce too. The goal and each round are kept in `goal-runs.jsonl` in the state folder.
@@ -181,6 +181,7 @@ function chat({ runtimeDir, key, text, model, sessions, wsId, now = new Date() }
181
181
  const extra = goal ? { goal } : {};
182
182
  if (alive) {
183
183
  if (!sessions.type(live, msg)) return fail(409, 'The message did not reach the session. Open it in Agent sessions.');
184
+ if (!goal) Goal.resume({ runtimeDir, key, now }); // slice 3: the PM's answer to a goal that needs them sets it going again; a finished one is seen
184
185
  return { status: 200, body: { ok: true, session: live, started: false, ...extra } };
185
186
  }
186
187
  let s;
@@ -70,11 +70,122 @@ function goalOf(runtimeDir, key) {
70
70
  if (!l.trim()) continue; let e; try { e = JSON.parse(l); } catch { continue; }
71
71
  if (!e || e.key !== key) continue;
72
72
  if (e.event === 'grilling') g = { id: e.id, state: 'grilling', text: e.text, at: e.at };
73
- else if (g && e.id === g.id && (e.event === 'started' || e.event === 'cancelled')) g = { ...g, state: e.event, ...(e.draft ? { draft: e.draft } : {}), at: e.at };
73
+ else if (!g || e.id !== g.id) continue;
74
+ else if (e.event === 'started') g = { ...g, state: 'started', draft: e.draft, startedAt: e.at, rounds: 0, met: [], open: (e.draft && e.draft.done) || [], at: e.at };
75
+ else if (e.event === 'cancelled') g = { ...g, state: 'cancelled', at: e.at };
76
+ else if (e.event === 'round') g = { ...g, rounds: e.n, met: e.met || [], open: e.open || [], at: e.at };
77
+ else if (e.event === 'seen') g = { ...g, seen: true };
78
+ else if (e.event === 'resumed') g = { ...g, state: 'started', reason: undefined, at: e.at };
79
+ else if (['done', 'stopped', 'waiting'].includes(e.event)) g = { ...g, state: e.event, ...(e.reason ? { reason: e.reason } : {}), met: e.met || g.met, open: e.open || g.open, at: e.at };
74
80
  }
75
81
  return g;
76
82
  }
77
83
 
84
+ /* ── slice 3: until achieved (PRD U1–U7) ───────────────────────────────────────────────────────────────────────────────
85
+ * Claude Code's Stop hook posts here each time Claude would end its turn in a chat session. While the key's goal is started
86
+ * and not done, the answer blocks the stop and tells Claude what is still open; it lets Claude stop when Claude reports the
87
+ * goal done or needs the PM, at the deadline, after the round limit, or after NO_PROGRESS rounds that met no new point.
88
+ * The done check is Claude's own report (a pmos-goal progress block), so the page calls it unverified. */
89
+ const NO_PROGRESS = 3;
90
+ const REASON = { deadline: 'The deadline has passed.', limit: 'It used all its rounds.', 'no-progress': 'Three rounds in a row met no new done point.', pm: 'You stopped it.' };
91
+ /** The last fenced pmos-goal block in a message, parsed, or null. */
92
+ function blockOf(text) {
93
+ const re = /```pmos-goal[^\n]*\n([\s\S]*?)```/g;
94
+ let m, last = null; while ((m = re.exec(String(text || '')))) last = m;
95
+ if (!last) return null;
96
+ try { const b = JSON.parse(last[1]); return b && typeof b === 'object' ? b : null; } catch { return null; }
97
+ }
98
+ const strs = (a) => (Array.isArray(a) ? a.map((x) => clip(x, 200)).filter(Boolean).slice(0, 8) : null);
99
+ /** The chat key a session belongs to (premium-chat-sessions.jsonl, the last line that names it), or null. */
100
+ function keyOfSession(runtimeDir, session, chatsFile) {
101
+ let t; try { t = fs.readFileSync(path.join(runtimeDir, chatsFile), 'utf8'); } catch { return null; }
102
+ let key = null;
103
+ for (const l of t.split('\n')) { if (!l.trim()) continue; let e; try { e = JSON.parse(l); } catch { continue; } if (e && e.session === session && typeof e.key === 'string') key = e.key; }
104
+ return key;
105
+ }
106
+ const roundsOf = (runtimeDir, id) => {
107
+ let t; try { t = fs.readFileSync(path.join(runtimeDir, RUNS), 'utf8'); } catch { return []; }
108
+ return t.split('\n').filter((l) => l.trim()).map((l) => { try { return JSON.parse(l); } catch { return null; } }).filter((e) => e && e.id === id && e.event === 'round');
109
+ };
110
+ /** The Stop hook's answer for one chat session: {} lets Claude stop; { decision: 'block', reason } keeps it working. */
111
+ function onStop({ runtimeDir, key, message, now = new Date() }) {
112
+ const g = key && goalOf(runtimeDir, key);
113
+ if (!g || g.state !== 'started' || !g.draft) return {};
114
+ const d = g.draft, b = blockOf(message), all = d.done || [];
115
+ const met = (b && b.step === 'progress' && strs(b.met)) || g.met || [];
116
+ const open = (b && b.step === 'progress' && strs(b.open)) || all.filter((x) => !met.includes(x));
117
+ const base = { id: g.id, key, met, open, at: now.toISOString() };
118
+ if (b && b.step === 'progress' && (b.state === 'done' || (open.length === 0 && met.length > 0))) { append(runtimeDir, { event: 'done', ...base }); return {}; }
119
+ if (b && b.step === 'progress' && b.state === 'needs-you') { append(runtimeDir, { event: 'waiting', ...base }); return {}; }
120
+ const due = Date.parse(d.by || '');
121
+ const stop = (reason) => { append(runtimeDir, { event: 'stopped', reason, ...base }); return {}; };
122
+ if (Number.isFinite(due) && now.getTime() > due) return stop('deadline');
123
+ const n = (g.rounds || 0) + 1;
124
+ if (n > (d.limit || LIMIT)) return stop('limit');
125
+ const prev = roundsOf(runtimeDir, g.id);
126
+ if (prev.length >= NO_PROGRESS && prev.slice(-NO_PROGRESS).every((r) => (r.met || []).length >= met.length)) return stop('no-progress');
127
+ append(runtimeDir, { event: 'round', n, ...base });
128
+ return { decision: 'block', reason: '[PMOS /goal round ' + n + '] The goal is not done yet: ' + met.length + ' of ' + all.length + ' done points met. Keep working on: ' + (open.length ? open.join('; ') : 'the open points') + '. This is round ' + n + ' of ' + (d.limit || LIMIT) + '. If you need the PM, ask and end with a pmos-goal progress block whose state is needs-you. End each message with the progress block.' };
129
+ }
130
+ /** The PM wrote in the goal's conversation. A goal that waits on them is working again (U3); a finished or stopped goal is seen,
131
+ * so its Briefing row goes (U7). A goal in any other state is left as it is. */
132
+ function resume({ runtimeDir, key, now = new Date() }) {
133
+ const g = goalOf(runtimeDir, key);
134
+ if (!g) return false;
135
+ if (g.state === 'waiting') { append(runtimeDir, { event: 'resumed', id: g.id, key, at: now.toISOString() }); return true; }
136
+ if ((g.state === 'done' || g.state === 'stopped') && !g.seen) append(runtimeDir, { event: 'seen', id: g.id, key, at: now.toISOString() });
137
+ return false;
138
+ }
139
+
140
+ /* ── U7: the Briefing row of a goal that is done, stopped or needs the PM ────────────────────────────────────────────────
141
+ * One row per conversation (key goal:<conversation key>); chatKey names the conversation, so pressing the row opens it and its goal card.
142
+ * A row goes when the PM writes in the conversation, starts a new /goal there, or after ROW_DAYS. */
143
+ const ROW_DAYS = 7;
144
+ const ROW_TITLE = { done: 'Check the goal Claude finished', waiting: 'Claude needs you on a goal', stopped: 'A goal stopped before it was done' };
145
+ function briefingRows(runtimeDir, now = Date.now()) {
146
+ let t; try { t = fs.readFileSync(path.join(runtimeDir, RUNS), 'utf8'); } catch { return []; }
147
+ const keys = new Set();
148
+ for (const l of t.split('\n')) { if (!l.trim()) continue; try { const e = JSON.parse(l); if (e && typeof e.key === 'string') keys.add(e.key); } catch { /* skip */ } }
149
+ const out = [];
150
+ for (const key of keys) {
151
+ const g = goalOf(runtimeDir, key);
152
+ if (!g || !g.draft || !ROW_TITLE[g.state] || g.seen) continue;
153
+ const at = Date.parse(g.at || '');
154
+ if (Number.isFinite(at) && now - at > ROW_DAYS * 86400000) continue;
155
+ const all = g.draft.done || [], met = (g.met || []).length;
156
+ const why = g.state === 'stopped' ? (REASON[g.reason] || 'It stopped.') : g.state === 'waiting' ? 'Claude asked you something in the conversation.' : 'Claude reports every done point met. It checked its own work.';
157
+ out.push({
158
+ kind: 'goal', key: 'goal:' + key, chatKey: key, title: ROW_TITLE[g.state], subject: clip(g.draft.goal, 90),
159
+ prepared: met + ' of ' + all.length + ' done points met, as Claude reports it. ' + why,
160
+ skip: g.state === 'waiting' ? 'If you skip: the goal waits and nothing more is done on it.' : 'If you skip: nobody checks the work before it is relied on.',
161
+ at,
162
+ dialog: {
163
+ eye: 'Goal', logTitle: 'Read from the goal record', log: ['Read goal-runs.jsonl in the state folder', 'Kept the latest state of this goal', 'Changed nothing'],
164
+ say: clip(g.draft.goal, 200) + ': ' + why, head: 'The goal',
165
+ facts: [['State', ROW_TITLE[g.state]], ['Done points', met + ' of ' + all.length + ' met, unverified'], ['By', g.draft.by], ['Rounds', String(g.rounds || 0)]].filter((x) => x[1]),
166
+ opts: [], sel: null, nodef: 'The goal card is in the conversation beside this. Write there to answer Claude or to go on.',
167
+ pane: { label: 'Goal', file: 'goal-runs.jsonl', h: clip(g.draft.goal, 90), intro: why, rows: all.map((x) => [(g.met || []).includes(x) ? 'Met' : 'Open', x]), paras: [] },
168
+ },
169
+ });
170
+ }
171
+ // the newest first, those that wait on the PM before the rest
172
+ return out.sort((a, b) => ((a.title === ROW_TITLE.waiting ? 0 : 1) - (b.title === ROW_TITLE.waiting ? 0 : 1)) || (b.at - a.at)).map(({ at, ...r }) => r);
173
+ }
174
+ /** The Briefing model with the goal rows first (U7). The rows already on the list follow; the count and the dock count them too. */
175
+ function withGoalRows(model, rows) {
176
+ if (!model || !model.list || !rows.length) return model;
177
+ const have = new Set((model.list.rows || []).map((r) => r.key));
178
+ const add = rows.filter((r) => !have.has(r.key));
179
+ if (!add.length) return model;
180
+ const list = add.concat(model.list.rows || []).map((r, k) => Object.assign({}, r, { n: k + 1, first: k === 0 }));
181
+ const count = (model.list.count || 0) + add.length;
182
+ return { ...model, list: { ...model.list, rows: list, count }, dock: model.dock && model.dock.needs != null ? { ...model.dock, needs: count, label: count === 1 ? 'needs you' : 'need you', next: list[0].title } : model.dock };
183
+ }
184
+ /** The Claude Code --settings for a chat session: one Stop hook that posts to this workspace with the session's token. */
185
+ function hookSettings(port, host = '127.0.0.1') {
186
+ return { hooks: { Stop: [{ hooks: [{ type: 'http', url: 'http://' + host + ':' + port + '/api/briefing-premium/goal-stop', headers: { 'x-pmos-session': '$PMOS_SESSION' }, allowedEnvVars: ['PMOS_SESSION'], timeout: 10 }] }] } };
187
+ }
188
+
78
189
  /** chat() hands a `/goal` message here: { error } or { id, prompt } with the grilling line already on record. */
79
190
  function begin({ runtimeDir, key, text, now = new Date() }) {
80
191
  const t = String(text || '').trim();
@@ -89,10 +200,16 @@ const fail = (status, error) => ({ status, body: { ok: false, error } });
89
200
  /** The PM's Start or Cancel on the goal card. sessions: { alive(id), type(id, text) }; session: the key's chat session id. */
90
201
  function decide({ runtimeDir, key, id, act, draft, session, sessions, now = new Date() }) {
91
202
  if (!runtimeDir) return fail(409, 'this workspace has no state folder to keep the goal in');
92
- if (act !== 'start' && act !== 'cancel') return fail(400, 'act must be start or cancel');
203
+ if (!['start', 'cancel', 'stop'].includes(act)) return fail(400, 'act must be start, cancel or stop');
93
204
  const g = goalOf(runtimeDir, key);
94
205
  if (!g || g.id !== id) return fail(404, 'That goal is not the one this conversation is on.');
95
- if (g.state !== 'grilling') return fail(409, g.state === 'started' ? 'This goal has already started.' : 'This goal was cancelled.');
206
+ if (act === 'stop') { // U5: the PM's Stop on a working goal: Esc in the session, and the goal ends
207
+ if (g.state !== 'started') return fail(409, 'This goal is not working.');
208
+ if (session && sessions && sessions.alive(session) && sessions.keys) sessions.keys(session, '\x1b');
209
+ append(runtimeDir, { event: 'stopped', reason: 'pm', id, key, at: now.toISOString() });
210
+ return { status: 200, body: { ok: true, id, state: 'stopped' } };
211
+ }
212
+ if (g.state !== 'grilling') return fail(409, g.state === 'cancelled' ? 'This goal was cancelled.' : 'This goal has already started.');
96
213
  if (!session || !sessions || !sessions.alive(session)) return fail(409, 'No session is running for this conversation. Send /goal again to start one.');
97
214
  let d = null;
98
215
  if (act === 'start') { d = cleanDraft(draft); if (!d) return fail(400, 'The goal needs a sentence and at least one done point before it can start.'); }
@@ -101,4 +218,4 @@ function decide({ runtimeDir, key, id, act, draft, session, sessions, now = new
101
218
  return { status: 200, body: { ok: true, id, state: act === 'start' ? 'started' : 'cancelled' } };
102
219
  }
103
220
 
104
- module.exports = { parseCommand, grillPrompt, startMessage, cancelMessage, cleanDraft, goalOf, begin, decide, MARK, RUNS, LIMIT };
221
+ module.exports = { parseCommand, grillPrompt, startMessage, cancelMessage, cleanDraft, goalOf, begin, decide, onStop, resume, briefingRows, withGoalRows, blockOf, keyOfSession, hookSettings, MARK, RUNS, LIMIT, NO_PROGRESS, REASON };
@@ -14,6 +14,7 @@ const guard = require('./pm-guard.js');
14
14
  const Wr = require('./briefing-premium-writes.js');
15
15
  const Ag = require('./briefing-premium-agent.js');
16
16
  const Goal = require('./goal-chat.js');
17
+ const actor = require('./actor.js');
17
18
  const WP = require('./my-work-premium.js');
18
19
  const BoardP = require('./board-premium.js');
19
20
  const InitP = require('./initiative-premium.js');
@@ -107,6 +108,18 @@ async function post(req, res, url, ctx) {
107
108
  module.exports = {
108
109
  prefixes: ['/api/briefing-premium'],
109
110
  handle: async (req, res, url, ctx) => {
111
+ if (url.pathname === '/api/briefing-premium/goal-stop') {
112
+ // premium-chat-session U1: Claude Code's Stop hook for a chat session. The session's own token names it; the answer keeps a started goal going.
113
+ if (req.method !== 'POST') { ctx.json(res, { ok: false, error: 'POST only' }, 405); return true; }
114
+ const got = await ctx.readJson(req);
115
+ const tok = req.headers && req.headers['x-pmos-session'];
116
+ const who = actor.sessionForToken(Array.isArray(tok) ? tok[0] : tok, { sessDir: ctx.sessDir || path.join(ctx.runtimeDir || '', 'sessions') });
117
+ if (!who || !ctx.runtimeDir) { ctx.json(res, { ok: false, error: 'no valid session token' }, 401); return true; }
118
+ const key = Goal.keyOfSession(ctx.runtimeDir, who.session, Ag.CHATS);
119
+ const body = got.ok && got.body && typeof got.body === 'object' ? got.body : {};
120
+ ctx.json(res, key ? Goal.onStop({ runtimeDir: ctx.runtimeDir, key, message: body.last_assistant_message }) : {});
121
+ return true;
122
+ }
110
123
  if (url.pathname.startsWith('/api/briefing-premium/') && POSTS.includes(url.pathname.slice('/api/briefing-premium/'.length))) {
111
124
  if (req.method !== 'POST') { ctx.json(res, { ok: false, error: 'POST only' }, 405); return true; }
112
125
  return post(req, res, url, ctx);
@@ -127,6 +140,7 @@ module.exports = {
127
140
  const sources = await Src.readSources(ctx, Date.now()).catch(() => null);
128
141
  const agent = Drafts.readDrafts(sel.available);
129
142
  const r = await Prod.modelOfMany({ available: sel.available, engine: enginePath(), runtimeDir: ctx.runtimeDir, sources, agent });
143
+ if (r.model && ctx.runtimeDir) r.model = Goal.withGoalRows(r.model, Goal.briefingRows(ctx.runtimeDir)); // premium-chat-session U7: goals read live, not cached
130
144
  ctx.json(res, r.state === 'error' ? { ok: false, ...r } : { ok: true, ...r }, r.state === 'ready' ? 200 : r.state === 'reading' ? 202 : 500);
131
145
  return true;
132
146
  }
@@ -134,6 +148,7 @@ module.exports = {
134
148
  try { const w = ctx.getWs && ctx.getWs(url.searchParams.get('ws') || null); root = w && w.root; } catch { root = null; }
135
149
  root = root || path.resolve(__dirname, '..', '..');
136
150
  const r = await BP.modelOf({ root, engine: enginePath(), runtimeDir: ctx.runtimeDir });
151
+ if (r.model && ctx.runtimeDir) r.model = Goal.withGoalRows(r.model, Goal.briefingRows(ctx.runtimeDir));
137
152
  // 200 with the model, 202 while the first read goes on, 500 with the reason when a read failed
138
153
  ctx.json(res, r.state === 'error' ? { ok: false, ...r } : { ok: true, ...r }, r.state === 'ready' ? 200 : r.state === 'reading' ? 202 : 500);
139
154
  return true;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.338.0",
3
+ "version": "0.340.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.338.0",
9
+ "version": "0.340.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@xterm/addon-fit": "^0.11.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.338.0",
3
+ "version": "0.340.0",
4
4
  "private": true,
5
5
  "description": "PMOS Terminal Workspace — local companion hosting real PTYs beside the library and gates (D62)",
6
6
  "license": "MIT",
@@ -30,6 +30,7 @@ const OPENING = 'The PM is talking to you from the chat panel';
30
30
  export function shownUser(text) {
31
31
  const t = String(text == null ? '' : text);
32
32
  if (t.includes(MARK.start)) return 'Start the goal';
33
+ const r = /\[PMOS \/goal round (\d+)\]/.exec(t); if (r) return 'Keep going: round ' + r[1];
33
34
  if (t.includes(MARK.cancel)) return 'Cancel the goal';
34
35
  const g = t.indexOf(MARK.grill + ' The PM set a goal: ');
35
36
  if (g >= 0) return '/goal ' + t.slice(g + (MARK.grill + ' The PM set a goal: ').length).split('\n')[0];
@@ -46,7 +47,7 @@ export const smartHtml = (d) => `<div class="smart" aria-label="SMART points fil
46
47
  export function goalCard(d, state) {
47
48
  const a = new Set(Array.isArray(d.assumed) ? d.assumed : []);
48
49
  const row = (k, label, v) => (v ? `<dt>${label}</dt><dd${a.has(k) ? ' class="assumed"' : ''}>${v}</dd>` : '');
49
- const pill = state === 'started' ? 'Started' : state === 'cancelled' ? 'Cancelled' : 'Not started';
50
+ const pill = state === 'cancelled' ? 'Cancelled' : state && state !== 'grilling' ? 'Started' : 'Not started';
50
51
  const done = Array.isArray(d.done) && d.done.length ? `<ul>${d.done.map((x) => `<li>${esc(x)}</li>`).join('')}</ul>` : '';
51
52
  return `<div class="gcard"><div class="grow"><b>${esc(d.goal || 'Goal')}</b><span class="gpill">${pill}</span></div><dl class="gkv">${row('done', 'Done when', done)}${row('may', 'It may', esc(d.may))}${row('serves', 'Serves', esc(d.serves))}${row('by', 'By', esc(d.by))}${row('limit', 'Limit', esc((Number.isInteger(d.limit) ? d.limit : 12) + ' rounds of work at most'))}</dl></div>`;
52
53
  }
@@ -72,3 +73,20 @@ export function goalBlockHtml(block, { live = false, state = 'grilling' } = {})
72
73
  }
73
74
  return '';
74
75
  }
76
+
77
+ const WHY = { deadline: 'The deadline has passed.', limit: 'It used all its rounds.', 'no-progress': 'Three rounds in a row met no new done point.', pm: 'You stopped it.' };
78
+ /** The working goal's card (slice 3, PRD U4, U5): its state, the round, each done point met or open, and Stop while it works.
79
+ * goal: the GET /thread goal record. The done check is Claude's own report, so it says "unverified". */
80
+ export function goalProgressHtml(goal) {
81
+ if (!goal || !goal.draft || !['started', 'done', 'stopped', 'waiting'].includes(goal.state)) return '';
82
+ const d = goal.draft, all = Array.isArray(d.done) ? d.done : [], met = new Set(goal.met || []);
83
+ const limit = Number.isInteger(d.limit) ? d.limit : 12;
84
+ const pill = goal.state === 'started' ? 'Working · round ' + Math.max(1, (goal.rounds || 0) + 1) + ' of ' + limit
85
+ : goal.state === 'done' ? 'Done, as Claude reports it' : goal.state === 'waiting' ? 'Needs you' : 'Stopped';
86
+ const note = goal.state === 'stopped' ? (WHY[goal.reason] || 'It stopped.') + ' Send a message to go on, or /goal to set a new goal.'
87
+ : goal.state === 'waiting' ? 'Claude needs your answer above. Your reply lets it go on.'
88
+ : goal.state === 'done' ? 'Check the work before you rely on it. Claude checked its own points.' : 'Claude keeps working until every point is met, the deadline, or ' + limit + ' rounds.';
89
+ const pts = all.map((x) => `<li class="${met.has(x) ? 'm' : ''}"><i aria-hidden="true"></i><span>${esc(x)}</span><em>${met.has(x) ? 'met' : 'open'}</em></li>`).join('');
90
+ const stop = goal.state === 'started' ? '<div class="chatopts"><button type="button" class="cta alt" data-goal="stop">Stop the goal</button></div>' : '';
91
+ return `<div class="gcard gprog2" role="status"><div class="grow"><b>${esc(d.goal)}</b><span class="gpill">${esc(pill)}</span></div><p class="gprog">${met.size} of ${all.length} done points met · unverified${d.by ? ' · due ' + esc(d.by) : ''}</p><ul class="gpts">${pts}</ul><p class="gprog">${esc(note)}</p>${stop}</div>`;
92
+ }
@@ -4,7 +4,7 @@ import { recChipView, STOP_LINE } from './premium-meeting.js';
4
4
  import { vwReset } from './premium-viewer.js';
5
5
  import { chipActs, openLive, openFocus, mountRecord, HL_LINE } from './premium-vw-rec.js';
6
6
  import { lineItems, behindOf, refreshTargets, whenRead } from './freshness-words.js';
7
- import { splitGoal, shownUser, goalBlockHtml, slashMatches } from './goal-chat.js';
7
+ import { splitGoal, shownUser, goalBlockHtml, goalProgressHtml, slashMatches } from './goal-chat.js';
8
8
  export const $ = (s, r = document) => r.querySelector(s);
9
9
  export const $$ = (s, r = document) => [...r.querySelectorAll(s)];
10
10
  export const esc = (s) => String(s == null ? '' : s).replace(/[&<>"]/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;' }[c]));
@@ -257,6 +257,7 @@ export function sessionHtml(c, goal = null) {
257
257
  const live = i === last && waiting && !!goal && goal.state === 'grilling';
258
258
  return turnAgent(`<p class="agtag">Claude</p>${g.text ? paras(g.text) : ''}${goalBlockHtml(g.block, { live, state: goal && goal.state })}`);
259
259
  });
260
+ const gp = goalProgressHtml(goal); if (gp) out.push(gp);
260
261
  if (c.ask) out.push(turnAgent(`<p class="agtag">Claude asks before it goes on</p><p class="tt">${esc(c.ask.question)}</p><div class="chatopts">${(c.ask.options || []).map((o) => `<button type="button" class="cta alt" data-chat-press="${esc(o.n)}">${esc(o.label)}</button>`).join('')}</div>`));
261
262
  else if (c.turn === 'agent' || c.turn === 'tool') out.push(turnAgent(`<p class="tt" role="status">${c.turn === 'tool' && c.openCall ? 'Running ' + esc(c.openCall) + '.' : 'Claude is working.'} <button type="button" class="cta alt" data-chat-press="esc">Stop</button></p>`));
262
263
  return out.join('');
@@ -319,7 +320,7 @@ $('#dBody').addEventListener('click', async (e) => {
319
320
  if (!S.goal) return;
320
321
  gb.disabled = true;
321
322
  const r = await chatPost('goal', { key: S.key, id: S.goal.id, act, draft: S.draft });
322
- $('#askNote').textContent = r && r.ok ? (act === 'start' ? 'Claude is starting on the goal.' : 'The goal is cancelled.') : (r && r.error) || 'The press did not reach the session.';
323
+ $('#askNote').textContent = r && r.ok ? ({ start: 'Claude is starting on the goal.', cancel: 'The goal is cancelled.', stop: 'The goal is stopped.' }[act]) : (r && r.error) || 'The press did not reach the session.';
323
324
  loadThread(S.key);
324
325
  });
325
326
  /* the `/` menu (G1): opens on a leading `/`, arrows move, Enter or Tab picks, Esc shuts it */
@@ -2158,3 +2158,8 @@ button.wl-row[aria-pressed="true"] .wl-tog{background:var(--solid);color:var(--o
2158
2158
  .gkv dd.assumed::after{content:" · assumed";color:var(--ember-ink);font-size:var(--t-micro)}
2159
2159
  .gprog{margin:8px 0 0;font-size:var(--t-small);color:var(--ink-2)}
2160
2160
  @media (max-width:520px){.gkv{grid-template-columns:1fr;gap:2px}.gkv dd{margin-bottom:6px}}
2161
+ .gpts{list-style:none;margin:10px 0 0;padding:0;display:grid;gap:6px}
2162
+ .gpts li{display:grid;grid-template-columns:14px 1fr auto;gap:10px;align-items:baseline;font-size:var(--t-small)}
2163
+ .gpts i{width:10px;height:10px;border-radius:50%;box-shadow:inset 0 0 0 1.5px var(--ink-3)}
2164
+ .gpts li.m i{background:var(--ok);box-shadow:none}
2165
+ .gpts em{font-style:normal;color:var(--ink-3);font-size:var(--t-micro)}
@@ -228,9 +228,9 @@ function openRow(r) {
228
228
  if (!r) return;
229
229
  if (!r.dialog) r = { ...r, dialog: r.src ? consoleDialog(r) : plainDialog(r) };
230
230
  openR = r; const d = r.dialog;
231
- openDlg({ eye: d.eye + ' · real data', title: d.title || r.title, sub: d.sub || r.subject, say: d.say, stream: turnA(logHtml(d)) + turnA(ptx(d.say)) + cardHtml(r), noteKey: r.key, pane: paneHtml(r), label: d.pane.label });
231
+ openDlg({ eye: d.eye + ' · real data', title: d.title || r.title, sub: d.sub || r.subject, say: d.say, stream: turnA(logHtml(d)) + turnA(ptx(d.say)) + cardHtml(r), noteKey: r.chatKey || r.key, pane: paneHtml(r), label: d.pane.label }); // a goal row (premium-chat-session U7) opens its own conversation
232
232
  ctaState(r);
233
- if (r.dialog.noAsk) { $('#askF').hidden = true; $('#askNote').hidden = true; } else loadThread(r.key); // the read-only agent answers about the model's rows only
233
+ if (r.dialog.noAsk) { $('#askF').hidden = true; $('#askNote').hidden = true; } else loadThread(r.chatKey || r.key); // the read-only agent answers about the model's rows only
234
234
  setTimeout(() => { const b = $('#dBody'); b.scrollTop = b.scrollHeight; }, 120);
235
235
  }
236
236
  function showErr(msg) { const e = $('#cardErr'); if (!e) { toast(msg); return; } e.textContent = msg; e.hidden = false; }
@@ -3991,7 +3991,9 @@ function spawnSessionInner({ name, agent, cwd, ws, origin, initialInput, profile
3991
3991
  const argv = [...(mres.state === 'applied' ? mres.args : []), ...fres.args];
3992
3992
  /* PER-SESSION HOOKS (console3 wave D). Off unless PMOS_AGENT_HOOKS=1: then an agent session starts with --settings whose
3993
3993
  * hooks post to this workspace (lib/routes-hooks.js, loopback only; the session token travels in the PMOS_SESSION env). */
3994
- if (process.env.PMOS_AGENT_HOOKS === '1' && agent === 'claude') argv.push('--settings', JSON.stringify(require('./lib/routes-hooks.js').settingsFor(PORT)));
3994
+ // premium-chat-session U1: a chat panel's session gets the /goal Stop hook (lib/goal-chat.js) instead, so a started goal keeps going until done.
3995
+ if (agent === 'claude' && /^chat:/.test(String(tag || ''))) argv.push('--settings', JSON.stringify(require('./lib/goal-chat.js').hookSettings(PORT)));
3996
+ else if (process.env.PMOS_AGENT_HOOKS === '1' && agent === 'claude') argv.push('--settings', JSON.stringify(require('./lib/routes-hooks.js').settingsFor(PORT)));
3995
3997
  const launchArgs = argv;
3996
3998
  if (mres.tier) {
3997
3999
  const mc = modelLib.core();