@openspecui/core 6.2.0 → 7.0.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 (121) hide show
  1. package/dist/active-root-config-BXb2HeOF.d.mts +668 -0
  2. package/dist/active-root-config-L5QaMb3A.mjs +333 -0
  3. package/dist/active-root-config.d.mts +6 -0
  4. package/dist/active-root-config.mjs +3 -0
  5. package/dist/app-daemon-control.d.mts +10 -10
  6. package/dist/{cli-projection-CvRCkCyI.d.mts → cli-projection-CBwRFPMi.d.mts} +13 -13
  7. package/dist/{cli-projection-BHfqvlpA.mjs → cli-projection-CKRwTvwf.mjs} +1 -1
  8. package/dist/cli-projection.d.mts +5 -5
  9. package/dist/cli-projection.mjs +2 -2
  10. package/dist/{common-BpgNUOOT.mjs → common-BRL_34xt.mjs} +2 -1
  11. package/dist/{dashboard-summary-transport-iutogi2N.d.mts → dashboard-summary-transport-BCaB0LKb.d.mts} +3979 -3187
  12. package/dist/{dashboard-summary-transport-BMtZ0q12.mjs → dashboard-summary-transport-ILCfZD_I.mjs} +2 -2
  13. package/dist/dashboard-summary-transport.d.mts +26 -25
  14. package/dist/dashboard-summary-transport.mjs +4 -4
  15. package/dist/{document-translation-CUkkxnYV.mjs → document-translation-B3xaP0dJ.mjs} +1 -1
  16. package/dist/{document-translation-DOcHp3o0.d.mts → document-translation-BNbM3fEj.d.mts} +2 -2
  17. package/dist/document-translation.d.mts +1 -1
  18. package/dist/document-translation.mjs +2 -2
  19. package/dist/{hosted-app-C3gBSvov.mjs → hosted-app-B_T_tTvO.mjs} +7 -2
  20. package/dist/hosted-app.d.mts +27 -26
  21. package/dist/hosted-app.mjs +7 -7
  22. package/dist/{hosted-contract-CaN2aw54.mjs → hosted-contract-BxUx6ksP.mjs} +5 -5
  23. package/dist/hosted-contract.d.mts +26 -25
  24. package/dist/hosted-contract.mjs +6 -6
  25. package/dist/{command-result-DPdfvbPT.d.mts → index-CF5niw80.d.mts} +8117 -7976
  26. package/dist/index.d.mts +27 -26
  27. package/dist/index.mjs +904 -332
  28. package/dist/{local-download-profiles-xAbDVjd6.d.mts → local-download-profiles-Bq0bQbTA.d.mts} +1 -1
  29. package/dist/local-download-profiles.d.mts +2 -2
  30. package/dist/local-download-profiles.mjs +1 -1
  31. package/dist/markdown-facts.d.mts +1 -1
  32. package/dist/markdown-facts.mjs +1 -1
  33. package/dist/{markdown-reading-w686Obnl.d.mts → markdown-reading--Sr6JAl5.d.mts} +1 -1
  34. package/dist/{markdown-reading-0L-mVBJp.mjs → markdown-reading-LtgFpB8E.mjs} +1 -1
  35. package/dist/markdown-reading.d.mts +2 -2
  36. package/dist/markdown-reading.mjs +2 -2
  37. package/dist/{notifications-BP_02fdj.d.mts → notifications-ClhEHZU3.d.mts} +11 -11
  38. package/dist/{notifications-E6_WBjQO.mjs → notifications-Cy74GVN7.mjs} +2 -2
  39. package/dist/notifications.d.mts +2 -2
  40. package/dist/notifications.mjs +3 -3
  41. package/dist/{openspec-annotations-DiHje5HD.mjs → openspec-annotations-BJ1BlVyo.mjs} +2 -2
  42. package/dist/{openspec-annotations-BXAqKLXc.d.mts → openspec-annotations-BylPW5rz.d.mts} +2 -2
  43. package/dist/openspec-annotations.d.mts +3 -3
  44. package/dist/openspec-annotations.mjs +3 -3
  45. package/dist/openspec-compat.d.mts +14 -14
  46. package/dist/openspec-compat.mjs +18 -32
  47. package/dist/{openspec-projection-DvJnsxLZ.mjs → openspec-projection-Cno7FlwE.mjs} +2 -2
  48. package/dist/{openspec-projection-CPKTjO43.d.mts → openspec-projection-EgTIZCfC.d.mts} +3 -3
  49. package/dist/openspec-projection.d.mts +5 -5
  50. package/dist/openspec-projection.mjs +4 -4
  51. package/dist/opsx-display-path.d.mts +1 -1
  52. package/dist/opsx-display-path.mjs +1 -1
  53. package/dist/{opsx-entity-BJz_BsKn.d.mts → opsx-entity-BNthD6Ks.d.mts} +2 -2
  54. package/dist/opsx-entity.d.mts +7 -7
  55. package/dist/opsx-entity.mjs +1 -1
  56. package/dist/{opsx-schema-detail-tkv6htQB.d.mts → opsx-schema-detail-B4li4BMU.d.mts} +2 -2
  57. package/dist/opsx-schema-detail.d.mts +8 -8
  58. package/dist/opsx-schema-detail.mjs +1 -1
  59. package/dist/{opsx-types-BNEqpP-B.d.mts → opsx-types-DP8JjGq0.d.mts} +544 -295
  60. package/dist/opsx-workflows.d.mts +1 -1
  61. package/dist/opsx-workflows.mjs +1 -1
  62. package/dist/{planning-cli-projection-DrkT18EI.mjs → planning-cli-projection-BreqsrYA.mjs} +51 -11
  63. package/dist/planning-cli-projection.d.mts +26 -25
  64. package/dist/planning-cli-projection.mjs +7 -7
  65. package/dist/{schemas-D4afES_m.d.mts → schemas-divIlNvA.d.mts} +128 -128
  66. package/dist/{sounds-CsPiQKxX.d.mts → sounds-qIKfPgxj.d.mts} +1 -1
  67. package/dist/sounds.d.mts +1 -1
  68. package/dist/sounds.mjs +1 -1
  69. package/dist/{spec-catalog-Dv2qolxy.mjs → spec-catalog-DEk_oHAx.mjs} +99 -18
  70. package/dist/spec-catalog.d.mts +27 -26
  71. package/dist/spec-catalog.mjs +5 -5
  72. package/dist/{store-content-projection-CiMcGZnG.mjs → store-content-projection-Bpdb7_d9.mjs} +1 -1
  73. package/dist/store-content-projection.d.mts +1 -1
  74. package/dist/store-content-projection.mjs +2 -2
  75. package/dist/{store-mutation-protocol-CLtYUSwC.mjs → store-mutation-protocol-CJGUWWI6.mjs} +1 -1
  76. package/dist/{store-mutation-protocol-Ckcv2-zs.d.mts → store-mutation-protocol-Cr4pWWbh.d.mts} +24 -24
  77. package/dist/store-mutation-protocol.d.mts +1 -1
  78. package/dist/store-mutation-protocol.mjs +2 -2
  79. package/dist/{store-types-DIws57FV.d.mts → store-types-DjWxHHvs.d.mts} +1 -1
  80. package/dist/store-types.d.mts +5 -5
  81. package/dist/store-types.mjs +1 -1
  82. package/dist/{task-progress-DpZak5xA.mjs → task-progress-Bvid_Ws8.mjs} +1 -1
  83. package/dist/task-progress.d.mts +6 -6
  84. package/dist/task-progress.mjs +2 -2
  85. package/dist/{terminal-audio-BXa1vpkF.d.mts → terminal-audio-CSUGxzx3.d.mts} +2 -2
  86. package/dist/{terminal-audio-punFQHXI.mjs → terminal-audio-DeubAfFC.mjs} +1 -1
  87. package/dist/terminal-audio.d.mts +2 -2
  88. package/dist/terminal-audio.mjs +2 -2
  89. package/dist/terminal-control.d.mts +2 -2
  90. package/dist/terminal-control.mjs +1 -1
  91. package/dist/{terminal-invocation-DFhNS_lc.d.mts → terminal-invocation-kFxUD_5T.d.mts} +96 -96
  92. package/dist/terminal-invocation.d.mts +1 -1
  93. package/dist/terminal-invocation.mjs +1 -1
  94. package/dist/terminal-theme.d.mts +1 -1
  95. package/dist/terminal-theme.mjs +1 -1
  96. package/dist/translation-language-pair.d.mts +1 -1
  97. package/dist/translation-language-pair.mjs +1 -1
  98. package/dist/{translator-B9j5lGVS.d.mts → translator-DgIIyl6v.d.mts} +141 -141
  99. package/dist/translator.d.mts +1 -1
  100. package/dist/translator.mjs +1 -1
  101. package/package.json +15 -5
  102. /package/dist/{local-download-profiles-DK4g6FRe.mjs → local-download-profiles-h9lUTXr-.mjs} +0 -0
  103. /package/dist/{markdown-facts-Dve6IAJP.mjs → markdown-facts-BIx47NNY.mjs} +0 -0
  104. /package/dist/{markdown-facts-C9yWB2I9.d.mts → markdown-facts-DLclHfpE.d.mts} +0 -0
  105. /package/dist/{opsx-display-path-eWJ4ve-O.d.mts → opsx-display-path-BD34M8QV.d.mts} +0 -0
  106. /package/dist/{opsx-display-path-DuPEvPV0.mjs → opsx-display-path-ocbNzMZj.mjs} +0 -0
  107. /package/dist/{opsx-entity-Br5S5N0o.mjs → opsx-entity-BnO3k48r.mjs} +0 -0
  108. /package/dist/{opsx-schema-detail-CckZIEVr.mjs → opsx-schema-detail-zk8ePaKK.mjs} +0 -0
  109. /package/dist/{opsx-workflows-Bhh_bI-e.d.mts → opsx-workflows-DX1r6e5j.d.mts} +0 -0
  110. /package/dist/{opsx-workflows-GPZSe1C_.mjs → opsx-workflows-byPfLlo8.mjs} +0 -0
  111. /package/dist/{schemas-BrS9qSB3.mjs → schemas-CMThmKx1.mjs} +0 -0
  112. /package/dist/{sounds-na4c8j0c.mjs → sounds-6prQvKXl.mjs} +0 -0
  113. /package/dist/{store-content-projection-BPDCma8v.d.mts → store-content-projection-R74MV_sD.d.mts} +0 -0
  114. /package/dist/{store-types-Cs40yohL.mjs → store-types-CvpEVNoE.mjs} +0 -0
  115. /package/dist/{terminal-control-BvoxwQ6m.mjs → terminal-control-c6oS-lFb.mjs} +0 -0
  116. /package/dist/{terminal-invocation-BexVY5E2.mjs → terminal-invocation-DIpoFYDo.mjs} +0 -0
  117. /package/dist/{terminal-theme-DIhzj5Si.mjs → terminal-theme-Byzxmnjm.mjs} +0 -0
  118. /package/dist/{terminal-theme-BzARb2Do.d.mts → terminal-theme-DX08Gci8.d.mts} +0 -0
  119. /package/dist/{translation-language-pair-DeAiww3_.d.mts → translation-language-pair-BR5uxGm-.d.mts} +0 -0
  120. /package/dist/{translation-language-pair-BV2cGjfv.mjs → translation-language-pair-DG9mOuFD.mjs} +0 -0
  121. /package/dist/{translator-DCCZeHt1.mjs → translator-CEGdRmKw.mjs} +0 -0
