kcode-pi 0.1.20 → 0.1.23

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.
@@ -47,11 +47,12 @@ export function defaultArtifactContent(phase: KdPhase, goal?: string, profile?:
47
47
  "- 版本:未知",
48
48
  `- 技术栈:${profile?.techStack ?? "未知"}`,
49
49
  `- 语言:${profile?.language ?? "未知"}`,
50
- "- 插件类型:未知",
51
- "- 目标单据/实体/表单:未知",
50
+ "- 需求条目:未知",
51
+ "- 目标对象:未知",
52
+ "- 依赖和批次:未知",
52
53
  "- 非目标范围:未知",
53
54
  "- 待确认问题:",
54
- " - 确认金蝶产品/版本、技术栈、插件类型和目标对象。",
55
+ " - 从需求来源中提取可确认事实;只把无法判断且阻塞推进的关键点列为待确认。",
55
56
  "",
56
57
  ].join("\n");
57
58
  case "spec":
@@ -60,9 +61,11 @@ export function defaultArtifactContent(phase: KdPhase, goal?: string, profile?:
60
61
  "",
61
62
  "## 验收标准",
62
63
  "",
63
- "## 生命周期 / 扩展点",
64
+ "## 需求条目",
64
65
  "",
65
- "## 数据对象和字段",
66
+ "## 数据对象、字段或影响范围",
67
+ "",
68
+ "## 依赖和批次",
66
69
  "",
67
70
  "## 异常行为和性能约束",
68
71
  "",
@@ -81,12 +84,21 @@ export function defaultArtifactContent(phase: KdPhase, goal?: string, profile?:
81
84
  "",
82
85
  "## 允许修改的文件",
83
86
  "",
87
+ "## 产品实现范围",
88
+ "",
89
+ "- 是否涉及产品实现、构建、元数据或 SDK 查证:待确认",
90
+ "- 判断依据:待确认",
91
+ "",
84
92
  "## 必需的金蝶查证项",
85
93
  "",
86
94
  "- Java/C# 代码涉及 SDK 类、方法、构造器、枚举、属性时,必须先用 kd_sdk_signature 或项目构建输出确认真实签名。",
87
95
  "- 知识库搜索、随包 Cosmic API 查询只能作为线索,不能作为最终方法签名事实。",
88
96
  "- SDK 签名证据:evidence/sdk-signature.md",
89
97
  "",
98
+ "## 需求条目 / 依赖 / 批次",
99
+ "",
100
+ "## 验收与验证对应关系",
101
+ "",
90
102
  "## 执行步骤",
91
103
  "",
92
104
  "- [ ] STEP-001:检查现有目标文件,确认精确修改位置。",
@@ -37,8 +37,9 @@ function collectGateProblems(cwd: string, run: ActiveRun, phase: KdPhase, mode:
37
37
  const missing: string[] = [];
38
38
  const reasonParts: string[] = [];
39
39
 
40
- if (phase !== "discuss" && !isKnownProduct(run.profile?.product ?? run.product)) {
41
- reasonParts.push(unknownProductReason());
40
+ if (phaseIndex >= PHASE_ORDER.indexOf("execute") && !isKnownProduct(run.profile?.product ?? run.product)) {
41
+ const declaration = productImplementationDeclaration(cwd, run);
42
+ if (declaration !== false) reasonParts.push(unknownProductReason(declaration));
42
43
  }
43
44
 
44
45
  if (phaseIndex >= PHASE_ORDER.indexOf("ship") && !hasRiskAssessment(cwd, run)) {
@@ -103,8 +104,24 @@ function gateResult(reasonParts: string[]): GateResult {
103
104
  };
104
105
  }
105
106
 
106
- function unknownProductReason(): string {
107
- return "不能离开 discuss:产品画像未知。下一步:根据需求或用户回答确认产品,然后执行 /kd-product <flagship|cosmic|xinghan|cangqiong|enterprise>;如果无法判断,先用 kd_question 只问一个最阻塞的产品确认问题。";
107
+ function unknownProductReason(declaration: boolean | undefined): string {
108
+ if (declaration === undefined) {
109
+ return "不能进入 execute:产品画像未知,且 PLAN.md 未明确声明是否涉及产品实现、构建、元数据或 SDK 查证。下一步:先由当前需求和项目计划判断该范围;如果涉及产品实现,执行 /kd-product <flagship|xinghan|cangqiong|enterprise>;如果不涉及,在 PLAN.md 的“产品实现范围”写明“不涉及”及依据。";
110
+ }
111
+ return "不能进入 execute:PLAN.md 声明涉及产品实现、构建、元数据或 SDK 查证,但产品画像未知。下一步:根据需求、计划或用户回答确认产品,然后执行 /kd-product <flagship|xinghan|cangqiong|enterprise>;如果无法判断,先用 kd_question 只问一个最阻塞的产品确认问题。";
112
+ }
113
+
114
+ function productImplementationDeclaration(cwd: string, run: ActiveRun): boolean | undefined {
115
+ const plan = readArtifact(cwd, run, "plan") ?? "";
116
+ const line = plan
117
+ .split(/\r?\n/)
118
+ .map((item) => item.trim())
119
+ .find((item) => item.includes("是否涉及产品实现、构建、元数据或 SDK 查证"));
120
+ if (!line) return undefined;
121
+ const value = line.replace(/^[-*]\s*/, "").split(/[::]/).slice(1).join(":").trim();
122
+ if (/^(是|涉及|需要|yes|true)(\s|。|,|,|;|;|$)/i.test(value)) return true;
123
+ if (/^(否|不涉及|不需要|无|no|false)(\s|。|,|,|;|;|$)/i.test(value)) return false;
124
+ return undefined;
108
125
  }
109
126
 
110
127
  function hasRiskAssessment(cwd: string, run: ActiveRun): boolean {
@@ -66,7 +66,7 @@ export function finishActiveRun(cwd: string, run: ActiveRun): ActiveRun {
66
66
  }
67
67
 
68
68
  export function createActiveRun(cwd: string, goal: string, productInput?: string, version?: string): ActiveRun {
69
- const profile = resolveProductProfile(productInput ?? goal);
69
+ const profile = resolveProductProfile(productInput);
70
70
  const now = new Date().toISOString();
71
71
  const run: ActiveRun = {
72
72
  id: createRunId(goal),
@@ -155,7 +155,7 @@ export function updateRisk(cwd: string, run: ActiveRun, risk: KdRisk, reason: st
155
155
  }
156
156
 
157
157
  export function ensurePhaseArtifact(cwd: string, run: ActiveRun, phase: KdPhase): string {
158
- const path = ensureArtifact(cwd, run, phase, defaultArtifactContent(phase));
158
+ const path = ensureArtifact(cwd, run, phase, defaultArtifactContent(phase, run.goal, run.profile));
159
159
  run.artifacts[phase] = PHASE_ARTIFACTS[phase];
160
160
  run.gate = inspectGate(cwd, run);
161
161
  writeActiveRun(cwd, run);
@@ -1,4 +1,4 @@
1
- export type KdProduct = "unknown" | "flagship" | "cosmic" | "xinghan" | "cangqiong" | "enterprise";
1
+ export type KdProduct = "unknown" | "flagship" | "xinghan" | "cangqiong" | "enterprise";
2
2
  export type KdPlatform = "unknown" | "cosmic" | "enterprise-csharp" | "enterprise-python";
3
3
  export type KdTechStack = "unknown" | "java-bos" | "java-cosmic" | "csharp-bos" | "python-bos" | "ksql";
4
4
  export type KdLanguage = "unknown" | "java" | "csharp" | "python" | "sql";
@@ -24,7 +24,7 @@ const PROFILES: Record<KdProduct, ProductProfile> = {
24
24
  language: "unknown",
25
25
  knowledgeScope: "common",
26
26
  requiresMetadataVerification: true,
27
- notes: ["尚未选择产品;不要假设 Java、C#、BOSCosmic KSQL 规则。"],
27
+ notes: ["尚未选择产品;不要假设插件技术栈、BOS/Cosmic 平台规则或 KSQL/SQL 交付规则。"],
28
28
  },
29
29
  flagship: {
30
30
  product: "flagship",
@@ -35,21 +35,11 @@ const PROFILES: Record<KdProduct, ProductProfile> = {
35
35
  knowledgeScope: "flagship",
36
36
  requiresMetadataVerification: true,
37
37
  notes: [
38
- "星空旗舰版属于 Cosmic 家族。使用 Cosmic 元数据、插件生命周期、SDK 和后置检查约束。",
38
+ "星空旗舰版基于苍穹/Cosmic 平台。使用平台元数据、插件生命周期、SDK 和后置检查约束,但接口可能存在旗舰版差异。",
39
39
  "如果当前工作区存在 code/ 目录,产品代码应放在 code/ 下。",
40
40
  "创建或编辑代码前,必须检查 code/ 下真实项目结构,并跟随其实际布局;可能按云、按应用组织,也可能不分模块。",
41
41
  ],
42
42
  },
43
- cosmic: {
44
- product: "cosmic",
45
- displayName: "金蝶 Cosmic 平台",
46
- platform: "cosmic",
47
- techStack: "java-cosmic",
48
- language: "java",
49
- knowledgeScope: "cosmic",
50
- requiresMetadataVerification: true,
51
- notes: ["Cosmic 是苍穹、星瀚和星空旗舰版的共享平台基础。"],
52
- },
53
43
  xinghan: {
54
44
  product: "xinghan",
55
45
  displayName: "金蝶星瀚",
@@ -58,7 +48,7 @@ const PROFILES: Record<KdProduct, ProductProfile> = {
58
48
  language: "java",
59
49
  knowledgeScope: "xinghan",
60
50
  requiresMetadataVerification: true,
61
- notes: ["除非存在星瀚特有规则,否则按 Cosmic 家族 Java 处理。"],
51
+ notes: ["星瀚基于苍穹/Cosmic 平台。默认按平台 Java 插件处理,但接口可能存在星瀚差异。"],
62
52
  },
63
53
  cangqiong: {
64
54
  product: "cangqiong",
@@ -68,7 +58,7 @@ const PROFILES: Record<KdProduct, ProductProfile> = {
68
58
  language: "java",
69
59
  knowledgeScope: "cangqiong",
70
60
  requiresMetadataVerification: true,
71
- notes: ["使用苍穹/Cosmic 插件、SDK、元数据、KSQL 和生命周期规则。"],
61
+ notes: ["Cosmic 在 KCode 中按苍穹平台语境处理。使用苍穹/Cosmic 平台插件、SDK、元数据、KSQL/SQL 和生命周期规则。"],
72
62
  },
73
63
  enterprise: {
74
64
  product: "enterprise",
@@ -86,7 +76,7 @@ const PRODUCT_ALIASES: Array<[RegExp, KdProduct]> = [
86
76
  [/企业版|enterprise|csharp|c#|\.net/i, "enterprise"],
87
77
  [/星瀚|xinghan/i, "xinghan"],
88
78
  [/苍穹|cangqiong/i, "cangqiong"],
89
- [/cosmic|云苍穹/i, "cosmic"],
79
+ [/cosmic|云苍穹/i, "cangqiong"],
90
80
  [/星空旗舰版|星空旗舰|旗舰版|旗舰|flagship/i, "flagship"],
91
81
  ];
92
82