@turri-dev/cli 0.4.3-next.3fc888b → 0.4.3-next.7ada234

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 (58) hide show
  1. package/dist/capture/agents.d.ts +21 -6
  2. package/dist/capture/agents.js +49 -8
  3. package/dist/capture/assemble.d.ts +4 -14
  4. package/dist/capture/assemble.js +19 -18
  5. package/dist/capture/capture.d.ts +3 -3
  6. package/dist/capture/capture.js +67 -33
  7. package/dist/capture/checks.js +7 -1
  8. package/dist/capture/config.d.ts +1 -1
  9. package/dist/capture/config.js +16 -10
  10. package/dist/capture/interface.js +1 -1
  11. package/dist/capture/map.d.ts +0 -2
  12. package/dist/capture/map.js +1 -1
  13. package/dist/capture/models.d.ts +4 -0
  14. package/dist/capture/models.js +16 -0
  15. package/dist/capture/plan.d.ts +2 -3
  16. package/dist/capture/plan.js +9 -9
  17. package/dist/capture/progress.d.ts +3 -1
  18. package/dist/capture/progress.js +28 -2
  19. package/dist/capture/python-interface.d.ts +3 -0
  20. package/dist/capture/python-interface.js +17 -0
  21. package/dist/capture/report.js +2 -2
  22. package/dist/capture/runners.d.ts +6 -0
  23. package/dist/capture/runners.js +59 -0
  24. package/dist/capture/scripts.d.ts +1 -1
  25. package/dist/capture/scripts.js +5 -0
  26. package/dist/capture/state.d.ts +11 -0
  27. package/dist/capture-cli.js +4 -4
  28. package/dist/chat-tab-header.d.ts +3 -2
  29. package/dist/chat-tab-header.js +22 -9
  30. package/dist/chat-terminal.js +22 -4
  31. package/dist/chats.d.ts +3 -0
  32. package/dist/chats.js +14 -2
  33. package/dist/config-edit.js +4 -3
  34. package/dist/config.d.ts +1 -1
  35. package/dist/config.js +8 -7
  36. package/dist/extension.d.ts +1 -1
  37. package/dist/extension.js +40 -16
  38. package/dist/init-config.d.ts +4 -1
  39. package/dist/init-config.js +31 -6
  40. package/dist/pi.d.ts +2 -2
  41. package/dist/pi.js +2 -2
  42. package/dist/question-dialog.d.ts +2 -2
  43. package/dist/question-dialog.js +10 -6
  44. package/dist/regenerate/agent-env.js +5 -1
  45. package/dist/terminal-notifications.d.ts +8 -2
  46. package/dist/terminal-notifications.js +45 -15
  47. package/docs/capture.md +31 -11
  48. package/docs/chats.md +3 -1
  49. package/docs/config.md +4 -3
  50. package/docs/sandbox.md +2 -0
  51. package/docs/sentinel.md +1 -1
  52. package/genome/capture/check-reference.md +1 -0
  53. package/genome/capture/modules.md +2 -0
  54. package/genome/capture/python-interface.py +111 -0
  55. package/genome/capture/runners/python-requirements.sh +67 -0
  56. package/genome/capture/survey.md +2 -0
  57. package/genome/capture/trial.md +1 -1
  58. package/package.json +1 -1
@@ -1,4 +1,5 @@
1
- import { Type, type TSchema } from "typebox";
1
+ import { Type, type TObject } from "typebox";
2
+ import type { CaptureRole } from "./models.ts";
2
3
  /**
3
4
  * Capture's agents, each fresh, each with one thing to hand over through a submit tool of its own: the survey, its
4
5
  * conventions checked, a split, an outline, a part's features divided, a feature, the interface no feature captured, a
@@ -11,6 +12,8 @@ import { Type, type TSchema } from "typebox";
11
12
  export declare const RETRIES = 2;
12
13
  /** How long one turn of a capture agent may take, unless the config says: exploring takes a while. */
13
14
  export declare const CAPTURE_TURN_LIMIT_MS: number;
15
+ /** Part of the first response, so explaining the work costs no separate model call. */
16
+ export declare const CAPTURE_PLAN_NOTE = "Before your first tool call, write one short line beginning 'Plan: ' for the person watching. Say what you will inspect, write or test for this assignment. Then do it in the same turn. Say the plan only once.";
14
17
  /** One of capture's prompts, from genome/capture. */
15
18
  export declare function capturePrompt(name: string): string;
