create-pmos 0.786.0 → 0.788.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.
Files changed (35) hide show
  1. package/package.json +46 -33
  2. package/payload/KIT-VERSION +1 -1
  3. package/payload/planning/evals/eval-calibration.md +1 -1
  4. package/payload/planning/okrs/health-budgets.md +1 -1
  5. package/payload/state/discoveries.md +1 -1
  6. package/workspace/changelog.json +45 -0
  7. package/workspace/guide/agent-capabilities.md +1 -0
  8. package/workspace/guide/claude-proposes.md +1 -0
  9. package/workspace/guide/home.md +3 -1
  10. package/workspace/guide/settings-and-switches.md +1 -1
  11. package/workspace/lib/features.json +31 -0
  12. package/workspace/lib/jev-command.js +88 -0
  13. package/workspace/lib/proposals.js +13 -2
  14. package/workspace/lib/routes-boards.js +1 -0
  15. package/workspace/lib/routes-proposals.js +30 -7
  16. package/workspace/lib/routes-slash.js +57 -14
  17. package/workspace/lib/stuck-next.js +82 -0
  18. package/workspace/package-lock.json +2 -2
  19. package/workspace/package.json +1 -1
  20. package/workspace/public/pm/action-keys.js +5 -1
  21. package/workspace/public/pm/cozy-home.css +2 -0
  22. package/workspace/public/pm/cozy-jl.js +6 -2
  23. package/workspace/public/pm/cozy-nav.js +4 -2
  24. package/workspace/public/pm/feature-match.js +77 -0
  25. package/workspace/public/pm/features-dir.js +83 -0
  26. package/workspace/public/pm/goal-chat.js +10 -7
  27. package/workspace/public/pm/home-chat.js +49 -7
  28. package/workspace/public/pm/ini-props.js +4 -3
  29. package/workspace/public/pm/palette-all.js +12 -3
  30. package/workspace/public/pm/premium-shell.js +6 -3
  31. package/workspace/public/pm/premium-vw-features.css +17 -0
  32. package/workspace/public/pm/premium-vw-open.js +2 -1
  33. package/workspace/public/pm/premium-vw-page.js +2 -1
  34. package/workspace/test-lists/feature-directory.json +9 -0
  35. package/workspace/test-lists/stuck-next-step.json +9 -0
@@ -4,7 +4,8 @@
4
4
  * GET /api/slash-commands[?ws=<id>] → { ok, commands: [{ cmd, name, say, src }] } src 'pmos' | 'claude' | 'project' | 'yours'
5
5
  *
6
6
  * READ ONLY. The commands are, in this order:
7
- * pmos /goal, which PMOS answers itself (goal-chat.js)
7
+ * pmos PMOS's own commands from lib/features.json (/goal, /why, /rehearse, …); a sent one runs its pmos verb (pm/feature-match.js expand);
8
+ * then one /pmos:<verb> per command a card button runs (the card catalog), which pmosAsk turns into words
8
9
  * claude the commands built into Claude Code
9
10
  * project the workspace's own: .claude/commands/<name>.md and .claude/skills/<name>/SKILL.md under the workspace root
10
11
  * yours the PM's own: the same two folders under ~/.claude
@@ -13,8 +14,14 @@ const fs = require('fs');
13
14
  const os = require('os');
14
15
  const path = require('path');
15
16
 
