@mycadet/cli 0.13.0-dev.202611152026.e6958cf → 0.13.0-dev.202611152042.1bf2622

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/service-contracts",
3
- "version": "0.13.0-dev.202611152026.e6958cf",
3
+ "version": "0.13.0-dev.202611152042.1bf2622",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/avatar-manifest",
3
- "version": "0.13.0-dev.202611152026.e6958cf",
3
+ "version": "0.13.0-dev.202611152042.1bf2622",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/ipc-server-utils",
3
- "version": "0.13.0-dev.202611152026.e6958cf",
3
+ "version": "0.13.0-dev.202611152042.1bf2622",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/avatar-manifest",
3
- "version": "0.13.0-dev.202611152026.e6958cf",
3
+ "version": "0.13.0-dev.202611152042.1bf2622",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/ipc-server-utils",
3
- "version": "0.13.0-dev.202611152026.e6958cf",
3
+ "version": "0.13.0-dev.202611152042.1bf2622",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/service-contracts",
3
- "version": "0.13.0-dev.202611152026.e6958cf",
3
+ "version": "0.13.0-dev.202611152042.1bf2622",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/shared",
3
- "version": "0.13.0-dev.202611152026.e6958cf",
3
+ "version": "0.13.0-dev.202611152042.1bf2622",
4
4
  "private": true,
5
5
  "exports": {
6
6
  ".": "./index.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/local-mode",
3
- "version": "0.13.0-dev.202611152026.e6958cf",
3
+ "version": "0.13.0-dev.202611152042.1bf2622",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/service-contracts",
3
- "version": "0.13.0-dev.202611152026.e6958cf",
3
+ "version": "0.13.0-dev.202611152042.1bf2622",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/shared",
3
- "version": "0.13.0-dev.202611152026.e6958cf",
3
+ "version": "0.13.0-dev.202611152042.1bf2622",
4
4
  "private": true,
5
5
  "exports": {
6
6
  ".": "./index.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mycadet/cli",
3
- "version": "0.13.0-dev.202611152026.e6958cf",
3
+ "version": "0.13.0-dev.202611152042.1bf2622",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/vargasjr-dev/mycadet-temp.git"
@@ -0,0 +1,59 @@
1
+ import { mkdtempSync } from "node:fs";
2
+ import { tmpdir } from "node:os";
3
+ import { join } from "node:path";
4
+
5
+ import { afterEach, describe, expect, test } from "bun:test";
6
+
7
+ import {
8
+ appServerLogPath,
9
+ getAppServerPaths,
10
+ } from "../../lib/servers/common.js";
11
+
12
+ const originalDataHome = process.env.XDG_DATA_HOME;
13
+ const originalEnvironment = process.env.CADET_ENVIRONMENT;
14
+
15
+ function useIsolatedDataHome(): string {
16
+ const home = mkdtempSync(join(tmpdir(), "app-server-log-"));
17
+ process.env.XDG_DATA_HOME = home;
18
+ process.env.CADET_ENVIRONMENT = "test";
19
+ return home;
20
+ }
21
+
22
+ describe("appServerLogPath", () => {
23
+ afterEach(() => {
24
+ if (originalDataHome === undefined) delete process.env.XDG_DATA_HOME;
25
+ else process.env.XDG_DATA_HOME = originalDataHome;
26
+ if (originalEnvironment === undefined) delete process.env.CADET_ENVIRONMENT;
27
+ else process.env.CADET_ENVIRONMENT = originalEnvironment;
28
+ });
29
+
30
+ test("names the file by the local calendar day", () => {
31
+ // Local-time constructors keep the assertion timezone-proof.
32
+ const noon = new Date(2026, 10, 14, 12, 0, 0);
33
+ const lateNight = new Date(2026, 10, 14, 23, 59, 59);
34
+ for (const moment of [noon, lateNight]) {
35
+ expect(appServerLogPath(moment).endsWith("app-2026-11-14.log")).toBe(
36
+ true,
37
+ );
38
+ }
39
+ });
40
+
41
+ test("rolls per day under the data dir's app-server/logs", () => {
42
+ const beforeMidnight = appServerLogPath(new Date(2026, 10, 14, 23, 59));
43
+ const afterMidnight = appServerLogPath(new Date(2026, 10, 15, 0, 0));
44
+ expect(beforeMidnight).not.toBe(afterMidnight);
45
+ for (const path of [beforeMidnight, afterMidnight]) {
46
+ expect(path).toContain(join("app-server", "logs"));
47
+ }
48
+ });
49
+
50
+ test("lives under the environment's XDG data home", () => {
51
+ const home = useIsolatedDataHome();
52
+ const path = appServerLogPath(new Date(2026, 0, 2));
53
+ // The data dir carries the environment segment (cadet-test here), so the
54
+ // path starts at the data home and narrows through the app-server logs.
55
+ expect(path.startsWith(home)).toBe(true);
56
+ expect(path).toContain(join("cadet-test", "app-server", "logs"));
57
+ expect(getAppServerPaths().logPath).toBe(appServerLogPath());
58
+ });
59
+ });
@@ -1146,7 +1146,7 @@ describe("ensureAppServer", () => {
1146
1146
  mockServerSpawnExitsOnStartup();
1147
1147
 
1148
1148
  await expect(ensureAppServer()).rejects.toThrow(
1149
- /exited on startup[\s\S]*app-server\.log/,
1149
+ /exited on startup[\s\S]*logs\/app-\d{4}-\d{2}-\d{2}\.log/,
1150
1150
  );
1151
1151
  });
1152
1152
  });
