@granular-software/fractory 0.0.0-stage → 0.1.25
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 +4 -0
- package/README.md +28 -2
- package/dist/activity-volume.d.ts +18 -0
- package/dist/activity-volume.js +94 -0
- package/dist/annotations.d.ts +122 -0
- package/dist/annotations.js +304 -0
- package/dist/benchmark-cli.d.ts +1 -0
- package/dist/benchmark-cli.js +95 -0
- package/dist/benchmark-worker.d.ts +2 -0
- package/dist/benchmark-worker.js +22 -0
- package/dist/benchmarks.d.ts +19 -0
- package/dist/benchmarks.js +414 -0
- package/dist/bin.d.ts +2 -0
- package/dist/bin.js +63 -0
- package/dist/block-cli.d.ts +1 -0
- package/dist/block-cli.js +88 -0
- package/dist/block-documents.d.ts +35 -0
- package/dist/block-documents.js +84 -0
- package/dist/change-impact.d.ts +55 -0
- package/dist/change-impact.js +223 -0
- package/dist/check-source.d.ts +2 -0
- package/dist/check-source.js +66 -0
- package/dist/checks-model.d.ts +64 -0
- package/dist/checks-model.js +36 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +359 -0
- package/dist/code-model.d.ts +38 -0
- package/dist/code-model.js +94 -0
- package/dist/code-store.d.ts +9 -0
- package/dist/code-store.js +79 -0
- package/dist/compare-artifact.d.ts +6 -0
- package/dist/compare-artifact.js +277 -0
- package/dist/compare.d.ts +81 -0
- package/dist/compare.js +291 -0
- package/dist/compiler.d.ts +10 -0
- package/dist/compiler.js +1240 -0
- package/dist/compose.d.ts +9 -0
- package/dist/compose.js +72 -0
- package/dist/core.d.ts +87 -0
- package/dist/core.js +207 -0
- package/dist/coverage-cli.d.ts +1 -0
- package/dist/coverage-cli.js +42 -0
- package/dist/declaration-sources.d.ts +3 -0
- package/dist/declaration-sources.js +51 -0
- package/dist/declared-graph.d.ts +3 -0
- package/dist/declared-graph.js +67 -0
- package/dist/display-name.d.ts +2 -0
- package/dist/display-name.js +8 -0
- package/dist/error-heat.d.ts +58 -0
- package/dist/error-heat.js +96 -0
- package/dist/evidence.d.ts +3 -0
- package/dist/evidence.js +68 -0
- package/dist/factory-graph.d.ts +7 -0
- package/dist/factory-graph.js +389 -0
- package/dist/factory-model.d.ts +111 -0
- package/dist/factory-model.js +1 -0
- package/dist/git-code.d.ts +47 -0
- package/dist/git-code.js +352 -0
- package/dist/git-refs.d.ts +4 -0
- package/dist/git-refs.js +37 -0
- package/dist/history-activity.d.ts +4 -0
- package/dist/history-activity.js +129 -0
- package/dist/history-churn.d.ts +36 -0
- package/dist/history-churn.js +302 -0
- package/dist/history-git.d.ts +21 -0
- package/dist/history-git.js +125 -0
- package/dist/history-ledger.d.ts +43 -0
- package/dist/history-ledger.js +450 -0
- package/dist/history-ownership.d.ts +10 -0
- package/dist/history-ownership.js +75 -0
- package/dist/history-source.d.ts +13 -0
- package/dist/history-source.js +100 -0
- package/dist/integrations-cli.d.ts +2 -0
- package/dist/integrations-cli.js +159 -0
- package/dist/interface-map.d.ts +15 -0
- package/dist/interface-map.js +125 -0
- package/dist/issue-cache.d.ts +9 -0
- package/dist/issue-cache.js +68 -0
- package/dist/issue-cli.d.ts +1 -0
- package/dist/issue-cli.js +89 -0
- package/dist/issue-links.d.ts +15 -0
- package/dist/issue-links.js +125 -0
- package/dist/linear-issues.d.ts +19 -0
- package/dist/linear-issues.js +124 -0
- package/dist/local-runtime.d.ts +8 -0
- package/dist/local-runtime.js +59 -0
- package/dist/map-activity.d.ts +73 -0
- package/dist/map-activity.js +234 -0
- package/dist/map-model.d.ts +5 -0
- package/dist/map-model.js +166 -0
- package/dist/map-quality.d.ts +20 -0
- package/dist/map-quality.js +61 -0
- package/dist/mapping-coverage.d.ts +87 -0
- package/dist/mapping-coverage.js +404 -0
- package/dist/model.d.ts +186 -0
- package/dist/model.js +66 -0
- package/dist/operation-benchmark-worker.d.ts +2 -0
- package/dist/operation-benchmark-worker.js +60 -0
- package/dist/operation-benchmark.d.ts +29 -0
- package/dist/operation-benchmark.js +1 -0
- package/dist/otel-metrics.d.ts +21 -0
- package/dist/otel-metrics.js +146 -0
- package/dist/performance-model.d.ts +185 -0
- package/dist/performance-model.js +396 -0
- package/dist/product-map.d.ts +71 -0
- package/dist/product-map.js +197 -0
- package/dist/provider-access.cjs +207 -0
- package/dist/provider-access.d.cts +14 -0
- package/dist/public-boundaries.d.ts +13 -0
- package/dist/public-boundaries.js +115 -0
- package/dist/reports-cli.d.ts +1 -0
- package/dist/reports-cli.js +111 -0
- package/dist/reports-model.d.ts +27 -0
- package/dist/reports-model.js +39 -0
- package/dist/reports.d.ts +23 -0
- package/dist/reports.js +223 -0
- package/dist/repository-map.d.ts +22 -0
- package/dist/repository-map.js +153 -0
- package/dist/resource-cache.d.ts +17 -0
- package/dist/resource-cache.js +65 -0
- package/dist/review-cli.d.ts +19 -0
- package/dist/review-cli.js +224 -0
- package/dist/review.d.ts +48 -0
- package/dist/review.js +289 -0
- package/dist/runtime-metrics.d.ts +26 -0
- package/dist/runtime-metrics.js +290 -0
- package/dist/scope.d.ts +14 -0
- package/dist/scope.js +168 -0
- package/dist/sentry-activity.d.ts +39 -0
- package/dist/sentry-activity.js +174 -0
- package/dist/sentry.d.ts +130 -0
- package/dist/sentry.js +369 -0
- package/dist/service-release.d.ts +16 -0
- package/dist/service-release.js +14 -0
- package/dist/setup-cli.d.ts +2 -0
- package/dist/setup-cli.js +52 -0
- package/dist/setup-kit.cjs +163 -0
- package/dist/setup-kit.d.cts +32 -0
- package/dist/source-index.d.ts +37 -0
- package/dist/source-index.js +170 -0
- package/dist/source-review-git.d.ts +7 -0
- package/dist/source-review-git.js +105 -0
- package/dist/source-review.d.ts +18 -0
- package/dist/source-review.js +573 -0
- package/dist/telemetry.d.ts +17 -0
- package/dist/telemetry.js +51 -0
- package/dist/time-window.d.ts +9 -0
- package/dist/time-window.js +35 -0
- package/dist/trace-evidence.d.ts +23 -0
- package/dist/trace-evidence.js +55 -0
- package/dist/trace-model.d.ts +26 -0
- package/dist/trace-model.js +1 -0
- package/dist/tracing.d.ts +44 -0
- package/dist/tracing.js +123 -0
- package/dist/work-check.d.ts +18 -0
- package/dist/work-check.js +115 -0
- package/dist/work-cli.d.ts +1 -0
- package/dist/work-cli.js +176 -0
- package/dist/work-context.d.ts +59 -0
- package/dist/work-context.js +594 -0
- package/dist/work-intents.d.ts +6 -0
- package/dist/work-intents.js +140 -0
- package/dist/work-items.d.ts +58 -0
- package/dist/work-items.js +86 -0
- package/dist/work-lock-check.d.ts +12 -0
- package/dist/work-lock-check.js +339 -0
- package/dist/work-locks.d.ts +10 -0
- package/dist/work-locks.js +98 -0
- package/dist/work-model.d.ts +119 -0
- package/dist/work-model.js +310 -0
- package/dist/work-review-git.d.ts +8 -0
- package/dist/work-review-git.js +111 -0
- package/dist/work-review.d.ts +26 -0
- package/dist/work-review.js +426 -0
- package/dist/work-switcher-model.d.ts +43 -0
- package/dist/work-switcher-model.js +79 -0
- package/dist/work-switcher.d.ts +6 -0
- package/dist/work-switcher.js +171 -0
- package/dist/working-cli.d.ts +1 -0
- package/dist/working-cli.js +33 -0
- package/dist/working-code.d.ts +74 -0
- package/dist/working-code.js +421 -0
- package/dist/workspace-notes.d.ts +71 -0
- package/dist/workspace-notes.js +177 -0
- package/dist/workspace-tests.d.ts +21 -0
- package/dist/workspace-tests.js +573 -0
- package/package.json +547 -4
- package/src/activity-volume.ts +149 -0
- package/src/annotations.ts +485 -0
- package/src/benchmark-cli.ts +118 -0
- package/src/benchmark-worker.ts +22 -0
- package/src/benchmarks.ts +493 -0
- package/src/bin.ts +54 -0
- package/src/block-cli.ts +106 -0
- package/src/block-documents.ts +117 -0
- package/src/change-impact.ts +280 -0
- package/src/check-source.ts +82 -0
- package/src/checks-model.ts +108 -0
- package/src/cli.ts +440 -0
- package/src/code-model.ts +159 -0
- package/src/code-store.ts +98 -0
- package/src/compare-artifact.ts +314 -0
- package/src/compare.ts +440 -0
- package/src/compiler.ts +1512 -0
- package/src/compose.ts +94 -0
- package/src/core.ts +361 -0
- package/src/coverage-cli.ts +52 -0
- package/src/declaration-sources.ts +69 -0
- package/src/declared-graph.ts +75 -0
- package/src/display-name.ts +8 -0
- package/src/error-heat.ts +161 -0
- package/src/evidence.ts +94 -0
- package/src/factory-graph.ts +462 -0
- package/src/factory-model.ts +82 -0
- package/src/git-code.ts +461 -0
- package/src/git-refs.ts +43 -0
- package/src/history-activity.ts +146 -0
- package/src/history-churn.ts +416 -0
- package/src/history-git.ts +163 -0
- package/src/history-ledger.ts +636 -0
- package/src/history-ownership.ts +116 -0
- package/src/history-source.ts +117 -0
- package/src/integrations-cli.ts +187 -0
- package/src/interface-map.ts +166 -0
- package/src/issue-cache.ts +96 -0
- package/src/issue-cli.ts +137 -0
- package/src/issue-links.ts +153 -0
- package/src/linear-issues.ts +154 -0
- package/src/local-runtime.ts +70 -0
- package/src/map-activity.ts +309 -0
- package/src/map-model.ts +213 -0
- package/src/map-quality.ts +66 -0
- package/src/mapping-coverage.ts +570 -0
- package/src/model.ts +228 -0
- package/src/operation-benchmark-worker.ts +60 -0
- package/src/operation-benchmark.ts +28 -0
- package/src/otel-metrics.ts +176 -0
- package/src/performance-model.ts +575 -0
- package/src/product-map.ts +271 -0
- package/src/provider-access.cjs +207 -0
- package/src/provider-access.d.cts +14 -0
- package/src/public-boundaries.ts +143 -0
- package/src/reports-cli.ts +125 -0
- package/src/reports-model.ts +73 -0
- package/src/reports.ts +276 -0
- package/src/repository-map.ts +191 -0
- package/src/resource-cache.ts +76 -0
- package/src/review-cli.ts +256 -0
- package/src/review.ts +376 -0
- package/src/runtime-metrics.ts +386 -0
- package/src/scope.ts +192 -0
- package/src/sentry-activity.ts +234 -0
- package/src/sentry.ts +545 -0
- package/src/service-release.ts +18 -0
- package/src/setup-cli.ts +58 -0
- package/src/setup-kit.cjs +163 -0
- package/src/setup-kit.d.cts +32 -0
- package/src/source-index.ts +208 -0
- package/src/source-review-git.ts +131 -0
- package/src/source-review.ts +736 -0
- package/src/telemetry.ts +68 -0
- package/src/time-window.ts +51 -0
- package/src/trace-evidence.ts +80 -0
- package/src/trace-model.ts +26 -0
- package/src/tracing.ts +165 -0
- package/src/work-check.ts +149 -0
- package/src/work-cli.ts +229 -0
- package/src/work-context.ts +753 -0
- package/src/work-intents.ts +196 -0
- package/src/work-items.ts +151 -0
- package/src/work-lock-check.ts +549 -0
- package/src/work-locks.ts +108 -0
- package/src/work-model.ts +466 -0
- package/src/work-review-git.ts +130 -0
- package/src/work-review.ts +573 -0
- package/src/work-switcher-model.ts +121 -0
- package/src/work-switcher.ts +191 -0
- package/src/working-cli.ts +38 -0
- package/src/working-code.ts +582 -0
- package/src/workspace-notes.ts +203 -0
- package/src/workspace-tests.ts +654 -0
- package/toolkit/GUIDE.md +354 -0
- package/toolkit/SKILL.md +142 -0
- package/toolkit/bin/fractory +2 -0
- package/toolkit/build.json +1 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { interfaceMap } from "./interface-map.js";
|
|
2
|
+
/** Convert a reviewed inventory into the same graph used by the runtime viewer. */
|
|
3
|
+
export function buildProductMap(catalog) {
|
|
4
|
+
const sources = (ids) => [...new Set(ids)].map((id) => {
|
|
5
|
+
const source = catalog.evidence[id];
|
|
6
|
+
if (!source)
|
|
7
|
+
throw new Error(`Missing source evidence: ${id}`);
|
|
8
|
+
return {
|
|
9
|
+
file: source.file,
|
|
10
|
+
line: source.line,
|
|
11
|
+
symbol: source.anchor,
|
|
12
|
+
digest: source.digest,
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
const partKind = (value) => {
|
|
16
|
+
const kinds = ["block", "interface", "process", "method"];
|
|
17
|
+
if (value === undefined)
|
|
18
|
+
return "block";
|
|
19
|
+
if (!kinds.includes(value))
|
|
20
|
+
throw new Error(`Unknown part kind: ${value}`);
|
|
21
|
+
return value;
|
|
22
|
+
};
|
|
23
|
+
const idFor = (id) => `${catalog.id}/${id}`;
|
|
24
|
+
const elements = [
|
|
25
|
+
{
|
|
26
|
+
id: catalog.id,
|
|
27
|
+
label: catalog.name,
|
|
28
|
+
kind: "block",
|
|
29
|
+
provenance: "inferred",
|
|
30
|
+
description: catalog.basis,
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
const entries = [];
|
|
34
|
+
for (const system of catalog.systems) {
|
|
35
|
+
const evidence = sources(system.parts.flatMap((part) => part.evidence));
|
|
36
|
+
elements.push({
|
|
37
|
+
id: idFor(system.id),
|
|
38
|
+
parent: catalog.id,
|
|
39
|
+
label: system.name,
|
|
40
|
+
kind: "block",
|
|
41
|
+
provenance: "inferred",
|
|
42
|
+
description: system.purpose,
|
|
43
|
+
source: evidence[0],
|
|
44
|
+
sources: evidence,
|
|
45
|
+
hosting: system.hosting,
|
|
46
|
+
externalBoundaries: system.external,
|
|
47
|
+
});
|
|
48
|
+
const addParts = (parts, parent) => {
|
|
49
|
+
for (const part of parts) {
|
|
50
|
+
const evidence = sources(part.evidence);
|
|
51
|
+
const slug = part.id ||
|
|
52
|
+
part.name
|
|
53
|
+
.toLowerCase()
|
|
54
|
+
.replace(/[^a-z0-9]+/g, "-")
|
|
55
|
+
.replace(/^-|-$/g, "");
|
|
56
|
+
const id = slug.startsWith(`${catalog.id}/`)
|
|
57
|
+
? slug
|
|
58
|
+
: `${parent}/${slug}`;
|
|
59
|
+
elements.push({
|
|
60
|
+
id,
|
|
61
|
+
parent,
|
|
62
|
+
label: part.name,
|
|
63
|
+
kind: partKind(part.kind),
|
|
64
|
+
provenance: "source",
|
|
65
|
+
description: part.summary,
|
|
66
|
+
signature: part.signature,
|
|
67
|
+
...(part.entryFor
|
|
68
|
+
? {
|
|
69
|
+
contract: {
|
|
70
|
+
id,
|
|
71
|
+
input: {
|
|
72
|
+
language: "reviewed-source",
|
|
73
|
+
signature: part.signature,
|
|
74
|
+
declarations: evidence.map((source) => ({
|
|
75
|
+
source,
|
|
76
|
+
declaration: source.symbol,
|
|
77
|
+
})),
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
: {}),
|
|
82
|
+
source: part.entryFor
|
|
83
|
+
? { ...evidence[0], scope: "contract" }
|
|
84
|
+
: evidence[0],
|
|
85
|
+
sources: part.entryFor
|
|
86
|
+
? evidence.map((source) => ({
|
|
87
|
+
...source,
|
|
88
|
+
scope: "contract",
|
|
89
|
+
}))
|
|
90
|
+
: evidence,
|
|
91
|
+
resources: part.resources?.map((resource) => ({
|
|
92
|
+
id: resource.id,
|
|
93
|
+
label: resource.name,
|
|
94
|
+
description: resource.summary,
|
|
95
|
+
sources: sources(resource.evidence),
|
|
96
|
+
source: sources(resource.evidence)[0],
|
|
97
|
+
provenance: "source",
|
|
98
|
+
})),
|
|
99
|
+
outputs: part.outputs?.map((artifact) => ({
|
|
100
|
+
id: artifact.id,
|
|
101
|
+
label: artifact.name,
|
|
102
|
+
description: artifact.summary,
|
|
103
|
+
sources: sources(artifact.evidence),
|
|
104
|
+
source: sources(artifact.evidence)[0],
|
|
105
|
+
provenance: "source",
|
|
106
|
+
})),
|
|
107
|
+
});
|
|
108
|
+
if (part.entryFor)
|
|
109
|
+
entries.push({
|
|
110
|
+
implementation: part.entryFor,
|
|
111
|
+
interface: elements[elements.length - 1],
|
|
112
|
+
});
|
|
113
|
+
addParts(part.parts || [], id);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
addParts(system.parts, idFor(system.id));
|
|
117
|
+
}
|
|
118
|
+
const ids = new Set(elements.map((element) => element.id));
|
|
119
|
+
if (ids.size !== elements.length)
|
|
120
|
+
throw new Error("Duplicate product map identity");
|
|
121
|
+
const connections = catalog.connections.map((edge) => {
|
|
122
|
+
const source = idFor(edge.source), target = idFor(edge.target);
|
|
123
|
+
if (!ids.has(source) || !ids.has(target))
|
|
124
|
+
throw new Error(`Unknown system or block in ${edge.id}`);
|
|
125
|
+
const evidence = sources(edge.evidence);
|
|
126
|
+
const relation = edge.relation || "flows";
|
|
127
|
+
if (![
|
|
128
|
+
"flows",
|
|
129
|
+
"calls",
|
|
130
|
+
"resumes",
|
|
131
|
+
"requires",
|
|
132
|
+
"reads",
|
|
133
|
+
"writes",
|
|
134
|
+
"produces",
|
|
135
|
+
"loads",
|
|
136
|
+
].includes(relation))
|
|
137
|
+
throw new Error(`Unknown relation: ${relation}`);
|
|
138
|
+
if (edge.path && edge.path !== "failure" && edge.path !== "retry")
|
|
139
|
+
throw new Error(`Unknown path kind: ${edge.path}`);
|
|
140
|
+
return {
|
|
141
|
+
id: `flow:${edge.id}`,
|
|
142
|
+
source,
|
|
143
|
+
target,
|
|
144
|
+
label: edge.label,
|
|
145
|
+
relation: relation,
|
|
146
|
+
condition: edge.condition,
|
|
147
|
+
path: edge.path,
|
|
148
|
+
overview: edge.backbone,
|
|
149
|
+
provenance: "inferred",
|
|
150
|
+
sourceRef: evidence[0],
|
|
151
|
+
sources: evidence,
|
|
152
|
+
transport: edge.transport,
|
|
153
|
+
bidirectional: edge.bidirectional,
|
|
154
|
+
artifacts: edge.artifacts?.map((artifact) => ({
|
|
155
|
+
id: artifact.id,
|
|
156
|
+
label: artifact.name,
|
|
157
|
+
description: artifact.summary,
|
|
158
|
+
sources: sources(artifact.evidence),
|
|
159
|
+
source: sources(artifact.evidence)[0],
|
|
160
|
+
provenance: "inferred",
|
|
161
|
+
})) ||
|
|
162
|
+
(relation === "flows"
|
|
163
|
+
? [
|
|
164
|
+
{
|
|
165
|
+
id: `payload:${edge.id}`,
|
|
166
|
+
label: edge.label,
|
|
167
|
+
sources: evidence,
|
|
168
|
+
source: evidence[0],
|
|
169
|
+
provenance: "inferred",
|
|
170
|
+
},
|
|
171
|
+
]
|
|
172
|
+
: undefined),
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
const content = JSON.stringify({
|
|
176
|
+
elements,
|
|
177
|
+
connections,
|
|
178
|
+
support: catalog.support,
|
|
179
|
+
});
|
|
180
|
+
let hash = 14695981039346656037n;
|
|
181
|
+
for (const byte of new TextEncoder().encode(content))
|
|
182
|
+
hash = BigInt.asUintN(64, (hash ^ BigInt(byte)) * 1099511628211n);
|
|
183
|
+
return interfaceMap({
|
|
184
|
+
schema: "fractal.definition.v1",
|
|
185
|
+
id: catalog.id,
|
|
186
|
+
revision: hash.toString(16).padStart(16, "0"),
|
|
187
|
+
generatedAt: catalog.date,
|
|
188
|
+
scope: `${catalog.name} — whole product`,
|
|
189
|
+
basis: "repository-review",
|
|
190
|
+
supportingAreas: catalog.support,
|
|
191
|
+
elements,
|
|
192
|
+
connections,
|
|
193
|
+
tests: [],
|
|
194
|
+
failures: [],
|
|
195
|
+
gaps: [],
|
|
196
|
+
}, entries, { exposeAncestors: true });
|
|
197
|
+
}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/** Fixed read-only provider checks. Never return credential material or provider error bodies. */
|
|
2
|
+
const { execFileSync } = require("node:child_process");
|
|
3
|
+
const { readFileSync } = require("node:fs");
|
|
4
|
+
const { join } = require("node:path");
|
|
5
|
+
const { homedir } = require("node:os");
|
|
6
|
+
const { parseEnv } = require("node:util");
|
|
7
|
+
function command(binary, args) {
|
|
8
|
+
return execFileSync(binary, args, {
|
|
9
|
+
encoding: "utf8",
|
|
10
|
+
timeout: 15000,
|
|
11
|
+
maxBuffer: 1024 * 1024,
|
|
12
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
13
|
+
}).trim();
|
|
14
|
+
}
|
|
15
|
+
function discovery(root, env = process.env) {
|
|
16
|
+
const values = { ...env };
|
|
17
|
+
for (const file of [
|
|
18
|
+
".env",
|
|
19
|
+
".env.local",
|
|
20
|
+
])
|
|
21
|
+
try {
|
|
22
|
+
for (const [key, value] of Object.entries(
|
|
23
|
+
parseEnv(readFileSync(join(root, file), "utf8")),
|
|
24
|
+
))
|
|
25
|
+
if (
|
|
26
|
+
/^(FRACTAL_(GITHUB_(TOKEN|REPOSITORY)|SENTRY_(TOKEN|ORG|PROJECTS)|LINEAR_(API_KEY|WORKSPACE_ID|WORKSPACE_URL))|SENTRY_(AUTH_TOKEN|ORG|PROJECT)|LINEAR_API_KEY|GH_TOKEN|GITHUB_TOKEN)$/.test(
|
|
27
|
+
key,
|
|
28
|
+
)
|
|
29
|
+
)
|
|
30
|
+
values[key] = value;
|
|
31
|
+
} catch (e) {
|
|
32
|
+
if (e.code !== "ENOENT")
|
|
33
|
+
throw Error("Could not read repository integration settings.");
|
|
34
|
+
}
|
|
35
|
+
let repository = values.FRACTAL_GITHUB_REPOSITORY;
|
|
36
|
+
if (!repository)
|
|
37
|
+
try {
|
|
38
|
+
const remote = command("git", [
|
|
39
|
+
"-C",
|
|
40
|
+
root,
|
|
41
|
+
"remote",
|
|
42
|
+
"get-url",
|
|
43
|
+
"origin",
|
|
44
|
+
]);
|
|
45
|
+
repository = remote.match(
|
|
46
|
+
/(?:github\.com[:/])([\w.-]+\/[\w.-]+?)(?:\.git)?$/,
|
|
47
|
+
)?.[1];
|
|
48
|
+
} catch {}
|
|
49
|
+
let sentry = values.FRACTAL_SENTRY_TOKEN || values.SENTRY_AUTH_TOKEN;
|
|
50
|
+
if (!sentry)
|
|
51
|
+
try {
|
|
52
|
+
sentry = readFileSync(join(homedir(), ".sentryclirc"), "utf8").match(
|
|
53
|
+
/\[auth\][\s\S]*?^token\s*=\s*(\S+)/m,
|
|
54
|
+
)?.[1];
|
|
55
|
+
} catch {}
|
|
56
|
+
return {
|
|
57
|
+
github: {
|
|
58
|
+
token:
|
|
59
|
+
values.FRACTAL_GITHUB_TOKEN || values.GH_TOKEN || values.GITHUB_TOKEN,
|
|
60
|
+
repository,
|
|
61
|
+
},
|
|
62
|
+
sentry: {
|
|
63
|
+
token: sentry,
|
|
64
|
+
org: values.FRACTAL_SENTRY_ORG || values.SENTRY_ORG,
|
|
65
|
+
projects: values.FRACTAL_SENTRY_PROJECTS || values.SENTRY_PROJECT,
|
|
66
|
+
},
|
|
67
|
+
linear: {
|
|
68
|
+
token: values.FRACTAL_LINEAR_API_KEY || values.LINEAR_API_KEY,
|
|
69
|
+
workspaceId: values.FRACTAL_LINEAR_WORKSPACE_ID,
|
|
70
|
+
workspaceUrl: values.FRACTAL_LINEAR_WORKSPACE_URL,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
async function checkProvider(provider, input, fetcher = fetch) {
|
|
75
|
+
const config = { ...input };
|
|
76
|
+
if (provider === "github" && config.mode === "cli") {
|
|
77
|
+
try {
|
|
78
|
+
config.token = command("gh", [
|
|
79
|
+
"auth",
|
|
80
|
+
"token",
|
|
81
|
+
"--hostname",
|
|
82
|
+
"github.com",
|
|
83
|
+
]);
|
|
84
|
+
} catch {
|
|
85
|
+
throw Error(
|
|
86
|
+
"GitHub authorization required. Run fractory integrations connect github --login.",
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (provider === "sentry" && config.mode === "cli") {
|
|
91
|
+
try {
|
|
92
|
+
config.token = command("sentry", ["auth", "token"]);
|
|
93
|
+
} catch {
|
|
94
|
+
throw Error(
|
|
95
|
+
"Sentry authorization required. Run fractory integrations connect sentry --login.",
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (!config.token)
|
|
100
|
+
throw Error(
|
|
101
|
+
"No credential found. The agent must complete provider authorization.",
|
|
102
|
+
);
|
|
103
|
+
const request = async (url, body) => {
|
|
104
|
+
let response;
|
|
105
|
+
try {
|
|
106
|
+
response = await fetcher(url, {
|
|
107
|
+
method: body ? "POST" : "GET",
|
|
108
|
+
headers: {
|
|
109
|
+
Authorization:
|
|
110
|
+
provider === "linear" ? config.token : `Bearer ${config.token}`,
|
|
111
|
+
"Content-Type": "application/json",
|
|
112
|
+
Accept: "application/json",
|
|
113
|
+
},
|
|
114
|
+
...(body ? { body: JSON.stringify(body) } : {}),
|
|
115
|
+
redirect: "error",
|
|
116
|
+
signal: AbortSignal.timeout(15000),
|
|
117
|
+
});
|
|
118
|
+
} catch {
|
|
119
|
+
throw Error(
|
|
120
|
+
`${provider} could not be reached. Check the network and retry.`,
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
if (!response.ok)
|
|
124
|
+
throw Error(
|
|
125
|
+
`${provider} access check failed (HTTP ${response.status}). Credentials were not saved.`,
|
|
126
|
+
);
|
|
127
|
+
const json = await response.json();
|
|
128
|
+
if (json.errors)
|
|
129
|
+
throw Error(
|
|
130
|
+
`${provider} rejected the read request. Check the account and read permissions.`,
|
|
131
|
+
);
|
|
132
|
+
return json;
|
|
133
|
+
};
|
|
134
|
+
let account;
|
|
135
|
+
if (provider === "github") {
|
|
136
|
+
if (!/^[\w.-]+\/[\w.-]+$/.test(config.repository || ""))
|
|
137
|
+
throw Error("Choose the GitHub repository with --repository owner/repo.");
|
|
138
|
+
const repo = await request(
|
|
139
|
+
"https://api.github.com/repos/" + config.repository,
|
|
140
|
+
);
|
|
141
|
+
if (repo.full_name?.toLowerCase() !== config.repository.toLowerCase())
|
|
142
|
+
throw Error("GitHub returned a different repository.");
|
|
143
|
+
await request(
|
|
144
|
+
"https://api.github.com/repos/" +
|
|
145
|
+
config.repository +
|
|
146
|
+
"/pulls?state=open&per_page=1",
|
|
147
|
+
);
|
|
148
|
+
account = repo.full_name;
|
|
149
|
+
} else if (provider === "sentry") {
|
|
150
|
+
if (config.org && !/^[\w.-]+$/.test(config.org))
|
|
151
|
+
throw Error("Invalid Sentry organization.");
|
|
152
|
+
if (!config.org) {
|
|
153
|
+
const orgs = await request("https://sentry.io/api/0/organizations/");
|
|
154
|
+
if (orgs.length !== 1)
|
|
155
|
+
throw Error("Choose a Sentry organization with --org.");
|
|
156
|
+
config.org = orgs[0].slug;
|
|
157
|
+
}
|
|
158
|
+
const projects = await request(
|
|
159
|
+
"https://sentry.io/api/0/organizations/" + config.org + "/projects/",
|
|
160
|
+
);
|
|
161
|
+
const chosen = (config.projects || "")
|
|
162
|
+
.split(",")
|
|
163
|
+
.map((s) => s.trim())
|
|
164
|
+
.filter(Boolean);
|
|
165
|
+
if (chosen.some((p) => !projects.some((x) => x.slug === p || x.id === p)))
|
|
166
|
+
throw Error(
|
|
167
|
+
"A selected Sentry project is not accessible to this account.",
|
|
168
|
+
);
|
|
169
|
+
if (!chosen.length)
|
|
170
|
+
throw Error(
|
|
171
|
+
"Choose this repository’s Sentry projects with --projects slug,slug.",
|
|
172
|
+
);
|
|
173
|
+
await request(
|
|
174
|
+
"https://sentry.io/api/0/projects/" +
|
|
175
|
+
config.org +
|
|
176
|
+
"/" +
|
|
177
|
+
projects.find((p) => p.slug === chosen[0] || p.id === chosen[0]).slug +
|
|
178
|
+
"/issues/?limit=1&statsPeriod=24h",
|
|
179
|
+
);
|
|
180
|
+
config.projects = chosen.join(",");
|
|
181
|
+
account = config.org;
|
|
182
|
+
} else if (provider === "linear") {
|
|
183
|
+
const data = (
|
|
184
|
+
await request("https://api.linear.app/graphql", {
|
|
185
|
+
query:
|
|
186
|
+
"query FractoryAccess { viewer { id name } organization { id name urlKey } issues(first: 1) { nodes { id } } }",
|
|
187
|
+
})
|
|
188
|
+
).data;
|
|
189
|
+
if (!data?.organization?.id)
|
|
190
|
+
throw Error("Linear did not return a workspace.");
|
|
191
|
+
if (config.workspaceId && config.workspaceId !== data.organization.id)
|
|
192
|
+
throw Error("This credential belongs to a different Linear workspace.");
|
|
193
|
+
config.workspaceId = data.organization.id;
|
|
194
|
+
config.workspaceUrl = "https://linear.app/" + data.organization.urlKey;
|
|
195
|
+
account = data.organization.name;
|
|
196
|
+
} else throw Error("Unsupported integration.");
|
|
197
|
+
if (config.mode === "cli") delete config.token;
|
|
198
|
+
else config.mode = "token";
|
|
199
|
+
return {
|
|
200
|
+
value: Object.fromEntries(
|
|
201
|
+
Object.entries(config).filter(([, v]) => typeof v === "string"),
|
|
202
|
+
),
|
|
203
|
+
account,
|
|
204
|
+
checkedAt: new Date().toISOString(),
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
module.exports = { discovery, checkProvider };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type Provider = "github" | "sentry" | "linear";
|
|
2
|
+
export function discovery(
|
|
3
|
+
root: string,
|
|
4
|
+
env?: NodeJS.ProcessEnv,
|
|
5
|
+
): Record<Provider, Record<string, string | undefined>>;
|
|
6
|
+
export function checkProvider(
|
|
7
|
+
provider: Provider,
|
|
8
|
+
input: Record<string, string>,
|
|
9
|
+
fetcher?: typeof fetch,
|
|
10
|
+
): Promise<{
|
|
11
|
+
value: Record<string, string>;
|
|
12
|
+
account: string;
|
|
13
|
+
checkedAt: string;
|
|
14
|
+
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DefinitionGraph, Connection } from "./model.js";
|
|
2
|
+
/** Outside is relative to each enclosing black box. Never fabricate an interface
|
|
3
|
+
* to make a direct implementation call look encapsulated. Pure source diagnosis. */
|
|
4
|
+
export declare function boundaryViolations(graph: DefinitionGraph): {
|
|
5
|
+
connection: string;
|
|
6
|
+
block: string;
|
|
7
|
+
target: string;
|
|
8
|
+
reason: string;
|
|
9
|
+
}[];
|
|
10
|
+
/** New definitions and plan edits are rejected at the model boundary. Readers
|
|
11
|
+
* can still inspect older snapshots and report their original violations. */
|
|
12
|
+
export declare function assertPublicConnections(graph: DefinitionGraph): void;
|
|
13
|
+
export declare function publicConnectionError(graph: DefinitionGraph, edge: Connection): string | undefined;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
const transfers = new Set([
|
|
2
|
+
"calls",
|
|
3
|
+
"renders",
|
|
4
|
+
"callbacks",
|
|
5
|
+
"delegates",
|
|
6
|
+
"resumes",
|
|
7
|
+
"requires",
|
|
8
|
+
"flows",
|
|
9
|
+
"reads",
|
|
10
|
+
"writes",
|
|
11
|
+
"loads",
|
|
12
|
+
"produces",
|
|
13
|
+
"exposes",
|
|
14
|
+
]);
|
|
15
|
+
/** Outside is relative to each enclosing black box. Never fabricate an interface
|
|
16
|
+
* to make a direct implementation call look encapsulated. Pure source diagnosis. */
|
|
17
|
+
export function boundaryViolations(graph) {
|
|
18
|
+
const byId = new Map(graph.elements.map((n) => [n.id, n]));
|
|
19
|
+
const path = (id) => {
|
|
20
|
+
const result = [], seen = new Set();
|
|
21
|
+
while (byId.has(id) && !seen.has(id)) {
|
|
22
|
+
seen.add(id);
|
|
23
|
+
result.push(id);
|
|
24
|
+
id = byId.get(id)?.parent || "";
|
|
25
|
+
}
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
const paths = new Map(graph.elements.map((n) => [n.id, path(n.id)]));
|
|
29
|
+
const exposures = new Map();
|
|
30
|
+
for (const e of graph.connections)
|
|
31
|
+
if (e.relation === "exposes" && byId.get(e.target)?.kind === "interface") {
|
|
32
|
+
if (!exposures.has(e.source))
|
|
33
|
+
exposures.set(e.source, new Set());
|
|
34
|
+
exposures.get(e.source).add(e.target);
|
|
35
|
+
}
|
|
36
|
+
return graph.connections.flatMap((edge) => {
|
|
37
|
+
if (!transfers.has(edge.relation))
|
|
38
|
+
return [];
|
|
39
|
+
const sourcePath = new Set(paths.get(edge.source) || []), targetPath = paths.get(edge.target) || [];
|
|
40
|
+
// A receiver itself can be an interface; methods inside it also belong to its contract.
|
|
41
|
+
const issues = [];
|
|
42
|
+
const receiver = byId.get(edge.target);
|
|
43
|
+
if (edge.relation === "exposes") {
|
|
44
|
+
return receiver?.kind === "interface"
|
|
45
|
+
? []
|
|
46
|
+
: [
|
|
47
|
+
{
|
|
48
|
+
connection: edge.id,
|
|
49
|
+
block: edge.source,
|
|
50
|
+
target: edge.target,
|
|
51
|
+
reason: "Only an interface can be publicly exposed.",
|
|
52
|
+
},
|
|
53
|
+
];
|
|
54
|
+
}
|
|
55
|
+
const owner = targetPath.find((id) => {
|
|
56
|
+
const node = byId.get(id);
|
|
57
|
+
return ![
|
|
58
|
+
"interface",
|
|
59
|
+
"method",
|
|
60
|
+
"operation",
|
|
61
|
+
"resource",
|
|
62
|
+
"artifact",
|
|
63
|
+
].includes(node.kind);
|
|
64
|
+
});
|
|
65
|
+
if (receiver &&
|
|
66
|
+
owner &&
|
|
67
|
+
!sourcePath.has(owner) &&
|
|
68
|
+
!["interface", "resource", "artifact"].includes(receiver.kind))
|
|
69
|
+
issues.push({
|
|
70
|
+
connection: edge.id,
|
|
71
|
+
block: owner,
|
|
72
|
+
target: edge.target,
|
|
73
|
+
reason: `Connect to a public interface of ${byId.get(owner).label}, not its internal ${receiver.label}.`,
|
|
74
|
+
});
|
|
75
|
+
for (let i = 0; i < targetPath.length; i++) {
|
|
76
|
+
const id = targetPath[i], node = byId.get(id);
|
|
77
|
+
if (sourcePath.has(id))
|
|
78
|
+
break;
|
|
79
|
+
if (["interface", "method", "operation", "resource", "artifact"].includes(node.kind) ||
|
|
80
|
+
id === graph.id)
|
|
81
|
+
continue;
|
|
82
|
+
const entry = i > 0 ? byId.get(targetPath[i - 1]) : undefined;
|
|
83
|
+
// An interface is public to its immediate owner. An inner interface is
|
|
84
|
+
// not implicitly exposed on every ancestor.
|
|
85
|
+
const exposed = entry?.kind === "interface" ||
|
|
86
|
+
targetPath.slice(0, i).some((target) => exposures.get(id)?.has(target));
|
|
87
|
+
if (!exposed && !issues.some((issue) => issue.block === id))
|
|
88
|
+
issues.push({
|
|
89
|
+
connection: edge.id,
|
|
90
|
+
block: id,
|
|
91
|
+
target: edge.target,
|
|
92
|
+
reason: `Call bypasses the public interface of ${node.label}.`,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return issues;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
/** New definitions and plan edits are rejected at the model boundary. Readers
|
|
99
|
+
* can still inspect older snapshots and report their original violations. */
|
|
100
|
+
export function assertPublicConnections(graph) {
|
|
101
|
+
const issues = boundaryViolations(graph);
|
|
102
|
+
if (issues.length)
|
|
103
|
+
throw Error(issues.map((issue) => `${issue.connection}: ${issue.reason}`).join("\n"));
|
|
104
|
+
}
|
|
105
|
+
export function publicConnectionError(graph, edge) {
|
|
106
|
+
if (![edge.source, edge.target].every((id) => graph.elements.some((node) => node.id === id)))
|
|
107
|
+
return "Choose an existing block and a public interface.";
|
|
108
|
+
return boundaryViolations({
|
|
109
|
+
...graph,
|
|
110
|
+
connections: [
|
|
111
|
+
...graph.connections.filter((item) => item.relation === "exposes" && item.id !== edge.id),
|
|
112
|
+
edge,
|
|
113
|
+
],
|
|
114
|
+
}).find((issue) => issue.connection === edge.id)?.reason;
|
|
115
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function runReports(args: string[]): Promise<string>;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { readRepositoryMap } from "./repository-map.js";
|
|
2
|
+
import { listWorkContexts, workDeepLink } from "./work-context.js";
|
|
3
|
+
import { realpathSync } from "node:fs";
|
|
4
|
+
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
5
|
+
import { execFileSync } from "node:child_process";
|
|
6
|
+
import { dirname, join, resolve } from "node:path";
|
|
7
|
+
import { createReport, listReports, markReport, readReport } from "./reports.js";
|
|
8
|
+
import { reportsForBlock } from "./reports-model.js";
|
|
9
|
+
export async function runReports(args) {
|
|
10
|
+
if (args.includes("--help"))
|
|
11
|
+
return "fractory reports [list] [--block ID] [--unread]\nfractory reports create --block ID [--block ID ...] --title TITLE (--file report.md | --stdin) [--author LABEL]\nfractory reports show REPORT_ID\nfractory reports open REPORT_ID\nfractory reports read REPORT_ID\nfractory reports unread REPORT_ID\nUse --root PATH from another directory. Reports are versioned Markdown; read status stays local. Showing a report does not mark it read.";
|
|
12
|
+
const value = (name) => {
|
|
13
|
+
const index = args.indexOf(name);
|
|
14
|
+
if (index < 0)
|
|
15
|
+
return undefined;
|
|
16
|
+
if (!args[index + 1] || args[index + 1].startsWith("--"))
|
|
17
|
+
throw Error(`${name} needs a value.`);
|
|
18
|
+
return args[index + 1];
|
|
19
|
+
};
|
|
20
|
+
let root = resolve(value("--root") || process.cwd());
|
|
21
|
+
if (!value("--root"))
|
|
22
|
+
while (!existsSync(join(root, ".git")) &&
|
|
23
|
+
!existsSync(join(root, "fractory.json")) &&
|
|
24
|
+
dirname(root) !== root)
|
|
25
|
+
root = dirname(root);
|
|
26
|
+
const action = args[1]?.startsWith("--") ? "list" : args[1] || "list";
|
|
27
|
+
const reportURL = (report) => {
|
|
28
|
+
let link = `fractory://open?repo=${encodeURIComponent(root)}`;
|
|
29
|
+
try {
|
|
30
|
+
const context = listWorkContexts(root).find((t) => t.path === realpathSync(root));
|
|
31
|
+
link = workDeepLink(root, context?.id || "main");
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
/* Offline report fixtures still produce a repository link. */
|
|
35
|
+
}
|
|
36
|
+
const url = new URL(link);
|
|
37
|
+
url.searchParams.set("block", report.blocks[0]);
|
|
38
|
+
url.searchParams.set("inspect", report.blocks[0]);
|
|
39
|
+
url.searchParams.set("workspace", "reports");
|
|
40
|
+
url.searchParams.set("report", report.id);
|
|
41
|
+
return url.href;
|
|
42
|
+
};
|
|
43
|
+
if (["show", "read", "unread", "open"].includes(action)) {
|
|
44
|
+
const id = args[2];
|
|
45
|
+
if (!id || id.startsWith("--"))
|
|
46
|
+
throw Error("Choose a report ID from fractory reports list.");
|
|
47
|
+
const report = readReport(root, id);
|
|
48
|
+
if (action === "open") {
|
|
49
|
+
const url = reportURL(report);
|
|
50
|
+
execFileSync("open", [url], { stdio: "ignore", timeout: 5000 });
|
|
51
|
+
return url;
|
|
52
|
+
}
|
|
53
|
+
return JSON.stringify(action === "show"
|
|
54
|
+
? report
|
|
55
|
+
: markReport(root, id, report.revision, action === "read"), null, 2);
|
|
56
|
+
}
|
|
57
|
+
if (!["list", "create"].includes(action))
|
|
58
|
+
throw Error(`Unknown reports command: ${action}`);
|
|
59
|
+
const graph = readRepositoryMap(root);
|
|
60
|
+
if (!graph)
|
|
61
|
+
throw Error("No Fractory map in this repository. Run fractory setup.");
|
|
62
|
+
if (action === "list") {
|
|
63
|
+
const view = listReports(root);
|
|
64
|
+
const reports = value("--block")
|
|
65
|
+
? reportsForBlock(graph, view.reports, value("--block"))
|
|
66
|
+
: view.reports;
|
|
67
|
+
return JSON.stringify({
|
|
68
|
+
...view,
|
|
69
|
+
reports: args.includes("--unread")
|
|
70
|
+
? reports.filter((report) => report.unread)
|
|
71
|
+
: reports,
|
|
72
|
+
}, null, 2);
|
|
73
|
+
}
|
|
74
|
+
const blocks = args.flatMap((arg, index) => arg === "--block" ? [args[index + 1]] : []);
|
|
75
|
+
if (blocks.some((block) => !block || block.startsWith("--")))
|
|
76
|
+
throw Error("--block needs a block ID.");
|
|
77
|
+
const file = value("--file"), stdin = args.includes("--stdin");
|
|
78
|
+
if ((!file && !stdin) || (file && stdin))
|
|
79
|
+
throw Error("Supply Markdown with either --file PATH or --stdin.");
|
|
80
|
+
if (stdin && process.stdin.isTTY)
|
|
81
|
+
throw Error("Pipe Markdown to --stdin, or use --file PATH.");
|
|
82
|
+
let body;
|
|
83
|
+
if (file) {
|
|
84
|
+
const path = resolve(process.cwd(), file), stat = statSync(path);
|
|
85
|
+
if (!stat.isFile() || stat.size > 128000)
|
|
86
|
+
throw Error("Supply a Markdown file below 128 KB.");
|
|
87
|
+
body = readFileSync(path, "utf8");
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
const chunks = [];
|
|
91
|
+
let size = 0;
|
|
92
|
+
for await (const chunk of process.stdin) {
|
|
93
|
+
const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
94
|
+
size += buffer.length;
|
|
95
|
+
if (size > 128000)
|
|
96
|
+
throw Error("Keep this report below 128 KB.");
|
|
97
|
+
chunks.push(buffer);
|
|
98
|
+
}
|
|
99
|
+
body = Buffer.concat(chunks).toString("utf8");
|
|
100
|
+
}
|
|
101
|
+
const report = createReport(root, graph, {
|
|
102
|
+
title: value("--title") || "",
|
|
103
|
+
blocks,
|
|
104
|
+
body,
|
|
105
|
+
author: value("--author"),
|
|
106
|
+
});
|
|
107
|
+
const url = reportURL(report);
|
|
108
|
+
if (args.includes("--open"))
|
|
109
|
+
execFileSync("open", [url], { stdio: "ignore", timeout: 5000 });
|
|
110
|
+
return JSON.stringify({ ...report, url }, null, 2);
|
|
111
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { DefinitionGraph } from "./model.js";
|
|
2
|
+
export interface ReportMetadata {
|
|
3
|
+
schema: "fractory.report.v1";
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
blocks: string[];
|
|
7
|
+
createdAt: string;
|
|
8
|
+
author?: string;
|
|
9
|
+
codeRevision?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface BlockReport extends ReportMetadata {
|
|
12
|
+
file: string;
|
|
13
|
+
revision: string;
|
|
14
|
+
unread: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface ReportDocument extends BlockReport {
|
|
17
|
+
body: string;
|
|
18
|
+
}
|
|
19
|
+
export interface ReportsView {
|
|
20
|
+
reports: BlockReport[];
|
|
21
|
+
warnings: string[];
|
|
22
|
+
}
|
|
23
|
+
export declare function resolvedReportBlock(graph: DefinitionGraph, id: string): string;
|
|
24
|
+
/** A multi-target report contributes once to each ancestor, including the root. */
|
|
25
|
+
export declare function reportBlocks(graph: DefinitionGraph, report: Pick<BlockReport, "blocks">): Set<string>;
|
|
26
|
+
export declare function unreadReportCounts(graph: DefinitionGraph, reports: BlockReport[]): Record<string, number>;
|
|
27
|
+
export declare function reportsForBlock(graph: DefinitionGraph, reports: BlockReport[], block: string): BlockReport[];
|