@xcompiler/cli 0.2.2 → 0.2.3

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.
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
 
3
- declare const XCOMPILER_VERSION = "0.2.2";
3
+ declare const XCOMPILER_VERSION = "0.2.3";
4
4
  declare const XCOMPILER_PLUGIN_API_VERSION = 1;
5
5
 
6
6
  /** Supported target languages for generated projects. */
@@ -72,6 +72,7 @@ declare const PlanSchema: z.ZodPipe<z.ZodObject<{
72
72
  refactor: "refactor";
73
73
  self: "self";
74
74
  }>>;
75
+ phaseId: z.ZodDefault<z.ZodString>;
75
76
  projectType: z.ZodDefault<z.ZodEnum<{
76
77
  application: "application";
77
78
  library: "library";
@@ -165,6 +166,7 @@ declare const PlanSchema: z.ZodPipe<z.ZodObject<{
165
166
  version: "1";
166
167
  language: "python" | "typescript";
167
168
  intent: "greenfield" | "feature" | "refactor" | "self";
169
+ phaseId: string;
168
170
  projectType: "application" | "library" | "mixed";
169
171
  requirementDigest: string;
170
172
  globalPrompt: string;
@@ -221,6 +223,7 @@ declare const PlanSchema: z.ZodPipe<z.ZodObject<{
221
223
  version: "1";
222
224
  language: "python" | "typescript";
223
225
  intent: "greenfield" | "feature" | "refactor" | "self";
226
+ phaseId: string;
224
227
  projectType: "application" | "library" | "mixed";
225
228
  requirementDigest: string;
226
229
  globalPrompt: string;
@@ -305,6 +308,12 @@ interface ChatOptions {
305
308
  * 空输出、model token loop 等“表面成功但语义不可用”场景。
306
309
  */
307
310
  validate?: (text: string) => void;
311
+ /**
312
+ * Whether a provider response should increase its dynamic score.
313
+ * Step/workflow executors should disable this and score quality through
314
+ * their own validation instead of treating "returned text" as task success.
315
+ */
316
+ scoreSuccess?: boolean;
308
317
  /**
309
318
  * 调用者可传入回调,与 LLM 输出一同拿到实际产出该响应的 provider 名。
310
319
  * 主要用于追溯:在 FallbackClient 中服务于响应的是链中某一个后选 provider,
@@ -462,7 +471,7 @@ interface Sandbox {
462
471
  /**
463
472
  * 运行工程入口程序。
464
473
  * - Python:`python <args>`(自动选用 venv 内解释器)。
465
- * - TypeScript:`npx tsx <args>`。
474
+ * - TypeScript:默认 `npx tsx <entry>`;当 args 以 `npm`/`npx`/`node`/`tsx`/`tsc` 开头时执行对应项目命令。
466
475
  */
467
476
  runProgram(args: string[], extra?: ExecExtra): Promise<ExecResult>;
468
477
  /**
@@ -524,6 +533,8 @@ interface ToolContext {
524
533
  language?: Language;
525
534
  /** 当前 Step 的 write_file / append_file 单次 content 字节预算。 */
526
535
  writeChunkBytes?: number;
536
+ /** run_tests 未提供有效过滤参数时使用的当前阶段默认测试范围。 */
537
+ defaultTestArgs?: string[];
527
538
  /** Optional protocol/UI permission hook for sensitive tool operations. */
528
539
  requestPermission?: ToolPermissionRequester;
529
540
  /** Optional protocol/UI event hook for tool calls and file changes. */
@@ -600,6 +611,8 @@ interface HookContextMap {
600
611
  'compile.finish': {
601
612
  plan: Plan;
602
613
  planPath: string;
614
+ phasePlanPath?: string;
615
+ currentPlanPath?: string;
603
616
  };
604
617
  'run.before': {
605
618
  plan: Plan;
@@ -845,7 +858,7 @@ interface CompileOptions {
845
858
  * 已澄清的 topic.md 直接输入:跳过 intake / clarify / Addenda / Gate 1,把该文件
846
859
  * 内容当作冻结后的项目选题书,直接进入 decompose。常用于:
847
860
  * - 用户上次已澄清并保留了 topic.md,重新跑 decompose 不想再问一遍
848
- * - 离线编辑了 topic.md 想直接拿来出 plan.json
861
+ * - 离线编辑了 topic.md 想直接拿来出 phasePlan.json 与当前阶段计划
849
862
  * 与 --input 互斥;同时给则 --topic 优先并打印警告。
850
863
  */
851
864
  topicFile?: string;
@@ -873,41 +886,65 @@ declare function runCompile(opts: CompileOptions): Promise<{
873
886
  planPath?: string;
874
887
  }>;
875
888
 
889
+ interface ScoreStoreOptions {
890
+ /** Providers tagged as aggregated/route pools such as OpenRouter free mode. */
891
+ clusterProviderNames?: string[];
892
+ /** Dynamic score floor for cluster providers. Defaults to 0.2. */
893
+ clusterScoreMin?: number;
894
+ /** Dynamic score cap and default score for cluster providers. Defaults to 0.5. */
895
+ clusterScoreMax?: number;
896
+ }
876
897
  /**
877
898
  * 每个 LLM provider 的运行时评分(默认 1.0)。
878
899
  *
879
900
  * 设计动机:
880
901
  * - 配置允许给一个角色挂多个 provider;运行时按评分降序选择当前"最可信"的。
881
- * - 评分会随成功/失败动态调整:失败 -0.5 直到 0(=禁用);成功 +0.1 直到 cap=10
882
- * - preflight 检测到 ollama 服务器上**模型不存在**会直接把评分置 0。
902
+ * - 评分会随成功/失败动态调整:失败 -0.5 直到 0.1;成功 +0.1 直到 cap=1
903
+ * - 只有用户在配置中显式设置 score=0 才表示禁用;运行时自动评分不会写出 0。
904
+ * - preflight 检测到 ollama 服务器上**模型不存在**会在当前运行跳过该 provider,并把评分降到 0.1。
883
905
  * - 持久化到 config 同目录的 sidecar 文件 `llm_scores.yaml`,避免改写用户的 config.yaml
884
906
  * (会丢注释)。配置里 `llm.scores` 段作为 sidecar 缺失时的初值。
885
907
  */
886
908
  declare class ScoreStore {
887
909
  private readonly audit?;
888
910
  static readonly DEFAULT = 1;
889
- static readonly MIN = 0;
890
- static readonly MAX = 10;
911
+ static readonly DISABLED = 0;
912
+ static readonly MIN = 0.1;
913
+ static readonly MAX = 1;
914
+ static readonly CLUSTER_MIN = 0.2;
915
+ static readonly CLUSTER_MAX = 0.5;
891
916
  static readonly DECAY = 0.5;
892
917
  static readonly BOOST = 0.1;
893
918
  private readonly scores;
919
+ private readonly userDisabled;
920
+ private readonly clusterProviders;
921
+ private readonly clusterMin;
922
+ private readonly clusterMax;
894
923
  private dirty;
895
924
  private writeQueue;
896
925
  private readonly sidecarPath;
897
- constructor(configPath: string, initial?: Record<string, number>, audit?: AuditLogger | undefined);
926
+ constructor(configPath: string, initial?: Record<string, number>, audit?: AuditLogger | undefined, opts?: ScoreStoreOptions);
898
927
  /** 异步加载 sidecar 文件;失败/不存在不抛错,使用 ctor 提供的初值。 */
899
928
  load(): Promise<void>;
900
929
  get(name: string): number;
901
- /** 主动设置评分(如 preflight 把不存在的模型置 0)。 */
930
+ /** 主动设置评分;value=0 仅用于显式禁用,其它值会归一到动态范围。 */
902
931
  set(name: string, value: number, reason?: string): void;
903
932
  decay(name: string, reason: string): void;
904
933
  boost(name: string, reason: string): void;
934
+ /** True only for providers explicitly disabled by user config (`llm.scores.<provider>: 0`). */
935
+ isUserDisabled(name: string): boolean;
905
936
  /** 全量快照(用于测试与 audit 输出)。 */
906
937
  snapshot(): Record<string, number>;
907
938
  /** 等待待写入完成(CLI 退出前调用,确保评分已落盘)。 */
908
939
  flush(): Promise<void>;
909
940
  private scheduleSave;
910
941
  private persist;
942
+ private defaultFor;
943
+ private minFor;
944
+ private maxFor;
945
+ private isClusterProvider;
946
+ private clampConfigured;
947
+ private clampDynamic;
911
948
  }
912
949
 
913
950
  /** 插件注册、扩展能力合并与生命周期 Hook 调度中心。 */
@@ -1130,7 +1167,7 @@ declare function runDoctorCommand(opts?: RuntimeDoctorOptions): Promise<RuntimeD
1130
1167
 
1131
1168
  interface LsOptions {
1132
1169
  workspace: string;
1133
- /** Maximum depth for recursively finding plan.json files. Defaults to 4. */
1170
+ /** Maximum depth for recursively finding phasePlan.json / legacy plan.json files. Defaults to 4. */
1134
1171
  maxDepth?: number;
1135
1172
  }
1136
1173
  interface PlanSummary {