create-pmos 0.410.0 → 0.412.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 +25 -30
- package/payload/KIT-VERSION +1 -1
- package/payload/planning/evals/eval-calibration.md +1 -1
- package/payload/planning/okrs/health-budgets.md +1 -1
- package/payload/state/discoveries.md +1 -1
- package/workspace/briefing-premium-adddoc-test.js +2 -2
- package/workspace/briefing-premium-initiative-test.js +9 -15
- package/workspace/briefing-premium-insights-test.js +2 -2
- package/workspace/briefing-premium-test.js +3 -3
- package/workspace/changelog.json +24 -0
- package/workspace/chat-asks-test.js +146 -0
- package/workspace/guide/board.md +1 -1
- package/workspace/guide/breakdown.md +6 -13
- package/workspace/guide/briefing-premium.md +1 -1
- package/workspace/guide/home.md +24 -0
- package/workspace/guide/index.md +1 -1
- package/workspace/guide/initiative-driver.md +1 -1
- package/workspace/guide/initiatives-screen.md +1 -1
- package/workspace/guide/pm-only-acts.md +23 -24
- package/workspace/guide/today.md +1 -1
- package/workspace/home-rows-test.js +149 -56
- package/workspace/ini-workflow-test.js +4 -4
- package/workspace/lib/briefing-premium-agent.js +8 -1
- package/workspace/lib/briefing-premium-writes.js +5 -4
- package/workspace/lib/coredoc-cli.js +1 -1
- package/workspace/lib/driver-cli.js +2 -1
- package/workspace/lib/driver-decide.js +3 -2
- package/workspace/lib/driver.js +2 -1
- package/workspace/lib/engine/boards.js +3 -1
- package/workspace/lib/goal-chat.js +94 -30
- package/workspace/lib/grant-mint.js +3 -2
- package/workspace/lib/initiative-cli.js +9 -9
- package/workspace/lib/issues.js +5 -4
- package/workspace/lib/mention-cli.js +70 -0
- package/workspace/lib/mention-store.js +307 -0
- package/workspace/lib/people-store.js +1 -1
- package/workspace/lib/people.js +3 -1
- package/workspace/lib/placements.js +13 -15
- package/workspace/lib/plan-items.js +17 -48
- package/workspace/lib/pm-guard.js +18 -5
- package/workspace/lib/pm-lines-needs.js +9 -5
- package/workspace/lib/pmos-verbs.js +3 -0
- package/workspace/lib/report-cli.js +2 -2
- package/workspace/lib/routes-board-metric-targets.js +0 -1
- package/workspace/lib/routes-boards.js +12 -0
- package/workspace/lib/routes-briefing-premium.js +5 -7
- package/workspace/lib/routes-core-docs.js +0 -1
- package/workspace/lib/routes-custom-docs.js +0 -1
- package/workspace/lib/routes-driver.js +0 -1
- package/workspace/lib/routes-home-desk.js +1 -1
- package/workspace/lib/routes-home-review.js +1 -1
- package/workspace/lib/routes-initiative-layout.js +1 -1
- package/workspace/lib/routes-insights-records.js +0 -1
- package/workspace/lib/routes-meeting-material.js +0 -1
- package/workspace/lib/routes-mentions.js +62 -9
- package/workspace/lib/routes-onboarding.js +3 -1
- package/workspace/lib/routes-orchestrator.js +0 -1
- package/workspace/lib/routes-premium-charts.js +0 -1
- package/workspace/lib/routes-premium-dashboards.js +0 -1
- package/workspace/lib/routes-programs.js +1 -1
- package/workspace/lib/routes-records.js +1 -1
- package/workspace/lib/routes-report-design.js +7 -3
- package/workspace/lib/routes-report-setups.js +0 -1
- package/workspace/lib/routes-report-structure.js +0 -1
- package/workspace/lib/routes-runs.js +2 -5
- package/workspace/lib/routes-scan.js +0 -1
- package/workspace/lib/routes-sources.js +1 -1
- package/workspace/lib/run-answers.js +14 -5
- package/workspace/lib/scan-cli.js +2 -1
- package/workspace/lib/scan.js +2 -1
- package/workspace/lib/session-files.js +132 -0
- package/workspace/lib/session-name.js +103 -0
- package/workspace/lib/source-reads.js +4 -1
- package/workspace/lib/vendor/scripts/onboarding/proposals.js +7 -3
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/premium-board-actions-test.js +10 -8
- package/workspace/premium-chat-goal-setup-test.js +203 -0
- package/workspace/premium-chat-goal-view-test.js +28 -23
- package/workspace/premium-chat-line-test.js +189 -0
- package/workspace/premium-core-doc-issue-test.js +1 -1
- package/workspace/premium-viewer-share-test.js +5 -2
- package/workspace/premium-vw-backlog-test.js +1 -1
- package/workspace/premium-vw-item-test.js +1 -1
- package/workspace/premium-vw-jira-test.js +1 -1
- package/workspace/public/pm/chat-ask.js +17 -9
- package/workspace/public/pm/cozy-home-rows.css +39 -1
- package/workspace/public/pm/cozy-home.css +112 -12
- package/workspace/public/pm/cozy-search.js +2 -1
- package/workspace/public/pm/cozy-steps.css +69 -0
- package/workspace/public/pm/cozy-steps.js +90 -0
- package/workspace/public/pm/goal-chat.js +141 -23
- package/workspace/public/pm/home-app.js +68 -35
- package/workspace/public/pm/home-ask.js +121 -0
- package/workspace/public/pm/home-chat.js +120 -68
- package/workspace/public/pm/home-data.js +10 -2
- package/workspace/public/pm/home-goal.js +159 -0
- package/workspace/public/pm/home-ini.css +35 -0
- package/workspace/public/pm/home-ini.js +50 -19
- package/workspace/public/pm/home-line.css +59 -0
- package/workspace/public/pm/home-line.js +200 -0
- package/workspace/public/pm/home-list.js +2 -2
- package/workspace/public/pm/home-mentions.js +303 -111
- package/workspace/public/pm/home-ses-name.js +65 -0
- package/workspace/public/pm/home-stage-card.js +94 -0
- package/workspace/public/pm/home-sweep.js +112 -0
- package/workspace/public/pm/home-today.js +7 -2
- package/workspace/public/pm/premium-initiative-head.js +8 -4
- package/workspace/public/pm/rename-press.js +24 -0
- package/workspace/public/pm/wf-page.css +3 -0
- package/workspace/public/pm/wf-page.js +2 -1
- package/workspace/public/premium-workflows.html +1 -0
- package/workspace/replaced-tests.json +101 -0
- package/workspace/server.js +133 -20
- package/workspace/session-names-test.js +144 -0
- package/workspace/skills/jira-push.skill +1 -0
- package/workspace/skills/morning-brief.skill +2 -1
- package/workspace/skills/report-daily.skill +1 -0
- package/workspace/skills/report-monthly.skill +1 -0
- package/workspace/skills/report-weekly.skill +1 -0
- package/workspace/skills/sources-read.skill +3 -2
- package/workspace/stage-card-test.js +203 -0
- package/workspace/test-lists/chat-asks.json +13 -0
- package/workspace/test-lists/chat-progress.json +13 -0
- package/workspace/test-lists/mentions-a-plus.json +9 -0
- package/workspace/test-lists/premium-chat-goal-setup.json +9 -0
- package/workspace/test-lists/session-files.json +5 -0
- package/workspace/test-lists/session-names.json +13 -0
- package/workspace/test-lists/stage-card.json +6 -0
- package/workspace/tk-tasks-test.js +1 -1
- package/workspace/workflows-setup-test.js +17 -0
|
@@ -157,7 +157,7 @@ function foundOf(f) {
|
|
|
157
157
|
const sources = Array.isArray(f.sources) ? f.sources.filter((x) => x && typeof x.ref === 'string').slice(0, 8).map((x) => ({ label: String(x.label || ''), ref: x.ref })) : [];
|
|
158
158
|
return { why: typeof f.why === 'string' ? f.why : '', sources, match: typeof f.match === 'string' && f.match ? f.match : null, scan: typeof f.scan === 'string' ? f.scan : null, run: typeof f.run === 'string' ? f.run : null };
|
|
159
159
|
}
|
|
160
|
-
const KINDS = new Set(['board', 'workflow', 'move', 'assign', 'ask', 'ask-accept', 'ask-decline', 'ask-more', 'ini-workflow', 'task', 'task-update', 'ini-epics', 'ini-archive', 'ini-notdup', 'ini-wf', 'ini-end', 'stage-judge', 'ini-auto']);
|
|
160
|
+
const KINDS = new Set(['board', 'workflow', 'move', 'assign', 'ask', 'ask-accept', 'ask-decline', 'ask-more', 'ini-workflow', 'task', 'task-update', 'task-remove', 'ini-epics', 'ini-archive', 'ini-notdup', 'ini-wf', 'ini-end', 'stage-judge', 'ini-auto']);
|
|
161
161
|
const TASK_STATES = Object.freeze(['To do', 'In progress', 'In review', 'Done']);
|
|
162
162
|
|
|
163
163
|
const copyStages = (stages) => stages.map((s) => ({ name: s.name, cat: s.cat, hint: s.hint || '' }));
|
|
@@ -260,6 +260,8 @@ function fold(events) {
|
|
|
260
260
|
if (typeof e.due === 'string') t.due = e.due;
|
|
261
261
|
if (typeof e.title === 'string' && e.title.trim()) t.title = e.title.trim(); // a rename (canvas RnATask)
|
|
262
262
|
t.history.push({ at: e.at || null, by: e.by || null, state: e.state || null, start: e.start || null, due: e.due || null, why: e.why || '' });
|
|
263
|
+
} else if (e.kind === 'task-remove' && typeof e.task === 'string' && tasks.has(e.task)) {
|
|
264
|
+
tasks.delete(e.task); // the Undo of a task just added (routes-boards.js tasks/undo-add)
|
|
263
265
|
} else if (e.kind === 'ini-epics' && typeof e.id === 'string' && Array.isArray(e.epics)) {
|
|
264
266
|
epics.set(e.id, e.epics.filter((k) => typeof k === 'string' && JIRA_KEY_RE.test(k)).map((k) => k.toUpperCase()));
|
|
265
267
|
} else if (e.kind === 'ini-archive' && typeof e.id === 'string') {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* goal-chat — `/goal` in the premium chat panel (initiative premium-chat-session, slice 2; PRD G2–G7).
|
|
3
|
-
* `/goal <text>` turns into a PMOS grilling prompt typed into the panel's own Claude Code session: Claude reads the records,
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* `/goal <text>` turns into a PMOS grilling prompt typed into the panel's own Claude Code session: Claude reads the records, picks the
|
|
4
|
+
* questioning method that fits the goal (METHODS; the PM can change it), asks one question at a time, and ends each message with a fenced
|
|
5
|
+
* `pmos-goal` JSON block the panel draws as a dots row, answer chips or the plan card. Start, Change, Cancel, a skipped point and a replaced
|
|
6
|
+
* goal are the PM's presses. The record is append-only: goal-runs.jsonl in the state folder. */
|
|
6
7
|
const fs = require('fs');
|
|
7
8
|
const path = require('path');
|
|
8
9
|
const crypto = require('crypto');
|
|
@@ -11,7 +12,17 @@ const RUNS = 'goal-runs.jsonl';
|
|
|
11
12
|
const LIMIT = 12;
|
|
12
13
|
const MAX_TEXT = 1000;
|
|
13
14
|
// The first line of every message PMOS types for a goal. The panel reads it to show the PM's turn as typed (public/pm/goal-chat.js).
|
|
14
|
-
const MARK = { grill: '[PMOS /goal]', start: '[PMOS /goal start]', cancel: '[PMOS /goal cancel]' };
|
|
15
|
+
const MARK = { grill: '[PMOS /goal]', start: '[PMOS /goal start]', cancel: '[PMOS /goal cancel]', method: '[PMOS /goal method]', plan: '[PMOS /goal plan]', skip: '[PMOS /goal skip]', unskip: '[PMOS /goal unskip]' };
|
|
16
|
+
/* The questioning methods Claude picks from (Wawan, 2026-10-25: SMART is one method, not the only one). Each names the points it needs; the
|
|
17
|
+
* dots row over a question has one dot per point. public/pm/goal-chat.js keeps the same list for the Change menu (goal-chat.test.js M1). */
|
|
18
|
+
const METHODS = [
|
|
19
|
+
{ id: 'done-criteria', name: 'Done criteria', fits: 'it ends in a deliverable, such as a document or a release', points: ['What it delivers', 'The done points', 'By when', 'What it may do'] },
|
|
20
|
+
{ id: 'pre-mortem', name: 'Pre-mortem', fits: 'a risky launch or change', points: ['What ships', 'How it could fail', 'What prevents each failure', 'By when'] },
|
|
21
|
+
{ id: 'outcome', name: 'Outcome and measure', fits: 'it moves a metric', points: ['The outcome', 'The measure and its target', 'The baseline', 'By when'] },
|
|
22
|
+
{ id: 'problem', name: 'Problem statement', fits: 'discovery, while the problem is not clear yet', points: ['The problem', 'Who has it', 'The evidence', 'What we want to learn'] },
|
|
23
|
+
{ id: 'smart', name: 'SMART', fits: 'any other goal', points: ['Specific', 'Measurable', 'Achievable', 'Relevant', 'Time-bound'] },
|
|
24
|
+
];
|
|
25
|
+
const methodOf = (id) => METHODS.find((m) => m.id === id) || null;
|
|
15
26
|
|
|
16
27
|
/** '/goal Ship X' → { text: 'Ship X' }; '/goal' → { text: '' }; anything else → null. */
|
|
17
28
|
function parseCommand(s) {
|
|
@@ -23,18 +34,37 @@ function grillPrompt(text) {
|
|
|
23
34
|
return [
|
|
24
35
|
MARK.grill + ' The PM set a goal: ' + text,
|
|
25
36
|
'',
|
|
26
|
-
'
|
|
27
|
-
'1.
|
|
28
|
-
|
|
29
|
-
'
|
|
30
|
-
'
|
|
37
|
+
'Agree this goal with the PM before any work. Do not start the work: nothing runs until the PM presses Start on the page.',
|
|
38
|
+
'1. Pick the questioning method that fits this goal best, from this list. The page shows your pick in one line, and the PM can change it.',
|
|
39
|
+
...METHODS.map((m) => ' - ' + m.id + ' (' + m.name + '): when ' + m.fits + '. Its points: ' + m.points.join('; ') + '.'),
|
|
40
|
+
'2. Read the records first (this repository\'s planning/ folder, its initiatives and OKRs, open pull requests where you can) and fill what you can of the method\'s points. Done points are always checkable.',
|
|
41
|
+
'3. Ask the PM only about the points you could not fill. One question per message, at most 5 questions in all. Each question offers 2 or 3 short answers; mark one as recommended. The PM can also type their own answer.',
|
|
42
|
+
'4. Stop asking when every point is agreed, after 5 questions, or when the PM says "start with defaults". A value the PM did not give takes a sensible default and is listed in "assumed".',
|
|
43
|
+
'5. If the goal needs something you cannot do here (for example sending mail that is not set up), say so and propose what you can do instead.',
|
|
44
|
+
'6. A message that starts with ' + MARK.method + ' changes the method: keep what is already agreed where it fits, and ask from there. A message that starts with ' + MARK.plan + ' is the plan as the PM edited it.',
|
|
31
45
|
'',
|
|
32
46
|
'End every message of this exchange with one fenced code block with the language tag pmos-goal, holding one JSON object. The page draws it; keep the words before it short.',
|
|
33
|
-
'- While asking: {"step":"question","
|
|
34
|
-
'- When ready: {"step":"ready","draft":{...}}',
|
|
35
|
-
'The draft: {"goal":"one sentence","done":["checkable point", "..."],"may":"what you may do","serves":"initiative or KR","by":"deadline, ISO 8601 date and time","limit":' + LIMIT + ',"assumed":["by"]}. Leave out the keys you do not know yet.',
|
|
47
|
+
'- While asking: {"step":"question","method":"done-criteria","why":"it ends in a document","points":[{"name":"What it delivers","agreed":true},{"name":"The done points","agreed":false}],"question":"What must be true for it to be done?","options":[{"label":"PR green and checklist ticked","recommended":true},{"label":"PR merged"}],"draft":{...what is known so far}}',
|
|
48
|
+
'- When ready: {"step":"ready","method":"done-criteria","points":[...every point, agreed],"draft":{...}}',
|
|
49
|
+
'"why" is a few words on why the method fits this goal. The draft: {"goal":"one sentence","done":["checkable point", "..."],"may":"what you may do","serves":"initiative or KR","by":"deadline, ISO 8601 date and time","limit":' + LIMIT + ',"assumed":["by"]}. Leave out the keys you do not know yet.',
|
|
36
50
|
].join('\n');
|
|
37
51
|
}
|
|
52
|
+
/** The PM's Change on the method line: the message the panel sends. Unknown ids give null. */
|
|
53
|
+
function methodMessage(id) {
|
|
54
|
+
const m = methodOf(id); if (!m) return null;
|
|
55
|
+
return MARK.method + ' Use the ' + m.name + ' method for this goal instead. Its points: ' + m.points.join('; ') + '. Keep what is already agreed where it fits, and ask from there.';
|
|
56
|
+
}
|
|
57
|
+
/** The plan as the PM edited it in place. running: the goal works, so the change applies after the current step. */
|
|
58
|
+
function planMessage(draft, running = false) {
|
|
59
|
+
return [
|
|
60
|
+
MARK.plan + ' The PM changed the plan in place' + (running ? ' while you work. Apply it after your current step.' : '.'),
|
|
61
|
+
JSON.stringify(draft),
|
|
62
|
+
running ? 'Work to this plan from now on. Do not repeat it back.'
|
|
63
|
+
: 'Read it again. Write one line only if a done point has no way to check it; otherwise write nothing but the block. End with a ready pmos-goal block that holds exactly this plan.',
|
|
64
|
+
].join('\n');
|
|
65
|
+
}
|
|
66
|
+
const skipMessage = (point) => MARK.skip + ' The PM skipped the done point "' + point + '". Drop it after your current step and do not work on it. It no longer counts.';
|
|
67
|
+
const unskipMessage = (point) => MARK.unskip + ' The PM took the skip back: the done point "' + point + '" counts again.';
|
|
38
68
|
|
|
39
69
|
function startMessage(draft) {
|
|
40
70
|
return [
|
|
@@ -71,10 +101,14 @@ function goalOf(runtimeDir, key) {
|
|
|
71
101
|
if (!e || e.key !== key) continue;
|
|
72
102
|
if (e.event === 'grilling') g = { id: e.id, state: 'grilling', text: e.text, at: e.at };
|
|
73
103
|
else if (!g || e.id !== g.id) continue;
|
|
74
|
-
else if (e.event === 'started') g = { ...g, state: 'started', draft: e.draft, startedAt: e.at, rounds: 0, met: [], open: (e.draft && e.draft.done) || [], at: e.at };
|
|
104
|
+
else if (e.event === 'started') g = { ...g, state: 'started', draft: e.draft, startedAt: e.at, roundAt: e.at, rounds: 0, met: [], open: (e.draft && e.draft.done) || [], at: e.at };
|
|
75
105
|
else if (e.event === 'cancelled') g = { ...g, state: 'cancelled', at: e.at };
|
|
76
|
-
else if (e.event === 'round') g = { ...g, rounds: e.n, met: e.met || [], open: e.open || [], at: e.at };
|
|
106
|
+
else if (e.event === 'round') g = { ...g, rounds: e.n, met: e.met || [], open: e.open || [], at: e.at, roundAt: e.at };
|
|
77
107
|
else if (e.event === 'seen') g = { ...g, seen: true };
|
|
108
|
+
else if (e.event === 'planned') g = { ...g, plan: e.draft, planAt: e.at }; // the PM's in-place edit before Start
|
|
109
|
+
else if (e.event === 'edited') g = { ...g, draft: e.draft, open: ((e.draft && e.draft.done) || []).filter((x) => !(g.met || []).includes(x)) }; // ... and while it works
|
|
110
|
+
else if (e.event === 'skip') g = { ...g, skipped: [...new Set((g.skipped || []).concat(e.point))], skipAt: { ...(g.skipAt || {}), [e.point]: e.at } };
|
|
111
|
+
else if (e.event === 'unskip') g = { ...g, skipped: (g.skipped || []).filter((x) => x !== e.point) };
|
|
78
112
|
else if (e.event === 'resumed') g = { ...g, state: 'started', reason: undefined, at: e.at };
|
|
79
113
|
else if (['done', 'stopped', 'waiting'].includes(e.event)) g = { ...g, state: e.event, ...(e.reason ? { reason: e.reason } : {}), met: e.met || g.met, open: e.open || g.open, at: e.at };
|
|
80
114
|
}
|
|
@@ -96,7 +130,9 @@ function statesAt(runtimeDir) {
|
|
|
96
130
|
* goal done or needs the PM, at the deadline, after the round limit, or after NO_PROGRESS rounds that met no new point.
|
|
97
131
|
* The done check is Claude's own report (a pmos-goal progress block), so the page calls it unverified. */
|
|
98
132
|
const NO_PROGRESS = 3;
|
|
99
|
-
|
|
133
|
+
/** The done points that still count: the draft's, less the ones the PM skipped. */
|
|
134
|
+
const requiredOf = (g) => ((g.draft && g.draft.done) || []).filter((x) => !(g.skipped || []).includes(x));
|
|
135
|
+
const REASON = { deadline: 'The deadline has passed.', limit: 'It used all its rounds.', 'no-progress': 'Three rounds in a row met no new done point.', pm: 'You stopped it.', replaced: 'You replaced it with a new goal.' };
|
|
100
136
|
/** The last fenced pmos-goal block in a message, parsed, or null. */
|
|
101
137
|
function blockOf(text) {
|
|
102
138
|
const re = /```pmos-goal[^\n]*\n([\s\S]*?)```/g;
|
|
@@ -120,9 +156,9 @@ const roundsOf = (runtimeDir, id) => {
|
|
|
120
156
|
function onStop({ runtimeDir, key, message, now = new Date() }) {
|
|
121
157
|
const g = key && goalOf(runtimeDir, key);
|
|
122
158
|
if (!g || g.state !== 'started' || !g.draft) return {};
|
|
123
|
-
const d = g.draft, b = blockOf(message), all =
|
|
124
|
-
const met = (b && b.step === 'progress' && strs(b.met)) || g.met || [];
|
|
125
|
-
const open = (b && b.step === 'progress' && strs(b.open)) || all.filter((x) => !met.includes(x));
|
|
159
|
+
const d = g.draft, b = blockOf(message), all = requiredOf(g), skipped = g.skipped || [];
|
|
160
|
+
const met = ((b && b.step === 'progress' && strs(b.met)) || g.met || []).filter((x) => !skipped.includes(x));
|
|
161
|
+
const open = ((b && b.step === 'progress' && strs(b.open)) || all.filter((x) => !met.includes(x))).filter((x) => !skipped.includes(x));
|
|
126
162
|
const base = { id: g.id, key, met, open, at: now.toISOString() };
|
|
127
163
|
if (b && b.step === 'progress' && (b.state === 'done' || (open.length === 0 && met.length > 0))) { append(runtimeDir, { event: 'done', ...base }); return {}; }
|
|
128
164
|
if (b && b.step === 'progress' && b.state === 'needs-you') { append(runtimeDir, { event: 'waiting', ...base }); return {}; }
|
|
@@ -163,7 +199,7 @@ function goalRowsAt(runtimeDir, now = Date.now()) {
|
|
|
163
199
|
if (!g || !g.draft || !ROW_TITLE[g.state] || g.seen) continue;
|
|
164
200
|
const at = Date.parse(g.at || '');
|
|
165
201
|
if (Number.isFinite(at) && now - at > ROW_DAYS * 86400000) continue;
|
|
166
|
-
const all = g
|
|
202
|
+
const all = requiredOf(g), met = (g.met || []).filter((x) => all.includes(x)).length;
|
|
167
203
|
const why = g.state === 'stopped' ? (REASON[g.reason] || 'It stopped.') : g.state === 'waiting' ? 'Claude asked you something in the conversation.' : 'Claude reports every done point met. It checked its own work.';
|
|
168
204
|
out.push({
|
|
169
205
|
kind: 'goal', key: 'goal:' + key, chatKey: key, goalState: g.state, title: ROW_TITLE[g.state], subject: clip(g.draft.goal, 90),
|
|
@@ -175,7 +211,7 @@ function goalRowsAt(runtimeDir, now = Date.now()) {
|
|
|
175
211
|
say: clip(g.draft.goal, 200) + ': ' + why, head: 'The goal',
|
|
176
212
|
facts: [['State', ROW_TITLE[g.state]], ['Done points', met + ' of ' + all.length + ' met, unverified'], ['By', g.draft.by], ['Rounds', String(g.rounds || 0)]].filter((x) => x[1]),
|
|
177
213
|
opts: [], sel: null, nodef: 'The goal card is in the conversation beside this. Write there to answer Claude or to go on.',
|
|
178
|
-
pane: { label: 'Goal', file: 'goal-runs.jsonl', h: clip(g.draft.goal, 90), intro: why, rows:
|
|
214
|
+
pane: { label: 'Goal', file: 'goal-runs.jsonl', h: clip(g.draft.goal, 90), intro: why, rows: (g.draft.done || []).map((x) => [(g.skipped || []).includes(x) ? 'Skipped' : (g.met || []).includes(x) ? 'Met' : 'Open', x]), paras: [] },
|
|
179
215
|
},
|
|
180
216
|
});
|
|
181
217
|
}
|
|
@@ -215,30 +251,58 @@ function begin({ runtimeDir, key, text, now = new Date() }) {
|
|
|
215
251
|
if (!t) return { error: 'Write the goal after /goal, for example: /goal Ship the Board metrics card.' };
|
|
216
252
|
if (t.length > MAX_TEXT) return { error: 'The goal is too long (' + MAX_TEXT + ' characters at most).' };
|
|
217
253
|
const id = 'goal-' + crypto.randomBytes(6).toString('hex');
|
|
254
|
+
// one goal runs in a chat at a time: the panel asks first (In a new chat, or Here instead); a /goal that lands here replaces the working one
|
|
255
|
+
const cur = goalOf(runtimeDir, key);
|
|
256
|
+
if (cur && (cur.state === 'started' || cur.state === 'waiting')) append(runtimeDir, { event: 'stopped', reason: 'replaced', id: cur.id, key, at: now.toISOString() });
|
|
218
257
|
append(runtimeDir, { event: 'grilling', id, key, text: t, at: now.toISOString() });
|
|
219
258
|
return { id, prompt: grillPrompt(t) };
|
|
220
259
|
}
|
|
221
260
|
|
|
222
261
|
const fail = (status, error) => ({ status, body: { ok: false, error } });
|
|
223
|
-
/** The PM's Start or Cancel on the
|
|
224
|
-
|
|
262
|
+
/** The PM's presses on the goal: Start or Cancel on the plan card, Stop, the plan edited in place (plan), a done point skipped or kept
|
|
263
|
+
* (skip, unskip), and a working goal replaced by a new /goal here (replace). sessions: { alive(id), type(id, text), keys?(id, k) };
|
|
264
|
+
* session: the key's chat session id. */
|
|
265
|
+
const ACTS = ['start', 'cancel', 'stop', 'plan', 'skip', 'unskip', 'replace'];
|
|
266
|
+
function decide({ runtimeDir, key, id, act, draft, point, session, sessions, now = new Date() }) {
|
|
225
267
|
if (!runtimeDir) return fail(409, 'this workspace has no state folder to keep the goal in');
|
|
226
|
-
if (!
|
|
268
|
+
if (!ACTS.includes(act)) return fail(400, 'act must be one of ' + ACTS.join(', '));
|
|
227
269
|
const g = goalOf(runtimeDir, key);
|
|
228
270
|
if (!g || g.id !== id) return fail(404, 'That goal is not the one this conversation is on.');
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
271
|
+
const at = now.toISOString(), working = g.state === 'started' || g.state === 'waiting';
|
|
272
|
+
const alive = !!(session && sessions && sessions.alive(session));
|
|
273
|
+
if (act === 'stop' || act === 'replace') { // U5: the PM's Stop on a working goal: Esc in the session, and the goal ends
|
|
274
|
+
if (act === 'stop' ? g.state !== 'started' : !working) return fail(409, 'This goal is not working.');
|
|
275
|
+
if (alive && sessions.keys) sessions.keys(session, '\x1b');
|
|
276
|
+
append(runtimeDir, { event: 'stopped', reason: act === 'stop' ? 'pm' : 'replaced', id, key, at });
|
|
233
277
|
return { status: 200, body: { ok: true, id, state: 'stopped' } };
|
|
234
278
|
}
|
|
279
|
+
if (act === 'skip' || act === 'unskip') {
|
|
280
|
+
if (!working) return fail(409, 'Only a working goal has points to skip.');
|
|
281
|
+
const p = clip(point, 200), all = (g.draft && g.draft.done) || [], skipped = g.skipped || [];
|
|
282
|
+
if (!all.includes(p)) return fail(400, 'That point is not in this goal.');
|
|
283
|
+
if (act === 'skip' && (skipped.includes(p) || (g.met || []).includes(p))) return fail(409, 'That point is already ' + (skipped.includes(p) ? 'skipped.' : 'met.'));
|
|
284
|
+
if (act === 'skip' && requiredOf(g).length <= 1) return fail(409, 'A goal keeps at least one done point. Stop it instead.');
|
|
285
|
+
if (act === 'unskip' && !skipped.includes(p)) return fail(409, 'That point is not skipped.');
|
|
286
|
+
if (act === 'unskip' && Date.parse((g.skipAt || {})[p] || '') <= Date.parse(g.roundAt || '')) return fail(409, 'Claude has already dropped that point. Tell Claude to pick it up again.');
|
|
287
|
+
// a queued instruction: typed while Claude works, so Claude reads it after its current step
|
|
288
|
+
if (!alive || !sessions.type(session, act === 'skip' ? skipMessage(p) : unskipMessage(p))) return fail(409, 'The message did not reach the session. Open it in Sessions.');
|
|
289
|
+
append(runtimeDir, { event: act, point: p, id, key, at });
|
|
290
|
+
return { status: 200, body: { ok: true, id, state: g.state } };
|
|
291
|
+
}
|
|
292
|
+
if (act === 'plan') { // the plan edited in place: before Start it is the newest plan; while it works it applies after the current step
|
|
293
|
+
if (g.state !== 'grilling' && !working) return fail(409, 'This goal has ended. Send /goal to set a new one.');
|
|
294
|
+
const d = cleanDraft(draft); if (!d) return fail(400, 'The plan needs a sentence and at least one done point.');
|
|
295
|
+
if (!alive || !sessions.type(session, planMessage(d, working))) return fail(409, 'The message did not reach the session. Open it in Sessions.');
|
|
296
|
+
append(runtimeDir, { event: working ? 'edited' : 'planned', id, key, draft: d, at });
|
|
297
|
+
return { status: 200, body: { ok: true, id, state: g.state } };
|
|
298
|
+
}
|
|
235
299
|
if (g.state !== 'grilling') return fail(409, g.state === 'cancelled' ? 'This goal was cancelled.' : 'This goal has already started.');
|
|
236
|
-
if (!
|
|
300
|
+
if (!alive) return fail(409, 'No session is running for this conversation. Send /goal again to start one.');
|
|
237
301
|
let d = null;
|
|
238
302
|
if (act === 'start') { d = cleanDraft(draft); if (!d) return fail(400, 'The goal needs a sentence and at least one done point before it can start.'); }
|
|
239
303
|
if (!sessions.type(session, act === 'start' ? startMessage(d) : cancelMessage())) return fail(409, 'The message did not reach the session. Open it in Sessions.');
|
|
240
|
-
append(runtimeDir, { event: act === 'start' ? 'started' : 'cancelled', id, key, ...(d ? { draft: d } : {}), at
|
|
304
|
+
append(runtimeDir, { event: act === 'start' ? 'started' : 'cancelled', id, key, ...(d ? { draft: d } : {}), at });
|
|
241
305
|
return { status: 200, body: { ok: true, id, state: act === 'start' ? 'started' : 'cancelled' } };
|
|
242
306
|
}
|
|
243
307
|
|
|
244
|
-
module.exports = { parseCommand, grillPrompt, startMessage, cancelMessage, cleanDraft, goalOf, statesAt, begin, decide, onStop, resume, briefingRows, goalRowsAt, withGoalRows, blockOf, keyOfSession, hookSettings, askToolReply, ASK_TOOL, MARK, RUNS, LIMIT, NO_PROGRESS, REASON };
|
|
308
|
+
module.exports = { parseCommand, grillPrompt, methodMessage, planMessage, skipMessage, unskipMessage, METHODS, startMessage, cancelMessage, cleanDraft, goalOf, statesAt, begin, decide, onStop, resume, briefingRows, goalRowsAt, withGoalRows, blockOf, keyOfSession, hookSettings, askToolReply, ASK_TOOL, MARK, RUNS, LIMIT, NO_PROGRESS, REASON };
|
|
@@ -82,14 +82,15 @@ function bulkTarget({ target, ids, state } = {}) {
|
|
|
82
82
|
|
|
83
83
|
function mintFromPress(root, { scope, target, ids, state, instruction, initiative } = {}, { actor: who } = {}) {
|
|
84
84
|
if (!PRESS_SCOPES.includes(scope)) return { ok: false, status: 400, error: 'a press cannot mint a grant of scope ' + JSON.stringify(scope) };
|
|
85
|
-
|
|
85
|
+
// D98: an agent session mints one too; the grant's `pm` field names the agent, so the ledger says who pressed.
|
|
86
|
+
if (!actor.isPm(who) && !actor.isAgent(who)) return { ok: false, status: 403, error: 'only the PM or an agent session mints a grant' };
|
|
86
87
|
if (scope === 'lifecycle-bulk') target = bulkTarget({ target, ids, state }) ?? target;
|
|
87
88
|
if (typeof target !== 'string' || !target.trim()) return { ok: false, status: 400, error: 'a ' + scope + ' grant names its target' };
|
|
88
89
|
const repo = planTree.mainTree(path.resolve(String(root)));
|
|
89
90
|
const w = writerOf(repo);
|
|
90
91
|
if (!w) return { ok: false, status: 500, error: 'this repository has no grants writer (scripts/record-grant.js or pmos/scripts/pmos-log.sh)' };
|
|
91
92
|
const words = typeof instruction === 'string' && instruction.trim() ? instruction.trim() : 'the PM pressed ' + scope + ' in the workspace';
|
|
92
|
-
const argv = [...w.argv, 'grant', scope + ':' + target, who.by.slice('pm:'.length), words, TTL_MINUTES];
|
|
93
|
+
const argv = [...w.argv, 'grant', scope + ':' + target, actor.isPm(who) ? who.by.slice('pm:'.length) : who.by, words, TTL_MINUTES];
|
|
93
94
|
if (typeof initiative === 'string' && initiative) argv.push(initiative);
|
|
94
95
|
const env = { PATH: process.env.PATH || '/usr/bin:/bin', HOME: process.env.HOME || repo, LANG: 'C.UTF-8' };
|
|
95
96
|
const r = spawnSync(argv[0], argv.slice(1), { cwd: repo, env, encoding: 'utf8', timeout: 20000, shell: false });
|
|
@@ -6,19 +6,19 @@
|
|
|
6
6
|
* pmos initiative new --from capture-YYYY-MM-DD-<n> [--anchor …] [--lane …] [--title "…"]
|
|
7
7
|
* pmos initiative now <id> PM only: type the id to confirm
|
|
8
8
|
* pmos initiative next|later <id> [--top] to the end of that horizon, or its top
|
|
9
|
-
* pmos initiative top|up|down <id> reorder inside its horizon
|
|
9
|
+
* pmos initiative top|up|down <id> reorder inside its horizon
|
|
10
10
|
* pmos initiative check-by <id> <YYYY-MM-DD|none>
|
|
11
|
-
* pmos initiative adopt <proposal-eid> PM
|
|
11
|
+
* pmos initiative adopt <proposal-eid> the PM types the eid to confirm; an agent passes (D98)
|
|
12
12
|
* pmos initiative drop <proposal-eid>
|
|
13
13
|
* pmos initiative list
|
|
14
14
|
* pmos initiative export <id> the breakdown as markdown on stdout; nothing is written
|
|
15
15
|
* every command: [--json] [--root <dir>]
|
|
16
16
|
*
|
|
17
17
|
* The SAME writers the workspace page uses (lib/initiative-writer.js, lib/placements.js) — no server is needed. Who
|
|
18
|
-
* wrote a line comes from the call path, never from an argument:
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* PMOS_SESSION, `agent:unknown` otherwise. An agent's placement
|
|
18
|
+
* wrote a line comes from the call path, never from an argument: Move to Now, adopt, and any line into Now go through
|
|
19
|
+
* lib/pm-guard.js requirePmCli — the PM types the confirmation at a terminal, and an agent session passes with its own
|
|
20
|
+
* actor (D98); every other command takes lib/actor.js fromCli: the PM at a terminal, the bound agent session from
|
|
21
|
+
* PMOS_SESSION, `agent:unknown` otherwise. An agent's placement applies at once and its line names the agent (D98).
|
|
22
22
|
* Work lanes only (D86 point 4): `list` and `export` leave document-lane initiatives out.
|
|
23
23
|
* Exit codes: 0 done, 1 refused, 2 usage.
|
|
24
24
|
*/
|
|
@@ -43,12 +43,12 @@ const USAGE = [
|
|
|
43
43
|
' pmos initiative next|later <id> [--top] move it to the end of Next or Later, or to its top',
|
|
44
44
|
' pmos initiative top|up|down <id> reorder it inside its horizon',
|
|
45
45
|
' pmos initiative check-by <id> <YYYY-MM-DD|none>',
|
|
46
|
-
' pmos initiative adopt <proposal> keep an
|
|
47
|
-
' pmos initiative drop <proposal> close an
|
|
46
|
+
' pmos initiative adopt <proposal> keep an open proposal (you type the proposal to confirm)',
|
|
47
|
+
' pmos initiative drop <proposal> close an open proposal',
|
|
48
48
|
' pmos initiative list Now, Next and Later, in order',
|
|
49
49
|
' pmos initiative export <id> the breakdown as markdown on stdout',
|
|
50
50
|
' every command: [--json] [--root <dir>]',
|
|
51
|
-
'An agent session
|
|
51
|
+
'An agent session\'s placement applies at once and names the agent. A new initiative lands in Later.',
|
|
52
52
|
];
|
|
53
53
|
const BOOL = new Set(['json', 'top', 'help']);
|
|
54
54
|
const VALUE = new Set(['lane', 'anchor', 'intent', 'id', 'from', 'title', 'root']);
|
package/workspace/lib/issues.js
CHANGED
|
@@ -99,7 +99,8 @@ function readIssues(root) {
|
|
|
99
99
|
}
|
|
100
100
|
const why = lineErr(rec);
|
|
101
101
|
if (why) { out.flags.push({ kind: 'invalid', eid: rec.eid || null, why: `line ${n}: ${why}` }); continue; }
|
|
102
|
-
|
|
102
|
+
// D98: the PM or an agent session issues a report; the line keeps who issued it.
|
|
103
|
+
if (!actorLib.valid({ by: rec.by, via: rec.via })) { out.flags.push({ kind: 'not-pm', eid: rec.eid, why: `line ${n}: ${rec.by} issued ${rec.cadence} ${rec.slot}, but the line names no PM or agent session, so it has no effect` }); continue; }
|
|
103
104
|
const key = `${rec.cadence}\u0000${rec.slot}`;
|
|
104
105
|
if (seen.has(key)) { out.flags.push({ kind: 'duplicate-slot', eid: rec.eid, why: `line ${n}: ${rec.cadence} ${rec.slot} was issued on line ${seen.get(key)}; the later line has no effect` }); continue; }
|
|
105
106
|
seen.set(key, n);
|
|
@@ -133,12 +134,12 @@ function randomChars(n) {
|
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
/**
|
|
136
|
-
* One `issued` line per event. The actor is the caller's guard result (pm-guard.js), never a field;
|
|
137
|
-
* issues, and the call path must match the actor (`ui` from the page, `cli` from a terminal). Each event names a file
|
|
137
|
+
* One `issued` line per event. The actor is the caller's guard result (pm-guard.js), never a field; the PM or an agent
|
|
138
|
+
* session issues (D98), and the call path must match the actor (`ui` from the page, `cli` from a terminal). Each event names a file
|
|
138
139
|
* that exists in `root` with exactly the sha sent, so a line can never freeze bytes nobody read.
|
|
139
140
|
*/
|
|
140
141
|
function append(root, events, actor, via, { now } = {}) {
|
|
141
|
-
if (!actorLib.
|
|
142
|
+
if (!actorLib.valid(actor) || actor.via !== via) return refuse(403, `a report is issued by the PM or an agent session, from the ${via === 'ui' ? 'page' : 'terminal'}; nothing was written`, null);
|
|
142
143
|
if (!Array.isArray(events) || !events.length) return refuse(400, 'send at least one line', null);
|
|
143
144
|
if (events.length > MAX_LINES) return refuse(413, `send at most ${MAX_LINES} lines at once`, null);
|
|
144
145
|
let read;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/* mention-cli.js — `pmos mention …`: Home's Mentions from a terminal (canvas XmsDeskRefine, agreed A+).
|
|
3
|
+
* pmos mention list [--json] what waits on you, oldest first, then the last 7 days
|
|
4
|
+
* pmos mention draft <id> --text "<reply>" | --file <path|-> [--json] change the proposed reply the Mentions Viewer shows
|
|
5
|
+
* Claude runs `draft` from the chat where the PM changes a reply ("Reply to Arif"): the Viewer shows the new reply on its next read.
|
|
6
|
+
* The mark is one line in <runtime>/mentions/marks.jsonl with by: agent. This command posts nothing: the PM sends the reply where the
|
|
7
|
+
* mention is. */
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
const stateRoot = require('./state-root');
|
|
11
|
+
const store = require('./mention-store.js');
|
|
12
|
+
|
|
13
|
+
const COMMANDS = { mention: ['list', 'draft'] };
|
|
14
|
+
const USAGE = [
|
|
15
|
+
'usage: pmos mention list|draft — Home\'s Mentions',
|
|
16
|
+
' pmos mention list what waits on you, oldest first, then the last 7 days',
|
|
17
|
+
' pmos mention draft <id> --text "<reply>" change the proposed reply of one mention (or --file <path|->)',
|
|
18
|
+
' every command: [--json]',
|
|
19
|
+
'This command never posts. You send the reply where the mention is.',
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
function parseArgs(argv) {
|
|
23
|
+
const out = { _: [] };
|
|
24
|
+
for (let i = 0; i < argv.length; i++) {
|
|
25
|
+
const t = argv[i];
|
|
26
|
+
if (!t.startsWith('--')) { out._.push(t); continue; }
|
|
27
|
+
const key = t.slice(2);
|
|
28
|
+
if (key === 'json' || key === 'help') out[key] = true;
|
|
29
|
+
else if (argv[i + 1] !== undefined) out[key] = argv[++i];
|
|
30
|
+
else out[key] = '';
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function run(argv, { say = console.log, env = process.env, stateDir, cwd = process.cwd(), now = () => new Date(), stdin } = {}) {
|
|
36
|
+
const a = parseArgs(argv.slice(1));
|
|
37
|
+
const sub = a._[0];
|
|
38
|
+
const out = (o, line) => { if (a.json) say(JSON.stringify(o)); else say(line); };
|
|
39
|
+
if (!sub || a.help || sub === 'help') { USAGE.forEach((l) => say(l)); return sub || a.help ? 0 : 2; }
|
|
40
|
+
if (!COMMANDS.mention.includes(sub)) { say(`✗ pmos mention ${sub} is not a command`); USAGE.forEach((l) => say(l)); return 2; }
|
|
41
|
+
const dir = stateDir || stateRoot.defaultRoot({ env });
|
|
42
|
+
|
|
43
|
+
if (sub === 'list') {
|
|
44
|
+
const v = require('./routes-mentions.js').answer(dir, { now: now().getTime(), cwd });
|
|
45
|
+
if (a.json) { say(JSON.stringify(v)); return 0; }
|
|
46
|
+
if (!v.waiting.length && !v.recent.length) { say('Nobody mentioned you in the last 7 days.'); return 0; }
|
|
47
|
+
say(v.waiting.length ? `${v.waiting.length} wait on your reply` : 'Nothing waits on you');
|
|
48
|
+
for (const m of v.waiting) say(` ${m.id} ${m.who || m.source} · ${m.where || m.source} · since ${m.since || '?'}${m.count > 1 ? ' · ' + m.count + ' asks' : ''}: ${m.text}`);
|
|
49
|
+
if (v.recent.length) say('Last 7 days');
|
|
50
|
+
for (const m of v.recent) say(` ${m.id} ${m.who || m.source} · ${m.where || m.source}${m.status ? ' · ' + m.status : ''}: ${m.text}`);
|
|
51
|
+
return 0;
|
|
52
|
+
}
|
|
53
|
+
// draft
|
|
54
|
+
const id = a._[1];
|
|
55
|
+
if (!id || !/^[0-9a-f]{12}$/.test(id)) { out({ ok: false, error: 'the mention id is 12 hex characters (pmos mention list shows it)' }, '✗ the mention id is 12 hex characters (pmos mention list shows it)'); return 2; }
|
|
56
|
+
let text = a.text;
|
|
57
|
+
if (text === undefined && a.file !== undefined) {
|
|
58
|
+
try { text = a.file === '-' ? (stdin !== undefined ? stdin : fs.readFileSync(0, 'utf8')) : fs.readFileSync(path.resolve(cwd, a.file), 'utf8'); }
|
|
59
|
+
catch (e) { out({ ok: false, error: `could not read ${a.file}: ${e.message}` }, `✗ could not read ${a.file}`); return 1; }
|
|
60
|
+
}
|
|
61
|
+
if (typeof text !== 'string' || !text.trim()) { out({ ok: false, error: '--text "<reply>" or --file <path|-> is required' }, '✗ --text "<reply>" or --file <path|-> is required'); return 2; }
|
|
62
|
+
const known = JSON.parse(JSON.stringify(require('./routes-mentions.js').answer(dir, { now: now().getTime(), cwd })));
|
|
63
|
+
if (![...known.waiting, ...known.recent].some((m) => m.id === id)) { out({ ok: false, error: `no mention ${id}` }, `✗ no mention ${id}. pmos mention list shows them.`); return 1; }
|
|
64
|
+
const r = store.mark(dir, { id, act: 'draft', text }, now(), 'agent');
|
|
65
|
+
if (!r.ok) { out(r, `✗ refused: ${r.error}`); return 1; }
|
|
66
|
+
out({ ok: true, id }, `saved the proposed reply of ${id}. The Mentions Viewer shows it; you send it where the mention is.`);
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
module.exports = { run, COMMANDS, USAGE };
|