@pebblehouse/odin-cli 0.8.0 → 0.9.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.
- package/dist/index.js +53 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { Command as
|
|
4
|
+
import { Command as Command12 } from "commander";
|
|
5
5
|
|
|
6
6
|
// src/auth/login.ts
|
|
7
7
|
import { createServer } from "http";
|
|
@@ -408,13 +408,19 @@ ${supersededTitles.map((t) => ` \u21B3 "${t}"`).join("\n")}
|
|
|
408
408
|
|
|
409
409
|
// src/commands/context.ts
|
|
410
410
|
import { Command as Command4 } from "commander";
|
|
411
|
-
var contextCmd = new Command4("context").description("Get Tier 1 context for a pebble").argument("<slug>", "Pebble slug").action(async (slug) => {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
411
|
+
var contextCmd = new Command4("context").description("Get Tier 1 context packet for a pebble (brief + rules + guidelines)").argument("<slug>", "Pebble slug").action(async (slug) => {
|
|
412
|
+
const res = await apiRequest(`/pebbles/${slug}/context`);
|
|
413
|
+
if (res.error) {
|
|
414
|
+
console.error(`error: ${res.error}`);
|
|
415
|
+
process.exit(1);
|
|
416
|
+
}
|
|
417
|
+
if (res.data?.context) {
|
|
418
|
+
process.stdout.write(res.data.context + "\n");
|
|
419
|
+
} else {
|
|
420
|
+
console.error(`No context available for "${slug}". Create a brief first:`);
|
|
421
|
+
console.error(` odin briefs update ${slug} --file brief.md`);
|
|
422
|
+
process.exit(0);
|
|
423
|
+
}
|
|
418
424
|
});
|
|
419
425
|
|
|
420
426
|
// src/commands/search.ts
|
|
@@ -717,12 +723,47 @@ rulesCmd.command("deprecate <slug> <id>").description("Deprecate a rule").action
|
|
|
717
723
|
if (res.error) process.exit(1);
|
|
718
724
|
});
|
|
719
725
|
|
|
720
|
-
// src/
|
|
726
|
+
// src/commands/briefs.ts
|
|
727
|
+
import { Command as Command11 } from "commander";
|
|
721
728
|
import { readFileSync as readFileSync8 } from "fs";
|
|
729
|
+
var briefsCmd = new Command11("briefs").description("Manage pebble context briefs");
|
|
730
|
+
briefsCmd.command("get <slug>").description("Get the context brief for a pebble").action(async (slug) => {
|
|
731
|
+
const res = await apiRequest(`/pebbles/${slug}/brief`);
|
|
732
|
+
process.stdout.write(JSON.stringify(res) + "\n");
|
|
733
|
+
if (res.error) process.exit(1);
|
|
734
|
+
});
|
|
735
|
+
briefsCmd.command("update <slug>").description("Create or update the context brief").option("--content <content>", "Brief content").option("--file <path>", "Read content from file").option("--title <title>", "Brief title").option("--source <source>", "Source", "manual").action(async (slug, opts) => {
|
|
736
|
+
const content = opts.file ? readFileSync8(opts.file, "utf-8") : opts.content;
|
|
737
|
+
if (!content) {
|
|
738
|
+
console.error("error: --content or --file is required");
|
|
739
|
+
process.exit(1);
|
|
740
|
+
}
|
|
741
|
+
const body = { content, source: opts.source };
|
|
742
|
+
if (opts.title) body.title = opts.title;
|
|
743
|
+
const res = await apiRequest(`/pebbles/${slug}/brief`, {
|
|
744
|
+
method: "PUT",
|
|
745
|
+
body
|
|
746
|
+
});
|
|
747
|
+
process.stdout.write(JSON.stringify(res) + "\n");
|
|
748
|
+
if (res.error) process.exit(1);
|
|
749
|
+
});
|
|
750
|
+
briefsCmd.command("delete <slug>").description("Delete the context brief for a pebble").action(async (slug) => {
|
|
751
|
+
const res = await apiRequest(`/pebbles/${slug}/brief`, { method: "DELETE" });
|
|
752
|
+
process.stdout.write(JSON.stringify(res) + "\n");
|
|
753
|
+
if (res.error) process.exit(1);
|
|
754
|
+
});
|
|
755
|
+
briefsCmd.command("versions <slug>").description("List version history for a pebble's brief").action(async (slug) => {
|
|
756
|
+
const res = await apiRequest(`/pebbles/${slug}/brief/versions`);
|
|
757
|
+
process.stdout.write(JSON.stringify(res) + "\n");
|
|
758
|
+
if (res.error) process.exit(1);
|
|
759
|
+
});
|
|
760
|
+
|
|
761
|
+
// src/index.ts
|
|
762
|
+
import { readFileSync as readFileSync9 } from "fs";
|
|
722
763
|
import { fileURLToPath } from "url";
|
|
723
764
|
import { dirname as dirname2, resolve } from "path";
|
|
724
765
|
var __dirname = dirname2(fileURLToPath(import.meta.url));
|
|
725
|
-
var pkg = JSON.parse(
|
|
766
|
+
var pkg = JSON.parse(readFileSync9(resolve(__dirname, "../package.json"), "utf-8"));
|
|
726
767
|
var GOLD = "\x1B[33m";
|
|
727
768
|
var DIM = "\x1B[2m";
|
|
728
769
|
var RESET = "\x1B[0m";
|
|
@@ -740,7 +781,7 @@ ${RESET}
|
|
|
740
781
|
${DIM}${cwd}${RESET}
|
|
741
782
|
`);
|
|
742
783
|
}
|
|
743
|
-
var program = new
|
|
784
|
+
var program = new Command12();
|
|
744
785
|
program.name("odin").description("CLI for Odin \u2014 the knowledge backbone for Pebble House").version(VERSION);
|
|
745
786
|
program.command("login").description("Authenticate with Odin via browser").action(async () => {
|
|
746
787
|
printBanner();
|
|
@@ -766,6 +807,7 @@ program.addCommand(artifactsCmd);
|
|
|
766
807
|
program.addCommand(versionsCmd);
|
|
767
808
|
program.addCommand(guidelinesCmd);
|
|
768
809
|
program.addCommand(rulesCmd);
|
|
810
|
+
program.addCommand(briefsCmd);
|
|
769
811
|
process.on("exit", () => {
|
|
770
812
|
process.stderr.write("\n\n\n\n\n");
|
|
771
813
|
});
|