@12ui/design 0.2.55 → 0.2.57
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/SKILL.md +1 -1
- package/dist/branch-client.d.ts +2 -0
- package/dist/branch-client.d.ts.map +1 -1
- package/dist/branch-client.js +1 -0
- package/dist/branch-client.js.map +1 -1
- package/dist/cli-arguments.d.ts.map +1 -1
- package/dist/cli-arguments.js +2 -0
- package/dist/cli-arguments.js.map +1 -1
- package/dist/cli-conversion-derivation.d.ts +2 -1
- package/dist/cli-conversion-derivation.d.ts.map +1 -1
- package/dist/cli-conversion-derivation.js +9 -1
- package/dist/cli-conversion-derivation.js.map +1 -1
- package/dist/cli-convert-command.d.ts.map +1 -1
- package/dist/cli-convert-command.js +111 -16
- package/dist/cli-convert-command.js.map +1 -1
- package/dist/cli-corpus-command.d.ts.map +1 -1
- package/dist/cli-corpus-command.js +5 -2
- package/dist/cli-corpus-command.js.map +1 -1
- package/dist/cli-corpus-evidence.d.ts.map +1 -1
- package/dist/cli-corpus-evidence.js +2 -1
- package/dist/cli-corpus-evidence.js.map +1 -1
- package/dist/cli-corpus-reference-downloads.d.ts +1 -0
- package/dist/cli-corpus-reference-downloads.d.ts.map +1 -1
- package/dist/cli-corpus-reference-downloads.js +13 -3
- package/dist/cli-corpus-reference-downloads.js.map +1 -1
- package/dist/cli-corpus-types.d.ts +2 -0
- package/dist/cli-corpus-types.d.ts.map +1 -1
- package/dist/cli-draft-command.d.ts +11 -0
- package/dist/cli-draft-command.d.ts.map +1 -1
- package/dist/cli-draft-command.js +10 -1
- package/dist/cli-draft-command.js.map +1 -1
- package/dist/cli-help/design.d.ts +2 -2
- package/dist/cli-help/design.d.ts.map +1 -1
- package/dist/cli-help/design.js +12 -2
- package/dist/cli-help/design.js.map +1 -1
- package/dist/cli-help/index.d.ts +2 -2
- package/dist/cli-improve-command.d.ts.map +1 -1
- package/dist/cli-improve-command.js +317 -70
- package/dist/cli-improve-command.js.map +1 -1
- package/dist/cli-next-command.d.ts.map +1 -1
- package/dist/cli-next-command.js +44 -4
- package/dist/cli-next-command.js.map +1 -1
- package/dist/cli-usage.js +2 -2
- package/dist/concept-input.d.ts +21 -0
- package/dist/concept-input.d.ts.map +1 -1
- package/dist/concept-input.js +32 -10
- package/dist/concept-input.js.map +1 -1
- package/dist/conversion-client.d.ts +39 -1
- package/dist/conversion-client.d.ts.map +1 -1
- package/dist/conversion-client.js +205 -3
- package/dist/conversion-client.js.map +1 -1
- package/dist/corpus-client.d.ts +7 -1
- package/dist/corpus-client.d.ts.map +1 -1
- package/dist/corpus-client.js +6 -2
- package/dist/corpus-client.js.map +1 -1
- package/dist/corpus-reference-download-retry.d.ts +68 -0
- package/dist/corpus-reference-download-retry.d.ts.map +1 -0
- package/dist/corpus-reference-download-retry.js +123 -0
- package/dist/corpus-reference-download-retry.js.map +1 -0
- package/dist/corpus-request-error.d.ts +17 -0
- package/dist/corpus-request-error.d.ts.map +1 -0
- package/dist/corpus-request-error.js +21 -0
- package/dist/corpus-request-error.js.map +1 -0
- package/dist/draft-run.d.ts +9 -0
- package/dist/draft-run.d.ts.map +1 -1
- package/dist/draft-run.js +22 -5
- package/dist/draft-run.js.map +1 -1
- package/dist/draft-workspace.d.ts +2 -1
- package/dist/draft-workspace.d.ts.map +1 -1
- package/dist/draft-workspace.js.map +1 -1
- package/dist/hosted-draft-identity.d.ts +1 -0
- package/dist/hosted-draft-identity.d.ts.map +1 -1
- package/dist/hosted-draft-identity.js +1 -0
- package/dist/hosted-draft-identity.js.map +1 -1
- package/dist/improve-added-specs.d.ts +9 -0
- package/dist/improve-added-specs.d.ts.map +1 -1
- package/dist/improve-added-specs.js +28 -7
- package/dist/improve-added-specs.js.map +1 -1
- package/dist/improve-bootstrap-secret.d.ts +35 -0
- package/dist/improve-bootstrap-secret.d.ts.map +1 -0
- package/dist/improve-bootstrap-secret.js +61 -0
- package/dist/improve-bootstrap-secret.js.map +1 -0
- package/dist/improve-capture-redirect.d.ts +46 -0
- package/dist/improve-capture-redirect.d.ts.map +1 -0
- package/dist/improve-capture-redirect.js +68 -0
- package/dist/improve-capture-redirect.js.map +1 -0
- package/dist/improve-concept.d.ts +14 -1
- package/dist/improve-concept.d.ts.map +1 -1
- package/dist/improve-concept.js +29 -8
- package/dist/improve-concept.js.map +1 -1
- package/dist/improve-conversion-attempts.d.ts +96 -0
- package/dist/improve-conversion-attempts.d.ts.map +1 -0
- package/dist/improve-conversion-attempts.js +93 -0
- package/dist/improve-conversion-attempts.js.map +1 -0
- package/dist/improve-conversion-stage.d.ts +14 -0
- package/dist/improve-conversion-stage.d.ts.map +1 -1
- package/dist/improve-conversion-stage.js +254 -70
- package/dist/improve-conversion-stage.js.map +1 -1
- package/dist/improve-convert-progress.d.ts +36 -0
- package/dist/improve-convert-progress.d.ts.map +1 -0
- package/dist/improve-convert-progress.js +43 -0
- package/dist/improve-convert-progress.js.map +1 -0
- package/dist/improve-convert-resilience.d.ts +116 -0
- package/dist/improve-convert-resilience.d.ts.map +1 -1
- package/dist/improve-convert-resilience.js +158 -1
- package/dist/improve-convert-resilience.js.map +1 -1
- package/dist/improve-delivery-stages.d.ts.map +1 -1
- package/dist/improve-delivery-stages.js +5 -0
- package/dist/improve-delivery-stages.js.map +1 -1
- package/dist/improve-dom-diff.d.ts +2 -0
- package/dist/improve-dom-diff.d.ts.map +1 -1
- package/dist/improve-dom-diff.js +7 -0
- package/dist/improve-dom-diff.js.map +1 -1
- package/dist/improve-dom-gate.d.ts +7 -0
- package/dist/improve-dom-gate.d.ts.map +1 -1
- package/dist/improve-dom-gate.js +13 -0
- package/dist/improve-dom-gate.js.map +1 -1
- package/dist/improve-generation-stages.d.ts +3 -0
- package/dist/improve-generation-stages.d.ts.map +1 -1
- package/dist/improve-generation-stages.js +56 -10
- package/dist/improve-generation-stages.js.map +1 -1
- package/dist/improve-icon-svg.d.ts +47 -0
- package/dist/improve-icon-svg.d.ts.map +1 -0
- package/dist/improve-icon-svg.js +83 -0
- package/dist/improve-icon-svg.js.map +1 -0
- package/dist/improve-kit-assets.d.ts +129 -0
- package/dist/improve-kit-assets.d.ts.map +1 -0
- package/dist/improve-kit-assets.js +333 -0
- package/dist/improve-kit-assets.js.map +1 -0
- package/dist/improve-kit-ignore.d.ts +32 -0
- package/dist/improve-kit-ignore.d.ts.map +1 -0
- package/dist/improve-kit-ignore.js +111 -0
- package/dist/improve-kit-ignore.js.map +1 -0
- package/dist/improve-kit-readme.d.ts +11 -2
- package/dist/improve-kit-readme.d.ts.map +1 -1
- package/dist/improve-kit-readme.js +282 -26
- package/dist/improve-kit-readme.js.map +1 -1
- package/dist/improve-kit-stall.d.ts +113 -0
- package/dist/improve-kit-stall.d.ts.map +1 -0
- package/dist/improve-kit-stall.js +311 -0
- package/dist/improve-kit-stall.js.map +1 -0
- package/dist/improve-kit-status.d.ts +105 -0
- package/dist/improve-kit-status.d.ts.map +1 -0
- package/dist/improve-kit-status.js +215 -0
- package/dist/improve-kit-status.js.map +1 -0
- package/dist/improve-options.d.ts +16 -1
- package/dist/improve-options.d.ts.map +1 -1
- package/dist/improve-options.js +65 -15
- package/dist/improve-options.js.map +1 -1
- package/dist/improve-plan-annotated-render.d.ts +45 -0
- package/dist/improve-plan-annotated-render.d.ts.map +1 -0
- package/dist/improve-plan-annotated-render.js +196 -0
- package/dist/improve-plan-annotated-render.js.map +1 -0
- package/dist/improve-plan-annotator.d.ts +7 -1
- package/dist/improve-plan-annotator.d.ts.map +1 -1
- package/dist/improve-plan-annotator.js +22 -45
- package/dist/improve-plan-annotator.js.map +1 -1
- package/dist/improve-raster-layers-section.d.ts +21 -0
- package/dist/improve-raster-layers-section.d.ts.map +1 -0
- package/dist/improve-raster-layers-section.js +45 -0
- package/dist/improve-raster-layers-section.js.map +1 -0
- package/dist/improve-reset.d.ts +122 -0
- package/dist/improve-reset.d.ts.map +1 -0
- package/dist/improve-reset.js +141 -0
- package/dist/improve-reset.js.map +1 -0
- package/dist/improve-run-summary.d.ts +35 -0
- package/dist/improve-run-summary.d.ts.map +1 -0
- package/dist/improve-run-summary.js +180 -0
- package/dist/improve-run-summary.js.map +1 -0
- package/dist/improve-stage-shared.d.ts +44 -1
- package/dist/improve-stage-shared.d.ts.map +1 -1
- package/dist/improve-stage-shared.js +80 -3
- package/dist/improve-stage-shared.js.map +1 -1
- package/dist/improve-stop-handler.d.ts +73 -0
- package/dist/improve-stop-handler.d.ts.map +1 -0
- package/dist/improve-stop-handler.js +126 -0
- package/dist/improve-stop-handler.js.map +1 -0
- package/dist/improve-terminal-event.d.ts +118 -0
- package/dist/improve-terminal-event.d.ts.map +1 -0
- package/dist/improve-terminal-event.js +87 -0
- package/dist/improve-terminal-event.js.map +1 -0
- package/dist/improve-token-patch.d.ts +2 -0
- package/dist/improve-token-patch.d.ts.map +1 -1
- package/dist/improve-token-patch.js +23 -5
- package/dist/improve-token-patch.js.map +1 -1
- package/dist/improve-workspace.d.ts +94 -2
- package/dist/improve-workspace.d.ts.map +1 -1
- package/dist/improve-workspace.js +19 -1
- package/dist/improve-workspace.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/legacy-skill-catalog.d.ts.map +1 -1
- package/dist/legacy-skill-catalog.js +143 -0
- package/dist/legacy-skill-catalog.js.map +1 -1
- package/dist/mcp-tool-definitions.js +1 -1
- package/dist/mcp-tool-definitions.js.map +1 -1
- package/dist/mcp-tool-handler.d.ts.map +1 -1
- package/dist/mcp-tool-handler.js +3 -0
- package/dist/mcp-tool-handler.js.map +1 -1
- package/dist/redesign-capture.d.ts +17 -0
- package/dist/redesign-capture.d.ts.map +1 -1
- package/dist/redesign-capture.js +55 -3
- package/dist/redesign-capture.js.map +1 -1
- package/dist/responsive-alternative-materializer.d.ts +19 -0
- package/dist/responsive-alternative-materializer.d.ts.map +1 -0
- package/dist/responsive-alternative-materializer.js +76 -0
- package/dist/responsive-alternative-materializer.js.map +1 -0
- package/dist/run-journal-unfinished.d.ts +56 -0
- package/dist/run-journal-unfinished.d.ts.map +1 -0
- package/dist/run-journal-unfinished.js +126 -0
- package/dist/run-journal-unfinished.js.map +1 -0
- package/dist/run-journal.d.ts +25 -1
- package/dist/run-journal.d.ts.map +1 -1
- package/dist/run-journal.js +15 -1
- package/dist/run-journal.js.map +1 -1
- package/open-design.json +2 -2
- package/package.json +1 -1
- package/skills/12ui-design/SKILL.md +9 -1
- package/skills/12ui-design/improve.md +83 -6
- package/skills/12ui-design/inspire.md +1 -1
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { formatDuration } from './cli-progress.js';
|
|
3
|
+
import { readImproveKitAssets } from './improve-kit-assets.js';
|
|
4
|
+
import { IMPROVE_NO_APPROXIMATION_RULE, improvePickSlotHint, improveRecoveryLine, improveStageStatusLine, readImproveKitStatus, shellArg, } from './improve-kit-status.js';
|
|
5
|
+
import { improveCapturedUrlLine } from './improve-capture-redirect.js';
|
|
6
|
+
import { improveKitIgnoreNote } from './improve-kit-ignore.js';
|
|
7
|
+
import { improveAbandonedLines } from './improve-reset.js';
|
|
8
|
+
import { improvePaths } from './improve-workspace.js';
|
|
9
|
+
/**
|
|
10
|
+
* The last thing `12ui improve` prints.
|
|
11
|
+
*
|
|
12
|
+
* A run that ends with a 200-line JSON record tells a reader nothing about
|
|
13
|
+
* whether it worked. This block does: stage statuses, what the target actually
|
|
14
|
+
* is, which raster layers have to be carried by name, the plan result, and the
|
|
15
|
+
* kit path. On a stall it leads with INCOMPLETE and the recovery commands,
|
|
16
|
+
* because that is the moment a lane decides whether to code from a PNG.
|
|
17
|
+
*/
|
|
18
|
+
const planLine = (record, status) => {
|
|
19
|
+
if (status.gateBlocked)
|
|
20
|
+
return 'Plan: blocked by the coverage gate — read plan/GATE.md';
|
|
21
|
+
if (!record.plan)
|
|
22
|
+
return 'Plan: none';
|
|
23
|
+
return `Plan: ${record.plan.mode}, coverage gate ${record.plan.gate}`;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The headline is the one line a skimming reader takes away, so it carries the
|
|
27
|
+
* caveat rather than leaving it eight lines down. A fixed-layout fallback that
|
|
28
|
+
* announces itself as "Kit ready" is the same defect as `12ui next` reporting
|
|
29
|
+
* ok over a wedged export.
|
|
30
|
+
*/
|
|
31
|
+
const headline = (record, status) => {
|
|
32
|
+
if (status.gateBlocked)
|
|
33
|
+
return 'Kit ready — coverage gate blocked the plan';
|
|
34
|
+
// "Fixed-layout fallback" named the OUTCOME and not the event, so a reader
|
|
35
|
+
// who had watched a silent wait could not tell the run had overrun anything
|
|
36
|
+
// (F8). Name what happened first: the plan is real, and it was built from a
|
|
37
|
+
// derivation because the responsive export did not settle.
|
|
38
|
+
if (record.convert?.layout === 'fixed') {
|
|
39
|
+
return 'Kit ready — responsive export stalled; plan from fixed-layout fallback';
|
|
40
|
+
}
|
|
41
|
+
return 'Kit ready';
|
|
42
|
+
};
|
|
43
|
+
/** What stalled and where it is written down, on the line after the headline. */
|
|
44
|
+
const fallbackLines = (record) => {
|
|
45
|
+
if (record.convert?.layout !== 'fixed')
|
|
46
|
+
return [];
|
|
47
|
+
const stall = record.convert.responsiveStall;
|
|
48
|
+
const id = stall?.conversionId ?? record.convert.sourceConversionId;
|
|
49
|
+
return [
|
|
50
|
+
`- Responsive export: stalled${stall
|
|
51
|
+
? ` after ${formatDuration(stall.waitedSeconds)} (bound ${formatDuration(stall.boundSeconds)})`
|
|
52
|
+
: ''}${id ? `, conversion ${id}` : ''}`
|
|
53
|
+
+ ' — read plan/STALL.md, which has the command that collects it later',
|
|
54
|
+
];
|
|
55
|
+
};
|
|
56
|
+
const assetsLine = (index) => {
|
|
57
|
+
if (index.assets.length === 0)
|
|
58
|
+
return 'Assets: none';
|
|
59
|
+
const carry = index.rasterLayers
|
|
60
|
+
.map((layer) => `${layer.kind}${layer.asset ? ` (${layer.asset.id})` : ''}`);
|
|
61
|
+
return `Assets: ${index.assets.length} file${index.assets.length === 1 ? '' : 's'};`
|
|
62
|
+
+ ` raster layers to carry: ${carry.length > 0 ? carry.join(', ') : 'none declared'}`;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* The kit is inside the repository and committable. One line, at the end, where
|
|
66
|
+
* the reader is already looking — the run never edits a `.gitignore` it cannot
|
|
67
|
+
* be sure about, so this is all it can honestly do (F17).
|
|
68
|
+
*/
|
|
69
|
+
const kitIgnoreLines = (record) => {
|
|
70
|
+
const note = improveKitIgnoreNote(record.kitIgnore);
|
|
71
|
+
return note ? [`- ${note}`] : [];
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* What a run prints when the draw is ready and nobody has chosen.
|
|
75
|
+
*
|
|
76
|
+
* This is the whole point of the dispatch-discipline change, so it has to leave
|
|
77
|
+
* the reader with two things and nothing else: where the candidates are, and
|
|
78
|
+
* the one command that continues from here. It is a finished run, not a
|
|
79
|
+
* failure — the stages that were asked for and could run, ran.
|
|
80
|
+
*/
|
|
81
|
+
export const awaitingImprovePick = (args) => {
|
|
82
|
+
const slots = (args.record.draft?.candidates ?? []).map((candidate) => candidate.slot);
|
|
83
|
+
return [
|
|
84
|
+
'',
|
|
85
|
+
'Draw ready — choose a candidate',
|
|
86
|
+
`- Candidates: ${slots.length > 0 ? slots.join(', ') : 'none recorded'}`
|
|
87
|
+
+ ` in ${args.options.paths.candidatesDir}`,
|
|
88
|
+
'- Nothing was converted. A conversion of a candidate nobody chose is money spent on a guess,'
|
|
89
|
+
+ ' and it cannot be cancelled once it starts.',
|
|
90
|
+
`- Kit: ${args.record.runDir}`,
|
|
91
|
+
...kitIgnoreLines(args.record),
|
|
92
|
+
`Next: 12ui improve ${shellArg(args.record.input.value)}`
|
|
93
|
+
+ ` --out-dir ${shellArg(args.record.runDir)}`
|
|
94
|
+
+ ` --from pick --pick ${improvePickSlotHint(args.record)}`,
|
|
95
|
+
].join('\n');
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* The page that was photographed, when it is not the page that was requested.
|
|
99
|
+
* One line, high in the summary, is what the notion app surface needed and did
|
|
100
|
+
* not get (F27).
|
|
101
|
+
*/
|
|
102
|
+
const capturedLines = (record) => {
|
|
103
|
+
const line = improveCapturedUrlLine(record);
|
|
104
|
+
return line ? [`- ${line}`] : [];
|
|
105
|
+
};
|
|
106
|
+
/** Which candidate the target came from, and why that one was converted. */
|
|
107
|
+
const convertedLine = (record) => {
|
|
108
|
+
if (record.target)
|
|
109
|
+
return ['- Converted: the supplied --target'];
|
|
110
|
+
if (!record.pick)
|
|
111
|
+
return [];
|
|
112
|
+
return [`- Converted: candidate ${record.pick.slot}, chosen with --pick`];
|
|
113
|
+
};
|
|
114
|
+
export const renderImproveRunSummary = (args) => {
|
|
115
|
+
const readme = path.join(args.record.runDir, 'README.md');
|
|
116
|
+
const stages = `Stages: ${args.status.stages.map(improveStageStatusLine).join('; ')}`;
|
|
117
|
+
if (args.status.complete) {
|
|
118
|
+
return [
|
|
119
|
+
'',
|
|
120
|
+
headline(args.record, args.status),
|
|
121
|
+
`- ${stages}`,
|
|
122
|
+
...capturedLines(args.record),
|
|
123
|
+
`- Target: ${args.status.targetMode}`,
|
|
124
|
+
...fallbackLines(args.record),
|
|
125
|
+
`- ${assetsLine(args.index)}`,
|
|
126
|
+
...convertedLine(args.record),
|
|
127
|
+
`- ${planLine(args.record, args.status)}`,
|
|
128
|
+
...improveAbandonedLines(args.record),
|
|
129
|
+
`- Kit: ${args.record.runDir}`,
|
|
130
|
+
...kitIgnoreLines(args.record),
|
|
131
|
+
`Next: read ${readme}`,
|
|
132
|
+
].join('\n');
|
|
133
|
+
}
|
|
134
|
+
return [
|
|
135
|
+
'',
|
|
136
|
+
'INCOMPLETE',
|
|
137
|
+
`- Missing: ${args.status.missing.join(', ')}`,
|
|
138
|
+
`- ${stages}`,
|
|
139
|
+
...capturedLines(args.record),
|
|
140
|
+
`- Target: ${args.status.targetMode}`,
|
|
141
|
+
...fallbackLines(args.record),
|
|
142
|
+
`- ${assetsLine(args.index)}`,
|
|
143
|
+
...convertedLine(args.record),
|
|
144
|
+
`- ${planLine(args.record, args.status)}`,
|
|
145
|
+
...improveAbandonedLines(args.record),
|
|
146
|
+
`- Kit: ${args.record.runDir}`,
|
|
147
|
+
...kitIgnoreLines(args.record),
|
|
148
|
+
'- Recovery:',
|
|
149
|
+
...args.status.recovery.map(improveRecoveryLine),
|
|
150
|
+
`- ${IMPROVE_NO_APPROXIMATION_RULE}`,
|
|
151
|
+
`Next: read ${readme}`,
|
|
152
|
+
].join('\n');
|
|
153
|
+
};
|
|
154
|
+
export const buildImproveRunSummary = async (args) => {
|
|
155
|
+
const paths = improvePaths(args.record.runDir);
|
|
156
|
+
const [status, index] = await Promise.all([
|
|
157
|
+
readImproveKitStatus({
|
|
158
|
+
record: args.record,
|
|
159
|
+
...(args.requestedTo ? { requestedTo: args.requestedTo } : {}),
|
|
160
|
+
}),
|
|
161
|
+
readImproveKitAssets({ runDir: args.record.runDir, layerDocPath: paths.targetLayerDoc }),
|
|
162
|
+
]);
|
|
163
|
+
return renderImproveRunSummary({ record: args.record, status, index });
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Put the summary AFTER the failure text.
|
|
167
|
+
*
|
|
168
|
+
* `cli.ts` prints `error.message` last, so a summary written to stdout before
|
|
169
|
+
* the throw leaves the reader's final line as the error rather than
|
|
170
|
+
* "Next: read <kit>/README.md" — which is the line the summary exists to
|
|
171
|
+
* leave there. Carrying it in the message is what keeps the order right.
|
|
172
|
+
*/
|
|
173
|
+
export const improveStallErrorWithSummary = (error, summary) => {
|
|
174
|
+
if (error instanceof Error) {
|
|
175
|
+
error.message = `${error.message}\n${summary}`;
|
|
176
|
+
return error;
|
|
177
|
+
}
|
|
178
|
+
return new Error(`${String(error)}\n${summary}`);
|
|
179
|
+
};
|
|
180
|
+
//# sourceMappingURL=improve-run-summary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"improve-run-summary.js","s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C;QACxC,oBAAoB,CAAC;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC/D,CAAC;QACF,oBAAoB,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,CAAC,cAAc,EAAE,CAAC;KACzF,CAAC,CAAC;IACH,OAAO,uBAAuB,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;AACzE,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,KAAc,EAAE,OAAe,EAAW,EAAE;IACvF,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,KAAK,CAAC,OAAO,GAAG,GAAG,KAAK,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;QAC/C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,KAAK,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;AACnD,CAAC,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { runConversionCommand } from './cli-convert-command.js';
|
|
2
2
|
import { runDraftCommand } from './cli-draft-command.js';
|
|
3
3
|
import { captureImprovePage } from './redesign-capture.js';
|
|
4
|
+
import type { ImproveStopTarget } from './improve-stop-handler.js';
|
|
4
5
|
import type { RunJournalNotes } from './run-journal.js';
|
|
5
|
-
import { type ImproveRecord, type ImproveStage } from './improve-workspace.js';
|
|
6
|
+
import { type ImproveRecord, type ImproveStage, type ImproveStageOutcome } from './improve-workspace.js';
|
|
6
7
|
export type ImproveCommandDependencies = {
|
|
7
8
|
capture?: typeof captureImprovePage;
|
|
8
9
|
runDraft?: typeof runDraftCommand;
|
|
@@ -13,8 +14,21 @@ export type ImproveCommandDependencies = {
|
|
|
13
14
|
sleep?: (milliseconds: number) => Promise<void>;
|
|
14
15
|
onRunDirectory?: (runDir: string) => void;
|
|
15
16
|
journal?: RunJournalNotes;
|
|
17
|
+
/** Where the stop handler listens; `process` unless a test supplies one. */
|
|
18
|
+
stopTarget?: ImproveStopTarget;
|
|
19
|
+
/** How a stopped run leaves; `process.exit` unless a test supplies one. */
|
|
20
|
+
exit?: (code: number) => void;
|
|
16
21
|
};
|
|
17
22
|
export declare const improveSha256: (bytes: Uint8Array) => string;
|
|
23
|
+
/**
|
|
24
|
+
* The word for what this stage did, read off the record it just wrote (F28).
|
|
25
|
+
*
|
|
26
|
+
* The facts were always there — `convert.layout`, `convert.responsiveWarning`,
|
|
27
|
+
* `plan.gate` — and the README already printed them. Only `improve.json` said
|
|
28
|
+
* `settled` over a fixed-layout fallback and a gate-blocked plan, which is the
|
|
29
|
+
* one place a supervisor or a campaign parser looks.
|
|
30
|
+
*/
|
|
31
|
+
export declare const improveStageOutcome: (record: ImproveRecord, stage: ImproveStage) => ImproveStageOutcome;
|
|
18
32
|
export declare const noteImproveStage: (args: {
|
|
19
33
|
record: ImproveRecord;
|
|
20
34
|
stage: ImproveStage;
|
|
@@ -23,5 +37,34 @@ export declare const noteImproveStage: (args: {
|
|
|
23
37
|
outcome?: "settled" | "skipped";
|
|
24
38
|
write: boolean;
|
|
25
39
|
}) => Promise<ImproveRecord>;
|
|
40
|
+
/**
|
|
41
|
+
* The paid call this stage dispatched did not come back in this run.
|
|
42
|
+
*
|
|
43
|
+
* It rewrites the dispatched entry rather than adding one, so the price stays
|
|
44
|
+
* the price of the call that is still running and a resume still re-attaches
|
|
45
|
+
* to it. A stage with no entry bought nothing; it gets an unpriced `stalled`
|
|
46
|
+
* entry only when the run itself stalled, so `stages.plan.outcome` can say so
|
|
47
|
+
* instead of staying silent.
|
|
48
|
+
*/
|
|
49
|
+
export declare const markImproveStageStalled: (args: {
|
|
50
|
+
record: ImproveRecord;
|
|
51
|
+
stage: ImproveStage;
|
|
52
|
+
stalled: boolean;
|
|
53
|
+
}) => ImproveRecord;
|
|
54
|
+
/**
|
|
55
|
+
* The stage's paid work is in flight, priced, and written down before it can
|
|
56
|
+
* fail (F19).
|
|
57
|
+
*
|
|
58
|
+
* `improve.json` is the kit's spend ledger, and it only ever held stages that
|
|
59
|
+
* SETTLED. The pipedrive kit dispatched two parent conversions and settled
|
|
60
|
+
* neither, so its recorded ceiling was the draft's $0.242 and the lane had to
|
|
61
|
+
* publish a planning proxy in place of a receipt. A stage already recorded is
|
|
62
|
+
* left alone: a resume re-attaches to the conversion this entry paid for.
|
|
63
|
+
*/
|
|
64
|
+
export declare const noteImproveStageDispatched: (args: {
|
|
65
|
+
record: ImproveRecord;
|
|
66
|
+
stage: ImproveStage;
|
|
67
|
+
priceCeilingUsd: number;
|
|
68
|
+
}) => ImproveRecord;
|
|
26
69
|
export declare const markImproveStageSkipped: (record: ImproveRecord, stage: ImproveStage) => Promise<ImproveRecord>;
|
|
27
70
|
//# sourceMappingURL=improve-stage-shared.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"improve-stage-shared.d.ts","sourceRoot":"","sources":["../src/improve-stage-shared.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"improve-stage-shared.d.ts","sourceRoot":"","sources":["../src/improve-stage-shared.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO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,YAAY,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;IAChC,KAAK,EAAE,OAAO,CAAC;CAChB,KAAG,OAAO,CAAC,aAAa,CA+BxB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,uBAAuB,GAAI,MAAM;IAC5C,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;CAClB,KAAG,aAcH,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,GAAI,MAAM;IAC/C,MAAM,EAAE,aAAa,CAAC;IACtB,KAAK,EAAE,YAAY,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB,KAAG,aAaH,CAAC;AAEF,eAAO,MAAM,uBAAuB,GAClC,QAAQ,aAAa,EACrB,OAAO,YAAY,KAClB,OAAO,CAAC,aAAa,CAOtB,CAAC"}
|
|
@@ -2,20 +2,49 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { writeImproveRecord, } from './improve-workspace.js';
|
|
4
4
|
export const improveSha256 = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
5
|
+
/**
|
|
6
|
+
* The word for what this stage did, read off the record it just wrote (F28).
|
|
7
|
+
*
|
|
8
|
+
* The facts were always there — `convert.layout`, `convert.responsiveWarning`,
|
|
9
|
+
* `plan.gate` — and the README already printed them. Only `improve.json` said
|
|
10
|
+
* `settled` over a fixed-layout fallback and a gate-blocked plan, which is the
|
|
11
|
+
* one place a supervisor or a campaign parser looks.
|
|
12
|
+
*/
|
|
13
|
+
export const improveStageOutcome = (record, stage) => {
|
|
14
|
+
if (stage === 'convert' && record.convert?.layout === 'fixed')
|
|
15
|
+
return 'fallback';
|
|
16
|
+
if (stage === 'plan' && record.plan?.gate === 'blocked')
|
|
17
|
+
return 'blocked';
|
|
18
|
+
return 'settled';
|
|
19
|
+
};
|
|
20
|
+
/** A priced entry whose paid call has not come back yet. */
|
|
21
|
+
const isPendingOutcome = (outcome) => (outcome === 'dispatched' || outcome === 'stalled');
|
|
5
22
|
export const noteImproveStage = async (args) => {
|
|
6
23
|
const previous = args.record.stages[args.stage];
|
|
24
|
+
// A stage recorded at DISPATCH is not a replay of anything: the paid call it
|
|
25
|
+
// priced is the one settling now, so settling completes that entry rather
|
|
26
|
+
// than counting a second run of the stage. A stage that STALLED holds the
|
|
27
|
+
// same entry — the resume is that call finishing, not a second run of it.
|
|
28
|
+
const pending = previous && isPendingOutcome(previous.outcome) ? previous : undefined;
|
|
29
|
+
const outcome = args.outcome ?? improveStageOutcome(args.record, args.stage);
|
|
7
30
|
const record = {
|
|
8
31
|
...args.record,
|
|
9
32
|
stages: {
|
|
10
33
|
...args.record.stages,
|
|
11
|
-
[args.stage]: previous ? {
|
|
34
|
+
[args.stage]: previous && !pending ? {
|
|
12
35
|
...previous,
|
|
13
36
|
replayCount: previous.replayCount + (args.replayed ? 1 : 0),
|
|
37
|
+
// A replay re-reads the outcome too, so a kit written before this
|
|
38
|
+
// field could tell the truth stops calling a fallback settled the
|
|
39
|
+
// first time it is resumed.
|
|
40
|
+
outcome,
|
|
14
41
|
} : {
|
|
42
|
+
...(pending?.dispatchedAt ? { dispatchedAt: pending.dispatchedAt } : {}),
|
|
15
43
|
settledAt: new Date().toISOString(),
|
|
16
44
|
replayCount: 0,
|
|
17
|
-
|
|
18
|
-
|
|
45
|
+
// The dispatch priced this call; a settlement never prices it lower.
|
|
46
|
+
priceCeilingUsd: Math.max(pending?.priceCeilingUsd ?? 0, args.priceCeilingUsd),
|
|
47
|
+
outcome,
|
|
19
48
|
},
|
|
20
49
|
},
|
|
21
50
|
};
|
|
@@ -23,6 +52,54 @@ export const noteImproveStage = async (args) => {
|
|
|
23
52
|
await writeImproveRecord(path.join(args.record.runDir, 'improve.json'), record);
|
|
24
53
|
return record;
|
|
25
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* The paid call this stage dispatched did not come back in this run.
|
|
57
|
+
*
|
|
58
|
+
* It rewrites the dispatched entry rather than adding one, so the price stays
|
|
59
|
+
* the price of the call that is still running and a resume still re-attaches
|
|
60
|
+
* to it. A stage with no entry bought nothing; it gets an unpriced `stalled`
|
|
61
|
+
* entry only when the run itself stalled, so `stages.plan.outcome` can say so
|
|
62
|
+
* instead of staying silent.
|
|
63
|
+
*/
|
|
64
|
+
export const markImproveStageStalled = (args) => {
|
|
65
|
+
const previous = args.record.stages[args.stage];
|
|
66
|
+
if (previous && previous.outcome !== 'dispatched')
|
|
67
|
+
return args.record;
|
|
68
|
+
if (!previous && !args.stalled)
|
|
69
|
+
return args.record;
|
|
70
|
+
return {
|
|
71
|
+
...args.record,
|
|
72
|
+
stages: {
|
|
73
|
+
...args.record.stages,
|
|
74
|
+
[args.stage]: {
|
|
75
|
+
...(previous ?? { replayCount: 0, priceCeilingUsd: 0 }),
|
|
76
|
+
outcome: 'stalled',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* The stage's paid work is in flight, priced, and written down before it can
|
|
83
|
+
* fail (F19).
|
|
84
|
+
*
|
|
85
|
+
* `improve.json` is the kit's spend ledger, and it only ever held stages that
|
|
86
|
+
* SETTLED. The pipedrive kit dispatched two parent conversions and settled
|
|
87
|
+
* neither, so its recorded ceiling was the draft's $0.242 and the lane had to
|
|
88
|
+
* publish a planning proxy in place of a receipt. A stage already recorded is
|
|
89
|
+
* left alone: a resume re-attaches to the conversion this entry paid for.
|
|
90
|
+
*/
|
|
91
|
+
export const noteImproveStageDispatched = (args) => (args.record.stages[args.stage] ? args.record : {
|
|
92
|
+
...args.record,
|
|
93
|
+
stages: {
|
|
94
|
+
...args.record.stages,
|
|
95
|
+
[args.stage]: {
|
|
96
|
+
dispatchedAt: new Date().toISOString(),
|
|
97
|
+
replayCount: 0,
|
|
98
|
+
priceCeilingUsd: args.priceCeilingUsd,
|
|
99
|
+
outcome: 'dispatched',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
});
|
|
26
103
|
export const markImproveStageSkipped = async (record, stage) => noteImproveStage({
|
|
27
104
|
record,
|
|
28
105
|
stage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"improve-stage-shared.js","sourceRoot":"","sources":["../src/improve-stage-shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"improve-stage-shared.js","sourceRoot":"","sources":["../src/improve-stage-shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,IAAI,MAAM,WAAW,CAAC;AAO7B,OAAO,EACL,kBAAkB,GAInB,MAAM,wBAAwB,CAAC;AAkBhC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAiB,EAAU,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAE7G;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,MAAqB,EACrB,KAAmB,EACE,EAAE;IACvB,IAAI,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO;QAAE,OAAO,UAAU,CAAC;IACjF,IAAI,KAAK,KAAK,MAAM,IAAI,MAAM,CAAC,IAAI,EAAE,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1E,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF,4DAA4D;AAC5D,MAAM,gBAAgB,GAAG,CAAC,OAA4B,EAAW,EAAE,CAAC,CAClE,OAAO,KAAK,YAAY,IAAI,OAAO,KAA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K,CAAC,EAAE;YACZ,YAAY,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACtC,WAAW,EAAE,CAAC;YACd,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,OAAO,EAAE,YAAY;SACtB;KACF;CACF,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,EAC1C,MAAqB,EACrB,KAAmB,EACK,EAAE,CAAC,gBAAgB,CAAC;IAC5C,MAAM;IACN,KAAK;IACL,eAAe,EAAE,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,OAAO,KAAK,SAAS;IACrD,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,IAAI;CACZ,CAAC,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type ImproveLiveStage, type ImproveStopSignal } from './improve-terminal-event.js';
|
|
2
|
+
import type { RunJournalNotes } from './run-journal.js';
|
|
3
|
+
import { type ImproveRecord, type ImproveStage } from './improve-workspace.js';
|
|
4
|
+
/**
|
|
5
|
+
* A stopped run owes the same kit a stalled run owes, and the same record.
|
|
6
|
+
*
|
|
7
|
+
* The pipedrive lane killed a conversion at 97 seconds. Nothing threw, so no
|
|
8
|
+
* README, no `plan/STALL.md`, no end-of-run summary and no terminal journal
|
|
9
|
+
* event were ever written, and the reader was left with an empty `target/` and
|
|
10
|
+
* a PNG — the exact starting condition that produced a hand-authored hero.
|
|
11
|
+
* Ctrl-C is not a silent exit.
|
|
12
|
+
*
|
|
13
|
+
* The handler is armed for the WHOLE run, not just the delivery stages: a kill
|
|
14
|
+
* during capture, draft or pick used to leave nothing at all. The stage it
|
|
15
|
+
* reports comes from the LIVE invocation first and the record only second —
|
|
16
|
+
* see `ImproveLiveStage`, and the pipedrive kit of 2026-09-02, where a record
|
|
17
|
+
* left settled by an earlier replay read as complete while a `--fresh`
|
|
18
|
+
* conversion this process had dispatched was still in flight.
|
|
19
|
+
*
|
|
20
|
+
* WHAT THIS PATH DOES NOT WRITE: `improve.json`. It reads it, and never the
|
|
21
|
+
* other way round. Making a stopped `--fresh` or retry conversion resumable
|
|
22
|
+
* needs its idempotency key on the record, and the convert stage puts it there
|
|
23
|
+
* BEFORE it dispatches (`improve-conversion-attempts.ts`) — so by the time a
|
|
24
|
+
* signal arrives the fact is already durable, and a record write racing a
|
|
25
|
+
* second signal after the journal end line buys nothing.
|
|
26
|
+
*/
|
|
27
|
+
export type { ImproveStopSignal };
|
|
28
|
+
export type ImproveStopArtifacts = {
|
|
29
|
+
/** Absent when nothing was in flight and every stage in range had settled. */
|
|
30
|
+
stage?: ImproveStage;
|
|
31
|
+
/** Absent for the same reason: a complete kit is owed no STALL.md. */
|
|
32
|
+
stall?: string;
|
|
33
|
+
readme: string;
|
|
34
|
+
summary: string;
|
|
35
|
+
errorClass: string;
|
|
36
|
+
};
|
|
37
|
+
export declare const writeImproveStopArtifacts: (args: {
|
|
38
|
+
record: ImproveRecord;
|
|
39
|
+
signal: ImproveStopSignal;
|
|
40
|
+
requestedTo?: ImproveStage;
|
|
41
|
+
journal?: RunJournalNotes;
|
|
42
|
+
/** The stage this invocation entered and had not finished. See `ImproveLiveStage`. */
|
|
43
|
+
live?: ImproveStage;
|
|
44
|
+
}) => Promise<ImproveStopArtifacts>;
|
|
45
|
+
export type ImproveStopTarget = {
|
|
46
|
+
once: (signal: ImproveStopSignal, listener: () => void) => unknown;
|
|
47
|
+
off: (signal: ImproveStopSignal, listener: () => void) => unknown;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Arm the stop path and return the disarm function. The record is read through
|
|
51
|
+
* a getter because the caller reassigns it as each stage settles, and the kit
|
|
52
|
+
* written on the way out has to describe the record as it stands at the moment
|
|
53
|
+
* of the stop.
|
|
54
|
+
*
|
|
55
|
+
* What this cannot do: SIGKILL, which a lane timeout may send, runs no handler
|
|
56
|
+
* at all. That case leaves the journal's last progress line as the record, and
|
|
57
|
+
* `12ui next` reads it as an unfinished paid run — which is the truth.
|
|
58
|
+
*/
|
|
59
|
+
export declare const registerImproveStopHandler: (args: {
|
|
60
|
+
getRecord: () => ImproveRecord;
|
|
61
|
+
/**
|
|
62
|
+
* The stage this invocation is inside right now. Without it the handler can
|
|
63
|
+
* only ask the record, which a `--fresh` conversion in flight makes a liar.
|
|
64
|
+
*/
|
|
65
|
+
getLiveStage?: ImproveLiveStage;
|
|
66
|
+
write: (line: string) => void;
|
|
67
|
+
requestedTo?: ImproveStage;
|
|
68
|
+
journal?: RunJournalNotes;
|
|
69
|
+
onStopped?: (result: ImproveStopArtifacts) => void;
|
|
70
|
+
target?: ImproveStopTarget;
|
|
71
|
+
exit?: (code: number) => void;
|
|
72
|
+
}) => (() => void);
|
|
73
|
+
//# sourceMappingURL=improve-stop-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"improve-stop-handler.d.ts","sourceRoot":"","sources":["../src/improve-stop-handler.ts"],"names":[],"mappings":"AAKA,OAAO,EAIL,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,YAAY,EAClB,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAElC,MAAM,MAAM,oBAAoB,GAAG;IACjC,8EAA8E;IAC9E,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAKF,eAAO,MAAM,yBAAyB,GAAU,MAAM;IACpD,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,sFAAsF;IACtF,IAAI,CAAC,EAAE,YAAY,CAAC;CACrB,KAAG,OAAO,CAAC,oBAAoB,CA+D/B,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,CAAC,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,IAAI,KAAK,OAAO,CAAC;IACnE,GAAG,EAAE,CAAC,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,IAAI,KAAK,OAAO,CAAC;CACnE,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,GAAI,MAAM;IAC/C,SAAS,EAAE,MAAM,aAAa,CAAC;IAC/B;;;OAGG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,WAAW,CAAC,EAAE,YAAY,CAAC;IAC3B,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACnD,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/B,KAAG,CAAC,MAAM,IAAI,CAuCd,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { writeImproveReadme } from './improve-kit-readme.js';
|
|
3
|
+
import { writeImproveStallReport } from './improve-kit-stall.js';
|
|
4
|
+
import { buildImproveRunSummary } from './improve-run-summary.js';
|
|
5
|
+
import { improveUnsettledStage, IMPROVE_SIGNALLED_AFTER_COMPLETION, noteImproveTerminalEvent, } from './improve-terminal-event.js';
|
|
6
|
+
import { improvePaths, readImproveRecord, } from './improve-workspace.js';
|
|
7
|
+
/** Exit codes for a signalled stop are 128 plus the signal number. */
|
|
8
|
+
const EXIT_CODE = { SIGINT: 130, SIGTERM: 143 };
|
|
9
|
+
export const writeImproveStopArtifacts = async (args) => {
|
|
10
|
+
// WHAT DECIDES. Live invocation state first, the record only when this
|
|
11
|
+
// invocation has nothing in flight. A stage this process is still inside is
|
|
12
|
+
// proof the run is not complete, whatever the record says — and after
|
|
13
|
+
// `--fresh` the record says the opposite, because the clear it wrote to disk
|
|
14
|
+
// has not reached the copy held here. "Signalled after completion" is only
|
|
15
|
+
// true when no stage is in flight AND every requested stage has settled.
|
|
16
|
+
const stage = args.live ?? improveUnsettledStage(args.record, args.requestedTo);
|
|
17
|
+
const context = args.requestedTo ? { requestedTo: args.requestedTo } : {};
|
|
18
|
+
const paths = improvePaths(args.record.runDir);
|
|
19
|
+
// The handler stays armed until the `finally` block, so a signal can land
|
|
20
|
+
// after the last requested stage has settled. That run is complete: writing
|
|
21
|
+
// "# INCOMPLETE — this run was stopped" over it, and journalling a stop that
|
|
22
|
+
// leaves a hosted run open, is the kit lying in the opposite direction from
|
|
23
|
+
// the pipedrive defect. It gets the terminal line, the README and the
|
|
24
|
+
// ordinary summary, and no STALL.md.
|
|
25
|
+
if (!stage) {
|
|
26
|
+
const errorClass = await noteImproveTerminalEvent({
|
|
27
|
+
record: args.record,
|
|
28
|
+
stage: args.requestedTo ?? 'plan',
|
|
29
|
+
kind: 'stopped',
|
|
30
|
+
error: new Error(`The run was stopped with ${args.signal} after every requested stage settled.`),
|
|
31
|
+
signal: args.signal,
|
|
32
|
+
errorClass: IMPROVE_SIGNALLED_AFTER_COMPLETION,
|
|
33
|
+
writes: [paths.readme],
|
|
34
|
+
...(args.journal ? { journal: args.journal } : {}),
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
readme: await writeImproveReadme(args.record, context),
|
|
38
|
+
summary: await buildImproveRunSummary({ record: args.record, ...context }),
|
|
39
|
+
errorClass,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const error = new Error(`The run was stopped with ${args.signal} before ${stage} settled.`);
|
|
43
|
+
// The record closes FIRST. Everything after this is a filesystem write that a
|
|
44
|
+
// second signal can cut short; the journal line cannot be written later.
|
|
45
|
+
const errorClass = await noteImproveTerminalEvent({
|
|
46
|
+
record: args.record,
|
|
47
|
+
stage,
|
|
48
|
+
kind: 'stopped',
|
|
49
|
+
error,
|
|
50
|
+
signal: args.signal,
|
|
51
|
+
writes: [path.join(paths.planDir, 'STALL.md'), paths.readme],
|
|
52
|
+
...(args.live ? { inFlight: true } : {}),
|
|
53
|
+
...(args.journal ? { journal: args.journal } : {}),
|
|
54
|
+
});
|
|
55
|
+
// The kit is written from the DURABLE record, the way the stall path in
|
|
56
|
+
// `cli-improve-command.ts` already does: a stage in flight has written down
|
|
57
|
+
// what it abandoned and what it cleared, and the in-memory copy predates
|
|
58
|
+
// that. It is read only AFTER the end line, so the one-read-before-the-end
|
|
59
|
+
// rule this module's header states still holds.
|
|
60
|
+
const durable = await readImproveRecord(paths.record) ?? args.record;
|
|
61
|
+
const stall = await writeImproveStallReport({
|
|
62
|
+
record: durable,
|
|
63
|
+
stage,
|
|
64
|
+
error,
|
|
65
|
+
kind: 'stopped',
|
|
66
|
+
...(args.live ? { inFlight: true } : {}),
|
|
67
|
+
...context,
|
|
68
|
+
});
|
|
69
|
+
const readme = await writeImproveReadme(durable, context);
|
|
70
|
+
const summary = await buildImproveRunSummary({ record: durable, ...context });
|
|
71
|
+
return { stage, stall, readme, summary, errorClass };
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Arm the stop path and return the disarm function. The record is read through
|
|
75
|
+
* a getter because the caller reassigns it as each stage settles, and the kit
|
|
76
|
+
* written on the way out has to describe the record as it stands at the moment
|
|
77
|
+
* of the stop.
|
|
78
|
+
*
|
|
79
|
+
* What this cannot do: SIGKILL, which a lane timeout may send, runs no handler
|
|
80
|
+
* at all. That case leaves the journal's last progress line as the record, and
|
|
81
|
+
* `12ui next` reads it as an unfinished paid run — which is the truth.
|
|
82
|
+
*/
|
|
83
|
+
export const registerImproveStopHandler = (args) => {
|
|
84
|
+
const target = args.target ?? process;
|
|
85
|
+
const exit = args.exit ?? ((code) => { process.exit(code); });
|
|
86
|
+
const signals = ['SIGINT', 'SIGTERM'];
|
|
87
|
+
let stopping = false;
|
|
88
|
+
const listeners = new Map();
|
|
89
|
+
const disarm = () => {
|
|
90
|
+
for (const [signal, listener] of listeners)
|
|
91
|
+
target.off(signal, listener);
|
|
92
|
+
listeners.clear();
|
|
93
|
+
};
|
|
94
|
+
for (const signal of signals) {
|
|
95
|
+
const listener = () => {
|
|
96
|
+
if (stopping)
|
|
97
|
+
return;
|
|
98
|
+
stopping = true;
|
|
99
|
+
disarm();
|
|
100
|
+
void (async () => {
|
|
101
|
+
try {
|
|
102
|
+
const live = args.getLiveStage?.();
|
|
103
|
+
const result = await writeImproveStopArtifacts({
|
|
104
|
+
record: args.getRecord(),
|
|
105
|
+
signal,
|
|
106
|
+
...(live ? { live } : {}),
|
|
107
|
+
...(args.requestedTo ? { requestedTo: args.requestedTo } : {}),
|
|
108
|
+
...(args.journal ? { journal: args.journal } : {}),
|
|
109
|
+
});
|
|
110
|
+
args.write(result.summary);
|
|
111
|
+
args.onStopped?.(result);
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
// Say so rather than exiting quietly: an unwritten kit that also
|
|
115
|
+
// said nothing is the failure this whole path exists to end.
|
|
116
|
+
args.write(`Could not write the stopped kit: ${error instanceof Error ? error.message : String(error)}`);
|
|
117
|
+
}
|
|
118
|
+
exit(EXIT_CODE[signal]);
|
|
119
|
+
})();
|
|
120
|
+
};
|
|
121
|
+
listeners.set(signal, listener);
|
|
122
|
+
target.once(signal, listener);
|
|
123
|
+
}
|
|
124
|
+
return disarm;
|
|
125
|
+
};
|
|
126
|
+
//# sourceMappingURL=improve-stop-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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