@poetics/cli 0.1.2 → 0.2.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/dist/backfill.d.ts +98 -0
- package/dist/backfill.d.ts.map +1 -0
- package/dist/backfill.js +582 -0
- package/dist/backfill.js.map +1 -0
- package/dist/change.d.ts +18 -0
- package/dist/change.d.ts.map +1 -0
- package/dist/change.js +155 -0
- package/dist/change.js.map +1 -0
- package/dist/changes.d.ts +4 -0
- package/dist/changes.d.ts.map +1 -0
- package/dist/changes.js +38 -0
- package/dist/changes.js.map +1 -0
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +6 -2
- package/dist/commands.js.map +1 -1
- package/dist/coverage.d.ts +39 -0
- package/dist/coverage.d.ts.map +1 -0
- package/dist/coverage.js +88 -0
- package/dist/coverage.js.map +1 -0
- package/dist/declarations.d.ts +26 -0
- package/dist/declarations.d.ts.map +1 -0
- package/dist/declarations.js +34 -0
- package/dist/declarations.js.map +1 -0
- package/dist/drift.d.ts +29 -0
- package/dist/drift.d.ts.map +1 -0
- package/dist/drift.js +84 -0
- package/dist/drift.js.map +1 -0
- package/dist/frameworks.d.ts +6 -0
- package/dist/frameworks.d.ts.map +1 -0
- package/dist/frameworks.js +8 -0
- package/dist/frameworks.js.map +1 -0
- package/dist/git.d.ts +19 -0
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +40 -0
- package/dist/git.js.map +1 -0
- package/dist/history.d.ts +6 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/history.js +53 -0
- package/dist/history.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/indexing.d.ts +91 -0
- package/dist/indexing.d.ts.map +1 -0
- package/dist/indexing.js +372 -0
- package/dist/indexing.js.map +1 -0
- package/dist/init.d.ts +35 -0
- package/dist/init.d.ts.map +1 -0
- package/dist/init.js +186 -0
- package/dist/init.js.map +1 -0
- package/dist/rehash.d.ts +31 -0
- package/dist/rehash.d.ts.map +1 -0
- package/dist/rehash.js +73 -0
- package/dist/rehash.js.map +1 -0
- package/dist/run.d.ts +2 -2
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +258 -2
- package/dist/run.js.map +1 -1
- package/package.json +6 -3
package/dist/drift.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// Compares the code with the store: which declarations have no unit, which
|
|
2
|
+
// units are behind their code, and which units no longer have code.
|
|
3
|
+
import { isProvisional, isRemoved } from "@poetics/core";
|
|
4
|
+
export const DRIFT_SEVERITY = {
|
|
5
|
+
untracked: "error",
|
|
6
|
+
stale: "error",
|
|
7
|
+
orphaned: "error",
|
|
8
|
+
duplicate: "error",
|
|
9
|
+
};
|
|
10
|
+
const key = (file, name) => `${file}#${name}`;
|
|
11
|
+
/**
|
|
12
|
+
* Matches declarations to units by file and name (lineage keeps these current
|
|
13
|
+
* across renames and moves). Only units whose file satisfies `covers` can be
|
|
14
|
+
* orphaned: pass the set of files that were scanned, so units for files outside
|
|
15
|
+
* the scan (or that the parser cannot read yet, like .svelte) are left alone.
|
|
16
|
+
* Removed units are history, not code, so they never match: an export that
|
|
17
|
+
* reappears under a removed unit's name gets a new unit.
|
|
18
|
+
*/
|
|
19
|
+
export function compareCodeWithStore(declarations, units, covers) {
|
|
20
|
+
const findings = [];
|
|
21
|
+
const byKey = new Map();
|
|
22
|
+
for (const unit of units) {
|
|
23
|
+
if (unit.owner !== undefined || isRemoved(unit))
|
|
24
|
+
continue;
|
|
25
|
+
const k = key(unit.location.file, unit.location.export ?? unit.name);
|
|
26
|
+
const existing = byKey.get(k);
|
|
27
|
+
if (existing) {
|
|
28
|
+
findings.push({
|
|
29
|
+
kind: "duplicate",
|
|
30
|
+
file: unit.location.file,
|
|
31
|
+
name: unit.name,
|
|
32
|
+
uid: unit.uid,
|
|
33
|
+
message: `${unit.name} has two units (${existing.uid}, ${unit.uid}); merge them with lineage`,
|
|
34
|
+
});
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
byKey.set(k, unit);
|
|
38
|
+
}
|
|
39
|
+
let tracked = 0;
|
|
40
|
+
let fresh = 0;
|
|
41
|
+
const matched = new Set();
|
|
42
|
+
for (const decl of declarations) {
|
|
43
|
+
const k = key(decl.file, decl.name);
|
|
44
|
+
const unit = byKey.get(k);
|
|
45
|
+
if (!unit) {
|
|
46
|
+
findings.push({
|
|
47
|
+
kind: "untracked",
|
|
48
|
+
file: decl.file,
|
|
49
|
+
name: decl.name,
|
|
50
|
+
message: `${decl.name} has no unit; mint a uid and create one (lines ${decl.startLine}-${decl.endLine}, contentHash ${decl.contentHash})`,
|
|
51
|
+
});
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
matched.add(k);
|
|
55
|
+
tracked++;
|
|
56
|
+
// Compare like with like: history before the rehash recorded git: hashes of the text (ADR 0014).
|
|
57
|
+
const latest = unit.versions.at(-1).contentHash;
|
|
58
|
+
if (latest === (isProvisional(latest) ? decl.hash : decl.contentHash)) {
|
|
59
|
+
fresh++;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
findings.push({
|
|
63
|
+
kind: "stale",
|
|
64
|
+
file: decl.file,
|
|
65
|
+
name: decl.name,
|
|
66
|
+
uid: unit.uid,
|
|
67
|
+
message: `${decl.name} changed but its unit has no version for it; append one with contentHash ${decl.contentHash} (lines ${decl.startLine}-${decl.endLine})`,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
for (const [k, unit] of byKey) {
|
|
72
|
+
if (matched.has(k) || !covers(unit.location.file))
|
|
73
|
+
continue;
|
|
74
|
+
findings.push({
|
|
75
|
+
kind: "orphaned",
|
|
76
|
+
file: unit.location.file,
|
|
77
|
+
name: unit.name,
|
|
78
|
+
uid: unit.uid,
|
|
79
|
+
message: `${unit.name} no longer exists in ${unit.location.file}; record lineage if it moved or was renamed, or append a "removed" version saying why it went`,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return { findings, tracked, fresh, declarations: declarations.length };
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=drift.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drift.js","sourceRoot":"","sources":["../src/drift.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,oEAAoE;AACpE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAuBzD,MAAM,CAAC,MAAM,cAAc,GAA2C;IACpE,SAAS,EAAE,OAAO;IAClB,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,OAAO;IACjB,SAAS,EAAE,OAAO;CACnB,CAAC;AAEF,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,IAAY,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,IAAI,EAAE,CAAC;AAE9D;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,YAAoC,EACpC,KAAsB,EACtB,MAAiC;IAEjC,MAAM,QAAQ,GAAmB,EAAE,CAAC;IACpC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAgB,CAAC;IACtC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,SAAS,CAAC,IAAI,CAAC;YAAE,SAAS;QAC1D,MAAM,CAAC,GAAG,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;QACrE,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9B,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI;gBACxB,IAAI,EAAE,I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C,EAAE,CAAC;YACtE,KAAK,EAAE,CAAC;QACV,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,IAAI,CAAC;gBACZ,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,OAAO,EAAE,GAAG,IAAI,CAAC,IAAI,4EAA4E,IAAI,CAAC,WAAW,WAAW,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,GAAG;aAC9J,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,KAAK,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;QAC9B,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,SAAS;QAC5D,QAAQ,CAAC,IAAI,CAAC;YACZ,IAAI,EAAE,UAAU;YAChB,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI;YACxB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,OAAO,EAAE,GAAG,IAAI,CAAC,IAAI,wBAAwB,IAAI,CAAC,QAAQ,CAAC,IAAI,+FAA+F;SAC/J,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,CAAC,MAAM,EAAE,CAAC;AACzE,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FrameworkPlugin } from "@poetics/adapter-typescript";
|
|
2
|
+
/** The plugins for `config.adapters`: React's when `react` is listed. Svelte's arrives with its adapter. */
|
|
3
|
+
export declare function pluginsFor(config: {
|
|
4
|
+
adapters?: readonly string[];
|
|
5
|
+
}): FrameworkPlugin[];
|
|
6
|
+
//# sourceMappingURL=frameworks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frameworks.d.ts","sourceRoot":"","sources":["../src/frameworks.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,4GAA4G;AAC5G,wBAAgB,UAAU,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,GAAG,eAAe,EAAE,CAEtF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Which framework plugins the TypeScript indexer runs for a repository, from the
|
|
2
|
+
// adapters its config lists.
|
|
3
|
+
import { reactPlugin } from "@poetics/adapter-react";
|
|
4
|
+
/** The plugins for `config.adapters`: React's when `react` is listed. Svelte's arrives with its adapter. */
|
|
5
|
+
export function pluginsFor(config) {
|
|
6
|
+
return config.adapters?.includes("react") ? [reactPlugin()] : [];
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=frameworks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frameworks.js","sourceRoot":"","sources":["../src/frameworks.ts"],"names":[],"mappings":"AAAA,iFAAiF;AACjF,6BAA6B;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGrD,4GAA4G;AAC5G,MAAM,UAAU,UAAU,CAAC,MAAwC;IACjE,OAAO,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACnE,CAAC"}
|
package/dist/git.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare function git(root: string, args: readonly string[]): string;
|
|
2
|
+
/** File contents at a ref, or undefined if the file did not exist there. */
|
|
3
|
+
export declare function showAt(root: string, ref: string, path: string): string | undefined;
|
|
4
|
+
export interface FileChange {
|
|
5
|
+
status: "A" | "M" | "D" | "R";
|
|
6
|
+
path: string;
|
|
7
|
+
/** Previous path, for renames. */
|
|
8
|
+
from?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Files that differ between `base` and the working tree, including untracked
|
|
12
|
+
* files, with renames detected. `base` is resolved to its merge base with HEAD
|
|
13
|
+
* so a branch is compared with where it forked.
|
|
14
|
+
*/
|
|
15
|
+
export declare function changesSince(root: string, base: string): {
|
|
16
|
+
base: string;
|
|
17
|
+
changes: FileChange[];
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=git.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAEA,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAEjE;AAED,4EAA4E;AAC5E,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAMlF;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,UAAU,EAAE,CAAA;CAAE,CAehG"}
|
package/dist/git.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process";
|
|
2
|
+
export function git(root, args) {
|
|
3
|
+
return execFileSync("git", args, { cwd: root, encoding: "utf8", maxBuffer: 64 * 1024 * 1024 });
|
|
4
|
+
}
|
|
5
|
+
/** File contents at a ref, or undefined if the file did not exist there. */
|
|
6
|
+
export function showAt(root, ref, path) {
|
|
7
|
+
try {
|
|
8
|
+
return execFileSync("git", ["show", `${ref}:${path}`], { cwd: root, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] });
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Files that differ between `base` and the working tree, including untracked
|
|
16
|
+
* files, with renames detected. `base` is resolved to its merge base with HEAD
|
|
17
|
+
* so a branch is compared with where it forked.
|
|
18
|
+
*/
|
|
19
|
+
export function changesSince(root, base) {
|
|
20
|
+
const resolved = base === "HEAD" ? git(root, ["rev-parse", "HEAD"]).trim() : git(root, ["merge-base", base, "HEAD"]).trim();
|
|
21
|
+
const changes = [];
|
|
22
|
+
for (const line of git(root, ["diff", "--name-status", "-M", resolved]).split("\n")) {
|
|
23
|
+
if (!line)
|
|
24
|
+
continue;
|
|
25
|
+
const [status, first, second] = line.split("\t");
|
|
26
|
+
const code = status[0];
|
|
27
|
+
if (code === "R")
|
|
28
|
+
changes.push({ status: "R", from: first, path: second });
|
|
29
|
+
else if (code === "A" || code === "M" || code === "D")
|
|
30
|
+
changes.push({ status: code, path: first });
|
|
31
|
+
else if (code === "T" || code === "C")
|
|
32
|
+
changes.push({ status: "M", path: second ?? first });
|
|
33
|
+
}
|
|
34
|
+
for (const path of git(root, ["ls-files", "--others", "--exclude-standard"]).split("\n")) {
|
|
35
|
+
if (path)
|
|
36
|
+
changes.push({ status: "A", path });
|
|
37
|
+
}
|
|
38
|
+
return { base: resolved, changes };
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=git.js.map
|
package/dist/git.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAA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GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjD,MAAM,IAAI,GAAG,MAAO,CAAC,CAAC,CAAC,CAAC;QACxB,IAAI,IAAI,KAAK,GAAG;YAAE,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,KAAM,EAAE,IAAI,EAAE,MAAO,EAAE,CAAC,CAAC;aACxE,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG;YAAE,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAM,EAAE,CAAC,CAAC;aAC/F,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG;YAAE,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,IAAI,KAAM,EAAE,CAAC,CAAC;IAC/F,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACzF,IAAI,IAAI;YAAE,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Unit } from "@poetics/core";
|
|
2
|
+
/** Renders `poetics log`: every version of a unit, newest first, with its hash, commit, author and rationale. */
|
|
3
|
+
export declare function formatLog(unit: Unit): string;
|
|
4
|
+
/** Renders `poetics why`: the rationale chain that led to the current version, oldest first. */
|
|
5
|
+
export declare function formatWhy(unit: Unit): string;
|
|
6
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../src/history.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAA6B,IAAI,EAAW,MAAM,eAAe,CAAC;AAE9E,iHAAiH;AACjH,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAgB5C;AAED,gGAAgG;AAChG,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,CAQ5C"}
|
package/dist/history.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** Renders `poetics log`: every version of a unit, newest first, with its hash, commit, author and rationale. */
|
|
2
|
+
export function formatLog(unit) {
|
|
3
|
+
const prehistory = unit.prehistory ?? [];
|
|
4
|
+
const lines = [`${unit.name} (${unit.kind}, ${unit.location.file}) ${unit.uid}: ${unit.versions.length} version(s)${prehistory.length ? `, ${prehistory.length} before it was recorded` : ""}`];
|
|
5
|
+
for (let seq = unit.versions.length - 1; seq >= 0; seq--) {
|
|
6
|
+
const version = unit.versions[seq];
|
|
7
|
+
const where = [version.contentHash.slice(0, 12), version.commit?.slice(0, 7)].filter(Boolean).join(" ");
|
|
8
|
+
lines.push("", `#${seq} ${version.change} ${where} by ${actorLabel(version.actor)}`, ...details(version, " "));
|
|
9
|
+
}
|
|
10
|
+
if (prehistory.length > 0)
|
|
11
|
+
lines.push("", "Before it was recorded (reconstructed from git):");
|
|
12
|
+
for (let seq = prehistory.length - 1; seq >= 0; seq--) {
|
|
13
|
+
const version = prehistory[seq];
|
|
14
|
+
const where = [version.contentHash.slice(0, 12), version.commit?.slice(0, 7)].filter(Boolean).join(" ");
|
|
15
|
+
lines.push("", `~${seq} ${version.change} ${where} by ${actorLabel(version.actor)}${inferredLabel(version)}`, ...details(version, " "));
|
|
16
|
+
}
|
|
17
|
+
if ((unit.lineage ?? []).length > 0)
|
|
18
|
+
lines.push("", "Lineage:", ...unit.lineage.map((entry) => ` ${lineageLabel(entry)}`));
|
|
19
|
+
return lines.join("\n");
|
|
20
|
+
}
|
|
21
|
+
/** Renders `poetics why`: the rationale chain that led to the current version, oldest first. */
|
|
22
|
+
export function formatWhy(unit) {
|
|
23
|
+
const lines = [`Why ${unit.name} (${unit.location.file}) is the way it is:`];
|
|
24
|
+
const prehistory = unit.prehistory ?? [];
|
|
25
|
+
// Oldest first: what happened before the unit was recorded comes first, marked as reconstructed.
|
|
26
|
+
prehistory.forEach((version, seq) => lines.push("", `${seq + 1}. ${version.change}${inferredLabel(version)}`, ...details(version, " ")));
|
|
27
|
+
unit.versions.forEach((version, seq) => lines.push("", `${prehistory.length + seq + 1}. ${version.change}`, ...details(version, " ")));
|
|
28
|
+
if ((unit.lineage ?? []).length > 0)
|
|
29
|
+
lines.push("", "Along the way:", ...unit.lineage.map((entry) => ` ${lineageLabel(entry)}`));
|
|
30
|
+
return lines.join("\n");
|
|
31
|
+
}
|
|
32
|
+
function details(version, indent) {
|
|
33
|
+
const lines = [`${indent}${version.rationale}`];
|
|
34
|
+
const links = (version.links ?? []).map(linkLabel);
|
|
35
|
+
if (links.length > 0)
|
|
36
|
+
lines.push(`${indent}links: ${links.join(", ")}`);
|
|
37
|
+
return lines;
|
|
38
|
+
}
|
|
39
|
+
function inferredLabel(version) {
|
|
40
|
+
return version.inferred ? ` (inferred, ${version.inferred.confidence} confidence)` : "";
|
|
41
|
+
}
|
|
42
|
+
function actorLabel(actor) {
|
|
43
|
+
if (actor.kind !== "agent")
|
|
44
|
+
return actor.kind;
|
|
45
|
+
return `${actor.tool}${actor.model ? ` (${actor.model})` : ""}${actor.reviewed ? ", reviewed" : ", unreviewed"}`;
|
|
46
|
+
}
|
|
47
|
+
function linkLabel(link) {
|
|
48
|
+
return typeof link === "string" ? link : (link.url ?? link.ref);
|
|
49
|
+
}
|
|
50
|
+
function lineageLabel(entry) {
|
|
51
|
+
return `${entry.kind}${entry.from ? ` from ${entry.from}` : ""}${entry.uids ? ` with ${entry.uids.join(", ")}` : ""}${entry.commit ? ` in ${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.d.ts
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
|
+
export type { ChangeFinding, ChangeFindingKind, ChangeReport } from "./change.ts";
|
|
2
|
+
export { checkChange } from "./change.ts";
|
|
3
|
+
export { formatChanges } from "./changes.ts";
|
|
1
4
|
export type { CommandSpec } from "./commands.ts";
|
|
2
5
|
export { COMMANDS } from "./commands.ts";
|
|
6
|
+
export type { CoverageThresholds, PoeticsConfig, Scope } from "@poetics/store";
|
|
7
|
+
export { filesInScope, readConfig } from "@poetics/store";
|
|
8
|
+
export type { CoverageMetrics, CoverageReport, Ratio } from "./coverage.ts";
|
|
9
|
+
export { METRICS, areaOf, computeCoverage, coverageFor, formatCoverage } from "./coverage.ts";
|
|
10
|
+
export type { Declaration } from "./declarations.ts";
|
|
11
|
+
export { declarationsIn, discoverDeclarations } from "./declarations.ts";
|
|
12
|
+
export type { Drift, DriftFinding, DriftKind } from "./drift.ts";
|
|
13
|
+
export { DRIFT_SEVERITY, compareCodeWithStore } from "./drift.ts";
|
|
14
|
+
export { formatLog, formatWhy } from "./history.ts";
|
|
3
15
|
export type { Io } from "./run.ts";
|
|
4
16
|
export { VERSION, run } from "./run.ts";
|
|
17
|
+
export type { RehashEntry, RehashPlan } from "./rehash.ts";
|
|
18
|
+
export { applyRehash, planRehash, unitHashes } from "./rehash.ts";
|
|
19
|
+
export type { IndexOptions, IndexPlan, PlannedMove, PlannedReclassification, PlannedRelink, PlannedVersion } from "./indexing.ts";
|
|
20
|
+
export { applyIndex, declareLineage, formatIndexPlan, hasWrites, needsRationale, planIndex } from "./indexing.ts";
|
|
21
|
+
export type { BackfillPlan, Evidence, PrehistoryEntry, PrehistoryPlan } from "./backfill.ts";
|
|
22
|
+
export { applyBackfill, applyPrehistory, formatBackfillPlan, formatPrehistoryPlan, hasBackfill, planBackfill, planPrehistory } from "./backfill.ts";
|
|
23
|
+
export type { Adapter, InitConfig, InitPlan } from "./init.ts";
|
|
24
|
+
export { applyInit, formatInitPlan, planInit } from "./init.ts";
|
|
25
|
+
export { pluginsFor } from "./frameworks.ts";
|
|
5
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,aAAa,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,YAAY,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,YAAY,EAAE,kBAAkB,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC1D,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC9F,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzE,YAAY,EAAE,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAClE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,uBAAuB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAClI,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAClH,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpJ,YAAY,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
export { checkChange } from "./change.js";
|
|
2
|
+
export { formatChanges } from "./changes.js";
|
|
1
3
|
export { COMMANDS } from "./commands.js";
|
|
4
|
+
export { filesInScope, readConfig } from "@poetics/store";
|
|
5
|
+
export { METRICS, areaOf, computeCoverage, coverageFor, formatCoverage } from "./coverage.js";
|
|
6
|
+
export { declarationsIn, discoverDeclarations } from "./declarations.js";
|
|
7
|
+
export { DRIFT_SEVERITY, compareCodeWithStore } from "./drift.js";
|
|
8
|
+
export { formatLog, formatWhy } from "./history.js";
|
|
2
9
|
export { VERSION, run } from "./run.js";
|
|
10
|
+
export { applyRehash, planRehash, unitHashes } from "./rehash.js";
|
|
11
|
+
export { applyIndex, declareLineage, formatIndexPlan, hasWrites, needsRationale, planIndex } from "./indexing.js";
|
|
12
|
+
export { applyBackfill, applyPrehistory, formatBackfillPlan, formatPrehistoryPlan, hasBackfill, planBackfill, planPrehistory } from "./backfill.js";
|
|
13
|
+
export { applyInit, formatInitPlan, planInit } from "./init.js";
|
|
14
|
+
export { pluginsFor } from "./frameworks.js";
|
|
3
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE9F,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAEzE,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAElE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAElH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpJ,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { Actor, LineageDeclaration, LineageEntry, QueuedMatch, RejectedDeclaration, Unit, Version } from "@poetics/core";
|
|
2
|
+
import type { PoeticsConfig, StoreLayout } from "@poetics/store";
|
|
3
|
+
export interface IndexOptions {
|
|
4
|
+
/** The ref whose code the store was last in step with. Default `HEAD`. */
|
|
5
|
+
since?: string;
|
|
6
|
+
/** Rationale for every version written. Default: the messages of the commits since `since`. */
|
|
7
|
+
rationale?: string;
|
|
8
|
+
/** Renames, moves, splits and merges someone declared, matched first and checked against the code. */
|
|
9
|
+
declarations?: LineageDeclaration[];
|
|
10
|
+
}
|
|
11
|
+
/** A version to append, with where its unit is, for reporting. */
|
|
12
|
+
export interface PlannedVersion {
|
|
13
|
+
uid: string;
|
|
14
|
+
key: string;
|
|
15
|
+
version: Omit<Version, "actor">;
|
|
16
|
+
/** For a removal a declared merge caused: the unit it merged into. */
|
|
17
|
+
mergedInto?: string;
|
|
18
|
+
}
|
|
19
|
+
/** A unit that moved or was renamed, and the lineage that says so. */
|
|
20
|
+
export interface PlannedMove {
|
|
21
|
+
uid: string;
|
|
22
|
+
from: string;
|
|
23
|
+
key: string;
|
|
24
|
+
to: {
|
|
25
|
+
file: string;
|
|
26
|
+
name: string;
|
|
27
|
+
export?: string;
|
|
28
|
+
};
|
|
29
|
+
lineage: LineageEntry[];
|
|
30
|
+
via: string;
|
|
31
|
+
score?: number;
|
|
32
|
+
}
|
|
33
|
+
/** A unit whose code the adapters now see as a different kind or framework, such as a function React claims as a component. */
|
|
34
|
+
export interface PlannedReclassification {
|
|
35
|
+
uid: string;
|
|
36
|
+
key: string;
|
|
37
|
+
from: Pick<Unit, "kind" | "framework">;
|
|
38
|
+
to: Pick<Unit, "kind" | "framework">;
|
|
39
|
+
}
|
|
40
|
+
/** A unit whose linked test files were renamed, and where each went. */
|
|
41
|
+
export interface PlannedRelink {
|
|
42
|
+
uid: string;
|
|
43
|
+
key: string;
|
|
44
|
+
tests: Array<{
|
|
45
|
+
from: string;
|
|
46
|
+
to: string;
|
|
47
|
+
}>;
|
|
48
|
+
}
|
|
49
|
+
export interface IndexPlan {
|
|
50
|
+
/** The commit the code was compared with; null in a repository with no commits yet. */
|
|
51
|
+
base: string | null;
|
|
52
|
+
/** Undefined when neither `--rationale` nor any commit since `base` gives one. */
|
|
53
|
+
rationale: string | undefined;
|
|
54
|
+
/** Units whose recorded place already has their latest hash. */
|
|
55
|
+
fresh: number;
|
|
56
|
+
moves: PlannedMove[];
|
|
57
|
+
versions: PlannedVersion[];
|
|
58
|
+
created: Unit[];
|
|
59
|
+
removed: PlannedVersion[];
|
|
60
|
+
relinks: PlannedRelink[];
|
|
61
|
+
reclassified: PlannedReclassification[];
|
|
62
|
+
queued: QueuedMatch[];
|
|
63
|
+
/** Declarations the code disagrees with, and why. Nothing is written for them. */
|
|
64
|
+
rejected: RejectedDeclaration[];
|
|
65
|
+
}
|
|
66
|
+
/** What poetics index would record: nothing is written until `applyIndex`. */
|
|
67
|
+
export declare function planIndex(root: string, config: PoeticsConfig, options?: IndexOptions): Promise<IndexPlan>;
|
|
68
|
+
/** Writes the plan as `actor`. Queued units are left as they are. Returns how many unit files changed. */
|
|
69
|
+
export declare function applyIndex(root: string, plan: IndexPlan, actor: Actor, layout?: StoreLayout): Promise<number>;
|
|
70
|
+
/** The plan for people: one line per unit, then a summary. `written` is set after a write. */
|
|
71
|
+
export declare function formatIndexPlan(plan: IndexPlan, written?: number): string;
|
|
72
|
+
/** Whether applying the plan would write anything. */
|
|
73
|
+
export declare function hasWrites(plan: IndexPlan): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Whether the plan writes a version with no rationale of its own. Moves, test
|
|
76
|
+
* links and reclassifications carry none; a declared split or merge brings its
|
|
77
|
+
* own.
|
|
78
|
+
*/
|
|
79
|
+
export declare function needsRationale(plan: IndexPlan): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* Records one declared rename, move, split or merge, checked the way
|
|
82
|
+
* `poetics index` matches: the declaration is refused, with the reason, when
|
|
83
|
+
* the code disagrees. Only identity is written (places, lineage, split parts,
|
|
84
|
+
* merged removals); code changes are left for `poetics index` to record.
|
|
85
|
+
*/
|
|
86
|
+
export declare function declareLineage(root: string, config: PoeticsConfig, declaration: LineageDeclaration, actor: Actor, layout?: StoreLayout): Promise<{
|
|
87
|
+
moved: PlannedMove[];
|
|
88
|
+
created: Unit[];
|
|
89
|
+
removed: PlannedVersion[];
|
|
90
|
+
}>;
|
|
91
|
+
//# sourceMappingURL=indexing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexing.d.ts","sourceRoot":"","sources":["../src/indexing.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,KAAK,EAA+B,kBAAkB,EAAE,YAAY,EAAQ,WAAW,EAAE,mBAAmB,EAAe,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE9K,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAIjE,MAAM,WAAW,YAAY;IAC3B,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+FAA+F;IAC/F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,sGAAsG;IACtG,YAAY,CAAC,EAAE,kBAAkB,EAAE,C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