@openspecui/core 1.0.2 → 1.0.4

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/dist/index.d.mts CHANGED
@@ -2270,17 +2270,17 @@ declare const PtyCreateMessageSchema: z.ZodObject<{
2270
2270
  }, "strip", z.ZodTypeAny, {
2271
2271
  type: "create";
2272
2272
  requestId: string;
2273
- cols?: number | undefined;
2274
- rows?: number | undefined;
2275
2273
  command?: string | undefined;
2276
2274
  args?: string[] | undefined;
2275
+ cols?: number | undefined;
2276
+ rows?: number | undefined;
2277
2277
  }, {
2278
2278
  type: "create";
2279
2279
  requestId: string;
2280
- cols?: number | undefined;
2281
- rows?: number | undefined;
2282
2280
  command?: string | undefined;
2283
2281
  args?: string[] | undefined;
2282
+ cols?: number | undefined;
2283
+ rows?: number | undefined;
2284
2284
  }>;
2285
2285
  declare const PtyInputMessageSchema: z.ZodObject<{
2286
2286
  type: z.ZodLiteral<"input">;
@@ -2354,17 +2354,17 @@ declare const PtyClientMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
2354
2354
  }, "strip", z.ZodTypeAny, {
2355
2355
  type: "create";
2356
2356
  requestId: string;
2357
- cols?: number | undefined;
2358
- rows?: number | undefined;
2359
2357
  command?: string | undefined;
2360
2358
  args?: string[] | undefined;
2359
+ cols?: number | undefined;
2360
+ rows?: number | undefined;
2361
2361
  }, {
2362
2362
  type: "create";
2363
2363
  requestId: string;
2364
- cols?: number | undefined;
2365
- rows?: number | undefined;
2366
2364
  command?: string | undefined;
2367
2365
  args?: string[] | undefined;
2366
+ cols?: number | undefined;
2367
+ rows?: number | undefined;
2368
2368
  }>, z.ZodObject<{
2369
2369
  type: z.ZodLiteral<"input">;
2370
2370
  sessionId: z.ZodString;
@@ -2541,19 +2541,19 @@ declare const PtyListResponseSchema: z.ZodObject<{
2541
2541
  isExited: boolean;
2542
2542
  }[];
2543
2543
  }>;
2544
- declare const PtyErrorCodeSchema: z.ZodEnum<["INVALID_JSON", "INVALID_MESSAGE", "SESSION_NOT_FOUND"]>;
2544
+ declare const PtyErrorCodeSchema: z.ZodEnum<["INVALID_JSON", "INVALID_MESSAGE", "SESSION_NOT_FOUND", "PTY_CREATE_FAILED"]>;
2545
2545
  declare const PtyErrorResponseSchema: z.ZodObject<{
2546
2546
  type: z.ZodLiteral<"error">;
2547
- code: z.ZodEnum<["INVALID_JSON", "INVALID_MESSAGE", "SESSION_NOT_FOUND"]>;
2547
+ code: z.ZodEnum<["INVALID_JSON", "INVALID_MESSAGE", "SESSION_NOT_FOUND", "PTY_CREATE_FAILED"]>;
2548
2548
  message: z.ZodString;
2549
2549
  sessionId: z.ZodOptional<z.ZodString>;
2550
2550
  }, "strip", z.ZodTypeAny, {
2551
- code: "INVALID_JSON" | "INVALID_MESSAGE" | "SESSION_NOT_FOUND";
2551
+ code: "INVALID_JSON" | "INVALID_MESSAGE" | "SESSION_NOT_FOUND" | "PTY_CREATE_FAILED";
2552
2552
  message: string;
2553
2553
  type: "error";
2554
2554
  sessionId?: string | undefined;
2555
2555
  }, {
2556
- code: "INVALID_JSON" | "INVALID_MESSAGE" | "SESSION_NOT_FOUND";
2556
+ code: "INVALID_JSON" | "INVALID_MESSAGE" | "SESSION_NOT_FOUND" | "PTY_CREATE_FAILED";
2557
2557
  message: string;
2558
2558
  type: "error";
2559
2559
  sessionId?: string | undefined;
@@ -2672,16 +2672,16 @@ declare const PtyServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
2672
2672
  }[];