16
19
  export interface AgentOptions {
@@ -18,7 +21,7 @@ export interface AgentOptions {
18
21
  plainDir: string;
19
22
  /** The codebase, which the agent reads. */
20
23
  root: string;
21
- role: "capture" | "capture-analysis";
24
+ role: CaptureRole;
22
25
  model?: string;
23
26
  label: string;
24
27
  /** Its prompt's name in genome/capture, after the shared one - or several, in order. */
@@ -50,22 +53,27 @@ export interface AgentOptions {
50
53
  /** Who watches an agent at work - the capture's status: when it starts, what it does, what it costs, when it ends. */
51
54
  export interface AgentWatch {
52
55
  started(): void;
56
+ /** The agent's opening line, or its assigned task when it starts straight on a tool. */
57
+ plan(line?: string): void;
53
58
  /** A tool call it made, or a result worth a line: `○ read app/main.py`. */
54
59
  did(line: string): void;
55
60
  /** What it is at this moment - thinking, waiting for the model, writing a call - or nothing. */
56
61
  now(label: string | undefined): void;
57
62
  /** What one model response cost, in dollars. */
58
63
  spent(cost: number): void;
64
+ /** The agent's own account, once its submitted work passes the harness's checks. */
65
+ finding(line: string): void;
59
66
  ended(): void;
60
67
  }
61
- /** Ask an agent for one answer, sending it back with what is wrong until it holds. Undefined, with the last problems, when it never did. */
62
- export declare function askAgent<A>(options: AgentOptions, tool: {
68
+ interface AnswerTool<A> {
63
69
  name: string;
64
70
  label: string;
65
71
  description: string;
66
- parameters: TSchema;
72
+ parameters: TObject;
67
73
  convert: (params: Record<string, unknown>) => A;
68
- }, check: (answer: A) => string[]): Promise<{
74
+ }
75
+ /** Ask an agent for one answer, sending it back with what is wrong until it holds. Undefined, with the last problems, when it never did. */
76
+ export declare function askAgent<A>(options: AgentOptions, tool: AnswerTool<A>, check: (answer: A) => string[]): Promise<{
69
77
  answer?: A;
70
78
  problems: string[];
71
79
  }>;
@@ -116,12 +124,19 @@ export declare const SURVEY_TOOL: {
116
124
  concept: Type.TString;
117
125
  text: Type.TString;
118
126
  }>>;
127
+ runners: Type.TObject<{
128
+ unit: Type.TUnion<[Type.TLiteral<"pytest">, Type.TLiteral<"custom">]>;
129
+ conformance: Type.TUnion<[Type.TLiteral<"pytest">, Type.TLiteral<"bats">, Type.TLiteral<"custom">]>;
130
+ build_dir_env: Type.TOptional<Type.TString>;
131
+ python_env: Type.TOptional<Type.TString>;
132
+ }>;
119
133
  }>>;
120
134
  left_out: Type.TArray<Type.TObject<{
121
135
  path: Type.TString;
122
136
  why: Type.TString;
123
137
  }>>;
124
138
  assumptions: Type.TArray<Type.TString>;
139
+ separate_concerns: Type.TOptional<Type.TString>;
125
140
  }>;
126
141
  };
127
142
  export declare const REFERENCE_TOOL: {
@@ -20,19 +20,47 @@ import { STDLIB_DIR } from "../regenerate/paths.js";
20
20
  export const RETRIES = 2;
21
21
  /** How long one turn of a capture agent may take, unless the config says: exploring takes a while. */
22
22
  export const CAPTURE_TURN_LIMIT_MS = 10 * 60 * 1000;
23
+ /** Part of the first response, so explaining the work costs no separate model call. */
24
+ export const CAPTURE_PLAN_NOTE = "Before your first tool call, write one short line beginning 'Plan: ' for the person watching. Say what you will inspect, write or test for this assignment. Then do it in the same turn. Say the plan only once.";
23
25
  const PROMPTS_DIR = join(PACKAGE_ROOT, "genome", "capture");
26
+ // These reviewers can only return edits to existing text. Keep the rules for that text and the full source/reference
27
+ // evidence; they have no modules, stacks, integrations, testing scripts or regeneration workflow to design.
28
+ const REVIEW_TEXT_RULES = ["concise-specs", "concise-specs-examples", "func-specs", "test-plain-files", "definitions", "linked-resources", "bullet-continuation", "semantic-ids"];
24
29
  /** One of capture's prompts, from genome/capture. */
25
30
  export function capturePrompt(name) {
26
31
  return readFileSync(join(PROMPTS_DIR, `${name}.md`), "utf8").trim();
27
32
  }
28
33
  /** What the agent's session reports, handed to its watch - and the capture's stop, which ends its turn. */
29
34
  function watchedBy(watch, signal) {
35
+ let opening = "";
36
+ let announced = false;
37
+ // Only the explicitly labelled opening line is public. Reasoning, later prose and tool results never enter this trace.
38
+ const announce = () => {
39
+ if (announced)
40
+ return;
41
+ announced = true;
42
+ watch?.plan(/^\s*Plan:[ \t]*([^\r\n]+)/i.exec(opening)?.[1]?.trim());
43
+ };
30
44
  return {
31
45
  stage: () => { },
32
46
  activity: (line) => watch?.did(line),
33
- now: (label) => watch?.now(label),
47
+ now: (label) => {
48
+ if (label === "preparing a tool call")
49
+ announce();
50
+ watch?.now(label);
51
+ },
34
52
  usage: (usage) => watch?.spent(usage.cost),
35
- transcript: () => { },
53
+ transcript: (entry) => {
54
+ if (announced)
55
+ return;
56
+ if (entry.kind === "text") {
57
+ opening += entry.text.slice(0, 320 - opening.length);
58
+ if (opening.trimStart().includes("\n") || opening.length === 320)
59
+ announce();
60
+ }
61
+ else if (entry.kind === "tool")
62
+ announce();
63
+ },
36
64
  ...(signal !== undefined ? { signal } : {}),
37
65
  };
38
66
  }
@@ -52,13 +80,16 @@ export async function watched(watch, signal, work) {
52
80
  }
53
81
  async function answerOf(options, tool, check) {
54
82
  let answer;
83
+ let finding = "";
55
84
  const submit = defineTool({
56
85
  name: tool.name,
57
86
  label: tool.label,
58
87
  description: tool.description,
59
- parameters: tool.parameters,
88
+ parameters: Type.Object({ ...tool.parameters.properties, finding: Type.String({ description: "For the person watching: one short sentence naming the most useful behaviour you found, corrected or could not verify. Give a concrete example rather than a count or a list of actions." }) }),
60
89
  async execute(_id, params) {
61
- answer = tool.convert(params);
90
+ const { finding: report, ...work } = params;
91
+ answer = tool.convert(work);
92
+ finding = text(report);
62
93
  return { content: [{ type: "text", text: "Recorded." }], details: {}, terminate: true };
63
94
  },
64
95
  });
@@ -72,11 +103,11 @@ async function answerOf(options, tool, check) {
72
103
  customTools: [submit, ...(fence?.tools ?? [])],
73
104
  tools: [...(fence?.names ?? []), submit.name],
74
105
  model: options.model,
75
- rules: options.rules,
106
+ rules: options.rules && (options.prompt === "verify" || options.prompt === "readability") ? REVIEW_TEXT_RULES : options.rules,
76
107
  label: options.label,
77
108
  role: options.role,
78
109
  ...(fence !== undefined ? { system: fence.note } : {}),
79
- task: [capturePrompt("capture"), ...[options.prompt].flat().map(capturePrompt), options.context].join("\n\n"),
110
+ task: [capturePrompt("capture"), ...[options.prompt].flat().map(capturePrompt), options.context, CAPTURE_PLAN_NOTE].join("\n\n"),
80
111
  budget: { calls: options.calls, finish: [submit.name] },
81
112
  });
82
113
  const limit = turnLimit(options.plainDir, options.role);
@@ -86,8 +117,11 @@ async function answerOf(options, tool, check) {
86
117
  await ask(session, BEGIN);
87
118
  for (let again = 0;; again += 1) {
88
119
  problems = answer === undefined ? [`You did not call ${submit.name}.`] : check(answer);
89
- if (problems.length === 0)
120
+ if (problems.length === 0) {
121
+ if (finding)
122
+ options.watch?.finding(finding);
90
123
  return { answer, problems };
124
+ }
91
125
  if (again >= RETRIES)
92
126
  return { problems };
93
127
  answer = undefined;
@@ -158,9 +192,16 @@ export const SURVEY_TOOL = {
158
192
  })),
159
193
  test_reqs: Strings("How its conformance tests run, one fact each, and what each sets up so the software acts the same on every run and machine - empty when the conformance template says it all."),
160
194
  definitions: Definitions,
195
+ runners: Type.Object({
196
+ unit: Type.Union([Type.Literal("pytest"), Type.Literal("custom")]),
197
+ conformance: Type.Union([Type.Literal("pytest"), Type.Literal("bats"), Type.Literal("custom")]),
198
+ build_dir_env: Type.Optional(Type.String({ description: "Build-folder variable used by external tests, if any. Omit rather than an empty string." })),
199
+ python_env: Type.Optional(Type.String({ description: "Interpreter variable used by external tests, if any. Omit rather than an empty string." })),
200
+ }, { description: "Select each runner explicitly. pytest: ordinary pytest for a root requirements.txt project, or an installable pyproject.toml package (pip install . creates its console scripts; external tests can use a src layout). bats: bats-core with a root requirements.txt build, including --separate-stderr and env -C. Choose custom when the suite needs other services, plugins, checkers, environment or setup." }),
161
201
  })),
