cyc-stack 0.10.0 → 0.11.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/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +1 -1
- package/bin/cyc.mjs +55 -7
- package/docs/README.md +2 -0
- package/docs/runtime.md +4 -0
- package/docs/work-queue.md +187 -0
- package/methods/cyc-build/SKILL.md +1 -1
- package/methods/cyc-design/frontend-design/SKILL.md +125 -28
- package/methods/cyc-design/frontend-design/references/color.md +42 -50
- package/methods/cyc-design/frontend-design/references/craft-rules.md +13 -10
- package/methods/cyc-design/frontend-design/references/decision-sheet.md +94 -98
- package/methods/cyc-design/frontend-design/references/experience-review.md +10 -2
- package/methods/cyc-design/frontend-design/references/field-guide.md +439 -0
- package/methods/cyc-design/frontend-design/references/generic-tells.md +82 -33
- package/methods/cyc-design/frontend-design/references/layout-archetypes.md +5 -5
- package/methods/cyc-design/frontend-design/references/patterns.md +108 -0
- package/methods/cyc-design/frontend-design/references/reference-standards.md +118 -22
- package/methods/cyc-design/frontend-design/references/typography.md +59 -44
- package/methods/cyc-design/frontend-design/references/visual-material.md +40 -7
- package/methods/cyc-design/frontend-design/scripts/contrast.mjs +1 -1
- package/methods/cyc-design/frontend-design/scripts/first-screen.mjs +911 -0
- package/methods/cyc-design/frontend-design/scripts/photo-text.mjs +230 -0
- package/methods/cyc-verify/SKILL.md +1 -1
- package/package.json +6 -1
- package/plugin.json +1 -1
- package/scripts/hub-page.mjs +275 -0
- package/scripts/hub.mjs +139 -0
- package/scripts/queue-board.mjs +287 -0
- package/scripts/queue.mjs +283 -0
- package/scripts/run-gate.mjs +1 -1
- package/scripts/runtime.mjs +248 -13
- package/scripts/source-snapshot.mjs +1 -1
- package/scripts/work-review.mjs +1 -1
- package/skills/cyc/SKILL.md +8 -0
- package/skills/cyc/references/playbooks/plan.md +2 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
// Measures text that sits on a photograph, a gradient or a see-through surface.
|
|
2
|
+
//
|
|
3
|
+
// A script in the page cannot read the pixels of most photographs: an image from
|
|
4
|
+
// another origin, or any image on a file:// page, taints the canvas it is drawn on.
|
|
5
|
+
// So the probe records where such text sits, and the builder saves two screenshots:
|
|
6
|
+
// one after `markText` paints every letter one flat magenta, and one after `hideText`
|
|
7
|
+
// makes every letter transparent. Neither moves anything. The pixels that differ
|
|
8
|
+
// between the two are the letters themselves, and the hidden screenshot holds what is
|
|
9
|
+
// behind them, scrims, panels and text shadows included. Line boxes, rotation and the
|
|
10
|
+
// gaps between letters do not count, so a bright band beside a word does not fail it.
|
|
11
|
+
//
|
|
12
|
+
// WCAG gives no method for text on a photograph. The rule here is the method's own:
|
|
13
|
+
// the text's colour meets 4.5:1, or 3:1 when large, against what is behind at least
|
|
14
|
+
// 90 percent of its letters.
|
|
15
|
+
|
|
16
|
+
import { inflateSync } from 'node:zlib';
|
|
17
|
+
|
|
18
|
+
// Run in the page after the probe, then take the first screenshot. Self-contained.
|
|
19
|
+
export async function markText() {
|
|
20
|
+
for (const image of document.images) if (image.loading === 'lazy') image.loading = 'eager';
|
|
21
|
+
const settle = (image) => new Promise((done) => {
|
|
22
|
+
if (image.complete) { done(); return; }
|
|
23
|
+
image.addEventListener('load', done, { once: true });
|
|
24
|
+
image.addEventListener('error', done, { once: true });
|
|
25
|
+
}).then(() => image.decode().catch(() => {}));
|
|
26
|
+
const waiting = [...document.images].filter((image) => !image.complete || !image.naturalWidth);
|
|
27
|
+
await Promise.race([Promise.all([...document.images].map(settle)), new Promise((done) => setTimeout(done, 10000))]);
|
|
28
|
+
for (const old of document.querySelectorAll('#cyc-hide-text, #cyc-mark-text')) old.remove();
|
|
29
|
+
const style = document.createElement('style');
|
|
30
|
+
style.id = 'cyc-mark-text';
|
|
31
|
+
style.textContent = '*, *::before, *::after { color: #ff00ff !important; -webkit-text-fill-color: #ff00ff !important;'
|
|
32
|
+
+ ' text-decoration-color: transparent !important; caret-color: transparent !important;'
|
|
33
|
+
+ ' transition: none !important; animation-play-state: paused !important; }'
|
|
34
|
+
+ ' svg text, svg tspan, svg textPath { fill: #ff00ff !important; stroke: none !important; }';
|
|
35
|
+
document.head.appendChild(style);
|
|
36
|
+
window.scrollTo(0, 0);
|
|
37
|
+
await new Promise((done) => requestAnimationFrame(() => requestAnimationFrame(done)));
|
|
38
|
+
return { marked: true, images: document.images.length, waitedFor: waiting.length,
|
|
39
|
+
pageHeight: Math.round(Math.max(document.documentElement.scrollHeight, document.body.scrollHeight)) };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Run in the page after the first screenshot, then take the second. Self-contained.
|
|
43
|
+
export async function hideText() {
|
|
44
|
+
for (const image of document.images) if (image.loading === 'lazy') image.loading = 'eager';
|
|
45
|
+
const settle = (image) => new Promise((done) => {
|
|
46
|
+
if (image.complete) { done(); return; }
|
|
47
|
+
image.addEventListener('load', done, { once: true });
|
|
48
|
+
image.addEventListener('error', done, { once: true });
|
|
49
|
+
}).then(() => image.decode().catch(() => {}));
|
|
50
|
+
const waiting = [...document.images].filter((image) => !image.complete || !image.naturalWidth);
|
|
51
|
+
await Promise.race([Promise.all([...document.images].map(settle)), new Promise((done) => setTimeout(done, 10000))]);
|
|
52
|
+
for (const old of document.querySelectorAll('#cyc-hide-text, #cyc-mark-text')) old.remove();
|
|
53
|
+
const style = document.createElement('style');
|
|
54
|
+
style.id = 'cyc-hide-text';
|
|
55
|
+
style.textContent = '*, *::before, *::after { color: transparent !important; -webkit-text-fill-color: transparent !important;'
|
|
56
|
+
+ ' text-decoration-color: transparent !important; caret-color: transparent !important;'
|
|
57
|
+
+ ' transition: none !important; animation-play-state: paused !important; }'
|
|
58
|
+
+ ' svg text, svg tspan, svg textPath { fill: transparent !important; stroke: none !important; }';
|
|
59
|
+
document.head.appendChild(style);
|
|
60
|
+
window.scrollTo(0, 0);
|
|
61
|
+
await new Promise((done) => requestAnimationFrame(() => requestAnimationFrame(done)));
|
|
62
|
+
return { hidden: true, images: document.images.length, waitedFor: waiting.length,
|
|
63
|
+
pageHeight: Math.round(Math.max(document.documentElement.scrollHeight, document.body.scrollHeight)) };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const SIGNATURE = [137, 80, 78, 71, 13, 10, 26, 10];
|
|
67
|
+
const CHANNELS = { 0: 1, 2: 3, 4: 2, 6: 4 };
|
|
68
|
+
|
|
69
|
+
// Reads an 8-bit, non-interlaced PNG, which is what browsers write for a screenshot.
|
|
70
|
+
export function readPng(bytes) {
|
|
71
|
+
if (!Buffer.isBuffer(bytes) || bytes.length < 33 || SIGNATURE.some((byte, index) => bytes[index] !== byte)) {
|
|
72
|
+
throw new TypeError('not a PNG file.');
|
|
73
|
+
}
|
|
74
|
+
let offset = 8;
|
|
75
|
+
let header = null;
|
|
76
|
+
const data = [];
|
|
77
|
+
while (offset + 8 <= bytes.length) {
|
|
78
|
+
const length = bytes.readUInt32BE(offset);
|
|
79
|
+
const kind = bytes.toString('latin1', offset + 4, offset + 8);
|
|
80
|
+
const body = bytes.subarray(offset + 8, offset + 8 + length);
|
|
81
|
+
if (body.length !== length) throw new TypeError('the PNG is cut short.');
|
|
82
|
+
if (kind === 'IHDR') header = { width: body.readUInt32BE(0), height: body.readUInt32BE(4), depth: body[8], type: body[9], interlace: body[12] };
|
|
83
|
+
else if (kind === 'IDAT') data.push(body);
|
|
84
|
+
else if (kind === 'IEND') break;
|
|
85
|
+
offset += 12 + length;
|
|
86
|
+
}
|
|
87
|
+
const channels = header && CHANNELS[header.type];
|
|
88
|
+
if (!header || !header.width || !header.height || header.depth !== 8 || !channels || header.interlace !== 0) {
|
|
89
|
+
throw new TypeError('the PNG must be 8-bit grey or colour and not interlaced, as a browser screenshot is.');
|
|
90
|
+
}
|
|
91
|
+
const { width, height } = header;
|
|
92
|
+
const stride = width * channels;
|
|
93
|
+
let raw;
|
|
94
|
+
try { raw = inflateSync(Buffer.concat(data)); } catch { throw new TypeError('the PNG data does not decompress.'); }
|
|
95
|
+
if (raw.length < height * (stride + 1)) throw new TypeError('the PNG data is cut short.');
|
|
96
|
+
const pixels = Buffer.alloc(height * stride);
|
|
97
|
+
for (let y = 0; y < height; y += 1) {
|
|
98
|
+
const filter = raw[y * (stride + 1)];
|
|
99
|
+
const line = y * (stride + 1) + 1;
|
|
100
|
+
const out = y * stride;
|
|
101
|
+
for (let x = 0; x < stride; x += 1) {
|
|
102
|
+
const left = x >= channels ? pixels[out + x - channels] : 0;
|
|
103
|
+
const up = y ? pixels[out - stride + x] : 0;
|
|
104
|
+
const corner = y && x >= channels ? pixels[out - stride + x - channels] : 0;
|
|
105
|
+
let guess;
|
|
106
|
+
if (filter === 0) guess = 0;
|
|
107
|
+
else if (filter === 1) guess = left;
|
|
108
|
+
else if (filter === 2) guess = up;
|
|
109
|
+
else if (filter === 3) guess = (left + up) >> 1;
|
|
110
|
+
else if (filter === 4) {
|
|
111
|
+
const p = left + up - corner;
|
|
112
|
+
const [a, b, c] = [Math.abs(p - left), Math.abs(p - up), Math.abs(p - corner)];
|
|
113
|
+
guess = a <= b && a <= c ? left : b <= c ? up : corner;
|
|
114
|
+
} else throw new TypeError(`the PNG has an unknown row filter (${filter}).`);
|
|
115
|
+
pixels[out + x] = (raw[line + x] + guess) & 255;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return { width, height, channels, pixels };
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const linear = (value) => (value / 255 <= 0.03928 ? value / 255 / 12.92 : ((value / 255 + 0.055) / 1.055) ** 2.4);
|
|
122
|
+
const luminance = (r, g, b) => 0.2126 * linear(r) + 0.7152 * linear(g) + 0.0722 * linear(b);
|
|
123
|
+
const MARK = [255, 0, 255];
|
|
124
|
+
const distance = (a, b) => Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
|
|
125
|
+
|
|
126
|
+
// The colour at one pixel, over white where the screenshot is not opaque.
|
|
127
|
+
function pixel(shot, x, y) {
|
|
128
|
+
const at = (y * shot.width + x) * shot.channels;
|
|
129
|
+
const p = shot.pixels;
|
|
130
|
+
const [r, g, b, a] = shot.channels >= 3
|
|
131
|
+
? [p[at], p[at + 1], p[at + 2], shot.channels === 4 ? p[at + 3] / 255 : 1]
|
|
132
|
+
: [p[at], p[at], p[at], shot.channels === 2 ? p[at + 1] / 255 : 1];
|
|
133
|
+
return [r * a + 255 * (1 - a), g * a + 255 * (1 - a), b * a + 255 * (1 - a)];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function refuse(message) {
|
|
137
|
+
const error = new TypeError(message);
|
|
138
|
+
error.shot = true;
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Measures each recorded piece of text against the two screenshots of its view. Returns
|
|
143
|
+
// the pieces that fall short and the count of those that could not be measured, by reason.
|
|
144
|
+
export function measurePhotoText(access, view, { hidden, marked }, cover) {
|
|
145
|
+
const ratio = access.pixelRatio || 1;
|
|
146
|
+
const expected = view.width * ratio;
|
|
147
|
+
if (hidden.width !== marked.width) {
|
|
148
|
+
refuse(`the two screenshots differ in size (${marked.width}×${marked.height} marked, ${hidden.width}×${hidden.height} hidden):`
|
|
149
|
+
+ ' take both the same way, one straight after the other.');
|
|
150
|
+
}
|
|
151
|
+
// A screenshot may include a scrollbar that the probe's width leaves out, and a full-page
|
|
152
|
+
// screenshot of a page that scrolls sideways is as wide as the page.
|
|
153
|
+
if (hidden.width < expected - 1 || hidden.width > (view.width + (view.overflow || 0) + 24) * ratio) {
|
|
154
|
+
refuse(`the screenshots are ${hidden.width} px wide, and this view is ${view.width} CSS px at a pixel ratio of ${ratio}:`
|
|
155
|
+
+ ' take them at the width the probe ran at.');
|
|
156
|
+
}
|
|
157
|
+
const shotHeight = Math.min(hidden.height, marked.height) / ratio;
|
|
158
|
+
const fullPage = shotHeight > view.height + 2;
|
|
159
|
+
// A lazy image that loaded after the probe pushes everything below it down, and a live
|
|
160
|
+
// page may change height between the two shots; then only the first screen still lines up.
|
|
161
|
+
const grew = fullPage && ((access.pageHeight > 0 && Math.abs(hidden.height / ratio - access.pageHeight) > 2) || hidden.height !== marked.height);
|
|
162
|
+
const reach = fullPage && !grew ? shotHeight : view.height;
|
|
163
|
+
const found = { measured: 0, low: [], outside: 0, moved: 0, unseen: 0, changed: 0,
|
|
164
|
+
unrecorded: Math.max(0, access.textOnPictures - access.photoText.length) };
|
|
165
|
+
for (const text of access.photoText) {
|
|
166
|
+
if (text.rects.some(([, top, , tall]) => top + tall > reach + 0.5 || top < -0.5)) {
|
|
167
|
+
if (grew && text.rects.every(([, top, , tall]) => top + tall <= shotHeight + 0.5)) found.moved += 1;
|
|
168
|
+
else found.outside += 1;
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
const [inkR, inkG, inkB, alpha] = text.ink;
|
|
172
|
+
const ratios = [];
|
|
173
|
+
let inside = false;
|
|
174
|
+
let around = 0;
|
|
175
|
+
let differ = 0;
|
|
176
|
+
const seen = new Set();
|
|
177
|
+
for (const [left, top, wide, tall] of text.rects) {
|
|
178
|
+
// Two CSS pixels of margin to each side, where an italic can reach past its box; none
|
|
179
|
+
// above or below, where the next line's letters are.
|
|
180
|
+
const x0 = Math.max(0, Math.floor((left - 2) * ratio));
|
|
181
|
+
const y0 = Math.max(0, Math.floor(top * ratio));
|
|
182
|
+
const x1 = Math.min(hidden.width, Math.ceil((left + wide + 2) * ratio));
|
|
183
|
+
const y1 = Math.min(hidden.height, Math.ceil((top + tall) * ratio));
|
|
184
|
+
if (x1 > x0 && y1 > y0) inside = true;
|
|
185
|
+
const step = (x1 - x0) * (y1 - y0) > 400000 ? 2 : 1;
|
|
186
|
+
for (let y = y0; y < y1; y += step) {
|
|
187
|
+
for (let x = x0; x < x1; x += step) {
|
|
188
|
+
if (seen.has(y * hidden.width + x)) continue;
|
|
189
|
+
seen.add(y * hidden.width + x);
|
|
190
|
+
const back = pixel(hidden, x, y);
|
|
191
|
+
const lit = pixel(marked, x, y);
|
|
192
|
+
// A letter is where the marked screenshot moved at least halfway from the
|
|
193
|
+
// background toward magenta. Where the background is itself near magenta, no
|
|
194
|
+
// letter can be told from it, and the pixel is left out.
|
|
195
|
+
const span = distance(back, MARK);
|
|
196
|
+
if (span < 60 || distance(lit, back) < span * 0.5 || distance(lit, MARK) >= span) {
|
|
197
|
+
// Around the letters the two screenshots should match.
|
|
198
|
+
around += 1;
|
|
199
|
+
if (distance(lit, back) > 24) differ += 1;
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
const behind = luminance(...back);
|
|
203
|
+
const ink = luminance(inkR * alpha + back[0] * (1 - alpha), inkG * alpha + back[1] * (1 - alpha), inkB * alpha + back[2] * (1 - alpha));
|
|
204
|
+
ratios.push((Math.max(behind, ink) + 0.05) / (Math.min(behind, ink) + 0.05));
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (!inside) { found.outside += 1; continue; }
|
|
209
|
+
// An image that loaded, or a slide that moved, between the two screenshots.
|
|
210
|
+
if (around && differ > around * 0.2) { found.changed += 1; continue; }
|
|
211
|
+
if (ratios.length < 8) { found.unseen += 1; continue; }
|
|
212
|
+
ratios.sort((a, b) => a - b);
|
|
213
|
+
const worst = ratios[Math.min(ratios.length - 1, Math.floor(ratios.length * (1 - cover)))];
|
|
214
|
+
found.measured += 1;
|
|
215
|
+
if (worst < text.need) found.low.push({ tell: text.tell, ratio: worst, need: text.need });
|
|
216
|
+
}
|
|
217
|
+
found.low.sort((a, b) => a.ratio - b.ratio);
|
|
218
|
+
return found;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const finite = (value) => typeof value === 'number' && Number.isFinite(value);
|
|
222
|
+
|
|
223
|
+
// What the probe records for one piece of text it could not measure on a solid background.
|
|
224
|
+
export function validPhotoText(list) {
|
|
225
|
+
return Array.isArray(list) && list.every((text) => Boolean(text) && typeof text === 'object' && typeof text.tell === 'string'
|
|
226
|
+
&& Array.isArray(text.ink) && text.ink.length === 4 && text.ink.every(finite) && text.ink[3] >= 0 && text.ink[3] <= 1
|
|
227
|
+
&& finite(text.need) && text.need > 0
|
|
228
|
+
&& Array.isArray(text.rects) && text.rects.length > 0
|
|
229
|
+
&& text.rects.every((rect) => Array.isArray(rect) && rect.length === 4 && rect.every(finite) && rect[2] > 0 && rect[3] > 0));
|
|
230
|
+
}
|
|
@@ -14,7 +14,7 @@ Establish behavior with checks actually run against current files. Follow the [h
|
|
|
14
14
|
3. **Exercise authority together.** A new protected consumer requires the existing authoritative state-changing entrypoint → existing status → new protected read/write operations in one named journey. Use query-aware isolated storage/session adapters and actual handler behavior, including conflicting canonical/legacy representations. Cover canonical-only, legacy-only, ordinary transition and applicable eligible/unauthenticated/other-resource controls. Reuse a shared authoritative resolver or explicit reconciliation. Declared Scout journey names must match the scenario record; do not merely flip an invented status flag.
|
|
15
15
|
4. **Exercise asynchronous identity.** Validate actor/resource/operation context before acknowledging sends or merging reads. Test mismatched send identity while props/caches stay unchanged, mismatched reads/resources, older operations/contexts and delayed empty polling after a confirmed send. Invalidate stale context without falsely acknowledging the draft. Keep loaded-empty distinct from not loaded. Authorization remains server-owned: client rejection cannot reverse a completed write; preventing switched-session writes requires a separately tested server-verified expected-session precondition.
|
|
16
16
|
5. **Run the actual journey.** Prefer an existing behavioral test, then a focused boundary test, CLI/API trial, or supported browser journey. Check reload/persistence, error/retry and relevant negative cases. For record recreation inspect stored fields/references/access metadata beyond the UI projection using the [preservation contract](../../docs/engineering/failure-handling.md#preserve-records-when-an-operation-recreates-them). Known CYC development fixtures demonstrate these contracts; they do not prove a model finds unseen defects.
|
|
17
|
-
6. **Keep browser auditing external.** Reuse the host's actual documented API and current handles; do not guess methods/variables. Declare proportional desktop/phone and applicable send/reload, empty/error, membership-loss, overflow, keyboard/history/focus checks. Run supplementary accessibility scanning from a separate harness/context with dependencies/artifacts in its designated scope. Never string-replace application layouts or rewrite CSS/build configuration for instrumentation. Batch independent observations only after known state and when host policy permits. Respect interruption and report incomplete coverage. For new visual design also apply the [generic-tells](../cyc-design/frontend-design/references/generic-tells.md#score-sheet) and [experience](../cyc-design/frontend-design/references/experience-review.md) checks
|
|
17
|
+
6. **Keep browser auditing external.** Reuse the host's actual documented API and current handles; do not guess methods/variables. Declare proportional desktop/phone and applicable send/reload, empty/error, membership-loss, overflow, keyboard/history/focus checks. Run supplementary accessibility scanning from a separate harness/context with dependencies/artifacts in its designated scope. Never string-replace application layouts or rewrite CSS/build configuration for instrumentation. Batch independent observations only after known state and when host policy permits. Respect interruption and report incomplete coverage. For new visual design also apply the [generic-tells](../cyc-design/frontend-design/references/generic-tells.md#score-sheet) and [experience](../cyc-design/frontend-design/references/experience-review.md) checks. Reopen the study decision in the project’s `design/decisions.md` (or its recorded run-local path). Follow the chosen item or criteria through the first action and return, and record observed desktop, phone and keyboard evidence there. Narrow repairs preserve identity.
|
|
18
18
|
7. **Finish context, proof and verification.** Finish first validates planned canonical records/index against actual target source, or returns needs-context with the remaining authoring input. Required feature learning cannot be none or only a general handoff. Finalize context before final checks; later edits require fresh verification. Structural validation cannot certify the explanation’s semantic truth. Use run finish --run ID --file FINISH.json --wait-ms 30000 as the normal entrypoint. Frozen proofCommands can target decisive tests on originals; --tests only chooses swapped files. Bug-fix/feature tests go red on originals; refactor characterization stays green. Keep original-only, original-plus-new-tests and candidate roles distinct. A broad original result is required to excuse a pre-existing broad failure; finish measures it when needed and can retain compatible focused treatment. Missing/corrupt originals or source conflicts halt safely; never manually reset source or locks. See [run-start originals](../../docs/runtime.md#run-start-originals).
|
|
19
19
|
Finish returns needs-proof-review when judgment is required, with receipt/failure IDs, errors, unknown boundaries and the exact bound continuation file. Supply categories/reasons there and call its command. Missing new interfaces/module-load/setup failures are not existing behavioral defects. Bug fixes need a decisive behavioral boundary; feature proof may establish a new interface. Inadequate/stale/foreign/placeholder judgments cannot complete. Non-testable exemptions and genuine unavailable-proof limits must be honest. Successful steps resume only while compatible. Final checks stay broad; deterministic receipt reuse needs explicit suitability and matching source/tests/config/dependency/toolchain/environment inputs. External/freshness-dependent checks remain nonreusable.
|
|
20
20
|
8. **Review the source and interpret results.** Check intent, consumers, conventions and the [principles](../../docs/principles.md); trace domain ownership and partial-effect/recovery boundaries. Prioritize demonstrated critical state/identity transitions before cosmetics, retaining history continuity and keyboard/return focus. Resolve or justify dismissing findings with evidence; open findings block. Capture before review and use the generated record template with actual evidence/identity or null. Bounded scoped review can survive an unrelated edit only with unchanged reviewed files, criteria and dependency/contract context. Unknown impact requires broader review; never relabel stale coverage as fresh. Final context/ledger/source edits invalidate affected evidence.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cyc-stack",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -44,6 +44,10 @@
|
|
|
44
44
|
"scripts/delegation.mjs",
|
|
45
45
|
"scripts/codex-host.mjs",
|
|
46
46
|
"scripts/swarm.mjs",
|
|
47
|
+
"scripts/queue.mjs",
|
|
48
|
+
"scripts/queue-board.mjs",
|
|
49
|
+
"scripts/hub.mjs",
|
|
50
|
+
"scripts/hub-page.mjs",
|
|
47
51
|
"scripts/run-worker.mjs",
|
|
48
52
|
"scripts/source-hash-worker.mjs",
|
|
49
53
|
"scripts/source-snapshot.mjs",
|
|
@@ -70,6 +74,7 @@
|
|
|
70
74
|
"docs/skill-craft.md",
|
|
71
75
|
"docs/validation.md",
|
|
72
76
|
"docs/work-assessments.md",
|
|
77
|
+
"docs/work-queue.md",
|
|
73
78
|
"docs/assets/cyc-method-library.svg",
|
|
74
79
|
"docs/assets/cyc-overview.svg",
|
|
75
80
|
"docs/assets/cyc-readme-banner.svg",
|
package/plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
3
|
"name": "cycstack",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.11.0",
|
|
5
5
|
"description": "Portable AI engineering workflows with shared project context and verifiable changes.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "CYC Stack contributors"
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
// The hub's one page. Self-contained: no font, script, image or request leaves this machine. Its
|
|
2
|
+
// script builds every element with textContent, so what an agent writes is shown, never run.
|
|
3
|
+
// Design decisions: docs/maintainers/hub-design.md.
|
|
4
|
+
export const hubPage = String.raw`<!doctype html>
|
|
5
|
+
<html lang="en">
|
|
6
|
+
<head>
|
|
7
|
+
<meta charset="utf-8">
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
9
|
+
<title>CYC hub</title>
|
|
10
|
+
<style>
|
|
11
|
+
:root{--paper:#F4F1EA;--surface:#FFFDF8;--ink:#1C1B18;--soft:#5A554C;--rule:#D9D2C3;--signal:#B4420F;--signal-wash:#FBE9DD;--builder:#0B5C63;--reviewer:#5A3E9B;--done:#1E6B41;
|
|
12
|
+
--display:"Bahnschrift","DIN Alternate","Avenir Next Condensed","Franklin Gothic Medium","Arial Narrow",sans-serif;--body:"Segoe UI Variable Text","Segoe UI",system-ui,-apple-system,"Helvetica Neue",sans-serif;--mono:ui-monospace,"Cascadia Mono",Consolas,Menlo,monospace}
|
|
13
|
+
@media (prefers-color-scheme:dark){:root{--paper:#151410;--surface:#1F1D18;--ink:#F1EDE3;--soft:#B3AC9D;--rule:#3A362D;--signal:#F59E5B;--signal-wash:#3A2415;--builder:#62CDD3;--reviewer:#BDA8F2;--done:#74DDA6}}
|
|
14
|
+
*{box-sizing:border-box}
|
|
15
|
+
html{background:var(--paper);color:var(--ink);font:16px/1.55 var(--body);-webkit-text-size-adjust:100%}
|
|
16
|
+
body{margin:0}
|
|
17
|
+
h1,h2,h3,p,ol{margin:0;padding:0}
|
|
18
|
+
ol{list-style:none}
|
|
19
|
+
a{color:inherit}
|
|
20
|
+
:focus-visible{outline:3px solid var(--signal);outline-offset:2px;border-radius:2px}
|
|
21
|
+
.skip{position:absolute;left:-999px;top:8px;background:var(--surface);padding:8px 12px;border:1px solid var(--rule)}
|
|
22
|
+
.skip:focus{left:8px;z-index:5}
|
|
23
|
+
.vh{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
|
|
24
|
+
.top{display:flex;flex-wrap:wrap;gap:8px 24px;align-items:center;justify-content:space-between;padding:14px clamp(16px,4vw,40px);border-bottom:1px solid var(--rule)}
|
|
25
|
+
.brand{display:flex;align-items:baseline;gap:12px;min-width:0}
|
|
26
|
+
.name{font:600 15px/1 var(--display);letter-spacing:.12em;text-transform:uppercase}
|
|
27
|
+
.project{color:var(--soft);font:14px var(--mono);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
28
|
+
.tools{display:flex;flex-wrap:wrap;gap:8px 16px;align-items:center}
|
|
29
|
+
.tools label{font-size:14px;color:var(--soft)}
|
|
30
|
+
select{font:14px var(--body);color:var(--ink);background:var(--surface);border:1px solid var(--rule);border-radius:4px;padding:6px 8px;max-width:min(60vw,320px)}
|
|
31
|
+
.live{display:flex;align-items:center;gap:8px;font-size:14px;color:var(--soft)}
|
|
32
|
+
.dot{width:9px;height:9px;border-radius:50%;background:var(--done)}
|
|
33
|
+
.live.lost{color:var(--signal)}
|
|
34
|
+
.live.lost .dot{background:var(--signal)}
|
|
35
|
+
main{padding:clamp(20px,4vw,40px);max-width:1280px;margin:0 auto}
|
|
36
|
+
.line{margin-bottom:clamp(24px,4vw,40px)}
|
|
37
|
+
#goal{font:600 clamp(26px,4.2vw,44px)/1.08 var(--display);letter-spacing:-.01em;max-width:22ch;text-wrap:balance;overflow-wrap:anywhere}
|
|
38
|
+
#line-state{margin-top:10px;color:var(--soft);font-size:15px}
|
|
39
|
+
#line-state b{color:var(--ink);font-weight:600}
|
|
40
|
+
.track{display:flex;margin-top:28px;overflow-x:auto;padding:6px 2px 10px}
|
|
41
|
+
.stop{flex:1 0 150px;position:relative;padding:34px 16px 0 0;min-width:0}
|
|
42
|
+
.stop::before{content:"";position:absolute;left:0;right:0;top:12px;height:2px;background:var(--rule)}
|
|
43
|
+
.stop:last-child::before{right:auto;width:26px}
|
|
44
|
+
.pin{position:absolute;left:0;top:0;width:26px;height:26px;border-radius:50%;background:var(--paper);border:2px solid var(--rule);display:grid;place-items:center;font:600 13px/1 var(--display);color:var(--soft)}
|
|
45
|
+
.stop.done .pin{background:var(--done);border-color:var(--done);color:var(--paper)}
|
|
46
|
+
.stop.done::before{background:var(--done)}
|
|
47
|
+
.stop.now .pin{background:var(--ink);border-color:var(--ink);color:var(--paper)}
|
|
48
|
+
.stop.now .pin::after{content:"";position:absolute;inset:-7px;border-radius:50%;border:2px solid var(--ink);opacity:.35;animation:pulse 1.8s ease-out infinite}
|
|
49
|
+
.stop.halt .pin{background:var(--signal);border-color:var(--signal);color:var(--paper)}
|
|
50
|
+
.stop.still .pin::after{display:none}
|
|
51
|
+
@keyframes pulse{from{transform:scale(.8);opacity:.5}to{transform:scale(1.25);opacity:0}}
|
|
52
|
+
.stop h3{font:600 17px/1.2 var(--display);letter-spacing:.01em;overflow-wrap:anywhere}
|
|
53
|
+
.stop .what{font-size:14px;color:var(--soft);margin-top:2px}
|
|
54
|
+
.stop.now .what,.stop.halt .what{color:var(--ink)}
|
|
55
|
+
.stop .more{font-size:13px;color:var(--soft);margin-top:2px}
|
|
56
|
+
.stop.halt .more{color:var(--signal)}
|
|
57
|
+
.floor{display:grid;grid-template-columns:minmax(0,1fr) minmax(260px,340px);grid-template-areas:"talk you" "talk log";grid-template-rows:auto 1fr;gap:32px clamp(24px,4vw,48px);align-items:start}
|
|
58
|
+
.talk{grid-area:talk}.you{grid-area:you}.log{grid-area:log}
|
|
59
|
+
h2{font:600 13px/1 var(--display);letter-spacing:.14em;text-transform:uppercase;color:var(--soft);padding-bottom:10px;border-bottom:1px solid var(--rule);margin-bottom:6px}
|
|
60
|
+
.talk{outline:none}
|
|
61
|
+
.msg{padding:16px 0 16px 16px;border-bottom:1px solid var(--rule);border-left:3px solid var(--rule);margin-left:1px;transition:background-color 1.6s}
|
|
62
|
+
.msg.builder{border-left-color:var(--builder)}
|
|
63
|
+
.msg.reviewer{border-left-color:var(--reviewer)}
|
|
64
|
+
.msg.person{border-left-color:var(--signal)}
|
|
65
|
+
.msg.fresh{background:var(--signal-wash)}
|
|
66
|
+
.who{display:flex;flex-wrap:wrap;gap:4px 10px;align-items:baseline;font-size:14px;color:var(--soft)}
|
|
67
|
+
.who strong{font:600 14px/1.2 var(--display);letter-spacing:.08em;text-transform:uppercase}
|
|
68
|
+
.builder .who strong{color:var(--builder)}
|
|
69
|
+
.reviewer .who strong{color:var(--reviewer)}
|
|
70
|
+
.person .who strong{color:var(--signal)}
|
|
71
|
+
.who time,.who .num{font:13px var(--mono);color:var(--soft)}
|
|
72
|
+
.who .num{margin-left:auto}
|
|
73
|
+
.re{margin-top:6px;font-size:14px;color:var(--soft);border-left:2px solid var(--rule);padding-left:10px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
74
|
+
.text{margin-top:8px;max-width:72ch;overflow-wrap:anywhere;white-space:pre-wrap}
|
|
75
|
+
.text code,.card code{font:.9em var(--mono);background:var(--surface);border:1px solid var(--rule);border-radius:3px;padding:0 4px}
|
|
76
|
+
.foot{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center;margin-top:10px}
|
|
77
|
+
.chip{font:600 12px/1 var(--display);letter-spacing:.08em;text-transform:uppercase;padding:5px 8px;border-radius:3px;border:1px solid var(--rule);color:var(--soft)}
|
|
78
|
+
.chip.open{border-color:var(--signal);color:var(--signal);background:var(--signal-wash)}
|
|
79
|
+
.chip.ok{border-color:var(--done);color:var(--done)}
|
|
80
|
+
.closed{font-size:14px;color:var(--soft)}
|
|
81
|
+
button{font:14px var(--body);color:var(--ink);background:none;border:1px solid var(--rule);border-radius:4px;padding:6px 10px;min-height:32px;cursor:pointer}
|
|
82
|
+
button:hover{border-color:var(--soft)}
|
|
83
|
+
.empty{padding:20px 0;color:var(--soft);max-width:52ch}
|
|
84
|
+
.card{padding:14px 0;border-bottom:1px solid var(--rule)}
|
|
85
|
+
.card .ask{font-weight:600}
|
|
86
|
+
.card .by{font-size:14px;color:var(--soft);margin-top:4px}
|
|
87
|
+
.card .by a{display:inline-block;min-width:24px;padding:3px 6px;margin:-3px 0;text-align:center}
|
|
88
|
+
.you.has h2{color:var(--signal);border-bottom-color:var(--signal)}
|
|
89
|
+
.how{font-size:14px;color:var(--soft);margin-top:12px}
|
|
90
|
+
#activity li{display:grid;grid-template-columns:auto minmax(0,1fr);gap:2px 12px;padding:9px 0;border-bottom:1px solid var(--rule);font-size:14px}
|
|
91
|
+
#activity time{font:13px var(--mono);color:var(--soft);padding-top:1px}
|
|
92
|
+
#activity b{font:600 13px/1.2 var(--display);letter-spacing:.06em;text-transform:uppercase}
|
|
93
|
+
.jump{position:sticky;bottom:16px;margin:16px auto 0;display:none;background:var(--ink);color:var(--paper);border-color:var(--ink)}
|
|
94
|
+
.jump.show{display:block}
|
|
95
|
+
.problem{margin-top:16px;padding:14px 16px;border:1px solid var(--signal);border-radius:4px;color:var(--signal);background:var(--signal-wash);max-width:72ch}
|
|
96
|
+
@media (max-width:860px){.floor{grid-template-columns:minmax(0,1fr);grid-template-areas:"you" "talk" "log";grid-template-rows:auto}.stop{flex-basis:132px}}
|
|
97
|
+
@media (prefers-reduced-motion:reduce){.stop.now .pin::after{animation:none}.msg{transition:none}}
|
|
98
|
+
</style>
|
|
99
|
+
</head>
|
|
100
|
+
<body>
|
|
101
|
+
<a class="skip" href="#talk">Skip to the conversation</a>
|
|
102
|
+
<header class="top">
|
|
103
|
+
<div class="brand"><span class="name">CYC hub</span><span class="project" id="project"></span></div>
|
|
104
|
+
<div class="tools">
|
|
105
|
+
<span id="picker" hidden><label for="queue">Queue</label> <select id="queue"></select></span>
|
|
106
|
+
<div class="live" id="live" role="status"><span class="dot" aria-hidden="true"></span><span id="live-text">Connecting</span></div>
|
|
107
|
+
</div>
|
|
108
|
+
</header>
|
|
109
|
+
<main>
|
|
110
|
+
<section class="line" aria-labelledby="goal">
|
|
111
|
+
<h1 id="goal">Opening the hub</h1>
|
|
112
|
+
<p id="line-state"></p>
|
|
113
|
+
<div id="problem" class="problem" hidden></div>
|
|
114
|
+
<ol id="units" class="track" aria-label="The line: each unit of work in order"></ol>
|
|
115
|
+
</section>
|
|
116
|
+
<div class="floor" id="floor" hidden>
|
|
117
|
+
<section class="you" id="you-box" aria-labelledby="you-h"><h2 id="you-h">Waiting on you</h2><div id="you"></div><p id="say" class="vh" role="status"></p></section>
|
|
118
|
+
<section id="talk" class="talk" aria-labelledby="talk-h" tabindex="-1">
|
|
119
|
+
<h2 id="talk-h">Conversation</h2>
|
|
120
|
+
<div id="messages" aria-live="polite" aria-relevant="additions"></div>
|
|
121
|
+
<button class="jump" id="jump" type="button">New messages below</button>
|
|
122
|
+
</section>
|
|
123
|
+
<section class="log" aria-labelledby="log-h"><h2 id="log-h">Activity</h2><ol id="activity"></ol></section>
|
|
124
|
+
</div>
|
|
125
|
+
</main>
|
|
126
|
+
<script>
|
|
127
|
+
(function () {
|
|
128
|
+
var byId = function (id) { return document.getElementById(id); };
|
|
129
|
+
// Characters that reverse or re-order the text around them are dropped: what is shown reads as written.
|
|
130
|
+
var plain = function (text) { return String(text).replace(/[\u202A-\u202E\u2066-\u2069]/g, ''); };
|
|
131
|
+
var el = function (tag, cls, text) { var node = document.createElement(tag); if (cls) node.className = cls; if (text !== undefined) node.textContent = plain(text); return node; };
|
|
132
|
+
var clock = function (iso) { var d = new Date(iso); return isNaN(d) ? '' : d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false }); };
|
|
133
|
+
// Words between a pair of backticks are shown as code, and one left without a partner is shown
|
|
134
|
+
// as it is. Everything is set as text, never as markup.
|
|
135
|
+
var mark = String.fromCharCode(96);
|
|
136
|
+
var prose = function (node, text) {
|
|
137
|
+
var parts = plain(text).split(mark); if (parts.length % 2 === 0) parts.push(parts.splice(-2).join(mark));
|
|
138
|
+
parts.forEach(function (part, i) { if (!part) return; node.appendChild(i % 2 ? el('code', '', part) : document.createTextNode(part)); }); return node;
|
|
139
|
+
};
|
|
140
|
+
var speaker = function (who) { return who.role === 'person' ? 'You' : who.role === 'reviewer' ? 'Reviewer' : 'Builder'; };
|
|
141
|
+
var listener = function (to) { return to.role === 'person' ? 'you' : to.role === 'all' ? 'everyone' : to.role === 'reviewer' ? 'the reviewer' : 'the builder of ' + to.unit; };
|
|
142
|
+
var said = function (m) {
|
|
143
|
+
var s = m.from.role === 'person' ? '' : 's';
|
|
144
|
+
if (m.kind === 'question') return 'ask' + s + ' ' + listener(m.to);
|
|
145
|
+
if (m.kind === 'finding') return 'found a problem, for ' + listener(m.to);
|
|
146
|
+
if (m.kind === 'notice') return m.topic === 'ready-for-review' ? 'asks for a review' : m.topic === 'review-done' ? 'signs off the review' : 'tell' + s + ' ' + listener(m.to);
|
|
147
|
+
return { fixed: 'fixed it', declined: 'declined it', assumed: 'went on with an assumption', withdrawn: 'took it back' }[m.disposition] || 'answer' + s + ' ' + listener(m.to);
|
|
148
|
+
};
|
|
149
|
+
var how = { fixed: 'Fixed', declined: 'Declined', assumed: 'Went on with an assumption', withdrawn: 'Taken back' };
|
|
150
|
+
var words = { done: 'Done', 'in-progress': 'In progress', ready: 'Next up', waiting: 'Waiting', halted: 'Halted: needs you', skipped: 'Skipped', cancelled: 'Cancelled' };
|
|
151
|
+
var lines = { ready: 'Ready for the next unit', 'in-progress': 'Work in progress', halted: 'Halted: a unit needs your decision', complete: 'Complete', ended: 'Nothing more can start', cancelled: 'Cancelled' };
|
|
152
|
+
var drawn = {}, shown = {}, keys = {}, first = true, lastSeen = 0, current = null, waited = 0, tag = '';
|
|
153
|
+
// A section is redrawn only when what it shows changed, so focus and a selection in it are kept.
|
|
154
|
+
var changed = function (name, data) { var key = JSON.stringify(data); if (keys[name] === key) return false; keys[name] = key; return true; };
|
|
155
|
+
|
|
156
|
+
function unitsOf(state) {
|
|
157
|
+
if (!changed('units', state.units)) return;
|
|
158
|
+
var list = byId('units'); list.textContent = '';
|
|
159
|
+
state.units.forEach(function (unit, index) {
|
|
160
|
+
var cls = unit.status === 'done' ? 'done' : unit.status === 'in-progress' ? (unit.paused ? 'now still' : 'now') : unit.status === 'halted' ? 'halt' : '';
|
|
161
|
+
var item = el('li', 'stop ' + cls);
|
|
162
|
+
var pin = el('span', 'pin', unit.status === 'done' ? '✓' : unit.status === 'halted' ? '!' : String(index + 1)); pin.setAttribute('aria-hidden', 'true');
|
|
163
|
+
item.appendChild(pin); item.appendChild(el('h3', '', unit.id));
|
|
164
|
+
item.appendChild(el('p', 'what', unit.paused ? 'Paused' + (unit.doing ? ' while ' + unit.doing : '') : unit.status === 'in-progress' && unit.doing ? 'In progress: ' + unit.doing : words[unit.status] || unit.status));
|
|
165
|
+
var more = unit.reason || (unit.waitsOn ? 'After ' + unit.waitsOn.join(', ') : unit.reviewer ? 'Reviewer ' + unit.reviewer : unit.attempts > 1 ? 'Attempt ' + unit.attempts : '');
|
|
166
|
+
if (more) item.appendChild(el('p', 'more', more));
|
|
167
|
+
if (unit.outcome) item.title = unit.outcome;
|
|
168
|
+
list.appendChild(item);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function footOf(m, node, waits) {
|
|
172
|
+
var foot = node.querySelector('.foot') || node.appendChild(el('div', 'foot'));
|
|
173
|
+
var long = node.querySelector('button'); foot.textContent = '';
|
|
174
|
+
if (m.open !== undefined) foot.appendChild(el('span', 'chip ' + (m.open ? 'open' : 'ok'), m.open ? (waits ? 'Open: waits on you' : 'Open') : (m.closed && how[m.closed.disposition]) || 'Answered'));
|
|
175
|
+
if (m.closed) foot.appendChild(el('span', 'closed', 'by ' + m.closed.by));
|
|
176
|
+
if (m.answeredLater) foot.appendChild(el('span', 'closed', 'Answered later by ' + m.answeredLater.by + ': ' + m.answeredLater.text));
|
|
177
|
+
if (long) foot.appendChild(long);
|
|
178
|
+
if (!foot.childNodes.length) foot.remove();
|
|
179
|
+
}
|
|
180
|
+
function messageOf(m, all) {
|
|
181
|
+
var node = el('article', 'msg ' + m.from.role); node.id = 'm' + m.id;
|
|
182
|
+
var who = el('p', 'who'); who.appendChild(el('strong', '', speaker(m.from) + (m.from.unit ? ' · ' + m.from.unit : '')));
|
|
183
|
+
who.appendChild(el('span', '', said(m) + (m.from.relayedBy ? ' (relayed by ' + m.from.relayedBy + ')' : '')));
|
|
184
|
+
var time = el('time', '', clock(m.at)); time.dateTime = m.at; who.appendChild(time); who.appendChild(el('span', 'num', '#' + m.id));
|
|
185
|
+
node.appendChild(who);
|
|
186
|
+
if (m.replyTo) { var about = all.filter(function (x) { return x.id === m.replyTo; })[0]; if (about) node.appendChild(el('p', 're', 'On #' + about.id + ': ' + about.text)); }
|
|
187
|
+
// Cut by whole characters, so a character stored as a pair is never split.
|
|
188
|
+
var limit = 420, chars = Array.from(m.text), long = chars.length > limit, open = false, text = el('p', 'text');
|
|
189
|
+
var draw = function () { text.textContent = ''; prose(text, long && !open ? chars.slice(0, limit).join('').replace(/\s+\S*$/, '') + ' …' : m.text); };
|
|
190
|
+
draw(); node.appendChild(text);
|
|
191
|
+
var foot = el('div', 'foot'); node.appendChild(foot);
|
|
192
|
+
if (long) { var more = el('button', '', 'Show all'); more.type = 'button'; more.setAttribute('aria-expanded', 'false'); more.addEventListener('click', function () { open = !open; draw(); more.textContent = open ? 'Show less' : 'Show all'; more.setAttribute('aria-expanded', String(open)); }); foot.appendChild(more); }
|
|
193
|
+
return node;
|
|
194
|
+
}
|
|
195
|
+
function talkOf(state) {
|
|
196
|
+
var box = byId('messages'), near = window.innerHeight + window.scrollY > document.body.scrollHeight - 240, added = 0;
|
|
197
|
+
if (!state.messages.length) { if (!box.querySelector('.empty')) { box.textContent = ''; drawn = {}; box.appendChild(el('p', 'empty', 'No messages yet. Agents post here when they ask something, find a problem or answer one.')); } return; }
|
|
198
|
+
var none = box.querySelector('.empty'); if (none) none.remove();
|
|
199
|
+
state.messages.forEach(function (m) {
|
|
200
|
+
var waits = state.waitingOnYou.indexOf(m.id) >= 0, key = JSON.stringify([m.open, m.closed, m.answeredLater, waits]);
|
|
201
|
+
if (!drawn[m.id]) { var node = messageOf(m, state.messages); box.appendChild(node); drawn[m.id] = node; added++; if (!first) { node.classList.add('fresh'); setTimeout(function () { node.classList.remove('fresh'); }, 2400); } }
|
|
202
|
+
if (shown[m.id] !== key) { footOf(m, drawn[m.id], waits); shown[m.id] = key; }
|
|
203
|
+
});
|
|
204
|
+
if (added && !first) { if (near) drawn[state.messages[state.messages.length - 1].id].scrollIntoView({ block: 'end', behavior: matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth' }); else byId('jump').classList.add('show'); }
|
|
205
|
+
}
|
|
206
|
+
function youOf(state) {
|
|
207
|
+
var waiting = state.messages.filter(function (m) { return state.waitingOnYou.indexOf(m.id) >= 0; });
|
|
208
|
+
if (!changed('you', waiting)) return;
|
|
209
|
+
var box = byId('you'); box.textContent = '';
|
|
210
|
+
if (!first && waiting.length > waited) byId('say').textContent = waiting.length === 1 ? 'One item now waits on you.' : waiting.length + ' items now wait on you.';
|
|
211
|
+
waited = waiting.length;
|
|
212
|
+
byId('you-box').classList.toggle('has', waiting.length > 0);
|
|
213
|
+
if (!waiting.length) { box.appendChild(el('p', 'empty', 'Nothing is waiting on you.')); return; }
|
|
214
|
+
waiting.forEach(function (m) {
|
|
215
|
+
var card = el('div', 'card'); prose(card.appendChild(el('p', 'ask')), m.text);
|
|
216
|
+
var by = el('p', 'by'); var link = el('a', '', '#' + m.id); link.href = '#m' + m.id; by.appendChild(document.createTextNode((m.kind === 'finding' ? 'A problem found by ' : 'Asked by ') + speaker(m.from).toLowerCase() + (m.from.unit ? ' of ' + m.from.unit : '') + ', ')); by.appendChild(link);
|
|
217
|
+
card.appendChild(by); box.appendChild(card);
|
|
218
|
+
});
|
|
219
|
+
box.appendChild(el('p', 'how', 'To answer, tell your agent what you decided. It posts your answer here.'));
|
|
220
|
+
}
|
|
221
|
+
function logOf(state) {
|
|
222
|
+
var recent = state.activity.slice(0, 14);
|
|
223
|
+
if (!changed('log', recent)) return;
|
|
224
|
+
var list = byId('activity'); list.textContent = '';
|
|
225
|
+
if (!recent.length) { list.appendChild(el('li', 'empty', 'No run has started yet.')); return; }
|
|
226
|
+
recent.forEach(function (a) { var item = el('li'); var time = el('time', '', clock(a.at)); time.dateTime = a.at; item.appendChild(time); var what = el('span'); what.appendChild(el('b', '', a.unit)); what.appendChild(document.createTextNode(' ' + a.text)); item.appendChild(what); list.appendChild(item); });
|
|
227
|
+
}
|
|
228
|
+
function pickerOf(state) {
|
|
229
|
+
var picker = byId('picker'), select = byId('queue');
|
|
230
|
+
picker.hidden = state.queues.length < 2;
|
|
231
|
+
if (changed('queues', state.queues)) { select.textContent = ''; state.queues.slice().reverse().forEach(function (q) { var option = el('option', '', q.goal + (q.cancelled ? ' (cancelled)' : '')); option.value = q.id; select.appendChild(option); }); }
|
|
232
|
+
if (state.queue) select.value = state.queue.id;
|
|
233
|
+
}
|
|
234
|
+
function show(state) {
|
|
235
|
+
byId('project').textContent = state.project;
|
|
236
|
+
pickerOf(state);
|
|
237
|
+
var problem = byId('problem'), queue = state.queue;
|
|
238
|
+
problem.hidden = true;
|
|
239
|
+
if ((queue ? queue.id : null) !== current) { current = queue ? queue.id : null; byId('messages').textContent = ''; drawn = {}; shown = {}; keys = {}; first = true; waited = 0; byId('jump').classList.remove('show'); }
|
|
240
|
+
if (!queue) { byId('goal').textContent = 'No work queue yet'; byId('line-state').textContent = 'When your agent plans work as a queue, each unit and everything the agents say to each other appears here.'; byId('units').textContent = ''; byId('floor').hidden = true; return; }
|
|
241
|
+
byId('goal').textContent = plain(queue.goal || 'Work queue');
|
|
242
|
+
if (queue.error) { byId('line-state').textContent = ''; problem.hidden = false; problem.textContent = 'This queue cannot be read: ' + queue.error; byId('units').textContent = ''; byId('floor').hidden = true; return; }
|
|
243
|
+
var status = byId('line-state'); status.textContent = ''; status.appendChild(el('b', '', lines[queue.line] || queue.line)); status.appendChild(document.createTextNode(' · ' + queue.done + ' of ' + queue.total + ' units done'));
|
|
244
|
+
if (queue.boardError) { problem.hidden = false; problem.textContent = 'The conversation cannot be read: ' + queue.boardError; }
|
|
245
|
+
byId('floor').hidden = false;
|
|
246
|
+
unitsOf(state); talkOf(state); youOf(state); logOf(state);
|
|
247
|
+
document.title = (state.waitingOnYou.length ? '(' + state.waitingOnYou.length + ') ' : '') + 'CYC hub · ' + state.project;
|
|
248
|
+
first = false;
|
|
249
|
+
}
|
|
250
|
+
function live(ok, text) { var box = byId('live'); box.classList.toggle('lost', !ok); if (byId('live-text').textContent !== text) byId('live-text').textContent = text; }
|
|
251
|
+
function tick() {
|
|
252
|
+
// The hub answers "unchanged" to the tag of what is already shown, so a quiet queue costs nothing to watch.
|
|
253
|
+
var options = { cache: 'no-store', headers: tag ? { 'If-None-Match': tag } : {} };
|
|
254
|
+
if (typeof AbortSignal !== 'undefined' && AbortSignal.timeout) options.signal = AbortSignal.timeout(8000);
|
|
255
|
+
fetch('/api/state' + location.search, options).then(function (reply) {
|
|
256
|
+
if (reply.status === 304) return null;
|
|
257
|
+
return reply.json().then(function (state) { if (!reply.ok) { var fault = new Error(state.error || 'The hub could not read the project.'); fault.served = true; throw fault; } tag = reply.headers.get('ETag') || ''; return state; });
|
|
258
|
+
}).then(function (state) { lastSeen = Date.now(); live(true, 'Live'); if (state) show(state); })
|
|
259
|
+
.catch(function (error) {
|
|
260
|
+
tag = '';
|
|
261
|
+
// The hub answered and named a fault: it is running, and the project is what it cannot read.
|
|
262
|
+
if (error && error.served) { live(false, 'The hub is running but cannot read this project'); byId('problem').hidden = false; byId('problem').textContent = plain(error.message); return; }
|
|
263
|
+
live(false, Date.now() - lastSeen > 4000 || !lastSeen ? 'Lost contact with the hub. Is cyc hub still running?' : 'Reconnecting');
|
|
264
|
+
})
|
|
265
|
+
.then(function () { setTimeout(tick, document.hidden ? 5000 : 1500); });
|
|
266
|
+
}
|
|
267
|
+
byId('queue').addEventListener('change', function () { location.search = '?queue=' + encodeURIComponent(byId('queue').value); });
|
|
268
|
+
byId('jump').addEventListener('click', function () { byId('jump').classList.remove('show'); var last = byId('messages').lastElementChild; if (last) last.scrollIntoView({ block: 'end' }); });
|
|
269
|
+
window.addEventListener('scroll', function () { if (window.innerHeight + window.scrollY > document.body.scrollHeight - 240) byId('jump').classList.remove('show'); }, { passive: true });
|
|
270
|
+
tick();
|
|
271
|
+
})();
|
|
272
|
+
</script>
|
|
273
|
+
</body>
|
|
274
|
+
</html>
|
|
275
|
+
`;
|