2673
2673
  }>, z.ZodObject<{
2674
2674
  type: z.ZodLiteral<"error">;
2675
- code: z.ZodEnum<["INVALID_JSON", "INVALID_MESSAGE", "SESSION_NOT_FOUND"]>;
2675
+ code: z.ZodEnum<["INVALID_JSON", "INVALID_MESSAGE", "SESSION_NOT_FOUND", "PTY_CREATE_FAILED"]>;
2676
2676
  message: z.ZodString;
2677
2677
  sessionId: z.ZodOptional<z.ZodString>;
2678
2678
  }, "strip", z.ZodTypeAny, {
2679
- code: "INVALID_JSON" | "INVALID_MESSAGE" | "SESSION_NOT_FOUND";
2679
+ code: "INVALID_JSON" | "INVALID_MESSAGE" | "SESSION_NOT_FOUND" | "PTY_CREATE_FAILED";
2680
2680
  message: string;
2681
2681
  type: "error";
2682
2682
  sessionId?: string | undefined;
2683
2683
  }, {
2684
- code: "INVALID_JSON" | "INVALID_MESSAGE" | "SESSION_NOT_FOUND";
2684
+ code: "INVALID_JSON" | "INVALID_MESSAGE" | "SESSION_NOT_FOUND" | "PTY_CREATE_FAILED";
2685
2685
  message: string;
2686
2686
  type: "error";
2687
2687
  sessionId?: string | undefined;
package/dist/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  import { mkdir, readFile, rename, writeFile } from "fs/promises";
2
- import { join } from "path";
2
+ import { dirname, join } from "path";
3
3
  import { AsyncLocalStorage } from "node:async_hooks";
4
4
  import { readFile as readFile$1, readdir, stat } from "node:fs/promises";
5
- import { dirname, join as join$1, matchesGlob, relative, resolve, sep } from "node:path";
5
+ import { dirname as dirname$1, join as join$1, matchesGlob, relative, resolve, sep } from "node:path";
6
6
  import { existsSync, realpathSync, utimesSync } from "node:fs";
7
7
  import { z } from "zod";
8
8
  import { watch } from "fs";
@@ -704,7 +704,7 @@ var ProjectWatcher = class {
704
704
  const eventPath = event.path;
705
705
  if (sub.watchChildren) return eventPath.startsWith(sub.path + "/") || eventPath === sub.path;
706
706
  else {
707
- const eventDir = dirname(eventPath);
707
+ const eventDir = dirname$1(eventPath);
708
708
  return eventPath === sub.path || eventDir === sub.path;
709
709
  }
710
710
  }
@@ -1065,7 +1065,7 @@ async function reactiveReadFile(filepath) {
1065
1065
  if (!state) {
1066
1066
  state = new ReactiveState(await getValue());
1067
1067
  stateCache$1.set(key, state);
1068
- const release = acquireWatcher(dirname(normalizedPath), async () => {
1068
+ const release = acquireWatcher(dirname$1(normalizedPath), async () => {
1069
1069
  const newValue = await getValue();
1070
1070
  state.set(newValue);
1071
1071
  }, { onError: () => {
@@ -1153,7 +1153,7 @@ async function reactiveExists(path) {
1153
1153
  if (!state) {
1154
1154
  state = new ReactiveState(await getValue());
1155
1155
  stateCache$1.set(key, state);
1156
- const release = acquireWatcher(dirname(normalizedPath), async () => {
1156
+ const release = acquireWatcher(dirname$1(normalizedPath), async () => {
1157
1157
  const newValue = await getValue();
1158
1158
  state.set(newValue);
1159
1159
  }, { onError: () => {
@@ -1194,7 +1194,7 @@ async function reactiveStat(path) {
1194
1194
  return a.isDirectory === b.isDirectory && a.isFile === b.isFile && a.mtime === b.mtime && a.birthtime === b.birthtime;
1195
1195
  } });
1196
1196
  stateCache$1.set(key, state);
1197
- const release = acquireWatcher(dirname(normalizedPath), async () => {
1197
+ const release = acquireWatcher(dirname$1(normalizedPath), async () => {
1198
1198
  const newValue = await getValue();
1199
1199
  state.set(newValue);
1200
1200
  }, { onError: () => {
@@ -2315,6 +2315,7 @@ var ConfigManager = class {
2315
2315
  }
2316
2316
  };
2317
2317
  const serialized = JSON.stringify(merged, null, 2);
2318
+ await mkdir(dirname(this.configPath), { recursive: true });
2318
2319
  await writeFile(this.configPath, serialized, "utf-8");
2319
2320
  updateReactiveFileCache(this.configPath, serialized);
2320
2321
  this.invalidateResolvedCliRunner();
@@ -2349,10 +2350,14 @@ var ConfigManager = class {
2349
2350
  const [resolvedCommand, ...resolvedArgs] = resolved.commandParts;
2350
2351
  const currentCommand = config.cli.command?.trim();
2351
2352
  const currentArgs = config.cli.args ?? [];
2352
- if (currentCommand !== resolvedCommand || currentArgs.length !== resolvedArgs.length || currentArgs.some((arg, index) => arg !== resolvedArgs[index])) await this.writeConfig({ cli: {
2353
- command: resolvedCommand,
2354
- args: resolvedArgs
2355
- } });
2353
+ if (currentCommand !== resolvedCommand || currentArgs.length !== resolvedArgs.length || currentArgs.some((arg, index) => arg !== resolvedArgs[index])) try {
2354
+ await this.writeConfig({ cli: {
2355
+ command: resolvedCommand,
2356
+ args: resolvedArgs
2357
+ } });
2358
+ } catch (err) {
2359
+ console.warn("Failed to persist auto-detected CLI command:", err);
2360
+ }
2356
2361
  }
2357
2362
  return resolved;
2358
2363
  }
@@ -3829,7 +3834,8 @@ const PtyListResponseSchema = z.object({
3829
3834
  const PtyErrorCodeSchema = z.enum([
3830
3835
  "INVALID_JSON",
3831
3836
  "INVALID_MESSAGE",
3832
- "SESSION_NOT_FOUND"
3837
+ "SESSION_NOT_FOUND",
3838
+ "PTY_CREATE_FAILED"
3833
3839
  ]);
3834
3840
  const PtyErrorResponseSchema = z.object({
3835
3841
  type: z.literal("error"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openspecui/core",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Core OpenSpec adapter and parser",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",