tldr-experts 0.3.1 → 0.4.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.
@@ -1,8 +1,9 @@
1
1
  import {
2
2
  emitFactsYaml,
3
3
  withWorkspaceLock,
4
- workspaceRootOfFactsPath
5
- } from "./chunk-9kkm6q0t.js";
4
+ workspaceRootOfFactsPath,
5
+ writeAtomic
6
+ } from "./chunk-c6t5nx0r.js";
6
7
  import {
7
8
  FACT_CONFIDENCES,
8
9
  FACT_KINDS,
@@ -10,9 +11,10 @@ import {
10
11
  MAX_FACT_CHARS,
11
12
  factNumber,
12
13
  formatFactId,
14
+ isLive,
13
15
  isRetired,
14
16
  noteDeprecations
15
- } from "./chunk-3t91gvpp.js";
17
+ } from "./chunk-rpcxsqh3.js";
16
18
  import {
17
19
  asDocument,
18
20
  isRecord,
@@ -25,11 +27,10 @@ import {
25
27
  } from "./chunk-39zh2e44.js";
26
28
  import {
27
29
  parseYaml
28
- } from "./chunk-ztczwtj0.js";
30
+ } from "./chunk-sq44k6g2.js";
29
31
 
30
32
  // src/core/facts/FactsStore.ts
31
- import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
32
- import { dirname } from "node:path";
33
+ import { existsSync, readFileSync } from "node:fs";
33
34
 
34
35
  // src/core/facts/validateFactsFile.ts
35
36
  var ID_RE = /^F\d{3,6}$/;
@@ -153,7 +154,7 @@ function findDuplicate(question, area, facts, threshold = DEFAULT_JACCARD_THRESH
153
154
  for (const fact of facts) {
154
155
  if (fact.area !== area)
155
156
  continue;
156
- if (isRetired(fact))
157
+ if (!isLive(fact))
157
158
  continue;
158
159
  const score = jaccard(asked, tokenize(fact.fact));
159
160
  if (score < threshold)
@@ -199,7 +200,7 @@ class FactsStore {
199
200
  return this.rows;
200
201
  }
201
202
  get active() {
202
- return this.rows.filter((f) => !isRetired(f));
203
+ return this.rows.filter(isLive);
203
204
  }
204
205
  get(id) {
205
206
  return this.rows.find((f) => f.id === id);
@@ -226,6 +227,15 @@ class FactsStore {
226
227
  this.rows.push(fact);
227
228
  return fact;
228
229
  }
230
+ headOf(id) {
231
+ let fact = this.get(id);
232
+ for (let step = 0;fact !== undefined && fact.superseded_by !== null; step++) {
233
+ if (step >= this.rows.length)
234
+ return;
235
+ fact = this.get(fact.superseded_by);
236
+ }
237
+ return fact;
238
+ }
229
239
  supersede(oldId, input) {
230
240
  const index = this.rows.findIndex((f) => f.id === oldId);
231
241
  if (index === -1)
@@ -269,7 +279,7 @@ class FactsStore {
269
279
  throw new Error(`refusing to write an invalid facts.yml: ${first?.path ?? ""} ${first?.message ?? ""}`);
270
280
  }
271
281
  withWorkspaceLock(workspaceRootOfFactsPath(path), () => {
272
- writeFactsAtomic(path, text);
282
+ writeAtomic(path, text);
273
283
  });
274
284
  }
275
285
  static update(path, fn) {
@@ -281,19 +291,5 @@ class FactsStore {
281
291
  });
282
292
  }
283
293
  }
284
- function writeFactsAtomic(path, text) {
285
- const temp = `${path}.tmp-${String(process.pid)}`;
286
- mkdirSync(dirname(path), { recursive: true });
287
- try {
288
- writeFileSync(temp, text, "utf8");
289
- renameSync(temp, path);
290
- } catch (error) {
291
- try {
292
- if (existsSync(temp))
293
- rmSync(temp, { force: true });
294
- } catch {}
295
- throw error;
296
- }
297
- }
298
294
 
299
295
  export { FactsStore };
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  parseHookInput,
3
3
  readStdin
4
- } from "./chunk-s5qsb4k6.js";
4
+ } from "./chunk-b8kxzna2.js";
5
5
 
6
6
  // src/hooks/lib/decide.ts
7
7
  function deny(reason) {
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  wouldBeContent
4
- } from "./chunk-afamdvyn.js";
4
+ } from "./chunk-7y2dq0pj.js";
5
5
  import {
6
6
  claimSourcesDeny,
7
7
  claimSourcesEmptySectionDeny,
@@ -16,18 +16,19 @@ import {
16
16
  postContext,
17
17
  readPayload,
18
18
  runHook
19
- } from "./chunk-3g61yg59.js";
20
- import"./chunk-s5qsb4k6.js";
19
+ } from "./chunk-tzzwddct.js";
20
+ import"./chunk-b8kxzna2.js";
21
21
  import {
22
22
  isHandoff,
23
+ validateCitations,
23
24
  validateHandoff
24
- } from "./chunk-458wgg9j.js";
25
- import"./chunk-sznsenee.js";
25
+ } from "./chunk-9zsqxr6y.js";
26
+ import"./chunk-m3mewgnw.js";
26
27
  import {
27
28
  loadWorkspace,
28
29
  locateWork,
29
30
  toSrcContext
30
- } from "./chunk-ztczwtj0.js";
31
+ } from "./chunk-sq44k6g2.js";
31
32
 
