hadara 0.1.0-rc.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/LICENSE +21 -0
- package/README.md +109 -0
- package/dist/agent/evidence.js +50 -0
- package/dist/agent/loop.js +124 -0
- package/dist/cli/args.js +70 -0
- package/dist/cli/dashboard.js +185 -0
- package/dist/cli/debt.js +41 -0
- package/dist/cli/doctor.js +68 -0
- package/dist/cli/errors.js +58 -0
- package/dist/cli/evidence-json.js +75 -0
- package/dist/cli/evidence.js +80 -0
- package/dist/cli/handoff.js +16 -0
- package/dist/cli/harness.js +57 -0
- package/dist/cli/hermes-json.js +31 -0
- package/dist/cli/hermes.js +28 -0
- package/dist/cli/init.js +142 -0
- package/dist/cli/install.js +34 -0
- package/dist/cli/main.js +216 -0
- package/dist/cli/mcp.js +15 -0
- package/dist/cli/package-smoke.js +37 -0
- package/dist/cli/policy-json.js +22 -0
- package/dist/cli/policy.js +43 -0
- package/dist/cli/release-artifact.js +47 -0
- package/dist/cli/release-dry-run.js +24 -0
- package/dist/cli/release-gate.js +28 -0
- package/dist/cli/release-publish.js +41 -0
- package/dist/cli/run-scaffold.js +68 -0
- package/dist/cli/run-state.js +41 -0
- package/dist/cli/run.js +191 -0
- package/dist/cli/smoke.js +58 -0
- package/dist/cli/status-json.js +6 -0
- package/dist/cli/status.js +26 -0
- package/dist/cli/task-json.js +8 -0
- package/dist/cli/task.js +64 -0
- package/dist/cli/tools.js +25 -0
- package/dist/cli/tui.js +72 -0
- package/dist/cli/write-preflight.js +27 -0
- package/dist/core/audit.js +41 -0
- package/dist/core/events.js +63 -0
- package/dist/core/fs.js +44 -0
- package/dist/core/paths.js +59 -0
- package/dist/core/redaction.js +178 -0
- package/dist/core/schema.js +253 -0
- package/dist/core/workspace.js +47 -0
- package/dist/evidence/evidence.js +170 -0
- package/dist/evidence/private-manifest.js +101 -0
- package/dist/handoff/handoff.js +49 -0
- package/dist/harness/replay.js +200 -0
- package/dist/harness/validate.js +465 -0
- package/dist/hermes/context-export.js +104 -0
- package/dist/index.js +29 -0
- package/dist/mcp/server.js +104 -0
- package/dist/mcp/tool-dispatch.js +159 -0
- package/dist/mcp/tool-registry.js +150 -0
- package/dist/mcp/tool-schemas.js +18 -0
- package/dist/policy/command-risk.js +39 -0
- package/dist/policy/permission-matrix.js +42 -0
- package/dist/policy/policy.js +20 -0
- package/dist/policy/preflight.js +47 -0
- package/dist/policy/presets.js +24 -0
- package/dist/policy/tokenizer.js +53 -0
- package/dist/providers/fallback-executor.js +46 -0
- package/dist/providers/mock-provider.js +49 -0
- package/dist/providers/provider-contract.js +2 -0
- package/dist/providers/provider-preparation.js +220 -0
- package/dist/providers/scripted-provider.js +69 -0
- package/dist/schemas/active-run-projection.schema.json +73 -0
- package/dist/schemas/active-run-resume.schema.json +68 -0
- package/dist/schemas/clean-checkout-smoke.schema.json +126 -0
- package/dist/schemas/context-export.schema.json +35 -0
- package/dist/schemas/event.schema.json +17 -0
- package/dist/schemas/evidence-list.schema.json +49 -0
- package/dist/schemas/feature-smoke.schema.json +67 -0
- package/dist/schemas/install-plan.schema.json +93 -0
- package/dist/schemas/package-smoke.schema.json +130 -0
- package/dist/schemas/private-evidence.schema.json +48 -0
- package/dist/schemas/provider-call.schema.json +42 -0
- package/dist/schemas/provider-config.schema.json +43 -0
- package/dist/schemas/release-artifact-manifest.schema.json +55 -0
- package/dist/schemas/release-artifact.schema.json +140 -0
- package/dist/schemas/release-dry-run.schema.json +141 -0
- package/dist/schemas/release-gate.schema.json +42 -0
- package/dist/schemas/release-publish.schema.json +114 -0
- package/dist/schemas/schema-index.json +145 -0
- package/dist/schemas/smoke-evidence-summary.schema.json +88 -0
- package/dist/schemas/tools-list.schema.json +78 -0
- package/dist/schemas/write-preflight.schema.json +47 -0
- package/dist/services/active-run-state.js +215 -0
- package/dist/services/capability-registry.js +540 -0
- package/dist/services/clean-checkout-smoke.js +393 -0
- package/dist/services/evidence-list.js +136 -0
- package/dist/services/feature-smoke.js +155 -0
- package/dist/services/harness-service.js +7 -0
- package/dist/services/install-plan.js +233 -0
- package/dist/services/operational-debt.js +767 -0
- package/dist/services/operations-status-service.js +195 -0
- package/dist/services/package-smoke.js +676 -0
- package/dist/services/policy-service.js +25 -0
- package/dist/services/project-read-model.js +101 -0
- package/dist/services/release-artifact-evidence.js +77 -0
- package/dist/services/release-artifact.js +351 -0
- package/dist/services/release-dry-run.js +253 -0
- package/dist/services/release-evidence.js +138 -0
- package/dist/services/release-publish.js +163 -0
- package/dist/services/smoke-evidence.js +104 -0
- package/dist/services/task-read-model.js +125 -0
- package/dist/services/tools-list.js +26 -0
- package/dist/services/write-preflight.js +240 -0
- package/dist/task/task-capsule.js +121 -0
- package/dist/tools/fake-shell.js +56 -0
- package/dist/tui/cache.js +341 -0
- package/dist/tui/constants.js +44 -0
- package/dist/tui/layout.js +140 -0
- package/dist/tui/markdown.js +238 -0
- package/dist/tui/read-model-worker.js +24 -0
- package/dist/tui/read-model.js +502 -0
- package/dist/tui/snapshot.js +434 -0
- package/dist/tui/state.js +229 -0
- package/dist/tui/terminal.js +475 -0
- package/dist/tui/theme.js +86 -0
- package/package.json +16 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderMarkdownDocument = renderMarkdownDocument;
|
|
4
|
+
exports.markdownPreview = markdownPreview;
|
|
5
|
+
exports.incompleteChecklist = incompleteChecklist;
|
|
6
|
+
exports.evidenceFromMarkdown = evidenceFromMarkdown;
|
|
7
|
+
exports.cleanPreviewLine = cleanPreviewLine;
|
|
8
|
+
const layout_1 = require("./layout");
|
|
9
|
+
function renderMarkdownDocument(markdown, width, options = {}) {
|
|
10
|
+
const sourceLines = String(markdown || '').split(/\r?\n/);
|
|
11
|
+
const rows = [];
|
|
12
|
+
for (let index = 0; index < sourceLines.length; index += 1) {
|
|
13
|
+
const raw = sourceLines[index].trimEnd();
|
|
14
|
+
const line = raw.trim();
|
|
15
|
+
if (!line) {
|
|
16
|
+
pushBlank(rows, options.maxRows);
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (isMarkdownTableStart(sourceLines, index)) {
|
|
20
|
+
const tableLines = [sourceLines[index]];
|
|
21
|
+
index += 2;
|
|
22
|
+
while (index < sourceLines.length && /^\s*\|.+\|\s*$/.test(sourceLines[index] ?? '')) {
|
|
23
|
+
tableLines.push(sourceLines[index]);
|
|
24
|
+
index += 1;
|
|
25
|
+
}
|
|
26
|
+
index -= 1;
|
|
27
|
+
pushMany(rows, renderMarkdownTable(tableLines, width), options.maxRows);
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const heading = line.match(/^(#{1,6})\s+(.+?)\s*$/);
|
|
31
|
+
if (heading) {
|
|
32
|
+
const title = heading[2].replace(/\s+#+$/, '').trim();
|
|
33
|
+
if (rows.length && rows[rows.length - 1] !== '')
|
|
34
|
+
pushBlank(rows, options.maxRows);
|
|
35
|
+
pushMany(rows, [(0, layout_1.trimFit)(heading[1].length === 1 ? title : title.toUpperCase(), width)], options.maxRows);
|
|
36
|
+
if (heading[1].length <= 2)
|
|
37
|
+
pushMany(rows, [(0, layout_1.repeat)('─', Math.min(width, Math.max(12, (0, layout_1.visibleWidth)(title) + 6)))], options.maxRows);
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const checkbox = line.match(/^[-*]\s+\[([ xX])\]\s+(.*)$/);
|
|
41
|
+
if (checkbox) {
|
|
42
|
+
const mark = checkbox[1].trim() ? 'x' : ' ';
|
|
43
|
+
pushMany(rows, renderWrapped(`[${mark}] ${checkbox[2]}`, width, ' '), options.maxRows);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const bullet = line.match(/^[-*]\s+(.*)$/);
|
|
47
|
+
if (bullet) {
|
|
48
|
+
pushMany(rows, renderWrapped(`• ${bullet[1]}`, width, ' '), options.maxRows);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const numbered = line.match(/^(\d+)\.\s+(.*)$/);
|
|
52
|
+
if (numbered) {
|
|
53
|
+
pushMany(rows, renderWrapped(`${numbered[1].padStart(2, '0')} ${numbered[2]}`, width, ' '), options.maxRows);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
pushMany(rows, renderWrapped(line, width, ''), options.maxRows);
|
|
57
|
+
}
|
|
58
|
+
return rows.length ? rows : [''];
|
|
59
|
+
}
|
|
60
|
+
function markdownPreview(markdown, options = 2) {
|
|
61
|
+
const previewOptions = typeof options === 'number' ? { limit: options } : options;
|
|
62
|
+
const limit = previewOptions.limit ?? 2;
|
|
63
|
+
const section = previewOptions.headings?.length ? markdownSection(markdown, previewOptions.headings, limit) : [];
|
|
64
|
+
if (section.length)
|
|
65
|
+
return section;
|
|
66
|
+
const parsed = parseMarkdown(markdown);
|
|
67
|
+
return parsed.lines.slice(0, limit);
|
|
68
|
+
}
|
|
69
|
+
function incompleteChecklist(markdown, limit = 2) {
|
|
70
|
+
return String(markdown || '')
|
|
71
|
+
.split(/\r?\n/)
|
|
72
|
+
.filter((line) => /^\s*[-*]\s+\[\s\]/.test(line))
|
|
73
|
+
.map(cleanPreviewLine)
|
|
74
|
+
.filter(Boolean)
|
|
75
|
+
.slice(0, limit);
|
|
76
|
+
}
|
|
77
|
+
function evidenceFromMarkdown(markdown, limit = 2) {
|
|
78
|
+
return String(markdown || '')
|
|
79
|
+
.split(/\r?\n/)
|
|
80
|
+
.map((line) => {
|
|
81
|
+
if (/^\s*#{1,6}\s+/.test(line))
|
|
82
|
+
return '';
|
|
83
|
+
const cells = line.trim().match(/^\|\s*([^|]+?)\s*\|\s*([^|]+?)\s*\|\s*([^|]+?)\s*\|\s*([^|]+?)\s*\|$/);
|
|
84
|
+
if (!cells)
|
|
85
|
+
return cleanPreviewLine(line);
|
|
86
|
+
if (/^time$/i.test(cells[1] ?? '') || /^---$/.test(cells[1] ?? ''))
|
|
87
|
+
return '';
|
|
88
|
+
return `${String(cells[4] ?? '').trim()}: ${String(cells[3] ?? '').trim()}`;
|
|
89
|
+
})
|
|
90
|
+
.map(cleanPreviewLine)
|
|
91
|
+
.filter(Boolean)
|
|
92
|
+
.slice(0, limit);
|
|
93
|
+
}
|
|
94
|
+
function cleanPreviewLine(value) {
|
|
95
|
+
return String(value ?? '')
|
|
96
|
+
.replace(/^#{1,6}\s+/, '')
|
|
97
|
+
.replace(/^[-*]\s+\[[ xX]\]\s+/, '')
|
|
98
|
+
.replace(/^[-*]\s+/, '')
|
|
99
|
+
.replace(/\s+/g, ' ')
|
|
100
|
+
.trim();
|
|
101
|
+
}
|
|
102
|
+
function renderMarkdownTable(lines, width) {
|
|
103
|
+
const header = tableCells(lines[0] ?? '');
|
|
104
|
+
const rows = lines
|
|
105
|
+
.slice(1)
|
|
106
|
+
.filter((line) => !isMarkdownTableSeparator(line))
|
|
107
|
+
.map(tableCells)
|
|
108
|
+
.filter((cells) => cells.length && cells.some(Boolean));
|
|
109
|
+
const columnCount = Math.max(header.length, ...rows.map((row) => row.length));
|
|
110
|
+
if (!columnCount)
|
|
111
|
+
return [];
|
|
112
|
+
const normalizedRows = rows.map((row) => Array.from({ length: columnCount }, (_, index) => row[index] || ''));
|
|
113
|
+
const widths = Array.from({ length: columnCount }, (_, index) => {
|
|
114
|
+
const values = [header[index] || '', ...normalizedRows.map((row) => row[index] || '')];
|
|
115
|
+
return Math.max(3, Math.min(28, Math.max(...values.map((value) => (0, layout_1.visibleWidth)(value)))));
|
|
116
|
+
});
|
|
117
|
+
shrinkTableWidths(widths, Math.max(20, width));
|
|
118
|
+
const dividerLine = widths.map((columnWidth) => (0, layout_1.repeat)('─', columnWidth)).join('─┼─');
|
|
119
|
+
return [renderTableRow(header, widths), dividerLine, ...normalizedRows.map((row) => renderTableRow(row, widths))].map((line) => (0, layout_1.trimFit)(line, width));
|
|
120
|
+
}
|
|
121
|
+
function parseMarkdown(markdown) {
|
|
122
|
+
const parsed = { lines: [], sections: {} };
|
|
123
|
+
let current = null;
|
|
124
|
+
for (const rawLine of String(markdown || '').split(/\r?\n/)) {
|
|
125
|
+
const heading = rawLine.match(/^(#{1,6})\s+(.+?)\s*$/);
|
|
126
|
+
if (heading) {
|
|
127
|
+
current = normalizeHeading(heading[2].replace(/\s+#+$/, '').trim());
|
|
128
|
+
if (!parsed.sections[current])
|
|
129
|
+
parsed.sections[current] = [];
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const cleaned = cleanPreviewLine(rawLine);
|
|
133
|
+
if (!cleaned || cleaned.startsWith('|---'))
|
|
134
|
+
continue;
|
|
135
|
+
if (current)
|
|
136
|
+
parsed.sections[current].push(cleaned);
|
|
137
|
+
else
|
|
138
|
+
parsed.lines.push(cleaned);
|
|
139
|
+
}
|
|
140
|
+
return parsed;
|
|
141
|
+
}
|
|
142
|
+
function markdownSection(markdown, headings, limit) {
|
|
143
|
+
const parsed = parseMarkdown(markdown);
|
|
144
|
+
for (const heading of headings) {
|
|
145
|
+
const section = parsed.sections[normalizeHeading(heading)];
|
|
146
|
+
if (section?.length)
|
|
147
|
+
return section.slice(0, limit);
|
|
148
|
+
}
|
|
149
|
+
return [];
|
|
150
|
+
}
|
|
151
|
+
function normalizeHeading(value) {
|
|
152
|
+
return String(value || '')
|
|
153
|
+
.toLowerCase()
|
|
154
|
+
.replace(/[^a-z0-9]+/g, ' ')
|
|
155
|
+
.trim();
|
|
156
|
+
}
|
|
157
|
+
function isMarkdownTableStart(lines, index) {
|
|
158
|
+
return /^\s*\|.+\|\s*$/.test(lines[index] ?? '') && isMarkdownTableSeparator(lines[index + 1] ?? '');
|
|
159
|
+
}
|
|
160
|
+
function isMarkdownTableSeparator(line) {
|
|
161
|
+
return /^\s*\|\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)+\|\s*$/.test(line || '');
|
|
162
|
+
}
|
|
163
|
+
function tableCells(line) {
|
|
164
|
+
return String(line || '')
|
|
165
|
+
.trim()
|
|
166
|
+
.split('|')
|
|
167
|
+
.slice(1, -1)
|
|
168
|
+
.map(cleanPreviewLine);
|
|
169
|
+
}
|
|
170
|
+
function shrinkTableWidths(widths, width) {
|
|
171
|
+
const gapWidth = Math.max(0, widths.length - 1) * 3;
|
|
172
|
+
while (widths.reduce((sum, columnWidth) => sum + columnWidth, gapWidth) > width) {
|
|
173
|
+
const largest = widths.reduce((best, columnWidth, index) => (columnWidth > widths[best] ? index : best), 0);
|
|
174
|
+
if (widths[largest] <= 6)
|
|
175
|
+
break;
|
|
176
|
+
widths[largest] -= 1;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function renderTableRow(cells, widths) {
|
|
180
|
+
return widths.map((columnWidth, index) => (0, layout_1.fit)(cells[index] || '', columnWidth)).join(' │ ');
|
|
181
|
+
}
|
|
182
|
+
function renderWrapped(text, width, indent) {
|
|
183
|
+
const targetWidth = Math.max(12, width);
|
|
184
|
+
const words = String(text || '').split(/\s+/).filter(Boolean);
|
|
185
|
+
if (!words.length)
|
|
186
|
+
return [''];
|
|
187
|
+
const lines = [];
|
|
188
|
+
let current = '';
|
|
189
|
+
for (const word of words) {
|
|
190
|
+
const candidate = current ? `${current} ${word}` : word;
|
|
191
|
+
if ((0, layout_1.visibleWidth)(candidate) <= targetWidth) {
|
|
192
|
+
current = candidate;
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
if (current)
|
|
196
|
+
lines.push(current);
|
|
197
|
+
current = `${indent}${word}`;
|
|
198
|
+
}
|
|
199
|
+
if (current)
|
|
200
|
+
lines.push(current);
|
|
201
|
+
return lines.flatMap((line) => splitLongLine(line, targetWidth));
|
|
202
|
+
}
|
|
203
|
+
function splitLongLine(line, width) {
|
|
204
|
+
if ((0, layout_1.visibleWidth)(line) <= width)
|
|
205
|
+
return [line];
|
|
206
|
+
const chunks = [];
|
|
207
|
+
let remaining = line;
|
|
208
|
+
while ((0, layout_1.visibleWidth)(remaining) > width) {
|
|
209
|
+
chunks.push((0, layout_1.trimFit)(remaining, width));
|
|
210
|
+
remaining = `${(0, layout_1.repeat)(' ', 2)}${takeRemainderByVisibleWidth(remaining, Math.max(1, width - 1)).trimStart()}`;
|
|
211
|
+
}
|
|
212
|
+
chunks.push(remaining);
|
|
213
|
+
return chunks;
|
|
214
|
+
}
|
|
215
|
+
function takeRemainderByVisibleWidth(text, width) {
|
|
216
|
+
let used = 0;
|
|
217
|
+
let index = 0;
|
|
218
|
+
const chars = Array.from(text);
|
|
219
|
+
for (; index < chars.length; index += 1) {
|
|
220
|
+
const charWidth = (chars[index].codePointAt(0) ?? 0) > 0x2e80 ? 2 : 1;
|
|
221
|
+
if (used + charWidth > width)
|
|
222
|
+
break;
|
|
223
|
+
used += charWidth;
|
|
224
|
+
}
|
|
225
|
+
return chars.slice(index).join('');
|
|
226
|
+
}
|
|
227
|
+
function pushBlank(rows, maxRows) {
|
|
228
|
+
if (maxRows !== undefined && rows.length >= maxRows)
|
|
229
|
+
return;
|
|
230
|
+
rows.push('');
|
|
231
|
+
}
|
|
232
|
+
function pushMany(rows, lines, maxRows) {
|
|
233
|
+
for (const line of lines) {
|
|
234
|
+
if (maxRows !== undefined && rows.length >= maxRows)
|
|
235
|
+
return;
|
|
236
|
+
rows.push(line);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const node_worker_threads_1 = require("node:worker_threads");
|
|
4
|
+
const read_model_1 = require("./read-model");
|
|
5
|
+
const cache_1 = require("./cache");
|
|
6
|
+
function loadModel(input) {
|
|
7
|
+
if (input.cache?.enabled) {
|
|
8
|
+
return (0, cache_1.createTuiReadModelWithCache)(input.projectRoot, {
|
|
9
|
+
...input.readOptions,
|
|
10
|
+
cache: {
|
|
11
|
+
enabled: true,
|
|
12
|
+
root: input.cache.root,
|
|
13
|
+
refresh: input.refresh
|
|
14
|
+
}
|
|
15
|
+
}).model;
|
|
16
|
+
}
|
|
17
|
+
return (0, read_model_1.createTuiReadModel)(input.projectRoot, input.readOptions);
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
node_worker_threads_1.parentPort?.postMessage({ ok: true, model: loadModel(node_worker_threads_1.workerData) });
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
node_worker_threads_1.parentPort?.postMessage({ ok: false, error: error instanceof Error ? error.message : String(error) });
|
|
24
|
+
}
|