parley-live 0.4.2 → 0.5.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.
Files changed (32) hide show
  1. package/README.md +1 -0
  2. package/dist/index.js +8 -2
  3. package/dist/lens.js +252 -0
  4. package/kb/index/bm25.json +1 -0
  5. package/kb/index/chunks-meta.jsonl +11523 -0
  6. package/lens-builder/build-from-prompt.mjs +19 -0
  7. package/lens-builder/build.mjs +147 -0
  8. package/lens-builder/cli.mjs +103 -0
  9. package/lens-builder/kb/lib-fetch.mjs +35 -0
  10. package/lens-builder/kb/search.mjs +61 -0
  11. package/lens-builder/kb/show.mjs +4 -0
  12. package/lens-builder/kb/tokenize.mjs +27 -0
  13. package/lens-builder/lib/bridge.mjs +186 -0
  14. package/lens-builder/lib/submission.mjs +246 -0
  15. package/lens-builder/mcp-client.mjs +101 -0
  16. package/lens-builder/pitch/one-pager.mjs +70 -0
  17. package/lens-builder/planner.mjs +108 -0
  18. package/lens-builder/publish.mjs +127 -0
  19. package/lens-builder/training/author-scene.ts +77 -0
  20. package/lens-builder/training/compile.mjs +258 -0
  21. package/lens-builder/vendor/specs-publish/LICENSE +208 -0
  22. package/lens-builder/vendor/specs-publish/NOTICE +13 -0
  23. package/lens-builder/vendor/specs-publish/scripts/make-eec-script.py +85 -0
  24. package/lens-builder/vendor/specs-publish/scripts/package.ts +189 -0
  25. package/lens-builder/vendor/specs-publish/scripts/preflight.ts +852 -0
  26. package/lens-builder/vendor/specs-publish/scripts/set-lens-icon.ts +107 -0
  27. package/lens-builder/vendor/specs-publish/scripts/set-lens-name.ts +121 -0
  28. package/lens-builder/vendor/specs-publish/scripts/set-signing-key.ts +129 -0
  29. package/lens-builder/vendor/specs-publish/scripts/signing-key.js +290 -0
  30. package/lens-builder/verify.mjs +186 -0
  31. package/lens-builder/webxr/generate.mjs +238 -0
  32. package/package.json +11 -5
