@longtable/cli 0.1.30 → 0.1.31
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/cli.js +414 -486
- package/dist/project-session.d.ts +20 -0
- package/dist/project-session.js +55 -7
- package/dist/prompt-renderer.d.ts +11 -0
- package/dist/prompt-renderer.js +130 -0
- package/dist/search/publisher-access.js +1 -1
- package/dist/search/sources.js +2 -2
- package/package.json +8 -7
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { existsSync, readFileSync, statSync } from "node:fs";
|
|
3
3
|
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
4
4
|
import { execSync } from "node:child_process";
|
|
5
|
-
import { emitKeypressEvents } from "node:readline";
|
|
6
5
|
import { createInterface } from "node:readline/promises";
|
|
7
6
|
import { stdin as input, stdout as output, cwd, env, exit } from "node:process";
|
|
8
7
|
import { dirname, join, resolve } from "node:path";
|
|
@@ -18,6 +17,7 @@ import { PERSONA_DEFINITIONS, listRoleDefinitions } from "./personas.js";
|
|
|
18
17
|
import { buildPanelFallback, renderPanelSummary } from "./panel.js";
|
|
19
18
|
import { appendInvocationRecordToWorkspace, assertWorkspaceNotBlocked, answerWorkspaceQuestion, createWorkspaceFollowUpQuestions, createWorkspaceQuestion, createOrUpdateProjectWorkspace, inspectProjectWorkspace, loadWorkspaceState, loadProjectContextFromDirectory, renderProjectWorkspaceSummary, syncCurrentWorkspaceView } from "./project-session.js";
|
|
20
19
|
import { buildTeamDebate, buildTeamReview, renderTeamDebateSummary } from "./debate.js";
|
|
20
|
+
import { createPromptRenderer } from "./prompt-renderer.js";
|
|
21
21
|
const VALID_MODES = new Set([
|
|
22
22
|
"explore",
|
|
23
23
|
"review",
|
|
@@ -43,7 +43,7 @@ const ANSI = {
|
|
|
43
43
|
green: "\u001B[32m"
|
|
44
44
|
};
|
|
45
45
|
const LONGTABLE_MCP_SERVER_NAME = "longtable-state";
|
|
46
|
-
const LONGTABLE_MCP_PACKAGE_VERSION = "0.1.
|
|
46
|
+
const LONGTABLE_MCP_PACKAGE_VERSION = "0.1.31";
|
|
47
47
|
const LONGTABLE_MCP_MARKER_START = "# LongTable state MCP START";
|
|
48
48
|
const LONGTABLE_MCP_MARKER_END = "# LongTable state MCP END";
|
|
49
49
|
function style(text, prefix) {
|
|
@@ -171,11 +171,6 @@ function parseArgs(argv) {
|
|
|
171
171
|
}
|
|
172
172
|
return { command, subcommand, values };
|
|
173
173
|
}
|
|
174
|
-
function renderChoices(choices) {
|
|
175
|
-
return choices
|
|
176
|
-
.map((choice, index) => `${index + 1}. ${choice.label} — ${choice.description}`)
|
|
177
|
-
.join("\n");
|
|
178
|
-
}
|
|
179
174
|
function buildSetupFlowChoices() {
|
|
180
175
|
return [
|
|
181
176
|
{
|
|
@@ -219,23 +214,6 @@ function questionSection(questionId) {
|
|
|
219
214
|
function formatModeLabel(mode) {
|
|
220
215
|
return `${mode[0].toUpperCase()}${mode.slice(1)}`;
|
|
221
216
|
}
|
|
222
|
-
function moveCursorUp(lines) {
|
|
223
|
-
return lines > 0 ? `\u001B[${lines}A` : "";
|
|
224
|
-
}
|
|
225
|
-
function clearLine() {
|
|
226
|
-
return "\u001B[2K\r";
|
|
227
|
-
}
|
|
228
|
-
function renderArrowMenu(prompt, choices, selectedIndex) {
|
|
229
|
-
const lines = [style(prompt, ANSI.bold), style("Use ↑/↓ and Enter.", ANSI.dim)];
|
|
230
|
-
for (let index = 0; index < choices.length; index += 1) {
|
|
231
|
-
const prefix = index === selectedIndex ? style(">", `${ANSI.bold}${ANSI.green}`) : " ";
|
|
232
|
-
lines.push(`${prefix} ${choices[index].label} - ${choices[index].description}`);
|
|
233
|
-
}
|
|
234
|
-
return lines.join("\n");
|
|
235
|
-
}
|
|
236
|
-
function countRenderedLines(text) {
|
|
237
|
-
return text.split("\n").length;
|
|
238
|
-
}
|
|
239
217
|
function stripWrappingQuotes(value) {
|
|
240
218
|
const trimmed = value.trim();
|
|
241
219
|
if ((trimmed.startsWith("\"") && trimmed.endsWith("\"")) ||
|
|
@@ -302,186 +280,14 @@ async function verifyWritableWorkspaceParent(projectPath) {
|
|
|
302
280
|
].join("\n"));
|
|
303
281
|
}
|
|
304
282
|
}
|
|
305
|
-
async function
|
|
306
|
-
|
|
307
|
-
const answer = await rl.question(`${prompt}\n${renderChoices(choices)}\nSelect one number: `);
|
|
308
|
-
const numeric = Number(answer.trim());
|
|
309
|
-
if (!Number.isInteger(numeric) || numeric < 1 || numeric > choices.length) {
|
|
310
|
-
console.log("Invalid selection. Enter one of the listed numbers.");
|
|
311
|
-
continue;
|
|
312
|
-
}
|
|
313
|
-
const choice = choices[numeric - 1];
|
|
314
|
-
if (choice.fallbackToText) {
|
|
315
|
-
const freeText = await rl.question("Type your custom value: ");
|
|
316
|
-
if (!freeText.trim()) {
|
|
317
|
-
console.log("Custom value cannot be empty.");
|
|
318
|
-
continue;
|
|
319
|
-
}
|
|
320
|
-
return freeText.trim();
|
|
321
|
-
}
|
|
322
|
-
return choice.id;
|
|
323
|
-
}
|
|
283
|
+
async function promptText(prompt, required) {
|
|
284
|
+
return createPromptRenderer().text(prompt, { required });
|
|
324
285
|
}
|
|
325
|
-
async function
|
|
326
|
-
|
|
327
|
-
const answer = (await rl.question(`${prompt}\n> `)).trim();
|
|
328
|
-
if (!required) {
|
|
329
|
-
return answer || undefined;
|
|
330
|
-
}
|
|
331
|
-
if (answer) {
|
|
332
|
-
return answer;
|
|
333
|
-
}
|
|
334
|
-
console.log("This answer cannot be empty.");
|
|
335
|
-
}
|
|
286
|
+
async function promptChoice(prompt, choices) {
|
|
287
|
+
return createPromptRenderer().select(prompt, choices);
|
|
336
288
|
}
|
|
337
|
-
async function
|
|
338
|
-
|
|
339
|
-
if (!stream.isTTY || !output.isTTY) {
|
|
340
|
-
return promptChoiceByNumber(rl, prompt, choices);
|
|
341
|
-
}
|
|
342
|
-
const previousRawMode = stream.isRaw;
|
|
343
|
-
let selectedIndex = 0;
|
|
344
|
-
let lastRenderLineCount = 0;
|
|
345
|
-
return await new Promise((resolve, reject) => {
|
|
346
|
-
function draw(first = false) {
|
|
347
|
-
const renderedText = renderArrowMenu(prompt, choices, selectedIndex);
|
|
348
|
-
const rendered = renderedText.split("\n");
|
|
349
|
-
if (!first && lastRenderLineCount > 0) {
|
|
350
|
-
output.write(moveCursorUp(lastRenderLineCount));
|
|
351
|
-
}
|
|
352
|
-
for (const line of rendered) {
|
|
353
|
-
output.write(clearLine());
|
|
354
|
-
output.write(`${line}\n`);
|
|
355
|
-
}
|
|
356
|
-
lastRenderLineCount = countRenderedLines(renderedText);
|
|
357
|
-
}
|
|
358
|
-
function cleanup() {
|
|
359
|
-
stream.off("keypress", onKeypress);
|
|
360
|
-
if (stream.isTTY) {
|
|
361
|
-
stream.setRawMode(previousRawMode ?? false);
|
|
362
|
-
}
|
|
363
|
-
output.write("\u001B[?25h");
|
|
364
|
-
}
|
|
365
|
-
async function handleChoice(choice) {
|
|
366
|
-
cleanup();
|
|
367
|
-
if (choice.fallbackToText) {
|
|
368
|
-
const freeText = await rl.question("Type your custom value: ");
|
|
369
|
-
if (!freeText.trim()) {
|
|
370
|
-
resolve(await promptChoiceWithArrows(rl, prompt, choices));
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
resolve(freeText.trim());
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
resolve(choice.id);
|
|
377
|
-
}
|
|
378
|
-
function onKeypress(_, key) {
|
|
379
|
-
if (key.ctrl && key.name === "c") {
|
|
380
|
-
cleanup();
|
|
381
|
-
reject(new Error("Setup cancelled."));
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
if (key.name === "up") {
|
|
385
|
-
selectedIndex = selectedIndex === 0 ? choices.length - 1 : selectedIndex - 1;
|
|
386
|
-
draw();
|
|
387
|
-
return;
|
|
388
|
-
}
|
|
389
|
-
if (key.name === "down") {
|
|
390
|
-
selectedIndex = selectedIndex === choices.length - 1 ? 0 : selectedIndex + 1;
|
|
391
|
-
draw();
|
|
392
|
-
return;
|
|
393
|
-
}
|
|
394
|
-
if (key.name === "return") {
|
|
395
|
-
void handleChoice(choices[selectedIndex]);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
emitKeypressEvents(stream);
|
|
399
|
-
stream.setRawMode(true);
|
|
400
|
-
output.write("\u001B[?25l");
|
|
401
|
-
draw(true);
|
|
402
|
-
stream.on("keypress", onKeypress);
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
async function promptChoice(rl, prompt, choices) {
|
|
406
|
-
return promptChoiceWithArrows(rl, prompt, choices);
|
|
407
|
-
}
|
|
408
|
-
async function promptMultiChoice(rl, prompt, choices) {
|
|
409
|
-
const stream = input;
|
|
410
|
-
if (!stream.isTTY || !output.isTTY) {
|
|
411
|
-
const answer = await rl.question(`${prompt}\nType comma-separated ids or leave blank for auto.\n> `);
|
|
412
|
-
return answer
|
|
413
|
-
.split(",")
|
|
414
|
-
.map((part) => part.trim())
|
|
415
|
-
.filter(Boolean);
|
|
416
|
-
}
|
|
417
|
-
const previousRawMode = stream.isRaw;
|
|
418
|
-
let selectedIndex = 0;
|
|
419
|
-
const selected = new Set();
|
|
420
|
-
let lastRenderLineCount = 0;
|
|
421
|
-
return await new Promise((resolvePromise, reject) => {
|
|
422
|
-
function draw(first = false) {
|
|
423
|
-
const lines = [prompt, "Use ↑/↓, Space to toggle, and Enter to confirm."];
|
|
424
|
-
for (let index = 0; index < choices.length; index += 1) {
|
|
425
|
-
const choice = choices[index];
|
|
426
|
-
const pointer = index === selectedIndex ? ">" : " ";
|
|
427
|
-
const marker = selected.has(choice.id) ? "[x]" : "[ ]";
|
|
428
|
-
lines.push(`${pointer} ${marker} ${choice.label} - ${choice.description}`);
|
|
429
|
-
}
|
|
430
|
-
const renderedText = lines.join("\n");
|
|
431
|
-
if (!first && lastRenderLineCount > 0) {
|
|
432
|
-
output.write(moveCursorUp(lastRenderLineCount));
|
|
433
|
-
}
|
|
434
|
-
for (const line of lines) {
|
|
435
|
-
output.write(clearLine());
|
|
436
|
-
output.write(`${line}\n`);
|
|
437
|
-
}
|
|
438
|
-
lastRenderLineCount = countRenderedLines(renderedText);
|
|
439
|
-
}
|
|
440
|
-
function cleanup() {
|
|
441
|
-
stream.off("keypress", onKeypress);
|
|
442
|
-
if (stream.isTTY) {
|
|
443
|
-
stream.setRawMode(previousRawMode ?? false);
|
|
444
|
-
}
|
|
445
|
-
output.write("\u001B[?25h");
|
|
446
|
-
}
|
|
447
|
-
function onKeypress(_, key) {
|
|
448
|
-
if (key.ctrl && key.name === "c") {
|
|
449
|
-
cleanup();
|
|
450
|
-
reject(new Error("Setup cancelled."));
|
|
451
|
-
return;
|
|
452
|
-
}
|
|
453
|
-
if (key.name === "up") {
|
|
454
|
-
selectedIndex = selectedIndex === 0 ? choices.length - 1 : selectedIndex - 1;
|
|
455
|
-
draw();
|
|
456
|
-
return;
|
|
457
|
-
}
|
|
458
|
-
if (key.name === "down") {
|
|
459
|
-
selectedIndex = selectedIndex === choices.length - 1 ? 0 : selectedIndex + 1;
|
|
460
|
-
draw();
|
|
461
|
-
return;
|
|
462
|
-
}
|
|
463
|
-
if (key.name === "space") {
|
|
464
|
-
const id = choices[selectedIndex].id;
|
|
465
|
-
if (selected.has(id)) {
|
|
466
|
-
selected.delete(id);
|
|
467
|
-
}
|
|
468
|
-
else {
|
|
469
|
-
selected.add(id);
|
|
470
|
-
}
|
|
471
|
-
draw();
|
|
472
|
-
return;
|
|
473
|
-
}
|
|
474
|
-
if (key.name === "return") {
|
|
475
|
-
cleanup();
|
|
476
|
-
resolvePromise([...selected]);
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
emitKeypressEvents(stream);
|
|
480
|
-
stream.setRawMode(true);
|
|
481
|
-
output.write("\u001B[?25l");
|
|
482
|
-
draw(true);
|
|
483
|
-
stream.on("keypress", onKeypress);
|
|
484
|
-
});
|
|
289
|
+
async function promptMultiChoice(prompt, choices) {
|
|
290
|
+
return createPromptRenderer().multiselect(prompt, choices);
|
|
485
291
|
}
|
|
486
292
|
function hasCompleteFlagInput(args) {
|
|
487
293
|
const required = ["provider", "career-stage", "experience", "checkpoint"];
|
|
@@ -516,58 +322,52 @@ function toSetupAnswers(args) {
|
|
|
516
322
|
};
|
|
517
323
|
}
|
|
518
324
|
async function collectInteractiveAnswers(initialFlow) {
|
|
519
|
-
const
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
if (!value) {
|
|
543
|
-
continue;
|
|
544
|
-
}
|
|
545
|
-
if (question.id === "careerStage")
|
|
546
|
-
answers.careerStage = value;
|
|
547
|
-
if (question.id === "experienceLevel")
|
|
548
|
-
answers.experienceLevel = value;
|
|
549
|
-
if (question.id === "preferredCheckpointIntensity") {
|
|
550
|
-
answers.preferredCheckpointIntensity = value;
|
|
551
|
-
}
|
|
552
|
-
if (question.id === "humanAuthorshipSignal" && value !== "other") {
|
|
553
|
-
answers.humanAuthorshipSignal = value;
|
|
554
|
-
}
|
|
555
|
-
if (question.id === "preferredEntryMode")
|
|
556
|
-
answers.preferredEntryMode = value;
|
|
557
|
-
if (question.id === "weakestDomain")
|
|
558
|
-
answers.weakestDomain = value;
|
|
559
|
-
if (question.id === "panelPreference")
|
|
560
|
-
answers.panelPreference = value;
|
|
325
|
+
const flow = initialFlow ??
|
|
326
|
+
(await promptChoice("How would you like to set up LongTable?", buildSetupFlowChoices()));
|
|
327
|
+
console.log("");
|
|
328
|
+
console.log(renderSetupHeader(flow));
|
|
329
|
+
console.log("");
|
|
330
|
+
const provider = await promptChoice("Which provider do you want to configure?", buildProviderChoices());
|
|
331
|
+
const answers = {
|
|
332
|
+
field: "unspecified",
|
|
333
|
+
currentProjectType: "unspecified research task"
|
|
334
|
+
};
|
|
335
|
+
const questions = buildQuickSetupFlow(flow);
|
|
336
|
+
for (let index = 0; index < questions.length; index += 1) {
|
|
337
|
+
const question = questions[index];
|
|
338
|
+
const prompt = renderQuestionHeader(index + 1, questions.length, questionSection(question.id), question.prompt);
|
|
339
|
+
let value;
|
|
340
|
+
if (question.kind === "text") {
|
|
341
|
+
value = await promptText(prompt, question.required);
|
|
342
|
+
}
|
|
343
|
+
else if (question.choices) {
|
|
344
|
+
value = await promptChoice(prompt, question.choices);
|
|
345
|
+
}
|
|
346
|
+
if (!value) {
|
|
347
|
+
continue;
|
|
561
348
|
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
answers
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
349
|
+
if (question.id === "careerStage")
|
|
350
|
+
answers.careerStage = value;
|
|
351
|
+
if (question.id === "experienceLevel")
|
|
352
|
+
answers.experienceLevel = value;
|
|
353
|
+
if (question.id === "preferredCheckpointIntensity") {
|
|
354
|
+
answers.preferredCheckpointIntensity = value;
|
|
355
|
+
}
|
|
356
|
+
if (question.id === "humanAuthorshipSignal" && value !== "other") {
|
|
357
|
+
answers.humanAuthorshipSignal = value;
|
|
358
|
+
}
|
|
359
|
+
if (question.id === "preferredEntryMode")
|
|
360
|
+
answers.preferredEntryMode = value;
|
|
361
|
+
if (question.id === "weakestDomain")
|
|
362
|
+
answers.weakestDomain = value;
|
|
363
|
+
if (question.id === "panelPreference")
|
|
364
|
+
answers.panelPreference = value;
|
|
570
365
|
}
|
|
366
|
+
return {
|
|
367
|
+
flow,
|
|
368
|
+
provider,
|
|
369
|
+
answers: answers
|
|
370
|
+
};
|
|
571
371
|
}
|
|
572
372
|
function buildPermissionSetupChoices() {
|
|
573
373
|
return {
|
|
@@ -735,129 +535,123 @@ function checkpointUiIntervention(intervention, checkpointUi) {
|
|
|
735
535
|
}
|
|
736
536
|
async function runSetup(args) {
|
|
737
537
|
const json = args.json === true;
|
|
738
|
-
const
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
provider,
|
|
795
|
-
setupTarget: await saveSetupOutput(outputValue, setupPath)
|
|
796
|
-
}
|
|
797
|
-
: await saveSetupAndRuntimeConfig(outputValue, {
|
|
798
|
-
setupPath,
|
|
799
|
-
runtimePath
|
|
800
|
-
});
|
|
801
|
-
const scopedInstallDir = setupInstallDir(provider, installScope, typeof args["skills-dir"] === "string" ? args["skills-dir"] : typeof args.dir === "string" ? args.dir : undefined, projectRoot);
|
|
802
|
-
const installedSkills = !shouldInstallSkills(installScope, surfaces)
|
|
803
|
-
? []
|
|
804
|
-
: provider === "codex"
|
|
805
|
-
? await installCodexSkills(listRoleDefinitions(), scopedInstallDir)
|
|
806
|
-
: await installClaudeSkills(listRoleDefinitions(), scopedInstallDir);
|
|
807
|
-
let mcpInstall;
|
|
808
|
-
if (shouldInstallMcp(installScope, surfaces)) {
|
|
809
|
-
mcpInstall = await installMcpForSetup(provider, {
|
|
810
|
-
...mcpArgsForScope(provider, installScope, args, projectRoot),
|
|
811
|
-
...(provider === "codex" && checkpointUiRequiresMcp(checkpointUi)
|
|
812
|
-
? { "checkpoint-ui": checkpointUi }
|
|
813
|
-
: {})
|
|
814
|
-
});
|
|
815
|
-
}
|
|
816
|
-
if (json) {
|
|
817
|
-
console.log(JSON.stringify({
|
|
818
|
-
setup: outputValue,
|
|
819
|
-
runtime: result,
|
|
820
|
-
installedSkills: installedSkills.map((skill) => skill.name),
|
|
821
|
-
mcpInstall,
|
|
822
|
-
workspacePreference
|
|
823
|
-
}, null, 2));
|
|
824
|
-
return;
|
|
538
|
+
const provider = (typeof args.provider === "string"
|
|
539
|
+
? (args.provider === "claude" ? "claude" : "codex")
|
|
540
|
+
: await promptChoice("Which provider should LongTable configure?", buildProviderChoices()));
|
|
541
|
+
const choices = buildPermissionSetupChoices();
|
|
542
|
+
const installScope = parseSetupInstallScope(args["install-scope"]) ?? await promptChoice("Where may LongTable install runtime support?", choices.installScope);
|
|
543
|
+
const surfaces = parseSetupSurface(args.surfaces) ?? await promptChoice([
|
|
544
|
+
"Which LongTable runtime surfaces should be enabled?",
|
|
545
|
+
"This is a permission choice because skills, MCP, and sentinel support write provider-facing runtime files."
|
|
546
|
+
].join("\n"), choices.surfaces);
|
|
547
|
+
const intervention = parseSetupIntervention(args.intervention) ?? await promptChoice("How strongly may LongTable interrupt research decisions?", choices.intervention);
|
|
548
|
+
const parsedCheckpointUi = parseSetupCheckpointUi(args["checkpoint-ui"]);
|
|
549
|
+
const checkpointUiEligible = provider === "codex" && installScope !== "none" && shouldInstallMcp(installScope, surfaces);
|
|
550
|
+
if (parsedCheckpointUi && checkpointUiRequiresMcp(parsedCheckpointUi) && !checkpointUiEligible) {
|
|
551
|
+
throw new Error("`--checkpoint-ui interactive|strong` requires Codex with an MCP runtime surface.");
|
|
552
|
+
}
|
|
553
|
+
const checkpointUi = parsedCheckpointUi ?? (checkpointUiEligible
|
|
554
|
+
? await promptChoice([
|
|
555
|
+
"Should Codex use UI Researcher Checkpoints when MCP elicitation is available?",
|
|
556
|
+
"This writes Codex MCP elicitation approval only when you choose an interactive mode."
|
|
557
|
+
].join("\n"), choices.checkpointUi)
|
|
558
|
+
: "off");
|
|
559
|
+
const workspacePreference = parseSetupWorkspace(args.workspace) ?? await promptChoice("Should LongTable create a project workspace now?", choices.workspace);
|
|
560
|
+
const projectRoot = setupProjectRoot(args);
|
|
561
|
+
const effectiveIntervention = checkpointUiIntervention(intervention, checkpointUi);
|
|
562
|
+
const outputValue = createPersistedSetupOutput({
|
|
563
|
+
field: "unspecified",
|
|
564
|
+
careerStage: "unspecified",
|
|
565
|
+
experienceLevel: "advanced",
|
|
566
|
+
preferredCheckpointIntensity: checkpointIntensityFromIntervention(effectiveIntervention),
|
|
567
|
+
checkpointUiMode: checkpointUi,
|
|
568
|
+
preferredEntryMode: "explore",
|
|
569
|
+
panelPreference: "show_on_conflict"
|
|
570
|
+
}, provider, "quickstart");
|
|
571
|
+
outputValue.initialState.explicitState = {
|
|
572
|
+
...outputValue.initialState.explicitState,
|
|
573
|
+
installScope,
|
|
574
|
+
runtimeSurfaces: surfaces,
|
|
575
|
+
interventionPosture: effectiveIntervention,
|
|
576
|
+
checkpointUiMode: checkpointUi,
|
|
577
|
+
workspaceCreationPreference: workspacePreference,
|
|
578
|
+
teamMode: "panel"
|
|
579
|
+
};
|
|
580
|
+
if (surfaces === "skills_mcp_sentinel") {
|
|
581
|
+
outputValue.initialState.inferredHypotheses.push({
|
|
582
|
+
hypothesis: "Researcher approved advisory Gap/Tacit Sentinel setup.",
|
|
583
|
+
confidence: 0.95,
|
|
584
|
+
evidence: ["Selected Skills + MCP + Sentinel during permission-first setup."],
|
|
585
|
+
status: "confirmed"
|
|
586
|
+
});
|
|
587
|
+
}
|
|
588
|
+
const setupPath = setupPathForScope(installScope, args, projectRoot);
|
|
589
|
+
const runtimePath = runtimePathForScope(provider, installScope, args, projectRoot);
|
|
590
|
+
const result = installScope === "none"
|
|
591
|
+
? {
|
|
592
|
+
provider,
|
|
593
|
+
setupTarget: await saveSetupOutput(outputValue, setupPath)
|
|
825
594
|
}
|
|
595
|
+
: await saveSetupAndRuntimeConfig(outputValue, {
|
|
596
|
+
setupPath,
|
|
597
|
+
runtimePath
|
|
598
|
+
});
|
|
599
|
+
const scopedInstallDir = setupInstallDir(provider, installScope, typeof args["skills-dir"] === "string" ? args["skills-dir"] : typeof args.dir === "string" ? args.dir : undefined, projectRoot);
|
|
600
|
+
const installedSkills = !shouldInstallSkills(installScope, surfaces)
|
|
601
|
+
? []
|
|
602
|
+
: provider === "codex"
|
|
603
|
+
? await installCodexSkills(listRoleDefinitions(), scopedInstallDir)
|
|
604
|
+
: await installClaudeSkills(listRoleDefinitions(), scopedInstallDir);
|
|
605
|
+
let mcpInstall;
|
|
606
|
+
if (shouldInstallMcp(installScope, surfaces)) {
|
|
607
|
+
mcpInstall = await installMcpForSetup(provider, {
|
|
608
|
+
...mcpArgsForScope(provider, installScope, args, projectRoot),
|
|
609
|
+
...(provider === "codex" && checkpointUiRequiresMcp(checkpointUi)
|
|
610
|
+
? { "checkpoint-ui": checkpointUi }
|
|
611
|
+
: {})
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
if (json) {
|
|
615
|
+
console.log(JSON.stringify({
|
|
616
|
+
setup: outputValue,
|
|
617
|
+
runtime: result,
|
|
618
|
+
installedSkills: installedSkills.map((skill) => skill.name),
|
|
619
|
+
mcpInstall,
|
|
620
|
+
workspacePreference
|
|
621
|
+
}, null, 2));
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
console.log("");
|
|
625
|
+
console.log(renderSetupSummary(outputValue));
|
|
626
|
+
console.log("");
|
|
627
|
+
if ("runtimeTarget" in result) {
|
|
628
|
+
console.log(renderInstallSummary(result));
|
|
629
|
+
}
|
|
630
|
+
else {
|
|
631
|
+
console.log("LongTable setup summary");
|
|
632
|
+
console.log(`setup path: ${result.setupTarget.path}`);
|
|
633
|
+
console.log("provider files: not installed by researcher choice");
|
|
634
|
+
}
|
|
635
|
+
console.log(`Installed skills: ${installedSkills.length}`);
|
|
636
|
+
if (mcpInstall) {
|
|
826
637
|
console.log("");
|
|
827
|
-
console.log(
|
|
828
|
-
|
|
829
|
-
if ("runtimeTarget" in result) {
|
|
830
|
-
console.log(renderInstallSummary(result));
|
|
831
|
-
}
|
|
832
|
-
else {
|
|
833
|
-
console.log("LongTable setup summary");
|
|
834
|
-
console.log(`setup path: ${result.setupTarget.path}`);
|
|
835
|
-
console.log("provider files: not installed by researcher choice");
|
|
836
|
-
}
|
|
837
|
-
console.log(`Installed skills: ${installedSkills.length}`);
|
|
838
|
-
if (mcpInstall) {
|
|
839
|
-
console.log("");
|
|
840
|
-
console.log(renderMcpInstallSummary(mcpInstall));
|
|
841
|
-
if (provider === "codex" && checkpointUiRequiresMcp(checkpointUi)) {
|
|
842
|
-
console.log("");
|
|
843
|
-
console.log("Restart Codex after this config change, then run `longtable doctor` in the project workspace.");
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
if (surfaces === "skills_mcp_sentinel") {
|
|
847
|
-
console.log("");
|
|
848
|
-
console.log("Background sentinel approval recorded.");
|
|
849
|
-
console.log("Hook installation remains opt-in; LongTable will not install hooks without an explicit hook command.");
|
|
850
|
-
}
|
|
851
|
-
if (workspacePreference === "create") {
|
|
638
|
+
console.log(renderMcpInstallSummary(mcpInstall));
|
|
639
|
+
if (provider === "codex" && checkpointUiRequiresMcp(checkpointUi)) {
|
|
852
640
|
console.log("");
|
|
853
|
-
console.log("
|
|
854
|
-
await runStart({
|
|
855
|
-
setup: result.setupTarget.path
|
|
856
|
-
});
|
|
641
|
+
console.log("Restart Codex after this config change, then run `longtable doctor` in the project workspace.");
|
|
857
642
|
}
|
|
858
643
|
}
|
|
859
|
-
|
|
860
|
-
|
|
644
|
+
if (surfaces === "skills_mcp_sentinel") {
|
|
645
|
+
console.log("");
|
|
646
|
+
console.log("Background sentinel approval recorded.");
|
|
647
|
+
console.log("Hook installation remains opt-in; LongTable will not install hooks without an explicit hook command.");
|
|
648
|
+
}
|
|
649
|
+
if (workspacePreference === "create") {
|
|
650
|
+
console.log("");
|
|
651
|
+
console.log("Project workspace requested. LongTable will now run `longtable start` with an adaptive start interview.");
|
|
652
|
+
await runStart({
|
|
653
|
+
setup: result.setupTarget.path
|
|
654
|
+
});
|
|
861
655
|
}
|
|
862
656
|
}
|
|
863
657
|
function perspectiveChoices() {
|
|
@@ -894,6 +688,157 @@ function protectedDecisionChoices() {
|
|
|
894
688
|
{ id: "submission_public_sharing", label: "Submission/public sharing", description: "Do not let public-facing commitments settle quietly." }
|
|
895
689
|
];
|
|
896
690
|
}
|
|
691
|
+
function compactAnswer(value, maxLength = 180) {
|
|
692
|
+
const firstLine = value
|
|
693
|
+
.split(/\r?\n/)
|
|
694
|
+
.map((line) => line.trim())
|
|
695
|
+
.find(Boolean) ?? "";
|
|
696
|
+
return firstLine.length > maxLength ? `${firstLine.slice(0, maxLength - 1)}…` : firstLine;
|
|
697
|
+
}
|
|
698
|
+
function answerIncludes(answer, patterns) {
|
|
699
|
+
return patterns.some((pattern) => pattern.test(answer));
|
|
700
|
+
}
|
|
701
|
+
function classifyStartInterviewSignal(answer) {
|
|
702
|
+
const normalized = answer.toLowerCase();
|
|
703
|
+
if (answerIncludes(normalized, [/\bvoice\b/, /\bauthor(ship)?\b/, /\bwriting\b/, /저자|목소리|문체|글쓰기/])) {
|
|
704
|
+
return "voice";
|
|
705
|
+
}
|
|
706
|
+
if (answerIncludes(normalized, [/\breader\b/, /\breviewer\b/, /\bvenue\b/, /\bjournal\b/, /\baudience\b/, /독자|심사자|저널|학회|대상/])) {
|
|
707
|
+
return "audience";
|
|
708
|
+
}
|
|
709
|
+
if (answerIncludes(normalized, [/\bpaper\b/, /\bproposal\b/, /\bmanuscript\b/, /\bdraft\b/, /\bdeliverable\b/, /논문|제안서|원고|초안|산출물/])) {
|
|
710
|
+
return "artifact";
|
|
711
|
+
}
|
|
712
|
+
if (answerIncludes(normalized, [/\bevidence\b/, /\bdata\b/, /\bsource\b/, /\bcitation\b/, /\bliterature\b/, /\bmeasure\b/, /\bscale\b/, /\binstrument\b/, /근거|자료|데이터|문헌|인용|측정|척도|도구/])) {
|
|
713
|
+
return "evidence";
|
|
714
|
+
}
|
|
715
|
+
if (answerIncludes(normalized, [/\bassum/, /\btacit\b/, /\bimplicit\b/, /\bpremise\b/, /전제|암묵|가정|숨겨진/])) {
|
|
716
|
+
return "assumption";
|
|
717
|
+
}
|
|
718
|
+
if (answerIncludes(normalized, [/\bdecid/, /\bchoose\b/, /\bcommit\b/, /\bsettle\b/, /\block\b/, /결정|선택|확정|고정/])) {
|
|
719
|
+
return "decision_risk";
|
|
720
|
+
}
|
|
721
|
+
return "phenomenon";
|
|
722
|
+
}
|
|
723
|
+
function inferResearchObjectFromAnswers(answers) {
|
|
724
|
+
const joined = answers.join("\n").toLowerCase();
|
|
725
|
+
if (answerIncludes(joined, [/\bmeasure\b/, /\bscale\b/, /\binstrument\b/, /\bvariable\b/, /\bconstruct\b/, /측정|척도|변수|구성개념|도구/])) {
|
|
726
|
+
return "measurement_instrument";
|
|
727
|
+
}
|
|
728
|
+
if (answerIncludes(joined, [/\bmethod\b/, /\bdesign\b/, /\bsample\b/, /\binterview\b/, /\bexperiment\b/, /\bparticipant\b/, /방법|설계|표본|인터뷰|실험|참여자/])) {
|
|
729
|
+
return "study_design";
|
|
730
|
+
}
|
|
731
|
+
if (answerIncludes(joined, [/\btheory\b/, /\bframework\b/, /\bmodel\b/, /\bconcept\b/, /이론|프레임워크|모형|개념/])) {
|
|
732
|
+
return "theory_framework";
|
|
733
|
+
}
|
|
734
|
+
if (answerIncludes(joined, [/\banalysis\b/, /\bmodel\b/, /\bcoding\b/, /\bstatistic\b/, /분석|모델|코딩|통계/])) {
|
|
735
|
+
return "analysis_plan";
|
|
736
|
+
}
|
|
737
|
+
if (answerIncludes(joined, [/\bpaper\b/, /\bmanuscript\b/, /\bdraft\b/, /\bwriting\b/, /논문|원고|초안|글쓰기/])) {
|
|
738
|
+
return "manuscript";
|
|
739
|
+
}
|
|
740
|
+
return "research_question";
|
|
741
|
+
}
|
|
742
|
+
function inferGapRiskFromSignals(signals) {
|
|
743
|
+
if (signals.includes("assumption") || signals.includes("decision_risk")) {
|
|
744
|
+
return "suspected_tacit_assumptions";
|
|
745
|
+
}
|
|
746
|
+
if (signals.includes("evidence")) {
|
|
747
|
+
return "known_gap";
|
|
748
|
+
}
|
|
749
|
+
return "diagnose";
|
|
750
|
+
}
|
|
751
|
+
function inferProtectedDecisionFromAnswers(answers) {
|
|
752
|
+
const joined = answers.join("\n").toLowerCase();
|
|
753
|
+
if (answerIncludes(joined, [/\bmeasure\b/, /\bscale\b/, /\binstrument\b/, /\bvariable\b/, /측정|척도|변수|도구/])) {
|
|
754
|
+
return "measurement";
|
|
755
|
+
}
|
|
756
|
+
if (answerIncludes(joined, [/\bmethod\b/, /\bdesign\b/, /\bsample\b/, /\binterview\b/, /\bexperiment\b/, /방법|설계|표본|인터뷰|실험/])) {
|
|
757
|
+
return "method";
|
|
758
|
+
}
|
|
759
|
+
if (answerIncludes(joined, [/\bevidence\b/, /\bsource\b/, /\bcitation\b/, /\bliterature\b/, /근거|출처|인용|문헌/])) {
|
|
760
|
+
return "evidence_citation";
|
|
761
|
+
}
|
|
762
|
+
if (answerIncludes(joined, [/\bvoice\b/, /\bauthor(ship)?\b/, /\bwriting\b/, /저자|목소리|문체|글쓰기/])) {
|
|
763
|
+
return "authorship_voice";
|
|
764
|
+
}
|
|
765
|
+
if (answerIncludes(joined, [/\bsubmit\b/, /\bpublication\b/, /\bjournal\b/, /\bvenue\b/, /투고|출판|저널|학회|공개/])) {
|
|
766
|
+
return "submission_public_sharing";
|
|
767
|
+
}
|
|
768
|
+
if (answerIncludes(joined, [/\btheory\b/, /\bframework\b/, /\bconstruct\b/, /이론|프레임워크|구성개념/])) {
|
|
769
|
+
return "theory";
|
|
770
|
+
}
|
|
771
|
+
return undefined;
|
|
772
|
+
}
|
|
773
|
+
function uniqueSignals(turns) {
|
|
774
|
+
return [...new Set(turns.map((turn) => turn.signal))];
|
|
775
|
+
}
|
|
776
|
+
function renderStartInterviewPrompt(turn, total, question, context) {
|
|
777
|
+
return [
|
|
778
|
+
`LongTable Start Interview Turn ${turn}/${total}`,
|
|
779
|
+
context ? `Context: ${context}` : undefined,
|
|
780
|
+
question
|
|
781
|
+
].filter(Boolean).join("\n");
|
|
782
|
+
}
|
|
783
|
+
async function collectAdaptiveStartInterview(args) {
|
|
784
|
+
if (!args.needsResearchSeed) {
|
|
785
|
+
return {};
|
|
786
|
+
}
|
|
787
|
+
const createdAt = new Date().toISOString();
|
|
788
|
+
const turns = [];
|
|
789
|
+
async function ask(question, purpose, context) {
|
|
790
|
+
const answer = await promptText(renderStartInterviewPrompt(turns.length + 1, 5, question, context), true);
|
|
791
|
+
if (!answer?.trim()) {
|
|
792
|
+
return undefined;
|
|
793
|
+
}
|
|
794
|
+
turns.push({
|
|
795
|
+
index: turns.length + 1,
|
|
796
|
+
question,
|
|
797
|
+
answer: answer.trim(),
|
|
798
|
+
signal: classifyStartInterviewSignal(answer),
|
|
799
|
+
purpose
|
|
800
|
+
});
|
|
801
|
+
return answer.trim();
|
|
802
|
+
}
|
|
803
|
+
let currentGoal = args.currentGoal;
|
|
804
|
+
let currentBlocker = args.currentBlocker;
|
|
805
|
+
if (!currentGoal) {
|
|
806
|
+
const opening = await ask("What scene, problem, or moment made you want to start this research?", "Open from the researcher's lived entry point instead of a taxonomy.");
|
|
807
|
+
currentGoal = opening ? compactAnswer(opening) : undefined;
|
|
808
|
+
}
|
|
809
|
+
const openingContext = currentGoal ? compactAnswer(currentGoal, 120) : undefined;
|
|
810
|
+
if (!currentBlocker) {
|
|
811
|
+
const blocker = await ask("In that scene, what still feels least explained or hardest to justify?", "Name the first uncertainty without asking the researcher to classify it as theory, method, or measurement.", openingContext);
|
|
812
|
+
currentBlocker = blocker ? compactAnswer(blocker) : undefined;
|
|
813
|
+
}
|
|
814
|
+
const readerContext = currentBlocker ? compactAnswer(currentBlocker, 120) : openingContext;
|
|
815
|
+
await ask("If this research succeeds, what should a reader or reviewer understand differently?", "Locate the audience-facing contribution before proposing a direction.", readerContext);
|
|
816
|
+
await ask("What material would you inspect first to make this research concrete: a case, dataset, text, instrument, draft, or literature trail?", "Convert the opening story into a first inspectable research move.", readerContext);
|
|
817
|
+
const answers = turns.map((turn) => turn.answer);
|
|
818
|
+
const inferredSignals = uniqueSignals(turns);
|
|
819
|
+
const summary = [
|
|
820
|
+
currentGoal ? `Opening: ${compactAnswer(currentGoal, 120)}.` : "",
|
|
821
|
+
currentBlocker ? `First uncertainty: ${compactAnswer(currentBlocker, 120)}.` : "",
|
|
822
|
+
inferredSignals.length > 0 ? `Early lenses: ${inferredSignals.join(", ")}.` : ""
|
|
823
|
+
].filter(Boolean).join(" ");
|
|
824
|
+
return {
|
|
825
|
+
currentGoal,
|
|
826
|
+
currentBlocker,
|
|
827
|
+
startInterview: {
|
|
828
|
+
mode: "adaptive",
|
|
829
|
+
openingStyle: "scene_problem",
|
|
830
|
+
createdAt,
|
|
831
|
+
completedAt: new Date().toISOString(),
|
|
832
|
+
turnCount: turns.length,
|
|
833
|
+
turns,
|
|
834
|
+
inferredSignals,
|
|
835
|
+
summary: summary || "Adaptive start interview completed."
|
|
836
|
+
},
|
|
837
|
+
inferredResearchObject: inferResearchObjectFromAnswers(answers),
|
|
838
|
+
inferredGapRisk: inferGapRiskFromSignals(inferredSignals),
|
|
839
|
+
inferredProtectedDecision: inferProtectedDecisionFromAnswers(answers)
|
|
840
|
+
};
|
|
841
|
+
}
|
|
897
842
|
function normalizePerspectiveList(value) {
|
|
898
843
|
if (!value?.trim()) {
|
|
899
844
|
return [];
|
|
@@ -904,82 +849,76 @@ function normalizePerspectiveList(value) {
|
|
|
904
849
|
.filter(Boolean);
|
|
905
850
|
}
|
|
906
851
|
async function collectProjectInterview(setup, args) {
|
|
852
|
+
const providedPerspectives = normalizePerspectiveList(typeof args.perspectives === "string" ? args.perspectives : undefined);
|
|
853
|
+
const providedGoal = typeof args.goal === "string" && args.goal.trim() ? args.goal.trim() : undefined;
|
|
854
|
+
const providedBlocker = typeof args.blocker === "string" && args.blocker.trim() ? args.blocker.trim() : undefined;
|
|
855
|
+
const providedResearchObject = typeof args["research-object"] === "string" && args["research-object"].trim()
|
|
856
|
+
? args["research-object"].trim()
|
|
857
|
+
: undefined;
|
|
858
|
+
const providedGapRisk = typeof args["gap-risk"] === "string" && args["gap-risk"].trim()
|
|
859
|
+
? args["gap-risk"].trim()
|
|
860
|
+
: undefined;
|
|
861
|
+
const providedProtectedDecision = typeof args["protected-decision"] === "string" && args["protected-decision"].trim()
|
|
862
|
+
? args["protected-decision"].trim()
|
|
863
|
+
: undefined;
|
|
907
864
|
const needsInteractivePrompts = !(typeof args.name === "string" && args.name.trim()) ||
|
|
908
865
|
!(typeof args.path === "string" && args.path.trim()) ||
|
|
909
|
-
!
|
|
910
|
-
|
|
911
|
-
!
|
|
912
|
-
!
|
|
913
|
-
!
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
"We will create a project workspace and a session memory seed for today's work.",
|
|
924
|
-
"At the end, LongTable will tell you exactly which directory to open in Codex."
|
|
925
|
-
]));
|
|
926
|
-
console.log("");
|
|
927
|
-
}
|
|
928
|
-
const projectName = (typeof args.name === "string" && args.name.trim()) ||
|
|
929
|
-
(await promptText(rl, renderQuestionHeader(1, 9, "Project interview", "What should this project be called?"), true));
|
|
930
|
-
const suggestedParentDir = typeof args.path === "string" && args.path.trim()
|
|
931
|
-
? normalizeUserPath(args.path.trim())
|
|
932
|
-
: homedir();
|
|
933
|
-
const suggestedPath = resolveInteractiveProjectPath(suggestedParentDir, projectName);
|
|
934
|
-
const projectPath = (typeof args.path === "string" && args.path.trim()
|
|
935
|
-
? normalizeUserPath(args.path.trim())
|
|
936
|
-
: resolveInteractiveProjectPath((await promptText(rl, renderQuestionHeader(2, 9, "Project interview", `Which parent directory should contain this project?\nLongTable will create this folder:\n${suggestedPath}`), true)), projectName));
|
|
937
|
-
const currentGoal = (typeof args.goal === "string" && args.goal.trim()) ||
|
|
938
|
-
(await promptText(rl, renderQuestionHeader(3, 9, "Current session", "What are you trying to accomplish in this session?"), true));
|
|
939
|
-
const currentBlocker = (typeof args.blocker === "string" && args.blocker.trim()) ||
|
|
940
|
-
(await promptText(rl, renderQuestionHeader(4, 9, "Current session", "What is the main blocker or uncertainty right now?"), false));
|
|
941
|
-
const researchObject = (typeof args["research-object"] === "string" && args["research-object"].trim()) ||
|
|
942
|
-
await promptChoice(rl, renderQuestionHeader(5, 9, "Research object", "What kind of research object are we protecting right now?"), researchObjectChoices());
|
|
943
|
-
const gapRisk = (typeof args["gap-risk"] === "string" && args["gap-risk"].trim()) ||
|
|
944
|
-
await promptChoice(rl, renderQuestionHeader(6, 9, "Gap/tacit risk", "What is the most likely gap risk at the start of this workspace?"), gapRiskChoices());
|
|
945
|
-
const protectedDecision = (typeof args["protected-decision"] === "string" && args["protected-decision"].trim()) ||
|
|
946
|
-
await promptChoice(rl, renderQuestionHeader(7, 9, "Protected decision", "Which decision should LongTable not let you settle quietly?"), protectedDecisionChoices());
|
|
947
|
-
const requestedPerspectives = normalizePerspectiveList(typeof args.perspectives === "string" ? args.perspectives : undefined).length > 0
|
|
948
|
-
? normalizePerspectiveList(typeof args.perspectives === "string" ? args.perspectives : undefined)
|
|
949
|
-
: await promptMultiChoice(rl, renderQuestionHeader(8, 9, "Perspectives", "Which perspectives do you already know you want at the table? Leave everything unchecked for auto."), perspectiveChoices());
|
|
950
|
-
const disagreementPreference = (typeof args.disagreement === "string" && args.disagreement.trim()) ||
|
|
951
|
-
(await promptChoice(rl, renderQuestionHeader(9, 9, "Disagreement", "How visible should disagreement between perspectives be in this project by default?"), [
|
|
952
|
-
{
|
|
953
|
-
id: "synthesis_only",
|
|
954
|
-
label: "Synthesis only",
|
|
955
|
-
description: "Show one LongTable answer unless I ask for more."
|
|
956
|
-
},
|
|
957
|
-
{
|
|
958
|
-
id: "show_on_conflict",
|
|
959
|
-
label: "Show on conflict",
|
|
960
|
-
description: "Surface disagreement when the perspectives materially diverge."
|
|
961
|
-
},
|
|
962
|
-
{
|
|
963
|
-
id: "always_visible",
|
|
964
|
-
label: "Always visible",
|
|
965
|
-
description: "Keep panel opinions visible by default."
|
|
966
|
-
}
|
|
967
|
-
]));
|
|
968
|
-
return {
|
|
969
|
-
projectName: projectName.trim(),
|
|
970
|
-
projectPath: projectPath.trim(),
|
|
971
|
-
currentGoal: currentGoal.trim(),
|
|
972
|
-
...(currentBlocker?.trim() ? { currentBlocker: currentBlocker.trim() } : {}),
|
|
973
|
-
researchObject: researchObject.trim(),
|
|
974
|
-
gapRisk: gapRisk.trim(),
|
|
975
|
-
protectedDecision: protectedDecision.trim(),
|
|
976
|
-
requestedPerspectives,
|
|
977
|
-
disagreementPreference: disagreementPreference
|
|
978
|
-
};
|
|
979
|
-
}
|
|
980
|
-
finally {
|
|
981
|
-
rl.close();
|
|
866
|
+
!providedGoal ||
|
|
867
|
+
!providedBlocker ||
|
|
868
|
+
!providedResearchObject ||
|
|
869
|
+
!providedGapRisk ||
|
|
870
|
+
!providedProtectedDecision;
|
|
871
|
+
if (needsInteractivePrompts) {
|
|
872
|
+
console.log("");
|
|
873
|
+
console.log(renderBrandBanner("LongTable", "Project workspace interview"));
|
|
874
|
+
console.log("");
|
|
875
|
+
console.log(renderSectionCard("LongTable Project Start", [
|
|
876
|
+
"LongTable will create a workspace and seed today's research memory.",
|
|
877
|
+
"The start interview begins from the scene or problem, then LongTable quietly infers the research shape."
|
|
878
|
+
]));
|
|
879
|
+
console.log("");
|
|
982
880
|
}
|
|
881
|
+
const projectName = (typeof args.name === "string" && args.name.trim()) ||
|
|
882
|
+
(await promptText(renderQuestionHeader(1, 2, "Workspace", "What should this project be called?"), true));
|
|
883
|
+
const suggestedParentDir = typeof args.path === "string" && args.path.trim()
|
|
884
|
+
? normalizeUserPath(args.path.trim())
|
|
885
|
+
: homedir();
|
|
886
|
+
const suggestedPath = resolveInteractiveProjectPath(suggestedParentDir, projectName);
|
|
887
|
+
const projectPath = (typeof args.path === "string" && args.path.trim()
|
|
888
|
+
? normalizeUserPath(args.path.trim())
|
|
889
|
+
: resolveInteractiveProjectPath((await promptText(renderQuestionHeader(2, 2, "Workspace", `Which parent directory should contain this project?\nLongTable will create this folder:\n${suggestedPath}`), true)), projectName));
|
|
890
|
+
const adaptive = await collectAdaptiveStartInterview({
|
|
891
|
+
currentGoal: providedGoal,
|
|
892
|
+
currentBlocker: providedBlocker,
|
|
893
|
+
needsResearchSeed: !providedGoal ||
|
|
894
|
+
!providedBlocker ||
|
|
895
|
+
!providedResearchObject ||
|
|
896
|
+
!providedGapRisk ||
|
|
897
|
+
!providedProtectedDecision
|
|
898
|
+
});
|
|
899
|
+
const currentGoal = providedGoal ?? adaptive.currentGoal;
|
|
900
|
+
if (!currentGoal?.trim()) {
|
|
901
|
+
throw new Error("LongTable start needs a current research goal or an opening interview answer.");
|
|
902
|
+
}
|
|
903
|
+
const currentBlocker = providedBlocker ?? adaptive.currentBlocker;
|
|
904
|
+
const researchObject = providedResearchObject ?? adaptive.inferredResearchObject;
|
|
905
|
+
const gapRisk = providedGapRisk ?? adaptive.inferredGapRisk;
|
|
906
|
+
const protectedDecision = providedProtectedDecision ?? adaptive.inferredProtectedDecision;
|
|
907
|
+
const disagreementPreference = (typeof args.disagreement === "string" && args.disagreement.trim()
|
|
908
|
+
? args.disagreement.trim()
|
|
909
|
+
: setup.profileSeed.panelPreference ?? "show_on_conflict");
|
|
910
|
+
return {
|
|
911
|
+
projectName: projectName.trim(),
|
|
912
|
+
projectPath: projectPath.trim(),
|
|
913
|
+
currentGoal: currentGoal.trim(),
|
|
914
|
+
...(currentBlocker?.trim() ? { currentBlocker: currentBlocker.trim() } : {}),
|
|
915
|
+
...(researchObject?.trim() ? { researchObject: researchObject.trim() } : {}),
|
|
916
|
+
...(gapRisk?.trim() ? { gapRisk: gapRisk.trim() } : {}),
|
|
917
|
+
...(protectedDecision?.trim() ? { protectedDecision: protectedDecision.trim() } : {}),
|
|
918
|
+
...(adaptive.startInterview ? { startInterview: adaptive.startInterview } : {}),
|
|
919
|
+
requestedPerspectives: providedPerspectives,
|
|
920
|
+
disagreementPreference
|
|
921
|
+
};
|
|
983
922
|
}
|
|
984
923
|
function normalizePersistAnswers(raw) {
|
|
985
924
|
return {
|
|
@@ -2338,30 +2277,24 @@ async function runQuestion(args) {
|
|
|
2338
2277
|
return;
|
|
2339
2278
|
}
|
|
2340
2279
|
if (isInteractiveTerminal()) {
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
console.log(`- current: ${context.currentFilePath}`);
|
|
2360
|
-
return;
|
|
2361
|
-
}
|
|
2362
|
-
finally {
|
|
2363
|
-
rl.close();
|
|
2364
|
-
}
|
|
2280
|
+
console.log(renderBrandBanner("LongTable", "Researcher Checkpoint"));
|
|
2281
|
+
console.log("");
|
|
2282
|
+
const answer = await promptChoice(renderQuestionHeader(1, 1, result.question.prompt.title, result.question.prompt.question), questionRecordToChoices(result.question));
|
|
2283
|
+
const decision = await answerWorkspaceQuestion({
|
|
2284
|
+
context,
|
|
2285
|
+
questionId: result.question.id,
|
|
2286
|
+
answer,
|
|
2287
|
+
provider,
|
|
2288
|
+
surface: "terminal_selector"
|
|
2289
|
+
});
|
|
2290
|
+
console.log("");
|
|
2291
|
+
console.log("LongTable checkpoint decision recorded");
|
|
2292
|
+
console.log(`- question: ${decision.question.id}`);
|
|
2293
|
+
console.log(`- decision: ${decision.decision.id}`);
|
|
2294
|
+
console.log(`- answer: ${decision.decision.selectedOption ?? answer}`);
|
|
2295
|
+
console.log(`- state: ${context.stateFilePath}`);
|
|
2296
|
+
console.log(`- current: ${context.currentFilePath}`);
|
|
2297
|
+
return;
|
|
2365
2298
|
}
|
|
2366
2299
|
const optionValues = [
|
|
2367
2300
|
...result.question.prompt.options.map((option) => option.value),
|
|
@@ -2452,25 +2385,19 @@ async function answerFollowUpQuestionsInTerminal(context, questions, provider) {
|
|
|
2452
2385
|
if (questions.length === 0) {
|
|
2453
2386
|
return;
|
|
2454
2387
|
}
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
surface: "terminal_selector"
|
|
2469
|
-
});
|
|
2470
|
-
}
|
|
2471
|
-
}
|
|
2472
|
-
finally {
|
|
2473
|
-
rl.close();
|
|
2388
|
+
console.log(renderBrandBanner("LongTable", "Follow-up Questions"));
|
|
2389
|
+
console.log("");
|
|
2390
|
+
for (let index = 0; index < questions.length; index += 1) {
|
|
2391
|
+
const question = questions[index];
|
|
2392
|
+
const prompt = renderQuestionHeader(index + 1, questions.length, question.prompt.title, question.prompt.question);
|
|
2393
|
+
const answer = await promptChoice(prompt, questionRecordToChoices(question));
|
|
2394
|
+
await answerWorkspaceQuestion({
|
|
2395
|
+
context,
|
|
2396
|
+
questionId: question.id,
|
|
2397
|
+
answer,
|
|
2398
|
+
provider,
|
|
2399
|
+
surface: "terminal_selector"
|
|
2400
|
+
});
|
|
2474
2401
|
}
|
|
2475
2402
|
}
|
|
2476
2403
|
async function runClarify(args) {
|
|
@@ -2861,6 +2788,7 @@ async function runStart(args) {
|
|
|
2861
2788
|
researchObject: interview.researchObject,
|
|
2862
2789
|
gapRisk: interview.gapRisk,
|
|
2863
2790
|
protectedDecision: interview.protectedDecision,
|
|
2791
|
+
startInterview: interview.startInterview,
|
|
2864
2792
|
requestedPerspectives: interview.requestedPerspectives,
|
|
2865
2793
|
disagreementPreference: interview.disagreementPreference,
|
|
2866
2794
|
setup: existingSetup
|