@openspecui/server 2.0.2 → 2.1.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.
Files changed (2) hide show
  1. package/dist/index.mjs +27 -33
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -1,10 +1,13 @@
1
1
  import { createServer as createServer$1 } from "node:net";
2
2
  import { serve } from "@hono/node-server";
3
- import { CliExecutor, CodeEditorThemeSchema, ConfigManager, DASHBOARD_METRIC_KEYS, DashboardConfigSchema, OpenSpecAdapter, OpenSpecWatcher, OpsxKernel, PtyClientMessageSchema, ReactiveContext, TerminalConfigSchema, TerminalRendererEngineSchema, contextStorage, getAllTools, getAvailableTools, getConfiguredTools, getDefaultCliCommandString, getWatcherRuntimeStatus, initWatcherPool, isWatcherPoolInitialized, reactiveReadDir, reactiveReadFile, reactiveStat, sniffGlobalCli } from "@openspecui/core";
3
+ import { CliExecutor, CodeEditorThemeSchema, ConfigManager, DASHBOARD_METRIC_KEYS, DashboardConfigSchema, OpenSpecAdapter, OpenSpecWatcher, OpsxKernel, PtyClientMessageSchema, ReactiveContext, TerminalConfigSchema, TerminalRendererEngineSchema, contextStorage, getAllTools, getAvailableTools, getConfiguredTools, getDefaultCliCommandString, getWatcherRuntimeStatus, initWatcherPool, isWatcherPoolInitialized, reactiveReadDir, reactiveReadFile, sniffGlobalCli } from "@openspecui/core";
4
4
  import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
5
5
  import { applyWSSHandler } from "@trpc/server/adapters/ws";
6
6
  import { Hono } from "hono";
7
7
  import { cors } from "hono/cors";
8
+ import { readFileSync } from "node:fs";
9
+ import { basename, dirname, join, relative, resolve, sep } from "node:path";
10
+ import { fileURLToPath } from "node:url";
8
11
  import { WebSocketServer } from "ws";
9
12
  import * as pty from "@lydell/node-pty";
10
13
  import { EventEmitter } from "events";
@@ -14,7 +17,6 @@ import { observable } from "@trpc/server/observable";
14
17
  import { execFile } from "node:child_process";
15
18
  import { EventEmitter as EventEmitter$1 } from "node:events";
16
19
  import { mkdir, rm, stat, writeFile } from "node:fs/promises";
17
- import { dirname, join, relative, resolve, sep } from "node:path";
18
20
  import { promisify } from "node:util";
19
21
  import { z } from "zod";
20
22
  import { NodeWorkerSearchProvider } from "@openspecui/search/node";
@@ -1259,35 +1261,12 @@ async function fetchDashboardOverview(ctx, reason = "dashboard-refresh") {
1259
1261
  ctx.adapter.listChangesWithMeta(),
1260
1262
  ctx.adapter.listArchivedChangesWithMeta()
1261
1263
  ]);
