@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.
- package/LICENSE +21 -0
- package/README.md +99 -0
- package/dist/act-body-interpreter.d.ts +24 -0
- package/dist/act-body-interpreter.js +159 -0
- package/dist/act-body-parser.d.ts +10 -0
- package/dist/act-body-parser.js +577 -0
- package/dist/act-builtins.d.ts +12 -0
- package/dist/act-builtins.js +104 -0
- package/dist/ast-helpers.d.ts +26 -0
- package/dist/ast-helpers.js +58 -0
- package/dist/ast-runtime.d.ts +49 -0
- package/dist/ast-runtime.js +224 -0
- package/dist/ast-types.d.ts +260 -0
- package/dist/ast-types.js +4 -0
- package/dist/cli-types.d.ts +190 -0
- package/dist/cli-types.js +4 -0
- package/dist/cli.d.ts +26 -0
- package/dist/cli.js +623 -0
- package/dist/dispatcher.d.ts +92 -0
- package/dist/dispatcher.js +692 -0
- package/dist/doc-ref.d.ts +41 -0
- package/dist/doc-ref.js +214 -0
- package/dist/engine-traverse.d.ts +37 -0
- package/dist/engine-traverse.js +385 -0
- package/dist/engine.d.ts +141 -0
- package/dist/engine.js +1792 -0
- package/dist/errors.d.ts +47 -0
- package/dist/errors.js +34 -0
- package/dist/hoplog.d.ts +120 -0
- package/dist/hoplog.js +501 -0
- package/dist/parser.d.ts +7 -0
- package/dist/parser.js +802 -0
- package/dist/persistence.d.ts +60 -0
- package/dist/persistence.js +208 -0
- package/dist/prompt.d.ts +130 -0
- package/dist/prompt.js +1014 -0
- package/dist/provider-types.d.ts +134 -0
- package/dist/provider-types.js +3 -0
- package/dist/runtime-types.d.ts +84 -0
- package/dist/runtime-types.js +4 -0
- package/dist/tools.d.ts +16 -0
- package/dist/tools.js +141 -0
- package/dist/validator.d.ts +23 -0
- package/dist/validator.js +959 -0
- package/driver/codex/AGENTS.md +54 -0
- package/driver/hopskill-build/SKILL.md +137 -0
- package/driver/hopskill-build/references/spec-skeleton.md +132 -0
- package/driver/hopskill-build/references/step-type-cheatsheet.md +56 -0
- package/driver/hopskill-build/references/three-focus-rules.md +148 -0
- package/driver/hopspec-skill.md +187 -0
- package/driver/references/cli-discovery.md +36 -0
- package/driver/references/discovery.md +45 -0
- package/driver/references/driver-subagent.md +50 -0
- package/driver/references/parallel-worker.md +50 -0
- package/driver/references/step-execution-rules.md +47 -0
- package/package.json +52 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import type { OutputDecl, StepSummary, ExecutableStepType, ResponseOption } from './ast-types.js';
|
|
2
|
+
import type { AssembledContext, RetryRecord } from './runtime-types.js';
|
|
3
|
+
import type { SpecError, ErrorCode } from './errors.js';
|
|
4
|
+
/** hopjit init 响应联合:成功创建实例或校验失败。见 [[hop-cli#^anc-cli-init-response]] */
|
|
5
|
+
export type InitResponse = InitSuccess | InitError;
|
|
6
|
+
/** init 成功:实例已创建,warn 级校验结果透传供作者修复。见 [[hop-cli#^anc-cli-init-response]] */
|
|
7
|
+
export interface InitSuccess {
|
|
8
|
+
status: 'ok';
|
|
9
|
+
instance_id: string;
|
|
10
|
+
warnings?: SpecError[];
|
|
11
|
+
}
|
|
12
|
+
/** init 失败:error 级解析或校验违规阻断,不创建实例。见 [[hop-cli#^anc-cli-init-response]] */
|
|
13
|
+
export interface InitError {
|
|
14
|
+
status: 'error';
|
|
15
|
+
errors: SpecError[];
|
|
16
|
+
}
|
|
17
|
+
export interface ValidateResponse {
|
|
18
|
+
status: 'ok' | 'error';
|
|
19
|
+
errors: SpecError[];
|
|
20
|
+
warnings: SpecError[];
|
|
21
|
+
}
|
|
22
|
+
export interface ListResponse {
|
|
23
|
+
status: 'ok';
|
|
24
|
+
dir: string;
|
|
25
|
+
specs: Array<{
|
|
26
|
+
file: string;
|
|
27
|
+
id: string;
|
|
28
|
+
goal: string;
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
31
|
+
/** hopjit next 推进响应联合,6 形态由 status 区分(parallel_ready 仅复用模式真并行)。见 [[hop-cli#^anc-cli-next-response]] */
|
|
32
|
+
export type NextResponse = StepReady | AdaptiveNeeded | ExecutionCompleted | ExecutionFailed | ExecutionPaused | ParallelReady;
|
|
33
|
+
/** agent 主循环的正常推进信号:返回待执行步骤及其装配上下文。见 [[hop-cli#^anc-cli-step-ready]] */
|
|
34
|
+
export interface StepReady {
|
|
35
|
+
status: 'step_ready';
|
|
36
|
+
instance_id: string;
|
|
37
|
+
step_id: string;
|
|
38
|
+
step_type: ExecutableStepType;
|
|
39
|
+
summary: string;
|
|
40
|
+
context: AssembledContext;
|
|
41
|
+
work_zone: string;
|
|
42
|
+
output_path: string;
|
|
43
|
+
}
|
|
44
|
+
export interface ParallelReady {
|
|
45
|
+
status: 'parallel_ready';
|
|
46
|
+
instance_id: string;
|
|
47
|
+
parallel_step_id: string;
|
|
48
|
+
children: ParallelChildSpec[];
|
|
49
|
+
max_concurrent: number;
|
|
50
|
+
parent_log_dir?: string;
|
|
51
|
+
work_zone: string;
|
|
52
|
+
}
|
|
53
|
+
/** fan-out CLI 调度顾问(fanout-plan/fanout-next)的返回:下一步调度动作。
|
|
54
|
+
* 主 agent 是句柄执行器(起 worker/收通知),CLI 无状态算调度决策。
|
|
55
|
+
* 见 design/parallel-execution.md ^anc-exec-parallel-fanout-advisor。 // @a: anc-exec-parallel-fanout-advisor */
|
|
56
|
+
export type FanoutScheduleResult = {
|
|
57
|
+
action: 'launch';
|
|
58
|
+
max_concurrent: number;
|
|
59
|
+
workers: FanoutWorker[];
|
|
60
|
+
remaining: string[];
|
|
61
|
+
} | {
|
|
62
|
+
action: 'join';
|
|
63
|
+
command: string;
|
|
64
|
+
} | {
|
|
65
|
+
action: 'wait';
|
|
66
|
+
running: string[];
|
|
67
|
+
} | {
|
|
68
|
+
action: 'error';
|
|
69
|
+
message: string;
|
|
70
|
+
};
|
|
71
|
+
/** 待起 worker:child 步骤 ID + CLI 拼好的完整启动命令(含 cd 锁 cwd、run 参数、log-dir;不含 --params)。 */
|
|
72
|
+
export interface FanoutWorker {
|
|
73
|
+
child_step_id: string;
|
|
74
|
+
launch_command: string;
|
|
75
|
+
}
|
|
76
|
+
/** 单个待并发 child 容器规格:步骤 ID、子实例目录及引擎自动解析的入参。见 [[hop-cli#^anc-types-parallel-ready]] */
|
|
77
|
+
export interface ParallelChildSpec {
|
|
78
|
+
child_step_id: string;
|
|
79
|
+
summary: string;
|
|
80
|
+
subinstance_dir: string;
|
|
81
|
+
params_for_child: Record<string, unknown>;
|
|
82
|
+
}
|
|
83
|
+
/** subtask 重试耗尽需重规划信号:携交付契约、原 children 与重试历史供 replan。见 [[hop-cli#^anc-cli-next-response]] */
|
|
84
|
+
export interface AdaptiveNeeded {
|
|
85
|
+
status: 'adaptive_needed';
|
|
86
|
+
instance_id: string;
|
|
87
|
+
spec_id: string;
|
|
88
|
+
subtask_id: string;
|
|
89
|
+
failure: {
|
|
90
|
+
step_id: string;
|
|
91
|
+
reason: string;
|
|
92
|
+
attempt: number;
|
|
93
|
+
max_retries: number;
|
|
94
|
+
};
|
|
95
|
+
subtask_contract: {
|
|
96
|
+
outputs: OutputDecl[];
|
|
97
|
+
constraints: string[];
|
|
98
|
+
};
|
|
99
|
+
original_children: StepSummary[];
|
|
100
|
+
retry_history: RetryRecord[];
|
|
101
|
+
}
|
|
102
|
+
export interface ReplanAudit {
|
|
103
|
+
spec_id: string;
|
|
104
|
+
step_id: string;
|
|
105
|
+
error_reason: string;
|
|
106
|
+
generated_children: StepSummary[];
|
|
107
|
+
base: 'scratch' | 'fallback';
|
|
108
|
+
at: string;
|
|
109
|
+
}
|
|
110
|
+
/** 执行成功终态:返回全部 outputs(大值可能为 $file 指针)。见 [[hop-cli#^anc-cli-next-response]] */
|
|
111
|
+
export interface ExecutionCompleted {
|
|
112
|
+
status: 'completed';
|
|
113
|
+
instance_id: string;
|
|
114
|
+
outputs: Record<string, unknown>;
|
|
115
|
+
work_zone: string;
|
|
116
|
+
}
|
|
117
|
+
/** 执行失败终态:给出失败步骤、原因与含 null 的部分产物。见 [[hop-cli#^anc-cli-next-response]] */
|
|
118
|
+
export interface ExecutionFailed {
|
|
119
|
+
status: 'failed';
|
|
120
|
+
instance_id: string;
|
|
121
|
+
failed_step_id: string;
|
|
122
|
+
failure_reason: string;
|
|
123
|
+
partial_outputs: Record<string, unknown>;
|
|
124
|
+
work_zone: string;
|
|
125
|
+
}
|
|
126
|
+
/** CITL 介入暂停信号(confirm 审批 / ask 数据收集):自包含介入请求,caller 拿到即知看什么给什么。见 [[hop-cli#^anc-cli-execution-paused]] */
|
|
127
|
+
export interface ExecutionPaused {
|
|
128
|
+
status: 'paused';
|
|
129
|
+
instance_id: string;
|
|
130
|
+
step_id: string;
|
|
131
|
+
pause_reason: 'confirm' | 'commit' | 'waiting_human' | 'ask';
|
|
132
|
+
presented_data: {
|
|
133
|
+
summary: string;
|
|
134
|
+
question?: string;
|
|
135
|
+
instruction: string;
|
|
136
|
+
engine_impact?: string;
|
|
137
|
+
context?: Record<string, unknown>;
|
|
138
|
+
output_schema?: OutputDecl[];
|
|
139
|
+
default_value?: unknown;
|
|
140
|
+
present_inputs?: string[];
|
|
141
|
+
};
|
|
142
|
+
response_options: ResponseOption[];
|
|
143
|
+
timeout_seconds?: number;
|
|
144
|
+
timeout_action?: 'fail' | 'default_response';
|
|
145
|
+
work_zone: string;
|
|
146
|
+
}
|
|
147
|
+
/** done/fail/branch/answer 命令的通用响应:ok 或带错误码的 error。见 [[hop-cli#^anc-cli-command-response]] */
|
|
148
|
+
export interface CommandResponse {
|
|
149
|
+
status: 'ok' | 'error';
|
|
150
|
+
code?: ErrorCode;
|
|
151
|
+
message?: string;
|
|
152
|
+
}
|
|
153
|
+
/** hopjit vars 响应:实例当前变量表与尚未赋值的 Outputs 变量名。见 [[hop-cli#^anc-cli-vars-response]] */
|
|
154
|
+
export interface VarsResponse {
|
|
155
|
+
status: 'ok';
|
|
156
|
+
instance_id: string;
|
|
157
|
+
execution_status: 'running' | 'completed' | 'failed';
|
|
158
|
+
variables: Record<string, unknown>;
|
|
159
|
+
pending_outputs: string[];
|
|
160
|
+
}
|
|
161
|
+
/** hopjit status 响应:实例执行状态与步骤计数(总/完成/失败/待执行/当前)。见 [[hop-cli#^anc-cli-status-response]] */
|
|
162
|
+
export interface StatusResponse {
|
|
163
|
+
status: 'ok';
|
|
164
|
+
instance_id: string;
|
|
165
|
+
execution_status: 'running' | 'completed' | 'failed';
|
|
166
|
+
total_steps: number;
|
|
167
|
+
completed: number;
|
|
168
|
+
failed: number;
|
|
169
|
+
pending: number;
|
|
170
|
+
current_step?: string;
|
|
171
|
+
}
|
|
172
|
+
/** hopjit replan 响应联合:重规划成功或解析/校验失败。见 [[hop-cli#^anc-cli-replan-response]] */
|
|
173
|
+
export type ReplanResponse = ReplanSuccess | ReplanError;
|
|
174
|
+
/** replan 成功:返回替换后的新步骤摘要。见 [[hop-cli#^anc-cli-replan-response]] */
|
|
175
|
+
export interface ReplanSuccess {
|
|
176
|
+
status: 'ok';
|
|
177
|
+
new_children: StepSummary[];
|
|
178
|
+
}
|
|
179
|
+
/** replan 失败:携错误码与解析或校验错误。见 [[hop-cli#^anc-cli-replan-response]] */
|
|
180
|
+
export interface ReplanError {
|
|
181
|
+
status: 'error';
|
|
182
|
+
code: ErrorCode;
|
|
183
|
+
errors: SpecError[];
|
|
184
|
+
}
|
|
185
|
+
/** hopjit branch 请求体:手动覆盖引擎自动条件评估,用于调试或外部 HITL 介入。见 [[hop-cli#^anc-cli-branch-request]] */
|
|
186
|
+
export interface BranchRequest {
|
|
187
|
+
step_id: string;
|
|
188
|
+
selected_case_id: string;
|
|
189
|
+
reason?: string;
|
|
190
|
+
}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import type { HostConfig } from './provider-types.js';
|
|
4
|
+
declare const program: Command;
|
|
5
|
+
/** 把结果序列化为单行 JSON 写 stdout——CLI 对 Agent 消费方的结构化输出约定。见 [[hop-cli#^anc-cli-json-io]] */
|
|
6
|
+
export declare function output(data: unknown): void;
|
|
7
|
+
/** 运行时错误(参数非法、IO 失败)写 stderr 并以非零 exit code 退出,与业务错误的 stdout JSON 分流。见 [[hop-cli#^anc-cli-json-io]] */
|
|
8
|
+
export declare function errorExit(message: string, code?: number): never;
|
|
9
|
+
export declare function resolveFileArgBase(filePath: string, workZoneBase?: string): string;
|
|
10
|
+
/** 解析 JSON 参数:`@file` 前缀从文件读取(走 worker work_zone 重定向),否则原样 JSON.parse。见 [[hop-cli#^anc-cli-file-arg-safety]] */
|
|
11
|
+
export declare function resolveParam(value: string | undefined, workZoneBase?: string): unknown;
|
|
12
|
+
/** 提交越界校验:`--output @<path>` 的解析路径必须落在本执行单元 work_zone 内,越界(/tmp、
|
|
13
|
+
* 项目根、兄弟 child)→ 抛错拒绝提交。引擎唯一能真拦的点(复用模式 act 由 CC 执行、写入不过引擎,
|
|
14
|
+
* 只能提交时校验)。回归 ppt-html v4 串台:worker 写共享 /tmp 互相覆盖。见 [[hop-cli#^anc-cli-file-arg-safety]]。
|
|
15
|
+
* @a: anc-cli-file-arg-safety */
|
|
16
|
+
export declare function assertOutputInWorkZone(value: string | undefined, instanceDir: string, workZoneBase?: string): void;
|
|
17
|
+
/** 解析文本参数(如 --steps/--reason):`@file` 前缀读文件原文,否则返回原值——LLM 生成内容经 @file 防注入。见 [[hop-cli#^anc-cli-file-arg-safety]] */
|
|
18
|
+
export declare function resolveTextParam(value: string | undefined, workZoneBase?: string): string | undefined;
|
|
19
|
+
export declare function workerWorkZone(instanceDir: string, instanceOpt?: string): string | undefined;
|
|
20
|
+
/** 解析目标实例目录:显式 --instance 直接定位,省略时取 state_dir 下最新(按 mtime)实例。见 [[hop-cli#^anc-cli-instance-resolve]] */
|
|
21
|
+
export declare function resolveInstance(stateDir: string, instanceId?: string): string;
|
|
22
|
+
/** 构造 CLI 默认 HostConfig(workspace=cwd + 默认沙箱),供独立模式命令实例化 Engine/Dispatcher。见 [[hop-cli#^anc-struct-hop-cli]] */
|
|
23
|
+
export declare function buildHostConfig(): HostConfig;
|
|
24
|
+
/** context 精简档 resolve:env HOPJIT_CONTEXT_MODE > --context-mode flag > 默认 full。见 [[prompt-assembler#^anc-exec-context-mode]] */
|
|
25
|
+
export declare function resolveContextMode(flag?: string): 'full' | 'minimal';
|
|
26
|
+
export { program };
|