@@ -0,0 +1,333 @@
1
+ import { isMap, isNode, isScalar, isSeq, parseDocument } from "yaml";
2
+ import { z } from "zod";
3
+
4
+ //#region src/active-root-config-contract.ts
5
+ /**
6
+ * Orthogonal intents (updated 2026-08-02 Asia/Shanghai):
7
+ * 1. Define OpenSpec 1.7 Active Root official-field and diagnostic contracts.
8
+ * 2. Define exact owner/file/revision mutation admission and typed recovery results.
9
+ *
10
+ * Original request (2026-08-01): structured fields align with official OpenSpec while raw YAML accepts team extensions.
11
+ * Derived checkpoint (2026-08-02): stale Active Root saves return the latest physical source instead of overwriting it.
12
+ */
13
+ /** OpenSpec 1.7 hard limit for project context encoded as UTF-8. */
14
+ const MAX_ACTIVE_ROOT_CONTEXT_BYTES = 50 * 1024;
15
+ const NonEmptyStringSchema = z.string().min(1);
16
+ const NonEmptyStringListSchema = z.array(NonEmptyStringSchema);
17
+ const ActiveRootRulesSchema = z.record(NonEmptyStringSchema, NonEmptyStringListSchema);
18
+ const ActiveRootOperationSchema = z.object({ guidance: NonEmptyStringListSchema }).strict();
19
+ const ActiveRootOperationsSchema = z.object({
20
+ apply: ActiveRootOperationSchema.optional(),
21
+ archive: ActiveRootOperationSchema.optional()
22
+ }).strict();
23
+ function withinContextByteLimit(value) {
24
+ return new TextEncoder().encode(value).byteLength <= MAX_ACTIVE_ROOT_CONTEXT_BYTES;
25
+ }
26
+ const ActiveRootContextSchema = z.string().refine(withinContextByteLimit, `Context must not exceed ${MAX_ACTIVE_ROOT_CONTEXT_BYTES} UTF-8 bytes.`);
27
+ /** Runtime schema for the resilient official-field projection. */
28
+ const ActiveRootOfficialConfigSchema = z.object({
29
+ schema: NonEmptyStringSchema.nullable(),
30
+ context: ActiveRootContextSchema.nullable(),
31
+ rules: ActiveRootRulesSchema.nullable(),
32
+ operations: ActiveRootOperationsSchema.nullable()
33
+ }).strict();
34
+ /** Runtime schema for one complete Structured-mode update. */
35
+ const ActiveRootStructuredUpdateSchema = z.object({
36
+ schema: NonEmptyStringSchema,
37
+ context: ActiveRootContextSchema.nullable(),
38
+ rules: ActiveRootRulesSchema.nullable(),
39
+ operations: z.object({
40
+ apply: ActiveRootOperationSchema.nullable(),
41
+ archive: ActiveRootOperationSchema.nullable()
42
+ }).strict().nullable()
43
+ }).strict();
44
+ /** Opaque digest proving the exact Active Root owner, file, presence, and source bytes read by an editor. */
45
+ const ActiveRootRevisionSchema = z.string().regex(/^sha256:[a-f0-9]{64}$/);
46
+ const ActiveRootMutationLocatorShape = {
47
+ ownerPath: z.string().min(1),
48
+ filePath: z.string().min(1),
49
+ revision: ActiveRootRevisionSchema
50
+ };
51
+ /** Runtime schema for Structured or Raw mutation admission at one exact physical revision. */
52
+ const ActiveRootMutationSchema = z.discriminatedUnion("mode", [z.object({
53
+ ...ActiveRootMutationLocatorShape,
54
+ mode: z.literal("structured"),
55
+ update: ActiveRootStructuredUpdateSchema
56
+ }).strict(), z.object({
57
+ ...ActiveRootMutationLocatorShape,
58
+ mode: z.literal("raw"),
59
+ content: z.string()
60
+ }).strict()]);
61
+
62
+ //#endregion
63
+ //#region src/active-root-config-yaml.ts
64
+ /**
65
+ * Orthogonal intents (updated 2026-08-02 Asia/Shanghai):
66
+ * 1. Inspect OpenSpec 1.7 official fields resiliently while ignoring team-key ownership.
67
+ * 2. Validate Raw YAML syntax without imposing the official key set.
68
+ * 3. Patch only Structured-owned YAML nodes while retaining representable presentation and extensions.
69
+ *
70
+ * Original request (2026-08-01): preserve complete raw YAML because teams may define their own configuration keys.
71
+ * Derived checkpoint (2026-08-02): Structured mode owns schema, context, rules, and apply/archive guidance only.
72
+ */
73
+ const EMPTY_OFFICIAL_CONFIG = {
74
+ schema: null,
75
+ context: null,
76
+ rules: null,
77
+ operations: null
78
+ };
79
+ function isRecord(value) {
80
+ return typeof value === "object" && value !== null && !Array.isArray(value);
81
+ }
82
+ function contextByteLength(value) {
83
+ return new TextEncoder().encode(value).byteLength;
84
+ }
85
+ function yamlErrors(content) {
86
+ const document = parseDocument(content);
87
+ if (document.errors.length === 0) return [];
88
+ return [{
89
+ code: "config-unparseable",
90
+ severity: "error",
91
+ path: "$",
92
+ message: document.errors.map((error) => error.message).join("\n")
93
+ }];
94
+ }
95
+ function inspectRules(value, diagnostics) {
96
+ if (value === void 0) return null;
97
+ if (!isRecord(value)) {
98
+ diagnostics.push({
99
+ code: "rules-invalid",
100
+ severity: "error",
101
+ path: "rules",
102
+ message: "The rules field must be a mapping of artifact ids to string arrays."
103
+ });
104
+ return null;
105
+ }
106
+ const rules = {};
107
+ for (const [artifactId, candidate] of Object.entries(value)) {
108
+ if (!Array.isArray(candidate) || candidate.some((entry) => typeof entry !== "string")) {
109
+ diagnostics.push({
110
+ code: "rules-entry-invalid",
111
+ severity: "error",
112
+ path: `rules.${artifactId}`,
113
+ message: `Rules for '${artifactId}' must be an array of strings.`
114
+ });
115
+ continue;
116
+ }
117
+ const entries = candidate.filter((entry) => entry.length > 0);
118
+ if (entries.length < candidate.length) diagnostics.push({
119
+ code: "rules-entry-empty",
120
+ severity: "warning",
121
+ path: `rules.${artifactId}`,
122
+ message: `Empty rules for '${artifactId}' are ignored by OpenSpec.`
123
+ });
124
+ if (entries.length > 0) rules[artifactId] = entries;
125
+ }
126
+ return Object.keys(rules).length > 0 ? rules : null;
127
+ }
128
+ function inspectOperations(value, diagnostics) {
129
+ if (value === void 0) return null;
130
+ if (!isRecord(value)) {
131
+ diagnostics.push({
132
+ code: "operations-invalid",
133
+ severity: "error",
134
+ path: "operations",
135
+ message: "The operations field must be a mapping."
136
+ });
137
+ return null;
138
+ }
139
+ const operations = {};
140
+ for (const operationId of ["apply", "archive"]) {
141
+ const candidate = value[operationId];
142
+ if (candidate === void 0) continue;
143
+ if (!isRecord(candidate)) {
144
+ diagnostics.push({
145
+ code: "operation-invalid",
146
+ severity: "error",
147
+ path: `operations.${operationId}`,
148
+ message: `Operation '${operationId}' must be a mapping.`
149
+ });
150
+ continue;
151
+ }
152
+ if (candidate.guidance === void 0) continue;
153
+ if (!Array.isArray(candidate.guidance) || candidate.guidance.some((entry) => typeof entry !== "string")) {
154
+ diagnostics.push({
155
+ code: "operation-guidance-invalid",
156
+ severity: "error",
157
+ path: `operations.${operationId}.guidance`,
158
+ message: `Guidance for '${operationId}' must be an array of strings.`
159
+ });
160
+ continue;
161
+ }
162
+ const guidance = candidate.guidance.filter((entry) => entry.length > 0);
163
+ if (guidance.length < candidate.guidance.length) diagnostics.push({
164
+ code: "operation-guidance-empty",
165
+ severity: "warning",
166
+ path: `operations.${operationId}.guidance`,
167
+ message: `Empty '${operationId}' guidance entries are ignored by OpenSpec.`
168
+ });
169
+ if (guidance.length > 0) operations[operationId] = { guidance };
170
+ }
171
+ return Object.keys(operations).length > 0 ? operations : null;
172
+ }
173
+ /** Inspect official OpenSpec 1.7 Active Root fields independently and retain recoverable diagnostics. */
174
+ function inspectActiveRootOfficialConfig(content) {
175
+ if (content === null || content.trim().length === 0) return {
176
+ official: { ...EMPTY_OFFICIAL_CONFIG },
177
+ diagnostics: [{
178
+ code: "schema-missing",
179
+ severity: "error",
180
+ path: "schema",
181
+ message: "The active OpenSpec config does not declare a schema."
182
+ }]
183
+ };
184
+ const document = parseDocument(content);
185
+ if (document.errors.length > 0) return {
186
+ official: { ...EMPTY_OFFICIAL_CONFIG },
187
+ diagnostics: yamlErrors(content)
188
+ };
189
+ const raw = document.toJS();
190
+ if (!isRecord(raw)) return {
191
+ official: { ...EMPTY_OFFICIAL_CONFIG },
192
+ diagnostics: [{
193
+ code: "config-not-mapping",
194
+ severity: "error",
195
+ path: "$",
196
+ message: "OpenSpec config must be a YAML mapping for Structured mode."
197
+ }]
198
+ };
199
+ const diagnostics = [];
200
+ let schema = null;
201
+ if (raw.schema === void 0) diagnostics.push({
202
+ code: "schema-missing",
203
+ severity: "error",
204
+ path: "schema",
205
+ message: "The active OpenSpec config does not declare a schema."
206
+ });
207
+ else if (typeof raw.schema !== "string" || raw.schema.length === 0) diagnostics.push({
208
+ code: "schema-invalid",
209
+ severity: "error",
210
+ path: "schema",
211
+ message: "The schema field must be a non-empty string."
212
+ });
213
+ else schema = raw.schema;
214
+ let context = null;
215
+ if (raw.context !== void 0) if (typeof raw.context !== "string") diagnostics.push({
216
+ code: "context-invalid",
217
+ severity: "error",
218
+ path: "context",
219
+ message: "The context field must be a string."
220
+ });
221
+ else if (contextByteLength(raw.context) > MAX_ACTIVE_ROOT_CONTEXT_BYTES) diagnostics.push({
222
+ code: "context-too-large",
223
+ severity: "error",
224
+ path: "context",
225
+ message: `The context field exceeds ${MAX_ACTIVE_ROOT_CONTEXT_BYTES} UTF-8 bytes.`
226
+ });
227
+ else context = raw.context;
228
+ return {
229
+ official: {
230
+ schema,
231
+ context,
232
+ rules: inspectRules(raw.rules, diagnostics),
233
+ operations: inspectOperations(raw.operations, diagnostics)
234
+ },
235
+ diagnostics
236
+ };
237
+ }
238
+ /** Validate Raw-mode YAML syntax while allowing any syntactically valid document shape and custom keys. */
239
+ function validateActiveRootRawYaml(content) {
240
+ const diagnostics = yamlErrors(content);
241
+ return {
242
+ valid: diagnostics.length === 0,
243
+ diagnostics
244
+ };
245
+ }
246
+ function editableDocument(content) {
247
+ const document = parseDocument(content ?? "");
248
+ if (document.errors.length > 0) throw new Error(`Active Root cannot be edited in Structured mode: ${document.errors.map((error) => error.message).join("\n")}`);
249
+ if (document.contents !== null && !isMap(document.contents)) throw new Error("Active Root cannot be edited in Structured mode: config is not a YAML mapping.");
250
+ return document;
251
+ }
252
+ function copyPresentation(source, target) {
253
+ if (!isNode(source) || !isNode(target)) return;
254
+ target.comment = source.comment;
255
+ target.commentBefore = source.commentBefore;
256
+ target.spaceBefore = source.spaceBefore;
257
+ if (isScalar(source) && isScalar(target) && typeof target.value === "string") target.type = source.type;
258
+ if (isMap(source) && isMap(target) || isSeq(source) && isSeq(target)) target.flow = source.flow;
259
+ if (isSeq(source) && isSeq(target)) for (let index = 0; index < Math.min(source.items.length, target.items.length); index += 1) copyPresentation(source.items[index], target.items[index]);
260
+ }
261
+ function replaceNode(document, path, value) {
262
+ const previous = document.getIn(path, true);
263
+ const replacement = document.createNode(value);
264
+ copyPresentation(previous, replacement);
265
+ document.setIn(path, replacement);
266
+ }
267
+ function ensureMap(document, path) {
268
+ const current = document.getIn(path, true);
269
+ if (isMap(current)) return current;
270
+ replaceNode(document, path, {});
271
+ const replacement = document.getIn(path, true);
272
+ if (!isMap(replacement)) throw new Error(`Unable to create YAML mapping at ${path.join(".")}.`);
273
+ return replacement;
274
+ }
275
+ function mappingStringKeys(mapping) {
276
+ const keys = [];
277
+ for (const pair of mapping.items) if (isScalar(pair.key) && typeof pair.key.value === "string") keys.push(pair.key.value);
278
+ return keys;
279
+ }
280
+ function patchRules(document, rules) {
281
+ if (rules === null) {
282
+ document.delete("rules");
283
+ return;
284
+ }
285
+ const mapping = ensureMap(document, ["rules"]);
286
+ for (const artifactId of mappingStringKeys(mapping)) if (!Object.hasOwn(rules, artifactId)) mapping.delete(artifactId);
287
+ for (const [artifactId, entries] of Object.entries(rules)) replaceNode(document, ["rules", artifactId], entries);
288
+ }
289
+ function removeOperationGuidance(document, operationId) {
290
+ const operations = document.getIn(["operations"], true);
291
+ if (!isMap(operations)) return;
292
+ const operation = document.getIn(["operations", operationId], true);
293
+ if (isMap(operation)) {
294
+ operation.delete("guidance");
295
+ if (operation.items.length === 0) operations.delete(operationId);
296
+ } else if (operation !== void 0) operations.delete(operationId);
297
+ if (operations.items.length === 0) document.delete("operations");
298
+ }
299
+ function patchOperations(document, operations) {
300
+ if (operations === null) {
301
+ removeOperationGuidance(document, "apply");
302
+ removeOperationGuidance(document, "archive");
303
+ return;
304
+ }
305
+ ensureMap(document, ["operations"]);
306
+ for (const operationId of ["apply", "archive"]) {
307
+ const operation = operations[operationId];
308
+ if (operation === null) {
309
+ removeOperationGuidance(document, operationId);
310
+ continue;
311
+ }
312
+ ensureMap(document, ["operations", operationId]);
313
+ replaceNode(document, [
314
+ "operations",
315
+ operationId,
316
+ "guidance"
317
+ ], operation.guidance);
318
+ }
319
+ }
320
+ /** Patch only Structured-owned official nodes and retain all representable unowned YAML evidence. */
321
+ function patchActiveRootOfficialFields(content, update) {
322
+ const validated = ActiveRootStructuredUpdateSchema.parse(update);
323
+ const document = editableDocument(content);
324
+ replaceNode(document, ["schema"], validated.schema);
325
+ if (validated.context === null) document.delete("context");
326
+ else replaceNode(document, ["context"], validated.context);
327
+ patchRules(document, validated.rules);
328
+ patchOperations(document, validated.operations);
329
+ return document.toString({ lineWidth: 0 });
330
+ }
331
+
332
+ //#endregion
333
+ export { ActiveRootOfficialConfigSchema as a, MAX_ACTIVE_ROOT_CONTEXT_BYTES as c, ActiveRootMutationSchema as i, patchActiveRootOfficialFields as n, ActiveRootRevisionSchema as o, validateActiveRootRawYaml as r, ActiveRootStructuredUpdateSchema as s, inspectActiveRootOfficialConfig as t };
@@ -0,0 +1,6 @@
1
+ import "./document-translation-BNbM3fEj.mjs";
2
+ import "./sounds-qIKfPgxj.mjs";
3
+ import "./notifications-ClhEHZU3.mjs";
4
+ import "./index-CF5niw80.mjs";
5
+ import { _ as ActiveRootStructuredUpdateSchema, a as ActiveRootConfigDiagnostic, c as ActiveRootMutation, d as ActiveRootOfficialConfig, f as ActiveRootOfficialConfigSchema, g as ActiveRootStructuredUpdate, h as ActiveRootRevisionSchema, i as ActiveRootConfig, l as ActiveRootMutationResult, m as ActiveRootRevision, n as patchActiveRootOfficialFields, o as ActiveRootConfigFile, p as ActiveRootRawValidation, r as validateActiveRootRawYaml, s as ActiveRootConfigInspection, t as inspectActiveRootOfficialConfig, u as ActiveRootMutationSchema, v as MAX_ACTIVE_ROOT_CONTEXT_BYTES } from "./active-root-config-BXb2HeOF.mjs";
6
+ export { ActiveRootConfig, ActiveRootConfigDiagnostic, ActiveRootConfigFile, ActiveRootConfigInspection, ActiveRootMutation, ActiveRootMutationResult, ActiveRootMutationSchema, ActiveRootOfficialConfig, ActiveRootOfficialConfigSchema, ActiveRootRawValidation, ActiveRootRevision, ActiveRootRevisionSchema, ActiveRootStructuredUpdate, ActiveRootStructuredUpdateSchema, MAX_ACTIVE_ROOT_CONTEXT_BYTES, inspectActiveRootOfficialConfig, patchActiveRootOfficialFields, validateActiveRootRawYaml };
@@ -0,0 +1,3 @@
1
+ import { a as ActiveRootOfficialConfigSchema, c as MAX_ACTIVE_ROOT_CONTEXT_BYTES, i as ActiveRootMutationSchema, n as patchActiveRootOfficialFields, o as ActiveRootRevisionSchema, r as validateActiveRootRawYaml, s as ActiveRootStructuredUpdateSchema, t as inspectActiveRootOfficialConfig } from "./active-root-config-L5QaMb3A.mjs";
2
+
3
+ export { ActiveRootMutationSchema, ActiveRootOfficialConfigSchema, ActiveRootRevisionSchema, ActiveRootStructuredUpdateSchema, MAX_ACTIVE_ROOT_CONTEXT_BYTES, inspectActiveRootOfficialConfig, patchActiveRootOfficialFields, validateActiveRootRawYaml };
@@ -33,8 +33,8 @@ declare const AppDaemonWorkspaceBindingSchema: z.ZodObject<{
33
33
  githubSlug: string | null;
34
34
  } | null;
