kwc-project-scaffold
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseKWC Project Scaffold
KWC Project Scaffold
将本 Skill 作为 KWC 工程脚手架工作的入口。
优先把用户需求归入以下几类:初始化项目、创建组件、创建页面元数据、配置环境、部署、调试。
Use this Skill as the entry point for KWC project scaffolding work.
Prioritize categorizing user requirements into the following types: project initialization, component creation, page metadata creation, environment configuration, deployment, debugging.
正确认知交付对象
Correct Understanding of Deliverables
不要把 KWC 工作流理解成“本地把一个组件渲染出来”。
KWC 的核心交付对象是:
- 组件工程本身
- 页面元数据
*.page-meta.kwp - 目标环境配置与认证
- 通过 上传后的环境渲染结果
kd project deploy
页面最终展示依赖页面元数据中的 和组件类型映射,而不是本地 是否挂载了某个组件。
和 只用于本地辅助预览,不是最终交付路径。
<controls>main.tsxmain.tsxnpm run devDo not interpret the KWC workflow as "rendering a component locally".
The core deliverables of KWC are:
- The component project itself
- Page metadata
*.page-meta.kwp - Target environment configuration and authentication
- Environment rendering results after uploading via
kd project deploy
The final page display depends on the in the page metadata and component type mapping, not whether a component is mounted in the local .
and are only used for local auxiliary preview, not the final delivery path.
<controls>main.tsxmain.tsxnpm run dev元数据优先的开发模型
Metadata-First Development Model
从用户开发角度看,一个 KWC 功能要拆成三层:
- 组件代码:真正负责渲染和行为逻辑
- 组件元数据 :声明“这个组件可以被页面如何引用、可以暴露哪些可配置属性”
.js-meta.kwc - 页面元数据 :声明“这个页面由哪些组件实例组成,并给每个实例传什么属性值”
.page-meta.kwp
因此,面对需求时不要只问“要写几个组件”,还要继续判断:
- 哪些参数是写死在组件代码里的
- 哪些参数需要暴露给页面配置者,通过组件元数据定义为
<property> - 哪些组件实例会出现在页面元数据的 中
<controls>
默认原则:
- 能固定在组件内部的实现细节,不要暴露到元数据
- 只有需要被页面装配、复用、配置的参数,才进入组件元数据和页面元数据
From the user's development perspective, a KWC function should be divided into three layers:
- Component code: Responsible for rendering and business logic
- Component metadata : Declares "how this component can be referenced by pages and which configurable properties it can expose"
.js-meta.kwc - Page metadata : Declares "which component instances this page consists of and what property values are passed to each instance"
.page-meta.kwp
Therefore, when handling requirements, do not only ask "how many components need to be written", but also judge:
- Which parameters are hard-coded in the component code
- Which parameters need to be exposed to page configurators and defined as in component metadata
<property> - Which component instances will appear in the of the page metadata
<controls>
Default principles:
- Implementation details that can be fixed inside the component should not be exposed to metadata
- Only parameters that need to be assembled, reused, or configured by pages should be included in component metadata and page metadata
先把需求翻译成工程目标
Translate Requirements into Project Objectives First
面对“帮我开发一个 KWC 页面/功能”的请求时,先把需求翻译成下面几项:
- 是否需要新建工程,还是在已有工程里继续开发
- 需要几个组件,各自承担什么职责
- 需要几个页面元数据文件,页面里如何组合这些组件
- 最终要部署到哪个环境
- 是否还需要进入 做联调验证
kd debug
只有把这几项补齐,脚手架命令才有明确目标。
When receiving a request like "Help me develop a KWC page/function", first translate the requirements into the following items:
- Whether a new project needs to be created or development continues in an existing project
- How many components are needed and their respective responsibilities
- How many page metadata files are needed and how to combine these components in the page
- Which target environment to deploy to finally
- Whether is needed for joint debugging and verification
kd debug
Only when these items are clarified can the scaffolding commands have clear objectives.
框架开发 Skill 协作
Framework Development Skill Collaboration
将 视为 KWC 工作流的总入口,但不要让它吞掉框架开发 Skill 的职责。
kwc-project-scaffold职责边界如下:
- 负责项目初始化、组件与页面元数据生成、环境配置、部署、调试编排
kwc-project-scaffold - 负责 React KWC 项目的具体组件代码实现、框架规范和本地预览约束
kwc-react-development - 负责 Vue KWC 项目的具体组件代码实现、框架规范和本地预览约束
kwc-vue-development - 负责 LWC KWC 项目的具体组件代码实现、框架规范和本地预览约束
kwc-lwc-development
协作约定:
- 当任务仍处于需求拆分、脚手架命令、元数据、环境、、
deploy阶段时,继续由本 Skill 主导debug - 当任务进入“具体代码开发、组件修改、页面前端实现”阶段时,建议加载与当前 framework 对应的开发 Skill
- 不要同时加载三个框架开发 Skill;只根据当前工程的 framework 推荐一个
- 不要把三个框架 Skill 的具体编码细则复制进本 Skill;本 Skill 只保留选择逻辑和切换时机
推荐规则:
- 若是新建工程,以 交互中用户选择的 framework 作为后续推荐 Skill 依据
kd project init - 若是已有工程,以 中的
.kd/config.json作为推荐 Skill 依据framework - 当 时,建议转入
framework=reactkwc-react-development - 当 时,建议转入
framework=vuekwc-vue-development - 当 时,建议转入
framework=lwckwc-lwc-development - 若还无法判断 framework,先停下来向用户确认,不要直接继续写代码
Treat as the general entry point for the KWC workflow, but do not let it take over the responsibilities of framework development Skills.
kwc-project-scaffoldResponsibility boundaries:
- is responsible for project initialization, component and page metadata generation, environment configuration, deployment, and debugging orchestration
kwc-project-scaffold - is responsible for specific component code implementation, framework specifications, and local preview constraints for React KWC projects
kwc-react-development - is responsible for specific component code implementation, framework specifications, and local preview constraints for Vue KWC projects
kwc-vue-development - is responsible for specific component code implementation, framework specifications, and local preview constraints for LWC KWC projects
kwc-lwc-development
Collaboration agreements:
- When the task is still in the stages of requirement splitting, scaffolding commands, metadata, environment, , or
deploy, this Skill continues to leaddebug - When the task enters the stage of "specific code development, component modification, front-end page implementation", it is recommended to load the development Skill corresponding to the current framework
- Do not load three framework development Skills at the same time; only recommend one based on the framework of the current project
- Do not copy the specific coding rules of the three framework Skills into this Skill; this Skill only retains the selection logic and switching timing
Recommendation rules:
- For new projects, use the framework selected by the user in the interaction as the basis for subsequent Skill recommendations
kd project init - For existing projects, use the in
frameworkas the basis for Skill recommendations.kd/config.json - When , it is recommended to switch to
framework=reactkwc-react-development - When , it is recommended to switch to
framework=vuekwc-vue-development - When , it is recommended to switch to
framework=lwckwc-lwc-development - If the framework cannot be determined yet, stop and confirm with the user instead of proceeding directly to write code
需要用户提供或确认的输入
Inputs that Require User Provision or Confirmation
这些输入若无法从现有工程或上下文推断,就必须向用户确认:
- 项目名或现有项目路径
- 框架和语言
- 苍穹应用编码
app - 目标环境别名和 URL
- 认证方式,以及 OpenAPI 所需的真实参数
- 页面标识,例如 page name、formId、业务页面用途
- 页面标题、是否需要 、是否需要扩展和权限控制
bizUnit - 哪些组件需要暴露给页面使用,哪些只是内部逻辑组件
- 哪些参数需要做成可配置属性
- 若用户已有环境,是否允许直接部署到该环境
这些信息不要擅自编造,尤其是 、环境 URL、认证参数和最终部署环境。
app关于 (开发商标识):开发阶段可以留空,在组件与环境绑定时会从环境拉取开发商标识, 时会自动写入组件和页面元数据,因此不需要用户手工提供或维护。
isvkd project deploy对 使用最严格的规则(本节为全文唯一权威定义,后续各章节不再重复):
app- 不是 Skill 可以猜测或写死的值
app - 必须由用户明确提供,或来自当前工程里已经存在的
app.kd/config.json - 新建工程时,的交互步骤里必须手动填写
kd project initapp - 如果用户没有给 ,就不要继续初始化、生成正式元数据或部署
app - 不要把示例中的 值当默认值
app - 不要复用上一次任务里的
app - 不要因为当前环境里存在某个应用就自动代入
If these inputs cannot be inferred from the existing project or context, they must be confirmed with the user:
- Project name or existing project path
- Framework and language
- Sky application code
app - Target environment alias and URL
- Authentication method, and real parameters required by OpenAPI
- Page identifier, such as page name, formId, business page purpose
- Page title, whether is needed, whether extension and permission control are needed
bizUnit - Which components need to be exposed to the page and which are only internal logic components
- Which parameters need to be made into configurable properties
- If the user already has an environment, whether direct deployment to this environment is allowed
Do not fabricate this information without authorization, especially , environment URL, authentication parameters, and the final deployment environment.
appRegarding (developer identifier): It can be left blank during the development phase, and the developer identifier will be pulled from the environment when binding components to the environment, and automatically written into components and page metadata during , so users do not need to provide or maintain it manually.
isvkd project deployThe strictest rules apply to (this section is the only authoritative definition in the full text and will not be repeated in subsequent sections):
app- is not a value that can be guessed or hard-coded by the Skill
app - must be explicitly provided by the user or come from the existing
appin the current project.kd/config.json - When creating a new project, must be manually filled in during the interaction steps of
appkd project init - If the user does not provide , do not proceed with initialization, formal metadata generation, or deployment
app - Do not use the value in examples as the default value
app - Do not reuse the from the previous task
app - Do not automatically substitute it just because an application exists in the current environment
由 Skill 自动决策或生成的内容
Content Automatically Decided or Generated by the Skill
这些内容应由 Skill 基于用户需求主动完成,不要把它们再推回给用户逐项设计:
- 将业务需求拆成组件列表
- 为组件生成稳定的 名称
PascalCase - 为页面和实例生成符合规范的小写标识
- 判断组件是否需要保留 ,还是应删除以避免被当成可部署组件
.js-meta.kwc - 将需求映射为组件元数据里的
<property> - 为页面生成 并填充
page-meta.kwp<controls> - 为页面中的每个组件实例生成唯一
name - 判断当前该执行 、
init、create还是deploydebug - 仅当对应元数据文件变更并需要重新上传时,递增该元数据的
version - 在环境操作后复核 和
kd env listkd env info
默认策略是:让用户确认不可推断的关键环境参数,由 Skill 负责把需求落实成工程结构和元数据。
appappThese contents should be actively completed by the Skill based on user requirements, and should not be pushed back to the user for item-by-item design:
- Split business requirements into component lists
- Generate stable names for components
PascalCase - Generate standardized lowercase identifiers for pages and instances
- Judge whether components need to retain or should be deleted to avoid being treated as deployable components by the scaffolding
.js-meta.kwc - Map requirements to in component metadata
<property> - Generate for pages and fill in
page-meta.kwp<controls> - Generate a unique for each component instance in the page
name - Judge whether to execute ,
init,create, ordeploycurrentlydebug - Increment the of the metadata only when the corresponding metadata file is changed and needs to be re-uploaded
version - Review and
kd env listafter environment operationskd env info
The default strategy is: Let the user confirm key environment parameters that cannot be inferred, and the Skill is responsible for implementing requirements into project structure and metadata.
appapp从需求生成组件元数据
Generate Component Metadata from Requirements
当用户要“开发一个页面功能”时,不要等到最后才补 。
应在组件职责确定后,立即判断组件元数据应如何生成。
.js-meta.kwc按这个顺序处理:
- 先识别组件是否会被页面元数据直接引用。
- 若会被页面引用,就保留并完善对应的 。
.js-meta.kwc - 若组件只是内部复用逻辑、不需要在元数据页面中声明,可删除对应 ,避免被脚手架当作可部署组件。
.js-meta.kwc - 将“页面配置者可调的参数”提炼为 ,不要把所有内部 props 都暴露出去。
<property>
组件元数据至少应关注这些字段:
- :自然数;脚手架模板可能留空,Skill 需要补成有效值
version - :通常与组件名保持一致,作为组件类型标识
name - :组件在页面装配侧显示的名称
masterLabel - :开发商标识,开发阶段可留空,deploy 时自动从环境拉取写入
isv - :规则见"需要用户提供或确认的输入"一节
app frameworktargetstargetConfigs
属性设计原则:
- 文本输入用
String - 整数范围用
Integer - 开关型配置用
Boolean - 固定枚举选择用
Combo
只有当页面需要给组件实例传值时,才在组件元数据里声明 。
页面元数据 中出现的属性名,必须能在组件元数据里找到对应定义。
<property><propertys>appapp如果需要字段规则、类型和示例,读取:
references/component-metadata.md
When the user wants to "develop a page function", do not wait until the end to supplement .
After determining component responsibilities, immediately judge how to generate component metadata.
.js-meta.kwcProcess in this order:
- First identify whether the component will be directly referenced by page metadata.
- If it will be referenced by the page, retain and improve the corresponding .
.js-meta.kwc - If the component is only for internal reuse logic and does not need to be declared in the metadata page, the corresponding can be deleted to avoid being treated as a deployable component by the scaffolding.
.js-meta.kwc - Refine "parameters adjustable by page configurators" into , and do not expose all internal props.
<property>
Component metadata should focus on at least these fields:
- : Natural number; the scaffolding template may leave it blank, and the Skill needs to fill in a valid value
version - : Usually consistent with the component name, used as the component type identifier
name - : The name of the component displayed on the page assembly side
masterLabel - : Developer identifier, can be left blank during development, and automatically pulled from the environment and written during deploy
isv - : Rules refer to the section "Inputs that Require User Provision or Confirmation"
app frameworktargetstargetConfigs
Property design principles:
- Use for text input
String - Use for integer ranges
Integer - Use for switch-type configurations
Boolean - Use for fixed enumeration selections
Combo
Only when the page needs to pass values to component instances should be declared in the component metadata.
The property names appearing in of page metadata must have corresponding definitions in component metadata.
<property><propertys>The filling rules for refer to the section "Inputs that Require User Provision or Confirmation"; if there is no credible in the current project, do not generate formal deployable metadata.
appappIf field rules, types, and examples are needed, read:
references/component-metadata.md
从需求生成页面元数据
Generate Page Metadata from Requirements
页面元数据不是简单“列出组件名称”,而是把用户要的页面装配结构显式写出来。
按这个顺序处理:
- 先确定页面名称、标题、所属应用、业务单元、版本策略。
- 根据需求把页面拆成一个或多个组件实例。
- 为每个实例生成 。
<control> - 必须与组件元数据里的组件
control.type完全一致,包含大小写也必须一致。name - 是页面内唯一实例名,必须符合页面元数据命名规范。
control.name - 只有组件元数据中定义过的属性,才能写进 。
<propertys>
例如,若组件元数据中的 是 ,则页面元数据里的 只能写 。
不要因为组件目录在 下,就擅自写成 ;这类前缀不是组件类型名的一部分。
nameOverviewCardcontrol.typeOverviewCardapp/kwc/kwc_OverviewCard页面字段默认策略:
- 默认使用
templateoneregion - 、
bizUnit、enableExtend仅在需求明确时填写enablePermissionControl - 、
isv以页面主信息为主,控制级别只有在需要覆盖时才填写app
appapp.kd/config.json如果需要字段规则、校验约束和示例,读取:
references/page-metadata.md
Page metadata is not simply "listing component names", but explicitly writing out the page assembly structure required by the user.
Process in this order:
- First determine the page name, title, affiliated application, business unit, and version strategy.
- Split the page into one or more component instances according to requirements.
- Generate for each instance.
<control> - must be exactly consistent with the component
control.typein the component metadata, including case.name - is the unique instance name within the page and must comply with the page metadata naming specifications.
control.name - Only properties defined in component metadata can be written into .
<propertys>
For example, if the in the component metadata is , then in the page metadata can only be written as .
Do not arbitrarily write it as just because the component directory is under ; such prefixes are not part of the component type name.
nameOverviewCardcontrol.typeOverviewCardkwc_OverviewCardapp/kwc/Default strategies for page fields:
- uses
templateby defaultoneregion - ,
bizUnit,enableExtendare only filled in when explicitly required by the requirementsenablePermissionControl - and
isvare based on the main page information, and the control level is only filled in when overwriting is neededapp
The filling rules for refer to the section "Inputs that Require User Provision or Confirmation". If it is found that the in the page metadata is inconsistent with , stop and check first instead of deploying directly.
appapp.kd/config.jsonIf field rules, verification constraints, and examples are needed, read:
references/page-metadata.md
先判断当前所处阶段
First Judge the Current Stage
按这个顺序判断并推进:
- 若当前目录下不存在 ,先视为“尚未初始化 KWC 工程”。
.kd - 若用户要新建页面或组件,优先使用 ,不要手工拼目录结构。
kd project create - 若用户要部署或调试,先检查环境是否已经通过 和
kd env create完成配置。kd env auth openapi - 若用户开始编写具体前端实现代码,先判断当前工程 framework,再建议转入对应框架的专用 Skill,不要把本 Skill 当成组件编码规范。
判断顺序:
- 新建工程:以 中用户选择的 framework 作为推荐依据
kd project init - 已有工程:以 作为推荐依据
.kd/config.json.framework - -> 建议加载
reactkwc-react-development - -> 建议加载
vuekwc-vue-development - -> 建议加载
lwckwc-lwc-development - 若 framework 未知,先停下来确认,不要默认猜测
Judge and advance in this order:
- If does not exist in the current directory, it is regarded as "KWC project not initialized yet".
.kd - If the user wants to create a new page or component, prefer using instead of manually constructing the directory structure.
kd project create - If the user wants to deploy or debug, first check whether the environment has been configured via and
kd env create.kd env auth openapi - If the user starts writing specific front-end implementation code, first judge the framework of the current project, then recommend switching to the dedicated Skill for the corresponding framework, and do not treat this Skill as the component coding specification.
Judgment order:
- New project: Use the framework selected by the user in as the recommendation basis
kd project init - Existing project: Use as the recommendation basis
.kd/config.json.framework - -> It is recommended to load
reactkwc-react-development - -> It is recommended to load
vuekwc-vue-development - -> It is recommended to load
lwckwc-lwc-development - If the framework is unknown, stop and confirm first instead of guessing by default
执行前置检查
Perform Pre-Checks
本 Skill 基于 验证,若 CLI 版本有较大变更,部分 workaround 可能不再适用。
kd 0.0.9先确认以下前提:
- 将 理解为本地工程目录。
Project - 将 理解为远端苍穹环境。
Env - 提醒用户本地需具备 、
node、npm。git - 若命令需要联网安装 CLI 或依赖,再根据环境决定是否需要设置内网镜像。
This Skill is verified based on . If there are major changes in the CLI version, some workarounds may no longer be applicable.
kd 0.0.9First confirm the following prerequisites:
- Treat as the local project directory.
Project - Treat as the remote Sky environment.
Env - Remind the user that ,
node, andnpmare required locally.git - If the command requires network installation of CLI or dependencies, decide whether to set up an intranet mirror according to the environment.
初始化工程
Initialize the Project
在用户尚未拥有 KWC 工程时,按以下流程执行:
- 安装 CLI。
- 运行 。
kd project init <project-name> - 在交互流程中按用户要求选择框架和语言;若用户未指定框架和语言,不要擅自假定,应主动询问用户选择。
- 输入应用标识 编码,这个值必须由用户手工提供。
app - 初始化完成后进入项目目录,执行 。
npm install - 仅在需要本地辅助预览组件时,再执行 。
npm run dev
若用户只是让你“创建一个 KWC 工程”,默认交付应至少覆盖:初始化命令、框架/语言选择、 编码输入、依赖安装,以及后续如何继续创建组件、页面元数据和部署。
app如果用户没有提供 ,遵循"需要用户提供或确认的输入"中的 规则,先停在初始化前让用户补齐。
appapp补充: 依赖 下载模板,若失败优先检查 、网络连通性和执行环境是否允许联网。更多实测细节见 。
kd project initgit clonegitreferences/validation-notes.mdWhen the user does not have a KWC project yet, follow this process:
- Install the CLI.
- Run .
kd project init <project-name> - Select the framework and language as required by the user during the interaction process; if the user does not specify the framework and language, do not assume it arbitrarily and should actively ask the user to choose.
- Enter the application identifier code, which must be manually provided by the user.
app - After initialization is completed, enter the project directory and execute .
npm install - Only execute when local auxiliary preview of components is needed.
npm run dev
If the user only asks you to "create a KWC project", the default delivery should at least cover: initialization commands, framework/language selection, code input, dependency installation, and how to continue creating components, page metadata, and deployment later.
appIf the user does not provide , follow the rules in "Inputs that Require User Provision or Confirmation" and stop before initialization to let the user supplement it.
appappSupplement: relies on to download the template. If it fails, first check , network connectivity, and whether the execution environment allows network access. For more actual measurement details, see .
kd project initgit clonegitreferences/validation-notes.md创建组件
Create Components
在已有项目中新增组件时:
- 运行 。
kd project create <ComponentName> --type kwc - 使用 组件名。
PascalCase - 让 CLI 生成目录和基础文件,再在生成结果上修改代码。
- 立刻检查生成出来的 ,补齐可部署所需字段和属性定义。
.js-meta.kwc - 若用户同时要创建多个组件,逐个执行创建命令,不要手工复制推断目录结构。
若用户只提供了页面结构想法,没有组件名,先根据语义生成稳定、可复用的组件名,再创建。
若用户给的是完整业务诉求,而不是组件清单,先主动拆分组件职责,再批量创建。
补充:组件生成在 下;脚手架生成的 只是模板,需按上述规则补齐。更多实测细节见 。
app/kwc/<ComponentName>/.js-meta.kwcreferences/validation-notes.mdWhen adding new components to an existing project:
- Run .
kd project create <ComponentName> --type kwc - Use for component names.
PascalCase - Let the CLI generate the directory and basic files, then modify the code based on the generated results.
- Immediately check the generated and complete the fields and property definitions required for deployment.
.js-meta.kwc - If the user wants to create multiple components at the same time, execute the creation command one by one instead of manually copying and inferring the directory structure.
If the user only provides ideas for the page structure but no component names, first generate stable, reusable component names based on semantics, then create them.
If the user provides complete business requirements instead of a component list, first actively split component responsibilities, then create them in batches.
Supplement: Components are generated under ; the generated by the scaffolding is only a template and needs to be completed according to the above rules. For more actual measurement details, see .
app/kwc/<ComponentName>/.js-meta.kwcreferences/validation-notes.md创建页面元数据
Create Page Metadata
页面元数据是最终交付链路的核心。
环境在部署后会根据 的 来渲染页面包含的组件,因此这里不是可选步骤,而是页面交付的主入口。
page-meta.kwp<controls>在需要新增页面时:
- 运行 。
kd project create <page-name> --type page - 打开 。
app/pages/<page-name>.page-meta.kwp - 至少核对并填写 、
name、masterLabel、app。version - 在 中把页面实例和组件类型关联起来。
<controls> - 仅当该页面元数据文件有变更并准备重新上传时,手动将 加
version。1 - 将组件树、实例名和页面布局映射到 XML,而不是停留在“组件已经创建”这一步。
不要忽略以下约束:
- 是组件类型名,必须与组件元数据中的组件
type完全一致,不能只做到语义对应或名称相近。name - 是组件实例名,需要在页面内唯一。
name - 必须与当前苍穹应用编码一致。
app - 开发阶段可留空,deploy 时会自动从环境拉取并写入,不需要手工维护。
isv
若需要字段规则、校验约束和示例,读取 。
references/page-metadata.md补充:新生成的 默认只包含注释掉的 模板,Skill 必须根据需求主动补全 。更多实测细节见 。
page-meta.kwp<control><controls>references/validation-notes.mdPage metadata is the core of the final delivery link.
After deployment, the environment will render the components contained in the page according to the in , so this is not an optional step but the main entry point for page delivery.
<controls>page-meta.kwpWhen a new page needs to be added:
- Run .
kd project create <page-name> --type page - Open .
app/pages/<page-name>.page-meta.kwp - At least check and fill in ,
name,masterLabel, andapp.version - Associate page instances with component types in .
<controls> - Manually increase by 1 only when the page metadata file is changed and ready for re-upload.
version - Map the component tree, instance names, and page layout to XML instead of stopping at the step of "components have been created".
Do not ignore the following constraints:
- is the component type name and must be exactly consistent with the component
typein the component metadata, not just semantically corresponding or similar in name.name - is the component instance name and must be unique within the page.
name - must be consistent with the current Sky application code.
app - can be left blank during the development phase and will be automatically pulled from the environment and written during deploy, so no manual maintenance is needed.
isv
If field rules, verification constraints, and examples are needed, read .
references/page-metadata.mdSupplement: The newly generated only contains a commented-out template by default, and the Skill must actively complete according to requirements. For more actual measurement details, see .
page-meta.kwp<control><controls>references/validation-notes.md脚手架命令的推荐编排
Recommended Orchestration of Scaffold Commands
当用户要新增一个完整 KWC 页面功能时,优先按这条顺序执行:
- 若无工程,执行
kd project init - 对每个“会出现在页面里的组件”执行
kd project create <ComponentName> --type kwc - 确认当前工程 framework;若后续进入代码实现,建议切换到对应框架开发 Skill
- 实现组件代码
- 先确认当前工程 里的
.kd/config.json是用户手工输入的真实值,再补全这些组件的app.js-meta.kwc - 执行
kd project create <page-name> --type page - 补全页面
app/pages/<page-name>.page-meta.kwp - 确认或创建目标环境
- 完成认证
- 若组件元数据或页面元数据有变更,执行
kd project deploy - 需要联调时执行
kd debug
如果是修改已有页面:
- 先识别是改组件实现、改组件元数据、改页面元数据,还是三者都改
- 若组件元数据或页面元数据变更,部署前一定检查版本号
- 若仅是组件实现代码变更,且所有元数据文件未变,通常不需要
deploy - 若仅是组件实现代码变更,优先执行 ;需要联调时再继续
npm run buildkd debug
不要采用下面这些错误顺序:
- 先写页面元数据,再回头猜组件属性名
- 先 deploy,再补版本号
- 创建了组件后完全不检查
.js-meta.kwc - 把所有组件都保留元数据,即使它们只是内部辅助组件
When the user wants to add a complete KWC page function, follow this order first:
- If there is no project, execute
kd project init - Execute for each "component that will appear in the page"
kd project create <ComponentName> --type kwc - Confirm the current project framework; if entering code implementation later, it is recommended to switch to the corresponding framework development Skill
- Implement component code
- First confirm that the in the current project's
appis the real value manually entered by the user, then complete the.kd/config.jsonof these components.js-meta.kwc - Execute
kd project create <page-name> --type page - Complete the page
app/pages/<page-name>.page-meta.kwp - Confirm or create the target environment
- Complete authentication
- If component metadata or page metadata is changed, execute
kd project deploy - Execute when joint debugging is needed
kd debug
If modifying an existing page:
- First identify whether to modify component implementation, component metadata, page metadata, or all three
- If component metadata or page metadata is changed, be sure to check the version number before deployment
- If only component implementation code is changed and all metadata files are unchanged, is usually not needed
deploy - If only component implementation code is changed, prefer executing ; continue with
npm run buildwhen joint debugging is neededkd debug
Do not use the following wrong orders:
- Write page metadata first, then guess component property names later
- Deploy first, then supplement the version number
- Create components and completely ignore checking
.js-meta.kwc - Retain metadata for all components even if they are only internal auxiliary components
配置环境
Configure the Environment
在部署前先完成环境配置:
- 使用 创建环境别名。
kd env create <env-name> --url <url> - 使用 走交互式认证。
kd env auth openapi - 若用户经常切换环境,可用 设置默认环境。
kd env set target-env <env-name> - 必要时使用 和
kd env list检查当前配置。kd env info
优先采用 认证方式; 模式暂不作为默认路径。
openapiweb如果目标环境不存在,或环境存在但尚未完成认证,先停下来收集这些字段:
- 环境别名
- 环境 URL
- Client ID
- Client Secret
- Username
其中 不属于预先手填字段,而属于“读取后选择”的字段:
data center- 先有环境 URL
- 再进入
kd env auth openapi - 由脚手架读取该环境可用的数据中心列表
- 最后让用户从列表中选择
收集规则:
- 环境别名、环境 URL、Client ID、Client Secret、Username 这些值必须由用户手工提供
- 不要让用户自由输入,应让脚手架读取候选项后再选择
data center - 不要使用历史环境中的凭据去猜测新环境
- 不要因为存在 、
dev、sit等别名,就自动推断这次要绑定哪个环境base
交互方式规则:
- 不要假设当前一定支持弹窗或表单式输入
- 在当前常规模式下,先让用户回填手工字段,再在 的交互里选择数据中心
kd env auth openapi - 若运行环境明确支持结构化选择工具,可以在读到数据中心列表后把候选项展示给用户选择
- 即便如此,Client Secret 这类自由文本仍应让用户手填
推荐向用户索要环境信息的格式:
text
请补充以下环境信息:
1. env name:
2. env url:
3. client id:
4. client secret:
5. username:
说明:data center 不需要先手填,后续会由脚手架读取候选项供选择。补充:环境配置保存在 而非项目目录;创建后必须用 复核是否持久化成功; 在 URL 不可达时会直接失败。更多实测细节见 。
~/.kdkd env listkd env auth openapireferences/validation-notes.mdComplete environment configuration before deployment:
- Use to create an environment alias.
kd env create <env-name> --url <url> - Use for interactive authentication.
kd env auth openapi - If the user frequently switches environments, use to set the default environment.
kd env set target-env <env-name> - Use and
kd env listto check the current configuration when necessary.kd env info
Prioritize using the authentication method; the mode is not used as the default path for now.
openapiwebIf the target environment does not exist or the environment exists but authentication has not been completed, stop and collect these fields first:
- Environment alias
- Environment URL
- Client ID
- Client Secret
- Username
Among them, is not a pre-filled field but a field that is "selected after reading":
data center- First have the environment URL
- Then enter
kd env auth openapi - The scaffolding reads the list of available data centers in the environment
- Finally, let the user select from the list
Collection rules:
- Environment alias, environment URL, Client ID, Client Secret, and Username must be manually provided by the user
- Do not let the user freely enter ; instead, let the scaffolding read the candidates before selection
data center - Do not use credentials from historical environments to guess new environments
- Do not automatically infer which environment to bind this time just because aliases like ,
dev, andsitexistbase
Interaction rules:
- Do not assume that pop-up windows or form-based input are currently supported
- In the current regular mode, first let the user fill in the manual fields, then select the data center in the interaction of
kd env auth openapi - If the running environment clearly supports structured selection tools, the candidates can be displayed to the user for selection after reading the data center list
- Even so, free-text fields like Client Secret should still be filled in manually by the user
Recommended format for requesting environment information from the user:
text
Please supplement the following environment information:
1. env name:
2. env url:
3. client id:
4. client secret:
5. username:
Note: data center does not need to be filled in first; candidates will be read by the scaffolding for selection later.Supplement: Environment configurations are saved in instead of the project directory; after creation, be sure to use to review whether the persistence is successful; will fail directly if the URL is unreachable. For more actual measurement details, see .
~/.kdkd env listkd env auth openapireferences/validation-notes.md部署与调试
Deployment and Debugging
不要把 当成“每次改代码后都要跑”的固定步骤。
的核心作用是把元数据上传到目标环境,因此只有组件元数据 或页面元数据 发生变更时,才需要考虑 。
kd project deploydeploy.js-meta.kwc.page-meta.kwpdeploy常用命令:
- :部署整个项目到默认环境
kd project deploy - :仅部署指定组件到
kd project deploy -d app/kwc/MyComponent -e sitsit - :仅部署指定页面元数据到
kd project deploy -d app/pages/MyPage -e sitsit - :进入调试
kd debug - 若需要指定环境或表单,使用 或
kd debug -e <env-name>kd debug -f <formid>
版本管理规则:
- 只改组件实现代码,如 、
.tsx、.vue、.js、.html,且没有改任何元数据文件:不需要.scss,也不要递增deployversion - 改了组件元数据 :递增该组件元数据的
.js-meta.kwc,再部署该组件或整个项目version - 改了页面元数据 :递增该页面元数据的
.page-meta.kwp,再部署该页面元数据或整个项目version - 同时改了组件元数据和页面元数据:分别递增各自 ,再部署受影响路径或整个项目
version - 新建组件元数据或页面元数据:初始 设为
version,首次上传时执行1deploy
判断原则:
- 是否需要 ,先看元数据文件是否变更,不要只因为“刚改过代码”就默认部署
deploy - 是否需要递增 ,也先看对应元数据文件是否变更,不要因为构建、调试或纯代码改动而递增
version - 若只是组件代码改动,优先 ;需要联调时继续
npm run buildkd debug
遇到跨应用调试时,优先检查 里的 编码是否需要手工切换。
.kd/config.jsonapp补充:环境未认证时 会直接阻止部署; 在部分版本中可能异常,更稳妥的路径是先 再执行 。更多实测细节见 。
kd project deploykd debug -e <env> -f <formid>kd env set target-env <env>kd debug -f <formid>references/validation-notes.mdDo not treat as a fixed step that "must be run every time code is changed".
The core function of is to upload metadata to the target environment, so only needs to be considered when component metadata or page metadata changes.
kd project deploydeploydeploy.js-meta.kwc.page-meta.kwpCommon commands:
- : Deploy the entire project to the default environment
kd project deploy - : Only deploy the specified component to
kd project deploy -d app/kwc/MyComponent -e sitsit - : Only deploy the specified page metadata to
kd project deploy -d app/pages/MyPage -e sitsit - : Enter debugging mode
kd debug - To specify an environment or form, use or
kd debug -e <env-name>kd debug -f <formid>
Version management rules:
- Only modify component implementation code, such as ,
.tsx,.vue,.js,.html, and no metadata files are changed: No need for.scss, and no need to incrementdeployversion - Modify component metadata : Increment the
.js-meta.kwcof the component metadata, then deploy the component or the entire projectversion - Modify page metadata : Increment the
.page-meta.kwpof the page metadata, then deploy the page metadata or the entire projectversion - Modify both component metadata and page metadata: Increment their respective s, then deploy the affected paths or the entire project
version - Create new component metadata or page metadata: Set the initial to
version, and execute1during the first uploaddeploy
Judgment principles:
- Whether is needed depends on whether metadata files are changed, not just because "code has just been modified"
deploy - Whether needs to be incremented also depends on whether the corresponding metadata file is changed, not because of build, debugging, or pure code changes
version - If only component code is modified, prefer executing ; continue with
npm run buildwhen joint debugging is neededkd debug
When debugging across applications, first check whether the code in needs to be manually switched.
app.kd/config.jsonSupplement: will be directly blocked if the environment is not authenticated; may be abnormal in some versions, and a more reliable path is to first execute and then execute . For more actual measurement details, see .
kd project deploykd debug -e <env> -f <formid>kd env set target-env <env>kd debug -f <formid>references/validation-notes.md端到端执行原则
End-to-End Execution Principles
当用户说“帮我开发一个 KWC 页面/功能”时,默认按这条链路推进:
- 识别是新工程还是已有工程
- 收集不可推断的环境输入
- 拆分组件并创建组件工程
- 实现组件代码
- 创建并补全页面元数据
- 配置环境并确认认证状态
- 若元数据有变更,执行
deploy - 必要时执行
debug
不要只完成其中的“创建组件”或“本地跑起来”,除非用户明确只要某个局部步骤。
When the user says "Help me develop a KWC page/function", follow this link by default:
- Identify whether it is a new project or an existing project
- Collect environment inputs that cannot be inferred
- Split components and create component projects
- Implement component code
- Create and complete page metadata
- Configure the environment and confirm the authentication status
- If metadata is changed, execute
deploy - Execute when necessary
debug
Do only complete "component creation" or "run locally" unless the user explicitly only wants a partial step.
输出要求
Output Requirements
输出方案或执行命令时,尽量同时给出:
- 用户还需要补充哪些关键输入
- 当前处于哪个阶段
- 下一条应执行的命令
- 是否依赖已有环境认证
- 是否需要修改
page-meta.kwp - 页面元数据将如何组合组件
- 是否真的需要
deploy - 若需要部署,是否因为元数据变更而必须递增
version
When outputting solutions or execution commands, try to provide the following at the same time:
- Which key inputs the user still needs to supplement
- Which stage is currently in
- The next command to be executed
- Whether it depends on existing environment authentication
- Whether needs to be modified
page-meta.kwp - How the page metadata will combine components
- Whether is really needed
deploy - If deployment is needed, whether must be incremented due to metadata changes
version
常见失误
Common Mistakes
优先排查这些问题:
- 在非 KWC 工程目录里直接执行
kd project create - 创建了页面但没有把组件写入
<controls> - 和真实组件名不一致
type - 编码与目标应用不一致
app - 页面元数据重复上传但未递增
version - 只改了组件代码,却误以为必须立刻
deploy - 只创建了组件,却没有把组件写进页面元数据
- 元数据已经变更,却只做了本地预览,没有继续
deploy - 未认证环境就直接执行 或
deploydebug
Prioritize troubleshooting these issues:
- Directly execute in a non-KWC project directory
kd project create - Create a page but do not write components into
<controls> - is inconsistent with the real component name
type - code is inconsistent with the target application
app - Page metadata is uploaded repeatedly but is not incremented
version - Only modify component code but mistakenly think that must be done immediately
deploy - Only create components but do not write them into page metadata
- Metadata has been changed but only local preview is done without continuing to
deploy - Execute or
deploydirectly without authenticating the environmentdebug
参考资料
Reference Materials
在需要精确命令、参数说明、OpenAPI 字段说明和 page-meta 示例时,读取:
references/cli-reference.mdreferences/component-metadata.mdreferences/env-setup.mdreferences/page-metadata.mdreferences/validation-notes.md
When precise commands, parameter descriptions, OpenAPI field descriptions, and page-meta examples are needed, read:
references/cli-reference.mdreferences/component-metadata.mdreferences/env-setup.mdreferences/page-metadata.mdreferences/validation-notes.md