@olorehq/olore 0.4.0 → 0.4.3

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 (3) hide show
  1. package/dist/cli.js +122 -189
  2. package/package.json +4 -10
  3. package/dist/cli.d.ts +0 -2
package/dist/cli.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  import pc12 from "picocolors";
7
7
 
8
8
  // src/commands/doctor.ts
9
- import pc from "picocolors";
9
+ import pc2 from "picocolors";
10
10
 
11
11
  // src/core/doctor.ts
12
12
  import fs4 from "fs";
@@ -28,7 +28,95 @@ import * as tar from "tar";
28
28
  var REGISTRY_URL = "https://github.com/olorehq/olore/releases/download/registry/registry.json";
29
29
  var REGISTRY_FALLBACK_URL = "https://olore.dev/registry";
30
30
  var DOWNLOAD_TIMEOUT = 6e4;
31
- var USER_AGENT = "olore-cli/0.1.0";
31
+ function getUserAgent(version2) {
32
+ return `olore-cli/${version2}`;
33
+ }
34
+
35
+ // src/core/version-check.ts
36
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
37
+ import { homedir } from "os";
38
+ import { join } from "path";
39
+ import pc from "picocolors";
40
+ var currentVersion = "0.0.0";
41
+ function setVersion(version2) {
42
+ currentVersion = version2;
43
+ }
44
+ var NPM_REGISTRY = "https://registry.npmjs.org/@olorehq/olore";
45
+ var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
46
+ var CACHE_DIR = join(homedir(), ".olore");
47
+ var CACHE_FILE = join(CACHE_DIR, "version-check.json");
48
+ var FETCH_TIMEOUT = 3e3;
49
+ function readCache() {
50
+ try {
51
+ if (existsSync(CACHE_FILE)) {
52
+ return JSON.parse(readFileSync(CACHE_FILE, "utf-8"));
53
+ }
54
+ } catch {
55
+ }
56
+ return null;
57
+ }
58
+ function writeCache(cache) {
59
+ try {
60
+ if (!existsSync(CACHE_DIR)) {
61
+ mkdirSync(CACHE_DIR, { recursive: true });
62
+ }
63
+ writeFileSync(CACHE_FILE, JSON.stringify(cache, null, 2));
64
+ } catch {
65
+ }
66
+ }
67
+ async function fetchLatestVersion() {
68
+ try {
69
+ const controller = new AbortController();
70
+ const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT);
71
+ const response = await fetch(NPM_REGISTRY, {
72
+ signal: controller.signal,
73
+ headers: { Accept: "application/json" }
74
+ });
75
+ clearTimeout(timeoutId);
76
+ if (!response.ok) return null;
77
+ const data = await response.json();
78
+ return data["dist-tags"]?.latest || null;
79
+ } catch {
80
+ return null;
81
+ }
82
+ }
83
+ function compareVersions(current, latest) {
84
+ const parseVersion = (v) => v.replace(/^v/, "").split(".").map((n) => parseInt(n, 10) || 0);
85
+ const curr = parseVersion(current);
86
+ const lat = parseVersion(latest);
87
+ for (let i = 0; i < 3; i++) {
88
+ if ((curr[i] || 0) < (lat[i] || 0)) return -1;
89
+ if ((curr[i] || 0) > (lat[i] || 0)) return 1;
90
+ }
91
+ return 0;
92
+ }
93
+ async function checkForUpdates() {
94
+ const cache = readCache();
95
+ const now = Date.now();
96
+ if (cache && now - cache.lastCheck < CHECK_INTERVAL_MS) {
97
+ if (cache.latestVersion && compareVersions(currentVersion, cache.latestVersion) < 0) {
98
+ printUpdateNotice(cache.latestVersion);
99
+ }
100
+ return;
101
+ }
102
+ const latestVersion = await fetchLatestVersion();
103
+ writeCache({
104
+ lastCheck: now,
105
+ latestVersion
106
+ });
107
+ if (latestVersion && compareVersions(currentVersion, latestVersion) < 0) {
108
+ printUpdateNotice(latestVersion);
109
+ }
110
+ }
111
+ function printUpdateNotice(latestVersion) {
112
+ console.log();
113
+ console.log(
114
+ pc.yellow(`\u26A0\uFE0F Update available: ${currentVersion} \u2192 ${latestVersion}`) + pc.gray(` \u2014 Run `) + pc.cyan(`npm update -g @olorehq/olore`) + pc.gray(` to update`)
115
+ );
116
+ }
117
+ function getVersion() {
118
+ return currentVersion;
119
+ }
32
120
 
