yap2app 1.1.9 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/cli-esm.js CHANGED
@@ -1,5 +1,3 @@
1
- #!/usr/bin/env node
2
-
3
1
  import '../polyfills.js';
4
2
  import { startBridge } from '../bridge.js';
5
3
  import { runMcpServer } from '../mcp.js';
@@ -20,7 +18,7 @@ async function main() {
20
18
  console.log(` Path Alias: ${context.path_alias || '@/'}`);
21
19
  console.log(` Files: ${context.discovered_files?.length || 0}`);
22
20
  console.log(` Components: ${(context.component_names || []).join(', ') || 'None'}\n`);
23
- } else if (command === 'init' || command === 'install') {
21
+ } else if (command === 'init' || command === 'install' || command === 'insall') {
24
22
  const context = await scanCodebase(process.cwd());
25
23
  console.log(`\n⚡ Yap2App Workspace Initializer:`);
26
24
  console.log(` Directory: ${context.project_root}`);
package/bin/cli.bundle.js CHANGED
@@ -1,6 +1,3 @@
1
- #!/usr/bin/env node
2
- #!/usr/bin/env node
3
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
4
1
  var __create = Object.create;
5
2
  var __defProp = Object.defineProperty;
6
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -7581,7 +7578,7 @@ var fs2 = fsSync2.promises || {
7581
7578
  var PORT = Number(process.env.YAP2APP_PORT) || 10420;
7582
7579
  var PROJECT_ROOT = process.cwd();
7583
7580
  var PAIR_CODE = (process.env.YAP2APP_PAIR_CODE || "Y2A-" + Math.floor(1e3 + Math.random() * 9e3)).toUpperCase();
7584
- var CLI_VERSION = "1.1.9";
7581
+ var CLI_VERSION = "1.2.0";
7585
7582
  function safeResolvePath(baseDir, relativePath) {
7586
7583
  const cleanRel = (relativePath || "").replace(/^[\\\/]+/, "");
7587
7584
  const resolved = path2.resolve(baseDir, cleanRel);
@@ -7756,35 +7753,95 @@ var server = http.createServer(async (req, res) => {
7756
7753
  res.writeHead(404, headers);
7757
7754
  res.end(JSON.stringify({ error: "Endpoint Not Found", path: pathname }));
7758
7755
  });
7756
+ var CLOUD_URL = process.env.YAP2APP_CLOUD_URL || "https://yap2app-dot-cybage-hackathon.uc.r.appspot.com";
7757
+ async function sendCloudHeartbeat() {
7758
+ try {
7759
+ const context = await scanCodebase(PROJECT_ROOT);
7760
+ const payload = {
7761
+ pair_code: PAIR_CODE,
7762
+ project_name: path2.basename(PROJECT_ROOT),
7763
+ project_root: PROJECT_ROOT,
7764
+ framework: context.framework || "plain_html_css_js",
7765
+ context,
7766
+ version: CLI_VERSION
7767
+ };
7768
+ const res = await fetch(`${CLOUD_URL}/api/v1/bridge/heartbeat`, {
7769
+ method: "POST",
7770
+ headers: { "Content-Type": "application/json" },
7771
+ body: JSON.stringify(payload)
7772
+ });
7773
+ if (res.ok) {
7774
+ const data = await res.json();
7775
+ if (data.pending_writes_count > 0) {
7776
+ await pollAndExecuteCloudWrites();
7777
+ }
7778
+ }
7779
+ } catch (err) {
7780
+ }
7781
+ }
7782
+ async function pollAndExecuteCloudWrites() {
7783
+ try {
7784
+ const res = await fetch(`${CLOUD_URL}/api/v1/bridge/poll-writes?pair_code=${encodeURIComponent(PAIR_CODE)}`);
7785
+ if (!res.ok) return;
7786
+ const data = await res.json();
7787
+ const tasks = data.pending_tasks || [];
7788
+ for (const task of tasks) {
7789
+ const written = [];
7790
+ for (const file of task.files || []) {
7791
+ const fullPath = safeResolvePath(PROJECT_ROOT, file.path);
7792
+ await fs2.mkdir(path2.dirname(fullPath), { recursive: true });
7793
+ await fs2.writeFile(fullPath, file.content, "utf8");
7794
+ console.log(` [bridge] Wrote ${file.path}`);
7795
+ written.push(file.path);
7796
+ }
7797
+ await fetch(`${CLOUD_URL}/api/v1/bridge/complete-write`, {
7798
+ method: "POST",
7799
+ headers: { "Content-Type": "application/json" },
7800
+ body: JSON.stringify({
7801
+ task_id: task.task_id,
7802
+ success: true,
7803
+ written,
7804
+ message: `Successfully wrote ${written.length} files to ${path2.basename(PROJECT_ROOT)}`
7805
+ })
7806
+ });
7807
+ }
7808
+ } catch (err) {
7809
+ console.error(" [bridge] Cloud write sync error:", err.message);
7810
+ }
7811
+ }
7759
7812
  server.on("error", (err) => {
7760
7813
  if (err && err.code === "EADDRINUSE") {
7761
7814
  console.log(`
7762
7815
  ---------------------------------------------------------------`);
7763
7816
  console.log(`Yap2App Local Bridge v${CLI_VERSION}`);
7817
+ console.log(`Pair Code: ${PAIR_CODE}`);
7764
7818
  console.log(`Local Endpoint: http://127.0.0.1:${PORT}`);
7765
7819
  console.log(`Active Workspace: ${PROJECT_ROOT}`);
7766
7820
  console.log(`Status: Already active & ready on port ${PORT}`);
7767
7821
  console.log(`---------------------------------------------------------------
7768
7822
  `);
7769
- console.log(`Bridge is running.`);
7823
+ console.log(`Bridge is running & synced.`);
7770
7824
  console.log(`Open Web Studio in your browser to sync components to this workspace.`);
7771
7825
  console.log(`Press Ctrl/Cmd+C to stop.
7772
7826
  `);
7827
+ sendCloudHeartbeat();
7828
+ setInterval(sendCloudHeartbeat, 3e3);
7773
7829
  return;
7774
7830
  }
7775
7831
  console.error(" [bridge] Error:", err.message || err);
7776
7832
  });
7777
7833
  async function startBridge(port = PORT) {
7778
- server.listen(port, "0.0.0.0", () => {
7834
+ server.listen(port, () => {
7779
7835
  console.log(`
7780
7836
  ---------------------------------------------------------------`);
7781
7837
  console.log(`Yap2App Local Bridge v${CLI_VERSION}`);
7838
+ console.log(`Pair Code: ${PAIR_CODE}`);
7782
7839
  console.log(`Local Endpoint: http://127.0.0.1:${port}`);
7783
7840
  console.log(`Active Workspace: ${PROJECT_ROOT}`);
7784
7841
  console.log(`Web Studio: https://yap2app-dot-cybage-hackathon.uc.r.appspot.com`);
7785
7842
  console.log(`---------------------------------------------------------------
7786
7843
  `);
7787
- console.log(`Bridge is running.`);
7844
+ console.log(`Bridge is running & synced.`);
7788
7845
  console.log(`Open Web Studio in your browser to automatically connect and sync.`);
7789
7846
  console.log(`Press Ctrl/Cmd+C to stop.
7790
7847
  `);
@@ -7798,6 +7855,8 @@ async function startBridge(port = PORT) {
7798
7855
  }
7799
7856
  } catch (e) {
7800
7857
  }
7858
+ sendCloudHeartbeat();
7859
+ setInterval(sendCloudHeartbeat, 3e3);
7801
7860
  }
7802
7861
  var isDirectRun = Boolean(typeof process !== "undefined" && process.argv && process.argv[1] && (process.argv[1].endsWith("bridge.js") || process.argv[1].endsWith("bridge")));
7803
7862
  if (isDirectRun) {
@@ -16503,7 +16562,7 @@ Yap2App Codebase Context:
16503
16562
  console.log(` Files: ${context.discovered_files?.length || 0}`);
16504
16563
  console.log(` Components: ${(context.component_names || []).join(", ") || "None"}
16505
16564
  `);
16506
- } else if (command === "init" || command === "install") {
16565
+ } else if (command === "init" || command === "install" || command === "insall") {
16507
16566
  const context = await scanCodebase(process.cwd());
16508
16567
  console.log(`
16509
16568
  \u26A1 Yap2App Workspace Initializer:`);
package/bin/cli.js CHANGED
@@ -1,6 +1,4 @@
1
1
  #!/usr/bin/env node
2
- #!/usr/bin/env node
3
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
4
2
  var __create = Object.create;
5
3
  var __defProp = Object.defineProperty;
6
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -7581,7 +7579,7 @@ var fs2 = fsSync2.promises || {
7581
7579
  var PORT = Number(process.env.YAP2APP_PORT) || 10420;
7582
7580
  var PROJECT_ROOT = process.cwd();
7583
7581
  var PAIR_CODE = (process.env.YAP2APP_PAIR_CODE || "Y2A-" + Math.floor(1e3 + Math.random() * 9e3)).toUpperCase();
7584
- var CLI_VERSION = "1.1.9";
7582
+ var CLI_VERSION = "1.2.0";
7585
7583
  function safeResolvePath(baseDir, relativePath) {
7586
7584
  const cleanRel = (relativePath || "").replace(/^[\\\/]+/, "");
7587
7585
  const resolved = path2.resolve(baseDir, cleanRel);
@@ -7756,35 +7754,95 @@ var server = http.createServer(async (req, res) => {
7756
7754
  res.writeHead(404, headers);
7757
7755
  res.end(JSON.stringify({ error: "Endpoint Not Found", path: pathname }));
7758
7756
  });
7757
+ var CLOUD_URL = process.env.YAP2APP_CLOUD_URL || "https://yap2app-dot-cybage-hackathon.uc.r.appspot.com";
7758
+ async function sendCloudHeartbeat() {
7759
+ try {
7760
+ const context = await scanCodebase(PROJECT_ROOT);
7761
+ const payload = {
7762
+ pair_code: PAIR_CODE,
7763
+ project_name: path2.basename(PROJECT_ROOT),
7764
+ project_root: PROJECT_ROOT,
7765
+ framework: context.framework || "plain_html_css_js",
7766
+ context,
7767
+ version: CLI_VERSION
7768
+ };
7769
+ const res = await fetch(`${CLOUD_URL}/api/v1/bridge/heartbeat`, {
7770
+ method: "POST",
7771
+ headers: { "Content-Type": "application/json" },
7772
+ body: JSON.stringify(payload)
7773
+ });
7774
+ if (res.ok) {
7775
+ const data = await res.json();
7776
+ if (data.pending_writes_count > 0) {
7777
+ await pollAndExecuteCloudWrites();
7778
+ }
7779
+ }
7780
+ } catch (err) {
7781
+ }
7782
+ }
7783
+ async function pollAndExecuteCloudWrites() {
7784
+ try {
7785
+ const res = await fetch(`${CLOUD_URL}/api/v1/bridge/poll-writes?pair_code=${encodeURIComponent(PAIR_CODE)}`);
7786
+ if (!res.ok) return;
7787
+ const data = await res.json();
7788
+ const tasks = data.pending_tasks || [];
7789
+ for (const task of tasks) {
7790
+ const written = [];
7791
+ for (const file of task.files || []) {
7792
+ const fullPath = safeResolvePath(PROJECT_ROOT, file.path);
7793
+ await fs2.mkdir(path2.dirname(fullPath), { recursive: true });
7794
+ await fs2.writeFile(fullPath, file.content, "utf8");
7795
+ console.log(` [bridge] Wrote ${file.path}`);
7796
+ written.push(file.path);
7797
+ }
7798
+ await fetch(`${CLOUD_URL}/api/v1/bridge/complete-write`, {
7799
+ method: "POST",
7800
+ headers: { "Content-Type": "application/json" },
7801
+ body: JSON.stringify({
7802
+ task_id: task.task_id,
7803
+ success: true,
7804
+ written,
7805
+ message: `Successfully wrote ${written.length} files to ${path2.basename(PROJECT_ROOT)}`
7806
+ })
7807
+ });
7808
+ }
7809
+ } catch (err) {
7810
+ console.error(" [bridge] Cloud write sync error:", err.message);
7811
+ }
7812
+ }
7759
7813
  server.on("error", (err) => {
7760
7814
  if (err && err.code === "EADDRINUSE") {
7761
7815
  console.log(`
7762
7816
  ---------------------------------------------------------------`);
7763
7817
  console.log(`Yap2App Local Bridge v${CLI_VERSION}`);
7818
+ console.log(`Pair Code: ${PAIR_CODE}`);
7764
7819
  console.log(`Local Endpoint: http://127.0.0.1:${PORT}`);
7765
7820
  console.log(`Active Workspace: ${PROJECT_ROOT}`);
7766
7821
  console.log(`Status: Already active & ready on port ${PORT}`);
7767
7822
  console.log(`---------------------------------------------------------------
7768
7823
  `);
7769
- console.log(`Bridge is running.`);
7824
+ console.log(`Bridge is running & synced.`);
7770
7825
  console.log(`Open Web Studio in your browser to sync components to this workspace.`);
7771
7826
  console.log(`Press Ctrl/Cmd+C to stop.
7772
7827
  `);
7828
+ sendCloudHeartbeat();
7829
+ setInterval(sendCloudHeartbeat, 3e3);
7773
7830
  return;
7774
7831
  }
7775
7832
  console.error(" [bridge] Error:", err.message || err);
7776
7833
  });
7777
7834
  async function startBridge(port = PORT) {
7778
- server.listen(port, "0.0.0.0", () => {
7835
+ server.listen(port, () => {
7779
7836
  console.log(`
7780
7837
  ---------------------------------------------------------------`);
7781
7838
  console.log(`Yap2App Local Bridge v${CLI_VERSION}`);
7839
+ console.log(`Pair Code: ${PAIR_CODE}`);
7782
7840
  console.log(`Local Endpoint: http://127.0.0.1:${port}`);
7783
7841
  console.log(`Active Workspace: ${PROJECT_ROOT}`);
7784
7842
  console.log(`Web Studio: https://yap2app-dot-cybage-hackathon.uc.r.appspot.com`);
7785
7843
  console.log(`---------------------------------------------------------------
7786
7844
  `);
7787
- console.log(`Bridge is running.`);
7845
+ console.log(`Bridge is running & synced.`);
7788
7846
  console.log(`Open Web Studio in your browser to automatically connect and sync.`);
7789
7847
  console.log(`Press Ctrl/Cmd+C to stop.
7790
7848
  `);
@@ -7798,6 +7856,8 @@ async function startBridge(port = PORT) {
7798
7856
  }
7799
7857
  } catch (e) {
7800
7858
  }
7859
+ sendCloudHeartbeat();
7860
+ setInterval(sendCloudHeartbeat, 3e3);
7801
7861
  }
7802
7862
  var isDirectRun = Boolean(typeof process !== "undefined" && process.argv && process.argv[1] && (process.argv[1].endsWith("bridge.js") || process.argv[1].endsWith("bridge")));
7803
7863
  if (isDirectRun) {
@@ -16503,7 +16563,7 @@ Yap2App Codebase Context:
16503
16563
  console.log(` Files: ${context.discovered_files?.length || 0}`);
16504
16564
  console.log(` Components: ${(context.component_names || []).join(", ") || "None"}
16505
16565
  `);
16506
- } else if (command === "init" || command === "install") {
16566
+ } else if (command === "init" || command === "install" || command === "insall") {
16507
16567
  const context = await scanCodebase(process.cwd());
16508
16568
  console.log(`
16509
16569
  \u26A1 Yap2App Workspace Initializer:`);
package/bridge.js CHANGED
@@ -15,7 +15,7 @@ const fs = fsSync.promises || {
15
15
  const PORT = Number(process.env.YAP2APP_PORT) || 10420;
16
16
  const PROJECT_ROOT = process.cwd();
17
17
  const PAIR_CODE = (process.env.YAP2APP_PAIR_CODE || ('Y2A-' + Math.floor(1000 + Math.random() * 9000))).toUpperCase();
18
- const CLI_VERSION = '1.1.9';
18
+ const CLI_VERSION = '1.2.0';
19
19
 
20
20
  /**
21
21
  * Validates and resolves relative file paths strictly inside PROJECT_ROOT.
@@ -237,32 +237,102 @@ const server = http.createServer(async (req, res) => {
237
237
  res.end(JSON.stringify({ error: 'Endpoint Not Found', path: pathname }));
238
238
  });
239
239
 
240
+ const CLOUD_URL = process.env.YAP2APP_CLOUD_URL || 'https://yap2app-dot-cybage-hackathon.uc.r.appspot.com';
241
+
242
+ async function sendCloudHeartbeat() {
243
+ try {
244
+ const context = await scanCodebase(PROJECT_ROOT);
245
+ const payload = {
246
+ pair_code: PAIR_CODE,
247
+ project_name: path.basename(PROJECT_ROOT),
248
+ project_root: PROJECT_ROOT,
249
+ framework: context.framework || 'plain_html_css_js',
250
+ context: context,
251
+ version: CLI_VERSION
252
+ };
253
+
254
+ const res = await fetch(`${CLOUD_URL}/api/v1/bridge/heartbeat`, {
255
+ method: 'POST',
256
+ headers: { 'Content-Type': 'application/json' },
257
+ body: JSON.stringify(payload)
258
+ });
259
+
260
+ if (res.ok) {
261
+ const data = await res.json();
262
+ if (data.pending_writes_count > 0) {
263
+ await pollAndExecuteCloudWrites();
264
+ }
265
+ }
266
+ } catch (err) {
267
+ // Quiet fallback if offline or unreachable
268
+ }
269
+ }
270
+
271
+ async function pollAndExecuteCloudWrites() {
272
+ try {
273
+ const res = await fetch(`${CLOUD_URL}/api/v1/bridge/poll-writes?pair_code=${encodeURIComponent(PAIR_CODE)}`);
274
+ if (!res.ok) return;
275
+ const data = await res.json();
276
+ const tasks = data.pending_tasks || [];
277
+
278
+ for (const task of tasks) {
279
+ const written = [];
280
+ for (const file of task.files || []) {
281
+ const fullPath = safeResolvePath(PROJECT_ROOT, file.path);
282
+ await fs.mkdir(path.dirname(fullPath), { recursive: true });
283
+ await fs.writeFile(fullPath, file.content, 'utf8');
284
+ console.log(` [bridge] Wrote ${file.path}`);
285
+ written.push(file.path);
286
+ }
287
+
288
+ await fetch(`${CLOUD_URL}/api/v1/bridge/complete-write`, {
289
+ method: 'POST',
290
+ headers: { 'Content-Type': 'application/json' },
291
+ body: JSON.stringify({
292
+ task_id: task.task_id,
293
+ success: true,
294
+ written,
295
+ message: `Successfully wrote ${written.length} files to ${path.basename(PROJECT_ROOT)}`
296
+ })
297
+ });
298
+ }
299
+ } catch (err) {
300
+ console.error(' [bridge] Cloud write sync error:', err.message);
301
+ }
302
+ }
303
+
240
304
  // Gracefully handle EADDRINUSE without crashing
241
305
  server.on('error', (err) => {
242
306
  if (err && err.code === 'EADDRINUSE') {
243
307
  console.log(`\n---------------------------------------------------------------`);
244
308
  console.log(`Yap2App Local Bridge v${CLI_VERSION}`);
309
+ console.log(`Pair Code: ${PAIR_CODE}`);
245
310
  console.log(`Local Endpoint: http://127.0.0.1:${PORT}`);
246
311
  console.log(`Active Workspace: ${PROJECT_ROOT}`);
247
312
  console.log(`Status: Already active & ready on port ${PORT}`);
248
313
  console.log(`---------------------------------------------------------------\n`);
249
- console.log(`Bridge is running.`);
314
+ console.log(`Bridge is running & synced.`);
250
315
  console.log(`Open Web Studio in your browser to sync components to this workspace.`);
251
316
  console.log(`Press Ctrl/Cmd+C to stop.\n`);
317
+
318
+ // Still maintain cloud heartbeat even if port was bound by another process
319
+ sendCloudHeartbeat();
320
+ setInterval(sendCloudHeartbeat, 3000);
252
321
  return;
253
322
  }
254
323
  console.error(' [bridge] Error:', err.message || err);
255
324
  });
256
325
 
257
326
  export async function startBridge(port = PORT) {
258
- server.listen(port, '0.0.0.0', () => {
327
+ server.listen(port, () => {
259
328
  console.log(`\n---------------------------------------------------------------`);
260
329
  console.log(`Yap2App Local Bridge v${CLI_VERSION}`);
330
+ console.log(`Pair Code: ${PAIR_CODE}`);
261
331
  console.log(`Local Endpoint: http://127.0.0.1:${port}`);
262
332
  console.log(`Active Workspace: ${PROJECT_ROOT}`);
263
333
  console.log(`Web Studio: https://yap2app-dot-cybage-hackathon.uc.r.appspot.com`);
264
334
  console.log(`---------------------------------------------------------------\n`);
265
- console.log(`Bridge is running.`);
335
+ console.log(`Bridge is running & synced.`);
266
336
  console.log(`Open Web Studio in your browser to automatically connect and sync.`);
267
337
  console.log(`Press Ctrl/Cmd+C to stop.\n`);
268
338
  });
@@ -275,6 +345,10 @@ export async function startBridge(port = PORT) {
275
345
  console.log(` Yap2App will automatically scaffold directories and write files when synced from Web Studio.\n`);
276
346
  }
277
347
  } catch (e) {}
348
+
349
+ // Start bidirectional cloud relay heartbeat
350
+ sendCloudHeartbeat();
351
+ setInterval(sendCloudHeartbeat, 3000);
278
352
  }
279
353
 
280
354
  // Direct execution
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yap2app",
3
- "version": "1.1.9",
3
+ "version": "1.2.1",
4
4
  "type": "module",
5
5
  "description": "Autonomous Vibe-to-Prod Localhost Bridge & Model Context Protocol (MCP) Server",
6
6
  "main": "bin/cli.bundle.js",