@granular-software/fractory 0.0.0-stage → 0.1.24
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 +118 -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 +1083 -0
- package/dist/compose.d.ts +9 -0
- package/dist/compose.js +72 -0
- package/dist/core.d.ts +86 -0
- package/dist/core.js +206 -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 +66 -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 +4 -0
- package/dist/factory-graph.js +318 -0
- package/dist/factory-model.d.ts +97 -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/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 +14 -0
- package/dist/map-quality.js +56 -0
- package/dist/mapping-coverage.d.ts +87 -0
- package/dist/mapping-coverage.js +404 -0
- package/dist/model.d.ts +182 -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 +69 -0
- package/dist/product-map.js +168 -0
- package/dist/provider-access.cjs +207 -0
- package/dist/provider-access.d.cts +14 -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 +151 -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 +12 -0
- package/dist/scope.js +94 -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 +166 -0
- package/dist/source-review-git.d.ts +7 -0
- package/dist/source-review-git.js +103 -0
- package/dist/source-review.d.ts +16 -0
- package/dist/source-review.js +493 -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 +17 -0
- package/dist/work-check.js +110 -0
- package/dist/work-cli.d.ts +1 -0
- package/dist/work-cli.js +148 -0
- package/dist/work-context.d.ts +57 -0
- package/dist/work-context.js +568 -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-model.d.ts +110 -0
- package/dist/work-model.js +261 -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 +481 -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 +1326 -0
- package/src/compose.ts +94 -0
- package/src/core.ts +357 -0
- package/src/coverage-cli.ts +52 -0
- package/src/declaration-sources.ts +69 -0
- package/src/declared-graph.ts +74 -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 +378 -0
- package/src/factory-model.ts +73 -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/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 +61 -0
- package/src/mapping-coverage.ts +570 -0
- package/src/model.ts +221 -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 +236 -0
- package/src/provider-access.cjs +207 -0
- package/src/provider-access.d.cts +14 -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 +189 -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 +103 -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 +205 -0
- package/src/source-review-git.ts +129 -0
- package/src/source-review.ts +637 -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 +143 -0
- package/src/work-cli.ts +195 -0
- package/src/work-context.ts +713 -0
- package/src/work-intents.ts +196 -0
- package/src/work-items.ts +151 -0
- package/src/work-model.ts +400 -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 +305 -0
- package/toolkit/SKILL.md +131 -0
- package/toolkit/bin/fractory +2 -0
- package/toolkit/build.json +1 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/** Tiny Git-versionable link registry; Linear retains ownership of issue metadata/status. */
|
|
2
|
+
import {
|
|
3
|
+
readFileSync,
|
|
4
|
+
writeFileSync,
|
|
5
|
+
renameSync,
|
|
6
|
+
unlinkSync,
|
|
7
|
+
lstatSync,
|
|
8
|
+
mkdirSync,
|
|
9
|
+
} from "node:fs";
|
|
10
|
+
import { dirname } from "node:path";
|
|
11
|
+
import { createHash } from "node:crypto";
|
|
12
|
+
import { issueReference, type IssueLinks } from "./work-items";
|
|
13
|
+
const empty: IssueLinks = { schema: "fractal.issues.v1", links: [] };
|
|
14
|
+
export class IssueLinkConflict extends Error {}
|
|
15
|
+
export function readIssueLinks(file: string): {
|
|
16
|
+
registry: IssueLinks;
|
|
17
|
+
revision: string;
|
|
18
|
+
} {
|
|
19
|
+
let raw: string;
|
|
20
|
+
try {
|
|
21
|
+
if (lstatSync(file).isSymbolicLink())
|
|
22
|
+
throw Error("Issue link registry must not be a symlink");
|
|
23
|
+
raw = readFileSync(file, "utf8");
|
|
24
|
+
} catch (error: any) {
|
|
25
|
+
if (error.code !== "ENOENT") throw error;
|
|
26
|
+
raw = JSON.stringify(empty);
|
|
27
|
+
}
|
|
28
|
+
if (raw.length > 256_000)
|
|
29
|
+
throw Error("Issue link registry exceeds its size limit");
|
|
30
|
+
const value = JSON.parse(raw) as IssueLinks;
|
|
31
|
+
if (
|
|
32
|
+
value.schema !== "fractal.issues.v1" ||
|
|
33
|
+
!Array.isArray(value.links) ||
|
|
34
|
+
value.links.length > 500
|
|
35
|
+
)
|
|
36
|
+
throw Error("Invalid issue link registry");
|
|
37
|
+
const ids = new Set<string>();
|
|
38
|
+
if (value.workspace) {
|
|
39
|
+
const url = new URL(value.workspace.url);
|
|
40
|
+
if (
|
|
41
|
+
url.origin !== "https://linear.app" ||
|
|
42
|
+
url.username ||
|
|
43
|
+
url.password ||
|
|
44
|
+
url.search ||
|
|
45
|
+
url.hash ||
|
|
46
|
+
url.pathname.split("/").filter(Boolean).length !== 1
|
|
47
|
+
)
|
|
48
|
+
throw Error("Invalid Linear workspace URL");
|
|
49
|
+
}
|
|
50
|
+
for (const link of value.links) {
|
|
51
|
+
const key = issueReference(link.issue).key;
|
|
52
|
+
if (
|
|
53
|
+
key !== link.issue ||
|
|
54
|
+
ids.has(key) ||
|
|
55
|
+
!Array.isArray(link.blocks) ||
|
|
56
|
+
!link.blocks.length ||
|
|
57
|
+
link.blocks.length > 64 ||
|
|
58
|
+
link.blocks.some((b) => typeof b !== "string" || !b || b.length > 400) ||
|
|
59
|
+
new Set(link.blocks).size !== link.blocks.length
|
|
60
|
+
)
|
|
61
|
+
throw Error("Invalid or duplicate issue link");
|
|
62
|
+
if (
|
|
63
|
+
link.identifier &&
|
|
64
|
+
issueReference(link.identifier).key !== link.identifier
|
|
65
|
+
)
|
|
66
|
+
throw Error("Invalid issue identifier");
|
|
67
|
+
for (const alias of new Set([
|
|
68
|
+
key,
|
|
69
|
+
...(link.identifier ? [link.identifier] : []),
|
|
70
|
+
])) {
|
|
71
|
+
if (ids.has(alias)) throw Error("Duplicate issue alias");
|
|
72
|
+
ids.add(alias);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
registry: value,
|
|
77
|
+
revision: createHash("sha256").update(raw).digest("hex"),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
export function saveIssueLink(
|
|
81
|
+
file: string,
|
|
82
|
+
expectedRevision: string,
|
|
83
|
+
input: { issue: string; identifier?: string; blocks: string[] },
|
|
84
|
+
knownBlocks: ReadonlySet<string>,
|
|
85
|
+
) {
|
|
86
|
+
if (!/^[a-f0-9]{64}$/.test(expectedRevision))
|
|
87
|
+
throw new IssueLinkConflict("Reload issue links before saving");
|
|
88
|
+
mkdirSync(dirname(file), { recursive: true });
|
|
89
|
+
const lock = file + ".lock";
|
|
90
|
+
let owned = false;
|
|
91
|
+
try {
|
|
92
|
+
try {
|
|
93
|
+
writeFileSync(lock, "", { flag: "wx", mode: 0o600 });
|
|
94
|
+
owned = true;
|
|
95
|
+
} catch (error: any) {
|
|
96
|
+
if (error.code === "EEXIST")
|
|
97
|
+
throw new IssueLinkConflict(
|
|
98
|
+
"Another writer holds the issue-link lock; retry when it finishes",
|
|
99
|
+
);
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
const current = readIssueLinks(file);
|
|
103
|
+
if (current.revision !== expectedRevision)
|
|
104
|
+
throw new IssueLinkConflict(
|
|
105
|
+
"Issue links changed. Reload before saving so another edit is not overwritten",
|
|
106
|
+
);
|
|
107
|
+
const key = issueReference(input.issue).key,
|
|
108
|
+
identifier = input.identifier
|
|
109
|
+
? issueReference(input.identifier).key
|
|
110
|
+
: undefined;
|
|
111
|
+
if (
|
|
112
|
+
!Array.isArray(input.blocks) ||
|
|
113
|
+
input.blocks.length > 64 ||
|
|
114
|
+
input.blocks.some((b) => typeof b !== "string")
|
|
115
|
+
)
|
|
116
|
+
throw Error("Choose up to 64 blocks");
|
|
117
|
+
const prior = current.registry.links.find(
|
|
118
|
+
(l) =>
|
|
119
|
+
l.issue === key ||
|
|
120
|
+
l.identifier === key ||
|
|
121
|
+
(identifier && (l.identifier === identifier || l.issue === identifier)),
|
|
122
|
+
);
|
|
123
|
+
const blocks = [...new Set(input.blocks)].sort();
|
|
124
|
+
for (const block of blocks)
|
|
125
|
+
if (!knownBlocks.has(block) && !prior?.blocks.includes(block))
|
|
126
|
+
throw Error("Unknown block: " + block);
|
|
127
|
+
const links = current.registry.links.filter((l) => l !== prior);
|
|
128
|
+
const savedKey = prior?.identifier === key ? prior.issue : key;
|
|
129
|
+
const savedIdentifier = identifier || prior?.identifier;
|
|
130
|
+
if (blocks.length)
|
|
131
|
+
links.push({
|
|
132
|
+
issue: savedKey,
|
|
133
|
+
...(savedIdentifier ? { identifier: savedIdentifier } : {}),
|
|
134
|
+
blocks,
|
|
135
|
+
});
|
|
136
|
+
const value: IssueLinks = {
|
|
137
|
+
...current.registry,
|
|
138
|
+
links: links.sort((a, b) =>
|
|
139
|
+
(a.identifier || a.issue).localeCompare(b.identifier || b.issue),
|
|
140
|
+
),
|
|
141
|
+
};
|
|
142
|
+
writeFileSync(lock, JSON.stringify(value, null, 2) + "\n");
|
|
143
|
+
readIssueLinks(lock);
|
|
144
|
+
renameSync(lock, file);
|
|
145
|
+
owned = false;
|
|
146
|
+
return readIssueLinks(file);
|
|
147
|
+
} finally {
|
|
148
|
+
if (owned)
|
|
149
|
+
try {
|
|
150
|
+
unlinkSync(lock);
|
|
151
|
+
} catch {}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { issueReference, type LinearWorkIssue } from "./work-items";
|
|
2
|
+
export function normalizeLinearIssue(
|
|
3
|
+
raw: any,
|
|
4
|
+
checkedAt = new Date().toISOString(),
|
|
5
|
+
): LinearWorkIssue {
|
|
6
|
+
const id = raw.uuid || raw.id,
|
|
7
|
+
identifier = raw.identifier || raw.id;
|
|
8
|
+
if (
|
|
9
|
+
!/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(id || "") ||
|
|
10
|
+
!/^[A-Z][A-Z0-9]{0,15}-[1-9][0-9]{0,9}$/.test(identifier || "") ||
|
|
11
|
+
typeof raw.title !== "string" ||
|
|
12
|
+
raw.title.length > 1000
|
|
13
|
+
)
|
|
14
|
+
throw Error("Invalid Linear issue metadata");
|
|
15
|
+
const url = issueReference(raw.url);
|
|
16
|
+
if (url.key !== identifier)
|
|
17
|
+
throw Error("Linear issue URL does not match its identifier");
|
|
18
|
+
const state = raw.state || { name: raw.status, type: raw.statusType };
|
|
19
|
+
if (
|
|
20
|
+
typeof state?.name !== "string" ||
|
|
21
|
+
typeof state?.type !== "string" ||
|
|
22
|
+
!Number.isFinite(Date.parse(raw.updatedAt)) ||
|
|
23
|
+
!Number.isFinite(Date.parse(checkedAt))
|
|
24
|
+
)
|
|
25
|
+
throw Error("Issue status or timestamps unavailable");
|
|
26
|
+
return {
|
|
27
|
+
id,
|
|
28
|
+
identifier,
|
|
29
|
+
title: raw.title,
|
|
30
|
+
url: url.url!,
|
|
31
|
+
state: { name: state.name.slice(0, 100), type: state.type.slice(0, 40) },
|
|
32
|
+
updatedAt: raw.updatedAt,
|
|
33
|
+
checkedAt,
|
|
34
|
+
...(raw.archivedAt ? { archivedAt: raw.archivedAt } : {}),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export class LinearIssuesReader {
|
|
38
|
+
constructor(
|
|
39
|
+
private token: string,
|
|
40
|
+
private workspaceId?: string,
|
|
41
|
+
private fetcher: typeof fetch = fetch,
|
|
42
|
+
) {}
|
|
43
|
+
/** Explicit, bounded title search. Never used to assign ownership automatically. */
|
|
44
|
+
async search(
|
|
45
|
+
query: string,
|
|
46
|
+
): Promise<{ issues: LinearWorkIssue[]; more: boolean }> {
|
|
47
|
+
const term = query.trim();
|
|
48
|
+
if (term.length < 3 || term.length > 120)
|
|
49
|
+
throw Error("Search with 3–120 characters");
|
|
50
|
+
const response = await this.fetcher("https://api.linear.app/graphql", {
|
|
51
|
+
method: "POST",
|
|
52
|
+
headers: {
|
|
53
|
+
"content-type": "application/json",
|
|
54
|
+
Authorization: this.token,
|
|
55
|
+
},
|
|
56
|
+
body: JSON.stringify({
|
|
57
|
+
query: `query FractalIssueSearch($term: String!) {
|
|
58
|
+
organization { id }
|
|
59
|
+
issues(first: 20, filter: { title: { containsIgnoreCase: $term } }) {
|
|
60
|
+
nodes { id identifier title url updatedAt archivedAt state { name type } }
|
|
61
|
+
pageInfo { hasNextPage }
|
|
62
|
+
}
|
|
63
|
+
}`,
|
|
64
|
+
variables: { term },
|
|
65
|
+
}),
|
|
66
|
+
signal: AbortSignal.timeout(10000),
|
|
67
|
+
});
|
|
68
|
+
if (response.status === 429)
|
|
69
|
+
throw Error("Linear rate limit reached; retry later");
|
|
70
|
+
if (!response.ok)
|
|
71
|
+
throw Error("Linear search failed (" + response.status + ")");
|
|
72
|
+
const body = await response.json();
|
|
73
|
+
if (
|
|
74
|
+
body.errors?.length ||
|
|
75
|
+
!Array.isArray(body.data?.issues?.nodes) ||
|
|
76
|
+
!body.data?.organization?.id
|
|
77
|
+
)
|
|
78
|
+
throw Error("Linear returned incomplete search results");
|
|
79
|
+
if (this.workspaceId && body.data.organization.id !== this.workspaceId)
|
|
80
|
+
throw Error("Linear credential belongs to a different workspace");
|
|
81
|
+
const checkedAt = new Date().toISOString();
|
|
82
|
+
return {
|
|
83
|
+
issues: body.data.issues.nodes.map((issue: unknown) =>
|
|
84
|
+
normalizeLinearIssue(issue, checkedAt),
|
|
85
|
+
),
|
|
86
|
+
more: !!body.data.issues.pageInfo?.hasNextPage,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
async issues(references: string[]): Promise<LinearWorkIssue[]> {
|
|
90
|
+
return (await this.issueResults(references)).issues;
|
|
91
|
+
}
|
|
92
|
+
/** Refresh every permitted registry link; unavailable issues are explicit, not old successes. */
|
|
93
|
+
async issueResults(
|
|
94
|
+
references: string[],
|
|
95
|
+
): Promise<{ issues: LinearWorkIssue[]; unavailable: string[] }> {
|
|
96
|
+
const keys = [...new Set(references.map((ref) => issueReference(ref).key))];
|
|
97
|
+
if (keys.length > 500)
|
|
98
|
+
throw Error("Refresh up to 500 linked issues at a time");
|
|
99
|
+
const result: LinearWorkIssue[] = [];
|
|
100
|
+
const unavailable: string[] = [];
|
|
101
|
+
for (let start = 0; start < keys.length; start += 25) {
|
|
102
|
+
const refs = keys.slice(start, start + 25),
|
|
103
|
+
definitions = refs.map((_, i) => `$id${i}: String!`).join(","),
|
|
104
|
+
queries = refs
|
|
105
|
+
.map(
|
|
106
|
+
(_, i) =>
|
|
107
|
+
`i${i}: issue(id:$id${i}) { id identifier title url updatedAt archivedAt state { name type } }`,
|
|
108
|
+
)
|
|
109
|
+
.join("\n");
|
|
110
|
+
const checkedAt = new Date().toISOString();
|
|
111
|
+
const response = await this.fetcher("https://api.linear.app/graphql", {
|
|
112
|
+
method: "POST",
|
|
113
|
+
headers: {
|
|
114
|
+
"content-type": "application/json",
|
|
115
|
+
Authorization: this.token,
|
|
116
|
+
},
|
|
117
|
+
body: JSON.stringify({
|
|
118
|
+
query: `query FractalIssues(${definitions}) { organization { id } ${queries} }`,
|
|
119
|
+
variables: Object.fromEntries(refs.map((ref, i) => ["id" + i, ref])),
|
|
120
|
+
}),
|
|
121
|
+
signal: AbortSignal.timeout(10000),
|
|
122
|
+
});
|
|
123
|
+
if (response.status === 429)
|
|
124
|
+
throw Error(
|
|
125
|
+
"Linear rate limit reached; recorded status remains available",
|
|
126
|
+
);
|
|
127
|
+
if (!response.ok)
|
|
128
|
+
throw Error("Linear status refresh failed (" + response.status + ")");
|
|
129
|
+
const body = await response.json();
|
|
130
|
+
if (
|
|
131
|
+
!body.data?.organization?.id ||
|
|
132
|
+
body.errors?.some(
|
|
133
|
+
(error: { path?: unknown[] }) =>
|
|
134
|
+
!/^i\d+$/.test(String(error.path?.[0] || "")),
|
|
135
|
+
)
|
|
136
|
+
)
|
|
137
|
+
throw Error(
|
|
138
|
+
"Linear returned incomplete issue data; recorded status remains available",
|
|
139
|
+
);
|
|
140
|
+
if (this.workspaceId && body.data.organization.id !== this.workspaceId)
|
|
141
|
+
throw Error("Linear credential belongs to a different workspace");
|
|
142
|
+
for (let i = 0; i < refs.length; i++)
|
|
143
|
+
if (
|
|
144
|
+
body.data["i" + i] &&
|
|
145
|
+
!body.errors?.some(
|
|
146
|
+
(error: { path?: unknown[] }) => error.path?.[0] === "i" + i,
|
|
147
|
+
)
|
|
148
|
+
)
|
|
149
|
+
result.push(normalizeLinearIssue(body.data["i" + i], checkedAt));
|
|
150
|
+
else unavailable.push(refs[i]);
|
|
151
|
+
}
|
|
152
|
+
return { issues: result, unavailable };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** A desktop backend is a local workspace even when its UI is production-built.
|
|
2
|
+
* This is a capability flag, not authentication: every desktop request must also
|
|
3
|
+
* present the per-launch session and exact loopback host. */
|
|
4
|
+
export function desktopRuntime(
|
|
5
|
+
env: Record<string, string | undefined> = process.env,
|
|
6
|
+
) {
|
|
7
|
+
if (
|
|
8
|
+
env.FRACTORY_DESKTOP !== "1" ||
|
|
9
|
+
!/^[a-f0-9]{64}$/.test(env.FRACTORY_DESKTOP_TOKEN || "")
|
|
10
|
+
)
|
|
11
|
+
return false;
|
|
12
|
+
try {
|
|
13
|
+
const url = new URL(env.FRACTORY_DESKTOP_ORIGIN || "");
|
|
14
|
+
return (
|
|
15
|
+
url.protocol === "http:" &&
|
|
16
|
+
url.hostname === "127.0.0.1" &&
|
|
17
|
+
!!url.port &&
|
|
18
|
+
url.origin === env.FRACTORY_DESKTOP_ORIGIN
|
|
19
|
+
);
|
|
20
|
+
} catch {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function localRepositoryRuntime(
|
|
25
|
+
env: Record<string, string | undefined> = process.env,
|
|
26
|
+
) {
|
|
27
|
+
return env.NODE_ENV !== "production" || desktopRuntime(env);
|
|
28
|
+
}
|
|
29
|
+
export function desktopRequestAllowed(
|
|
30
|
+
headers: Pick<Headers, "get">,
|
|
31
|
+
env: Record<string, string | undefined> = process.env,
|
|
32
|
+
) {
|
|
33
|
+
if (!desktopRuntime(env)) return false;
|
|
34
|
+
const expected = new URL(env.FRACTORY_DESKTOP_ORIGIN!);
|
|
35
|
+
if (headers.get("host") !== expected.host) return false;
|
|
36
|
+
const origin = headers.get("origin");
|
|
37
|
+
if (origin && origin !== expected.origin) return false;
|
|
38
|
+
const cookie = (headers.get("cookie") || "")
|
|
39
|
+
.split(";")
|
|
40
|
+
.map((part) => part.trim())
|
|
41
|
+
.find((part) => part.startsWith("fractory-session="))
|
|
42
|
+
?.slice("fractory-session=".length);
|
|
43
|
+
const token = env.FRACTORY_DESKTOP_TOKEN!;
|
|
44
|
+
if (!cookie || cookie.length !== token.length) return false;
|
|
45
|
+
let difference = 0;
|
|
46
|
+
for (let index = 0; index < token.length; index++)
|
|
47
|
+
difference |= token.charCodeAt(index) ^ cookie.charCodeAt(index);
|
|
48
|
+
return difference === 0;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Explicit loopback-only web development; packaged builds always require their session. */
|
|
52
|
+
export function developmentRequestAllowed(
|
|
53
|
+
headers: Pick<Headers, "get">,
|
|
54
|
+
env: Record<string, string | undefined> = process.env,
|
|
55
|
+
) {
|
|
56
|
+
if (env.NODE_ENV !== "development" || env.FRACTORY_WEB_DEV !== "1")
|
|
57
|
+
return false;
|
|
58
|
+
try {
|
|
59
|
+
const expected = new URL(env.FRACTORY_DEV_ORIGIN || "");
|
|
60
|
+
return (
|
|
61
|
+
expected.protocol === "http:" &&
|
|
62
|
+
expected.hostname === "127.0.0.1" &&
|
|
63
|
+
!!expected.port &&
|
|
64
|
+
headers.get("host") === expected.host &&
|
|
65
|
+
(!headers.get("origin") || headers.get("origin") === expected.origin)
|
|
66
|
+
);
|
|
67
|
+
} catch {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import type { DefinitionGraph } from "./model";
|
|
2
|
+
import type { WorkingOverview } from "./working-code";
|
|
3
|
+
import type { WorkView } from "./work-items";
|
|
4
|
+
import { inTimeWindow, type TimeWindow } from "./time-window";
|
|
5
|
+
|
|
6
|
+
export type ActivityKind =
|
|
7
|
+
| "worktrees"
|
|
8
|
+
| "history"
|
|
9
|
+
| "sentry"
|
|
10
|
+
| "linear"
|
|
11
|
+
| "metrics"
|
|
12
|
+
| "benchmarks";
|
|
13
|
+
export interface ActivityCell {
|
|
14
|
+
tone?: "regression" | "improvement" | "neutral";
|
|
15
|
+
displayValue?: string;
|
|
16
|
+
recent?: boolean;
|
|
17
|
+
count: number;
|
|
18
|
+
intensity: number;
|
|
19
|
+
label: string;
|
|
20
|
+
summary: string;
|
|
21
|
+
segments?: { label: string; count: number; tone: string }[];
|
|
22
|
+
series?: number[];
|
|
23
|
+
measurements?: {
|
|
24
|
+
label: string;
|
|
25
|
+
value: string;
|
|
26
|
+
series: number[];
|
|
27
|
+
tone?: "regression" | "improvement" | "neutral";
|
|
28
|
+
}[];
|
|
29
|
+
related?: boolean;
|
|
30
|
+
lineChange?: { added: number; deleted: number; partial: boolean };
|
|
31
|
+
}
|
|
32
|
+
export interface HistorySample {
|
|
33
|
+
source?: import("./history-source").HistorySource;
|
|
34
|
+
latestAt?: string;
|
|
35
|
+
churn?: import("./history-churn").HistoryChurn;
|
|
36
|
+
ledger?: import("./history-ledger").HistoryLedger;
|
|
37
|
+
checkedAt: string;
|
|
38
|
+
windowEnd?: string;
|
|
39
|
+
windowStart?: string;
|
|
40
|
+
days: number;
|
|
41
|
+
partial: boolean;
|
|
42
|
+
commits: {
|
|
43
|
+
commit: string;
|
|
44
|
+
at: string;
|
|
45
|
+
subject: string;
|
|
46
|
+
files: string[];
|
|
47
|
+
changes?: {
|
|
48
|
+
path: string;
|
|
49
|
+
added: number;
|
|
50
|
+
deleted: number;
|
|
51
|
+
binary: boolean;
|
|
52
|
+
}[];
|
|
53
|
+
}[];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const indexes = new WeakMap<
|
|
57
|
+
DefinitionGraph,
|
|
58
|
+
{
|
|
59
|
+
revision: string;
|
|
60
|
+
byId: Map<string, DefinitionGraph["elements"][number]>;
|
|
61
|
+
files: Map<string, string[]>;
|
|
62
|
+
}
|
|
63
|
+
>();
|
|
64
|
+
/** File associations, not line-level ownership. Shared files can relate to several blocks. */
|
|
65
|
+
export function fileBlocks(graph: DefinitionGraph, path: string): Set<string> {
|
|
66
|
+
let index = indexes.get(graph);
|
|
67
|
+
if (!index || index.revision !== graph.revision) {
|
|
68
|
+
const files = new Map<string, string[]>();
|
|
69
|
+
for (const node of graph.elements) {
|
|
70
|
+
for (const source of node.sources || (node.source ? [node.source] : []))
|
|
71
|
+
files.set(source.file, [...(files.get(source.file) || []), node.id]);
|
|
72
|
+
for (const file of [
|
|
73
|
+
...(node.attachments?.benchmarks || []),
|
|
74
|
+
...(node.attachments?.docs || []),
|
|
75
|
+
...(node.attachments?.tests || []),
|
|
76
|
+
])
|
|
77
|
+
files.set(file, [...(files.get(file) || []), node.id]);
|
|
78
|
+
}
|
|
79
|
+
for (const test of graph.tests || [])
|
|
80
|
+
files.set(test.source.file, [
|
|
81
|
+
...(files.get(test.source.file) || []),
|
|
82
|
+
...test.targets.map((id) => graph.aliases?.[id] || id),
|
|
83
|
+
]);
|
|
84
|
+
index = {
|
|
85
|
+
revision: graph.revision,
|
|
86
|
+
byId: new Map(graph.elements.map((node) => [node.id, node])),
|
|
87
|
+
files,
|
|
88
|
+
};
|
|
89
|
+
indexes.set(graph, index);
|
|
90
|
+
}
|
|
91
|
+
const { byId, files } = index;
|
|
92
|
+
const owners = new Set<string>();
|
|
93
|
+
const ids = path.endsWith("/")
|
|
94
|
+
? [...files]
|
|
95
|
+
.filter(([file]) => file.startsWith(path))
|
|
96
|
+
.flatMap(([, ids]) => ids)
|
|
97
|
+
: files.get(path) || [];
|
|
98
|
+
for (const id of ids) {
|
|
99
|
+
let current = byId.get(graph.aliases?.[id] || id)!;
|
|
100
|
+
const seen = new Set<string>();
|
|
101
|
+
while (current && !seen.has(current.id)) {
|
|
102
|
+
seen.add(current.id);
|
|
103
|
+
owners.add(current.id);
|
|
104
|
+
current = byId.get(current.parent!)!;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return owners;
|
|
108
|
+
}
|
|
109
|
+
function normalize(
|
|
110
|
+
graph: DefinitionGraph,
|
|
111
|
+
cells: Record<string, ActivityCell>,
|
|
112
|
+
) {
|
|
113
|
+
const max = Math.max(
|
|
114
|
+
1,
|
|
115
|
+
...Object.entries(cells)
|
|
116
|
+
.filter(([id]) => id !== graph.id)
|
|
117
|
+
.map(([, cell]) => cell.count),
|
|
118
|
+
);
|
|
119
|
+
for (const cell of Object.values(cells))
|
|
120
|
+
cell.intensity = Math.min(1, cell.count / max);
|
|
121
|
+
return cells;
|
|
122
|
+
}
|
|
123
|
+
export function workingCells(
|
|
124
|
+
graph: DefinitionGraph,
|
|
125
|
+
overview: WorkingOverview,
|
|
126
|
+
) {
|
|
127
|
+
if (overview.mapping?.revision === graph.revision && overview.mapping)
|
|
128
|
+
return overview.mapping;
|
|
129
|
+
const cells: Record<string, ActivityCell> = {};
|
|
130
|
+
let unmapped = 0;
|
|
131
|
+
for (const path of overview.paths) {
|
|
132
|
+
const owners = fileBlocks(graph, path.path);
|
|
133
|
+
if (!owners.size) unmapped++;
|
|
134
|
+
for (const id of owners) {
|
|
135
|
+
const cell = (cells[id] ||= {
|
|
136
|
+
count: 0,
|
|
137
|
+
intensity: 0,
|
|
138
|
+
label: "changed paths",
|
|
139
|
+
summary: "",
|
|
140
|
+
segments: [
|
|
141
|
+
{ label: "Staged", count: 0, tone: "staged" },
|
|
142
|
+
{ label: "Unstaged", count: 0, tone: "unstaged" },
|
|
143
|
+
{ label: "Untracked", count: 0, tone: "untracked" },
|
|
144
|
+
{ label: "Conflicts", count: 0, tone: "conflict" },
|
|
145
|
+
],
|
|
146
|
+
});
|
|
147
|
+
cell.count++;
|
|
148
|
+
const age = path.modifiedAt
|
|
149
|
+
? Date.parse(overview.checkedAt) - Date.parse(path.modifiedAt)
|
|
150
|
+
: Infinity;
|
|
151
|
+
// A folder's mtime describes directory entries, not edits to its files.
|
|
152
|
+
if (path.kind !== "directory" && age >= 0 && age < 30_000)
|
|
153
|
+
cell.recent = true;
|
|
154
|
+
if (path.conflict) cell.segments![3].count++;
|
|
155
|
+
else if (path.untracked) cell.segments![2].count++;
|
|
156
|
+
else {
|
|
157
|
+
if (path.index !== ".") cell.segments![0].count++;
|
|
158
|
+
if (path.working !== ".") cell.segments![1].count++;
|
|
159
|
+
}
|
|
160
|
+
cell.summary = cell
|
|
161
|
+
.segments!.filter((s) => s.count)
|
|
162
|
+
.map((s) => `${s.count} ${s.label.toLowerCase()}`)
|
|
163
|
+
.join(" · ");
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return { cells: normalize(graph, cells), unmapped };
|
|
167
|
+
}
|
|
168
|
+
export function historyCells(graph: DefinitionGraph, sample: HistorySample) {
|
|
169
|
+
const cells: Record<string, ActivityCell> = {};
|
|
170
|
+
if (sample.ledger) {
|
|
171
|
+
for (const [id, value] of Object.entries(sample.ledger.blocks)) {
|
|
172
|
+
const changed = value.added + value.deleted;
|
|
173
|
+
if (!changed) continue;
|
|
174
|
+
cells[id] = {
|
|
175
|
+
count: changed,
|
|
176
|
+
intensity: 0,
|
|
177
|
+
displayValue: new Intl.NumberFormat("en", {
|
|
178
|
+
notation: "compact",
|
|
179
|
+
maximumFractionDigits: 1,
|
|
180
|
+
}).format(changed),
|
|
181
|
+
label:
|
|
182
|
+
sample.ledger.mode === "activity" ? "line edits" : "line difference",
|
|
183
|
+
lineChange: {
|
|
184
|
+
added: value.added,
|
|
185
|
+
deleted: value.deleted,
|
|
186
|
+
partial: value.associated > 0,
|
|
187
|
+
},
|
|
188
|
+
summary: `${sample.ledger.mode === "activity" ? "Activity across mainline commits; repeated edits count again" : "Difference between range endpoints"} · +${value.added} added · −${value.deleted} removed · ${value.associated} lines use file-level associations rather than exact historical ranges.`,
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
cells: normalize(graph, cells),
|
|
193
|
+
unmapped:
|
|
194
|
+
sample.ledger.buckets.unassigned.added +
|
|
195
|
+
sample.ledger.buckets.unassigned.deleted,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
if (sample.churn && !sample.churn.error) {
|
|
199
|
+
for (const [id, value] of Object.entries(sample.churn.blocks)) {
|
|
200
|
+
const changed = value.added + value.deleted;
|
|
201
|
+
if (!changed) continue;
|
|
202
|
+
const percent =
|
|
203
|
+
value.percent == null ? null : Math.round(value.percent * 10) / 10;
|
|
204
|
+
cells[id] = {
|
|
205
|
+
count: percent || 0,
|
|
206
|
+
intensity: 0,
|
|
207
|
+
displayValue:
|
|
208
|
+
percent == null
|
|
209
|
+
? `${changed}`
|
|
210
|
+
: value.percent! > 0 && percent === 0
|
|
211
|
+
? "<0.1%"
|
|
212
|
+
: `${percent}%`,
|
|
213
|
+
label: percent == null ? "line changes" : "churn",
|
|
214
|
+
lineChange: {
|
|
215
|
+
added: value.added,
|
|
216
|
+
deleted: value.deleted,
|
|
217
|
+
partial: value.partial,
|
|
218
|
+
},
|
|
219
|
+
summary: `+${value.added} added · −${value.deleted} removed · net ${value.added - value.deleted > 0 ? "+" : ""}${value.added - value.deleted} lines. Churn = (added + removed) / ${value.baseline} matched starting lines; an edit counts on both sides.${value.partial ? " Partial source mapping: some historical source could not be assigned." : ""}${percent == null ? " No starting baseline for a percentage." : ""}`,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
return {
|
|
223
|
+
cells: normalize(graph, cells),
|
|
224
|
+
unmapped: sample.churn.unmappedLines,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
const end = Date.parse(sample.windowEnd || sample.checkedAt),
|
|
228
|
+
start = sample.windowStart
|
|
229
|
+
? Date.parse(sample.windowStart)
|
|
230
|
+
: end - sample.days * 86400000,
|
|
231
|
+
span = Math.max(1000, end - start);
|
|
232
|
+
let unmapped = 0;
|
|
233
|
+
for (const commit of sample.commits) {
|
|
234
|
+
const owners = new Set(
|
|
235
|
+
commit.files.flatMap((file) => [...fileBlocks(graph, file)]),
|
|
236
|
+
);
|
|
237
|
+
if (!owners.size) unmapped++;
|
|
238
|
+
const bucket = Math.max(
|
|
239
|
+
0,
|
|
240
|
+
Math.min(13, Math.floor(((Date.parse(commit.at) - start) / span) * 14)),
|
|
241
|
+
);
|
|
242
|
+
for (const id of owners) {
|
|
243
|
+
const cell = (cells[id] ||= {
|
|
244
|
+
count: 0,
|
|
245
|
+
intensity: 0,
|
|
246
|
+
label: "commits",
|
|
247
|
+
summary: `${sample.days ? `Last ${sample.days} days` : "Latest commits"} · file associations`,
|
|
248
|
+
series: Array(14).fill(0),
|
|
249
|
+
});
|
|
250
|
+
cell.count++;
|
|
251
|
+
cell.series![bucket]++;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return { cells: normalize(graph, cells), unmapped };
|
|
255
|
+
}
|
|
256
|
+
export function linearCells(
|
|
257
|
+
graph: DefinitionGraph,
|
|
258
|
+
view: WorkView,
|
|
259
|
+
window?: TimeWindow,
|
|
260
|
+
) {
|
|
261
|
+
const cells: Record<string, ActivityCell> = {};
|
|
262
|
+
const byId = new Map(graph.elements.map((node) => [node.id, node]));
|
|
263
|
+
let unmapped = 0;
|
|
264
|
+
for (const item of view.items) {
|
|
265
|
+
if (window && !inTimeWindow(item.metadata?.updatedAt, window)) continue;
|
|
266
|
+
const owners = new Set<string>();
|
|
267
|
+
for (const block of item.blocks) {
|
|
268
|
+
let current = byId.get(graph.aliases?.[block] || block);
|
|
269
|
+
const seen = new Set<string>();
|
|
270
|
+
while (current && !seen.has(current.id)) {
|
|
271
|
+
seen.add(current.id);
|
|
272
|
+
owners.add(current.id);
|
|
273
|
+
current = byId.get(current.parent!);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (!owners.size && !["done", "canceled", "archived"].includes(item.state))
|
|
277
|
+
unmapped++;
|
|
278
|
+
if (item.state === "canceled" || item.state === "archived") continue;
|
|
279
|
+
for (const id of owners) {
|
|
280
|
+
const cell = (cells[id] ||= {
|
|
281
|
+
count: 0,
|
|
282
|
+
intensity: 0,
|
|
283
|
+
label: "open issues",
|
|
284
|
+
summary: "",
|
|
285
|
+
segments: [
|
|
286
|
+
{ label: "Planned", count: 0, tone: "todo" },
|
|
287
|
+
{ label: "Active", count: 0, tone: "active" },
|
|
288
|
+
{ label: "Done", count: 0, tone: "done" },
|
|
289
|
+
{ label: "Unknown", count: 0, tone: "unknown" },
|
|
290
|
+
],
|
|
291
|
+
});
|
|
292
|
+
if (item.state === "todo" || item.state === "in_progress") cell.count++;
|
|
293
|
+
const position =
|
|
294
|
+
item.state === "todo"
|
|
295
|
+
? 0
|
|
296
|
+
: item.state === "in_progress"
|
|
297
|
+
? 1
|
|
298
|
+
: item.state === "done"
|
|
299
|
+
? 2
|
|
300
|
+
: 3;
|
|
301
|
+
cell.segments![position].count++;
|
|
302
|
+
cell.summary = cell
|
|
303
|
+
.segments!.filter((s) => s.count)
|
|
304
|
+
.map((s) => `${s.count} ${s.label.toLowerCase()}`)
|
|
305
|
+
.join(" · ");
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return { cells: normalize(graph, cells), unmapped };
|
|
309
|
+
}
|