@neta-art/cohub-cli 6.6.0 → 6.8.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.
@@ -168,7 +168,7 @@ async function putUploadEntry(entry, uploadUrl, headers) {
168
168
  }
169
169
  }
170
170
  async function uploadFiles(command, paths, opts) {
171
- const spaceId = resolveSpace(command);
171
+ const spaceId = await resolveSpace(command);
172
172
  const client = createClient();
173
173
  try {
174
174
  const files = await collectUploadFiles(paths);
@@ -242,7 +242,7 @@ async function sendPrompt(command, words, opts) {
242
242
  && !new Set(["off", "minimal", "low", "medium", "high", "xhigh", "max"]).has(thinkingLevel)) {
243
243
  return error("Invalid thinking level", "Use off|minimal|low|medium|high|xhigh|max");
244
244
  }
245
- const spaceId = resolveSpace(command);
245
+ const spaceId = await resolveSpace(command);
246
246
  const client = createClient();
247
247
  try {
248
248
  const schedule = opts.delayMs
@@ -304,7 +304,7 @@ async function sendPrompt(command, words, opts) {
304
304
  }
305
305
  }
306
306
  async function runCompletionCommand(command, words, opts) {
307
- const spaceId = resolveSpace(command);
307
+ const spaceId = await resolveSpace(command);
308
308
  const content = words.join(" ").trim();
309
309
  if (!content && process.stdin.isTTY) {
310
310
  return error("Message required", "Pass content args or pipe via stdin");
@@ -490,7 +490,7 @@ export function registerSpaces(program) {
490
490
  .description("Show space details")
491
491
  .option("--json", "Output as JSON")
492
492
  .action(async (id, opts) => {
493
- const spaceId = id?.trim() || resolveSpace(spacesCmd);
493
+ const spaceId = id?.trim() || await resolveSpace(spacesCmd);
494
494
  const client = createClient();
495
495
  try {
496
496
  const space = await client.spaces.get(spaceId);
@@ -562,7 +562,7 @@ export function registerSpaces(program) {
562
562
  .description("Upload the space avatar")
563
563
  .option("--json", "Output as JSON")
564
564
  .action(async (path, opts) => {
565
- const spaceId = resolveSpace(spacesCmd);
565
+ const spaceId = await resolveSpace(spacesCmd);
566
566
  const client = createClient();
567
567
  try {
568
568
  const asset = await uploadAvatarAsset({ client, purpose: "space_avatar", spaceId, path });
@@ -699,7 +699,7 @@ export function registerSpaces(program) {
699
699
  .description("Space usage statistics (default: 30 days)")
700
700
  .option("--json", "Output as JSON")
701
701
  .action(async (days, opts) => {
702
- const spaceId = resolveSpace(spacesCmd);
702
+ const spaceId = await resolveSpace(spacesCmd);
703
703
  const client = createClient();
704
704
  try {
705
705
  const usage = await client.space(spaceId).usage.get(parseInteger(days ?? "30", "days", { min: 1 }));
@@ -737,14 +737,14 @@ function registerLabels(spacesCmd) {
737
737
  const labelsCmd = spacesCmd
738
738
  .command("labels")
739
739
  .description("Manage labels")
740
- .hook("preAction", () => { resolveSpace(spacesCmd); });
740
+ .hook("preAction", async () => { await resolveSpace(spacesCmd); });
741
741
  labelsCmd
742
742
  .command("ls")
743
743
  .alias("list")
744
744
  .description("List labels")
745
745
  .option("--json", "Output as JSON")
746
746
  .action(async (opts) => {
747
- const spaceId = resolveSpace(spacesCmd);
747
+ const spaceId = await resolveSpace(spacesCmd);
748
748
  const client = createClient();
749
749
  try {
750
750
  const result = await client.space(spaceId).labels.list();
@@ -764,7 +764,7 @@ function registerLabels(spacesCmd) {
764
764
  .description("Create a label")
765
765
  .option("--json", "Output as JSON")
766
766
  .action(async (labelRef, opts) => {
767
- const spaceId = resolveSpace(spacesCmd);
767
+ const spaceId = await resolveSpace(spacesCmd);
768
768
  const client = createClient();
769
769
  try {
770
770
  const result = await client.space(spaceId).labels.create(labelRef);
@@ -784,7 +784,7 @@ function registerLabels(spacesCmd) {
784
784
  .option("--rank <n>", "Sort rank")
785
785
  .option("--json", "Output as JSON")
786
786
  .action(async (labelRef, opts) => {
787
- const spaceId = resolveSpace(spacesCmd);
787
+ const spaceId = await resolveSpace(spacesCmd);
788
788
  const client = createClient();
789
789
  try {
790
790
  const result = await client.space(spaceId).labels.update(labelRef, {
@@ -805,7 +805,7 @@ function registerLabels(spacesCmd) {
805
805
  .alias("delete")
806
806
  .description("Delete a label")
807
807
  .action(async (labelRef) => {
808
- const spaceId = resolveSpace(spacesCmd);
808
+ const spaceId = await resolveSpace(spacesCmd);
809
809
  const client = createClient();
810
810
  try {
811
811
  await client.space(spaceId).labels.delete(labelRef);
@@ -820,7 +820,7 @@ function registerLabels(spacesCmd) {
820
820
  .description("Reorder labels")
821
821
  .option("--json", "Output as JSON")
822
822
  .action(async (labelRefs, opts) => {
823
- const spaceId = resolveSpace(spacesCmd);
823
+ const spaceId = await resolveSpace(spacesCmd);
824
824
  const client = createClient();
825
825
  try {
826
826
  const result = await client.space(spaceId).labels.reorder(labelRefs);
@@ -839,7 +839,7 @@ function registerLabels(spacesCmd) {
839
839
  .option("--cursor <cursor>", "Page cursor")
840
840
  .option("--json", "Output as JSON")
841
841
  .action(async (labelRef, opts) => {
842
- const spaceId = resolveSpace(spacesCmd);
842
+ const spaceId = await resolveSpace(spacesCmd);
843
843
  const client = createClient();
844
844
  try {
845
845
  const result = await client.space(spaceId).labels.listItems(labelRef, {
@@ -864,7 +864,7 @@ function registerLabels(spacesCmd) {
864
864
  .description("Attach a label")
865
865
  .option("--json", "Output as JSON")
866
866
  .action(async (labelRef, resourceType, resourceRef, opts) => {
867
- const spaceId = resolveSpace(spacesCmd);
867
+ const spaceId = await resolveSpace(spacesCmd);
868
868
  const client = createClient();
869
869
  try {
870
870
  const result = await client.space(spaceId).labels.attach(labelRef, { resourceType: parseLabelResourceType(resourceType), resourceRef });
@@ -880,7 +880,7 @@ function registerLabels(spacesCmd) {
880
880
  .command("detach <labelRef> <resourceType> <resourceRef>")
881
881
  .description("Detach a label")
882
882
  .action(async (labelRef, resourceType, resourceRef) => {
883
- const spaceId = resolveSpace(spacesCmd);
883
+ const spaceId = await resolveSpace(spacesCmd);
884
884
  const client = createClient();
885
885
  try {
886
886
  await client.space(spaceId).labels.detach(labelRef, { resourceType: parseLabelResourceType(resourceType), resourceRef });
@@ -897,7 +897,7 @@ function registerLabels(spacesCmd) {
897
897
  .option("--remove <refs>", "Comma-separated label refs to remove")
898
898
  .option("--json", "Output as JSON")
899
899
  .action(async (resourceType, resourceRef, opts) => {
900
- const spaceId = resolveSpace(spacesCmd);
900
+ const spaceId = await resolveSpace(spacesCmd);
901
901
  const client = createClient();
902
902
  try {
903
903
  const result = await client.space(spaceId).labels.patchResourceLabels(parseLabelResourceType(resourceType), resourceRef, {
@@ -918,7 +918,7 @@ function registerLabels(spacesCmd) {
918
918
  .option("--labels <refs>", "Comma-separated label refs")
919
919
  .option("--json", "Output as JSON")
920
920
  .action(async (resourceType, resourceRef, labelRefs, opts) => {
921
- const spaceId = resolveSpace(spacesCmd);
921
+ const spaceId = await resolveSpace(spacesCmd);
922
922
  const client = createClient();
923
923
  try {
924
924
  const refs = [...parseLabelRefs(opts.labels), ...labelRefs];
@@ -936,14 +936,14 @@ function registerMods(spacesCmd) {
936
936
  const modsCmd = spacesCmd
937
937
  .command("mods")
938
938
  .description("Manage space mods")
939
- .hook("preAction", () => { resolveSpace(spacesCmd); });
939
+ .hook("preAction", async () => { await resolveSpace(spacesCmd); });
940
940
  modsCmd
941
941
  .command("ls")
942
942
  .alias("list")
943
943
  .description("List mods")
944
944
  .option("--json", "Output as JSON")
945
945
  .action(async (opts) => {
946
- const spaceId = resolveSpace(spacesCmd);
946
+ const spaceId = await resolveSpace(spacesCmd);
947
947
  const client = createClient();
948
948
  try {
949
949
  const result = await client.space(spaceId).mods.list();
@@ -969,7 +969,7 @@ function registerMods(spacesCmd) {
969
969
  .option("--json", "Output as JSON")
970
970
  .action(async (modSpaceId, opts) => {
971
971
  await confirmRestart(opts);
972
- const spaceId = resolveSpace(spacesCmd);
972
+ const spaceId = await resolveSpace(spacesCmd);
973
973
  const client = createClient();
974
974
  try {
975
975
  const result = await client.space(spaceId).mods.create({ modSpaceId, name: opts.name, mountSlug: opts.slug });
@@ -988,7 +988,7 @@ function registerMods(spacesCmd) {
988
988
  .option("--json", "Output as JSON")
989
989
  .action(async (modId, opts) => {
990
990
  await confirmRestart(opts);
991
- const spaceId = resolveSpace(spacesCmd);
991
+ const spaceId = await resolveSpace(spacesCmd);
992
992
  const client = createClient();
993
993
  try {
994
994
  const result = await client.space(spaceId).mods.update(modId, { enabled: true });
@@ -1007,7 +1007,7 @@ function registerMods(spacesCmd) {
1007
1007
  .option("--json", "Output as JSON")
1008
1008
  .action(async (modId, opts) => {
1009
1009
  await confirmRestart(opts);
1010
- const spaceId = resolveSpace(spacesCmd);
1010
+ const spaceId = await resolveSpace(spacesCmd);
1011
1011
  const client = createClient();
1012
1012
  try {
1013
1013
  const result = await client.space(spaceId).mods.update(modId, { enabled: false });
@@ -1027,7 +1027,7 @@ function registerMods(spacesCmd) {
1027
1027
  .option("--json", "Output as JSON")
1028
1028
  .action(async (modId, opts) => {
1029
1029
  await confirmRestart(opts);
1030
- const spaceId = resolveSpace(spacesCmd);
1030
+ const spaceId = await resolveSpace(spacesCmd);
1031
1031
  const client = createClient();
1032
1032
  try {
1033
1033
  const result = await client.space(spaceId).mods.remove(modId);
@@ -1111,14 +1111,14 @@ function registerFiles(spacesCmd) {
1111
1111
  const filesCmd = spacesCmd
1112
1112
  .command("files")
1113
1113
  .description("File operations")
1114
- .hook("preAction", () => { resolveSpace(spacesCmd); });
1114
+ .hook("preAction", async () => { await resolveSpace(spacesCmd); });
1115
1115
  filesCmd
1116
1116
  .command("ls [path]")
1117
1117
  .alias("list")
1118
1118
  .description("List directory tree")
1119
1119
  .option("--json", "Output as JSON")
1120
1120
  .action(async (path, opts) => {
1121
- const spaceId = resolveSpace(spacesCmd);
1121
+ const spaceId = await resolveSpace(spacesCmd);
1122
1122
  const client = createClient();
1123
1123
  try {
1124
1124
  const tree = await client.space(spaceId).files.list(path ?? "");
@@ -1143,7 +1143,7 @@ function registerFiles(spacesCmd) {
1143
1143
  .command("cat <path>")
1144
1144
  .description("Read file content")
1145
1145
  .action(async (path) => {
1146
- const spaceId = resolveSpace(spacesCmd);
1146
+ const spaceId = await resolveSpace(spacesCmd);
1147
1147
  const client = createClient();
1148
1148
  try {
1149
1149
  const file = await client.space(spaceId).files.read(path);
@@ -1173,7 +1173,7 @@ function registerFiles(spacesCmd) {
1173
1173
  }
1174
1174
  if (!content)
1175
1175
  return error("No content provided", "Use -c or pipe via stdin");
1176
- const spaceId = resolveSpace(spacesCmd);
1176
+ const spaceId = await resolveSpace(spacesCmd);
1177
1177
  const client = createClient();
1178
1178
  try {
1179
1179
  const result = await client.space(spaceId).files.write({
@@ -1197,7 +1197,7 @@ function registerFiles(spacesCmd) {
1197
1197
  .command("mkdir <path>")
1198
1198
  .description("Create a directory")
1199
1199
  .action(async (path) => {
1200
- const spaceId = resolveSpace(spacesCmd);
1200
+ const spaceId = await resolveSpace(spacesCmd);
1201
1201
  const client = createClient();
1202
1202
  try {
1203
1203
  await client.space(spaceId).files.createDir(path);
@@ -1212,7 +1212,7 @@ function registerFiles(spacesCmd) {
1212
1212
  .description("Delete a file or directory")
1213
1213
  .option("-r, --recursive", "Delete recursively")
1214
1214
  .action(async (path, opts) => {
1215
- const spaceId = resolveSpace(spacesCmd);
1215
+ const spaceId = await resolveSpace(spacesCmd);
1216
1216
  const client = createClient();
1217
1217
  try {
1218
1218
  await client.space(spaceId).files.delete(path, opts.recursive ?? false);
@@ -1226,7 +1226,7 @@ function registerFiles(spacesCmd) {
1226
1226
  .command("mv <from> <to>")
1227
1227
  .description("Move or rename")
1228
1228
  .action(async (from, to) => {
1229
- const spaceId = resolveSpace(spacesCmd);
1229
+ const spaceId = await resolveSpace(spacesCmd);
1230
1230
  const client = createClient();
1231
1231
  try {
1232
1232
  await client.space(spaceId).files.move({ fromPath: from, toPath: to });
@@ -1241,7 +1241,7 @@ function registerFiles(spacesCmd) {
1241
1241
  .description("Show pending workspace changes vs last checkpoint")
1242
1242
  .option("--json", "Output as JSON")
1243
1243
  .action(async (path, opts) => {
1244
- const spaceId = resolveSpace(spacesCmd);
1244
+ const spaceId = await resolveSpace(spacesCmd);
1245
1245
  const client = createClient();
1246
1246
  try {
1247
1247
  if (path) {
@@ -1272,14 +1272,14 @@ function registerSessions(spacesCmd) {
1272
1272
  const sessionsCmd = spacesCmd
1273
1273
  .command("sessions")
1274
1274
  .description("Browse sessions and turns")
1275
- .hook("preAction", () => { resolveSpace(spacesCmd); });
1275
+ .hook("preAction", async () => { await resolveSpace(spacesCmd); });
1276
1276
  sessionsCmd
1277
1277
  .command("ls")
1278
1278
  .alias("list")
1279
1279
  .description("List sessions")
1280
1280
  .option("--json", "Output as JSON")
1281
1281
  .action(async (opts) => {
1282
- const spaceId = resolveSpace(spacesCmd);
1282
+ const spaceId = await resolveSpace(spacesCmd);
1283
1283
  const client = createClient();
1284
1284
  try {
1285
1285
  const result = await client.space(spaceId).sessions.list();
@@ -1306,7 +1306,7 @@ function registerSessions(spacesCmd) {
1306
1306
  .option("--label <ref>", "Attach a label, e.g. Bug or Area/Frontend", collectOption, [])
1307
1307
  .option("--json", "Output as JSON")
1308
1308
  .action(async (title, opts) => {
1309
- const spaceId = resolveSpace(spacesCmd);
1309
+ const spaceId = await resolveSpace(spacesCmd);
1310
1310
  const client = createClient();
1311
1311
  try {
1312
1312
  const result = await client.space(spaceId).sessions.create({
@@ -1330,7 +1330,7 @@ function registerSessions(spacesCmd) {
1330
1330
  .description("Session details")
1331
1331
  .option("--json", "Output as JSON")
1332
1332
  .action(async (id, opts) => {
1333
- const spaceId = resolveSpace(spacesCmd);
1333
+ const spaceId = await resolveSpace(spacesCmd);
1334
1334
  const client = createClient();
1335
1335
  try {
1336
1336
  const result = await client.space(spaceId).session(id).get();
@@ -1352,7 +1352,7 @@ function registerSessions(spacesCmd) {
1352
1352
  .command("rename <id> <name>")
1353
1353
  .description("Rename a session")
1354
1354
  .action(async (id, name) => {
1355
- const spaceId = resolveSpace(spacesCmd);
1355
+ const spaceId = await resolveSpace(spacesCmd);
1356
1356
  const client = createClient();
1357
1357
  try {
1358
1358
  await client.space(spaceId).session(id).rename(name);
@@ -1368,7 +1368,7 @@ function registerSessions(spacesCmd) {
1368
1368
  .description("Stream realtime session events")
1369
1369
  .option("--json", "Output as JSON")
1370
1370
  .action(async (id, opts) => {
1371
- const spaceId = resolveSpace(spacesCmd);
1371
+ const spaceId = await resolveSpace(spacesCmd);
1372
1372
  const client = createClient();
1373
1373
  const session = client.space(spaceId).session(id);
1374
1374
  process.stdout.write(" Listening for events...\n\n");
@@ -1423,7 +1423,7 @@ function registerTurns(sessionsCmd) {
1423
1423
  .option("--limit <n>", "Page size", "30")
1424
1424
  .option("--json", "Output as JSON")
1425
1425
  .action(async (sessionId, opts) => {
1426
- const spaceId = resolveSpace(sessionsCmd);
1426
+ const spaceId = await resolveSpace(sessionsCmd);
1427
1427
  const client = createClient();
1428
1428
  try {
1429
1429
  const result = await client.space(spaceId).session(sessionId).turns.listPaginated({
@@ -1455,7 +1455,7 @@ function registerTurns(sessionsCmd) {
1455
1455
  .description("Show turn details")
1456
1456
  .option("--json", "Output as JSON")
1457
1457
  .action(async (sessionId, turnId, opts) => {
1458
- const spaceId = resolveSpace(sessionsCmd);
1458
+ const spaceId = await resolveSpace(sessionsCmd);
1459
1459
  const client = createClient();
1460
1460
  try {
1461
1461
  const result = await client.space(spaceId).session(sessionId).turns.get(turnId);
@@ -1484,7 +1484,7 @@ function registerTurns(sessionsCmd) {
1484
1484
  .description("Run a queued follow-up now")
1485
1485
  .option("--json", "Output as JSON")
1486
1486
  .action(async (sessionId, turnId, opts) => {
1487
- const spaceId = resolveSpace(sessionsCmd);
1487
+ const spaceId = await resolveSpace(sessionsCmd);
1488
1488
  const client = createClient();
1489
1489
  try {
1490
1490
  const result = await client.space(spaceId).session(sessionId).steerTurn(turnId);
@@ -1501,7 +1501,7 @@ function registerTurns(sessionsCmd) {
1501
1501
  .description("Cancel a queued follow-up")
1502
1502
  .option("--json", "Output as JSON")
1503
1503
  .action(async (sessionId, turnId, opts) => {
1504
- const spaceId = resolveSpace(sessionsCmd);
1504
+ const spaceId = await resolveSpace(sessionsCmd);
1505
1505
  const client = createClient();
1506
1506
  try {
1507
1507
  const result = await client.space(spaceId).session(sessionId).cancelTurn(turnId);
@@ -1520,7 +1520,7 @@ function registerTurns(sessionsCmd) {
1520
1520
  .option("--limit <n>", "Page size", "100")
1521
1521
  .option("--json", "Output as JSON")
1522
1522
  .action(async (sessionId, opts) => {
1523
- const spaceId = resolveSpace(sessionsCmd);
1523
+ const spaceId = await resolveSpace(sessionsCmd);
1524
1524
  const client = createClient();
1525
1525
  try {
1526
1526
  const result = await client.space(spaceId).session(sessionId).turns.index({
@@ -1554,7 +1554,7 @@ function registerTurns(sessionsCmd) {
1554
1554
  .option("--after <n>", "Turns after anchor", "20")
1555
1555
  .option("--json", "Output as JSON")
1556
1556
  .action(async (sessionId, opts) => {
1557
- const spaceId = resolveSpace(sessionsCmd);
1557
+ const spaceId = await resolveSpace(sessionsCmd);
1558
1558
  if (!opts.sequence && !opts.turn)
1559
1559
  return error("Missing anchor", "Use --sequence <n> or --turn <id>");
1560
1560
  const client = createClient();
@@ -1647,14 +1647,14 @@ function registerMembers(spacesCmd) {
1647
1647
  const memCmd = spacesCmd
1648
1648
  .command("members")
1649
1649
  .description("Member management")
1650
- .hook("preAction", () => { resolveSpace(spacesCmd); });
1650
+ .hook("preAction", async () => { await resolveSpace(spacesCmd); });
1651
1651
  memCmd
1652
1652
  .command("ls")
1653
1653
  .alias("list")
1654
1654
  .description("List space members")
1655
1655
  .option("--json", "Output as JSON")
1656
1656
  .action(async (opts) => {
1657
- const spaceId = resolveSpace(spacesCmd);
1657
+ const spaceId = await resolveSpace(spacesCmd);
1658
1658
  const client = createClient();
1659
1659
  try {
1660
1660
  const result = await client.space(spaceId).members.list();
@@ -1678,7 +1678,7 @@ function registerMembers(spacesCmd) {
1678
1678
  .command("update <userId> <role>")
1679
1679
  .description("Change member role (host | builder | guest)")
1680
1680
  .action(async (userId, role) => {
1681
- const spaceId = resolveSpace(spacesCmd);
1681
+ const spaceId = await resolveSpace(spacesCmd);
1682
1682
  const client = createClient();
1683
1683
  try {
1684
1684
  await client.space(spaceId).members.update(userId, parseChoice(role, "role", SPACE_ROLES));
@@ -1692,7 +1692,7 @@ function registerMembers(spacesCmd) {
1692
1692
  .command("remove <userId>")
1693
1693
  .description("Remove a member")
1694
1694
  .action(async (userId) => {
1695
- const spaceId = resolveSpace(spacesCmd);
1695
+ const spaceId = await resolveSpace(spacesCmd);
1696
1696
  const client = createClient();
1697
1697
  try {
1698
1698
  await client.space(spaceId).members.remove(userId);
@@ -1708,13 +1708,13 @@ function registerAccess(spacesCmd) {
1708
1708
  const accCmd = spacesCmd
1709
1709
  .command("access")
1710
1710
  .description("Access control")
1711
- .hook("preAction", () => { resolveSpace(spacesCmd); });
1711
+ .hook("preAction", async () => { await resolveSpace(spacesCmd); });
1712
1712
  accCmd
1713
1713
  .command("get")
1714
1714
  .description("Get access policy")
1715
1715
  .option("--json", "Output as JSON")
1716
1716
  .action(async (opts) => {
1717
- const spaceId = resolveSpace(spacesCmd);
1717
+ const spaceId = await resolveSpace(spacesCmd);
1718
1718
  const client = createClient();
1719
1719
  try {
1720
1720
  const policy = await client.space(spaceId).access.get();
@@ -1736,7 +1736,7 @@ function registerAccess(spacesCmd) {
1736
1736
  .option("--anonymous <role>", "Role for anonymous users (host|builder|guest|null)")
1737
1737
  .option("--json", "Output as JSON")
1738
1738
  .action(async (opts) => {
1739
- const spaceId = resolveSpace(spacesCmd);
1739
+ const spaceId = await resolveSpace(spacesCmd);
1740
1740
  const client = createClient();
1741
1741
  try {
1742
1742
  const policy = await client.space(spaceId).access.set({
@@ -1761,7 +1761,7 @@ function registerCheckpoints(spacesCmd) {
1761
1761
  const cpCmd = spacesCmd
1762
1762
  .command("checkpoints")
1763
1763
  .description("Checkpoint management")
1764
- .hook("preAction", () => { resolveSpace(spacesCmd); });
1764
+ .hook("preAction", async () => { await resolveSpace(spacesCmd); });
1765
1765
  cpCmd
1766
1766
  .command("ls")
1767
1767
  .alias("list")
@@ -1770,7 +1770,7 @@ function registerCheckpoints(spacesCmd) {
1770
1770
  .option("--cursor <cursor>", "Pagination cursor")
1771
1771
  .option("--json", "Output as JSON")
1772
1772
  .action(async (opts) => {
1773
- const spaceId = resolveSpace(spacesCmd);
1773
+ const spaceId = await resolveSpace(spacesCmd);
1774
1774
  const client = createClient();
1775
1775
  try {
1776
1776
  const result = await client.space(spaceId).checkpoints.list({
@@ -1799,7 +1799,7 @@ function registerCheckpoints(spacesCmd) {
1799
1799
  .description("Checkpoint details")
1800
1800
  .option("--json", "Output as JSON")
1801
1801
  .action(async (id, opts) => {
1802
- const spaceId = resolveSpace(spacesCmd);
1802
+ const spaceId = await resolveSpace(spacesCmd);
1803
1803
  const client = createClient();
1804
1804
  try {
1805
1805
  const result = await client.space(spaceId).checkpoints.get(id);
@@ -1822,7 +1822,7 @@ function registerCheckpoints(spacesCmd) {
1822
1822
  .description("Create a checkpoint")
1823
1823
  .option("--json", "Output as JSON")
1824
1824
  .action(async (description, opts) => {
1825
- const spaceId = resolveSpace(spacesCmd);
1825
+ const spaceId = await resolveSpace(spacesCmd);
1826
1826
  const client = createClient();
1827
1827
  try {
1828
1828
  const result = await client.space(spaceId).checkpoints.create(description ?? null);
@@ -1839,7 +1839,7 @@ function registerCheckpoints(spacesCmd) {
1839
1839
  .description("List checkpoint tree")
1840
1840
  .option("--json", "Output as JSON")
1841
1841
  .action(async (checkpointId, path, opts) => {
1842
- const spaceId = resolveSpace(spacesCmd);
1842
+ const spaceId = await resolveSpace(spacesCmd);
1843
1843
  const client = createClient();
1844
1844
  try {
1845
1845
  const tree = await client.space(spaceId).checkpoints(checkpointId).files.list(path ?? "");
@@ -1866,7 +1866,7 @@ function registerCheckpoints(spacesCmd) {
1866
1866
  .description("Show checkpoint file content")
1867
1867
  .option("--json", "Output as JSON")
1868
1868
  .action(async (checkpointId, path, opts) => {
1869
- const spaceId = resolveSpace(spacesCmd);
1869
+ const spaceId = await resolveSpace(spacesCmd);
1870
1870
  const client = createClient();
1871
1871
  try {
1872
1872
  const file = await client.space(spaceId).checkpoints(checkpointId).files.read(path);
@@ -1888,7 +1888,7 @@ function registerCheckpoints(spacesCmd) {
1888
1888
  .option("--base <checkpointId>", "Compare against another checkpoint")
1889
1889
  .option("--json", "Output as JSON")
1890
1890
  .action(async (checkpointId, path, opts) => {
1891
- const spaceId = resolveSpace(spacesCmd);
1891
+ const spaceId = await resolveSpace(spacesCmd);
1892
1892
  const client = createClient();
1893
1893
  try {
1894
1894
  if (path) {
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ program
36
36
  .summary("Work with Cohub from your terminal")
37
37
  .description("Send prompts, manage Space files, and publish public output.")
38
38
  .version(VERSION, "-v, --version", "Show version")
39
- .option("-s, --space <id>", "Target Space ID")
39
+ .option("-s, --space <id>", "Target Space ID (defaults to your Home space)")
40
40
  .option("--json", "Print machine-readable JSON when supported")
41
41
  .helpOption("-h, --help", "Show help")
42
42
  .addHelpText("after", `
@@ -45,9 +45,9 @@ Common commands:
45
45
  cohub auth login
46
46
  cohub profile avatar ./avatar.png
47
47
  cohub spaces ls
48
- cohub -s <space-id> prompt "Fix the failing tests"
49
- cohub -s <space-id> completion "Summarize AGENTS.md" --system-prompt AGENTS.md --stream
50
- cohub -s <space-id> run -- git status
48
+ cohub prompt "Fix the failing tests"
49
+ cohub completion "Summarize AGENTS.md" --system-prompt AGENTS.md --stream
50
+ cohub run -- git status
51
51
  cohub sandbox up ./my-project
52
52
  cohub search "release notes"
53
53
  cohub -s <space-id> boards inspect <board-id>
@@ -62,7 +62,11 @@ Common commands:
62
62
  cohub models ls --model-type multimodal
63
63
  cohub generate "A calm lake at sunrise" --model <model> --output lake.png
64
64
 
65
+ Target space:
66
+ -s <space-id>, then COHUB_SPACE_ID, then your Home space
67
+
65
68
  Environment:
69
+ COHUB_SPACE_ID Target Space ID when -s is omitted
66
70
  COHUB_EXECUTION_TOKEN Use this token instead of the stored Logto session
67
71
  ENV=dev Use the development Cohub environment
68
72
  `);
package/dist/space.d.ts CHANGED
@@ -1,2 +1,32 @@
1
1
  import type { Command } from "commander";
2
- export declare function resolveSpace(program: Command): string;
2
+ /**
3
+ * Cache key aligned with auth: execution token is exclusive (same as
4
+ * `resolveAccessToken`) and never falls back to a local Logto session.
5
+ * Execution grants identify the actor as `actorUserId`, not `sub`.
6
+ */
7
+ export declare function identityKeyFrom(input: {
8
+ env: string;
9
+ executionToken?: string | null;
10
+ idToken?: string | null;
11
+ accessToken?: string | null;
12
+ }): string | null;
13
+ /** Exported for tests; production always uses `CACHE_PATH`. */
14
+ export declare function readDefaultSpaceCache(path: string, key: string, now?: number): string | null;
15
+ export declare function clearDefaultSpaceCache(): void;
16
+ /** Explicit target from `-s/--space` (any ancestor) or `COHUB_SPACE_ID`, else null. */
17
+ export declare function explicitSpace(program: Command): string | null;
18
+ /**
19
+ * Resolve the user's home space when no target is given. Cached locally per
20
+ * identity so repeated invocations skip the network entirely, and memoized
21
+ * in-process so preAction hooks and actions share a single lookup.
22
+ * Network and auth failures propagate so callers can report them faithfully.
23
+ */
24
+ export declare function resolveDefaultSpace(): Promise<string | null>;
25
+ /** Shared exit for commands that need a space but resolved none. */
26
+ export declare function missingSpaceError(): never;
27
+ /**
28
+ * Target space for a command: explicit `-s`/`COHUB_SPACE_ID` first, then the
29
+ * user's home space. Exits with guidance when neither is available; request
30
+ * failures go through the shared HTTP error handler.
31
+ */
32
+ export declare function resolveSpace(program: Command): Promise<string>;