35
35
  credential: string | null;
36
- projectDir: string;
37
36
  backendUrl: string;
37
+ projectDir: string;
38
38
  ownership: "daemon-managed" | "external";
39
39
  registeredAt: number;
40
40
  managedGeneration: number | null;
@@ -47,8 +47,8 @@ declare const AppDaemonWorkspaceBindingSchema: z.ZodObject<{
47
47
  githubSlug: string | null;
48
48
  } | null;
49
49
  credential: string | null;
50
- projectDir: string;
51
50
  backendUrl: string;
51
+ projectDir: string;
52
52
  ownership: "daemon-managed" | "external";
53
53
  registeredAt: number;
54
54
  managedGeneration: number | null;
@@ -88,8 +88,8 @@ declare const AppDaemonWorkspaceSnapshotSchema: z.ZodObject<{
88
88
  githubSlug: string | null;
89
89
  } | null;
90
90
  credential: string | null;
91
- projectDir: string;
92
91
  backendUrl: string;
92
+ projectDir: string;
93
93
  ownership: "daemon-managed" | "external";
94
94
  registeredAt: number;
95
95
  managedGeneration: number | null;
@@ -102,8 +102,8 @@ declare const AppDaemonWorkspaceSnapshotSchema: z.ZodObject<{
102
102
  githubSlug: string | null;
103
103
  } | null;
