@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.
Files changed (60) hide show
  1. package/dist/backfill.d.ts +98 -0
  2. package/dist/backfill.d.ts.map +1 -0
  3. package/dist/backfill.js +582 -0
  4. package/dist/backfill.js.map +1 -0
  5. package/dist/change.d.ts +18 -0
  6. package/dist/change.d.ts.map +1 -0
  7. package/dist/change.js +155 -0
  8. package/dist/change.js.map +1 -0
  9. package/dist/changes.d.ts +4 -0
  10. package/dist/changes.d.ts.map +1 -0
  11. package/dist/changes.js +38 -0
  12. package/dist/changes.js.map +1 -0
  13. package/dist/commands.d.ts.map +1 -1
  14. package/dist/commands.js +6 -2
  15. package/dist/commands.js.map +1 -1
  16. package/dist/coverage.d.ts +39 -0
  17. package/dist/coverage.d.ts.map +1 -0
  18. package/dist/coverage.js +88 -0
  19. package/dist/coverage.js.map +1 -0
  20. package/dist/declarations.d.ts +26 -0
  21. package/dist/declarations.d.ts.map +1 -0
  22. package/dist/declarations.js +34 -0
  23. package/dist/declarations.js.map +1 -0
  24. package/dist/drift.d.ts +29 -0
  25. package/dist/drift.d.ts.map +1 -0
  26. package/dist/drift.js +84 -0
  27. package/dist/drift.js.map +1 -0
  28. package/dist/frameworks.d.ts +6 -0
  29. package/dist/frameworks.d.ts.map +1 -0
  30. package/dist/frameworks.js +8 -0
  31. package/dist/frameworks.js.map +1 -0
  32. package/dist/git.d.ts +19 -0
  33. package/dist/git.d.ts.map +1 -0
  34. package/dist/git.js +40 -0
  35. package/dist/git.js.map +1 -0
  36. package/dist/history.d.ts +6 -0
  37. package/dist/history.d.ts.map +1 -0
  38. package/dist/history.js +53 -0
  39. package/dist/history.js.map +1 -0
  40. package/dist/index.d.ts +21 -0
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +12 -0
  43. package/dist/index.js.map +1 -1
  44. package/dist/indexing.d.ts +91 -0
  45. package/dist/indexing.d.ts.map +1 -0
  46. package/dist/indexing.js +372 -0
  47. package/dist/indexing.js.map +1 -0
  48. package/dist/init.d.ts +35 -0
  49. package/dist/init.d.ts.map +1 -0
  50. package/dist/init.js +186 -0
  51. package/dist/init.js.map +1 -0
  52. package/dist/rehash.d.ts +31 -0
  53. package/dist/rehash.d.ts.map +1 -0
  54. package/dist/rehash.js +73 -0
  55. package/dist/rehash.js.map +1 -0
  56. package/dist/run.d.ts +2 -2
  57. package/dist/run.d.ts.map +1 -1
  58. package/dist/run.js +258 -2
  59. package/dist/run.js.map +1 -1
  60. package/package.json +6 -3