162
202
  left_out: LeftOutSchema,
163
203
  assumptions: Strings("What you decided where the codebase left it open, a line each."),
204
+ separate_concerns: Type.Optional(Type.String({ description: "Only for a single part whose behaviour demonstrably needs separate writers: name distinct independently useful concerns that cannot fit one readable module of eight functional specs. Omit when one compact writer can capture it." })),
164
205
  }),
165
206
  };
166
207
  export const REFERENCE_TOOL = {
@@ -172,7 +213,7 @@ export const REFERENCE_TOOL = {
172
213
  kind: Type.Union([Type.Literal("command"), Type.Literal("argument"), Type.Literal("option"), Type.Literal("route"), Type.Literal("env"), Type.Literal("other")]),
173
214
  name: Type.String({ description: "Exactly as the code has it: --proxy, http, httpie plugins install, GET /notes/<int:id> (the code's own parameter syntax), HTTPIE_CONFIG_DIR." }),
174
215
  aliases: Strings("Every other name it has, as the code has each: -x."),
175
- command: Type.Optional(Type.String({ description: "For an argument or an option: the command it belongs to, as its users type it - http, httpie plugins install." })),
216
+ command: Type.Optional(Type.String({ description: "For an argument or option: one actual command, as typed. Repeat a shared option's entry for each command accepting it; never join commands into a made-up command name." })),
176
217
  takes: Type.Optional(Type.String({ description: "What it takes: its value's form or type, as the code names it - its metavar, its type, a body." })),
177
218
  choices: Strings("The values it accepts when the code lists them, each exactly as the code has it."),
178
219
  default: Type.Optional(Type.String({ description: "Its default, exactly as the code has it. Left out when it has none." })),
@@ -97,6 +97,9 @@ export declare function assemble(state: CaptureState, moduleSpecs?: number, opti
97
97
  export declare function areaModules(state: CaptureState, part: string, moduleSpecs: number, taken: Set<string>): AssembledModule[];
98
98
  /** Definitions with each after the concepts its text uses, where they are among them; otherwise in the order given. */
99
99
  export declare function inDefinitionOrder(definitions: Definition[]): Definition[];
100
+ /** Captured examples are data. Backticks alone do not protect them: Liquid runs before Markdown. Normal examples
101
+ * stay readable in a single raw block. Escape just the opening delimiter for a literal raw/endraw or incomplete tag. */
102
+ export declare function capturedText(text: string): string;
100
103
  export declare function renderShared(module: SharedModule): string;
101
104
  export declare function renderModule(module: AssembledModule): string;
102
105
  export declare function renderTestPlainFile(module: string, spec: CapturedSpec): string | undefined;
@@ -104,19 +107,6 @@ export declare function renderTestPlainFile(module: string, spec: CapturedSpec):
104
107
  export declare function captureFiles(assembly: Assembly): Map<string, string>;
105
108
  /** The asset files capture copies into `assets/`: images, fonts and media of the parts, none of what is left out. */
106
109
  export declare function assetsToCopy(map: CodeMap, state: CaptureState): string[];
107
- /**
108
- * The project's config, over what it holds already - the config in use it started as (`capture/config.ts`): conformance
109
- * tests on, the assets as the base folder, the models when they were named. A capture started before it held one starts
110
- * from nothing.
111
- */
112
- export declare function configText(existing: string, options: {
113
- assets: boolean;
114
- harnessModel?: string;
115
- codingModel?: string;
116
- }): string;
117
110
  /** Put a capture on disk: its ***plain, its config, the assets copied, and what keeps the regenerated code's histories out of the repo. */
118
- export declare function writeCapture(plainDir: string, map: CodeMap, state: CaptureState, assembly: Assembly, models: {
119
- harnessModel?: string;
120
- codingModel?: string;
121
- }): string[];
111
+ export declare function writeCapture(plainDir: string, map: CodeMap, state: CaptureState, assembly: Assembly): string[];
122
112
  export {};
@@ -2,7 +2,6 @@ import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from
2
2
  import { dirname, join } from "node:path";
3
3
  import { CONFIG_FILE, CONFIG_KEYS } from "../config.js";
4
4
  import { withSetting } from "../config-edit.js";
5
- import { startingConfig } from "./config.js";
6
5
  import { referenceOf, referencePath, renderReference } from "./interface.js";
7
6
  import { moduleConfigFile } from "../config.js";
8
7
  import { conformanceOf } from "../stdlib.js";
@@ -319,10 +318,19 @@ export function inDefinitionOrder(definitions) {
319
318
  }
320
319
  /** A YAML scalar that reads back as the text, whatever it holds. */
321
320
  function yamlText(text) {
322
- return JSON.stringify(text.replace(/\s+/g, " ").trim());
321
+ return JSON.stringify(capturedText(text.replace(/\s+/g, " ").trim()));
322
+ }
323
+ /** Captured examples are data. Backticks alone do not protect them: Liquid runs before Markdown. Normal examples
324
+ * stay readable in a single raw block. Escape just the opening delimiter for a literal raw/endraw or incomplete tag. */
325
+ export function capturedText(text) {
326
+ return text.replace(/\{(?:\{[^\n{}]*?\}\}|%[^\n{}]*?%\}|[\{%])/g, tag => {
327
+ if (tag.length === 2 || /^\{%[-\s]*(?:raw|endraw)\b/.test(tag))
328
+ return `{% raw %}${tag.slice(0, 2)}{% endraw %}${tag.slice(2)}`;
329
+ return `{% raw %}${tag}{% endraw %}`;
330
+ });
323
331
  }
324
332
  function section(title, bullets) {
325
- return bullets.length === 0 ? [] : [`***${title}***`, "", ...bullets.map((bullet) => `- ${bullet}`), ""];
333
+ return bullets.length === 0 ? [] : [`***${title}***`, "", ...bullets.map((bullet) => `- ${capturedText(bullet)}`), ""];
326
334
  }
327
335
  function frontmatter(fields) {
328
336
  const lines = ["---"];
@@ -352,7 +360,7 @@ export function renderShared(module) {
352
360
  .concat("\n");
353
361
  }
354
362
  export function renderModule(module) {
355
- const specs = module.features.flatMap((feature) => feature.specs.flatMap((spec) => [`# ${spec.funcId}`, spec.text.trim(), ""]));
363
+ const specs = module.features.flatMap((feature) => feature.specs.flatMap((spec) => [`# ${spec.funcId}`, capturedText(spec.text.trim()), ""]));
356
364
  return [
357
365
  ...frontmatter([
358
366
  ["import", [module.shared]],
@@ -371,7 +379,7 @@ export function renderModule(module) {
371
379
  export function renderTestPlainFile(module, spec) {
372
380
  if (spec.conformance.length === 0 && spec.acceptance.length === 0)
373
381
  return undefined;
374
- const scenarios = (title, list) => (list.length === 0 ? [] : [`***${title}***`, "", ...list.flatMap((scenario) => [`# ${scenario.id}`, scenario.text.trim(), ""])]);
382
+ const scenarios = (title, list) => (list.length === 0 ? [] : [`***${title}***`, "", ...list.flatMap((scenario) => [`# ${scenario.id}`, capturedText(scenario.text.trim()), ""])]);
375
383
  return ["---", `module: ${module}`, `func_id: ${spec.funcId}`, "---", "", ...scenarios("conformance tests", spec.conformance), ...scenarios("acceptance tests", spec.acceptance)].join("\n").trimEnd().concat("\n");
376
384
  }
377
385
  /** The files a capture writes, by path relative to its folder: the modules, the import modules, the test plain files. */
@@ -401,17 +409,8 @@ export function assetsToCopy(map, state) {
401
409
  .filter((file) => !leftOut.some((item) => covers(item.path, file.path)))
402
410
  .map((file) => file.path);
403
411
  }
404
- /**
405
- * The project's config, over what it holds already - the config in use it started as (`capture/config.ts`): conformance
406
- * tests on, the assets as the base folder, the models when they were named. A capture started before it held one starts
407
- * from nothing.
408
- */
409
- export function configText(existing, options) {
410
- const from = existing.trim() === "" ? startingConfig(undefined, options) : existing;
411
- return withSetting(withSetting(from, CONFIG_KEYS.conformanceTests, true), CONFIG_KEYS.baseFolder, options.assets ? "assets" : undefined);
412
- }
413
412
  /** Put a capture on disk: its ***plain, its config, the assets copied, and what keeps the regenerated code's histories out of the repo. */
414
- export function writeCapture(plainDir, map, state, assembly, models) {
413
+ export function writeCapture(plainDir, map, state, assembly) {
415
414
  const written = [];
416
415
  const put = (path, text) => {
417
416
  const file = join(plainDir, ...path.split("/"));
@@ -430,11 +429,13 @@ export function writeCapture(plainDir, map, state, assembly, models) {
430
429
  // Each part's interface reference, which its interface concept links: exact where the ***plain is prose.
431
430
  for (const part of state.survey?.parts ?? []) {
432
431
  const { entries } = referenceOf(state, part.name);
433
- if (entries.length > 0)
434
- put(referencePath(part.name), renderReference(part.name, entries));
432
+ const api = state.pythonInterfaces?.[part.name];
433
+ if (entries.length > 0 || api)
434
+ put(referencePath(part.name), renderReference(part.name, entries) + (api ? `\n## Public Python imports\n\n${api}\n` : ""));
435
435
  }
436
436
  const config = join(plainDir, CONFIG_FILE);
437
- put(CONFIG_FILE, configText(existsSync(config) ? readFileSync(config, "utf8") : "", { assets: assets.length > 0, ...models }));
437
+ const tested = withSetting(readFileSync(config, "utf8"), CONFIG_KEYS.conformanceTests, true);
438
+ put(CONFIG_FILE, withSetting(tested, CONFIG_KEYS.baseFolder, assets.length > 0 ? "assets" : undefined));
438
439
  // A part of its own: its testing scripts go in a config file of its own, on its first module, which the rest of its chain reads.
439
440
  if ((state.survey?.parts.length ?? 0) > 1) {
440
441
  for (const part of state.survey.parts) {
@@ -20,7 +20,7 @@ export interface CaptureOptions {
20
20
  root: string;
21
21
  /** Where the ***plain goes: `<root>/plain` unless given. */
22
22
  plainDir?: string;
23
- /** What the agents that write or correct ***plain run on - the chat's model, or `--harness-model`. */
23
+ /** The harness model from which capture chooses its provider and default tiers. */
24
24
  model?: string;
25
25
  /** Written into the new project's config, when given. */
26
26
  harnessModel?: string;
@@ -42,7 +42,7 @@ export interface CaptureOptions {
42
42
  writeScript?: ScriptWriter;
43
43
  /**
44
44
  * The folder whose config is in use where the capture was started - the chat's, the command line's: the captured
45
- * project's config starts as it (`capture/config.ts`). None: it starts empty.
45
+ * project's config starts as it (`capture/config.ts`). Without one it starts with the init-config defaults.
46
46
  */
47
47
  configFrom?: string;
48
48
  }
@@ -66,7 +66,7 @@ export declare const LEAF_LINES: number;
66
66
  /** Characters of the map an agent is shown: about six thousand tokens. */
67
67
  export declare const MAP_BUDGET = 24000;
68
68
  /** How many agents work at once, unless told. */
69
- export declare const DEFAULT_PARALLEL = 4;
69
+ export declare const DEFAULT_PARALLEL = 8;
70
70
  /** The output folder's state as it stands: nothing there, a capture to go on with, or something capture must not touch. */
71
71
  export declare function plainDirState(plainDir: string): {
72
72
  kind: "empty";
@@ -1,21 +1,25 @@
1
1
  import { existsSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
2
2
  import { join, relative, resolve } from "node:path";
3
- import { CONFIG_FILE, modelOnly, modelSpec, projectModels, readProjectConfig, withConfigModule } from "../config.js";
3
+ import { CONFIG_FILE, inheritModel, modelSpec, projectModels, readProjectConfig, roleModel, withConfigModule } from "../config.js";
4
+ import { captureDefaults } from "./models.js";
5
+ import { writeSetting } from "../config-edit.js";
4
6
  import { slashed } from "../regenerate/paths.js";
5
7
  import { findTestScripts, testingScriptSkill } from "../regenerate/test-scripts.js";
6
8
  import { checkPlainFile } from "../plain/check.js";
7
9
  import { conformanceOf, stdlibCatalogue, stdlibTemplates } from "../stdlib.js";
8
- import { AREAS_TOOL, askAgent, watched, COMPACT_TOOL, CONCEPTS_TOOL, CONVENTIONS_TOOL, CORRECTIONS_TOOL, definitionsOf, EDITS_TOOL, FEATURE_TOOL, FEATURES_TOOL, INTERFACE_TOOL, leftOutOf, MODULES_TOOL, OWNERS_TOOL, records, REFERENCE_CHECKED_TOOL, REFERENCE_TOOL, strings, SURVEY_TOOL, text, TRIAL_TOOL } from "./agents.js";
10
+ import { AREAS_TOOL, askAgent, capturePrompt, watched, COMPACT_TOOL, CONCEPTS_TOOL, CONVENTIONS_TOOL, CORRECTIONS_TOOL, definitionsOf, EDITS_TOOL, FEATURE_TOOL, FEATURES_TOOL, INTERFACE_TOOL, leftOutOf, MODULES_TOOL, OWNERS_TOOL, records, REFERENCE_CHECKED_TOOL, REFERENCE_TOOL, strings, SURVEY_TOOL, text, TRIAL_TOOL } from "./agents.js";
9
11
  import { buildOrder, covers, entriesOf, filesOf, kebab, linesOf, renderArea, testEvidence } from "./area.js";
10
12
  import { entriesIn, entryFile, entrySurface, interfaceConcept, renderReference, interfaceDefinition, interfaceGaps, interfaceIn, leftOutPaths, namedExactly, namedIn, optionsNotInReference, referenceOf, shownSurface } from "./interface.js";
11
13
  import { assemble, featureKey, featurePaths, featuresOf, leavesOf, mergedInto, MODULE_SPECS, outlinedFeature, sharedName, writeCapture } from "./assemble.js";
12
14
  import { conventionProblems, correctionProblems, divisionProblems, moduleProblems, referenceProblems, editProblems, featureProblems, gapProblems, outlineProblems, reconciledProblems, scenarioBudget, splitProblems, surveyProblems, trialProblems, unplaced } from "./checks.js";
13
15
  import { buildMap, INTERFACE_KINDS } from "./map.js";
14
- import { CaptureTracker } from "./progress.js";
15
- import { capturePlan, COMPACT_SURFACES } from "./plan.js";
16
+ import { CaptureTracker, findingLine } from "./progress.js";
17
+ import { capturePlan } from "./plan.js";
18
+ import { pythonInterface } from "./python-interface.js";
16
19
  import { configInUse, configInUseProblem, startingConfig } from "./config.js";
17
20
  import { renderReport, summaryOf } from "./report.js";
18
21
  import { writeTestingScript } from "./scripts.js";
22
+ import { runnerChoices, reuseRunner } from "./runners.js";
19
23
  import { captureDir, newState, readState, reportFile, saveState } from "./state.js";
20
24
  import { copyOriginal, trialBatches, trialTestReqs } from "./trial.js";
21
25
  /** A capture that cannot start, or cannot go on: said as it is, nothing written but what was before. */
@@ -30,7 +34,7 @@ export const LEAF_LINES = Number(process.env.TURRI_CAPTURE_LEAF_LINES ?? 6000);
30
34
  /** Characters of the map an agent is shown: about six thousand tokens. */
31
35
  export const MAP_BUDGET = 24_000;
32
36
  /** How many agents work at once, unless told. */
33
- export const DEFAULT_PARALLEL = 4;
37
+ export const DEFAULT_PARALLEL = 8;
34
38
  /** How many concepts one reconciling agent is given, and how many functional specs one readability pass reads. */
35
39
  const CONFLICTS_PER_AGENT = 20;
36
40
  const SPECS_PER_PASS = 30;
@@ -74,7 +78,9 @@ export async function runCapture(options) {
74
78
  if (found.kind === "taken")
75
79
  throw new CaptureError(`Nothing captured: ${found.why}. Capture writes into a folder of its own - name another.`);
76
80
  const source = options.configFrom !== undefined ? configInUse(options.configFrom) : undefined;
77
- const unusable = found.kind === "empty" ? configInUseProblem(source) : undefined;
81
+ const configPath = join(plainDir, CONFIG_FILE);
82
+ const needsConfig = !existsSync(configPath);
83
+ const unusable = needsConfig ? configInUseProblem(source) : undefined;
78
84
  if (unusable !== undefined)
79
85
  throw new CaptureError(unusable);
80
86
  const tracker = new CaptureTracker(root, options.progress, options.watch);
@@ -84,22 +90,22 @@ export async function runCapture(options) {
84
90
  const state = found.kind === "resume" ? found.state : newState(root);
85
91
  if (found.kind === "resume")
86
92
  tracker.said(`going on with the capture started ${state.started}`);
87
- state.plan ??= found.kind === "resume" ? { kind: "staged", reason: "continuing a capture started before compact captures" } : capturePlan(map, options.leafLines ?? LEAF_LINES);
93
+ state.plan ??= found.kind === "resume" ? { kind: "staged", reason: "continuing a capture started before compact captures" } : capturePlan(map);
88
94
  const save = () => {
89
95
  saveState(plainDir, state);
90
96
  tracker.counted(state);
91
97
  };
98
+ const initialConfig = needsConfig ? await startingConfig(source, { harnessModel: options.harnessModel ?? options.model, codingModel: options.codingModel }) : undefined;
92
99
  save();
93
100
  tracker.said(`${state.plan.kind} capture: ${state.plan.reason}`);
94
101
  // The config in use, from the start - after the state, so a capture stopped here goes on: its agents run on its models,
95
102
  // and the project it writes keeps them.
96
- const given = { ...(options.harnessModel !== undefined ? { harnessModel: options.harnessModel } : {}), ...(options.codingModel !== undefined ? { codingModel: options.codingModel } : {}) };
97
- if (found.kind === "empty")
98
- writeFileSync(join(plainDir, CONFIG_FILE), startingConfig(source, given));
103
+ if (initialConfig !== undefined)
104
+ writeFileSync(configPath, initialConfig);
99
105
  const inUse = projectModels(readProjectConfig(plainDir));
100
- const model = options.model ?? modelSpec(inUse.harness);
106
+ const model = options.model ?? options.harnessModel ?? modelSpec(inUse.harness);
101
107
  const codingModel = options.codingModel ?? modelSpec(inUse.coding);
102
- const run = new CaptureRun({ ...options, root, plainDir, ...(model !== undefined ? { model } : {}), ...(codingModel !== undefined ? { codingModel } : {}), given }, map, state, save, tracker);
108
+ const run = new CaptureRun({ ...options, root, plainDir, ...(model !== undefined ? { model } : {}), ...(codingModel !== undefined ? { codingModel } : {}) }, map, state, save, tracker);
103
109
  tracker.stage("surveying");
104
110
  await run.survey();
105
111
  await run.checkConventions();
@@ -153,8 +159,14 @@ class CaptureRun {
153
159
  limited;
154
160
  leafLines;
155
161
  budget;
162
+ models;
156
163
  constructor(options, map, state, save, tracker) {
157
164
  this.options = options;
165
+ const defaults = captureDefaults(options.model, options.codingModel);
166
+ const config = readProjectConfig(options.plainDir);
167
+ const tier = (role) => modelSpec(inheritModel(roleModel(config, role), defaults[role]));
168
+ this.models = { capture: tier("capture"), "capture-analysis": tier("capture-analysis"), "capture-exploration": tier("capture-exploration") };
169
+ tracker.said(`models: exploration ${this.models["capture-exploration"]}, analysis ${this.models["capture-analysis"]}, reasoning and writing ${this.models.capture}`);
158
170
  this.map = map;
159
171
  this.state = state;
160
172
  this.save = save;
@@ -169,7 +181,7 @@ class CaptureRun {
169
181
  throw new CaptureError("The capture was stopped. Run it again to go on from where it was.");
170
182
  }
171
183
  agent(label, prompt, context, extra, role = "capture") {
172
- const model = role === "capture-analysis" ? modelOnly(this.options.codingModel ?? this.options.model).model : this.options.model;
184
+ const model = this.models[role];
173
185
  return {
174
186
  plainDir: this.options.plainDir,
175
187
  root: this.options.root,
@@ -177,13 +189,13 @@ class CaptureRun {
177
189
  ...(model !== undefined ? { model } : {}),
178
190
  ...(this.options.signal !== undefined ? { signal: this.options.signal } : {}),
179
191
  label: `capture ${label}`,
180
- watch: this.tracker.agent(label),
192
+ watch: this.tracker.agent(label, capturePrompt([prompt].flat().at(-1)).split("\n", 1)[0].replace(/^#\s+/, "")),
181
193
  prompt,
182
194
  context,
183
195
  ...extra,
184
196
  };
185
197
  }
186
- /** Work that hands back data or a plan. A check that can rewrite ***plain is a writer, even when it needs no authoring rules. */
198
+ /** Analysis of evidence: plans, checks and trials, including corrections the evidence requires. */
187
199
  analysis(label, prompt, context, extra) {
188
200
  return this.agent(label, prompt, context, { ...extra, rules: false }, "capture-analysis");
189
201
  }
@@ -202,7 +214,7 @@ class CaptureRun {
202
214
  `<docs>\n${this.docs()}\n</docs>`,
203
215
  `<standard library>\n${stdlibCatalogue()}\n</standard library>`,
204
216
  ].join("\n\n");
205
- const { answer, problems } = await this.limited(() => askAgent(this.agent("survey", "survey", context, { reads: true, rules: true, calls: 45 }), { ...SURVEY_TOOL, convert: (params) => ({ parts: records(params.parts).map(partOf), leftOut: leftOutOf(params.left_out), assumptions: strings(params.assumptions) }) }, (survey) => surveyProblems(this.map, survey)));
217
+ const { answer, problems } = await this.limited(() => askAgent(this.agent("survey", "survey", context, { reads: true, rules: true, calls: 45 }), { ...SURVEY_TOOL, convert: (params) => ({ parts: records(params.parts).map(partOf), leftOut: leftOutOf(params.left_out), assumptions: strings(params.assumptions), separateConcerns: text(params.separate_concerns) || undefined }) }, (survey) => surveyProblems(this.map, survey)));
206
218
  if (answer === undefined)
207
219
  throw new CaptureError(`The survey of the codebase did not hold, so nothing could be captured:\n- ${problems.join("\n- ")}`);
208
220
  this.state.survey = answer;
@@ -231,7 +243,7 @@ class CaptureRun {
231
243
  `<concepts>\n${part.definitions.map((definition) => `- ${definition.text}`).join("\n") || "None."}\n</concepts>`,
232
244
  `<conventions>\n${part.conventions.map((convention, at) => `${at + 1}. ${convention.text}\n decided in: ${convention.where.join(", ")}`).join("\n")}\n</conventions>`,
233
245
  ].join("\n\n");
234
- const { answer, problems } = await askAgent(this.agent(`check ${part.name}`, "check-conventions", context, { reads: true, rules: false, calls: 30 }), { ...CONVENTIONS_TOOL, convert: (params) => ({ conventions: conventionsOf(params.conventions), changes: strings(params.changes) }) }, (answer) => [...(answer.conventions.length === 0 ? ["Give every convention as the code has it - those that hold too."] : []), ...conventionProblems(this.map, answer.conventions, known)]);
246
+ const { answer, problems } = await askAgent(this.analysis(`check ${part.name}`, "check-conventions", context, { reads: true, calls: 30 }), { ...CONVENTIONS_TOOL, convert: (params) => ({ conventions: conventionsOf(params.conventions), changes: strings(params.changes) }) }, (answer) => [...(answer.conventions.length === 0 ? ["Give every convention as the code has it - those that hold too."] : []), ...conventionProblems(this.map, answer.conventions, known)]);
235
247
  if (answer !== undefined)
236
248
  part.conventions = answer.conventions;
237
249
  (this.state.conventionsChecked ??= {})[part.name] = answer !== undefined ? { changes: answer.changes } : { changes: [], failed: `the check did not hold: ${problems.join(" ")}` };
@@ -296,7 +308,7 @@ class CaptureRun {
296
308
  `<files>\n${listed.length > 0 ? listed.join("\n") : "The map found no interface in the part's files: find it - from its entry points, where its arguments, routes and variables are read."}\n</files>`,
297
309
  `<map>\n${renderArea(this.map, item.part.paths, Math.floor(this.budget / 2))}\n</map>`,
298
310
  ].join("\n\n");
299
- const { answer, problems } = await askAgent(this.analysis(item.label, "reference", context, { reads: true, calls: 60 }), { ...REFERENCE_TOOL, convert: referenceAnswerOf }, (answer) => referenceProblems(this.map, this.options.root, item.files, answer));
311
+ const { answer, problems } = await askAgent(this.agent(item.label, "reference", context, { reads: true, rules: false, calls: 60 }, "capture-exploration"), { ...REFERENCE_TOOL, convert: referenceAnswerOf }, (answer) => referenceProblems(this.map, this.options.root, item.files, answer));
300
312
  ((this.state.interfaces ??= {})[item.part.name] ??= {})[item.key] = answer ?? { failed: `what its agent handed over did not hold: ${problems.join(" ")}` };
301
313
  this.save();
302
314
  this.tracker.worked();
@@ -306,7 +318,10 @@ class CaptureRun {
306
318
  await this.checkReference(parts);
307
319
  for (const part of parts) {
308
320
  const concept = interfaceConcept(part.name);
309
- if (referenceOf(this.state, part.name).entries.length > 0 && !part.definitions.some((definition) => definition.concept === concept))
321
+ const api = pythonInterface(this.map, part.paths);
322
+ if (api)
323
+ (this.state.pythonInterfaces ??= {})[part.name] = api;
324
+ if ((api || referenceOf(this.state, part.name).entries.length > 0) && !part.definitions.some((definition) => definition.concept === concept))
310
325
  part.definitions.push({ concept, text: interfaceDefinition(part.name) });
311
326
  (this.state.interfaceTaken ??= []).push(part.name);
312
327
  }
@@ -366,12 +381,14 @@ class CaptureRun {
366
381
  }
367
382
  /** What a feature's writer is told of the interface in its files: the reference's entries, exact, and what to do with them. */
368
383
  writerInterfaceBlock(part, paths) {
384
+ const api = this.state.pythonInterfaces?.[part];
385
+ const library = api ? `\n<public Python API>\nThese exact public imports and signatures are already in ${interfaceConcept(part)}'s linked reference. Use the concept where you describe their behaviour. Keep literal lists and signatures in the reference; write what a caller observes in the spec.\n${api.slice(0, this.budget)}\n</public Python API>` : "";
369
386
  const { entries, unlisted } = this.interfaceFor(part, paths);
370
387
  if (referenceOf(this.state, part).entries.length === 0) {
371
- return interfaceBlock("the interface in your files", "Every option, command, route, screen and environment variable the code defines in your feature's files - capture exactly each your feature owns:", unlisted);
388
+ return interfaceBlock("the interface in your files", "Every option, command, route, screen and environment variable the code defines in your feature's files - capture exactly each your feature owns:", unlisted) + library;
372
389
  }
373
390
  const concept = interfaceConcept(part);
374
- return referenceBlock("the interface in your files", `Taken from the code, every literal checked against it: ${concept}'s reference, which every functional spec using ${concept} carries. Of these, capture what each your feature owns does - by its exact name, using ${concept}. What one takes, its choices, its default and its help are the reference's: say them only where a behaviour turns on them, and never otherwise than here.`, entries, unlisted);
391
+ return referenceBlock("the interface in your files", `Taken from the code, every literal checked against it: ${concept}'s reference, which every functional spec using ${concept} carries. Of these, capture what each your feature owns does - by its exact name, using ${concept}. What one takes, its choices, its default and its help are the reference's: say them only where a behaviour turns on them, and never otherwise than here.`, entries, unlisted) + library;
375
392
  }
376
393
  /** What a writer of the interface no feature captured is given: those pieces, with the reference's entry of each. */
377
394
  gapBlock(part, gaps) {
@@ -422,14 +439,17 @@ class CaptureRun {
422
439
  };
423
440
  if (parts.length !== 1)
424
441
  return expand(`the survey found ${parts.length} parts`);
442
+ if (this.state.survey?.separateConcerns)
443
+ return expand(this.state.survey.separateConcerns);
425
444
  const part = parts[0];
426
445
  const key = featureKey(part.name, part.name);
427
446
  if (this.state.features[key]?.captured !== undefined)
428
447
  return;
429
448
  const { entries, unlisted } = this.interfaceFor(part.name, part.paths);
430
449
  const surfaces = [...entries.map(entrySurface), ...unlisted];
431
- if (surfaces.length > COMPACT_SURFACES)
432
- return expand(`the interface contains ${surfaces.length} entries`);
450
+ const checkedPlan = capturePlan(this.map, surfaces.length);
451
+ if (checkedPlan.kind === "staged")
452
+ return expand(checkedPlan.reason);
433
453
  this.stopIfAsked();
434
454
  this.tracker.stage("compact-writing");
435
455
  const evidence = testEvidence(this.map, part.paths);
@@ -721,7 +741,7 @@ class CaptureRun {
721
741
  ...(invented.length > 0 ? [`<options the ***plain names that the reference does not have>\n${invented.map((option) => `\`${option}\``).join(", ")} - an option the code does not define is wrong, unless the code shows otherwise.\n</options the ***plain names that the reference does not have>`] : []),
722
742
  `<map>\n${renderArea(this.map, paths, Math.floor(this.budget / 2))}\n</map>`,
723
743
  ].join("\n\n");
724
- const { answer } = await askAgent(this.agent(`verify ${module.name}`, "verify", context, { reads: true, rules: true, calls: 40 }), {
744
+ const { answer } = await askAgent(this.agent(`verify ${module.name}`, "verify", context, { reads: true, rules: true, calls: 40 }, "capture-analysis"), {
725
745
  ...CORRECTIONS_TOOL,
726
746
  convert: (params) => records(params.corrections).map((item) => ({ funcId: text(item.func_id), ...(text(item.scenario_id) !== "" ? { scenarioId: text(item.scenario_id) } : {}), text: text(item.text), why: text(item.why) })),
727
747
  }, (answer) => correctionProblems(answer, byId, known));
@@ -852,7 +872,7 @@ class CaptureRun {
852
872
  specs: records(params.functional_specs).map((item) => ({ funcId: text(item.func_id), text: text(item.text), why: text(item.why) })),
853
873
  testReqs: strings(params.test_reqs).map((req) => req.replace(/^-\s+/, "")),
854
874
  });
855
- const { answer, problems } = await askAgent({ ...this.agent(label, "trial", context, { reads: true, rules: false, calls: TRIAL_CALLS }), shell: { workdir: original, home: dir }, turnAtLeastMs: TRIAL_TURN_MS }, { ...TRIAL_TOOL, convert }, (answer) => trialProblems(answer, batch, checked));
875
+ const { answer, problems } = await askAgent({ ...this.analysis(label, "trial", context, { reads: true, calls: TRIAL_CALLS }), shell: { workdir: original, home: dir }, turnAtLeastMs: TRIAL_TURN_MS }, { ...TRIAL_TOOL, convert }, (answer) => trialProblems(answer, batch, checked));
856
876
  ((this.state.trials ??= {})[module.name] ??= {})[key] = answer ?? { failed: `what its agent handed over did not hold: ${problems.join(" ")}` };
857
877
  this.save();
858
878
  this.tracker.worked();
@@ -981,13 +1001,13 @@ class CaptureRun {
981
1001
  throw new CaptureError("Nothing could be captured: no feature of the codebase held. Run it again to try the areas and features that failed once more.");
982
1002
  if (this.state.written === true)
983
1003
  return;
984
- writeCapture(this.options.plainDir, this.map, this.state, assembly, this.options.given);
1004
+ writeCapture(this.options.plainDir, this.map, this.state, assembly);
985
1005
  this.state.written = true;
986
1006
  this.save();
987
1007
  }
988
1008
  /**
989
- * Each part's testing scripts, written by turri's skills on the ***plain just written - on the coding model when one
990
- * was given - side by side. One that is not written does not stop the capture: the report says why, and what to ask.
1009
+ * Each part's testing scripts: reuse a matching stock runner, otherwise use the writing tier. One that is not written
1010
+ * does not stop the capture: the report says why, and what to ask.
991
1011
  */
992
1012
  async scripts() {
993
1013
  const assembly = assemble(this.state, this.options.moduleSpecs);
@@ -1010,14 +1030,21 @@ class CaptureRun {
1010
1030
  this.save();
1011
1031
  this.tracker.worked();
1012
1032
  const { what } = testingScriptSkill(item.kind);
1013
- this.progress("written" in outcome ? `wrote the ${what} of ${item.part.name}: ${outcome.written}` : `no ${what} for ${item.part.name}: ${outcome.failed}`);
1033
+ this.progress("written" in outcome ? `wrote the ${what} of ${item.part.name}: ${outcome.written}${outcome.finding ? ` - ${outcome.finding}` : ""}` : `no ${what} for ${item.part.name}: ${outcome.failed}`);
1014
1034
  })));
1015
1035
  }
1016
1036
  async script(item) {
1017
1037
  const { plainDir, root, signal } = this.options;
1018
- const model = this.options.codingModel ?? this.options.model;
1038
+ const model = this.models.capture;
1039
+ let finding;
1019
1040
  try {
1020
- await watched(this.tracker.agent(testingScriptSkill(item.kind).what), signal, () => (this.options.writeScript ?? writeTestingScript)({
1041
+ if (!this.options.writeScript) {
1042
+ const reused = reuseRunner(plainDir, this.map, item.part, item.kind, item.configModule);
1043
+ if (reused)
1044
+ return reused;
1045
+ }
1046
+ const what = testingScriptSkill(item.kind).what;
1047
+ finding = await watched(this.tracker.agent(`${what} ${item.part.name}`, `Write the ${what} for ${item.module}.`), signal, () => (this.options.writeScript ?? writeTestingScript)({
1021
1048
  plainDir,
1022
1049
  root,
1023
1050
  module: item.module,
@@ -1033,7 +1060,13 @@ class CaptureRun {
1033
1060
  return { failed: error instanceof Error ? error.message : String(error) };
1034
1061
  }
1035
1062
  const found = withConfigModule(item.configModule, () => findTestScripts(plainDir, join(plainDir, `${item.module}.plain`)))[item.kind];
1036
- return found !== undefined ? { written: slashed(relative(plainDir, found)) } : { failed: "its skill ended with no script written" };
1063
+ if (found === undefined)
1064
+ return { failed: "its skill ended with no script written" };
1065
+ const written = slashed(relative(plainDir, found));
1066
+ // A single-part runner may have been found by name alone. Put its path in the exported config too.
1067
+ if (item.configModule === undefined)
1068
+ writeSetting(plainDir, item.kind === "unit" ? "unittests-script" : "conformance-tests-script", written);
1069
+ return { written, ...(finding ? { finding: findingLine(finding) } : {}) };
1037
1070
  }
1038
1071
  /** Check the ***plain, write the report, and mark the capture finished. */
1039
1072
  finish() {
@@ -1073,6 +1106,7 @@ function partOf(item) {
1073
1106
  conventions: conventionsOf(item.conventions),
1074
1107
  testReqs: strings(item.test_reqs).map((req) => req.replace(/^-\s+/, "")),
1075
1108
  definitions: definitionsOf(item.definitions),
1109
+ runners: runnerChoices(item.runners),
1076
1110
  };
1077
1111
  }
1078
1112
  function capturedOf(params) {
@@ -1127,7 +1161,7 @@ function referenceAnswerOf(params) {
1127
1161
  const command = given(item.command);
1128
1162
  const takes = given(item.takes);
1129
1163
  const value = typeof item.default === "string" && item.default.trim() !== "" ? item.default.trim() : undefined;
1130
- const help = typeof item.help === "string" && item.help.trim() !== "" ? item.help.trim() : undefined;
1164
+ const help = typeof item.help === "string" && item.help.trim() !== "" ? item.help : undefined;
1131
1165
  return {
1132
1166
  kind: text(item.kind),
1133
1167
  name: text(item.name),