@xcompiler/cli 0.2.2 → 0.2.4

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.4";
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,
@@ -368,11 +377,12 @@ declare class AuditLogger {
368
377
  llmResponse(role: string, model: string, content: string, meta?: Record<string, unknown>): Promise<void>;
369
378
  llmError(role: string, model: string, err: unknown): Promise<void>;
370
379
  /**
371
- * 记录一轮 Executor 思考:thoughts 文本、计划调用的 actions、是否完成。
372
- * 写入 jsonl + markdown 折叠块,交付时可作为"AI 思考过程完整记录"。
380
+ * 记录一轮 Executor 执行摘要:简短 intent、issue 处理方案、计划调用的 actions、是否完成。
381
+ * 写入 jsonl + markdown 折叠块,交付时可追溯每轮决策和动作。
373
382
  */
374
383
  executorTurn(stepId: string, role: string, round: number, payload: {
375
384
  thoughts?: string;
385
+ issueResolutionPlan?: string;
376
386
  actions?: unknown[];
377
387
  done?: boolean;
378
388
  raw?: string;
@@ -436,11 +446,23 @@ interface ExecResult {
436
446
  stderr: string;
437
447
  timedOut: boolean;
438
448
  durationMs: number;
449
+ timeoutReason?: string;
450
+ }
451
+ interface ExecProgressWatch {
452
+ /** Host-side paths whose recursive size indicates install progress. */
453
+ paths: string[];
454
+ /** Kill the child only after this much time without size growth. */
455
+ idleTimeoutMs: number;
456
+ /** Poll interval for recursive size checks. */
457
+ checkIntervalMs?: number;
458
+ /** Human-readable label used in timeout diagnostics. */
459
+ label?: string;
439
460
  }
440
461
  interface ExecExtra {
441
462
  cwd?: string;
442
463
  env?: Record<string, string>;
443
464
  timeoutMs?: number;
465
+ progressWatch?: ExecProgressWatch;
444
466
  }
445
467
  /** 沙盒统一接口。任意 phase / tool 都通过此接口与运行时交互。 */
446
468
  interface Sandbox {
@@ -462,7 +484,7 @@ interface Sandbox {
462
484
  /**
463
485
  * 运行工程入口程序。
464
486
  * - Python:`python <args>`(自动选用 venv 内解释器)。
465
- * - TypeScript:`npx tsx <args>`。
487
+ * - TypeScript:默认 `npx tsx <entry>`;当 args 以 `npm`/`npx`/`node`/`tsx`/`tsc` 开头时执行对应项目命令。
466
488
  */
467
489
  runProgram(args: string[], extra?: ExecExtra): Promise<ExecResult>;
468
490
  /**
@@ -524,6 +546,8 @@ interface ToolContext {
524
546
  language?: Language;
525
547
  /** 当前 Step 的 write_file / append_file 单次 content 字节预算。 */
526
548
  writeChunkBytes?: number;
549
+ /** run_tests 未提供有效过滤参数时使用的当前阶段默认测试范围。 */
550
+ defaultTestArgs?: string[];
527
551
  /** Optional protocol/UI permission hook for sensitive tool operations. */
528
552
  requestPermission?: ToolPermissionRequester;
529
553
  /** Optional protocol/UI event hook for tool calls and file changes. */
@@ -600,6 +624,8 @@ interface HookContextMap {
600
624
  'compile.finish': {
601
625
  plan: Plan;
602
626
  planPath: string;
627
+ phasePlanPath?: string;
628
+ currentPlanPath?: string;
603
629
  };
604
630
  'run.before': {
605
631
  plan: Plan;
@@ -845,7 +871,7 @@ interface CompileOptions {
845
871
  * 已澄清的 topic.md 直接输入:跳过 intake / clarify / Addenda / Gate 1,把该文件
846
872
  * 内容当作冻结后的项目选题书,直接进入 decompose。常用于:
847
873
  * - 用户上次已澄清并保留了 topic.md,重新跑 decompose 不想再问一遍
848
- * - 离线编辑了 topic.md 想直接拿来出 plan.json
874
+ * - 离线编辑了 topic.md 想直接拿来出 phasePlan.json 与当前阶段计划
849
875
  * 与 --input 互斥;同时给则 --topic 优先并打印警告。
850
876
  */
851
877
  topicFile?: string;
@@ -873,41 +899,73 @@ declare function runCompile(opts: CompileOptions): Promise<{
873
899
  planPath?: string;
874
900
  }>;
875
901
 
902
+ interface ScoreStoreOptions {
903
+ /** Providers tagged as aggregated/route pools such as OpenRouter free mode. */
904
+ clusterProviderNames?: string[];
905
+ /** Dynamic score floor for cluster providers. Defaults to 0.2. */
906
+ clusterScoreMin?: number;
907
+ /** Dynamic score cap and default score for cluster providers. Defaults to 0.5. */
908
+ clusterScoreMax?: number;
909
+ }
876
910
  /**
877
911
  * 每个 LLM provider 的运行时评分(默认 1.0)。
878
912
  *
879
913
  * 设计动机:
880
914
  * - 配置允许给一个角色挂多个 provider;运行时按评分降序选择当前"最可信"的。
881
- * - 评分会随成功/失败动态调整:失败 -0.5 直到 0(=禁用);成功 +0.1 直到 cap=10
882
- * - preflight 检测到 ollama 服务器上**模型不存在**会直接把评分置 0。
883
- * - 持久化到 config 同目录的 sidecar 文件 `llm_scores.yaml`,避免改写用户的 config.yaml
884
- * (会丢注释)。配置里 `llm.scores` 段作为 sidecar 缺失时的初值。
915
+ * - 评分会随成功/失败动态调整:失败 -0.5 直到 0.1;成功 +0.1 直到 cap=1
916
+ * - `llm_scores.yaml` XCompiler 维护的动态快照;它不是用户策略文件。
917
+ * - 用户手动覆盖写在 `llm_scores_user.yaml`;其中 score=0 表示禁用,并且优先生效。
918
+ * - preflight 检测到 ollama 服务器上**模型不存在**会在当前运行跳过该 provider,并把评分降到 0.1。
919
+ * - 动态评分持久化到 config 同目录的 sidecar 文件 `llm_scores.yaml`,避免改写用户的 config.yaml
920
+ * (会丢注释)。配置里 `llm.scores` 段仅作为兼容初值;旧配置中显式 0 仍视为用户禁用。
885
921
  */
886
922
  declare class ScoreStore {
887
923
  private readonly audit?;
888
924
  static readonly DEFAULT = 1;
889
- static readonly MIN = 0;
890
- static readonly MAX = 10;
925
+ static readonly DISABLED = 0;
926
+ static readonly MIN = 0.1;
927
+ static readonly MAX = 1;
928
+ static readonly CLUSTER_MIN = 0.2;
929
+ static readonly CLUSTER_MAX = 0.5;
891
930
  static readonly DECAY = 0.5;
892
931
  static readonly BOOST = 0.1;
893
- private readonly scores;
932
+ private readonly dynamicScores;
933
+ private readonly userScores;
934
+ private readonly clusterProviders;
935
+ private readonly clusterMin;
936
+ private readonly clusterMax;
894
937
  private dirty;
895
938
  private writeQueue;
896
939
  private readonly sidecarPath;
897
- constructor(configPath: string, initial?: Record<string, number>, audit?: AuditLogger | undefined);
898
- /** 异步加载 sidecar 文件;失败/不存在不抛错,使用 ctor 提供的初值。 */
940
+ private readonly userScoresPath;
941
+ constructor(configPath: string, initial?: Record<string, number>, audit?: AuditLogger | undefined, opts?: ScoreStoreOptions);
942
+ /** 异步加载动态 sidecar 与用户覆盖文件;失败/不存在不抛错,使用 ctor 提供的初值。 */
899
943
  load(): Promise<void>;
944
+ private loadDynamicScores;
945
+ private loadUserScores;
900
946
  get(name: string): number;
901
- /** 主动设置评分(如 preflight 把不存在的模型置 0)。 */
947
+ /** 主动设置动态评分;用户覆盖只从配置或 llm_scores_user.yaml 读取。 */
902
948
  set(name: string, value: number, reason?: string): void;
903
949
  decay(name: string, reason: string): void;
904
950
  boost(name: string, reason: string): void;
905
- /** 全量快照(用于测试与 audit 输出)。 */
951
+ /** True only for providers explicitly disabled by user config or llm_scores_user.yaml. */
952
+ isUserDisabled(name: string): boolean;
953
+ /** 动态评分快照(用于持久化、测试与 audit 输出;不包含用户覆盖)。 */
906
954
  snapshot(): Record<string, number>;
955
+ /** 用户覆盖快照(用于测试/诊断;运行时不会改写用户文件)。 */
956
+ userSnapshot(): Record<string, number>;
907
957
  /** 等待待写入完成(CLI 退出前调用,确保评分已落盘)。 */
908
958
  flush(): Promise<void>;
909
959
  private scheduleSave;
910
960
  private persist;
961
+ private defaultFor;
962
+ private minFor;
963
+ private maxFor;
964
+ private isClusterProvider;
965
+ private dynamicScore;
966
+ private clampDynamic;
967
+ private clampPersistedDynamic;
968
+ private clampUserScore;
911
969
  }
912
970
 
913
971
  /** 插件注册、扩展能力合并与生命周期 Hook 调度中心。 */
@@ -975,6 +1033,8 @@ interface ExecuteOptions {
975
1033
  force?: boolean;
976
1034
  /** Optional XXX.xc project file to keep in sync with execution progress. */
977
1035
  projectFilePath?: string;
1036
+ /** Optional debug wiki root directory. Defaults to XCompiler's own .xcompiler/debug-wiki. */
1037
+ debugWikiPath?: string;
978
1038
  /** Project-file history command label; defaults to run. */
979
1039
  projectCommand?: string;
980
1040
  /** Whether to append a history row when execution starts; defaults to true. */
@@ -1017,6 +1077,7 @@ declare function runBuildCommand(opts: RuntimeBuildCommandOptions): Promise<Runt
1017
1077
  type RuntimeEvolveCommandOptions = Omit<CompileOptions, 'workspace' | 'outputFile' | 'projectCommand'> & WorkspaceOptions & {
1018
1078
  planOut?: string;
1019
1079
  cwd?: string;
1080
+ debugWikiPath?: string;
1020
1081
  };
1021
1082
  interface RuntimeEvolveCommandResult {
1022
1083
  workspace: string;
@@ -1038,6 +1099,7 @@ declare function runLoadCommand(opts: RuntimeLoadCommandOptions): Promise<Execut
1038
1099
  type RuntimeAppendCommandOptions = Omit<CompileOptions, 'workspace' | 'baselinePlanFile' | 'outputFile' | 'projectFilePath' | 'projectCommand'> & {
1039
1100
  projectFile: string;
1040
1101
  planOut?: string;
1102
+ debugWikiPath?: string;
1041
1103
  };
1042
1104
  interface RuntimeAppendCommandResult {
1043
1105
  workspace: string;
@@ -1130,7 +1192,7 @@ declare function runDoctorCommand(opts?: RuntimeDoctorOptions): Promise<RuntimeD
1130
1192
 
1131
1193
  interface LsOptions {
1132
1194
  workspace: string;
1133
- /** Maximum depth for recursively finding plan.json files. Defaults to 4. */
1195
+ /** Maximum depth for recursively finding phasePlan.json / legacy plan.json files. Defaults to 4. */
1134
1196
  maxDepth?: number;
1135
1197
  }
1136
1198
  interface PlanSummary {