openyida 2026.11.2 → 2026.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +11 -9
  2. package/bin/yida.js +2 -1
  3. package/lib/app/application-entry-urls.js +35 -1
  4. package/lib/app/check-prd-completeness.js +27 -6
  5. package/lib/app/create-app.js +17 -9
  6. package/lib/app/fast-build.js +151 -0
  7. package/lib/app/fast-theme.js +83 -0
  8. package/lib/app/form-data-contract.js +162 -0
  9. package/lib/app/services/canvas-page-schema-builder.js +10 -0
  10. package/lib/asset/ai-image.js +8 -5
  11. package/lib/asset/asset-cmd.js +24 -4
  12. package/lib/asset/asset-execution.js +25 -4
  13. package/lib/asset/asset-plan.js +4 -2
  14. package/lib/asset/asset-resolve.js +21 -7
  15. package/lib/auth/oauth-loopback.js +1 -1
  16. package/lib/auth/org.js +2 -0
  17. package/lib/auth/token-auth.js +1 -0
  18. package/lib/core/agent-capabilities.js +30 -9
  19. package/lib/core/batch.js +71 -122
  20. package/lib/core/command-manifest.js +71 -38
  21. package/lib/core/locales/en.js +20 -4
  22. package/lib/core/locales/zh.js +19 -3
  23. package/lib/core/permission-guidance.js +10 -10
  24. package/lib/core/query-data.js +67 -10
  25. package/lib/core/sample.js +73 -0
  26. package/lib/core/task-concurrency.js +96 -0
  27. package/lib/corp-efficiency/corp-efficiency.js +15 -8
  28. package/lib/design/fast-document.js +118 -0
  29. package/lib/design-plan/design-plan.js +3 -3
  30. package/lib/design-plan/init.js +90 -5
  31. package/lib/design-plan/materialize.js +2 -2
  32. package/lib/design-plan/validate.js +64 -9
  33. package/lib/flash-note/build-flash-note-prompt.js +1 -1
  34. package/lib/samples/openyida-scaffold/canvas-data-source.jsx +135 -0
  35. package/lib/samples/openyida-scaffold/canvas-file-upload.jsx +106 -0
  36. package/lib/samples/openyida-scaffold/file-upload-client.jsx +160 -0
  37. package/lib/samples/yida-app/fast-app.json +64 -0
  38. package/lib/samples/yida-design/fast-design.json +38 -0
  39. package/package.json +3 -3
  40. package/scripts/postinstall.js +6 -6
  41. package/yida-skills/SKILL.md +10 -9
  42. package/yida-skills/references/official-example-schema-patterns.md +3 -3
  43. package/yida-skills/references/qwenwork-link-presentation.md +11 -16
  44. package/yida-skills/references/user-facing-summary.md +1 -1
  45. package/yida-skills/skills/yida-app/SKILL.md +23 -12
  46. package/yida-skills/skills/yida-app/references/fast-context.md +7 -0
  47. package/yida-skills/skills/yida-app/workflow/fast-build.md +65 -0
  48. package/yida-skills/skills/yida-app/workflow/parallel-work.md +15 -5
  49. package/yida-skills/skills/yida-app/workflow/plan/workflow.md +5 -1
  50. package/yida-skills/skills/yida-app/workflow/step-2-design.md +13 -6
  51. package/yida-skills/skills/yida-app/workflow/step-3-create-or-reuse-app.md +7 -2
  52. package/yida-skills/skills/yida-app/workflow/step-4-forms-processes.md +4 -1
  53. package/yida-skills/skills/yida-app/workflow/step-5-seed-records.md +4 -1
  54. package/yida-skills/skills/yida-app/workflow/step-6-main-page.md +3 -0
  55. package/yida-skills/skills/yida-app/workflow/step-7-page-code.md +5 -2
  56. package/yida-skills/skills/yida-app/workflow/step-8-publish-navigation.md +3 -0
  57. package/yida-skills/skills/yida-app/workflow/step-9-output-finish.md +7 -2
  58. package/yida-skills/skills/yida-canvas-custom-page/SKILL.md +14 -4
  59. package/yida-skills/skills/yida-canvas-custom-page/references/data-bridge-guide.md +2 -0
  60. package/yida-skills/skills/yida-canvas-custom-page/references/file-upload.md +75 -0
  61. package/yida-skills/skills/yida-canvas-custom-page/references/native-components-bridge.md +4 -3
  62. package/yida-skills/skills/yida-canvas-custom-page/references/page-generation-guide.md +1 -1
  63. package/yida-skills/skills/yida-canvas-data-binding/SKILL.md +23 -82
  64. package/yida-skills/skills/yida-corp-efficiency/SKILL.md +3 -3
  65. package/yida-skills/skills/yida-create-app/SKILL.md +9 -5
  66. package/yida-skills/skills/yida-create-form-page/SKILL.md +1 -1
  67. package/yida-skills/skills/yida-create-form-page/references/field-definition-guide.md +1 -1
  68. package/yida-skills/skills/yida-create-form-page/references/form-field-properties.md +13 -17
  69. package/yida-skills/skills/yida-custom-page/SKILL.md +2 -0
  70. package/yida-skills/skills/yida-custom-page/references/attachment-upload-guide.md +4 -0
  71. package/yida-skills/skills/yida-data-management/SKILL.md +2 -0
  72. package/yida-skills/skills/yida-data-management/references/data-format-guide.md +9 -0
  73. package/yida-skills/skills/yida-design/SKILL.md +7 -2
  74. package/yida-skills/skills/yida-design/references/application-theme-consistency.md +4 -4
  75. package/yida-skills/skills/yida-design/references/ask-human-interaction-contract.md +2 -2
  76. package/yida-skills/skills/yida-design/references/design-mode.md +4 -2
  77. package/yida-skills/skills/yida-design/references/fast-design-spec.md +32 -0
  78. package/yida-skills/skills/yida-design/references/native-form-styles.md +2 -2
  79. package/yida-skills/skills/yida-design/templates/design-themes/app-teal/design.md +4 -4
  80. package/yida-skills/skills/yida-design/templates/design-themes/app-terminal/design.md +4 -4
  81. package/yida-skills/skills/yida-design/workflow/output-design.md +1 -1
  82. package/yida-skills/skills/yida-design/workflow/step-4-wireframe-interaction.md +1 -1
  83. package/yida-skills/skills/yida-design/workflow/step-6-handoff.md +1 -1
  84. package/yida-skills/skills/yida-dingtalk-openapi/references/api-contract.md +1 -1
  85. package/yida-skills/skills/yida-flash-note-to-prd/references/flash-note-prompt.md +1 -1
  86. package/yida-skills/skills/yida-image-assets/SKILL.md +11 -5
  87. package/yida-skills/skills/yida-login/SKILL.md +6 -0
  88. package/yida-skills/skills/yida-ppt-slider/references/examples.md +3 -3
  89. package/yida-skills/skills/yida-prd/SKILL.md +5 -1
  90. package/yida-skills/skills/yida-publish-page/SKILL.md +3 -0
  91. package/yida-skills/skills/yida-requirement-analysis/SKILL.md +4 -1
  92. package/yida-skills/skills/yida-requirement-analysis/references/handoff.md +4 -1
  93. package/yida-skills/skills/yida-requirement-analysis/workflow/prepare-brief.md +3 -0
  94. package/yida-skills/skills-index.json +2 -2
