@nimiplatform/app-tools 0.6.2 → 0.7.5
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/README.md +106 -10
- package/bin/nimi-app.mjs +6 -12
- package/lib/app-dependency-combinations.mjs +62 -0
- package/lib/app-doctor-update.mjs +18 -16
- package/lib/app-info.mjs +25 -2
- package/lib/app-lifecycle-guidance.mjs +4 -2
- package/lib/app-pack.mjs +5 -2
- package/lib/app-project-lifecycle.mjs +208 -50
- package/lib/app-safety-profile.mjs +204 -0
- package/lib/app-scaffold-capabilities.mjs +8 -0
- package/lib/app-scaffold-profiles.mjs +44 -4
- package/lib/app-scaffold.mjs +2 -1
- package/lib/canonical-capability-ids.generated.mjs +21 -0
- package/lib/index.mjs +0 -4
- package/package.json +7 -12
- package/scripts/dev-shell.mjs +20 -2
- package/skills/nimi-app-lifecycle/SKILL.md +7 -3
- package/skills/nimi-app-lifecycle/references/acceptance.md +6 -0
- package/skills/nimi-app-lifecycle/references/adapt.md +46 -1
- package/skills/nimi-app-lifecycle/references/audit.md +55 -0
- package/skills/nimi-app-lifecycle/references/platform-gaps.md +15 -0
- package/skills/nimi-app-lifecycle/references/release.md +3 -1
- package/skills/nimi-app-lifecycle/references/safety-declaration.md +37 -0
- package/skills/nimi-app-lifecycle/references/upgrade-platform.md +2 -2
- package/templates/app-source/src/studio-modules/studio-voice/parameters.ts +8 -10
- package/templates/default-starter/AGENTS.md +4 -2
- package/templates/default-starter/README.md +1 -1
- package/lib/simulator-conformance-ast.mjs +0 -498
- package/lib/simulator-conformance-css.mjs +0 -116
- package/lib/simulator-conformance-graph.mjs +0 -757
- package/lib/simulator-conformance.d.mts +0 -14
- package/lib/simulator-conformance.mjs +0 -203
- package/lib/simulator-css-profile.d.mts +0 -27
- package/lib/simulator-css-profile.mjs +0 -531
- package/lib/simulator-kit-export-resolution.mjs +0 -70
- package/lib/simulator-manifest.mjs +0 -334
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-napp-043a
|
|
2
|
+
|
|
3
|
+
// Publisher safety declaration: `nimi.app.yaml.safety_profile` is the only
|
|
4
|
+
// author input. This module owns the closed vocabulary, the structural
|
|
5
|
+
// constraints, and the canonical serialization (key order, list order,
|
|
6
|
+
// deduplication) that every generated copy uses. It never fills, infers, or
|
|
7
|
+
// certifies a value; an absent declaration is "undeclared", not an empty
|
|
8
|
+
// risk list.
|
|
9
|
+
|
|
10
|
+
export const SAFETY_PROFILE_FIELD = 'safety_profile';
|
|
11
|
+
export const SAFETY_PROFILE_MAX_BYTES = 16 * 1024;
|
|
12
|
+
|
|
13
|
+
export const SAFETY_PROFILE_VOCABULARY = Object.freeze({
|
|
14
|
+
intended_audience: Object.freeze(['children', 'general', 'teen', 'adult']),
|
|
15
|
+
content_descriptors: Object.freeze([
|
|
16
|
+
'sexual-content', 'violence', 'self-harm', 'drugs-alcohol', 'gambling',
|
|
17
|
+
'hate-harassment', 'frightening-content', 'strong-language', 'unmoderated-shared-content',
|
|
18
|
+
]),
|
|
19
|
+
risk_features: Object.freeze(['realistic-face-manipulation', 'realistic-voice-replication', 'emotion-recognition', 'biometric-categorization']),
|
|
20
|
+
modality: Object.freeze(['text', 'image', 'audio', 'video', 'virtual-scene']),
|
|
21
|
+
exposure: Object.freeze(['in-app-only', 'exportable', 'publishable']),
|
|
22
|
+
publication_control: Object.freeze(['not-applicable', 'user-confirmed', 'automatic']),
|
|
23
|
+
notice: Object.freeze(['present', 'absent', 'not-applicable']),
|
|
24
|
+
marking: Object.freeze(['present', 'absent']),
|
|
25
|
+
export_visible_marking: Object.freeze(['present', 'absent', 'not-applicable']),
|
|
26
|
+
telemetry: Object.freeze(['crash-diagnostics', 'usage-analytics']),
|
|
27
|
+
third_party_account: Object.freeze(['none', 'optional', 'required']),
|
|
28
|
+
user_content_sharing: Object.freeze(['none', 'private', 'public']),
|
|
29
|
+
commercial_features: Object.freeze(['purchase', 'subscription', 'advertising']),
|
|
30
|
+
sensitive_data_categories: Object.freeze(['precise-location', 'contacts', 'health', 'financial', 'biometric', 'government-identifier']),
|
|
31
|
+
high_impact_decision_uses: Object.freeze([
|
|
32
|
+
'medical-diagnosis-treatment', 'legal-decision-support', 'employment-decision', 'education-admission-decision',
|
|
33
|
+
'credit-insurance-decision', 'biometric-identification', 'public-safety-decision',
|
|
34
|
+
]),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const SUBJECT_NOTICE_TRIGGERS = new Set(['emotion-recognition', 'biometric-categorization']);
|
|
38
|
+
|
|
39
|
+
class SafetyProfileError extends Error {
|
|
40
|
+
constructor(field, detail) {
|
|
41
|
+
super(`${field} ${detail}`);
|
|
42
|
+
this.name = 'SafetyProfileError';
|
|
43
|
+
this.field = field;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function fail(field, detail) {
|
|
48
|
+
throw new SafetyProfileError(field, detail);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function object(value, field, required) {
|
|
52
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) fail(field, 'must be an object');
|
|
53
|
+
const allowed = new Set(required);
|
|
54
|
+
for (const key of Object.keys(value)) if (!allowed.has(key)) fail(`${field}.${key}`, 'is not a supported safety_profile field');
|
|
55
|
+
for (const key of required) if (!Object.hasOwn(value, key)) fail(`${field}.${key}`, 'is required');
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function enumeration(value, field, vocabulary) {
|
|
60
|
+
if (typeof value !== 'string' || !vocabulary.includes(value)) {
|
|
61
|
+
fail(field, `must be one of ${vocabulary.join(', ')}`);
|
|
62
|
+
}
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function boolean(value, field) {
|
|
67
|
+
if (typeof value !== 'boolean') fail(field, 'must be true or false');
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function closedList(value, field, vocabulary) {
|
|
72
|
+
if (!Array.isArray(value)) fail(field, 'must be an explicit list (empty is allowed)');
|
|
73
|
+
const seen = new Set();
|
|
74
|
+
for (const item of value) {
|
|
75
|
+
enumeration(item, field, vocabulary);
|
|
76
|
+
if (seen.has(item)) fail(field, `must not repeat ${item}`);
|
|
77
|
+
seen.add(item);
|
|
78
|
+
}
|
|
79
|
+
// Tool-owned order: the closed vocabulary order, never author order.
|
|
80
|
+
return vocabulary.filter((item) => seen.has(item));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function output(value, index) {
|
|
84
|
+
const field = `${SAFETY_PROFILE_FIELD}.ai.outputs[${index}]`;
|
|
85
|
+
object(value, field, ['modality', 'exposure', 'publication_control', 'in_product_notice', 'export_visible_marking', 'machine_readable_marking']);
|
|
86
|
+
const modality = enumeration(value.modality, `${field}.modality`, SAFETY_PROFILE_VOCABULARY.modality);
|
|
87
|
+
const exposure = enumeration(value.exposure, `${field}.exposure`, SAFETY_PROFILE_VOCABULARY.exposure);
|
|
88
|
+
const publicationControl = enumeration(value.publication_control, `${field}.publication_control`, SAFETY_PROFILE_VOCABULARY.publication_control);
|
|
89
|
+
if (exposure === 'publishable' ? publicationControl === 'not-applicable' : publicationControl !== 'not-applicable') {
|
|
90
|
+
fail(`${field}.publication_control`, exposure === 'publishable' ? 'must be user-confirmed or automatic for publishable output' : 'must be not-applicable unless exposure is publishable');
|
|
91
|
+
}
|
|
92
|
+
const exportVisibleMarking = enumeration(value.export_visible_marking, `${field}.export_visible_marking`, SAFETY_PROFILE_VOCABULARY.export_visible_marking);
|
|
93
|
+
if (exposure === 'in-app-only' ? exportVisibleMarking !== 'not-applicable' : exportVisibleMarking === 'not-applicable') {
|
|
94
|
+
fail(`${field}.export_visible_marking`, exposure === 'in-app-only' ? 'must be not-applicable for in-app-only output' : 'must be present or absent for exportable or publishable output');
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
modality,
|
|
98
|
+
exposure,
|
|
99
|
+
publication_control: publicationControl,
|
|
100
|
+
in_product_notice: enumeration(value.in_product_notice, `${field}.in_product_notice`, SAFETY_PROFILE_VOCABULARY.marking),
|
|
101
|
+
export_visible_marking: exportVisibleMarking,
|
|
102
|
+
machine_readable_marking: enumeration(value.machine_readable_marking, `${field}.machine_readable_marking`, SAFETY_PROFILE_VOCABULARY.marking),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function ai(value) {
|
|
107
|
+
const field = `${SAFETY_PROFILE_FIELD}.ai`;
|
|
108
|
+
object(value, field, ['direct_interaction', 'interaction_notice', 'risk_features', 'subject_notice', 'outputs']);
|
|
109
|
+
const directInteraction = boolean(value.direct_interaction, `${field}.direct_interaction`);
|
|
110
|
+
const interactionNotice = enumeration(value.interaction_notice, `${field}.interaction_notice`, SAFETY_PROFILE_VOCABULARY.notice);
|
|
111
|
+
if (directInteraction ? interactionNotice === 'not-applicable' : interactionNotice !== 'not-applicable') {
|
|
112
|
+
fail(`${field}.interaction_notice`, directInteraction ? 'must be present or absent when direct_interaction is true' : 'must be not-applicable when direct_interaction is false');
|
|
113
|
+
}
|
|
114
|
+
const riskFeatures = closedList(value.risk_features, `${field}.risk_features`, SAFETY_PROFILE_VOCABULARY.risk_features);
|
|
115
|
+
const subjectNotice = enumeration(value.subject_notice, `${field}.subject_notice`, SAFETY_PROFILE_VOCABULARY.notice);
|
|
116
|
+
const subjectNoticeApplies = riskFeatures.some((item) => SUBJECT_NOTICE_TRIGGERS.has(item));
|
|
117
|
+
if (subjectNoticeApplies ? subjectNotice === 'not-applicable' : subjectNotice !== 'not-applicable') {
|
|
118
|
+
fail(`${field}.subject_notice`, subjectNoticeApplies ? 'must be present or absent when emotion-recognition or biometric-categorization is declared' : 'must be not-applicable without emotion-recognition or biometric-categorization');
|
|
119
|
+
}
|
|
120
|
+
if (!Array.isArray(value.outputs)) fail(`${field}.outputs`, 'must be an explicit list (empty is allowed)');
|
|
121
|
+
const outputs = value.outputs.map(output);
|
|
122
|
+
const modalities = new Set();
|
|
123
|
+
for (const entry of outputs) {
|
|
124
|
+
if (modalities.has(entry.modality)) fail(`${field}.outputs`, `must declare at most one entry for ${entry.modality}`);
|
|
125
|
+
modalities.add(entry.modality);
|
|
126
|
+
}
|
|
127
|
+
outputs.sort((left, right) => SAFETY_PROFILE_VOCABULARY.modality.indexOf(left.modality) - SAFETY_PROFILE_VOCABULARY.modality.indexOf(right.modality));
|
|
128
|
+
return { direct_interaction: directInteraction, interaction_notice: interactionNotice, risk_features: riskFeatures, subject_notice: subjectNotice, outputs };
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function dataPractices(value) {
|
|
132
|
+
const field = `${SAFETY_PROFILE_FIELD}.data_practices`;
|
|
133
|
+
object(value, field, ['publisher_direct_external_network', 'telemetry', 'third_party_account', 'user_content_sharing', 'commercial_features', 'sensitive_data_categories']);
|
|
134
|
+
return {
|
|
135
|
+
publisher_direct_external_network: boolean(value.publisher_direct_external_network, `${field}.publisher_direct_external_network`),
|
|
136
|
+
telemetry: closedList(value.telemetry, `${field}.telemetry`, SAFETY_PROFILE_VOCABULARY.telemetry),
|
|
137
|
+
third_party_account: enumeration(value.third_party_account, `${field}.third_party_account`, SAFETY_PROFILE_VOCABULARY.third_party_account),
|
|
138
|
+
user_content_sharing: enumeration(value.user_content_sharing, `${field}.user_content_sharing`, SAFETY_PROFILE_VOCABULARY.user_content_sharing),
|
|
139
|
+
commercial_features: closedList(value.commercial_features, `${field}.commercial_features`, SAFETY_PROFILE_VOCABULARY.commercial_features),
|
|
140
|
+
sensitive_data_categories: closedList(value.sensitive_data_categories, `${field}.sensitive_data_categories`, SAFETY_PROFILE_VOCABULARY.sensitive_data_categories),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Canonical form uses sorted object keys (matching the canonical JSON sidecar
|
|
145
|
+
// that Registry and Runtime consume) and closed-vocabulary list order.
|
|
146
|
+
function sortedKeys(value) {
|
|
147
|
+
if (Array.isArray(value)) return value.map(sortedKeys);
|
|
148
|
+
if (!value || typeof value !== 'object') return value;
|
|
149
|
+
return Object.fromEntries(Object.keys(value).sort().map((key) => [key, sortedKeys(value[key])]));
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// Returns the canonical declaration or throws naming the offending field.
|
|
153
|
+
// `undefined` input is not accepted here: callers decide what "absent" means.
|
|
154
|
+
export function normalizeSafetyProfile(value) {
|
|
155
|
+
const field = SAFETY_PROFILE_FIELD;
|
|
156
|
+
object(value, field, ['intended_audience', 'content_descriptors', 'ai', 'data_practices', 'high_impact_decision_uses']);
|
|
157
|
+
const normalized = {
|
|
158
|
+
intended_audience: enumeration(value.intended_audience, `${field}.intended_audience`, SAFETY_PROFILE_VOCABULARY.intended_audience),
|
|
159
|
+
content_descriptors: closedList(value.content_descriptors, `${field}.content_descriptors`, SAFETY_PROFILE_VOCABULARY.content_descriptors),
|
|
160
|
+
ai: ai(value.ai),
|
|
161
|
+
data_practices: dataPractices(value.data_practices),
|
|
162
|
+
high_impact_decision_uses: closedList(value.high_impact_decision_uses, `${field}.high_impact_decision_uses`, SAFETY_PROFILE_VOCABULARY.high_impact_decision_uses),
|
|
163
|
+
};
|
|
164
|
+
if (Buffer.byteLength(JSON.stringify(normalized)) > SAFETY_PROFILE_MAX_BYTES) fail(field, `exceeds ${SAFETY_PROFILE_MAX_BYTES} bytes`);
|
|
165
|
+
return sortedKeys(normalized);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function isCanonicalSafetyProfile(value) {
|
|
169
|
+
try {
|
|
170
|
+
return JSON.stringify(normalizeSafetyProfile(value)) === JSON.stringify(value);
|
|
171
|
+
} catch {
|
|
172
|
+
return false;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// Field-level difference between two canonical declarations for review and
|
|
177
|
+
// display. Returns [] when both are absent or equal; an absent side is
|
|
178
|
+
// reported as `undeclared`.
|
|
179
|
+
export function diffSafetyProfiles(before, after) {
|
|
180
|
+
const changes = [];
|
|
181
|
+
const flatten = (value, prefix, into) => {
|
|
182
|
+
if (Array.isArray(value)) {
|
|
183
|
+
if (prefix.endsWith('.outputs')) {
|
|
184
|
+
for (const entry of value) flatten(entry, `${prefix}[${entry.modality}]`, into);
|
|
185
|
+
} else into.set(prefix, value.join(', ') || '[]');
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (value && typeof value === 'object') {
|
|
189
|
+
for (const [key, child] of Object.entries(value)) flatten(child, prefix ? `${prefix}.${key}` : key, into);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
into.set(prefix, String(value));
|
|
193
|
+
};
|
|
194
|
+
const left = new Map();
|
|
195
|
+
const right = new Map();
|
|
196
|
+
if (before !== undefined && before !== null) flatten(before, '', left);
|
|
197
|
+
if (after !== undefined && after !== null) flatten(after, '', right);
|
|
198
|
+
for (const key of new Set([...left.keys(), ...right.keys()])) {
|
|
199
|
+
const previous = left.has(key) ? left.get(key) : 'undeclared';
|
|
200
|
+
const next = right.has(key) ? right.get(key) : 'undeclared';
|
|
201
|
+
if (previous !== next) changes.push({ field: key, before: previous, after: next });
|
|
202
|
+
}
|
|
203
|
+
return changes.sort((a, b) => (a.field < b.field ? -1 : a.field > b.field ? 1 : 0));
|
|
204
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-019c
|
|
2
2
|
|
|
3
3
|
import semver from 'semver';
|
|
4
|
+
import { CANONICAL_CAPABILITY_IDS } from './canonical-capability-ids.generated.mjs';
|
|
5
|
+
|
|
6
|
+
const canonicalCapabilityIds = new Set(CANONICAL_CAPABILITY_IDS);
|
|
4
7
|
|
|
5
8
|
function frozenSourceMapping(sourceRoot, targetRoot = sourceRoot) {
|
|
6
9
|
return Object.freeze({ sourceRoot, targetRoot });
|
|
@@ -440,6 +443,11 @@ function assertModuleEntry(id, entry, registry) {
|
|
|
440
443
|
assertUniqueStrings(entry.requires, `${id} requires`);
|
|
441
444
|
assertUniqueStrings(entry.appAccessItems, `${id} appAccessItems`);
|
|
442
445
|
assertUniqueStrings(entry.capabilityContractRefs || [], `${id} capabilityContractRefs`);
|
|
446
|
+
for (const capability of entry.capabilityContractRefs || []) {
|
|
447
|
+
if (!canonicalCapabilityIds.has(capability)) {
|
|
448
|
+
throw new Error(`App scaffold module references unknown canonical capability: ${id}: ${capability}`);
|
|
449
|
+
}
|
|
450
|
+
}
|
|
443
451
|
assertUniqueStrings(entry.requiredStandardizedFeatureRefs || [], `${id} requiredStandardizedFeatureRefs`);
|
|
444
452
|
assertUniqueStrings(entry.views, `${id} views`);
|
|
445
453
|
assertUniqueStrings(entry.navigation, `${id} navigation`);
|
|
@@ -1,5 +1,33 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
|
|
1
3
|
export const SUPPORTED_APP_SCAFFOLD_PROFILES = ['standalone'];
|
|
2
4
|
|
|
5
|
+
export function rebaseLocalPackagePaths(value, sourceDir, targetDir) {
|
|
6
|
+
// Parsed pnpm documents retain complete locators in overrides, specifiers
|
|
7
|
+
// and resolutions. Reuse those exact strings in package/peer keys instead
|
|
8
|
+
// of guessing whether a parenthesis belongs to a path or a peer suffix.
|
|
9
|
+
const replacements = new Map();
|
|
10
|
+
const collect = (item) => {
|
|
11
|
+
if (typeof item === 'string' && /^file:[^\r\n]+\.(?:tgz|tar\.gz)$/u.test(item)) {
|
|
12
|
+
replacements.set(item, 'file:' + path.relative(targetDir, path.resolve(sourceDir, item.slice(5))).split(path.sep).join('/'));
|
|
13
|
+
} else if (Array.isArray(item)) item.forEach(collect);
|
|
14
|
+
else if (item && typeof item === 'object') Object.values(item).forEach(collect);
|
|
15
|
+
};
|
|
16
|
+
collect(value);
|
|
17
|
+
if (replacements.size === 0) return value;
|
|
18
|
+
const pattern = new RegExp([...replacements.keys()].sort((a, b) => b.length - a.length)
|
|
19
|
+
.map((locator) => locator.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&')).join('|'), 'gu');
|
|
20
|
+
const rebase = (text) => text.replace(pattern, (locator) => replacements.get(locator));
|
|
21
|
+
const rewrite = (item) => {
|
|
22
|
+
if (typeof item === 'string') return rebase(item);
|
|
23
|
+
if (Array.isArray(item)) return item.map(rewrite);
|
|
24
|
+
if (item && typeof item === 'object') return Object.fromEntries(Object.entries(item)
|
|
25
|
+
.map(([key, child]) => [rebase(key), rewrite(child)]));
|
|
26
|
+
return item;
|
|
27
|
+
};
|
|
28
|
+
return rewrite(value);
|
|
29
|
+
}
|
|
30
|
+
|
|
3
31
|
export function resolveWindowsResourceVersion(appVersion) {
|
|
4
32
|
const semverPattern = /^(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?(?:\+[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?$/u;
|
|
5
33
|
if (typeof appVersion !== 'string' || !semverPattern.test(appVersion)) {
|
|
@@ -132,10 +160,12 @@ function renderDefaultElectronProductionPackager(identity) {
|
|
|
132
160
|
"import { fileURLToPath } from 'node:url';",
|
|
133
161
|
"import { packager } from '@electron/packager';",
|
|
134
162
|
"import { build } from 'esbuild';",
|
|
163
|
+
"import { parse as parseYaml, stringify as stringifyYaml } from 'yaml';",
|
|
135
164
|
'',
|
|
136
165
|
`const APP_EXECUTABLE_NAME = ${JSON.stringify(identity.cargoPackageName)};`,
|
|
137
166
|
`const APP_PRODUCT_NAME = ${JSON.stringify(identity.appTitle)};`,
|
|
138
167
|
resolveWindowsResourceVersion.toString(),
|
|
168
|
+
rebaseLocalPackagePaths.toString(),
|
|
139
169
|
"const MACOS_BUILD = process.platform === 'darwin' && process.arch === 'arm64';",
|
|
140
170
|
"const NATIVE_PLATFORM = MACOS_BUILD ? 'darwin' : 'win32';",
|
|
141
171
|
"const NATIVE_ARCH = MACOS_BUILD ? 'arm64' : 'x64';",
|
|
@@ -168,7 +198,8 @@ function renderDefaultElectronProductionPackager(identity) {
|
|
|
168
198
|
'const nativePackageRoot = await findPackageRoot(nativeEntry, NATIVE_BINDING_PACKAGE);',
|
|
169
199
|
'',
|
|
170
200
|
'await rm(outputRoot, { recursive: true, force: true });',
|
|
171
|
-
|
|
201
|
+
'// Use the physical staging root: pnpm canonicalizes cwd before resolving relative tarballs.',
|
|
202
|
+
"const stagingRoot = await realpath(await mkdtemp(path.join(tmpdir(), 'nimi-electron-packager-')));",
|
|
172
203
|
"const productionSourceRoot = path.join(stagingRoot, 'app');",
|
|
173
204
|
"const packagerTempRoot = path.join(stagingRoot, 'packager');",
|
|
174
205
|
'let packageCompleted = false;',
|
|
@@ -192,7 +223,12 @@ function renderDefaultElectronProductionPackager(identity) {
|
|
|
192
223
|
'',
|
|
193
224
|
' await mkdir(path.join(productionSourceRoot, \'dist-electron\'), { recursive: true });',
|
|
194
225
|
" await copyFile(path.join(appRoot, 'package.json'), path.join(productionSourceRoot, 'package.json'));",
|
|
195
|
-
" await
|
|
226
|
+
" const dependencyLock = parseYaml(await readFile(path.join(appRoot, 'pnpm-lock.yaml'), 'utf8'));",
|
|
227
|
+
" await writeFile(path.join(productionSourceRoot, 'pnpm-lock.yaml'), stringifyYaml(rebaseLocalPackagePaths(dependencyLock, appRoot, productionSourceRoot)));",
|
|
228
|
+
' try {',
|
|
229
|
+
" const workspace = parseYaml(await readFile(path.join(appRoot, 'pnpm-workspace.yaml'), 'utf8'));",
|
|
230
|
+
" await writeFile(path.join(productionSourceRoot, 'pnpm-workspace.yaml'), stringifyYaml({ ...rebaseLocalPackagePaths(workspace, appRoot, productionSourceRoot), packages: ['.'] }));",
|
|
231
|
+
" } catch (cause) { if (cause.code !== 'ENOENT') throw cause; }",
|
|
196
232
|
" await cp(path.join(appRoot, 'dist'), path.join(productionSourceRoot, 'dist'), { recursive: true, force: false });",
|
|
197
233
|
" await copyFile(path.join(appRoot, 'dist-electron', 'main.js'), path.join(productionSourceRoot, 'dist-electron', 'main.js'));",
|
|
198
234
|
" await copyFile(path.join(appRoot, 'dist-electron', 'preload.cjs'), path.join(productionSourceRoot, 'dist-electron', 'preload.cjs'));",
|
|
@@ -203,6 +239,7 @@ function renderDefaultElectronProductionPackager(identity) {
|
|
|
203
239
|
' delete productionManifest.devDependencies;',
|
|
204
240
|
" await writeFile(productionManifestPath, `${JSON.stringify(productionManifest, null, 2)}\\n`);",
|
|
205
241
|
" await rm(path.join(productionSourceRoot, 'pnpm-lock.yaml'));",
|
|
242
|
+
" await rm(path.join(productionSourceRoot, 'pnpm-workspace.yaml'), { force: true });",
|
|
206
243
|
'',
|
|
207
244
|
" const installedNativePackage = path.join(productionSourceRoot, 'node_modules', ...NATIVE_BINDING_PACKAGE.split('/'));",
|
|
208
245
|
' const nativeDestination = MACOS_BUILD',
|
|
@@ -226,7 +263,8 @@ function renderDefaultElectronProductionPackager(identity) {
|
|
|
226
263
|
' out: outputRoot,',
|
|
227
264
|
' tmpdir: packagerTempRoot,',
|
|
228
265
|
' overwrite: false,',
|
|
229
|
-
|
|
266
|
+
' // Native add-ons and their shared libraries must remain accessible to the OS loader.',
|
|
267
|
+
" asar: { unpack: '**/*.{node,dylib,dll}' },",
|
|
230
268
|
" ...(MACOS_BUILD ? { extraResource: [path.join(stagingRoot, 'nimi-native')] } : {}),",
|
|
231
269
|
' prune: false,',
|
|
232
270
|
' quiet: true,',
|
|
@@ -348,7 +386,9 @@ function renderDefaultMain(identity) {
|
|
|
348
386
|
'});',
|
|
349
387
|
'',
|
|
350
388
|
"const rendererRoot = document.getElementById('root') as HTMLElement;",
|
|
351
|
-
|
|
389
|
+
'/* Admitted workbench styles use this module scope, including body-portaled controls. */',
|
|
390
|
+
"document.body.classList.add('nimi-ui-module--lab');",
|
|
391
|
+
"rendererRoot.classList.add('nimi-workbench-host', 'nimi-ui-module--lab');",
|
|
352
392
|
'createRoot(rendererRoot).render(',
|
|
353
393
|
' <React.StrictMode>',
|
|
354
394
|
` <NimiThemeProvider accentPack="${identity.accentPack}">`,
|
package/lib/app-scaffold.mjs
CHANGED
|
@@ -1087,6 +1087,7 @@ export function renderAppSubmissionInput(identity, options = {}) {
|
|
|
1087
1087
|
required_standardized_feature_refs: options.requiredStandardizedFeatureRefs || [],
|
|
1088
1088
|
...(options.aiProfileRecommendationRef ? { ai_profile_recommendation_ref: options.aiProfileRecommendationRef } : {}),
|
|
1089
1089
|
storage_policy: options.storagePolicy || { kind: 'nimi-mediated-default' },
|
|
1090
|
+
...(options.safetyProfile ? { safety_profile: options.safetyProfile } : {}),
|
|
1090
1091
|
support_manifest: supportManifest,
|
|
1091
1092
|
review_inputs: {
|
|
1092
1093
|
manifest: 'nimi.app.yaml',
|
|
@@ -1594,7 +1595,7 @@ export function createAppScaffoldCandidate(input) {
|
|
|
1594
1595
|
return createAppScaffold({ ...input, plan });
|
|
1595
1596
|
}
|
|
1596
1597
|
|
|
1597
|
-
export const APP_AUTHOR_DECLARATION_FIELDS = Object.freeze(['metadata', 'capability_contract_refs', 'required_standardized_feature_refs', 'storage_policy']);
|
|
1598
|
+
export const APP_AUTHOR_DECLARATION_FIELDS = Object.freeze(['metadata', 'capability_contract_refs', 'required_standardized_feature_refs', 'storage_policy', 'safety_profile']);
|
|
1598
1599
|
|
|
1599
1600
|
// Source configuration is editable; existing scaffold checks still cover identity and carrier fields.
|
|
1600
1601
|
export function hashScaffoldManagedContent(relativePath, content) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// GENERATED FILE — DO NOT EDIT.
|
|
2
|
+
// Source: config/platform-canonical-capability-catalog.yaml
|
|
3
|
+
// Regenerate: pnpm gen:canonical-capability-catalog
|
|
4
|
+
// These identities validate references; they do not admit scaffold features.
|
|
5
|
+
export const CANONICAL_CAPABILITY_IDS = Object.freeze([
|
|
6
|
+
"audio.separate",
|
|
7
|
+
"audio.synthesize",
|
|
8
|
+
"audio.transcribe",
|
|
9
|
+
"image.face_swap",
|
|
10
|
+
"image.generate",
|
|
11
|
+
"music.generate",
|
|
12
|
+
"realtime.interact",
|
|
13
|
+
"text.annotate",
|
|
14
|
+
"text.embed",
|
|
15
|
+
"text.generate",
|
|
16
|
+
"video.face_swap",
|
|
17
|
+
"video.generate",
|
|
18
|
+
"vision.locate",
|
|
19
|
+
"voice.create",
|
|
20
|
+
"world.generate"
|
|
21
|
+
]);
|
package/lib/index.mjs
CHANGED
|
@@ -20,10 +20,6 @@ import {
|
|
|
20
20
|
} from './app-project-lifecycle.mjs';
|
|
21
21
|
import { aggregateAppTargetCandidates, packAppTarget } from './app-pack.mjs';
|
|
22
22
|
export { runDevShell } from '../scripts/dev-shell.mjs';
|
|
23
|
-
export {
|
|
24
|
-
validateSimulatorAppSource,
|
|
25
|
-
validateSimulatorAppSourceWithCanonicalKitExports,
|
|
26
|
-
} from './simulator-conformance.mjs';
|
|
27
23
|
export { APP_SCAFFOLD_FEATURE_IDS } from './app-scaffold-capabilities.mjs';
|
|
28
24
|
|
|
29
25
|
const APP_TOOLS_PACKAGE_MANIFEST = JSON.parse(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nimiplatform/app-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"description": "Public app-authoring CLI for Nimi App projects.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"provenance": true
|
|
19
19
|
},
|
|
20
20
|
"nimiScaffoldVersions": {
|
|
21
|
-
"sdkVersion": "^0.
|
|
22
|
-
"appToolsVersion": "^0.
|
|
21
|
+
"sdkVersion": "^0.15.0",
|
|
22
|
+
"appToolsVersion": "^0.7.5",
|
|
23
23
|
"nimicodingVersion": "0.6.3",
|
|
24
24
|
"aiSdkVersion": "^6.0.85",
|
|
25
|
-
"kitVersion": "^0.
|
|
25
|
+
"kitVersion": "^0.11.0",
|
|
26
26
|
"reactVersion": "^19.2.8",
|
|
27
27
|
"reactDomVersion": "^19.2.8",
|
|
28
28
|
"i18nextVersion": "^25.10.10",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"tailwindcssViteVersion": "^4.3.3",
|
|
39
39
|
"tauriCliVersion": "^2.11.4",
|
|
40
40
|
"yamlVersion": "^2.9.0",
|
|
41
|
-
"nimiShellTauriVersion": "0.
|
|
41
|
+
"nimiShellTauriVersion": "0.6.0",
|
|
42
42
|
"electronPackagerVersion": "^20.3.0",
|
|
43
43
|
"electronVersion": "^42.10.1",
|
|
44
44
|
"esbuildVersion": "^0.28.2",
|
|
@@ -47,10 +47,7 @@
|
|
|
47
47
|
"bin": {
|
|
48
48
|
"nimi-app": "./bin/nimi-app.mjs"
|
|
49
49
|
},
|
|
50
|
-
"exports": {
|
|
51
|
-
"./simulator-conformance": "./lib/simulator-conformance.mjs",
|
|
52
|
-
"./simulator-css-profile": "./lib/simulator-css-profile.mjs"
|
|
53
|
-
},
|
|
50
|
+
"exports": {},
|
|
54
51
|
"scripts": {
|
|
55
52
|
"build": "node scripts/sync-scaffold-versions.mjs --apply && node scripts/sync-app-source.mjs --apply",
|
|
56
53
|
"sync:versions": "node scripts/sync-scaffold-versions.mjs --apply",
|
|
@@ -58,7 +55,7 @@
|
|
|
58
55
|
"prepack": "pnpm run build",
|
|
59
56
|
"prepublishOnly": "pnpm run build",
|
|
60
57
|
"test": "node ../scripts/with-workspace-surfaces.mjs -- pnpm run test:prepared",
|
|
61
|
-
"test:prepared": "node scripts/sync-scaffold-versions.mjs --check && node --test test/
|
|
58
|
+
"test:prepared": "node scripts/sync-scaffold-versions.mjs --check && node --test test/dev-shell.test.mjs && node --test test/app-safety-profile.test.mjs test/app-project-lifecycle.test.mjs test/app-pack.test.mjs test/app-scaffold.test.mjs"
|
|
62
59
|
},
|
|
63
60
|
"files": [
|
|
64
61
|
"bin",
|
|
@@ -70,8 +67,6 @@
|
|
|
70
67
|
],
|
|
71
68
|
"dependencies": {
|
|
72
69
|
"pngjs": "7.0.0",
|
|
73
|
-
"postcss": "^8.5.26",
|
|
74
|
-
"postcss-selector-parser": "^7.1.5",
|
|
75
70
|
"semver": "^7.8.5",
|
|
76
71
|
"typescript": "^5.9.3",
|
|
77
72
|
"yaml": "^2.9.0"
|
package/scripts/dev-shell.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { lstat, readFile, realpath } from 'node:fs/promises';
|
|
3
|
+
import { lstat, readFile, realpath, stat } from 'node:fs/promises';
|
|
4
4
|
import { homedir } from 'node:os';
|
|
5
5
|
import path from 'node:path';
|
|
6
6
|
import process from 'node:process';
|
|
@@ -63,6 +63,7 @@ export async function runDevShell(cwd, options = {}) {
|
|
|
63
63
|
return listed.registrations;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
await assertProjectElectronRuntime(projectRoot);
|
|
66
67
|
const startIntent = {
|
|
67
68
|
schemaVersion: 1,
|
|
68
69
|
appId,
|
|
@@ -104,7 +105,8 @@ export async function runDevShell(cwd, options = {}) {
|
|
|
104
105
|
if (current.state !== lastState) lastState = current.state;
|
|
105
106
|
lastLogSequence = printNewLogs(output, current, lastLogSequence);
|
|
106
107
|
if (TERMINAL_STATES.has(current.state)) {
|
|
107
|
-
|
|
108
|
+
// Desktop may finish an ordinary stop from its own UI, without a CLI signal.
|
|
109
|
+
if (current.state === 'stopped') return current;
|
|
108
110
|
throw new DevShellError(
|
|
109
111
|
current.reasonCode || `local-development-${current.state}`,
|
|
110
112
|
current.message || `Nimi local development ended in state ${current.state}.`,
|
|
@@ -148,6 +150,22 @@ export function assertLocalDevelopmentPlatform(platform, shell) {
|
|
|
148
150
|
);
|
|
149
151
|
}
|
|
150
152
|
|
|
153
|
+
// This is a dependency-presence check, not executable identity or admission.
|
|
154
|
+
// Desktop still verifies and supervises the actual Host process.
|
|
155
|
+
export async function assertProjectElectronRuntime(projectRoot, platform = process.platform) {
|
|
156
|
+
if (platform !== 'win32') return;
|
|
157
|
+
const executable = path.join(projectRoot, 'node_modules', 'electron', 'dist', 'electron.exe');
|
|
158
|
+
const available = await stat(executable).then((value) => value.isFile()).catch(() => false);
|
|
159
|
+
if (!available) {
|
|
160
|
+
throw new DevShellError(
|
|
161
|
+
'local-development-launcher-unavailable',
|
|
162
|
+
'The project Electron binary is missing (node_modules/electron/dist/electron.exe). '
|
|
163
|
+
+ 'For the matched Electron package, run pnpm exec install-electron --no in this project, '
|
|
164
|
+
+ 'resolve any reported installation error, then retry nimi-app dev.',
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
151
169
|
export class DevShellError extends Error {
|
|
152
170
|
constructor(reasonCode, message) {
|
|
153
171
|
super(message);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: nimi-app-lifecycle
|
|
3
|
-
description:
|
|
3
|
+
description: Audit Nimi App adaptation feasibility, capability fit and cost, or create, adapt, maintain and prepare releases with app-tools and the standard SDK/Kit carrier. Use for App development, not for carrying out the App's own creative or research tasks.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Nimi App lifecycle
|
|
@@ -9,20 +9,24 @@ Start with the repository's package manifest, actual product entry and nearest i
|
|
|
9
9
|
|
|
10
10
|
| Task | Guide |
|
|
11
11
|
| --- | --- |
|
|
12
|
+
| Decide whether to adapt an App; assess feasibility, gaps or cost | [Audit](references/audit.md) |
|
|
12
13
|
| Create a new App | [Create](references/create.md) |
|
|
13
14
|
| Adapt an existing project | [Adapt](references/adapt.md) |
|
|
15
|
+
| Resolve a Nimi AI capability or carrier gap | [Platform gaps](references/platform-gaps.md) |
|
|
14
16
|
| Upgrade app-tools, SDK or Kit | [Platform upgrade](references/upgrade-platform.md) |
|
|
15
17
|
| Bring in upstream changes | [Upstream sync](references/sync-upstream.md) |
|
|
18
|
+
| Declare audience, content, AI output and data facts | [Safety declaration](references/safety-declaration.md) |
|
|
16
19
|
| Prepare a Release or Registry submission | [Release](references/release.md) |
|
|
17
20
|
| Verify real App behavior or installation | [Acceptance](references/acceptance.md) |
|
|
18
21
|
|
|
19
|
-
For an ordinary product edit, follow its existing code and tests. Do not reinitialize or run the entire release journey unless affected inputs or behavior require it.
|
|
22
|
+
An audit or planning request produces findings and a proposal; the future adaptation goal does not authorize implementation. If implementation is also explicitly requested, continue within that authorization after resolving the necessary decisions. For an ordinary product edit, follow its existing code and tests. Do not reinitialize or run the entire release journey unless affected inputs or behavior require it.
|
|
20
23
|
|
|
21
24
|
## Boundaries that matter
|
|
22
25
|
|
|
23
26
|
- App-owned workflows, tool handlers, business accounts, non-AI services and product presentation stay with the App. Nimi AI, configuration, managed storage and protected sessions use public SDK/Kit Local App surfaces. Display identity is not a business login ticket.
|
|
27
|
+
- When implementing an existing App's first Nimi integration or foundation wiring change, follow the adaptation guide's same-package generated reference first. Reuse its Host, preload, renderer, session, App Access, AIConfig and AI call wiring; documentation complements that implementation. Preserve the original product journeys and settings rather than treating the reference workbench as the finished App. Reuse passing baseline results for ordinary business edits; creating or running a reference App is not a default audit prerequisite.
|
|
24
28
|
- Fresh Apps use pnpm, Vite and Desktop-supervised Electron. Existing Apps may use another renderer framework with an App-owned development command and the `electron-pnpm` build profile. A Next/server or Python project still needs real Host and backend lifecycle/build work. Preserve its original user tasks and framework where they fit; initialization does not convert the product.
|
|
25
|
-
- Read the selected app-tools package's `nimiScaffoldVersions` and the SDK/Kit migration notes.
|
|
29
|
+
- Read the selected app-tools package's `nimiScaffoldVersions` and the SDK/Kit migration notes. Fresh Apps use the tool default SDK/Kit combination; an existing App keeps its current supported SDK/Kit combination through sync and check while only the app-tools and nimi-coding tool dependencies follow the tool, and a declaration or tool update never upgrades business dependencies. Development can consume complete local npm tarballs through explicit pnpm-workspace overrides; keep the selected combination and lockfile, follow the package README, and do not require publication before iteration. Public release preflight requires registry resolutions; local package acceptance is not public installation evidence.
|
|
26
30
|
- App Tools maintains its fixed lifecycle skill, AGENTS block and declared engineering projections. Existing Apps have no fresh scaffold intent/lock. Preserve their Host, product source and license; report unknown file collisions rather than inventing ownership.
|
|
27
31
|
- GitHub owns publisher builds and Releases; Registry owns candidate validation and human admission; Runtime owns packages and App access; Desktop owns exact processes. These are separate facts. The external AI host owns the development task.
|
|
28
32
|
- Continue authorized work through verification. Missing prerequisites pause dependent steps only. Never infer publication or human approval from a passing command. Mark relevant unrun product paths NOT-VERIFIED.
|
|
@@ -4,8 +4,12 @@ Select the actual user journey and affected capability. Reuse the App's package
|
|
|
4
4
|
|
|
5
5
|
For development, run the official `nimi-app dev` launcher with Desktop supervising Electron. Attach only to the exact App's reported loopback CDP target. Renderer URLs or independently launched processes cannot prove protected access. Use the existing `--list-registrations` and explicit `--resume <selector>` when continuing the same development data; do not persist selectors or reopen by App ID/path. Native and installed UI use their owner-supported paths, not production CDP additions.
|
|
6
6
|
|
|
7
|
+
On Windows the project must have its Electron binary installed. If the launcher reports a missing `node_modules/electron/dist/electron.exe`, run the matched package's explicit `pnpm exec install-electron --no`, then retry the original launch. An installed npm wrapper or a successful `pnpm rebuild electron` alone does not prove that binary is present. Keep the explicit installer in the App's normal dependency setup; no empty renderer or alternate Host is needed.
|
|
8
|
+
|
|
7
9
|
Verify the real output the user needs: a cited research result, a correctly indexed document, or a playable/exported media artifact. Check cancellation, reconnect or account change when that behavior is affected. Tests and mocks can establish a contract; they cannot replace actual AI or App acceptance.
|
|
8
10
|
|
|
11
|
+
For local installed-App acceptance with complete local npm tarballs, run ordinary `check` and `build --target <target>`, then `pack --target <target> --production` on the matching host. The pack flag observes actual native signature and execution permissions; it neither requires registry dependency resolutions nor publishes. Plain `pack` produces a development archive that Runtime rejects for installation. Use Desktop's Apps → Add App → Import local package, review the actual preview, install and launch that source. Keep this separate from public-release `check --production` and `build --production`.
|
|
12
|
+
|
|
9
13
|
For a declared release target, verify Catalog discovery/download/install, exact Host launch, current Access, real business use and uninstall on an ordinary machine without the source workspace or development runtimes. Local-package import proves only that separate source path. Keep missing external services visible.
|
|
10
14
|
|
|
11
15
|
With two separately admitted versions, verify N to N+1 and the promised data retention. Reuse existing Runtime failure tests for preservation of the old package; if a normal real failure is observed, retry the same N/N+1 after confirming N remains available. Do not manufacture N+2, a downgrade path or a new fault-injection service.
|
|
@@ -13,3 +17,5 @@ With two separately admitted versions, verify N to N+1 and the promised data ret
|
|
|
13
17
|
Runtime uninstall removes its exact managed package after Desktop stops the Host. App-owned OS storage remains untouched, including disclosed paths; explain the App's own cleanup action separately. Ordinary repair and arbitrary rollback remain outside this workflow.
|
|
14
18
|
|
|
15
19
|
Report the tested App/version, target and result, plus relevant NOT-VERIFIED paths. Tool-core checks, a representative App slice, first release/install and a later update are separate completion levels. Keep necessary local output under `.nimi/local/`; do not create another task or proof ledger.
|
|
20
|
+
|
|
21
|
+
Separate results obtained now from prior actual acceptance that still applies to the same behavior and combination. Reuse sufficient evidence until a change, failure or concrete risk invalidates it; not rerunning a journey does not mean it never passed. Keep contract correctness and the user's required business result distinct from model-content quality. Maintain a current summary in existing project notes, label historical stages, and do not promote a bounded platform fix into completion of an ongoing App adaptation.
|