@rayul/kordis 0.6.1 → 0.6.2

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 (2) hide show
  1. package/dist/index.js +20 -23
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1779,14 +1779,25 @@ function loginCommand() {
1779
1779
 
1780
1780
  // src/commands/whoami.ts
1781
1781
  import { Command as Command2 } from "commander";
1782
+
1783
+ // src/lib/require-auth.ts
1784
+ init_src2();
1785
+ function requireAuth(bundle) {
1786
+ if (bundle.username) return;
1787
+ throw new KordisApiError(401, {
1788
+ error: {
1789
+ code: "not_authenticated",
1790
+ message: "authentication required",
1791
+ hint: "Run `kordis login --emit-only` to start browser sign-in (exits immediately, no blocking poll), then re-run this command \u2014 the next CLI call auto-claims the token. For interactive shells, plain `kordis login` (10-min poll) also works."
1792
+ }
1793
+ });
1794
+ }
1795
+
1796
+ // src/commands/whoami.ts
1782
1797
  function whoamiCommand() {
1783
1798
  return new Command2("whoami").description("show the currently authenticated user").action(async () => {
1784
1799
  const bundle = await useClient();
1785
- if (!bundle.username) {
1786
- printHuman(c.yellow("Not logged in. Run `kordis login`."));
1787
- process.exitCode = 10;
1788
- return;
1789
- }
1800
+ requireAuth(bundle);
1790
1801
  const me = await bundle.authedRequest((api) => api.me());
1791
1802
  printDual({
1792
1803
  json: me,
@@ -3763,11 +3774,7 @@ function commentCommand() {
3763
3774
  throw new Error('full_slug must be "{username}/{slug}"');
3764
3775
  }
3765
3776
  const bundle = await useClient();
3766
- if (!bundle.username) {
3767
- printHuman(c.yellow("Not logged in. Run `kordis login`."));
3768
- process.exitCode = 10;
3769
- return;
3770
- }
3777
+ requireAuth(bundle);
3771
3778
  const res = await bundle.authedRequest(
3772
3779
  (api) => api.createComment(username, slug, {
3773
3780
  kind: opts.kind,
@@ -3798,11 +3805,7 @@ function starCommand() {
3798
3805
  throw new Error('full_slug must be "{username}/{slug}"');
3799
3806
  }
3800
3807
  const bundle = await useClient();
3801
- if (!bundle.username) {
3802
- printHuman(c.yellow("Not logged in. Run `kordis login`."));
3803
- process.exitCode = 10;
3804
- return;
3805
- }
3808
+ requireAuth(bundle);
3806
3809
  const res = await bundle.authedRequest((api) => api.star(username, slug));
3807
3810
  printDual({
3808
3811
  json: res,
@@ -3820,11 +3823,7 @@ function unstarCommand() {
3820
3823
  throw new Error('full_slug must be "{username}/{slug}"');
3821
3824
  }
3822
3825
  const bundle = await useClient();
3823
- if (!bundle.username) {
3824
- printHuman(c.yellow("Not logged in. Run `kordis login`."));
3825
- process.exitCode = 10;
3826
- return;
3827
- }
3826
+ requireAuth(bundle);
3828
3827
  const res = await bundle.authedRequest(
3829
3828
  (api) => api.unstar(username, slug)
3830
3829
  );
@@ -3883,9 +3882,7 @@ function listCommand() {
3883
3882
  return new Command13("list").description("list your own packages (requires login)").option("--limit <n>", "max results per page", (v) => parseInt(v, 10), 20).option("--page <n>", "page number (1-based)", (v) => parseInt(v, 10), 1).option("--sort <mode>", "sort: latest|popular", "latest").action(async (opts) => {
3884
3883
  const sort = opts.sort === "popular" ? "popular" : "latest";
3885
3884
  const bundle = await useClient();
3886
- if (!bundle.username) {
3887
- throw new Error("Not logged in. Run `kordis login` first.");
3888
- }
3885
+ requireAuth(bundle);
3889
3886
  const spin = spinner("Fetching your packages");
3890
3887
  const res = await bundle.authedRequest(
3891
3888
  (api) => api.listMyPackages({ page: opts.page, limit: opts.limit, sort })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rayul/kordis",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "private": false,
5
5
  "description": "Command-line client for the Kordis registry — discover, install, and publish agentic-coding packages.",
6
6
  "license": "MIT",