unoverse 0.1.6 → 0.1.7

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/bin/unoverse.mjs CHANGED
@@ -9,8 +9,45 @@
9
9
  */
10
10
  import { existsSync } from "node:fs";
11
11
  import { spawnSync } from "node:child_process";
12
+ import { join, resolve } from "node:path";
12
13
  import { create } from "../lib/create.mjs";
13
14
 
15
+ /**
16
+ * ONE BINARY. There is no `./unoverse` any more.
17
+ *
18
+ * A universe is a folder holding the operator lib. Walk up for it, the same way git finds
19
+ * a repo, so the commands work from anywhere inside your universe rather than only at its
20
+ * root. Found means the operator commands exist; not found means they simply are not
21
+ * offered, instead of being advertised and then refusing.
22
+ */
23
+ function findUniverse() {
24
+ for (let dir = process.cwd(); ; ) {
25
+ if (existsSync(join(dir, "scripts/lib/common.sh"))) return dir;
26
+ const parent = resolve(dir, "..");
27
+ if (parent === dir) return null;
28
+ dir = parent;
29
+ }
30
+ }
31
+
32
+ /** Run an operator command in the universe we are standing in. */
33
+ function operator(root, args) {
34
+ const r = spawnSync("bash", [join(root, "scripts/operator.sh"), ...args], {
35
+ stdio: "inherit",
36
+ cwd: root,
37
+ });
38
+ process.exit(r.status ?? 0);
39
+ }
40
+
41
+ const UNIVERSE = findUniverse();
42
+
43
+ // Everything the operator half owns. Listed here so an unknown command can say so,
44
+ // rather than the two CLIs disagreeing about what exists.
45
+ const OPERATOR_COMMANDS = new Set([
46
+ "start", "stop", "check", "logs", "deploy",
47
+ // kept working, not advertised
48
+ "ground", "dev", "build", "publish", "init", "doctor", "db-setup", "db-verify", "open",
49
+ ]);
50
+
14
51
  const [, , cmd, ...args] = process.argv;
15
52
 
16
53
  const HELP = `
@@ -23,8 +60,7 @@ const HELP = `
23
60
  unoverse update Update this CLI to the latest version
24
61
  unoverse help This
25
62
 
26
- Operating a running universe? That lives in your universe folder:
27
- cd <your-universe> && ./unoverse
63
+ Standing in a universe folder adds: start · stop · check · logs · deploy
28
64
  `;
29
65
 
30
66
  switch (cmd) {
@@ -33,12 +69,9 @@ switch (cmd) {
33
69
  break;
34
70
 
35
71
  case "update": {
36
- // The command people type when the CLI is stale. Inside a universe folder,
37
- // update means the OPERATOR kit defer to it. Otherwise update this package.
38
- if (existsSync("./unoverse")) {
39
- console.log(`\n This folder is a universe — its own CLI owns updates:\n\n ./unoverse update\n`);
40
- process.exit(1);
41
- }
72
+ // In a universe, "update" means THAT UNIVERSE (pull images, restart), not this CLI.
73
+ // Same word, different object, decided by where you are standing.
74
+ if (UNIVERSE) operator(UNIVERSE, ["update", ...args]);
42
75
  const r = spawnSync("npm", ["install", "-g", "unoverse@latest"], { stdio: "inherit" });
43
76
  if (r.status === 0) {
44
77
  const v = spawnSync("unoverse", ["-v"], { encoding: "utf8" }).stdout?.trim();
@@ -69,6 +102,8 @@ switch (cmd) {
69
102
  case "--help":
70
103
  case "-h":
71
104
  case undefined:
105
+ // In a universe, its own help prints — it knows whether this kit has the owner lane.
106
+ if (UNIVERSE) operator(UNIVERSE, ["help"]);
72
107
  console.log(HELP);
73
108
  break;
74
109
 
@@ -84,10 +119,10 @@ switch (cmd) {
84
119
  }
85
120
 
86
121
  default:
87
- // A universe folder has its own operator CLI point there rather than
88
- // half-implementing its commands here (v0.2 absorbs them properly).
89
- if (existsSync("./unoverse")) {
90
- console.log(`\n '${cmd}' is an operator command run it in your universe:\n\n ./unoverse ${cmd} ${args.join(" ")}\n`);
122
+ // The operator half, run right here. No second CLI to be sent to.
123
+ if (UNIVERSE && OPERATOR_COMMANDS.has(cmd)) operator(UNIVERSE, [cmd, ...args]);
124
+ if (OPERATOR_COMMANDS.has(cmd)) {
125
+ console.log(`\n '${cmd}' operates a universe, and this folder is not one.\n ${"cd into your universe, or run: unoverse create"}\n`);
91
126
  } else {
92
127
  console.log(`\n Unknown command: ${cmd}\n${HELP}`);
93
128
  }
package/lib/create.mjs CHANGED
@@ -133,11 +133,25 @@ export async function create(nameArg) {
133
133
  const name = resolveTarget(nameArg);
134
134
  download(name);
135
135
  ok(`universe scaffolded in ${label(name)}`);
136
+
137
+ // CREATE FINISHES THE JOB. It used to stop here and tell you to go and run
138
+ // `./unoverse init`, which asked for this same token a second time. The token is
139
+ // already in hand and already validated, so hand it over and configure now.
140
+ rl.close();
141
+ console.log("");
142
+ const r = spawnSync("bash", [`${name}/scripts/operator.sh`, "init"], {
143
+ stdio: "inherit",
144
+ cwd: name,
145
+ env: { ...process.env, UNOVERSE_DOCR_TOKEN: token },
146
+ });
147
+ if (r.status !== 0) {
148
+ fail("setup did not finish — run 'unoverse init' in that folder to pick it up");
149
+ process.exit(r.status ?? 1);
150
+ }
136
151
  console.log(`
137
152
  Next:${name === "." ? "" : `
138
153
  cd ${name}`}
139
- ./unoverse init ${dim("(setup wizard — have this token ready, it asks for it)")}
140
- ./unoverse start
154
+ unoverse start
141
155
 
142
156
  ${cyan("Build with Claude:")} open the folder in Claude Code — it ships an
143
157
  authoring skill (components, nodes, agent skills) and a builder MCP that
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unoverse",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "The Unoverse front door — create a Studio project, a universe, or a client app, and launch Studio.",
5
5
  "license": "SEE LICENSE IN README.md",
6
6
  "type": "module",