create-pmos 0.786.0 → 0.787.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.786.0",
3
+ "version": "0.787.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": {
@@ -33,6 +33,29 @@
33
33
  "audit"
34
34
  ],
35
35
  "pmosChanges": [
36
+ {
37
+ "v": "0.787.0",
38
+ "at": "2026-11-24T17:51:02.745Z",
39
+ "f": 4,
40
+ "prs": [
41
+ {
42
+ "n": 1772,
43
+ "t": "Find every feature — PMOS / commands, typed-words suggestion and What PMOS can do",
44
+ "s": "Find every feature — PMOS / commands, typed-words suggestion and What PMOS can do",
45
+ "k": "new",
46
+ "h": "Find every feature — PMOS / commands, typed-words suggestion and What PMOS can do",
47
+ "try": {
48
+ "steps": [
49
+ "On Today, type / in the chat and pick Why this work exists",
50
+ "Type 'what if the API task slips a week' and press Tab on the suggestion",
51
+ "Press Ctrl+K, type features, and open What PMOS can do"
52
+ ],
53
+ "see": "The / menu lists PMOS commands first, each with its name and one line; the typed sentence turns into /rehearse; the directory lists features by job with New since you last looked on top",
54
+ "open": "/today.html"
55
+ }
56
+ }
57
+ ]
58
+ },
36
59
  {
37
60
  "v": "0.786.0",
38
61
  "at": "2026-11-24T17:39:55.270Z",
@@ -439,19 +462,6 @@
439
462
  "k": "new"
440
463
  }
441
464
  ]
442
- },
443
- {
444
- "v": "0.767.0",
445
- "at": "2026-11-24T07:34:38.820Z",
446
- "f": 4,
447
- "prs": [
448
- {
449
- "n": 1727,
450
- "t": "Let the work breakdown Gantt scroll sideways",
451
- "s": "Let the work breakdown Gantt scroll sideways",
452
- "k": "fix"
453
- }
454
- ]
455
465
  }
456
466
  ]
457
467
  }
@@ -1,3 +1,3 @@
1
- kernel-source: pmos@767dc6b77
1
+ kernel-source: pmos@8deceff9a
2
2
  assembled: 2026-11-24
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-11-24T17:39:51Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-24T17:50:59Z"}
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-11-24T17:39:51Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-24T17:50:59Z"}
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-11-24T17:39:51Z"}
5
+ generated: {by: process:create-pmos, at: "2026-11-24T17:50:59Z"}
6
6
  status: stable
7
7
  ---
8
8
 
