kcode-pi 0.1.0

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 (219) hide show
  1. package/README.md +358 -0
  2. package/dist/cli/kcode.d.ts +15 -0
  3. package/dist/cli/kcode.js +153 -0
  4. package/dist/cli/main.d.ts +2 -0
  5. package/dist/cli/main.js +7 -0
  6. package/docs/KCODE_DISTRIBUTION.md +91 -0
  7. package/extensions/kingdee-harness.ts +180 -0
  8. package/extensions/kingdee-header.ts +122 -0
  9. package/extensions/kingdee-tools.ts +379 -0
  10. package/knowledge/.backup/v1.0.0/version.json +10 -0
  11. package/knowledge/cangqiong/product-notes.md +15 -0
  12. package/knowledge/common/business-flows.md +115 -0
  13. package/knowledge/common/config-guides.md +110 -0
  14. package/knowledge/common/error-patterns.md +170 -0
  15. package/knowledge/common/implementation.md +144 -0
  16. package/knowledge/cosmic/hard-constraints.md +38 -0
  17. package/knowledge/cosmic/ksql-datafix.md +34 -0
  18. package/knowledge/cosmic/platform-baseline.md +32 -0
  19. package/knowledge/cosmic/plugin-decision-matrix.md +40 -0
  20. package/knowledge/cosmic/review-checklist.md +40 -0
  21. package/knowledge/cosmic/unittest.md +35 -0
  22. package/knowledge/enterprise/api-reference.md +186 -0
  23. package/knowledge/enterprise/code-patterns.md +217 -0
  24. package/knowledge/enterprise/plugin-lifecycle.md +188 -0
  25. package/knowledge/enterprise/tables.json +159 -0
  26. package/knowledge/flagship/api-reference.md +237 -0
  27. package/knowledge/flagship/code-patterns.md +246 -0
  28. package/knowledge/flagship/cosmic-platform-note.md +15 -0
  29. package/knowledge/flagship/plugin-lifecycle.md +248 -0
  30. package/knowledge/flagship/tables.json +159 -0
  31. package/knowledge/version.json +10 -0
  32. package/knowledge/xinghan/product-notes.md +15 -0
  33. package/package.json +71 -0
  34. package/prompts/kd-discuss.md +11 -0
  35. package/prompts/kd-execute.md +12 -0
  36. package/prompts/kd-plan.md +12 -0
  37. package/prompts/kd-ship.md +12 -0
  38. package/prompts/kd-spec.md +12 -0
  39. package/prompts/kd-verify.md +12 -0
  40. package/skills/kd-check/SKILL.md +26 -0
  41. package/skills/kd-cosmic-dev/SKILL.md +82 -0
  42. package/skills/kd-cosmic-review/SKILL.md +90 -0
  43. package/skills/kd-cosmic-unittest/SKILL.md +92 -0
  44. package/skills/kd-debug/SKILL.md +30 -0
  45. package/skills/kd-discuss/SKILL.md +24 -0
  46. package/skills/kd-execute/SKILL.md +22 -0
  47. package/skills/kd-gen/SKILL.md +34 -0
  48. package/skills/kd-ksql/SKILL.md +86 -0
  49. package/skills/kd-plan/SKILL.md +24 -0
  50. package/skills/kd-ship/SKILL.md +22 -0
  51. package/skills/kd-spec/SKILL.md +24 -0
  52. package/skills/kd-verify/SKILL.md +22 -0
  53. package/themes/kcode-dark.json +81 -0
  54. package/vendor/kingdee-skills/cosmic-unittest/SKILL.md +788 -0
  55. package/vendor/kingdee-skills/cosmic-unittest/author-cache.json +5 -0
  56. package/vendor/kingdee-skills/cosmic-unittest/cosmic-unittest-skill-overview.html +746 -0
  57. package/vendor/kingdee-skills/cosmic-unittest/examples/business-test.md +205 -0
  58. package/vendor/kingdee-skills/cosmic-unittest/examples/common-test.md +257 -0
  59. package/vendor/kingdee-skills/cosmic-unittest/examples/formplugin-test.md +560 -0
  60. package/vendor/kingdee-skills/cosmic-unittest/examples/op-plugin-test.md +231 -0
  61. package/vendor/kingdee-skills/cosmic-unittest/examples/validator-test.md +232 -0
  62. package/vendor/kingdee-skills/cosmic-unittest/patterns/business-helper.md +184 -0
  63. package/vendor/kingdee-skills/cosmic-unittest/patterns/common-module.md +355 -0
  64. package/vendor/kingdee-skills/cosmic-unittest/patterns/convert-plugin.md +130 -0
  65. package/vendor/kingdee-skills/cosmic-unittest/patterns/formplugin.md +235 -0
  66. package/vendor/kingdee-skills/cosmic-unittest/patterns/op-plugin.md +226 -0
  67. package/vendor/kingdee-skills/cosmic-unittest/patterns/validator.md +206 -0
  68. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/SKILL.md +674 -0
  69. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/advanced-scenario-checklist.md +307 -0
  70. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/algox-performance-checklist.md +129 -0
  71. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/coding-standard-checklist.md +491 -0
  72. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/cosmic-api-checklist.md +285 -0
  73. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/data-access-checklist.md +261 -0
  74. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/data-transaction-checklist.md +390 -0
  75. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/domain-logic-checklist.md +295 -0
  76. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/form-plugin-checklist.md +508 -0
  77. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/infra-checklist.md +254 -0
  78. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/ksql-checklist.md +305 -0
  79. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/lifecycle-checklist.md +298 -0
  80. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/operation-plugin-checklist.md +442 -0
  81. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/test-mock-checklist.md +120 -0
  82. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/ui-performance-checklist.md +320 -0
  83. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/scripts/pattern-matcher.py +336 -0
  84. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/scripts/review-score-calculator.py +121 -0
  85. package/vendor/kingdee-skills/ok-cosmic/CHANGELOG.md +295 -0
  86. package/vendor/kingdee-skills/ok-cosmic/README.md +460 -0
  87. package/vendor/kingdee-skills/ok-cosmic/SKILL.md +287 -0
  88. package/vendor/kingdee-skills/ok-cosmic/agents/openai.yaml +17 -0
  89. package/vendor/kingdee-skills/ok-cosmic/assets/BatchImportPluginTemplate.java +93 -0
  90. package/vendor/kingdee-skills/ok-cosmic/assets/BillPlugInTemplate.java +156 -0
  91. package/vendor/kingdee-skills/ok-cosmic/assets/ConvertPlugInTemplate.java +255 -0
  92. package/vendor/kingdee-skills/ok-cosmic/assets/FormPluginTemplate.java +597 -0
  93. package/vendor/kingdee-skills/ok-cosmic/assets/IWorkflowPluginTemplate.java +91 -0
  94. package/vendor/kingdee-skills/ok-cosmic/assets/ListPluginTemplate.java +194 -0
  95. package/vendor/kingdee-skills/ok-cosmic/assets/OpPluginTemplate.java +201 -0
  96. package/vendor/kingdee-skills/ok-cosmic/assets/OpenApiControllerTemplate.java +103 -0
  97. package/vendor/kingdee-skills/ok-cosmic/assets/PrintPluginTemplate.java +95 -0
  98. package/vendor/kingdee-skills/ok-cosmic/assets/ReportFormPluginTemplate.java +257 -0
  99. package/vendor/kingdee-skills/ok-cosmic/assets/ReportListDataPluginTemplate.java +70 -0
  100. package/vendor/kingdee-skills/ok-cosmic/assets/StandardTreeListPluginTemplate.java +130 -0
  101. package/vendor/kingdee-skills/ok-cosmic/assets/TaskTemplate.java +80 -0
  102. package/vendor/kingdee-skills/ok-cosmic/assets/TreeListPluginTemplate.java +152 -0
  103. package/vendor/kingdee-skills/ok-cosmic/assets/WriteBackPlugInTemplate.java +286 -0
  104. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/attachment/AttachmentUploadBindSample.java +93 -0
  105. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/botp/BotpTracePushSample.java +168 -0
  106. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/botp/SampleConvertPlugin.java +223 -0
  107. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/cache/SampleCacheUsage.java +218 -0
  108. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/concurrent/SampleThreadPoolBatch.java +156 -0
  109. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/data/DynamicObjectCrudSample.java +205 -0
  110. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/data/DynamicObjectOpsSample.java +100 -0
  111. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/BeforeOperationConfirmSample.java +217 -0
  112. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/ConfirmDialogSample.java +131 -0
  113. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/EntryRowCalculateSample.java +116 -0
  114. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/F7FilterSample.java +134 -0
  115. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/GetAndSetValueSample.java +176 -0
  116. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/HyperlinkJumpSample.java +124 -0
  117. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/OpenBillModalSample.java +253 -0
  118. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/ReturnParentDataSample.java +295 -0
  119. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/TreeControlSample.java +140 -0
  120. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/ViewControlOpsSample.java +132 -0
  121. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/list/ListPluginBasicSample.java +170 -0
  122. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/list/ListPreOpenFilterSample.java +68 -0
  123. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/message/MessageNotifySample.java +95 -0
  124. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/mq/SampleMQConsumer.java +198 -0
  125. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/mq/sample_mq.xml +15 -0
  126. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/operation/OpAddValidatorsSample.java +137 -0
  127. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/operation/OperationOptionBridgeSample.java +228 -0
  128. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/package-info.java +19 -0
  129. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/query/BaseDataQuerySample.java +194 -0
  130. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/query/BatchQuerySample.java +368 -0
  131. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/query/DataSetQueryStatSample.java +131 -0
  132. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/report/SampleReportFormPlugin.java +179 -0
  133. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/report/SampleReportListDataPlugin.java +616 -0
  134. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/snippets-guide.md +64 -0
  135. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/task/ScheduleTaskSample.java +160 -0
  136. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/workflow/SampleWorkflowPlugin.java +302 -0
  137. package/vendor/kingdee-skills/ok-cosmic/manifest.json +78 -0
  138. package/vendor/kingdee-skills/ok-cosmic/ok-cosmic-intro.html +903 -0
  139. package/vendor/kingdee-skills/ok-cosmic/references/adv/attachment-api.md +114 -0
  140. package/vendor/kingdee-skills/ok-cosmic/references/adv/botp-convert.md +98 -0
  141. package/vendor/kingdee-skills/ok-cosmic/references/adv/dynamic-object.md +113 -0
  142. package/vendor/kingdee-skills/ok-cosmic/references/adv/entity-metadata.md +123 -0
  143. package/vendor/kingdee-skills/ok-cosmic/references/adv/event-lifecycle.md +184 -0
  144. package/vendor/kingdee-skills/ok-cosmic/references/adv/flex-prop.md +114 -0
  145. package/vendor/kingdee-skills/ok-cosmic/references/adv/form-utils.md +133 -0
  146. package/vendor/kingdee-skills/ok-cosmic/references/adv/operate-chain.md +159 -0
  147. package/vendor/kingdee-skills/ok-cosmic/references/adv/plugin-base.md +218 -0
  148. package/vendor/kingdee-skills/ok-cosmic/references/adv/query-dataset.md +149 -0
  149. package/vendor/kingdee-skills/ok-cosmic/references/adv/request-context.md +88 -0
  150. package/vendor/kingdee-skills/ok-cosmic/references/adv/view-handler.md +157 -0
  151. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-bill.md +76 -0
  152. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-botp.md +70 -0
  153. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-form.md +165 -0
  154. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-import.md +69 -0
  155. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-list.md +227 -0
  156. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-openapi.md +112 -0
  157. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-operation.md +135 -0
  158. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-print.md +65 -0
  159. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-report-data.md +64 -0
  160. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-report-form.md +90 -0
  161. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-task.md +62 -0
  162. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-tree-list.md +71 -0
  163. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-workflow.md +82 -0
  164. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-writeback.md +71 -0
  165. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-algo.md +67 -0
  166. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-cache.md +63 -0
  167. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-dynamic-model-svc.md +82 -0
  168. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-dynamic-object.md +70 -0
  169. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-entity-model.md +61 -0
  170. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-exception.md +64 -0
  171. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-file.md +63 -0
  172. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-id.md +47 -0
  173. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-lock.md +61 -0
  174. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-log.md +63 -0
  175. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-network-control.md +70 -0
  176. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-orm-access.md +78 -0
  177. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-request-context.md +62 -0
  178. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-threadpool.md +63 -0
  179. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-tx.md +64 -0
  180. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-utils.md +67 -0
  181. package/vendor/kingdee-skills/ok-cosmic/requirements.txt +2 -0
  182. package/vendor/kingdee-skills/ok-cosmic/rules/a-layer-rules.json +24 -0
  183. package/vendor/kingdee-skills/ok-cosmic/rules/anti-patterns.md +48 -0
  184. package/vendor/kingdee-skills/ok-cosmic/rules/cheat-sheet.md +256 -0
  185. package/vendor/kingdee-skills/ok-cosmic/rules/coding-preferences.md +140 -0
  186. package/vendor/kingdee-skills/ok-cosmic/rules/constraints.md +61 -0
  187. package/vendor/kingdee-skills/ok-cosmic/rules/decision-matrix.md +222 -0
  188. package/vendor/kingdee-skills/ok-cosmic/rules/intent-routing.md +94 -0
  189. package/vendor/kingdee-skills/ok-cosmic/rules/platform-baseline.md +69 -0
  190. package/vendor/kingdee-skills/ok-cosmic/rules/post-check.md +109 -0
  191. package/vendor/kingdee-skills/ok-cosmic/scripts/config_loader.py +204 -0
  192. package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-api-knowledge.py +910 -0
  193. package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-basedata-query.py +359 -0
  194. package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-config-check.py +181 -0
  195. package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-extpoints-query.py +389 -0
  196. package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-form-metadata.py +856 -0
  197. package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-post-check.py +262 -0
  198. package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-post-lint.py +293 -0
  199. package/vendor/kingdee-skills/ok-cosmic/scripts/lint/__init__.py +2 -0
  200. package/vendor/kingdee-skills/ok-cosmic/scripts/lint/base.py +393 -0
  201. package/vendor/kingdee-skills/ok-cosmic/scripts/lint/resource_check.py +176 -0
  202. package/vendor/kingdee-skills/ok-cosmic/scripts/lint/scene_check.py +375 -0
  203. package/vendor/kingdee-skills/ok-cosmic/scripts/lint/style_check.py +434 -0
  204. package/vendor/kingdee-skills/ok-cosmic/scripts/lint/verify_check.py +36 -0
  205. package/vendor/kingdee-skills/ok-cosmic/scripts/route_client.py +186 -0
  206. package/vendor/kingdee-skills/ok-cosmic/scripts/script_utils.py +40 -0
  207. package/vendor/kingdee-skills/ok-cosmic/scripts/sqlite_cache.py +142 -0
  208. package/vendor/kingdee-skills/ok-cosmic/setup/cuslib/kd-cd-cosmic-commons.jar +0 -0
  209. package/vendor/kingdee-skills/ok-cosmic/setup/cuslib/kd-cd-cosmic-features.jar +0 -0
  210. package/vendor/kingdee-skills/ok-cosmic/setup/ok-cosmic-docs.db +0 -0
  211. package/vendor/kingdee-skills/ok-cosmic/setup/ok-cosmic.json +13 -0
  212. package/vendor/kingdee-skills/ok-cosmic/setup/setup-mac.sh +18 -0
  213. package/vendor/kingdee-skills/ok-cosmic/setup/setup-windows.bat +53 -0
  214. package/vendor/kingdee-skills/ok-cosmic/setup/setup.jar +0 -0
  215. package/vendor/kingdee-skills/ok-ksql/SKILL.md +81 -0
  216. package/vendor/kingdee-skills/ok-ksql/agents/openai.yaml +7 -0
  217. package/vendor/kingdee-skills/ok-ksql/manifest.json +14 -0
  218. package/vendor/kingdee-skills/ok-ksql/references/ksql-datafix.md +452 -0
  219. package/vendor/kingdee-skills/ok-ksql/scripts/ksql_lint.py +363 -0
