@olorehq/olore 0.3.0 → 0.3.1
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.
- package/dist/cli.js +59 -20
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -725,29 +725,48 @@ function formatLibraryName(name) {
|
|
|
725
725
|
if (specialNames[name]) return specialNames[name];
|
|
726
726
|
return name.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
727
727
|
}
|
|
728
|
-
|
|
729
|
-
const
|
|
730
|
-
|
|
731
|
-
|
|
728
|
+
function resolvePackages(requested, installed) {
|
|
729
|
+
const matched = [];
|
|
730
|
+
const notFound = [];
|
|
731
|
+
for (const req of requested) {
|
|
732
|
+
const normalized = req.replace(/^olore-/, "");
|
|
733
|
+
let found = installed.find((pkg) => pkg.name === normalized);
|
|
734
|
+
if (!found && normalized.includes("@")) {
|
|
735
|
+
const [name, version2] = normalized.split("@");
|
|
736
|
+
found = installed.find((pkg) => pkg.name === name && pkg.version === version2);
|
|
737
|
+
}
|
|
738
|
+
if (!found) {
|
|
739
|
+
found = installed.find((pkg) => `${pkg.name}-${pkg.version}` === normalized);
|
|
740
|
+
}
|
|
741
|
+
if (found) {
|
|
742
|
+
if (!matched.includes(found)) {
|
|
743
|
+
matched.push(found);
|
|
744
|
+
}
|
|
745
|
+
} else {
|
|
746
|
+
notFound.push(req);
|
|
747
|
+
}
|
|
732
748
|
}
|
|
749
|
+
return { matched, notFound };
|
|
750
|
+
}
|
|
751
|
+
function buildInjectedContent(packages) {
|
|
733
752
|
const rows = packages.map((pkg) => {
|
|
734
753
|
const library = formatLibraryName(pkg.name);
|
|
735
754
|
const version2 = pkg.version !== "latest" ? ` ${pkg.version}` : "";
|
|
736
|
-
const skillCommand =
|
|
755
|
+
const skillCommand = `olore-${pkg.name}-${pkg.version}`;
|
|
737
756
|
return `| ${library}${version2} | \`${skillCommand}\` |`;
|
|
738
757
|
});
|
|
739
758
|
const lines = [
|
|
740
759
|
MARKER_START,
|
|
741
760
|
"## Documentation Reference",
|
|
742
761
|
"",
|
|
743
|
-
"Use these
|
|
762
|
+
"Use these skills to access up-to-date documentation. Your training data may be outdated.",
|
|
744
763
|
"",
|
|
745
|
-
"| Library | Skill
|
|
746
|
-
"
|
|
764
|
+
"| Library | Skill |",
|
|
765
|
+
"|---------|-------|",
|
|
747
766
|
...rows,
|
|
748
767
|
MARKER_END
|
|
749
768
|
];
|
|
750
|
-
return
|
|
769
|
+
return lines.join("\n");
|
|
751
770
|
}
|
|
752
771
|
function smartMerge(filePath, injectedContent) {
|
|
753
772
|
if (!fs6.existsSync(filePath)) {
|
|
@@ -782,7 +801,7 @@ function removeSection(filePath) {
|
|
|
782
801
|
}
|
|
783
802
|
return true;
|
|
784
803
|
}
|
|
785
|
-
async function inject(options) {
|
|
804
|
+
async function inject(packages, options) {
|
|
786
805
|
const cwd = process.cwd();
|
|
787
806
|
if (options.remove) {
|
|
788
807
|
const filesRemoved = [];
|
|
@@ -809,8 +828,7 @@ async function inject(options) {
|
|
|
809
828
|
}
|
|
810
829
|
return;
|
|
811
830
|
}
|
|
812
|
-
|
|
813
|
-
if (count === 0) {
|
|
831
|
+
if (packages.length === 0) {
|
|
814
832
|
if (options.json) {
|
|
815
833
|
const result = {
|
|
816
834
|
packagesFound: 0,
|
|
@@ -821,10 +839,31 @@ async function inject(options) {
|
|
|
821
839
|
console.log(JSON.stringify(result, null, 2));
|
|
822
840
|
return;
|
|
823
841
|
}
|
|
824
|
-
console.log(pc3.yellow("No
|
|
825
|
-
console.log(pc3.gray("
|
|
842
|
+
console.log(pc3.yellow("No packages specified."));
|
|
843
|
+
console.log(pc3.gray("Usage: olore inject <package1> <package2> ..."));
|
|
844
|
+
console.log(pc3.gray("Example: olore inject nextjs prisma zod"));
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
const installed = await getInstalledPackages();
|
|
848
|
+
const { matched, notFound } = resolvePackages(packages, installed);
|
|
849
|
+
if (notFound.length > 0) {
|
|
850
|
+
console.log(pc3.yellow(`Not installed: ${notFound.join(", ")}`));
|
|
851
|
+
console.log(pc3.gray("Run olore install <package> first."));
|
|
852
|
+
if (matched.length === 0) return;
|
|
853
|
+
}
|
|
854
|
+
if (matched.length === 0) {
|
|
855
|
+
if (options.json) {
|
|
856
|
+
const result = {
|
|
857
|
+
packagesFound: 0,
|
|
858
|
+
packagesInjected: 0,
|
|
859
|
+
filesWritten: [],
|
|
860
|
+
removed: false
|
|
861
|
+
};
|
|
862
|
+
console.log(JSON.stringify(result, null, 2));
|
|
863
|
+
}
|
|
826
864
|
return;
|
|
827
865
|
}
|
|
866
|
+
const content = buildInjectedContent(matched);
|
|
828
867
|
const filesWritten = [];
|
|
829
868
|
for (const fileName of TARGET_FILES) {
|
|
830
869
|
const filePath = path6.join(cwd, fileName);
|
|
@@ -833,8 +872,8 @@ async function inject(options) {
|
|
|
833
872
|
}
|
|
834
873
|
if (options.json) {
|
|
835
874
|
const result = {
|
|
836
|
-
packagesFound:
|
|
837
|
-
packagesInjected:
|
|
875
|
+
packagesFound: installed.length,
|
|
876
|
+
packagesInjected: matched.length,
|
|
838
877
|
filesWritten,
|
|
839
878
|
removed: false
|
|
840
879
|
};
|
|
@@ -843,7 +882,7 @@ async function inject(options) {
|
|
|
843
882
|
}
|
|
844
883
|
console.log(
|
|
845
884
|
pc3.green(
|
|
846
|
-
`Injected ${
|
|
885
|
+
`Injected ${matched.length} package${matched.length === 1 ? "" : "s"} into: ${filesWritten.join(", ")}`
|
|
847
886
|
)
|
|
848
887
|
);
|
|
849
888
|
console.log(pc3.gray("Run olore inject --remove to clean up."));
|
|
@@ -941,7 +980,7 @@ import pc4 from "picocolors";
|
|
|
941
980
|
// package.json
|
|
942
981
|
var package_default = {
|
|
943
982
|
name: "@olorehq/olore",
|
|
944
|
-
version: "0.3.
|
|
983
|
+
version: "0.3.1",
|
|
945
984
|
description: "Universal documentation for any AI coding agent",
|
|
946
985
|
keywords: [
|
|
947
986
|
"ai",
|
|
@@ -1773,9 +1812,9 @@ program.command("prune").description("Remove dangling symlinks, orphaned package
|
|
|
1773
1812
|
process.exit(1);
|
|
1774
1813
|
}
|
|
1775
1814
|
});
|
|
1776
|
-
program.command("inject").description("Inject documentation
|
|
1815
|
+
program.command("inject [packages...]").description("Inject documentation reference into AGENTS.md and CLAUDE.md").option("--remove", "Remove injected content from project files").option("--json", "Output as JSON").action(async (packages, options) => {
|
|
1777
1816
|
try {
|
|
1778
|
-
await inject(options);
|
|
1817
|
+
await inject(packages, options);
|
|
1779
1818
|
} catch (error) {
|
|
1780
1819
|
console.error(pc12.red(`Error: ${error.message}`));
|
|
1781
1820
|
process.exit(1);
|