@@ -1,4 +1,27 @@
1
1
  [
2
+ {
3
+ "v": "0.787.0",
4
+ "at": "2026-11-24T17:51:02.745Z",
5
+ "f": 4,
6
+ "prs": [
7
+ {
8
+ "n": 1772,
9
+ "t": "Find every feature — PMOS / commands, typed-words suggestion and What PMOS can do",
10
+ "s": "Find every feature — PMOS / commands, typed-words suggestion and What PMOS can do",
11
+ "k": "new",
12
+ "h": "Find every feature — PMOS / commands, typed-words suggestion and What PMOS can do",
13
+ "try": {
14
+ "steps": [
15
+ "On Today, type / in the chat and pick Why this work exists",
16
+ "Type 'what if the API task slips a week' and press Tab on the suggestion",
17
+ "Press Ctrl+K, type features, and open What PMOS can do"
18
+ ],
19
+ "see": "The / menu lists PMOS commands first, each with its name and one line; the typed sentence turns into /rehearse; the directory lists features by job with New since you last looked on top",
20
+ "open": "/today.html"
21
+ }
22
+ }
23
+ ]
24
+ },
2
25
  {
3
26
  "v": "0.786.0",
4
27
  "at": "2026-11-24T17:39:55.270Z",
@@ -182,6 +182,7 @@ Some features, such as Notes, open as a plain card in the Viewer. Each one works
182
182
  ## Search, Guide and Settings
183
183
 
184
184
  - **Guide** (the **?** icon in the menu) opens this guide in the Viewer.
185
+ - **What PMOS can do** lists every feature by job, each with how to reach it: its command (press it to put it in the chat box), its page, or its keys. Open it from Ctrl K (type "features"), from the ? key list, or from the guide. Features new since you last looked come first.
185
186
  - **Search** (Ctrl K or ⌘K, or `/`) finds initiatives, documents, sessions and files in your work. It always reads the repository and all its worktrees, so it has no worktree picker. It also reaches every page, each Settings section, the themes and the actions of the item you last pointed at: type "lib" to go to Library, or "conn" for Settings › Connectors.
186
187
  - **Dates** show the year only when the year is not this year, for example "Jun 23 ’27". New for you shows a due date as "due 25 Nov".
187
188
  - **Settings** holds the workspace settings. **General** holds the theme (Light, Dark or Auto) and **Product**, which names the product the page reads. **Connectors** shows when PMOS last read each source. A source that is old or failed has an amber dot and ↻ to read it again. ↻ in the Connectors header reads every source again. While a source is old, an amber box at the top of Settings names it, with ↻.
@@ -235,7 +236,8 @@ There is no My work page. The list on Today is your list:
235
236
  - A conversation opens at its latest message.
236
237
  - A file that you send shows as a chip in your message, with a small picture for a photo. Press the chip to open the file beside the conversation.
237
238
  - Your message shows as you typed it. Markdown that you paste (headings, lists, bold, code, tables) shows formatted.
238
- - Type `/` to see every command: `/goal`, then one `/pmos:` command for each button a PMOS card has (`/pmos:task-set` moves a task's dates; the list comes from the card catalog), the commands built into Claude Code, and the commands and skills in the workspace's `.claude` folder and in your own `~/.claude` folder.
239
+ - Type `/` to see the commands. PMOS's own come first, each with its name and one line: the ones for the page you are on, then the others (`/why`, `/rehearse`, `/missed`, `/critic` and more), then one `/pmos:` command for each button a PMOS card has (`/pmos:task-set` moves a task's dates; the list comes from the card catalog). Pick one and its arguments show above the box, for example `/rehearse <task> <days>`. When you send it, PMOS runs the matching `pmos` command and answers from what it prints. The session's own commands (`/compact`, `/model` and the rest) show once you type a letter of their name, then the commands and skills in the workspace's `.claude` folder and in your own `~/.claude` folder.
240
+ - Type in plain words and PMOS suggests the command they ask for, above the box: "what if the API task slips a week" suggests `/rehearse`. Press Tab to take it, or keep typing to ignore it. The suggestion is matched on this computer. When nothing matches and **Suggest commands** is on in Settings › Jev and Laya, Jev is asked which command fits.
239
241
  - The mic types what you say into the box. **Stop** keeps the words, and **Discard** puts the box back. Both end listening at once.
240
242
  - When Claude Code asks whether to trust the folder of a new chat, the chat shows the ask as a card: **Trust this folder** or **No, end the session**. Your first message waits until you answer, for up to 15 minutes, and is then sent. It is never typed into the question.
241
243
 
@@ -77,7 +77,7 @@ When PMOS sees a pattern, one suggestion opens the section, with **Why**, **PMOS
77
77
  At the bottom of **General**, **Extras** has three rows. Press the arrow on a row to open its settings; the back arrow returns to General.
78
78
 
79
79
  - **Adler ›**: how much of Adler you see (Full, Face only or Off), motion, celebrations, Quiet after, and Dress for the day. See [Adler, PMOS's face](layout.md).
80
- - **Jev and Laya ›**: the TypeSafe key for Jev, the local model Laya, and the switches for each repository: whether Jev may read it, sort documents, check claims and label notes.
80
+ - **Jev and Laya ›**: the TypeSafe key for Jev, the local model Laya, and the switches for each repository: whether Jev may read it, sort documents, suggest commands from the words you type in the chat (off until you turn it on), check claims and label notes.
81
81
  - **Use log ›**: what PMOS notes on this computer about how you use it: the pages you open and the buttons you press, kept 30 days. A button is noted by its code name, never by its text or anything you typed. The log stays in the PMOS folder on this computer and is never sent. The panel shows the last 30 days (days, page opens, presses, and the pages and buttons you use most). Press **Clear** to empty it.
82
82
  - **Hidden buttons**: after 14 days, when a page has buttons you saw on many days and never pressed, PMOS offers on that page to hide them (✦, Yes or No; while it shows, those buttons are outlined). Yes hides them and a Toast offers Undo; No keeps them, and PMOS does not suggest them again. Every hidden button is listed here with **Show**, and **Show all** puts them all back. Buttons in the menu, a list, a table, a dialog or a form are never suggested.
83
83
  - **Ease check ›**: how easy each page is for you, read from the use log on this computer. For each page, PMOS takes the button you press most there as the page's main task, and shows the usual number of presses and seconds from opening the page to that press. A page over 3 presses or 10 seconds is listed first as slow. It reads the last 14 days, and a page needs 3 visits that reach its main task before it shows. Nothing is sent.
@@ -0,0 +1,31 @@
1
+ {
2
+ "about": "The user features of PMOS, one row each, for the chat's / menu, the typed-words suggestion, the What PMOS can do directory, Ctrl+K and the ? sheet (initiative feature-directory). Only audience user rows are shown. A row with cmd names a pmos verb (lib/pmos-verbs.js) that its prompt runs; place is a page key of the menu (pm/cozy-nav.js). since is the first version that has the feature. features.test.js F1 checks every row.",
3
+ "groups": ["Plan and decide", "Before you ship", "Catch up", "Your product", "What PMOS did", "Find your way"],
4
+ "features": [
5
+ {"id": "goal", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Give PMOS a goal", "say": "PMOS asks a few questions, then works on the goal after you press Start.", "cmd": "/goal", "phrases": ["work on this until", "keep going until", "make it happen"], "since": "0.560.0"},
6
+ {"id": "why", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Why this work exists", "say": "Three lines on an initiative or a task: its goal, its problem and the evidence.", "cmd": "/why", "verb": "why", "hint": "<initiative or task>", "phrases": ["why does this exist", "why are we doing", "why are we building", "what is the point of", "reason for this work", "why this initiative"], "phone": true, "since": "0.700.0"},
7
+ {"id": "rehearse", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Rehearse a change", "say": "Move a task by some days and see what else slips, before anything changes.", "cmd": "/rehearse", "verb": "rehearse", "sub": "move", "hint": "<task> <days>", "place": "board", "phrases": ["what if slips", "what happens if slips", "what if move", "push back", "delay by", "slips a week", "what breaks if", "move the date", "what if we cut"], "since": "0.600.0"},
8
+ {"id": "decisions", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Decision journal", "say": "Write one line per decision, with what you expect and the date to check it.", "cmd": "/decide", "verb": "decisions", "sub": "add", "hint": "<the decision>", "phrases": ["we decided", "log a decision", "record a decision", "note the decision", "decision journal", "list decisions"], "since": "0.640.0"},
9
+ {"id": "questions", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Open questions", "say": "Every question nobody has answered yet, oldest first, in one list.", "cmd": "/questions", "verb": "questions", "phrases": ["open questions", "unanswered questions", "what is still open", "questions nobody answered", "what do we not know"], "phone": true, "since": "0.660.0"},
10
+ {"id": "press-release", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Press release and FAQ", "say": "A one-page press release and FAQ for a bet, drafted from its record, for you to edit.", "cmd": "/press-release", "verb": "press-release", "hint": "<initiative>", "phrases": ["press release", "working backwards", "write the faq", "announce this"], "since": "0.690.0"},
11
+ {"id": "launch", "audience": "user", "status": "ga", "group": "Before you ship", "name": "What is not ready", "say": "Before a launch date: the tasks, sign-offs and documents still open.", "cmd": "/launch", "verb": "launch", "sub": "check", "hint": "<initiative>", "phrases": ["ready to launch", "what is not ready", "before launch", "launch checklist", "can we ship", "ready to ship", "is it ready for launch"], "since": "0.650.0"},
12
+ {"id": "ready", "audience": "user", "status": "ga", "group": "Before you ship", "name": "Ready for engineers", "say": "The five basics the engineers need before the tickets go to them.", "cmd": "/ready", "verb": "ready", "sub": "check", "hint": "<initiative>", "phrases": ["ready for engineering", "ready for engineers", "ready for dev", "hand over to engineers", "ready for development"], "since": "0.650.0"},
13
+ {"id": "critic", "audience": "user", "status": "ga", "group": "Before you ship", "name": "Critic before you share", "say": "Reads a document as a sceptical reviewer and lists the hardest questions.", "cmd": "/critic", "verb": "critic", "hint": "<document>", "phrases": ["poke holes", "review this doc", "critique this", "before I share", "hardest questions", "sceptical review", "skeptical review", "what would they ask"], "since": "0.680.0"},
14
+ {"id": "missed", "audience": "user", "status": "ga", "group": "Catch up", "name": "What you might have missed", "say": "What each of the last weeks would have shown you, in one list.", "cmd": "/missed", "verb": "drift", "sub": "show", "phrases": ["what did I miss", "what have I missed", "catch me up", "while I was away", "what changed this week", "what changed since"], "phone": true, "since": "0.620.0"},
15
+ {"id": "past", "audience": "user", "status": "ga", "group": "Catch up", "name": "Ask about the past", "say": "The decisions, notes and records that answer a question, each with its source.", "cmd": "/past", "verb": "past", "sub": "ask", "hint": "<question>", "phrases": ["when did we decide", "why did we decide", "who decided", "what did we agree", "last time we", "history of"], "phone": true, "since": "0.630.0"},
16
+ {"id": "parked", "audience": "user", "status": "ga", "group": "Catch up", "name": "Parked work", "say": "Each initiative on hold, why it is parked and what brings it back.", "cmd": "/parked", "verb": "parked", "sub": "list", "phrases": ["parked work", "what is on hold", "what is parked", "paused initiatives"], "since": "0.700.0"},
17
+ {"id": "people", "audience": "user", "status": "ga", "group": "Catch up", "name": "People you work with", "say": "Each person with their role, how often you talk and their tone.", "cmd": "/people", "verb": "people", "sub": "list", "phrases": ["who do I work with", "stakeholders list", "people on this", "who is involved"], "since": "0.610.0"},
18
+ {"id": "strategy", "audience": "user", "status": "ga", "group": "Your product", "name": "Five-line strategy", "say": "Who it is for, the problem, the bet, how you win and what you will not do.", "cmd": "/strategy", "verb": "strategy", "sub": "show", "place": "board", "phrases": ["our strategy", "product strategy", "draft the strategy", "how we win"], "since": "0.776.0"},
19
+ {"id": "positioning", "audience": "user", "status": "ga", "group": "Your product", "name": "Positioning and key messages", "say": "A positioning statement and key messages, each citing a strategy line.", "cmd": "/positioning", "verb": "positioning", "sub": "list", "phrases": ["positioning statement", "key messages", "messaging for"], "since": "0.740.0"},
20
+ {"id": "principles", "audience": "user", "status": "ga", "group": "Your product", "name": "Product principles", "say": "Four to six principles drafted from your past decisions, each citing them.", "cmd": "/principles", "verb": "principles", "sub": "list", "phrases": ["product principles", "our principles", "design principles for"], "since": "0.720.0"},
21
+ {"id": "glossary", "audience": "user", "status": "ga", "group": "Your product", "name": "Glossary", "say": "The product's own words; every page shows a word's meaning on hover.", "cmd": "/glossary", "verb": "glossary", "sub": "list", "hint": "<word>", "phrases": ["define the word", "glossary", "add to glossary", "meaning of the word"], "since": "0.690.0"},
22
+ {"id": "health", "audience": "user", "status": "ga", "group": "Your product", "name": "Health score", "say": "This product's health from 0 to 100, and the three parts that make it.", "cmd": "/health", "verb": "health", "sub": "score", "phrases": ["health score", "how healthy is", "product health"], "phone": true, "since": "0.737.0"},
23
+ {"id": "outcomes", "audience": "user", "status": "ga", "group": "Your product", "name": "Did it work?", "say": "Each initiative's expected outcome and the date to check it.", "cmd": "/outcomes", "verb": "outcomes", "sub": "list", "phrases": ["did it work", "expected outcome", "outcomes due", "check the outcome"], "since": "0.640.0"},
24
+ {"id": "changed", "audience": "user", "status": "ga", "group": "What PMOS did", "name": "What PMOS changed by itself", "say": "Every change PMOS made on its own today, with its source and its Undo.", "cmd": "/changed", "verb": "factory", "sub": "today", "phrases": ["what did pmos change", "what did you change", "changes pmos made", "what did the agents do"], "phone": true, "since": "0.700.0"},
25
+ {"id": "autonomy", "audience": "user", "status": "ga", "group": "What PMOS did", "name": "What agents applied", "say": "What agents applied by themselves in the last 14 days, each with its Undo.", "cmd": "/applied", "verb": "autonomy", "sub": "status", "phrases": ["what did agents apply", "applied by themselves", "auto applied"], "since": "0.680.0"},
26
+ {"id": "describe", "audience": "user", "status": "ga", "group": "Plan and decide", "name": "Task descriptions", "say": "What, why and done-when for each task, drafted from its sources.", "cmd": "/describe", "verb": "task", "sub": "describe", "hint": "<task>", "place": "board", "phrases": ["describe this task", "task description", "write the description", "what is this task about"], "since": "0.770.0"},
27
+ {"id": "search", "audience": "user", "status": "ga", "group": "Find your way", "name": "Search and ask", "say": "Ctrl+K finds work, pages and features, and answers questions from your files.", "keys": "Ctrl K", "since": "0.737.0"},
28
+ {"id": "action-keys", "audience": "user", "status": "ga", "group": "Find your way", "name": "Keys for the five common actions", "say": "Yes, open, next sprint, park and undo, one key each. Press ? to see them.", "keys": "?", "since": "0.730.0"},
29
+ {"id": "guide", "audience": "user", "status": "ga", "group": "Find your way", "name": "The Guide", "say": "How each part of PMOS works, page by page.", "action": "guide", "since": "0.500.0"}
30
+ ]
31
+ }
@@ -0,0 +1,88 @@
1
+ 'use strict';
2
+ /* jev-command.js — ask Jev which PMOS command plain typed words ask for, only when the local match cannot tell
3
+ * (initiative feature-directory, done test F5). The bridge between the chat box and the one TypeSafe module (lib/typesafe.js);
4
+ * like lib/jev-route.js it opens no client of its own, and no-network.test.js holds it to that.
5
+ *
6
+ * Three gates, all required: a saved key, D79 consent for the repository, and the "suggest commands with Jev" switch (`suggest`,
7
+ * default OFF). With any one shut nothing is sent and the answer is { cmd: null }. Text the secret scan matches, or that names an
8
+ * excluded path, is withheld the same way. At most MAX_CHARS of the typed words leave the machine, nothing else: no path, no file.
9
+ *
10
+ * Jev gets one Choice question over the command ids plus `none`. An answer under BAR, or within GAP of the next option, is no
11
+ * suggestion: a wrong suggestion costs more than none. Jev does not treat its input as hostile, so the answer only ever names one
12
+ * of the listed commands, and the PM still presses Tab to take it.
13
+ *
14
+ * The switch is kept beside the other settings, in <state>/feature-suggest.json ({ repos: { <root>: true } }), one boolean per repository.
15
+ *
16
+ * switchOf(stateDir, root) → boolean · setSwitch(stateDir, root, on) → { ok } | { ok: false, error }
17
+ * gates({ key, flags }) → { open, missing }
18
+ * suggest({ text, cmds, key, flags, ask?, askOpts? }) → Promise<{ ok: true, cmd: string|null, sent: boolean, why?: string }> never throws */
19
+ const fs = require('fs');
20
+ const path = require('path');
21
+ const typesafe = require('./typesafe');
22
+ const scanner = require('./secret-scan');
23
+
24
+ const FILE = 'feature-suggest.json';
25
+ function readSw(stateDir) { try { const j = JSON.parse(fs.readFileSync(path.join(stateDir, FILE), 'utf8')); return j && typeof j.repos === 'object' && j.repos ? j : { repos: {} }; } catch { return { repos: {} }; } }
26
+ function switchOf(stateDir, root) { return !!(stateDir && root && readSw(stateDir).repos[root] === true); }
27
+ function setSwitch(stateDir, root, on) {
28
+ if (!stateDir || !root || typeof on !== 'boolean') return { ok: false, error: 'a repository and true or false are needed' };
29
+ const j = readSw(stateDir);
30
+ if (on) j.repos[root] = true; else delete j.repos[root];
31
+ try { fs.mkdirSync(stateDir, { recursive: true }); const tmp = path.join(stateDir, FILE + '.' + process.pid + '.tmp'); fs.writeFileSync(tmp, JSON.stringify(j, null, 2) + '\n'); fs.renameSync(tmp, path.join(stateDir, FILE)); return { ok: true }; }
32
+ catch (e) { return { ok: false, error: String((e && e.message) || e).slice(0, 200) }; }
33
+ }
34
+
35
+ const MAX_CHARS = 400;
36
+ const BAR = 0.6;
37
+ const GAP = 0.15;
38
+ const INSTRUCTIONS = 'Which one of these PMOS commands does the message ask for? Answer none when it asks for something else, or for no command at all.';
39
+
40
+ function gates({ key, flags = {} }) {
41
+ const missing = [];
42
+ if (!typesafe.validKey(key)) missing.push('key');
43
+ if (!flags.consent) missing.push('consent');
44
+ if (!flags.suggest) missing.push('suggest');
45
+ return { open: missing.length === 0, missing };
46
+ }
47
+
48
+ /** The options of the Choice question: each command's id (its name without the /) with its name and line, plus none. */
49
+ function optionsOf(cmds) {
50
+ const o = {};
51
+ for (const c of cmds || []) if (c && c.cmd && c.verb) o[c.cmd.slice(1)] = `${c.name}: ${c.say}`;
52
+ o.none = 'Something else, or no command';
53
+ return o;
54
+ }
55
+
56
+ /** The leading option and its lead over the next, from a defensively read answer. Pure. */
57
+ function pick(ans, options) {
58
+ if (!ans || typeof ans !== 'object') return null;
59
+ const p = {};
60
+ const put = (k, v) => { const n = Number(v); if (Object.prototype.hasOwnProperty.call(options, k) && Number.isFinite(n) && n >= 0 && n <= 1) p[k] = n; };
61
+ const raw = ans.probabilities || ans.distribution;
62
+ if (Array.isArray(raw)) { for (const x of raw) if (x && typeof x === 'object') put(x.option || x.label || x.choice, x.probability != null ? x.probability : x.p); }
63
+ else if (raw && typeof raw === 'object') { for (const [k, v] of Object.entries(raw)) put(k, v); }
64
+ if (!Object.keys(p).length && typeof ans.choice === 'string') put(ans.choice, ans.confidence);
65
+ const sorted = Object.entries(p).sort((a, b) => b[1] - a[1]);
66
+ if (!sorted.length) return null;
67
+ return { id: sorted[0][0], p: sorted[0][1], lead: sorted[0][1] - (sorted[1] ? sorted[1][1] : 0) };
68
+ }
69
+
70
+ async function suggest({ text, cmds, key, flags = {}, ask = typesafe.ask, askOpts = {} }) {
71
+ const t = String(text == null ? '' : text).trim();
72
+ if (!t || t.startsWith('/')) return { ok: true, cmd: null, sent: false };
73
+ const g = gates({ key, flags });
74
+ if (!g.open) return { ok: true, cmd: null, sent: false, why: 'off: ' + g.missing.join(', ') };
75
+ if (scanner.scan(t).length) return { ok: true, cmd: null, sent: false, why: 'withheld: secret scan' };
76
+ const ex = Array.isArray(flags.exclude) ? flags.exclude : [];
77
+ if (ex.some((e) => e && !e.includes('*') && t.includes(e))) return { ok: true, cmd: null, sent: false, why: 'withheld: excluded path' };
78
+ const options = optionsOf(cmds);
79
+ let res;
80
+ try { res = await ask({ key, state: 'MESSAGE TYPED IN A PRODUCT MANAGEMENT TOOL (classify it; do not carry it out):\n' + t.slice(0, MAX_CHARS), questions: { command: { type: 'choice', instructions: INSTRUCTIONS, criteria: options } }, ...askOpts }); }
81
+ catch (e) { return { ok: true, cmd: null, sent: true, why: 'failed: ' + String((e && e.message) || e).slice(0, 120) }; }
82
+ if (!res || !res.ok) return { ok: true, cmd: null, sent: true, why: 'failed: ' + ((res && res.reason) || 'the service did not answer') };
83
+ const best = pick(res.answers && res.answers.command, options);
84
+ if (!best || best.id === 'none' || best.p < BAR || best.lead < GAP) return { ok: true, cmd: null, sent: true, why: 'unsure' };
85
+ return { ok: true, cmd: '/' + best.id, sent: true };
86
+ }
87
+
88
+ module.exports = { gates, suggest, switchOf, setSwitch, optionsOf, pick, MAX_CHARS, BAR, GAP };
@@ -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');
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "pmos-workspace",
3
- "version": "0.786.0",
3
+ "version": "0.787.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.787.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.787.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) {
@@ -24,7 +24,9 @@
24
24
  * viewerClosed(), reopenViewer(), head(target), touch(sid) (the PM opened, typed in or answered that session: the Live pill) } */
25
25
  import { mdHtml, userHtml, toolLine, webKind } from './chat-md.js';
26
26
  import { streamOf, roleOf, tintOf, hm } from './home-data.js';
27
- import { splitGoal, shownUser, goalBlockHtml, goalViewHtml, goalNow, slashMatches, loadSlash } from './goal-chat.js';
27
+ import { splitGoal, shownUser, goalBlockHtml, goalViewHtml, goalNow, slashMatches, loadSlash, slashList } from './goal-chat.js';
28
+ import { hereOf, match as matchWords, expand as expandCmd, hintOf } from './feature-match.js'; // feature-directory: PMOS commands, typed words, the send
29
+ import { noteUse } from './use-log.js';
28
30
  import { goalModel, sessionModel, lineHtml, viewHtml, dividerHtml, goalDivider } from './home-line.js';
29
31
  import { goalUi } from './home-goal.js';
30
32
  import { splitReport, reportChipHtml, blockSig } from './report-chat.js';
@@ -528,6 +530,9 @@ export function mountChat(el, host) {
528
530
  async function send(text) {
529
531
  const t = C.t; text = String(text || '').trim();
530
532
  if (!t || (!text && !C.files.length) || C.sending) return false;
533
+ if (C.cmdSug && C.cmdSug.for.trim() === text) { noteUse('slash-suggest-skip'); C.cmdSug = null; } // sent as typed: the suggestion was not wanted
534
+ { const cmd = /^\/[a-z0-9-]+/i.exec(text), own = cmd && slashList().find((x) => x.src === 'pmos' && x.cmd === cmd[0].toLowerCase()); if (own) noteUse('slash-pmos-' + own.cmd.slice(1)); }
535
+ text = expandCmd(text, slashList()); // a PMOS command runs its pmos verb (feature-directory F4); any other text is unchanged
531
536
  if (t.key && C.files.some((f) => f.state === 'saving')) { host.toast('A file is still being saved. Send again in a moment.'); return false; }
532
537
  // the canvas's marks go before the words (lib/live-round.js marksOf reads them), then they are used up
533
538
  const mk = C.mark || {};
@@ -632,6 +637,7 @@ export function mountChat(el, host) {
632
637
  send(d.chatSay); return;
633
638
  }
634
639
  if (d.slash) { pickSlash(d.slash); return; }
640
+ if (d.cmdSug) { takeSug(); return; }
635
641
  if (d.askPick) {
636
642
  const card = b.closest('.tc'), btn = card && card.querySelector('[data-ask-send]'), at = btn ? btn.dataset.askSend : null, ask = at != null && askOf(at); if (!ask) return;
637
643
  const [q, k] = d.askPick.split(':').map(Number);
@@ -684,16 +690,17 @@ export function mountChat(el, host) {
684
690
  if (e.key === 'Escape' && GU.escape()) { e.preventDefault(); e.stopPropagation(); return; }
685
691
  if (e.target.id !== 'hmIn') { if (e.key === 'Escape' && running() && !document.querySelector('[data-esc-layer]') && !(window.czViewer && window.czViewer.isOpen())) press('esc'); return; }
686
692
  if (e.isComposing || e.keyCode === 229) return;
687
- const list = slashMatches(e.target.value), sm = el.querySelector('#hmSlash'), menu = list.length && sm && !sm.hidden;
693
+ const list = menuList(e.target.value), sm = el.querySelector('#hmSlash'), menu = list.length && sm && !sm.hidden;
688
694
  if (menu && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) { e.preventDefault(); C.slashAt = (C.slashAt + (e.key === 'ArrowDown' ? 1 : list.length - 1)) % list.length; drawSlash(); return; }
689
695
  if (menu && (e.key === 'Tab' || (e.key === 'Enter' && !e.shiftKey && e.target.value !== list[C.slashAt].cmd))) { e.preventDefault(); pickSlash(list[C.slashAt].cmd); return; }
696
+ if (!menu && e.key === 'Tab' && !e.shiftKey && sugNow(e.target.value)) { e.preventDefault(); takeSug(); return; }
690
697
  if (menu && e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); e.target.value = ''; drawSlash(); grow(e.target); return; }
691
698
  if (e.key === 'Enter' && !e.shiftKey && !e.altKey && !e.ctrlKey && !e.metaKey) { e.preventDefault(); el.querySelector('#hmForm').requestSubmit(); }
692
699
  });
693
700
  el.addEventListener('input', (e) => {
694
701
  const card = C.t && C.t.intro && C.t.intro.card;
695
702
  if (card && card.input && e.target.closest('.hm-icard')) { card.input(e.target, e.target.closest('.hm-icard')); return; }
696
- if (e.target.id === 'hmIn') { grow(e.target); C.slashAt = 0; drawSlash(); NPU.input(e.target.value); if (C.err) { C.err = ''; const er = foot.querySelector('.hm-senderr'); if (er) er.remove(); foot.__h = null; } }
703
+ if (e.target.id === 'hmIn') { grow(e.target); C.slashAt = 0; suggestFor(e.target.value); drawSlash(); NPU.input(e.target.value); if (C.err) { C.err = ''; const er = foot.querySelector('.hm-senderr'); if (er) er.remove(); foot.__h = null; } }
697
704
  });
698
705
  /* ── the mic ── dictation into the box only (HmMic). A desk shows the blue dot in the box; a phone shows the Speak to Claude sheet. */
699
706
  const box = () => foot.querySelector('textarea');
@@ -731,18 +738,53 @@ export function mountChat(el, host) {
731
738
  else { C.sendAfter = true; C.dict.stop(); }
732
739
  sheetOf({ on: false });
733
740
  }
734
- /* the / menu: opens on a leading /, arrows move, Enter or Tab picks, Esc shuts it */
741
+ /* the / menu: opens on a leading /, arrows move, Enter or Tab picks, Esc shuts it. PMOS's commands for this page come first, then
742
+ * the other PMOS ones; the session's own commands fold away on a bare / and show once a letter is typed (feature-directory).
743
+ * With a command picked, its arguments' hint stays above the box. Plain words that ask for a command get one suggestion; Tab takes it. */
744
+ const here = () => hereOf(location.pathname);
745
+ function menuList(v) { const l = slashMatches(v, here()); return v === '/' ? l.filter((x) => x.grp !== 'Session') : l; }
735
746
  function drawSlash() {
736
747
  const ta = foot.querySelector('textarea'); if (!ta) return;
737
748
  let m = el.querySelector('#hmSlash');
738
- const list = slashMatches(ta.value);
739
- if (!list.length) { if (m) { m.hidden = true; m.removeAttribute('data-esc-layer'); } return; }
749
+ const v = ta.value, list = menuList(v), hint = list.length ? null : hintOf(v, slashList()), sug = list.length || hint ? null : sugNow(v);
750
+ if (!list.length && !hint && !sug) { if (m) { m.hidden = true; m.removeAttribute('data-esc-layer'); } return; }
740
751
  if (!m) { foot.insertAdjacentHTML('afterbegin', '<div class="hm-slash" id="hmSlash" role="listbox" aria-label="Commands"></div>'); m = el.querySelector('#hmSlash'); }
752
+ if (hint) { m.innerHTML = `<p class="hm-slhint"><code>${esc(hint.cmd)} ${esc(hint.hint)}</code><span>${esc(hint.name)}</span></p>`; m.hidden = false; m.removeAttribute('data-esc-layer'); return; }
753
+ if (sug) { m.innerHTML = `<button type="button" role="option" aria-selected="true" data-cmd-sug="1" title="Tab turns your words into this command"><span class="l1"><code>${esc(sug.cmd)}</code><b>${esc(sug.name)}</b></span><em>Tab turns your words into this command</em></button>`; m.hidden = false; m.removeAttribute('data-esc-layer'); return; }
741
754
  C.slashAt = Math.min(C.slashAt, list.length - 1);
742
- m.innerHTML = list.map((x, i) => `<button type="button" role="option" aria-selected="${i === C.slashAt}" data-slash="${esc(x.cmd)}"><span class="l1"><code>${esc(x.cmd)}</code>${x.name && x.name !== x.cmd.slice(1) ? `<b>${esc(x.name)}</b>` : ''}</span>${x.say ? `<em>${esc(x.say)}</em>` : ''}</button>`).join('');
755
+ let grp = null;
756
+ const multi = new Set(list.map((x) => x.grp)).size > 1;
757
+ m.innerHTML = list.map((x, i) => { const head = multi && x.grp !== grp ? `<p class="hm-slgrp" role="presentation">${esc(x.grp)}</p>` : ''; grp = x.grp;
758
+ return head + `<button type="button" role="option" aria-selected="${i === C.slashAt}" data-slash="${esc(x.cmd)}"><span class="l1"><code>${esc(x.cmd)}</code>${x.name && x.name !== x.cmd.slice(1) ? `<b>${esc(x.name)}</b>` : ''}</span>${x.say ? `<em>${esc(x.say)}</em>` : ''}</button>`; }).join('')
759
+ + (v === '/' ? '<p class="hm-slgrp" role="presentation">Session commands show as you type their name</p>' : '');
743
760
  const on = m.querySelector('[aria-selected="true"]'); if (on && on.scrollIntoView) on.scrollIntoView({ block: 'nearest' });
744
761
  m.hidden = false; m.setAttribute('data-esc-layer', '');
745
762
  }
763
+ /* the typed-words suggestion: the local phrases first (instant, on this computer); only when they find nothing, and only when the PM
764
+ * switched "Suggest commands with Jev" on for this repository, one question to Jev a moment after typing stops (lib/jev-command.js) */
765
+ let sugT = null, jevOn = null;
766
+ const sugNow = (v) => (C.cmdSug && C.cmdSug.for === v ? C.cmdSug : null);
767
+ function suggestFor(v) {
768
+ clearTimeout(sugT);
769
+ const t = String(v || '');
770
+ const loc = matchWords(t, slashList(), here());
771
+ if (loc) { C.cmdSug = { ...loc, for: t, from: 'local' }; return; }
772
+ if (C.cmdSug && C.cmdSug.for !== t) C.cmdSug = null;
773
+ if (t.startsWith('/') || t.trim().split(/\s+/).length < 4 || !C.t || !C.t.ws) return;
774
+ sugT = setTimeout(async () => {
775
+ if (jevOn == null) { const f = await host.pmGet('/api/features?ws=' + encodeURIComponent(C.t.ws)).catch(() => null); jevOn = !!(f && f.ok && f.suggest); }
776
+ if (!jevOn) return;
777
+ const r = await host.pmPost('/api/features/suggest', { ws: C.t.ws, text: t }).catch(() => null);
778
+ const ta = foot.querySelector('textarea');
779
+ const c = r && r.ok && r.cmd ? slashList().find((x) => x.cmd === r.cmd) : null;
780
+ if (c && ta && ta.value === t) { C.cmdSug = { ...c, for: t, from: 'jev' }; drawSlash(); }
781
+ }, 500);
782
+ }
783
+ function takeSug() {
784
+ const ta = foot.querySelector('textarea'), s = C.cmdSug; if (!ta || !s) return;
785
+ noteUse('slash-suggest-take'); C.cmdSug = null;
786
+ ta.value = s.cmd + ' ' + s.for.trim(); drawSlash(); grow(ta); ta.focus();
787
+ }
746
788
  function pickSlash(cmd) { const ta = foot.querySelector('textarea'); ta.value = cmd + ' '; C.slashAt = 0; drawSlash(); grow(ta); ta.focus(); }
747
789
  /* Notes: the notepad opens in the Viewer for the conversation's key; Add selection writes into this box, Share with Claude puts the note
748
790
  * on the next message as a chip (premium-attach's sink), and on a phone both return to the chat. */
@@ -14,7 +14,8 @@
14
14
  *
15
15
  * paletteGroups(q, ctx) PURE (but for the item's buttons, read from the page): [{ label, allOnly: true, rows: [{ id, title, sub?, tag?, icon, open() }] }]
16
16
  * withEverything(scope, ctx) a Search scope ({ name, hits(q) }): the page's own groups first, then paletteGroups
17
- * ctx: { places: [{ key, label, href }], here, item?, doc?, wsq?(prefix) → '?ws=…' | '', chat?(), setTheme?(pick), go?(url) } */
17
+ * ctx: { places: [{ key, label, href }], here, item?, doc?, wsq?(prefix) → '?ws=…' | '', chat?(), setTheme?(pick), go?(url),
18
+ * features?: the user features (feature-directory), found by name; a pick opens What PMOS can do } */
18
19
  import { KEYS, targetOf, wordsOf } from './action-keys.js';
19
20
  import { SECTIONS } from './set-ds.js';
20
21
  import { noteUse } from './use-log.js';
@@ -54,6 +55,7 @@ function actionRows(q, ctx) {
54
55
  const A = [
55
56
  { id: 'chat', title: 'Ask PMOS', also: 'chat talk', icon: 'chat', run: () => (ctx.chat ? ctx.chat() : null) },
56
57
  { id: 'guide', title: 'Open the Guide', also: 'help how', icon: 'guide', run: lazy('./premium-vw-open.js', (M) => M.openGuide('index')) },
58
+ { id: 'features', title: 'What PMOS can do', also: 'features commands shortcuts directory slash', icon: 'guide', run: lazy('./premium-vw-open.js', (M) => M.openFeatures()) },
57
59
  { id: 'calendar', title: 'Open the calendar', also: 'events meetings', icon: 'cal', run: lazy('./premium-vw-open.js', (M) => M.openCalendar({ ws: ctx.ws || '' })) },
58
60
  { id: 'notes', title: 'Open notes', also: 'meeting notes', icon: 'doc', run: lazy('./premium-vw-open.js', (M) => M.openNotes({ ws: ctx.ws || '' })) },
59
61
  { id: 'note', title: 'New note', also: 'write capture', icon: 'doc', run: lazy('./premium-vw-open.js', (M) => M.newNote(ctx.ws || '')) },
@@ -79,11 +81,18 @@ function itemRows(q, ctx) {
79
81
  return out;
80
82
  }
81
83
 
82
- /** The groups for a query: On this item, Go to, Do; a group with no row is left out. */
84
+ /* feature-directory: the user features (GET /api/features, held by the menu in ctx.features) found by name; a pick opens the directory */
85
+ function featureRows(q, ctx) {
86
+ return (Array.isArray(ctx.features) ? ctx.features : []).filter((f) => f && matches(q, f.name, f.say, f.cmd || ''))
87
+ .map((f) => ({ id: 'feature:' + f.id, title: f.name, sub: f.cmd || 'Feature', icon: 'guide', open: pick('palette-feature', lazy('./premium-vw-open.js', (M) => M.openFeatures())) }))
88
+ .sort(byName(q));
89
+ }
90
+
91
+ /** The groups for a query: On this item, Go to, Do, Features; a group with no row is left out. */
83
92
  export function paletteGroups(q, ctx = {}) {
84
93
  const s = String(q || '').trim();
85
94
  if (s.length < 2) return [];
86
- return [['On this item', itemRows(s, ctx)], ['Go to', pageRows(s, ctx).slice(0, 6)], ['Do', actionRows(s, ctx).slice(0, 6)]]
95
+ return [['On this item', itemRows(s, ctx)], ['Go to', pageRows(s, ctx).slice(0, 6)], ['Do', actionRows(s, ctx).slice(0, 6)], ['Features', featureRows(s, ctx).slice(0, 6)]]
87
96
  .filter(([, rows]) => rows.length).map(([label, rows]) => ({ label, rows, allOnly: true })); // Search: on All only, never counted as initiatives
88
97
  }
89
98
 
@@ -6,7 +6,8 @@ import { turnsOf } from './chat-context.js';
6
6
  import { chipsHtml, itemOf, openCtx } from './premium-vw-ctx.js';
7
7
  import { lineItems, behindOf, whenRead } from './freshness-words.js';
8
8
  import { weeksOf, lineOf, KINDS } from './upd-weeks.js';
9
- import { splitGoal, shownUser, goalBlockHtml, goalProgressHtml, goalChipHtml, goalViewHtml, goalNow, slashMatches } from './goal-chat.js';
9
+ import { splitGoal, shownUser, goalBlockHtml, goalProgressHtml, goalChipHtml, goalViewHtml, goalNow, slashMatches, slashList, loadSlash } from './goal-chat.js';
10
+ import { hereOf, expand as expandCmd } from './feature-match.js'; // feature-directory: PMOS commands run their pmos verb
10
11
  import { mdHtml, userHtml, toolLine, webKind } from './chat-md.js';
11
12
  import { splitReport, reportChipHtml, blockSig } from './report-chat.js';
12
13
  import { askCardHtml, answerText } from './chat-ask.js';
@@ -730,6 +731,7 @@ $('#dBody').addEventListener('click', onWebLink); $('#dOut').addEventListener('c
730
731
  /** Send one message to the open popup's own conversation (a viewer tab's Read it now). False when no popup conversation is open. */
731
732
  export async function askHere(text) { return S.key && $('#dlg').classList.contains('on') ? sendText(S.key, text) : false; }
732
733
  async function sendText(key, text, files) {
734
+ text = expandCmd(text, slashList());
733
735
  const go = $('#askGo'); if (go) go.disabled = true; $('#askNote').textContent = 'Sending.';
734
736
  const ctx = S.ctx && key === S.key ? { context: S.ctx } : {};
735
737
  const res = await chatPost('ask', files && files.length ? { key, text, files, ...ctx } : { key, text, ...ctx });
@@ -778,9 +780,10 @@ $('#dBody').addEventListener('click', onGoalPress);
778
780
  $('#dOut').addEventListener('click', (e) => { if (e.target.closest('.vwgoal [data-goal]')) onGoalPress(e); }); // Start, Change, Cancel and Stop in the Goal tab
779
781
  /* the `/` menu (G1): opens on a leading `/`, arrows move, Enter or Tab picks, Esc shuts it */
780
782
  let slashAt = 0;
783
+ loadSlash(pmGet); // every command, PMOS's own first (feature-directory)
781
784
  function drawSlash() {
782
785
  const m = $('#slashM'), inp = $('#askIn'); if (!m || !inp) return;
783
- const list = slashMatches(inp.value);
786
+ const list = slashMatches(inp.value, hereOf(location.pathname));
784
787
  if (!list.length) { m.hidden = true; m.removeAttribute('data-esc-layer'); inp.removeAttribute('aria-activedescendant'); return; }
785
788
  slashAt = Math.min(slashAt, list.length - 1);
786
789
  m.innerHTML = list.map((x, i) => `<button type="button" role="option" id="slash-${i}" aria-selected="${i === slashAt}" class="${i === slashAt ? 'sel' : ''}" data-slash="${esc(x.cmd)}"><code>${esc(x.cmd)}</code><b>${esc(x.name)}</b><em>${esc(x.say)}</em></button>`).join('');
@@ -795,7 +798,7 @@ export function growAsk() {
795
798
  $('#dBody').addEventListener('input', (e) => { if (e.target.id === 'askIn') { slashAt = 0; drawSlash(); growAsk(); } });
796
799
  $('#dBody').addEventListener('keydown', (e) => {
797
800
  if (e.target.id !== 'askIn' || e.isComposing || e.keyCode === 229) return; // an IME is still composing: its Enter picks the word, it does not send
798
- const list = slashMatches(e.target.value), menu = list.length && !$('#slashM').hidden;
801
+ const list = slashMatches(e.target.value, hereOf(location.pathname)), menu = list.length && !$('#slashM').hidden;
799
802
  if (menu && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) { e.preventDefault(); slashAt = (slashAt + (e.key === 'ArrowDown' ? 1 : list.length - 1)) % list.length; drawSlash(); }
800
803
  else if (menu && (e.key === 'Tab' || (e.key === 'Enter' && !e.shiftKey && e.target.value !== list[slashAt].cmd))) { e.preventDefault(); pickSlash(list[slashAt].cmd); }
801
804
  else if (menu && e.key === 'Escape') { e.preventDefault(); e.target.value = ''; drawSlash(); growAsk(); }
@@ -0,0 +1,17 @@
1
+ /* premium-vw-features.css — What PMOS can do in the Viewer (pm/features-dir.js; board FdA, Exploring 3 page features). Quiet: one row
2
+ * shape, the group name as the only header, a blue dot only on the New group, chips that say how to reach each feature. */
3
+ .vwdoc.fd{display:flex;flex-direction:column;gap:var(--space-4)}
4
+ .fd-find input{width:100%;height:40px;box-sizing:border-box;padding:0 var(--space-12);border-radius:var(--radius-md);border:0;background:var(--well);color:var(--ink);font:inherit}
5
+ .fd-grp h3{display:flex;align-items:center;gap:var(--space-8);margin:var(--space-12) 0 var(--space-4);font-size:var(--fs-meta);line-height:var(--lh-meta);font-weight:var(--fw-strong);color:var(--ink-3)}
6
+ .fd-dot{width:8px;height:8px;border-radius:4px;background:var(--ember);display:inline-block}
7
+ .fd-row{display:flex;align-items:center;gap:var(--space-12);min-height:56px;padding:6px var(--space-8);border-radius:var(--radius-md)}
8
+ .fd-row:hover{background:var(--well)}
9
+ .fd-row .tx{flex:1;min-width:0;display:flex;flex-direction:column}
10
+ .fd-row .tx b{font-weight:var(--fw-strong)}
11
+ .fd-row .tx span{font-size:var(--fs-meta);line-height:var(--lh-meta);color:var(--ink-3)}
12
+ .fd-how{display:flex;gap:6px;flex-shrink:0;flex-wrap:wrap;justify-content:flex-end}
13
+ .fd-ch{min-height:32px;display:inline-flex;align-items:center;gap:4px;padding:0 10px;border-radius:999px;border:1px solid var(--hair);background:none;font:inherit;font-size:var(--fs-meta);color:var(--ink);text-decoration:none;cursor:pointer}
14
+ .fd-ch:hover{background:var(--well)}
15
+ .fd-ch code{font-family:var(--mono);color:var(--vw-lnk)}
16
+ .fd-ch kbd{font-family:var(--mono)}
17
+ @media (max-width:760px){.fd-row{flex-wrap:wrap}.fd-how{justify-content:flex-start}.fd-ch{min-height:44px}}
@@ -30,8 +30,9 @@ export async function openReport(ref, o = {}) { vzStyle(); return (await rep()).
30
30
  export async function newNote(o) { vzStyle(); return (await mtg()).newNote(typeof o === 'string' ? o : (o && o.ws) || ''); }
31
31
  export async function makeWorkItem(noteId, step) { return (await mtg()).workItem(noteId, step); }
32
32
  export async function openGuide(page) { vzStyle(); return (await gd()).openGuide(page); }
33
+ export async function openFeatures() { vzStyle(); return (await import('./features-dir.js')).openFeatures(); } // feature-directory: What PMOS can do
33
34
 
34
- export const views = { openMeeting, openCalendar, openNotes, openReport, newNote, makeWorkItem, openGuide };
35
+ export const views = { openMeeting, openCalendar, openNotes, openReport, newNote, makeWorkItem, openGuide, openFeatures };
35
36
  if (typeof window !== 'undefined') {
36
37
  window.czViews = Object.assign(window.czViews || {}, views);
37
38
  window.pmViewer = window.czViews;
@@ -1,6 +1,6 @@
1
1
  /* pm/premium-vw-page.js — /premium-viewer.html: opens the item its address names in the Viewer card (initiative premium-agreed-design).
2
2
  * ?open=meeting&note=<id> | &event=<id>&date=YYYY-MM-DD ?open=calendar[&tab=notes][&date=] ?open=notes[&initiative=]
3
- * ?open=report&path=reports/<cadence>/<date>.md ?open=guide[&page=<name>] each with an optional &ws=
3
+ * ?open=report&path=reports/<cadence>/<date>.md ?open=guide[&page=<name>] ?open=features each with an optional &ws=
4
4
  * Closing the card leaves a line that links to Home. An address that names nothing says so. */
5
5
  import { views } from './premium-vw-open.js';
6
6
  import { onChange } from './cozy-viewer.js';
@@ -15,4 +15,5 @@ else if (what === 'calendar') views.openCalendar({ ws, tab: q.get('tab') === 'no
15
15
  else if (what === 'notes') views.openNotes({ ws, initiative: q.get('initiative') || '' });
16
16
  else if (what === 'report' && q.get('path')) views.openReport(q.get('path'), { ws });
17
17
  else if (what === 'guide') views.openGuide(q.get('page') || 'index');
18
+ else if (what === 'features') views.openFeatures();
18
19
  else gone.hidden = false;
@@ -0,0 +1,9 @@
1
+ {
2
+ "_comment": "Find every feature (initiative feature-directory, done test F1-F6): the registry against the pmos verbs and pages, the / menu route, the typed-words match, the send's expansion, the Jev bridge with a fake ask, and the directory, Ctrl+K and ? wiring. Pure checks; no server, model or network.",
3
+ "modules": [
4
+ "features.test.js"
5
+ ],
6
+ "seconds": {
7
+ "features.test.js": 2
8
+ }
9
+ }