104
104
  credential: string | null;
105
- projectDir: string;
106
105
  backendUrl: string;
106
+ projectDir: string;
107
107
  ownership: "daemon-managed" | "external";
108
108
  registeredAt: number;
109
109
  managedGeneration: number | null;
@@ -119,8 +119,8 @@ declare const AppDaemonWorkspaceSnapshotSchema: z.ZodObject<{
119
119
  githubSlug: string | null;
120
120
  } | null;
121
121
  credential: string | null;
122
- projectDir: string;
123
122
  backendUrl: string;
123
+ projectDir: string;
124
124
  ownership: "daemon-managed" | "external";
125
125
  registeredAt: number;
126
126
  managedGeneration: number | null;
@@ -136,8 +136,8 @@ declare const AppDaemonWorkspaceSnapshotSchema: z.ZodObject<{
136
136
  githubSlug: string | null;
137
137
  } | null;
138
138
  credential: string | null;
139
- projectDir: string;
140
139
  backendUrl: string;
140
+ projectDir: string;
141
141
  ownership: "daemon-managed" | "external";
142
142
  registeredAt: number;
143
143
  managedGeneration: number | null;
@@ -238,8 +238,8 @@ declare const AppDaemonStartManagedProjectResponseSchema: z.ZodDiscriminatedUnio
238
238
  githubSlug: string | null;
