@adep/cli 0.0.6 → 0.0.8

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 (3) hide show
  1. package/README.md +24 -51
  2. package/dist/index.js +264 -828
  3. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -232,316 +232,6 @@ var init_auth = __esm({
232
232
  }
233
233
  });
234
234
 
235
- // packages/cli/src/widget/templates.ts
236
- function vue3Files(name) {
237
- return {
238
- ...TS_BASE(),
239
- "manifest.json": MANIFEST(name, "vue3"),
240
- "package.json": `{
241
- "name": "${name}",
242
- "version": "0.1.0",
243
- "private": true,
244
- "type": "module",
245
- "scripts": {
246
- "typecheck": "tsc --noEmit",
247
- "dev": "adep widget dev",
248
- "widget:publish": "adep widget publish -p"
249
- },
250
- "dependencies": {
251
- "vue": "^3.5.0",
252
- "@adep/types": "workspace:*"
253
- },
254
- "devDependencies": {
255
- "typescript": "^5.5.0"
256
- }
257
- }
258
- `,
259
- "src/theme.css": THEME_CSS,
260
- "src/App.ts": `import { defineComponent, h } from 'vue'
261
-
262
- /** \u7EC4\u4EF6 props \u4E0E manifest.json \u7684 props schema \u5BF9\u9F50\uFF08contracts/ \u6821\u9A8C\u5B57\u6BB5\u5B50\u96C6\uFF09\u3002 */
263
- export const App = defineComponent({
264
- name: 'HelloVue',
265
- props: {
266
- title: { type: String, default: 'Hello' },
267
- },
268
- setup(props) {
269
- return () =>
270
- h('div', { style: { padding: 'var(--adep-space-4)' } }, [
271
- h('h2', { style: { color: 'var(--adep-color-accent)' } }, props.title),
272
- h(
273
- 'p',
274
- { style: { color: 'var(--adep-color-text-secondary)' } },
275
- 'Vue 3 \u6E32\u67D3\u51FD\u6570\u7EC4\u4EF6\u3002\u4E3B\u9898\u53D8\u91CF\u4E0E\u9274\u6743 token \u7531\u5BBF\u4E3B\u6CE8\u5165\u3002'
276
- ),
277
- ])
278
- },
279
- })
280
- `,
281
- "src/index.ts": `// Widget \u8FD0\u884C\u65F6\u5165\u53E3\uFF08FE-002\uFF09\u3002\u5BFC\u51FA HarnessWidgetRuntime \u4E09\u4EF6\u5957\uFF1A
282
- // __harness / mount(host, ctx) / unmount(host)\u3002
283
- // \u7EC4\u4EF6\u4EE5\u6E32\u67D3\u51FD\u6570\u7F16\u5199\uFF08\u975E SFC\uFF09\uFF0Cesbuild \u514D\u63D2\u4EF6\u76F4\u7F16\uFF08M3 MVP\uFF1B.vue SFC \u8D70 Vite \u5C5E\u4E8C\u671F\uFF09\u3002
284
- import { createApp, type App as VueApp } from 'vue'
285
- import type { HarnessMountHost, HarnessWidgetContext } from '@adep/types'
286
- import { App } from './App'
287
-
288
- // \u5BBF\u4E3B \u2192 \u6302\u8F7D\u7684 app \u5F15\u7528\uFF0Cunmount \u65F6\u7528\u5B8C\u91CA\u653E\uFF08WeakMap \u4E0D\u963B\u6B62\u5BBF\u4E3B\u56DE\u6536\uFF09\u3002
289
- const mounted = new WeakMap<object, { app: VueApp; root: HTMLElement }>()
290
-
291
- export const __harness = true as const
292
-
293
- export function mount(host: HarnessMountHost, ctx: HarnessWidgetContext): void {
294
- const root = document.createElement('div')
295
- host.appendChild(root)
296
- const app = createApp(App, ctx.props as never)
297
- app.mount(root)
298
- mounted.set(host, { app, root })
299
- }
300
-
301
- export function unmount(host: HarnessMountHost): void {
302
- const entry = mounted.get(host)
303
- if (entry === undefined) return
304
- entry.app.unmount()
305
- host.removeChild(entry.root)
306
- mounted.delete(host)
307
- }
308
- `,
309
- "src/mock-props.json": MOCK_PROPS
310
- };
311
- }
312
- function reactFiles(name) {
313
- return {
314
- ...TS_BASE(),
315
- "manifest.json": MANIFEST(name, "react"),
316
- "package.json": `{
317
- "name": "${name}",
318
- "version": "0.1.0",
319
- "private": true,
320
- "type": "module",
321
- "scripts": {
322
- "typecheck": "tsc --noEmit",
323
- "dev": "adep widget dev",
324
- "widget:publish": "adep widget publish -p"
325
- },
326
- "dependencies": {
327
- "react": "^18.3.0",
328
- "react-dom": "^18.3.0",
329
- "@adep/types": "workspace:*"
330
- },
331
- "devDependencies": {
332
- "@types/react": "^18.3.0",
333
- "@types/react-dom": "^18.3.0",
334
- "typescript": "^5.5.0"
335
- }
336
- }
337
- `,
338
- "src/theme.css": THEME_CSS,
339
- "src/App.tsx": `import type { CSSProperties } from 'react'
340
-
341
- /** \u7EC4\u4EF6 props \u4E0E manifest.json \u7684 props schema \u5BF9\u9F50\uFF08contracts/ \u6821\u9A8C\u5B57\u6BB5\u5B50\u96C6\uFF09\u3002 */
342
- export interface WidgetProps {
343
- title: string
344
- }
345
-
346
- const styleRoot: CSSProperties = { padding: 'var(--adep-space-4)' }
347
- const styleTitle: CSSProperties = { color: 'var(--adep-color-accent)', margin: 0 }
348
- const styleDesc: CSSProperties = { color: 'var(--adep-color-text-secondary)' }
349
-
350
- export default function App(props: WidgetProps): React.JSX.Element {
351
- return (
352
- <div style={styleRoot}>
353
- <h2 style={styleTitle}>{props.title}</h2>
354
- <p style={styleDesc}>React 18 \u7EC4\u4EF6\u3002\u4E3B\u9898\u53D8\u91CF\u4E0E\u9274\u6743 token \u7531\u5BBF\u4E3B\u6CE8\u5165\u3002</p>
355
- </div>
356
- )
357
- }
358
- `,
359
- "src/index.tsx": `// Widget \u8FD0\u884C\u65F6\u5165\u53E3\uFF08FE-002\uFF09\u3002\u5BFC\u51FA HarnessWidgetRuntime \u4E09\u4EF6\u5957\uFF1A
360
- // __harness / mount(host, ctx) / unmount(host)\u3002
361
- import { createRoot, type Root } from 'react-dom/client'
362
- import type { HarnessMountHost, HarnessWidgetContext } from '@adep/types'
363
- import App from './App'
364
-
365
- const mounted = new WeakMap<object, { root: Root; host: HTMLElement }>()
366
-
367
- export const __harness = true as const
368
-
369
- export function mount(host: HarnessMountHost, ctx: HarnessWidgetContext): void {
370
- const container = document.createElement('div')
371
- host.appendChild(container)
372
- const root = createRoot(container)
373
- root.render(<App {...(ctx.props as never)} />)
374
- mounted.set(host, { root, host: container })
375
- }
376
-
377
- export function unmount(host: HarnessMountHost): void {
378
- const entry = mounted.get(host)
379
- if (entry === undefined) return
380
- entry.root.unmount()
381
- host.removeChild(entry.host)
382
- mounted.delete(host)
383
- }
384
- `,
385
- "src/mock-props.json": MOCK_PROPS
386
- };
387
- }
388
- function widgetTemplateFiles(name, template) {
389
- return template === "react-ts" ? reactFiles(name) : vue3Files(name);
390
- }
391
- var WIDGET_TEMPLATES, TS_BASE, MANIFEST, THEME_CSS, MOCK_PROPS;
392
- var init_templates = __esm({
393
- "packages/cli/src/widget/templates.ts"() {
394
- "use strict";
395
- WIDGET_TEMPLATES = ["vue3-ts", "react-ts"];
396
- TS_BASE = () => ({
397
- "tsconfig.json": `{
398
- "compilerOptions": {
399
- "target": "ES2020",
400
- "module": "ESNext",
401
- "moduleResolution": "Bundler",
402
- "strict": true,
403
- "jsx": "react-jsx",
404
- "skipLibCheck": true,
405
- "noEmit": true
406
- },
407
- "include": ["src"]
408
- }
409
- `,
410
- "README.md": `# <widget>
411
-
412
- AgentDeploy \u5FAE\u524D\u7AEF\u7EC4\u4EF6\uFF08widget\uFF09\u3002
413
-
414
- - \`adep widget dev\`\uFF1A\u672C\u5730\u5BBF\u4E3B\u6C99\u7BB1\uFF08\u4E3B\u9898\u53D8\u91CF + mock props + token \u6CE8\u5165 + \u70ED\u66F4\u65B0\uFF09
415
- - \`adep widget publish -p <project-slug>\`\uFF1A\u6309\u6846\u67B6\u6784\u5EFA \u2192 \u4E0A\u4F20\u5E73\u53F0\u9759\u6001\u8D44\u6E90 \u2192 \u7248\u672C\u5316\u8F93\u51FA URL
416
-
417
- > \u7EC4\u4EF6\u5165\u53E3\u5BFC\u51FA \`__harness\` / \`mount(host, ctx)\` / \`unmount(host)\`\uFF0C\u5951\u7EA6\u89C1
418
- > \`@adep/types\` \u7684 HarnessWidgetRuntime\uFF1B\u5BBF\u4E3B\u7528 \`<RemoteWidget>\` \u6309\u9700\u62C9\u53D6\u3002
419
- `,
420
- ".gitignore": "node_modules/\n.adep/\ndist/\n"
421
- });
422
- MANIFEST = (name, framework) => `{
423
- "name": "${name}",
424
- "framework": "${framework}",
425
- "props": {
426
- "type": "object",
427
- "properties": {
428
- "title": { "type": "string" }
429
- },
430
- "required": ["title"]
431
- },
432
- "entry": "../dist/index.js"
433
- }
434
- `;
435
- THEME_CSS = `/* \u8BBE\u8BA1\u7CFB\u7EDF\u4E3B\u9898\u53D8\u91CF\uFF1A\u5BBF\u4E3B\u7ECF CSS Variables \u6CE8\u5165\uFF08FE-002 widget dev\uFF09\u3002
436
- \u672C\u5730\u6C99\u7BB1\u7F3A\u7701\u4EE5\u4E0B\u503C\uFF1B\u90E8\u7F72\u540E\u7531 Web IDE / \u5BBF\u4E3B\u4FA7\u6CE8\u5165\u540C\u540D\u5B57\u7684\u53D8\u91CF\u8986\u76D6\u3002 */
437
- :root {
438
- --adep-color-accent: #3370ff;
439
- --adep-color-text: #1f2329;
440
- --adep-color-text-secondary: #4c5561;
441
- --adep-space-4: 16px;
442
- }
443
- `;
444
- MOCK_PROPS = `{
445
- "title": "Hello from mock props"
446
- }
447
- `;
448
- }
449
- });
450
-
451
- // packages/cli/src/widget/build.ts
452
- import { createHash } from "node:crypto";
453
- import { join as join2, resolve as resolve2 } from "node:path";
454
- import { build as esbuildBuild } from "esbuild";
455
- async function buildWidget(options) {
456
- const root = resolve2(options.cwd);
457
- const entry = join2(root, options.entry ?? "src/index.ts");
458
- const result = await esbuildBuild({
459
- entryPoints: [entry],
460
- bundle: true,
461
- write: false,
462
- format: "esm",
463
- target: ["es2020"],
464
- logLevel: "error",
465
- loader: { ".ts": "ts", ".tsx": "tsx", ".js": "js", ".jsx": "jsx" },
466
- ...options.framework === "react" ? { jsx: "automatic", jsxImportSource: "react" } : {}
467
- });
468
- const text = result.outputFiles?.[0]?.text ?? "";
469
- if (text.length === 0) {
470
- throw new WidgetError("EMPTY_BUILD", "\u6784\u5EFA\u4EA7\u7269\u4E3A\u7A7A\uFF1A\u8BF7\u68C0\u67E5 widget \u5165\u53E3\u662F\u5426\u6B63\u786E");
471
- }
472
- const hash = createHash("sha256").update(text).digest("hex");
473
- return { text, hash };
474
- }
475
- var WidgetError;
476
- var init_build = __esm({
477
- "packages/cli/src/widget/build.ts"() {
478
- "use strict";
479
- WidgetError = class extends Error {
480
- constructor(code, message) {
481
- super(message);
482
- this.code = code;
483
- this.name = "WidgetError";
484
- }
485
- };
486
- }
487
- });
488
-
489
- // packages/cli/src/widget/init.ts
490
- var init_exports = {};
491
- __export(init_exports, {
492
- WIDGET_TEMPLATES: () => WIDGET_TEMPLATES,
493
- WidgetInitError: () => WidgetInitError,
494
- initWidget: () => initWidget
495
- });
496
- import { mkdir as mkdir3, stat as stat3, writeFile as writeFile2 } from "node:fs/promises";
497
- import { dirname as dirname3, join as join3, resolve as resolve3 } from "node:path";
498
- async function initWidget(cwd, name, template) {
499
- if (!WIDGET_NAME_RE.test(name)) {
500
- throw new WidgetInitError(
501
- "INVALID_NAME",
502
- `widget \u540D "${name}" \u4E0D\u5408\u6CD5\uFF1A\u9700\u4EE5\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\uFF0C\u4EC5\u542B\u5C0F\u5199\u5B57\u6BCD / \u6570\u5B57 / \u8FDE\u5B57\u7B26`
503
- );
504
- }
505
- if (!WIDGET_TEMPLATES.includes(template)) {
506
- throw new WidgetInitError("INVALID_TEMPLATE", `\u672A\u77E5\u6A21\u677F "${template}"\uFF1A\u53EF\u9009 vue3-ts | react-ts`);
507
- }
508
- const projectPath = resolve3(cwd, name);
509
- let existing;
510
- try {
511
- existing = await stat3(projectPath);
512
- } catch {
513
- existing = null;
514
- }
515
- if (existing !== null) {
516
- throw new WidgetInitError("DIR_EXISTS", `\u76EE\u5F55 ${projectPath} \u5DF2\u5B58\u5728\uFF1A\u8BF7\u6362\u4E00\u4E2A\u540D\u5B57\u6216\u5148\u5220\u9664`);
517
- }
518
- const files = widgetTemplateFiles(name, template);
519
- await mkdir3(projectPath, { recursive: true });
520
- await Promise.all(
521
- Object.entries(files).map(async ([rel, content]) => {
522
- const target = join3(projectPath, rel);
523
- await mkdir3(dirname3(target), { recursive: true });
524
- await writeFile2(target, content);
525
- })
526
- );
527
- return { projectPath, files: Object.keys(files).toSorted() };
528
- }
529
- var WidgetInitError, WIDGET_NAME_RE;
530
- var init_init = __esm({
531
- "packages/cli/src/widget/init.ts"() {
532
- "use strict";
533
- init_templates();
534
- WidgetInitError = class extends Error {
535
- constructor(code, message) {
536
- super(message);
537
- this.code = code;
538
- this.name = "WidgetInitError";
539
- }
540
- };
541
- WIDGET_NAME_RE = /^[a-z][a-z0-9-]{0,62}$/;
542
- }
543
- });
544
-
545
235
  // packages/cli/src/prompt.ts
