@coresource/hz 0.20.3 → 0.20.5
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/dist/hz.mjs +54 -7
- package/package.json +2 -2
package/dist/hz.mjs
CHANGED
|
@@ -3976,6 +3976,7 @@ import ora2 from "ora";
|
|
|
3976
3976
|
import pc9 from "picocolors";
|
|
3977
3977
|
var DEFAULT_ANALYSIS_TIMEOUT_MS = 5 * 60 * 1e3;
|
|
3978
3978
|
var DEFAULT_POLL_INTERVAL_MS = 5e3;
|
|
3979
|
+
var DEFAULT_PLANNER_MUTATION_TIMEOUT_MS = 6e4;
|
|
3979
3980
|
var FREE_TEXT_OPTION_ID = "free_text";
|
|
3980
3981
|
function isRecord7(value) {
|
|
3981
3982
|
return value !== null && !Array.isArray(value) && typeof value === "object";
|
|
@@ -3986,11 +3987,36 @@ function asNonEmptyString8(value) {
|
|
|
3986
3987
|
function asStringArray2(value) {
|
|
3987
3988
|
return Array.isArray(value) ? value.map((item) => asNonEmptyString8(item)).filter((item) => item !== null) : [];
|
|
3988
3989
|
}
|
|
3990
|
+
function asCodeSnippets(value) {
|
|
3991
|
+
if (!Array.isArray(value)) {
|
|
3992
|
+
return [];
|
|
3993
|
+
}
|
|
3994
|
+
const snippets = [];
|
|
3995
|
+
const dedupe = /* @__PURE__ */ new Set();
|
|
3996
|
+
for (const entry of value) {
|
|
3997
|
+
const snippet = asNonEmptyString8(
|
|
3998
|
+
typeof entry === "string" ? entry : isRecord7(entry) ? entry.snippet ?? entry.code ?? entry.code_evidence ?? entry.content : void 0
|
|
3999
|
+
);
|
|
4000
|
+
if (!snippet) {
|
|
4001
|
+
continue;
|
|
4002
|
+
}
|
|
4003
|
+
const pathValue = isRecord7(entry) ? asNonEmptyString8(entry.path ?? entry.file_path ?? entry.filePath) : null;
|
|
4004
|
+
const key = `${pathValue ?? ""}\0${snippet}`;
|
|
4005
|
+
if (dedupe.has(key)) {
|
|
4006
|
+
continue;
|
|
4007
|
+
}
|
|
4008
|
+
dedupe.add(key);
|
|
4009
|
+
snippets.push(pathValue ? { path: pathValue, snippet } : { snippet });
|
|
4010
|
+
}
|
|
4011
|
+
return snippets;
|
|
4012
|
+
}
|
|
3989
4013
|
function extractQuestions(payload) {
|
|
3990
4014
|
if (!payload || !Array.isArray(payload.questions)) {
|
|
3991
4015
|
return [];
|
|
3992
4016
|
}
|
|
3993
4017
|
return payload.questions.filter((question) => isRecord7(question)).map((question) => ({
|
|
4018
|
+
codeSnippets: asCodeSnippets(question.codeSnippets ?? question.code_snippets ?? question.snippets),
|
|
4019
|
+
context: asNonEmptyString8(question.context) ?? void 0,
|
|
3994
4020
|
detailPrompt: asNonEmptyString8(question.detailPrompt) ?? void 0,
|
|
3995
4021
|
freeTextOptionId: asNonEmptyString8(question.freeTextOptionId) ?? void 0,
|
|
3996
4022
|
id: asNonEmptyString8(question.id) ?? "question",
|
|
@@ -4181,7 +4207,8 @@ async function postClarification(client, sessionId, signal, body) {
|
|
|
4181
4207
|
body,
|
|
4182
4208
|
method: "POST",
|
|
4183
4209
|
path: `/plan/${sessionId}/clarify`,
|
|
4184
|
-
signal
|
|
4210
|
+
signal,
|
|
4211
|
+
timeoutMs: DEFAULT_PLANNER_MUTATION_TIMEOUT_MS
|
|
4185
4212
|
});
|
|
4186
4213
|
}
|
|
4187
4214
|
async function postMilestoneConfirmation(client, sessionId, signal, body) {
|
|
@@ -4189,25 +4216,44 @@ async function postMilestoneConfirmation(client, sessionId, signal, body) {
|
|
|
4189
4216
|
body,
|
|
4190
4217
|
method: "POST",
|
|
4191
4218
|
path: `/plan/${sessionId}/confirm-milestones`,
|
|
4192
|
-
signal
|
|
4219
|
+
signal,
|
|
4220
|
+
timeoutMs: DEFAULT_PLANNER_MUTATION_TIMEOUT_MS
|
|
4193
4221
|
});
|
|
4194
4222
|
}
|
|
4195
4223
|
async function postDraftApproval(client, sessionId, signal) {
|
|
4196
4224
|
return client.request({
|
|
4197
4225
|
method: "POST",
|
|
4198
4226
|
path: `/plan/${sessionId}/approve`,
|
|
4199
|
-
signal
|
|
4227
|
+
signal,
|
|
4228
|
+
timeoutMs: DEFAULT_PLANNER_MUTATION_TIMEOUT_MS
|
|
4200
4229
|
});
|
|
4201
4230
|
}
|
|
4202
4231
|
function writeSection3(stdout, title) {
|
|
4203
4232
|
writeLine(stdout);
|
|
4204
4233
|
writeLine(stdout, pc9.bold(title));
|
|
4205
4234
|
}
|
|
4235
|
+
function formatInlineSnippet(snippet) {
|
|
4236
|
+
return snippet.replace(/\s+/g, " ").trim();
|
|
4237
|
+
}
|
|
4238
|
+
function isFreeTextQuestion(question) {
|
|
4239
|
+
return Boolean(question.freeTextOptionId) || !question.options || question.options.length === 0;
|
|
4240
|
+
}
|
|
4206
4241
|
function renderQuestion(stdout, question, index) {
|
|
4207
4242
|
writeLine(stdout, `${index + 1}. ${question.text}`);
|
|
4208
4243
|
if (question.references && question.references.length > 0) {
|
|
4209
4244
|
writeLine(stdout, ` ${pc9.dim(`References: ${question.references.join(", ")}`)}`);
|
|
4210
4245
|
}
|
|
4246
|
+
if (question.context) {
|
|
4247
|
+
writeLine(stdout, ` ${pc9.dim(`Context: ${question.context}`)}`);
|
|
4248
|
+
}
|
|
4249
|
+
if (question.codeSnippets && question.codeSnippets.length > 0) {
|
|
4250
|
+
writeLine(stdout, ` ${pc9.dim("Code:")}`);
|
|
4251
|
+
for (const codeSnippet of question.codeSnippets) {
|
|
4252
|
+
const renderedSnippet = formatInlineSnippet(codeSnippet.snippet);
|
|
4253
|
+
const label = codeSnippet.path ? `${codeSnippet.path}: ` : "";
|
|
4254
|
+
writeLine(stdout, ` ${label}${renderedSnippet}`);
|
|
4255
|
+
}
|
|
4256
|
+
}
|
|
4211
4257
|
}
|
|
4212
4258
|
function renderMilestones(stdout, milestones, reviewRound) {
|
|
4213
4259
|
writeSection3(stdout, `Milestone review round ${reviewRound}`);
|
|
@@ -4307,9 +4353,10 @@ async function promptForAnswers(options, interruption, questions, round) {
|
|
|
4307
4353
|
const transcript = [];
|
|
4308
4354
|
for (const question of questions) {
|
|
4309
4355
|
throwIfInterrupted3(interruption);
|
|
4310
|
-
if (question
|
|
4356
|
+
if (!isFreeTextQuestion(question)) {
|
|
4357
|
+
const selectableOptions = question.options ?? [];
|
|
4311
4358
|
const autoSelectedOption = options.autoApprove ? pickAutoApprovedOption(question, options.taskDescription, options.repoPaths) : null;
|
|
4312
|
-
const choices =
|
|
4359
|
+
const choices = selectableOptions.map((option) => ({
|
|
4313
4360
|
description: option.description,
|
|
4314
4361
|
name: option.label,
|
|
4315
4362
|
value: option.id
|
|
@@ -4320,7 +4367,7 @@ async function promptForAnswers(options, interruption, questions, round) {
|
|
|
4320
4367
|
signal: interruption.abortController.signal
|
|
4321
4368
|
});
|
|
4322
4369
|
throwIfInterrupted3(interruption);
|
|
4323
|
-
const selectedOption =
|
|
4370
|
+
const selectedOption = selectableOptions.find((option) => option.id === optionId2);
|
|
4324
4371
|
answers.push({
|
|
4325
4372
|
optionId: optionId2,
|
|
4326
4373
|
questionId: question.id
|
|
@@ -4341,7 +4388,7 @@ async function promptForAnswers(options, interruption, questions, round) {
|
|
|
4341
4388
|
signal: interruption.abortController.signal
|
|
4342
4389
|
});
|
|
4343
4390
|
throwIfInterrupted3(interruption);
|
|
4344
|
-
const optionId =
|
|
4391
|
+
const optionId = FREE_TEXT_OPTION_ID;
|
|
4345
4392
|
answers.push({
|
|
4346
4393
|
detail,
|
|
4347
4394
|
optionId,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coresource/hz",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"hz": "dist/hz.mjs"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/node": "^25.5.0",
|
|
30
30
|
"@types/ws": "^8.18.1",
|
|
31
|
-
"tsup": "^8.5.
|
|
31
|
+
"tsup": "^8.5.1",
|
|
32
32
|
"typescript": "^5.9.3",
|
|
33
33
|
"vitest": "^3.2.4"
|
|
34
34
|
}
|