SuperAPI AI Directory

kwc-ks-controller-development

Coding & development

View repository

Updated 10-15 23:23

About this skill

KWC KS Controller Development Expert

When a KingScript script controller (backend REST API) needs to be developed in a project, this Skill is responsible for the controller's .kws metadata configuration and script code implementation.

The hard constraints defined in rule.md under this Skill's directory must be strictly followed.

Usage Prerequisites

All of the following conditions must be met to use this Skill:

  1. The current directory already contains the .kd/config.json file
  2. The project already contains the app/ks/controller/ directory
  3. The project has been initialized via kwc-project-scaffold Complete initialization

The following scenarios must be handled by kwc-project-scaffold:

  • Project initialization, creating component/page/Controller directories (kd project init / kd project create)
  • Generating or modifying .js-meta.kwc / .page-meta.kwp metadata
  • Environment configuration, build, deployment, debugging (kd env / npm run build / kd project deploy / kd debug)

If the above prerequisites are not currently met, stop immediately and switch to kwc-project-scaffold Skill。

Standard Workflow

  1. Confirm the directory exists: The Controller directory has been created by scaffold (app/ks/controller/<Name>/)
  2. Read the project configuration(mandatory): Read .kd/config.json, obtain the actual values of fields such as isv、app , and the subsequent <isv>、<app>、<url> in .kws must be assembled based on these values;guessing or hardcoding is prohibited
  3. Query entity fields(when business entity operations are involved): via meta-query-api.mjs obtain the actual field structure;guessing field names is prohibited
  4. Write .kws metadata: Assemble the URL based on the configuration read in step 2 (/{isv}/{app}/...), and define the HTTP method and permissions
  5. Write script code: Before starting to write code,you must first read ./reference/脚本控制器防坑指南.md, ensure you do not use nonexistent APIs and do not step on known runtime pitfalls; before calling an SDK, first confirm in the index that it exists
  6. Deliver the build: After completion, notify the user to return to scaffold for deployment

Reference Resources

Category Resource Path
This Skill .kws metadata configuration specification ./reference/kws-metadata-reference.md
Controller integration workflow ./reference/controller-scaffold-workflow.md
Common patterns and code examples ./reference/controller-patterns.md
Frontend adapterApi calling guide ./reference/frontend-integration.md
KingScript Script controller development guide ../kingscript-code-generator/references/docs/custom-development/脚本控制器开发指南.md
Script controller pitfall prevention guide ./reference/脚本控制器防坑指南.md
Language Basics ../kingscript-code-generator/references/language/kingscript/README.md
SDK class index ../kingscript-code-generator/references/sdk/indexes/class-index.md
SDK method index ../kingscript-code-generator/references/sdk/indexes/method-index.md
SDK scenario index ../kingscript-code-generator/references/sdk/indexes/scenario-index.md
SDK policies and fallback chains ../kingscript-code-generator/references/sdk/strategy.md
Java-KS type bridging ../kingscript-code-generator/references/sdk/docs/java-kingscript-bridge.md
Scaffold Entity field query tool ../kwc-project-scaffold/references/meta-query.md