@openspecui/core 2.1.7 → 2.3.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.
package/dist/index.d.mts CHANGED
@@ -19,13 +19,13 @@ declare const ChangeFileSchema: z.ZodObject<{
19
19
  /** Optional byte size for files */
20
20
  size: z.ZodOptional<z.ZodNumber>;
21
21
  }, "strip", z.ZodTypeAny, {
22
- path: string;
23
22
  type: "file" | "directory";
23
+ path: string;
24
24
  content?: string | undefined;
25
25
  size?: number | undefined;
26
26
  }, {
27
- path: string;
28
27
  type: "file" | "directory";
28
+ path: string;
29
29
  content?: string | undefined;
30
30
  size?: number | undefined;
31
31
  }>;
@@ -306,11 +306,11 @@ declare const DeltaSpecSchema: z.ZodObject<{
306
306
  /** Raw markdown content of the delta spec */
307
307
  content: z.ZodString;
308
308
  }, "strip", z.ZodTypeAny, {
309
- content: string;
310
309
  specId: string;
311
- }, {
312
310
  content: string;
311
+ }, {
313
312
  specId: string;
313
+ content: string;
314
314
  }>;
315
315
  type DeltaSpec = z.infer<typeof DeltaSpecSchema>;
316
316
  /**
@@ -488,11 +488,11 @@ declare const ChangeSchema: z.ZodObject<{
488
488
  /** Raw markdown content of the delta spec */
489
489
  content: z.ZodString;
490
490
  }, "strip", z.ZodTypeAny, {
491
- content: string;
492
491
  specId: string;
493
- }, {
494
492
  content: string;
493
+ }, {
495
494
  specId: string;
495
+ content: string;
496
496
  }>, "many">>;
497
497
  /** Optional metadata */
498
498
  metadata: z.ZodOptional<z.ZodObject<{
@@ -549,8 +549,8 @@ declare const ChangeSchema: z.ZodObject<{
549
549
  } | undefined;
550
550
  design?: string | undefined;
551
551
  deltaSpecs?: {
552
- content: string;
553
552
  specId: string;
553
+ content: string;
554
554
  }[] | undefined;
555
555
  }, {
556
556
  id: string;
@@ -596,8 +596,8 @@ declare const ChangeSchema: z.ZodObject<{
596
596
  } | undefined;
597
597
  design?: string | undefined;
598
598
  deltaSpecs?: {
599
- content: string;
600
599
  specId: string;
600
+ content: string;
601
601
  }[] | undefined;
602
602
  }>;
603
603
  type Change = z.infer<typeof ChangeSchema>;
@@ -803,8 +803,8 @@ declare class OpenSpecAdapter {
803
803
  } | undefined;
804
804
  design?: string | undefined;
805
805
  deltaSpecs?: {
806
- content: string;
807
806
  specId: string;
807
+ content: string;
808
808
  }[] | undefined;
809
809
  }[];
810
810
  archivedCount: number;
@@ -1406,6 +1406,15 @@ declare const DashboardConfigSchema: z.ZodObject<{
1406
1406
  trendPointLimit?: number | undefined;
1407
1407
  }>;
1408
1408
  type DashboardConfig = z.infer<typeof DashboardConfigSchema>;
