create-pmos 0.547.0 → 0.548.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 +14 -32
- package/payload/KIT-VERSION +2 -2
- 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/payload/state/log.md +1 -1
- package/workspace/changelog.json +13 -0
- package/workspace/guide/home.md +9 -4
- package/workspace/lib/artefacts.js +12 -0
- package/workspace/lib/autonomy.js +27 -7
- package/workspace/lib/driver-decide.js +6 -1
- package/workspace/lib/routes-artefacts.js +18 -1
- package/workspace/lib/routes-autonomy.js +56 -8
- package/workspace/lib/routes-proposals.js +1 -1
- package/workspace/package-lock.json +2 -2
- package/workspace/package.json +1 -1
- package/workspace/public/pm/cozy-today.css +7 -0
- package/workspace/public/pm/good-morning.js +72 -14
- package/workspace/public/pm/home-app.js +4 -3
- package/workspace/public/pm/home-day.js +11 -6
- package/workspace/public/pm/ini-agent.js +164 -0
- package/workspace/public/pm/ini-view.css +32 -3
- package/workspace/public/pm/ini-view.js +25 -2
- package/workspace/public/pm/move-rank.js +6 -3
- package/workspace/stage-card-tasks-test.js +3 -0
- package/workspace/test-lists/agent-run-workspace.json +9 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.548.0",
|
|
4
4
|
"description": "Scaffold the PMOS portable kit — run the PMOS product-management workflow (initiative → lane-fit spec → contract → build → three gates, with work-type lanes for features, research, maintenance, incidents, and content) entirely inside your own repo, with all state as git-versioned files. Includes `workflow-sweep`, which audits the state every board derives from and separates real defects from work you simply have not done. `create-pmos workspace` also installs + launches the local Terminal Workspace GUI. No database, no network, no telemetry.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -32,6 +32,19 @@
|
|
|
32
32
|
"audit"
|
|
33
33
|
],
|
|
34
34
|
"pmosChanges": [
|
|
35
|
+
{
|
|
36
|
+
"v": "0.548.0",
|
|
37
|
+
"at": "2026-11-10T02:35:02.323Z",
|
|
38
|
+
"f": 4,
|
|
39
|
+
"prs": [
|
|
40
|
+
{
|
|
41
|
+
"n": 1276,
|
|
42
|
+
"t": "Agent-run Your day and initiative Viewer",
|
|
43
|
+
"s": "Agent-run Your day and initiative Viewer",
|
|
44
|
+
"k": "new"
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
},
|
|
35
48
|
{
|
|
36
49
|
"v": "0.547.0",
|
|
37
50
|
"at": "2026-11-09T23:58:24.564Z",
|
|
@@ -362,37 +375,6 @@
|
|
|
362
375
|
"k": "new"
|
|
363
376
|
}
|
|
364
377
|
]
|
|
365
|
-
},
|
|
366
|
-
{
|
|
367
|
-
"v": "0.528.0",
|
|
368
|
-
"at": "2026-11-04T12:00:44.809Z",
|
|
369
|
-
"f": 4,
|
|
370
|
-
"prs": [
|
|
371
|
-
{
|
|
372
|
-
"n": 1229,
|
|
373
|
-
"t": "Dates carry their year, and plain words across the workspace (workspace grill W4)",
|
|
374
|
-
"s": "Dates carry their year, and plain words across the workspace (workspace grill W4)",
|
|
375
|
-
"k": "fix"
|
|
376
|
-
},
|
|
377
|
-
{
|
|
378
|
-
"n": 1241,
|
|
379
|
-
"t": "Good morning on live data — a stale source said once, a quiet quarter, goal tags, say-it-once folds",
|
|
380
|
-
"s": "Good morning on live data — a stale source said once, a quiet quarter, goal tags, say-it-once folds",
|
|
381
|
-
"k": "fix"
|
|
382
|
-
},
|
|
383
|
-
{
|
|
384
|
-
"n": 1239,
|
|
385
|
-
"t": "The Lab's background record leaves out a chat's own runs",
|
|
386
|
-
"s": "The Lab's background record leaves out a chat's own runs",
|
|
387
|
-
"k": "fix"
|
|
388
|
-
},
|
|
389
|
-
{
|
|
390
|
-
"n": 1242,
|
|
391
|
-
"t": "Report reader no longer flickers while a draft is written",
|
|
392
|
-
"s": "Report reader no longer flickers while a draft is written",
|
|
393
|
-
"k": "fix"
|
|
394
|
-
}
|
|
395
|
-
]
|
|
396
378
|
}
|
|
397
379
|
]
|
|
398
380
|
}
|
package/payload/KIT-VERSION
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
kernel-source: pmos@
|
|
2
|
-
assembled: 2026-11-
|
|
1
|
+
kernel-source: pmos@fabcb8e9
|
|
2
|
+
assembled: 2026-11-10
|
|
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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-10T02:34: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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-10T02:34: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-
|
|
5
|
+
generated: {by: process:create-pmos, at: "2026-11-10T02:34:59Z"}
|
|
6
6
|
status: stable
|
|
7
7
|
---
|
|
8
8
|
|
package/payload/state/log.md
CHANGED
package/workspace/changelog.json
CHANGED
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "0.548.0",
|
|
4
|
+
"at": "2026-11-10T02:35:02.323Z",
|
|
5
|
+
"f": 4,
|
|
6
|
+
"prs": [
|
|
7
|
+
{
|
|
8
|
+
"n": 1276,
|
|
9
|
+
"t": "Agent-run Your day and initiative Viewer",
|
|
10
|
+
"s": "Agent-run Your day and initiative Viewer",
|
|
11
|
+
"k": "new"
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
},
|
|
2
15
|
{
|
|
3
16
|
"v": "0.547.0",
|
|
4
17
|
"at": "2026-11-09T23:58:24.564Z",
|
package/workspace/guide/home.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
type: Guide
|
|
3
3
|
title: "Home: your list, the chat, the Viewer, My work, documents and people"
|
|
4
4
|
description: "Home's list, Mentions, Your day, the chat and the Viewer; My work; documents and their copies; People; and the suggested next prompt."
|
|
5
|
-
timestamp: 2026-11-
|
|
5
|
+
timestamp: 2026-11-10
|
|
6
6
|
---
|
|
7
7
|
|
|
8
8
|
# Home
|
|
@@ -17,11 +17,14 @@ Home, the Board, Insights and the Viewer use one typeface, Plus Jakarta Sans, wi
|
|
|
17
17
|
- Press **Good morning** to open **Your day** in the Viewer. This is the same on a computer and on a phone. To open the calendar, press the calendar icon in Your day's header. A program's milestone changes that wait on you are the first line of the program's card.
|
|
18
18
|
- Your day is the **Good morning** page. It shows the date and greeting, then the quarter, then two columns. On a computer it opens wide.
|
|
19
19
|
- **The quarter.** One bar with all goals of the products Home reads: reached, on track, still reading, at risk and will miss, each with its count. A black tick marks your line, for example "line 18". One sentence says how many goals are on track or better, and one line says why. When no goal has a reading yet, the sentence says that instead, for example "3 goals, none read yet." **By product** opens Intelligence. With no goals, there is no bar. With no line, there is no tick, and Claude can propose a line with ✦: press ✓ to keep it, or ✕ to not set one this quarter. A product that could not be read is named and is not counted.
|
|
20
|
-
- **The left column.** Claude's lead,
|
|
20
|
+
- **The left column.** Claude's lead says it straight, for example "Straight answer: 5 calls are yours. I did the other 54." When a source such as Jira cannot be read, one quiet line under the lead says so and what it shows instead, with an icon to read it again. The source never takes the lead's place.
|
|
21
|
+
- **Your move** shows only the calls that always wait for you: a verdict, a new request or a decision, a message to people, a move the team reads, a merge, and a delete or spend. Each row starts with its kind and says why, for example "Message · I drafted it. It goes to people and cannot be unsent." It also shows its due day (orange when late) and the goal it moves when a goal reads it. At most 5 show. **N more calls of yours** opens the rest. Claude acts on everything else by itself, so there is no Can wait.
|
|
22
|
+
- **Claude did** lists what Claude finished by itself, newest first. Each row has a one-line reason, for example "Did it quietly. You kept this kind 4 times before.", and Undo. Undo works for 14 days. After two Undos in a row on one kind, Claude asks first for that kind for 7 days. A run that stopped is one amber line at the top, never a row in Your move. **N more Claude did** opens the rest.
|
|
23
|
+
- **Since yesterday**: up to 3 new items, then **New for you · N** to see all of them. ✓✓ marks all of them seen.
|
|
21
24
|
- **The right column.** Today's agenda, not to scale: a line at the time now, each meeting with its prep note, ✦ picks in free time, and "3 h free" for a long free stretch. The meeting where your call is decided has an orange edge. Under it, **Notes since yesterday**: meeting notes with their main lines, and recordings with no initiative. When Claude finds the initiative a recording belongs to, press the link icon to link it.
|
|
22
25
|
- **In the hour before a meeting**, the meeting's prep leads: what to agree, the points, and the record icon. The quarter shows only when it moved since the morning. Past meetings fade, with their notes under them.
|
|
23
|
-
- **On a phone or in a narrow Viewer**, the page is one column: the quarter, the lead,
|
|
24
|
-
- Under the page are **Now** (on a phone)
|
|
26
|
+
- **On a phone or in a narrow Viewer**, the page is one column: the quarter, the lead, Your move, Claude did, the agenda, then Since yesterday.
|
|
27
|
+
- Under the page are **Now** (on a phone) and **This week** (the Weekly review and **Mentions**). The rest of your calls, the rest of Claude did and **Drafted for you** open there from their line.
|
|
25
28
|
- **Drafted for you** lists what Claude drafted today and the weekly update. Press a row to open it: a finished draft opens what Claude wrote, and the weekly update opens the update.
|
|
26
29
|
- Your day does not show the meeting on now or the next meeting. Home's meeting line shows them. On a phone, the **Now** card does not show while a meeting is in progress.
|
|
27
30
|
- When a conversation in Mentions waits on your answer, Your day names the oldest one under its first line: who asked, where, how many more wait, and what they asked. Press its icon to open that conversation in Mentions.
|
|
@@ -74,6 +77,8 @@ A reply PMOS sees in the thread clears the ask on the next read. A new ask after
|
|
|
74
77
|
Press an initiative's name in the list, or open `?ini=<id>`. The list stays as it is and the initiative's row is selected. The chat talks about the initiative, and its page opens in the Viewer.
|
|
75
78
|
|
|
76
79
|
- The page's header shows the lane and the anchor, the name, **New session** (+), ⋯, Open wide and Close.
|
|
80
|
+
- **Experiment** shows what Claude keeps for the initiative: **We bet**, **Stop if**, **Budget**, **Who builds**, **Specimens** and **Done when**. A line that nobody wrote does not show. Press a line to change it. After you change a line, Claude asks before it changes that line again. When an experiment is on record, **Gate to Build** shows the done test and the kill condition (D107) instead of the PRD and the rubric.
|
|
81
|
+
- **Claude's work** lists what Claude changed on this initiative by itself, each with its reason, its day and Undo. A run that stopped is one amber line. **Coming up** names the next dated thing, for example a milestone that is due.
|
|
77
82
|
- The stage card shows the stage, **N of M done** for its tasks, the days in the stage (for example "9 of ~7 days", amber when over the usual time) and → for the next stage. → turns blue when every task of the stage is done.
|
|
78
83
|
- Under the header is one line for the whole initiative. Each stage is a part of the line, on its own dates. Done stages are grey, the current stage is blue, later stages are light, and a stage with no dated task is dashed. The ◇ marks are the milestone tasks, with the name above and the date below. The end ◇ is the end date. When the initiative has milestone tasks, the end ◇ stands for one of them (one on the end date, else the latest in the last milestone stage, else the latest of all), sits on that task's own date and shows it. A thin tick is Today.
|
|
79
84
|
- Press a part to show that stage in **Tasks**. Press **N of M done** to do the same. Press a ◇ to open the milestone task in **Tasks**. Milestones a few days apart merge into one ◇ with a count. Press it to list them.
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
* file(dir) · readLines(file) · fold(lines) → Map scope → Map artefact → { fields: { name: value|[values] }, carried: [line] }
|
|
13
13
|
* set(file, { scope, artefact, field, text, sources }, actor, { now }) → { ok, line } | { ok: false, status, error }
|
|
14
14
|
* undo(file, { ref }, actor, { now }) → { ok, line } | refusal a set goes back; carry lines cannot be undone (they point at records)
|
|
15
|
+
* pmEdited(state, { scope, artefact, field }) → bool the newest set of that field is the PM's: Claude asks before it changes it (board AwB)
|
|
15
16
|
* viewOf(state, scope) → { scope, artefacts: [{ key, title, owner, for, fields, carried, empty }] } always all seven that fit the scope
|
|
16
17
|
* migrate({ dir, coreDocs, driverLines, reports }, { now }) → { ok, carried, already, lines } idempotent; deletes nothing
|
|
17
18
|
*
|
|
@@ -226,6 +227,16 @@ function viewOf(state, scope) {
|
|
|
226
227
|
return { scope: p.scope, kind: p.kind, artefacts };
|
|
227
228
|
}
|
|
228
229
|
|
|
230
|
+
/** True when the newest set of this field is the PM's own (the Viewer's "You edit any line. Claude asks before it changes one you edited",
|
|
231
|
+
* agent-run workspace board AwB). The Driver then files Claude's change as a proposal instead of applying it. Pure. */
|
|
232
|
+
function pmEdited(state, { scope, artefact, field } = {}) {
|
|
233
|
+
const p = parseScope(scope);
|
|
234
|
+
const x = p && state && state.get(p.scope) && state.get(p.scope).get(artefact);
|
|
235
|
+
if (!x) return false;
|
|
236
|
+
const sets = x.sets.filter((l) => l.field === field);
|
|
237
|
+
return !!sets.length && /^pm:/.test(String(sets[sets.length - 1].by || ''));
|
|
238
|
+
}
|
|
239
|
+
|
|
229
240
|
// ── writes ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
230
241
|
const refuse = (status, error) => ({ ok: false, status, error });
|
|
231
242
|
const oneLine = (v, max) => typeof v === 'string' && v.trim().length >= 1 && v.trim().length <= max && !/[\r\n\x00-\x08\x0b-\x1f]/.test(v);
|
|
@@ -363,6 +374,7 @@ function migrateRepo(root, { now } = {}) {
|
|
|
363
374
|
}
|
|
364
375
|
|
|
365
376
|
module.exports = {
|
|
377
|
+
pmEdited,
|
|
366
378
|
LEDGER, EVENTS, ARTEFACTS, KEYS, EXECUTORS, FROM_DOCS, FROM_WHATS, FROM_CADENCES, FROM_LANES,
|
|
367
379
|
parseScope, targetOfDoc, targetOfWhat, fieldOf, file, readLines, append, fold, viewOf, checkSet, set, undo,
|
|
368
380
|
planMigration, migrate, migrateRepo, reportDrafts, dirOf, proposalText,
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
* A change with no Undo writer is never applied by itself, whatever its class ("no Undo, no auto"): it waits like C.
|
|
11
11
|
*
|
|
12
12
|
* THE LEDGER: <state folder>/autonomy.jsonl, append-only, THIS FILE IS ITS ONE WRITER. One line per event { v: 1, at, ev, ... }:
|
|
13
|
-
* applied { job, product, ref, title, cls }
|
|
13
|
+
* applied { job, product, ref, title, cls, ini?, why? } an agent applied a change by itself (ref: the proposal id or the ✦ batch;
|
|
14
|
+
* ini: the initiative it changed; why: the evidence it acted on, one line)
|
|
14
15
|
* setback { job, product, ref?, kind } kind: undo (the PM pressed Undo) · revert (a revert of the change) ·
|
|
15
16
|
* verifier-fail (the T4 verifier failed it; counts like an Undo)
|
|
16
17
|
* demote { job, product, until, why } the job falls back to propose for this product until `until`
|
|
@@ -33,7 +34,9 @@
|
|
|
33
34
|
* killed({ env, settingsDir }) → null | reason PMOS_AUTONOMY=off or `pmos ai off` stops every auto apply
|
|
34
35
|
* demotedNow(state, job, product, now) → null | { until, why }
|
|
35
36
|
* notices(stateDir, { now }) → [{ job, product, until, why }] demotions Home has not said yet; markSeen(stateDir, n, { now })
|
|
36
|
-
* done(stateDir, { now, days }) → [applied line, newest first] the applied changes of the last 14 days that are not undone
|
|
37
|
+
* done(stateDir, { now, days }) → [applied line, newest first] the applied changes of the last 14 days that are not undone, each with
|
|
38
|
+
* `kept` (earlier changes of its job and product nobody undid) and `reason` (reasonOf)
|
|
39
|
+
* reasonOf({ cls, why, kept }) → one line: how Claude did it and why ("Did it quietly. You kept this kind 4 times before.")
|
|
37
40
|
* restore(stateDir, { job, product }, actor, { now })
|
|
38
41
|
*/
|
|
39
42
|
const fs = require('fs');
|
|
@@ -112,7 +115,7 @@ function fold(lines) {
|
|
|
112
115
|
if (!isObj(l) || typeof l.job !== 'string') continue;
|
|
113
116
|
const j = get(l.job, l.product);
|
|
114
117
|
if (l.ev === 'applied') {
|
|
115
|
-
const a = { ref: l.ref || null, title: l.title || '', cls: l.cls || null, job: l.job, product: l.product || null, at: l.at, undone: false, undoneAt: null };
|
|
118
|
+
const a = { ref: l.ref || null, title: l.title || '', cls: l.cls || null, job: l.job, product: l.product || null, ini: l.ini || null, why: l.why || '', at: l.at, undone: false, undoneAt: null };
|
|
116
119
|
j.applied.push(a);
|
|
117
120
|
if (a.ref) applied.set(a.ref, a);
|
|
118
121
|
} else if (l.ev === 'setback') {
|
|
@@ -148,9 +151,10 @@ function trip(j, now) {
|
|
|
148
151
|
return null;
|
|
149
152
|
}
|
|
150
153
|
|
|
151
|
-
function recordApplied(stateDir, { job, product, ref, title, cls }, { now } = {}) {
|
|
154
|
+
function recordApplied(stateDir, { job, product, ref, title, cls, ini, why }, { now } = {}) {
|
|
152
155
|
if (!JOB_RE.test(String(job || ''))) return null;
|
|
153
|
-
return append(stateDir, { ev: 'applied', job, product: product || null, ref: ref ? one(ref, 120) : null, title: one(title, 200), cls: CLASSES.includes(cls) ? cls : null
|
|
156
|
+
return append(stateDir, { ev: 'applied', job, product: product || null, ref: ref ? one(ref, 120) : null, title: one(title, 200), cls: CLASSES.includes(cls) ? cls : null,
|
|
157
|
+
...(ini ? { ini: one(ini, 80) } : {}), ...(why ? { why: one(why, 200) } : {}) }, { now });
|
|
154
158
|
}
|
|
155
159
|
|
|
156
160
|
/** THE HOOK for an Undo, a revert or a verifier FAIL. Writes the setback and, when it trips, the demotion. */
|
|
@@ -205,12 +209,28 @@ function notices(stateDir, { now } = {}) {
|
|
|
205
209
|
}
|
|
206
210
|
const markSeen = (stateDir, n, { now } = {}) => append(stateDir, { ev: 'seen', job: n.job, product: n.product || null, until: n.until }, { now });
|
|
207
211
|
|
|
212
|
+
/** The one-line reason a change shows beside its Undo (agent-run workspace, board AwA: "each change says why"). Honest from the ledger:
|
|
213
|
+
* a kind the PM kept before is done quietly and says how often; the first of its kind is done and shown; the evidence follows when the
|
|
214
|
+
* change carries one. Pure. */
|
|
215
|
+
function reasonOf({ cls = null, why = '', kept = 0 } = {}) {
|
|
216
|
+
const how = kept > 0 ? 'Did it quietly. You kept this kind ' + (kept === 1 ? 'once' : kept + ' times') + ' before.'
|
|
217
|
+
: 'Did it and showed you. It is the first of its kind' + (cls === 'A' ? ', and it is upkeep with one right answer.' : '.');
|
|
218
|
+
const w = one(why, 200);
|
|
219
|
+
return w ? how + ' ' + w.replace(/\.?$/, '.') : how;
|
|
220
|
+
}
|
|
221
|
+
|
|
208
222
|
/** The Done group: what agents applied by themselves in the last `days` days and nobody undid, newest first. */
|
|
209
223
|
function done(stateDir, { now, days = UNDO_DAYS } = {}) {
|
|
210
224
|
const t = now == null ? Date.now() : now;
|
|
211
225
|
const since = t - days * DAY;
|
|
212
226
|
const out = [];
|
|
213
|
-
for (const j of fold(read(stateDir)).jobs.values())
|
|
227
|
+
for (const j of fold(read(stateDir)).jobs.values()) {
|
|
228
|
+
let kept = 0;
|
|
229
|
+
for (const a of j.applied) {
|
|
230
|
+
if (!a.undone && Date.parse(a.at) >= since) out.push({ ...a, kept, reason: reasonOf({ cls: a.cls, why: a.why, kept }) });
|
|
231
|
+
if (!a.undone) kept++;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
214
234
|
return out.sort((a, b) => Date.parse(b.at) - Date.parse(a.at));
|
|
215
235
|
}
|
|
216
236
|
|
|
@@ -231,5 +251,5 @@ function restore(stateDir, { job, product }, actor, { now } = {}) {
|
|
|
231
251
|
|
|
232
252
|
module.exports = {
|
|
233
253
|
LEDGER, CLASSES, DRIVER_CLASS, PROPOSAL_CLASS, DEMOTE_DAYS, UNDO_DAYS, RATE_LIMIT, RATE_MIN, KINDS,
|
|
234
|
-
classOfDriver, classOfProposal, killed, autoFor, file, read, fold, recordApplied, recordSetback, decide, demotedNow, notices, markSeen, done, undoOpen, restore,
|
|
254
|
+
classOfDriver, classOfProposal, killed, autoFor, file, read, fold, recordApplied, reasonOf, recordSetback, decide, demotedNow, notices, markSeen, done, undoOpen, restore,
|
|
235
255
|
};
|
|
@@ -137,9 +137,14 @@ async function autoApply({ file, proposal, actor, ctx = {}, now, stateDir, produ
|
|
|
137
137
|
const cls = A.classOfDriver(p.what);
|
|
138
138
|
const d = A.decide({ stateDir, job: jobOf(p), product, cls, mode: m, undoable: UNDOABLE.has(p.what), now, settingsDir: ctx.settingsDir || null });
|
|
139
139
|
if (!d.apply) return { applied: false, why: d.why, cls };
|
|
140
|
+
// board AwB: a line of an artefact the PM edited is the PM's now; Claude's change to it waits as a proposal
|
|
141
|
+
if (p.what === 'artefact' && ctx.root) {
|
|
142
|
+
const AR = require('./artefacts.js');
|
|
143
|
+
try { if (AR.pmEdited(AR.fold(AR.readLines(AR.file(AR.dirOf(ctx.root)))), p.data || {})) return { applied: false, why: 'the PM edited this line, so Claude asks first', cls }; } catch { /* no artefacts yet: nothing edited */ }
|
|
144
|
+
}
|
|
140
145
|
const r = await decide('keep', { file, proposal, actor, ctx, now, auto: true });
|
|
141
146
|
if (!r.ok) return { applied: false, why: r.error, cls };
|
|
142
|
-
A.recordApplied(stateDir, { job: jobOf(p), product, ref: p.id, title: `${p.what}: ${p.why}`, cls }, { now });
|
|
147
|
+
A.recordApplied(stateDir, { job: jobOf(p), product, ref: p.id, title: `${p.what}: ${p.why}`, cls, ini: p.target && p.target.kind === 'initiative' ? p.target.id : null }, { now });
|
|
143
148
|
return { applied: true, why: d.why, cls, wrote: r.wrote };
|
|
144
149
|
} catch (e) { return { applied: false, why: 'the apply failed: ' + String((e && e.message) || e).slice(0, 160) }; }
|
|
145
150
|
}
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
* GET /api/artefacts?ws&scope → { ok, ws, scope, kind, artefacts: [{ key, title, owner, for, labels, fields, carried, empty }] }
|
|
5
5
|
* scope: portfolio (default), board:<id>, goal:<id>, experiment:<id> (initiative:<id> is an alias)
|
|
6
6
|
* GET /api/artefacts/map → { ok, artefacts, rows: [{ from, name, artefact, field, note }] } what every older shape became
|
|
7
|
+
* POST /api/artefacts/set { ws, scope, artefact, field, text } → { ok, line } the PM edits one line from the Viewer (board AwB: "You edit
|
|
8
|
+
* any line"). A page press (pm-guard requirePagePress); the actor is the PM, so Claude asks before it
|
|
9
|
+
* changes that line again (lib/artefacts.js pmEdited, lib/driver-decide.js autoApply).
|
|
7
10
|
*
|
|
8
11
|
* THE MIGRATION. Every read of a repository carries its older records (core documents, kept driver proposals,
|
|
9
12
|
* report drafts) under their artefacts: lib/artefacts.js migrateRepo. It is idempotent and only appends pointers; nothing is deleted or
|
|
@@ -24,8 +27,22 @@ const pageBy = (x) => (x && x.by ? { ...x, by: actorLib.pageName(x.by) } : x);
|
|
|
24
27
|
|
|
25
28
|
async function handle(req, res, url, ctx) {
|
|
26
29
|
const send = (status, body) => { ctx.json(res, body, status); return true; };
|
|
27
|
-
if (req.method !== 'GET') return send(405, { ok: false, error: 'the artefacts are read here; agents write them through the driver' });
|
|
28
30
|
const sub = url.pathname.replace(/^\/api\/artefacts\/?/, '');
|
|
31
|
+
if (sub === 'set' && req.method === 'POST') {
|
|
32
|
+
const read = await ctx.readJson(req);
|
|
33
|
+
if (!read.ok) return send(400, { ok: false, error: 'the body is not JSON' });
|
|
34
|
+
const b = read.body || {};
|
|
35
|
+
const g = require('./pm-guard.js').requirePagePress(req, b);
|
|
36
|
+
if (!g.ok) return send(g.status, { ok: false, error: g.error });
|
|
37
|
+
if (!/^pm:/.test(String((g.actor && g.actor.by) || ''))) return send(403, { ok: false, error: 'the Viewer edits a line for the PM; agents propose through the driver' });
|
|
38
|
+
const w = wsOf(ctx, typeof b.ws === 'string' ? b.ws : '');
|
|
39
|
+
if (!w || !w.root) return send(404, { ok: false, error: 'no such workspace' });
|
|
40
|
+
let dir;
|
|
41
|
+
try { dir = A.dirOf(w.root); } catch (e) { return send(409, { ok: false, error: String((e && e.message) || e) }); }
|
|
42
|
+
const r = A.set(A.file(dir), { scope: b.scope, artefact: b.artefact, field: b.field, text: typeof b.text === 'string' ? b.text : '' }, g.actor);
|
|
43
|
+
return r.ok ? send(200, { ok: true, line: pageBy(r.line) }) : send(r.status, { ok: false, error: r.error });
|
|
44
|
+
}
|
|
45
|
+
if (req.method !== 'GET') return send(405, { ok: false, error: 'the artefacts are read here; the PM edits a line with POST /api/artefacts/set' });
|
|
29
46
|
if (sub === 'map') return send(200, { ok: true, artefacts: A.KEYS, rows: require('./artefacts-cli.js').mapRows() });
|
|
30
47
|
if (sub) return send(404, { ok: false, error: 'no such artefacts route' });
|
|
31
48
|
const q = url.searchParams;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
/* routes-autonomy.js — what agents did by themselves, and its Undo (D106, "Full autonomy now").
|
|
3
3
|
*
|
|
4
|
-
* GET /api/autonomy?ws → { ok, ws, done: [change], notices: [demotion] }
|
|
5
|
-
* change: { ref, job, title, cls, at, undo_until } the changes agents applied by themselves in the last 14 days that
|
|
6
|
-
* newest first: the Done group
|
|
4
|
+
* GET /api/autonomy?ws → { ok, ws, done: [change], notices: [demotion], failed: [run] }
|
|
5
|
+
* change: { ref, job, title, cls, at, undo_until, ini, reason } the changes agents applied by themselves in the last 14 days that
|
|
6
|
+
* nobody undid, newest first: the Done group ("Claude did" on Your day, "Claude's work" in the Viewer; agent-run workspace, boards
|
|
7
|
+
* AwA and AwB). title is said as an act ("Wrote the problem: …"); reason is lib/autonomy.js reasonOf, one line.
|
|
8
|
+
* notices: the jobs that fell back to propose and Home has not said so yet (say it once).
|
|
9
|
+
* failed: the agent runs of the last 7 days that ended with an error and that no later run of the same target answered:
|
|
10
|
+
* { run, ini, at, why, source: 'driver' | 'team' }, newest first. Requirement R4: a failure is never the PM's work; it is one amber
|
|
11
|
+
* line where the work is.
|
|
7
12
|
* POST /api/autonomy/undo { ws, ref } → { ok, back, demoted? } Undo of one change: a Driver proposal (p-…) or a ✦ batch (pk-…)
|
|
8
13
|
* POST /api/autonomy/seen { ws, job, product, until } → { ok } Home said the demotion once
|
|
9
14
|
*
|
|
@@ -59,19 +64,62 @@ async function undoRef(ctx, w, ref, g) {
|
|
|
59
64
|
return bad(400, 'ref is a Driver proposal id (p-…) or a ✦ batch id (pk-…)');
|
|
60
65
|
}
|
|
61
66
|
|
|
67
|
+
/* the Driver's kinds said as an act: "problem: Scarlet tickets lack…" reads "Wrote the problem: Scarlet tickets lack…" */
|
|
68
|
+
const ACT = { problem: 'Wrote the problem', evidence: 'Added evidence', sizing: 'Sized it', assumption: 'Wrote an assumption', stakeholders: 'Named the people',
|
|
69
|
+
move: 'Moved it', note: 'Added a note', doc: 'Drafted a document', overlap: 'Noted an overlap', artefact: 'Wrote the experiment', 'next-step': 'Set the next step', 'follow-up': 'Set a follow-up' };
|
|
70
|
+
function sayOf(a) {
|
|
71
|
+
const m = /^driver:([a-z-]+)$/.exec(String(a.job || ''));
|
|
72
|
+
const t = String(a.title || '').trim();
|
|
73
|
+
if (!m || !ACT[m[1]]) return t;
|
|
74
|
+
const rest = t.startsWith(m[1] + ': ') ? t.slice(m[1].length + 2) : t;
|
|
75
|
+
return rest ? ACT[m[1]] + ': ' + rest : ACT[m[1]];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** The runs that stopped (R4): the Driver's runs (run-end ok false) and the role agents' steps (state failed) of the last `days` days whose
|
|
79
|
+
* target no later run answered. Never throws: an unreadable ledger is no failure to show. */
|
|
80
|
+
function failedOf(w, dirs, { now = Date.now(), days = 7 } = {}) {
|
|
81
|
+
const since = now - days * DAY, out = [];
|
|
82
|
+
try {
|
|
83
|
+
const stateDir = D.stateDirOf(w.root);
|
|
84
|
+
const file = stateDir ? D.ledgerFile(stateDir) : null;
|
|
85
|
+
if (file) {
|
|
86
|
+
const runs = [...D.fold(D.readLines(file)).runs.values()].filter((r) => r.end && r.target);
|
|
87
|
+
const lastOk = new Map();
|
|
88
|
+
for (const r of runs) if (r.ok) { const k = r.target.id; if (!lastOk.has(k) || r.end > lastOk.get(k)) lastOk.set(k, r.end); }
|
|
89
|
+
for (const r of runs) {
|
|
90
|
+
if (r.ok || Date.parse(r.end) < since) continue;
|
|
91
|
+
if (lastOk.has(r.target.id) && lastOk.get(r.target.id) > r.end) continue;
|
|
92
|
+
out.push({ run: r.run, ini: r.target.kind === 'initiative' ? r.target.id : null, at: r.end, why: r.reason || '', source: 'driver' });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} catch { /* no driver ledger */ }
|
|
96
|
+
try {
|
|
97
|
+
const TR = require('./team-runs.js');
|
|
98
|
+
for (const d of dirs) {
|
|
99
|
+
const steps = TR.fold(TR.read(d)).steps;
|
|
100
|
+
for (const s of steps) {
|
|
101
|
+
if (s.state !== 'failed' || Date.parse(s.at) < since) continue;
|
|
102
|
+
if (steps.some((x) => x.state === 'done' && x.ini === s.ini && x.role === s.role && String(x.at) > String(s.at))) continue;
|
|
103
|
+
out.push({ run: s.id, ini: s.ini || null, at: s.at, why: s.why || '', source: 'team' });
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
} catch { /* no team ledger */ }
|
|
107
|
+
return out.sort((a, b) => String(b.at).localeCompare(String(a.at)));
|
|
108
|
+
}
|
|
109
|
+
|
|
62
110
|
async function handle(req, res, url, ctx) {
|
|
63
111
|
const send = (r) => { ctx.json(res, r.body, r.status); return true; };
|
|
64
112
|
const sub = url.pathname.replace(/^\/api\/autonomy\/?/, '');
|
|
65
113
|
if (sub === '' && req.method === 'GET') {
|
|
66
114
|
const w = wsOf(ctx, url.searchParams.get('ws'));
|
|
67
115
|
if (!w) return send(bad(404, 'no such workspace'));
|
|
68
|
-
const done = [], notices = [];
|
|
69
|
-
for (const d of
|
|
70
|
-
for (const a of A.done(d)) done.push({ ref: a.ref, job: a.job, title: a
|
|
116
|
+
const done = [], notices = [], dirs = dirsOf(ctx, w);
|
|
117
|
+
for (const d of dirs) {
|
|
118
|
+
for (const a of A.done(d)) done.push({ ref: a.ref, job: a.job, title: sayOf(a), cls: a.cls, at: a.at, undo_until: new Date(Date.parse(a.at) + A.UNDO_DAYS * DAY).toISOString(), ini: a.ini || null, reason: a.reason });
|
|
71
119
|
for (const n of A.notices(d)) notices.push(n);
|
|
72
120
|
}
|
|
73
121
|
done.sort((a, b) => Date.parse(b.at) - Date.parse(a.at));
|
|
74
|
-
return send({ status: 200, body: { ok: true, ws: w.id, done, notices } });
|
|
122
|
+
return send({ status: 200, body: { ok: true, ws: w.id, done, notices, failed: failedOf(w, dirs) } });
|
|
75
123
|
}
|
|
76
124
|
if (sub !== 'undo' && sub !== 'seen') return send(bad(404, 'no such autonomy route'));
|
|
77
125
|
if (req.method !== 'POST') return send(bad(405, 'POST only'));
|
|
@@ -92,4 +140,4 @@ async function handle(req, res, url, ctx) {
|
|
|
92
140
|
return send({ status: 200, body: { ok: true } });
|
|
93
141
|
}
|
|
94
142
|
|
|
95
|
-
module.exports = { prefixes: ['/api/autonomy'], handle, undoRef };
|
|
143
|
+
module.exports = { prefixes: ['/api/autonomy'], handle, undoRef, failedOf, sayOf };
|
|
@@ -154,7 +154,7 @@ function autoKeep(ctx, w, { modeOf = () => 'auto', now } = {}) {
|
|
|
154
154
|
if (!d.apply) { out.held++; continue; }
|
|
155
155
|
try {
|
|
156
156
|
const r = keepCore(ctx, p, g, f, ini, [x], {}, { auto: true, group: x.group });
|
|
157
|
-
A.recordApplied(dir, { job: `propose:${x.group}`, product: w.id, ref: r.batch, title: x.title || x.why || x.group, cls }, { now });
|
|
157
|
+
A.recordApplied(dir, { job: `propose:${x.group}`, product: w.id, ref: r.batch, title: x.title || x.why || x.group, cls, ini, why: x.title && x.why && x.why !== x.title ? x.why : '' }, { now });
|
|
158
158
|
out.applied.push({ ini, batch: r.batch, group: x.group, title: x.title || x.why || '' });
|
|
159
159
|
} catch { out.held++; }
|
|
160
160
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pmos-workspace",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.548.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pmos-workspace",
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.548.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@anthropic-ai/sdk": "^1.3.0",
|
package/workspace/package.json
CHANGED
|
@@ -652,6 +652,13 @@ body.cz-home .hm-hd.hv-bar > .hv-hi { flex: 1 0 auto; max-width: 100%; }
|
|
|
652
652
|
.gm-more { display: flex; flex-wrap: wrap; gap: 4px 18px; padding-top: 8px; }
|
|
653
653
|
.gm-more button { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; border: 0; background: none; padding: 0; font: inherit; font-size: var(--fs-body); color: var(--cz-ink2); cursor: pointer; }
|
|
654
654
|
.gm-more b { color: var(--cz-ink); font-weight: var(--fw-strong); }
|
|
655
|
+
/* agent-run (AwA, AwAPhone): each call says its kind; Claude did lists each change with its reason and Undo; a run that stopped is one amber line */
|
|
656
|
+
.gm-rt .gm-k2 { color: var(--cz-ink2); font-weight: var(--fw-strong); }
|
|
657
|
+
.gm-didl { margin-top: 18px; }
|
|
658
|
+
.gm-r .gm-undo { flex: none; margin-top: 4px; }
|
|
659
|
+
.gm-fail { display: flex; align-items: flex-start; gap: 8px; margin: 6px 0 2px; padding: 10px 12px; border-radius: 14px; background: var(--cz-latebg); color: var(--cz-late); font-size: var(--fs-label); line-height: 1.45; }
|
|
660
|
+
.gm-fail svg { flex: none; margin-top: 2px; }
|
|
661
|
+
.gm-fail b { font-weight: var(--fw-strong); }
|
|
655
662
|
/* Since yesterday: neutral dots; orange only for a real rise */
|
|
656
663
|
.gm-sl { display: flex; flex-direction: column; }
|
|
657
664
|
.gm-si { display: flex; align-items: baseline; gap: 10px; min-height: 44px; padding: 8px 0; border: 0; border-bottom: 1px solid var(--cz-hair); background: none; text-align: left; font: inherit; font-size: var(--fs-body); color: var(--cz-ink); cursor: pointer; line-height: 1.4; }
|
|
@@ -19,6 +19,13 @@
|
|
|
19
19
|
* morning (zero is silence); past items fade and their notes fold under them. After 17:00 (G3) the strip says how the quarter moved since
|
|
20
20
|
* the morning, "Today made possible" lists what the day moved, "Still yours" what is left, and the rail turns to tomorrow.
|
|
21
21
|
*
|
|
22
|
+
* AGENT-RUN (agreed 2026-11-10, boards AwA and AwAPhone on the main canvas, In development; requirements R1, R2, R4). Your move holds only
|
|
23
|
+
* the calls that always wait for the PM (callKindOf: a verdict, a new request or decision, a message to people, a move the team reads, a
|
|
24
|
+
* merge, a delete or spend), each with its kind and why, in W3's order; at most 5 show and the rest fold under one line. Can wait is gone:
|
|
25
|
+
* Claude acts on the rest. "Claude did" lists what Claude finished by itself (GET /api/autonomy done), each with its one-line reason and
|
|
26
|
+
* Undo (14 days); a run that stopped is one amber line there, never a row of Your move. The lead says it straight: "N calls are yours. I
|
|
27
|
+
* did the other M." Your call is no longer a section of its own: it is a row of Your move (say it once).
|
|
28
|
+
*
|
|
22
29
|
* PROVEN ONLY. The quarter's goal states, the PM's line, the morning's snapshot, a row's goal tag and what Yes does to a goal come from the
|
|
23
30
|
* Good morning goal data (GM1), passed in o.quarter, o.tags and the call's effect. Each part that is missing is left out: no goals, no strip;
|
|
24
31
|
* no line, no tick and the verdict counts only; no morning snapshot, no "up from"; no effect, no goal clause. Nothing is guessed.
|
|
@@ -196,6 +203,26 @@ export function notesOf(rows, now, o = {}) {
|
|
|
196
203
|
});
|
|
197
204
|
}
|
|
198
205
|
|
|
206
|
+
/** The kind of a ranked row that always waits for the PM (the six kinds of requirement R2, as the rows of W3 name them), or null: Claude
|
|
207
|
+
* acts on that row by itself. A call that is not a message is the PM's decision, a blocked one says so. Pure. */
|
|
208
|
+
export function callKindOf(r) {
|
|
209
|
+
if (!r) return null;
|
|
210
|
+
if (r.kind === 'verdict') return 'Verdict';
|
|
211
|
+
if (r.kind === 'mention' || r.kind === 'outbox') return 'Message';
|
|
212
|
+
if (r.kind === 'meeting') return 'Move the team reads';
|
|
213
|
+
if (r.kind !== 'call' || !r.call) return null;
|
|
214
|
+
const c = r.call, t = String(c.name || '') + ' ' + String((c.row && c.row.title) || '');
|
|
215
|
+
if (c.kind === 'update') return 'Message';
|
|
216
|
+
if (/\b(intake|new request|request)\b/i.test(t)) return 'New request';
|
|
217
|
+
if (/\b(merge|pull request)\b/i.test(t)) return 'Merge';
|
|
218
|
+
if (/\b(delete|spend|budget)\b/i.test(t)) return 'Delete or spend';
|
|
219
|
+
if (c.state === 'blocked') return 'Blocked';
|
|
220
|
+
return 'Your call';
|
|
221
|
+
}
|
|
222
|
+
/** At most this many of the PM's calls show; the rest fold under one line ("N more of your calls"). */
|
|
223
|
+
export const MOVE_CAP = 5;
|
|
224
|
+
const SINCE_MS = 24 * 3600e3;
|
|
225
|
+
|
|
199
226
|
/** The page's model. Y: dayModel's answer (Y.rank from W3); D: Home's data; o: { quarter, tags, notes, picks, today: meetings }. */
|
|
200
227
|
export function gmModel(Y, D, now = Date.now(), o = {}) {
|
|
201
228
|
D = D || {};
|
|
@@ -214,10 +241,20 @@ export function gmModel(Y, D, now = Date.now(), o = {}) {
|
|
|
214
241
|
why: [meet ? 'Yes puts it on the ' + hm(meet.start) + ' agenda.' : '', fx ? fx.goal + ' moves from ' + WORD[fx.from] + ' to ' + WORD[fx.to] + '.' : ''].filter(Boolean).join(' ')
|
|
215
242
|
|| (c.pick ? 'I’d ' + c.pick.charAt(0).toLowerCase() + c.pick.slice(1).replace(/\.?$/, '.') + ' It’s your call.' : c.when ? 'Goes out ' + c.when + '.' : c.sub || '') } : null;
|
|
216
243
|
|
|
217
|
-
// Your move: the
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
const
|
|
244
|
+
// Your move (agent-run, AwA): only the calls that always wait for the PM, in W3's order (its Can wait included: a call is never "can
|
|
245
|
+
// wait"), each with its kind and why; the rest of W3's list is Claude's to do. With no ranked list, the calls Your day holds.
|
|
246
|
+
const all = Y.rank ? [...Y.rank.rows, ...(Y.rank.wait || [])] : (Y.calls || []).map((x) => ({ key: 'call:' + x.id, kind: 'call', call: x, title: x.name, sub: '', age: '' }));
|
|
247
|
+
const callWhy = (x) => (c && x.id === c.id && call && call.why) || (x.pick ? 'I’d ' + x.pick.charAt(0).toLowerCase() + x.pick.slice(1).replace(/\.?$/, '.') + ' It’s your call.' : x.when ? 'Goes out ' + x.when + '.' : x.sub || x.hint || '');
|
|
248
|
+
const mine = all.map((r) => ({ r, k: callKindOf(r) })).filter((x) => x.k)
|
|
249
|
+
.map(({ r, k }) => ({ ...r, callKind: k, sub: r.kind === 'call' ? callWhy(r.call) : r.sub, goal: tagOf(o.tags, r.ws, r.ini), late: r.days != null && r.days > 0 }));
|
|
250
|
+
const move = mine.slice(0, MOVE_CAP), more = mine.length - move.length;
|
|
251
|
+
// Claude did (AwA): what Claude finished by itself, newest first, each with its reason and Undo; a run that stopped is one amber line
|
|
252
|
+
const R = Y.rank || {}, recent = (x) => { const t = Date.parse(x.at || ''); return Number.isFinite(t) && now - t <= SINCE_MS; };
|
|
253
|
+
const did = (R.done || []).map((d) => ({ ...d, title: d.via === 'proposals' && d.name ? d.name + ': ' + (d.said || 'done') : d.said || 'done',
|
|
254
|
+
why: d.reason || 'Done by itself. You can undo it for 14 days.' }));
|
|
255
|
+
const didN = did.filter(recent).length;
|
|
256
|
+
const fl = (R.failed || []).filter(recent);
|
|
257
|
+
const failed = fl.length ? { n: fl.length, names: [...new Set(fl.map((x) => x.name).filter(Boolean))], why: fl[0].why || '' } : null;
|
|
221
258
|
|
|
222
259
|
// the lead: honest first; a call that moves a goal ties today to the quarter; else Your day's own line. A failed source is one quiet line
|
|
223
260
|
// under the lead, never the lead itself (G1, G3), and the face is never happier than the data
|
|
@@ -235,6 +272,13 @@ export function gmModel(Y, D, now = Date.now(), o = {}) {
|
|
|
235
272
|
// the header already greets: the lead never says "Morning, Wawan." again (say it once); a festival's wish stays
|
|
236
273
|
const g = /^(?:Morning|Afternoon|Evening)(?:, [^.]+)?\.\s*/;
|
|
237
274
|
if (g.test(line)) { line = line.replace(g, ''); if (!line) { line = sub || ''; sub = ''; } }
|
|
275
|
+
// the straight answer (AwA): how many calls are the PM's and how much Claude did since yesterday; Your day's own line when nothing is read
|
|
276
|
+
if (state !== 'soon' && B.mood !== 'concerned' && Y.rank && (mine.length || didN)) {
|
|
277
|
+
const n = mine.length, yours = n === 1 ? '1 call is yours.' : n + ' calls are yours.', prev = line;
|
|
278
|
+
const wish = /^Happy [^.]+\./.exec(prev); // a festival's wish stays first (AsPlaces); the straight answer follows it
|
|
279
|
+
line = (wish ? wish[0] + ' ' : '') + (n && didN ? 'Straight answer: ' + yours + ' I did the other ' + didN + '.' : n ? 'Straight answer: ' + yours : 'Straight answer: nothing needs you. I did ' + plural(didN, 'thing', 'things') + '.');
|
|
280
|
+
sub = didN ? 'Each one says why. You can undo any of them for 14 days.' : prev || sub; // Your day's own line (or the gap line) follows
|
|
281
|
+
}
|
|
238
282
|
const lead = { ...Y, mood: B.mood, face: B === Y ? Y.face : B.mood, failLead: false, line, sub, did: Y.chips.length ? 'Done for you: ' + Y.chips.join(', ') : '' };
|
|
239
283
|
|
|
240
284
|
// the next meeting's prep card (G2): what to agree, its bullets, Record as an icon
|
|
@@ -267,7 +311,7 @@ export function gmModel(Y, D, now = Date.now(), o = {}) {
|
|
|
267
311
|
|
|
268
312
|
// Since yesterday: up to 3 of New for you, neutral dots; orange only for a real rise (an item that says so)
|
|
269
313
|
const since = state === 'soon' ? [] : (Y.news || []).slice(0, 3); // the hour before a meeting shows no Since yesterday at all (G2)
|
|
270
|
-
return { state, date, hello, quarter, lead, call, move, more, made, prep, rail, notes, since, newsN: state === 'soon' ? 0 : (Y.news || []).length + (Y.digests || 0),
|
|
314
|
+
return { state, date, hello, quarter, lead, call, move, more, rest: mine.slice(MOVE_CAP), did, didN, failed, made, prep, rail, notes, since, newsN: state === 'soon' ? 0 : (Y.news || []).length + (Y.digests || 0),
|
|
271
315
|
drafts: Y.drafts.length, wait: Y.wait.length, concerned: B.mood === 'concerned', confirm: state === 'evening' && rc && rc.to_confirm > 0 ? rc.to_confirm : 0 };
|
|
272
316
|
}
|
|
273
317
|
|
|
@@ -289,10 +333,23 @@ function quarterHtml(Q) {
|
|
|
289
333
|
function rowHtml(r) {
|
|
290
334
|
const yes = r.yes ? `<button type="button" class="gm-tc" data-yd="mv-yes" data-key="${esc(r.key)}" aria-label="${esc(r.yes + ': ' + r.title)}" title="${esc(r.yes)}"></button>`
|
|
291
335
|
: r.kind === 'call' ? `<button type="button" class="gm-tc" data-yd="mv-open" data-key="${esc(r.key)}" aria-label="${esc('Open: ' + r.title)}" title="Open"></button>` : '<span class="gm-tc no" aria-hidden="true"></span>';
|
|
292
|
-
const tag = r.goal ? `<span class="gm-gt"><i class="d-${r.goal.dot}"></i>${esc(r.goal.text)}</span>` :
|
|
336
|
+
const tag = r.callKind ? `<em><span class="gm-k2">${esc(r.callKind)}</span>${r.sub ? ' · ' + esc(r.sub) : ''}</em>${r.goal ? `<span class="gm-gt"><i class="d-${r.goal.dot}"></i>${esc(r.goal.text)}</span>` : ''}`
|
|
337
|
+
: r.goal ? `<span class="gm-gt"><i class="d-${r.goal.dot}"></i>${esc(r.goal.text)}</span>` : r.sub ? `<em>${esc(r.sub)}</em>` : '';
|
|
293
338
|
return `<div class="gm-r" data-key="${esc(r.key)}"${r.kind === 'call' && r.call ? ` data-id="${esc(r.call.id)}"` : ''}>${yes}<button type="button" class="gm-rt" data-yd="mv-open" data-key="${esc(r.key)}"><b>${esc(r.title)}</b>${tag}</button>${r.age ? `<span class="gm-due${r.late ? ' late' : ''}">${esc(r.age)}</span>` : ''}</div>`;
|
|
294
339
|
}
|
|
295
340
|
const doneHtml = (r) => `<div class="gm-r done"><span class="gm-tc dn" aria-hidden="true">${svg(CHECK, 13, 2.6)}</span><span class="gm-rt"><b>${esc(r.title)}</b>${r.goal ? `<span class="gm-gt"><i class="d-o"></i>${esc(r.goal)}</span>` : r.sub ? `<em>${esc(r.sub)}</em>` : ''}</span></div>`;
|
|
341
|
+
const UNDO = 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3', WARN = 'M12 8v5M12 16.5v.01M10.3 3.9L2.6 17.5A2 2 0 0 0 4.3 20.5h15.4a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z';
|
|
342
|
+
/** One change Claude made by itself (AwA): ✓, what it did, its one-line reason, and Undo as an icon. Your day's Done fold draws it too. */
|
|
343
|
+
export function didRowHtml(d) {
|
|
344
|
+
return `<div class="gm-r done" data-ref="${esc(d.ref)}"><span class="gm-tc dn" aria-hidden="true">${svg(CHECK, 13, 2.6)}</span><span class="gm-rt"><b>${esc(d.title)}</b>${d.why ? `<em>${esc(d.why)}</em>` : ''}</span>`
|
|
345
|
+
+ `<button type="button" class="yd-alt sm gm-undo" data-yd="done-undo" data-ref="${esc(d.ref)}" data-via="${esc(d.via || 'proposals')}" data-ws="${esc(d.ws || '')}" data-board="${esc(d.board || '')}" aria-label="${esc('Undo: ' + d.title)}" title="Undo">${svg(UNDO, 16, 2)}</button></div>`;
|
|
346
|
+
}
|
|
347
|
+
/** A run that stopped, said once as one amber line (R4): never a row of Your move. */
|
|
348
|
+
export function failHtml(F) {
|
|
349
|
+
if (!F) return '';
|
|
350
|
+
const who = F.names.length === 1 ? F.names[0] + ' ' : '';
|
|
351
|
+
return `<div class="gm-fail" role="status">${svg(WARN, 14, 2)}<span><b>${esc(plural(F.n, who + 'run', who + 'runs') + ' stopped.')}</b>${F.why ? ' ' + esc(String(F.why).replace(/\.?$/, '.')) : ''} I run ${F.n === 1 ? 'it' : 'them'} again on the next wake. Nothing ${F.n === 1 ? 'it' : 'they'} made was kept.</span></div>`;
|
|
352
|
+
}
|
|
296
353
|
function agendaHtml(rows) {
|
|
297
354
|
return rows.map((x) => {
|
|
298
355
|
if (x.kind === 'allday') return `<div class="gm-ar"><span class="gm-tm">All day</span><div class="gm-ad">${esc(x.title)}</div></div>`;
|
|
@@ -317,19 +374,20 @@ export function gmHtml(G, openHtml, o = {}) {
|
|
|
317
374
|
a += `<section class="gm-prep"><span class="gm-k">${esc(P.k)}</span>${P.head ? `<h2>${esc(P.head)}</h2>` : ''}${P.bullets.length ? `<ul>${P.bullets.map((b) => `<li>${esc(b)}</li>`).join('')}</ul>` : ''}`
|
|
318
375
|
+ `<div class="gm-pr"><button type="button" class="gm-rec" data-yd="gm-rec" data-id="${esc(P.meeting.id || '')}" aria-label="Record this meeting" title="Record">${svg(MIC, 18, 2)}</button>${P.files ? `<em>${esc(P.files)}</em>` : ''}</div></section>`;
|
|
319
376
|
}
|
|
320
|
-
|
|
321
|
-
a += `<section class="gm-sec"><h3 class="gm-sh">Your call</h3><div class="gm-call yd-call${G.call.blocked ? ' am' : ''}" data-id="${esc(G.call.id)}"><div><b>${esc(G.call.name)}</b>${G.call.why ? `<em>${esc(G.call.why)}</em>` : ''}</div>`
|
|
322
|
-
+ `<button type="button" class="yd-alt" data-yd="sel" aria-label="${esc('Open: ' + G.call.name)}" title="Open">${svg(CHEV, 18, 2)}</button></div></section>`;
|
|
323
|
-
}
|
|
377
|
+
// Your call is a row of Your move now (AwA: say it once); its why rides on that row
|
|
324
378
|
// a decision caught in today's notes counts only once the PM confirms it (GET /api/phone-day recap.to_confirm): until then it is one quiet line
|
|
325
379
|
const conf = G.confirm ? `<div class="gm-more"><button type="button" data-yd="gm-notes"><b>${G.confirm}</b> ${G.confirm === 1 ? 'decision' : 'decisions'} from today’s notes to confirm${svg(CHEV, 14, 2)}</button></div>` : '';
|
|
326
380
|
if (G.made.length) a += `<section class="gm-sec"><h3 class="gm-sh">Today made possible</h3>${G.made.map(doneHtml).join('')}${conf}</section>`;
|
|
327
381
|
else a += conf;
|
|
328
|
-
const quiet = [G.more > 0
|
|
329
|
-
G.drafts ? `<button type="button" data-yd="gm-fold" data-fold="drafts"><b>${G.drafts}</b> drafted for you${svg(CHEV, 14, 2)}</button>` : ''
|
|
330
|
-
|
|
331
|
-
if (G.move.length) a += `<section class="gm-sec gm-move"><h3 class="gm-sh">${G.state === 'evening' ? 'Still yours' : 'Your move'} <span class="gm-n">${
|
|
382
|
+
const quiet = [G.more > 0 ? `<button type="button" data-yd="gm-fold" data-fold="more"><b>${G.more}</b> more ${G.more === 1 ? 'call' : 'calls'} of yours${svg(CHEV, 14, 2)}</button>` : '',
|
|
383
|
+
G.drafts ? `<button type="button" data-yd="gm-fold" data-fold="drafts"><b>${G.drafts}</b> drafted for you${svg(CHEV, 14, 2)}</button>` : ''].filter(Boolean).join('');
|
|
384
|
+
const nMine = G.move.length + (G.more || 0);
|
|
385
|
+
if (G.move.length) a += `<section class="gm-sec gm-move"><h3 class="gm-sh">${G.state === 'evening' ? 'Still yours' : 'Your move'} <span class="gm-n">${nMine}</span></h3>${G.move.map(rowHtml).join('')}${quiet ? `<div class="gm-more">${quiet}</div>` : ''}</section>`;
|
|
332
386
|
else if (quiet) a += `<div class="gm-more">${quiet}</div>`;
|
|
387
|
+
// Claude did (AwA): the amber line of a run that stopped, then the newest changes with their reasons and Undo; the rest fold
|
|
388
|
+
const dl = (G.did || []).slice(0, MOVE_CAP), dmore = (G.did || []).length - dl.length;
|
|
389
|
+
if (dl.length || G.failed) a += `<section class="gm-sec gm-didl"><h3 class="gm-sh">Claude did${G.didN ? ` <span class="gm-n">${G.didN} since yesterday</span>` : ''}</h3>${failHtml(G.failed)}${dl.map(didRowHtml).join('')}`
|
|
390
|
+
+ (dmore > 0 ? `<div class="gm-more"><button type="button" data-yd="gm-fold" data-fold="done"><b>${dmore}</b> more Claude did${svg(CHEV, 14, 2)}</button></div>` : '') + '</section>';
|
|
333
391
|
const b = G.since.length || G.newsN ? `<section class="gm-sec gm-since"><h3 class="gm-sh">Since yesterday${G.since.length ? `<button type="button" class="yd-all" data-yd="seen" aria-label="Mark all ${G.newsN} seen" title="Mark all seen">${svg(MARK2, 18, 1.9)}</button>` : ''}</h3>`
|
|
334
392
|
+ `<div class="gm-sl">${G.since.map((it) => `<button type="button" class="gm-si${it.rise ? ' hot' : ''}" data-yd="news" data-id="${esc(it.id)}"><i aria-hidden="true"></i><span>${esc(it.kind === 'task' ? String(it.title || '').replace(/^New task: /, '') : it.title)}</span>${it.at ? `<em>${esc(at(it.at))}</em>` : ''}</button>`).join('')}</div>`
|
|
335
393
|
+ `<button type="button" class="gm-lnk" data-yd="news-all">New for you · ${G.newsN}</button></section>` : '';
|
|
@@ -398,9 +398,10 @@ async function readMove() {
|
|
|
398
398
|
return pmGet('/api/lab' + (q ? '?' + q : '')).then((r) => (r && r.ok && r.lab && (r.lab.loose || []).length ? { ws: L[i], board: b, n: r.lab.loose.length, say: r.lab.say || '' } : null)).catch(() => null); }));
|
|
399
399
|
L.forEach((ws, i) => {
|
|
400
400
|
const r = got[i], A = auto[i] && auto[i].ok ? auto[i] : null; if (!r || !r.ok) return;
|
|
401
|
-
const done = A ? (A.done || []).map((d) => ({ ref: d.ref, ini: d.ini || '', said: d.title || 'done', at: d.at, via: 'autonomy' }))
|
|
401
|
+
const done = A ? (A.done || []).map((d) => ({ ref: d.ref, ini: d.ini || '', said: d.title || 'done', at: d.at, via: 'autonomy', reason: d.reason || '' }))
|
|
402
402
|
: (r.done || []).map((d) => ({ ref: d.batch, ini: d.ini, board: d.board, said: d.said, at: d.at, via: 'proposals' }));
|
|
403
|
-
|
|
403
|
+
// agent-run (AwA, R4): the runs that stopped, one amber line in Claude did
|
|
404
|
+
next[ws] = { verdicts: r.verdicts || [], kr: r.kr || null, expired: r.expired || [], done, notices: A ? A.notices || [] : [], failed: A ? A.failed || [] : [] };
|
|
404
405
|
});
|
|
405
406
|
const ob = await pmGet('/api/outbox').catch(() => null);
|
|
406
407
|
const outbox = ob && ob.ok && Array.isArray(ob.entries) ? ob.entries.filter((e) => e && (e.state === 'queued' || e.state === 'blocked')) : [];
|
|
@@ -498,7 +499,7 @@ function dayParts() {
|
|
|
498
499
|
// Good morning (GM2): the goal data (the quarter, the PM's line, the morning snapshot, a goal tag per row) is GM1's, in S.gmGoals once it reads
|
|
499
500
|
const G = GM.gmModel(Y, S.D, NOW(), { quarter: S.gmGoals && S.gmGoals.quarter, tags: S.gmGoals && S.gmGoals.tags, notes: noteRows(), picks: S.notePicks || {}, today: H.todayOf(S.D) });
|
|
500
501
|
S.G = G;
|
|
501
|
-
return { Y, P: YD.gmParts(Y, G, { moment: !!(isPhone() && PHC), now: NOW(), first: !!S.first, html: GM.gmHtml }) };
|
|
502
|
+
return { Y, P: YD.gmParts(Y, G, { moment: !!(isPhone() && PHC), now: NOW(), first: !!S.first, html: GM.gmHtml, didRow: GM.didRowHtml }) };
|
|
502
503
|
}
|
|
503
504
|
/** The quarter under Good morning (GET /api/morning-goals, GM1): goal states, the PM's line or Claude's ✦ line, the move since the
|
|
504
505
|
* morning, and a goal tag per initiative. Read when Your day opens (never on Home's first draw: page speed). No answer, no strip. */
|
|
@@ -352,14 +352,19 @@ export function dayParts(Y, o = {}) {
|
|
|
352
352
|
* Drafted for you, Can wait, Now (a phone's moment card) and This week. Nothing is dropped. → { gm, sections, night } */
|
|
353
353
|
export function gmParts(Y, G, o = {}) {
|
|
354
354
|
const now = o.now || Date.now(), sections = [];
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
355
|
+
// agent-run (AwA): the fold under Your move holds only the rest of the PM's calls (Can wait is gone: Claude acts on the rest), and the
|
|
356
|
+
// fold under Claude did the rest of what Claude did, each with its reason and Undo (o.didRow: good-morning.js didRowHtml)
|
|
357
|
+
const calls = G.rest || [];
|
|
358
|
+
if (calls.length || (Y.rank && (Y.rank.expired || []).length)) {
|
|
359
|
+
const mv = moveSection({ rows: calls, expired: Y.rank && Y.rank.expired });
|
|
360
|
+
if (mv) sections.push({ ...mv, id: 'more', title: 'More of your calls', open: false });
|
|
359
361
|
}
|
|
360
362
|
if (Y.drafts.length) sections.push({ id: 'drafts', title: 'Drafted for you', count: Y.drafts.length, html: `<div class="hv-card">${Y.drafts.map((d, i) => draftRow(d, i)).join('')}</div>` });
|
|
361
|
-
|
|
362
|
-
|
|
363
|
+
const dr = (G.did || []).slice(5);
|
|
364
|
+
if ((dr.length && o.didRow) || ((Y.rank && Y.rank.notices) || []).length) {
|
|
365
|
+
const nt = ((Y.rank && Y.rank.notices) || []).map((n) => `<p class="yd-exp">${esc(n.text || ((n.job || 'A job') + ' asks again before it changes anything, until ' + String(n.until || '').slice(0, 10) + '.'))}</p>`).join('');
|
|
366
|
+
sections.push({ id: 'done', title: 'More Claude did', count: dr.length, open: !!nt, html: nt + (o.didRow ? `<div class="gm-didl">${dr.map(o.didRow).join('')}</div>` : '') });
|
|
367
|
+
}
|
|
363
368
|
if (o.moment) sections.push({ id: 'now', title: 'Now', open: true, html: '<div class="hd-now"></div>' });
|
|
364
369
|
sections.push(weekSection(Y));
|
|
365
370
|
// one Adler per screen: the morning scene on the day's first open before noon, else his face on the lead
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/* pm/ini-agent.js — the agent's part of the initiative Viewer (agent-run workspace, board AwB on the main canvas, In development; agreed by
|
|
2
|
+
* Wawan 2026-11-10; requirements R4, R5, R7, R12, R17, R18 and decision D107). Pure parts first: Node imports them (ini-agent.test.js).
|
|
3
|
+
*
|
|
4
|
+
* agentModel(art, auto, id, o) → M | null what the Viewer shows, from GET /api/artefacts?scope=experiment:<id> and GET /api/autonomy
|
|
5
|
+
* expHtml(M) · workHtml(M) · sectionsHtml(M) the Experiment section and Claude's work (with its amber line and Coming up), or ''
|
|
6
|
+
* comingUp(v) → { date, text } | null the next dated thing of the initiative, from the Viewer's own model (ini-view-model.js)
|
|
7
|
+
* gateOf(M) → { label, parts } | null D107: the gate to Build reads the done test and the kill condition, not PRD and rubric
|
|
8
|
+
* want(ws, id, done) · cached(id) · edit(body, btn) · save(body, form) · undo(btn) the reads and presses (the page only)
|
|
9
|
+
*
|
|
10
|
+
* THE EXPERIMENT (R12, R18): we bet (hypothesis), stop if (kill), budget, who builds (executor, R17), specimens (the kept one, or how many
|
|
11
|
+
* attempts) and done when (the done test's checks). Claude writes it from the record; a field nobody wrote is left out, and with nothing
|
|
12
|
+
* written there is no section (zero is silence). The PM edits a one-line field in place (POST /api/artefacts/set); Claude then asks before
|
|
13
|
+
* it changes that line again (lib/artefacts.js pmEdited).
|
|
14
|
+
* CLAUDE'S WORK (R7): the changes Claude made here by itself in the last 14 days (GET /api/autonomy done, by initiative), each with its
|
|
15
|
+
* one-line reason, its day and Undo; a run that stopped is one amber line (R4); one Coming up line names the next dated thing (R5).
|
|
16
|
+
* Icon-only presses carry their words in aria-label and title. */
|
|
17
|
+
import { pmGet, pmPost } from './http.js';
|
|
18
|
+
|
|
19
|
+
const esc = (s) => String(s == null ? '' : s).replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
20
|
+
const SVG = (d, w = 16, sw = 1.8) => `<svg aria-hidden="true" width="${w}" height="${w}" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="${sw}" stroke-linecap="round" stroke-linejoin="round"><path d="${d}"/></svg>`;
|
|
21
|
+
const P = { undo: 'M9 14L4 9l5-5M4 9h10a6 6 0 0 1 0 12h-3', check: 'M5 12l5 5 9-10', warn: 'M12 8v5M12 16.5v.01M10.3 3.9L2.6 17.5A2 2 0 0 0 4.3 20.5h15.4a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z',
|
|
22
|
+
clock: 'M12 7.5V12l3 2M12 3.5a8.5 8.5 0 1 0 0 17a8.5 8.5 0 1 0 0-17', x: 'M6 6l12 12M18 6L6 18', right: 'M10 7l5 5-5 5' };
|
|
23
|
+
const MON = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
24
|
+
const dm = (iso) => { const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(String(iso || '')); return m ? +m[3] + ' ' + MON[+m[2] - 1] : ''; };
|
|
25
|
+
const DAY = 864e5, SHOW = 3;
|
|
26
|
+
export const WHO = { factory: 'Claude builds it (the factory).', team: 'The team builds it. Claude writes the done test.', 'team-agents': 'The team’s agents build it. Claude writes the done test.' };
|
|
27
|
+
|
|
28
|
+
const art = (A, key) => ((A && A.artefacts) || []).find((a) => a.key === key) || null;
|
|
29
|
+
const one = (a, f) => { const v = a && a.fields && a.fields[f]; return v && !Array.isArray(v) && v.text ? v : null; };
|
|
30
|
+
const list = (a, f) => { const v = a && a.fields && a.fields[f]; return Array.isArray(v) ? v.filter((x) => x && x.text) : []; };
|
|
31
|
+
const carried = (a, f) => ((a && a.carried) || []).filter((c) => c.field === f && c.text);
|
|
32
|
+
|
|
33
|
+
/** The Viewer's model. art: GET /api/artefacts answer for scope experiment:<id>; auto: GET /api/autonomy answer; o: { now }. */
|
|
34
|
+
export function agentModel(A, U, id, o = {}) {
|
|
35
|
+
const now = o.now || Date.now();
|
|
36
|
+
const X = art(A, 'experiment'), S = art(A, 'specimens'), T = art(A, 'done-test');
|
|
37
|
+
const row = (key, label, v, edit) => (v ? { key, label, text: v.text, by: v.by || '', at: v.at || '', edit: edit || null } : null);
|
|
38
|
+
const hyp = one(X, 'hypothesis') || (carried(X, 'hypothesis')[0] ? { text: carried(X, 'hypothesis')[0].text } : null);
|
|
39
|
+
const kill = one(X, 'kill'), budget = one(X, 'budget'), ex = one(X, 'executor');
|
|
40
|
+
const kept = one(S, 'kept'), tries = list(S, 'specimen'), checks = list(T, 'check'), result = one(T, 'result');
|
|
41
|
+
const rows = [
|
|
42
|
+
row('hypothesis', 'We bet', hyp, { artefact: 'experiment', field: 'hypothesis' }),
|
|
43
|
+
row('kill', 'Stop if', kill, { artefact: 'experiment', field: 'kill' }),
|
|
44
|
+
row('budget', 'Budget', budget, { artefact: 'experiment', field: 'budget' }),
|
|
45
|
+
ex ? { key: 'executor', label: 'Who builds', text: WHO[ex.text] || ex.text, value: ex.text, by: ex.by || '', at: ex.at || '', edit: { artefact: 'experiment', field: 'executor', pick: Object.keys(WHO) } } : null,
|
|
46
|
+
kept ? row('specimens', 'Specimens', { ...kept, text: 'Kept: ' + kept.text + (tries.length > 1 ? ' (of ' + tries.length + ' attempts)' : '') })
|
|
47
|
+
: tries.length ? row('specimens', 'Specimens', { text: tries.length + (tries.length === 1 ? ' attempt' : ' attempts') + ', none kept yet: ' + tries[tries.length - 1].text, at: tries[tries.length - 1].at }) : null,
|
|
48
|
+
checks.length ? { key: 'done', label: 'Done when', text: checks.map((c) => c.text).join(' · '), sub: result ? 'Result: ' + result.text : '', at: checks[checks.length - 1].at || '', edit: null } : null,
|
|
49
|
+
].filter(Boolean);
|
|
50
|
+
// the newest line Claude wrote dates the section: "Claude keeps it · 3 Nov"
|
|
51
|
+
const dates = rows.map((r) => r.at).filter(Boolean).sort();
|
|
52
|
+
const exp = rows.length ? { rows, at: dates.length ? dates[dates.length - 1] : '' } : null;
|
|
53
|
+
const gate = rows.length ? { kill: !!kill, done: checks.length > 0 } : null;
|
|
54
|
+
// Claude's work: this initiative's changes, newest first, and its runs that stopped
|
|
55
|
+
const mine = ((U && U.done) || []).filter((d) => d && d.ini === id);
|
|
56
|
+
const work = mine.map((d) => ({ ref: d.ref, title: d.title || 'A change', reason: d.reason || '', at: d.at || '', ws: (U && U.ws) || '' }));
|
|
57
|
+
const fl = ((U && U.failed) || []).filter((f) => f && f.ini === id && now - Date.parse(f.at || '') <= 7 * DAY);
|
|
58
|
+
const failed = fl.length ? { n: fl.length, at: fl[0].at, why: fl[0].why || '' } : null;
|
|
59
|
+
const week = work.filter((w) => now - Date.parse(w.at) <= 7 * DAY).length;
|
|
60
|
+
return { id, ws: (U && U.ws) || (A && A.ws) || '', exp, gate, work, week, failed };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** D107: with an experiment on record, the gate to Build is its done test and its kill condition (not the PRD and the rubric). */
|
|
64
|
+
export function gateOf(M) {
|
|
65
|
+
if (!M || !M.gate) return null;
|
|
66
|
+
return { label: 'Gate to Build', parts: [{ text: 'done test', ok: M.gate.done, ...(M.gate.done ? {} : { note: 'No done test is written yet' }) }, { text: 'kill condition', ok: M.gate.kill, ...(M.gate.kill ? {} : { note: 'No kill condition is written yet' }) }] };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The next dated thing of the initiative (R5), from the Viewer's model: the nearest open milestone ahead, else the plan's end. */
|
|
70
|
+
export function comingUp(v) {
|
|
71
|
+
const st = v && v.stage;
|
|
72
|
+
if (!st) return null;
|
|
73
|
+
const g = ((st.gates && st.gates.open) || []).find((x) => !x.late && x.date);
|
|
74
|
+
if (g) return { date: g.date, text: g.name + (g.left === 0 ? ' is due today.' : g.left === 1 ? ' is due tomorrow.' : ' is due.') };
|
|
75
|
+
const D = st.dates;
|
|
76
|
+
if (D && D.end && !D.over && D.left) return { date: D.end, text: 'The plan ends (' + D.left + ').' };
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const failLine = (F) => `<div class="ia-fl" role="status">${SVG(P.warn, 14, 2)}<span>${esc((F.n === 1 ? 'The ' + dm(F.at) + ' run' : F.n + ' runs') + ' ended with an error.' + (F.why ? ' ' + String(F.why).replace(/\.?$/, '.') : '') + ' Claude runs ' + (F.n === 1 ? 'it' : 'them') + ' again on the next wake. Nothing ' + (F.n === 1 ? 'it' : 'they') + ' made was kept.')}</span></div>`;
|
|
81
|
+
|
|
82
|
+
export function expHtml(M) {
|
|
83
|
+
if (!M || !M.exp) return '';
|
|
84
|
+
const rowHtml = (r) => {
|
|
85
|
+
const val = `<span class="ia-v">${esc(r.text)}${r.sub ? `<small>${esc(r.sub)}</small>` : ''}</span>`;
|
|
86
|
+
return r.edit ? `<button type="button" class="ia-xr" data-ia-edit="${esc(r.key)}" aria-label="${esc(r.label + ': ' + r.text + '. Edit')}" title="Edit"><b>${esc(r.label)}</b>${val}</button>`
|
|
87
|
+
: `<div class="ia-xr"><b>${esc(r.label)}</b>${val}</div>`;
|
|
88
|
+
};
|
|
89
|
+
return `<section class="ia-sec" aria-label="Experiment" data-ia-exp><div class="ia-th"><b>Experiment</b><span class="n">${esc('Claude keeps it' + (M.exp.at ? ' · ' + dm(M.exp.at) : ''))}</span></div>`
|
|
90
|
+
+ `<div class="iv-folds">${M.exp.rows.map(rowHtml).join('')}<p class="ia-note">Press a line to edit it. Claude asks before it changes one you edited.</p></div></section>`;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function workHtml(M, up, o = {}) {
|
|
94
|
+
if (!M || (!M.work.length && !M.failed && !up)) return '';
|
|
95
|
+
const all = !!o.all, shown = all ? M.work : M.work.slice(0, SHOW), more = M.work.length - shown.length;
|
|
96
|
+
const row = (w) => `<div class="ia-dr" data-ref="${esc(w.ref)}"><span class="ck" aria-hidden="true">${SVG(P.check, 12, 2.6)}</span><span><b>${esc(w.title)}</b><em>${esc([w.reason, dm(w.at)].filter(Boolean).join(' · '))}</em></span>`
|
|
97
|
+
+ `<button type="button" class="yd-alt sm" data-ia-undo="${esc(w.ref)}" data-ws="${esc(w.ws)}" aria-label="${esc('Undo: ' + w.title)}" title="Undo">${SVG(P.undo, 16, 2)}</button></div>`;
|
|
98
|
+
const list = M.work.length || M.failed ? `<div class="iv-folds">${M.failed ? failLine(M.failed) : ''}${shown.map(row).join('')}`
|
|
99
|
+
+ (more > 0 ? `<button type="button" class="iv-fr" data-ia-more aria-expanded="false"><b>${more} more</b><span class="iv-cv" aria-hidden="true">${SVG(P.right, 14, 2)}</span></button>` : '') + '</div>' : '';
|
|
100
|
+
const cu = up ? `<p class="ia-cu">${SVG(P.clock, 14, 2)}<span><b>${esc('Coming up · ' + up.date + '.')}</b> ${esc(up.text)}</span></p>` : '';
|
|
101
|
+
const n = M.week ? M.week + ' this week' : M.work.length ? M.work.length + ' in 14 days' : '';
|
|
102
|
+
return `<section class="ia-sec" aria-label="Claude’s work" data-ia-work><div class="ia-th"><b>Claude’s work</b>${n ? `<span class="n">${esc(n)}</span>` : ''}</div>${list}${cu}</section>`;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Both sections in one holder the page can swap when the reads arrive. */
|
|
106
|
+
export function sectionsHtml(M, v, id, o = {}) {
|
|
107
|
+
return `<div class="ia" data-ia="${esc(id)}">${expHtml(M)}${workHtml(M, comingUp(v), o)}</div>`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* ── the reads and the presses (the page only) ── */
|
|
111
|
+
const CACHE = new Map(), WANT = new Map(), OPEN = new Set();
|
|
112
|
+
const FRESH_MS = 30e3;
|
|
113
|
+
export const cached = (id) => (CACHE.get(id) || {}).M || null;
|
|
114
|
+
export const allOpen = (id) => OPEN.has(id);
|
|
115
|
+
/** Read the experiment and Claude's work for one initiative, at most every 30 s; done() runs when the answer changed what shows. */
|
|
116
|
+
export function want(ws, id, done) {
|
|
117
|
+
if (!id) return;
|
|
118
|
+
const c = CACHE.get(id), k = ws + '|' + id;
|
|
119
|
+
if (c && Date.now() - c.at < FRESH_MS) return;
|
|
120
|
+
if (WANT.has(k)) return;
|
|
121
|
+
const q = ws ? 'ws=' + encodeURIComponent(ws) + '&' : '';
|
|
122
|
+
const p = Promise.all([pmGet('/api/artefacts?' + q + 'scope=' + encodeURIComponent('experiment:' + id)).catch(() => null), pmGet('/api/autonomy' + (ws ? '?ws=' + encodeURIComponent(ws) : '')).catch(() => null)])
|
|
123
|
+
.then(([a, u]) => {
|
|
124
|
+
const M = agentModel(a && a.ok ? a : null, u && u.ok ? u : null, id);
|
|
125
|
+
const was = JSON.stringify(cached(id));
|
|
126
|
+
CACHE.set(id, { M, at: Date.now() });
|
|
127
|
+
if (JSON.stringify(M) !== was && done) done();
|
|
128
|
+
}).finally(() => WANT.delete(k));
|
|
129
|
+
WANT.set(k, p);
|
|
130
|
+
}
|
|
131
|
+
const forget = (id) => { const c = CACHE.get(id); if (c) c.at = 0; };
|
|
132
|
+
export function toggleMore(id) { if (OPEN.has(id)) OPEN.delete(id); else OPEN.add(id); }
|
|
133
|
+
|
|
134
|
+
/** A press on a field: the line turns into its editor (a text field, or the three builders for Who builds). */
|
|
135
|
+
export function edit(btn) {
|
|
136
|
+
const sec = btn.closest('[data-ia]'), id = sec && sec.dataset.ia, M = cached(id);
|
|
137
|
+
const r = M && M.exp && M.exp.rows.find((x) => x.key === btn.dataset.iaEdit);
|
|
138
|
+
if (!r || !r.edit) return;
|
|
139
|
+
const field = r.edit.pick ? `<select name="v" aria-label="${esc(r.label)}">${r.edit.pick.map((p) => `<option value="${esc(p)}"${p === r.value ? ' selected' : ''}>${esc(WHO[p])}</option>`).join('')}</select>`
|
|
140
|
+
: `<textarea name="v" rows="2" aria-label="${esc(r.label)}">${esc(r.text)}</textarea>`;
|
|
141
|
+
const f = document.createElement('form');
|
|
142
|
+
f.className = 'ia-xr ia-ed'; f.dataset.iaKey = r.key;
|
|
143
|
+
f.innerHTML = `<b>${esc(r.label)}</b><span class="ia-v">${field}<span class="ia-eb"><button type="submit" class="yd-ok sm" aria-label="Save" title="Save">${SVG(P.check, 16, 2.6)}</button><button type="button" class="yd-alt sm" data-ia-cancel aria-label="Cancel" title="Cancel">${SVG(P.x, 16, 2)}</button></span></span>`;
|
|
144
|
+
btn.replaceWith(f);
|
|
145
|
+
const el = f.querySelector('[name="v"]'); if (el) el.focus();
|
|
146
|
+
}
|
|
147
|
+
/** Save the PM's edit of one line; then read again and draw. */
|
|
148
|
+
export async function save(form, ws, redraw, toast) {
|
|
149
|
+
const id = form.closest('[data-ia]').dataset.ia, M = cached(id), r = M && M.exp && M.exp.rows.find((x) => x.key === form.dataset.iaKey);
|
|
150
|
+
const v = String(form.querySelector('[name="v"]').value || '').trim();
|
|
151
|
+
if (!r || !v) { redraw(); return; }
|
|
152
|
+
const res = await pmPost('/api/artefacts/set', { ws: ws || undefined, scope: 'experiment:' + id, artefact: r.edit.artefact, field: r.edit.field, text: v }).catch(() => null);
|
|
153
|
+
if (!res || !res.ok) { if (toast) toast((res && res.error) || 'It could not be saved. Nothing changed.'); redraw(); return; }
|
|
154
|
+
forget(id); want(ws, id, redraw);
|
|
155
|
+
}
|
|
156
|
+
/** Undo one change Claude made here (POST /api/autonomy/undo); then read again and draw. */
|
|
157
|
+
export async function undo(btn, ws, redraw, toast) {
|
|
158
|
+
if (btn.disabled) return; btn.disabled = true;
|
|
159
|
+
const id = btn.closest('[data-ia]').dataset.ia;
|
|
160
|
+
const res = await pmPost('/api/autonomy/undo', { ws: btn.dataset.ws || ws || undefined, ref: btn.dataset.iaUndo }).catch(() => null);
|
|
161
|
+
if (!res || !res.ok) { btn.disabled = false; if (toast) toast((res && res.error) || 'It could not be undone. Nothing changed.'); return; }
|
|
162
|
+
if (toast) toast('Undone.');
|
|
163
|
+
forget(id); want(ws, id, redraw);
|
|
164
|
+
}
|
|
@@ -169,9 +169,9 @@ button.iv-wf:hover, .iv-prog:hover { background: var(--cz-well2) !important; col
|
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
/* Tasks: the WBS, one section per stage */
|
|
172
|
-
.iv-th { display: flex; align-items: center; gap: 8px; padding: 4px 2px 0; }
|
|
173
|
-
.iv-th b { font-size: var(--fs-row); font-weight: var(--fw-strong); line-height: var(--lh-row); }
|
|
174
|
-
.iv-th .n { font-size: var(--fs-label); color: var(--cz-ink3); font-weight: var(--fw-strong); line-height: var(--lh-label); }
|
|
172
|
+
.iv-th, .ia-th { display: flex; align-items: center; gap: 8px; padding: 4px 2px 0; }
|
|
173
|
+
.iv-th b, .ia-th b { font-size: var(--fs-row); font-weight: var(--fw-strong); line-height: var(--lh-row); }
|
|
174
|
+
.iv-th .n, .ia-th .n { font-size: var(--fs-label); color: var(--cz-ink3); font-weight: var(--fw-strong); line-height: var(--lh-label); }
|
|
175
175
|
.iv-th .iv-ib { margin-left: auto; }
|
|
176
176
|
.iv-wbs { display: flex; flex-direction: column; border-radius: 18px; border: 1px solid var(--cz-hair); overflow: hidden; }
|
|
177
177
|
.iv-ws { display: flex !important; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 4px 12px 4px 14px !important; position: relative; }
|
|
@@ -1324,3 +1324,32 @@ body.iv-dragging { user-select: none; -webkit-user-select: none; cursor: grabbin
|
|
|
1324
1324
|
.bp-say { flex: 1 1 100%; min-height: 40px; border-radius: 12px; border: 1px solid var(--cz-hair); background: var(--cz-card); color: var(--cz-ink); padding: 0 12px; font: inherit; }
|
|
1325
1325
|
.bp-full { display: flex; align-items: center; gap: 8px; min-height: 44px; margin-top: 12px; border: 0; background: none; color: var(--cz-ink3); font: inherit; font-size: var(--fs-meta); cursor: pointer; }
|
|
1326
1326
|
.bp-full:hover { color: var(--cz-blueink); }
|
|
1327
|
+
|
|
1328
|
+
/* agent-run (board AwB, agreed 2026-11-10): the Experiment, Claude's work with its reasons and Undo, one Coming up line (pm/ini-agent.js) */
|
|
1329
|
+
.ia { display: contents; }
|
|
1330
|
+
.ia-sec { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
|
|
1331
|
+
.ia-xr, .iv button.ia-xr { display: flex; gap: 12px; width: 100%; padding: 11px 14px; position: relative; border: 0; background: none; text-align: left; font: inherit; font-size: var(--fs-meta); line-height: 1.45; color: var(--cz-ink); }
|
|
1332
|
+
button.ia-xr { cursor: pointer; }
|
|
1333
|
+
button.ia-xr:hover { background: var(--cz-well); }
|
|
1334
|
+
.ia-xr + .ia-xr::before { content: ""; position: absolute; left: 14px; right: 12px; top: 0; height: 1px; background: var(--cz-hair); }
|
|
1335
|
+
.ia-xr > b { flex: none; width: 112px; font-weight: var(--fw-strong); color: var(--cz-ink2); }
|
|
1336
|
+
.ia-v { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
|
|
1337
|
+
.ia-v small { display: block; font-size: var(--fs-label); color: var(--cz-ink3); }
|
|
1338
|
+
.ia-ed textarea, .ia-ed select { width: 100%; box-sizing: border-box; font: inherit; color: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--cz-hair); background: var(--cz-card); }
|
|
1339
|
+
.ia-eb { display: flex; gap: 6px; }
|
|
1340
|
+
.ia-note { margin: 0; padding: 4px 14px 11px; font-size: var(--fs-label); color: var(--cz-ink3); line-height: 1.45; }
|
|
1341
|
+
.ia-dr { display: flex; align-items: flex-start; gap: 10px; padding: 8px 8px 8px 14px; position: relative; font-size: var(--fs-meta); line-height: 1.45; }
|
|
1342
|
+
.ia-dr + .ia-dr::before, .ia-fl + .ia-dr::before { content: ""; position: absolute; left: 14px; right: 12px; top: 0; height: 1px; background: var(--cz-hair); }
|
|
1343
|
+
.ia-dr .ck { flex: none; width: 20px; height: 20px; border-radius: 10px; margin-top: 1px; background: var(--cz-blueink); color: var(--cz-onsolid); display: inline-flex; align-items: center; justify-content: center; }
|
|
1344
|
+
.ia-dr > span:not(.ck) { flex: 1; min-width: 0; }
|
|
1345
|
+
.ia-dr b { font-weight: var(--fw-strong); }
|
|
1346
|
+
.ia-dr em { display: block; font-style: normal; font-size: var(--fs-label); color: var(--cz-ink3); }
|
|
1347
|
+
.ia-dr .yd-alt.sm { flex: none; width: 36px; height: 36px; }
|
|
1348
|
+
.ia-fl { display: flex; gap: 8px; align-items: flex-start; margin: 8px 8px 4px; padding: 9px 12px; border-radius: 12px; background: var(--cz-latebg); color: var(--cz-late); font-size: var(--fs-label); line-height: 1.45; }
|
|
1349
|
+
.ia-fl svg, .ia-cu svg { flex: none; margin-top: 2px; }
|
|
1350
|
+
.ia-cu { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 10px 14px; font-size: var(--fs-label); color: var(--cz-blueink); line-height: 1.45; }
|
|
1351
|
+
@media (max-width: 760px) { .ia-xr { flex-direction: column; gap: 2px; } .ia-xr > b { width: auto; } }
|
|
1352
|
+
.ia .yd-ok, .ia .yd-alt { flex: none; border: 0; padding: 0; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; font: inherit; width: 36px; height: 36px; border-radius: 18px; }
|
|
1353
|
+
.ia .yd-ok { background: var(--cz-blue); color: var(--cz-onsolid); }
|
|
1354
|
+
.ia .yd-alt { background: var(--cz-well); color: var(--cz-ink2); }
|
|
1355
|
+
.ia .yd-alt:disabled { opacity: .5; cursor: default; }
|
|
@@ -47,6 +47,7 @@ import * as AB from './ini-about.js'; // About: the description and the succes
|
|
|
47
47
|
import { headerFlags } from './grill-words.js'; // the grill findings on the header (workspace grill W3)
|
|
48
48
|
import * as ED from './ini-edit.js'; // a task changed where it sits in the List: open in place, ⋯, + per stage, drag (batch 18 item 16)
|
|
49
49
|
import { ticks } from './ini-view-model.js'; // W1: a task group ticks only when every task in it is done
|
|
50
|
+
import * as IA from './ini-agent.js'; // agent-run (board AwB): the Experiment, Claude's work with Undo, Coming up; the D107 gate
|
|
50
51
|
|
|
51
52
|
const CSS = new URL('./ini-view.css', import.meta.url).href;
|
|
52
53
|
if (typeof document !== 'undefined' && document.head && !document.querySelector(`link[href="${CSS}"]`)) {
|
|
@@ -409,12 +410,15 @@ function foldsHtml(v, o) {
|
|
|
409
410
|
const VIEWED = new Map(); // initiative id → the view drawn last (the ✦ in the Viewer's header reads it)
|
|
410
411
|
const OPTS = new Map(); // initiative id → the options it was drawn with, so About can draw alone when its description arrives
|
|
411
412
|
export function viewHtml(v, o = {}) {
|
|
413
|
+
// agent-run (AwB): with an experiment on record the gate to Build reads its done test and kill condition (D107), not PRD and rubric
|
|
414
|
+
const AM = v && v.id ? IA.cached(v.id) : null, ag = IA.gateOf(AM);
|
|
415
|
+
if (ag && v.stage) v = { ...v, stage: { ...v.stage, gate: ag } };
|
|
412
416
|
if (v && v.id) { VIEWED.set(v.id, v); OPTS.set(v.id, o); }
|
|
413
417
|
// a merged initiative leads with where its work went, and draws no stage or tasks (they moved; its folds stay); an open one shows Claude's split or merge card under the summary (batch 11 item 14)
|
|
414
418
|
if (v.merged) return `<div class="iv" data-iv="${esc(v.id || v.key || '')}"><div class="iv-cols"><div class="iv-cl">${smMerged(v.merged)}</div><div class="iv-cr">${foldsHtml(v, o)}${o.tail || ''}</div></div></div>`;
|
|
415
419
|
// One reading column: summary, milestones and proposals, then content-sized Tasks and document folds.
|
|
416
420
|
return `<div class="iv" data-iv="${esc(v.id || v.key || '')}"><div class="iv-cols"><div class="iv-cl">${ctrlHtml(v, o)}${o.sm !== false ? smCard(v.suggest, v.title) : ''}</div>`
|
|
417
|
-
+ `<div class="iv-cr"
|
|
421
|
+
+ `<div class="iv-cr">${v.id ? IA.sectionsHtml(AM, v, v.id, { all: IA.allOpen(v.id) }) : ''}<section class="iv-tasks" aria-label="Tasks">${tasksHtml(v, o)}</section>${foldsHtml(v, o)}${o.tail || ''}</div></div></div>`;
|
|
418
422
|
}
|
|
419
423
|
|
|
420
424
|
/* ── the presses ── */
|
|
@@ -423,7 +427,19 @@ export function wireView(body, h) {
|
|
|
423
427
|
const idOf = () => { const n = body.querySelector('[data-iv]'); return n ? n.dataset.iv : null; };
|
|
424
428
|
body.__iv = LK.wrap(VS.wrap(ED.writes({ ...h, __id: idOf }), body, (id) => SHOWN.get(id)), idOf);
|
|
425
429
|
// the one blue ✦ after the title (pm/ini-props.js), drawn again with each draw of the initiative
|
|
426
|
-
const chip = () => { const id = idOf(); if (id && VIEWED.has(id)) PP.sync(VIEWED.get(id), body.__iv || {}); drafts(id); about(id); fitMission(body); };
|
|
430
|
+
const chip = () => { const id = idOf(); if (id && VIEWED.has(id)) PP.sync(VIEWED.get(id), body.__iv || {}); drafts(id); about(id); agent(id); fitMission(body); };
|
|
431
|
+
// agent-run (AwB): the experiment and Claude's work, read every 30 s at most; they draw alone (and the gate with them) when they change
|
|
432
|
+
const wsOf = () => { const H = body.__iv || {}; return ((H.where && H.where()) || {}).ws || ''; };
|
|
433
|
+
const agent = (id) => { if (id && VIEWED.has(id)) IA.want(wsOf(), id, () => paintAgent(id)); };
|
|
434
|
+
const paintAgent = (id) => {
|
|
435
|
+
if (idOf() !== id || !VIEWED.has(id)) return;
|
|
436
|
+
const v0 = VIEWED.get(id), M = IA.cached(id), g = IA.gateOf(M), v = g ? { ...v0, stage: { ...v0.stage, gate: g } } : v0;
|
|
437
|
+
VIEWED.set(id, v);
|
|
438
|
+
// replace only what changed: a node another press holds (a task card's day picker) is never swapped for an identical copy
|
|
439
|
+
const swap = (n, html) => { const t = document.createElement('template'); t.innerHTML = html; const x = t.content.firstElementChild; if (!x || !x.isEqualNode(n)) n.outerHTML = html; };
|
|
440
|
+
const at = body.querySelector('[data-ia]'); if (at) swap(at, IA.sectionsHtml(M, v, id, { all: IA.allOpen(id) }));
|
|
441
|
+
if (g) for (const n of body.querySelectorAll('.iv-gate')) swap(n, srcGateHtml({ gate: g }));
|
|
442
|
+
};
|
|
427
443
|
// the success measure Claude drafted: read once per page load, the view draws again when it arrives
|
|
428
444
|
const drafts = (id) => { const H = body.__iv || {}; if (id && VIEWED.has(id)) MD.want(((H.where && H.where()) || {}).ws || '', 'initiative', id, () => { if (idOf() === id && H.redraw) H.redraw(); }); };
|
|
429
445
|
// the description: the PRD, read once per path through /api/doc; the view draws again when it arrives
|
|
@@ -465,6 +481,11 @@ export function wireView(body, h) {
|
|
|
465
481
|
const root = b.closest('[data-iv]'); if (!root) return;
|
|
466
482
|
const id = root.dataset.iv;
|
|
467
483
|
const d = b.dataset;
|
|
484
|
+
// agent-run (AwB): edit a line of the experiment, Undo a change of Claude's, the rest of Claude's work
|
|
485
|
+
if (d.iaEdit) { e.preventDefault(); IA.edit(b); return; }
|
|
486
|
+
if ('iaCancel' in d) { e.preventDefault(); paintAgent(id); return; }
|
|
487
|
+
if (d.iaUndo) { e.preventDefault(); IA.undo(b, wsOf(), () => paintAgent(id), H.toast); return; }
|
|
488
|
+
if ('iaMore' in d) { e.preventDefault(); IA.toggleMore(id); paintAgent(id); return; }
|
|
468
489
|
if (d.ivMc) { e.preventDefault(); const M = MD.measuresOf(id); mcToggle(id, d.ivMc, { proposal: !!(M && M.mode === 'open') }); if (H.redraw) H.redraw(); later(b, (r) => r.querySelector(`[data-iv-mc="${d.ivMc}"]`), true); return; }
|
|
469
490
|
if (d.abMore && AB.pressMore(b, H.redraw)) { e.preventDefault(); return; }
|
|
470
491
|
if (d.md && MD.press(b, { redraw: H.redraw, toast: H.toast })) { e.preventDefault(); return; }
|
|
@@ -497,6 +518,8 @@ export function wireView(body, h) {
|
|
|
497
518
|
});
|
|
498
519
|
// the inline add (the Tasks + icon): Enter adds, Esc puts the + back
|
|
499
520
|
body.addEventListener('submit', (e) => {
|
|
521
|
+
const ed = e.target.closest('form.ia-ed');
|
|
522
|
+
if (ed) { e.preventDefault(); const r = ed.closest('[data-iv]'); IA.save(ed, wsOf(), () => paintAgent(r && r.dataset.iv), (body.__iv || {}).toast); return; }
|
|
500
523
|
const f = e.target.closest('[data-iv-addform]'); if (!f) return;
|
|
501
524
|
e.preventDefault(); const H = body.__iv || {}, inp = f.querySelector('input'), t = inp ? inp.value.trim() : '';
|
|
502
525
|
if (t && H.addTask) H.addTask(t, inp);
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
* rows, mentions: GET /api/mentions waiting, outbox: GET /api/outbox entries, now }
|
|
37
37
|
* → { rows (at most CAP), wait (Can wait, ranked), older: [] (kept for old callers), expired: [{ ini, title, why, at, name }],
|
|
38
38
|
* done: [{ ref, via: 'autonomy' | 'proposals', ini, board, ws, at, said, name }] (C2: what Claude finished by itself, with Undo),
|
|
39
|
-
* notices: [{ job, product, until, text?, ws }] (a job demoted to propose, said once),
|
|
39
|
+
* notices: [{ job, product, until, text?, ws }] (a job demoted to propose, said once), failed: [{ run, ini, at, why, ws, name }] (agent-run
|
|
40
|
+
* R4: the runs that stopped, GET /api/autonomy failed), n }
|
|
40
41
|
* A row: { key, rank, kind, title, sub, tag, at, age, older, ws, board, ini, program, props: [{ ws, board, ini, ids, sigs }], ms: { program,
|
|
41
42
|
* keys } | null, verdict: { ini, board, verdict, text } | null, yes: label | '', alt: label | '', call } */
|
|
42
43
|
import { findingOf } from './grill-words.js';
|
|
@@ -201,13 +202,15 @@ export function rankMove(o = {}) {
|
|
|
201
202
|
rows.sort((a, b) => a.rank - b.rank || (a.at == null) - (b.at == null) || (a.at || 0) - (b.at || 0) || a.key.localeCompare(b.key));
|
|
202
203
|
// C3: at most CAP show; the rest can wait, in the same order. The expired ✦ of the last 7 days, said once.
|
|
203
204
|
// C2: what Claude finished by itself (lib/done-feed.js), one line per batch with its initiative's name and one Undo
|
|
204
|
-
const expired = [], done = [], notices = [];
|
|
205
|
+
const expired = [], done = [], notices = [], failed = [];
|
|
205
206
|
for (const P of o.products || []) {
|
|
206
207
|
const M = (o.move && o.move[P.ws || '']) || {}, nameOf = (ini) => { const r = (P.rows || []).find((x) => x && x.id === ini); return (r && (r.title || r.id)) || ini || ''; };
|
|
207
208
|
for (const x of M.expired || []) expired.push({ ...x, ws: P.ws || '', name: nameOf(x.ini) });
|
|
208
209
|
for (const x of M.done || []) done.push({ ...x, ws: P.ws || '', board: x.board || P.board || '', name: x.ini ? nameOf(x.ini) : '' });
|
|
209
210
|
for (const x of M.notices || []) notices.push({ ...x, ws: P.ws || '' });
|
|
211
|
+
for (const x of M.failed || []) failed.push({ ...x, ws: P.ws || '', name: P.name || '', iniName: x.ini ? nameOf(x.ini) : '' }); // agent-run R4: a run that stopped
|
|
210
212
|
}
|
|
211
213
|
done.sort((a, b) => String(b.at).localeCompare(String(a.at)));
|
|
212
|
-
|
|
214
|
+
failed.sort((a, b) => String(b.at).localeCompare(String(a.at)));
|
|
215
|
+
return { rows: rows.slice(0, CAP), wait: rows.slice(CAP), older: [], expired, done, notices, failed, n: rows.length };
|
|
213
216
|
}
|
|
@@ -237,6 +237,9 @@ const TICKETS = [{ key: 'IDPF-3387', title: 'Refactor the AppAuthService', statu
|
|
|
237
237
|
ok('S7 ⋯ Milestone makes it a milestone and clears its start (one date), keeping the due day', ms && ms.body.task === 'task-b3' && ms.body.start === '' && ms.body.due == null, JSON.stringify(ms));
|
|
238
238
|
const one7 = await until(() => p.evaluate(() => { const r = document.querySelector('#czViewer .iv-ed[data-iv-open="task-b3"]'); if (!r) return null; const d = [...r.querySelectorAll('.iv-edd')]; return d.length === 1 && d[0].dataset.one === '1' ? d[0].getAttribute('aria-label') : null; }));
|
|
239
239
|
ok('S7 the open row then shows one ◇ date chip, no Start and Due', one7 === 'Milestone date: Nov 12. Change', one7);
|
|
240
|
+
// the Viewer's Experiment and Claude's work sit above Tasks, so the row may sit below the fold: bring it in first and let that scroll
|
|
241
|
+
// settle, or its late scroll event closes the picker the click just opened (a scroll outside the picker closes it)
|
|
242
|
+
await p.$eval('#czViewer .iv-ed .iv-edd', (n) => n.scrollIntoView({ block: 'center' })); await p.evaluate(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r))));
|
|
240
243
|
await p.click('#czViewer .iv-ed .iv-edd');
|
|
241
244
|
const op7 = await until(() => p.evaluate(() => { const q = document.querySelector('.tkc.ivq .tkc-dp'); return q ? { tabs: q.querySelectorAll('[data-tkc-field]').length, head: (q.querySelector('.ivd-h b') || {}).textContent, sub: (q.querySelector('.ivd-s') || {}).textContent } : null; }));
|
|
242
245
|
ok('S7 its picker is one date: "◇ Date", no Start and Due tabs', op7 && op7.tabs === 0 && op7.head === 'Date' && /one date: the milestone/.test(op7.sub || ''), JSON.stringify(op7));
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "Agent-run workspace (boards AwA, AwB): the initiative Viewer's Experiment, Claude's work with Undo, Coming up and the D107 gate (pure, node): pm/ini-agent.js.",
|
|
3
|
+
"modules": [
|
|
4
|
+
"ini-agent.test.js"
|
|
5
|
+
],
|
|
6
|
+
"seconds": {
|
|
7
|
+
"ini-agent.test.js": 1
|
|
8
|
+
}
|
|
9
|
+
}
|