@openspecui/core 4.1.0 → 6.0.0-beta.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 (116) hide show
  1. package/dist/cli-projection-DxnVGm2B.d.mts +789 -0
  2. package/dist/cli-projection-vO3-FJg5.mjs +161 -0
  3. package/dist/cli-projection.d.mts +6 -0
  4. package/dist/cli-projection.mjs +4 -0
  5. package/dist/command-result-fkH3Ekdz.d.mts +8477 -0
  6. package/dist/common-D8YUK9dA.mjs +57 -0
  7. package/dist/dashboard-summary-transport-CQ4is5_e.d.mts +66227 -0
  8. package/dist/dashboard-summary-transport-D2VBAIxg.mjs +175 -0
  9. package/dist/dashboard-summary-transport.d.mts +25 -0
  10. package/dist/dashboard-summary-transport.mjs +6 -0
  11. package/dist/{document-translation-D4YK18I3.mjs → document-translation-CeJFGMoy.mjs} +1 -1
  12. package/dist/{document-translation-CIPGsZD8.d.mts → document-translation-D50BnvVh.d.mts} +100 -100
  13. package/dist/document-translation.d.mts +1 -1
  14. package/dist/document-translation.mjs +2 -2
  15. package/dist/{hosted-app-CzMRiEgY.mjs → hosted-app-BPU4OR41.mjs} +31 -9
  16. package/dist/hosted-app.d.mts +25 -2
  17. package/dist/hosted-app.mjs +7 -2
  18. package/dist/hosted-contract-CcRnb51e.mjs +234 -0
  19. package/dist/hosted-contract.d.mts +25 -0
  20. package/dist/hosted-contract.mjs +7 -0
  21. package/dist/index.d.mts +25 -2686
  22. package/dist/index.mjs +2114 -1098
  23. package/dist/{local-download-profiles-B30HrSO2.d.mts → local-download-profiles-BL_rtlVM.d.mts} +1 -1
  24. package/dist/local-download-profiles.d.mts +2 -2
  25. package/dist/local-download-profiles.mjs +1 -1
  26. package/dist/markdown-facts.d.mts +1 -1
  27. package/dist/markdown-facts.mjs +1 -1
  28. package/dist/{markdown-reading-CgXuXp6s.d.mts → markdown-reading-LUdqfbxH.d.mts} +1 -1
  29. package/dist/{markdown-reading-DdcB7run.mjs → markdown-reading-mG4OAbDO.mjs} +1 -1
  30. package/dist/markdown-reading.d.mts +2 -2
  31. package/dist/markdown-reading.mjs +2 -2
  32. package/dist/{notifications-AKAcmeKT.mjs → notifications-C2bxAzX_.mjs} +13 -2
  33. package/dist/{notifications-HYH-lklF.d.mts → notifications-CgJlLgLO.d.mts} +34 -8
  34. package/dist/notifications.d.mts +2 -2
  35. package/dist/notifications.mjs +3 -3
  36. package/dist/{openspec-annotations-CeXd0JIZ.d.mts → openspec-annotations-C58Aoi-V.d.mts} +2 -2
  37. package/dist/{openspec-annotations-D_6Pz7k4.mjs → openspec-annotations-DCfqBMal.mjs} +2 -2
  38. package/dist/openspec-annotations.d.mts +3 -3
  39. package/dist/openspec-annotations.mjs +3 -3
  40. package/dist/openspec-compat.d.mts +18 -11
  41. package/dist/openspec-compat.mjs +22 -14
  42. package/dist/{openspec-projection-B8s-KWQ7.mjs → openspec-projection-DCgToo0Q.mjs} +2 -2
  43. package/dist/{openspec-projection-BphzrwYP.d.mts → openspec-projection-RohNZI4p.d.mts} +3 -3
  44. package/dist/openspec-projection.d.mts +5 -5
  45. package/dist/openspec-projection.mjs +4 -4
  46. package/dist/opsx-display-path.d.mts +1 -1
  47. package/dist/opsx-display-path.mjs +1 -1
  48. package/dist/{opsx-entity-CFUCqev8.d.mts → opsx-entity-D7kDQsze.d.mts} +2 -2
  49. package/dist/opsx-entity.d.mts +7 -3
  50. package/dist/opsx-entity.mjs +1 -1
  51. package/dist/{opsx-schema-detail-DXKXqMQa.d.mts → opsx-schema-detail-BxDXEwDY.d.mts} +2 -2
  52. package/dist/opsx-schema-detail.d.mts +8 -4
  53. package/dist/opsx-schema-detail.mjs +1 -1
  54. package/dist/opsx-types-BJ8AjhrS.d.mts +3642 -0
  55. package/dist/opsx-workflows-BvnJqjfL.d.mts +36 -0
  56. package/dist/opsx-workflows-Ccc6U7IR.mjs +89 -0
  57. package/dist/opsx-workflows.d.mts +2 -0
  58. package/dist/opsx-workflows.mjs +3 -0
  59. package/dist/planning-cli-projection-DIRxeq2H.mjs +421 -0
  60. package/dist/planning-cli-projection.d.mts +25 -0
  61. package/dist/planning-cli-projection.mjs +9 -0
  62. package/dist/schemas-BFroDdOC.mjs +287 -0
  63. package/dist/{schemas-CNKCVc7m.d.mts → schemas-DS-JqAJ2.d.mts} +498 -52
  64. package/dist/{sounds-J6z7o4mt.d.mts → sounds-qhRgCy0F.d.mts} +5 -5
  65. package/dist/sounds.d.mts +1 -1
  66. package/dist/sounds.mjs +1 -1
  67. package/dist/spec-catalog-ZGuiZ4CE.mjs +901 -0
  68. package/dist/spec-catalog.d.mts +25 -0
  69. package/dist/spec-catalog.mjs +6 -0
  70. package/dist/store-mutation-protocol-5tfs-RmD.d.mts +727 -0
  71. package/dist/store-mutation-protocol-CSwD-xPO.mjs +63 -0
  72. package/dist/store-mutation-protocol.d.mts +2 -0
  73. package/dist/store-mutation-protocol.mjs +4 -0
  74. package/dist/{store-types-Cu41QSww.mjs → store-types-DlX1REBg.mjs} +39 -18
  75. package/dist/{store-types-BiE-Ey--.d.mts → store-types-b554wAQJ.d.mts} +22 -12
  76. package/dist/store-types.d.mts +6 -2
  77. package/dist/store-types.mjs +2 -2
  78. package/dist/task-progress-B_IWVXjA.mjs +216 -0
  79. package/dist/task-progress.d.mts +7 -4
  80. package/dist/task-progress.mjs +3 -3
  81. package/dist/{terminal-audio-TBoU2jSK.mjs → terminal-audio-d6KItUeJ.mjs} +1 -1
  82. package/dist/{terminal-audio-BeUXlQgj.d.mts → terminal-audio-tXDm_EDe.d.mts} +2 -2
  83. package/dist/terminal-audio.d.mts +2 -2
  84. package/dist/terminal-audio.mjs +2 -2
  85. package/dist/terminal-control.d.mts +2 -2
  86. package/dist/terminal-control.mjs +1 -1
  87. package/dist/{terminal-invocation-ClVh0HeM.d.mts → terminal-invocation-BOvxThym.d.mts} +203 -84
  88. package/dist/terminal-invocation.d.mts +1 -1
  89. package/dist/terminal-invocation.mjs +1 -1
  90. package/dist/terminal-theme.d.mts +1 -1
  91. package/dist/terminal-theme.mjs +1 -1
  92. package/dist/translation-language-pair.d.mts +1 -1
  93. package/dist/translation-language-pair.mjs +1 -1
  94. package/dist/{translator-D6t_LEVN.d.mts → translator-NKv1wo3o.d.mts} +208 -208
  95. package/dist/translator.d.mts +1 -1
  96. package/dist/translator.mjs +1 -1
  97. package/package.json +55 -7
  98. package/dist/hosted-app-DHs94gIR.d.mts +0 -43
  99. package/dist/opsx-types-2rgsQHsB.d.mts +0 -402
  100. package/dist/task-progress-BHn4bCoD.d.mts +0 -24
  101. package/dist/task-progress-DhHYHnTv.mjs +0 -70
  102. /package/dist/{local-download-profiles-kpNEcdF_.mjs → local-download-profiles-odzOdf96.mjs} +0 -0
  103. /package/dist/{markdown-facts-BBCTe_qq.mjs → markdown-facts-BUqLvFRf.mjs} +0 -0
  104. /package/dist/{markdown-facts-Dk7FKaaT.d.mts → markdown-facts-CCw3QdbM.d.mts} +0 -0
  105. /package/dist/{opsx-display-path-CUCOrHcM.mjs → opsx-display-path-D13XV20v.mjs} +0 -0
  106. /package/dist/{opsx-display-path-cIMKa1aw.d.mts → opsx-display-path-RXS5JTbV.d.mts} +0 -0
  107. /package/dist/{opsx-entity-c7m5CbgU.mjs → opsx-entity-Cn_Zu1J3.mjs} +0 -0
  108. /package/dist/{opsx-schema-detail-BH82X6aU.mjs → opsx-schema-detail-Beis4Ba2.mjs} +0 -0
  109. /package/dist/{sounds-CB3ubSnj.mjs → sounds-NXwveBqq.mjs} +0 -0
  110. /package/dist/{terminal-control-VpTuh17B.mjs → terminal-control-BSAlOTs8.mjs} +0 -0
  111. /package/dist/{terminal-invocation-C2MCNBhK.mjs → terminal-invocation-0p-j2eSP.mjs} +0 -0
  112. /package/dist/{terminal-theme-cevliJw2.mjs → terminal-theme-B8iRttTR.mjs} +0 -0
  113. /package/dist/{terminal-theme-hvQjTsNh.d.mts → terminal-theme-m3MSGJ7U.d.mts} +0 -0
  114. /package/dist/{translation-language-pair-DZ_WNp_M.mjs → translation-language-pair-Bbhk-LAC.mjs} +0 -0
  115. /package/dist/{translation-language-pair-DmaOfHqD.d.mts → translation-language-pair-C18GPATW.d.mts} +0 -0
  116. /package/dist/{translator-DbUT1Ayn.mjs → translator-Cjtv4tya.mjs} +0 -0
