@hoplogic/hopjit 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 (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +99 -0
  3. package/dist/act-body-interpreter.d.ts +24 -0
  4. package/dist/act-body-interpreter.js +159 -0
  5. package/dist/act-body-parser.d.ts +10 -0
  6. package/dist/act-body-parser.js +577 -0
  7. package/dist/act-builtins.d.ts +12 -0
  8. package/dist/act-builtins.js +104 -0
  9. package/dist/ast-helpers.d.ts +26 -0
  10. package/dist/ast-helpers.js +58 -0
  11. package/dist/ast-runtime.d.ts +49 -0
  12. package/dist/ast-runtime.js +224 -0
  13. package/dist/ast-types.d.ts +260 -0
  14. package/dist/ast-types.js +4 -0
  15. package/dist/cli-types.d.ts +190 -0
  16. package/dist/cli-types.js +4 -0
  17. package/dist/cli.d.ts +26 -0
  18. package/dist/cli.js +623 -0
  19. package/dist/dispatcher.d.ts +92 -0
  20. package/dist/dispatcher.js +692 -0
  21. package/dist/doc-ref.d.ts +41 -0
  22. package/dist/doc-ref.js +214 -0
  23. package/dist/engine-traverse.d.ts +37 -0
  24. package/dist/engine-traverse.js +385 -0
  25. package/dist/engine.d.ts +141 -0
  26. package/dist/engine.js +1792 -0
  27. package/dist/errors.d.ts +47 -0
  28. package/dist/errors.js +34 -0
  29. package/dist/hoplog.d.ts +120 -0
  30. package/dist/hoplog.js +501 -0
  31. package/dist/parser.d.ts +7 -0
  32. package/dist/parser.js +802 -0
  33. package/dist/persistence.d.ts +60 -0
  34. package/dist/persistence.js +208 -0
  35. package/dist/prompt.d.ts +130 -0
  36. package/dist/prompt.js +1014 -0
  37. package/dist/provider-types.d.ts +134 -0
  38. package/dist/provider-types.js +3 -0
  39. package/dist/runtime-types.d.ts +84 -0
  40. package/dist/runtime-types.js +4 -0
  41. package/dist/tools.d.ts +16 -0
  42. package/dist/tools.js +141 -0
  43. package/dist/validator.d.ts +23 -0
  44. package/dist/validator.js +959 -0
  45. package/driver/codex/AGENTS.md +54 -0
  46. package/driver/hopskill-build/SKILL.md +137 -0
  47. package/driver/hopskill-build/references/spec-skeleton.md +132 -0
  48. package/driver/hopskill-build/references/step-type-cheatsheet.md +56 -0
  49. package/driver/hopskill-build/references/three-focus-rules.md +148 -0
  50. package/driver/hopspec-skill.md +187 -0
  51. package/driver/references/cli-discovery.md +36 -0
  52. package/driver/references/discovery.md +45 -0
  53. package/driver/references/driver-subagent.md +50 -0
  54. package/driver/references/parallel-worker.md +50 -0
  55. package/driver/references/step-execution-rules.md +47 -0
  56. package/package.json +52 -0
@@ -0,0 +1,141 @@
1
+ import { VariableStore, type StepStatus } from './ast-runtime.js';
2
+ import { HopLog, type LogLevel } from './hoplog.js';
3
+ import type { PersistenceProvider, HostConfig } from './provider-types.js';
4
+ import type { ExecEvent, FailKind } from './runtime-types.js';
5
+ import type { SpecAST } from './ast-types.js';
6
+ import type { InitResponse, NextResponse, CommandResponse, StatusResponse, VarsResponse, ReplanResponse, ParallelReady, FanoutScheduleResult } from './cli-types.js';
7
+ /** ExecutionEngine 构造/初始化选项——状态目录、持久化、日志、Inputs 实参、call/parallel 子实例参数等。见 [[exec-engine#^anc-struct-exec-engine]] */
8
+ export interface EngineOptions {
9
+ stateDir?: string;
10
+ persistence?: PersistenceProvider;
11
+ logDir?: string;
12
+ logLevel?: LogLevel;
13
+ params?: Record<string, unknown>;
14
+ parentInstanceId?: string;
15
+ callStepId?: string;
16
+ traceId?: string;
17
+ canFanout?: boolean;
18
+ subtreeRoot?: string;
19
+ specPath?: string;
20
+ cliAbsPath?: string;
21
+ contextMode?: 'full' | 'minimal';
22
+ }
23
+ /** HopJIT 执行状态机——驱动 HopSpec 从初始化到终态,管理步骤状态机/树状变量作用域/retry-adaptive 配额/None 传播。见 [[exec-engine#^anc-struct-exec-engine]] */
24
+ export declare class ExecutionEngine {
25
+ private instanceId;
26
+ private spec;
27
+ private hostConfig;
28
+ private stepStates;
29
+ private variables;
30
+ private loopCounters;
31
+ private retryCounters;
32
+ private retryHistory;
33
+ private replanCounters;
34
+ private lastReplanChildren;
35
+ private adaptiveNeededSubtask;
36
+ private execEvents;
37
+ private stepFailReasons;
38
+ private stateDir;
39
+ private instanceDir;
40
+ private persistence;
41
+ private logDir;
42
+ private hoplog;
43
+ private canFanout;
44
+ private subtreeRoot;
45
+ private specPath;
46
+ private cliAbsPath;
47
+ private dispatched;
48
+ private joinStartedAt;
49
+ private maxConcurrent;
50
+ private forEachWorkerIdx;
51
+ private contextMode;
52
+ initExecution(specMarkdown: string, hostConfig: HostConfig, options?: EngineOptions): InitResponse;
53
+ getSpec(): SpecAST | null;
54
+ getInstanceId(): string;
55
+ getStepStates(): Map<string, StepStatus>;
56
+ getVariableStore(): VariableStore;
57
+ getExecEvents(): ExecEvent[];
58
+ getLoopCounters(): Map<string, number>;
59
+ getHopLog(): HopLog | null;
60
+ setCanFanout(on: boolean): void;
61
+ getCanFanout(): boolean;
62
+ getSubtreeRoot(): string | null;
63
+ setContextMode(mode: 'full' | 'minimal'): void;
64
+ getContextMode(): 'full' | 'minimal';
65
+ private isMinimalNonFirst;
66
+ getInstanceDir(): string | null;
67
+ getHopLogRunDir(): string | null;
68
+ /** 顶层步骤是否全部终态(done/failed/skipped)。终态判据单点复用 isTerminalStatus。 */
69
+ private allTopLevelTerminal;
70
+ nextStep(): NextResponse;
71
+ completeStep(stepId: string, outputs?: Record<string, unknown>): CommandResponse;
72
+ completeAndAdvance(stepId: string, outputs?: Record<string, unknown>): Promise<NextResponse | CommandResponse>;
73
+ advanceToCaller(): Promise<NextResponse>;
74
+ nextParallelBatch(): ParallelReady | null;
75
+ private resolveChildParams;
76
+ fanoutSchedule(parallelStepId: string): FanoutScheduleResult;
77
+ private isChildTerminal;
78
+ private buildWorkerLaunchCommand;
79
+ private childLogDir;
80
+ private buildJoinCommand;
81
+ joinParallel(parallelStepId: string, childResults: Record<string, {
82
+ vars: Record<string, unknown>;
83
+ failed: boolean;
84
+ log?: string;
85
+ }>): CommandResponse;
86
+ /** parallel join 两分支(for-each / static)共同尾段:记 parallel 完成 + join 审计 + 落盘 + 返回 ok。 */
87
+ private finalizeParallelJoin;
88
+ private isCallerActionPoint;
89
+ completeCallStep(callStepId: string, childVars: Record<string, unknown>): CommandResponse;
90
+ failStep(stepId: string, reason: string, failKind?: FailKind): CommandResponse;
91
+ submitReplan(subtaskId: string, stepsMd: string): ReplanResponse;
92
+ selectBranch(stepId: string, selectedCaseId: string, reason?: string): CommandResponse;
93
+ getStatus(): StatusResponse;
94
+ getVars(): VarsResponse;
95
+ /** 递归把子树所有步骤置 pending(init 时初始化 / retry 时重置——同一操作,单点定义)。 */
96
+ private setSubtreePending;
97
+ private executeSubtreeOnly;
98
+ private findFirstFailedStep;
99
+ private propagateAndRecord;
100
+ getWorkZone(): string;
101
+ private resolveRawInputs;
102
+ private deflateValues;
103
+ private findStepById;
104
+ private collectOutputs;
105
+ private assembleBasicContext;
106
+ private resolveStepDocRefs;
107
+ private pendingDocRefSources;
108
+ private flushDocRefMeta;
109
+ private determineExecutionStatus;
110
+ private getFailureReason;
111
+ private handleFailStepRetry;
112
+ getActiveRetryFeedback(stepId: string): {
113
+ attempt: number;
114
+ reason: string;
115
+ } | undefined;
116
+ private extractDecision;
117
+ private mapConfirmOutputs;
118
+ private mapAskOutputs;
119
+ private findNearestSubtaskAncestor;
120
+ private resetSubtaskForRetry;
121
+ private markSubtaskFailed;
122
+ private removeChildStates;
123
+ private reIdSteps;
124
+ private skipAllDescendants;
125
+ /** 把步骤节点投影为 StepSummary(step_id/type/summary/输出名)。单点定义——四处(adaptive
126
+ * original_children、replan 两处、summarizeChildren)复用,字段增减只改这里。 */
127
+ private toStepSummary;
128
+ private summarizeChildren;
129
+ private recordEvent;
130
+ private recordStepFailure;
131
+ private persist;
132
+ private buildStateFile;
133
+ static load(instanceDir: string): ExecutionEngine;
134
+ static recover(instanceDir: string): ExecutionEngine;
135
+ private hasBranchSelection;
136
+ private validateCheckPreservation;
137
+ private hasCheckStep;
138
+ private getCheckFinallySteps;
139
+ private isReplanDuplicate;
140
+ private jaccardSimilarity;
141
+ }