@opum-ai/lore 0.1.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 (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +306 -0
  3. package/bin/lore.cjs +109 -0
  4. package/package.json +67 -0
  5. package/src/adapters/backlog.ts +1084 -0
  6. package/src/adapters/git.ts +221 -0
  7. package/src/cli.ts +667 -0
  8. package/src/commands/agent.ts +301 -0
  9. package/src/commands/agents.ts +302 -0
  10. package/src/commands/args.ts +209 -0
  11. package/src/commands/changed.ts +70 -0
  12. package/src/commands/check.ts +1031 -0
  13. package/src/commands/codex-bridge.ts +49 -0
  14. package/src/commands/concurrency.ts +48 -0
  15. package/src/commands/context.ts +292 -0
  16. package/src/commands/discover.ts +89 -0
  17. package/src/commands/explorer.ts +253 -0
  18. package/src/commands/export.ts +93 -0
  19. package/src/commands/fswrite.ts +928 -0
  20. package/src/commands/graph.ts +291 -0
  21. package/src/commands/help.ts +151 -0
  22. package/src/commands/impact.ts +59 -0
  23. package/src/commands/init.ts +583 -0
  24. package/src/commands/instructions.ts +91 -0
  25. package/src/commands/link.ts +929 -0
  26. package/src/commands/new.ts +476 -0
  27. package/src/commands/orphans.ts +457 -0
  28. package/src/commands/path.ts +67 -0
  29. package/src/commands/provenance.ts +68 -0
  30. package/src/commands/query.ts +312 -0
  31. package/src/commands/reconcile-shared.ts +280 -0
  32. package/src/commands/rename.ts +585 -0
  33. package/src/commands/replace.ts +320 -0
  34. package/src/commands/scaffold.ts +346 -0
  35. package/src/commands/schema.ts +293 -0
  36. package/src/commands/snapshot.ts +130 -0
  37. package/src/commands/supersede.ts +400 -0
  38. package/src/commands/sync.ts +371 -0
  39. package/src/commands/tasks.ts +271 -0
  40. package/src/commands/traversal.ts +151 -0
  41. package/src/commands/validate.ts +226 -0
  42. package/src/config.ts +598 -0
  43. package/src/core/agent-bridge.ts +287 -0
  44. package/src/core/agent-context.ts +498 -0
  45. package/src/core/agent-profile.ts +447 -0
  46. package/src/core/bundle.ts +893 -0
  47. package/src/core/check.ts +853 -0
  48. package/src/core/codex-bridge.ts +100 -0
  49. package/src/core/concept.ts +597 -0
  50. package/src/core/consumer-scaffold.ts +433 -0
  51. package/src/core/context.ts +271 -0
  52. package/src/core/explorer-contract.ts +441 -0
  53. package/src/core/explorer-qualification.ts +58 -0
  54. package/src/core/explorer.ts +518 -0
  55. package/src/core/finding.ts +31 -0
  56. package/src/core/graph.ts +201 -0
  57. package/src/core/indexes.ts +436 -0
  58. package/src/core/instructions.ts +209 -0
  59. package/src/core/ladybug-driver.ts +1795 -0
  60. package/src/core/ladybug-lifecycle.ts +1178 -0
  61. package/src/core/ladybug-native.ts +95 -0
  62. package/src/core/ladybug-source.ts +667 -0
  63. package/src/core/links.ts +681 -0
  64. package/src/core/log.ts +253 -0
  65. package/src/core/managed-block.ts +540 -0
  66. package/src/core/manifest.ts +718 -0
  67. package/src/core/order.ts +13 -0
  68. package/src/core/profile.ts +1007 -0
  69. package/src/core/projection.ts +195 -0
  70. package/src/core/query.ts +542 -0
  71. package/src/core/reconcile.ts +236 -0
  72. package/src/core/replace.ts +419 -0
  73. package/src/core/retrieval.ts +213 -0
  74. package/src/core/rewrite.ts +940 -0
  75. package/src/core/scaffold.ts +255 -0
  76. package/src/core/schema.ts +366 -0
  77. package/src/core/snapshot-runtime.ts +52 -0
  78. package/src/core/snapshot-store.ts +287 -0
  79. package/src/core/snapshot.ts +711 -0
  80. package/src/core/template.ts +429 -0
  81. package/src/core/traversal.ts +487 -0
  82. package/src/core/validate.ts +517 -0
  83. package/src/core/workspace-contract.ts +473 -0
  84. package/src/core/workspace-projection.ts +365 -0
  85. package/src/core/workspace-retrieval.ts +196 -0
  86. package/src/core/workspace-source.ts +174 -0
  87. package/src/errors.ts +697 -0
  88. package/src/meta.ts +7 -0
  89. package/src/output.ts +589 -0
  90. package/src/scripts/upstream-backlog-watch.ts +288 -0
  91. package/src/state.ts +390 -0
@@ -0,0 +1,100 @@
1
+ import type { BridgeAction, BridgeFilePlan, BridgePlan } from "./agent-bridge";
2
+ import { upsertManagedBlock } from "./managed-block";
3
+
4
+ export const CODEX_SKILL_REL_PATH = ".codex/skills/lore/SKILL.md";
5
+ export const AGENTS_MD_REL_PATH = "AGENTS.md";
6
+ export const CODEX_AGENT_BLOCK_LABEL = "lore:agents";
7
+
8
+ export function buildCodexSkillDoc(): string {
9
+ return `---
10
+ name: lore
11
+ description: Author and maintain this repository's OKF documentation bundle under docs/ with the Lore CLI. Use whenever Codex reads, writes, links, moves, synchronizes, validates, or checks documentation so Story/Task coupling, managed blocks, and cross-links remain coherent. Run \`lore instructions\` for the canonical agent loop and its topic subcommands for just-in-time details.
12
+ ---
13
+
14
+ # Lore — OKF documentation CLI
15
+
16
+ Use \`lore\` as this repository's deterministic, CLI-first documentation engine. Treat
17
+ \`lore instructions\` as the source of truth; this skill is the Codex discovery bridge.
18
+
19
+ ## Start
20
+
21
+ 1. Run \`lore instructions\`.
22
+ 2. Read \`docs/index.md\`, follow the relevant Story, and inspect its coupled task status.
23
+ 3. Pull only the needed topic instructions: \`linking\`, \`sync\`, \`check\`, or \`validation\`.
24
+ 4. Author prose only outside Lore-managed regions.
25
+ 5. After documentation changes, run \`lore sync\`, \`lore validate --strict\`,
26
+ \`lore check --strict\`, and \`git diff --check\`.
27
+
28
+ ## Guardrails
29
+
30
+ - Use \`lore new\` to create typed concepts.
31
+ - Use \`lore link\` and \`lore unlink\` for Story/Task coupling.
32
+ - Use \`lore rename\`, \`lore replace\`, and \`lore supersede\` instead of manually rewriting
33
+ managed references.
34
+ - Do not hand-edit Lore-managed blocks, generated indexes, or generated logs.
35
+ - Follow the repository's Backlog workflow independently; Lore does not replace Backlog task
36
+ lifecycle commands.
37
+ - Prefer \`--json\` for machine-stable output and \`--plain\` for readable output. Branch on exit
38
+ codes: \`0\` success, \`2\` usage, \`3\` not found, \`4\` denied, \`5\` conflict, \`6\`
39
+ validation/drift.
40
+
41
+ ## Command map
42
+
43
+ - Authoring: \`new\`, \`replace\`, \`rename\`, \`supersede\`
44
+ - Coupling and reconciliation: \`link\`, \`unlink\`, \`sync\`, \`tasks\`, \`orphans\`
45
+ - Verification: \`validate\`, \`check\`
46
+ - Discovery and context: \`query\`, \`context\`, \`agent\`, \`graph\`, \`instructions\`
47
+ - Interchange and setup: \`export\`, \`schema\`, \`scaffold\`, \`agents\`
48
+
49
+ ## Optional task-scoped context
50
+
51
+ When native Codex developer instructions name a committed Lore profile, use this stable opt-in line:
52
+
53
+ > Lore profile: \`<name>\`. Before working, run \`lore agent context <name> --task "<assigned task>"\`
54
+ > and ground decisions in the returned source IDs.
55
+
56
+ Lore supplies evidence only. It does not create or patch native agents, prompts, tools, models,
57
+ permissions, or execution settings.
58
+
59
+ <!-- Generated by \`lore init --codex\`; do not hand-edit. -->
60
+ `;
61
+ }
62
+
63
+ export function buildCodexNudgeBody(): string {
64
+ return `This repo uses **lore** — an OKF-native documentation CLI — for the docs bundle under \`docs/\`.
65
+ When working on documentation, drive it through \`lore\` (not a plain editor) so Story <-> Task
66
+ coupling, managed blocks, and cross-links stay coherent.
67
+
68
+ - **Skill:** \`${CODEX_SKILL_REL_PATH}\` — how to drive lore.
69
+ - **Just-in-time detail:** run \`lore instructions\` for the canonical agent loop, then
70
+ \`lore instructions <topic>\` (\`linking\`, \`sync\`, \`check\`, \`validation\`).`;
71
+ }
72
+
73
+ export interface PlanCodexBridgeInput {
74
+ readonly skillOnDisk: string | null;
75
+ readonly agentsOnDisk: string | null;
76
+ readonly force: boolean;
77
+ readonly check: boolean;
78
+ }
79
+
80
+ export function planCodexBridge(input: PlanCodexBridgeInput): BridgePlan {
81
+ return { files: [planSkill(input), planNudge(input)] };
82
+ }
83
+
84
+ function planSkill(input: PlanCodexBridgeInput): BridgeFilePlan {
85
+ const desired = buildCodexSkillDoc();
86
+ if (input.skillOnDisk === null) return { path: CODEX_SKILL_REL_PATH, action: "created", contents: desired };
87
+ if (input.skillOnDisk === desired) return { path: CODEX_SKILL_REL_PATH, action: "unchanged", contents: null };
88
+ const action: BridgeAction = input.force && !input.check ? "updated" : "protected";
89
+ return { path: CODEX_SKILL_REL_PATH, action, contents: action === "updated" ? desired : null };
90
+ }
91
+
92
+ function planNudge(input: PlanCodexBridgeInput): BridgeFilePlan {
93
+ const desired = upsertManagedBlock(input.agentsOnDisk ?? "", {
94
+ label: CODEX_AGENT_BLOCK_LABEL,
95
+ body: buildCodexNudgeBody(),
96
+ });
97
+ if (input.agentsOnDisk === null) return { path: AGENTS_MD_REL_PATH, action: "created", contents: desired };
98
+ if (input.agentsOnDisk === desired) return { path: AGENTS_MD_REL_PATH, action: "unchanged", contents: null };
99
+ return { path: AGENTS_MD_REL_PATH, action: "updated", contents: desired };
100
+ }