@pebblehouse/odin-cli 0.3.0 → 0.4.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 +58 -5
- 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 Command14 } from "commander";
|
|
5
5
|
|
|
6
6
|
// src/auth/login.ts
|
|
7
7
|
import { createServer } from "http";
|
|
@@ -104,6 +104,14 @@ import { Command } from "commander";
|
|
|
104
104
|
import { createClient } from "@supabase/supabase-js";
|
|
105
105
|
var SUPABASE_URL = process.env.ODIN_SUPABASE_URL ?? "https://vdiwtiiksdyhlibqrngw.supabase.co";
|
|
106
106
|
var SUPABASE_ANON_KEY = process.env.ODIN_SUPABASE_ANON_KEY ?? "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZkaXd0aWlrc2R5aGxpYnFybmd3Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzM2ODM4NDksImV4cCI6MjA4OTI1OTg0OX0.gAccODqqhBnL_npqG7H42EvaT2CWR1P2pqo5NVjKFas";
|
|
107
|
+
function createNodeClient() {
|
|
108
|
+
return createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
|
|
109
|
+
auth: {
|
|
110
|
+
autoRefreshToken: false,
|
|
111
|
+
persistSession: false
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
107
115
|
async function getValidToken() {
|
|
108
116
|
const creds = getCredentials();
|
|
109
117
|
if (!creds) {
|
|
@@ -113,9 +121,8 @@ async function getValidToken() {
|
|
|
113
121
|
if (creds.expires_at > now + 60) {
|
|
114
122
|
return creds.access_token;
|
|
115
123
|
}
|
|
116
|
-
const supabase =
|
|
117
|
-
const { data, error } = await supabase.auth.
|
|
118
|
-
access_token: creds.access_token,
|
|
124
|
+
const supabase = createNodeClient();
|
|
125
|
+
const { data, error } = await supabase.auth.refreshSession({
|
|
119
126
|
refresh_token: creds.refresh_token
|
|
120
127
|
});
|
|
121
128
|
if (error || !data.session) {
|
|
@@ -608,6 +615,51 @@ guidelinesCmd.command("deprecate <id>").description("Deprecate a guideline").act
|
|
|
608
615
|
if (res.error) process.exit(1);
|
|
609
616
|
});
|
|
610
617
|
|
|
618
|
+
// src/commands/observations.ts
|
|
619
|
+
import { Command as Command13 } from "commander";
|
|
620
|
+
var observationsCmd = new Command13("observations").description(
|
|
621
|
+
"View and synthesize observations"
|
|
622
|
+
);
|
|
623
|
+
observationsCmd.command("list <slug>").description("List observations for a pebble").option("--limit <n>", "Max results", "50").option("--offset <n>", "Offset for pagination", "0").action(async (slug, opts) => {
|
|
624
|
+
const res = await apiRequest(
|
|
625
|
+
`/pebbles/${slug}/observations`,
|
|
626
|
+
{
|
|
627
|
+
params: { limit: opts.limit, offset: opts.offset }
|
|
628
|
+
}
|
|
629
|
+
);
|
|
630
|
+
process.stdout.write(JSON.stringify(res) + "\n");
|
|
631
|
+
if (res.error) process.exit(1);
|
|
632
|
+
});
|
|
633
|
+
observationsCmd.command("synthesize [slug]").description("Trigger observation synthesis (requires running worker)").action(async (slug) => {
|
|
634
|
+
try {
|
|
635
|
+
const body = {};
|
|
636
|
+
if (slug) body.slug = slug;
|
|
637
|
+
const res = await fetch("http://127.0.0.1:7433/synthesize", {
|
|
638
|
+
method: "POST",
|
|
639
|
+
headers: { "Content-Type": "application/json" },
|
|
640
|
+
body: JSON.stringify(body)
|
|
641
|
+
});
|
|
642
|
+
if (!res.ok) {
|
|
643
|
+
const text = await res.text();
|
|
644
|
+
console.error(`Worker returned ${res.status}: ${text}`);
|
|
645
|
+
process.exit(1);
|
|
646
|
+
}
|
|
647
|
+
const data = await res.json();
|
|
648
|
+
process.stdout.write(JSON.stringify(data) + "\n");
|
|
649
|
+
} catch (err) {
|
|
650
|
+
if (err instanceof Error && (err.message.includes("ECONNREFUSED") || err.message.includes("fetch failed"))) {
|
|
651
|
+
console.error(
|
|
652
|
+
"Worker not running. Start a Claude Code session to launch the worker."
|
|
653
|
+
);
|
|
654
|
+
} else {
|
|
655
|
+
console.error(
|
|
656
|
+
`Failed: ${err instanceof Error ? err.message : err}`
|
|
657
|
+
);
|
|
658
|
+
}
|
|
659
|
+
process.exit(1);
|
|
660
|
+
}
|
|
661
|
+
});
|
|
662
|
+
|
|
611
663
|
// src/index.ts
|
|
612
664
|
import { readFileSync as readFileSync6 } from "fs";
|
|
613
665
|
import { fileURLToPath } from "url";
|
|
@@ -631,7 +683,7 @@ ${RESET}
|
|
|
631
683
|
${DIM}${cwd}${RESET}
|
|
632
684
|
`);
|
|
633
685
|
}
|
|
634
|
-
var program = new
|
|
686
|
+
var program = new Command14();
|
|
635
687
|
program.name("odin").description("CLI for Odin \u2014 the knowledge backbone for Pebble House").version(VERSION);
|
|
636
688
|
program.command("login").description("Authenticate with Odin via browser").action(async () => {
|
|
637
689
|
printBanner();
|
|
@@ -659,6 +711,7 @@ program.addCommand(specsCmd);
|
|
|
659
711
|
program.addCommand(executionsCmd);
|
|
660
712
|
program.addCommand(versionsCmd);
|
|
661
713
|
program.addCommand(guidelinesCmd);
|
|
714
|
+
program.addCommand(observationsCmd);
|
|
662
715
|
process.on("exit", () => {
|
|
663
716
|
process.stderr.write("\n\n\n\n\n");
|
|
664
717
|
});
|