@openspecui/core 1.5.0 → 1.6.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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { n as toOpsxDisplayPath, t as VIRTUAL_PROJECT_DIRNAME } from "./opsx-display-path-RBULE8_G.mjs";
|
|
1
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
import { EventEmitter } from "events";
|
|
@@ -2077,15 +2078,19 @@ declare const SchemaResolutionSchema: z.ZodObject<{
|
|
|
2077
2078
|
name: z.ZodString;
|
|
2078
2079
|
source: z.ZodEnum<["project", "user", "package"]>;
|
|
2079
2080
|
path: z.ZodString;
|
|
2081
|
+
displayPath: z.ZodOptional<z.ZodString>;
|
|
2080
2082
|
shadows: z.ZodArray<z.ZodObject<{
|
|
2081
2083
|
source: z.ZodEnum<["project", "user", "package"]>;
|
|
2082
2084
|
path: z.ZodString;
|
|
2085
|
+
displayPath: z.ZodOptional<z.ZodString>;
|
|
2083
2086
|
}, "strip", z.ZodTypeAny, {
|
|
2084
2087
|
path: string;
|
|
2085
2088
|
source: "project" | "user" | "package";
|
|
2089
|
+
displayPath?: string | undefined;
|
|
2086
2090
|
}, {
|
|
2087
2091
|
path: string;
|
|
2088
2092
|
source: "project" | "user" | "package";
|
|
2093
|
+
displayPath?: string | undefined;
|
|
2089
2094
|
}>, "many">;
|
|
2090
2095
|
}, "strip", z.ZodTypeAny, {
|
|
2091
2096
|
path: string;
|
|
@@ -2094,7 +2099,9 @@ declare const SchemaResolutionSchema: z.ZodObject<{
|
|
|
2094
2099
|
shadows: {
|
|
2095
2100
|
path: string;
|
|
2096
2101
|
source: "project" | "user" | "package";
|
|
2102
|
+
displayPath?: string | undefined;
|
|
2097
2103
|
}[];
|
|
2104
|
+
displayPath?: string | undefined;
|
|
2098
2105
|
}, {
|
|
2099
2106
|
path: string;
|
|
2100
2107
|
name: string;
|
|
@@ -2102,18 +2109,23 @@ declare const SchemaResolutionSchema: z.ZodObject<{
|
|
|
2102
2109
|
shadows: {
|
|
2103
2110
|
path: string;
|
|
2104
2111
|
source: "project" | "user" | "package";
|
|
2112
|
+
displayPath?: string | undefined;
|
|
2105
2113
|
}[];
|
|
2114
|
+
displayPath?: string | undefined;
|
|
2106
2115
|
}>;
|
|
2107
2116
|
type SchemaResolution = z.infer<typeof SchemaResolutionSchema>;
|
|
2108
2117
|
declare const TemplatesSchema: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
2109
2118
|
path: z.ZodString;
|
|
2119
|
+
displayPath: z.ZodOptional<z.ZodString>;
|
|
2110
2120
|
source: z.ZodEnum<["project", "user", "package"]>;
|
|
2111
2121
|
}, "strip", z.ZodTypeAny, {
|
|
2112
2122
|
path: string;
|
|
2113
2123
|
source: "project" | "user" | "package";
|
|
2124
|
+
displayPath?: string | undefined;
|
|
2114
2125
|
}, {
|
|
2115
2126
|
path: string;
|
|
2116
2127
|
source: "project" | "user" | "package";
|
|
2128
|
+
displayPath?: string | undefined;
|
|
2117
2129
|
}>>;
|
|
2118
2130
|
type TemplatesMap = z.infer<typeof TemplatesSchema>;
|
|
2119
2131
|
declare const SchemaArtifactSchema: z.ZodObject<{
|
|
@@ -2218,6 +2230,23 @@ interface ExportSnapshot {
|
|
|
2218
2230
|
changesCount: number;
|
|
2219
2231
|
archivesCount: number;
|
|
2220
2232
|
};
|
|
2233
|
+
/** Git snapshot used by static dashboard */
|
|
2234
|
+
git?: {
|
|
2235
|
+
defaultBranch: string;
|
|
2236
|
+
repositoryUrl: string | null;
|
|
2237
|
+
latestCommitTs: number | null;
|
|
2238
|
+
recentCommits: Array<{
|
|
2239
|
+
hash: string;
|
|
2240
|
+
title: string;
|
|
2241
|
+
committedAt: number;
|
|
2242
|
+
relatedChanges: string[];
|
|
2243
|
+
diff: {
|
|
2244
|
+
files: number;
|
|
2245
|
+
insertions: number;
|
|
2246
|
+
deletions: number;
|
|
2247
|
+
};
|
|
2248
|
+
}>;
|
|
2249
|
+
};
|
|
2221
2250
|
/** OpenSpecUI runtime config captured during export */
|
|
2222
2251
|
config?: OpenSpecUIConfig;
|
|
2223
2252
|
/** All specs with parsed content */
|
|
@@ -2289,8 +2318,15 @@ interface ExportSnapshot {
|
|
|
2289
2318
|
configYaml?: string;
|
|
2290
2319
|
schemas: SchemaInfo[];
|
|
2291
2320
|
schemaDetails: Record<string, SchemaDetail>;
|
|
2321
|
+
schemaYamls?: Record<string, string>;
|
|
2292
2322
|
schemaResolutions: Record<string, SchemaResolution>;
|
|
2293
2323
|
templates: Record<string, TemplatesMap>;
|
|
2324
|
+
templateContents?: Record<string, Record<string, {
|
|
2325
|
+
content: string | null;
|
|
2326
|
+
path: string;
|
|
2327
|
+
displayPath?: string;
|
|
2328
|
+
source: 'project' | 'user' | 'package';
|
|
2329
|
+
}>>;
|
|
2294
2330
|
changeMetadata: Record<string, string | null>;
|
|
2295
2331
|
};
|
|
2296
2332
|
}
|
|
@@ -2299,6 +2335,7 @@ interface ExportSnapshot {
|
|
|
2299
2335
|
type TemplateContentMap = Record<string, {
|
|
2300
2336
|
content: string | null;
|
|
2301
2337
|
path: string;
|
|
2338
|
+
displayPath?: string;
|
|
2302
2339
|
source: TemplatesMap[string]['source'];
|
|
2303
2340
|
}>;
|
|
2304
2341
|
interface GlobArtifactFile {
|
|
@@ -2890,4 +2927,4 @@ type PtyServerMessage = z.infer<typeof PtyServerMessageSchema>;
|
|
|
2890
2927
|
type PtySessionInfo = z.infer<typeof PtySessionInfoSchema>;
|
|
2891
2928
|
type PtyPlatform = z.infer<typeof PtyPlatformSchema>;
|
|
2892
2929
|
//#endregion
|
|
2893
|
-
export { type AIToolOption, AI_TOOLS, type ApplyInstructions, ApplyInstructionsSchema, type ApplyTask, ApplyTaskSchema, type ArchiveMeta, type ArtifactInstructions, ArtifactInstructionsSchema, type ArtifactStatus, ArtifactStatusSchema, type Change, type ChangeFile, ChangeFileSchema, type ChangeMeta, ChangeSchema, type ChangeStatus, ChangeStatusSchema, CliExecutor, type CliResult, type CliRunnerAttempt, type CliSniffResult, type CliStreamEvent, 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, MarkdownParser, 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, type Task, TaskSchema, type TemplateContentMap, type TemplatesMap, TemplatesSchema, type TerminalConfig, TerminalConfigSchema, type TerminalRendererEngine, TerminalRendererEngineSchema, type ToolConfig, type ValidationIssue, type ValidationResult, Validator, type WatchEvent, type WatchEventType, type WatcherRuntimeStatus, acquireWatcher, buildCliRunnerCandidates, clearCache, closeAllProjectWatchers, closeAllWatchers, contextStorage, createCleanCliEnv, createFileChangeObservable, getActiveWatcherCount, getAllToolIds, getAllTools, getAvailableToolIds, getAvailableTools, getCacheSize, getConfiguredTools, getDefaultCliCommand, getDefaultCliCommandString, getProjectWatcher, getToolById, getWatchedProjectDir, getWatcherRuntimeStatus, initWatcherPool, isGlobPattern, isTerminalRendererEngine, isToolConfigured, isWatcherPoolInitialized, parseCliCommand, reactiveExists, reactiveReadDir, reactiveReadFile, reactiveStat, sniffGlobalCli };
|
|
2930
|
+
export { type AIToolOption, AI_TOOLS, type ApplyInstructions, ApplyInstructionsSchema, type ApplyTask, ApplyTaskSchema, type ArchiveMeta, type ArtifactInstructions, ArtifactInstructionsSchema, type ArtifactStatus, ArtifactStatusSchema, type Change, type ChangeFile, ChangeFileSchema, type ChangeMeta, ChangeSchema, type ChangeStatus, ChangeStatusSchema, CliExecutor, type CliResult, type CliRunnerAttempt, type CliSniffResult, type CliStreamEvent, 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, MarkdownParser, 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, type Task, TaskSchema, type TemplateContentMap, type TemplatesMap, TemplatesSchema, type TerminalConfig, TerminalConfigSchema, type TerminalRendererEngine, TerminalRendererEngineSchema, type ToolConfig, VIRTUAL_PROJECT_DIRNAME, type ValidationIssue, type ValidationResult, Validator, type WatchEvent, type WatchEventType, type WatcherRuntimeStatus, acquireWatcher, buildCliRunnerCandidates, clearCache, closeAllProjectWatchers, closeAllWatchers, contextStorage, createCleanCliEnv, createFileChangeObservable, getActiveWatcherCount, getAllToolIds, getAllTools, getAvailableToolIds, getAvailableTools, getCacheSize, getConfiguredTools, getDefaultCliCommand, getDefaultCliCommandString, getProjectWatcher, getToolById, getWatchedProjectDir, getWatcherRuntimeStatus, initWatcherPool, isGlobPattern, isTerminalRendererEngine, isToolConfigured, isWatcherPoolInitialized, parseCliCommand, reactiveExists, reactiveReadDir, reactiveReadFile, reactiveStat, sniffGlobalCli, toOpsxDisplayPath };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { n as toOpsxDisplayPath, t as VIRTUAL_PROJECT_DIRNAME } from "./opsx-display-path-DYIjMsbM.mjs";
|
|
1
2
|
import { mkdir, readFile, rename, writeFile } from "fs/promises";
|
|
2
3
|
import { dirname, join } from "path";
|
|
3
4
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
@@ -3226,17 +3227,20 @@ const SchemaResolutionSchema = z.object({
|
|
|
3226
3227
|
"package"
|
|
3227
3228
|
]),
|
|
3228
3229
|
path: z.string(),
|
|
3230
|
+
displayPath: z.string().optional(),
|
|
3229
3231
|
shadows: z.array(z.object({
|
|
3230
3232
|
source: z.enum([
|
|
3231
3233
|
"project",
|
|
3232
3234
|
"user",
|
|
3233
3235
|
"package"
|
|
3234
3236
|
]),
|
|
3235
|
-
path: z.string()
|
|
3237
|
+
path: z.string(),
|
|
3238
|
+
displayPath: z.string().optional()
|
|
3236
3239
|
}))
|
|
3237
3240
|
});
|
|
3238
3241
|
const TemplatesSchema = z.record(z.object({
|
|
3239
3242
|
path: z.string(),
|
|
3243
|
+
displayPath: z.string().optional(),
|
|
3240
3244
|
source: z.enum([
|
|
3241
3245
|
"project",
|
|
3242
3246
|
"user",
|
|
@@ -3280,6 +3284,12 @@ function parseCliJson(raw, schema, label) {
|
|
|
3280
3284
|
function toRelativePath(root, absolutePath) {
|
|
3281
3285
|
return relative(root, absolutePath).split(sep).join("/");
|
|
3282
3286
|
}
|
|
3287
|
+
function isAbsoluteFsPath(path) {
|
|
3288
|
+
return path.startsWith("/") || /^[A-Za-z]:\//.test(path);
|
|
3289
|
+
}
|
|
3290
|
+
function toAbsoluteProjectPath(projectDir, path) {
|
|
3291
|
+
return isAbsoluteFsPath(path.replace(/\\/g, "/")) ? path : resolve(projectDir, path);
|
|
3292
|
+
}
|
|
3283
3293
|
async function readEntriesUnderRoot(root) {
|
|
3284
3294
|
if (!(await reactiveStat(root))?.isDirectory) return [];
|
|
3285
3295
|
const collectEntries = async (dir) => {
|
|
@@ -3718,7 +3728,21 @@ var OpsxKernel = class {
|
|
|
3718
3728
|
await touchOpsxProjectDeps(this.projectDir);
|
|
3719
3729
|
const result = await this.cliExecutor.schemaWhich(name);
|
|
3720
3730
|
if (!result.success) throw new Error(result.stderr || `openspec schema which failed (exit ${result.exitCode ?? "null"})`);
|
|
3721
|
-
|
|
3731
|
+
const parsed = parseCliJson(result.stdout, SchemaResolutionSchema, "openspec schema which");
|
|
3732
|
+
return {
|
|
3733
|
+
...parsed,
|
|
3734
|
+
displayPath: toOpsxDisplayPath(parsed.path, {
|
|
3735
|
+
source: parsed.source,
|
|
3736
|
+
projectDir: this.projectDir
|
|
3737
|
+
}),
|
|
3738
|
+
shadows: parsed.shadows.map((shadow) => ({
|
|
3739
|
+
...shadow,
|
|
3740
|
+
displayPath: toOpsxDisplayPath(shadow.path, {
|
|
3741
|
+
source: shadow.source,
|
|
3742
|
+
projectDir: this.projectDir
|
|
3743
|
+
})
|
|
3744
|
+
}))
|
|
3745
|
+
};
|
|
3722
3746
|
}
|
|
3723
3747
|
async fetchSchemaDetail(name) {
|
|
3724
3748
|
await touchOpsxProjectDeps(this.projectDir);
|
|
@@ -3742,7 +3766,15 @@ var OpsxKernel = class {
|
|
|
3742
3766
|
await touchOpsxProjectDeps(this.projectDir);
|
|
3743
3767
|
const result = await this.cliExecutor.templates(schema);
|
|
3744
3768
|
if (!result.success) throw new Error(result.stderr || `openspec templates failed (exit ${result.exitCode ?? "null"})`);
|
|
3745
|
-
|
|
3769
|
+
const templates = parseCliJson(result.stdout, TemplatesSchema, "openspec templates");
|
|
3770
|
+
return Object.fromEntries(Object.entries(templates).map(([artifactId, info]) => [artifactId, {
|
|
3771
|
+
...info,
|
|
3772
|
+
path: toAbsoluteProjectPath(this.projectDir, info.path),
|
|
3773
|
+
displayPath: toOpsxDisplayPath(info.path, {
|
|
3774
|
+
source: info.source,
|
|
3775
|
+
projectDir: this.projectDir
|
|
3776
|
+
})
|
|
3777
|
+
}]));
|
|
3746
3778
|
}
|
|
3747
3779
|
async fetchTemplateContents(schema) {
|
|
3748
3780
|
await this.ensureTemplates(schema);
|
|
@@ -3751,6 +3783,10 @@ var OpsxKernel = class {
|
|
|
3751
3783
|
return [artifactId, {
|
|
3752
3784
|
content: await reactiveReadFile(info.path),
|
|
3753
3785
|
path: info.path,
|
|
3786
|
+
displayPath: info.displayPath ?? toOpsxDisplayPath(info.path, {
|
|
3787
|
+
source: info.source,
|
|
3788
|
+
projectDir: this.projectDir
|
|
3789
|
+
}),
|
|
3754
3790
|
source: info.source
|
|
3755
3791
|
}];
|
|
3756
3792
|
}));
|
|
@@ -3999,4 +4035,4 @@ const PtyServerMessageSchema = z.discriminatedUnion("type", [
|
|
|
3999
4035
|
]);
|
|
4000
4036
|
|
|
4001
4037
|
//#endregion
|
|
4002
|
-
export { AI_TOOLS, ApplyInstructionsSchema, ApplyTaskSchema, ArtifactInstructionsSchema, ArtifactStatusSchema, ChangeFileSchema, ChangeSchema, ChangeStatusSchema, CliExecutor, ConfigManager, DASHBOARD_METRIC_KEYS, DEFAULT_CONFIG, DashboardConfigSchema, DeltaOperationType, DeltaSchema, DeltaSpecSchema, DependencyInfoSchema, MarkdownParser, 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, TaskSchema, TemplatesSchema, TerminalConfigSchema, TerminalRendererEngineSchema, Validator, acquireWatcher, buildCliRunnerCandidates, clearCache, closeAllProjectWatchers, closeAllWatchers, contextStorage, createCleanCliEnv, createFileChangeObservable, getActiveWatcherCount, getAllToolIds, getAllTools, getAvailableToolIds, getAvailableTools, getCacheSize, getConfiguredTools, getDefaultCliCommand, getDefaultCliCommandString, getProjectWatcher, getToolById, getWatchedProjectDir, getWatcherRuntimeStatus, initWatcherPool, isGlobPattern, isTerminalRendererEngine, isToolConfigured, isWatcherPoolInitialized, parseCliCommand, reactiveExists, reactiveReadDir, reactiveReadFile, reactiveStat, sniffGlobalCli };
|
|
4038
|
+
export { AI_TOOLS, ApplyInstructionsSchema, ApplyTaskSchema, ArtifactInstructionsSchema, ArtifactStatusSchema, ChangeFileSchema, ChangeSchema, ChangeStatusSchema, CliExecutor, ConfigManager, DASHBOARD_METRIC_KEYS, DEFAULT_CONFIG, DashboardConfigSchema, DeltaOperationType, DeltaSchema, DeltaSpecSchema, DependencyInfoSchema, MarkdownParser, 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, TaskSchema, TemplatesSchema, TerminalConfigSchema, TerminalRendererEngineSchema, VIRTUAL_PROJECT_DIRNAME, Validator, acquireWatcher, buildCliRunnerCandidates, clearCache, closeAllProjectWatchers, closeAllWatchers, contextStorage, createCleanCliEnv, createFileChangeObservable, getActiveWatcherCount, getAllToolIds, getAllTools, getAvailableToolIds, getAvailableTools, getCacheSize, getConfiguredTools, getDefaultCliCommand, getDefaultCliCommandString, getProjectWatcher, getToolById, getWatchedProjectDir, getWatcherRuntimeStatus, initWatcherPool, isGlobPattern, isTerminalRendererEngine, isToolConfigured, isWatcherPoolInitialized, parseCliCommand, reactiveExists, reactiveReadDir, reactiveReadFile, reactiveStat, sniffGlobalCli, toOpsxDisplayPath };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
//#region src/opsx-display-path.ts
|
|
2
|
+
const VIRTUAL_PROJECT_DIRNAME = "project";
|
|
3
|
+
const WINDOWS_DRIVE_PREFIX = /^[A-Za-z]:\//;
|
|
4
|
+
function normalizeFsPath(path) {
|
|
5
|
+
return path.replace(/\\/g, "/").replace(/\/+$/g, "");
|
|
6
|
+
}
|
|
7
|
+
function isAbsolutePath(path) {
|
|
8
|
+
return path.startsWith("/") || WINDOWS_DRIVE_PREFIX.test(path);
|
|
9
|
+
}
|
|
10
|
+
function stripRelativePrefix(path) {
|
|
11
|
+
return path.replace(/^\.?\//, "");
|
|
12
|
+
}
|
|
13
|
+
function splitSegments(path) {
|
|
14
|
+
return normalizeFsPath(path).split("/").filter(Boolean);
|
|
15
|
+
}
|
|
16
|
+
function toNpmSpecifier(path) {
|
|
17
|
+
const normalized = normalizeFsPath(path);
|
|
18
|
+
const match = /(?:^|\/)node_modules\/(?:\.pnpm\/[^/]+\/node_modules\/)?(@[^/]+\/[^/]+|[^/]+)(\/.*)?/.exec(normalized);
|
|
19
|
+
const pkgName = match?.[1];
|
|
20
|
+
if (!pkgName) return null;
|
|
21
|
+
return `npm:${pkgName}${match[2] ?? ""}`;
|
|
22
|
+
}
|
|
23
|
+
function toVirtualProjectPath(path) {
|
|
24
|
+
return `${VIRTUAL_PROJECT_DIRNAME}:${stripRelativePrefix(path)}`;
|
|
25
|
+
}
|
|
26
|
+
function isPathInside(root, target) {
|
|
27
|
+
const normalizedRoot = normalizeFsPath(root);
|
|
28
|
+
const normalizedTarget = normalizeFsPath(target);
|
|
29
|
+
const rootLower = normalizedRoot.toLowerCase();
|
|
30
|
+
const targetLower = normalizedTarget.toLowerCase();
|
|
31
|
+
return targetLower === rootLower || targetLower.startsWith(`${rootLower}/`);
|
|
32
|
+
}
|
|
33
|
+
function toRelativeFromRoot(root, target) {
|
|
34
|
+
const rootSegments = splitSegments(root);
|
|
35
|
+
const targetSegments = splitSegments(target);
|
|
36
|
+
let index = 0;
|
|
37
|
+
while (index < rootSegments.length && index < targetSegments.length) {
|
|
38
|
+
if (rootSegments[index]?.toLowerCase() !== targetSegments[index]?.toLowerCase()) break;
|
|
39
|
+
index += 1;
|
|
40
|
+
}
|
|
41
|
+
return targetSegments.slice(index).join("/");
|
|
42
|
+
}
|
|
43
|
+
function findOpspecSlice(path) {
|
|
44
|
+
const segments = splitSegments(path);
|
|
45
|
+
const idx = segments.lastIndexOf("openspec");
|
|
46
|
+
if (idx < 0) return null;
|
|
47
|
+
return segments.slice(idx).join("/");
|
|
48
|
+
}
|
|
49
|
+
function toOpsxDisplayPath(absoluteOrRelativePath, options) {
|
|
50
|
+
const normalized = normalizeFsPath(absoluteOrRelativePath);
|
|
51
|
+
const npmSpecifier = toNpmSpecifier(normalized);
|
|
52
|
+
if (options?.source === "package" || npmSpecifier) {
|
|
53
|
+
if (npmSpecifier) return npmSpecifier;
|
|
54
|
+
}
|
|
55
|
+
if (!isAbsolutePath(normalized)) return toVirtualProjectPath(normalized);
|
|
56
|
+
if (options?.projectDir && isPathInside(options.projectDir, normalized)) return toVirtualProjectPath(toRelativeFromRoot(options.projectDir, normalized));
|
|
57
|
+
const openspecSlice = findOpspecSlice(normalized);
|
|
58
|
+
if (openspecSlice) return toVirtualProjectPath(openspecSlice);
|
|
59
|
+
return toVirtualProjectPath(splitSegments(normalized).slice(-4).join("/"));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
//#endregion
|
|
63
|
+
export { toOpsxDisplayPath as n, VIRTUAL_PROJECT_DIRNAME as t };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region src/opsx-display-path.d.ts
|
|
2
|
+
declare const VIRTUAL_PROJECT_DIRNAME = "project";
|
|
3
|
+
declare function toOpsxDisplayPath(absoluteOrRelativePath: string, options?: {
|
|
4
|
+
source?: 'project' | 'user' | 'package';
|
|
5
|
+
projectDir?: string;
|
|
6
|
+
}): string;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { toOpsxDisplayPath as n, VIRTUAL_PROJECT_DIRNAME as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openspecui/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "Core OpenSpec adapter and parser",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
".": {
|
|
10
10
|
"import": "./dist/index.mjs",
|
|
11
11
|
"types": "./dist/index.d.mts"
|
|
12
|
+
},
|
|
13
|
+
"./opsx-display-path": {
|
|
14
|
+
"import": "./dist/opsx-display-path.mjs",
|
|
15
|
+
"types": "./dist/opsx-display-path.d.mts"
|
|
12
16
|
}
|
|
13
17
|
},
|
|
14
18
|
"files": [
|
|
@@ -29,8 +33,8 @@
|
|
|
29
33
|
"typescript": "^5.0.0"
|
|
30
34
|
},
|
|
31
35
|
"scripts": {
|
|
32
|
-
"build": "tsdown src/index.ts --format esm --dts",
|
|
33
|
-
"dev": "tsdown src/index.ts --format esm --dts --watch",
|
|
36
|
+
"build": "tsdown src/index.ts src/opsx-display-path.ts --format esm --dts",
|
|
37
|
+
"dev": "tsdown src/index.ts src/opsx-display-path.ts --format esm --dts --watch",
|
|
34
38
|
"test": "vitest run",
|
|
35
39
|
"test:watch": "vitest",
|
|
36
40
|
"typecheck": "tsc --noEmit"
|