@openspecui/server 1.6.0 → 1.6.2

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 +33 -8
  2. package/package.json +3 -3
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createServer as createServer$1 } from "node:net";
2
2
  import { serve } from "@hono/node-server";
3
- import { CliExecutor, ConfigManager, DASHBOARD_METRIC_KEYS, DashboardConfigSchema, OpenSpecAdapter, OpenSpecWatcher, OpsxKernel, PtyClientMessageSchema, ReactiveContext, TerminalConfigSchema, TerminalRendererEngineSchema, contextStorage, getAllTools, getAvailableTools, getConfiguredTools, getDefaultCliCommandString, getWatcherRuntimeStatus, initWatcherPool, isWatcherPoolInitialized, reactiveExists, reactiveReadDir, reactiveReadFile, 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, reactiveExists, reactiveReadDir, reactiveReadFile, reactiveStat, 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";
@@ -1157,6 +1157,35 @@ async function fetchDashboardOverview(ctx, reason = "dashboard-refresh") {
1157
1157
  ctx.adapter.listChangesWithMeta(),
1158
1158
  ctx.adapter.listArchivedChangesWithMeta()
1159
1159
  ]);
1160
+ await ctx.kernel.waitForWarmup();
1161
+ await ctx.kernel.ensureStatusList();
1162
+ const statusList = ctx.kernel.getStatusList();
1163
+ const changeMetaMap = new Map(changeMetas.map((change) => [change.id, change]));
1164
+ const activeChangeIds = new Set([...changeMetas.map((change) => change.id), ...statusList.map((status) => status.changeName)]);
1165
+ const statusByChange = new Map(statusList.map((status) => [status.changeName, status]));
1166
+ const activeChanges = (await Promise.all([...activeChangeIds].map(async (changeId) => {
1167
+ const status = statusByChange.get(changeId);
1168
+ const changeMeta = changeMetaMap.get(changeId);
1169
+ const statInfo = await reactiveStat(join(ctx.projectDir, "openspec", "changes", changeId));
1170
+ let progress = changeMeta?.progress ?? {
1171
+ total: 0,
1172
+ completed: 0
1173
+ };
1174
+ if (status) try {
1175
+ await ctx.kernel.ensureApplyInstructions(changeId, status.schemaName);
1176
+ const apply = ctx.kernel.getApplyInstructions(changeId, status.schemaName);
1177
+ progress = {
1178
+ total: apply.progress.total,
1179
+ completed: apply.progress.complete
1180
+ };
1181
+ } catch {}
1182
+ return {
1183
+ id: changeId,
1184
+ name: changeMeta?.name ?? changeId,
1185
+ progress,
1186
+ updatedAt: changeMeta?.updatedAt ?? statInfo?.mtime ?? 0
1187
+ };
1188
+ }))).sort((a, b) => b.updatedAt - a.updatedAt);
1160
1189
  const archivedChanges = (await Promise.all(archiveMetas.map(async (meta) => {
1161
1190
  const change = await ctx.adapter.readArchivedChange(meta.id);
1162
1191
  if (!change) return null;
@@ -1177,12 +1206,6 @@ async function fetchDashboardOverview(ctx, reason = "dashboard-refresh") {
1177
1206
  updatedAt: meta.updatedAt
1178
1207
  };
1179
1208
  }))).filter((item) => item !== null).sort((a, b) => b.requirements - a.requirements || b.updatedAt - a.updatedAt);
1180
- const activeChanges = changeMetas.map((change) => ({
1181
- id: change.id,
1182
- name: change.name,
1183
- progress: change.progress,
1184
- updatedAt: change.updatedAt
1185
- }));
1186
1209
  const requirements = specifications.reduce((sum, spec) => sum + spec.requirements, 0);
1187
1210
  const tasksTotal = activeChanges.reduce((sum, change) => sum + change.progress.total, 0);
1188
1211
  const tasksCompleted = activeChanges.reduce((sum, change) => sum + change.progress.completed, 0);
@@ -1513,6 +1536,7 @@ const configRouter = router({
1513
1536
  "dark",
1514
1537
  "system"
1515
1538
  ]).optional(),
1539
+ codeEditor: z.object({ theme: CodeEditorThemeSchema.optional() }).optional(),
1516
1540
  terminal: TerminalConfigSchema.omit({ rendererEngine: true }).partial().extend({ rendererEngine: TerminalRendererEngineSchema.optional() }).optional(),
1517
1541
  dashboard: DashboardConfigSchema.partial().optional()
1518
1542
  })).mutation(async ({ ctx, input }) => {
@@ -1520,8 +1544,9 @@ const configRouter = router({
1520
1544
  const hasCliArgs = input.cli !== void 0 && Object.prototype.hasOwnProperty.call(input.cli, "args");
1521
1545
  if (hasCliCommand && !hasCliArgs) {
1522
1546
  await ctx.configManager.setCliCommand(input.cli?.command ?? "");
1523
- if (input.theme !== void 0 || input.terminal !== void 0 || input.dashboard !== void 0) await ctx.configManager.writeConfig({
1547
+ if (input.theme !== void 0 || input.codeEditor !== void 0 || input.terminal !== void 0 || input.dashboard !== void 0) await ctx.configManager.writeConfig({
1524
1548
  theme: input.theme,
1549
+ codeEditor: input.codeEditor,
1525
1550
  terminal: input.terminal,
1526
1551
  dashboard: input.dashboard
1527
1552
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openspecui/server",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "type": "module",
5
5
  "main": "dist/index.mjs",
6
6
  "exports": {
@@ -20,8 +20,8 @@
20
20
  "yaml": "^2.8.0",
21
21
  "yargs": "^18.0.0",
22
22
  "zod": "^3.24.1",
23
- "@openspecui/search": "1.1.0",
24
- "@openspecui/core": "1.6.0"
23
+ "@openspecui/core": "1.6.2",
24
+ "@openspecui/search": "1.1.0"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@types/node": "^22.10.2",