@@ -0,0 +1,372 @@
1
+ // poetics index: reconcile the store with the code. Units already recorded are
2
+ // left alone; units edited in place get a version; units that left their
3
+ // recorded place are matched to the code that appeared (moves and renames keep
4
+ // their uid), and whatever is left is created or removed. Ambiguous matches are
5
+ // reported, never guessed, and nothing is written for them. Test links follow
6
+ // test files that git saw renamed.
7
+ import { existsSync, readFileSync } from "node:fs";
8
+ import { join } from "node:path";
9
+ import ts from "typescript";
10
+ import { contentTree, createTypeScriptIndexer, detectUnits, fingerprint } from "@poetics/adapter-typescript";
11
+ import { REMOVED_CONTENT_HASH, contentHash, isRemoved, matchIdentities, mintUid } from "@poetics/core";
12
+ import { appendVersion, createMatcher, createUnit, filesInScope, parseUnit, readUnitFiles, reclassifyUnit, relinkTests, relocateUnit, storePaths } from "@poetics/store";
13
+ import { pluginsFor } from "./frameworks.js";
14
+ import { changesSince, git, showAt } from "./git.js";
15
+ const CACHE = "typescript.json";
16
+ /** What poetics index would record: nothing is written until `applyIndex`. */
17
+ export async function planIndex(root, config, options = {}) {
18
+ const since = changesFromBase(root, options.since ?? "HEAD");
19
+ const base = since?.base ?? null;
20
+ const rationale = options.rationale?.trim() || (base ? commitMessages(root, base) : "") || undefined;
21
+ const { parseable } = await filesInScope(root, config);
22
+ const tsconfig = config.typescript?.tsconfig;
23
+ const paths = storePaths(root);
24
+ const plugins = pluginsFor(config);
25
+ const code = createTypeScriptIndexer({ root, files: parseable, cacheFile: join(paths.cache, CACHE), plugins, ...(tsconfig ? { tsconfig } : {}) }).index().units;
26
+ // By scope, not by what exists now: a unit whose file was deleted or moved is exactly what matching is for.
27
+ const inScope = createMatcher(config.include, config.exclude ?? []);
28
+ const indexable = (file) => inScope(file) && /\.(ts|tsx|mts|cts)$/.test(file) && !file.endsWith(".d.ts");
29
+ const live = (await readUnitFiles(paths))
30
+ .map(parseUnit)
31
+ .filter((unit) => !isRemoved(unit))
32
+ .sort((a, b) => (a.uid < b.uid ? -1 : 1));
33
+ const units = live.filter((unit) => unit.owner === undefined && indexable(unit.location.file));
34
+ const plan = { base, rationale, fresh: 0, moves: [], versions: [], created: [], removed: [], relinks: [], reclassified: [], queued: [], rejected: [] };
35
+ // A declared unit goes through matching even when its old place still has code, as a split's original does.
36
+ const declared = new Set((options.declarations ?? []).flatMap((declaration) => declaration.uids));
37
+ // A store recorded before an adapter existed calls its components functions; the code now says otherwise.
38
+ const reclassify = (unit, at) => {
39
+ if (unit.kind === at.kind && unit.framework === at.framework)
40
+ return;
41
+ plan.reclassified.push({ uid: unit.uid, key: at.key, from: { kind: unit.kind, framework: unit.framework }, to: { kind: at.kind, framework: at.framework } });
42
+ };
43
+ const baseCode = baseSnapshot(root, base, plugins);
44
+ const codeByPlace = new Map(code.map((unit) => [place(unit.span.file, unit.name, unit.kind), unit]));
45
+ const uidOfKey = new Map();
46
+ const claimed = new Set();
47
+ const orphans = [];
48
+ const pending = [];
49
+ // 1. Units at their recorded place: recorded already, or edited in place.
50
+ for (const unit of units) {
51
+ const at = codeByPlace.get(place(unit.location.file, unit.name, unit.kind));
52
+ if (!at || declared.has(unit.uid)) {
53
+ orphans.push(unit);
54
+ continue;
55
+ }
56
+ claimed.add(at.key);
57
+ uidOfKey.set(at.key, unit.uid);
58
+ reclassify(unit, at);
59
+ if (unit.versions.at(-1).contentHash === at.contentHash)
60
+ plan.fresh++;
61
+ else
62
+ pending.push({ unit, at });
63
+ }
64
+ // 2. Units that left their place, matched to code no unit claims, using the code at `base` for their shape.
65
+ const untracked = code.filter((unit) => !claimed.has(unit.key));
66
+ const before = orphans.map((unit) => {
67
+ const was = baseCode(unit.location.file, unit.name, unit.kind);
68
+ return was ? { ...was, uid: unit.uid } : { key: `${unit.location.file}#${unit.name}`, file: unit.location.file, name: unit.name, kind: unit.kind, contentHash: unit.versions.at(-1).contentHash, fingerprint: [], uid: unit.uid };
69
+ });
70
+ const result = matchIdentities(before, untracked.map(codeUnit), options.declarations ?? []);
71
+ plan.rejected = result.rejected;
72
+ const unitByUid = new Map(units.map((unit) => [unit.uid, unit]));
73
+ const codeByKey = new Map(code.map((unit) => [unit.key, unit]));
74
+ // New units first, so a declared split's original can name its parts' uids.
75
+ const createdFrom = [];
76
+ for (const created of result.created) {
77
+ const at = codeByKey.get(created.key);
78
+ const uid = mintUid();
79
+ uidOfKey.set(at.key, uid);
80
+ const unit = newUnit(root, uid, at);
81
+ const original = created.lineage?.find((entry) => entry.kind === "split")?.uids?.[0];
82
+ if (created.lineage)
83
+ unit.lineage = created.lineage;
84
+ createdFrom.push({ unit, at, ...(original ? { splitFrom: unitByUid.get(original) } : {}) });
85
+ }
86
+ for (const match of result.matched) {
87
+ const unit = unitByUid.get(match.uid);
88
+ const at = codeByKey.get(match.key);
89
+ uidOfKey.set(at.key, unit.uid);
90
+ const lineage = [...match.lineage];
91
+ if (match.splitInto)
92
+ lineage.push({ kind: "split", uids: match.splitInto.map((key) => uidOfKey.get(key)) });
93
+ // A declared unit that kept its place and gained no lineage is simply where it was.
94
+ if (lineage.length > 0) {
95
+ const to = { file: at.span.file, name: at.name };
96
+ if (at.exportedAs !== undefined)
97
+ to.export = at.exportedAs;
98
+ const move = { uid: unit.uid, from: `${unit.location.file}#${unit.name}`, key: at.key, to, lineage, via: match.via };
99
+ if (match.score !== undefined)
100
+ move.score = match.score;
101
+ plan.moves.push(move);
102
+ }
103
+ else if (unit.versions.at(-1).contentHash === at.contentHash) {
104
+ plan.fresh++;
105
+ }
106
+ reclassify(unit, at);
107
+ if (unit.versions.at(-1).contentHash !== at.contentHash)
108
+ pending.push({ unit, at });
109
+ }
110
+ plan.created = createdFrom.map(({ unit }) => unit);
111
+ plan.queued = result.queued;
112
+ // 3. Versions, now that every key has its uid for deps.
113
+ const words = rationale ?? "";
114
+ // An explicit rationale speaks for the whole run; a commit's references belong to the units in the files it touched.
115
+ const explicit = options.rationale?.trim() ? issueLinks(options.rationale) : [];
116
+ const commits = base ? commitReferences(root, base) : [];
117
+ const linksFor = (...files) => {
118
+ const found = [...explicit, ...commits.filter((c) => files.some((file) => c.files.has(file))).flatMap((c) => c.links)];
119
+ return found.filter((link, i) => found.findIndex((other) => linkKey(other) === linkKey(link)) === i);
120
+ };
121
+ const depsOf = (at) => {
122
+ const deps = {};
123
+ for (const edge of at.edges) {
124
+ const uid = uidOfKey.get(edge.to);
125
+ const target = codeByKey.get(edge.to);
126
+ if (uid && target)
127
+ deps[uid] = target.contentHash;
128
+ }
129
+ return Object.keys(deps).length > 0 ? deps : undefined;
130
+ };
131
+ for (const { unit, at } of pending) {
132
+ const previous = unit.versions.at(-1);
133
+ const was = baseCode(unit.location.file, unit.name, unit.kind);
134
+ const version = {
135
+ contentHash: at.contentHash,
136
+ interfaceHash: at.interfaceHash,
137
+ parent: previous.contentHash,
138
+ change: classify(previous, at, was?.contentHash === previous.contentHash ? was.runtimeHash : undefined),
139
+ rationale: words,
140
+ };
141
+ const links = linksFor(at.span.file, unit.location.file);
142
+ if (links.length > 0)
143
+ version.links = links;
144
+ const deps = depsOf(at);
145
+ if (deps)
146
+ version.deps = deps;
147
+ plan.versions.push({ uid: unit.uid, key: at.key, version });
148
+ }
149
+ for (const { unit, at, splitFrom } of createdFrom) {
150
+ const first = unit.versions[0];
151
+ // A declared split says where the part came from; that is its reason to exist.
152
+ first.rationale = splitFrom ? `Split out of ${splitFrom.name} (${splitFrom.uid}).` : words;
153
+ const links = linksFor(at.span.file);
154
+ if (links.length > 0)
155
+ first.links = links;
156
+ const deps = depsOf(at);
157
+ if (deps)
158
+ first.deps = deps;
159
+ }
160
+ for (const { uid, mergedInto } of result.removed) {
161
+ const unit = unitByUid.get(uid);
162
+ const survivor = mergedInto ? unitByUid.get(mergedInto) : undefined;
163
+ const reason = survivor ? `Merged into ${survivor.name} (${survivor.uid}).` : words;
164
+ const version = { contentHash: REMOVED_CONTENT_HASH, provisional: true, parent: unit.versions.at(-1).contentHash, change: "removed", rationale: reason };
165
+ const links = linksFor(unit.location.file);
166
+ if (links.length > 0)
167
+ version.links = links;
168
+ plan.removed.push({ uid, key: `${unit.location.file}#${unit.name}`, version, ...(mergedInto ? { mergedInto } : {}) });
169
+ }
170
+ // 4. Test links, for every live unit (moved or not, in scope or not): a renamed test file would leave them dangling.
171
+ const renamed = new Map((since?.changes ?? []).filter((change) => change.status === "R").map((change) => [change.from, change.path]));
172
+ const movedTo = new Map(plan.moves.map((move) => [move.uid, move.key]));
173
+ for (const unit of live) {
174
+ const files = [...new Set((unit.tests ?? []).map((test) => test.file))].filter((file) => renamed.has(file));
175
+ if (files.length === 0)
176
+ continue;
177
+ const key = movedTo.get(unit.uid) ?? `${unit.location.file}#${unit.name}`;
178
+ plan.relinks.push({ uid: unit.uid, key, tests: files.map((from) => ({ from, to: renamed.get(from) })) });
179
+ }
180
+ const byKey = (a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0);
181
+ plan.moves.sort(byKey);
182
+ plan.versions.sort(byKey);
183
+ plan.removed.sort(byKey);
184
+ plan.relinks.sort(byKey);
185
+ plan.reclassified.sort(byKey);
186
+ plan.created.sort((a, b) => byKey({ key: `${a.location.file}#${a.name}` }, { key: `${b.location.file}#${b.name}` }));
187
+ return plan;
188
+ }
189
+ /** Writes the plan as `actor`. Queued units are left as they are. Returns how many unit files changed. */
190
+ export async function applyIndex(root, plan, actor, layout = "flat") {
191
+ if (plan.rationale === undefined && needsRationale(plan))
192
+ throw new Error("No rationale: pass --rationale, or commit with a message first");
193
+ const ctx = { paths: storePaths(root), actor };
194
+ for (const move of plan.moves)
195
+ await relocateUnit(ctx, move.uid, move.to, move.lineage);
196
+ for (const { uid, version } of [...plan.versions, ...plan.removed])
197
+ await appendVersion(ctx, uid, { ...version, actor });
198
+ for (const unit of plan.created)
199
+ await createUnit(ctx, unit, layout);
200
+ for (const { uid, tests } of plan.relinks)
201
+ await relinkTests(ctx, uid, new Map(tests.map(({ from, to }) => [from, to])));
202
+ for (const { uid, to } of plan.reclassified)
203
+ await reclassifyUnit(ctx, uid, to);
204
+ return new Set([...plan.moves, ...plan.versions, ...plan.removed, ...plan.relinks, ...plan.reclassified].map((entry) => entry.uid)).size + plan.created.length;
205
+ }
206
+ /** The plan for people: one line per unit, then a summary. `written` is set after a write. */
207
+ export function formatIndexPlan(plan, written) {
208
+ const lines = [];
209
+ for (const move of plan.moves) {
210
+ lines.push(`> ${move.from} -> ${move.key} (${move.via}${move.score !== undefined ? ` ${move.score}` : ""}): ${move.lineage.map((l) => l.kind).join(", ")}`);
211
+ }
212
+ for (const { key, version } of plan.versions)
213
+ lines.push(`~ ${key} ${version.change}`);
214
+ for (const unit of plan.created)
215
+ lines.push(`+ ${unit.location.file}#${unit.name} (${unit.kind}, new uid ${unit.uid})`);
216
+ for (const { key } of plan.removed)
217
+ lines.push(`- ${key} removed`);
218
+ for (const { key, tests } of plan.relinks)
219
+ lines.push(`= ${key} tests: ${tests.map(({ from, to }) => `${from} -> ${to}`).join(", ")}`);
220
+ for (const { key, from, to } of plan.reclassified)
221
+ lines.push(`* ${key} ${from.kind} (${from.framework}) -> ${to.kind} (${to.framework})`);
222
+ for (const q of plan.queued)
223
+ lines.push(`? ${q.reason}: ${q.uids.join(", ")} -> ${q.keys.join(", ")}; declare which is which with lineage (poetics-refactor)`);
224
+ for (const r of plan.rejected)
225
+ lines.push(`! declared ${r.declaration.kind} of ${r.declaration.uids.join(", ")} rejected: ${r.reason}`);
226
+ if (plan.rationale === undefined && needsRationale(plan))
227
+ lines.push("No rationale yet: pass --rationale, or commit with a message first.");
228
+ const counts = `${plan.moves.length} moved, ${plan.versions.length} changed, ${plan.created.length} new, ${plan.removed.length} removed, ${plan.relinks.length} relinked, ${plan.reclassified.length} reclassified, ${plan.queued.length} queued, ${plan.fresh} up to date`;
229
+ lines.push(written === undefined ? `Would record: ${counts}. Run with --write to record it.` : `Recorded ${written} unit file(s): ${counts}.`);
230
+ return lines.join("\n");
231
+ }
232
+ /** Whether applying the plan would write anything. */
233
+ export function hasWrites(plan) {
234
+ return needsRationale(plan) || plan.reclassified.length > 0;
235
+ }
236
+ /**
237
+ * Whether the plan writes a version with no rationale of its own. Moves, test
238
+ * links and reclassifications carry none; a declared split or merge brings its
239
+ * own.
240
+ */
241
+ export function needsRationale(plan) {
242
+ return [...plan.versions.map((v) => v.version), ...plan.removed.map((v) => v.version), ...plan.created.map((u) => u.versions[0])].some((v) => v.rationale === "");
243
+ }
244
+ /**
245
+ * Records one declared rename, move, split or merge, checked the way
246
+ * `poetics index` matches: the declaration is refused, with the reason, when
247
+ * the code disagrees. Only identity is written (places, lineage, split parts,
248
+ * merged removals); code changes are left for `poetics index` to record.
249
+ */
250
+ export async function declareLineage(root, config, declaration, actor, layout = "flat") {
251
+ const plan = await planIndex(root, config, { declarations: [declaration], rationale: "" });
252
+ const rejected = plan.rejected[0];
253
+ if (rejected)
254
+ throw new Error(`Declaration rejected: ${rejected.reason}`);
255
+ const uids = new Set(declaration.uids);
256
+ const own = {
257
+ ...plan,
258
+ fresh: 0,
259
+ moves: plan.moves.filter((move) => uids.has(move.uid)),
260
+ versions: [],
261
+ created: plan.created.filter((unit) => unit.lineage?.some((entry) => entry.kind === "split" && entry.uids?.some((uid) => uids.has(uid)))),
262
+ removed: plan.removed.filter((entry) => entry.mergedInto !== undefined && uids.has(entry.uid)),
263
+ relinks: [],
264
+ reclassified: plan.reclassified.filter((entry) => uids.has(entry.uid)),
265
+ queued: [],
266
+ };
267
+ await applyIndex(root, own, actor, layout);
268
+ return { moved: own.moves, created: own.created, removed: own.removed };
269
+ }
270
+ /**
271
+ * The change class from hashes alone: a new interface hash is `interface`; the
272
+ * same runtime tree (types and docs aside) is `cosmetic`; anything else, or a
273
+ * previous version whose runtime tree is unknown, is `behaviour`.
274
+ */
275
+ function classify(previous, at, previousRuntime) {
276
+ if (previous.interfaceHash !== undefined && previous.interfaceHash !== at.interfaceHash)
277
+ return "interface";
278
+ if (previousRuntime !== undefined && previousRuntime === at.runtimeHash)
279
+ return "cosmetic";
280
+ return "behaviour";
281
+ }
282
+ function newUnit(root, uid, at) {
283
+ const unit = {
284
+ uid,
285
+ kind: at.kind,
286
+ framework: at.framework,
287
+ name: at.name,
288
+ location: at.exportedAs !== undefined ? { file: at.span.file, export: at.exportedAs } : { file: at.span.file },
289
+ versions: [{ contentHash: at.contentHash, interfaceHash: at.interfaceHash, parent: null, change: "created", actor: { kind: "human" }, rationale: "" }],
290
+ };
291
+ if (at.docs !== undefined)
292
+ unit.docs = at.docs;
293
+ // A sibling test file that names the unit is a static link, the convention AGENTS.md asks for.
294
+ const test = at.span.file.replace(/\.(tsx?|mts|cts)$/, ".test.$1");
295
+ if (test !== at.span.file && existsSync(join(root, test)) && readFileSync(join(root, test), "utf8").includes(at.name)) {
296
+ unit.tests = [{ file: test, via: "static" }];
297
+ }
298
+ return unit;
299
+ }
300
+ /** `since` resolved to a commit with the files changed from it, or null when it is `HEAD` and nothing is committed yet. */
301
+ function changesFromBase(root, since) {
302
+ if (since === "HEAD") {
303
+ try {
304
+ git(root, ["rev-parse", "--verify", "--quiet", "HEAD"]);
305
+ }
306
+ catch {
307
+ return null;
308
+ }
309
+ }
310
+ return changesSince(root, since);
311
+ }
312
+ /** The units of a file as it was at `base`, read syntactically: enough for content hashes and fingerprints. */
313
+ function baseSnapshot(root, base, plugins) {
314
+ const files = new Map();
315
+ return (file, name, kind) => {
316
+ if (!files.has(file)) {
317
+ const found = new Map();
318
+ const text = base === null ? undefined : showAt(root, base, file);
319
+ if (text !== undefined) {
320
+ for (const unit of detectUnits(ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true), file, plugins)) {
321
+ const tree = contentTree(unit);
322
+ found.set(place(file, unit.name, unit.kind), {
323
+ key: unit.key,
324
+ file,
325
+ name: unit.name,
326
+ kind: unit.kind,
327
+ contentHash: contentHash(tree),
328
+ runtimeHash: contentHash(contentTree(unit, true)),
329
+ fingerprint: fingerprint(tree),
330
+ });
331
+ }
332
+ }
333
+ files.set(file, found);
334
+ }
335
+ return files.get(file).get(place(file, name, kind));
336
+ };
337
+ }
338
+ function codeUnit(unit) {
339
+ return { key: unit.key, file: unit.span.file, name: unit.name, kind: unit.kind, contentHash: unit.contentHash, fingerprint: unit.fingerprint };
340
+ }
341
+ /** The messages of the commits from `base` to HEAD, oldest first, as the default rationale. */
342
+ function commitMessages(root, base) {
343
+ return git(root, ["log", "--reverse", "--format=%B", `${base}..HEAD`])
344
+ .split("\n")
345
+ .filter((line) => !/^Co-Authored-By:/i.test(line))
346
+ .join("\n")
347
+ .trim();
348
+ }
349
+ /** `#123` and `owner/repo#123` references in text, as issue links, so a version cites its source. */
350
+ function issueLinks(text) {
351
+ const refs = [...new Set([...text.matchAll(/(?:^|[\s(])((?:[\w.-]+\/[\w.-]+)?#\d+)\b/g)].map((m) => m[1]))];
352
+ return refs.map((ref) => ({ kind: "github-issue", ref }));
353
+ }
354
+ /** Each commit from `base` to HEAD: the files it touched and the issues its message references. */
355
+ function commitReferences(root, base) {
356
+ return git(root, ["log", "--name-only", "--format=%x1e%B%x1f", `${base}..HEAD`])
357
+ .split("\x1e")
358
+ .filter((record) => record.trim() !== "")
359
+ .map((record) => {
360
+ const [message = "", files = ""] = record.split("\x1f");
361
+ return { files: new Set(files.split("\n").filter(Boolean)), links: issueLinks(message) };
362
+ })
363
+ .filter((commit) => commit.links.length > 0);
364
+ }
365
+ function linkKey(link) {
366
+ return typeof link === "string" ? link : `${link.kind}:${link.ref}`;
367
+ }
368
+ // Types and values live in separate namespaces.
369
+ function place(file, name, kind) {
370
+ return `${file}#${name}#${kind === "type" ? "type" : "value"}`;
371
+ }
372
+ //# sourceMappingURL=indexing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexing.js","sourceRoot":"","sources":["../src/indexing.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,yEAAyE;AACzE,+EAA+E;AAC/E,gFAAgF;AAChF,8EAA8E;AAC9E,mCAAmC;AACnC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE7G,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAEvG,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEzK,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAgErD,MAAM,KAAK,GAAG,iBAAiB,CAAC;AAEhC,8EAA8E;AAC9E,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,IAAY,EAAE,MAAqB,EAAE,UAAwB,EAAE;IAC7F,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,IAAI,MAAM,CAAC,CAAC;IAC7D,MAAM,IAAI,GAAG,KAAK,EAAE,IAAI,IAAI,IAAI,CAAC;IACjC,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,IAA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C;SACD,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,SAAS,OAAO,CAAC,IAAU;IACzB,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;AACtE,CAAC;AAED,gDAAgD;AAChD,SAAS,KAAK,CAAC,IAAY,EAAE,IAAY,EAAE,IAAkB;IAC3D,OAAO,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC;AACjE,CAAC"}
package/dist/init.d.ts ADDED
@@ -0,0 +1,35 @@
1
+ import type { CoverageThresholds, PoeticsConfig } from "@poetics/store";
2
+ import type { BackfillPlan } from "./backfill.ts";
3
+ export type Adapter = "typescript" | "react" | "svelte";
4
+ /** The config `poetics init` writes, in the shape of `schemas/config.schema.json`. */
5
+ export interface InitConfig extends PoeticsConfig {
6
+ version: 1;
7
+ adapters: Adapter[];
8
+ policy: {
9
+ requireRationale: boolean;
10
+ agentRationaleNeedsReview: boolean;
11
+ allowProvisionalHashes: boolean;
12
+ coverage?: CoverageThresholds;
13
+ };
14
+ }
15
+ export interface InitPlan {
16
+ /** Set when the repository already has a config: init then changes nothing. */
17
+ existing?: string;
18
+ config: InitConfig;
19
+ /** What decided the adapters, for people to check. */
20
+ detected: {
21
+ react: string[];
22
+ svelte: string[];
23
+ };
24
+ /** Whether `.gitignore` needs `.poetics/cache/` added. */
25
+ ignoreCache: boolean;
26
+ /** The snapshot backfill the new config leads to. */
27
+ backfill?: BackfillPlan;
28
+ }
29
+ /** What `poetics init` would write. Nothing is written until `applyInit`. */
30
+ export declare function planInit(root: string): Promise<InitPlan>;
31
+ /** Writes the config, ignores the cache and runs the snapshot backfill. Refuses a repository that has a config. */
32
+ export declare function applyInit(root: string, plan: InitPlan): Promise<number>;
33
+ /** The plan for people: what was detected, the config, and the backfill summary. */
34
+ export declare function formatInitPlan(plan: InitPlan, written?: number): string;
35
+ //# sourceMappingURL=init.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAElD,MAAM,MAAM,OAAO,GAAG,YAAY,GAAG,OAAO,GAAG,QAAQ,CAAC;AAExD,sFAAsF;AACtF,MAAM,WAAW,UAAW,SAAQ,aAAa;IAC/C,OAAO,EAAE,CAAC,CAAC;IACX,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,MAAM,EAAE;QAAE,gBAAgB,EAAE,OAAO,CAAC;QAAC,yBAAyB,EAAE,OAAO,CAAC;QAAC,sBAAsB,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,EAAE,kBAAkB,CAAA;KAAE,CAAC;CAC3I;AAED,MAAM,WAAW,QAAQ;IACvB,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,UAAU,CAAC;IACnB,sDAAsD;IACtD,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IAChD,0DAA0D;IAC1D,WAAW,EAAE,OAAO,CAAC;IACrB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,YAAY,CAAC;CACzB;AAKD,6EAA6E;AAC7E,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CA4C9D;AAED,mHAAmH;AACnH,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAW7E;AAED,oFAAoF;AACpF,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAiBvE"}
package/dist/init.js ADDED
@@ -0,0 +1,186 @@
1
+ // poetics init: adopt Poetics in a repository. Detect what it is written in,
2
+ // write a config whose scope covers its source, and capture the current state
3
+ // with a snapshot backfill (ADR 0011).
4
+ import { existsSync, readdirSync, readFileSync } from "node:fs";
5
+ import { appendFile, mkdir, writeFile } from "node:fs/promises";
6
+ import { join } from "node:path";
7
+ import ts from "typescript";
8
+ import { filesInScope, storePaths } from "@poetics/store";
9
+ import { applyBackfill, planBackfill } from "./backfill.js";
10
+ const EXCLUDE = ["**/*.test.*", "**/*.spec.*", "**/__tests__/**", "**/*.d.ts", "**/dist/**", "**/build/**", "**/node_modules/**"];
11
+ const CACHE_LINE = ".poetics/cache/";
12
+ /** What `poetics init` would write. Nothing is written until `applyInit`. */
13
+ export async function planInit(root) {
14
+ const paths = storePaths(root);
15
+ const packages = packageDirs(root);
16
+ const detected = { react: [], svelte: [] };
17
+ for (const dir of packages) {
18
+ const deps = dependenciesOf(root, dir);
19
+ const where = dir === "." ? "package.json" : `${dir}/package.json`;
20
+ if (deps.has("react") || deps.has("next") || deps.has("react-dom"))
21
+ detected.react.push(where);
22
+ if (deps.has("svelte") || deps.has("@sveltejs/kit"))
23
+ detected.svelte.push(where);
24
+ }
25
+ const roots = sourceRoots(root, packages);
26
+ const probe = await filesInScope(root, { include: roots.map((r) => `${r}**/*.{tsx,svelte}`), exclude: EXCLUDE });
27
+ const files = [...probe.parseable, ...probe.unsupported];
28
+ if (detected.react.length === 0 && files.some((f) => f.endsWith(".tsx")))
29
+ detected.react.push("*.tsx files");
30
+ if (detected.svelte.length === 0 && files.some((f) => f.endsWith(".svelte")))
31
+ detected.svelte.push("*.svelte files");
32
+ const adapters = ["typescript"];
33
+ const extensions = ["ts"];
34
+ if (detected.react.length > 0) {
35
+ adapters.push("react");
36
+ extensions.push("tsx");
37
+ }
38
+ if (detected.svelte.length > 0) {
39
+ adapters.push("svelte");
40
+ extensions.push("svelte");
41
+ }
42
+ const glob = extensions.length === 1 ? "ts" : `{${extensions.join(",")}}`;
43
+ const config = {
44
+ version: 1,
45
+ adapters,
46
+ include: roots.map((r) => `${r}**/*.${glob}`),
47
+ exclude: EXCLUDE,
48
+ policy: { requireRationale: true, agentRationaleNeedsReview: true, allowProvisionalHashes: false },
49
+ };
50
+ const tsconfig = tsconfigOf(root);
51
+ if (tsconfig)
52
+ config.typescript = { tsconfig };
53
+ const plan = { config, detected, ignoreCache: !ignoresCache(root) };
54
+ if (existsSync(paths.config)) {
55
+ plan.existing = ".poetics/config.json";
56
+ return plan;
57
+ }
58
+ plan.backfill = await planBackfill(root, config);
59
+ return plan;
60
+ }
61
+ /** Writes the config, ignores the cache and runs the snapshot backfill. Refuses a repository that has a config. */
62
+ export async function applyInit(root, plan) {
63
+ if (plan.existing)
64
+ throw new Error(`${plan.existing} already exists; run poetics index or poetics backfill --snapshot instead`);
65
+ const paths = storePaths(root);
66
+ await mkdir(paths.units, { recursive: true });
67
+ await writeFile(paths.config, `${JSON.stringify({ $schema: "https://raw.githubusercontent.com/Pixerate/poetics/main/schemas/config.schema.json", ...plan.config }, null, 2)}\n`);
68
+ if (plan.ignoreCache) {
69
+ const gitignore = join(root, ".gitignore");
70
+ const before = existsSync(gitignore) ? readFileSync(gitignore, "utf8") : "";
71
+ await appendFile(gitignore, `${before === "" || before.endsWith("\n") ? "" : "\n"}${CACHE_LINE}\n`);
72
+ }
73
+ return plan.backfill ? applyBackfill(root, plan.backfill) : 0;
74
+ }
75
+ /** The plan for people: what was detected, the config, and the backfill summary. */
76
+ export function formatInitPlan(plan, written) {
77
+ if (plan.existing)
78
+ return `${plan.existing} already exists, so init changes nothing. Run poetics index to record changes, or poetics backfill --snapshot for exports with no unit.`;
79
+ const lines = [
80
+ `Adapters: ${plan.config.adapters.join(", ")}${plan.detected.react.length ? ` (React from ${plan.detected.react.join(", ")})` : ""}${plan.detected.svelte.length ? ` (Svelte from ${plan.detected.svelte.join(", ")})` : ""}`,
81
+ `Include: ${plan.config.include.join(", ")}`,
82
+ ...(plan.config.typescript?.tsconfig ? [`Compiler options from ${plan.config.typescript.tsconfig}`] : []),
83
+ ...(plan.ignoreCache ? [`Adds ${CACHE_LINE} to .gitignore`] : []),
84
+ ];
85
+ const created = plan.backfill?.created.length ?? 0;
86
+ const { high = 0, medium = 0, low = 0 } = plan.backfill?.byConfidence ?? {};
87
+ const backfill = `${created} unit(s) from a snapshot backfill (${high} high, ${medium} medium, ${low} low confidence)`;
88
+ lines.push(written === undefined
89
+ ? `Would write .poetics/config.json and ${backfill}. Run with --write to write them; review them with the poetics-backfill skill.`
90
+ : `Wrote .poetics/config.json and ${backfill}.`);
91
+ return lines.join("\n");
92
+ }
93
+ /** The repository root, or each workspace package when it has workspaces. */
94
+ function packageDirs(root) {
95
+ const patterns = workspacePatterns(root);
96
+ if (patterns.length === 0)
97
+ return ["."];
98
+ const dirs = new Set(["."]);
99
+ for (const pattern of patterns)
100
+ for (const dir of expand(root, pattern))
101
+ dirs.add(dir);
102
+ return [...dirs];
103
+ }
104
+ /** Where each package keeps its source: its `src/` when it has one, else the package itself. */
105
+ function sourceRoots(root, packages) {
106
+ const patterns = workspacePatterns(root);
107
+ if (patterns.length > 0) {
108
+ return patterns.map((pattern) => {
109
+ const dirs = expand(root, pattern);
110
+ return dirs.length > 0 && dirs.every((dir) => existsSync(join(root, dir, "src"))) ? `${pattern}/src/` : `${pattern}/`;
111
+ });
112
+ }
113
+ return packages.includes(".") && existsSync(join(root, "src")) ? ["src/"] : [""];
114
+ }
115
+ /** Workspace globs from pnpm-workspace.yaml or package.json `workspaces`. Only literal paths and trailing `/*` are expanded. */
116
+ function workspacePatterns(root) {
117
+ const pnpm = join(root, "pnpm-workspace.yaml");
118
+ if (existsSync(pnpm)) {
119
+ const lines = readFileSync(pnpm, "utf8").split("\n");
120
+ const start = lines.findIndex((line) => /^packages:\s*$/.test(line));
121
+ const out = [];
122
+ for (const line of start === -1 ? [] : lines.slice(start + 1)) {
123
+ const item = /^\s+-\s+["']?([^"'#\s]+)["']?/.exec(line);
124
+ if (!item) {
125
+ if (/^\S/.test(line))
126
+ break;
127
+ continue;
128
+ }
129
+ if (!item[1].startsWith("!"))
130
+ out.push(item[1].replace(/\/$/, ""));
131
+ }
132
+ return out;
133
+ }
134
+ const pkg = readJson(join(root, "package.json"));
135
+ const workspaces = Array.isArray(pkg?.workspaces) ? pkg.workspaces : (pkg?.workspaces?.packages ?? []);
136
+ return workspaces.filter((w) => !w.startsWith("!")).map((w) => w.replace(/\/$/, ""));
137
+ }
138
+ function expand(root, pattern) {
139
+ if (!pattern.includes("*"))
140
+ return existsSync(join(root, pattern, "package.json")) ? [pattern] : [];
141
+ if (!pattern.endsWith("/*") || pattern.slice(0, -2).includes("*"))
142
+ return [];
143
+ const parent = pattern.slice(0, -2);
144
+ if (!existsSync(join(root, parent)))
145
+ return [];
146
+ return readdirSync(join(root, parent), { withFileTypes: true })
147
+ .filter((entry) => entry.isDirectory() && existsSync(join(root, parent, entry.name, "package.json")))
148
+ .map((entry) => `${parent}/${entry.name}`)
149
+ .sort();
150
+ }
151
+ function dependenciesOf(root, dir) {
152
+ const pkg = readJson(join(root, dir, "package.json"));
153
+ return new Set(["dependencies", "devDependencies", "peerDependencies"].flatMap((field) => Object.keys(pkg?.[field] ?? {})));
154
+ }
155
+ /** A tsconfig whose compiler options apply to the source: one that is only project references would give none. */
156
+ function tsconfigOf(root) {
157
+ for (const name of ["tsconfig.json", "tsconfig.base.json"]) {
158
+ const path = join(root, name);
159
+ if (!existsSync(path))
160
+ continue;
161
+ // TypeScript's own reader: comments, trailing commas, and `/*` inside strings such as `"@/*"`.
162
+ const config = ts.parseConfigFileTextToJson(path, readFileSync(path, "utf8")).config;
163
+ if (config?.compilerOptions && Object.keys(config.compilerOptions).length > 0)
164
+ return name;
165
+ }
166
+ return undefined;
167
+ }
168
+ function ignoresCache(root) {
169
+ const gitignore = join(root, ".gitignore");
170
+ if (!existsSync(gitignore))
171
+ return false;
172
+ return readFileSync(gitignore, "utf8")
173
+ .split("\n")
174
+ .some((line) => [".poetics/cache", ".poetics/cache/", "/.poetics/cache/", ".poetics/"].includes(line.trim()));
175
+ }
176
+ function readJson(path) {
177
+ if (!existsSync(path))
178
+ return undefined;
179
+ try {
180
+ return JSON.parse(readFileSync(path, "utf8"));
181
+ }
182
+ catch {
183
+ return undefined;
184
+ }
185
+ }
186
+ //# sourceMappingURL=init.js.map