package/README.md CHANGED
@@ -4,9 +4,9 @@
4
4
 
5
5
  # OpenYida
6
6
 
7
- **AI-native CLI for building DingTalk Yida low-code applications.**
7
+ **AI-native CLI for building applications with AI Yida.**
8
8
 
9
- OpenYida connects AI coding agents with Yida's low-code platform, so developers can create apps, forms, workflows, custom pages, reports, integrations, and deployment configuration from a normal chat-driven development workflow.
9
+ OpenYida connects AI coding agents with AI Yida, so developers can create apps, forms, workflows, custom pages, reports, integrations, and deployment configuration from a normal chat-driven development workflow.
10
10
 
11
11
  [Quick Start](#quick-start) · [帮助网站&文档](https://demo.aliwork.com/o/openyida/helpCenter) · [Capabilities](#capabilities) · [Full Capability List](https://demo.aliwork.com/o/openyida/helpCenter?openyidaPath=capabilities) · [CLI Reference](https://demo.aliwork.com/o/openyida/helpCenter?openyidaPath=features/skills) · [Examples](https://demo.aliwork.com/o/openyida/helpCenter?openyidaRoute=showcase) · [Contributing](./CONTRIBUTING.md) · [Changelog](https://demo.aliwork.com/o/openyida/helpCenter?openyidaRoute=changelog) · [Application Previews](#application-previews)
12
12
 
@@ -261,7 +261,9 @@ openyida publish pages/src/home.canvas.jsx APP_XXX FORM_XXX
261
261
 
262
262
  Custom page source is authored directly from PRD and design guidance. Custom page development uses `yida-canvas-custom-page` and `.canvas.jsx`.
263
263
 
264
- For member, department, attachment, and image upload components, `.canvas.jsx` pages should follow `yida-canvas-custom-page/references/native-components-bridge.md` for feature detection, fallback, and value normalization.
264
+ For member and department components, `.canvas.jsx` pages should follow `yida-canvas-custom-page/references/native-components-bridge.md` for feature detection, fallback, and value normalization. Attachment and image uploads use the automatically installed `window.__OPENYIDA_FILE_API__` bridge (`upload`, `getDownloadUrl`, `bindFiles`): obtain credentials, upload to OSS, confirm, get private URLs, then bind to the saved instance. This requires a signed-in browser session and does not support anonymous uploads. See `yida-canvas-custom-page/references/file-upload.md`.
265
+
266
+ Extract the upload control with `openyida sample openyida-page-template canvas-file-upload`. Legacy JSX pages can extract the shared client with `openyida sample openyida-page-template file-upload-client` and call `createYidaFileClient(window)`.
265
267
 
266
268
  For the current custom page native-component support matrix, see [Yida native components supported by custom pages](https://demo.aliwork.com/o/openyida/sample/canvas-native-components).
267
269
 
@@ -472,7 +474,7 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
472
474
  | `openyida login [--qwenwork] [target-url] [--env <name>\|--intl\|--overseas\|--global\|--yidaapps\|--alibaba] [--client-id <clientId>] [--endpoint <url>] [--no-browser]` | Login with OAuth token mode |
473
475
  | `openyida logout` | Logout / unbind current project auth |
474
476
  | `openyida auth <status\|login\|refresh\|logout\|profiles\|profile switch\|qwenwork user-info> [--json]` | Token login state and profile management |
475
- | `openyida org <list\|switch> [--json] [--corp-id <corpId>]` | Organization management (list / switch existing profiles first) |
477
+ | `openyida org <list\|switch> [--json] [--corp-id <corpId>] [--no-browser]` | Organization management (list / switch existing profiles first) |
476
478
  | `openyida env [--json\|setup\|list\|show\|switch\|add\|remove] [options]` | Detect AI tool environment & token login state |
477
479
 
478
480
  ### App Management
@@ -488,8 +490,8 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
488
490
  | `openyida app-list [--type managed\|created] [--page N] [--size N]` | Page through apps I manage or created |
489
491
  | `openyida solution-template <search\|detail\|prepare\|ai-build\|enable\|status> [templateId\|requestId] [options] [--json]` | Solution templates for independent local agents: discovery, cloud AI handoff and direct enable |
490
492
  | `openyida corp-efficiency [overview\|details\|detail\|groups\|notify] [options] [--open\|--no-open]` | Query enterprise efficiency overview and detail reports |
491
- | `openyida create-app "<name>"\|--name <name> [options] [--locale zh_CN\|en_US\|ja_JP] [--open\|--no-open]` | Create a Yida app |
492
- | `openyida design-plan catalog [--json]` | List available planning themes and page patterns |
493
+ | `openyida create-app "<name>"\|--name <name> [options] [--locale zh_CN\|en_US\|ja_JP] [--open\|--no-open] [--json]` | Create a Yida app |
494
+ | `openyida design-plan catalog [--compact] [--json]` | List available planning themes and page patterns |
493
495
  | `openyida design-plan init <requirement-brief.json> [--theme-id <id>] [--output-dir <dir>] [--json]` | Initialize a plan draft from confirmed requirements |
494
496
  | `openyida design-plan preview <build-plan.json> --part-file <module.json> [--json]` | Update plan drafts by module |
495
497
  | `openyida design-plan materialize <build-plan.json> [--from-preview \| --business-file <json> --visual-file <json>] [--output-dir <dir>] [--rebase-parts] [--check] [--json]` | Generate or update plan documents and theme with consistency checks |
@@ -532,7 +534,7 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
532
534
  | `openyida custom-button <list\|inspect\|options\|create\|update\|delete> <appType> <formUuid> [buttonUuid] [--config <file>] [--expected-hash <hash>] [--backup <file>] [--yes] [--json]` | Native custom buttons: inspect and configure form edits, automation flows and page links |
533
535
  | `openyida form-message <list\|inspect\|options\|create\|update\|delete> <appType> <formUuid> [messageId] [--config <file>] [--expected-hash <hash>] [--backup <file>] [--yes] [--json]` | Native form notifications: inspect triggers, recipients and templates, then safely maintain bindings |
534
536
  | `openyida get-schema <appType> <formUuid\|--all> [--summary-json\|--field-map-json\|--analysis-json]` | Get one form Schema or all form Schemas |
535
- | `openyida check-prd-completeness <prd.md> --app-type <appType> [--build-manifest <file>] [--json]` | Check resources, frontend menu hiding and application theme delivery |
537
+ | `openyida check-prd-completeness [<prd.md> \| --build-spec <build-context.json> \| --manifest-only] --app-type <appType> [--build-manifest <file>] [--json]` | Check resources, frontend menu hiding and application theme delivery |
536
538
  | `openyida check-design <design.md> [--prd <prd.md>] [--base-dir <dir>] [--json]` | Validate design documents, theme tokens and PRD handoff |
537
539
  | `openyida er <appType> [--format mermaid\|json] [--output file] [--include-system] [--include-pages]` | Export app entity relationship diagram |
538
540
  | `openyida create-page <appType> "<name>" [--mode dashboard] [--hide-nav] [--locale zh_CN\|en_US\|ja_JP] [--open\|--no-open]` | Create a custom display page |
@@ -636,7 +638,7 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
636
638
  | `openyida a2a <serve\|agent-card> [options]` | Start local read-only A2A adapter or print Agent Card |
637
639
  | `openyida bridge start [--token <pair-token>] [--port 6736] [--origin https://demo.aliwork.com] [--open\|--no-open]` | Start OpenYida local web bridge service |
638
640
  | `openyida copy [--force]` | Copy project working directory |
639
- | `openyida sample [--list] [<skill> <name>] [--output <file-or-directory>] [--var KEY=VALUE ...] [--design-file <design.md>] [--style-id <themeId\|free-creative>] [--theme-ids <id,...>] [--pop-art-context <explicit-request\|showcase>]` | Output code samples/templates |
641
+ | `openyida sample [--list] [<skill> <name>] [--output <file-or-directory>] [--var KEY=VALUE ...] [--design-file <design.md>] [--spec-file <spec.json>] [--primary-color <color>] [--tokens-file <theme.json>] [--nav-theme light\|dark] [--check] [--style-id <themeId\|free-creative>] [--theme-ids <id,...>] [--pop-art-context <explicit-request\|showcase>]` | Output code samples/templates |
640
642
  | `openyida doctor [--fix]` | Environment diagnostics & auto-fix |
641
643
  | `openyida db-seq-fix [--fix]` | Detect and repair PostgreSQL sequence drift |
642
644
  | `openyida formula evaluate <formula\|file> [--schema file] [--contract field-value\|validation-rule\|business-action\|node-expression] [--context form\|validation\|automation\|business] [--target-type NumberField] [--metadata file] [--strict] [--json]` | Static-check Yida formula syntax and field refs |
@@ -649,7 +651,7 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
649
651
  | `openyida update` | Check and update to latest version |
650
652
  | `openyida export-conversation [options]` | Export AI conversation records |
651
653
  | `openyida feedback <report\|github\|setup\|url\|dismiss\|status> [options]` | Prepare local issue reports, configure feedback forms and reminders |
652
- | `openyida batch <file>\|--commands "cmd1 ; cmd2" [--stop-on-error] [--json]` | Run OpenYida commands in batch |
654
+ | `openyida batch <file>\|--commands "cmd1 ; cmd2" [--concurrency 1..4] [--stop-on-error] [--json]` | Run OpenYida commands in batch |
653
655
  | `openyida flash-to-prd --file <path> --name "<project>"` | Convert flash notes or meeting notes to a PRD prompt |
654
656
  | `openyida ai <text\|image> [options]` | Call Yida AI text and image recognition APIs |
655
657
  | `openyida asset <status\|resolve\|sources> [options]` | Detect asset capability / resolve materials |
package/bin/yida.js CHANGED
@@ -1395,7 +1395,8 @@ async function main() {
1395
1395
 
1396
1396
  case 'batch': {
1397
1397
  const { run: runBatch } = require('../lib/core/batch');
1398
- await runBatch(args);
1398
+ const summary = await runBatch(args);
1399
+ if (summary?.success === false) { process.exitCode = 1; }
1399
1400
  break;
1400
1401
  }
1401
1402
 
@@ -62,4 +62,38 @@ function buildDisplayPageEntryUrls({ appType, formUuid, baseUrl, config, formTyp
62
62
  };
63
63
  }
64
64
 
65
- module.exports = { buildApplicationEntryUrls, buildApplicationSettingsUrls, buildDisplayPageEntryUrls, readRenderNav };
65
+ function preferredLinkPresentationTool(runtime = {}) {
66
+ return runtime.subtype === 'qwenwork_web' ? 'show_link'
67
+ : runtime.subtype === 'qwenwork_desktop' ? 'artifact_show_link' : null;
68
+ }
69
+
70
+ // A host action contract; CLI output cannot prove host tool execution.
71
+ function buildLinkPresentationCompletionGate() {
72
+ return {
73
+ host: 'qwenwork',
74
+ required_when: 'verified_target_and_available_host_link_tool_unless_user_excludes_target',
75
+ order: ['verify_business_result', 'select_verified_entry', 'call_host_link_tool', 'inspect_tool_result', 'final_reply'],
76
+ evidence: 'actual_host_tool_result_for_selected_url_in_current_turn',
77
+ not_evidence: ['create_app_success', 'resource_readback', 'markdown_link', 'sidebar_open', 'browser_handoff', 'previous_turn_tool_result'],
78
+ fallback: 'Only declared tool absence or an actual call failure permits clickable-link fallback. Record the evidence internally; an omitted call is not tool absence.',
79
+ enforcement_owner: 'host_agent',
80
+ };
81
+ }
82
+
83
+ function buildCreatedAppLinkPresentation(entry, runtime = {}) {
84
+ if (runtime.tool !== 'qwenwork' || !entry.adminUrl || !entry.appType) { return null; }
85
+ try {
86
+ const url = new URL(entry.adminUrl);
87
+ if (!['https:', 'http:'].includes(url.protocol) || url.pathname !== `/${entry.appType}/admin`) { return null; }
88
+ } catch { return null; }
89
+ return {
90
+ status: 'pending', timing: 'before_final_reply',
91
+ preferredTool: preferredLinkPresentationTool(runtime), toolAvailability: 'check_host_tool_inventory',
92
+ url: entry.adminUrl, title: entry.appName || entry.appType, maxCallsPerTurn: 1,
93
+ completionGate: buildLinkPresentationCompletionGate(),
94
+ instruction: 'Keep pending while building. Before final summary or delivery completion, call the host link tool once with this exact URL using its declared parameters, then inspect its result. App shells and partial deliveries also require this. --no-open does not cancel it. Honor user exclusions; never recreate the app for presentation.',
95
+ };
96
+ }
97
+
98
+ module.exports = { buildApplicationEntryUrls, buildApplicationSettingsUrls, buildDisplayPageEntryUrls, readRenderNav,
99
+ preferredLinkPresentationTool, buildLinkPresentationCompletionGate, buildCreatedAppLinkPresentation };
@@ -31,6 +31,8 @@ function parseArgs(args = [], options = {}) {
31
31
  if (options.strict && arg.startsWith('-')) {seen.add(key);}
32
32
  if (arg === '--help' || arg === '-h') {
33
33
  parsed.help = true;
34
+ } else if (arg === '--manifest-only') {
35
+ parsed.manifestOnly = true;
34
36
  } else if (arg === '--json') {
35
37
  parsed.json = true;
36
38
  } else if (APP_TYPE_OPTIONS.includes(arg) && args[index + 1] && (!options.strict || !args[index + 1].startsWith('-'))) {
@@ -39,6 +41,8 @@ function parseArgs(args = [], options = {}) {
39
41
  } else if ((arg === '--build-manifest' || arg === '--manifest') && args[index + 1] && (!options.strict || !args[index + 1].startsWith('-'))) {
40
42
  parsed.buildManifestPath = args[index + 1];
41
43
  index++;
44
+ } else if (arg === '--build-spec' && args[index + 1] && !args[index + 1].startsWith('-')) {
45
+ parsed.buildSpecPath = args[++index];
42
46
  } else if (!arg.startsWith(options.strict ? '-' : '--') && !parsed.prdPath) {
43
47
  parsed.prdPath = arg;
44
48
  } else if (options.strict) {
@@ -458,7 +462,15 @@ function matchResource(expected, actualResources) {
458
462
  async function evaluatePrdCompleteness(markdown, options = {}, deps = {}) {
459
463
  const appType = options.appType;
460
464
  const authRef = options.authRef || {};
461
- const parsedPrd = parsePrdMarkdown(markdown);
465
+ const fast = options.fastSpec;
466
+ const parsedPrd = fast ? {
467
+ resources: [...fast.resources, ...fast.pages.map(page => ({ ...page, type: 'display-page' }))]
468
+ .map(resource => ({ name: resource.name, type: resource.type, kind: resource.type, source: 'fast.resources' }))
469
+ .filter(resource => CHECKABLE_RESOURCE_KINDS.has(resource.kind)),
470
+ navigationVisibility: fast.navigationVisibility || [],
471
+ ...(fast.applicationTheme ? { applicationTheme: fast.applicationTheme } : {}),
472
+ } : options.manifestOnly ? { resources: [], navigationVisibility: options.buildManifest?.navigationVisibility || [],
473
+ ...(options.buildManifest?.applicationTheme ? { applicationTheme: options.buildManifest.applicationTheme } : {}) } : parsePrdMarkdown(markdown);
462
474
  const parsedManifest = parseBuildManifest(options.buildManifest);
463
475
  const items = [];
464
476
  const assetExecution = auditAssetExecution(options.buildManifest?.assetExecution, options.buildManifest?.assetTasks);
@@ -482,10 +494,11 @@ async function evaluatePrdCompleteness(markdown, options = {}, deps = {}) {
482
494
  prdPath: options.prdPath || '',
483
495
  buildManifestPath: options.buildManifestPath || '',
484
496
  sources: {
485
- prd: {
497
+ prd: fast || options.manifestOnly ? null : {
486
498
  mode: 'best_effort_hints',
487
499
  resources: parsedPrd.resources.length,
488
500
  },
501
+ ...(fast ? { buildSpec: { mode: 'execution_contract', path: options.buildSpecPath || '', resources: parsedPrd.resources.length } } : {}),
489
502
  buildManifest: options.buildManifest ? {
490
503
  mode: 'build_facts',
491
504
  path: options.buildManifestPath || '',
@@ -665,14 +678,19 @@ async function run(args = []) {
665
678
  if (parsed.help) {
666
679
  console.error(t('check_prd_completeness.usage'));
667
680
  console.error(t('check_prd_completeness.example'));
681
+ console.error('openyida check-prd-completeness --manifest-only --build-manifest <file> --app-type <appType> --json');
682
+ console.error('openyida check-prd-completeness --build-spec <build-context.json> --app-type <appType> [--build-manifest <file>] [--json]');
668
683
  return;
669
684
  }
670
- if (!parsed.prdPath || !parsed.appType) {
685
+ if ([!!parsed.prdPath, !!parsed.buildSpecPath, !!parsed.manifestOnly].filter(Boolean).length !== 1
686
+ || !parsed.appType || (parsed.manifestOnly && !parsed.buildManifestPath)) {
671
687
  throwUsage(t('check_prd_completeness.usage'), t('check_prd_completeness.example'));
672
688
  }
673
689
 
674
- const prdPath = path.resolve(parsed.prdPath);
675
- if (!fs.existsSync(prdPath)) {
690
+ const prdPath = parsed.prdPath ? path.resolve(parsed.prdPath) : '';
691
+ const buildSpecPath = parsed.buildSpecPath ? path.resolve(parsed.buildSpecPath) : '';
692
+ const fastSpec = buildSpecPath ? require('./fast-build').readFastBuild(buildSpecPath) : undefined;
693
+ if (prdPath && !fs.existsSync(prdPath)) {
676
694
  throwCommandError(t('check_prd_completeness.prd_not_found', prdPath), {
677
695
  code: 'PRD_COMPLETENESS_FILE_NOT_FOUND',
678
696
  });
@@ -686,11 +704,14 @@ async function run(args = []) {
686
704
  }
687
705
 
688
706
  console.error(t('check_prd_completeness.checking', parsed.appType));
689
- const markdown = fs.readFileSync(prdPath, 'utf8');
707
+ const markdown = prdPath ? fs.readFileSync(prdPath, 'utf8') : '';
690
708
  const buildManifest = loadBuildManifest(parsed.buildManifestPath);
691
709
  const result = await evaluatePrdCompleteness(markdown, {
692
710
  appType: parsed.appType,
693
711
  prdPath,
712
+ fastSpec,
713
+ manifestOnly: parsed.manifestOnly === true,
714
+ buildSpecPath,
694
715
  buildManifestPath: buildManifest ? buildManifest.path : '',
695
716
  buildManifest: buildManifest ? buildManifest.content : null,
696
717
  authRef,
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * create-app.js - 宜搭应用创建命令
3
3
  *
4
- * 用法:openyida create-app "<appName>" [description] [icon] [iconColor]
5
- * openyida create-app --name "<appName>" [--desc "<description>"]
4
+ * 用法:openyida create-app "<appName>" [description] [icon] [iconColor] [--json]
5
+ * openyida create-app --name "<appName>" [--desc "<description>"] [--json]
6
6
  */
7
7
 
8
8
  'use strict';
@@ -13,10 +13,11 @@ const querystring = require('querystring');
13
13
  const {
14
14
  httpPost,
15
15
  requestWithAutoLogin,
16
+ detectRuntimeCapabilities,
16
17
  } = require('../core/utils');
17
18
  const { createAuthRef } = require('../core/yida-client');
18
19
  const { t } = require('../core/i18n');
19
- const { buildApplicationEntryUrls } = require('./application-entry-urls');
20
+ const { buildApplicationEntryUrls, buildCreatedAppLinkPresentation } = require('./application-entry-urls');
20
21
  const { buildYidaI18n, normalizeYidaLocale, resolveContentLocale } = require('../core/yida-i18n');
21
22
  const { parseOpenOption, withBrowserHandoff } = require('../core/browser-handoff');
22
23
  const { throwCommandError } = require('../core/command-errors');
@@ -192,6 +193,9 @@ function parseCreateAppArgs(args, random = Math.random) {
192
193
  const arg = args[index];
193
194
 
194
195
  switch (arg) {
196
+ case '--json':
197
+ // Success already emits JSON on stdout; accept the explicit format flag.
198
+ break;
195
199
  case '--name':
196
200
  case '-n':
197
201
  params.appName = readOptionValue(args, index, arg);
@@ -316,16 +320,15 @@ async function run(args) {
316
320
  try {
317
321
  params = parseCreateAppArgs(args);
318
322
  } catch (err) {
319
- const { error: chalkError } = require('../core/chalk');
320
- chalkError(err.message, { hint: t('create_app.usage') });
323
+ throwCommandError(`${err.message}\n${t('create_app.usage')}`, { code: 'INVALID_ARGUMENTS' });
321
324
  }
322
325
 
323
326
  if (!params.appName) {
324
- const { error: chalkError } = require('../core/chalk');
325
- chalkError(t('create_app.usage'), { hint: t('create_app.example') });
327
+ throwCommandError(`${t('create_app.usage')}\n${t('create_app.example')}`, { code: 'INVALID_ARGUMENTS' });
326
328
  }
327
329
 
328
330
  const { appName, description, icon, iconColor } = params;
331
+ const runtime = typeof detectRuntimeCapabilities === 'function' ? detectRuntimeCapabilities() : {};
329
332
 
330
333
  const { c, banner, step, label, success: chalkSuccess, result: chalkResult } = require('../core/chalk');
331
334
 
@@ -374,6 +377,7 @@ async function run(args) {
374
377
  if (response && response.success && response.content) {
375
378
  const appType = response.content;
376
379
  const entryUrls = buildApplicationEntryUrls({ appType, baseUrl: authRef.baseUrl });
380
+ const linkPresentation = buildCreatedAppLinkPresentation({ appType, appName, ...entryUrls }, runtime);
377
381
  const appUrl = entryUrls.appUrl;
378
382
  const corpId = authRef.corpId || (authRef.authData && authRef.authData.corp_id) || '';
379
383
 
@@ -389,7 +393,8 @@ async function run(args) {
389
393
  themeVerification = { verified: true, appThemeMode: 'modern', source: theme.source,
390
394
  scope: 'configuration_readback', runtimeVerified: false };
391
395
  } catch (error) {
392
- const created = { appCreated: true, appType, corpId, url: appUrl, retryCreate: false,
396
+ const created = { appCreated: true, appType, corpId, url: appUrl, ...entryUrls,
397
+ ...(linkPresentation ? { linkPresentation } : {}), retryCreate: false,
393
398
  partial: true, residual: { appType, corpId }, retrySafe: false, mutationPerformed: true,
394
399
  sideEffectState: 'applied', readbackAllowed: true };
395
400
  if (isPermissionGuidanceError(error)) {
@@ -424,6 +429,7 @@ async function run(args) {
424
429
  themeVerification,
425
430
  url: appUrl,
426
431
  ...entryUrls,
432
+ ...(linkPresentation ? { linkPresentation } : {}),
427
433
  },
428
434
  appUrl,
429
435
  { stage: 'create_app_success', title: appName },
@@ -432,7 +438,9 @@ async function run(args) {
432
438
  } else {
433
439
  const errorMsg = response ? response.errorMsg || t('common.unknown_error') : t('common.request_failed');
434
440
  chalkResult(false, t('create_app.failed', errorMsg));
435
- console.log(JSON.stringify({ success: false, error: errorMsg }));
441
+ if (!args.includes('--json')) {
442
+ console.log(JSON.stringify({ success: false, error: errorMsg }));
443
+ }
436
444
  throwCommandError(errorMsg);
437
445
  }
438
446
  }
@@ -0,0 +1,151 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const crypto = require('crypto');
6
+ const { CliError } = require('../core/cli-error');
7
+ const { t } = require('../core/i18n');
8
+ const { renderFastDocument } = require('../design/fast-document');
9
+ const { generateThemeCss } = require('./theme-source');
10
+ const { writeFiles } = require('../design-plan/files');
11
+
12
+ const KIND = 'openyida-fast-build';
13
+ const object = value => value && typeof value === 'object' && !Array.isArray(value);
14
+ const filled = value => typeof value === 'string' && !!value.trim();
15
+ const sha = value => crypto.createHash('sha256').update(value).digest('hex');
16
+
17
+ function invalid(issues) {
18
+ throw new CliError(t('cli_argument.invalid', issues[0].path), {
19
+ code: 'FAST_BUILD_INVALID', details: { issues, stage: 'preflight', retrySafe: true, sideEffectState: 'not_started', mutationPerformed: false },
20
+ });
21
+ }
22
+
23
+ // These are declarations, not proof that platform resources or permissions exist.
24
+ function validateFastBuild(spec) {
25
+ const issues = [];
26
+ const add = (field, expected) => issues.push({ path: field, expected });
27
+ if (!object(spec)) {invalid([{ path: 'spec', expected: 'object' }]);}
28
+ if (spec.mode !== undefined && spec.mode !== 'fast') {add('mode', 'fast');}
29
+ if (spec.intake?.designMode !== undefined && spec.intake.designMode !== 'fast') {add('intake.designMode', 'fast');}
30
+ for (const field of ['resources', 'roles', 'businessRules', 'acceptanceChecks']) {
31
+ if (!Array.isArray(spec[field])) {add(field, 'array; use [] when not applicable');}
32
+ }
33
+ if (!Array.isArray(spec.pages)) {add('pages', 'array');}
34
+ if (Array.isArray(spec.acceptanceChecks) && (!spec.acceptanceChecks.length || !spec.acceptanceChecks.every(filled))) {
35
+ add('acceptanceChecks', 'nonempty string array');
36
+ }
37
+ if (Array.isArray(spec.businessRules) && !spec.businessRules.every(filled)) {add('businessRules', 'string array');}
38
+ const names = new Set(), keys = new Set();
39
+ const resources = Array.isArray(spec.resources) ? spec.resources : [];
40
+ for (const [i, resource] of resources.entries()) {
41
+ const field = `resources[${i}]`;
42
+ if (!object(resource)) {add(field, 'object'); continue;}
43
+ if (!filled(resource.key) || keys.has(resource.key)) {add(`${field}.key`, 'unique nonempty key');}
44
+ if (!filled(resource.name) || names.has(resource.name)) {add(`${field}.name`, 'unique nonempty name');}
45
+ keys.add(resource.key); names.add(resource.name);
46
+ if (!['normal-form', 'process-form', 'report', 'integration'].includes(resource.type)) {
47
+ add(`${field}.type`, 'normal-form | process-form | report | integration; display pages belong in pages');
48
+ }
49
+ if (['normal-form', 'process-form'].includes(resource.type) && !resource.formUuid
50
+ && (!Array.isArray(resource.fields) || !resource.fields.length || !resource.fields.every(object))) {
51
+ add(`${field}.fields`, 'nonempty field-definition array for a new form');
52
+ }
53
+ if (resource.formUuid !== undefined && !filled(resource.formUuid)) {add(`${field}.formUuid`, 'nonempty verified resource ID');}
54
+ if (resource.dependsOn !== undefined && (!Array.isArray(resource.dependsOn) || !resource.dependsOn.every(filled))) {
55
+ add(`${field}.dependsOn`, 'resource key array');
56
+ }
57
+ }
58
+ for (const [i, resource] of resources.entries()) {
59
+ for (const key of Array.isArray(resource?.dependsOn) ? resource.dependsOn : []) {
60
+ if (!keys.has(key) || key === resource.key) {add(`resources[${i}].dependsOn`, 'existing independent resource keys');}
61
+ }
62
+ }
63
+ const visited = new Set(), active = new Set();
64
+ const visit = key => {
65
+ if (active.has(key)) {add('resources.dependsOn', 'acyclic dependencies'); return;}
66
+ if (visited.has(key)) {return;}
67
+ active.add(key);
68
+ const resource = resources.find(item => item?.key === key);
69
+ for (const dep of Array.isArray(resource?.dependsOn) ? resource.dependsOn : []) {if (keys.has(dep)) {visit(dep);}}
70
+ active.delete(key); visited.add(key);
71
+ };
72
+ for (const key of keys) {visit(key);}
73
+ for (const [i, role] of (Array.isArray(spec.roles) ? spec.roles : []).entries()) {
74
+ if (!object(role) || !filled(role.name) || !filled(role.scope) || !Array.isArray(role.operations)
75
+ || !role.operations.length || !role.operations.every(filled)) {
76
+ add(`roles[${i}]`, { name: '<role>', scope: '<server-side data scope>', operations: ['<allowed business action>'] });
77
+ }
78
+ }
79
+ for (const [i, page] of (Array.isArray(spec.pages) ? spec.pages : []).entries()) {
80
+ if (!object(page)) {add(`pages[${i}]`, 'object'); continue;}
81
+ if (!filled(page.pageId) || !filled(page.name)) {add(`pages[${i}]`, 'nonempty pageId/name');}
82
+ if (names.has(page.name)) {add(`pages[${i}].name`, 'unique resource/page name');}
83
+ names.add(page.name);
84
+ if (page.dataSources !== undefined && (!Array.isArray(page.dataSources)
85
+ || !page.dataSources.every(key => keys.has(key)))) {add(`pages[${i}].dataSources`, 'existing resource key array');}
86
+ }
87
+ if (spec.navigationVisibility !== undefined && !Array.isArray(spec.navigationVisibility)) {add('navigationVisibility', 'array');}
88
+ if (spec.constraints !== undefined && !object(spec.constraints)) {add('constraints', 'object');}
89
+ if (spec.constraints?.prohibitedActions !== undefined && (!Array.isArray(spec.constraints.prohibitedActions)
90
+ || !spec.constraints.prohibitedActions.every(filled))) {add('constraints.prohibitedActions', 'string array');}
91
+ if (issues.length) {invalid(issues);}
92
+ return spec;
93
+ }
94
+
95
+ function readFastBuild(file) {
96
+ let context;
97
+ try {context = JSON.parse(fs.readFileSync(file, 'utf8'));} catch (error) {
98
+ invalid([{ path: file, expected: 'readable Fast build-context.json', reason: error.code || 'INVALID_JSON' }]);
99
+ }
100
+ if (context?.kind !== KIND || context?.schemaVersion !== '1.0' || context?.mode !== 'fast') {
101
+ invalid([{ path: file, expected: `${KIND} schemaVersion=1.0 mode=fast` }]);
102
+ }
103
+ validateFastBuild(context);
104
+ if (!Array.isArray(context.assetStrategy?.pages) || !object(context.themeProfile)) {
105
+ invalid([{ path: file, expected: 'generated assetStrategy and themeProfile' }]);
106
+ }
107
+ if (!context.constraints?.prohibitedActions?.includes('theme-file') && (!object(context.applicationTheme)
108
+ || !filled(context.applicationTheme.themeColor) || !['light', 'dark'].includes(context.applicationTheme.navTheme))) {
109
+ invalid([{ path: 'applicationTheme', expected: 'generated mandatory application theme contract' }]);
110
+ }
111
+ return context;
112
+ }
113
+
114
+ function prepareFastBuild(inputFile, outputDir, options = {}) {
115
+ const input = path.resolve(inputFile), dir = path.resolve(outputDir);
116
+ let bytes, spec;
117
+ try {bytes = fs.readFileSync(input); spec = JSON.parse(bytes);} catch (error) {
118
+ invalid([{ path: input, expected: 'readable Fast application JSON', reason: error.code || 'INVALID_JSON' }]);
119
+ }
120
+ validateFastBuild(spec);
121
+ const contextFile = path.join(dir, 'build-context.json'), themeFile = path.join(dir, 'app_theme.css');
122
+ // Reuse the strict visual compiler only in memory: no Markdown or plan output.
123
+ const { markdown, metadata } = renderFastDocument(spec, { outputDir: dir });
124
+ const skipTheme = spec.constraints?.prohibitedActions?.includes('theme-file');
125
+ const css = skipTheme ? undefined : generateThemeCss(markdown);
126
+ const themeProfile = { ...metadata.themeProfile, themeFile: skipTheme ? '' : themeFile,
127
+ themeDelivery: skipTheme ? 'current-app-theme' : 'app-custom-theme-file' };
128
+ const context = { ...spec, kind: KIND, schemaVersion: '1.0', mode: 'fast',
129
+ source: { path: input, sha256: sha(bytes) }, themeProfile,
130
+ ...(!skipTheme ? { applicationTheme: { required: true, source: 'fast-build',
131
+ themeFile, themeColor: themeProfile.themeColor, navTheme: themeProfile.navTheme } } : {}),
132
+ };
133
+ if (skipTheme) {delete context.applicationTheme;}
134
+ const files = [[contextFile, JSON.stringify(context, null, 2) + '\n'], ...(!skipTheme ? [[themeFile, css]] : [])];
135
+ for (const [file, content] of files) {
136
+ if (file === input) {invalid([{ path: file, expected: 'output distinct from input' }]);}
137
+ if (fs.existsSync(file) && fs.readFileSync(file, 'utf8') !== content) {
138
+ throw new CliError(t('design_document.invalid', file, 'OUTPUT_EXISTS'), { code: 'SAMPLE_OUTPUT_EXISTS' });
139
+ }
140
+ }
141
+ const assetTasks = require('../asset/asset-plan').buildAssetTasks(spec.assetStrategy, dir, { buildSpec: contextFile });
142
+ if (!options.check) {writeFiles(files.filter(([file]) => !fs.existsSync(file)));}
143
+ return { success: true, mode: 'fast', checkedOnly: options.check === true,
144
+ outputs: { context: contextFile, ...(!skipTheme ? { theme: themeFile } : {}) },
145
+ pages: spec.pages.map(({ pageId, name }) => ({ pageId, name })), resourceCount: spec.resources.length,
146
+ theme: { themeColor: themeProfile.themeColor, navTheme: themeProfile.navTheme, contentTone: themeProfile.contentTone },
147
+ assetTasks, ...(skipTheme ? { skipped: ['theme-file'] } : {}),
148
+ };
149
+ }
150
+
151
+ module.exports = { KIND, validateFastBuild, readFastBuild, prepareFastBuild };
@@ -0,0 +1,83 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const { CliError, isCliError } = require('../core/cli-error');
6
+ const { t } = require('../core/i18n');
7
+ const { loadThemeIndex, themeTemplatePath, themeNavTheme, resolveThemeColors } = require('../design-plan/themes');
8
+ const { parseDesignDocument, serializeDesignDocument, extractDesignTokens } = require('../design/document');
9
+ const { normalizeCssColorToHex } = require('./custom-theme');
10
+ const { generateThemeCss } = require('./theme-source');
11
+ const { validatePalette } = require('../design/palette-contrast');
12
+
13
+ function preflight(error) {
14
+ if (isCliError(error)) {
15
+ if (/^DESIGN_/.test(error.code)) {error.message = t('cli_argument.invalid', `app_theme.css (${error.code})`);}
16
+ error.details = { ...error.details, stage: 'preflight', retrySafe: true,
17
+ sideEffectState: 'not_started', mutationPerformed: false };
18
+ }
19
+ return error;
20
+ }
21
+
22
+ function invalid(field, expected, actual) {
23
+ throw preflight(new CliError(t('cli_argument.invalid', field), { code: 'FAST_THEME_INVALID',
24
+ details: { issues: [{ path: field, expected, ...(actual !== undefined ? { actual } : {}) }] } }));
25
+ }
26
+
27
+ // Theme-only generation: no business plan, page specification or Plan renderer.
28
+ function prepareFastTheme(options) {
29
+ let theme, color, css, palette, navTheme;
30
+ try {
31
+ theme = loadThemeIndex().themes.find(item => item.themeId === options.styleId);
32
+ if (!theme) {invalid('--style-id', 'themeId from design-plan catalog --compact', options.styleId);}
33
+ color = normalizeCssColorToHex(options.primaryColor);
34
+ if (!color) {invalid('--primary-color', 'CSS hex or rgb color', options.primaryColor);}
35
+ if (theme.themeId === 'app-pop' && !['explicit-request', 'showcase'].includes(options.popArtContext)) {
36
+ invalid('--pop-art-context', 'explicit-request | showcase');
37
+ }
38
+ let custom = {};
39
+ if (options.tokensFile) {
40
+ try {custom = JSON.parse(fs.readFileSync(path.resolve(options.tokensFile), 'utf8'));}
41
+ catch (error) {invalid('--tokens-file', 'readable theme-only JSON', error.code || 'INVALID_JSON');}
42
+ }
43
+ if (!custom || typeof custom !== 'object' || Array.isArray(custom) || (custom.tokens !== undefined
44
+ && (!custom.tokens || typeof custom.tokens !== 'object' || Array.isArray(custom.tokens)))) {
45
+ invalid('--tokens-file', '{ tokens: { "--token": "value" }, creativeDirection?: object }');
46
+ }
47
+ const parsed = parseDesignDocument(resolveThemeColors(fs.readFileSync(themeTemplatePath(theme), 'utf8')
48
+ .replace(/\{\{PRIMARY_COLOR\}\}/g, color)));
49
+ const tokens = { ...extractDesignTokens(parsed.metadata, { strict: false }), ...custom.tokens,
50
+ '--color-brand1-6': color };
51
+ for (const [name, value] of Object.entries(tokens)) {
52
+ if (!/^--[\w-]+$/.test(name) || typeof value !== 'string') {invalid(`tokens.${name}`, 'CSS variable string');}
53
+ }
54
+ navTheme = theme.mode === 'creative' ? options.navTheme : themeNavTheme(theme);
55
+ if (theme.mode !== 'creative' && options.navTheme !== undefined && options.navTheme !== navTheme) {
56
+ invalid('--nav-theme', `derived from ${theme.themeId}: ${navTheme}`, options.navTheme);
57
+ }
58
+ if (!['light', 'dark'].includes(navTheme)) {invalid('--nav-theme', 'light | dark for free-creative');}
59
+ if (theme.mode === 'creative') {require('./application-style').validateCreativeDirection(custom.creativeDirection, tokens);}
60
+ const markdown = serializeDesignDocument({ metadata: { tokens,
61
+ themeProfile: { sourceThemeId: theme.themeId, navTheme },
62
+ ...(parsed.metadata.applicationStyle ? { applicationStyle: parsed.metadata.applicationStyle } : {}),
63
+ ...(theme.mode === 'creative' ? { creativeDirection: custom.creativeDirection } : {}),
64
+ }, body: '' });
65
+ css = generateThemeCss(markdown);
66
+ const root = /^:root\s*\{([\s\S]*?)^\}/m.exec(css);
67
+ const actual = Object.fromEntries([...root[1].matchAll(/(--[\w-]+)\s*:\s*([^;]+);/g)].map(m => [m[1], m[2].trim()]));
68
+ palette = validatePalette({ ...tokens, ...actual }, { css });
69
+ } catch (error) {throw preflight(error);}
70
+ const output = path.resolve(options.output || '.cache/openyida/app_theme.css');
71
+ if (fs.existsSync(output) && fs.readFileSync(output, 'utf8') !== css) {
72
+ invalid('--output', 'new output path or identical existing stylesheet', output);
73
+ }
74
+ if (!options.check && !fs.existsSync(output)) {
75
+ fs.mkdirSync(path.dirname(output), { recursive: true });
76
+ fs.writeFileSync(output, css, { flag: 'wx' });
77
+ }
78
+ return { success: true, checkedOnly: options.check === true, themeId: theme.themeId,
79
+ outputs: { theme: output }, theme: { themeColor: color, navTheme }, paletteContrast: { status: palette.unresolved.length ? 'partial' : 'pass', checkedPairs: palette.checks.length, unresolved: palette.unresolved },
80
+ applicationTheme: { required: true, source: 'fast-theme', themeFile: output, themeColor: color, navTheme } };
81
+ }
82
+
83
+ module.exports = { prepareFastTheme, preflight };