239
239
  } | null;
240
240
  credential: string | null;
241
- projectDir: string;
242
241
  backendUrl: string;
242
+ projectDir: string;
243
243
  ownership: "daemon-managed" | "external";
244
244
  registeredAt: number;
245
245
  managedGeneration: number | null;
@@ -252,8 +252,8 @@ declare const AppDaemonStartManagedProjectResponseSchema: z.ZodDiscriminatedUnio
252
252
  githubSlug: string | null;
253
253
  } | null;
254
254
  credential: string | null;
255
- projectDir: string;
256
255
  backendUrl: string;
256
+ projectDir: string;
257
257
  ownership: "daemon-managed" | "external";
258
258
  registeredAt: number;
259
259
  managedGeneration: number | null;
@@ -270,8 +270,8 @@ declare const AppDaemonStartManagedProjectResponseSchema: z.ZodDiscriminatedUnio
270
270
  githubSlug: string | null;
271
271
  } | null;
272
272
  credential: string | null;
273
- projectDir: string;
274
273
  backendUrl: string;
274
+ projectDir: string;
275
275
  ownership: "daemon-managed" | "external";
276
276
  registeredAt: number;
277
277
  managedGeneration: number | null;
@@ -288,8 +288,8 @@ declare const AppDaemonStartManagedProjectResponseSchema: z.ZodDiscriminatedUnio
288
288
  githubSlug: string | null;
