@openspecui/core 6.2.1 → 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.
- package/dist/active-root-config-BXb2HeOF.d.mts +668 -0
- package/dist/active-root-config-L5QaMb3A.mjs +333 -0
- package/dist/active-root-config.d.mts +6 -0
- package/dist/active-root-config.mjs +3 -0
- package/dist/{cli-projection-Cus0QYkY.d.mts → cli-projection-CBwRFPMi.d.mts} +1 -1
- package/dist/{cli-projection-BHfqvlpA.mjs → cli-projection-CKRwTvwf.mjs} +1 -1
- package/dist/cli-projection.d.mts +5 -5
- package/dist/cli-projection.mjs +2 -2
- package/dist/{common-BpgNUOOT.mjs → common-BRL_34xt.mjs} +2 -1
- package/dist/{dashboard-summary-transport-ByWMiUWn.d.mts → dashboard-summary-transport-BCaB0LKb.d.mts} +1925 -1133
- package/dist/{dashboard-summary-transport-BMtZ0q12.mjs → dashboard-summary-transport-ILCfZD_I.mjs} +2 -2
- package/dist/dashboard-summary-transport.d.mts +26 -25
- package/dist/dashboard-summary-transport.mjs +4 -4
- package/dist/{document-translation-CUkkxnYV.mjs → document-translation-B3xaP0dJ.mjs} +1 -1
- package/dist/document-translation.d.mts +1 -1
- package/dist/document-translation.mjs +2 -2
- package/dist/{hosted-app-C3gBSvov.mjs → hosted-app-B_T_tTvO.mjs} +7 -2
- package/dist/hosted-app.d.mts +27 -26
- package/dist/hosted-app.mjs +7 -7
- package/dist/{hosted-contract-CaN2aw54.mjs → hosted-contract-BxUx6ksP.mjs} +5 -5
- package/dist/hosted-contract.d.mts +26 -25
- package/dist/hosted-contract.mjs +6 -6
- package/dist/{command-result-BkUqqa0m.d.mts → index-CF5niw80.d.mts} +8119 -7978
- package/dist/index.d.mts +27 -26
- package/dist/index.mjs +904 -332
- package/dist/{local-download-profiles-Detliqbu.d.mts → local-download-profiles-Bq0bQbTA.d.mts} +1 -1
- package/dist/local-download-profiles.d.mts +2 -2
- package/dist/local-download-profiles.mjs +1 -1
- package/dist/markdown-facts.d.mts +1 -1
- package/dist/markdown-facts.mjs +1 -1
- package/dist/{markdown-reading-w686Obnl.d.mts → markdown-reading--Sr6JAl5.d.mts} +1 -1
- package/dist/{markdown-reading-0L-mVBJp.mjs → markdown-reading-LtgFpB8E.mjs} +1 -1
- package/dist/markdown-reading.d.mts +2 -2
- package/dist/markdown-reading.mjs +2 -2
- package/dist/{notifications-COeXWb2h.d.mts → notifications-ClhEHZU3.d.mts} +4 -4
- package/dist/{notifications-E6_WBjQO.mjs → notifications-Cy74GVN7.mjs} +2 -2
- package/dist/notifications.d.mts +2 -2
- package/dist/notifications.mjs +3 -3
- package/dist/{openspec-annotations-DiHje5HD.mjs → openspec-annotations-BJ1BlVyo.mjs} +2 -2
- package/dist/{openspec-annotations-BXAqKLXc.d.mts → openspec-annotations-BylPW5rz.d.mts} +2 -2
- package/dist/openspec-annotations.d.mts +3 -3
- package/dist/openspec-annotations.mjs +3 -3
- package/dist/openspec-compat.d.mts +14 -14
- package/dist/openspec-compat.mjs +18 -32
- package/dist/{openspec-projection-DvJnsxLZ.mjs → openspec-projection-Cno7FlwE.mjs} +2 -2
- package/dist/{openspec-projection-BwPchxIq.d.mts → openspec-projection-EgTIZCfC.d.mts} +3 -3
- package/dist/openspec-projection.d.mts +5 -5
- package/dist/openspec-projection.mjs +4 -4
- package/dist/opsx-display-path.d.mts +1 -1
- package/dist/opsx-display-path.mjs +1 -1
- package/dist/{opsx-entity-D3aLGfC7.d.mts → opsx-entity-BNthD6Ks.d.mts} +2 -2
- package/dist/opsx-entity.d.mts +7 -7
- package/dist/opsx-entity.mjs +1 -1
- package/dist/{opsx-schema-detail-DJ9QKFSH.d.mts → opsx-schema-detail-B4li4BMU.d.mts} +2 -2
- package/dist/opsx-schema-detail.d.mts +8 -8
- package/dist/opsx-schema-detail.mjs +1 -1
- package/dist/{opsx-types-BJTT7C4w.d.mts → opsx-types-DP8JjGq0.d.mts} +361 -112
- package/dist/opsx-workflows.d.mts +1 -1
- package/dist/opsx-workflows.mjs +1 -1
- package/dist/{planning-cli-projection-DrkT18EI.mjs → planning-cli-projection-BreqsrYA.mjs} +51 -11
- package/dist/planning-cli-projection.d.mts +26 -25
- package/dist/planning-cli-projection.mjs +7 -7
- package/dist/{schemas-DKF6kaQ3.d.mts → schemas-divIlNvA.d.mts} +92 -92
- package/dist/{sounds-CsPiQKxX.d.mts → sounds-qIKfPgxj.d.mts} +1 -1
- package/dist/sounds.d.mts +1 -1
- package/dist/sounds.mjs +1 -1
- package/dist/{spec-catalog-Dv2qolxy.mjs → spec-catalog-DEk_oHAx.mjs} +99 -18
- package/dist/spec-catalog.d.mts +27 -26
- package/dist/spec-catalog.mjs +5 -5
- package/dist/{store-content-projection-CiMcGZnG.mjs → store-content-projection-Bpdb7_d9.mjs} +1 -1
- package/dist/store-content-projection.d.mts +1 -1
- package/dist/store-content-projection.mjs +2 -2
- package/dist/{store-mutation-protocol-CLtYUSwC.mjs → store-mutation-protocol-CJGUWWI6.mjs} +1 -1
- package/dist/{store-mutation-protocol-ZUGSy1a0.d.mts → store-mutation-protocol-Cr4pWWbh.d.mts} +24 -24
- package/dist/store-mutation-protocol.d.mts +1 -1
- package/dist/store-mutation-protocol.mjs +2 -2
- package/dist/{store-types-B42Br9lz.d.mts → store-types-DjWxHHvs.d.mts} +1 -1
- package/dist/store-types.d.mts +5 -5
- package/dist/store-types.mjs +1 -1
- package/dist/{task-progress-DpZak5xA.mjs → task-progress-Bvid_Ws8.mjs} +1 -1
- package/dist/task-progress.d.mts +6 -6
- package/dist/task-progress.mjs +2 -2
- package/dist/{terminal-audio-BXa1vpkF.d.mts → terminal-audio-CSUGxzx3.d.mts} +2 -2
- package/dist/{terminal-audio-punFQHXI.mjs → terminal-audio-DeubAfFC.mjs} +1 -1
- package/dist/terminal-audio.d.mts +2 -2
- package/dist/terminal-audio.mjs +2 -2
- package/dist/terminal-control.d.mts +2 -2
- package/dist/terminal-control.mjs +1 -1
- package/dist/{terminal-invocation-Bkic6avG.d.mts → terminal-invocation-kFxUD_5T.d.mts} +26 -26
- package/dist/terminal-invocation.d.mts +1 -1
- package/dist/terminal-invocation.mjs +1 -1
- package/dist/terminal-theme.d.mts +1 -1
- package/dist/terminal-theme.mjs +1 -1
- package/dist/translation-language-pair.d.mts +1 -1
- package/dist/translation-language-pair.mjs +1 -1
- package/dist/translator.d.mts +1 -1
- package/dist/translator.mjs +1 -1
- package/package.json +15 -5
- /package/dist/{document-translation-J_NddeDy.d.mts → document-translation-BNbM3fEj.d.mts} +0 -0
- /package/dist/{local-download-profiles-DK4g6FRe.mjs → local-download-profiles-h9lUTXr-.mjs} +0 -0
- /package/dist/{markdown-facts-Dve6IAJP.mjs → markdown-facts-BIx47NNY.mjs} +0 -0
- /package/dist/{markdown-facts-C9yWB2I9.d.mts → markdown-facts-DLclHfpE.d.mts} +0 -0
- /package/dist/{opsx-display-path-eWJ4ve-O.d.mts → opsx-display-path-BD34M8QV.d.mts} +0 -0
- /package/dist/{opsx-display-path-DuPEvPV0.mjs → opsx-display-path-ocbNzMZj.mjs} +0 -0
- /package/dist/{opsx-entity-Br5S5N0o.mjs → opsx-entity-BnO3k48r.mjs} +0 -0
- /package/dist/{opsx-schema-detail-CckZIEVr.mjs → opsx-schema-detail-zk8ePaKK.mjs} +0 -0
- /package/dist/{opsx-workflows-Bhh_bI-e.d.mts → opsx-workflows-DX1r6e5j.d.mts} +0 -0
- /package/dist/{opsx-workflows-GPZSe1C_.mjs → opsx-workflows-byPfLlo8.mjs} +0 -0
- /package/dist/{schemas-BrS9qSB3.mjs → schemas-CMThmKx1.mjs} +0 -0
- /package/dist/{sounds-na4c8j0c.mjs → sounds-6prQvKXl.mjs} +0 -0
- /package/dist/{store-content-projection-BPDCma8v.d.mts → store-content-projection-R74MV_sD.d.mts} +0 -0
- /package/dist/{store-types-Cs40yohL.mjs → store-types-CvpEVNoE.mjs} +0 -0
- /package/dist/{terminal-control-BvoxwQ6m.mjs → terminal-control-c6oS-lFb.mjs} +0 -0
- /package/dist/{terminal-invocation-BexVY5E2.mjs → terminal-invocation-DIpoFYDo.mjs} +0 -0
- /package/dist/{terminal-theme-DIhzj5Si.mjs → terminal-theme-Byzxmnjm.mjs} +0 -0
- /package/dist/{terminal-theme-BzARb2Do.d.mts → terminal-theme-DX08Gci8.d.mts} +0 -0
- /package/dist/{translation-language-pair-DeAiww3_.d.mts → translation-language-pair-BR5uxGm-.d.mts} +0 -0
- /package/dist/{translation-language-pair-BV2cGjfv.mjs → translation-language-pair-DG9mOuFD.mjs} +0 -0
- /package/dist/{translator-DCCZeHt1.mjs → translator-CEGdRmKw.mjs} +0 -0
- /package/dist/{translator-D_V2ZFPP.d.mts → translator-DgIIyl6v.d.mts} +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 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import "./
|
|
3
|
-
import "./
|
|
4
|
-
import "./
|
|
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-
|
|
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 };
|
package/dist/cli-projection.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./common-
|
|
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-
|
|
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 (
|
|
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. */
|