@@ -0,0 +1,287 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/file-preview.ts
4
+ const MIME_BY_EXTENSION = new Map([
5
+ [".md", "text/markdown"],
6
+ [".markdown", "text/markdown"],
7
+ [".mdown", "text/markdown"],
8
+ [".mkd", "text/markdown"],
9
+ [".txt", "text/plain"],
10
+ [".log", "text/plain"],
11
+ [".yaml", "application/yaml"],
12
+ [".yml", "application/yaml"],
13
+ [".json", "application/json"],
14
+ [".jsonc", "application/json"],
15
+ [".toml", "application/toml"],
16
+ [".ini", "text/plain"],
17
+ [".cfg", "text/plain"],
18
+ [".conf", "text/plain"],
19
+ [".html", "text/html"],
20
+ [".htm", "text/html"],
21
+ [".svg", "image/svg+xml"],
22
+ [".png", "image/png"],
23
+ [".jpg", "image/jpeg"],
24
+ [".jpeg", "image/jpeg"],
25
+ [".gif", "image/gif"],
26
+ [".webp", "image/webp"],
27
+ [".avif", "image/avif"],
28
+ [".bmp", "image/bmp"],
29
+ [".mp3", "audio/mpeg"],
30
+ [".wav", "audio/wav"],
31
+ [".ogg", "audio/ogg"],
32
+ [".oga", "audio/ogg"],
33
+ [".m4a", "audio/mp4"],
34
+ [".aac", "audio/aac"],
35
+ [".flac", "audio/flac"],
36
+ [".mp4", "video/mp4"],
37
+ [".m4v", "video/mp4"],
38
+ [".webm", "video/webm"],
39
+ [".mov", "video/quicktime"],
40
+ [".mkv", "video/x-matroska"],
41
+ [".ogv", "video/ogg"],
42
+ [".pdf", "application/pdf"],
43
+ [".js", "text/javascript"],
44
+ [".jsx", "text/javascript"],
45
+ [".ts", "text/typescript"],
46
+ [".tsx", "text/typescript"],
47
+ [".css", "text/css"],
48
+ [".sh", "text/plain"],
49
+ [".py", "text/plain"],
50
+ [".rs", "text/plain"],
51
+ [".go", "text/plain"],
52
+ [".java", "text/plain"],
53
+ [".c", "text/plain"],
54
+ [".cc", "text/plain"],
55
+ [".cpp", "text/plain"],
56
+ [".h", "text/plain"],
57
+ [".hpp", "text/plain"]
58
+ ]);
59
+ const TEXT_MIME_PREFIXES = ["text/"];
60
+ const TEXT_MIME_VALUES = new Set([
61
+ "application/json",
62
+ "application/yaml",
63
+ "application/toml",
64
+ "application/xml",
65
+ "image/svg+xml"
66
+ ]);
67
+ const FILE_PREVIEW_KINDS = [
68
+ "markdown",
69
+ "html",
70
+ "image",
71
+ "audio",
72
+ "video",
73
+ "pdf",
74
+ "text",
75
+ "none"
76
+ ];
77
+ function getExtension(path) {
78
+ const normalized = path.replace(/\\/g, "/");
79
+ const name = normalized.split("/").pop() ?? normalized;
80
+ const dotIndex = name.lastIndexOf(".");
81
+ if (dotIndex < 0) return "";
82
+ return name.slice(dotIndex).toLowerCase();
83
+ }
84
+ function inferFileMime(path) {
85
+ return MIME_BY_EXTENSION.get(getExtension(path)) ?? null;
86
+ }
87
+ function inferFilePreviewKind(path, mime) {
88
+ const resolvedMime = mime ?? inferFileMime(path);
89
+ if (!resolvedMime) return "none";
90
+ if (resolvedMime === "text/markdown") return "markdown";
91
+ if (resolvedMime === "text/html") return "html";
92
+ if (resolvedMime.startsWith("image/")) return resolvedMime === "image/svg+xml" ? "text" : "image";
93
+ if (resolvedMime.startsWith("audio/")) return "audio";
94
+ if (resolvedMime.startsWith("video/")) return "video";
95
+ if (resolvedMime === "application/pdf") return "pdf";
96
+ if (isTextLikeMime(resolvedMime)) return "text";
97
+ return "none";
98
+ }
99
+ function isTextLikeMime(mime) {
100
+ if (!mime) return false;
101
+ if (TEXT_MIME_VALUES.has(mime)) return true;
102
+ return TEXT_MIME_PREFIXES.some((prefix) => mime.startsWith(prefix));
103
+ }
104
+ function isTextLikeFile(path, mime) {
105
+ return isTextLikeMime(mime ?? inferFileMime(path));
106
+ }
107
+ function isPreviewableFile(path, mime) {
108
+ return inferFilePreviewKind(path, mime) !== "none";
109
+ }
110
+
111
+ //#endregion
112
+ //#region src/schemas.ts
113
+ /**
114
+ * Orthogonal intents (updated 2026-07-23 Asia/Shanghai):
115
+ * 1. Define Zod schemas and TypeScript types for OpenSpec documents and Change tasks.
116
+ * 2. Preserve tracked-task progress as a reusable typed contract for live Change projections.
117
+ *
118
+ * Original request (2026-07-23): "现在页面数据的加载数据非常慢(比如dashboard页面、changes页面都要等待非常久,页面刷新后,似乎后台没有缓存一样,也要加载很久。"
119
+ * @module schemas
120
+ */
121
+ /**
122
+ * File metadata for a change directory entry.
123
+ */
124
+ const ChangeFileSchema = z.object({
125
+ path: z.string(),
126
+ type: z.enum(["file", "directory"]),
127
+ content: z.string().optional(),
128
+ size: z.number().optional(),
129
+ mime: z.string().optional(),
130
+ previewKind: z.enum(FILE_PREVIEW_KINDS).optional()
131
+ });
132
+ const ScenarioStepKeywordSchema = z.enum([
133
+ "GIVEN",
134
+ "WHEN",
135
+ "THEN",
136
+ "AND",
137
+ "BUT"
138
+ ]);
139
+ const ScenarioStepSchema = z.object({
140
+ keyword: ScenarioStepKeywordSchema,
141
+ contentMarkdown: z.string(),
142
+ rawText: z.string()
143
+ });
144
+ /**
145
+ * A requirement within a specification.
146
+ * Requirements should use RFC 2119 keywords (SHALL, MUST, etc.)
147
+ */
148
+ const RequirementSchema = z.object({
149
+ id: z.string(),
150
+ title: z.string(),
151
+ bodyMarkdown: z.string(),
152
+ text: z.string(),
153
+ scenarios: z.array(z.object({
154
+ title: z.string(),
155
+ bodyMarkdown: z.string(),
156
+ rawText: z.string(),
157
+ steps: z.array(ScenarioStepSchema).optional()
158
+ }))
159
+ });
160
+ /**
161
+ * A specification document.
162
+ * Located at: openspec/specs/{id}/spec.md
163
+ */
164
+ const SpecSchema = z.object({
165
+ id: z.string(),
166
+ name: z.string(),
167
+ overview: z.string(),
168
+ requirements: z.array(RequirementSchema),
169
+ metadata: z.object({
170
+ version: z.string().default("1.0.0"),
171
+ format: z.literal("openspec").default("openspec"),
172
+ sourcePath: z.string().optional()
173
+ }).optional()
174
+ });
175
+ /**
176
+ * A delta describes changes to a spec within a change proposal.
177
+ * Deltas track which specs are affected and how.
178
+ */
179
+ const DeltaOperationType = z.enum([
180
+ "ADDED",
181
+ "MODIFIED",
182
+ "REMOVED",
183
+ "RENAMED"
184
+ ]);
185
+ const DeltaSchema = z.object({
186
+ spec: z.string(),
187
+ operation: DeltaOperationType,
188
+ description: z.string(),
189
+ requirement: RequirementSchema.optional(),
190
+ requirements: z.array(RequirementSchema).optional(),
191
+ rename: z.object({
192
+ from: z.string(),
193
+ to: z.string()
194
+ }).optional()
195
+ });
196
+ /**
197
+ * A task within a change proposal.
198
+ * Tasks are parsed from tasks.md using checkbox syntax: - [ ] or - [x]
199
+ */
200
+ const TaskSchema = z.object({
201
+ id: z.string(),
202
+ text: z.string(),
203
+ completed: z.boolean(),
204
+ section: z.string().optional()
205
+ });
206
+ const TrackedTaskSourceSchema = z.discriminatedUnion("kind", [
207
+ z.object({
208
+ kind: z.literal("artifact"),
209
+ artifactId: z.string(),
210
+ outputPath: z.string(),
211
+ filePaths: z.array(z.string())
212
+ }),
213
+ z.object({
214
+ kind: z.literal("top-level-fallback"),
215
+ artifactId: z.null(),
216
+ outputPath: z.literal("tasks.md"),
217
+ filePaths: z.tuple([z.literal("tasks.md")])
218
+ }),
219
+ z.object({
220
+ kind: z.literal("none"),
221
+ artifactId: z.null(),
222
+ outputPath: z.null(),
223
+ filePaths: z.tuple([])
224
+ })
225
+ ]);
226
+ const TrackedTaskSchema = TaskSchema.extend({ location: z.object({
227
+ filePath: z.string(),
228
+ taskIndex: z.number().int().positive()
229
+ }) });
230
+ const TrackedTaskProgressSchema = z.object({
231
+ tasks: z.array(TrackedTaskSchema),
232
+ total: z.number(),
233
+ completed: z.number(),
234
+ remaining: z.number(),
235
+ phase: z.enum([
236
+ "no-tasks",
237
+ "in-progress",
238
+ "complete"
239
+ ]),
240
+ source: TrackedTaskSourceSchema
241
+ });
242
+ const DocumentChecklistSummarySchema = z.object({
243
+ groups: z.array(z.object({
244
+ artifactIds: z.array(z.string()),
245
+ filePath: z.string(),
246
+ tasks: z.array(TaskSchema),
247
+ total: z.number(),
248
+ completed: z.number(),
249
+ remaining: z.number()
250
+ })),
251
+ total: z.number(),
252
+ completed: z.number(),
253
+ remaining: z.number()
254
+ });
255
+ /**
256
+ * A delta spec file from changes/{id}/specs/{specId}/spec.md
257
+ * Contains the proposed changes to a spec
258
+ */
259
+ const DeltaSpecSchema = z.object({
260
+ specId: z.string(),
261
+ content: z.string()
262
+ });
263
+ /**
264
+ * A change proposal document.
265
+ * Located at: openspec/changes/{id}/proposal.md + tasks.md
266
+ *
267
+ * Change proposals describe why a change is needed, what will change,
268
+ * which specs are affected (deltas), and trackable tasks.
269
+ */
270
+ const ChangeSchema = z.object({
271
+ id: z.string(),
272
+ name: z.string(),
273
+ why: z.string(),
274
+ whatChanges: z.string(),
275
+ deltas: z.array(DeltaSchema),
276
+ trackedTaskProgress: TrackedTaskProgressSchema,
277
+ documentChecklistSummary: DocumentChecklistSummarySchema,
278
+ design: z.string().optional(),
279
+ deltaSpecs: z.array(DeltaSpecSchema).optional(),
280
+ metadata: z.object({
281
+ version: z.string().default("1.0.0"),
282
+ format: z.literal("openspec-change").default("openspec-change")
283
+ }).optional()
284
+ });
285
+
286
+ //#endregion
287
+ export { isTextLikeMime as _, DeltaSpecSchema as a, ScenarioStepSchema as c, TrackedTaskProgressSchema as d, FILE_PREVIEW_KINDS as f, isTextLikeFile as g, isPreviewableFile as h, DeltaSchema as i, SpecSchema as l, inferFilePreviewKind as m, ChangeSchema as n, RequirementSchema as o, inferFileMime as p, DeltaOperationType as r, ScenarioStepKeywordSchema as s, ChangeFileSchema as t, TaskSchema as u };