openyida 2026.11.19 → 2026.11.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -548,7 +548,7 @@ When preparing a PR that needs a personal Fork, or when you ask how to support t
548
548
  | `openyida form-view <list\|inspect\|save\|create\|order\|rename\|add-button> <appType> <formUuid> [viewUuid] [--config <file>] [--name <title>] [--button <buttonUuid>] [--with-config] [--expected-hash <hash>] [--backup <file>] [--replace] [--json]` | Native form views: list, inspect and configure columns, widths, frozen columns and filters |
549
549
  | `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 |
550
550
  | `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 |
551
- | `openyida get-schema <appType> <formUuid\|--all> [--summary-json\|--field-map-json\|--analysis-json]` | Get one form Schema or all form Schemas |
551
+ | `openyida get-schema <appType> <formUuid\|--all> [--summary-json\|--field-map-json\|--analysis-json\|--canvas-source-dir <dir>]` | Get one form Schema or all form Schemas |
552
552
  | `openyida check-prd-completeness (<prd.md> [--build-manifest <file>] \| --build-spec <build-context.json> [--build-manifest <file>] \| --manifest-only --build-manifest <file>) --app-type <appType> [--json]` | Check resources, navigation visibility and application theme |
553
553
  | `openyida check-design <design.md> [--prd <prd.md>] [--base-dir <dir>] [--json]` | Validate design documents, theme tokens and PRD handoff |
554
554
  | `openyida er <appType> [--format mermaid\|json] [--output file] [--include-system] [--include-pages]` | Export app entity relationship diagram |
@@ -4,6 +4,7 @@
4
4
  * 用法:
5
5
  * openyida get-schema <appType> <formUuid> [--compact] [--resolve-fields <labelOrFieldId,...>]
6
6
  * openyida get-schema <appType> <formUuid> [--summary-json|--field-map-json|--analysis-json]
7
+ * openyida get-schema <appType> <formUuid> --canvas-source-dir <dir> [--json]
7
8
  * openyida get-schema <appType> --all [--summary-json|--analysis-json] [--output-dir <dir>] [--concurrency N] [--retries N]
8
9
  */
9
10
 
@@ -21,7 +22,7 @@ const {
21
22
  requestWithAutoLogin,
22
23
  } = require('../core/utils');
23
24
  const { t } = require('../core/i18n');
24
- const { throwCommandError } = require('../core/command-errors');
25
+ const { throwCommandError, throwUsage } = require('../core/command-errors');
25
26
  const { fetchFormPageList } = require('./form-navigation');
26
27
  const { buildFieldResolution } = require('./schema-field-resolution');
27
28
  const { buildSemanticAnalysis } = require('./schema-semantic-analysis');
@@ -251,7 +252,7 @@ function validateCodeBundleDescriptor(codeBundle) {
251
252
  return { bundleId, source, runtime };
252
253
  }
253
254
 
