spets 0.1.65 → 0.1.66
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/index.js +81 -25
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -965,8 +965,6 @@ function buildClarifyPrompt(params) {
|
|
|
965
965
|
if (resolvedEntries.length > 0) {
|
|
966
966
|
parts.push("## Previous Questions & Answers");
|
|
967
967
|
parts.push("");
|
|
968
|
-
parts.push("The following questions have been resolved:");
|
|
969
|
-
parts.push("");
|
|
970
968
|
for (const entry of resolvedEntries) {
|
|
971
969
|
parts.push(`**Q: ${entry.question.question}**`);
|
|
972
970
|
if (entry.question.context) {
|
|
@@ -975,8 +973,11 @@ function buildClarifyPrompt(params) {
|
|
|
975
973
|
parts.push(`A: ${entry.answer.answer}`);
|
|
976
974
|
parts.push("");
|
|
977
975
|
}
|
|
978
|
-
parts.push("
|
|
979
|
-
parts.push("
|
|
976
|
+
parts.push("**Rules:**");
|
|
977
|
+
parts.push('- If user said "you decide" or "\uC54C\uC544\uC11C \uD574" \u2192 use your judgment and move on');
|
|
978
|
+
parts.push("- If user asked for options \u2192 provide options for that specific topic only");
|
|
979
|
+
parts.push("- Do NOT ask about topics already answered, even with different wording");
|
|
980
|
+
parts.push("- When in doubt, proceed rather than ask again");
|
|
980
981
|
parts.push("");
|
|
981
982
|
}
|
|
982
983
|
}
|
|
@@ -4146,6 +4147,54 @@ function outputError(error) {
|
|
|
4146
4147
|
console.log(JSON.stringify({ type: "error", error }, null, 2));
|
|
4147
4148
|
process.exit(1);
|
|
4148
4149
|
}
|
|
4150
|
+
function parseFlexibleJSON(json, options = {}) {
|
|
4151
|
+
const { expectArray = false, arrayKeys = [], defaultValue, allowStringFallback = false } = options;
|
|
4152
|
+
try {
|
|
4153
|
+
const parsed = JSON.parse(json);
|
|
4154
|
+
if (expectArray) {
|
|
4155
|
+
if (Array.isArray(parsed)) {
|
|
4156
|
+
return { success: true, data: parsed };
|
|
4157
|
+
}
|
|
4158
|
+
if (typeof parsed === "object" && parsed !== null) {
|
|
4159
|
+
for (const key of arrayKeys) {
|
|
4160
|
+
if (Array.isArray(parsed[key])) {
|
|
4161
|
+
return { success: true, data: parsed[key] };
|
|
4162
|
+
}
|
|
4163
|
+
}
|
|
4164
|
+
for (const key of ["data", "items", "results", "list"]) {
|
|
4165
|
+
if (Array.isArray(parsed[key])) {
|
|
4166
|
+
return { success: true, data: parsed[key] };
|
|
4167
|
+
}
|
|
4168
|
+
}
|
|
4169
|
+
const values = Object.values(parsed);
|
|
4170
|
+
const arrays = values.filter(Array.isArray);
|
|
4171
|
+
if (arrays.length === 1) {
|
|
4172
|
+
return { success: true, data: arrays[0] };
|
|
4173
|
+
}
|
|
4174
|
+
}
|
|
4175
|
+
return { success: true, data: [] };
|
|
4176
|
+
}
|
|
4177
|
+
if (typeof parsed === "object" && parsed !== null && !Array.isArray(parsed)) {
|
|
4178
|
+
const keys = Object.keys(parsed);
|
|
4179
|
+
if (keys.length === 1) {
|
|
4180
|
+
const innerValue = parsed[keys[0]];
|
|
4181
|
+
if (typeof innerValue === "object" && innerValue !== null && !Array.isArray(innerValue)) {
|
|
4182
|
+
const innerKeys = Object.keys(innerValue);
|
|
4183
|
+
if (innerKeys.length > 1) {
|
|
4184
|
+
return { success: true, data: innerValue };
|
|
4185
|
+
}
|
|
4186
|
+
}
|
|
4187
|
+
}
|
|
4188
|
+
return { success: true, data: parsed };
|
|
4189
|
+
}
|
|
4190
|
+
return { success: true, data: parsed };
|
|
4191
|
+
} catch {
|
|
4192
|
+
if (allowStringFallback && defaultValue !== void 0) {
|
|
4193
|
+
return { success: true, data: defaultValue };
|
|
4194
|
+
}
|
|
4195
|
+
return { success: false, error: "Invalid JSON format" };
|
|
4196
|
+
}
|
|
4197
|
+
}
|
|
4149
4198
|
async function orchestrateCommand(action, args) {
|
|
4150
4199
|
try {
|
|
4151
4200
|
const orchestrator = new Orchestrator();
|
|
@@ -4167,18 +4216,21 @@ async function orchestrateCommand(action, args) {
|
|
|
4167
4216
|
outputError("Task ID is required for explore-done");
|
|
4168
4217
|
return;
|
|
4169
4218
|
}
|
|
4170
|
-
|
|
4219
|
+
const defaultExplore = {
|
|
4171
4220
|
summary: "",
|
|
4172
4221
|
relevantFiles: [],
|
|
4173
4222
|
patterns: [],
|
|
4174
4223
|
constraints: [],
|
|
4175
4224
|
dependencies: []
|
|
4176
4225
|
};
|
|
4226
|
+
let exploreOutput = defaultExplore;
|
|
4177
4227
|
if (exploreJson) {
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
4228
|
+
const parsed = parseFlexibleJSON(exploreJson, {
|
|
4229
|
+
allowStringFallback: true,
|
|
4230
|
+
defaultValue: { ...defaultExplore, summary: exploreJson }
|
|
4231
|
+
});
|
|
4232
|
+
if (parsed.success) {
|
|
4233
|
+
exploreOutput = { ...defaultExplore, ...parsed.data };
|
|
4182
4234
|
}
|
|
4183
4235
|
}
|
|
4184
4236
|
const result = orchestrator.cmdExploreDone(taskId, exploreOutput);
|
|
@@ -4194,13 +4246,15 @@ async function orchestrateCommand(action, args) {
|
|
|
4194
4246
|
}
|
|
4195
4247
|
let questions = [];
|
|
4196
4248
|
if (questionsJson) {
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
}
|
|
4201
|
-
|
|
4249
|
+
const parsed = parseFlexibleJSON(questionsJson, {
|
|
4250
|
+
expectArray: true,
|
|
4251
|
+
arrayKeys: ["questions"]
|
|
4252
|
+
});
|
|
4253
|
+
if (!parsed.success) {
|
|
4254
|
+
outputError(parsed.error);
|
|
4202
4255
|
return;
|
|
4203
4256
|
}
|
|
4257
|
+
questions = parsed.data;
|
|
4204
4258
|
}
|
|
4205
4259
|
const result = orchestrator.cmdClarifyDone(taskId, questions);
|
|
4206
4260
|
outputJSON(result);
|
|
@@ -4223,7 +4277,7 @@ async function orchestrateCommand(action, args) {
|
|
|
4223
4277
|
outputError("Task ID is required for verify-done");
|
|
4224
4278
|
return;
|
|
4225
4279
|
}
|
|
4226
|
-
|
|
4280
|
+
const defaultVerify = {
|
|
4227
4281
|
passed: false,
|
|
4228
4282
|
score: {
|
|
4229
4283
|
requirementsCoverage: 0,
|
|
@@ -4234,13 +4288,14 @@ async function orchestrateCommand(action, args) {
|
|
|
4234
4288
|
issues: [],
|
|
4235
4289
|
summary: ""
|
|
4236
4290
|
};
|
|
4291
|
+
let verifyOutput = defaultVerify;
|
|
4237
4292
|
if (verifyJson) {
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
outputError("Invalid JSON for verify output");
|
|
4293
|
+
const parsed = parseFlexibleJSON(verifyJson, {});
|
|
4294
|
+
if (!parsed.success) {
|
|
4295
|
+
outputError(parsed.error);
|
|
4242
4296
|
return;
|
|
4243
4297
|
}
|
|
4298
|
+
verifyOutput = { ...defaultVerify, ...parsed.data };
|
|
4244
4299
|
}
|
|
4245
4300
|
const result = orchestrator.cmdVerifyDone(taskId, verifyOutput);
|
|
4246
4301
|
outputJSON(result);
|
|
@@ -4253,14 +4308,15 @@ async function orchestrateCommand(action, args) {
|
|
|
4253
4308
|
outputError("Task ID and answers JSON are required for clarified");
|
|
4254
4309
|
return;
|
|
4255
4310
|
}
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
answers
|
|
4259
|
-
}
|
|
4260
|
-
|
|
4311
|
+
const parsed = parseFlexibleJSON(answersJson, {
|
|
4312
|
+
expectArray: true,
|
|
4313
|
+
arrayKeys: ["answers"]
|
|
4314
|
+
});
|
|
4315
|
+
if (!parsed.success) {
|
|
4316
|
+
outputError(parsed.error);
|
|
4261
4317
|
return;
|
|
4262
4318
|
}
|
|
4263
|
-
const result = orchestrator.cmdClarified(taskId,
|
|
4319
|
+
const result = orchestrator.cmdClarified(taskId, parsed.data);
|
|
4264
4320
|
outputJSON(result);
|
|
4265
4321
|
break;
|
|
4266
4322
|
}
|