copilot-hub 0.1.5 → 0.1.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "copilot-hub",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "description": "Copilot Hub CLI and runtime bundle",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -8,16 +8,32 @@ import { fileURLToPath } from "node:url";
8
8
  const __filename = fileURLToPath(import.meta.url);
9
9
  const __dirname = path.dirname(__filename);
10
10
  const repoRoot = path.resolve(__dirname, "..", "..");
11
+ const packageJsonPath = path.join(repoRoot, "package.json");
11
12
  const nodeBin = process.execPath;
12
13
  const agentEngineEnvPath = path.join(repoRoot, "apps", "agent-engine", ".env");
13
14
  const controlPlaneEnvPath = path.join(repoRoot, "apps", "control-plane", ".env");
14
15
  const codexNpmPackage = "@openai/codex";
15
16
  const codexInstallCommand = `npm install -g ${codexNpmPackage}`;
16
- const action = String(process.argv[2] ?? "start")
17
+ const packageVersion = readPackageVersion();
18
+ const rawArgs = process.argv
19
+ .slice(2)
20
+ .map((value) => String(value ?? "").trim())
21
+ .filter(Boolean);
22
+ const wantsVersion = rawArgs.includes("--version") || rawArgs.includes("-v");
23
+ const wantsHelp = rawArgs.includes("--help") || rawArgs.includes("-h");
24
+ const action = String(rawArgs[0] ?? "start")
17
25
  .trim()
18
26
  .toLowerCase();
19
27
  await main();
20
28
  async function main() {
29
+ if (wantsVersion || action === "version") {
30
+ console.log(packageVersion);
31
+ return;
32
+ }
33
+ if (wantsHelp || action === "help") {
34
+ printUsage();
35
+ return;
36
+ }
21
37
  switch (action) {
22
38
  case "start": {
23
39
  runNode(["scripts/dist/configure.mjs", "--required-only"]);
@@ -453,5 +469,19 @@ function spawnNpm(args, options) {
453
469
  });
454
470
  }
455
471
  function printUsage() {
456
- console.log("Usage: node scripts/dist/cli.mjs <start|stop|restart|status|logs|configure>");
472
+ console.log("Usage: node scripts/dist/cli.mjs <start|stop|restart|status|logs|configure|version|help>");
473
+ }
474
+ function readPackageVersion() {
475
+ try {
476
+ const content = fs.readFileSync(packageJsonPath, "utf8");
477
+ const parsed = JSON.parse(content);
478
+ const version = String(parsed?.version ?? "").trim();
479
+ if (version) {
480
+ return version;
481
+ }
482
+ }
483
+ catch {
484
+ // Ignore and use fallback.
485
+ }
486
+ return "0.0.0";
457
487
  }
@@ -9,19 +9,38 @@ import { fileURLToPath } from "node:url";
9
9
  const __filename = fileURLToPath(import.meta.url);
10
10
  const __dirname = path.dirname(__filename);
11
11
  const repoRoot = path.resolve(__dirname, "..", "..");
12
+ const packageJsonPath = path.join(repoRoot, "package.json");
12
13
  const nodeBin = process.execPath;
13
14
  const agentEngineEnvPath = path.join(repoRoot, "apps", "agent-engine", ".env");
14
15
  const controlPlaneEnvPath = path.join(repoRoot, "apps", "control-plane", ".env");
15
16
  const codexNpmPackage = "@openai/codex";
16
17
  const codexInstallCommand = `npm install -g ${codexNpmPackage}`;
18
+ const packageVersion = readPackageVersion();
17
19
 
18
- const action = String(process.argv[2] ?? "start")
20
+ const rawArgs = process.argv
21
+ .slice(2)
22
+ .map((value) => String(value ?? "").trim())
23
+ .filter(Boolean);
24
+ const wantsVersion = rawArgs.includes("--version") || rawArgs.includes("-v");
25
+ const wantsHelp = rawArgs.includes("--help") || rawArgs.includes("-h");
26
+
27
+ const action = String(rawArgs[0] ?? "start")
19
28
  .trim()
20
29
  .toLowerCase();
21
30
 
22
31
  await main();
23
32
 
24
33
  async function main() {
34
+ if (wantsVersion || action === "version") {
35
+ console.log(packageVersion);
36
+ return;
37
+ }
38
+
39
+ if (wantsHelp || action === "help") {
40
+ printUsage();
41
+ return;
42
+ }
43
+
25
44
  switch (action) {
26
45
  case "start": {
27
46
  runNode(["scripts/dist/configure.mjs", "--required-only"]);
@@ -533,5 +552,21 @@ function spawnNpm(args, options) {
533
552
  }
534
553
 
535
554
  function printUsage() {
536
- console.log("Usage: node scripts/dist/cli.mjs <start|stop|restart|status|logs|configure>");
555
+ console.log(
556
+ "Usage: node scripts/dist/cli.mjs <start|stop|restart|status|logs|configure|version|help>",
557
+ );
558
+ }
559
+
560
+ function readPackageVersion() {
561
+ try {
562
+ const content = fs.readFileSync(packageJsonPath, "utf8");
563
+ const parsed = JSON.parse(content);
564
+ const version = String(parsed?.version ?? "").trim();
565
+ if (version) {
566
+ return version;
567
+ }
568
+ } catch {
569
+ // Ignore and use fallback.
570
+ }
571
+ return "0.0.0";
537
572
  }