546
236
  var prompt_exports = {};
547
237
  __export(prompt_exports, {
@@ -676,7 +366,7 @@ var init_domain = __esm({
676
366
  });
677
367
 
678
368
  // packages/runtime/src/functions/deps/manifest.ts
679
- import { createHash as createHash2 } from "node:crypto";
369
+ import { createHash } from "node:crypto";
680
370
  function isVersionRangeSpec(spec) {
681
371
  if (spec === "*" || spec === "latest") return true;
682
372
  const unions = spec.split("||");
@@ -752,7 +442,7 @@ function classifyDependencies(dependencies, builtin) {
752
442
  }
753
443
  function depsKeyOf(dependencies) {
754
444
  const canonical = Object.entries(dependencies).map(([name, version]) => `${name}@${version}`).toSorted().join("\n");
755
- return createHash2("sha256").update(canonical).digest("hex").slice(0, 16);
445
+ return createHash("sha256").update(canonical).digest("hex").slice(0, 16);
756
446
  }
757
447
  var PACKAGE_NAME_PATTERN, COMPARATOR_PATTERN, MANIFEST_MAX_DEPS;
758
448
  var init_manifest = __esm({
@@ -766,14 +456,14 @@ var init_manifest = __esm({
766
456
  });
767
457
 
768
458
  // packages/runtime/src/functions/deps/resolve.ts
769
- import { resolve as resolve4 } from "node:path";
459
+ import { resolve as resolve2 } from "node:path";
770
460
  function resolveExecutionDeps(config, projectId, manifestContent) {
771
461
  const manifest = tryParseManifestDependencies(manifestContent);
772
462
  const { customDeps } = classifyDependencies(manifest, config.builtin);
773
463
  const custom = Object.keys(customDeps);
774
464
  return {
775
465
  // 绝对化(相对进程 cwd,与 installer 侧 resolve(rootDir) 同基准):worker 的 createRequire 需要确定路径
776
- dir: custom.length === 0 ? null : resolve4(config.rootDir, projectId, depsKeyOf(customDeps)),
466
+ dir: custom.length === 0 ? null : resolve2(config.rootDir, projectId, depsKeyOf(customDeps)),
777
467
  builtin: [...config.builtin],
778
468
  custom
779
469
  };
@@ -788,22 +478,22 @@ var init_resolve = __esm({
788
478
  // packages/runtime/src/functions/runtime/worker-executor.ts
789
479
  import { readFileSync } from "node:fs";
790
480
  import { fileURLToPath, pathToFileURL } from "node:url";
791
- import { dirname as dirname4, join as join4 } from "node:path";
481
+ import { dirname as dirname3, join as join2 } from "node:path";
792
482
  import { Worker } from "node:worker_threads";
793
483
  function resolveWorkerEntry(baseDir = fileURLToPath(new URL(".", import.meta.url))) {
794
484
  const candidates = [
795
- join4(baseDir, "worker-entry.js"),
796
- join4(baseDir, "worker-entry.ts"),
797
- join4(baseDir, "domains/functions/runtime/worker-entry.js"),
798
- join4(baseDir, "domains/functions/runtime/worker-entry.ts")
485
+ join2(baseDir, "worker-entry.js"),
486
+ join2(baseDir, "worker-entry.ts"),
487
+ join2(baseDir, "domains/functions/runtime/worker-entry.js"),
488
+ join2(baseDir, "domains/functions/runtime/worker-entry.ts")
799
489
  ];
800
490
  let current = baseDir;
801
491
  for (let depth = 0; depth < 8; depth += 1) {
802
492
  candidates.push(
803
- join4(current, "packages/runtime/src/functions/runtime/worker-entry.js"),
804
- join4(current, "packages/runtime/src/functions/runtime/worker-entry.ts")
493
+ join2(current, "packages/runtime/src/functions/runtime/worker-entry.js"),
494
+ join2(current, "packages/runtime/src/functions/runtime/worker-entry.ts")
805
495
  );
806
- const parent = dirname4(current);
496
+ const parent = dirname3(current);
807
497
  if (parent === current) break;
808
498
  current = parent;
809
499
  }
@@ -845,7 +535,7 @@ var init_worker_executor = __esm({
845
535
  const entry = input.entry ?? "index.ts";
846
536
  const deps = this.depsConfig === void 0 ? void 0 : resolveExecutionDeps(this.depsConfig, input.project.id, input.files["package.json"]);
847
537
  const logs = [];
848
- return new Promise((resolve15, reject) => {
538
+ return new Promise((resolve11, reject) => {
849
539
  let worker;
850
540
  try {
851
541
  worker = new Worker(resolveWorkerEntry(), {
@@ -907,7 +597,7 @@ var init_worker_executor = __esm({
907
597
  if (message.type === "result") {
908
598
  clearTimeout(timer);
909
599
  void worker.terminate();
910
- resolve15({ body: message.body, logs });
600
+ resolve11({ body: message.body, logs });
911
601
  return;
912
602
  }
913
603
  if (message.type === "error") {
@@ -2483,13 +2173,13 @@ var init_cloud2 = __esm({
2483
2173
  });
2484
2174
 
2485
2175
  // packages/runtime/src/storage/driver/local.ts
2486
- import { mkdir as mkdir4, readFile as readFile2, readdir, rm as rm2, stat as stat4, unlink, writeFile as writeFile3 } from "node:fs/promises";
2487
- import { dirname as dirname5, join as join5 } from "node:path";
2176
+ import { mkdir as mkdir3, readFile as readFile2, readdir, rm as rm2, stat as stat3, unlink, writeFile as writeFile2 } from "node:fs/promises";
2177
+ import { dirname as dirname4, join as join3 } from "node:path";
2488
2178
  function createLocalStorageDriver(options) {
2489
2179
  const quotaBytes = options.quotaBytes ?? PROJECT_QUOTA_BYTES;
2490
- const bucketDir = (projectId) => join5(options.dir, projectId);
2491
- const objectPath = (projectId, path) => join5(bucketDir(projectId), path);
2492
- const metaPath = (projectId, path) => join5(dirname5(objectPath(projectId, path)), `${path.split("/").pop() ?? ""}${META_SUFFIX}`);
2180
+ const bucketDir = (projectId) => join3(options.dir, projectId);
2181
+ const objectPath = (projectId, path) => join3(bucketDir(projectId), path);
2182
+ const metaPath = (projectId, path) => join3(dirname4(objectPath(projectId, path)), `${path.split("/").pop() ?? ""}${META_SUFFIX}`);
2493
2183
  const readStoredMeta = async (projectId, path) => {
2494
2184
  const raw = await readFile2(metaPath(projectId, path), "utf8");
2495
2185
  return JSON.parse(raw);
@@ -2501,7 +2191,7 @@ function createLocalStorageDriver(options) {
2501
2191
  updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
2502
2192
  ...meta.contentType === void 0 ? {} : { contentType: meta.contentType }
2503
2193
  };
2504
- await writeFile3(metaPath(projectId, path), JSON.stringify(payload), "utf8");
2194
+ await writeFile2(metaPath(projectId, path), JSON.stringify(payload), "utf8");
2505
2195
  };
2506
2196
  const totalSize = async (projectId) => {
2507
2197
  const root = bucketDir(projectId);
@@ -2515,14 +2205,14 @@ function createLocalStorageDriver(options) {
2515
2205
  }
2516
2206
  const tasks = [];
2517
2207
  for (const entry of entries) {
2518
- const full = join5(dir, entry.name);
2208
+ const full = join3(dir, entry.name);
2519
2209
  if (entry.isDirectory()) {
2520
2210
  tasks.push(walk(full));
2521
2211
  } else if (entry.isFile() && !entry.name.endsWith(META_SUFFIX)) {
2522
2212
  tasks.push(
2523
2213
  (async () => {
2524
2214
  try {
2525
- const info = await stat4(full);
2215
+ const info = await stat3(full);
2526
2216
  total += info.size;
2527
2217
  } catch {
2528
2218
  }
@@ -2544,7 +2234,7 @@ function createLocalStorageDriver(options) {
2544
2234
  const used = await totalSize(projectId);
2545
2235
  let existingSize = 0;
2546
2236
  try {
2547
- existingSize = (await stat4(objectPath(projectId, path))).size;
2237
+ existingSize = (await stat3(objectPath(projectId, path))).size;
2548
2238
  } catch {
2549
2239
  existingSize = 0;
2550
2240
  }
@@ -2559,8 +2249,8 @@ function createLocalStorageDriver(options) {
2559
2249
  );
2560
2250
  }
2561
2251
  const dest = objectPath(projectId, path);
2562
- await mkdir4(dirname5(dest), { recursive: true });
2563
- await writeFile3(dest, data);
2252
+ await mkdir3(dirname4(dest), { recursive: true });
2253
+ await writeFile2(dest, data);
2564
2254
  await writeStoredMeta(projectId, path, {
2565
2255
  visibility: putOptions.visibility,
2566
2256
  size: data.byteLength,
@@ -2614,7 +2304,7 @@ function createLocalStorageDriver(options) {
2614
2304
  assertSafeStoragePath(path);
2615
2305
  let exists = true;
2616
2306
  try {
2617
- await stat4(objectPath(projectId, path));
2307
+ await stat3(objectPath(projectId, path));
2618
2308
  } catch {
2619
2309
  exists = false;
2620
2310
  }
@@ -2647,7 +2337,7 @@ function createLocalStorageDriver(options) {
2647
2337
  const tasks = [];
2648
2338
  for (const entry of entries) {
2649
2339
  if (entry.name.endsWith(META_SUFFIX)) continue;
2650
- const full = join5(dir, entry.name);
2340
+ const full = join3(dir, entry.name);
2651
2341
  const rel = relative3 === "" ? entry.name : `${relative3}/${entry.name}`;
2652
2342
  if (entry.isFile()) {
2653
2343
  if (prefix !== void 0 && !rel.startsWith(prefix)) continue;
@@ -2697,9 +2387,9 @@ var init_local = __esm({
2697
2387
  });
2698
2388
 
2699
2389
  // packages/cli/src/sim/storage.ts
2700
- import { join as join6 } from "node:path";
2390
+ import { join as join4 } from "node:path";
2701
2391
  function createSimStorageCapability(options) {
2702
- const dir = join6(options.cwd, ".adep", "sim", "storage");
2392
+ const dir = join4(options.cwd, ".adep", "sim", "storage");
2703
2393
  const driver = createLocalStorageDriver({ dir });
2704
2394
  const signer = {
2705
2395
  secret: options.secret ?? "adep-sim-secret",
@@ -2846,10 +2536,10 @@ var init_realtime = __esm({
2846
2536
  });
2847
2537
 
2848
2538
  // packages/cli/src/sim/runtime.ts
2849
- import { mkdir as mkdir5, readFile as readFile3, writeFile as writeFile4 } from "node:fs/promises";
2850
- import { dirname as dirname6, join as join7 } from "node:path";
2539
+ import { mkdir as mkdir4, readFile as readFile3, writeFile as writeFile3 } from "node:fs/promises";
2540
+ import { dirname as dirname5, join as join5 } from "node:path";
2851
2541
  function simDir(cwd) {
2852
- return join7(cwd, ".adep", "sim");
2542
+ return join5(cwd, ".adep", "sim");
2853
2543
  }
2854
2544
  function mergeBundles(bundles) {
2855
2545
  const capabilities = [];
@@ -2871,7 +2561,7 @@ function mergeBundles(bundles) {
2871
2561
  return { capabilities, rpcHandlers };
2872
2562
  }
2873
2563
  function jsonStorage(cwd) {
2874
- const file = join7(simDir(cwd), "db.json");
2564
+ const file = join5(simDir(cwd), "db.json");
2875
2565
  return {
2876
2566
  async load() {
2877
2567
  try {
@@ -2882,8 +2572,8 @@ function jsonStorage(cwd) {
2882
2572
  }
2883
2573
  },
2884
2574
  async save(tables) {
2885
- await mkdir5(dirname6(file), { recursive: true });
2886
- await writeFile4(file, JSON.stringify(tables), "utf8");
2575
+ await mkdir4(dirname5(file), { recursive: true });
2576
+ await writeFile3(file, JSON.stringify(tables), "utf8");
2887
2577
  }
2888
2578
  };
2889
2579
  }
@@ -2920,7 +2610,7 @@ var init_runtime = __esm({
2920
2610
 
2921
2611
  // packages/cli/src/sim/env.ts
2922
2612
  import { readFile as readFile4 } from "node:fs/promises";
2923
- import { join as join8 } from "node:path";
2613
+ import { join as join6 } from "node:path";
2924
2614
  function parseEnv(content) {
2925
2615
  const env = {};
2926
2616
  for (const raw of content.split(/\r?\n/)) {
@@ -2935,8 +2625,8 @@ function parseEnv(content) {
2935
2625
  return env;
2936
2626
  }
2937
2627
  async function loadSimEnv(cwd, config = {}) {
2938
- const envRoot = await readFile4(join8(cwd, ".env"), "utf8").catch(() => "");
2939
- const envLocal = await readFile4(join8(cwd, ".env.local"), "utf8").catch(() => "");
2628
+ const envRoot = await readFile4(join6(cwd, ".env"), "utf8").catch(() => "");
2629
+ const envLocal = await readFile4(join6(cwd, ".env.local"), "utf8").catch(() => "");
2940
2630
  const merged = { ...parseEnv(envRoot), ...parseEnv(envLocal) };
2941
2631
  for (const secret of config.secrets ?? []) {
2942
2632
  if (merged[secret] !== void 0) continue;
@@ -3058,13 +2748,13 @@ __export(dev_exports, {
3058
2748
  });
3059
2749
  import { createServer } from "node:http";
3060
2750
  import { watch } from "node:fs";
3061
- import { mkdir as mkdir6, readdir as readdir2, readFile as readFile5, stat as stat5, writeFile as writeFile5 } from "node:fs/promises";
3062
- import { basename, join as join9, resolve as resolve5 } from "node:path";
2751
+ import { mkdir as mkdir5, readdir as readdir2, readFile as readFile5, stat as stat4, writeFile as writeFile4 } from "node:fs/promises";
2752
+ import { basename, join as join7, resolve as resolve3 } from "node:path";
3063
2753
  async function loadConfig(cwd) {
3064
- const name = basename(resolve5(cwd));
3065
- const configPath = join9(cwd, "adep.config.ts");
2754
+ const name = basename(resolve3(cwd));
2755
+ const configPath = join7(cwd, "adep.config.ts");
3066
2756
  try {
3067
- await stat5(configPath);
2757
+ await stat4(configPath);
3068
2758
  } catch {
3069
2759
  return { name, functionsDir: "functions" };
3070
2760
  }
@@ -3104,7 +2794,7 @@ async function collectFunctions(dir) {
3104
2794
  }
3105
2795
  for (const entry of entries) {
3106
2796
  const rel = prefix.length === 0 ? entry.name : `${prefix}/${entry.name}`;
3107
- const full = join9(sub, entry.name);
2797
+ const full = join7(sub, entry.name);
3108
2798
  if (entry.isDirectory()) {
3109
2799
  await walk(full, rel);
3110
2800
  } else if (entry.isFile() && entry.name.endsWith(".ts")) {
@@ -3145,22 +2835,22 @@ function printBoundaries(log) {
3145
2835
  }
3146
2836
  }
3147
2837
  async function ensureGitignore(cwd) {
3148
- const gitignorePath = join9(cwd, ".gitignore");
2838
+ const gitignorePath = join7(cwd, ".gitignore");
3149
2839
  const existing = await readFile5(gitignorePath, "utf8").catch(() => "");
3150
2840
  if (existing.split(/\r?\n/).includes(".adep/")) return;
3151
- await writeFile5(gitignorePath, `${existing.replace(/\n+$/, "")}
2841
+ await writeFile4(gitignorePath, `${existing.replace(/\n+$/, "")}
3152
2842
  .adep/
3153
2843
  `, "utf8");
3154
2844
  }
3155
2845
  async function startDevServer(options) {
3156
- const cwd = resolve5(options.cwd);
2846
+ const cwd = resolve3(options.cwd);
3157
2847
  const log = options.log ?? ((line) => process.stdout.write(`${line}
3158
2848
  `));
3159
2849
  const config = await loadConfig(cwd);
3160
- const functionsDir = join9(cwd, config.functionsDir);
2850
+ const functionsDir = join7(cwd, config.functionsDir);
3161
2851
  const coldStartAt = Date.now();
3162
2852
  const executor = new WorkerFunctionExecutor();
3163
- await mkdir6(functionsDir, { recursive: true });
2853
+ await mkdir5(functionsDir, { recursive: true });
3164
2854
  const runtime = await createSimRuntime({
3165
2855
  cwd,
3166
2856
  projectId: "local",
@@ -3175,12 +2865,12 @@ async function startDevServer(options) {
3175
2865
  const reload = async () => {
3176
2866
  const [nextFiles, envText2] = await Promise.all([
3177
2867
  collectFunctions(functionsDir),
3178
- readFile5(join9(cwd, ".env.local"), "utf8").catch(() => "")
2868
+ readFile5(join7(cwd, ".env.local"), "utf8").catch(() => "")
3179
2869
  ]);
3180
2870
  files = nextFiles;
3181
2871
  env = parseEnvFile(envText2);
3182
2872
  };
3183
- const envText = await readFile5(join9(cwd, ".env.local"), "utf8").catch(() => "");
2873
+ const envText = await readFile5(join7(cwd, ".env.local"), "utf8").catch(() => "");
3184
2874
  env = parseEnvFile(envText);
3185
2875
  let debounceTimer;
3186
2876
  let watcher;
@@ -3385,8 +3075,8 @@ __export(server_exports, {
3385
3075
  });
3386
3076
  import { createServer as createServer2 } from "node:http";
3387
3077
  import { watch as watch2 } from "node:fs";
3388
- import { mkdir as mkdir7, readdir as readdir3, readFile as readFile6, stat as stat6 } from "node:fs/promises";
3389
- import { join as join10, relative, resolve as resolve6 } from "node:path";
3078
+ import { mkdir as mkdir6, readdir as readdir3, readFile as readFile6, stat as stat5 } from "node:fs/promises";
3079
+ import { join as join8, relative, resolve as resolve4 } from "node:path";
3390
3080
  function envNumber(name) {
3391
3081
  const raw = process.env[name];
3392
3082
  if (raw === void 0 || raw.trim() === "") return void 0;
@@ -3408,7 +3098,7 @@ async function collectFunctions2(dir) {
3408
3098
  }
3409
3099
  for (const entry of entries) {
3410
3100
  const rel = prefix.length === 0 ? entry.name : `${prefix}/${entry.name}`;
3411
- const full = join10(sub, entry.name);
3101
+ const full = join8(sub, entry.name);
3412
3102
  if (entry.isDirectory()) {
3413
3103
  await walk(full, rel);
3414
3104
  } else if (entry.isFile() && entry.name.endsWith(".ts")) {
@@ -3447,27 +3137,27 @@ function contentTypeFor(path) {
3447
3137
  return MIME_TYPES[ext] ?? "application/octet-stream";
3448
3138
  }
3449
3139
  async function startServeServer(options) {
3450
- const cwd = resolve6(options.cwd);
3140
+ const cwd = resolve4(options.cwd);
3451
3141
  const log = options.log ?? ((line) => process.stdout.write(`${line}
3452
3142
  `));
3453
3143
  const host = options.host ?? envString("HOST") ?? "127.0.0.1";
3454
3144
  const port = options.port ?? envNumber("PORT") ?? 8787;
3455
- const staticDir = resolve6(
3145
+ const staticDir = resolve4(
3456
3146
  cwd,
3457
3147
  options.staticDir ?? envString("ADEP_SERVE_STATIC_DIR") ?? "public"
3458
3148
  );
3459
3149
  const config = await loadConfig(cwd);
3460
- const functionsDir = join10(cwd, config.functionsDir);
3150
+ const functionsDir = join8(cwd, config.functionsDir);
3461
3151
  let hasStatic = false;
3462
3152
  try {
3463
- const publicStat = await stat6(staticDir);
3153
+ const publicStat = await stat5(staticDir);
3464
3154
  hasStatic = publicStat.isDirectory();
3465
3155
  } catch {
3466
3156
  hasStatic = false;
3467
3157
  }
3468
3158
  let files = await collectFunctions2(functionsDir);
3469
3159
  let functionNames = listFunctionNames(files);
3470
- const envText = await readFile6(join10(cwd, ".env.local"), "utf8").catch(() => "");
3160
+ const envText = await readFile6(join8(cwd, ".env.local"), "utf8").catch(() => "");
3471
3161
  let env = parseEnvFile(envText);
3472
3162
  let simEnv = await loadSimEnv(cwd).catch(() => ({}));
3473
3163
  const runtime = await createSimRuntime({
@@ -3484,7 +3174,7 @@ async function startServeServer(options) {
3484
3174
  const reload = async () => {
3485
3175
  const [nextFiles, envLocalText] = await Promise.all([
3486
3176
  collectFunctions2(functionsDir),
3487
- readFile6(join10(cwd, ".env.local"), "utf8").catch(() => "")
3177
+ readFile6(join8(cwd, ".env.local"), "utf8").catch(() => "")
3488
3178
  ]);
3489
3179
  files = nextFiles;
3490
3180
  env = parseEnvFile(envLocalText);
@@ -3501,7 +3191,7 @@ async function startServeServer(options) {
3501
3191
  void reload();
3502
3192
  }, 120);
3503
3193
  };
3504
- await mkdir7(functionsDir, { recursive: true }).catch(() => void 0);
3194
+ await mkdir6(functionsDir, { recursive: true }).catch(() => void 0);
3505
3195
  try {
3506
3196
  watchers.push(watch2(functionsDir, { recursive: true }, scheduleReload));
3507
3197
  } catch {
@@ -3553,14 +3243,14 @@ async function startServeServer(options) {
3553
3243
  const serveStatic = async (pathname, res) => {
3554
3244
  if (!hasStatic) return false;
3555
3245
  const safePath = pathname.replace(/\.\.\//g, "").replace(/^\//, "");
3556
- const filePath = join10(staticDir, safePath);
3557
- const resolvedPath = safePath === "" || safePath === "/" ? join10(filePath, "index.html") : filePath;
3246
+ const filePath = join8(staticDir, safePath);
3247
+ const resolvedPath = safePath === "" || safePath === "/" ? join8(filePath, "index.html") : filePath;
3558
3248
  try {
3559
- const fileStat = await stat6(resolvedPath);
3249
+ const fileStat = await stat5(resolvedPath);
3560
3250
  if (fileStat.isDirectory()) {
3561
- const indexPath = join10(resolvedPath, "index.html");
3251
+ const indexPath = join8(resolvedPath, "index.html");
3562
3252
  try {
3563
- const indexStat = await stat6(indexPath);
3253
+ const indexStat = await stat5(indexPath);
3564
3254
  if (indexStat.isFile()) {
3565
3255
  const content2 = await readFile6(indexPath);
3566
3256
  res.writeHead(200, { "content-type": contentTypeFor(indexPath) });
@@ -3635,28 +3325,6 @@ async function startServeServer(options) {
3635
3325
  }
3636
3326
  const served = await serveStatic(pathname, res);
3637
3327
  if (served) return;
3638
- if (pathname.startsWith("/_preview/")) {
3639
- const widgetName = pathname.slice("/_preview/".length).split("/")[0];
3640
- if (widgetName !== void 0 && widgetName.length > 0) {
3641
- const widgetDir = join10(cwd, ".adep", "widgets", widgetName);
3642
- try {
3643
- const widgetStat = await stat6(widgetDir);
3644
- if (widgetStat.isDirectory()) {
3645
- const indexPath = join10(widgetDir, "index.html");
3646
- try {
3647
- const content = await readFile6(indexPath, "utf8");
3648
- res.writeHead(200, { "content-type": "text/html; charset=utf-8" });
3649
- res.end(content);
3650
- return;
3651
- } catch {
3652
- }
3653
- }
3654
- } catch {
3655
- }
3656
- }
3657
- writeJson2(res, 404, { error: { code: "WIDGET_NOT_FOUND", message: "\u7EC4\u4EF6\u4EA7\u7269\u4E0D\u5B58\u5728" } });
3658
- return;
3659
- }
3660
3328
  if (pathname === "/" || pathname === "") {
3661
3329
  writeJson2(res, 200, {
3662
3330
  service: "adep-serve",
@@ -3667,7 +3335,6 @@ async function startServeServer(options) {
3667
3335
  endpoints: {
3668
3336
  functions: "/api/{fn}",
3669
3337
  static: `/ \u2192 ${staticDir}`,
3670
- preview: "/_preview/{widget}",
3671
3338
  healthz: "/healthz"
3672
3339
  },
3673
3340
  warning: "\u8FD9\u662F\u5F00\u53D1\u6001\u670D\u52A1\u5668\uFF0C\u4E0D\u662F\u751F\u4EA7\u670D\u52A1\u5668"
@@ -3862,9 +3529,14 @@ __export(deploy_exports, {
3862
3529
  collectEntries: () => collectEntries,
3863
3530
  deploy: () => deploy
3864
3531
  });
3865
- import { createHash as createHash3 } from "node:crypto";
3532
+ import { createHash as createHash2 } from "node:crypto";
3866
3533
  import { readdir as readdir4, readFile as readFile7 } from "node:fs/promises";
3867
- import { join as join11, resolve as resolve7, basename as basename2 } from "node:path";
3534
+ import { join as join9, resolve as resolve5, basename as basename2 } from "node:path";
3535
+ function functionUrlBase(prefix) {
3536
+ const raw = (prefix ?? "/api").trim();
3537
+ const normalized = raw === "/" ? "/" : raw.replace(/\/+$/, "");
3538
+ return normalized === "/" ? "" : normalized;
3539
+ }
3868
3540
  async function collectEntries(functionsDir) {
3869
3541
  const entries = {};
3870
3542
  let names;
@@ -3875,22 +3547,22 @@ async function collectEntries(functionsDir) {
3875
3547
  return entries;
3876
3548
  }
3877
3549
  for (const name of names) {
3878
- entries[name] = await readFile7(join11(functionsDir, `${name}.ts`), "utf8");
3550
+ entries[name] = await readFile7(join9(functionsDir, `${name}.ts`), "utf8");
3879
3551
  }
3880
3552
  return entries;
3881
3553
  }
3882
3554
  function sha256Hex(content) {
3883
- return createHash3("sha256").update(content).digest("hex");
3555
+ return createHash2("sha256").update(content).digest("hex");
3884
3556
  }
3885
3557
  async function deploy(paths, options) {
3886
3558
  await requireNetwork("adep deploy");
3887
3559
  const log = options.silent === true ? () => void 0 : options.log ?? ((line) => process.stdout.write(`${line}
3888
3560
  `));
3889
3561
  const client = await createClient(paths);
3890
- const cwd = resolve7(options.cwd);
3562
+ const cwd = resolve5(options.cwd);
3891
3563
  const config = await loadConfig(cwd);
3892
3564
  const slug = options.slug ?? config.name;
3893
- const functionsDir = options.functionsDir === void 0 ? join11(cwd, config.functionsDir) : resolve7(cwd, options.functionsDir);
3565
+ const functionsDir = options.functionsDir === void 0 ? join9(cwd, config.functionsDir) : resolve5(cwd, options.functionsDir);
3894
3566
  const local = await collectEntries(functionsDir);
3895
3567
  if (Object.keys(local).length === 0) {
3896
3568
  throw new CliError("NO_FUNCTIONS", `${functionsDir} \u4E0B\u6CA1\u6709\u51FD\u6570\u6587\u4EF6`);
@@ -3909,6 +3581,8 @@ async function deploy(paths, options) {
3909
3581
  "DEPLOY_FAILED"
3910
3582
  );
3911
3583
  const baseUrl = `${remote.scheme}://${remote.slug}.${remote.domain}`;
3584
+ const prefixBase = functionUrlBase(remote.functionsPrefix);
3585
+ const functionUrl = (name) => `${baseUrl}${prefixBase}/${name}`;
3912
3586
  const deployed = [];
3913
3587
  for (const item of remote.functions) {
3914
3588
  const content = local[item.name];
@@ -3917,7 +3591,7 @@ async function deploy(paths, options) {
3917
3591
  name: item.name,
3918
3592
  action: "none",
3919
3593
  version: item.version ?? 0,
3920
- url: `${baseUrl}/${item.name}`
3594
+ url: functionUrl(item.name)
3921
3595
  });
3922
3596
  continue;
3923
3597
  }
@@ -3945,7 +3619,7 @@ async function deploy(paths, options) {
3945
3619
  name: item.name,
3946
3620
  action: item.action,
3947
3621
  version: published.version,
3948
- url: `${baseUrl}/${item.name}`
3622
+ url: functionUrl(item.name)
3949
3623
  });
3950
3624
  }
3951
3625
  return {
@@ -4035,13 +3709,13 @@ __export(functions_exports, {
4035
3709
  functionsList: () => functionsList,
4036
3710
  functionsLogs: () => functionsLogs
4037
3711
  });
4038
- import { resolve as resolve8 } from "node:path";
3712
+ import { resolve as resolve6 } from "node:path";
4039
3713
  async function functionsDeploy(paths, options) {
4040
3714
  const startedAt = Date.now();
4041
3715
  const result = await deploy(paths, {
4042
3716
  cwd: options.cwd,
4043
3717
  ...options.slug === void 0 ? {} : { slug: options.slug },
4044
- ...options.dir === void 0 ? {} : { functionsDir: resolve8(options.cwd, options.dir) },
3718
+ ...options.dir === void 0 ? {} : { functionsDir: resolve6(options.cwd, options.dir) },
4045
3719
  silent: true
4046
3720
  });
4047
3721
  return { ...result, elapsedSeconds: (Date.now() - startedAt) / 1e3 };
@@ -4054,10 +3728,12 @@ async function functionsList(paths, options) {
4054
3728
  {},
4055
3729
  "FUNCTION_LIST_FAILED"
4056
3730
  );
3731
+ const prefix = project2.functionsPrefix ?? "/api";
3732
+ const prefixBase = prefix.trim() === "/" ? "" : prefix.trim().replace(/\/+$/, "");
4057
3733
  return {
4058
3734
  projectId: project2.id,
4059
3735
  slug: project2.slug,
4060
- baseUrl: project2.url,
3736
+ baseUrl: `${project2.url.replace(/\/+$/, "")}${prefixBase}`,
4061
3737
  functions: result.functions
4062
3738
  };
4063
3739
  }
@@ -4085,7 +3761,7 @@ async function functionsLogs(paths, options) {
4085
3761
  return { functionId: target.id, name: target.name, logs: result.logs };
4086
3762
  }
4087
3763
  async function resolveProject(client, options) {
4088
- const slug = await resolveSlug(resolve8(options.cwd), options.slug);
3764
+ const slug = await resolveSlug(resolve6(options.cwd), options.slug);
4089
3765
  const projects = await projectsListFrom(client);
4090
3766
  const match = projects.find((project2) => project2.slug === slug);
4091
3767
  if (match === void 0) {
@@ -4116,7 +3792,7 @@ __export(mcp_exports, {
4116
3792
  mcpPublish: () => mcpPublish,
4117
3793
  mcpUnpublish: () => mcpUnpublish
4118
3794
  });
4119
- import { resolve as resolve9 } from "node:path";
3795
+ import { resolve as resolve7 } from "node:path";
4120
3796
  async function mcpPublish(paths, options) {
4121
3797
  const fn = requireFunctionName(options.fn);
4122
3798
  const client = await createClient(paths);
@@ -4152,7 +3828,9 @@ async function mcpUnpublish(paths, options) {
4152
3828
  async function mcpList(paths, options) {
4153
3829
  const client = await createClient(paths);
4154
3830
  const project2 = await resolveProject2(client, options);
4155
- const endpoint = `${project2.url.replace(/\/+$/, "")}/mcp`;
3831
+ const prefix = project2.functionsPrefix ?? "/api";
3832
+ const prefixBase = prefix.trim() === "/" ? "" : prefix.trim().replace(/\/+$/, "");
3833
+ const endpoint = `${project2.url.replace(/\/+$/, "")}${prefixBase}/mcp`;
4156
3834
  let response;
4157
3835
  try {
4158
3836
  response = await fetch(endpoint, {
@@ -4195,7 +3873,7 @@ function requireFunctionName(fn) {
4195
3873
  return fn.trim();
4196
3874
  }
4197
3875
  async function resolveProject2(client, options) {
4198
- const slug = await resolveSlug(resolve9(options.cwd), options.slug);
3876
+ const slug = await resolveSlug(resolve7(options.cwd), options.slug);
4199
3877
  const listed = await client.request("/api/v1/projects", {}, "PROJECT_LIST_FAILED");
4200
3878
  const match = listed.projects.find((project2) => project2.slug === slug);
4201
3879
  if (match === void 0) {
@@ -4204,7 +3882,12 @@ async function resolveProject2(client, options) {
4204
3882
  `\u5E73\u53F0\u9879\u76EE "${slug}" \u4E0D\u5B58\u5728\u6216\u4F60\u6CA1\u6709\u8BBF\u95EE\u6743\u9650\uFF1A\u5148\u6267\u884C adep projects create ${slug}`
4205
3883
  );
4206
3884
  }
4207
- return { id: match.id, slug: match.slug, url: match.url };
3885
+ return {
3886
+ id: match.id,
3887
+ slug: match.slug,
3888
+ url: match.url,
3889
+ ...match.functionsPrefix === void 0 ? {} : { functionsPrefix: match.functionsPrefix }
3890
+ };
4208
3891
  }
4209
3892
  async function resolveFunction(client, project2, name) {
4210
3893
  const listed = await client.request(`/api/v1/projects/${project2.id}/functions`, {}, "FUNCTION_LIST_FAILED");
@@ -4228,7 +3911,7 @@ __export(doctor_exports, {
4228
3911
  formatDoctorReport: () => formatDoctorReport,
4229
3912
  runDoctor: () => runDoctor
4230
3913
  });
4231
- import { stat as stat7 } from "node:fs/promises";
3914
+ import { stat as stat6 } from "node:fs/promises";
4232
3915
  async function probeServer(server) {
4233
3916
  const controller = new AbortController();
4234
3917
  const timer = setTimeout(() => controller.abort(), SERVER_PROBE_TIMEOUT_MS);
@@ -4246,7 +3929,7 @@ async function probeServer(server) {
4246
3929
  }
4247
3930
  async function credentialMode(file) {
4248
3931
  try {
4249
- const info = await stat7(file);
3932
+ const info = await stat6(file);
4250
3933
  return (info.mode & 511).toString(8).padStart(3, "0");
4251
3934
  } catch {
4252
3935
  return void 0;
@@ -4322,8 +4005,6 @@ var init_doctor = __esm({
4322
4005
  "adep init",
4323
4006
  "adep dev",
4324
4007
  "adep serve",
4325
- "adep widget init",
4326
- "adep widget dev",
4327
4008
  "adep db\uFF08\u672C\u5730\u6A21\u62DF\uFF09",
4328
4009
  "adep doctor"
4329
4010
  ];
@@ -4342,10 +4023,10 @@ __export(db_exports, {
4342
4023
  dbStatus: () => dbStatus,
4343
4024
  dbStop: () => dbStop
4344
4025
  });
4345
- import { resolve as resolve10 } from "node:path";
4026
+ import { resolve as resolve8 } from "node:path";
4346
4027
  async function open2(paths, options) {
4347
4028
  const client = await createClient(paths);
4348
- const project2 = await resolveSlug(resolve10(options.cwd), options.slug);
4029
+ const project2 = await resolveSlug(resolve8(options.cwd), options.slug);
4349
4030
  return { client, project: project2 };
4350
4031
  }
4351
4032
  async function dbStart(paths, options) {
@@ -4419,11 +4100,11 @@ __export(storage_exports, {
4419
4100
  storageRemove: () => storageRemove,
4420
4101
  storageUpload: () => storageUpload
4421
4102
  });
4422
- import { mkdir as mkdir8, readFile as readFile8, stat as stat8, writeFile as writeFile6 } from "node:fs/promises";
4423
- import { basename as basename3, dirname as dirname7, extname, join as join12, resolve as resolve11 } from "node:path";
4103
+ import { mkdir as mkdir7, readFile as readFile8, stat as stat7, writeFile as writeFile5 } from "node:fs/promises";
4104
+ import { basename as basename3, dirname as dirname6, extname, join as join10, resolve as resolve9 } from "node:path";
4424
4105
  async function open3(paths, options) {
4425
4106
  const client = await createClient(paths);
4426
- const project2 = await resolveSlug(resolve11(options.cwd), options.slug);
4107
+ const project2 = await resolveSlug(resolve9(options.cwd), options.slug);
4427
4108
  return { client, project: project2 };
4428
4109
  }
4429
4110
  function contentTypeOf(path) {
@@ -4456,8 +4137,8 @@ function contentTypeOf(path) {
4456
4137
  }
4457
4138
  async function storageUpload(paths, options) {
4458
4139
  const { client, project: project2 } = await open3(paths, options);
4459
- const local = resolve11(options.file);
4460
- const info = await stat8(local).catch(() => null);
4140
+ const local = resolve9(options.file);
4141
+ const info = await stat7(local).catch(() => null);
4461
4142
  if (info === null || !info.isFile()) {
4462
4143
  throw new CliError("FILE_NOT_FOUND", `\u672C\u5730\u6587\u4EF6\u4E0D\u5B58\u5728\uFF1A${local}`);
4463
4144
  }
@@ -4503,9 +4184,9 @@ async function storageDownload(paths, options) {
4503
4184
  const url = await resolveDownloadUrl(client, project2, options.path);
4504
4185
  const response = await client.download(url, "STORAGE_DOWNLOAD_FAILED");
4505
4186
  const bytes = Buffer.from(await response.arrayBuffer());
4506
- const output = resolve11(options.output ?? join12(resolve11(options.cwd), basename3(options.path)));
4507
- await mkdir8(dirname7(output), { recursive: true });
4508
- await writeFile6(output, bytes);
4187
+ const output = resolve9(options.output ?? join10(resolve9(options.cwd), basename3(options.path)));
4188
+ await mkdir7(dirname6(output), { recursive: true });
4189
+ await writeFile5(output, bytes);
4509
4190
  return { path: options.path, output, size: bytes.length };
4510
4191
  }
4511
4192
  async function storageRemove(paths, options) {
@@ -4531,11 +4212,11 @@ __export(hosting_exports, {
4531
4212
  hostingInfo: () => hostingInfo,
4532
4213
  hostingPull: () => hostingPull
4533
4214
  });
4534
- import { readdir as readdir5, readFile as readFile9, stat as stat9 } from "node:fs/promises";
4535
- import { dirname as dirname8, join as join13, relative as relative2, resolve as resolve12, sep } from "node:path";
4215
+ import { readdir as readdir5, readFile as readFile9, stat as stat8 } from "node:fs/promises";
4216
+ import { dirname as dirname7, join as join11, relative as relative2, resolve as resolve10, sep } from "node:path";
4536
4217
  async function open4(paths, options) {
4537
4218
  const client = await createClient(paths);
4538
- const project2 = await resolveSlug(resolve12(options.cwd), options.slug);
4219
+ const project2 = await resolveSlug(resolve10(options.cwd), options.slug);
4539
4220
  return { client, project: project2 };
4540
4221
  }
4541
4222
  async function hostingInfo(paths, options) {
@@ -4548,7 +4229,7 @@ async function hostingInfo(paths, options) {
4548
4229
  };
4549
4230
  }
4550
4231
  async function collectSiteFiles(dir) {
4551
- const root = resolve12(dir);
4232
+ const root = resolve10(dir);
4552
4233
  const files = /* @__PURE__ */ new Map();
4553
4234
  const walk = async (sub) => {
4554
4235
  let entries;
@@ -4558,7 +4239,7 @@ async function collectSiteFiles(dir) {
4558
4239
  return;
4559
4240
  }
4560
4241
  for (const entry of entries) {
4561
- const full = join13(sub, entry.name);
4242
+ const full = join11(sub, entry.name);
4562
4243
  if (entry.isDirectory()) {
4563
4244
  await walk(full);
4564
4245
  } else if (entry.isFile()) {
@@ -4576,12 +4257,12 @@ async function hostingDeploy(paths, options) {
4576
4257
  `));
4577
4258
  const files = await collectSiteFiles(options.dir);
4578
4259
  if (files.size === 0) {
4579
- throw new CliError("NO_SITE_FILES", `\u7AD9\u70B9\u76EE\u5F55\u4E3A\u7A7A\uFF1A${resolve12(options.dir)}`);
4260
+ throw new CliError("NO_SITE_FILES", `\u7AD9\u70B9\u76EE\u5F55\u4E3A\u7A7A\uFF1A${resolve10(options.dir)}`);
4580
4261
  }
4581
4262
  const uploaded = [];
4582
4263
  for (const [rel, full] of files) {
4583
4264
  log(`[adep] \u4E0A\u4F20 site/${rel}`);
4584
- const info2 = await stat9(full);
4265
+ const info2 = await stat8(full);
4585
4266
  const bytes = await readFile9(full);
4586
4267
  const form = new FormData();
4587
4268
  form.set("path", `site/${rel}`);
@@ -4609,8 +4290,8 @@ async function hostingPull(paths, options) {
4609
4290
  const log = options.log ?? ((line) => process.stdout.write(`${line}
4610
4291
  `));
4611
4292
  const info = await hostingInfo(paths, options);
4612
- const outputDir = resolve12(options.output ?? resolve12(options.cwd));
4613
- const { mkdir: mkdir10, writeFile: writeFile9 } = await import("node:fs/promises");
4293
+ const outputDir = resolve10(options.output ?? resolve10(options.cwd));
4294
+ const { mkdir: mkdir9, writeFile: writeFile8 } = await import("node:fs/promises");
4614
4295
  const files = [];
4615
4296
  for (const entry of info.files) {
4616
4297
  if (entry.visibility !== "public" || entry.path === HOSTING_CONFIG_PATH) continue;
@@ -4620,9 +4301,9 @@ async function hostingPull(paths, options) {
4620
4301
  const response = await client.download(url, "HOSTING_DOWNLOAD_FAILED");
4621
4302
  const bytes = Buffer.from(await response.arrayBuffer());
4622
4303
  const rel = entry.path.replace(/^site\//, "");
4623
- const target = join13(outputDir, ...rel.split("/"));
4624
- await mkdir10(dirname8(target), { recursive: true });
4625
- await writeFile9(target, bytes);
4304
+ const target = join11(outputDir, ...rel.split("/"));
4305
+ await mkdir9(dirname7(target), { recursive: true });
4306
+ await writeFile8(target, bytes);
4626
4307
  files.push({ path: entry.path, size: bytes.length });
4627
4308
  }
4628
4309
  return { siteUrl: info.siteUrl, outputDir, files };
@@ -4654,7 +4335,7 @@ var client_exports2 = {};
4654
4335
  __export(client_exports2, {
4655
4336
  createExportApiClient: () => createExportApiClient
4656
4337
  });
4657
- import { writeFile as writeFile7 } from "node:fs/promises";
4338
+ import { writeFile as writeFile6 } from "node:fs/promises";
4658
4339
  function toExportJob(view) {
4659
4340
  return {
4660
4341
  id: view.id,
@@ -4698,7 +4379,7 @@ async function createExportApiClient(paths) {
4698
4379
  }
4699
4380
  const response = await client.download(download.downloadUrl, "EXPORT_DOWNLOAD_FAILED");
4700
4381
  const bytes = Buffer.from(await response.arrayBuffer());
4701
- await writeFile7(outputPath, bytes);
4382
+ await writeFile6(outputPath, bytes);
4702
4383
  return { path: outputPath, size: bytes.length };
4703
4384
  }
4704
4385
  };
@@ -4795,33 +4476,33 @@ var fs_exports = {};
4795
4476
  __export(fs_exports, {
4796
4477
  createExportFileSystem: () => createExportFileSystem
4797
4478
  });
4798
- import { mkdir as mkdir9, readFile as readFile10, rm as rm3, stat as stat10, writeFile as writeFile8 } from "node:fs/promises";
4799
- import { dirname as dirname9, join as join14 } from "node:path";
4479
+ import { mkdir as mkdir8, readFile as readFile10, rm as rm3, stat as stat9, writeFile as writeFile7 } from "node:fs/promises";
4480
+ import { dirname as dirname8, join as join12 } from "node:path";
4800
4481
  function createExportFileSystem() {
4801
4482
  return {
4802
4483
  readFile: (path) => readFile10(path),
4803
- writeFile: (path, content) => writeFile8(path, content),
4484
+ writeFile: (path, content) => writeFile7(path, content),
4804
4485
  // 同时用于清理解压临时目录(${zip}.tmp 是个目录)——递归强制删除,缺失不报错。
4805
4486
  deleteFile: async (path) => {
4806
4487
  await rm3(path, { recursive: true, force: true });
4807
4488
  },
4808
4489
  fileExists: async (path) => {
4809
4490
  try {
4810
- await stat10(path);
4491
+ await stat9(path);
4811
4492
  return true;
4812
4493
  } catch {
4813
4494
  return false;
4814
4495
  }
4815
4496
  },
4816
4497
  mkdir: async (path) => {
4817
- await mkdir9(path, { recursive: true });
4498
+ await mkdir8(path, { recursive: true });
4818
4499
  },
4819
4500
  unzip: async (zipPath, targetDir) => {
4820
4501
  const entries = zipRead(await readFile10(zipPath));
4821
4502
  for (const [name, data] of entries) {
4822
- const dest = join14(targetDir, name);
4823
- await mkdir9(dirname9(dest), { recursive: true });
4824
- await writeFile8(dest, data);
4503
+ const dest = join12(targetDir, name);
4504
+ await mkdir8(dirname8(dest), { recursive: true });
4505
+ await writeFile7(dest, data);
4825
4506
  }
4826
4507
  }
4827
4508
  };
@@ -5102,7 +4783,7 @@ var command_exports = {};
5102
4783
  __export(command_exports, {
5103
4784
  ExportCommand: () => ExportCommand
5104
4785
  });
5105
- import { createHash as createHash4 } from "node:crypto";
4786
+ import { createHash as createHash3 } from "node:crypto";
5106
4787
  var ExportCommand;
5107
4788
  var init_command = __esm({
5108
4789
  "packages/cli/src/export/command.ts"() {
@@ -5250,7 +4931,7 @@ ${errors}`);
5250
4931
  const contentResult = verifyContents(
5251
4932
  manifest.contents,
5252
4933
  actual,
5253
- (text) => createHash4("sha256").update(Buffer.from(text, "latin1")).digest("hex")
4934
+ (text) => createHash3("sha256").update(Buffer.from(text, "latin1")).digest("hex")
5254
4935
  );
5255
4936
  if (!contentResult.valid) {
5256
4937
  const detail = contentResult.errors.map((e) => e.message).join("\n");
@@ -5321,302 +5002,12 @@ ${detail}`);
5321
5002
  * @param ms 毫秒数
5322
5003
  */
5323
5004
  sleep(ms) {
5324
- return new Promise((resolve15) => setTimeout(resolve15, ms));
5005
+ return new Promise((resolve11) => setTimeout(resolve11, ms));
5325
5006
  }
5326
5007
  };
5327
5008
  }
5328
5009
  });
5329
5010
 
5330
- // packages/cli/src/widget/dev.ts
5331
- var dev_exports2 = {};
5332
- __export(dev_exports2, {
5333
- loadWidgetProject: () => loadWidgetProject,
5334
- startWidgetDev: () => startWidgetDev
5335
- });
5336
- import { createServer as createServer3 } from "node:http";
5337
- import { watch as watch3 } from "node:fs";
5338
- import { readFile as readFile11, stat as stat11 } from "node:fs/promises";
5339
- import { join as join15, resolve as resolve13 } from "node:path";
5340
- async function loadWidgetProject(cwd) {
5341
- const fallback = {
5342
- name: "widget",
5343
- framework: "vue3"
5344
- };
5345
- const manifestPath = join15(resolve13(cwd), "manifest.json");
5346
- try {
5347
- await stat11(manifestPath);
5348
- } catch {
5349
- return fallback;
5350
- }
5351
- try {
5352
- const raw = await readFile11(manifestPath, "utf8");
5353
- const parsed = JSON.parse(raw);
5354
- return {
5355
- name: typeof parsed["name"] === "string" ? parsed["name"] : fallback.name,
5356
- framework: parsed["framework"] === "react" ? "react" : "vue3"
5357
- };
5358
- } catch {
5359
- return fallback;
5360
- }
5361
- }
5362
- function sandboxHtml(name, framework) {
5363
- return `<!doctype html>
5364
- <html>
5365
- <head>
5366
- <meta charset="utf-8" />
5367
- <title>adep widget dev \u2014 ${name}</title>
5368
- <link rel="stylesheet" href="/__widget/theme.css" />
5369
- <style>
5370
- body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #f5f6f7; margin: 0; padding: 24px; }
5371
- #toolbar { display: flex; gap: 12px; align-items: center; font-size: 13px; color: #4c5561; margin-bottom: 16px; }
5372
- #toolbar .dot { width: 8px; height: 8px; border-radius: 50%; background: #99a2ad; }
5373
- #toolbar .dot.on { background: #16a34a; }
5374
- #sandbox { background: #fff; border: 1px solid #e5e6eb; border-radius: 8px; min-height: 120px; }
5375
- code { background: #eef0f3; padding: 2px 6px; border-radius: 4px; }
5376
- </style>
5377
- </head>
5378
- <body>
5379
- <div id="toolbar"><span id="status"><span class="dot" id="dot"></span> sandbox connecting\u2026</span></div>
5380
- <div id="sandbox"></div>
5381
- <script type="module">
5382
- const q = new URLSearchParams(location.search)
5383
- const token = q.get('token') ?? ''
5384
- document.getElementById('status').textContent = 'token: ' + (token ? 'injected' : '(none)')
5385
- const hostEl = document.getElementById('sandbox')
5386
- const host = hostEl.attachShadow({ mode: 'open' })
5387
- let version = 0
5388
-
5389
- async function load(v) {
5390
- host.textContent = ''
5391
- let props = {}
5392
- try { props = await (await fetch('/__widget/mock-props')).json() } catch { props = {} }
5393
- const mod = await import('/__widget/index.js?v=' + v)
5394
- mod.mount(host, {
5395
- widgetName: '${name}',
5396
- framework: '${framework}',
5397
- props,
5398
- host: {
5399
- getProjectId: () => 'local-dev',
5400
- invokeFunction: async () => ({})
5401
- }
5402
- })
5403
- }
5404
-
5405
- function markConnected() {
5406
- const dot = document.getElementById('dot')
5407
- dot.classList.add('on')
5408
- document.getElementById('status').firstChild.textContent = 'sandbox live \u2014 watch src/\uFF0C\u4FDD\u5B58\u540E\u81EA\u52A8\u70ED\u66F4\u65B0 '
5409
- }
5410
-
5411
- const es = new EventSource('/__widget/events')
5412
- es.addEventListener('rebuild', (e) => {
5413
- version = Number(e.data) || 0
5414
- load(version).catch((err) => { console.error(err); host.textContent = 'mount error: ' + err.message })
5415
- })
5416
- es.addEventListener('open', (e) => {
5417
- e.preventDefault()
5418
- markConnected()
5419
- if (version === 0) load(0)
5420
- })
5421
- </script>
5422
- </body>
5423
- </html>
5424
- `;
5425
- }
5426
- async function startWidgetDev(options) {
5427
- const cwd = resolve13(options.cwd);
5428
- const log = options.log ?? ((line) => process.stdout.write(`${line}
5429
- `));
5430
- const project2 = await loadWidgetProject(cwd);
5431
- const framework = options.framework ?? project2.framework;
5432
- let state = { text: "", version: 0 };
5433
- const rebuild = async () => {
5434
- const built = await buildWidget({ cwd, framework });
5435
- const next = { text: built.text, version: state.version + 1 };
5436
- state = next;
5437
- return next;
5438
- };
5439
- try {
5440
- await rebuild();
5441
- } catch (error) {
5442
- throw new WidgetError(
5443
- "BUILD_FAILED",
5444
- `widget \u6784\u5EFA\u5931\u8D25\uFF1A${error instanceof Error ? error.message : String(error)}`
5445
- );
5446
- }
5447
- const clients = /* @__PURE__ */ new Set();
5448
- const broadcast = (version) => {
5449
- for (const res of clients) {
5450
- res.write(`event: rebuild
5451
- data: ${version}
5452
-
5453
- `);
5454
- }
5455
- };
5456
- let debounceTimer;
5457
- let watcher;
5458
- try {
5459
- watcher = watch3(cwd, { recursive: true }, () => {
5460
- if (debounceTimer !== void 0) clearTimeout(debounceTimer);
5461
- debounceTimer = setTimeout(() => {
5462
- void buildWidget({ cwd, framework }).then((built) => {
5463
- const next = { text: built.text, version: state.version + 1 };
5464
- state = next;
5465
- broadcast(next.version);
5466
- log(`[adep] widget rebuilt v${next.version}`);
5467
- return void 0;
5468
- }).catch((error) => {
5469
- log(`[adep] rebuild failed: ${error instanceof Error ? error.message : String(error)}`);
5470
- });
5471
- }, 120);
5472
- });
5473
- } catch {
5474
- watcher = void 0;
5475
- }
5476
- const readTheme = async () => {
5477
- try {
5478
- return await readFile11(join15(cwd, "src", "theme.css"), "utf8");
5479
- } catch {
5480
- return null;
5481
- }
5482
- };
5483
- const readProps = async () => {
5484
- try {
5485
- return await readFile11(join15(cwd, "src", "mock-props.json"), "utf8");
5486
- } catch {
5487
- return null;
5488
- }
5489
- };
5490
- const handle = async (req, res) => {
5491
- const url = new URL(req.url ?? "/", "http://127.0.0.1");
5492
- if (url.pathname === "/") {
5493
- res.writeHead(200, { "content-type": "text/html; charset=utf-8" });
5494
- res.end(sandboxHtml(project2.name, framework));
5495
- return;
5496
- }
5497
- if (url.pathname === "/__widget/index.js") {
5498
- const version = url.searchParams.get("v");
5499
- if (version !== null && Number(version) > state.version) {
5500
- await rebuild().catch(() => void 0);
5501
- }
5502
- res.writeHead(200, { "content-type": "application/javascript; charset=utf-8" });
5503
- res.end(state.text);
5504
- return;
5505
- }
5506
- if (url.pathname === "/__widget/theme.css") {
5507
- const css = await readTheme();
5508
- if (css === null) {
5509
- res.writeHead(404).end("not found");
5510
- return;
5511
- }
5512
- res.writeHead(200, { "content-type": "text/css; charset=utf-8" });
5513
- res.end(css);
5514
- return;
5515
- }
5516
- if (url.pathname === "/__widget/mock-props") {
5517
- const props = await readProps();
5518
- res.writeHead(200, { "content-type": "application/json; charset=utf-8" });
5519
- res.end(props ?? "{}");
5520
- return;
5521
- }
5522
- if (url.pathname === "/__widget/events") {
5523
- res.writeHead(200, {
5524
- "content-type": "text/event-stream",
5525
- "cache-control": "no-cache",
5526
- connection: "keep-alive"
5527
- });
5528
- res.write(": connected\n\n");
5529
- clients.add(res);
5530
- req.on("close", () => {
5531
- clients.delete(res);
5532
- });
5533
- return;
5534
- }
5535
- res.writeHead(404).end("not found");
5536
- };
5537
- const server = createServer3((req, res) => {
5538
- void handle(req, res);
5539
- });
5540
- await new Promise((resolveListen, rejectListen) => {
5541
- server.once("error", rejectListen);
5542
- server.listen(options.port ?? 8788, "127.0.0.1", () => {
5543
- server.off("error", rejectListen);
5544
- resolveListen();
5545
- });
5546
- });
5547
- const address = server.address();
5548
- const port = typeof address === "object" && address !== null ? address.port : options.port ?? 8788;
5549
- const baseUrl = `http://127.0.0.1:${port}`;
5550
- return {
5551
- port,
5552
- baseUrl,
5553
- close: async () => {
5554
- if (debounceTimer !== void 0) clearTimeout(debounceTimer);
5555
- watcher?.close();
5556
- for (const res of clients) res.end();
5557
- clients.clear();
5558
- await new Promise((resolveClose) => server.close(() => resolveClose()));
5559
- }
5560
- };
5561
- }
5562
- var init_dev2 = __esm({
5563
- "packages/cli/src/widget/dev.ts"() {
5564
- "use strict";
5565
- init_build();
5566
- }
5567
- });
5568
-
5569
- // packages/cli/src/widget/publish.ts
5570
- var publish_exports = {};
5571
- __export(publish_exports, {
5572
- publishWidget: () => publishWidget
5573
- });
5574
- import { readFile as readFile12 } from "node:fs/promises";
5575
- import { basename as basename4, join as join16, resolve as resolve14 } from "node:path";
5576
- async function publishWidget(paths, options) {
5577
- const log = options.log ?? ((line) => process.stdout.write(`${line}
5578
- `));
5579
- const client = await createClient(paths);
5580
- const root = resolve14(options.cwd);
5581
- const project2 = await loadWidgetProject(root);
5582
- const framework = options.framework ?? project2.framework;
5583
- let version = "0.1.0";
5584
- try {
5585
- const pkg = JSON.parse(await readFile12(join16(root, "package.json"), "utf8"));
5586
- if (typeof pkg["version"] === "string" && pkg["version"].length > 0) version = pkg["version"];
5587
- } catch {
5588
- version = "0.1.0";
5589
- }
5590
- const name = project2.name === "widget" ? basename4(root) : project2.name;
5591
- log(`[adep] \u6784\u5EFA ${name}\uFF08${framework}\uFF09v${version} \u2026`);
5592
- const built = await buildWidget({ cwd: root, framework });
5593
- const path = `widgets/${name}/${version}/index.js`;
5594
- const form = new FormData();
5595
- form.set("path", path);
5596
- form.set("visibility", "public");
5597
- form.set("file", new Blob([built.text], { type: "text/javascript" }), "index.js");
5598
- await client.upload(`/api/v1/projects/${options.project}/files`, form, "PUBLISH_UPLOAD_FAILED");
5599
- const prefix = encodeURIComponent(`widgets/${name}/${version}/`);
5600
- const listing = await client.request(
5601
- `/api/v1/projects/${options.project}/files?prefix=${prefix}`
5602
- );
5603
- const entry = (listing.files ?? []).find((file) => file.path?.endsWith("index.js"));
5604
- const url = entry?.url;
5605
- if (typeof url !== "string" || url.length === 0) {
5606
- throw new WidgetError("URL_MISSING", "\u4E0A\u4F20\u6210\u529F\u4F46\u65E0\u6CD5\u89E3\u6790\u4EA7\u7269 URL\uFF0C\u8BF7\u68C0\u67E5\u5E73\u53F0\u5B58\u50A8\u914D\u7F6E");
5607
- }
5608
- log(`[adep] \u5DF2\u53D1\u5E03 ${name} v${version}\uFF08hash ${built.hash.slice(0, 8)}\u2026\uFF09`);
5609
- return { name, version, framework, url, hash: built.hash };
5610
- }
5611
- var init_publish = __esm({
5612
- "packages/cli/src/widget/publish.ts"() {
5613
- "use strict";
5614
- init_client();
5615
- init_build();
5616
- init_dev2();
5617
- }
5618
- });
5619
-
5620
5011
  // packages/cli/src/cli.ts
5621
5012
  init_config();
5622
5013
  import { Command } from "commander";
@@ -5905,9 +5296,111 @@ var ADEP_TSCONFIG_JSON = `{
5905
5296
  }
5906
5297
  `;
5907
5298
 
5299
+ // shared/sdk/web-project-template.ts
5300
+ function webProjectFiles() {
5301
+ return [
5302
+ {
5303
+ path: "package.json",
5304
+ content: JSON.stringify(
5305
+ {
5306
+ name: "adep-web",
5307
+ version: "0.0.0",
5308
+ type: "module",
5309
+ scripts: { dev: "vite" },
5310
+ dependencies: { vue: "^3.3.4" },
5311
+ devDependencies: {
5312
+ vite: "^4.4.0",
5313
+ "@vitejs/plugin-vue": "^4.3.0",
5314
+ // vite 内部动态 import('esbuild-wasm'),必须在 package.json 显式声明才能被 Nodebox 解析
5315
+ "esbuild-wasm": "0.18.20"
5316
+ }
5317
+ },
5318
+ null,
5319
+ 2
5320
+ )
5321
+ },
5322
+ {
5323
+ path: "index.html",
5324
+ content: [
5325
+ `<!doctype html>`,
5326
+ `<html lang="zh-CN">`,
5327
+ `<head>`,
5328
+ ` <meta charset="utf-8" />`,
5329
+ ` <meta name="viewport" content="width=device-width, initial-scale=1" />`,
5330
+ ` <title>adep web</title>`,
5331
+ `</head>`,
5332
+ `<body>`,
5333
+ ` <div id="app"></div>`,
5334
+ ` <script type="module" src="/src/main.ts"></script>`,
5335
+ `</body>`,
5336
+ `</html>`,
5337
+ ``
5338
+ ].join("\n")
5339
+ },
5340
+ {
5341
+ path: "vite.config.ts",
5342
+ content: [
5343
+ `// web/vite.config.ts \u2014\u2014 \u6807\u51C6 Vite \u914D\u7F6E\uFF08Vue 3 \u63D2\u4EF6\uFF09\u3002`,
5344
+ `import { defineConfig } from 'vite'`,
5345
+ `import vue from '@vitejs/plugin-vue'`,
5346
+ ``,
5347
+ `export default defineConfig({`,
5348
+ ` plugins: [vue()],`,
5349
+ `})`,
5350
+ ``
5351
+ ].join("\n")
5352
+ },
5353
+ {
5354
+ path: "src/main.ts",
5355
+ content: [
5356
+ `// web/src/main.ts \u2014\u2014 \u5E94\u7528\u5165\u53E3\uFF08Vue 3 + Vite\uFF09\u3002`,
5357
+ `// \u5F00\u53D1\uFF1A\u5E95\u90E8\u300C\u6D4F\u89C8\u5668\u7EC8\u7AEF\u300D\u8FD0\u884C npm run dev\uFF08\u6216\u7B49 Nodebox \u81EA\u52A8\u62C9\u8D77\uFF09\uFF0C\u4FDD\u5B58\u540E\u9884\u89C8 HMR \u5237\u65B0\u3002`,
5358
+ `import { createApp } from 'vue'`,
5359
+ `import App from './App.vue'`,
5360
+ ``,
5361
+ `createApp(App).mount('#app')`,
5362
+ ``
5363
+ ].join("\n")
5364
+ },
5365
+ {
5366
+ path: "src/App.vue",
5367
+ content: [
5368
+ `<script setup lang="ts">`,
5369
+ `import { ref } from 'vue'`,
5370
+ ``,
5371
+ `const title = ref('adep web')`,
5372
+ `const clicks = ref(0)`,
5373
+ `</script>`,
5374
+ ``,
5375
+ `<template>`,
5376
+ ` <main>`,
5377
+ ` <h1>{{ title }}</h1>`,
5378
+ ` <p>\u5728 web/src/App.vue \u91CC\u7F16\u8F91\uFF0C\u4FDD\u5B58\u540E\u9884\u89C8\u81EA\u52A8\u5237\u65B0\uFF08HMR\uFF09\u3002</p>`,
5379
+ ` <button @click="clicks++">clicks: {{ clicks }}</button>`,
5380
+ ` </main>`,
5381
+ `</template>`,
5382
+ ``,
5383
+ `<style scoped>`,
5384
+ `main {`,
5385
+ ` margin: 24px;`,
5386
+ ` font-family: system-ui, -apple-system, sans-serif;`,
5387
+ `}`,
5388
+ `button {`,
5389
+ ` padding: 6px 14px;`,
5390
+ ` border: 1px solid #6366f1;`,
5391
+ ` border-radius: 6px;`,
5392
+ ` background: #eef2ff;`,
5393
+ ` cursor: pointer;`,
5394
+ `}`,
5395
+ `</style>`,
5396
+ ``
5397
+ ].join("\n")
5398
+ }
5399
+ ];
5400
+ }
5401
+
5908
5402
  // packages/cli/src/init.ts
5909
- init_templates();
5910
- var TEMPLATE_NAMES = ["empty", "function", "widget", "page"];
5403
+ var TEMPLATE_NAMES = ["empty", "function", "fullstack"];
5911
5404
  var InitError = class extends Error {
5912
5405
  constructor(code, message) {
5913
5406
  super(message);
@@ -5923,20 +5416,22 @@ export default {
5923
5416
  `;
5924
5417
  var README = (name, template) => `# ${name}
5925
5418
 
5926
- AgentDeploy \u9879\u76EE\uFF08\u6A21\u677F\uFF1A${template}\uFF09\u3002
5419
+ AgentDeploy \u5168\u6808\u9879\u76EE\uFF08\u6A21\u677F\uFF1A${template}\uFF09\u3002
5927
5420
 
5928
5421
  ## \u5E38\u7528\u547D\u4EE4
5929
5422
 
5930
5423
  - \`adep dev\`\uFF1A\u672C\u5730\u8C03\u8BD5\uFF08\u76D1\u542C functions/\uFF0C\u652F\u6301\u70ED\u91CD\u8F7D\uFF0C\u9ED8\u8BA4 http://127.0.0.1:8787/<fnName>\uFF09
5931
5424
  - \`adep deploy\`\uFF1A\u589E\u91CF\u90E8\u7F72\uFF08\u5BF9\u6BD4\u8FDC\u7AEF\u54C8\u5E0C \u2192 \u4EC5\u4E0A\u4F20\u53D8\u66F4 \u2192 \u53D1\u5E03 \u2192 \u8F93\u51FA\u8BBF\u95EE\u57DF\u540D\uFF09
5932
- - \`adep serve\`\uFF1A\u5F00\u53D1\u6001\u670D\u52A1\u5668\uFF08\u51FD\u6570 /api/{fn} + /healthz + \u9759\u6001\u6258\u7BA1 + \u7EC4\u4EF6\u9884\u89C8\uFF09
5425
+ - \`adep serve\`\uFF1A\u5F00\u53D1\u6001\u670D\u52A1\u5668\uFF08\u51FD\u6570 /api/{fn} + /healthz + \u9759\u6001\u6258\u7BA1 + \u524D\u7AEF\u9884\u89C8\uFF09
5933
5426
 
5934
5427
  ## \u76EE\u5F55\u7ED3\u6784
5935
5428
 
5936
5429
  - \`adep.config.ts\`\uFF1A\u9879\u76EE\u6807\u8BC6\uFF08dev / deploy \u6309\u6B64\u8BC6\u522B\uFF09
5430
+ - \`functions/\`\uFF1A\u4E91\u51FD\u6570\u76EE\u5F55\uFF08\u6BCF\u4E2A\u6587\u4EF6 = \u4E00\u4E2A\u51FD\u6570\uFF0C\u9ED8\u8BA4\u5BFC\u51FA \`(ctx: AdepContext) => Response\`\uFF09
5431
+ - \`web/\`\uFF1A\u524D\u7AEF\u5DE5\u7A0B\uFF08\u6807\u51C6 Vite + Vue 3\uFF1B\u4E0E Web IDE \u9879\u76EE\u540C\u6784\uFF0C\u53EF\u6574\u76EE\u5F55\u5BFC\u51FA\u4E8C\u6B21\u5F00\u53D1\uFF09
5432
+ - \`database/schema.sql\`\uFF1A\u6570\u636E\u5E93\u7ED3\u6784\uFF08\u8868\u7531\u5E73\u53F0\u63A7\u5236\u53F0 / \`adep db\` \u7BA1\u7406\uFF0C\u6B64\u5904\u4E3A\u7ED3\u6784\u8BB0\u5F55\uFF09
5937
5433
  - \`tsconfig.json\`\uFF1A\u4E91\u51FD\u6570 TypeScript \u7F16\u8F91\u5668\u914D\u7F6E\uFF08strict + noEmit\uFF09
5938
5434
  - \`adep.d.ts\`\uFF1A\u4E91\u51FD\u6570\u4E0A\u4E0B\u6587\u73AF\u5883\u7C7B\u578B\u58F0\u660E\uFF08\`ctx: AdepContext\` \u8865\u5168\uFF0C\u65E0\u9700\u88C5\u4F9D\u8D56\uFF09
5939
- ${template === "function" ? "- `functions/`\uFF1A\u4E91\u51FD\u6570\u76EE\u5F55\uFF08\u672C\u6A21\u677F\u751F\u6210\u5355\u4E2A\u793A\u4F8B\u51FD\u6570 `functions/hello.ts`\uFF09" : template === "widget" ? "- `widgets/`\uFF1A\u5FAE\u524D\u7AEF\u7EC4\u4EF6\uFF08widget\uFF09\u76EE\u5F55\uFF08\u672C\u6A21\u677F\u751F\u6210\u5355\u4E2A widget\uFF09" : template === "page" ? "- `web/`\uFF1A\u9759\u6001\u9875\u9762\u76EE\u5F55\uFF08\u672C\u6A21\u677F\u751F\u6210\u5355\u4E2A\u9875\u9762\uFF0C\u53EF\u7ECF `adep serve --static ./web` \u9884\u89C8\uFF09" : "- \u51FD\u6570\u653E\u5165 `functions/`\uFF0C\u914D\u7F6E\u89C1 `adep.config.ts`"}
5940
5435
 
5941
5436
  ## \u4E91\u51FD\u6570\u7C7B\u578B\u63D0\u793A
5942
5437
 
@@ -5946,13 +5441,17 @@ ${template === "function" ? "- `functions/`\uFF1A\u4E91\u51FD\u6570\u76EE\u5F55\
5946
5441
 
5947
5442
  ## \u6A21\u677F\u8BF4\u660E\uFF08adep init\uFF09
5948
5443
 
5949
- - \`adep init <name>\`\uFF1A\u9ED8\u8BA4 \`function\` \u6A21\u677F\uFF08\u5355\u4E2A\u51FD\u6570\uFF09
5444
+ - \`adep init <name>\`\uFF1A\u9ED8\u8BA4 \`fullstack\` \u6A21\u677F\uFF08functions/ + web/ \u524D\u7AEF\u5DE5\u7A0B + database/\uFF0C\u4E0E Web IDE \u9879\u76EE\u540C\u6784\uFF09
5445
+ - \`adep init <name> -t function\`\uFF1A\u4EC5\u4E91\u51FD\u6570\uFF08\u5355\u4E2A\u793A\u4F8B\u51FD\u6570\uFF09
5950
5446
  - \`adep init <name> -t empty\`\uFF1A\u7A7A\u6A21\u677F\uFF08\u4EC5\u9879\u76EE\u9AA8\u67B6\uFF09
5951
- - \`adep init <name> -t function\`\uFF1A\u5355\u4E2A\u51FD\u6570
5952
- - \`adep init <name> -t widget\`\uFF1A\u5355\u4E2A Widget\uFF08\u5FAE\u524D\u7AEF\u7EC4\u4EF6\uFF09
5953
- - \`adep init <name> -t page\`\uFF1A\u5355\u4E2A Page\uFF08\u9759\u6001\u9875\u9762\uFF09
5954
5447
  - \`adep init --list\`\uFF1A\u4ECE\u5E73\u53F0 /api/v1/templates \u5217\u51FA\u53EF\u7528\u6A21\u677F
5955
5448
  - \`adep init --list -s <server>\`\uFF1A\u6307\u5B9A\u5E73\u53F0\u5730\u5740
5449
+
5450
+ ## \u524D\u7AEF\u5DE5\u7A0B\uFF08web/\uFF09
5451
+
5452
+ \`web/\` \u662F\u6807\u51C6 Vite + Vue 3 \u5DE5\u7A0B\uFF0C\u4E0E Web IDE \u5185\u521B\u5EFA\u7684\u9879\u76EE\u5B8C\u5168\u540C\u6784\uFF1A
5453
+ \`index.html\` / \`package.json\` / \`vite.config.ts\` / \`src/main.ts\` / \`src/App.vue\`\u3002
5454
+ \u672C\u5730\u5F00\u53D1\uFF1A\`cd web && npm install && npm run dev\`\uFF1B\u90E8\u7F72\u7531 \`adep deploy\` \u7EDF\u4E00\u6784\u5EFA\u53D1\u5E03\u3002
5956
5455
  `;
5957
5456
  var HELLO_FUNCTION = `// \u793A\u4F8B\u51FD\u6570\uFF1Aadep deploy \u540E\u7ECF https://<project-slug>.<platform-domain>/hello \u89E6\u53D1\u3002
5958
5457
  // \u7528\u6237\u51FD\u6570\u5373 functions/ \u4E0B\u7684\u72EC\u7ACB\u6587\u4EF6\uFF0C\u9ED8\u8BA4\u5BFC\u51FA (ctx: AdepContext) => Response \u5F62\u72B6\u7684\u5904\u7406\u5668
@@ -5965,30 +5464,10 @@ export default async (ctx: AdepContext) => {
5965
5464
  var FUNCTION_INDEX = `// \u51FD\u6570\u6A21\u5757\u5165\u53E3\uFF1A\u9879\u76EE\u91CC\u7684\u6BCF\u4E2A\u51FD\u6570\u662F functions/ \u4E0B\u7684\u72EC\u7ACB\u6587\u4EF6\uFF0C
5966
5465
  // \u9ED8\u8BA4\u5BFC\u51FA (ctx: AdepContext) => Response \u5F62\u72B6\u7684\u5904\u7406\u5668\uFF08\u5951\u7EA6\u89C1 adep.d.ts\uFF09\u3002
5967
5466
  `;
5968
- var EMPTY_INDEX = `// AgentDeploy \u9879\u76EE\u5165\u53E3\u3002\u6A21\u677F\u6682\u65E0\u66F4\u591A\u5185\u5BB9\u2014\u2014\u51FD\u6570\u653E functions/\uFF0C\u914D\u7F6E\u89C1 adep.config.ts\u3002
5467
+ var EMPTY_INDEX = `// AgentDeploy \u9879\u76EE\u5165\u53E3\u3002\u6A21\u677F\u6682\u65E0\u66F4\u591A\u5185\u5BB9\u2014\u2014\u51FD\u6570\u653E functions/\uFF0C\u524D\u7AEF\u653E web/\uFF0C\u914D\u7F6E\u89C1 adep.config.ts\u3002
5969
5468
  `;
5970
- var PAGE_INDEX = (name) => `<!doctype html>
5971
- <html lang="zh-CN">
5972
- <head>
5973
- <meta charset="utf-8" />
5974
- <meta name="viewport" content="width=device-width, initial-scale=1" />
5975
- <title>${name}</title>
5976
- <style>
5977
- :root { --adep-accent: #3370ff; --adep-bg: #0d0f14; --adep-text: #e8eaed; }
5978
- body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--adep-bg); color: var(--adep-text); }
5979
- main { max-width: 640px; margin: 0 auto; padding: 5rem 1.5rem; }
5980
- h1 { color: var(--adep-accent); }
5981
- code { background: #1b1f27; padding: .15em .4em; border-radius: 4px; }
5982
- </style>
5983
- </head>
5984
- <body>
5985
- <main>
5986
- <h1>${name}</h1>
5987
- <p>\u8FD9\u662F\u4E00\u4E2A AgentDeploy \u9759\u6001\u9875\u9762\u3002\u53EF\u7ECF <code>adep serve --static ./web</code> \u9884\u89C8\u3002</p>
5988
- <p>\u628A\u9875\u9762\u4EA7\u7269\u653E\u5230 <code>web/</code> \u76EE\u5F55\uFF0C\u5373\u53EF\u88AB <code>adep serve</code> \u76F4\u63A5\u6258\u7BA1\u3002</p>
5989
- </main>
5990
- </body>
5991
- </html>
5469
+ var SCHEMA_SQL = `-- AgentDeploy \u9879\u76EE\u6570\u636E\u5E93\u7ED3\u6784\uFF08\u5360\u4F4D\uFF09\u3002
5470
+ -- \u8868\u7ED3\u6784\u8BF7\u5728\u5E73\u53F0\u63A7\u5236\u53F0\u300C\u6570\u636E\u5E93\u300D\u6216\u672C\u5730 \`adep db\` \u4E2D\u521B\u5EFA\u540E\u56DE\u586B\uFF0C\u4FDD\u6301\u4E0E\u7EBF\u4E0A schema \u4E00\u81F4\u3002
5992
5471
  `;
5993
5472
  async function initProject(cwd, name, template) {
5994
5473
  if (!/^[a-z][a-z0-9-]{0,62}$/.test(name)) {
@@ -6019,17 +5498,18 @@ async function initProject(cwd, name, template) {
6019
5498
  { path: "tsconfig.json", content: ADEP_TSCONFIG_JSON },
6020
5499
  { path: "adep.d.ts", content: ADEP_ENV_DTS },
6021
5500
  { path: "README.md", content: README(name, template) },
6022
- { path: ".gitignore", content: "node_modules/\ndata/\n.adep/\n" }
5501
+ { path: ".gitignore", content: "node_modules/\ndata/\n.adep/\nweb/node_modules/\n" }
6023
5502
  ];
6024
5503
  if (template === "function") {
6025
5504
  files.push({ path: "functions/hello.ts", content: HELLO_FUNCTION });
6026
5505
  files.push({ path: "functions/README.md", content: FUNCTION_INDEX });
6027
- } else if (template === "widget") {
6028
- for (const [rel, content] of Object.entries(widgetTemplateFiles(name, "vue3-ts"))) {
6029
- files.push({ path: `widgets/${name}/${rel}`, content });
5506
+ } else if (template === "fullstack") {
5507
+ files.push({ path: "functions/hello.ts", content: HELLO_FUNCTION });
5508
+ files.push({ path: "functions/README.md", content: FUNCTION_INDEX });
5509
+ files.push({ path: "database/schema.sql", content: SCHEMA_SQL });
5510
+ for (const file of webProjectFiles()) {
5511
+ files.push({ path: `web/${file.path}`, content: file.content });
6030
5512
  }
6031
- } else if (template === "page") {
6032
- files.push({ path: "web/index.html", content: PAGE_INDEX(name) });
6033
5513
  } else {
6034
5514
  files.push({ path: "README-EMPTY.md", content: EMPTY_INDEX });
6035
5515
  }
@@ -6045,10 +5525,8 @@ async function initProject(cwd, name, template) {
6045
5525
  }
6046
5526
 
6047
5527
  // packages/cli/src/output.ts
6048
- init_build();
6049
- init_init();
6050
5528
  function isCommandError(error) {
6051
- return error instanceof CliError || error instanceof InitError || error instanceof WidgetError || error instanceof WidgetInitError;
5529
+ return error instanceof CliError || error instanceof InitError;
6052
5530
  }
6053
5531
  function needsRelogin(error) {
6054
5532
  return error.code === "NOT_LOGGED_IN" || error.code === "AUTH_UNAUTHORIZED";
@@ -6217,7 +5695,7 @@ async function fetchTemplates(server) {
6217
5695
 
6218
5696
  // packages/cli/src/commands/init.ts
6219
5697
  function registerInit(program2, ctx) {
6220
- program2.command("init").description("\u521D\u59CB\u5316\u9879\u76EE\uFF08\u6A21\u677F\uFF1Aempty / function / widget / page\uFF09\uFF0C\u6216 --list \u4ECE\u5E73\u53F0\u53D6\u6A21\u677F\u6E05\u5355").argument("[name]", "\u9879\u76EE\u76EE\u5F55\u540D\uFF08\u914D\u5408 --list \u65F6\u53EF\u7701\u7565\uFF09").option("-t, --template <template>", "\u6A21\u677F\uFF1Aempty | function | widget | page", "function").option("-l, --list", "\u4ECE\u5E73\u53F0 /api/v1/templates \u5217\u51FA\u53EF\u7528\u6A21\u677F\uFF08\u4E0D\u811A\u624B\u67B6\uFF09", false).option(
5698
+ program2.command("init").description("\u521D\u59CB\u5316\u9879\u76EE\uFF08\u6A21\u677F\uFF1Aempty / function / fullstack\uFF09\uFF0C\u6216 --list \u4ECE\u5E73\u53F0\u53D6\u6A21\u677F\u6E05\u5355").argument("[name]", "\u9879\u76EE\u76EE\u5F55\u540D\uFF08\u914D\u5408 --list \u65F6\u53EF\u7701\u7565\uFF09").option("-t, --template <template>", "\u6A21\u677F\uFF1Aempty | function | fullstack", "fullstack").option("-l, --list", "\u4ECE\u5E73\u53F0 /api/v1/templates \u5217\u51FA\u53EF\u7528\u6A21\u677F\uFF08\u4E0D\u811A\u624B\u67B6\uFF09", false).option(
6221
5699
  "-s, --server <url>",
6222
5700
  "\u5E73\u53F0\u5730\u5740\uFF08--list \u7528\uFF1B\u7F3A\u7701\u8BFB ADEP_SERVER \u6216 http://localhost:3000\uFF09"
6223
5701
  ).action(
@@ -6803,47 +6281,6 @@ function registerExport(program2, ctx) {
6803
6281
  );
6804
6282
  }
6805
6283
 
6806
- // packages/cli/src/commands/widget.ts
6807
- function registerWidget(program2, ctx) {
6808
- const widget = program2.command("widget").description("\u5FAE\u524D\u7AEF\u7EC4\u4EF6\uFF08widget\uFF09\uFF1A\u811A\u624B\u67B6 / \u672C\u5730\u6C99\u7BB1 / \u53D1\u5E03");
6809
- widget.command("init").description("\u521D\u59CB\u5316 widget \u5DE5\u7A0B\uFF08\u6A21\u677F\uFF1Avue3-ts / react-ts\uFF09").argument("<name>", "widget \u540D\u79F0\uFF08\u5C0F\u5199\u5B57\u6BCD\u5F00\u5934\uFF0C\u4EC5\u5C0F\u5199\u5B57\u6BCD/\u6570\u5B57/\u8FDE\u5B57\u7B26\uFF09").option("-t, --template <template>", "\u6A21\u677F\uFF1Avue3-ts | react-ts", "vue3-ts").action(async (name, flags) => {
6810
- const command = ctx.io("widget init");
6811
- await command.run(async () => {
6812
- const { initWidget: initWidget2 } = await Promise.resolve().then(() => (init_init(), init_exports));
6813
- const result = await initWidget2(ctx.cwd, name, flags.template);
6814
- command.ok(
6815
- result,
6816
- (data) => `\u5DF2\u521B\u5EFA widget ${data.projectPath}`
6817
- );
6818
- });
6819
- });
6820
- widget.command("dev").description("\u672C\u5730\u5BBF\u4E3B\u6C99\u7BB1\uFF1A\u4E3B\u9898\u53D8\u91CF + mock props + token \u6CE8\u5165 + \u70ED\u66F4\u65B0").option("-p, --port <port>", "\u76D1\u542C\u7AEF\u53E3\uFF08\u7F3A\u7701 8788\uFF09", "8788").action(async (flags) => {
6821
- const command = ctx.io("widget dev");
6822
- await command.run(async () => {
6823
- const { startWidgetDev: startWidgetDev2 } = await Promise.resolve().then(() => (init_dev2(), dev_exports2));
6824
- const started = await startWidgetDev2({ cwd: ctx.cwd, port: Number(flags.port ?? "8788") });
6825
- command.raw(
6826
- `[adep] widget dev sandbox on ${started.baseUrl}\uFF08?token=<...> \u6CE8\u5165\u9274\u6743 token\uFF1BCtrl-C \u9000\u51FA\uFF09`
6827
- );
6828
- await new Promise(() => void 0);
6829
- });
6830
- });
6831
- widget.command("publish").description("\u6309\u6846\u67B6\u6784\u5EFA \u2192 \u4E0A\u4F20\u5E73\u53F0\u9759\u6001\u8D44\u6E90 \u2192 \u7248\u672C\u5316\u8F93\u51FA URL").requiredOption("-p, --project <slug>", "\u76EE\u6807\u5E73\u53F0\u9879\u76EE slug").action(async (flags) => {
6832
- const command = ctx.io("widget publish");
6833
- await command.run(async () => {
6834
- const { publishWidget: publishWidget2 } = await Promise.resolve().then(() => (init_publish(), publish_exports));
6835
- const result = await publishWidget2(ctx.paths, {
6836
- cwd: ctx.cwd,
6837
- project: flags.project
6838
- });
6839
- command.ok(result, (data) => {
6840
- const r = data;
6841
- return `${r.name} v${r.version} ${r.url}`;
6842
- });
6843
- });
6844
- });
6845
- }
6846
-
6847
6284
  // packages/cli/src/cli.ts
6848
6285
  var requireJson = createRequire(import.meta.url);
6849
6286
  var APP_VERSION = requireJson("../package.json").version;
@@ -6869,7 +6306,6 @@ function buildProgram(options = {}) {
6869
6306
  registerStorage(program2, ctx);
6870
6307
  registerHosting(program2, ctx);
6871
6308
  registerExport(program2, ctx);
6872
- registerWidget(program2, ctx);
6873
6309
  return program2;
6874
6310
  }
6875
6311