devcontour-harness-ui 0.0.0-stage → 0.1.0-alpha.2
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/LICENSE +21 -0
- package/README.md +143 -2
- package/dist/app/assets/index-Det9VYJC.css +1 -0
- package/dist/app/assets/index-veveke8K.js +9 -0
- package/dist/app/index.html +13 -0
- package/dist/demo/ru/view.sample.json +483 -0
- package/dist/demo/ru/work.accepted.sample.json +187 -0
- package/dist/demo/ru/work.sample.json +171 -0
- package/dist/demo/view.sample.json +483 -0
- package/dist/demo/work.accepted.sample.json +187 -0
- package/dist/demo/work.sample.json +171 -0
- package/dist/lib/cli.d.ts +2 -0
- package/dist/lib/cli.js +160 -0
- package/dist/lib/components/Activity.d.ts +13 -0
- package/dist/lib/components/Activity.js +19 -0
- package/dist/lib/components/Decisions.d.ts +6 -0
- package/dist/lib/components/Decisions.js +19 -0
- package/dist/lib/components/Health.d.ts +8 -0
- package/dist/lib/components/Health.js +24 -0
- package/dist/lib/components/History.d.ts +32 -0
- package/dist/lib/components/History.js +129 -0
- package/dist/lib/components/Overview.d.ts +19 -0
- package/dist/lib/components/Overview.js +54 -0
- package/dist/lib/components/Reviews.d.ts +23 -0
- package/dist/lib/components/Reviews.js +22 -0
- package/dist/lib/components/Settings.d.ts +21 -0
- package/dist/lib/components/Settings.js +77 -0
- package/dist/lib/components/WorkDetail.d.ts +18 -0
- package/dist/lib/components/WorkDetail.js +96 -0
- package/dist/lib/components/common.d.ts +71 -0
- package/dist/lib/components/common.js +85 -0
- package/dist/lib/index.d.ts +10 -0
- package/dist/lib/index.js +12 -0
- package/dist/lib/model/compat.d.ts +36 -0
- package/dist/lib/model/compat.js +365 -0
- package/dist/lib/model/dict.d.ts +387 -0
- package/dist/lib/model/dict.js +1119 -0
- package/dist/lib/model/format.d.ts +34 -0
- package/dist/lib/model/format.js +88 -0
- package/dist/lib/model/i18n.d.ts +44 -0
- package/dist/lib/model/i18n.js +109 -0
- package/dist/lib/model/index.d.ts +6 -0
- package/dist/lib/model/index.js +8 -0
- package/dist/lib/model/source.d.ts +16 -0
- package/dist/lib/model/source.js +57 -0
- package/dist/lib/model/view.d.ts +474 -0
- package/dist/lib/model/view.js +10 -0
- package/dist/lib/server/harness.d.ts +44 -0
- package/dist/lib/server/harness.js +172 -0
- package/dist/lib/server/serve.d.ts +62 -0
- package/dist/lib/server/serve.js +302 -0
- package/dist/lib/styles.css +485 -0
- package/docs/design.md +1689 -0
- package/docs/harness-proposals.md +560 -0
- package/docs/release-notes/0.1.0-alpha.1.md +96 -0
- package/docs/release-notes/0.1.0-alpha.2.md +218 -0
- package/package.json +75 -4
- package/skills/harness-ui/SKILL.md +246 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
{
|
|
2
|
+
"viewVersion": 1,
|
|
3
|
+
"viewRevision": 0,
|
|
4
|
+
"generatedAt": "2026-11-19T12:00:00.000Z",
|
|
5
|
+
"source": {
|
|
6
|
+
"producer": "fixture",
|
|
7
|
+
"producerVersion": "0.0.0",
|
|
8
|
+
"stateVersion": 1,
|
|
9
|
+
"token": "fixture-1"
|
|
10
|
+
},
|
|
11
|
+
"work": {
|
|
12
|
+
"id": "add-greeting",
|
|
13
|
+
"graphId": "g1",
|
|
14
|
+
"title": "Add greet(name)",
|
|
15
|
+
"status": "done",
|
|
16
|
+
"stage": {
|
|
17
|
+
"name": "done",
|
|
18
|
+
"next": []
|
|
19
|
+
},
|
|
20
|
+
"attempts": {
|
|
21
|
+
"used": 1,
|
|
22
|
+
"max": 3,
|
|
23
|
+
"left": 2,
|
|
24
|
+
"failed": 0,
|
|
25
|
+
"interrupted": 0,
|
|
26
|
+
"rechecks": 0,
|
|
27
|
+
"neutral": {
|
|
28
|
+
"used": 0,
|
|
29
|
+
"max": 3
|
|
30
|
+
},
|
|
31
|
+
"line": "1 attempt, accepted on the first"
|
|
32
|
+
},
|
|
33
|
+
"blockers": [],
|
|
34
|
+
"spend": {
|
|
35
|
+
"calls": 3,
|
|
36
|
+
"usd": {
|
|
37
|
+
"value": 1.92,
|
|
38
|
+
"bound": "exact"
|
|
39
|
+
},
|
|
40
|
+
"durationMs": 840000
|
|
41
|
+
},
|
|
42
|
+
"resultSha": "3b1f9e0c2a7d",
|
|
43
|
+
"target": {
|
|
44
|
+
"repositoryId": "app",
|
|
45
|
+
"ref": "refs/heads/harness/accepted",
|
|
46
|
+
"acceptedSha": "3b1f9e0c2a7d",
|
|
47
|
+
"remote": {
|
|
48
|
+
"state": "unknown",
|
|
49
|
+
"reason": "the remote-tracking ref is not read by this harness version"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"attempts": [
|
|
54
|
+
{
|
|
55
|
+
"attempt": 1,
|
|
56
|
+
"status": "succeeded",
|
|
57
|
+
"runtime": "claude",
|
|
58
|
+
"model": "example-writer",
|
|
59
|
+
"startedAt": "2026-11-19T11:00:00.000Z",
|
|
60
|
+
"finishedAt": "2026-11-19T11:14:00.000Z",
|
|
61
|
+
"stages": [
|
|
62
|
+
{
|
|
63
|
+
"stage": "prepare",
|
|
64
|
+
"durationMs": 20000,
|
|
65
|
+
"outcome": "passed"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"stage": "writer",
|
|
69
|
+
"durationMs": 540000,
|
|
70
|
+
"outcome": "passed"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"stage": "gates",
|
|
74
|
+
"durationMs": 90000,
|
|
75
|
+
"outcome": "passed"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"stage": "review",
|
|
79
|
+
"durationMs": 150000,
|
|
80
|
+
"outcome": "passed"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"stage": "integration",
|
|
84
|
+
"durationMs": 40000,
|
|
85
|
+
"outcome": "passed"
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"verification": [
|
|
91
|
+
{
|
|
92
|
+
"gate": "lint",
|
|
93
|
+
"kind": "gate",
|
|
94
|
+
"phase": "candidate",
|
|
95
|
+
"result": "passed",
|
|
96
|
+
"how": "executed",
|
|
97
|
+
"by": "harness",
|
|
98
|
+
"attempt": 1,
|
|
99
|
+
"at": "2026-11-19T11:10:30.000Z"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"gate": "unit",
|
|
103
|
+
"kind": "gate",
|
|
104
|
+
"phase": "candidate",
|
|
105
|
+
"result": "passed",
|
|
106
|
+
"how": "executed",
|
|
107
|
+
"by": "harness",
|
|
108
|
+
"attempt": 1,
|
|
109
|
+
"at": "2026-11-19T11:11:00.000Z"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"gate": "unit",
|
|
113
|
+
"kind": "gate",
|
|
114
|
+
"phase": "integration",
|
|
115
|
+
"result": "reused",
|
|
116
|
+
"how": "reused",
|
|
117
|
+
"attempt": 1,
|
|
118
|
+
"at": "2026-11-19T11:13:40.000Z"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"gate": "add-greeting",
|
|
122
|
+
"kind": "review",
|
|
123
|
+
"result": "passed",
|
|
124
|
+
"how": "read",
|
|
125
|
+
"by": "codex",
|
|
126
|
+
"attempt": 1,
|
|
127
|
+
"at": "2026-11-19T11:13:00.000Z"
|
|
128
|
+
}
|
|
129
|
+
],
|
|
130
|
+
"reviews": [
|
|
131
|
+
{
|
|
132
|
+
"kind": "plan",
|
|
133
|
+
"subject": "g1",
|
|
134
|
+
"approved": true,
|
|
135
|
+
"rounds": {
|
|
136
|
+
"used": 2,
|
|
137
|
+
"max": 6
|
|
138
|
+
},
|
|
139
|
+
"open": {
|
|
140
|
+
"blocking": 0,
|
|
141
|
+
"notes": 0
|
|
142
|
+
},
|
|
143
|
+
"accepted": 1,
|
|
144
|
+
"reviewer": {
|
|
145
|
+
"runtime": "codex"
|
|
146
|
+
},
|
|
147
|
+
"sameVendor": false,
|
|
148
|
+
"spend": {
|
|
149
|
+
"calls": 2,
|
|
150
|
+
"usd": {
|
|
151
|
+
"value": 0.6,
|
|
152
|
+
"bound": "exact"
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
"findings": [
|
|
156
|
+
{
|
|
157
|
+
"id": "F1",
|
|
158
|
+
"severity": "high",
|
|
159
|
+
"status": "closed",
|
|
160
|
+
"rounds": 1
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"id": "F2",
|
|
164
|
+
"severity": "note",
|
|
165
|
+
"status": "accepted-limitation",
|
|
166
|
+
"rounds": 2,
|
|
167
|
+
"disposition": {
|
|
168
|
+
"decision": "accepted-limitation",
|
|
169
|
+
"by": "lead",
|
|
170
|
+
"round": 2
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
],
|
|
174
|
+
"line": "plan approved after 2 rounds, 1 note accepted as a limitation"
|
|
175
|
+
}
|
|
176
|
+
],
|
|
177
|
+
"questions": [],
|
|
178
|
+
"drift": {
|
|
179
|
+
"workId": "add-greeting",
|
|
180
|
+
"repositoryId": "app",
|
|
181
|
+
"ref": "refs/heads/harness/accepted",
|
|
182
|
+
"acceptedSha": "3b1f9e0c2a7d",
|
|
183
|
+
"head": "9c04d1aa77e2",
|
|
184
|
+
"commitsSinceAccepted": 2,
|
|
185
|
+
"filesSinceAccepted": 3
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
{
|
|
2
|
+
"viewVersion": 1,
|
|
3
|
+
"viewRevision": 0,
|
|
4
|
+
"generatedAt": "2026-11-19T12:00:00.000Z",
|
|
5
|
+
"source": {
|
|
6
|
+
"producer": "fixture",
|
|
7
|
+
"producerVersion": "0.0.0",
|
|
8
|
+
"stateVersion": 1,
|
|
9
|
+
"token": "fixture-1"
|
|
10
|
+
},
|
|
11
|
+
"work": {
|
|
12
|
+
"id": "locale-format",
|
|
13
|
+
"graphId": "g1",
|
|
14
|
+
"title": "Format dates by locale",
|
|
15
|
+
"status": "verifying",
|
|
16
|
+
"stage": {
|
|
17
|
+
"name": "gates",
|
|
18
|
+
"step": "candidate-test:unit",
|
|
19
|
+
"since": "2026-11-19T11:52:10.000Z",
|
|
20
|
+
"next": ["review", "integration"],
|
|
21
|
+
"typical": {
|
|
22
|
+
"p50Ms": 300000,
|
|
23
|
+
"p90Ms": 720000,
|
|
24
|
+
"samples": 6
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"attempts": {
|
|
28
|
+
"used": 2,
|
|
29
|
+
"max": 3,
|
|
30
|
+
"left": 1,
|
|
31
|
+
"failed": 1,
|
|
32
|
+
"interrupted": 0,
|
|
33
|
+
"rechecks": 1,
|
|
34
|
+
"neutral": {
|
|
35
|
+
"used": 0,
|
|
36
|
+
"max": 3
|
|
37
|
+
},
|
|
38
|
+
"line": "2 attempts: 1 failed (check), 1 running; 1 left",
|
|
39
|
+
"lastFailure": {
|
|
40
|
+
"attempt": 1,
|
|
41
|
+
"bucket": "defect",
|
|
42
|
+
"plain": "a check failed: lint found an unused import",
|
|
43
|
+
"at": "2026-11-19T11:40:30.000Z"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"liveness": "active",
|
|
47
|
+
"runtime": "claude",
|
|
48
|
+
"model": "example-writer",
|
|
49
|
+
"blockers": [],
|
|
50
|
+
"spend": {
|
|
51
|
+
"calls": 5,
|
|
52
|
+
"usd": {
|
|
53
|
+
"value": 3.4,
|
|
54
|
+
"bound": "lower"
|
|
55
|
+
},
|
|
56
|
+
"durationMs": 1900000
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"attempts": [
|
|
60
|
+
{
|
|
61
|
+
"attempt": 2,
|
|
62
|
+
"status": "active",
|
|
63
|
+
"runtime": "claude",
|
|
64
|
+
"model": "example-writer",
|
|
65
|
+
"startedAt": "2026-11-19T11:41:00.000Z",
|
|
66
|
+
"stages": [
|
|
67
|
+
{
|
|
68
|
+
"stage": "prepare",
|
|
69
|
+
"durationMs": 20000,
|
|
70
|
+
"outcome": "passed"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"stage": "writer",
|
|
74
|
+
"durationMs": 600000,
|
|
75
|
+
"outcome": "passed"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"stage": "gates"
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"attempt": 1,
|
|
84
|
+
"status": "failed",
|
|
85
|
+
"failureBucket": "defect",
|
|
86
|
+
"runtime": "claude",
|
|
87
|
+
"model": "example-writer",
|
|
88
|
+
"startedAt": "2026-11-19T11:28:00.000Z",
|
|
89
|
+
"finishedAt": "2026-11-19T11:40:30.000Z",
|
|
90
|
+
"stages": [
|
|
91
|
+
{
|
|
92
|
+
"stage": "prepare",
|
|
93
|
+
"durationMs": 15000,
|
|
94
|
+
"outcome": "passed"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"stage": "writer",
|
|
98
|
+
"durationMs": 690000,
|
|
99
|
+
"outcome": "passed"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"stage": "gates",
|
|
103
|
+
"durationMs": 45000,
|
|
104
|
+
"outcome": "failed"
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
"verification": [
|
|
110
|
+
{
|
|
111
|
+
"gate": "lint",
|
|
112
|
+
"kind": "gate",
|
|
113
|
+
"phase": "candidate",
|
|
114
|
+
"result": "passed",
|
|
115
|
+
"how": "executed",
|
|
116
|
+
"by": "harness",
|
|
117
|
+
"attempt": 2,
|
|
118
|
+
"at": "2026-11-19T11:51:40.000Z"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"gate": "typecheck",
|
|
122
|
+
"kind": "gate",
|
|
123
|
+
"phase": "integration",
|
|
124
|
+
"result": "reused",
|
|
125
|
+
"how": "reused",
|
|
126
|
+
"attempt": 2,
|
|
127
|
+
"at": "2026-11-19T11:39:50.000Z"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"gate": "unit",
|
|
131
|
+
"kind": "gate",
|
|
132
|
+
"phase": "candidate",
|
|
133
|
+
"result": "not-run",
|
|
134
|
+
"how": "not-checked",
|
|
135
|
+
"attempt": 2
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"gate": "g1",
|
|
139
|
+
"kind": "review",
|
|
140
|
+
"result": "passed",
|
|
141
|
+
"how": "read",
|
|
142
|
+
"by": "codex",
|
|
143
|
+
"attempt": 2,
|
|
144
|
+
"at": "2026-11-19T11:10:00.000Z"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"gate": "e2e",
|
|
148
|
+
"kind": "gate",
|
|
149
|
+
"phase": "candidate",
|
|
150
|
+
"result": "skipped",
|
|
151
|
+
"how": "not-checked",
|
|
152
|
+
"attempt": 2
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
"reviews": [],
|
|
156
|
+
"questions": [
|
|
157
|
+
{
|
|
158
|
+
"requestId": "q-12",
|
|
159
|
+
"workId": "locale-format",
|
|
160
|
+
"state": "delivered",
|
|
161
|
+
"version": 1,
|
|
162
|
+
"severity": 6,
|
|
163
|
+
"answerableBy": "operator-or-lead",
|
|
164
|
+
"impact": "technical",
|
|
165
|
+
"plain": "Nothing changes for the user: dates look the same.",
|
|
166
|
+
"answeredBy": "lead",
|
|
167
|
+
"title": "Which date library should the formatter use?",
|
|
168
|
+
"createdAt": "2026-11-19T11:25:00.000Z"
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
}
|
package/dist/lib/cli.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// devcontour-harness-ui CLI: serves the read-only operator panel on loopback.
|
|
3
|
+
// stdout: one JSON line once listening ({ ok, url, port, readOnly }) or an
|
|
4
|
+
// error envelope; human hints go to stderr. Exit codes follow the harness:
|
|
5
|
+
// 0 success, 2 invalid input, 3 refusal, 4 infrastructure.
|
|
6
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
7
|
+
import { dirname, join, resolve } from 'node:path';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import { parseArgs } from 'node:util';
|
|
10
|
+
import { langOf } from "./model/i18n.js";
|
|
11
|
+
import { HarnessUnavailable, probeHarness } from "./server/harness.js";
|
|
12
|
+
import { ServeError, startServer } from "./server/serve.js";
|
|
13
|
+
/** Package root: the nearest ancestor whose package.json is this package. */
|
|
14
|
+
function packageRoot() {
|
|
15
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
16
|
+
for (;;) {
|
|
17
|
+
const file = join(dir, 'package.json');
|
|
18
|
+
if (existsSync(file) &&
|
|
19
|
+
JSON.parse(readFileSync(file, 'utf8')).name === 'devcontour-harness-ui') {
|
|
20
|
+
return dir;
|
|
21
|
+
}
|
|
22
|
+
const up = dirname(dir);
|
|
23
|
+
if (up === dir)
|
|
24
|
+
throw new Error('package root of devcontour-harness-ui not found');
|
|
25
|
+
dir = up;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const usage = `Usage: devcontour-harness-ui (--view <file> | --demo | --state <dir> [--policy <file>])
|
|
29
|
+
[--lang ru|en] [--harness <bin>] [--port N] [--host 127.0.0.1]
|
|
30
|
+
|
|
31
|
+
--view <file> operator view JSON (from \`harness view\`), re-read on each request
|
|
32
|
+
--demo serve the bundled sample view
|
|
33
|
+
--state <dir> compute the view with the installed \`harness view\` on each request
|
|
34
|
+
(devcontour-harness 0.1.0-alpha.55 or newer)
|
|
35
|
+
--policy <file> policy for --state; needed while the state has no binding
|
|
36
|
+
--lang ru|en language of harness texts when the page does not ask for one;
|
|
37
|
+
default from LC_ALL, LC_MESSAGES or LANG
|
|
38
|
+
--harness <bin> harness executable for --state (default: harness on PATH)
|
|
39
|
+
--port N exact port; busy = error. Without it ports 4790-4809 are probed
|
|
40
|
+
--host H loopback only: 127.0.0.1 (default), ::1 or localhost
|
|
41
|
+
--version print the package version
|
|
42
|
+
`;
|
|
43
|
+
function fail(code, message, exit) {
|
|
44
|
+
process.stdout.write(JSON.stringify({ ok: false, error: { code, message } }) + '\n');
|
|
45
|
+
process.stderr.write(message + '\n');
|
|
46
|
+
process.exit(exit);
|
|
47
|
+
}
|
|
48
|
+
async function main() {
|
|
49
|
+
let args;
|
|
50
|
+
try {
|
|
51
|
+
args = parseArgs({
|
|
52
|
+
options: {
|
|
53
|
+
view: { type: 'string' },
|
|
54
|
+
demo: { type: 'boolean' },
|
|
55
|
+
state: { type: 'string' },
|
|
56
|
+
policy: { type: 'string' },
|
|
57
|
+
lang: { type: 'string' },
|
|
58
|
+
harness: { type: 'string' },
|
|
59
|
+
port: { type: 'string' },
|
|
60
|
+
host: { type: 'string' },
|
|
61
|
+
version: { type: 'boolean' },
|
|
62
|
+
help: { type: 'boolean' },
|
|
63
|
+
},
|
|
64
|
+
strict: true,
|
|
65
|
+
}).values;
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
fail('INVALID_INPUT', err.message + '\n' + usage, 2);
|
|
69
|
+
}
|
|
70
|
+
const root = packageRoot();
|
|
71
|
+
const version = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')).version;
|
|
72
|
+
if (args.help)
|
|
73
|
+
return void process.stdout.write(usage);
|
|
74
|
+
if (args.version)
|
|
75
|
+
return void process.stdout.write(version + '\n');
|
|
76
|
+
if (args.lang !== undefined && args.lang !== 'ru' && args.lang !== 'en')
|
|
77
|
+
fail('INVALID_INPUT', `--lang: expected ru or en, got ${args.lang}.`, 2);
|
|
78
|
+
const sources = [args.view !== undefined, args.demo === true, args.state !== undefined];
|
|
79
|
+
if (sources.filter(Boolean).length > 1)
|
|
80
|
+
fail('INVALID_INPUT', 'Pass only one of --view, --demo and --state.\n' + usage, 2);
|
|
81
|
+
if (args.policy !== undefined && args.state === undefined)
|
|
82
|
+
fail('INVALID_INPUT', '--policy needs --state.\n' + usage, 2);
|
|
83
|
+
if (args.harness !== undefined && args.state === undefined)
|
|
84
|
+
fail('INVALID_INPUT', '--harness needs --state.\n' + usage, 2);
|
|
85
|
+
if (!sources.some(Boolean))
|
|
86
|
+
fail('INVALID_INPUT', 'Pass --view <file>, --demo or --state <dir>.\n' + usage, 2);
|
|
87
|
+
const lang = args.lang === 'ru' || args.lang === 'en'
|
|
88
|
+
? args.lang
|
|
89
|
+
: langOf([process.env.LC_ALL, process.env.LC_MESSAGES, process.env.LANG].find((v) => typeof v === 'string' && v.trim() !== ''));
|
|
90
|
+
let source;
|
|
91
|
+
if (args.state !== undefined) {
|
|
92
|
+
const bin = args.harness ?? 'harness';
|
|
93
|
+
let support;
|
|
94
|
+
try {
|
|
95
|
+
support = await probeHarness(bin);
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
if (!(err instanceof HarnessUnavailable))
|
|
99
|
+
throw err;
|
|
100
|
+
fail('HARNESS_VIEW_UNAVAILABLE', `${err.message} --state needs devcontour-harness 0.1.0-alpha.55 or newer ` +
|
|
101
|
+
'(pass --harness <bin> if it is not on PATH), or write the view to a file and pass --view <file>.', 2);
|
|
102
|
+
}
|
|
103
|
+
if (!support.view)
|
|
104
|
+
fail('HARNESS_VIEW_UNAVAILABLE', `The installed harness${support.version ? ' ' + support.version : ''} has no \`harness view\`. ` +
|
|
105
|
+
'--state needs devcontour-harness 0.1.0-alpha.55 or newer; until then write the view ' +
|
|
106
|
+
'to a file and pass --view <file>.', 2);
|
|
107
|
+
source = {
|
|
108
|
+
harness: {
|
|
109
|
+
bin,
|
|
110
|
+
state: resolve(args.state),
|
|
111
|
+
...(args.policy !== undefined ? { policy: resolve(args.policy) } : {}),
|
|
112
|
+
lang: support.lang,
|
|
113
|
+
defaultLang: lang,
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
if (args.view)
|
|
119
|
+
source = { viewFile: resolve(args.view) };
|
|
120
|
+
else {
|
|
121
|
+
// The demo: the checkout's fixtures, or their copy in the package (dist/demo).
|
|
122
|
+
const demo = existsSync(join(root, 'fixtures', 'view.sample.json'))
|
|
123
|
+
? join(root, 'fixtures')
|
|
124
|
+
: join(root, 'dist', 'demo');
|
|
125
|
+
// English files by default; Russian ones (harness texts in Russian) for `?lang=ru`.
|
|
126
|
+
const files = (dir) => ({
|
|
127
|
+
viewFile: join(dir, 'view.sample.json'),
|
|
128
|
+
workFiles: {
|
|
129
|
+
'locale-format': join(dir, 'work.sample.json'),
|
|
130
|
+
'add-greeting': join(dir, 'work.accepted.sample.json'),
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
source = { ...files(demo), localized: { ru: files(join(demo, 'ru')) } };
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const port = args.port === undefined ? undefined : Number(args.port);
|
|
137
|
+
try {
|
|
138
|
+
const server = await startServer({
|
|
139
|
+
...source,
|
|
140
|
+
appDir: join(root, 'dist', 'app'),
|
|
141
|
+
lang,
|
|
142
|
+
...(args.host ? { host: args.host } : {}),
|
|
143
|
+
...(port !== undefined ? { port } : {}),
|
|
144
|
+
version,
|
|
145
|
+
});
|
|
146
|
+
process.stdout.write(JSON.stringify({ ok: true, url: server.url, port: server.port, readOnly: true, version }) +
|
|
147
|
+
'\n');
|
|
148
|
+
process.stderr.write(`Harness panel (read-only): ${server.url} — stop with Ctrl-C\n`);
|
|
149
|
+
const stop = () => void server.close().then(() => process.exit(0));
|
|
150
|
+
process.on('SIGINT', stop);
|
|
151
|
+
process.on('SIGTERM', stop);
|
|
152
|
+
}
|
|
153
|
+
catch (err) {
|
|
154
|
+
if (err instanceof ServeError) {
|
|
155
|
+
fail(err.code, err.message, err.code === 'PORT_BUSY' ? 4 : 2);
|
|
156
|
+
}
|
|
157
|
+
fail('INFRASTRUCTURE', err.message, 4);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
void main();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { OperatorView } from '../model/view.ts';
|
|
2
|
+
import { type ScreenProps } from './common.tsx';
|
|
3
|
+
export interface ActivityFilter {
|
|
4
|
+
workId?: string;
|
|
5
|
+
actor?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ActivityProps extends ScreenProps {
|
|
8
|
+
view: OperatorView;
|
|
9
|
+
filter?: ActivityFilter;
|
|
10
|
+
/** Link of a filter (an anchor); without it the filter choices are not shown. */
|
|
11
|
+
filterHref?: (filter: ActivityFilter) => string;
|
|
12
|
+
}
|
|
13
|
+
export declare function Activity({ view, lang, timeZone, now, onOpenWork, workHref, filter, filterHref, }: ActivityProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// "Who did what" screen (`activity[]`, P2): harness events, newest first,
|
|
3
|
+
// filtered by work and by actor. These are harness events, not an agent's
|
|
4
|
+
// retelling. Without `activity` the producer keeps no feed: the screen says
|
|
5
|
+
// so and never reads it as "nothing happened".
|
|
6
|
+
import { dict, label } from "../model/dict.js";
|
|
7
|
+
import { Clipped, Heading, WorkRef, actorLabel, clockOf } from "./common.js";
|
|
8
|
+
export function Activity({ view, lang = 'ru', timeZone, now, onOpenWork, workHref, filter = {}, filterHref, }) {
|
|
9
|
+
const t = dict(lang);
|
|
10
|
+
const v = t.activity;
|
|
11
|
+
const links = { onOpenWork, workHref };
|
|
12
|
+
const all = view.activity;
|
|
13
|
+
const shown = (all ?? []).filter((e) => (filter.workId === undefined || e.workId === filter.workId) &&
|
|
14
|
+
(filter.actor === undefined || e.actor === filter.actor));
|
|
15
|
+
const works = [...new Set((all ?? []).map((e) => e.workId).filter((x) => !!x))];
|
|
16
|
+
const actors = [...new Set((all ?? []).map((e) => String(e.actor)))];
|
|
17
|
+
const chips = (title, values, current, make, text) => filterHref ? (_jsxs("div", { className: "hui-row hui-filter", role: "group", "aria-label": title, children: [_jsxs("span", { className: "hui-muted", children: [title, ":"] }), [undefined, ...values].map((x) => (_jsx("a", { className: 'hui-chip' + (x === current ? ' hui-chip-on' : ''), href: filterHref(make(x)), "aria-current": x === current ? 'true' : undefined, children: x === undefined ? v.all : text(x) }, x ?? '')))] })) : null;
|
|
18
|
+
return (_jsxs("section", { className: "hui hui-activity", "aria-labelledby": "hui-activity-title", lang: lang, children: [_jsx(Heading, { t: t, term: "lead", level: 2, id: "hui-activity-title", children: v.label }), all === undefined ? (_jsxs("p", { className: "hui-panel", "data-testid": "activity-missing", children: [t.noDataInHarness, ": ", v.missing] })) : (_jsxs("div", { className: "hui-panel", "data-testid": "activity-feed", children: [chips(v.filterWork, works, filter.workId, (x) => ({ ...filter, workId: x }), (x) => x), chips(v.filterActor, actors, filter.actor, (x) => ({ ...filter, actor: x }), (x) => label(t.actor, x)), all.length !== shown.length ? (_jsx("p", { className: "hui-muted", children: v.shown(shown.length, all.length) })) : null, shown.length === 0 ? (_jsx("p", { className: "hui-muted", children: v.none })) : (_jsx("ol", { className: "hui-list hui-feed", children: shown.map((e, i) => (_jsxs("li", { className: "hui-item", children: [_jsx("span", { className: "hui-muted", children: clockOf(e.at, t, timeZone, now) }), ' ', _jsx("strong", { children: actorLabel(t, e.actor) }), " ", e.plain, ' ', e.workId ? _jsx(WorkRef, { id: e.workId, ...links }) : null, ' ', _jsx("code", { className: "hui-muted hui-code", children: e.action })] }, i))) })), _jsx(Clipped, { n: view.truncated?.activity, t: t })] }))] }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { OperatorView } from '../model/view.ts';
|
|
2
|
+
import { type ScreenProps } from './common.tsx';
|
|
3
|
+
export interface DecisionsProps extends ScreenProps {
|
|
4
|
+
view: OperatorView;
|
|
5
|
+
}
|
|
6
|
+
export declare function Decisions({ view, lang, timeZone, now, onOpenWork, workHref, }: DecisionsProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// Decisions screen (`decisions[]`, P2): temporary decisions first with their
|
|
3
|
+
// revisit condition, then every decision with who took it, when and why.
|
|
4
|
+
// Without `decisions` the producer does not report them: the screen says so
|
|
5
|
+
// and never shows an empty list as "no decisions".
|
|
6
|
+
import { dict, label } from "../model/dict.js";
|
|
7
|
+
import { Clipped, Heading, WorkRef, actorLabel, clockOf } from "./common.js";
|
|
8
|
+
function DecisionItem({ d, t, links, timeZone, now, }) {
|
|
9
|
+
const v = t.decisions;
|
|
10
|
+
const about = [d.findingId, d.requestId, d.subject].filter(Boolean).join(', ');
|
|
11
|
+
return (_jsxs("li", { className: "hui-item", "data-testid": `decision-${d.id}`, children: [_jsx("span", { className: "hui-muted", children: clockOf(d.at, t, timeZone, now) }), ' ', _jsx("strong", { children: label(v.kind, d.kind) }), about ? (_jsxs(_Fragment, { children: [' ', v.about, " ", _jsx("code", { children: about })] })) : null, d.workId ? (_jsxs(_Fragment, { children: [' ', "(", _jsx(WorkRef, { id: d.workId, ...links }), ")"] })) : null, ' · ', _jsx("span", { className: "hui-who", children: v.by(actorLabel(t, d.by)) }), d.title ? _jsx("div", { children: d.title }) : null, _jsx("div", { className: "hui-muted", children: d.reason ? v.reason(d.reason) : v.reasonMissing }), d.temporary ? (_jsx("div", { className: "hui-warn-text", children: d.revisit ? v.revisit(d.revisit) : v.revisitUnknown })) : null] }));
|
|
12
|
+
}
|
|
13
|
+
export function Decisions({ view, lang = 'ru', timeZone, now, onOpenWork, workHref, }) {
|
|
14
|
+
const t = dict(lang);
|
|
15
|
+
const v = t.decisions;
|
|
16
|
+
const links = { onOpenWork, workHref };
|
|
17
|
+
const item = (d) => (_jsx(DecisionItem, { d: d, t: t, links: links, ...(timeZone ? { timeZone } : {}), ...(now !== undefined ? { now } : {}) }, d.id));
|
|
18
|
+
return (_jsxs("section", { className: "hui hui-decisions", "aria-labelledby": "hui-decisions-title", lang: lang, children: [_jsx(Heading, { t: t, term: "temporary", level: 2, id: "hui-decisions-title", children: v.label }), view.decisions === undefined ? (_jsxs("p", { className: "hui-panel", "data-testid": "decisions-missing", children: [t.noDataInHarness, ": ", v.missing] })) : (_jsxs(_Fragment, { children: [_jsxs("div", { className: "hui-panel", "data-testid": "decisions-temporary", children: [_jsx(Heading, { t: t, term: "temporary", children: v.temporary(view.decisions.filter((d) => d.temporary).length) }), view.decisions.some((d) => d.temporary) ? (_jsx("ul", { className: "hui-list", children: view.decisions.filter((d) => d.temporary).map(item) })) : (_jsx("p", { className: "hui-muted", children: v.noTemporary }))] }), _jsxs("div", { className: "hui-panel", "data-testid": "decisions-all", children: [_jsx(Heading, { t: t, term: "technical", children: v.all(view.decisions.length) }), view.decisions.length ? (_jsx("ul", { className: "hui-list", children: view.decisions.map(item) })) : (_jsx("p", { className: "hui-muted", children: v.none })), _jsx(Clipped, { n: view.truncated?.decisions, t: t })] })] }))] }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { OperatorView } from '../model/view.ts';
|
|
2
|
+
import { type ScreenProps } from './common.tsx';
|
|
3
|
+
export interface HealthProps extends ScreenProps {
|
|
4
|
+
view: OperatorView;
|
|
5
|
+
/** Version of the panel package, shown beside the harness version. */
|
|
6
|
+
uiVersion?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function Health({ view, lang, timeZone, now, onOpenWork, workHref, uiVersion, }: HealthProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
// Health screen in plain words, with the code beside: controller, stalled
|
|
3
|
+
// and quiet attempts, environment failures, budgets, drift after acceptance,
|
|
4
|
+
// harness warnings and versions. "Not checked" is never shown as zero drift.
|
|
5
|
+
import { dict, label } from "../model/dict.js";
|
|
6
|
+
import { formatDuration, formatUsd, formatWindow, usd } from "../model/format.js";
|
|
7
|
+
import { instantMs } from "../model/compat.js";
|
|
8
|
+
import { Clipped, Heading, WorkRef, clockOf } from "./common.js";
|
|
9
|
+
import { DriftLine } from "./WorkDetail.js";
|
|
10
|
+
export function Health({ view, lang = 'ru', timeZone, now, onOpenWork, workHref, uiVersion, }) {
|
|
11
|
+
const t = dict(lang);
|
|
12
|
+
const v = t.health;
|
|
13
|
+
const h = view.health;
|
|
14
|
+
const links = { onOpenWork, workHref };
|
|
15
|
+
const windowText = formatWindow(instantMs(view.history.to) - instantMs(view.history.from), lang);
|
|
16
|
+
const troubled = view.works.filter((w) => w.liveness === 'stalled' || w.liveness === 'quiet');
|
|
17
|
+
return (_jsxs("section", { className: "hui hui-health", "aria-labelledby": "hui-health-title", lang: lang, children: [_jsx(Heading, { t: t, level: 2, id: "hui-health-title", term: "controller", children: v.label }), _jsxs("div", { className: "hui-panel", "data-testid": "health-machine", children: [_jsxs("ul", { className: "hui-list", children: [_jsx("li", { className: h.controller.present ? '' : 'hui-bad', "data-testid": "health-controller", children: h.controller.present
|
|
18
|
+
? v.controllerOn(h.controller.leaseUntil
|
|
19
|
+
? clockOf(h.controller.leaseUntil, t, timeZone, now)
|
|
20
|
+
: undefined)
|
|
21
|
+
: v.controllerOff }), _jsxs("li", { className: h.stalledAttempts ? 'hui-bad' : '', "data-testid": "health-stalled", children: [h.stalledAttempts ? v.stalled(h.stalledAttempts) : v.stalledNone, ' ', v.quiet(h.quietAttempts)] }), _jsx("li", { "data-testid": "health-env", children: v.envFailures(h.environmentFailures, windowText) })] }), troubled.length ? (_jsxs(_Fragment, { children: [_jsx("h3", { className: "hui-minor", children: v.stalledWorks }), _jsx("ul", { className: "hui-list", children: troubled.map((w) => (_jsxs("li", { children: [_jsx(WorkRef, { id: w.id, ...links }), " \u2014 ", label(t.liveness, w.liveness)] }, w.id))) })] })) : null] }), _jsxs("div", { className: "hui-panel", "data-testid": "health-budgets", children: [_jsx(Heading, { t: t, term: "lowerBound", children: v.budgets }), h.budgets.length ? (_jsx("ul", { className: "hui-list", children: h.budgets.map((b, i) => (_jsx("li", { className: b.state === 'within' ? '' : 'hui-bad', children: v.budgetRow(label(t.budgetScope, b.scope) + (b.id ? ` ${b.id}` : ''), formatUsd(b.spentUsd, lang), b.limitUsd !== undefined ? usd(b.limitUsd) : undefined, label(t.budgetState, b.state), b.spentMs !== undefined || b.limitMs !== undefined
|
|
22
|
+
? v.timeOf(b.spentMs !== undefined ? formatDuration(b.spentMs, lang) : t.unknown, b.limitMs !== undefined ? formatDuration(b.limitMs, lang) : undefined)
|
|
23
|
+
: undefined) }, i))) })) : h.budgeting === 'off' ? (_jsx("p", { children: v.budgetingOff(formatUsd(h.spentTotalUsd, lang)) })) : (_jsxs("p", { children: [t.overview.budgetUnknown, "; ", t.overview.spent(formatUsd(h.spentTotalUsd, lang))] })), h.budgets.length ? (_jsx("p", { className: "hui-muted", children: v.spentTotal(formatUsd(h.spentTotalUsd, lang)) })) : null] }), _jsxs("div", { className: "hui-panel", "data-testid": "health-drift", children: [_jsx(Heading, { t: t, term: "drift", children: v.drift }), _jsx("p", { children: v.driftCounts(h.drift.drifted, h.drift.unavailable, h.drift.checked) }), view.drift.length ? (_jsx("ul", { className: "hui-list", children: view.drift.map((d) => (_jsxs("li", { children: [_jsx(WorkRef, { id: d.workId, ...links }), " ", _jsx(DriftLine, { d: d, t: t })] }, d.workId + d.ref))) })) : null, _jsx(Clipped, { n: view.truncated?.drift, t: t })] }), _jsxs("div", { className: "hui-panel", "data-testid": "health-warnings", children: [_jsx(Heading, { t: t, term: "unknown", children: v.warnings }), h.warnings.length ? (_jsx("ul", { className: "hui-list", children: h.warnings.map((w, i) => (_jsxs("li", { children: [w.message, " ", _jsx("code", { className: "hui-muted", children: w.code })] }, i))) })) : (_jsx("p", { className: "hui-muted", children: v.noWarnings })), _jsx(Clipped, { n: view.truncated?.warnings, t: t })] }), _jsxs("div", { className: "hui-panel", "data-testid": "health-versions", children: [_jsx("h3", { className: "hui-subtitle", children: v.versions }), _jsxs("ul", { className: "hui-list", children: [_jsx("li", { children: v.harness(view.source.producer, view.source.producerVersion) }), _jsx("li", { children: v.ui(uiVersion) }), _jsx("li", { children: v.view(view.viewVersion, view.viewRevision) }), _jsx("li", { children: v.state(view.source.stateVersion) })] })] })] }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { OperatorView, ViewHistory } from '../model/view.ts';
|
|
2
|
+
import { type ScreenProps } from './common.tsx';
|
|
3
|
+
export interface HistoryProps extends Pick<ScreenProps, 'lang' | 'timeZone' | 'now'> {
|
|
4
|
+
view: OperatorView;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Sums groups of buckets into hours when the bucket divides an hour and the
|
|
8
|
+
* window holds whole hours; otherwise keeps the buckets (a partial last hour
|
|
9
|
+
* would be drawn as wide as a full one).
|
|
10
|
+
*/
|
|
11
|
+
export declare function perHour(h: Pick<ViewHistory, 'bucketMs'>, values: number[]): {
|
|
12
|
+
values: number[];
|
|
13
|
+
hourly: boolean;
|
|
14
|
+
groupMs: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Cumulative spend at the bucket boundaries: `values[0]` is the opening
|
|
18
|
+
* balance (`spendOpeningUsd`) at `from`, `values[i]` the total at the end of
|
|
19
|
+
* bucket i. The end is exact only when both the window and the opening are
|
|
20
|
+
* exact; an unknown window bound (or one this build does not know) makes it
|
|
21
|
+
* unknown, never a number.
|
|
22
|
+
*/
|
|
23
|
+
export declare function cumulativeSpend(h: ViewHistory): {
|
|
24
|
+
values: number[];
|
|
25
|
+
openingKnown: boolean;
|
|
26
|
+
lower: boolean;
|
|
27
|
+
end: {
|
|
28
|
+
value: number;
|
|
29
|
+
bound: "exact" | "lower" | "unknown";
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export declare function History({ view, lang, timeZone, now: nowProp }: HistoryProps): import("react").JSX.Element;
|