254
- function collectCodeBundleCanvases(content) {
255
+ function collectCanvasComponents(content) {
255
256
  const canvases = [];
256
257
  function traverse(node) {
257
258
  if (Array.isArray(node)) {
@@ -261,9 +262,8 @@ function collectCodeBundleCanvases(content) {
261
262
  if (!node || typeof node !== 'object') {
262
263
  return;
263
264
  }
264
- if (node.componentName === 'YidaCodeCanvas' && node.id && node.props
265
- && node.props.codeBundle && typeof node.props.codeBundle === 'object') {
266
- canvases.push({ props: node.props, descriptor: validateCodeBundleDescriptor(node.props.codeBundle) });
265
+ if (node.componentName === 'YidaCodeCanvas' && isComponentInstance(node)) {
266
+ canvases.push(node);
267
267
  }
268
268
  Object.values(node).forEach(traverse);
269
269
  }
@@ -271,6 +271,12 @@ function collectCodeBundleCanvases(content) {
271
271
  return canvases;
272
272
  }
273
273
 
274
+ function collectCodeBundleCanvases(content) {
275
+ return collectCanvasComponents(content)
276
+ .filter(node => node.id && node.props?.codeBundle && typeof node.props.codeBundle === 'object')
277
+ .map(({ props }) => ({ props, descriptor: validateCodeBundleDescriptor(props.codeBundle) }));
278
+ }
279
+
274
280
  async function downloadCodeBundleArtifact(appType, formUuid, bundleId, artifact, descriptor, authRef) {
275
281
  let responseMetadata = null;
276
282
  const expectedContentTypes = artifact === 'source'
@@ -477,6 +483,7 @@ function parseArgs(args) {
477
483
  formUuid: '',
478
484
  all: false,
479
485
  outputDir: '',
486
+ canvasSourceDir: '',
480
487
  concurrency: 3,
481
488
  retries: 1,
482
489
  keyword: '',
@@ -496,6 +503,12 @@ function parseArgs(args) {
496
503
  } else if (arg === '--output-dir' && args[index + 1]) {
497
504
  parsed.outputDir = args[index + 1];
498
505
  index++;
506
+ } else if (arg === '--canvas-source-dir' || arg.startsWith('--canvas-source-dir=')) {
507
+ const dir = arg === '--canvas-source-dir' ? args[++index] : arg.slice('--canvas-source-dir='.length);
508
+ if (!dir?.trim() || dir.startsWith('-')) {
509
+ throwUsage(t('get_schema.usage'), canvasExportUsage());
510
+ }
511
+ parsed.canvasSourceDir = dir;
499
512
  } else if ((arg === '--concurrency' || arg === '--parallel') && args[index + 1]) {
500
513
  parsed.concurrency = parsePositiveInt(args[index + 1], 3, 1, 10);
501
514
  index++;
@@ -543,6 +556,10 @@ function appendFieldQueries(target, value) {
543
556
  }
544
557
 
545
558
  function ensureUsage(parsed) {
559
+ if (parsed.canvasSourceDir && (!parsed.appType || !parsed.formUuid || parsed.all || parsed.outputDir
560
+ || parsed.compact || parsed.field || parsed.summaryJson || parsed.analysisJson)) {
561
+ throwUsage(t('get_schema.usage'), canvasExportUsage());
562
+ }
546
563
  if (!parsed.appType || (!parsed.all && !parsed.formUuid)) {
547
564
  const { error: chalkError } = require('../core/chalk');
548
565
  chalkError(t('get_schema.usage'), { hint: t('get_schema.example') });
@@ -554,6 +571,10 @@ function ensureUsage(parsed) {
554
571
  }
555
572
  }
556
573
 
574
+ function canvasExportUsage() {
575
+ return 'openyida get-schema <appType> <formUuid> --canvas-source-dir <dir> [--json]';
576
+ }
577
+
557
578
  /**
558
579
  * 从已解析好的字段列表中按 label 或 fieldId 精确匹配。
559
580
  * 优先按 label 完整匹配(区分大小写),未命中再按 fieldId 完整匹配。
@@ -806,6 +827,34 @@ function writeBatchOutput(outputDir, records, options = {}) {
806
827
  return indexRecords;
807
828
  }
808
829
 
830
+ function exportCanvasSource(parsed, result) {
831
+ const content = resolveSchemaContent(result);
832
+ const canvases = collectCanvasComponents(content.pages.map(page => page?.componentsTree));
833
+ const source = canvases[0]?.props?.code;
834
+ if (canvases.length !== 1 || typeof source !== 'string' || !source.trim()) {
835
+ throwCommandError(t('get_schema.canvas_source_unavailable'), {
836
+ code: 'CANVAS_SOURCE_UNAVAILABLE',
837
+ details: { formUuid: parsed.formUuid, canvasCount: canvases.length },
838
+ });
839
+ }
840
+
841
+ const outputDir = path.resolve(parsed.canvasSourceDir);
842
+ const schemaFile = path.join(outputDir, 'schema.json');
843
+ const sourceFile = path.join(outputDir, 'page.canvas.jsx');
844
+ const schema = JSON.stringify(result, null, 2) + '\n';
845
+ fs.mkdirSync(path.dirname(outputDir), { recursive: true });
846
+ fs.mkdirSync(outputDir, { mode: 0o700 });
847
+ try {
848
+ const options = { encoding: 'utf8', flag: 'wx', mode: 0o600 };
849
+ fs.writeFileSync(schemaFile, schema, options);
850
+ fs.writeFileSync(sourceFile, source, options);
851
+ } catch (error) {
852
+ fs.rmSync(outputDir, { recursive: true, force: true });
853
+ throw error;
854
+ }
855
+ return { success: true, appType: parsed.appType, formUuid: parsed.formUuid, schemaFile, sourceFile };
856
+ }
857
+
809
858
  async function runSingle(parsed, authRef) {
810
859
  const { banner, step, label, info, success: chalkSuccess, result: chalkResult } = require('../core/chalk');
811
860
 
@@ -846,6 +895,11 @@ async function runSingle(parsed, authRef) {
846
895
  result = await resolveCodeBundleSchema(result, parsed.appType, parsed.formUuid, authRef);
847
896
  }
848
897
 
898
+ if (parsed.canvasSourceDir) {
899
+ console.log(JSON.stringify(exportCanvasSource(parsed, result), null, 2));
900
+ return;
901
+ }
902
+
849
903
  // 保留既有 --field 返回结构;新 contract 仅由 --compact / --resolve-fields 触发。
850
904
  if (parsed.field) {
851
905
  const allFieldNodes = collectFieldNodes(result);
@@ -398,6 +398,7 @@ const COMMAND_SIDE_EFFECTS = new Map([
398
398
  ['connector.connection', sideEffect('mixed', { mutates_yida: true, mutates_local: false,
399
399
  read_actions: ['detail'], mutating_actions: ['update'] })],
400
400
  ['formula.functions', sideEffect('remote_read', { mutates_local: true })],
401
+ ['get-schema', sideEffect('remote_read', { mutates_local: true })],
401
402
  ['formula.types', sideEffect('remote_read')],
402
403
  ['formula.inspect', sideEffect('remote_read')],
403
404
  ['formula.test', sideEffect('remote_read')],
@@ -464,7 +465,6 @@ const COMMAND_SIDE_EFFECTS = new Map([
464
465
  'get-form-config',
465
466
  'get-page-config',
466
467
  'get-permission',
467
- 'get-schema',
468
468
  'integration.check',
469
469
  'integration.detail-log',
470
470
  'integration.list',
@@ -1740,8 +1740,12 @@ const COMMAND_GROUPS = [
1740
1740
  examples: ['openyida form-message options APP_XXX FORM_XXX --json', 'openyida form-message create APP_XXX FORM_XXX --config message.json --json'],
1741
1741
  notes: ['Manages native form-level message notification bindings, not application settings, custom-page messaging or integration automation. list and inspect preserve native configurations. create and update currently support verified immediate events for ordinary forms and seven native templates; scheduled and process-node writes are rejected until their rule and process context can be verified. The platform exposes no independent enable/disable state, so deletion is the only supported removal action and requires --yes plus the current inspect hash. Writes back up first, detect concurrent changes and require readback; requests are never replayed automatically. Saving a binding does not send a test message or prove delivery. See docs/guides/form-messages.md.'],
1742
1742
  }),
1743
- command('get-schema', ['get-schema'], 'get-schema <appType> <formUuid|--all> [--summary-json|--field-map-json|--analysis-json]', 'help.cmd_get_schema', { taskConcurrency: {'kind':'read','forbiddenFlags':['--output-dir','--output','-o']}, managedRun: { scope: 'app', appPosition: 0 },
1744
- examples: ['openyida get-schema APP_XXX FORM_XXX --field-map-json'],
1743
+ command('get-schema', ['get-schema'], 'get-schema <appType> <formUuid|--all> [--summary-json|--field-map-json|--analysis-json|--canvas-source-dir <dir>]', 'help.cmd_get_schema', { taskConcurrency: { kind: 'read', forbiddenFlags: ['--output-dir', '--output', '-o', '--canvas-source-dir'] }, managedRun: { scope: 'app', appPosition: 0 },
1744
+ examples: [
1745
+ 'openyida get-schema APP_XXX FORM_XXX --field-map-json',
1746
+ 'openyida get-schema APP_XXX FORM_XXX --canvas-source-dir .cache/openyida/page-snapshot --json',
1747
+ ],
1748
+ notes: ['For a single page with one editable YidaCodeCanvas, --canvas-source-dir saves schema.json and page.canvas.jsx in a new local directory and prints their paths as JSON. It cannot be combined with batch, field or analysis modes. Existing paths are preserved.'],
1745
1749
  }),
1746
1750
  command('check-prd-completeness', ['check-prd-completeness'], 'check-prd-completeness (<prd.md> [--build-manifest <file>] | --build-spec <build-context.json> [--build-manifest <file>] | --manifest-only --build-manifest <file>) --app-type <appType> [--json]', 'help.cmd_check_prd_completeness', { managedRun: { scope: 'app', appParser: 'prd-completeness' },
1747
1751
  args: [
@@ -1001,6 +1001,7 @@ Examples:
1001
1001
 
1002
1002
  // ── lib/get-schema.js ──────────────────────────────
1003
1003
  get_schema: {
1004
+ canvas_source_unavailable: 'Export requires a page with one YidaCodeCanvas component and editable source. Check the page type and source in the designer.',
1004
1005
  title: ' openyida get-schema - Yida Form Schema Tool',
1005
1006
  usage: 'Usage: openyida get-schema <appType> <formUuid> or openyida get-schema <appType> --all [--output-dir <dir>]',
1006
1007
  example: 'Example: openyida get-schema "APP_XXX" "FORM-XXX"; openyida get-schema "APP_XXX" --all --output-dir .cache/schemas',
@@ -972,6 +972,7 @@ openyida - 宜搭命令行工具
972
972
 
973
973
  // ── lib/get-schema.js ──────────────────────────────
974
974
  get_schema: {
975
+ canvas_source_unavailable: '导出需要页面包含一个 YidaCodeCanvas 组件,且平台返回可编辑源码。请确认页面类型和设计器中的源码。',
975
976
  title: ' openyida get-schema - 宜搭表单 Schema 获取工具',
976
977
  usage: '用法: openyida get-schema <appType> <formUuid> 或 openyida get-schema <appType> --all [--output-dir <dir>]',
977
978
  example: '示例: openyida get-schema "APP_XXX" "FORM-XXX";openyida get-schema "APP_XXX" --all --output-dir .cache/schemas',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openyida",
3
- "version": "2026.11.19",
3
+ "version": "2026.11.20",
4
4
  "description": "OpenYida CLI - AI 宜搭应用开发工具(安装即用,零配置)",
5
5
  "bin": {
6
6
  "openyida": "bin/yida.js",
@@ -220,6 +220,7 @@ Fast / Plan 选定的主题和主色属于整个应用:导航、原生页、
220
220
  | 提交后跨表写入/更新/删除 | 默认 `yida-integration`;用户明确要业务关联规则/高级函数时用 `yida-business-rule` |
221
221
  | 集成自动化定时、字段变化触发、并行循环、批量取数及生命周期管理 | `yida-integration` 的 `--spec` 路径,读取 `references/batch-data.md`;已有自动化按其更新能力处理 |
222
222
  | 自定义页面开发 | `yida-canvas-custom-page`,新建和默认页面源码开发入口,源码使用 `.canvas.jsx`;Canvas 发布层会自动注入 `window.__OPENYIDA_YIDA_API__` 和 `window.__OPENYIDA_UTILS__` |
223
+ | 给已有 Canvas 页面加按钮、改交互或恢复本地缺失的源码 | 先用 `yida-openyida-publish-guard` 导出目标页源码和 Schema,再用 `yida-canvas-custom-page` 做局部修改 |
223
224
  | JSX 自定义页面开发 | `yida-custom-page`,仅用于已检测到的 `.oyd.jsx` / `.oyb.jsx` / `renderJsx` / 平台 `Jsx` 组件页面维护 |
224
225
  | `.canvas.jsx` 页面使用成员/部门/门户等宜搭运行态组件 | `yida-canvas-custom-page`,读取 `native-components-bridge.md` |
225
226
  | 自定义页面需要上传附件或图片 | `yida-canvas-custom-page`,必读 `references/file-upload.md`,提取 `canvas-file-upload` 示例;使用 OpenAPI 文件桥完成真实上传、确认和保存后绑定,仅支持登录用户 |
@@ -61,6 +61,7 @@ description: 确定性解析表单字段 ID、子表路径和表单行为语义
61
61
  openyida get-schema <appType> <formUuid> --compact [--resolve-fields <labelOrFieldId,...>]
62
62
  openyida get-schema <appType> <formUuid> [--summary-json|--field-map-json]
63
63
  openyida get-schema <appType> <formUuid> --analysis-json
64
+ openyida get-schema <appType> <formUuid> --canvas-source-dir <dir> --json
64
65
  openyida get-schema <appType> --all [--summary-json|--analysis-json] [--output-dir <dir>] [--keyword <text>] [--concurrency N] [--retries N]
65
66
  ```
66
67
 
@@ -79,6 +80,7 @@ openyida get-schema <appType> --all [--summary-json|--analysis-json] [--output-d
79
80
  | `--retries N` | 否 | 单个 Schema 失败后的重试次数,默认 1,范围 0-5 |
80
81
  | `--summary-json` / `--field-map-json` | 否 | 只输出字段摘要 JSON,不把完整 Schema 放入 stdout;`--field-map-json` 是语义别名 |
81
82
  | `--analysis-json` | 否 | 输出 `yida_schema_semantic_analysis` contract v1:字段摘要、动作函数/绑定、URL 参数、字段 mutation、只读/隐藏、校验、公式/联动、关联和数据源摘要;不回显动作源码 |
83
+ | `--canvas-source-dir <dir>` | 否 | 导出一个 Canvas 页面的源码和完整 Schema 到新目录,stdout 返回文件路径;单独使用,不与批量或字段分析模式混用 |
82
84
 
83
85
  ### 单表模式
84
86
 
@@ -94,6 +96,8 @@ Agent 只需要少量字段 ID 时,默认使用 `--compact --resolve-fields`
94
96
 
95
97
  反向分析时读取 `--analysis-json`,重点区分:源码字节数大不等于业务行为多;以 `urlParams`、`fieldMutations`、动作绑定、字段行为、关联规则和数据源摘要判断业务语义。需要等价迁移时,把字段结构与行为结构分别交给 `yida-create-form-page`,不要把缺失行为误报成“字段已创建所以表单完成”。
96
98
 
99
+ 修改已有 Canvas 页面时,加载 `use_skill("yida-openyida-publish-guard")`,用 `--canvas-source-dir` 取得 `page.canvas.jsx` 与 `schema.json`。目录应尚未存在。页面必须有一个可取回源码的 `YidaCodeCanvas` 组件。
100
+
97
101
  消费输出时读取完整 JSON,再由 agent / 脚本解析字段;不要用 `tail -20`、`head -30` 或 `grep` 只看局部 stdout。局部查看可以作为人工调试,但不能作为后续写页面、写数据或配置流程的字段证据。
98
102
 
99
103
  如需复用输出,使用 agent 的结构化文件写入工具创建:
@@ -28,7 +28,7 @@ Do not use this skill for creating a brand-new page that has no existing live sc
28
28
 
29
29
  ## Required Workflow
30
30
 
31
- 1. Confirm the target `appType`, `formUuid`, and local source path.
31
+ 1. Identify the target `appType` and `formUuid` from the active page or bound context. Check the local source path if it exists.
32
32
  2. Check the OpenYida environment and login state:
33
33
 
34
34
  ```bash
@@ -36,7 +36,15 @@ openyida env --json
36
36
  openyida login --check-only --json
37
37
  ```
38
38
 
39
- 3. Fetch the live schema before editing or publishing:
39
+ 3. For an existing Canvas page, export both the editable source and current schema in one call. Choose a fresh directory under the project cache:
40
+
41
+ ```bash
42
+ openyida get-schema <appType> <formUuid> --canvas-source-dir project/.cache/openyida/publish-guard/<snapshot> --json
43
+ ```
44
+
45
+ The path above is relative to the workspace root. From the project root, use `.cache/openyida/publish-guard/<snapshot>`. Read `sourceFile` for the relevant component or handler and keep `schemaFile` for checking the page configuration. If the local source is missing, use the exported source as the starting point. Keep the snapshot as a baseline and make the targeted edit in a working source file.
46
+
47
+ For a legacy JSX page, fetch its current schema:
40
48
 
41
49
  ```bash
42
50
  openyida get-schema <appType> <formUuid> --json
@@ -44,7 +52,7 @@ openyida get-schema <appType> <formUuid> --json
44
52
 
45
53
  If the schema needs to be inspected from a file, save stdout with the agent's structured file write tool to `<projectRoot>/.cache/openyida/publish-guard/live-<formUuid>.json`. From the workspace root that path is typically `project/.cache/openyida/publish-guard/live-<formUuid>.json`. Do not use shell redirection and do not commit fetched live schema files.
46
54
 
47
- 4. Inspect the fetched live page for current code and configuration. For custom display pages, check at least:
55
+ 4. Inspect the fetched live page for current code and configuration. Use the relevant data sources and component tree when comparing Canvas pages. For legacy JSX pages, also check:
48
56
 
49
57
  - `pages[].componentsTree[].methods.__initMethods__.source`
50
58
  - `pages[].componentsTree[].methods.__initMethods__.compiled`