289
289
  } | null;
290
290
  credential: string | null;
291
- projectDir: string;
292
291
  backendUrl: string;
292
+ projectDir: string;
293
293
  ownership: "daemon-managed" | "external";
294
294
  registeredAt: number;
295
295
  managedGeneration: number | null;
@@ -1,4 +1,4 @@
1
- import { n as CliJsonValue, t as CliCommandResult } from "./command-result-DPdfvbPT.mjs";
1
+ import { G as CliJsonValue, W as CliCommandResult } from "./index-CF5niw80.mjs";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/cli-projection.d.ts
@@ -216,21 +216,21 @@ declare function createCliProjectionStateSchema<TOutput, TInput>(dataSchema: z.Z
216
216
  invalidationCause: z.ZodEnum<["initial", "dependency", "explicit-refresh", "subscriber-resume"]>;
217
217
  }, "strip", z.ZodTypeAny, {
218
218
  identity: string;
219
+ workGeneration: number;
220
+ snapshotGeneration: null;
219
221
  error: null;
220
222
  state: "loading";
221
223
  data: null;
222
224
  freshness: null;
223
- snapshotGeneration: null;
224
- workGeneration: number;
225
225
  invalidationCause: "initial" | "dependency" | "explicit-refresh" | "subscriber-resume";
226
226
  }, {
227
227
  identity: string;
228
+ workGeneration: number;
229
+ snapshotGeneration: null;
228
230
  error: null;
229
231
  state: "loading";
230
232
  data: null;
231
233
  freshness: null;
232
- snapshotGeneration: null;
233
- workGeneration: number;
234
234
  invalidationCause: "initial" | "dependency" | "explicit-refresh" | "subscriber-resume";
235
235
  }>, z.ZodObject<{
236
236
  state: z.ZodLiteral<"ready">;
@@ -391,6 +391,8 @@ declare function createCliProjectionStateSchema<TOutput, TInput>(dataSchema: z.Z
391
391
  invalidationCause: z.ZodEnum<["initial", "dependency", "explicit-refresh", "subscriber-resume"]>;
392
392
  }, "strip", z.ZodTypeAny, {
393
393
  identity: string;
394
+ workGeneration: number;
395
+ snapshotGeneration: null;
394
396
  error: {
395
397
  message: string;
396
398
  name: string;
@@ -413,11 +415,11 @@ declare function createCliProjectionStateSchema<TOutput, TInput>(dataSchema: z.Z
413
415
  state: "error";
414
416
  data: null;
415
417
  freshness: null;
416
- snapshotGeneration: null;
417
- workGeneration: number;
418
418
  invalidationCause: "initial" | "dependency" | "explicit-refresh" | "subscriber-resume";
419
419
  }, {
420
420
  identity: string;
421
+ workGeneration: number;
422
+ snapshotGeneration: null;
421
423
  error: {
422
424
  message: string;
423
425
  name: string;
@@ -440,8 +442,6 @@ declare function createCliProjectionStateSchema<TOutput, TInput>(dataSchema: z.Z
440
442
  state: "error";
441
443
  data: null;
442
444
  freshness: null;
443
- snapshotGeneration: null;
444
- workGeneration: number;
445
445
  invalidationCause: "initial" | "dependency" | "explicit-refresh" | "subscriber-resume";
446
446
  }>, z.ZodObject<{
447
447
  state: z.ZodLiteral<"refresh-error">;
@@ -762,15 +762,15 @@ declare const CliProjectionNoticeSchema: z.ZodObject<{
762
762
  invalidationCause: z.ZodEnum<["initial", "dependency", "explicit-refresh", "subscriber-resume"]>;
763
763
  }, "strip", z.ZodTypeAny, {
764
764
  identity: string;
765
- state: "ready" | "error" | "loading" | "revalidating" | "refresh-error";
766
- snapshotGeneration: number | null;
767
765
  workGeneration: number;
766
+ snapshotGeneration: number | null;
767
+ state: "loading" | "ready" | "revalidating" | "error" | "refresh-error";
768
768
  invalidationCause: "initial" | "dependency" | "explicit-refresh" | "subscriber-resume";
769
769
  }, {
770
770
  identity: string;
771
- state: "ready" | "error" | "loading" | "revalidating" | "refresh-error";
772
- snapshotGeneration: number | null;
773
771
  workGeneration: number;
772
+ snapshotGeneration: number | null;
773
+ state: "loading" | "ready" | "revalidating" | "error" | "refresh-error";
774
774
  invalidationCause: "initial" | "dependency" | "explicit-refresh" | "subscriber-resume";
775
775
  }>;
776
776
  type CliProjectionNotice = z.infer<typeof CliProjectionNoticeSchema>;
@@ -1,4 +1,4 @@
1
- import { n as CliDiagnosticSchema } from "./common-BpgNUOOT.mjs";
1
+ import { n as CliDiagnosticSchema } from "./common-BRL_34xt.mjs";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/cli-projection.ts
@@ -1,6 +1,6 @@
1
- import "./command-result-DPdfvbPT.mjs";
2
- import "./document-translation-DOcHp3o0.mjs";
3
- import "./sounds-CsPiQKxX.mjs";
4
- import "./notifications-BP_02fdj.mjs";
5
- import { _ as toCliProjectionCommandEvidence, a as CliProjectionFailure, c as CliProjectionInvalidationCauseSchema, d as CliProjectionState, f as CliProjectionStateName, g as createCliProjectionStateSchema, h as cliProjectionStates, i as CliProjectionCommandEvidenceSchema, l as CliProjectionNotice, m as cliProjectionInvalidationCauses, n as CliProjectionCommandError, o as CliProjectionFailureSchema, p as CliProjectionStateNameSchema, r as CliProjectionCommandEvidence, s as CliProjectionInvalidationCause, t as CliJsonValueSchema, u as CliProjectionNoticeSchema, v as toCliProjectionFailure, y as toCliProjectionNotice } from "./cli-projection-CvRCkCyI.mjs";
1
+ import "./document-translation-BNbM3fEj.mjs";
2
+ import "./sounds-qIKfPgxj.mjs";
3
+ import "./notifications-ClhEHZU3.mjs";
4
+ import "./index-CF5niw80.mjs";
5
+ import { _ as toCliProjectionCommandEvidence, a as CliProjectionFailure, c as CliProjectionInvalidationCauseSchema, d as CliProjectionState, f as CliProjectionStateName, g as createCliProjectionStateSchema, h as cliProjectionStates, i as CliProjectionCommandEvidenceSchema, l as CliProjectionNotice, m as cliProjectionInvalidationCauses, n as CliProjectionCommandError, o as CliProjectionFailureSchema, p as CliProjectionStateNameSchema, r as CliProjectionCommandEvidence, s as CliProjectionInvalidationCause, t as CliJsonValueSchema, u as CliProjectionNoticeSchema, v as toCliProjectionFailure, y as toCliProjectionNotice } from "./cli-projection-CBwRFPMi.mjs";
6
6
  export { CliJsonValueSchema, CliProjectionCommandError, CliProjectionCommandEvidence, CliProjectionCommandEvidenceSchema, CliProjectionFailure, CliProjectionFailureSchema, CliProjectionInvalidationCause, CliProjectionInvalidationCauseSchema, CliProjectionNotice, CliProjectionNoticeSchema, CliProjectionState, CliProjectionStateName, CliProjectionStateNameSchema, cliProjectionInvalidationCauses, cliProjectionStates, createCliProjectionStateSchema, toCliProjectionCommandEvidence, toCliProjectionFailure, toCliProjectionNotice };
@@ -1,4 +1,4 @@
1
- import "./common-BpgNUOOT.mjs";
2
- import { a as CliProjectionInvalidationCauseSchema, c as cliProjectionInvalidationCauses, d as toCliProjectionCommandEvidence, f as toCliProjectionFailure, i as CliProjectionFailureSchema, l as cliProjectionStates, n as CliProjectionCommandError, o as CliProjectionNoticeSchema, p as toCliProjectionNotice, r as CliProjectionCommandEvidenceSchema, s as CliProjectionStateNameSchema, t as CliJsonValueSchema, u as createCliProjectionStateSchema } from "./cli-projection-BHfqvlpA.mjs";
1
+ import "./common-BRL_34xt.mjs";
2
+ import { a as CliProjectionInvalidationCauseSchema, c as cliProjectionInvalidationCauses, d as toCliProjectionCommandEvidence, f as toCliProjectionFailure, i as CliProjectionFailureSchema, l as cliProjectionStates, n as CliProjectionCommandError, o as CliProjectionNoticeSchema, p as toCliProjectionNotice, r as CliProjectionCommandEvidenceSchema, s as CliProjectionStateNameSchema, t as CliJsonValueSchema, u as createCliProjectionStateSchema } from "./cli-projection-CKRwTvwf.mjs";
3
3
 
4
4
  export { CliJsonValueSchema, CliProjectionCommandError, CliProjectionCommandEvidenceSchema, CliProjectionFailureSchema, CliProjectionInvalidationCauseSchema, CliProjectionNoticeSchema, CliProjectionStateNameSchema, cliProjectionInvalidationCauses, cliProjectionStates, createCliProjectionStateSchema, toCliProjectionCommandEvidence, toCliProjectionFailure, toCliProjectionNotice };
@@ -2,7 +2,7 @@ import { z } from "zod";
2
2
 
3
3
  //#region src/cli-contracts/common.ts
4
4
  /**
5
- * Orthogonal intents (created 2026-07-15 Asia/Shanghai):
5
+ * Orthogonal intents (updated 2026-08-01 Asia/Shanghai):
6
6
  * 1. Model OpenSpec CLI diagnostics without reinterpreting their meaning.
7
7
  * 2. Preserve root selection provenance exactly as emitted by the CLI.
8
8
  * 3. Preserve direct Reference indexes and their upstream health evidence.
@@ -26,6 +26,7 @@ const CliRootSourceSchema = z.enum([
26
26
  "store",
27
27
  "declared",
28
28
  "nearest",
29
+ "global_default",
29
30
  "implicit"
30
31
  ]);
31
32
  /** CLI-selected planning root with upstream selection provenance. */