package/README.md ADDED
@@ -0,0 +1,358 @@
1
+ # KCodeV2
2
+
3
+ KCodeV2 是面向金蝶开发的 Pi package 和企业启动器原型。
4
+
5
+ 它不 fork Pi,也不替换 Pi 生态。当前仓库主要提供:
6
+
7
+ - 金蝶专属 tools、skills、prompts、themes。
8
+ - 金蝶 Harness Engineering 工作流。
9
+ - 官方金蝶 skills 的 vendor 资源和 Pi 适配器。
10
+ - `kcode` 企业入口,用项目级 `.pi/settings.json` 加载 KCode package,并通过随包 Pi CLI 启动工作环境。
11
+
12
+ ## 当前定位
13
+
14
+ 当前仓库是:
15
+
16
+ ```text
17
+ kcode-pi
18
+ ```
19
+
20
+ 也就是金蝶 Pi package,同时包含 `kcode-cli` 的仓库内原型。
21
+
22
+ 仓库内的 `npm run kcode -- ...` 是启动器原型,用于验证 `kcode-cli` 的设计。企业入口由两部分组成:
23
+
24
+ ```text
25
+ kcode-pi 金蝶 Pi package,本仓库
26
+ kcode-cli 企业启动器,自动携带 Pi CLI,并启动 KCode 工作环境
27
+ ```
28
+
29
+ ## 环境要求
30
+
31
+ - Node.js `>=22.19.0`
32
+ - npm
33
+ - Pi CLI 由 KCode 运行依赖自动携带
34
+
35
+ 当前机器如果没有全局 `pi` 命令,`kcode start` 会优先使用随包的 Pi CLI。
36
+
37
+ 检查 KCode 能否找到 Pi CLI:
38
+
39
+ ```powershell
40
+ npm run kcode -- doctor
41
+ ```
42
+
43
+ ## 快速开始
44
+
45
+ 发布到 npm 后,开发者可以直接全局安装:
46
+
47
+ ```powershell
48
+ npm install -g kcode-pi
49
+ ```
50
+
51
+ 安装后会得到全局 `kcode` 命令。进入业务项目根目录,初始化 KCode 工作环境:
52
+
53
+ ```powershell
54
+ kcode init
55
+ ```
56
+
57
+ 检查 Node、随包 Pi CLI 和项目级配置:
58
+
59
+ ```powershell
60
+ kcode doctor
61
+ ```
62
+
63
+ 启动 KCode 工作环境:
64
+
65
+ ```powershell
66
+ kcode start
67
+ ```
68
+
69
+ 如果发布时改用 `kcode-cli` 或 `@kingdee/kcode-cli` 包名,把安装命令中的 `kcode-pi` 替换为实际包名即可;全局命令仍是 `kcode`。
70
+
71
+ ## 源码开发
72
+
73
+ 需要修改 KCodeV2 本身时,再 clone 仓库并安装依赖:
74
+
75
+ ```powershell
76
+ git clone <KCodeV2仓库地址>
77
+ cd KCodeV2
78
+ npm install
79
+ ```
80
+
81
+ 源码仓库内可以用 npm script 调试同一个入口:
82
+
83
+ ```powershell
84
+ npm run kcode -- doctor
85
+ npm run kcode -- init
86
+ npm run kcode -- start
87
+ ```
88
+
89
+ ## 安装依赖
90
+
91
+ 在仓库根目录执行:
92
+
93
+ ```powershell
94
+ npm install
95
+ ```
96
+
97
+ ## 本地验证
98
+
99
+ 常用检查:
100
+
101
+ ```powershell
102
+ npm run check
103
+ npm run build:cli
104
+ npm run smoke:knowledge
105
+ npm run smoke:checker
106
+ npm run smoke:harness
107
+ npm run smoke:official
108
+ npm run smoke:build-debug
109
+ npm run smoke:package
110
+ npm run smoke:kcode-cli
111
+ ```
112
+
113
+ 这些 smoke 分别验证:
114
+
115
+ - TypeScript 类型检查。
116
+ - 金蝶知识库搜索。
117
+ - `kd_check` 静态规则。
118
+ - Harness 阶段和门禁。
119
+ - 官方脚本适配器。
120
+ - 构建/调试诊断。
121
+ - package manifest、skills、vendor 文件完整性。
122
+ - `kcode` 项目级入口逻辑。
123
+
124
+ ## KCode 企业入口原型
125
+
126
+ 当前仓库提供 `kcode` 命令。发布后可直接运行全局命令;源码调试时使用 `npm run kcode -- ...`。它不会写用户全局 Pi 配置,只管理当前项目的 `.pi/settings.json`:
127
+
128
+ ```powershell
129
+ kcode init
130
+ kcode doctor
131
+ kcode start
132
+ ```
133
+
134
+ ### `kcode init`
135
+
136
+ 初始化当前项目的 Pi 配置:
137
+
138
+ ```powershell
139
+ kcode init
140
+ ```
141
+
142
+ 它只写当前项目:
143
+
144
+ ```text
145
+ .pi/settings.json
146
+ ```
147
+
148
+ 不会修改用户全局 Pi 配置。
149
+
150
+ 生成内容会把当前 KCodeV2 package 加入项目级 packages,例如:
151
+
152
+ ```json
153
+ {
154
+ "packages": [
155
+ "E:\\projects\\kingdee\\KCodeV2"
156
+ ]
157
+ }
158
+ ```
159
+
160
+ ### `kcode doctor`
161
+
162
+ 检查当前环境:
163
+
164
+ ```powershell
165
+ kcode doctor
166
+ ```
167
+
168
+ 它会检查:
169
+
170
+ - Node 版本。
171
+ - 是否能找到随包 Pi CLI。
172
+ - KCode package 路径。
173
+ - 当前项目 `.pi/settings.json` 是否存在。
174
+ - KCode package 是否已写入项目级配置。
175
+
176
+ ### `kcode start`
177
+
178
+ 初始化项目配置后启动 KCode 工作环境:
179
+
180
+ ```powershell
181
+ kcode start
182
+ ```
183
+
184
+ `kcode start` 会先写入项目级 `.pi/settings.json`,再优先通过随包 `@earendil-works/pi-coding-agent` 的 CLI 启动 Pi;只有随包 CLI 不存在时才回退全局 `pi`。传给 `start` 的后续参数会原样透传给 Pi CLI。
185
+
186
+ ## Pi 内使用方式
187
+
188
+ 安装到 Pi 后,KCodeV2 提供以下命令:
189
+
190
+ ```text
191
+ /kd-start [--product product] [--version version] <goal>
192
+ /kd-product <product> [--version version]
193
+ /kd-status
194
+ /kd-gate
195
+ /kd-advance [phase]
196
+ /kd-artifact [phase] [content]
197
+ ```
198
+
199
+ 工作流阶段:
200
+
201
+ ```text
202
+ discuss -> spec -> plan -> execute -> verify -> ship
203
+ ```
204
+
205
+ 运行状态保存在:
206
+
207
+ ```text
208
+ .pi/kd/active-run.json
209
+ .pi/kd/runs/<run-id>/
210
+ ```
211
+
212
+ ## 金蝶工具
213
+
214
+ 当前注册的主要工具:
215
+
216
+ ```text
217
+ kd_plan_status 查看当前 Harness run、阶段、产物和门禁
218
+ kd_search 搜索内置金蝶 SDK 知识和代码模式
219
+ kd_table 查询内置金蝶表结构
220
+ kd_check 检查金蝶 Java/C# 插件代码
221
+ kd_cosmic_config 运行官方 ok-cosmic 配置预检
222
+ kd_cosmic_metadata 查询官方 Cosmic 表单/单据元数据
223
+ kd_cosmic_api 查询官方 Cosmic API 签名和方法
224
+ kd_ksql_lint 运行官方 ok-ksql SQL/KSQL lint
225
+ kd_build 按产品画像执行或 dry-run 构建
226
+ kd_debug 分析金蝶日志和堆栈
227
+ ```
228
+
229
+ ## 产品画像
230
+
231
+ KCodeV2 会区分金蝶产品和技术栈:
232
+
233
+ ```text
234
+ cosmic -> Cosmic 平台底座
235
+ cangqiong -> Cosmic / Java
236
+ xinghan -> Cosmic / Java
237
+ flagship -> Cosmic / Java
238
+ enterprise -> Enterprise / C#
239
+ ```
240
+
241
+ 未知产品不能离开 `discuss` 阶段。不要把 Cosmic Java API 和 Enterprise C# API 混用。
242
+
243
+ ## 官方 skills 资源
244
+
245
+ 官方金蝶 skills 以 vendor 形式保存在:
246
+
247
+ ```text
248
+ vendor/kingdee-skills
249
+ ```
250
+
251
+ 包含:
252
+
253
+ ```text
254
+ ok-cosmic
255
+ ok-ksql
256
+ kingdee-cosmic-reviewer
257
+ cosmic-unittest
258
+ ```
259
+
260
+ 运行时默认使用包内 vendor 目录。本地开发可通过环境变量覆盖:
261
+
262
+ ```powershell
263
+ $env:KCODE_KINGDEE_SKILLS_ROOT="E:\projects\kingdee\skills"
264
+ ```
265
+
266
+ ## 官方证据与门禁
267
+
268
+ 官方工具在存在 active run 时会写入证据:
269
+
270
+ ```text
271
+ .pi/kd/runs/<run-id>/evidence/cosmic-config.txt
272
+ .pi/kd/runs/<run-id>/evidence/cosmic-metadata.json
273
+ .pi/kd/runs/<run-id>/evidence/cosmic-api.txt
274
+ .pi/kd/runs/<run-id>/evidence/ksql-lint.txt
275
+ ```
276
+
277
+ 当前门禁规则:
278
+
279
+ - Cosmic 体系进入 `execute` 前必须有配置证据。
280
+ - `PLAN.md` 声明字段/元数据验证时,进入 `execute` 前必须有 metadata 证据。
281
+ - `PLAN.md` 声明 API/方法签名验证时,进入 `execute` 前必须有 API 证据。
282
+ - KSQL/数据修复交付进入 `ship` 前必须有 metadata 和 lint 证据。
283
+
284
+ ## Skills
285
+
286
+ Pi-native skills 位于:
287
+
288
+ ```text
289
+ skills/
290
+ ```
291
+
292
+ 核心金蝶 skills:
293
+
294
+ ```text
295
+ kd-cosmic-dev
296
+ kd-cosmic-review
297
+ kd-cosmic-unittest
298
+ kd-ksql
299
+ kd-gen
300
+ kd-check
301
+ kd-plan
302
+ kd-execute
303
+ kd-verify
304
+ kd-ship
305
+ ```
306
+
307
+ 新增和维护文档、注释时,默认使用中文。
308
+
309
+ ## 打包策略
310
+
311
+ 当前不内置第三方 Pi packages。
312
+
313
+ 推荐策略:
314
+
315
+ - 不 fork Pi。
316
+ - 不改用户全局 Pi 配置。
317
+ - 第三方 Pi package 先进入 allowlist,再写入项目级 `.pi/settings.json`。
318
+ - 只有离线交付或强依赖时,才考虑 `dependencies` + `bundledDependencies` 内置。
319
+
320
+ 详细方案见:
321
+
322
+ ```text
323
+ docs/KCODE_DISTRIBUTION.md
324
+ ```
325
+
326
+ ## 发布 npm 包
327
+
328
+ 发布前确认 `package.json` 中的包名、版本和 npm registry。当前包名是 `kcode-pi`,也可以发布前改成企业内约定的 `kcode-cli` 或 `@kingdee/kcode-cli`。
329
+
330
+ 发布检查:
331
+
332
+ ```powershell
333
+ npm run check
334
+ npm run build:cli
335
+ npm run smoke:package
336
+ npm pack --dry-run
337
+ ```
338
+
339
+ 发布:
340
+
341
+ ```powershell
342
+ npm publish
343
+ ```
344
+
345
+ `prepack` 会自动执行 `build:cli` 和 `smoke:package`,确保发布包里有全局 `kcode` 入口和随包 Pi CLI 运行依赖。
346
+
347
+ ## 当前限制
348
+
349
+ - 当前仓库可以直接发布为 npm 包,但包名仍是 `kcode-pi`;如果企业侧要叫 `kcode-cli`,发布前需要调整 `package.json.name`。
350
+ - 更深层的 reviewer 语义规则、HTML 审查报告、自动 SQL 产物生成仍在后续计划中。
351
+
352
+ ## 状态文档
353
+
354
+ 集成进度见:
355
+
356
+ ```text
357
+ OFFICIAL_SKILLS_STATUS.md
358
+ ```
@@ -0,0 +1,15 @@
1
+ export interface KcodeCliResult {
2
+ exitCode: number;
3
+ output: string;
4
+ }
5
+ export interface PiCliCommand {
6
+ command: string;
7
+ args: string[];
8
+ source: "bundled" | "global";
9
+ displayPath: string;
10
+ }
11
+ export declare function runKcodeCli(args: string[], cwd?: string): KcodeCliResult;
12
+ export declare function initProject(cwd: string): KcodeCliResult;
13
+ export declare function doctor(cwd: string): KcodeCliResult;
14
+ export declare function start(cwd: string, piArgs: string[]): KcodeCliResult;
15
+ export declare function resolvePiCliCommand(piArgs?: string[]): PiCliCommand | undefined;
@@ -0,0 +1,153 @@
1
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { dirname, join, resolve } from "node:path";
3
+ import { spawnSync } from "node:child_process";
4
+ import { fileURLToPath } from "node:url";
5
+ import { createRequire } from "node:module";
6
+ const packageRoot = dirname(dirname(dirname(fileURLToPath(import.meta.url))));
7
+ const require = createRequire(import.meta.url);
8
+ export function runKcodeCli(args, cwd = process.cwd()) {
9
+ const command = args[0] ?? "help";
10
+ switch (command) {
11
+ case "init":
12
+ return initProject(cwd);
13
+ case "doctor":
14
+ return doctor(cwd);
15
+ case "start":
16
+ return start(cwd, args.slice(1));
17
+ case "help":
18
+ case "--help":
19
+ case "-h":
20
+ return { exitCode: 0, output: helpText() };
21
+ default:
22
+ return { exitCode: 1, output: `未知命令:${command}\n\n${helpText()}` };
23
+ }
24
+ }
25
+ export function initProject(cwd) {
26
+ const settingsPath = projectSettingsPath(cwd);
27
+ const settings = readSettings(settingsPath);
28
+ const kcodePackage = normalizePath(packageRoot);
29
+ const packages = settings.packages ?? [];
30
+ if (!packages.includes(kcodePackage)) {
31
+ packages.unshift(kcodePackage);
32
+ }
33
+ settings.packages = packages;
34
+ mkdirSync(dirname(settingsPath), { recursive: true });
35
+ writeFileSync(settingsPath, `${JSON.stringify(settings, null, 2)}\n`, "utf8");
36
+ return {
37
+ exitCode: 0,
38
+ output: [`已更新项目级 Pi 配置:${settingsPath}`, `已加入 KCode package:${kcodePackage}`].join("\n"),
39
+ };
40
+ }
41
+ export function doctor(cwd) {
42
+ const lines = [];
43
+ const node = spawnSync("node", ["--version"], { encoding: "utf8" });
44
+ const piCli = resolvePiCliCommand(["--version"]);
45
+ const pi = piCli ? spawnSync(piCli.command, piCli.args, { encoding: "utf8" }) : undefined;
46
+ const settingsPath = projectSettingsPath(cwd);
47
+ lines.push(`Node:${node.status === 0 ? node.stdout.trim() : "未找到"}`);
48
+ lines.push(`Pi CLI:${formatPiCliStatus(piCli, pi)}`);
49
+ lines.push(`KCode package:${packageRoot}`);
50
+ lines.push(`项目配置:${existsSync(settingsPath) ? settingsPath : "未创建,请先运行 kcode init"}`);
51
+ if (existsSync(settingsPath)) {
52
+ const settings = readSettings(settingsPath);
53
+ const hasKcode = (settings.packages ?? []).includes(normalizePath(packageRoot));
54
+ lines.push(`KCode package 已登记:${hasKcode ? "是" : "否"}`);
55
+ }
56
+ return {
57
+ exitCode: pi?.status === 0 ? 0 : 1,
58
+ output: lines.join("\n"),
59
+ };
60
+ }
61
+ export function start(cwd, piArgs) {
62
+ const init = initProject(cwd);
63
+ const piCli = resolvePiCliCommand(piArgs);
64
+ if (!piCli) {
65
+ return {
66
+ exitCode: 1,
67
+ output: `${init.output}\n未找到随包 Pi CLI 或全局 pi 命令。请重新安装 kcode-cli 后再运行 kcode start。`,
68
+ };
69
+ }
70
+ const pi = spawnSync(piCli.command, piCli.args, { cwd, stdio: "inherit", shell: false });
71
+ if (pi.error || pi.status === null) {
72
+ return {
73
+ exitCode: 1,
74
+ output: `${init.output}\nPi CLI 启动失败:${pi.error?.message ?? piCli.displayPath}`,
75
+ };
76
+ }
77
+ return {
78
+ exitCode: pi.status,
79
+ output: init.output,
80
+ };
81
+ }
82
+ export function resolvePiCliCommand(piArgs = []) {
83
+ const bundledPi = bundledPiCliPath();
84
+ if (bundledPi) {
85
+ return {
86
+ command: process.execPath,
87
+ args: [bundledPi, ...piArgs],
88
+ source: "bundled",
89
+ displayPath: bundledPi,
90
+ };
91
+ }
92
+ return {
93
+ command: "pi",
94
+ args: piArgs,
95
+ source: "global",
96
+ displayPath: "pi",
97
+ };
98
+ }
99
+ function projectSettingsPath(cwd) {
100
+ return join(cwd, ".pi", "settings.json");
101
+ }
102
+ function readSettings(path) {
103
+ if (!existsSync(path))
104
+ return {};
105
+ return JSON.parse(readFileSync(path, "utf8"));
106
+ }
107
+ function normalizePath(path) {
108
+ return resolve(path);
109
+ }
110
+ function bundledPiCliPath() {
111
+ const directPath = join(packageRoot, "node_modules", "@earendil-works", "pi-coding-agent", "dist", "cli.js");
112
+ if (existsSync(directPath))
113
+ return directPath;
114
+ try {
115
+ const mainPath = require.resolve("@earendil-works/pi-coding-agent");
116
+ const packageDir = dirname(dirname(mainPath));
117
+ const cliPath = join(packageDir, "dist", "cli.js");
118
+ return existsSync(cliPath) ? cliPath : undefined;
119
+ }
120
+ catch {
121
+ return undefined;
122
+ }
123
+ }
124
+ function formatPiCliStatus(piCli, result) {
125
+ if (!piCli || result?.status !== 0) {
126
+ return "未找到";
127
+ }
128
+ const version = result.stdout?.toString().trim() || result.stderr?.toString().trim() || piCliPackageVersion(piCli) || "可用";
129
+ const source = piCli.source === "bundled" ? "随包" : "全局";
130
+ return `${version}(${source}:${piCli.displayPath})`;
131
+ }
132
+ function piCliPackageVersion(piCli) {
133
+ if (piCli.source !== "bundled")
134
+ return undefined;
135
+ try {
136
+ const packageJsonPath = join(dirname(dirname(piCli.displayPath)), "package.json");
137
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8"));
138
+ return packageJson.version;
139
+ }
140
+ catch {
141
+ return undefined;
142
+ }
143
+ }
144
+ function helpText() {
145
+ return [
146
+ "KCode 企业入口",
147
+ "",
148
+ "用法:",
149
+ " kcode init 初始化当前项目的 .pi/settings.json",
150
+ " kcode doctor 检查 Node、随包 Pi CLI、KCode package 和项目级配置",
151
+ " kcode start 初始化项目配置后启动 KCode 工作环境",
152
+ ].join("\n");
153
+ }
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env node
2
+ import { runKcodeCli } from "./kcode.js";
3
+ const result = runKcodeCli(process.argv.slice(2));
4
+ if (result.output) {
5
+ console.log(result.output);
6
+ }
7
+ process.exitCode = result.exitCode;
@@ -0,0 +1,91 @@
1
+ # KCode 发行版方案
2
+
3
+ ## 目标
4
+
5
+ KCode 不 fork Pi,也不替换 Pi 生态。KCode 提供一个企业入口,自动携带 Pi CLI,并把 KCodeV2 和经过审查的 Pi packages 以项目级配置方式组合起来。
6
+
7
+ 核心目标:
8
+
9
+ - 保留原生 Pi 的安装、升级、package 管理和用户生态。
10
+ - 不修改用户全局 Pi 配置。
11
+ - 不强制安装未审查的第三方 package。
12
+ - 支持项目内复现同一套金蝶开发环境。
13
+ - 不要求用户额外安装全局 `pi` 命令。
14
+
15
+ ## 推荐结构
16
+
17
+ ```text
18
+ kcode-pi 当前仓库,作为 Pi package 提供金蝶工具、skills、prompts、themes。
19
+ kcode cli 启动器,负责项目初始化、环境检查和启动随包 Pi CLI。
20
+ ```
21
+
22
+ `kcode` 启动器只管理当前项目的 `.pi/settings.json`,不写 `~/.pi` 或其他用户全局目录。启动时优先调用随包 `@earendil-works/pi-coding-agent` 的 `dist/cli.js`,仅在随包 CLI 缺失时回退全局 `pi`。
23
+
24
+ ## 项目级配置
25
+
26
+ `kcode init` 生成或更新当前项目:
27
+
28
+ ```text
29
+ .pi/settings.json
30
+ ```
31
+
32
+ 默认只写入当前 KCodeV2 package:
33
+
34
+ ```json
35
+ {
36
+ "packages": [
37
+ "E:\\projects\\kingdee\\KCodeV2"
38
+ ]
39
+ }
40
+ ```
41
+
42
+ 后续如需接入第三方 Pi package,先进入 allowlist,再固定版本写入项目配置:
43
+
44
+ ```json
45
+ {
46
+ "packages": [
47
+ "E:\\projects\\kingdee\\KCodeV2",
48
+ "npm:pi-subagents@1.2.3"
49
+ ]
50
+ }
51
+ ```
52
+
53
+ ## 第三方 package 策略
54
+
55
+ 默认不内置第三方 package。
56
+
57
+ 允许接入前必须检查:
58
+
59
+ - package 来源和维护状态。
60
+ - license 是否允许企业内部分发。
61
+ - 是否注册 extensions、hooks、commands、tools。
62
+ - 是否写全局配置或访问敏感路径。
63
+ - 是否与 KCode harness、权限策略、上下文策略冲突。
64
+
65
+ 通过审查后有两种接入方式:
66
+
67
+ 1. 项目级推荐安装:写入 `.pi/settings.json`。
68
+ 2. 离线内置:写入 `dependencies` 和 `bundledDependencies`,并在 `package.json -> pi` 中显式引用其资源。
69
+
70
+ 优先使用项目级推荐安装。只有离线交付或强依赖时,才考虑离线内置。
71
+
72
+ ## 命令设计
73
+
74
+ ```text
75
+ kcode init 初始化当前项目的 .pi/settings.json
76
+ kcode doctor 检查 Node、随包 Pi CLI、KCode package、项目级 settings
77
+ kcode start 初始化后启动 KCode 工作环境
78
+ ```
79
+
80
+ ## 不破坏 Pi 生态的边界
81
+
82
+ - 不 fork Pi 核心。
83
+ - 不改用户全局 Pi 配置。
84
+ - 不覆盖用户已安装 package。
85
+ - 不自动安装未在 allowlist 中的 package。
86
+ - 不把第三方 package 静默 bundle 进 KCodeV2。
87
+ - 所有新增 package 固定版本,变更必须记录。
88
+
89
+ ## 当前限制
90
+
91
+ 当前仍是仓库内启动器原型,尚未拆成独立 npm 全局包。真实交互式 Pi runtime smoke 需要在具备可用模型/API 配置的环境中执行。