@@ -0,0 +1,77 @@
1
+ // ExecuteEditorCode body (no imports/exports). Authors the TrainingGuide scene from `args.layout`, imports the
2
+ // runtime script from `args.scriptPath` and attaches it to the root. Idempotent: an existing TrainingGuide is replaced.
3
+ // Editor API per Lens Studio 5.24.0 api_locks/public.txt:
4
+ // ObjectOwner.createSceneObject / reparentSceneObject, SceneObject.addComponent / destroy / localTransform,
5
+ // Components.Text { text, size, weight, horizontalOverflow, verticalOverflow, layoutRect },
6
+ // AssetManager.importExternalFileAsync / getFileMeta, Components.ScriptComponent.scriptAsset
7
+ const a = args as any;
8
+ const model = pluginSystem.findInterface(Editor.Model.IModel) as Editor.Model.IModel;
9
+ const project = model.project;
10
+ const scene = project.scene;
11
+ const assetManager = project.assetManager;
12
+
13
+ for (const existing of scene.rootSceneObjects) {
14
+ if (existing.name === a.layout.root.name) existing.destroy();
15
+ }
16
+
17
+ function place(obj: Editor.Model.SceneObject, x: number, y: number, z: number) {
18
+ const t = obj.localTransform;
19
+ t.position = new vec3(x, y, z);
20
+ obj.localTransform = t;
21
+ }
22
+
23
+ function addText(parent: Editor.Model.SceneObject, spec: any): Editor.Model.SceneObject {
24
+ const obj = scene.createSceneObject(spec.name);
25
+ scene.reparentSceneObject(obj, parent);
26
+ place(obj, spec.x || 0, spec.y || 0, spec.z || 0);
27
+ const text = obj.addComponent("Text") as Editor.Components.Text;
28
+ text.text = spec.text;
29
+ text.size = spec.size;
30
+ if (spec.weight) text.weight = spec.weight;
31
+ text.horizontalOverflow = Editor.Components.HorizontalOverflow.Wrap;
32
+ text.verticalOverflow = Editor.Components.VerticalOverflow.Shrink;
33
+ const rect = new Editor.Rect();
34
+ rect.left = -spec.halfW;
35
+ rect.right = spec.halfW;
36
+ rect.bottom = -spec.halfH;
37
+ rect.top = spec.halfH;
38
+ text.layoutRect = rect;
39
+ return obj;
40
+ }
41
+
42
+ const root = scene.createSceneObject(a.layout.root.name);
43
+ place(root, a.layout.root.position.x, a.layout.root.position.y, a.layout.root.position.z);
44
+
45
+ const created: string[] = [root.name];
46
+ for (const t of a.layout.texts) created.push(addText(root, t).name);
47
+ for (const b of a.layout.buttons) {
48
+ const btn = scene.createSceneObject(b.name);
49
+ scene.reparentSceneObject(btn, root);
50
+ place(btn, b.x, b.y, 0);
51
+ addText(btn, { name: b.name + "_Label", text: b.label, size: 39, weight: 500, z: 1, halfW: b.w / 2, halfH: b.h / 2 });
52
+ created.push(btn.name);
53
+ }
54
+
55
+ // Runtime script: import once, overwrite on later iterations.
56
+ const dir = "Scripts";
57
+ const fileName = "TrainingGuide.ts";
58
+ const rel = new Editor.Model.SourcePath(new Editor.Path(dir + "/" + fileName), Editor.Model.SourceRootDirectory.Assets);
59
+ let scriptAsset: Editor.Assets.Asset = null;
60
+ let mode = "imported";
61
+ const existingMeta = assetManager.getFileMeta(rel);
62
+ if (existingMeta && existingMeta.primaryAsset) {
63
+ const FileSystem: any = await import("LensStudio:FileSystem");
64
+ FileSystem.writeFile(assetManager.assetsDirectory.appended(new Editor.Path(dir + "/" + fileName)), FileSystem.readFile(new Editor.Path(String(a.scriptPath))));
65
+ scriptAsset = existingMeta.primaryAsset;
66
+ mode = "overwritten";
67
+ } else {
68
+ const dest = new Editor.Model.SourcePath(new Editor.Path(dir), Editor.Model.SourceRootDirectory.Assets);
69
+ const res = await assetManager.importExternalFileAsync(new Editor.Path(String(a.scriptPath)), dest);
70
+ scriptAsset = res.primary;
71
+ }
72
+ if (!scriptAsset) throw new Error("TrainingGuide.ts could not be imported");
73
+ const sc = root.addComponent("ScriptComponent") as Editor.Components.ScriptComponent;
74
+ sc.scriptAsset = scriptAsset as Editor.Assets.ScriptAsset;
75
+
76
+ project.save();
77
+ return { created, script: { mode, type: scriptAsset.getTypeName() }, rootId: root.id.toString() };
@@ -0,0 +1,258 @@
1
+ // Training vertical compiler: a filled form -> Lens Plan (schema 6.1) + runtime TypeScript + scene layout.
2
+ // Deterministic: no model calls, $0 per Lens. Free-form prompts go through the Planner, which outputs this same form.
3
+ //
4
+ // Design decisions and their sources (all in the KB):
5
+ // - Pinch buttons are the primary input; voice is an optional shortcut that needs a fallback.
6
+ // CLAD specs-asr/SKILL.md ("Not recommended for voice commands ... design a fallback (pinch, button, gaze)")
7
+ // https://developers.snap.com/spectacles/best-practices/design-for-spectacles/choosing-an-input
8
+ // - Panel at z = -110 cm, buttons >= 6 cm, dark/light contrast, slightly below eye level.
9
+ // CLAD specs-build-ui/references/spectacles-spatial-design.md#quick-reference-default-placement
10
+ // - Text sizes from Snap's type scale (Headline 2 = 48, Body = 39, Caption = 38, Button = 39).
11
+ // CLAD specs-build-ui/SKILL.md#type-scale-calibrated-for-the-default-z-110-cm
12
+ // - Buttons: UIKit RectangleButton created on an authored scene object.
13
+ // https://developers.snap.com/spectacles/spectacles-frameworks/spectacles-ui-kit/components/Button#code-example
14
+ // - Speech: LensStudio:AsrModule with AsrTranscriptionOptions.
15
+ // https://developers.snap.com/spectacles/about-spectacles-features/apis/asr-module
16
+ import { search } from '../kb/search.mjs';
17
+
18
+ export const LENS_VERSION = '1.0.0';
19
+ export const LIMITS = { maxSteps: 20, maxTitle: 40, maxInstruction: 220, maxWarning: 120 };
20
+ const PANEL_Z = -110;
21
+
22
+ export function validateForm(form) {
23
+ const errors = [];
24
+ if (!form || typeof form !== 'object') return ['form must be an object'];
25
+ if (!form.procedureName || typeof form.procedureName !== 'string') errors.push('procedureName is required');
26
+ else if (form.procedureName.length > LIMITS.maxTitle) errors.push(`procedureName must be <= ${LIMITS.maxTitle} characters to fit the panel`);
27
+ if (!Array.isArray(form.steps) || form.steps.length === 0) errors.push('at least one step is required');
28
+ else if (form.steps.length > LIMITS.maxSteps) errors.push(`at most ${LIMITS.maxSteps} steps`);
29
+ (form.steps || []).forEach((s, i) => {
30
+ if (!s.instruction || typeof s.instruction !== 'string') errors.push(`step ${i + 1}: instruction is required`);
31
+ else if (s.instruction.length > LIMITS.maxInstruction) errors.push(`step ${i + 1}: instruction must be <= ${LIMITS.maxInstruction} characters to stay readable`);
32
+ if (s.warning && s.warning.length > LIMITS.maxWarning) errors.push(`step ${i + 1}: warning must be <= ${LIMITS.maxWarning} characters`);
33
+ });
34
+ return errors;
35
+ }
36
+
37
+ export function lensIdFor(form) {
38
+ return 'training-' + form.procedureName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '').slice(0, 40);
39
+ }
40
+
41
+ // Scene layout the Implementer authors in the editor. Units are cm, local to the TrainingGuide root.
42
+ export function layout(form) {
43
+ return {
44
+ root: { name: 'TrainingGuide', position: { x: 0, y: -4, z: PANEL_Z } },
45
+ texts: [
46
+ { name: 'TG_Title', text: form.procedureName, size: 48, weight: 700, y: 17, halfW: 26, halfH: 3 },
47
+ { name: 'TG_Progress', text: `Step 1 of ${form.steps.length}`, size: 38, weight: 500, y: 11.5, halfW: 26, halfH: 2 },
48
+ { name: 'TG_Instruction', text: form.steps[0].instruction, size: 39, weight: 500, y: 2, halfW: 26, halfH: 7 },
49
+ { name: 'TG_Warning', text: form.steps[0].warning || '', size: 38, weight: 700, y: -8.5, halfW: 26, halfH: 3 },
50
+ // Snap's Spectacles publishing checklist asks for a visible version number.
51
+ { name: 'TG_Version', text: 'v' + (form.version || LENS_VERSION), size: 24, weight: 500, y: -23, halfW: 26, halfH: 1.5 },
52
+ ],
53
+ buttons: [
54
+ { name: 'TG_BtnBack', label: 'Back', x: -13, y: -17, w: 16, h: 6 },
55
+ { name: 'TG_BtnNext', label: 'Done', x: 13, y: -17, w: 16, h: 6 },
56
+ ],
57
+ };
58
+ }
59
+
60
+ export function runtimeScript(form) {
61
+ const steps = form.steps.map((s, i) => ({ n: i + 1, instruction: s.instruction, warning: s.warning || '' }));
62
+ const voice = form.voiceShortcuts !== false;
63
+ return `// Generated by Parley Lens Builder - hands-free training guide: ${form.procedureName.replace(/\*\//g, '')}
64
+ // Snap APIs used and where they are documented:
65
+ // - BaseScriptComponent, @component, print, getTime, SceneObject.getChild / getComponent("Component.Text") [Lens Scripting API, StudioLib.d.ts 5.24.0]
66
+ // - RectangleButton (SpectaclesUIKit): createComponent + size + initialize() + onTriggerUp
67
+ // https://developers.snap.com/spectacles/spectacles-frameworks/spectacles-ui-kit/components/Button#code-example
68
+ // - LensStudio:AsrModule: AsrTranscriptionOptions.create, startTranscribing, onTranscriptionUpdateEvent
69
+ // https://developers.snap.com/spectacles/about-spectacles-features/apis/asr-module
70
+ // Voice is a shortcut only; Snap advises a pinch/button fallback for commands (CLAD specs-asr/SKILL.md).
71
+ import { RectangleButton } from 'SpectaclesUIKit.lspkg/Scripts/Components/Button/RectangleButton';
72
+
73
+ const STEPS: { n: number; instruction: string; warning: string }[] = ${JSON.stringify(steps, null, 2)};
74
+ const COMPLETION = ${JSON.stringify(form.completionMessage || 'Procedure complete. Well done.')};
75
+ const VOICE_ENABLED = ${voice};
76
+ const TAG = '[ParleyTG]';
77
+ const VERSION = ${JSON.stringify(form.version || LENS_VERSION)};
78
+
79
+ @component
80
+ export class TrainingGuide extends BaseScriptComponent {
81
+ private index = 0;
82
+ private finished = false;
83
+ private lastPressAt = 0;
84
+ private title: Text;
85
+ private progress: Text;
86
+ private instruction: Text;
87
+ private warning: Text;
88
+ private nextLabel: Text;
89
+ private backObj: SceneObject;
90
+
91
+ onAwake() {
92
+ this.createEvent('OnStartEvent').bind(() => this.start());
93
+ }
94
+
95
+ private child(name: string): SceneObject {
96
+ const root = this.getSceneObject();
97
+ for (let i = 0; i < root.getChildrenCount(); i++) {
98
+ const c = root.getChild(i);
99
+ if (c.name === name) return c;
100
+ }
101
+ print(TAG + ' ERROR missing scene object: ' + name);
102
+ return null;
103
+ }
104
+
105
+ private textOf(obj: SceneObject): Text {
106
+ return obj ? (obj.getComponent('Component.Text') as Text) : null;
107
+ }
108
+
109
+ private start() {
110
+ this.title = this.textOf(this.child('TG_Title'));
111
+ this.progress = this.textOf(this.child('TG_Progress'));
112
+ this.instruction = this.textOf(this.child('TG_Instruction'));
113
+ this.warning = this.textOf(this.child('TG_Warning'));
114
+ const nextObj = this.child('TG_BtnNext');
115
+ this.backObj = this.child('TG_BtnBack');
116
+ if (!this.title || !this.progress || !this.instruction || !this.warning || !nextObj || !this.backObj) {
117
+ print(TAG + ' ERROR scene is not wired; aborting');
118
+ return;
119
+ }
120
+ this.nextLabel = this.textOf(nextObj.getChild(0));
121
+ this.makeButton(nextObj, () => this.next());
122
+ this.makeButton(this.backObj, () => this.back());
123
+ if (VOICE_ENABLED) this.startVoice();
124
+ print(TAG + ' ready steps=' + STEPS.length);
125
+ // Snap's Spectacles publishing checklist: log the version on startup. Printed after "ready" because the very
126
+ // first line after a preview reset can land before the log collector's reset boundary (observed 5.24.0).
127
+ print('Lens Opened: v' + VERSION);
128
+ this.render();
129
+ }
130
+
131
+ private makeButton(obj: SceneObject, onPress: () => void) {
132
+ const button = obj.createComponent(RectangleButton.getTypeName()) as RectangleButton;
133
+ button.size = new vec3(16, 6, 1);
134
+ button.initialize();
135
+ // One physical pinch can deliver more than one trigger (seen in preview); accept one press per 600 ms.
136
+ button.onTriggerUp.add(() => {
137
+ const now = getTime();
138
+ if (now - this.lastPressAt < 0.6) return;
139
+ this.lastPressAt = now;
140
+ onPress();
141
+ });
142
+ }
143
+
144
+ private next() {
145
+ if (this.finished) return;
146
+ if (this.index < STEPS.length - 1) {
147
+ this.index++;
148
+ this.render();
149
+ } else {
150
+ this.finished = true;
151
+ this.progress.text = 'Complete';
152
+ this.instruction.text = COMPLETION;
153
+ this.warning.text = '';
154
+ this.nextLabel.text = 'Finished';
155
+ this.backObj.enabled = false; // nothing to go back to once the procedure is signed off
156
+ print(TAG + ' complete');
157
+ }
158
+ }
159
+
160
+ private back() {
161
+ if (this.finished || this.index === 0) return;
162
+ this.index--;
163
+ this.render();
164
+ }
165
+
166
+ private render() {
167
+ const s = STEPS[this.index];
168
+ this.progress.text = 'Step ' + s.n + ' of ' + STEPS.length;
169
+ this.instruction.text = s.instruction;
170
+ this.warning.text = s.warning ? 'Caution: ' + s.warning : '';
171
+ this.nextLabel.text = this.index === STEPS.length - 1 ? 'Finish' : 'Done';
172
+ this.backObj.enabled = this.index > 0;
173
+ print(TAG + ' step=' + s.n + '/' + STEPS.length);
174
+ }
175
+
176
+ private startVoice() {
177
+ try {
178
+ const asrModule = require('LensStudio:AsrModule');
179
+ const options = AsrModule.AsrTranscriptionOptions.create();
180
+ options.silenceUntilTerminationMs = 800;
181
+ options.mode = AsrModule.AsrMode.HighAccuracy;
182
+ options.onTranscriptionUpdateEvent.add((e: AsrModule.TranscriptionUpdateEvent) => {
183
+ if (!e.isFinal) return;
184
+ const said = e.text.toLowerCase();
185
+ if (/\\b(done|next|continue|finished)\\b/.test(said)) this.next();
186
+ else if (/\\b(back|previous)\\b/.test(said)) this.back();
187
+ });
188
+ options.onTranscriptionErrorEvent.add((code: AsrModule.AsrStatusCode) => {
189
+ print(TAG + ' voice unavailable code=' + code + ' (buttons still work)');
190
+ });
191
+ asrModule.startTranscribing(options);
192
+ print(TAG + ' voice shortcuts on');
193
+ } catch (err) {
194
+ print(TAG + ' voice unavailable (buttons still work): ' + err);
195
+ }
196
+ }
197
+ }
198
+ `;
199
+ }
200
+
201
+ // Every API the plan names must trace to a KB chunk (Phase 1 acceptance, plan rule 1 + 2).
202
+ const API_QUERIES = [
203
+ { name: 'RectangleButton (SpectaclesUIKit)', why: 'Pinchable Done/Back buttons, the primary input', q: 'UIKit RectangleButton create from script onTriggerUp', must: 'spectacles-ui-kit/components/Button' },
204
+ { name: 'AsrModule.startTranscribing', why: 'Optional voice shortcuts: "done", "next", "back"', q: 'AsrModule startTranscribing options speech to text', must: 'asr' },
205
+ { name: 'Text (Component.Text)', why: 'Title, progress, instruction and caution text', q: 'Text component class text size property', must: 'Text' },
206
+ { name: 'BaseScriptComponent / @component', why: 'TypeScript component lifecycle (onAwake, OnStartEvent)', q: 'BaseScriptComponent component onAwake createEvent OnStartEvent', must: '' },
207
+ ];
208
+
209
+ export function citeApis(form) {
210
+ return API_QUERIES.filter((a) => form.voiceShortcuts !== false || !a.name.startsWith('Asr')).map((a) => {
211
+ const hits = search(a.q, { k: 8 });
212
+ const hit = hits.find((h) => !a.must || (h.source_url + h.title).toLowerCase().includes(a.must.toLowerCase())) || null;
213
+ return { name: a.name, why: a.why, kb_source: hit ? hit.source_url : null };
214
+ });
215
+ }
216
+
217
+ export function compile(form) {
218
+ const errors = validateForm(form);
219
+ if (errors.length) { const e = new Error('Form is not buildable: ' + errors.join('; ')); e.formErrors = errors; throw e; }
220
+ const lens_id = form.lensId || lensIdFor(form);
221
+ const snap_apis = citeApis(form);
222
+ const uncited = snap_apis.filter((a) => !a.kb_source).map((a) => a.name);
223
+ if (uncited.length) throw new Error(`No KB source for: ${uncited.join(', ')}. Refusing to build with uncited APIs.`);
224
+ const n = form.steps.length;
225
+ const voice = form.voiceShortcuts !== false;
226
+ const plan = {
227
+ lens_id,
228
+ vertical: 'training',
229
+ title: form.procedureName,
230
+ summary: `Hands-free guide for "${form.procedureName}" with ${n} step${n === 1 ? '' : 's'}. The wearer reads each instruction on a floating panel and pinches Done to advance${voice ? ', or says "done"' : ''}.`,
231
+ target_device: 'specs',
232
+ user_flow: [
233
+ ...form.steps.map((s, i) => ({ step: i + 1, trigger: i === 0 ? 'Lens start' : `Done pressed on step ${i}`, display: `Step ${i + 1} of ${n}: ${s.instruction}${s.warning ? ' (Caution: ' + s.warning + ')' : ''}`, interaction: voice ? 'pinch | voice' : 'pinch' })),
234
+ { step: n + 1, trigger: `Finish pressed on step ${n}`, display: form.completionMessage || 'Procedure complete. Well done.', interaction: 'none' },
235
+ ],
236
+ scene_objects: [
237
+ { name: 'TrainingGuide', type: 'root + TrainingGuide.ts', assets: ['TrainingGuide.ts'], anchoring: 'world' },
238
+ ...layout(form).texts.map((t) => ({ name: t.name, type: 'Text', assets: [], anchoring: 'world' })),
239
+ ...layout(form).buttons.map((b) => ({ name: b.name, type: 'RectangleButton + Text label', assets: ['SpectaclesUIKit.lspkg'], anchoring: 'world' })),
240
+ ],
241
+ scripts: [{ file: 'TrainingGuide.ts', purpose: 'Step state machine, button wiring, optional voice shortcuts, progress logging', apis_used: snap_apis.map((a) => a.name) }],
242
+ snap_apis,
243
+ assets_needed: [{ name: 'SpectaclesUIKit + SpectaclesInteractionKit', kind: 'text', source: 'library' }],
244
+ acceptance_tests: [
245
+ 'TypeScript compiles with zero errors',
246
+ `On start the log shows "Lens Opened: v${form.version || LENS_VERSION}" (Snap publishing checklist)`,
247
+ `On start the log shows "[ParleyTG] ready steps=${n}" and "[ParleyTG] step=1/${n}"`,
248
+ `Pressing Done ${n} time${n === 1 ? '' : 's'} logs every step up to ${n}/${n}, then "[ParleyTG] complete"`,
249
+ 'Pressing Back on step 2 returns to step 1',
250
+ 'No runtime errors in the preview log',
251
+ ],
252
+ open_questions: [
253
+ ...(voice ? ['Voice shortcut accuracy can only be judged on real Specs hardware (Snap advises against relying on ASR for commands).'] : []),
254
+ 'Panel comfort and legibility in the real workspace needs a hardware check.',
255
+ ],
256
+ };
257
+ return { lens_id, plan, script: runtimeScript(form), layout: layout(form) };
258
+ }
@@ -0,0 +1,208 @@
1
+ Copyright 2026 Specs Inc.
2
+
3
+ Except as otherwise noted, the software, documentation, and other materials in this repository are licensed under the Apache License, Version 2.0, reproduced below.
4
+
5
+ Use of Lens Studio, Lens Studio APIs, and other Snap products and services remains subject to the applicable Snap terms. Those terms do not modify the Apache License applicable to the contents of this repository.
6
+
7
+
8
+ Apache License
9
+ Version 2.0, January 2004
10
+ http://www.apache.org/licenses/
11
+
12
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
13
+
14
+ 1. Definitions.
15
+
16
+ "License" shall mean the terms and conditions for use, reproduction,
17
+ and distribution as defined by Sections 1 through 9 of this document.
18
+
19
+ "Licensor" shall mean the copyright owner or entity authorized by
20
+ the copyright owner that is granting the License.
21
+
22
+ "Legal Entity" shall mean the union of the acting entity and all
23
+ other entities that control, are controlled by, or are under common
24
+ control with that entity. For the purposes of this definition,
25
+ "control" means (i) the power, direct or indirect, to cause the
26
+ direction or management of such entity, whether by contract or
27
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
28
+ outstanding shares, or (iii) beneficial ownership of such entity.
29
+
30
+ "You" (or "Your") shall mean an individual or Legal Entity
31
+ exercising permissions granted by this License.
32
+
33
+ "Source" form shall mean the preferred form for making modifications,
34
+ including but not limited to software source code, documentation
35
+ source, and configuration files.
36
+
37
+ "Object" form shall mean any form resulting from mechanical
38
+ transformation or translation of a Source form, including but
39
+ not limited to compiled object code, generated documentation,
40
+ and conversions to other media types.
41
+
42
+ "Work" shall mean the work of authorship, whether in Source or
43
+ Object form, made available under the License, as indicated by a
44
+ copyright notice that is included in or attached to the work
45
+ (an example is provided in the Appendix below).
46
+
47
+ "Derivative Works" shall mean any work, whether in Source or Object
48
+ form, that is based on (or derived from) the Work and for which the
49
+ editorial revisions, annotations, elaborations, or other modifications
50
+ represent, as a whole, an original work of authorship. For the purposes
51
+ of this License, Derivative Works shall not include works that remain
52
+ separable from, or merely link (or bind by name) to the interfaces of,
53
+ the Work and Derivative Works thereof.
54
+
55
+ "Contribution" shall mean any work of authorship, including
56
+ the original version of the Work and any modifications or additions
57
+ to that Work or Derivative Works thereof, that is intentionally
58
+ submitted to Licensor for inclusion in the Work by the copyright owner
59
+ or by an individual or Legal Entity authorized to submit on behalf of
60
+ the copyright owner. For the purposes of this definition, "submitted"
61
+ means any form of electronic, verbal, or written communication sent
62
+ to the Licensor or its representatives, including but not limited to
63
+ communication on electronic mailing lists, source code control systems,
64
+ and issue tracking systems that are managed by, or on behalf of, the
65
+ Licensor for the purpose of discussing and improving the Work, but
66
+ excluding communication that is conspicuously marked or otherwise
67
+ designated in writing by the copyright owner as "Not a Contribution."
68
+
69
+ "Contributor" shall mean Licensor and any individual or Legal Entity
70
+ on behalf of whom a Contribution has been received by Licensor and
71
+ subsequently incorporated within the Work.
72
+
73
+ 2. Grant of Copyright License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ copyright license to reproduce, prepare Derivative Works of,
77
+ publicly display, publicly perform, sublicense, and distribute the
78
+ Work and such Derivative Works in Source or Object form.
79
+
80
+ 3. Grant of Patent License. Subject to the terms and conditions of
81
+ this License, each Contributor hereby grants to You a perpetual,
82
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
83
+ (except as stated in this section) patent license to make, have made,
84
+ use, offer to sell, sell, import, and otherwise transfer the Work,
85
+ where such license applies only to those patent claims licensable
86
+ by such Contributor that are necessarily infringed by their
87
+ Contribution(s) alone or by combination of their Contribution(s)
88
+ with the Work to which such Contribution(s) was submitted. If You
89
+ institute patent litigation against any entity (including a
90
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
91
+ or a Contribution incorporated within the Work constitutes direct
92
+ or contributory patent infringement, then any patent licenses
93
+ granted to You under this License for that Work shall terminate
94
+ as of the date such litigation is filed.
95
+
96
+ 4. Redistribution. You may reproduce and distribute copies of the
97
+ Work or Derivative Works thereof in any medium, with or without
98
+ modifications, and in Source or Object form, provided that You
99
+ meet the following conditions:
100
+
101
+ (a) You must give any other recipients of the Work or
102
+ Derivative Works a copy of this License; and
103
+
104
+ (b) You must cause any modified files to carry prominent notices
105
+ stating that You changed the files; and
106
+
107
+ (c) You must retain, in the Source form of any Derivative Works
108
+ that You distribute, all copyright, patent, trademark, and
109
+ attribution notices from the Source form of the Work,
110
+ excluding those notices that do not pertain to any part of
111
+ the Derivative Works; and
112
+
113
+ (d) If the Work includes a "NOTICE" text file as part of its
114
+ distribution, then any Derivative Works that You distribute must
115
+ include a readable copy of the attribution notices contained
116
+ within such NOTICE file, excluding those notices that do not
117
+ pertain to any part of the Derivative Works, in at least one
118
+ of the following places: within a NOTICE text file distributed
119
+ as part of the Derivative Works; within the Source form or
120
+ documentation, if provided along with the Derivative Works; or,
121
+ within a display generated by the Derivative Works, if and
122
+ wherever such third-party notices normally appear. The contents
123
+ of the NOTICE file are for informational purposes only and
124
+ do not modify the License. You may add Your own attribution
125
+ notices within Derivative Works that You distribute, alongside
126
+ or as an addendum to the NOTICE text from the Work, provided
127
+ that such additional attribution notices cannot be construed
128
+ as modifying the License.
129
+
130
+ You may add Your own copyright statement to Your modifications and
131
+ may provide additional or different license terms and conditions
132
+ for use, reproduction, or distribution of Your modifications, or
133
+ for any such Derivative Works as a whole, provided Your use,
134
+ reproduction, and distribution of the Work otherwise complies with
135
+ the conditions stated in this License.
136
+
137
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
138
+ any Contribution intentionally submitted for inclusion in the Work
139
+ by You to the Licensor shall be under the terms and conditions of
140
+ this License, without any additional terms or conditions.
141
+ Notwithstanding the above, nothing herein shall supersede or modify
142
+ the terms of any separate license agreement you may have executed
143
+ with Licensor regarding such Contributions.
144
+
145
+ 6. Trademarks. This License does not grant permission to use the trade
146
+ names, trademarks, service marks, or product names of the Licensor,
147
+ except as required for reasonable and customary use in describing the
148
+ origin of the Work and reproducing the content of the NOTICE file.
149
+
150
+ 7. Disclaimer of Warranty. Unless required by applicable law or
151
+ agreed to in writing, Licensor provides the Work (and each
152
+ Contributor provides its Contributions) on an "AS IS" BASIS,
153
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
154
+ implied, including, without limitation, any warranties or conditions
155
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
156
+ PARTICULAR PURPOSE. You are solely responsible for determining the
157
+ appropriateness of using or redistributing the Work and assume any
158
+ risks associated with Your exercise of permissions under this License.
159
+
160
+ 8. Limitation of Liability. In no event and under no legal theory,
161
+ whether in tort (including negligence), contract, or otherwise,
162
+ unless required by applicable law (such as deliberate and grossly
163
+ negligent acts) or agreed to in writing, shall any Contributor be
164
+ liable to You for damages, including any direct, indirect, special,
165
+ incidental, or consequential damages of any character arising as a
166
+ result of this License or out of the use or inability to use the
167
+ Work (including but not limited to damages for loss of goodwill,
168
+ work stoppage, computer failure or malfunction, or any and all
169
+ other commercial damages or losses), even if such Contributor
170
+ has been advised of the possibility of such damages.
171
+
172
+ 9. Accepting Warranty or Additional Liability. While redistributing
173
+ the Work or Derivative Works thereof, You may choose to offer,
174
+ and charge a fee for, acceptance of support, warranty, indemnity,
175
+ or other liability obligations and/or rights consistent with this
176
+ License. However, in accepting such obligations, You may act only
177
+ on Your own behalf and on Your sole responsibility, not on behalf
178
+ of any other Contributor, and only if You agree to indemnify,
179
+ defend, and hold each Contributor harmless for any liability
180
+ incurred by, or claims asserted against, such Contributor by reason
181
+ of your accepting any such warranty or additional liability.
182
+
183
+ END OF TERMS AND CONDITIONS
184
+
185
+ APPENDIX: How to apply the Apache License to your work.
186
+
187
+ To apply the Apache License to your work, attach the following
188
+ boilerplate notice, with the fields enclosed by brackets "[]"
189
+ replaced with your own identifying information. (Don't include
190
+ the brackets!) The text should be enclosed in the appropriate
191
+ comment syntax for the file format. We also recommend that a
192
+ file or class name and description of purpose be included on the
193
+ same "printed page" as the copyright notice for easier
194
+ identification within third-party archives.
195
+
196
+ Copyright 2026 Specs Inc.
197
+
198
+ Licensed under the Apache License, Version 2.0 (the "License");
199
+ you may not use this file except in compliance with the License.
200
+ You may obtain a copy of the License at
201
+
202
+ http://www.apache.org/licenses/LICENSE-2.0
203
+
204
+ Unless required by applicable law or agreed to in writing, software
205
+ distributed under the License is distributed on an "AS IS" BASIS,
206
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
207
+ See the License for the specific language governing permissions and
208
+ limitations under the License.
@@ -0,0 +1,13 @@
1
+ These scripts are Snap's own Specs publishing toolchain, copied unmodified from
2
+
3
+ https://github.com/lens-studio-devs/ls-extensions
4
+ plugins/ls-clad/skills/specs-publish/scripts
5
+ commit 8adedd5d5b93f9dbe55f31c6be4264a4f8a608b3
6
+
7
+ Copyright 2026 Specs Inc., licensed under the Apache License, Version 2.0 (see LICENSE).
8
+
9
+ Parley runs them as-is rather than reimplementing them. Snap's own guidance is that the
10
+ exact logic for signing-key setup, icon assignment, SnapOS Package (SPK) export and
11
+ authorized API calls must come from these pinned scripts. The export path cannot be
12
+ exercised without a signed-in Lens Studio, so reimplementing it blind would ship untested
13
+ code; running Snap's script is the honest option.
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env python3
2
+ # Copyright 2026 Specs Inc.
3
+ # SPDX-License-Identifier: Apache-2.0
4
+
5
+ """Fill a pinned ExecuteEditorCode script's CONFIG consts; print a temp file path.
6
+
7
+ Substituting these by hand is unsafe. A value containing a double quote makes
8
+ invalid TypeScript, and a Windows path like C:\\Users\\me\\P.esproj compiles fine
9
+ while silently becoming C:UsersmeP.esproj, because \\U and \\m are not the escapes
10
+ you meant. Everything here goes through json.dumps instead.
11
+
12
+ Each run writes a fresh temp file. Concurrent callers need that — build-mesh fans
13
+ out up to 4 SPECS jobs, and a shared path lets one job's config overwrite
14
+ another's between the write and the ExecuteEditorCode read.
15
+
16
+ make-eec-script.py TARGET.ts --set NAME=VALUE [...] [--json NAME=FILE ...]
17
+
18
+ --set takes a raw string: pass it exactly as intended, no escaping. --json reads
19
+ an object const (BODY, EXTRA_HEADERS) from a JSON file — write that file with
20
+ your editor tool and free text never touches the shell.
21
+
22
+ Only the value is replaced, so each declaration's type annotation and trailing
23
+ comment survive as written. That is load-bearing: text-to-3d-request.ts compares
24
+ METHOD === "GET", which only compiles while METHOD is declared ": string".
25
+ """
26
+
27
+ import argparse
28
+ import json
29
+ import os
30
+ import re
31
+ import sys
32
+ import tempfile
33
+
34
+ # const NAME[: Type] = value; [// trailing comment]
35
+ DECL = re.compile(r"(?P<head>const\s+(?P<name>\w+)\b[^=]*?)\s*=\s*.*?;(?P<comment>\s*//.*)?$")
36
+
37
+
38
+ def main():
39
+ ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
40
+ ap.add_argument("target", help="pinned .ts script with a CONFIG block")
41
+ ap.add_argument("--set", action="append", default=[], metavar="NAME=VALUE", help="string const, raw value")
42
+ ap.add_argument("--json", action="append", default=[], metavar="NAME=FILE", help="object const, JSON from FILE")
43
+ args = ap.parse_args()
44
+
45
+ values = {}
46
+ for raw in args.set:
47
+ name, _, value = raw.partition("=")
48
+ values[name] = json.dumps(value)
49
+ for raw in args.json:
50
+ name, _, path = raw.partition("=")
51
+ try:
52
+ with open(path, encoding="utf-8") as fh:
53
+ values[name] = json.dumps(json.load(fh))
54
+ except (OSError, json.JSONDecodeError) as e:
55
+ sys.exit(f"make-eec-script: --json {name}: {path}: {e}")
56
+
57
+ seen = {}
58
+ out = []
59
+ with open(args.target, encoding="utf-8") as fh:
60
+ for line in fh.read().splitlines():
61
+ m = DECL.match(line)
62
+ if m and m.group("name") in values:
63
+ name = m.group("name")
64
+ seen[name] = seen.get(name, 0) + 1
65
+ out.append(f"{m.group('head')} = {values[name]};{m.group('comment') or ''}")
66
+ else:
67
+ out.append(line)
68
+
69
+ # Catches a misspelled --set (which would otherwise leave the placeholder in
70
+ # place and run with an empty value) and any unexpected duplicate.
71
+ wrong = {n: seen.get(n, 0) for n in values if seen.get(n, 0) != 1}
72
+ if wrong:
73
+ sys.exit(
74
+ f"make-eec-script: {os.path.basename(args.target)}: expected exactly one declaration of each of "
75
+ + ", ".join(f"{n} (found {c})" for n, c in sorted(wrong.items()))
76
+ )
77
+
78
+ fd, path = tempfile.mkstemp(prefix=os.path.basename(args.target).removesuffix(".ts") + ".", suffix=".configured.ts")
79
+ with os.fdopen(fd, "w", encoding="utf-8") as fh:
80
+ fh.write("\n".join(out) + "\n")
81
+ print(path)
82
+
83
+
84
+ if __name__ == "__main__":
85
+ main()