@opum-ai/lore 0.1.0 → 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 (90) hide show
  1. package/README.md +33 -22
  2. package/bin/lore.cjs +35 -7
  3. package/package.json +17 -17
  4. package/src/adapters/backlog.ts +0 -1084
  5. package/src/adapters/git.ts +0 -221
  6. package/src/cli.ts +0 -667
  7. package/src/commands/agent.ts +0 -301
  8. package/src/commands/agents.ts +0 -302
  9. package/src/commands/args.ts +0 -209
  10. package/src/commands/changed.ts +0 -70
  11. package/src/commands/check.ts +0 -1031
  12. package/src/commands/codex-bridge.ts +0 -49
  13. package/src/commands/concurrency.ts +0 -48
  14. package/src/commands/context.ts +0 -292
  15. package/src/commands/discover.ts +0 -89
  16. package/src/commands/explorer.ts +0 -253
  17. package/src/commands/export.ts +0 -93
  18. package/src/commands/fswrite.ts +0 -928
  19. package/src/commands/graph.ts +0 -291
  20. package/src/commands/help.ts +0 -151
  21. package/src/commands/impact.ts +0 -59
  22. package/src/commands/init.ts +0 -583
  23. package/src/commands/instructions.ts +0 -91
  24. package/src/commands/link.ts +0 -929
  25. package/src/commands/new.ts +0 -476
  26. package/src/commands/orphans.ts +0 -457
  27. package/src/commands/path.ts +0 -67
  28. package/src/commands/provenance.ts +0 -68
  29. package/src/commands/query.ts +0 -312
  30. package/src/commands/reconcile-shared.ts +0 -280
  31. package/src/commands/rename.ts +0 -585
  32. package/src/commands/replace.ts +0 -320
  33. package/src/commands/scaffold.ts +0 -346
  34. package/src/commands/schema.ts +0 -293
  35. package/src/commands/snapshot.ts +0 -130
  36. package/src/commands/supersede.ts +0 -400
  37. package/src/commands/sync.ts +0 -371
  38. package/src/commands/tasks.ts +0 -271
  39. package/src/commands/traversal.ts +0 -151
  40. package/src/commands/validate.ts +0 -226
  41. package/src/config.ts +0 -598
  42. package/src/core/agent-bridge.ts +0 -287
  43. package/src/core/agent-context.ts +0 -498
  44. package/src/core/agent-profile.ts +0 -447
  45. package/src/core/bundle.ts +0 -893
  46. package/src/core/check.ts +0 -853
  47. package/src/core/codex-bridge.ts +0 -100
  48. package/src/core/concept.ts +0 -597
  49. package/src/core/consumer-scaffold.ts +0 -433
  50. package/src/core/context.ts +0 -271
  51. package/src/core/explorer-contract.ts +0 -441
  52. package/src/core/explorer-qualification.ts +0 -58
  53. package/src/core/explorer.ts +0 -518
  54. package/src/core/finding.ts +0 -31
  55. package/src/core/graph.ts +0 -201
  56. package/src/core/indexes.ts +0 -436
  57. package/src/core/instructions.ts +0 -209
  58. package/src/core/ladybug-driver.ts +0 -1795
  59. package/src/core/ladybug-lifecycle.ts +0 -1178
  60. package/src/core/ladybug-native.ts +0 -95
  61. package/src/core/ladybug-source.ts +0 -667
  62. package/src/core/links.ts +0 -681
  63. package/src/core/log.ts +0 -253
  64. package/src/core/managed-block.ts +0 -540
  65. package/src/core/manifest.ts +0 -718
  66. package/src/core/order.ts +0 -13
  67. package/src/core/profile.ts +0 -1007
  68. package/src/core/projection.ts +0 -195
  69. package/src/core/query.ts +0 -542
  70. package/src/core/reconcile.ts +0 -236
  71. package/src/core/replace.ts +0 -419
  72. package/src/core/retrieval.ts +0 -213
  73. package/src/core/rewrite.ts +0 -940
  74. package/src/core/scaffold.ts +0 -255
  75. package/src/core/schema.ts +0 -366
  76. package/src/core/snapshot-runtime.ts +0 -52
  77. package/src/core/snapshot-store.ts +0 -287
  78. package/src/core/snapshot.ts +0 -711
  79. package/src/core/template.ts +0 -429
  80. package/src/core/traversal.ts +0 -487
  81. package/src/core/validate.ts +0 -517
  82. package/src/core/workspace-contract.ts +0 -473
  83. package/src/core/workspace-projection.ts +0 -365
  84. package/src/core/workspace-retrieval.ts +0 -196
  85. package/src/core/workspace-source.ts +0 -174
  86. package/src/errors.ts +0 -697
  87. package/src/meta.ts +0 -7
  88. package/src/output.ts +0 -589
  89. package/src/scripts/upstream-backlog-watch.ts +0 -288
  90. package/src/state.ts +0 -390