1409
+ declare const DEFAULT_GIT_DIFF_EAGER_LINE_BUDGET = 1000;
1410
+ declare const GitConfigSchema: z.ZodObject<{
1411
+ diffEagerLineBudget: z.ZodDefault<z.ZodNumber>;
1412
+ }, "strip", z.ZodTypeAny, {
1413
+ diffEagerLineBudget: number;
1414
+ }, {
1415
+ diffEagerLineBudget?: number | undefined;
1416
+ }>;
1417
+ type GitConfig = z.infer<typeof GitConfigSchema>;
1409
1418
  /**
1410
1419
  * OpenSpecUI 配置 Schema
1411
1420
  *
@@ -1468,6 +1477,14 @@ declare const OpenSpecUIConfigSchema: z.ZodObject<{
1468
1477
  }, {
1469
1478
  trendPointLimit?: number | undefined;
1470
1479
  }>>;
1480
+ /** Git detail 配置 */
1481
+ git: z.ZodDefault<z.ZodObject<{
1482
+ diffEagerLineBudget: z.ZodDefault<z.ZodNumber>;
1483
+ }, "strip", z.ZodTypeAny, {
1484
+ diffEagerLineBudget: number;
1485
+ }, {
1486
+ diffEagerLineBudget?: number | undefined;
1487
+ }>>;
1471
1488
  }, "strip", z.ZodTypeAny, {
1472
1489
  theme: "light" | "dark" | "system";
1473
1490
  cli: {
@@ -1489,6 +1506,9 @@ declare const OpenSpecUIConfigSchema: z.ZodObject<{
1489
1506
  dashboard: {
1490
1507
  trendPointLimit: number;
1491
1508
  };
1509
+ git: {
1510
+ diffEagerLineBudget: number;
1511
+ };
1492
1512
  }, {
1493
1513
  theme?: "light" | "dark" | "system" | undefined;
1494
1514
  cli?: {
@@ -1510,6 +1530,9 @@ declare const OpenSpecUIConfigSchema: z.ZodObject<{
1510
1530
  dashboard?: {
1511
1531
  trendPointLimit?: number | undefined;
1512
1532
  } | undefined;
1533
+ git?: {
1534
+ diffEagerLineBudget?: number | undefined;
1535
+ } | undefined;
1513
1536
  }>;
1514
1537
  type OpenSpecUIConfig = z.infer<typeof OpenSpecUIConfigSchema>;
1515
1538
  type OpenSpecUIConfigUpdate = {
@@ -1522,6 +1545,7 @@ type OpenSpecUIConfigUpdate = {
1522
1545
  appBaseUrl?: OpenSpecUIConfig['appBaseUrl'];
1523
1546
  terminal?: Partial<TerminalConfig>;
1524
1547
  dashboard?: Partial<DashboardConfig>;
1548
+ git?: Partial<GitConfig>;
1525
1549
  };
1526
1550
  /** 默认配置(静态,用于测试和类型) */
1527
1551
  declare const DEFAULT_CONFIG: OpenSpecUIConfig;
@@ -1861,6 +1885,7 @@ type DashboardGitEntry = DashboardGitCommitEntry | DashboardGitUncommittedEntry;
1861
1885
  interface DashboardGitWorktree {
1862
1886
  path: string;
1863
1887
  relativePath: string;
1888
+ pathAvailable: boolean;
1864
1889
  branchName: string;
1865
1890
  detached: boolean;
1866
1891
  isCurrent: boolean;
@@ -2412,6 +2437,69 @@ interface ExportSnapshot {
2412
2437
  };
2413
2438
  }
2414
2439
  //#endregion
2440
+ //#region src/git-panel-types.d.ts
2441
+ type GitEntryCursor = string;
2442
+ type GitEntrySelector = {
2443
+ type: 'uncommitted';
2444
+ } | {
2445
+ type: 'commit';
2446
+ hash: string;
2447
+ };
2448
+ type GitFileChangeType = 'added' | 'modified' | 'deleted' | 'renamed' | 'copied' | 'typechanged' | 'unmerged' | 'unknown';
2449
+ type GitPatchState = 'available' | 'binary' | 'too-large' | 'unavailable';
2450
+ type GitEntryFileSource = 'tracked' | 'untracked';
2451
+ type GitEntryFileDiff = ({
2452
+ state: 'ready';
2453
+ } & DashboardGitDiffStats) | {
2454
+ state: 'loading' | 'unavailable';
2455
+ files: number;
2456
+ };
2457
+ type GitWorktreeSummary = Omit<DashboardGitWorktree, 'entries'>;
2458
+ interface GitEntriesPage {
2459
+ items: DashboardGitEntry[];
2460
+ nextCursor: GitEntryCursor | null;
2461
+ }
2462
+ interface GitEntryFileSummary {
2463
+ fileId: string;
2464
+ source: GitEntryFileSource;
2465
+ path: string;
2466
+ displayPath: string;
2467
+ previousPath: string | null;
2468
+ changeType: GitFileChangeType;
2469
+ diff: GitEntryFileDiff;
2470
+ }
2471
+ interface GitEntryFilePatch extends GitEntryFileSummary {
2472
+ patch: string | null;
2473
+ state: GitPatchState;
2474
+ }
2475
+ interface GitEntryShell {
2476
+ entry: DashboardGitEntry | null;
2477
+ files: GitEntryFileSummary[];
2478
+ }
2479
+ interface GitEntryFiles {
2480
+ files: GitEntryFileSummary[];
2481
+ eagerFiles: GitEntryFilePatch[];
2482
+ eagerPatchLineBudget: number;
2483
+ eagerPatchLineCount: number;
2484
+ }
2485
+ interface GitEntryPatch {
2486
+ file: GitEntryFilePatch | null;
2487
+ }
2488
+ type GitPatchFile = GitEntryFilePatch;
2489
+ interface GitEntryDetail {
2490
+ entry: DashboardGitEntry | null;
2491
+ files: GitEntryFilePatch[];
2492
+ }
2493
+ interface GitWorktreeOverview {
2494
+ defaultBranch: string;
2495
+ currentWorktree: GitWorktreeSummary | null;
2496
+ otherWorktrees: GitWorktreeSummary[];
2497
+ }
2498
+ interface GitWorktreeHandoff {
2499
+ projectDir: string;
2500
+ serverUrl: string;
2501
+ }
2502
+ //#endregion
2415
2503
  //#region src/opsx-kernel.d.ts
2416
2504
  type TemplateContentMap = Record<string, {
2417
2505
  content: string | null;
@@ -2525,22 +2613,22 @@ declare const PtySessionInfoSchema: z.ZodObject<{
2525
2613
  closeTip: z.ZodOptional<z.ZodString>;
2526
2614
  closeCallbackUrl: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
2527
2615
  }, "strip", z.ZodTypeAny, {
2528
- id: string;
2529
2616
  command: string;
2530
2617
  args: string[];
2531
2618
  platform: "windows" | "macos" | "common";
2532
2619
  exitCode: number | null;
2533
2620
  title: string;
2621
+ id: string;
2534
2622
  isExited: boolean;
2535
2623
  closeTip?: string | undefined;
2536
2624
  closeCallbackUrl?: string | Record<string, string> | undefined;
2537
2625
  }, {
2538
- id: string;
2539
2626
  command: string;
2540
2627
  args: string[];
2541
2628
  platform: "windows" | "macos" | "common";
2542
2629
  exitCode: number | null;
2543
2630
  title: string;
2631
+ id: string;
2544
2632
  isExited: boolean;
2545
2633
  closeTip?: string | undefined;
2546
2634
  closeCallbackUrl?: string | Record<string, string> | undefined;
@@ -2801,22 +2889,22 @@ declare const PtyListResponseSchema: z.ZodObject<{
2801
2889
  closeTip: z.ZodOptional<z.ZodString>;
2802
2890
  closeCallbackUrl: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
2803
2891
  }, "strip", z.ZodTypeAny, {
2804
- id: string;
2805
2892
  command: string;
2806
2893
  args: string[];
2807
2894
  platform: "windows" | "macos" | "common";
2808
2895
  exitCode: number | null;
2809
2896
  title: string;
2897
+ id: string;
2810
2898
  isExited: boolean;
2811
2899
  closeTip?: string | undefined;
2812
2900
  closeCallbackUrl?: string | Record<string, string> | undefined;
2813
2901
  }, {
2814
- id: string;
2815
2902
  command: string;
2816
2903
  args: string[];
2817
2904
  platform: "windows" | "macos" | "common";
2818
2905
  exitCode: number | null;
2819
2906
  title: string;
2907
+ id: string;
2820
2908
  isExited: boolean;
2821
2909
  closeTip?: string | undefined;
2822
2910
  closeCallbackUrl?: string | Record<string, string> | undefined;
@@ -2824,12 +2912,12 @@ declare const PtyListResponseSchema: z.ZodObject<{
2824
2912
  }, "strip", z.ZodTypeAny, {
2825
2913
  type: "list";
2826
2914
  sessions: {
2827
- id: string;
2828
2915
  command: string;
2829
2916
  args: string[];
2830
2917
  platform: "windows" | "macos" | "common";
2831
2918
  exitCode: number | null;
2832
2919
  title: string;
2920
+ id: string;
2833
2921
  isExited: boolean;
2834
2922
  closeTip?: string | undefined;
2835
2923
  closeCallbackUrl?: string | Record<string, string> | undefined;
@@ -2837,12 +2925,12 @@ declare const PtyListResponseSchema: z.ZodObject<{
2837
2925
  }, {
2838
2926
  type: "list";
2839
2927
  sessions: {
2840
- id: string;
2841
2928
  command: string;
2842
2929
  args: string[];
2843
2930
  platform: "windows" | "macos" | "common";
2844
2931
  exitCode: number | null;
2845
2932
  title: string;
2933
+ id: string;
2846
2934
  isExited: boolean;
2847
2935
  closeTip?: string | undefined;
2848
2936
  closeCallbackUrl?: string | Record<string, string> | undefined;
@@ -2941,22 +3029,22 @@ declare const PtyServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
2941
3029
  closeTip: z.ZodOptional<z.ZodString>;
2942
3030
  closeCallbackUrl: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
2943
3031
  }, "strip", z.ZodTypeAny, {
2944
- id: string;
2945
3032
  command: string;
2946
3033
  args: string[];
2947
3034
  platform: "windows" | "macos" | "common";
2948
3035
  exitCode: number | null;
2949
3036
  title: string;
3037
+ id: string;
2950
3038
  isExited: boolean;
2951
3039
  closeTip?: string | undefined;
2952
3040
  closeCallbackUrl?: string | Record<string, string> | undefined;
2953
3041
  }, {
2954
- id: string;
2955
3042
  command: string;
2956
3043
  args: string[];
2957
3044
  platform: "windows" | "macos" | "common";
2958
3045
  exitCode: number | null;
2959
3046
  title: string;
3047
+ id: string;
2960
3048
  isExited: boolean;
2961
3049
  closeTip?: string | undefined;
2962
3050
  closeCallbackUrl?: string | Record<string, string> | undefined;
@@ -2964,12 +3052,12 @@ declare const PtyServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
2964
3052
  }, "strip", z.ZodTypeAny, {
2965
3053
  type: "list";
2966
3054
  sessions: {
2967
- id: string;
2968
3055
  command: string;
2969
3056
  args: string[];
2970
3057
  platform: "windows" | "macos" | "common";
2971
3058
  exitCode: number | null;
2972
3059
  title: string;
3060
+ id: string;
2973
3061
  isExited: boolean;
2974
3062
  closeTip?: string | undefined;
2975
3063
  closeCallbackUrl?: string | Record<string, string> | undefined;
@@ -2977,12 +3065,12 @@ declare const PtyServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
2977
3065
  }, {
2978
3066
  type: "list";
2979
3067
  sessions: {
2980
- id: string;
2981
3068
  command: string;
2982
3069
  args: string[];
2983
3070
  platform: "windows" | "macos" | "common";
2984
3071
  exitCode: number | null;
2985
3072
  title: string;
3073
+ id: string;
2986
3074
  isExited: boolean;
2987
3075
  closeTip?: string | undefined;
2988
3076
  closeCallbackUrl?: string | Record<string, string> | undefined;
@@ -3008,4 +3096,4 @@ type PtyServerMessage = z.infer<typeof PtyServerMessageSchema>;
3008
3096
  type PtySessionInfo = z.infer<typeof PtySessionInfoSchema>;
3009
3097
  type PtyPlatform = z.infer<typeof PtyPlatformSchema>;
3010
3098
  //#endregion
3011
- export { type AIToolOption, AI_TOOLS, type ApplyInstructions, ApplyInstructionsSchema, type ApplyTask, ApplyTaskSchema, type ArchiveMeta, type ArtifactInstructions, ArtifactInstructionsSchema, type ArtifactStatus, ArtifactStatusSchema, CODE_EDITOR_THEME_VALUES, type Change, type ChangeFile, ChangeFileSchema, type ChangeMeta, ChangeSchema, type ChangeStatus, ChangeStatusSchema, CliExecutor, type CliResult, type CliRunnerAttempt, type CliSniffResult, type CliStreamEvent, type CodeEditorTheme, CodeEditorThemeSchema, ConfigManager, DASHBOARD_METRIC_KEYS, DEFAULT_CONFIG, type DashboardCardAvailability, type DashboardConfig, DashboardConfigSchema, type DashboardGitCommitEntry, type DashboardGitDiffStats, type DashboardGitEntry, type DashboardGitSnapshot, type DashboardGitUncommittedEntry, type DashboardGitWorktree, type DashboardMetricKey, type DashboardOverview, type DashboardSummary, type DashboardTrendKind, type DashboardTrendMeta, type DashboardTrendPoint, type DashboardTriColorTrendPoint, type Delta, type DeltaOperation, DeltaOperationType, DeltaSchema, type DeltaSpec, DeltaSpecSchema, type DependencyInfo, DependencyInfoSchema, type ExportSnapshot, type FileChangeEvent, type FileChangeType, type HostedAppChannelKind, type HostedAppChannelManifest, type HostedAppCompatibilityEntry, type HostedAppVersionManifest, type HostedBackendHealthResponse, MarkdownParser, OFFICIAL_APP_BASE_URL, OpenSpecAdapter, type OpenSpecUIConfig, OpenSpecUIConfigSchema, type OpenSpecUIConfigUpdate, OpenSpecWatcher, OpsxKernel, type PathCallback, ProjectWatcher, type ProjectWatcherReinitializeReason, type ProjectWatcherRuntimeStatus, PtyAttachMessageSchema, PtyBufferResponseSchema, type PtyClientMessage, PtyClientMessageSchema, PtyCloseMessageSchema, PtyCreateMessageSchema, PtyCreatedResponseSchema, PtyErrorCodeSchema, PtyErrorResponseSchema, PtyExitResponseSchema, PtyInputMessageSchema, PtyListMessageSchema, PtyListResponseSchema, PtyOutputResponseSchema, type PtyPlatform, PtyPlatformSchema, PtyResizeMessageSchema, type PtyServerMessage, PtyServerMessageSchema, type PtySessionInfo, PtyTitleResponseSchema, ReactiveContext, ReactiveState, type ReactiveStateOptions, type Requirement, RequirementSchema, type ResolvedCliRunner, type SchemaArtifact, SchemaArtifactSchema, type SchemaDetail, SchemaDetailSchema, type SchemaInfo, SchemaInfoSchema, type SchemaResolution, SchemaResolutionSchema, type Spec, type SpecMeta, SpecSchema, TOOL_WORKFLOW_TO_SKILL_DIR, type Task, TaskSchema, type TemplateContentMap, type TemplatesMap, TemplatesSchema, type TerminalConfig, TerminalConfigSchema, type TerminalRendererEngine, TerminalRendererEngineSchema, type ToolConfig, type ToolInitDelivery, type ToolInitState, type ToolInitStatus, type ToolWorkflowId, VIRTUAL_PROJECT_DIRNAME, type ValidationIssue, type ValidationResult, Validator, type WatchEvent, type WatchEventType, type WatcherRuntimeStatus, acquireWatcher, buildCliRunnerCandidates, buildHostedLaunchUrl, buildHostedVersionManifestUrl, clearCache, closeAllProjectWatchers, closeAllWatchers, contextStorage, createCleanCliEnv, createFileChangeObservable, getActiveWatcherCount, getAllToolIds, getAllTools, getAvailableToolIds, getAvailableTools, getCacheSize, getConfiguredTools, getDefaultCliCommand, getDefaultCliCommandString, getDetectedProjectTools, getProjectWatcher, getToolById, getToolInitStates, getWatchedProjectDir, getWatcherRuntimeStatus, initWatcherPool, isGlobPattern, isHostedAppVersionManifest, isHostedBackendHealthResponse, isTerminalRendererEngine, isToolConfigured, isWatcherPoolInitialized, normalizeHostedAppBaseUrl, parseCliCommand, reactiveExists, reactiveReadDir, reactiveReadFile, reactiveStat, resolveHostedAppBaseUrl, resolveHostedChannelForVersion, sniffGlobalCli, toOpsxDisplayPath };
3099
+ export { type AIToolOption, AI_TOOLS, type ApplyInstructions, ApplyInstructionsSchema, type ApplyTask, ApplyTaskSchema, type ArchiveMeta, type ArtifactInstructions, ArtifactInstructionsSchema, type ArtifactStatus, ArtifactStatusSchema, CODE_EDITOR_THEME_VALUES, type Change, type ChangeFile, ChangeFileSchema, type ChangeMeta, ChangeSchema, type ChangeStatus, ChangeStatusSchema, CliExecutor, type CliResult, type CliRunnerAttempt, type CliSniffResult, type CliStreamEvent, type CodeEditorTheme, CodeEditorThemeSchema, ConfigManager, DASHBOARD_METRIC_KEYS, DEFAULT_CONFIG, DEFAULT_GIT_DIFF_EAGER_LINE_BUDGET, type DashboardCardAvailability, type DashboardConfig, DashboardConfigSchema, type DashboardGitCommitEntry, type DashboardGitDiffStats, type DashboardGitEntry, type DashboardGitSnapshot, type DashboardGitUncommittedEntry, type DashboardGitWorktree, type DashboardMetricKey, type DashboardOverview, type DashboardSummary, type DashboardTrendKind, type DashboardTrendMeta, type DashboardTrendPoint, type DashboardTriColorTrendPoint, type Delta, type DeltaOperation, DeltaOperationType, DeltaSchema, type DeltaSpec, DeltaSpecSchema, type DependencyInfo, DependencyInfoSchema, type ExportSnapshot, type FileChangeEvent, type FileChangeType, type GitConfig, GitConfigSchema, type GitEntriesPage, type GitEntryCursor, type GitEntryDetail, type GitEntryFileDiff, type GitEntryFilePatch, type GitEntryFileSource, type GitEntryFileSummary, type GitEntryFiles, type GitEntryPatch, type GitEntrySelector, type GitEntryShell, type GitFileChangeType, type GitPatchFile, type GitPatchState, type GitWorktreeHandoff, type GitWorktreeOverview, type GitWorktreeSummary, type HostedAppChannelKind, type HostedAppChannelManifest, type HostedAppCompatibilityEntry, type HostedAppVersionManifest, type HostedBackendHealthResponse, MarkdownParser, OFFICIAL_APP_BASE_URL, OpenSpecAdapter, type OpenSpecUIConfig, OpenSpecUIConfigSchema, type OpenSpecUIConfigUpdate, OpenSpecWatcher, OpsxKernel, type PathCallback, ProjectWatcher, type ProjectWatcherReinitializeReason, type ProjectWatcherRuntimeStatus, PtyAttachMessageSchema, PtyBufferResponseSchema, type PtyClientMessage, PtyClientMessageSchema, PtyCloseMessageSchema, PtyCreateMessageSchema, PtyCreatedResponseSchema, PtyErrorCodeSchema, PtyErrorResponseSchema, PtyExitResponseSchema, PtyInputMessageSchema, PtyListMessageSchema, PtyListResponseSchema, PtyOutputResponseSchema, type PtyPlatform, PtyPlatformSchema, PtyResizeMessageSchema, type PtyServerMessage, PtyServerMessageSchema, type PtySessionInfo, PtyTitleResponseSchema, ReactiveContext, ReactiveState, type ReactiveStateOptions, type Requirement, RequirementSchema, type ResolvedCliRunner, type SchemaArtifact, SchemaArtifactSchema, type SchemaDetail, SchemaDetailSchema, type SchemaInfo, SchemaInfoSchema, type SchemaResolution, SchemaResolutionSchema, type Spec, type SpecMeta, SpecSchema, TOOL_WORKFLOW_TO_SKILL_DIR, type Task, TaskSchema, type TemplateContentMap, type TemplatesMap, TemplatesSchema, type TerminalConfig, TerminalConfigSchema, type TerminalRendererEngine, TerminalRendererEngineSchema, type ToolConfig, type ToolInitDelivery, type ToolInitState, type ToolInitStatus, type ToolWorkflowId, VIRTUAL_PROJECT_DIRNAME, type ValidationIssue, type ValidationResult, Validator, type WatchEvent, type WatchEventType, type WatcherRuntimeStatus, acquireWatcher, buildCliRunnerCandidates, buildHostedLaunchUrl, buildHostedVersionManifestUrl, clearCache, closeAllProjectWatchers, closeAllWatchers, contextStorage, createCleanCliEnv, createFileChangeObservable, getActiveWatcherCount, getAllToolIds, getAllTools, getAvailableToolIds, getAvailableTools, getCacheSize, getConfiguredTools, getDefaultCliCommand, getDefaultCliCommandString, getDetectedProjectTools, getProjectWatcher, getToolById, getToolInitStates, getWatchedProjectDir, getWatcherRuntimeStatus, initWatcherPool, isGlobPattern, isHostedAppVersionManifest, isHostedBackendHealthResponse, isTerminalRendererEngine, isToolConfigured, isWatcherPoolInitialized, normalizeHostedAppBaseUrl, parseCliCommand, reactiveExists, reactiveReadDir, reactiveReadFile, reactiveStat, resolveHostedAppBaseUrl, resolveHostedChannelForVersion, sniffGlobalCli, toOpsxDisplayPath };
package/dist/index.mjs CHANGED
@@ -9,7 +9,7 @@ import { existsSync, lstatSync, realpathSync } from "node:fs";
9
9
  import { z } from "zod";
10
10
  import { EventEmitter } from "events";
11
11
  import { watch } from "fs";
12
- import { exec, spawn } from "child_process";
12
+ import { exec, execFile, spawn } from "child_process";
13
13
  import { promisify } from "util";
14
14
  import { homedir } from "node:os";
15
15
  import { parse } from "yaml";
@@ -1922,6 +1922,7 @@ function createFileChangeObservable(watcher) {
1922
1922
  //#endregion
1923
1923
  //#region src/config.ts
1924
1924
  const execAsync = promisify(exec);
1925
+ const execFileAsync = promisify(execFile);
1925
1926
  const CLI_PROBE_TIMEOUT_MS = 2e4;
1926
1927
  const THEME_VALUES = [
1927
1928
  "light",
@@ -2084,6 +2085,53 @@ function commandToString(commandParts) {
2084
2085
  };
2085
2086
  return commandParts.map(formatToken).join(" ").trim();
2086
2087
  }
2088
+ function isBareExecutableCommand(command) {
2089
+ if (!command) return false;
2090
+ if (command === "." || command === "..") return false;
2091
+ return !/[\\/]/.test(command);
2092
+ }
2093
+ function quotePosixShellArg(value) {
2094
+ return `'${value.replace(/'/g, `'\\''`)}'`;
2095
+ }
2096
+ async function resolveShellExecutablePath(command, cwd, env) {
2097
+ if (!isBareExecutableCommand(command)) return null;
2098
+ try {
2099
+ if (process.platform === "win32") {
2100
+ const { stdout: stdout$1 } = await execFileAsync("where", [command], {
2101
+ cwd,
2102
+ env,
2103
+ encoding: "utf8",
2104
+ timeout: 5e3
2105
+ });
2106
+ return stdout$1.split(/\r?\n/).map((line) => line.trim()).find((line) => line.length > 0) || null;
2107
+ }
2108
+ const { stdout } = await execFileAsync(env.SHELL || process.env.SHELL || "/bin/sh", ["-lc", `command -v -- ${quotePosixShellArg(command)}`], {
2109
+ cwd,
2110
+ env,
2111
+ encoding: "utf8",
2112
+ timeout: 5e3
2113
+ });
2114
+ return stdout.split("\n").map((line) => line.trim()).find((line) => line.startsWith("/")) || null;
2115
+ } catch {
2116
+ return null;
2117
+ }
2118
+ }
2119
+ async function expandCliRunnerCandidates(candidates, cwd, env) {
2120
+ const expanded = [];
2121
+ for (const candidate of candidates) {
2122
+ const [command, ...rest] = candidate.commandParts;
2123
+ if ((candidate.id === "openspec" || candidate.id === "configured" && command.trim().toLowerCase() === "openspec") && command) {
2124
+ const shellResolved = await resolveShellExecutablePath(command, cwd, env);
2125
+ if (shellResolved && shellResolved !== command) expanded.push({
2126
+ ...candidate,
2127
+ source: `${candidate.source} (shell)`,
2128
+ commandParts: [shellResolved, ...rest]
2129
+ });
2130
+ }
2131
+ expanded.push(candidate);
2132
+ }
2133
+ return expanded;
2134
+ }
2087
2135
  function getRunnerPriorityFromUserAgent(userAgent) {
2088
2136
  if (!userAgent) return null;
2089
2137
  if (userAgent.startsWith("bun")) return "bunx";
@@ -2189,8 +2237,9 @@ async function probeCliRunner(candidate, cwd, env) {
2189
2237
  });
2190
2238
  }
2191
2239
  async function resolveCliRunner(candidates, cwd, env) {
2240
+ const expandedCandidates = await expandCliRunnerCandidates(candidates, cwd, env);
2192
2241
  const attempts = [];
2193
- for (const candidate of candidates) {
2242
+ for (const candidate of expandedCandidates) {
2194
2243
  const attempt = await probeCliRunner(candidate, cwd, env);
2195
2244
  attempts.push(attempt);
2196
2245
  if (attempt.success) return {
@@ -2243,7 +2292,13 @@ async function fetchLatestVersion() {
2243
2292
  * 每次调用都会重新检测,不使用缓存。
2244
2293
  */
2245
2294
  async function sniffGlobalCli() {
2246
- const [localResult, latestVersion] = await Promise.all([execAsync("openspec --version", { timeout: 1e4 }).catch((err) => ({ error: err })), fetchLatestVersion()]);
2295
+ const env = createCleanCliEnv();
2296
+ const resolvedCommand = await resolveShellExecutablePath("openspec", process.cwd(), env) ?? "openspec";
2297
+ const [localResult, latestVersion] = await Promise.all([execFileAsync(resolvedCommand, ["--version"], {
2298
+ env,
2299
+ timeout: 1e4,
2300
+ encoding: "utf8"
2301
+ }).catch((err) => ({ error: err })), fetchLatestVersion()]);
2247
2302
  if ("error" in localResult) {
2248
2303
  const error = localResult.error instanceof Error ? localResult.error.message : String(localResult.error);
2249
2304
  if (error.includes("not found") || error.includes("ENOENT") || error.includes("not recognized")) return {
@@ -2289,6 +2344,8 @@ const TerminalConfigSchema = z.object({
2289
2344
  rendererEngine: z.string().default("xterm")
2290
2345
  });
2291
2346
  const DashboardConfigSchema = z.object({ trendPointLimit: z.number().int().min(20).max(500).default(100) });
2347
+ const DEFAULT_GIT_DIFF_EAGER_LINE_BUDGET = 1e3;
2348
+ const GitConfigSchema = z.object({ diffEagerLineBudget: z.number().int().min(0).max(2e5).default(DEFAULT_GIT_DIFF_EAGER_LINE_BUDGET) });
2292
2349
  const CodeEditorConfigSchema = z.object({ theme: CodeEditorThemeSchema.default("github") });
2293
2350
  /**
2294
2351
  * OpenSpecUI 配置 Schema
@@ -2304,7 +2361,8 @@ const OpenSpecUIConfigSchema = z.object({
2304
2361
  codeEditor: CodeEditorConfigSchema.default(CodeEditorConfigSchema.parse({})),
2305
2362
  appBaseUrl: z.string().default(""),
2306
2363
  terminal: TerminalConfigSchema.default(TerminalConfigSchema.parse({})),
2307
- dashboard: DashboardConfigSchema.default(DashboardConfigSchema.parse({}))
2364
+ dashboard: DashboardConfigSchema.default(DashboardConfigSchema.parse({})),
2365
+ git: GitConfigSchema.default(GitConfigSchema.parse({}))
2308
2366
  });
2309
2367
  /** 默认配置(静态,用于测试和类型) */
2310
2368
  const DEFAULT_CONFIG = {
@@ -2313,7 +2371,8 @@ const DEFAULT_CONFIG = {
2313
2371
  codeEditor: CodeEditorConfigSchema.parse({}),
2314
2372
  appBaseUrl: "",
2315
2373
  terminal: TerminalConfigSchema.parse({}),
2316
- dashboard: DashboardConfigSchema.parse({})
2374
+ dashboard: DashboardConfigSchema.parse({}),
2375
+ git: GitConfigSchema.parse({})
2317
2376
  };
2318
2377
  function areStringArraysEqual(left, right) {
2319
2378
  if (left === right) return true;
@@ -2364,6 +2423,9 @@ function toPersistedConfig(config, options = {}) {
2364
2423
  const dashboard = {};
2365
2424
  if (config.dashboard.trendPointLimit !== DEFAULT_CONFIG.dashboard.trendPointLimit) dashboard.trendPointLimit = config.dashboard.trendPointLimit;
2366
2425
  if (hasOwnEntries(dashboard)) persisted.dashboard = dashboard;
2426
+ const git = {};
2427
+ if (config.git.diffEagerLineBudget !== DEFAULT_CONFIG.git.diffEagerLineBudget) git.diffEagerLineBudget = config.git.diffEagerLineBudget;
2428
+ if (hasOwnEntries(git)) persisted.git = git;
2367
2429
  return persisted;
2368
2430
  }
2369
2431
  function isPersistedConfigEmpty(config) {
@@ -2450,6 +2512,10 @@ var ConfigManager = class {
2450
2512
  dashboard: {
2451
2513
  ...current.dashboard,
2452
2514
  ...config.dashboard
2515
+ },
2516
+ git: {
2517
+ ...current.git,
2518
+ ...config.git
2453
2519
  }
2454
2520
  });
2455
2521
  if (isPersistedConfigEmpty(persisted) && !fileExists) return;
@@ -4286,4 +4352,4 @@ const PtyServerMessageSchema = z.discriminatedUnion("type", [
4286
4352
  ]);
4287
4353
 
4288
4354
  //#endregion
4289
- export { AI_TOOLS, ApplyInstructionsSchema, ApplyTaskSchema, ArtifactInstructionsSchema, ArtifactStatusSchema, CODE_EDITOR_THEME_VALUES, ChangeFileSchema, ChangeSchema, ChangeStatusSchema, CliExecutor, CodeEditorThemeSchema, ConfigManager, DASHBOARD_METRIC_KEYS, DEFAULT_CONFIG, DashboardConfigSchema, DeltaOperationType, DeltaSchema, DeltaSpecSchema, DependencyInfoSchema, MarkdownParser, OFFICIAL_APP_BASE_URL, OpenSpecAdapter, OpenSpecUIConfigSchema, OpenSpecWatcher, OpsxKernel, ProjectWatcher, PtyAttachMessageSchema, PtyBufferResponseSchema, PtyClientMessageSchema, PtyCloseMessageSchema, PtyCreateMessageSchema, PtyCreatedResponseSchema, PtyErrorCodeSchema, PtyErrorResponseSchema, PtyExitResponseSchema, PtyInputMessageSchema, PtyListMessageSchema, PtyListResponseSchema, PtyOutputResponseSchema, PtyPlatformSchema, PtyResizeMessageSchema, PtyServerMessageSchema, PtyTitleResponseSchema, ReactiveContext, ReactiveState, RequirementSchema, SchemaArtifactSchema, SchemaDetailSchema, SchemaInfoSchema, SchemaResolutionSchema, SpecSchema, TOOL_WORKFLOW_TO_SKILL_DIR, TaskSchema, TemplatesSchema, TerminalConfigSchema, TerminalRendererEngineSchema, VIRTUAL_PROJECT_DIRNAME, Validator, acquireWatcher, buildCliRunnerCandidates, buildHostedLaunchUrl, buildHostedVersionManifestUrl, clearCache, closeAllProjectWatchers, closeAllWatchers, contextStorage, createCleanCliEnv, createFileChangeObservable, getActiveWatcherCount, getAllToolIds, getAllTools, getAvailableToolIds, getAvailableTools, getCacheSize, getConfiguredTools, getDefaultCliCommand, getDefaultCliCommandString, getDetectedProjectTools, getProjectWatcher, getToolById, getToolInitStates, getWatchedProjectDir, getWatcherRuntimeStatus, initWatcherPool, isGlobPattern, isHostedAppVersionManifest, isHostedBackendHealthResponse, isTerminalRendererEngine, isToolConfigured, isWatcherPoolInitialized, normalizeHostedAppBaseUrl, parseCliCommand, reactiveExists, reactiveReadDir, reactiveReadFile, reactiveStat, resolveHostedAppBaseUrl, resolveHostedChannelForVersion, sniffGlobalCli, toOpsxDisplayPath };
4355
+ export { AI_TOOLS, ApplyInstructionsSchema, ApplyTaskSchema, ArtifactInstructionsSchema, ArtifactStatusSchema, CODE_EDITOR_THEME_VALUES, ChangeFileSchema, ChangeSchema, ChangeStatusSchema, CliExecutor, CodeEditorThemeSchema, ConfigManager, DASHBOARD_METRIC_KEYS, DEFAULT_CONFIG, DEFAULT_GIT_DIFF_EAGER_LINE_BUDGET, DashboardConfigSchema, DeltaOperationType, DeltaSchema, DeltaSpecSchema, DependencyInfoSchema, GitConfigSchema, MarkdownParser, OFFICIAL_APP_BASE_URL, OpenSpecAdapter, OpenSpecUIConfigSchema, OpenSpecWatcher, OpsxKernel, ProjectWatcher, PtyAttachMessageSchema, PtyBufferResponseSchema, PtyClientMessageSchema, PtyCloseMessageSchema, PtyCreateMessageSchema, PtyCreatedResponseSchema, PtyErrorCodeSchema, PtyErrorResponseSchema, PtyExitResponseSchema, PtyInputMessageSchema, PtyListMessageSchema, PtyListResponseSchema, PtyOutputResponseSchema, PtyPlatformSchema, PtyResizeMessageSchema, PtyServerMessageSchema, PtyTitleResponseSchema, ReactiveContext, ReactiveState, RequirementSchema, SchemaArtifactSchema, SchemaDetailSchema, SchemaInfoSchema, SchemaResolutionSchema, SpecSchema, TOOL_WORKFLOW_TO_SKILL_DIR, TaskSchema, TemplatesSchema, TerminalConfigSchema, TerminalRendererEngineSchema, VIRTUAL_PROJECT_DIRNAME, Validator, acquireWatcher, buildCliRunnerCandidates, buildHostedLaunchUrl, buildHostedVersionManifestUrl, clearCache, closeAllProjectWatchers, closeAllWatchers, contextStorage, createCleanCliEnv, createFileChangeObservable, getActiveWatcherCount, getAllToolIds, getAllTools, getAvailableToolIds, getAvailableTools, getCacheSize, getConfiguredTools, getDefaultCliCommand, getDefaultCliCommandString, getDetectedProjectTools, getProjectWatcher, getToolById, getToolInitStates, getWatchedProjectDir, getWatcherRuntimeStatus, initWatcherPool, isGlobPattern, isHostedAppVersionManifest, isHostedBackendHealthResponse, isTerminalRendererEngine, isToolConfigured, isWatcherPoolInitialized, normalizeHostedAppBaseUrl, parseCliCommand, reactiveExists, reactiveReadDir, reactiveReadFile, reactiveStat, resolveHostedAppBaseUrl, resolveHostedChannelForVersion, sniffGlobalCli, toOpsxDisplayPath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openspecui/core",
3
- "version": "2.1.7",
3
+ "version": "2.3.0",
4
4
  "description": "Core OpenSpec adapter and parser",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -39,10 +39,10 @@
39
39
  "zod": "^3.24.1"
40
40
  },
41
41
  "devDependencies": {
42
- "@vitest/coverage-v8": "^2.1.9",
42
+ "@vitest/coverage-v8": "^4.1.0",
43
43
  "tsdown": "^0.16.6",
44
44
  "typescript": "^5.7.2",
45
- "vitest": "^2.1.8"
45
+ "vitest": "^4.1.0"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "typescript": "^5.0.0"