@boxes-dev/dvb 0.2.45 → 0.2.47
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/dist/bin/dvb.cjs +495 -345
- package/dist/bin/dvbd.cjs +228 -124
- package/dist/devbox/commands/init/codex/prompts.d.ts.map +1 -1
- package/dist/devbox/commands/init/codex/prompts.js +20 -5
- package/dist/devbox/commands/init/codex/prompts.js.map +1 -1
- package/dist/devbox/commands/init/index.d.ts.map +1 -1
- package/dist/devbox/commands/init/index.js +236 -171
- package/dist/devbox/commands/init/index.js.map +1 -1
- package/dist/devbox/commands/init/remote.d.ts.map +1 -1
- package/dist/devbox/commands/init/remote.js +1 -17
- package/dist/devbox/commands/init/remote.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/dvbd.cjs
CHANGED
|
@@ -351,7 +351,7 @@ var init_repo = __esm({
|
|
|
351
351
|
});
|
|
352
352
|
|
|
353
353
|
// ../core/src/sprites.ts
|
|
354
|
-
var import_node_crypto, import_node_util, import_ws, SpritesApiError, logger, USE_INTERNAL_SERVICE_API, INTERNAL_SERVICE_SIGNAL_TIMEOUT_SECONDS, toWebSocketErrorInfo, toWsUrl, shellQuote, requestJson, listSprites, requestNdjson, writeFile, normalizeServiceRecord, readFile, openExecSocket, attachExecSocket, openProxySocket, listExecSessions, listServices, internalServicesRequest, createCheckpointInternal, listServicesInternal, getServiceInternal, createServiceInternal, startServiceInternal, stopServiceInternal, execCommand, createSpritesClient;
|
|
354
|
+
var import_node_crypto, import_node_util, import_ws, SpritesApiError, logger, USE_INTERNAL_SERVICE_API, INTERNAL_SERVICE_SIGNAL_TIMEOUT_SECONDS, toWebSocketErrorInfo, toWsUrl, shellQuote, DEFAULT_SPRITES_HTTP_TIMEOUT_MS_IDEMPOTENT, DEFAULT_SPRITES_HTTP_TIMEOUT_MS_NON_IDEMPOTENT, DEFAULT_SPRITES_HTTP_MAX_ATTEMPTS, SPRITES_HTTP_RETRYABLE_STATUSES, delay, isIdempotentMethod, computeRetryDelayMs, isAbortError, getErrorCode, isRetryableFetchError, shouldRetrySpritesRequest, withSpritesRetry, requestJson, listSprites, requestNdjson, writeFile, normalizeServiceRecord, readFile, openExecSocket, attachExecSocket, openProxySocket, listExecSessions, listServices, internalServicesRequest, createCheckpointInternal, listServicesInternal, getServiceInternal, createServiceInternal, startServiceInternal, stopServiceInternal, execCommand, createSpritesClient;
|
|
355
355
|
var init_sprites = __esm({
|
|
356
356
|
"../core/src/sprites.ts"() {
|
|
357
357
|
"use strict";
|
|
@@ -419,39 +419,126 @@ var init_sprites = __esm({
|
|
|
419
419
|
return new URL(path6, `${protocol}//${base.host}`);
|
|
420
420
|
};
|
|
421
421
|
shellQuote = (value) => `'${value.replace(/'/g, `'\\''`)}'`;
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
422
|
+
DEFAULT_SPRITES_HTTP_TIMEOUT_MS_IDEMPOTENT = 5e3;
|
|
423
|
+
DEFAULT_SPRITES_HTTP_TIMEOUT_MS_NON_IDEMPOTENT = 2e4;
|
|
424
|
+
DEFAULT_SPRITES_HTTP_MAX_ATTEMPTS = 5;
|
|
425
|
+
SPRITES_HTTP_RETRYABLE_STATUSES = /* @__PURE__ */ new Set([408, 409, 425, 429, 500, 502, 503, 504]);
|
|
426
|
+
delay = async (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
427
|
+
isIdempotentMethod = (method) => {
|
|
428
|
+
const normalized = method.toUpperCase();
|
|
429
|
+
return normalized === "GET" || normalized === "HEAD" || normalized === "PUT" || normalized === "DELETE" || normalized === "OPTIONS";
|
|
430
|
+
};
|
|
431
|
+
computeRetryDelayMs = (attempt) => {
|
|
432
|
+
const base = 250;
|
|
433
|
+
const cap = 2500;
|
|
434
|
+
const exp = Math.min(cap, base * 2 ** Math.max(0, attempt - 1));
|
|
435
|
+
const jitter = Math.floor(Math.random() * 120);
|
|
436
|
+
return exp + jitter;
|
|
437
|
+
};
|
|
438
|
+
isAbortError = (error) => error instanceof Error && (error.name === "AbortError" || error.message.includes("aborted"));
|
|
439
|
+
getErrorCode = (error) => {
|
|
440
|
+
if (!error || typeof error !== "object") return void 0;
|
|
441
|
+
const record = error;
|
|
442
|
+
const code2 = record.code;
|
|
443
|
+
return typeof code2 === "string" || typeof code2 === "number" ? String(code2) : void 0;
|
|
444
|
+
};
|
|
445
|
+
isRetryableFetchError = (error) => {
|
|
446
|
+
if (isAbortError(error)) return true;
|
|
447
|
+
if (error instanceof TypeError) return true;
|
|
448
|
+
const code2 = getErrorCode(error);
|
|
449
|
+
return code2 === "ECONNRESET" || code2 === "ETIMEDOUT" || code2 === "EAI_AGAIN" || code2 === "ENOTFOUND" || code2 === "ECONNREFUSED";
|
|
450
|
+
};
|
|
451
|
+
shouldRetrySpritesRequest = (method, error) => {
|
|
452
|
+
if (!isIdempotentMethod(method)) return false;
|
|
453
|
+
if (error instanceof SpritesApiError) {
|
|
454
|
+
return SPRITES_HTTP_RETRYABLE_STATUSES.has(error.status);
|
|
431
455
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
456
|
+
return isRetryableFetchError(error);
|
|
457
|
+
};
|
|
458
|
+
withSpritesRetry = async (options) => {
|
|
459
|
+
const opId = (0, import_node_crypto.randomUUID)();
|
|
460
|
+
const timeoutMs = options.timeoutMs ?? (isIdempotentMethod(options.method) ? DEFAULT_SPRITES_HTTP_TIMEOUT_MS_IDEMPOTENT : DEFAULT_SPRITES_HTTP_TIMEOUT_MS_NON_IDEMPOTENT);
|
|
461
|
+
const maxAttemptsRaw = options.maxAttempts ?? DEFAULT_SPRITES_HTTP_MAX_ATTEMPTS;
|
|
462
|
+
const maxAttempts = isIdempotentMethod(options.method) ? Math.max(1, maxAttemptsRaw) : 1;
|
|
463
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
464
|
+
const requestId = (0, import_node_crypto.randomUUID)();
|
|
465
|
+
const controller = new AbortController();
|
|
466
|
+
const timeoutHandle = typeof timeoutMs === "number" && timeoutMs > 0 ? setTimeout(() => controller.abort(), timeoutMs) : null;
|
|
467
|
+
try {
|
|
468
|
+
logger.info("sprites_request", {
|
|
469
|
+
opId,
|
|
470
|
+
attempt,
|
|
471
|
+
requestId,
|
|
472
|
+
method: options.method,
|
|
473
|
+
path: options.path,
|
|
474
|
+
timeoutMs
|
|
475
|
+
});
|
|
476
|
+
return await options.run(controller.signal, requestId);
|
|
477
|
+
} catch (error) {
|
|
478
|
+
const retryable = shouldRetrySpritesRequest(options.method, error);
|
|
479
|
+
const remaining = maxAttempts - attempt;
|
|
480
|
+
if (!retryable || remaining <= 0) {
|
|
481
|
+
throw error;
|
|
482
|
+
}
|
|
483
|
+
const delayMs = computeRetryDelayMs(attempt);
|
|
484
|
+
logger.warn("sprites_http_retry", {
|
|
485
|
+
opId,
|
|
486
|
+
attempt,
|
|
487
|
+
requestId,
|
|
488
|
+
method: options.method,
|
|
489
|
+
path: options.path,
|
|
490
|
+
timeoutMs,
|
|
491
|
+
delayMs,
|
|
492
|
+
remainingAttempts: remaining,
|
|
493
|
+
errorName: error instanceof Error ? error.name : void 0,
|
|
494
|
+
errorMessage: error instanceof Error ? error.message : String(error),
|
|
495
|
+
errorCode: getErrorCode(error),
|
|
496
|
+
...error instanceof SpritesApiError ? { status: error.status } : {}
|
|
497
|
+
});
|
|
498
|
+
await delay(delayMs);
|
|
499
|
+
} finally {
|
|
500
|
+
if (timeoutHandle) clearTimeout(timeoutHandle);
|
|
501
|
+
}
|
|
435
502
|
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
requestId,
|
|
503
|
+
throw new Error(`Sprites request failed: ${options.method} ${options.path}`);
|
|
504
|
+
};
|
|
505
|
+
requestJson = async (apiBaseUrl, token, method, path6, body) => {
|
|
506
|
+
return await withSpritesRetry({
|
|
441
507
|
method,
|
|
442
508
|
path: path6,
|
|
443
|
-
|
|
509
|
+
run: async (signal, requestId) => {
|
|
510
|
+
const url = new URL(path6, apiBaseUrl);
|
|
511
|
+
const headers = {
|
|
512
|
+
authorization: `Bearer ${token}`,
|
|
513
|
+
"x-request-id": requestId
|
|
514
|
+
};
|
|
515
|
+
if (body) {
|
|
516
|
+
headers["content-type"] = "application/json";
|
|
517
|
+
}
|
|
518
|
+
const init = { method, headers, signal };
|
|
519
|
+
if (body) {
|
|
520
|
+
init.body = JSON.stringify(body);
|
|
521
|
+
}
|
|
522
|
+
const response = await fetch(url, init);
|
|
523
|
+
const text = await response.text();
|
|
524
|
+
logger.info("sprites_response", {
|
|
525
|
+
requestId,
|
|
526
|
+
method,
|
|
527
|
+
path: path6,
|
|
528
|
+
status: response.status
|
|
529
|
+
});
|
|
530
|
+
if (!response.ok) {
|
|
531
|
+
const snippet = text.trim().slice(0, 200);
|
|
532
|
+
throw new SpritesApiError(response.status, method, path6, snippet);
|
|
533
|
+
}
|
|
534
|
+
if (!text) return null;
|
|
535
|
+
try {
|
|
536
|
+
return JSON.parse(text);
|
|
537
|
+
} catch {
|
|
538
|
+
return text;
|
|
539
|
+
}
|
|
540
|
+
}
|
|
444
541
|
});
|
|
445
|
-
if (!response.ok) {
|
|
446
|
-
const snippet = text.trim().slice(0, 200);
|
|
447
|
-
throw new SpritesApiError(response.status, method, path6, snippet);
|
|
448
|
-
}
|
|
449
|
-
if (!text) return null;
|
|
450
|
-
try {
|
|
451
|
-
return JSON.parse(text);
|
|
452
|
-
} catch {
|
|
453
|
-
return text;
|
|
454
|
-
}
|
|
455
542
|
};
|
|
456
543
|
listSprites = async (apiBaseUrl, token, options) => {
|
|
457
544
|
const params = new URLSearchParams();
|
|
@@ -492,88 +579,99 @@ var init_sprites = __esm({
|
|
|
492
579
|
return response;
|
|
493
580
|
};
|
|
494
581
|
requestNdjson = async (apiBaseUrl, token, method, path6, body) => {
|
|
495
|
-
|
|
496
|
-
const url = new URL(path6, apiBaseUrl);
|
|
497
|
-
const headers = {
|
|
498
|
-
authorization: `Bearer ${token}`,
|
|
499
|
-
"x-request-id": requestId
|
|
500
|
-
};
|
|
501
|
-
if (body) {
|
|
502
|
-
headers["content-type"] = "application/json";
|
|
503
|
-
}
|
|
504
|
-
const init = { method, headers };
|
|
505
|
-
if (body) {
|
|
506
|
-
init.body = JSON.stringify(body);
|
|
507
|
-
}
|
|
508
|
-
logger.info("sprites_request", { requestId, method, path: path6 });
|
|
509
|
-
const response = await fetch(url, init);
|
|
510
|
-
logger.info("sprites_response", {
|
|
511
|
-
requestId,
|
|
582
|
+
return await withSpritesRetry({
|
|
512
583
|
method,
|
|
513
584
|
path: path6,
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
585
|
+
run: async (signal, requestId) => {
|
|
586
|
+
const url = new URL(path6, apiBaseUrl);
|
|
587
|
+
const headers = {
|
|
588
|
+
authorization: `Bearer ${token}`,
|
|
589
|
+
"x-request-id": requestId
|
|
590
|
+
};
|
|
591
|
+
if (body) {
|
|
592
|
+
headers["content-type"] = "application/json";
|
|
593
|
+
}
|
|
594
|
+
const init = { method, headers, signal };
|
|
595
|
+
if (body) {
|
|
596
|
+
init.body = JSON.stringify(body);
|
|
597
|
+
}
|
|
598
|
+
const response = await fetch(url, init);
|
|
599
|
+
logger.info("sprites_response", {
|
|
600
|
+
requestId,
|
|
601
|
+
method,
|
|
602
|
+
path: path6,
|
|
603
|
+
status: response.status
|
|
604
|
+
});
|
|
605
|
+
const text = await response.text();
|
|
606
|
+
if (!response.ok) {
|
|
607
|
+
const snippet = text.trim().slice(0, 200);
|
|
608
|
+
throw new SpritesApiError(response.status, method, path6, snippet);
|
|
609
|
+
}
|
|
610
|
+
const lines = text.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0);
|
|
611
|
+
const events = [];
|
|
612
|
+
for (const line of lines) {
|
|
613
|
+
try {
|
|
614
|
+
const parsed = JSON.parse(line);
|
|
615
|
+
if (Array.isArray(parsed)) {
|
|
616
|
+
for (const entry of parsed) {
|
|
617
|
+
if (entry && typeof entry === "object") {
|
|
618
|
+
events.push(entry);
|
|
619
|
+
} else {
|
|
620
|
+
events.push({ value: entry });
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
continue;
|
|
532
624
|
}
|
|
625
|
+
if (parsed && typeof parsed === "object") {
|
|
626
|
+
events.push(parsed);
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
events.push({ value: parsed });
|
|
630
|
+
} catch {
|
|
631
|
+
events.push({ raw: line });
|
|
533
632
|
}
|
|
534
|
-
continue;
|
|
535
|
-
}
|
|
536
|
-
if (parsed && typeof parsed === "object") {
|
|
537
|
-
events.push(parsed);
|
|
538
|
-
continue;
|
|
539
633
|
}
|
|
540
|
-
events
|
|
541
|
-
} catch {
|
|
542
|
-
events.push({ raw: line });
|
|
634
|
+
return events;
|
|
543
635
|
}
|
|
544
|
-
}
|
|
545
|
-
return events;
|
|
636
|
+
});
|
|
546
637
|
};
|
|
547
638
|
writeFile = async (apiBaseUrl, token, name, remotePath, data) => {
|
|
548
|
-
const requestId = (0, import_node_crypto.randomUUID)();
|
|
549
639
|
const path6 = `/v1/sprites/${name}/fs/write`;
|
|
550
640
|
const url = new URL(path6, apiBaseUrl);
|
|
551
641
|
url.searchParams.set("path", remotePath);
|
|
552
642
|
url.searchParams.set("mkdir", "true");
|
|
553
|
-
|
|
554
|
-
requestId,
|
|
555
|
-
path: path6,
|
|
556
|
-
name,
|
|
557
|
-
remotePath,
|
|
558
|
-
size: data.length
|
|
559
|
-
});
|
|
560
|
-
const response = await fetch(url, {
|
|
643
|
+
await withSpritesRetry({
|
|
561
644
|
method: "PUT",
|
|
562
|
-
headers: {
|
|
563
|
-
authorization: `Bearer ${token}`,
|
|
564
|
-
"content-type": "application/octet-stream",
|
|
565
|
-
"x-request-id": requestId
|
|
566
|
-
},
|
|
567
|
-
body: data
|
|
568
|
-
});
|
|
569
|
-
logger.info("sprites_fs_write_response", {
|
|
570
|
-
requestId,
|
|
571
645
|
path: path6,
|
|
572
|
-
|
|
646
|
+
run: async (signal, requestId) => {
|
|
647
|
+
logger.info("sprites_fs_write", {
|
|
648
|
+
requestId,
|
|
649
|
+
path: path6,
|
|
650
|
+
name,
|
|
651
|
+
remotePath,
|
|
652
|
+
size: data.length
|
|
653
|
+
});
|
|
654
|
+
const response = await fetch(url, {
|
|
655
|
+
method: "PUT",
|
|
656
|
+
headers: {
|
|
657
|
+
authorization: `Bearer ${token}`,
|
|
658
|
+
"content-type": "application/octet-stream",
|
|
659
|
+
"x-request-id": requestId
|
|
660
|
+
},
|
|
661
|
+
body: data,
|
|
662
|
+
signal
|
|
663
|
+
});
|
|
664
|
+
logger.info("sprites_fs_write_response", {
|
|
665
|
+
requestId,
|
|
666
|
+
path: path6,
|
|
667
|
+
status: response.status
|
|
668
|
+
});
|
|
669
|
+
if (!response.ok) {
|
|
670
|
+
const snippet = (await response.text()).trim().slice(0, 200);
|
|
671
|
+
throw new SpritesApiError(response.status, "PUT", path6, snippet);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
573
674
|
});
|
|
574
|
-
if (!response.ok) {
|
|
575
|
-
throw new Error(`Sprites FS write failed: ${response.status}`);
|
|
576
|
-
}
|
|
577
675
|
};
|
|
578
676
|
normalizeServiceRecord = (entry) => {
|
|
579
677
|
const rawName = entry.name;
|
|
@@ -604,38 +702,44 @@ var init_sprites = __esm({
|
|
|
604
702
|
return service;
|
|
605
703
|
};
|
|
606
704
|
readFile = async (apiBaseUrl, token, name, options) => {
|
|
607
|
-
const requestId = (0, import_node_crypto.randomUUID)();
|
|
608
705
|
const path6 = `/v1/sprites/${name}/fs/read`;
|
|
609
706
|
const url = new URL(path6, apiBaseUrl);
|
|
610
707
|
url.searchParams.set("path", options.path);
|
|
611
708
|
if (options.workingDir) {
|
|
612
709
|
url.searchParams.set("workingDir", options.workingDir);
|
|
613
710
|
}
|
|
614
|
-
|
|
615
|
-
requestId,
|
|
616
|
-
path: path6,
|
|
617
|
-
name,
|
|
618
|
-
remotePath: options.path,
|
|
619
|
-
workingDir: options.workingDir
|
|
620
|
-
});
|
|
621
|
-
const response = await fetch(url, {
|
|
711
|
+
return await withSpritesRetry({
|
|
622
712
|
method: "GET",
|
|
623
|
-
headers: {
|
|
624
|
-
authorization: `Bearer ${token}`,
|
|
625
|
-
"x-request-id": requestId
|
|
626
|
-
}
|
|
627
|
-
});
|
|
628
|
-
logger.info("sprites_fs_read_response", {
|
|
629
|
-
requestId,
|
|
630
713
|
path: path6,
|
|
631
|
-
|
|
714
|
+
run: async (signal, requestId) => {
|
|
715
|
+
logger.info("sprites_fs_read", {
|
|
716
|
+
requestId,
|
|
717
|
+
path: path6,
|
|
718
|
+
name,
|
|
719
|
+
remotePath: options.path,
|
|
720
|
+
workingDir: options.workingDir
|
|
721
|
+
});
|
|
722
|
+
const response = await fetch(url, {
|
|
723
|
+
method: "GET",
|
|
724
|
+
headers: {
|
|
725
|
+
authorization: `Bearer ${token}`,
|
|
726
|
+
"x-request-id": requestId
|
|
727
|
+
},
|
|
728
|
+
signal
|
|
729
|
+
});
|
|
730
|
+
logger.info("sprites_fs_read_response", {
|
|
731
|
+
requestId,
|
|
732
|
+
path: path6,
|
|
733
|
+
status: response.status
|
|
734
|
+
});
|
|
735
|
+
if (!response.ok) {
|
|
736
|
+
const snippet = (await response.text()).trim().slice(0, 200);
|
|
737
|
+
throw new SpritesApiError(response.status, "GET", path6, snippet);
|
|
738
|
+
}
|
|
739
|
+
const buffer = await response.arrayBuffer();
|
|
740
|
+
return new Uint8Array(buffer);
|
|
741
|
+
}
|
|
632
742
|
});
|
|
633
|
-
if (!response.ok) {
|
|
634
|
-
const snippet = (await response.text()).trim().slice(0, 200);
|
|
635
|
-
throw new SpritesApiError(response.status, "GET", path6, snippet);
|
|
636
|
-
}
|
|
637
|
-
const buffer = await response.arrayBuffer();
|
|
638
|
-
return new Uint8Array(buffer);
|
|
639
743
|
};
|
|
640
744
|
openExecSocket = (apiBaseUrl, token, name, options) => {
|
|
641
745
|
const url = toWsUrl(apiBaseUrl, `/v1/sprites/${name}/exec`);
|
|
@@ -4556,27 +4660,27 @@ var init_authentication_manager = __esm({
|
|
|
4556
4660
|
);
|
|
4557
4661
|
return;
|
|
4558
4662
|
}
|
|
4559
|
-
let
|
|
4663
|
+
let delay2 = Math.min(
|
|
4560
4664
|
MAXIMUM_REFRESH_DELAY,
|
|
4561
4665
|
(tokenValiditySeconds - this.refreshTokenLeewaySeconds) * 1e3
|
|
4562
4666
|
);
|
|
4563
|
-
if (
|
|
4667
|
+
if (delay2 <= 0) {
|
|
4564
4668
|
this.logger.warn(
|
|
4565
4669
|
`Refetching auth token immediately, configured leeway ${this.refreshTokenLeewaySeconds}s is larger than the token's lifetime ${tokenValiditySeconds}s`
|
|
4566
4670
|
);
|
|
4567
|
-
|
|
4671
|
+
delay2 = 0;
|
|
4568
4672
|
}
|
|
4569
4673
|
const refetchTokenTimeoutId = setTimeout(() => {
|
|
4570
4674
|
this._logVerbose("running scheduled token refetch");
|
|
4571
4675
|
void this.refetchToken();
|
|
4572
|
-
},
|
|
4676
|
+
}, delay2);
|
|
4573
4677
|
this.setAuthState({
|
|
4574
4678
|
state: "waitingForScheduledRefetch",
|
|
4575
4679
|
refetchTokenTimeoutId,
|
|
4576
4680
|
config: this.authState.config
|
|
4577
4681
|
});
|
|
4578
4682
|
this._logVerbose(
|
|
4579
|
-
`scheduled preemptive auth token refetching in ${
|
|
4683
|
+
`scheduled preemptive auth token refetching in ${delay2}ms`
|
|
4580
4684
|
);
|
|
4581
4685
|
}
|
|
4582
4686
|
// Protects against simultaneous calls to `setConfig`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../../../src/devbox/commands/init/codex/prompts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../../../src/devbox/commands/init/codex/prompts.ts"],"names":[],"mappings":"AAyBA,QAAA,MAAM,kBAAkB,GAAU,MAAM,MAAM,oBAI7C,CAAC;AAOF,QAAA,MAAM,6BAA6B,uBACM,CAAC;AAC1C,QAAA,MAAM,2BAA2B,uBACK,CAAC;AACvC,QAAA,MAAM,iCAAiC,uBACM,CAAC;AAC9C,QAAA,MAAM,2BAA2B,uBACK,CAAC;AAEvC,QAAA,MAAM,qBAAqB,GACzB,WAAW,MAAM,EACjB,iBAAiB,MAAM,EACvB,mBAAmB,MAAM,EACzB,kBAAkB,MAAM,oBAOtB,CAAC;AAEL,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,EAC3B,iCAAiC,EACjC,qBAAqB,EACrB,2BAA2B,EAC3B,kBAAkB,GACnB,CAAC"}
|
|
@@ -1,16 +1,31 @@
|
|
|
1
|
-
import fs from "node:fs
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import fsPromises from "node:fs/promises";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { renderTemplate } from "./template.js";
|
|
4
5
|
const resolvePromptsDir = () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
// Prefer resolving relative to the real dvb entrypoint, since `process.argv[1]`
|
|
7
|
+
// may be a bin shim (e.g. ~/.nvm/.../bin/dvb) rather than `.../dist/bin/dvb.cjs`.
|
|
8
|
+
const argv1 = typeof process.argv[1] === "string" ? process.argv[1] : "";
|
|
9
|
+
if (argv1) {
|
|
10
|
+
try {
|
|
11
|
+
const real = fs.realpathSync(argv1);
|
|
12
|
+
return path.resolve(path.dirname(real), "..", "prompts");
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
// ignore and fall back
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
return path.resolve(path.dirname(argv1), "..", "prompts");
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
// ignore and fall back
|
|
22
|
+
}
|
|
8
23
|
}
|
|
9
24
|
return path.resolve(process.cwd(), "prompts");
|
|
10
25
|
};
|
|
11
26
|
const readPromptTemplate = async (name) => {
|
|
12
27
|
const promptPath = path.join(resolvePromptsDir(), name);
|
|
13
|
-
const raw = await
|
|
28
|
+
const raw = await fsPromises.readFile(promptPath, "utf8");
|
|
14
29
|
return raw;
|
|
15
30
|
};
|
|
16
31
|
const loadPrompt = async (name, vars = {}) => renderTemplate(await readPromptTemplate(name), vars).trim();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../../../src/devbox/commands/init/codex/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../../../src/devbox/commands/init/codex/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAC1C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAC7B,gFAAgF;IAChF,kFAAkF;IAClF,MAAM,KAAK,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACzE,IAAI,KAAK,EAAE,CAAC;QACV,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;YACpC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;QAC3D,CAAC;QAAC,MAAM,CAAC;YACP,uBAAuB;QACzB,CAAC;QACD,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,CAAC;QAC5D,CAAC;QAAC,MAAM,CAAC;YACP,uBAAuB;QACzB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC;AAChD,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IAChD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,IAAI,CAAC,CAAC;IACxD,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAC1D,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,KAAK,EACtB,IAAY,EACZ,OAA+B,EAAE,EACjC,EAAE,CAAC,cAAc,CAAC,MAAM,kBAAkB,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;AAEjE,MAAM,6BAA6B,GAAG,KAAK,IAAI,EAAE,CAC/C,UAAU,CAAC,2BAA2B,CAAC,CAAC;AAC1C,MAAM,2BAA2B,GAAG,KAAK,IAAI,EAAE,CAC7C,UAAU,CAAC,wBAAwB,CAAC,CAAC;AACvC,MAAM,iCAAiC,GAAG,KAAK,IAAI,EAAE,CACnD,UAAU,CAAC,+BAA+B,CAAC,CAAC;AAC9C,MAAM,2BAA2B,GAAG,KAAK,IAAI,EAAE,CAC7C,UAAU,CAAC,wBAAwB,CAAC,CAAC;AAEvC,MAAM,qBAAqB,GAAG,KAAK,EACjC,SAAiB,EACjB,eAAuB,EACvB,iBAAyB,EACzB,gBAAwB,EACxB,EAAE,CACF,UAAU,CAAC,iBAAiB,EAAE;IAC5B,UAAU,EAAE,SAAS;IACrB,gBAAgB,EAAE,eAAe;IACjC,kBAAkB,EAAE,iBAAiB;IACrC,iBAAiB,EAAE,gBAAgB;CACpC,CAAC,CAAC;AAEL,OAAO,EACL,6BAA6B,EAC7B,2BAA2B,EAC3B,iCAAiC,EACjC,qBAAqB,EACrB,2BAA2B,EAC3B,kBAAkB,GACnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/devbox/commands/init/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/devbox/commands/init/index.ts"],"names":[],"mappings":"AA0mBA,eAAO,MAAM,OAAO,GAAU,MAAM,MAAM,EAAE,kBA89E3C,CAAC"}
|