# Kingdee Project Context

> Project-level context generated for business projects that use KCode.

---

## Purpose

This `.trellis/spec` template is optimized for Kingdee development assistants. It gives AI sessions enough project, platform, and verification context to work on:

- Kingdee Cosmic / BOS Java plugins and services
- Kingdee Enterprise C# and IronPython plugins
- Metadata-driven data fixes and KSQL scripts
- OpenAPI-style integration contracts

Authoritative sources for implementation: this file's product profile, verified metadata from **readonly SQL + LLM parse** (not metadata MCP; see kcode-pi `skills/_shared/metadata-db-query.md`), and the business project's source code.

---

## 产品画像

> Product profile written by `kcode init --cosmic` or `--enterprise`; edit this section for your site.

- _（未选择）_

## Project Attributes

| Field | Value |
| --- | --- |
| Runtime platform | _auto-detected or selected by user_ |
| Business domain | _fill from the target business project_ |

Before coding: confirm **产品画像** in this file (`kcode init` sets the first line). For DB metadata: Agent guides the model to run **readonly SQL** against the business DB and parse results (enterprise: SQL Server FKERNELXML; Cosmic: PostgreSQL fdata). If host/db/readonly credentials are missing, **ask the user first**—do not invent field keys.

---

## Shared Rules

Before choosing platform-specific rules, read these when relevant:

| Topic | File |
| --- | --- |
| KCode skill/extension routing | [kcode-skills.md](./kcode-skills.md) |
| Metadata verification | [metadata-verification.md](./metadata-verification.md) |
| Cross-platform review gate | [review-checklist.md](./review-checklist.md) |

---

## Platform Routing

| If the task mentions | Treat as | Required spec layer |
| --- | --- | --- |
| Cangqiong, Cosmic, BOS, Xinghan, form plugin, bill plugin, operation plugin, KSQL | Cosmic Java | `../backend/cosmic-java/` |
| Enterprise, K/3 Cloud, C# plugin, bill/form/list plugin, dynamic form | Enterprise C# | `../backend/enterprise/` |
| Python script plugin, IronPython | Enterprise Python plugin | `../backend/enterprise/python-plugin.md` |
| REST contract, third-party integration, API document | OpenAPI contract | `../backend/enterprise/openapi-design.md` and platform-specific API rules |
| Data correction, metadata table, SQL/KSQL | Cosmic metadata/KSQL | `../backend/cosmic-java/ksql.md` |

If the platform cannot be determined from the request, source tree, or product profile, stop and ask before writing platform-specific code.

---

## Technical Stack

| Layer | Standard |
| --- | --- |
| Build system | Auto-detected: Maven / Gradle / MSBuild / dotnet / project script |
| Java runtime | Follow the target Cosmic project and platform SDK version |
| C# runtime | Follow the target Enterprise project and Kingdee SDK version |
| Python runtime | IronPython unless the target project explicitly uses CPython |
| Database | Readonly SQL via Agent-guided CLI (`sqlcmd`/`psql`); never infer metadata from captions alone |
| Assistant context | This spec + source code + verified metadata (readonly SQL + LLM parse) |

---

## Pre-Development Checklist

- [ ] Product profile in **产品画像** above matches the site (`kcode init` or hand-edited)
- [ ] Business DB connection is known (or user was asked); metadata via readonly SQL + LLM parse (`metadata-db-query.md`), not metadata MCP
- [ ] The correct platform layer is selected from Platform Routing
- [ ] Similar code has been searched before inventing a new pattern
- [ ] Entity IDs, form IDs, field keys, enum values, and table names are verified when used
- [ ] Build/test command for the target project is known

---

## Assistant Behavior

AI should prefer small, evidence-backed changes:

1. Read the relevant index file first.
2. Load only the specific guideline files required by the task.
3. Verify platform facts from code, metadata, or official project configuration.
4. Avoid generic Java/C# patterns when Kingdee platform helpers exist.
5. Report unresolved assumptions instead of generating code against guessed metadata.
