@nimiplatform/app-tools 0.1.3 → 0.2.1
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/LICENSE +198 -6
- package/README.md +83 -27
- package/bin/nimi-app.mjs +328 -45
- package/lib/app-access-declaration.mjs +49 -0
- package/lib/app-doctor-update.mjs +411 -149
- package/lib/app-pack.mjs +402 -0
- package/lib/app-project-lifecycle.mjs +1141 -0
- package/lib/app-scaffold-capabilities.mjs +769 -0
- package/lib/app-scaffold-default-source.mjs +21 -0
- package/lib/app-scaffold-profiles.mjs +1093 -0
- package/lib/app-scaffold.mjs +1266 -813
- package/lib/index.mjs +195 -42
- package/lib/simulator-conformance-ast.mjs +498 -0
- package/lib/simulator-conformance-css.mjs +116 -0
- package/lib/simulator-conformance-graph.mjs +757 -0
- package/lib/simulator-conformance.d.mts +14 -0
- package/lib/simulator-conformance.mjs +203 -0
- package/lib/simulator-css-profile.d.mts +27 -0
- package/lib/simulator-css-profile.mjs +531 -0
- package/lib/simulator-kit-export-resolution.mjs +70 -0
- package/lib/simulator-manifest.mjs +334 -0
- package/lib/windows-powershell.mjs +7 -0
- package/package.json +66 -3
- package/scripts/dev-shell.mjs +465 -0
- package/scripts/sync-app-source.mjs +300 -0
- package/scripts/sync-scaffold-versions.mjs +91 -0
- package/templates/app-source/LICENSE +21 -0
- package/templates/app-source/src/ai-studio-core/ai-config.ts +100 -0
- package/templates/app-source/src/ai-studio-core/ai-studio-core.css +338 -0
- package/templates/app-source/src/ai-studio-core/contexts.tsx +61 -0
- package/templates/app-source/src/ai-studio-core/history-policy.ts +447 -0
- package/templates/app-source/src/ai-studio-core/history.ts +824 -0
- package/templates/app-source/src/ai-studio-core/host-context.tsx +79 -0
- package/templates/app-source/src/ai-studio-core/index.ts +214 -0
- package/templates/app-source/src/ai-studio-core/messages/en.json +310 -0
- package/templates/app-source/src/ai-studio-core/messages/index.ts +47 -0
- package/templates/app-source/src/ai-studio-core/messages/zh.json +310 -0
- package/templates/app-source/src/ai-studio-core/module-registration.ts +109 -0
- package/templates/app-source/src/ai-studio-core/non-success-presentation.ts +65 -0
- package/templates/app-source/src/ai-studio-core/parameter-fields.tsx +247 -0
- package/templates/app-source/src/ai-studio-core/parameters.ts +110 -0
- package/templates/app-source/src/ai-studio-core/prompt-drafts.ts +69 -0
- package/templates/app-source/src/ai-studio-core/run-target.ts +123 -0
- package/templates/app-source/src/ai-studio-core/runtime-dispatcher.ts +35 -0
- package/templates/app-source/src/ai-studio-core/runtime-types.ts +86 -0
- package/templates/app-source/src/ai-studio-core/runtime.ts +306 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-admission.ts +38 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-ai-config.tsx +30 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-artifact-preview.ts +40 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-composer.tsx +257 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-history.tsx +676 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-input.ts +19 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-output.tsx +291 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-result.tsx +413 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +174 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-studio-result.tsx +449 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-surface.tsx +45 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing.tsx +494 -0
- package/templates/app-source/src/ai-studio-core/studio-directives.ts +33 -0
- package/templates/app-source/src/ai-studio-core/workspace.tsx +381 -0
- package/templates/app-source/src/product-modules/agent-center/index.tsx +27 -0
- package/templates/app-source/src/product-modules/agent-conversation/index.tsx +19 -0
- package/templates/app-source/src/product-modules/agent-realtime/index.tsx +29 -0
- package/templates/app-source/src/product-modules/kit-recipes/gallery.tsx +142 -0
- package/templates/app-source/src/product-modules/kit-recipes/index.tsx +19 -0
- package/templates/app-source/src/product-modules/kit-recipes/kit-component-gallery-data-recipes.tsx +336 -0
- package/templates/app-source/src/product-modules/kit-recipes/kit-component-gallery-demos.tsx +165 -0
- package/templates/app-source/src/product-modules/kit-recipes/kit-component-gallery-recipes.tsx +682 -0
- package/templates/app-source/src/product-modules/kit-recipes/kit-component-gallery-surface.tsx +341 -0
- package/templates/app-source/src/studio-modules/studio-create/descriptors.ts +26 -0
- package/templates/app-source/src/studio-modules/studio-create/index.ts +14 -0
- package/templates/app-source/src/studio-modules/studio-create/messages/en.json +67 -0
- package/templates/app-source/src/studio-modules/studio-create/messages/index.ts +5 -0
- package/templates/app-source/src/studio-modules/studio-create/messages/zh.json +67 -0
- package/templates/app-source/src/studio-modules/studio-create/parameter-panel.tsx +153 -0
- package/templates/app-source/src/studio-modules/studio-create/parameters.ts +70 -0
- package/templates/app-source/src/studio-modules/studio-create/registration.ts +46 -0
- package/templates/app-source/src/studio-modules/studio-create/runtime.ts +339 -0
- package/templates/app-source/src/studio-modules/studio-media/descriptors.ts +22 -0
- package/templates/app-source/src/studio-modules/studio-media/index.ts +12 -0
- package/templates/app-source/src/studio-modules/studio-media/messages/en.json +82 -0
- package/templates/app-source/src/studio-modules/studio-media/messages/index.ts +5 -0
- package/templates/app-source/src/studio-modules/studio-media/messages/zh.json +82 -0
- package/templates/app-source/src/studio-modules/studio-media/parameter-panel.tsx +283 -0
- package/templates/app-source/src/studio-modules/studio-media/parameters.ts +94 -0
- package/templates/app-source/src/studio-modules/studio-media/registration.ts +44 -0
- package/templates/app-source/src/studio-modules/studio-media/runtime.ts +113 -0
- package/templates/app-source/src/studio-modules/studio-voice/descriptors.ts +28 -0
- package/templates/app-source/src/studio-modules/studio-voice/index.ts +16 -0
- package/templates/app-source/src/studio-modules/studio-voice/messages/en.json +99 -0
- package/templates/app-source/src/studio-modules/studio-voice/messages/index.ts +5 -0
- package/templates/app-source/src/studio-modules/studio-voice/messages/zh.json +99 -0
- package/templates/app-source/src/studio-modules/studio-voice/parameter-panel.tsx +284 -0
- package/templates/app-source/src/studio-modules/studio-voice/parameters.ts +116 -0
- package/templates/app-source/src/studio-modules/studio-voice/registration.ts +59 -0
- package/templates/app-source/src/studio-modules/studio-voice/runtime.ts +347 -0
- package/templates/app-source/src/workbench-core/empty-state.tsx +31 -0
- package/templates/app-source/src/workbench-core/index.ts +17 -0
- package/templates/app-source/src/workbench-core/runtime-gate.tsx +131 -0
- package/templates/app-source/src/workbench-core/workbench-core.css +255 -0
- package/templates/app-source/src/workbench-core/workbench-core.tsx +140 -0
- package/templates/app-source.manifest.json +333 -0
- package/templates/default-starter/AGENTS.md +33 -0
- package/templates/default-starter/LICENSE +21 -0
- package/templates/default-starter/README.md +41 -0
- package/templates/default-starter/SECURITY.md +5 -0
- package/templates/default-starter/index.html +12 -0
- package/templates/default-starter/scripts/validate.mjs +26 -0
- package/templates/default-starter/src/shell/App.tsx +27 -0
- package/templates/default-starter/src/shell/auth/app-identity.ts +3 -0
- package/templates/default-starter/src/shell/auth/local-app-client.ts +18 -0
- package/templates/default-starter/src/shell/auth/runtime-platform.ts +110 -0
- package/templates/default-starter/src/shell/authenticated-shell.tsx +20 -0
- package/templates/default-starter/src/shell/workbench-target-adapter.ts +40 -0
- package/templates/default-starter/src/styles.css +26 -0
- package/templates/default-starter/src-tauri/Cargo.toml +17 -0
- package/templates/default-starter/src-tauri/build.rs +5 -0
- package/templates/default-starter/src-tauri/capabilities/default.json +7 -0
- package/templates/default-starter/src-tauri/tauri.conf.json +26 -0
- package/templates/default-starter/tsconfig.json +18 -0
- package/templates/default-starter.manifest.json +99 -0
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isAlias,
|
|
3
|
+
isMap,
|
|
4
|
+
isScalar,
|
|
5
|
+
isSeq,
|
|
6
|
+
parseDocument,
|
|
7
|
+
} from 'yaml';
|
|
8
|
+
|
|
9
|
+
export const SIMULATOR_MODULE_PROTOCOL = 'nimi.simulator.module/v1';
|
|
10
|
+
export const SIMULATOR_OPERATION_PROTOCOL = 'nimi.simulator.operation/v1';
|
|
11
|
+
export const SIMULATOR_INTERACTION_PROTOCOL = 'nimi.simulator.interaction/v1';
|
|
12
|
+
export const SIMULATOR_RENDERER_HOST_PROTOCOL = 'nimi.renderer.host/v1';
|
|
13
|
+
export const SIMULATOR_MANIFEST_PATH = 'nimi.simulator.yaml';
|
|
14
|
+
|
|
15
|
+
const MODULE_ID_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
16
|
+
const COMMAND_EVENT_PATTERN = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?:\.[a-z][a-z0-9-]*){2,}$/;
|
|
17
|
+
// Kit/SDK catalog IDs retain their owner-defined casing (for example the
|
|
18
|
+
// canonical SDK method `nimi.ai.generateText`). App-owned command/event IDs
|
|
19
|
+
// remain separately constrained to the lower-case module namespace.
|
|
20
|
+
const CATALOG_ID_PATTERN = /^[a-z][A-Za-z0-9-]*(?:\.[a-z][A-Za-z0-9-]*)+$/;
|
|
21
|
+
const EXPORT_NAME_PATTERN = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
22
|
+
const CORE_TAGS = new Set([
|
|
23
|
+
'tag:yaml.org,2002:map',
|
|
24
|
+
'tag:yaml.org,2002:seq',
|
|
25
|
+
'tag:yaml.org,2002:str',
|
|
26
|
+
'tag:yaml.org,2002:null',
|
|
27
|
+
'tag:yaml.org,2002:bool',
|
|
28
|
+
'tag:yaml.org,2002:int',
|
|
29
|
+
'tag:yaml.org,2002:float',
|
|
30
|
+
]);
|
|
31
|
+
const GENERATED_PATH_SEGMENTS = new Set([
|
|
32
|
+
'.next',
|
|
33
|
+
'.pnpm',
|
|
34
|
+
'build',
|
|
35
|
+
'coverage',
|
|
36
|
+
'dist',
|
|
37
|
+
'dist-electron',
|
|
38
|
+
'node_modules',
|
|
39
|
+
'out',
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
export class SimulatorConformanceError extends Error {
|
|
43
|
+
constructor(code, message, fieldPath = '') {
|
|
44
|
+
super(fieldPath ? `${fieldPath}: ${message}` : message);
|
|
45
|
+
this.name = 'SimulatorConformanceError';
|
|
46
|
+
this.code = code;
|
|
47
|
+
this.fieldPath = fieldPath;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function fail(code, message, fieldPath = '') {
|
|
52
|
+
throw new SimulatorConformanceError(code, message, fieldPath);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function utf8Length(value) {
|
|
56
|
+
return Buffer.byteLength(value, 'utf8');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function assertPlainObject(value, fieldPath) {
|
|
60
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
61
|
+
fail('SIM_MANIFEST_TYPE', 'must be a mapping', fieldPath);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function assertExactKeys(value, required, fieldPath) {
|
|
66
|
+
assertPlainObject(value, fieldPath);
|
|
67
|
+
const allowed = new Set(required);
|
|
68
|
+
for (const key of Object.keys(value)) {
|
|
69
|
+
if (!allowed.has(key)) {
|
|
70
|
+
fail('SIM_MANIFEST_UNKNOWN_FIELD', `unknown field ${JSON.stringify(key)}`, fieldPath || '<root>');
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
for (const key of required) {
|
|
74
|
+
if (!Object.hasOwn(value, key)) {
|
|
75
|
+
fail('SIM_MANIFEST_REQUIRED_FIELD', 'required field is missing', fieldPath ? `${fieldPath}.${key}` : key);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function assertString(value, fieldPath, { minBytes = 1, maxBytes = 4096, pattern = null } = {}) {
|
|
81
|
+
if (typeof value !== 'string') {
|
|
82
|
+
fail('SIM_MANIFEST_TYPE', 'must be a string', fieldPath);
|
|
83
|
+
}
|
|
84
|
+
const length = utf8Length(value);
|
|
85
|
+
if (length < minBytes || length > maxBytes) {
|
|
86
|
+
fail('SIM_MANIFEST_STRING_LENGTH', `must contain ${minBytes}-${maxBytes} UTF-8 bytes`, fieldPath);
|
|
87
|
+
}
|
|
88
|
+
if (value !== value.normalize('NFC')) {
|
|
89
|
+
fail('SIM_MANIFEST_NON_NFC', 'must be NFC-normalized', fieldPath);
|
|
90
|
+
}
|
|
91
|
+
if (pattern && !pattern.test(value)) {
|
|
92
|
+
fail('SIM_MANIFEST_IDENTIFIER', 'has invalid identifier syntax', fieldPath);
|
|
93
|
+
}
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function assertStringArray(value, fieldPath, options = {}) {
|
|
98
|
+
if (!Array.isArray(value)) {
|
|
99
|
+
fail('SIM_MANIFEST_TYPE', 'must be a sequence', fieldPath);
|
|
100
|
+
}
|
|
101
|
+
if (options.nonEmpty && value.length === 0) {
|
|
102
|
+
fail('SIM_MANIFEST_EMPTY_SET', 'must not be empty', fieldPath);
|
|
103
|
+
}
|
|
104
|
+
const seen = new Set();
|
|
105
|
+
return value.map((entry, index) => {
|
|
106
|
+
const checked = assertString(entry, `${fieldPath}[${index}]`, options.string || {});
|
|
107
|
+
if (seen.has(checked)) {
|
|
108
|
+
fail('SIM_MANIFEST_DUPLICATE_VALUE', `duplicate value ${JSON.stringify(checked)}`, fieldPath);
|
|
109
|
+
}
|
|
110
|
+
seen.add(checked);
|
|
111
|
+
return checked;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function assertSimulatorSourcePath(value, fieldPath = 'path') {
|
|
116
|
+
assertString(value, fieldPath, { maxBytes: 4096 });
|
|
117
|
+
if (value.startsWith('/') || value.startsWith('./')) {
|
|
118
|
+
fail('SIM_MANIFEST_PATH', 'must be a source-root-relative POSIX path', fieldPath);
|
|
119
|
+
}
|
|
120
|
+
if (value.includes('\\') || /^[A-Za-z][A-Za-z0-9+.-]*:/.test(value) || value.startsWith('//')) {
|
|
121
|
+
fail('SIM_MANIFEST_PATH', 'URL, authority, drive, and backslash paths are forbidden', fieldPath);
|
|
122
|
+
}
|
|
123
|
+
if (/[?#*{}\[\]!]/.test(value)) {
|
|
124
|
+
fail('SIM_MANIFEST_CONDITIONAL_PATH', 'conditional and glob paths are forbidden', fieldPath);
|
|
125
|
+
}
|
|
126
|
+
const segments = value.split('/');
|
|
127
|
+
if (segments.some((segment) => !segment || segment === '.' || segment === '..')) {
|
|
128
|
+
fail('SIM_MANIFEST_PATH', 'empty, dot, and parent path segments are forbidden', fieldPath);
|
|
129
|
+
}
|
|
130
|
+
if (segments.some((segment) => GENERATED_PATH_SEGMENTS.has(segment))) {
|
|
131
|
+
fail('SIM_MANIFEST_GENERATED_PATH', 'package-cache and generated bundle paths are forbidden', fieldPath);
|
|
132
|
+
}
|
|
133
|
+
if (/\.(?:bundle|min)\.(?:[cm]?js|css)$/i.test(value)) {
|
|
134
|
+
fail('SIM_MANIFEST_PREBUILT_PATH', 'prebuilt JavaScript and CSS artifacts are forbidden', fieldPath);
|
|
135
|
+
}
|
|
136
|
+
return value;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function inspectYamlNode(node, fieldPath = '<root>') {
|
|
140
|
+
if (!node) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (isAlias(node)) {
|
|
144
|
+
fail('SIM_MANIFEST_YAML_ALIAS', 'YAML aliases are forbidden', fieldPath);
|
|
145
|
+
}
|
|
146
|
+
if (node.anchor) {
|
|
147
|
+
fail('SIM_MANIFEST_YAML_ANCHOR', 'YAML anchors are forbidden', fieldPath);
|
|
148
|
+
}
|
|
149
|
+
if (node.tag && !CORE_TAGS.has(node.tag)) {
|
|
150
|
+
fail('SIM_MANIFEST_YAML_CUSTOM_TAG', `custom YAML tag ${JSON.stringify(node.tag)} is forbidden`, fieldPath);
|
|
151
|
+
}
|
|
152
|
+
if (isMap(node)) {
|
|
153
|
+
const seen = new Set();
|
|
154
|
+
for (const pair of node.items) {
|
|
155
|
+
if (!isScalar(pair.key) || typeof pair.key.value !== 'string') {
|
|
156
|
+
fail('SIM_MANIFEST_YAML_KEY', 'mapping keys must be strings', fieldPath);
|
|
157
|
+
}
|
|
158
|
+
const key = pair.key.value;
|
|
159
|
+
if (key === '<<') {
|
|
160
|
+
fail('SIM_MANIFEST_YAML_MERGE', 'YAML merge keys are forbidden', fieldPath);
|
|
161
|
+
}
|
|
162
|
+
if (seen.has(key)) {
|
|
163
|
+
fail('SIM_MANIFEST_YAML_DUPLICATE_KEY', `duplicate key ${JSON.stringify(key)}`, fieldPath);
|
|
164
|
+
}
|
|
165
|
+
seen.add(key);
|
|
166
|
+
inspectYamlNode(pair.key, `${fieldPath}.${key}`);
|
|
167
|
+
inspectYamlNode(pair.value, `${fieldPath}.${key}`);
|
|
168
|
+
}
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
if (isSeq(node)) {
|
|
172
|
+
node.items.forEach((item, index) => inspectYamlNode(item, `${fieldPath}[${index}]`));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function parseStrictYaml(text, label) {
|
|
177
|
+
if (typeof text !== 'string') {
|
|
178
|
+
fail('SIM_MANIFEST_TYPE', 'manifest source must be a UTF-8 string', label);
|
|
179
|
+
}
|
|
180
|
+
const document = parseDocument(text, {
|
|
181
|
+
schema: 'core',
|
|
182
|
+
uniqueKeys: true,
|
|
183
|
+
maxAliasCount: 0,
|
|
184
|
+
prettyErrors: false,
|
|
185
|
+
strict: true,
|
|
186
|
+
});
|
|
187
|
+
if (document.errors.length > 0) {
|
|
188
|
+
const duplicate = document.errors.some((error) => /unique keys|must be unique|already set|duplicate/i.test(error.message));
|
|
189
|
+
fail(
|
|
190
|
+
duplicate ? 'SIM_MANIFEST_YAML_DUPLICATE_KEY' : 'SIM_MANIFEST_YAML_PARSE',
|
|
191
|
+
document.errors.map((error) => error.message).join('; '),
|
|
192
|
+
label,
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
inspectYamlNode(document.contents);
|
|
196
|
+
let value;
|
|
197
|
+
try {
|
|
198
|
+
value = document.toJS({ maxAliasCount: 0, mapAsMap: false });
|
|
199
|
+
} catch (error) {
|
|
200
|
+
fail('SIM_MANIFEST_YAML_PARSE', error instanceof Error ? error.message : String(error), label);
|
|
201
|
+
}
|
|
202
|
+
return value;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function validateModuleId(value, fieldPath = 'module_id') {
|
|
206
|
+
assertString(value, fieldPath, { minBytes: 2, maxBytes: 64, pattern: MODULE_ID_PATTERN });
|
|
207
|
+
return value;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function validateExportName(value, fieldPath) {
|
|
211
|
+
return assertString(value, fieldPath, { maxBytes: 128, pattern: EXPORT_NAME_PATTERN });
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function validateCatalogIds(values, fieldPath) {
|
|
215
|
+
return assertStringArray(values, fieldPath, {
|
|
216
|
+
string: { maxBytes: 128, pattern: CATALOG_ID_PATTERN },
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function validateCommandEventIds(values, fieldPath, moduleId) {
|
|
221
|
+
const checked = assertStringArray(values, fieldPath, {
|
|
222
|
+
string: { maxBytes: 128, pattern: COMMAND_EVENT_PATTERN },
|
|
223
|
+
});
|
|
224
|
+
for (const value of checked) {
|
|
225
|
+
if (value.startsWith('simulator.') || !value.startsWith(`${moduleId}.`)) {
|
|
226
|
+
fail(
|
|
227
|
+
'SIM_MANIFEST_INTERACTION_NAMESPACE',
|
|
228
|
+
`must use the App-owned ${JSON.stringify(`${moduleId}.`)} namespace`,
|
|
229
|
+
fieldPath,
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return checked;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function validateRoute(value, fieldPath) {
|
|
237
|
+
assertString(value, fieldPath, { maxBytes: 512 });
|
|
238
|
+
if (!value.startsWith('/') || value.startsWith('//')) {
|
|
239
|
+
fail('SIM_MANIFEST_ROUTE', 'must begin with exactly one slash', fieldPath);
|
|
240
|
+
}
|
|
241
|
+
if (/^[A-Za-z][A-Za-z0-9+.-]*:/.test(value) || value.includes('\\') || /[\u0000-\u001f\u007f]/.test(value)) {
|
|
242
|
+
fail('SIM_MANIFEST_ROUTE', 'scheme, backslash, and control characters are forbidden', fieldPath);
|
|
243
|
+
}
|
|
244
|
+
const pathOnly = value.split(/[?#]/, 1)[0];
|
|
245
|
+
if (pathOnly.split('/').some((segment) => segment === '..')) {
|
|
246
|
+
fail('SIM_MANIFEST_ROUTE', 'parent route segments are forbidden', fieldPath);
|
|
247
|
+
}
|
|
248
|
+
return value;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export function validateSimulatorManifest(value) {
|
|
252
|
+
assertExactKeys(value, ['schema', 'module_id', 'composition', 'renderer', 'requires', 'fixtures'], '');
|
|
253
|
+
if (value.schema !== SIMULATOR_MODULE_PROTOCOL) {
|
|
254
|
+
fail('SIM_MANIFEST_PROTOCOL', `must equal ${SIMULATOR_MODULE_PROTOCOL}`, 'schema');
|
|
255
|
+
}
|
|
256
|
+
const moduleId = validateModuleId(value.module_id);
|
|
257
|
+
|
|
258
|
+
assertExactKeys(
|
|
259
|
+
value.composition,
|
|
260
|
+
['factory_entry', 'factory_export', 'style_entry'],
|
|
261
|
+
'composition',
|
|
262
|
+
);
|
|
263
|
+
assertSimulatorSourcePath(value.composition.factory_entry, 'composition.factory_entry');
|
|
264
|
+
validateExportName(value.composition.factory_export, 'composition.factory_export');
|
|
265
|
+
assertSimulatorSourcePath(value.composition.style_entry, 'composition.style_entry');
|
|
266
|
+
if (value.composition.factory_entry.startsWith('src/simulator/')) {
|
|
267
|
+
fail('SIM_MANIFEST_ALTERNATE_FACTORY', 'the canonical production factory cannot be Simulator-only source', 'composition.factory_entry');
|
|
268
|
+
}
|
|
269
|
+
if (value.composition.style_entry.startsWith('src/simulator/')) {
|
|
270
|
+
fail('SIM_MANIFEST_ALTERNATE_STYLE', 'the canonical production style cannot be Simulator-only source', 'composition.style_entry');
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
assertExactKeys(value.renderer, ['entry', 'export', 'adapter_entry', 'adapter_export', 'surfaces'], 'renderer');
|
|
274
|
+
assertSimulatorSourcePath(value.renderer.entry, 'renderer.entry');
|
|
275
|
+
validateExportName(value.renderer.export, 'renderer.export');
|
|
276
|
+
assertSimulatorSourcePath(value.renderer.adapter_entry, 'renderer.adapter_entry');
|
|
277
|
+
validateExportName(value.renderer.adapter_export, 'renderer.adapter_export');
|
|
278
|
+
if (!value.renderer.entry.startsWith('src/simulator/')) {
|
|
279
|
+
fail('SIM_MANIFEST_RENDERER_LOCATION', 'Simulator renderer entry must be under src/simulator/', 'renderer.entry');
|
|
280
|
+
}
|
|
281
|
+
if (!value.renderer.adapter_entry.startsWith('src/simulator/')) {
|
|
282
|
+
fail('SIM_MANIFEST_ADAPTER_LOCATION', 'Simulator Adapter must be under src/simulator/', 'renderer.adapter_entry');
|
|
283
|
+
}
|
|
284
|
+
if (!Array.isArray(value.renderer.surfaces) || value.renderer.surfaces.length === 0) {
|
|
285
|
+
fail('SIM_MANIFEST_SURFACES', 'must be a non-empty sequence', 'renderer.surfaces');
|
|
286
|
+
}
|
|
287
|
+
const surfaceIds = new Set();
|
|
288
|
+
let mainCount = 0;
|
|
289
|
+
for (const [index, surface] of value.renderer.surfaces.entries()) {
|
|
290
|
+
const fieldPath = `renderer.surfaces[${index}]`;
|
|
291
|
+
assertExactKeys(surface, ['id', 'factory_surface', 'label', 'initial_route'], fieldPath);
|
|
292
|
+
assertString(surface.id, `${fieldPath}.id`, { minBytes: 2, maxBytes: 64, pattern: MODULE_ID_PATTERN });
|
|
293
|
+
if (surfaceIds.has(surface.id)) {
|
|
294
|
+
fail('SIM_MANIFEST_DUPLICATE_SURFACE', `duplicate surface ${JSON.stringify(surface.id)}`, `${fieldPath}.id`);
|
|
295
|
+
}
|
|
296
|
+
surfaceIds.add(surface.id);
|
|
297
|
+
if (surface.id === 'main') {
|
|
298
|
+
mainCount += 1;
|
|
299
|
+
}
|
|
300
|
+
assertString(surface.factory_surface, `${fieldPath}.factory_surface`, { maxBytes: 128, pattern: MODULE_ID_PATTERN });
|
|
301
|
+
assertString(surface.label, `${fieldPath}.label`, { maxBytes: 128 });
|
|
302
|
+
validateRoute(surface.initial_route, `${fieldPath}.initial_route`);
|
|
303
|
+
}
|
|
304
|
+
if (mainCount !== 1) {
|
|
305
|
+
fail('SIM_MANIFEST_MAIN_SURFACE', 'exactly one surface must have id main', 'renderer.surfaces');
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
assertExactKeys(
|
|
309
|
+
value.requires,
|
|
310
|
+
['kit_capabilities', 'sdk_methods', 'simulator_commands', 'simulator_events'],
|
|
311
|
+
'requires',
|
|
312
|
+
);
|
|
313
|
+
validateCatalogIds(value.requires.kit_capabilities, 'requires.kit_capabilities');
|
|
314
|
+
validateCatalogIds(value.requires.sdk_methods, 'requires.sdk_methods');
|
|
315
|
+
validateCommandEventIds(value.requires.simulator_commands, 'requires.simulator_commands', moduleId);
|
|
316
|
+
validateCommandEventIds(value.requires.simulator_events, 'requires.simulator_events', moduleId);
|
|
317
|
+
|
|
318
|
+
assertExactKeys(value.fixtures, ['conformance'], 'fixtures');
|
|
319
|
+
assertSimulatorSourcePath(value.fixtures.conformance, 'fixtures.conformance');
|
|
320
|
+
if (!value.fixtures.conformance.startsWith('src/simulator/')) {
|
|
321
|
+
fail('SIM_MANIFEST_FIXTURE_LOCATION', 'conformance fixture must be under src/simulator/', 'fixtures.conformance');
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return Object.freeze(value);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export function parseSimulatorManifest(text, options = {}) {
|
|
328
|
+
const label = options.label || SIMULATOR_MANIFEST_PATH;
|
|
329
|
+
return validateSimulatorManifest(parseStrictYaml(text, label));
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export const simulatorManifestInternals = Object.freeze({
|
|
333
|
+
parseStrictYaml,
|
|
334
|
+
});
|
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nimiplatform/app-tools",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Public app-authoring CLI for Nimi App projects.",
|
|
4
5
|
"license": "Apache-2.0",
|
|
5
6
|
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=24.0.0"
|
|
9
|
+
},
|
|
6
10
|
"private": false,
|
|
7
11
|
"repository": {
|
|
8
12
|
"type": "git",
|
|
@@ -13,13 +17,72 @@
|
|
|
13
17
|
"access": "public",
|
|
14
18
|
"provenance": true
|
|
15
19
|
},
|
|
20
|
+
"nimiScaffoldVersions": {
|
|
21
|
+
"sdkVersion": "^0.7.0",
|
|
22
|
+
"appToolsVersion": "^0.2.1",
|
|
23
|
+
"nimicodingVersion": "0.6.1",
|
|
24
|
+
"aiSdkVersion": "^6.0.85",
|
|
25
|
+
"kitVersion": "^0.3.0",
|
|
26
|
+
"reactVersion": "^19.2.8",
|
|
27
|
+
"reactDomVersion": "^19.2.8",
|
|
28
|
+
"i18nextVersion": "^25.10.10",
|
|
29
|
+
"lucideReactVersion": "^0.577.0",
|
|
30
|
+
"tsxVersion": "^4.23.13",
|
|
31
|
+
"typescriptVersion": "^5.9.3",
|
|
32
|
+
"nodeTypesVersion": "^24.13.3",
|
|
33
|
+
"reactTypesVersion": "^19.2.18",
|
|
34
|
+
"reactDomTypesVersion": "^19.2.5",
|
|
35
|
+
"viteVersion": "^7.3.6",
|
|
36
|
+
"viteReactPluginVersion": "^5.2.0",
|
|
37
|
+
"tailwindcssVersion": "^4.3.3",
|
|
38
|
+
"tailwindcssViteVersion": "^4.3.3",
|
|
39
|
+
"tauriCliVersion": "^2.11.4",
|
|
40
|
+
"yamlVersion": "^2.9.0",
|
|
41
|
+
"nimiShellTauriVersion": "0.2.1",
|
|
42
|
+
"electronVersion": "^42.10.1",
|
|
43
|
+
"esbuildVersion": "^0.28.2",
|
|
44
|
+
"packageManager": "pnpm@10.34.5"
|
|
45
|
+
},
|
|
16
46
|
"bin": {
|
|
17
47
|
"nimi-app": "./bin/nimi-app.mjs"
|
|
18
48
|
},
|
|
49
|
+
"exports": {
|
|
50
|
+
"./simulator-conformance": "./lib/simulator-conformance.mjs",
|
|
51
|
+
"./simulator-css-profile": "./lib/simulator-css-profile.mjs"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "node scripts/sync-scaffold-versions.mjs --apply && node scripts/sync-app-source.mjs --apply",
|
|
55
|
+
"sync:versions": "node scripts/sync-scaffold-versions.mjs --apply",
|
|
56
|
+
"sync:app-source": "node scripts/sync-app-source.mjs --apply",
|
|
57
|
+
"prepack": "pnpm run build",
|
|
58
|
+
"prepublishOnly": "pnpm run build",
|
|
59
|
+
"test": "node scripts/sync-scaffold-versions.mjs --check && node ../scripts/with-workspace-surfaces.mjs -- node --test test/simulator-conformance.test.mjs test/dev-shell.test.mjs && node ../scripts/with-workspace-surfaces.mjs -- node --test test/app-project-lifecycle.test.mjs test/app-pack.test.mjs test/app-scaffold.test.mjs",
|
|
60
|
+
"test:full": "node ../scripts/with-workspace-surfaces.mjs -- node --test --test-name-pattern=\"^(sync regenerates|sync rejects|unsupported previous app scaffold lock|check fails closed on a missing scaffold lock|check fails closed on provider/model hardcoding|check fails closed on app-owned Realm permission grant shortcuts|check fails closed on installed-app custody bypasses|check requires official Desktop-supervised development scripts|sync fails closed on unsupported locks and classification conflicts|app source resolves only scaffoldable slices)\" test/app-scaffold.test.mjs"
|
|
61
|
+
},
|
|
19
62
|
"files": [
|
|
20
63
|
"bin",
|
|
21
64
|
"lib",
|
|
65
|
+
"scripts",
|
|
66
|
+
"templates",
|
|
22
67
|
"README.md"
|
|
23
68
|
],
|
|
24
|
-
"dependencies": {
|
|
25
|
-
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"postcss": "^8.5.26",
|
|
71
|
+
"postcss-selector-parser": "^7.1.5",
|
|
72
|
+
"semver": "^7.8.5",
|
|
73
|
+
"typescript": "^5.9.3",
|
|
74
|
+
"yaml": "^2.9.0"
|
|
75
|
+
},
|
|
76
|
+
"peerDependencies": {
|
|
77
|
+
"vite": "^7.3.6"
|
|
78
|
+
},
|
|
79
|
+
"peerDependenciesMeta": {
|
|
80
|
+
"vite": {
|
|
81
|
+
"optional": true
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"devDependencies": {
|
|
85
|
+
"@types/node": "^24.13.3",
|
|
86
|
+
"vite": "7.3.6"
|
|
87
|
+
}
|
|
88
|
+
}
|