@@ -18,7 +18,7 @@ import {
18
18
  rmSync,
19
19
  writeFileSync,
20
20
  } from "node:fs";
21
- import { join } from "node:path";
21
+ import { dirname, join } from "node:path";
22
22
  import { fileURLToPath } from "node:url";
23
23
 
24
24
  import { z } from "zod";
@@ -32,7 +32,6 @@ import {
32
32
  probePort,
33
33
  resolveConfigDir,
34
34
  resolveDataDir,
35
- resolveLogDir,
36
35
  waitForDaemonReady,
37
36
  } from "@mycadet/local-mode";
38
37
  import { resolveClientDists } from "../web-dist.js";
@@ -55,10 +54,29 @@ export function getAppServerPaths(): AppServerPaths {
55
54
  return {
56
55
  dir,
57
56
  pidPath: join(resolveConfigDir(), "app-server.pid"),
58
- logPath: join(resolveLogDir(), "app-server.log"),
57
+ logPath: appServerLogPath(),
59
58
  };
60
59
  }
61
60
 
61
+ /**
62
+ * The app server's rolling log file — one per local calendar day under the
63
+ * data dir (`<data>/app-server/logs/app-YYYY-MM-DD.log`), so restarts never
64
+ * grow a single unbounded file and old days can be pruned by date. The day
65
+ * is the server's launch day: a detached child binds its stdout/stderr to
66
+ * one fd at spawn, so a long-lived server keeps writing its launch-day file
67
+ * until it restarts.
68
+ */
69
+ export function appServerLogPath(now: Date = new Date()): string {
70
+ const month = String(now.getMonth() + 1).padStart(2, "0");
71
+ const day = String(now.getDate()).padStart(2, "0");
72
+ return join(
73
+ resolveDataDir(),
74
+ "app-server",
75
+ "logs",
76
+ `app-${now.getFullYear()}-${month}-${day}.log`,
77
+ );
78
+ }
79
+
62
80
  function readPidFile(pidPath: string): number | null {
63
81
  try {
64
82
  const pid = parseInt(readFileSync(pidPath, "utf-8").trim(), 10);
@@ -564,7 +582,7 @@ export async function startAppServer(): Promise<StartAppServerResult> {
564
582
  // serves the build-time vite stamp the dist indexes carry.
565
583
  const paths = getAppServerPaths();
566
584
  mkdirSync(paths.dir, { recursive: true });
567
- mkdirSync(resolveLogDir(), { recursive: true });
585
+ mkdirSync(dirname(paths.logPath), { recursive: true });
568
586
  const indexHtmlPath = join(paths.dir, "assistant-index.html");
569
587
  const appIndexHtmlPath = join(paths.dir, "app-index.html");
570
588
  const rawIndexHtml = readFileSync(join(webDistDir, "index.html"), "utf-8");
@@ -615,9 +633,10 @@ export async function startAppServer(): Promise<StartAppServerResult> {
615
633
  const rollback = async (
616
634
  status: "port-conflict" | "unreachable",
617
635
  ): Promise<AppServerUnreachableResult | AppServerPortConflictResult> => {
618
- const { logPath } = getAppServerPaths();
619
636
  await stopAppServer();
620
- return { status, listenPort, logPath };
637
+ // The launch-time path, not a fresh resolve: re-resolving could cross a
638
+ // local midnight and report a file the child never opened.
639
+ return { status, listenPort, logPath: paths.logPath };
621
640
  };
622
641
  const childExited = (): boolean => exited || child.exitCode !== null;
623
642
  if (!ready) {