@@ -1,195 +0,0 @@
1
- /**
2
- * Consumer-neutral, deterministic OKF projection records.
3
- *
4
- * This module is deliberately pure: callers supply the already-loaded bundle,
5
- * Backlog snapshot, Git commit, and generation time. It contains no Neo4j,
6
- * embedding, or downstream database vocabulary.
7
- */
8
-
9
- import { createHash } from "node:crypto";
10
- import type { BacklogTask } from "../adapters/backlog";
11
- import type { BundleGraph, EdgeKind } from "./bundle";
12
- import { toRefList } from "./bundle";
13
- import { serializeConcept } from "./concept";
14
-
15
- export const PROJECTION_SCHEMA_VERSION = "1.0";
16
- export const PROJECTION_NORMALIZATION_VERSION = "1";
17
- const BOUNDED_MEMORY_GC_RECORD_INTERVAL = 1024;
18
-
19
- export interface ProjectionInput {
20
- readonly graph: BundleGraph;
21
- readonly tasks: readonly BacklogTask[];
22
- readonly docsRoot: string;
23
- readonly okfVersion: string;
24
- readonly exporterVersion: string;
25
- readonly gitCommit: string | null;
26
- readonly generatedAt: string | null;
27
- /** Internal large-snapshot optimization; public export callers keep the default `true`. */
28
- readonly materializeJsonl?: boolean;
29
- }
30
-
31
- export type ProjectionRecord = Record<string, unknown> & { readonly record: string };
32
-
33
- export interface Projection {
34
- readonly records: readonly ProjectionRecord[];
35
- readonly jsonl: string;
36
- }
37
-
38
- /** Build the complete projection in deterministic record order. */
39
- export function buildProjection(input: ProjectionInput): Projection {
40
- const root = input.graph.concepts.get("index");
41
- const identitySeed = JSON.stringify({
42
- docsRoot: input.docsRoot,
43
- title: scalar(root?.frontmatter.title) ?? null,
44
- resource: scalar(root?.frontmatter.resource) ?? null,
45
- });
46
- const bundleId = hash(identitySeed);
47
- const conceptKeys = new Map<string, string>();
48
- for (const concept of input.graph.concepts.values()) {
49
- conceptKeys.set(concept.id, keyFor(bundleId, "concept", concept.id));
50
- }
51
-
52
- const taskKeys = new Map<string, string>();
53
- const tasks = [...input.tasks].sort((a, b) => compare(a.id.toLowerCase(), b.id.toLowerCase()) || compare(a.id, b.id));
54
- for (const task of tasks) {
55
- taskKeys.set(task.id.toLowerCase(), keyFor(bundleId, "task", task.id.toLowerCase()));
56
- }
57
-
58
- const manifest: ProjectionRecord = {
59
- record: "manifest",
60
- schemaVersion: PROJECTION_SCHEMA_VERSION,
61
- bundle: {
62
- id: bundleId,
63
- okfVersion: input.okfVersion,
64
- docsRoot: input.docsRoot,
65
- gitCommit: input.gitCommit,
66
- },
67
- exporter: { name: "lore", version: input.exporterVersion },
68
- generatedAt: input.generatedAt,
69
- normalizationVersion: PROJECTION_NORMALIZATION_VERSION,
70
- };
71
- const records: ProjectionRecord[] = [manifest];
72
-
73
- for (const concept of input.graph.concepts.values()) {
74
- const canonical = serializeConcept(concept);
75
- records.push({
76
- record: "concept",
77
- key: conceptKeys.get(concept.id),
78
- id: concept.id,
79
- path: `${input.docsRoot}/${concept.path}`,
80
- type: concept.type,
81
- frontmatter: concept.frontmatter,
82
- body: concept.body,
83
- contentHash: hash(`${PROJECTION_NORMALIZATION_VERSION}\0${canonical}`),
84
- tokenEstimate: input.graph.tokenEstimate(concept.id),
85
- });
86
- if (input.materializeJsonl === false && records.length % BOUNDED_MEMORY_GC_RECORD_INTERVAL === 0) Bun.gc(true);
87
- }
88
-
89
- const ordinals = new Map<string, number>();
90
- for (const edge of input.graph.edges) {
91
- const ordinalKey = `${edge.from}\0concept`;
92
- const ordinal = ordinals.get(ordinalKey) ?? 0;
93
- ordinals.set(ordinalKey, ordinal + 1);
94
- records.push(conceptEdge(bundleId, conceptKeys, edge.from, edge.to, edge.kind, edge.target, ordinal));
95
- }
96
-
97
- for (const task of tasks) {
98
- records.push({
99
- record: "task",
100
- key: taskKeys.get(task.id.toLowerCase()),
101
- id: task.id,
102
- title: task.title,
103
- status: task.status,
104
- labels: [...task.labels],
105
- priority: task.priority,
106
- ordinal: task.ordinal,
107
- assignees: [...task.assignees],
108
- milestone: task.milestone,
109
- parentTaskId: task.parentTaskId,
110
- sourceAdapterVersion: "backlog-json/1",
111
- });
112
- }
113
-
114
- for (const concept of input.graph.concepts.values()) {
115
- const seen = new Map<string, number>();
116
- for (const taskId of toRefList(concept.frontmatter.tasks)) {
117
- const normalized = taskId.toLowerCase();
118
- const ordinal = seen.get(normalized) ?? 0;
119
- seen.set(normalized, ordinal + 1);
120
- const to = taskKeys.get(normalized) ?? null;
121
- records.push({
122
- record: "edge",
123
- key: keyFor(bundleId, "task-edge", concept.id, normalized, String(ordinal)),
124
- from: conceptKeys.get(concept.id),
125
- to,
126
- kind: "task",
127
- target: taskId,
128
- ordinal,
129
- dangling: to === null,
130
- });
131
- }
132
- }
133
-
134
- records.push({
135
- record: "trailer",
136
- recordCount: records.length,
137
- streamHash: projectionStreamHash(records, input.materializeJsonl === false),
138
- });
139
- return {
140
- records,
141
- jsonl: input.materializeJsonl === false ? "" : `${records.map((record) => JSON.stringify(record)).join("\n")}\n`,
142
- };
143
- }
144
-
145
- /**
146
- * Compute export schema 1.0's semantic stream hash for every record before the
147
- * trailer. The generated timestamp is deliberately normalized away so the same
148
- * source snapshot has one digest regardless of wall-clock time.
149
- */
150
- export function projectionStreamHash(records: readonly ProjectionRecord[], boundedMemory = false): string {
151
- const digest = createHash("sha256");
152
- records.forEach((record, index) => {
153
- if (index > 0) digest.update("\n");
154
- digest.update(JSON.stringify(record.record === "manifest" ? { ...record, generatedAt: null } : record));
155
- if (boundedMemory && index > 0 && index % BOUNDED_MEMORY_GC_RECORD_INTERVAL === 0) Bun.gc(true);
156
- });
157
- return `sha256:${digest.digest("hex")}`;
158
- }
159
-
160
- function conceptEdge(
161
- bundleId: string,
162
- conceptKeys: ReadonlyMap<string, string>,
163
- from: string,
164
- to: string | null,
165
- kind: EdgeKind,
166
- target: string,
167
- ordinal: number,
168
- ): ProjectionRecord {
169
- return {
170
- record: "edge",
171
- key: keyFor(bundleId, "concept-edge", from, kind, target, String(ordinal)),
172
- from: conceptKeys.get(from),
173
- to: to === null ? null : conceptKeys.get(to),
174
- kind,
175
- target,
176
- ordinal,
177
- dangling: to === null,
178
- };
179
- }
180
-
181
- function keyFor(...parts: readonly string[]): string {
182
- return hash(parts.join("\0"));
183
- }
184
-
185
- function hash(value: string): string {
186
- return `sha256:${createHash("sha256").update(value).digest("hex")}`;
187
- }
188
-
189
- function compare(a: string, b: string): number {
190
- return a < b ? -1 : a > b ? 1 : 0;
191
- }
192
-
193
- function scalar(value: unknown): string | undefined {
194
- return typeof value === "string" && value.trim() !== "" ? value.trim() : undefined;
195
- }