32
33
  // src/hooks/claim-sources.ts
33
34
  await runHook("claim-sources", async () => {
@@ -43,24 +44,31 @@ await runHook("claim-sources", async () => {
43
44
  const wouldBe = wouldBeContent(payload, filePath);
44
45
  if (wouldBe.kind !== "content")
45
46
  return;
46
- const looksLikeHandoff = filePath.endsWith("handoff.md") || isHandoff(wouldBe.text);
47
- if (!looksLikeHandoff)
48
- return;
49
47
  const workspace = loadWorkspace(location.root);
50
- const report = validateHandoff(wouldBe.text, toSrcContext(workspace, location.runDir));
51
- if (report.ok)
52
- return;
48
+ const srcCtx = toSrcContext(workspace, location.runDir);
53
49
  const relPath = `tldrx-work/${location.run}/${location.relative}`;
54
50
  const parts = [];
55
- if (report.unsourced.length > 0)
56
- parts.push(claimSourcesDeny(relPath, report.unsourced));
57
- if (report.malformed.length > 0)
58
- parts.push(claimSourcesMalformedDeny(relPath, report.malformed));
59
- if (report.emptySections.length > 0) {
60
- parts.push(claimSourcesEmptySectionDeny(relPath, [...report.emptySections]));
51
+ const looksLikeHandoff = filePath.endsWith("handoff.md") || isHandoff(wouldBe.text);
52
+ if (looksLikeHandoff) {
53
+ const report = validateHandoff(wouldBe.text, srcCtx);
54
+ if (report.ok)
55
+ return;
56
+ if (report.unsourced.length > 0)
57
+ parts.push(claimSourcesDeny(relPath, report.unsourced));
58
+ if (report.malformed.length > 0)
59
+ parts.push(claimSourcesMalformedDeny(relPath, report.malformed));
60
+ if (report.emptySections.length > 0) {
61
+ parts.push(claimSourcesEmptySectionDeny(relPath, [...report.emptySections]));
62
+ }
63
+ if (report.unresolved.length > 0)
64
+ parts.push(claimSourcesUnresolvedDeny(relPath, report.unresolved));
65
+ } else {
66
+ const report = validateCitations(wouldBe.text, srcCtx);
67
+ if (report.malformed.length > 0)
68
+ parts.push(claimSourcesMalformedDeny(relPath, report.malformed));
69
+ if (report.unresolved.length > 0)
70
+ parts.push(claimSourcesUnresolvedDeny(relPath, report.unresolved));
61
71
  }
62
- if (report.unresolved.length > 0)
63
- parts.push(claimSourcesUnresolvedDeny(relPath, report.unresolved));
64
72
  if (parts.length === 0)
65
73
  return;
66
74
  const message = parts.join(`
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  wouldBeContent
4
- } from "./chunk-afamdvyn.js";
4
+ } from "./chunk-7y2dq0pj.js";
5
5
  import {
6
6
  dodGateDeny,
7
7
  dodGateInternalErrorDeny,
@@ -15,18 +15,18 @@ import {
15
15
  filePathOf,
16
16
  isWriteOrEdit,
17
17
  readPayload
18
- } from "./chunk-3g61yg59.js";
19
- import"./chunk-s5qsb4k6.js";
18
+ } from "./chunk-tzzwddct.js";
19
+ import"./chunk-b8kxzna2.js";
20
20
  import {
21
21
  parseDodBlock
22
- } from "./chunk-0z27twdk.js";
22
+ } from "./chunk-phmdk72a.js";
23
23
  import"./chunk-39zh2e44.js";
24
24
  import {
25
25
  loadWorkspace,
26
26
  locateWork,
27
27
  repoPath,
28
28
  runtime
29
- } from "./chunk-ztczwtj0.js";
29
+ } from "./chunk-sq44k6g2.js";
30
30
 
31
31
  // src/hooks/dod-gate.ts
32
32
  import { basename, join } from "node:path";
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  wouldBeContent
4
- } from "./chunk-afamdvyn.js";
4
+ } from "./chunk-7y2dq0pj.js";
5
5
  import {
6
6
  noReAskDeny
7
7
  } from "./chunk-9gb21660.js";
8
8
  import {
9
9
  FactsStore
10
- } from "./chunk-ytvmc5ns.js";
10
+ } from "./chunk-t1ywrfr4.js";
11
11
  import {
12
12
  allow,
13
13
  deny,
@@ -15,19 +15,19 @@ import {
15
15
  isWriteOrEdit,
16
16
  readPayload,
17
17
  runHook
18
- } from "./chunk-3g61yg59.js";
19
- import"./chunk-s5qsb4k6.js";
20
- import"./chunk-9kkm6q0t.js";
18
+ } from "./chunk-tzzwddct.js";
19
+ import"./chunk-b8kxzna2.js";
20
+ import"./chunk-c6t5nx0r.js";
21
21
  import {
22
22
  openBlocks,
23
23
  parseQuestions
24
- } from "./chunk-3t91gvpp.js";
25
- import"./chunk-sznsenee.js";
24
+ } from "./chunk-rpcxsqh3.js";
25
+ import"./chunk-m3mewgnw.js";
26
26
  import"./chunk-39zh2e44.js";
27
27
  import {
28
28
  factsPath,
29
29
  locateWork
30
- } from "./chunk-ztczwtj0.js";
30
+ } from "./chunk-sq44k6g2.js";
31
31
 
32
32
  // src/hooks/no-reask.ts
33
33
  import { existsSync, readFileSync } from "node:fs";
@@ -1,19 +1,19 @@
1
1
  #!/usr/bin/env node
2
- import"./chunk-ytvmc5ns.js";
2
+ import"./chunk-t1ywrfr4.js";
3
3
  import {
4
4
  allow,
5
5
  readPayload,
6
6
  runHook,
7
7
  sessionContext
8
- } from "./chunk-3g61yg59.js";
9
- import"./chunk-s5qsb4k6.js";
8
+ } from "./chunk-tzzwddct.js";
9
+ import"./chunk-b8kxzna2.js";
10
10
  import {
11
11
  RunStore,
12
12
  isMovable,
13
13
  openQuestions,
14
14
  runSnapshot,
15
15
  whatIsWaiting
16
- } from "./chunk-xpxe94qe.js";
16
+ } from "./chunk-s1c5h7yx.js";
17
17
  import {
18
18
  evidencePath,
19
19
  expertsDir,
@@ -24,16 +24,16 @@ import {
24
24
  pathsIntersect,
25
25
  readExpertDomain,
26
26
  stackExpertNames
27
- } from "./chunk-zdxgragg.js";
28
- import"./chunk-ybacnpxd.js";
29
- import"./chunk-458wgg9j.js";
30
- import"./chunk-0z27twdk.js";
31
- import"./chunk-9kkm6q0t.js";
27
+ } from "./chunk-4cp363kv.js";
28
+ import"./chunk-rz541e2b.js";
29
+ import"./chunk-9zsqxr6y.js";
30
+ import"./chunk-phmdk72a.js";
31
+ import"./chunk-c6t5nx0r.js";
32
32
  import {
33
33
  openBlocks,
34
34
  parseQuestions
35
- } from "./chunk-3t91gvpp.js";
36
- import"./chunk-sznsenee.js";
35
+ } from "./chunk-rpcxsqh3.js";
36
+ import"./chunk-m3mewgnw.js";
37
37
  import {
38
38
  isRecord
39
39
  } from "./chunk-39zh2e44.js";
@@ -45,7 +45,7 @@ import {
45
45
  findWorkspaceRoot,
46
46
  listRunDirs,
47
47
  parseYaml
48
- } from "./chunk-ztczwtj0.js";
48
+ } from "./chunk-sq44k6g2.js";
49
49
 
50
50
  // src/core/status/PendingItem.ts
51
51
  function isPending(item) {
@@ -2,19 +2,19 @@
2
2
  import {
3
3
  bar,
4
4
  runSnapshot
5
- } from "./chunk-xpxe94qe.js";
6
- import"./chunk-zdxgragg.js";
7
- import"./chunk-ybacnpxd.js";
8
- import"./chunk-458wgg9j.js";
9
- import"./chunk-0z27twdk.js";
10
- import"./chunk-9kkm6q0t.js";
11
- import"./chunk-3t91gvpp.js";
12
- import"./chunk-sznsenee.js";
5
+ } from "./chunk-s1c5h7yx.js";
6
+ import"./chunk-4cp363kv.js";
7
+ import"./chunk-rz541e2b.js";
8
+ import"./chunk-9zsqxr6y.js";
9
+ import"./chunk-phmdk72a.js";
10
+ import"./chunk-c6t5nx0r.js";
11
+ import"./chunk-rpcxsqh3.js";
12
+ import"./chunk-m3mewgnw.js";
13
13
  import"./chunk-39zh2e44.js";
14
14
  import {
15
15
  findWorkspaceRoot,
16
16
  runtime
17
- } from "./chunk-ztczwtj0.js";
17
+ } from "./chunk-sq44k6g2.js";
18
18
 
19
19
  // src/core/statusline/renderStatusLine.ts
20
20
  var NO_SESSION_DATA = "[tldrx] no session data";