16
- // /goal, then one entry per command a card button runs (the card catalog, A455)
17
- const PMOS = [{ cmd: '/goal', name: 'Give PMOS a goal', say: 'It asks a few questions to make the goal SMART, then works on it after you press Start.' },
17
+ /* PMOS's own commands come from the feature registry (lib/features.json, initiative feature-directory): user rows with a cmd,
18
+ * each with its hint, its page and the phrases the typed-words suggestion matches (pm/feature-match.js). */
19
+ const REG = require('./features.json');
20
+ const FEATURES = REG.features.filter((f) => f.audience === 'user');
21
+ const FROM_REG = FEATURES.filter((f) => f.cmd).map((f) => ({ cmd: f.cmd, name: f.name, say: f.say, ...(f.verb ? { verb: f.verb } : {}), ...(f.sub ? { sub: f.sub } : {}),
22
+ ...(f.hint ? { hint: f.hint } : {}), ...(f.place ? { place: f.place } : {}), phrases: f.phrases || [] }));
23
+ // then one entry per command a card button runs (the card catalog, A455); a pick of one becomes words for the session (pmosAsk)
24
+ const CARDS = [
18
25
  /* card-catalog:begin, generated by bin/card-catalog-gen.js: edit lib/card-catalog.json, not this block */
19
26
  {"cmd":"/pmos:task-set","run":"pmos task set","name":"Move the date and 7 more","say":"pmos task set <id> --due <date> [--start <date>] [--owner <who>] [--notes <text>] [--milestone] [--pin] [--no-milestone]"},
20
27
  {"cmd":"/pmos:task-state","run":"pmos task state","name":"Change status and 1 more","say":"pmos task state <id> --to <state> --why <text>"},
@@ -144,17 +151,18 @@ const PMOS = [{ cmd: '/goal', name: 'Give PMOS a goal', say: 'It asks a few ques
144
151
  {"cmd":"/pmos:grill-mode","run":"pmos grill mode","name":"Change mode","say":"pmos grill mode full|exits|off"},
145
152
  {"cmd":"/pmos:grill-cap","run":"pmos grill cap","name":"Set the cap","say":"pmos grill cap <dollars>"},
146
153
  /* card-catalog:end */];
154
+ const PMOS = [...FROM_REG, ...CARDS];
147
155
  const CLAUDE = [
148
- ['/compact', 'Compact the conversation', 'Claude Code summarises the conversation so far to free room.'],
149
- ['/clear', 'Clear the conversation', 'Claude Code starts again with an empty context in the same session.'],
156
+ ['/compact', 'Compact the conversation', 'Summarise the conversation so far to free room.'],
157
+ ['/clear', 'Clear the conversation', 'Start again with an empty context in the same session.'],
150
158
  ['/context', 'Show the context', 'How full the context window is, and what fills it.'],
151
159
  ['/cost', 'Show the cost', 'The tokens and cost of this session so far.'],
152
160
  ['/model', 'Change the model', 'Pick the model the session uses from now on.'],
153
- ['/review', 'Review a pull request', 'Claude Code reviews a pull request.'],
154
- ['/security-review', 'Security review', 'Claude Code checks the pending changes for security issues.'],
155
- ['/pr-comments', 'Pull request comments', 'Claude Code reads the comments on a pull request.'],
156
- ['/init', 'Write CLAUDE.md', 'Claude Code writes a CLAUDE.md that describes this repository.'],
157
- ['/memory', 'Edit memory', 'Open the CLAUDE.md memory files.'],
161
+ ['/review', 'Review a pull request', 'Review a pull request.'],
162
+ ['/security-review', 'Security review', 'Check the pending changes for security issues.'],
163
+ ['/pr-comments', 'Pull request comments', 'Read the comments on a pull request.'],
164
+ ['/init', 'Write the memory file', 'Write the memory file that describes this repository.'],
165
+ ['/memory', 'Edit memory', 'Open the memory files.'],
158
166
  ['/add-dir', 'Add a folder', 'Let the session read and work in another folder.'],
159
167
  ['/agents', 'Subagents', 'List and manage the subagents.'],
160
168
  ['/mcp', 'MCP servers', 'The MCP servers and their state.'],
@@ -163,8 +171,8 @@ const CLAUDE = [
163
171
  ['/todos', 'To-dos', 'The session’s current to-do list.'],
164
172
  ['/export', 'Export the conversation', 'Save the conversation to a file or the clipboard.'],
165
173
  ['/status', 'Status', 'The version, the model, the account and the connections.'],
166
- ['/doctor', 'Check the install', 'Claude Code checks its own installation.'],
167
- ['/help', 'Help', 'The commands Claude Code takes.'],
174
+ ['/doctor', 'Check the install', 'Check the session’s own installation.'],
175
+ ['/help', 'Help', 'The commands the session takes.'],
168
176
  ].map(([cmd, name, say]) => ({ cmd, name, say }));
169
177
 
170
178
  const NAME = /^[A-Za-z0-9][A-Za-z0-9_:.-]{0,63}$/;
@@ -210,6 +218,40 @@ function list(deps = {}) {
210
218
  return { status: 200, body: { ok: true, commands: out } };
211
219
  }
212
220
 
221
+ /* GET /api/features[?ws=<id>] → { ok, groups, features, suggest } suggest: Jev may be asked (all three gates open)
222
+ * POST /api/features/suggest { ws, text } → { ok, cmd|null, sent, why? } only when the local match found nothing
223
+ * POST /api/features/jev { ws, suggest } → the "suggest commands with Jev" switch, the PM's press (Settings › Jev and Laya) */
224
+ async function features(req, res, url, ctx) {
225
+ const J = require('./jev-command.js');
226
+ const S = require('./typesafe-settings.js');
227
+ const state = ctx.runtimeDir;
228
+ const wsOf = (id) => (id && ctx.getWs ? ctx.getWs(id) : null);
229
+ const flagsOf = (w) => (w && state ? { ...S.getRepo(state, w.root), suggest: J.switchOf(state, w.root) } : {});
230
+ const keyOf = () => { try { return state ? S.getKey(state) : null; } catch { return null; } };
231
+ if (url.pathname === '/api/features' && req.method === 'GET') {
232
+ const w = wsOf(url.searchParams.get('ws'));
233
+ ctx.json(res, { ok: true, groups: REG.groups, features: FEATURES, suggest: J.gates({ key: keyOf(), flags: flagsOf(w) }).open, switch: w ? J.switchOf(state, w.root) : false });
234
+ return true;
235
+ }
236
+ if (url.pathname === '/api/features/suggest' && req.method === 'POST') {
237
+ const r = await ctx.readJson(req); if (!r.ok) { ctx.json(res, { ok: false, error: 'invalid JSON body' }, 400); return true; }
238
+ const w = wsOf(r.body.ws); if (!w) { ctx.json(res, { ok: false, error: 'no workspace' }, 400); return true; }
239
+ const out = await J.suggest({ text: r.body.text, cmds: PMOS, key: keyOf(), flags: flagsOf(w), askOpts: ctx.jevModelOpts ? ctx.jevModelOpts(w.root) : {} });
240
+ ctx.json(res, out);
241
+ return true;
242
+ }
243
+ if (url.pathname === '/api/features/jev' && req.method === 'POST') {
244
+ const r = await ctx.readJson(req); if (!r.ok) { ctx.json(res, { ok: false, error: 'invalid JSON body' }, 400); return true; }
245
+ const w = wsOf(r.body.ws); if (!w) { ctx.json(res, { ok: false, error: 'no workspace' }, 400); return true; }
246
+ if (typeof r.body.suggest !== 'boolean') { ctx.json(res, { ok: false, error: 'suggest must be true or false' }, 400); return true; }
247
+ const out = J.setSwitch(state, w.root, r.body.suggest);
248
+ ctx.json(res, out.ok ? { ok: true, ws: w.id, suggest: J.switchOf(state, w.root) } : { ok: false, error: out.error }, out.ok ? 200 : 500);
249
+ return true;
250
+ }
251
+ ctx.json(res, { ok: false, error: 'not found' }, 404);
252
+ return true;
253
+ }
254
+
213
255
  /** A pick from the PMOS group of the / menu: "/pmos:task-set LEN-1 --due 2026-12-01". Claude Code takes no /pmos command, so the
214
256
  * chat turns it into words naming the pmos command before it reaches the session; anything else answers null. */
215
257
  function pmosAsk(q) {
@@ -226,10 +268,11 @@ function pmosAsk(q) {
226
268
  const BESIDE = [require('./card-catalog-route.js'), require('./star-drafts-route.js')];
227
269
 
228
270
  module.exports = { pmosAsk,
229
- prefixes: ['/api/slash-commands', '/api/card-catalog', '/api/star-drafts'],
230
- list, sayOf, CLAUDE,
271
+ prefixes: ['/api/slash-commands', '/api/card-catalog', '/api/star-drafts', '/api/features'],
272
+ list, sayOf, CLAUDE, FEATURES, PMOS,
231
273
  handle: async (req, res, url, ctx) => {
232
274
  for (const m of BESIDE) if (m.prefixes.includes(url.pathname)) return m.handle(req, res, url, ctx);
275
+ if (url.pathname.startsWith('/api/features')) return features(req, res, url, ctx);
233
276
  if (url.pathname !== '/api/slash-commands') return false;
234
277
  if (req.method !== 'GET') { ctx.json(res, { ok: false, error: 'GET only' }, 405); return true; }
235
278
  const ws = url.searchParams.get('ws');
@@ -0,0 +1,82 @@
1
+ 'use strict';
2
+ /* stuck-next.js — work that sat In progress for two weeks gets one prepared next step (initiative stuck-next-step, idea A63; done test
3
+ * planning/done-tests/stuck-next-step.md).
4
+ *
5
+ * On the proof product 48 in-progress sprint items had not changed in 14 or more days, and nobody asked about them: asking meant opening
6
+ * each one, finding its owner and writing a note. Here each one gets the step PMOS thinks most likely, ready, under its initiative's ✦
7
+ * (group `stuck`, beside the computed date proposals of lib/proposals.js). The PM answers yes or no.
8
+ *
9
+ * touchedOf(t) → the day the task last changed: a PMOS task's state day (`since`), a Jira ticket's `updated` day, or null PURE
10
+ * stuckOf(ini, T, o) → [task] In progress, not an Epic, last changed DAYS or more before o.today (a day number). No change day:
11
+ * never stuck (can't tell) PURE
12
+ * stepOf(t, o) → { step: 'nudge' | 'park', to?, text } an owner who is not the PM (o.me, o.pmName): nudge, with the note
13
+ * drafted; the PM's own task or one with no owner: park. A Jira ticket is never written: its steps are drafted
14
+ * comments (lib/routes-proposals.js sends them to the Outbox) PURE
15
+ * propsOf(ini, T, o) → [proposal] one per stuck task: { id, ini, group: 'stuck', type: 'nudge' | 'park', section: 'check' (its own ✓, never Keep all), title,
16
+ * why, sources: [], items: [{ id, task, title, step, to, text, since, days, jira? }], sig }. o.drops: a dropped
17
+ * signature hides it until the task changes again PURE
18
+ * say(s) the health log, `[stuck-next] kept …` / `[stuck-next] dropped …`
19
+ *
20
+ * Split, the bet's third step, needs a model to cut a task in two; it is not here. */
21
+ const crypto = require('crypto');
22
+
23
+ const DAYS = 14;
24
+ const DAY_MS = 86400000;
25
+ const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
26
+ const dn = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? Math.floor(Date.UTC(+m[1], +m[2] - 1, +m[3]) / DAY_MS) : null; };
27
+ const isoN = (n) => new Date(n * DAY_MS).toISOString().slice(0, 10);
28
+ const md = (n) => { const d = new Date(n * DAY_MS); return d.getUTCDate() + ' ' + MON[d.getUTCMonth()]; };
29
+ const one = (s, n) => { const t = String(s == null ? '' : s).replace(/\s+/g, ' ').trim(); return t.length > n ? t.slice(0, n - 1).replace(/\s+\S*$/, '') + '…' : t; };
30
+ const hash = (s) => crypto.createHash('sha1').update(String(s)).digest('hex').slice(0, 10);
31
+ const say = (s) => { try { console.log('[stuck-next] ' + s); } catch { /* no console */ } };
32
+
33
+ /** The PM's own name against an owner: the same name, or the same first name (Jira shows "Wawan Setiawan", the PM is "Wawan"), or the
34
+ * PM's own actor id (pm:<slug>, the owner of a task the PM made). */
35
+ function isPm(who, o = {}) {
36
+ const w = String(who || '').trim().toLowerCase().replace(/^pm:/, ''); // a task PMOS made carries its maker, pm:<slug>
37
+ if (!w) return false;
38
+ if (/^pm:/i.test(String(who).trim()) && (!o.me || String(o.me).toLowerCase() === w)) return true;
39
+ return [o.me, o.pmName].filter(Boolean).map((m) => String(m).trim().toLowerCase()).some((m) => w === m || w.split(/\s+/)[0] === m.split(/\s+/)[0]);
40
+ }
41
+
42
+ function touchedOf(t) { return dn(t && (t.jira ? t.updated || t.since : t.since || t.updated)); }
43
+
44
+ function stuckOf(ini, T, o = {}) {
45
+ const today = o.today, days = o.days || DAYS, out = [];
46
+ if (today == null) return out;
47
+ for (const t of T.values()) {
48
+ if (t.ini !== ini || t.closed || t.kind === 'Epic' || t.status !== 'In progress') continue;
49
+ const at = touchedOf(t);
50
+ if (at == null || today - at < days) continue;
51
+ out.push(t);
52
+ }
53
+ return out.sort((a, b) => touchedOf(a) - touchedOf(b));
54
+ }
55
+
56
+ function stepOf(t, o = {}) {
57
+ const who = String(t.owner || t.assignee || '').trim(), at = touchedOf(t), days = o.today != null && at != null ? o.today - at : null;
58
+ const when = at != null ? md(at) + (days != null ? ' (' + days + ' days)' : '') : 'a while';
59
+ const title = one(t.title || t.uid, 120);
60
+ if (who && !isPm(who, o)) {
61
+ const first = who.split(/\s+/)[0];
62
+ return { step: 'nudge', to: who, text: `Hi ${first}, ${title} has not moved since ${when}. What is the next step? If it should wait, tell me and I will park it.` };
63
+ }
64
+ return { step: 'park', text: `Parked: no change since ${when}.` + (t.jira ? ' Moving it back to To do.' : '') };
65
+ }
66
+
67
+ function propsOf(ini, T, o = {}) {
68
+ const out = [];
69
+ for (const t of stuckOf(ini, T, o)) {
70
+ const s = stepOf(t, o), at = touchedOf(t), days = o.today - at;
71
+ const id = 'stuck-' + hash(ini + '|' + t.uid);
72
+ const sig = 's:' + hash(id + '|' + isoN(at) + '|' + t.status); // a change to the task is a new signature: a ✕ holds until then
73
+ if (o.drops && o.drops.has(sig)) continue;
74
+ const title = s.step === 'nudge' ? 'Nudge ' + s.to + ': ' + one(t.title, 80) : 'Park ' + one(t.title, 80);
75
+ out.push({ id, ini, group: 'stuck', type: s.step, section: 'check', sig,
76
+ title, why: one(t.title, 80) + ' is In progress and has not changed since ' + md(at) + ' (' + days + ' days).', sources: [],
77
+ items: [{ id: t.uid, task: t.uid, title: t.title, step: s.step, ...(s.to ? { to: s.to } : {}), text: s.text, since: isoN(at), days, ...(t.jira ? { jira: true } : {}) }] });
78
+ }
79
+ return out;
80
+ }
81
+
82
+ module.exports = { DAYS, isPm, touchedOf, stuckOf, stepOf, propsOf, say };
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.786.0",
3
+ "version": "0.788.0",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "pmos-workspace",
9
- "version": "0.786.0",
9
+ "version": "0.788.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@anthropic-ai/sdk": "^1.3.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.786.0",
3
+ "version": "0.788.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",
@@ -165,7 +165,8 @@ export function sheetHtml(here = new Set()) {
165
165
  return `<div class="pm-row"><h2 class="pm-h-sm" id="akTitle">Keys</h2>`
166
166
  + `<button type="button" class="pm-btn" data-ak-close aria-label="Close" title="Close">${X}</button></div>`
167
167
  + '<p class="pm-meta">Point at an item, or tab to it, then press its key.</p>'
168
- + `<ul>${KEYS.map((k) => row(k.key.toUpperCase(), k.say, here.has(k.act))).join('')}${row('F', 'Focus on this item')}${row('?', 'This list')}</ul>`; // F: pm/focus-mode.js (bet A335)
168
+ + `<ul>${KEYS.map((k) => row(k.key.toUpperCase(), k.say, here.has(k.act))).join('')}${row('F', 'Focus on this item')}${row('?', 'This list')}</ul>`
169
+ + '<p class="pm-meta"><a href="/premium-viewer.html?open=features" data-ak-features>Every feature, with its command</a></p>'; // F: pm/focus-mode.js (bet A335); the link: feature-directory
169
170
  }
170
171
 
171
172
  let started = false;
@@ -201,6 +202,9 @@ export function startActionKeys(doc = typeof document !== 'undefined' ? document
201
202
  if (doc.defaultView) doc.defaultView.addEventListener('click', (e) => {
202
203
  const d = S.sheet;
203
204
  if (d && d.open && (e.target === d || (e.target && e.target.closest && e.target.closest('[data-ak-close]')))) d.close();
205
+ // the link to What PMOS can do opens it in this page's Viewer (feature-directory); without one the link's own page opens
206
+ const f = e.target && e.target.closest ? e.target.closest('[data-ak-features]') : null;
207
+ if (f && d && d.open) { e.preventDefault(); d.close(); import('./premium-vw-open.js').then((M) => M.openFeatures()).catch(() => { location.assign(f.href); }); }
204
208
  });
205
209
  doc.addEventListener('pointerover', (e) => {
206
210
  S.pointer = e.target; S.pointerT = Date.now();
@@ -624,6 +624,8 @@ form.hm-box textarea { min-height: 48px; border: 0; background: none; resize: no
624
624
  .hm-slash em { font-style: normal; font-size: var(--fs-meta); color: var(--cz-ink3); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; line-height: var(--lh-meta); }
625
625
  .hm-slash .l1 { display: flex; align-items: baseline; gap: var(--space-8); min-width: 0; }
626
626
  .hm-slash .l1 b { font-size: var(--fs-row); font-weight: var(--fw-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: var(--lh-row); }
627
+ .hm-slash .hm-slgrp { margin: 0; padding: 6px 10px 2px; font-size: var(--fs-meta); line-height: var(--lh-meta); font-weight: var(--fw-strong); color: var(--cz-ink3); }
628
+ .hm-slash .hm-slhint { margin: 0; padding: 6px 10px; display: flex; align-items: baseline; gap: var(--space-8); font-size: var(--fs-meta); line-height: var(--lh-meta); color: var(--cz-ink3); }
627
629
  .hm-scope + .hm-files { margin-bottom: 6px; }
628
630
  /* the phone moment card (home-phone-card.js) at the top of the phone's sheet */
629
631
  .hm-phc { display: grid; gap: 6px; margin: 2px 2px 14px; padding: 14px var(--space-16); border-radius: var(--radius-card, 18px); background: var(--cz-card); box-shadow: inset 3px 0 0 var(--cz-blue), var(--cz-float); color: var(--cz-ink); }
@@ -6,6 +6,7 @@
6
6
  * commands typed in; the PM presses Enter) · /api/typesafe/local/test (one question to 127.0.0.1)
7
7
  * per repository GET and POST /api/validate/repo { ws, consent } "Jev may read this repository" (D79)
8
8
  * POST /api/doccat/jev { ws, categorize } Sort documents into categories (D82)
9
+ * POST /api/features/jev { ws, suggest } Suggest commands (feature-directory)
9
10
  * POST /api/claims/watch { ws, watch } + /api/claims/jev { ws, jev } Check claims (both, D80)
10
11
  * GET /api/notes/engine · POST /api/notes/switch { ws, jev | check } Label notes, Check notes (D91)
11
12
  * With no key and no local model, Claude proposes Laya once as a ✦; the terminal icon approves it, ✕ hides it on this computer.
@@ -43,6 +44,7 @@ function repoHtml(w) {
43
44
  const n = r.notes || {};
44
45
  const sub2 = [
45
46
  ['categorize', 'Sort documents into categories', 'Asks Jev about documents the local rules cannot place.', r.categorize],
47
+ ['suggest', 'Suggest commands', 'Asks Jev which command your typed words ask for, when the local phrases cannot tell.', r.suggest],
46
48
  ['claims', 'Check claims', 'Keeps claims.jsonl in the repository up to date and asks Jev only about changed pairs.', r.watch && r.jev],
47
49
  ['label', 'Label notes', 'Names the line a meeting note is about. A private note is never sent.', n.jev],
48
50
  ['check', 'Check notes against the repository', 'Says whether a note agrees with the closest passage.', n.check],
@@ -75,9 +77,9 @@ export function html() {
75
77
 
76
78
  async function loadRepo(w) {
77
79
  const q = 'ws=' + encodeURIComponent(w.id);
78
- const [v, e] = await Promise.all([pmGet('/api/validate/repo?' + q), pmGet('/api/notes/engine?' + q)]);
80
+ const [v, e, f] = await Promise.all([pmGet('/api/validate/repo?' + q), pmGet('/api/notes/engine?' + q), pmGet('/api/features?' + q).catch(() => null)]);
79
81
  if (!v || v.ok === false) { J.repos[w.id] = { error: (v && v.error) || 'the server did not answer' }; return; }
80
- J.repos[w.id] = { consent: !!v.consent, exclude: v.exclude || [], watch: !!v.watch, jev: !!v.jev, categorize: !!v.categorize, notes: e && e.ok && e.jev ? { jev: !!e.jev.jev, check: !!e.jev.check } : {} };
82
+ J.repos[w.id] = { consent: !!v.consent, exclude: v.exclude || [], watch: !!v.watch, jev: !!v.jev, categorize: !!v.categorize, suggest: !!(f && f.switch), notes: e && e.ok && e.jev ? { jev: !!e.jev.jev, check: !!e.jev.check } : {} };
81
83
  if (v.key) J.key = v.key;
82
84
  }
83
85
 
@@ -96,6 +98,7 @@ export function reset() { J.key = null; J.err = ''; J.repos = {}; J.test = null;
96
98
  const SAID = {
97
99
  consent: (on) => (on ? 'Saved. Jev may read this repository.' : 'Saved. Jev reads nothing from this repository.'),
98
100
  categorize: (on) => (on ? 'Saved. Jev sorts the documents the local rules cannot place.' : 'Saved. Documents are sorted by the local rules only.'),
101
+ suggest: (on) => (on ? 'Saved. Jev suggests a command when the local phrases cannot tell.' : 'Saved. Commands are suggested from the local phrases only.'),
99
102
  claims: (on) => (on ? 'Saved. Claims are checked as the files change.' : 'Saved. Claims are no longer checked by Jev.'),
100
103
  label: (on) => (on ? 'Saved. Jev labels meeting note lines.' : 'Saved. Meeting note lines keep their local labels.'),
101
104
  check: (on) => (on ? 'Saved. Jev checks notes against this repository.' : 'Saved. Notes are not checked against this repository.'),
@@ -105,6 +108,7 @@ async function flip(kind, ws) {
105
108
  const r = J.repos[ws]; if (!r) return { ok: false, error: 'This repository is not read yet.' };
106
109
  const n = r.notes || {};
107
110
  if (kind === 'consent') { const out = await pmPost('/api/validate/repo', { ws, consent: !r.consent }); if (out && out.ok) { r.consent = !!out.consent; if (out.key) J.key = out.key; } return { out, on: r.consent }; }
111
+ if (kind === 'suggest') { const out = await pmPost('/api/features/jev', { ws, suggest: !r.suggest }); if (out && out.ok) r.suggest = !!out.suggest; return { out, on: r.suggest }; }
108
112
  if (kind === 'categorize') { const out = await pmPost('/api/doccat/jev', { ws, categorize: !r.categorize }); if (out && out.ok) r.categorize = !r.categorize; return { out, on: r.categorize }; }
109
113
  if (kind === 'claims') {
110
114
  const on = !(r.watch && r.jev);
@@ -312,10 +312,12 @@ export function mountNav(here, doc = document, opts = {}) {
312
312
  doc.addEventListener('pointerover', note, { capture: true, passive: true });
313
313
  doc.addEventListener('focusin', note, true);
314
314
  const chat = () => { if (N.rail && typeof window.czOpenChat === 'function') window.czOpenChat(); else if (opts.chat) opts.chat(); else import('./page-chat.js').then((M) => M.openCos({ here: opts.where ? opts.where() : PLACES.find((p) => p.key === here) ? PLACES.find((p) => p.key === here).label : '' })); };
315
+ let feats = null; // feature-directory: the user features, read once, so Ctrl+K finds a feature by name
315
316
  function search() {
316
317
  const item = lastAt && lastAt.isConnected ? lastAt : null;
317
- Promise.all([import('./cozy-search.js'), import('./palette-all.js')]).then(([M, P]) => M.openSearch({ ...(opts.search ? { go: opts.search() } : {}),
318
- scope: P.withEverything(opts.scope ? opts.scope() : null, { places: PLACES, here, item, doc, ws: wsParam(), wsq: wsQ, chat, setTheme: (k) => setTheme(k, doc) }) }));
318
+ const fr = feats ? Promise.resolve(feats) : import('./http.js').then((H) => H.pmGet('/api/features')).then((r) => (feats = r && r.ok ? r.features : [])).catch(() => []);
319
+ Promise.all([import('./cozy-search.js'), import('./palette-all.js'), fr]).then(([M, P, features]) => M.openSearch({ ...(opts.search ? { go: opts.search() } : {}),
320
+ scope: P.withEverything(opts.scope ? opts.scope() : null, { places: PLACES, here, item, doc, ws: wsParam(), wsq: wsQ, chat, setTheme: (k) => setTheme(k, doc), features }) }));
319
321
  }
320
322
  const read = async () => {
321
323
  if (doc.hidden) return;
@@ -0,0 +1,77 @@
1
+ /* pm/feature-match.js — one list of features behind every door (initiative feature-directory, done test F3, F4, F6).
2
+ *
3
+ * PURE: no DOM, no fetch, so Node tests it. The list is GET /api/features (lib/features.json, user rows only); the chat's / menu
4
+ * gets the same rows as commands from GET /api/slash-commands.
5
+ *
6
+ * hereOf(pathname) the menu's page key for a path ('home', 'board', …) or ''
7
+ * ranked(cmds, here) PMOS commands for this page first, then the other PMOS ones, then the rest; each with grp
8
+ * match(text, cmds, here) the one command plain words ask for, or null. Local and instant: every word of one of the
9
+ * command's phrases is in the text (a word matches its own start, so "slips" matches "slip").
10
+ * expand(text, cmds) a sent "/why lendly" becomes a prompt that runs `pmos why` on "lendly"; any other text is unchanged
11
+ * hintOf(text, cmds) after a command is picked: { cmd, hint, name } while only its arguments are being typed, else null
12
+ * groupsOf(feats, groups, seen) the directory: [{ label, rows }]. seen = the feature ids this browser already listed, or null on a
13
+ * first visit; "New since you last looked" comes first only when a row is not in seen (zero is silence) */
14
+
15
+ const words = (s) => String(s || '').toLowerCase().replace(/[’']/g, '').split(/[^a-z0-9]+/).filter(Boolean);
16
+ const same = (want, have) => have === want || (want.length >= 4 && have.startsWith(want)) || (have.length >= 4 && want.startsWith(have));
17
+
18
+ const HERE = [['/today.html', 'home'], ['/premium.html', 'home'], ['/premium-board.html', 'board'], ['/premium-goals.html', 'insights'],
19
+ ['/premium-events.html', 'events'], ['/premium-library.html', 'library'], ['/premium-routine.html', 'routine']];
20
+ export function hereOf(pathname) { const p = String(pathname || ''); const hit = HERE.find(([a]) => p.endsWith(a)); return hit ? hit[1] : ''; }
21
+
22
+ export function ranked(cmds, here = '') {
23
+ const list = Array.isArray(cmds) ? cmds : [];
24
+ const pm = list.filter((x) => x && x.src === 'pmos'), rest = list.filter((x) => x && x.src !== 'pmos');
25
+ const mine = here ? pm.filter((x) => x.place === here) : [];
26
+ const any = pm.filter((x) => !mine.includes(x));
27
+ return [...mine.map((x) => ({ ...x, grp: 'For this page' })), ...any.map((x) => ({ ...x, grp: mine.length ? 'Anywhere' : 'PMOS' })),
28
+ ...rest.map((x) => ({ ...x, grp: 'Session' }))];
29
+ }
30
+
31
+ /** The best command for plain words, or null. Text starting with / is a command already; under 3 words is too little to guess. */
32
+ export function match(text, cmds, here = '') {
33
+ const t = String(text || '').trim();
34
+ if (!t || t.startsWith('/')) return null;
35
+ const have = words(t);
36
+ if (have.length < 3) return null;
37
+ let best = null;
38
+ for (const c of Array.isArray(cmds) ? cmds : []) {
39
+ if (!c || c.src !== 'pmos' || !Array.isArray(c.phrases)) continue;
40
+ for (const ph of c.phrases) {
41
+ const want = words(ph);
42
+ if (!want.length || !want.every((w) => have.some((h) => same(w, h)))) continue;
43
+ const score = want.length * 10 + (here && c.place === here ? 5 : 0);
44
+ if (!best || score > best.score) best = { score, c };
45
+ }
46
+ }
47
+ return best && best.score >= 20 ? best.c : null; // a one-word phrase alone ("glossary") needs the page to back it
48
+ }
49
+
50
+ /** The prompt a sent PMOS command becomes. The words stay first, so the chat shows what the PM typed. */
51
+ export function expand(text, cmds) {
52
+ const t = String(text || '').trim();
53
+ const m = /^(\/[a-z0-9-]+)(?:\s+([\s\S]*))?$/i.exec(t);
54
+ if (!m) return t;
55
+ const c = (Array.isArray(cmds) ? cmds : []).find((x) => x && x.src === 'pmos' && x.verb && x.cmd === m[1].toLowerCase());
56
+ if (!c) return t;
57
+ const args = (m[2] || '').trim();
58
+ const run = 'pmos ' + c.verb + (c.sub ? ' ' + c.sub : '');
59
+ return `${t}\n\n(${c.name}: run \`${run}\`${args ? ' for "' + args.replace(/"/g, "'") + '"' : ''} in this repository, pass its arguments as its help asks, and answer from what it prints, in plain words.)`;
60
+ }
61
+
62
+ export function hintOf(text, cmds) {
63
+ const m = /^(\/[a-z0-9-]+)\s+(\S*)$/i.exec(String(text || ''));
64
+ if (!m) return null;
65
+ const c = (Array.isArray(cmds) ? cmds : []).find((x) => x && x.src === 'pmos' && x.cmd === m[1].toLowerCase());
66
+ return c && c.hint ? { cmd: c.cmd, hint: c.hint, name: c.name } : null;
67
+ }
68
+
69
+ export function groupsOf(feats, groups, seen) {
70
+ const rows = (Array.isArray(feats) ? feats : []).filter((f) => f && f.audience === 'user');
71
+ const known = Array.isArray(seen) ? new Set(seen) : null;
72
+ const fresh = known ? rows.filter((f) => !known.has(f.id)) : [];
73
+ const out = fresh.length ? [{ label: 'New since you last looked', fresh: true, rows: fresh }] : [];
74
+ const order = Array.isArray(groups) && groups.length ? groups : [...new Set(rows.map((f) => f.group))];
75
+ for (const g of order) { const r = rows.filter((f) => f.group === g && !fresh.includes(f)); if (r.length) out.push({ label: g, rows: r }); }
76
+ return out;
77
+ }
@@ -0,0 +1,83 @@
1
+ /* pm/features-dir.js — "What PMOS can do": every user feature in the Viewer (initiative feature-directory, board FdA, done test F6).
2
+ *
3
+ * One registry (GET /api/features, lib/features.json) grouped by job. "New since you last looked" leads only when this browser has
4
+ * listed the directory before and a feature is new to it (zero is silence); the ids it has listed are one localStorage key, no text.
5
+ * Each row says how to reach its feature: its command (a press puts it in the page's chat box), its page, or its keys. The keys
6
+ * themselves live in the ? sheet (pm/action-keys.js); this page links to it instead of listing them again.
7
+ * Never says Claude. Each open and each press is noted on this computer only (pm/use-log.js): features-open, features-cmd, features-page.
8
+ *
9
+ * openFeatures() open the page in the Viewer
10
+ * dirHtml(data, seen, places) PURE markup for { groups, features } */
11
+ import { vwOpen, vwStyle } from './premium-viewer.js';
12
+ import { groupsOf } from './feature-match.js';
13
+ import { pmGet } from './http.js';
14
+ import { noteUse } from './use-log.js';
15
+
16
+ const SEEN = 'pmos.features.seen';
17
+ const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
18
+ const PAGES = { home: ['Today', '/today.html'], board: ['Work', '/premium-board.html'], insights: ['Goals', '/premium-goals.html'], events: ['Events', '/premium-events.html'], library: ['Library', '/premium-library.html'], routine: ['Routine', '/premium-routine.html'] };
19
+ const store = { get() { try { const v = JSON.parse(localStorage.getItem(SEEN) || 'null'); return Array.isArray(v) ? v : null; } catch { return null; } },
20
+ set(ids) { try { localStorage.setItem(SEEN, JSON.stringify(ids)); } catch { /* no storage: nothing is ever new */ } } };
21
+
22
+ function howHtml(f) {
23
+ const out = [];
24
+ if (f.cmd) out.push(`<button type="button" class="fd-ch" data-fd-cmd="${esc(f.cmd)}" title="Put ${esc(f.cmd)} in the chat box"><code>${esc(f.cmd)}</code></button>`);
25
+ if (f.place && PAGES[f.place]) out.push(`<a class="fd-ch" href="${PAGES[f.place][1]}" data-fd-page="${esc(f.place)}">${esc(PAGES[f.place][0])}</a>`);
26
+ if (f.keys === '?') out.push('<button type="button" class="fd-ch" data-fd-keys title="Show the keys">?</button>');
27
+ else if (f.keys) out.push(`<span class="fd-ch">${f.keys.split(' ').map((k) => `<kbd>${esc(k)}</kbd>`).join('')}</span>`);
28
+ if (f.action === 'guide') out.push('<button type="button" class="fd-ch" data-fd-guide>Open</button>');
29
+ return out.join('');
30
+ }
31
+
32
+ export function dirHtml(data, seen) {
33
+ const groups = groupsOf((data && data.features) || [], data && data.groups, seen);
34
+ if (!groups.length) return '<div class="vwdoc fd"><p class="vwmut">No features to show.</p></div>';
35
+ return '<div class="vwdoc fd"><div class="fd-find"><input type="search" data-fd-find placeholder="Find a feature" aria-label="Find a feature" autocomplete="off"></div>'
36
+ + groups.map((g) => `<section class="fd-grp${g.fresh ? ' fresh' : ''}" aria-label="${esc(g.label)}"><h3>${g.fresh ? '<i class="fd-dot" aria-hidden="true"></i>' : ''}${esc(g.label)}</h3>`
37
+ + g.rows.map((f) => `<div class="fd-row" data-fd-t="${esc((f.name + ' ' + f.say + ' ' + (f.cmd || '')).toLowerCase())}"><div class="tx"><b>${esc(f.name)}</b><span>${esc(f.say)}</span></div><div class="fd-how">${howHtml(f)}</div></div>`).join('')
38
+ + '</section>').join('')
39
+ + '<p class="vwmut fd-none" data-fd-none hidden>No feature matches.</p></div>';
40
+ }
41
+
42
+ function putInChat(cmd) {
43
+ const box = document.querySelector('#hmIn, #askIn');
44
+ if (box) { box.value = cmd + ' '; box.dispatchEvent(new Event('input', { bubbles: true })); box.focus(); return true; }
45
+ try { navigator.clipboard.writeText(cmd + ' '); } catch { /* no clipboard */ }
46
+ return false;
47
+ }
48
+
49
+ let clicks = false;
50
+ function wire(el) {
51
+ if (el.__fd) return; el.__fd = true;
52
+ el.addEventListener('input', (e) => {
53
+ if (!e.target.matches('[data-fd-find]')) return;
54
+ const q = e.target.value.trim().toLowerCase(); let any = false;
55
+ el.querySelectorAll('.fd-grp').forEach((g) => { let n = 0; g.querySelectorAll('.fd-row').forEach((r) => { const hit = !q || r.dataset.fdT.includes(q); r.hidden = !hit; if (hit) n++; }); g.hidden = !n; if (n) any = true; });
56
+ const none = el.querySelector('[data-fd-none]'); if (none) none.hidden = any;
57
+ });
58
+ if (clicks) return; clicks = true;
59
+ // the chips are real buttons and links; their clicks are delegated from the document, scoped to the directory
60
+ document.addEventListener('click', (e) => {
61
+ if (!e.target.closest || !e.target.closest('.fd')) return;
62
+ const c = e.target.closest('[data-fd-cmd]'); if (c) { noteUse('features-cmd'); if (!putInChat(c.dataset.fdCmd)) c.title = 'Copied: paste it in the chat'; return; }
63
+ if (e.target.closest('[data-fd-page]')) { noteUse('features-page'); return; }
64
+ if (e.target.closest('[data-fd-keys]')) { document.dispatchEvent(new KeyboardEvent('keydown', { key: '?', bubbles: true })); return; }
65
+ if (e.target.closest('[data-fd-guide]')) import('./premium-vw-open.js').then((M) => M.openGuide('index')).catch(() => {});
66
+ });
67
+ }
68
+
69
+ export function openFeatures() {
70
+ vwStyle('doc'); vwStyle('features');
71
+ noteUse('features-open');
72
+ let done = null;
73
+ const pane = vwOpen({ id: 'features', kind: 'Guide', title: 'What PMOS can do', icon: 'doc', url: '/premium-viewer.html?open=features',
74
+ render: (el) => { el.innerHTML = done || '<div class="vwdoc"><p class="vwmut" role="status">Reading the features.</p></div>'; wire(el); } });
75
+ pmGet('/api/features').then((d) => {
76
+ const seen = store.get();
77
+ done = d && d.ok ? dirHtml(d, seen) : '<div class="vwdoc"><p class="vwmut">The features could not be read.</p></div>';
78
+ if (d && d.ok) store.set([...new Set([...(seen || []), ...d.features.map((f) => f.id)])]);
79
+ const el = document.querySelector('.obody.vw[data-vw="features"]') || pane;
80
+ if (el && el.isConnected) { el.innerHTML = done; wire(el); }
81
+ }).catch(() => {});
82
+ return pane;
83
+ }
@@ -3,20 +3,23 @@
3
3
  * splits that block off the words and draws the goal before Start (XcbOptions B, row 1): the method line with Change, a row of dots (one per
4
4
  * point the method needs), the question with tap answers, and the ready plan as a card in the chat with Start, Change and Cancel as icons,
5
5
  * which Change turns into an editor in place. It also shows the PM's PMOS-typed turns as typed. */
6
+ import { ranked } from './feature-match.js';
6
7
  const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
7
8
 
8
- /** The `/` menu (G1): PMOS's /goal, then Claude Code's own commands. */
9
+ /** The `/` menu (G1): PMOS's commands, then the session's own. Until GET /api/slash-commands answers, and when it cannot, these. */
9
10
  export const SLASH = [
10
- { cmd: '/goal', name: 'Give PMOS a goal', say: 'It picks a way to ask about the goal, asks a few questions, then works on it after you press Start.' },
11
- { cmd: '/compact', name: 'Compact the conversation', say: 'Claude Code summarises the conversation so far to free room.' },
12
- { cmd: '/clear', name: 'Clear the conversation', say: 'Claude Code starts again with an empty context in the same session.' },
11
+ { cmd: '/goal', name: 'Give PMOS a goal', say: 'It picks a way to ask about the goal, asks a few questions, then works on it after you press Start.', src: 'pmos' },
12
+ { cmd: '/compact', name: 'Compact the conversation', say: 'Summarise the conversation so far to free room.', src: 'claude' },
13
+ { cmd: '/clear', name: 'Clear the conversation', say: 'Start again with an empty context in the same session.', src: 'claude' },
13
14
  ];
14
- /* every command Claude Code takes (GET /api/slash-commands: its own, the workspace's and the PM's commands and skills), read once;
15
- * until it answers, and when it cannot, the three above */
15
+ /* every command the session takes (GET /api/slash-commands: PMOS's from lib/features.json, the session's own, the workspace's and the
16
+ * PM's commands and skills), read once; until it answers, and when it cannot, the three above */
16
17
  let ALL = null;
17
18
  export function loadSlash(get) { if (ALL || !get) return Promise.resolve(ALL); return get('/api/slash-commands').then((r) => { if (r && r.ok && Array.isArray(r.commands) && r.commands.length) ALL = r.commands; return ALL; }).catch(() => null); }
19
+ /** Every command known now, for the typed-words suggestion and the send (pm/feature-match.js). */
20
+ export const slashList = () => ALL || SLASH;
18
21
  /** The menu items for what is in the box, or [] when the menu stays shut (no leading `/`, or a space typed). */
19
- export const slashMatches = (v) => (/^\/[a-z0-9:_.-]*$/i.test(String(v || '')) ? (ALL || SLASH).filter((x) => x.cmd.toLowerCase().startsWith(String(v).toLowerCase())) : []);
22
+ export const slashMatches = (v, here = '') => (/^\/[a-z0-9:_.-]*$/i.test(String(v || '')) ? ranked(ALL || SLASH, here).filter((x) => x.cmd.toLowerCase().startsWith(String(v).toLowerCase())) : []);
20
23
 
21
24
  /** { text, block }: the words with the last `pmos-goal` block taken out, and that block parsed (null when there is none or it does not parse). */
22
25
  export function splitGoal(text) {