1262
- await ctx.kernel.waitForWarmup();
1263
- await ctx.kernel.ensureStatusList();
1264
- const statusList = ctx.kernel.getStatusList();
1265
- const changeMetaMap = new Map(changeMetas.map((change) => [change.id, change]));
1266
- const activeChangeIds = new Set([...changeMetas.map((change) => change.id), ...statusList.map((status) => status.changeName)]);
1267
- const statusByChange = new Map(statusList.map((status) => [status.changeName, status]));
1268
- const activeChanges = (await Promise.all([...activeChangeIds].map(async (changeId) => {
1269
- const status = statusByChange.get(changeId);
1270
- const changeMeta = changeMetaMap.get(changeId);
1271
- const statInfo = await reactiveStat(join(ctx.projectDir, "openspec", "changes", changeId));
1272
- let progress = changeMeta?.progress ?? {
1273
- total: 0,
1274
- completed: 0
1275
- };
1276
- if (status) try {
1277
- await ctx.kernel.ensureApplyInstructions(changeId, status.schemaName);
1278
- const apply = ctx.kernel.getApplyInstructions(changeId, status.schemaName);
1279
- progress = {
1280
- total: apply.progress.total,
1281
- completed: apply.progress.complete
1282
- };
1283
- } catch {}
1284
- return {
1285
- id: changeId,
1286
- name: changeMeta?.name ?? changeId,
1287
- progress,
1288
- updatedAt: changeMeta?.updatedAt ?? statInfo?.mtime ?? 0
1289
- };
1290
- }))).sort((a, b) => b.updatedAt - a.updatedAt);
1264
+ const activeChanges = changeMetas.map((changeMeta) => ({
1265
+ id: changeMeta.id,
1266
+ name: changeMeta.name ?? changeMeta.id,
1267
+ progress: changeMeta.progress,
1268
+ updatedAt: changeMeta.updatedAt
1269
+ })).sort((a, b) => b.updatedAt - a.updatedAt);
1291
1270
  const archivedChanges = (await Promise.all(archiveMetas.map(async (meta) => {
1292
1271
  const change = await ctx.adapter.readArchivedChange(meta.id);
1293
1272
  if (!change) return null;
@@ -1639,6 +1618,7 @@ const configRouter = router({
1639
1618
  "system"
1640
1619
  ]).optional(),
1641
1620
  codeEditor: z.object({ theme: CodeEditorThemeSchema.optional() }).optional(),
1621
+ appBaseUrl: z.string().optional(),
1642
1622
  terminal: TerminalConfigSchema.omit({ rendererEngine: true }).partial().extend({ rendererEngine: TerminalRendererEngineSchema.optional() }).optional(),
1643
1623
  dashboard: DashboardConfigSchema.partial().optional()
1644
1624
  })).mutation(async ({ ctx, input }) => {
@@ -1646,9 +1626,10 @@ const configRouter = router({
1646
1626
  const hasCliArgs = input.cli !== void 0 && Object.prototype.hasOwnProperty.call(input.cli, "args");
1647
1627
  if (hasCliCommand && !hasCliArgs) {
1648
1628
  await ctx.configManager.setCliCommand(input.cli?.command ?? "");
1649
- if (input.theme !== void 0 || input.codeEditor !== void 0 || input.terminal !== void 0 || input.dashboard !== void 0) await ctx.configManager.writeConfig({
1629
+ if (input.theme !== void 0 || input.codeEditor !== void 0 || input.appBaseUrl !== void 0 || input.terminal !== void 0 || input.dashboard !== void 0) await ctx.configManager.writeConfig({
1650
1630
  theme: input.theme,
1651
1631
  codeEditor: input.codeEditor,
1632
+ appBaseUrl: input.appBaseUrl,
1652
1633
  terminal: input.terminal,
1653
1634
  dashboard: input.dashboard
1654
1635
  });
@@ -2323,6 +2304,17 @@ var SearchService = class {
2323
2304
  *
2324
2305
  * @module server
2325
2306
  */
2307
+ const __dirname = dirname(fileURLToPath(import.meta.url));
2308
+ function getServerPackageVersion() {
2309
+ try {
2310
+ const packageJsonPath = join(__dirname, "..", "package.json");
2311
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
2312
+ return typeof packageJson.version === "string" ? packageJson.version : "0.0.0";
2313
+ } catch {
2314
+ return "0.0.0";
2315
+ }
2316
+ }
2317
+ const SERVER_PACKAGE_VERSION = getServerPackageVersion();
2326
2318
  /**
2327
2319
  * Create an OpenSpecUI HTTP server with optional WebSocket support
2328
2320
  */
@@ -2343,7 +2335,9 @@ function createServer(config) {
2343
2335
  return c.json({
2344
2336
  status: "ok",
2345
2337
  projectDir: config.projectDir,
2346
- watcherEnabled: !!watcher
2338
+ projectName: basename(config.projectDir) || config.projectDir,
2339
+ watcherEnabled: !!watcher,
2340
+ openspecuiVersion: SERVER_PACKAGE_VERSION
2347
2341
  });
2348
2342
  });
2349
2343
  app.use("/trpc/*", async (c) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openspecui/server",
3
- "version": "2.0.2",
3
+ "version": "2.1.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.mjs",
6
6
  "exports": {
@@ -20,7 +20,7 @@
20
20
  "yaml": "^2.8.0",
21
21
  "yargs": "^18.0.0",
22
22
  "zod": "^3.24.1",
23
- "@openspecui/core": "2.0.0",
23
+ "@openspecui/core": "2.1.0",
24
24
  "@openspecui/search": "1.1.0"
25
25
  },
26
26
  "devDependencies": {