33
121
  // src/core/download.ts
34
122
  var DownloadError = class extends Error {
@@ -45,7 +133,7 @@ async function downloadFile(url, dest) {
45
133
  const response = await fetch(url, {
46
134
  signal: controller.signal,
47
135
  headers: {
48
- "User-Agent": USER_AGENT
136
+ "User-Agent": getUserAgent(getVersion())
49
137
  }
50
138
  });
51
139
  if (!response.ok) {
@@ -140,7 +228,6 @@ function formatBytes(bytes) {
140
228
  import fs3 from "fs";
141
229
  import os3 from "os";
142
230
  import path3 from "path";
143
- import { fileURLToPath } from "url";
144
231
 
145
232
  // src/core/platform.ts
146
233
  import os2 from "os";
@@ -190,8 +277,6 @@ function getLinkTypeText() {
190
277
  }
191
278
 
192
279
  // src/core/paths.ts
193
- var __filename2 = fileURLToPath(import.meta.url);
194
- var __dirname2 = path3.dirname(__filename2);
195
280
  function getOloreHome() {
196
281
  return path3.join(os3.homedir(), ".olore");
197
282
  }
@@ -575,7 +660,7 @@ function formatIssue(issue) {
575
660
  // src/commands/doctor.ts
576
661
  async function doctor(options) {
577
662
  if (!options.json) {
578
- console.log(pc.bold("\nChecking installed packages...\n"));
663
+ console.log(pc2.bold("\nChecking installed packages...\n"));
579
664
  }
580
665
  const result = await diagnose();
581
666
  if (options.json) {
@@ -586,38 +671,38 @@ async function doctor(options) {
586
671
  return;
587
672
  }
588
673
  if (result.ok) {
589
- console.log(pc.green("No issues found. Everything looks good."));
674
+ console.log(pc2.green("No issues found. Everything looks good."));
590
675
  return;
591
676
  }
592
677
  const dangling = result.issues.filter((i) => i.type === "dangling-symlink");
593
678
  const orphaned = result.issues.filter((i) => i.type === "orphaned");
594
679
  const partial = result.issues.filter((i) => i.type === "partial-install");
595
680
  console.log(
596
- `Found ${pc.yellow(String(result.issues.length))} issue${result.issues.length === 1 ? "" : "s"}:
681
+ `Found ${pc2.yellow(String(result.issues.length))} issue${result.issues.length === 1 ? "" : "s"}:
597
682
  `
598
683
  );
599
684
  if (dangling.length > 0) {
600
- console.log(pc.bold(`Dangling symlinks (${dangling.length}):`));
685
+ console.log(pc2.bold(`Dangling symlinks (${dangling.length}):`));
601
686
  for (const issue of dangling) {
602
687
  console.log(` ${formatIssue(issue)}`);
603
688
  }
604
689
  console.log("");
605
690
  }
606
691
  if (orphaned.length > 0) {
607
- console.log(pc.bold(`Orphaned packages (${orphaned.length}):`));
692
+ console.log(pc2.bold(`Orphaned packages (${orphaned.length}):`));
608
693
  for (const issue of orphaned) {
609
694
  console.log(` ${formatIssue(issue)}`);
610
695
  }
611
696
  console.log("");
612
697
  }
613
698
  if (partial.length > 0) {
614
- console.log(pc.bold(`Partial installs (${partial.length}):`));
699
+ console.log(pc2.bold(`Partial installs (${partial.length}):`));
615
700
  for (const issue of partial) {
616
701
  console.log(` ${formatIssue(issue)}`);
617
702
  }
618
703
  console.log("");
619
704
  }
620
- console.log(`Run ${pc.cyan("olore prune")} to fix these issues.`);
705
+ console.log(`Run ${pc2.cyan("olore prune")} to fix these issues.`);
621
706
  process.exit(1);
622
707
  }
623
708
 
@@ -625,7 +710,7 @@ async function doctor(options) {
625
710
  import fs5 from "fs";
626
711
  import path5 from "path";
627
712
  import readline from "readline";
628
- import pc2 from "picocolors";
713
+ import pc3 from "picocolors";
629
714
  async function prompt(question, defaultValue) {
630
715
  const rl = readline.createInterface({
631
716
  input: process.stdin,
@@ -653,7 +738,7 @@ async function init(options) {
653
738
  version2 = options.version || "1.0.0";
654
739
  description = `Documentation for ${name}`;
655
740
  } else {
656
- console.log(pc2.bold("\nInitialize olore documentation package\n"));
741
+ console.log(pc3.bold("\nInitialize olore documentation package\n"));
657
742
  name = await prompt("Package name", options.name || folderName);
658
743
  version2 = await prompt("Version", options.version || "1.0.0");
659
744
  description = await prompt("Description", `Documentation for ${name}`);
@@ -692,24 +777,24 @@ Describe what this documentation covers.
692
777
  `
693
778
  );
694
779
  }
695
- console.log(pc2.bold(`
696
- Initialized olore package: `) + pc2.cyan(fullName));
780
+ console.log(pc3.bold(`
781
+ Initialized olore package: `) + pc3.cyan(fullName));
697
782
  console.log("");
698
- console.log(pc2.gray("Created:"));
699
- console.log(pc2.green(" \u2713 olore.config.json"));
700
- console.log(pc2.green(" \u2713 docs/") + pc2.gray(" (add your documentation here)"));
783
+ console.log(pc3.gray("Created:"));
784
+ console.log(pc3.green(" \u2713 olore.config.json"));
785
+ console.log(pc3.green(" \u2713 docs/") + pc3.gray(" (add your documentation here)"));
701
786
  console.log("");
702
- console.log(pc2.gray("Next steps:"));
703
- console.log(" 1. Add your .md files to the " + pc2.cyan("docs/") + " folder");
704
- console.log(" 2. Run " + pc2.cyan("/olore-docs-packager-1.0.0") + " in Claude Code to build");
705
- console.log(" 3. Run " + pc2.cyan("olore install ./olore-package") + " to install");
787
+ console.log(pc3.gray("Next steps:"));
788
+ console.log(" 1. Add your .md files to the " + pc3.cyan("docs/") + " folder");
789
+ console.log(" 2. Run " + pc3.cyan("/olore-docs-packager-1.0.0") + " in Claude Code to build");
790
+ console.log(" 3. Run " + pc3.cyan("olore install ./olore-package") + " to install");
706
791
  console.log("");
707
792
  }
708
793
 
709
794
  // src/commands/inject.ts
710
795
  import fs6 from "fs";
711
796
  import path6 from "path";
712
- import pc3 from "picocolors";
797
+ import pc4 from "picocolors";
713
798
  var MARKER_START = "<!-- olore:start -->";
714
799
  var MARKER_END = "<!-- olore:end -->";
715
800
  var TARGET_FILES = ["AGENTS.md", "CLAUDE.md"];
@@ -823,9 +908,9 @@ async function inject(packages, options) {
823
908
  return;
824
909
  }
825
910
  if (filesRemoved.length === 0) {
826
- console.log(pc3.yellow("No olore sections found in project files."));
911
+ console.log(pc4.yellow("No olore sections found in project files."));
827
912
  } else {
828
- console.log(pc3.green(`Removed olore sections from: ${filesRemoved.join(", ")}`));
913
+ console.log(pc4.green(`Removed olore sections from: ${filesRemoved.join(", ")}`));
829
914
  }
830
915
  return;
831
916
  }
@@ -840,16 +925,16 @@ async function inject(packages, options) {
840
925
  console.log(JSON.stringify(result, null, 2));
841
926
  return;
842
927
  }
843
- console.log(pc3.yellow("No packages specified."));
844
- console.log(pc3.gray("Usage: olore inject <package1> <package2> ..."));
845
- console.log(pc3.gray("Example: olore inject nextjs prisma zod"));
928
+ console.log(pc4.yellow("No packages specified."));
929
+ console.log(pc4.gray("Usage: olore inject <package1> <package2> ..."));
930
+ console.log(pc4.gray("Example: olore inject nextjs prisma zod"));
846
931
  return;
847
932
  }
848
933
  const installed = await getInstalledPackages();
849
934
  const { matched, notFound } = resolvePackages(packages, installed);
850
935
  if (notFound.length > 0) {
851
- console.log(pc3.yellow(`Not installed: ${notFound.join(", ")}`));
852
- console.log(pc3.gray("Run olore install <package> first."));
936
+ console.log(pc4.yellow(`Not installed: ${notFound.join(", ")}`));
937
+ console.log(pc4.gray("Run olore install <package> first."));
853
938
  if (matched.length === 0) return;
854
939
  }
855
940
  if (matched.length === 0) {
@@ -882,11 +967,11 @@ async function inject(packages, options) {
882
967
  return;
883
968
  }
884
969
  console.log(
885
- pc3.green(
970
+ pc4.green(
886
971
  `Injected ${matched.length} package${matched.length === 1 ? "" : "s"} into: ${filesWritten.join(", ")}`
887
972
  )
888
973
  );
889
- console.log(pc3.gray("Run olore inject --remove to clean up."));
974
+ console.log(pc4.gray("Run olore inject --remove to clean up."));
890
975
  }
891
976
 
892
977
  // src/commands/install.ts
@@ -910,7 +995,7 @@ async function fetchWithTimeout(url, timeout = DOWNLOAD_TIMEOUT) {
910
995
  const response = await fetch(url, {
911
996
  signal: controller.signal,
912
997
  headers: {
913
- "User-Agent": USER_AGENT
998
+ "User-Agent": getUserAgent(getVersion())
914
999
  }
915
1000
  });
916
1001
  return response;
@@ -1032,159 +1117,6 @@ async function resolveVersion(name, version2) {
1032
1117
  return versionInfo;
1033
1118
  }
1034
1119
 
1035
- // src/core/version-check.ts
1036
- import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
1037
- import { homedir } from "os";
1038
- import { join } from "path";
1039
- import pc4 from "picocolors";
1040
-
1041
- // package.json
1042
- var package_default = {
1043
- name: "@olorehq/olore",
1044
- version: "0.4.0",
1045
- description: "Version-pinned docs for AI coding agents. Offline. Local-first.",
1046
- keywords: [
1047
- "ai",
1048
- "documentation",
1049
- "claude",
1050
- "codex",
1051
- "opencode",
1052
- "coding-assistant",
1053
- "context",
1054
- "llm",
1055
- "skills",
1056
- "agents-md",
1057
- "claude-md"
1058
- ],
1059
- license: "MIT",
1060
- author: "olorehq",
1061
- repository: {
1062
- type: "git",
1063
- url: "git+https://github.com/olorehq/olore.git",
1064
- directory: "cli"
1065
- },
1066
- homepage: "https://www.olore.dev",
1067
- type: "module",
1068
- files: [
1069
- "dist"
1070
- ],
1071
- bin: {
1072
- olore: "dist/cli.js"
1073
- },
1074
- scripts: {
1075
- build: "tsup",
1076
- "build:bin": "bun build src/cli.ts --compile --outfile dist/olore",
1077
- "build:bin:all": "npm run build:bin:darwin-arm64 && npm run build:bin:darwin-x64 && npm run build:bin:linux-x64 && npm run build:bin:linux-arm64",
1078
- "build:bin:darwin-arm64": "bun build src/cli.ts --compile --target=bun-darwin-arm64 --outfile dist/olore-darwin-arm64",
1079
- "build:bin:darwin-x64": "bun build src/cli.ts --compile --target=bun-darwin-x64 --outfile dist/olore-darwin-x64",
1080
- "build:bin:linux-arm64": "bun build src/cli.ts --compile --target=bun-linux-arm64 --outfile dist/olore-linux-arm64",
1081
- "build:bin:linux-x64": "bun build src/cli.ts --compile --target=bun-linux-x64 --outfile dist/olore-linux-x64",
1082
- dev: "tsup --watch",
1083
- format: "prettier --write src/",
1084
- "format:check": "prettier --check src/",
1085
- lint: "eslint src/",
1086
- test: "vitest",
1087
- typecheck: "tsc --noEmit",
1088
- "generate-registry": "npx tsx scripts/generate-registry.ts"
1089
- },
1090
- dependencies: {
1091
- commander: "^12.1.0",
1092
- "fs-extra": "^11.3.3",
1093
- ora: "^9.0.0",
1094
- picocolors: "^1.1.1",
1095
- tar: "^7.4.3"
1096
- },
1097
- devDependencies: {
1098
- "@ianvs/prettier-plugin-sort-imports": "^4.7.0",
1099
- "@types/fs-extra": "^11.0.4",
1100
- "@types/node": "^22.10.7",
1101
- prettier: "^3.8.0",
1102
- "prettier-plugin-packagejson": "^2.5.22",
1103
- tsup: "^8.3.5",
1104
- typescript: "^5.7.3",
1105
- vitest: "^2.1.8"
1106
- },
1107
- engines: {
1108
- node: ">=18"
1109
- }
1110
- };
1111
-
1112
- // src/core/version-check.ts
1113
- var currentVersion = package_default.version;
1114
- var NPM_REGISTRY = "https://registry.npmjs.org/@olorehq/olore";
1115
- var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
1116
- var CACHE_DIR = join(homedir(), ".olore");
1117
- var CACHE_FILE = join(CACHE_DIR, "version-check.json");
1118
- var FETCH_TIMEOUT = 3e3;
1119
- function readCache() {
1120
- try {
1121
- if (existsSync(CACHE_FILE)) {
1122
- return JSON.parse(readFileSync(CACHE_FILE, "utf-8"));
1123
- }
1124
- } catch {
1125
- }
1126
- return null;
1127
- }
1128
- function writeCache(cache) {
1129
- try {
1130
- if (!existsSync(CACHE_DIR)) {
1131
- mkdirSync(CACHE_DIR, { recursive: true });
1132
- }
1133
- writeFileSync(CACHE_FILE, JSON.stringify(cache, null, 2));
1134
- } catch {
1135
- }
1136
- }
1137
- async function fetchLatestVersion() {
1138
- try {
1139
- const controller = new AbortController();
1140
- const timeoutId = setTimeout(() => controller.abort(), FETCH_TIMEOUT);
1141
- const response = await fetch(NPM_REGISTRY, {
1142
- signal: controller.signal,
1143
- headers: { Accept: "application/json" }
1144
- });
1145
- clearTimeout(timeoutId);
1146
- if (!response.ok) return null;
1147
- const data = await response.json();
1148
- return data["dist-tags"]?.latest || null;
1149
- } catch {
1150
- return null;
1151
- }
1152
- }
1153
- function compareVersions(current, latest) {
1154
- const parseVersion = (v) => v.replace(/^v/, "").split(".").map((n) => parseInt(n, 10) || 0);
1155
- const curr = parseVersion(current);
1156
- const lat = parseVersion(latest);
1157
- for (let i = 0; i < 3; i++) {
1158
- if ((curr[i] || 0) < (lat[i] || 0)) return -1;
1159
- if ((curr[i] || 0) > (lat[i] || 0)) return 1;
1160
- }
1161
- return 0;
1162
- }
1163
- async function checkForUpdates() {
1164
- const cache = readCache();
1165
- const now = Date.now();
1166
- if (cache && now - cache.lastCheck < CHECK_INTERVAL_MS) {
1167
- if (cache.latestVersion && compareVersions(currentVersion, cache.latestVersion) < 0) {
1168
- printUpdateNotice(cache.latestVersion);
1169
- }
1170
- return;
1171
- }
1172
- const latestVersion = await fetchLatestVersion();
1173
- writeCache({
1174
- lastCheck: now,
1175
- latestVersion
1176
- });
1177
- if (latestVersion && compareVersions(currentVersion, latestVersion) < 0) {
1178
- printUpdateNotice(latestVersion);
1179
- }
1180
- }
1181
- function printUpdateNotice(latestVersion) {
1182
- console.log();
1183
- console.log(
1184
- pc4.yellow(`\u26A0\uFE0F Update available: ${currentVersion} \u2192 ${latestVersion}`) + pc4.gray(` \u2014 Run `) + pc4.cyan(`npm update -g @olorehq/olore`) + pc4.gray(` to update`)
1185
- );
1186
- }
1187
-
1188
1120
  // src/commands/install.ts
1189
1121
  async function installFromLocal(localPath) {
1190
1122
  const fullPath = expandPath(localPath);
@@ -1810,6 +1742,7 @@ function truncate(str, maxLen) {
1810
1742
  // src/cli.ts
1811
1743
  var require2 = createRequire(import.meta.url);
1812
1744
  var { version } = require2("../package.json");
1745
+ setVersion(version);
1813
1746
  var program = new Command();
1814
1747
  program.name("olore").description("Version-pinned docs for AI coding agents").version(version).addHelpText("after", `
1815
1748
  ${pc12.gray("May the Skill be with you.")}`);
@@ -1821,7 +1754,7 @@ program.command("init").description("Initialize a documentation package in the c
1821
1754
  process.exit(1);
1822
1755
  }
1823
1756
  });
1824
- program.command("install <package>").alias("i").description("Install a documentation package from the registry").option("-v, --version <version>", "Install specific version").option("--keep", "Keep previous version active (for migrations)").option("--force", "Force installation").action(async (pkg, options) => {
1757
+ program.command("install <package>").alias("i").description("Install a documentation package from the registry").option("-v, --version <version>", "Install specific version").option("--force", "Force installation").action(async (pkg, options) => {
1825
1758
  try {
1826
1759
  await install(pkg, options);
1827
1760
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olorehq/olore",
3
- "version": "0.4.0",
3
+ "version": "0.4.3",
4
4
  "description": "Version-pinned docs for AI coding agents. Offline. Local-first.",
5
5
  "keywords": [
6
6
  "ai",
@@ -25,23 +25,17 @@
25
25
  "homepage": "https://www.olore.dev",
26
26
  "type": "module",
27
27
  "files": [
28
- "dist"
28
+ "dist",
29
+ "package.json"
29
30
  ],
30
31
  "bin": {
31
32
  "olore": "dist/cli.js"
32
33
  },
33
34
  "scripts": {
34
35
  "build": "tsup",
35
- "build:bin": "bun build src/cli.ts --compile --outfile dist/olore",
36
- "build:bin:all": "npm run build:bin:darwin-arm64 && npm run build:bin:darwin-x64 && npm run build:bin:linux-x64 && npm run build:bin:linux-arm64",
37
- "build:bin:darwin-arm64": "bun build src/cli.ts --compile --target=bun-darwin-arm64 --outfile dist/olore-darwin-arm64",
38
- "build:bin:darwin-x64": "bun build src/cli.ts --compile --target=bun-darwin-x64 --outfile dist/olore-darwin-x64",
39
- "build:bin:linux-arm64": "bun build src/cli.ts --compile --target=bun-linux-arm64 --outfile dist/olore-linux-arm64",
40
- "build:bin:linux-x64": "bun build src/cli.ts --compile --target=bun-linux-x64 --outfile dist/olore-linux-x64",
41
36
  "dev": "tsup --watch",
42
37
  "format": "prettier --write src/",
43
38
  "format:check": "prettier --check src/",
44
- "lint": "eslint src/",
45
39
  "test": "vitest",
46
40
  "typecheck": "tsc --noEmit",
47
41
  "generate-registry": "npx tsx scripts/generate-registry.ts"
@@ -64,6 +58,6 @@
64
58
  "vitest": "^2.1.8"
65
59
  },
66
60
  "engines": {
67
- "node": ">=18"
61
+ "node": ">=22"
68
62
  }
69
63
  }
package/dist/cli.d.ts DELETED
@@ -1,2 +0,0 @@
1
-
2
- export { }