@glassly/miniapp-cli 0.1.0-beta.3

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.
@@ -0,0 +1,412 @@
1
+ // Note: these enum string values must stay in sync with @glassly/engine and
2
+ // @glassly/miniapp. We cannot depend on them here because this lightweight CLI package
3
+ // is intentionally dependency-minimal (so `bunx @glassly/miniapp-cli` starts
4
+ // fast). Mirror string lists manually; failing validations point authors at
5
+ // the allowed values directly.
6
+ //
7
+ // Sources of truth:
8
+ // - AppPermissionType: mobile/modules/engine/src/types/applet.ts
9
+ // - HardwareType: mobile/modules/miniapp/src/hardware.ts
10
+ // - HardwareRequirementLevel: same
11
+ // - AppletPermission shape: {type, required?, description?}
12
+ // - HardwareRequirement shape: {type, level, description?}
13
+
14
+ export const ALLOWED_PERMISSIONS = [
15
+ 'MICROPHONE',
16
+ 'CAMERA',
17
+ 'CALENDAR',
18
+ 'LOCATION',
19
+ 'BACKGROUND_LOCATION',
20
+ 'READ_NOTIFICATIONS',
21
+ 'DISPLAY_MIRROR',
22
+ 'POST_NOTIFICATIONS',
23
+ 'API_KEYS',
24
+ 'MEMORY',
25
+ 'AI',
26
+ 'SPEAKERS',
27
+ 'MANAGE_MINIAPPS',
28
+ 'PLATFORM_SETTINGS',
29
+ ] as const;
30
+
31
+ export type AllowedPermission = (typeof ALLOWED_PERMISSIONS)[number];
32
+
33
+ export const ALLOWED_HARDWARE_TYPES = [
34
+ 'CAMERA',
35
+ 'DISPLAY',
36
+ 'MICROPHONE',
37
+ 'SPEAKER',
38
+ 'IMU',
39
+ 'BUTTON',
40
+ 'LIGHT',
41
+ 'WIFI',
42
+ // EXIST is injected by the phone at runtime (every miniapp needs glasses
43
+ // present). Do not allow authors to declare it — keep the surface minimal.
44
+ ] as const;
45
+
46
+ export type AllowedHardwareType = (typeof ALLOWED_HARDWARE_TYPES)[number];
47
+
48
+ export const ALLOWED_HARDWARE_LEVELS = ['REQUIRED', 'OPTIONAL'] as const;
49
+
50
+ export type AllowedHardwareLevel = (typeof ALLOWED_HARDWARE_LEVELS)[number];
51
+
52
+ export interface ManifestPermission {
53
+ type: AllowedPermission;
54
+ required?: boolean;
55
+ description?: string;
56
+ }
57
+
58
+ export interface ManifestHardwareRequirement {
59
+ type: AllowedHardwareType;
60
+ level: AllowedHardwareLevel;
61
+ description?: string;
62
+ }
63
+
64
+ export interface ManifestEntry {
65
+ /** Path to the background bundle entry, relative to the project root.
66
+ * Required for two-layer bundles. */
67
+ background: string;
68
+ /** Path to the UI HTML entry. Optional — pure-background miniapps
69
+ * don't include a WebView. */
70
+ ui?: string;
71
+ }
72
+
73
+ // Action parameter types — the MCP-compatible subset. "number" (not
74
+ // "integer") since the runtime is JavaScript; arrays of primitives allowed.
75
+ export const ALLOWED_ACTION_PARAM_TYPES = ['string', 'number', 'boolean', 'array'] as const;
76
+ export type AllowedActionParamType = (typeof ALLOWED_ACTION_PARAM_TYPES)[number];
77
+
78
+ export interface ManifestActionParameter {
79
+ type: AllowedActionParamType;
80
+ description?: string;
81
+ enum?: Array<string | number | boolean>;
82
+ /** For type: "array" — the primitive item type. */
83
+ items?: { type: 'string' | 'number' | 'boolean' };
84
+ }
85
+
86
+ /** JSON-Schema input descriptor for an action. Maps to an MCP tool inputSchema. */
87
+ export interface ManifestActionParameters {
88
+ type: 'object';
89
+ properties?: Record<string, ManifestActionParameter>;
90
+ required?: string[];
91
+ }
92
+
93
+ /**
94
+ * A declared action this miniapp exposes for other (system) miniapps to invoke
95
+ * via session.actions. Shape maps 1:1 onto an MCP tool.
96
+ */
97
+ export interface ManifestAction {
98
+ /** Unique-within-app id, ^[a-z][a-z0-9_]*$, ≤64 chars. */
99
+ id: string;
100
+ /** AI-facing contract — when to use the action. Required, non-empty. */
101
+ description: string;
102
+ parameters?: ManifestActionParameters;
103
+ /** JSON-Schema descriptor for the structured value returned by the handler. */
104
+ outputSchema?: Record<string, unknown>;
105
+ }
106
+
107
+ export interface MiniappManifestV1 {
108
+ packageName: string;
109
+ version: string;
110
+ name: string;
111
+ description?: string;
112
+ /** One line shown under the name in the store, max 80 characters. */
113
+ tagline?: string;
114
+ /** Store tags, lowercase slugs, max 5 (e.g. ["productivity", "ai"]). */
115
+ tags?: string[];
116
+ icon?: string;
117
+ port?: number;
118
+ permissions?: ManifestPermission[];
119
+ hardwareRequirements: ManifestHardwareRequirement[];
120
+ /** Semver of the @glassly/miniapp SDK ABI this bundle targets. */
121
+ sdkVersion?: string;
122
+ /** Lowest Glassly Manager host version that can run this bundle. */
123
+ minHostVersion?: string;
124
+ /** Two-layer bundle entry points. */
125
+ entry?: ManifestEntry;
126
+ /**
127
+ * Miniapp shape — defaults to "standard" (background + on-demand UI).
128
+ * "dashboard" is a standard app that can hold the dashboard role: one
129
+ * dashboard runs at a time, and the host hands the running one the overlay slot.
130
+ */
131
+ type?: "standard" | "background" | "dashboard";
132
+ /** Always On miniapp: started at launch, keeps running after its app switcher card is swiped away. The wearer can still stop it. */
133
+ alwaysOn?: boolean;
134
+ /** Actions other (system) miniapps can invoke via session.actions. */
135
+ actions?: ManifestAction[];
136
+ }
137
+
138
+ const ACTION_ID_RE = /^[a-z][a-z0-9_]*$/;
139
+
140
+ export const TAGLINE_MAX_LENGTH = 80;
141
+ export const TAGS_MAX_COUNT = 5;
142
+ export const TAG_MAX_LENGTH = 32;
143
+ export const TAG_SLUG_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
144
+
145
+ /** Store tag slugs the Glassly App shows as filter chips. Unknown tags are accepted and stored. */
146
+ export const KNOWN_TAGS = [
147
+ 'productivity',
148
+ 'communication',
149
+ 'navigation',
150
+ 'ai',
151
+ 'games',
152
+ 'developer',
153
+ 'media',
154
+ ] as const;
155
+
156
+ export function validateTagline(tagline: unknown): string[] {
157
+ if (typeof tagline !== 'string') return ['tagline must be a string when set'];
158
+ if (!tagline.trim()) return ['tagline must not be blank when set'];
159
+ if (tagline.length > TAGLINE_MAX_LENGTH) {
160
+ return [`tagline must be ${TAGLINE_MAX_LENGTH} characters or fewer (got ${tagline.length})`];
161
+ }
162
+ if (/[\r\n]/.test(tagline)) return ['tagline must be a single line'];
163
+ return [];
164
+ }
165
+
166
+ export function validateTags(tags: unknown): string[] {
167
+ if (!Array.isArray(tags)) return ['tags must be an array of lowercase slug strings when set'];
168
+ const errors: string[] = [];
169
+ if (tags.length > TAGS_MAX_COUNT) {
170
+ errors.push(`tags must have ${TAGS_MAX_COUNT} entries or fewer (got ${tags.length})`);
171
+ }
172
+ const seen = new Set<string>();
173
+ tags.forEach((tag, i) => {
174
+ if (typeof tag !== 'string') {
175
+ errors.push(`tags[${i}] must be a string. Got: ${JSON.stringify(tag)}`);
176
+ return;
177
+ }
178
+ if (!TAG_SLUG_RE.test(tag)) {
179
+ errors.push(
180
+ `tags[${i}]: "${tag}" must be a lowercase slug (letters, digits, single hyphens). Known tags: ${KNOWN_TAGS.join(', ')}`,
181
+ );
182
+ } else if (tag.length > TAG_MAX_LENGTH) {
183
+ errors.push(`tags[${i}] must be ${TAG_MAX_LENGTH} characters or fewer`);
184
+ } else if (seen.has(tag)) {
185
+ errors.push(`tags[${i}] "${tag}" is duplicated`);
186
+ }
187
+ seen.add(tag);
188
+ });
189
+ return errors;
190
+ }
191
+
192
+ function validateActionParameters(parameters: unknown, actionIndex: number, errors: string[]): void {
193
+ if (typeof parameters !== 'object' || parameters === null || Array.isArray(parameters)) {
194
+ errors.push(`actions[${actionIndex}].parameters must be a JSON-Schema object with "type": "object"`);
195
+ return;
196
+ }
197
+ const p = parameters as Record<string, unknown>;
198
+ if (p.type !== 'object') {
199
+ errors.push(`actions[${actionIndex}].parameters.type must be "object"`);
200
+ }
201
+ if (p.properties !== undefined) {
202
+ if (typeof p.properties !== 'object' || p.properties === null || Array.isArray(p.properties)) {
203
+ errors.push(`actions[${actionIndex}].parameters.properties must be an object`);
204
+ } else {
205
+ for (const [key, prop] of Object.entries(p.properties as Record<string, unknown>)) {
206
+ if (typeof prop !== 'object' || prop === null) {
207
+ errors.push(`actions[${actionIndex}].parameters.properties.${key} must be an object`);
208
+ continue;
209
+ }
210
+ const pr = prop as Record<string, unknown>;
211
+ if (typeof pr.type !== 'string' || !(ALLOWED_ACTION_PARAM_TYPES as readonly string[]).includes(pr.type)) {
212
+ errors.push(
213
+ `actions[${actionIndex}].parameters.properties.${key}.type must be one of: ${ALLOWED_ACTION_PARAM_TYPES.join(', ')} (use "number", not "integer")`,
214
+ );
215
+ }
216
+ if (pr.type === 'array') {
217
+ const items = pr.items as Record<string, unknown> | undefined;
218
+ const itemType = items?.type;
219
+ if (typeof itemType !== 'string' || !['string', 'number', 'boolean'].includes(itemType)) {
220
+ errors.push(
221
+ `actions[${actionIndex}].parameters.properties.${key}.items.type must be "string" | "number" | "boolean" for an array param`,
222
+ );
223
+ }
224
+ }
225
+ if (pr.description !== undefined && typeof pr.description !== 'string') {
226
+ errors.push(`actions[${actionIndex}].parameters.properties.${key}.description must be a string if set`);
227
+ }
228
+ if (pr.enum !== undefined && !Array.isArray(pr.enum)) {
229
+ errors.push(`actions[${actionIndex}].parameters.properties.${key}.enum must be an array if set`);
230
+ }
231
+ }
232
+ }
233
+ }
234
+ if (p.required !== undefined && (!Array.isArray(p.required) || !p.required.every((x) => typeof x === 'string'))) {
235
+ errors.push(`actions[${actionIndex}].parameters.required must be an array of strings if set`);
236
+ }
237
+ }
238
+
239
+ export function validateManifest(manifest: unknown): { valid: boolean; errors: string[] } {
240
+ const errors: string[] = [];
241
+
242
+ if (typeof manifest !== 'object' || manifest === null) {
243
+ return { valid: false, errors: ['Manifest must be a JSON object'] };
244
+ }
245
+
246
+ const m = manifest as Record<string, unknown>;
247
+
248
+ if (typeof m.packageName !== 'string' || !m.packageName) {
249
+ errors.push('packageName must be a non-empty string');
250
+ }
251
+
252
+ if (typeof m.version !== 'string' || !m.version) {
253
+ errors.push('version must be a non-empty string');
254
+ }
255
+
256
+ if (typeof m.name !== 'string' || !m.name) {
257
+ errors.push('name must be a non-empty string');
258
+ }
259
+
260
+ if (m.tagline !== undefined) errors.push(...validateTagline(m.tagline));
261
+ if (m.tags !== undefined) errors.push(...validateTags(m.tags));
262
+
263
+ // permissions — optional array of {type, required?, description?}
264
+ if (m.permissions !== undefined) {
265
+ if (!Array.isArray(m.permissions)) {
266
+ errors.push('permissions must be an array of {type, required?, description?} objects');
267
+ } else {
268
+ m.permissions.forEach((perm, i) => {
269
+ if (typeof perm !== 'object' || perm === null) {
270
+ errors.push(
271
+ `permissions[${i}] must be an object like {"type": "MICROPHONE"}. Got: ${JSON.stringify(perm)}`,
272
+ );
273
+ return;
274
+ }
275
+ const p = perm as Record<string, unknown>;
276
+ if (typeof p.type !== 'string') {
277
+ errors.push(`permissions[${i}].type must be a string`);
278
+ return;
279
+ }
280
+ if (!(ALLOWED_PERMISSIONS as readonly string[]).includes(p.type)) {
281
+ errors.push(
282
+ `permissions[${i}].type: unknown permission "${p.type}". Allowed: ${ALLOWED_PERMISSIONS.join(', ')}`,
283
+ );
284
+ }
285
+ if (p.required !== undefined && typeof p.required !== 'boolean') {
286
+ errors.push(`permissions[${i}].required must be a boolean if set`);
287
+ }
288
+ if (p.description !== undefined && typeof p.description !== 'string') {
289
+ errors.push(`permissions[${i}].description must be a string if set`);
290
+ }
291
+ });
292
+ }
293
+ }
294
+
295
+ // hardwareRequirements — REQUIRED, array of {type, level, description?}
296
+ if (m.hardwareRequirements === undefined) {
297
+ errors.push(
298
+ 'hardwareRequirements is required. Example: [{"type": "DISPLAY", "level": "REQUIRED"}]. ' +
299
+ `Allowed types: ${ALLOWED_HARDWARE_TYPES.join(', ')}. ` +
300
+ `Levels: ${ALLOWED_HARDWARE_LEVELS.join(', ')}.`,
301
+ );
302
+ } else if (!Array.isArray(m.hardwareRequirements)) {
303
+ errors.push('hardwareRequirements must be an array of {type, level, description?} objects');
304
+ } else {
305
+ m.hardwareRequirements.forEach((req, i) => {
306
+ if (typeof req !== 'object' || req === null) {
307
+ errors.push(
308
+ `hardwareRequirements[${i}] must be an object like {"type": "DISPLAY", "level": "REQUIRED"}. Got: ${JSON.stringify(req)}`,
309
+ );
310
+ return;
311
+ }
312
+ const r = req as Record<string, unknown>;
313
+ if (typeof r.type !== 'string') {
314
+ errors.push(`hardwareRequirements[${i}].type must be a string`);
315
+ } else if (!(ALLOWED_HARDWARE_TYPES as readonly string[]).includes(r.type)) {
316
+ errors.push(
317
+ `hardwareRequirements[${i}].type: unknown hardware "${r.type}". Allowed: ${ALLOWED_HARDWARE_TYPES.join(', ')}`,
318
+ );
319
+ }
320
+ if (typeof r.level !== 'string') {
321
+ errors.push(`hardwareRequirements[${i}].level must be a string`);
322
+ } else if (!(ALLOWED_HARDWARE_LEVELS as readonly string[]).includes(r.level)) {
323
+ errors.push(
324
+ `hardwareRequirements[${i}].level: unknown level "${r.level}". Allowed: ${ALLOWED_HARDWARE_LEVELS.join(', ')}`,
325
+ );
326
+ }
327
+ if (r.description !== undefined && typeof r.description !== 'string') {
328
+ errors.push(`hardwareRequirements[${i}].description must be a string if set`);
329
+ }
330
+ });
331
+ }
332
+
333
+ // Optional sdkVersion / minHostVersion (semver-coercible strings).
334
+ // We don't enforce strict semver — many real-world manifests use a
335
+ // shorthand like "0.2" that semver.coerce normalises to "0.2.0". Reject
336
+ // only if the field is present and not a non-empty string.
337
+ if (m.sdkVersion !== undefined && (typeof m.sdkVersion !== 'string' || !m.sdkVersion)) {
338
+ errors.push('sdkVersion must be a non-empty string when set');
339
+ }
340
+ if (m.minHostVersion !== undefined && (typeof m.minHostVersion !== 'string' || !m.minHostVersion)) {
341
+ errors.push('minHostVersion must be a non-empty string when set');
342
+ }
343
+
344
+ // Optional entry object. When set, entry.background is required.
345
+ if (m.entry !== undefined) {
346
+ if (typeof m.entry !== 'object' || m.entry === null || Array.isArray(m.entry)) {
347
+ errors.push('entry must be an object like {"background": "background/index.js", "ui": "ui/index.html"}');
348
+ } else {
349
+ const e = m.entry as Record<string, unknown>;
350
+ if (typeof e.background !== 'string' || !e.background) {
351
+ errors.push('entry.background is required and must be a non-empty string path');
352
+ }
353
+ if (e.ui !== undefined && (typeof e.ui !== 'string' || !e.ui)) {
354
+ errors.push('entry.ui must be a non-empty string path when set');
355
+ }
356
+ }
357
+ }
358
+
359
+ if (m.type !== undefined) {
360
+ if (m.type !== 'standard' && m.type !== 'background' && m.type !== 'dashboard') {
361
+ errors.push('type must be "standard", "background" or "dashboard" when set');
362
+ }
363
+ }
364
+
365
+ if (m.alwaysOn !== undefined && typeof m.alwaysOn !== 'boolean') {
366
+ errors.push('alwaysOn must be a boolean when set');
367
+ }
368
+
369
+ // actions — optional array of {id, description, parameters?}. The MCP-shaped
370
+ // capability surface other (system) miniapps invoke via session.actions.
371
+ if (m.actions !== undefined) {
372
+ if (!Array.isArray(m.actions)) {
373
+ errors.push('actions must be an array of {id, description, parameters?} objects');
374
+ } else {
375
+ const seenIds = new Set<string>();
376
+ m.actions.forEach((action, i) => {
377
+ if (typeof action !== 'object' || action === null) {
378
+ errors.push(`actions[${i}] must be an object like {"id": "add_todo", "description": "..."}`);
379
+ return;
380
+ }
381
+ const a = action as Record<string, unknown>;
382
+ if (typeof a.id !== 'string' || !ACTION_ID_RE.test(a.id)) {
383
+ errors.push(
384
+ `actions[${i}].id must match ^[a-z][a-z0-9_]*$ (lowercase, start with a letter). Got: ${JSON.stringify(a.id)}`,
385
+ );
386
+ } else if (a.id.length > 64) {
387
+ errors.push(`actions[${i}].id must be 64 characters or fewer`);
388
+ } else if (seenIds.has(a.id)) {
389
+ errors.push(`actions[${i}].id "${a.id}" is duplicated — action ids must be unique within a miniapp`);
390
+ } else {
391
+ seenIds.add(a.id);
392
+ }
393
+ if (typeof a.description !== 'string' || !a.description.trim()) {
394
+ errors.push(
395
+ `actions[${i}].description is required and must be a non-empty string (it's the AI-facing contract — say when to use the action)`,
396
+ );
397
+ }
398
+ if (a.parameters !== undefined) {
399
+ validateActionParameters(a.parameters, i, errors);
400
+ }
401
+ if (
402
+ a.outputSchema !== undefined &&
403
+ (typeof a.outputSchema !== 'object' || a.outputSchema === null || Array.isArray(a.outputSchema))
404
+ ) {
405
+ errors.push(`actions[${i}].outputSchema must be a JSON-Schema object when set`);
406
+ }
407
+ });
408
+ }
409
+ }
410
+
411
+ return { valid: errors.length === 0, errors };
412
+ }
package/src/pack.ts ADDED
@@ -0,0 +1,131 @@
1
+ import { existsSync, mkdirSync, readFileSync, copyFileSync, writeFileSync } from 'fs';
2
+ import { resolve, join } from 'path';
3
+ import { buildProduction } from './build.js';
4
+ import { validateManifest } from './manifest.js';
5
+
6
+ export interface PackOptions {
7
+ /** Miniapp project root. Defaults to the current working directory. */
8
+ cwd?: string;
9
+ /** Run the production build before zipping. Defaults to false. */
10
+ build?: boolean;
11
+ /** Where to write the resulting zip. Defaults to build/. */
12
+ outDir?: string;
13
+ /** Quiet stdout. The `release` command swallows pack output and prints
14
+ * its own progress; standalone `pack` calls leave it on. */
15
+ silent?: boolean;
16
+ }
17
+
18
+ /**
19
+ * Validate manifest, copy manifest+icon into dist/, zip dist/ into
20
+ * `build/<packageName>-<version>.zip`. Returns the absolute path of the zip.
21
+ *
22
+ * `build/` is self-ignoring: a `.gitignore` containing `*` is written into
23
+ * it on creation (the Cargo `target/` trick), so packed zips stay out of
24
+ * version control no matter which repo the miniapp lives in — no root
25
+ * .gitignore coordination needed.
26
+ */
27
+ export async function pack(opts: PackOptions = {}): Promise<string> {
28
+ const cwd = resolve(opts.cwd ?? process.cwd());
29
+ if (opts.build) {
30
+ await buildProduction(cwd);
31
+ }
32
+
33
+ const distDir = resolve(cwd, 'dist');
34
+ const manifestSrc = resolve(cwd, 'miniapp.json');
35
+ const iconSrc = resolve(cwd, 'icon.png');
36
+
37
+ if (!existsSync(distDir)) {
38
+ console.error('Error: dist/ directory not found. Build your miniapp first.');
39
+ process.exit(1);
40
+ }
41
+
42
+ if (!existsSync(manifestSrc)) {
43
+ console.error('Error: miniapp.json not found in current directory');
44
+ process.exit(1);
45
+ }
46
+
47
+ const manifestRaw = readFileSync(manifestSrc, 'utf-8');
48
+ let manifest: Record<string, unknown>;
49
+ try {
50
+ manifest = JSON.parse(manifestRaw);
51
+ } catch {
52
+ console.error('Error: miniapp.json is not valid JSON');
53
+ process.exit(1);
54
+ }
55
+
56
+ const { valid, errors } = validateManifest(manifest);
57
+ if (!valid) {
58
+ console.error('Manifest validation failed:');
59
+ for (const err of errors) {
60
+ console.error(` - ${err}`);
61
+ }
62
+ process.exit(1);
63
+ }
64
+
65
+ // Enforce two-layer bundle contract when manifest.entry is set.
66
+ // `entry.background` (required for two-layer) must resolve to a file in the
67
+ // bundle. `entry.ui` (optional, for UI-bearing miniapps) likewise. Legacy
68
+ // single-bundle manifests without an `entry` object skip this check —
69
+ // pack still zips dist/ verbatim.
70
+ //
71
+ // Entry paths are relative to the *bundle root*, which is dist/'s contents
72
+ // (we zip from inside dist/ below), so `background/index.js` in the manifest
73
+ // is `dist/background/index.js` on disk — resolve against distDir.
74
+ const entry = manifest.entry as {background?: string; ui?: string} | undefined;
75
+ if (entry) {
76
+ const checkRelative = (label: string, rel: string | undefined, required: boolean) => {
77
+ if (!rel) {
78
+ if (required) {
79
+ console.error(`Error: manifest.entry.${label} is required for two-layer bundles`);
80
+ process.exit(1);
81
+ }
82
+ return;
83
+ }
84
+ const abs = resolve(distDir, rel);
85
+ if (!existsSync(abs)) {
86
+ console.error(`Error: manifest.entry.${label} points at "${rel}" but dist/${rel} does not exist`);
87
+ process.exit(1);
88
+ }
89
+ };
90
+ checkRelative('background', entry.background, true);
91
+ checkRelative('ui', entry.ui, false);
92
+ }
93
+
94
+ copyFileSync(manifestSrc, join(distDir, 'miniapp.json'));
95
+
96
+ if (existsSync(iconSrc)) {
97
+ copyFileSync(iconSrc, join(distDir, 'icon.png'));
98
+ } else if (!opts.silent) {
99
+ console.warn('Warning: icon.png not found in project root, skipping');
100
+ }
101
+
102
+ const packageName = manifest.packageName as string;
103
+ const version = manifest.version as string;
104
+ const outputName = `${packageName}-${version}.zip`;
105
+ const outDir = resolve(cwd, opts.outDir ?? 'build');
106
+ if (!existsSync(outDir)) {
107
+ mkdirSync(outDir, { recursive: true });
108
+ }
109
+ const selfIgnore = join(outDir, '.gitignore');
110
+ if (!existsSync(selfIgnore)) {
111
+ writeFileSync(selfIgnore, '*\n');
112
+ }
113
+ const outputPath = resolve(outDir, outputName);
114
+
115
+ const zipProc = Bun.spawn(['zip', '-r', outputPath, '.'], {
116
+ cwd: distDir,
117
+ stdout: opts.silent ? 'pipe' : 'inherit',
118
+ stderr: opts.silent ? 'pipe' : 'inherit',
119
+ });
120
+
121
+ const exitCode = await zipProc.exited;
122
+ if (exitCode !== 0) {
123
+ console.error('Error: zip command failed');
124
+ process.exit(1);
125
+ }
126
+
127
+ if (!opts.silent) {
128
+ console.log(`\nPacked: ${outputPath}`);
129
+ }
130
+ return outputPath;
131
+ }
@@ -0,0 +1,40 @@
1
+ // User-facing one-liners for the wizard / interactive prompts. Kept separate
2
+ // so manifest.ts can stay UX-string-free.
3
+
4
+ import {AllowedHardwareType, AllowedPermission} from "./manifest.js"
5
+
6
+ const PERMISSION_HINTS: Record<AllowedPermission, string> = {
7
+ MICROPHONE: "Required for transcription, audio chunks, voice activity detection",
8
+ CAMERA: "Required for taking photos via session.camera.takePhoto()",
9
+ CALENDAR: "Required to receive calendar event subscriptions",
10
+ LOCATION: "Required for foreground location updates",
11
+ BACKGROUND_LOCATION: "Required for location updates while app is backgrounded",
12
+ DISPLAY_MIRROR: "Read the global glasses display, including other miniapps",
13
+ READ_NOTIFICATIONS: "Required to receive phone notifications",
14
+ POST_NOTIFICATIONS: "Required to post system notifications from the miniapp",
15
+ API_KEYS: "Required to read user-supplied provider API keys via session.keys.get()",
16
+ MEMORY: "Required to read/write the user's shared memory timeline via session.memory",
17
+ AI: "Required to run LLM completions via session.ai.complete()",
18
+ SPEAKERS: "Required to resolve enrolled speaker ids to display names via session.speakers",
19
+ MANAGE_MINIAPPS: "Required to list, start and stop other miniapps via session.miniapps",
20
+ PLATFORM_SETTINGS: "Required to read and write platform settings via session.settings",
21
+ }
22
+
23
+ const HARDWARE_HINTS: Record<AllowedHardwareType, string> = {
24
+ CAMERA: "Glasses-side camera; required for photo capture",
25
+ DISPLAY: "Glasses display; required to show layouts",
26
+ MICROPHONE: "Glasses-side mic; required for capture",
27
+ SPEAKER: "Audio output through the glasses",
28
+ IMU: "Head position / motion sensor",
29
+ BUTTON: "Physical button on the glasses",
30
+ LIGHT: "RGB LED indicator",
31
+ WIFI: "Glasses Wi-Fi capability (e.g. for streaming)",
32
+ }
33
+
34
+ export function permissionDescription(p: AllowedPermission): string {
35
+ return PERMISSION_HINTS[p] ?? ""
36
+ }
37
+
38
+ export function hardwareDescription(h: AllowedHardwareType): string {
39
+ return HARDWARE_HINTS[h] ?? ""
40
+ }