toolcraft-openapi 0.0.136 → 0.0.137

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 (24) hide show
  1. package/dist/composition.json +2 -2
  2. package/node_modules/@poe-code/frontmatter/README.md +3 -0
  3. package/node_modules/@poe-code/frontmatter/dist/index.d.ts +1 -1
  4. package/node_modules/@poe-code/frontmatter/dist/index.js +1 -1
  5. package/node_modules/@poe-code/frontmatter/dist/parse.d.ts +9 -0
  6. package/node_modules/@poe-code/frontmatter/dist/parse.js +16 -0
  7. package/node_modules/toolcraft-design/dist/acp/components.d.ts +8 -1
  8. package/node_modules/toolcraft-design/dist/acp/components.js +11 -6
  9. package/node_modules/toolcraft-design/dist/acp/index.d.ts +1 -0
  10. package/node_modules/toolcraft-design/dist/components/command-errors.d.ts +2 -0
  11. package/node_modules/toolcraft-design/dist/components/command-errors.js +8 -2
  12. package/node_modules/toolcraft-design/dist/components/index.d.ts +1 -1
  13. package/node_modules/toolcraft-design/dist/components/index.js +1 -1
  14. package/node_modules/toolcraft-design/dist/components/table.d.ts +1 -0
  15. package/node_modules/toolcraft-design/dist/components/table.js +52 -5
  16. package/node_modules/toolcraft-design/dist/components/template.d.ts +9 -0
  17. package/node_modules/toolcraft-design/dist/components/template.js +27 -2
  18. package/node_modules/toolcraft-design/dist/index.d.ts +2 -2
  19. package/node_modules/toolcraft-design/dist/index.js +2 -2
  20. package/node_modules/toolcraft-design/dist/prompts/interactive/core.d.ts +5 -0
  21. package/node_modules/toolcraft-design/dist/prompts/interactive/core.js +15 -1
  22. package/node_modules/toolcraft-design/dist/prompts/primitives/spinner.js +1 -1
  23. package/node_modules/toolcraft-schema/package.json +1 -1
  24. package/package.json +3 -3
@@ -38,12 +38,12 @@
38
38
  },
39
39
  {
40
40
  "name": "toolcraft-openapi",
41
- "version": "0.0.136",
41
+ "version": "0.0.137",
42
42
  "license": "MIT"
43
43
  },
44
44
  {
45
45
  "name": "toolcraft-schema",
46
- "version": "0.0.136",
46
+ "version": "0.0.137",
47
47
  "license": "MIT"
48
48
  },
49
49
  {
@@ -6,7 +6,9 @@ Shared YAML frontmatter parsing for poe-code packages.
6
6
 
7
7
  ```ts
8
8
  import {
9
+ FrontmatterKindError,
9
10
  FrontmatterParseError,
11
+ isFrontmatterKindError,
10
12
  parseFrontmatter,
11
13
  parseFrontmatterDocument,
12
14
  stringifyFrontmatter
@@ -17,6 +19,7 @@ import {
17
19
  - `parseFrontmatterDocument(source)` returns `{ frontmatter, body, errors, lineCounter }` for callers that need YAML diagnostics.
18
20
  - `stringifyFrontmatter(frontmatter, body)` writes `---` fences, YAML, and the body.
19
21
  - `FrontmatterParseError` is thrown for malformed frontmatter, invalid YAML, non-object frontmatter, and stringify failures.
22
+ - `FrontmatterKindError` extends `FrontmatterParseError` and carries `expectedKind` / `foundKind` so callers can report a document kind mismatch instead of a missing file. `isFrontmatterKindError(error)` narrows to it.
20
23
 
21
24
  When no leading frontmatter block exists, parsing returns `{ frontmatter: {}, body: source }`.
22
25
  The returned `body` is sliced from the original input and is otherwise byte-for-byte unchanged.
@@ -1,3 +1,3 @@
1
1
  export { splitFrontmatterBlock, type FrontmatterBlock, type SplitFrontmatterResult } from "./fences.js";
2
- export { FrontmatterParseError, parseFrontmatter, parseFrontmatterDocument, type ParsedFrontmatter, type ParsedFrontmatterDocument, type ParseFrontmatterOptions } from "./parse.js";
2
+ export { FrontmatterKindError, FrontmatterParseError, isFrontmatterKindError, parseFrontmatter, parseFrontmatterDocument, type ParsedFrontmatter, type ParsedFrontmatterDocument, type ParseFrontmatterOptions } from "./parse.js";
3
3
  export { stringifyFrontmatter } from "./stringify.js";
@@ -1,3 +1,3 @@
1
1
  export { splitFrontmatterBlock } from "./fences.js";
2
- export { FrontmatterParseError, parseFrontmatter, parseFrontmatterDocument } from "./parse.js";
2
+ export { FrontmatterKindError, FrontmatterParseError, isFrontmatterKindError, parseFrontmatter, parseFrontmatterDocument } from "./parse.js";
3
3
  export { stringifyFrontmatter } from "./stringify.js";
@@ -16,5 +16,14 @@ export interface ParseFrontmatterOptions {
16
16
  export declare class FrontmatterParseError extends Error {
17
17
  constructor(message: string);
18
18
  }
19
+ export declare class FrontmatterKindError extends FrontmatterParseError {
20
+ readonly expectedKind: string;
21
+ readonly foundKind: string;
22
+ constructor(message: string, kinds: {
23
+ expected: string;
24
+ found: string;
25
+ });
26
+ }
27
+ export declare function isFrontmatterKindError(error: unknown): error is FrontmatterKindError;
19
28
  export declare function parseFrontmatter(source: string, options?: ParseFrontmatterOptions): ParsedFrontmatter;
20
29
  export declare function parseFrontmatterDocument(source: string, options?: ParseFrontmatterOptions): ParsedFrontmatterDocument;
@@ -6,6 +6,22 @@ export class FrontmatterParseError extends Error {
6
6
  this.name = "FrontmatterParseError";
7
7
  }
8
8
  }
9
+ export class FrontmatterKindError extends FrontmatterParseError {
10
+ expectedKind;
11
+ foundKind;
12
+ constructor(message, kinds) {
13
+ super(message);
14
+ this.name = "FrontmatterKindError";
15
+ this.expectedKind = kinds.expected;
16
+ this.foundKind = kinds.found;
17
+ }
18
+ }
19
+ export function isFrontmatterKindError(error) {
20
+ return (error instanceof Error &&
21
+ error.name === "FrontmatterKindError" &&
22
+ typeof error.expectedKind === "string" &&
23
+ typeof error.foundKind === "string");
24
+ }
9
25
  export function parseFrontmatter(source, options = {}) {
10
26
  const split = splitFrontmatter(source);
11
27
  if (split.raw === undefined) {
@@ -1,4 +1,11 @@
1
- export declare function renderAgentMessage(text: string): void;
1
+ /**
2
+ * Status of the agent output being rendered.
3
+ *
4
+ * `streaming` covers partial/in-progress content, which has not reached any outcome yet and so must not
5
+ * claim success. `success`/`error` are terminal outcomes known to the caller.
6
+ */
7
+ export type AcpOutputState = "streaming" | "success" | "error";
8
+ export declare function renderAgentMessage(text: string, state?: AcpOutputState): void;
2
9
  export declare function renderToolStart(kind: string, title: string): void;
3
10
  export declare function renderToolComplete(kind: string): void;
4
11
  export declare function renderReasoning(text: string): void;
@@ -25,8 +25,13 @@ function colorForKind(kind) {
25
25
  function writeLine(line) {
26
26
  getAcpWriter()(line);
27
27
  }
28
- function agentPrefix() {
29
- return `${color.green.bold("")} agent: `;
28
+ const STATE_GLYPHS = {
29
+ streaming: () => color.dim("·"),
30
+ success: () => color.green.bold("✓"),
31
+ error: () => color.red.bold("✗")
32
+ };
33
+ function agentPrefix(state) {
34
+ return `${STATE_GLYPHS[state]()} agent: `;
30
35
  }
31
36
  function formatCost(costUsd) {
32
37
  return new Intl.NumberFormat("en-US", {
@@ -36,7 +41,7 @@ function formatCost(costUsd) {
36
41
  maximumFractionDigits: 6
37
42
  }).format(costUsd);
38
43
  }
39
- export function renderAgentMessage(text) {
44
+ export function renderAgentMessage(text, state = "streaming") {
40
45
  const format = resolveOutputFormat();
41
46
  if (format === "markdown") {
42
47
  writeLine(`- **agent:** ${text}`);
@@ -47,7 +52,7 @@ export function renderAgentMessage(text) {
47
52
  return;
48
53
  }
49
54
  const rendered = renderMarkdown(text).trimEnd();
50
- writeLine(`${agentPrefix()}${rendered}`);
55
+ writeLine(`${agentPrefix(state)}${rendered}`);
51
56
  }
52
57
  export function renderToolStart(kind, title) {
53
58
  const format = resolveOutputFormat();
@@ -85,7 +90,7 @@ export function renderReasoning(text) {
85
90
  writeLine(JSON.stringify({ event: "reasoning", text }));
86
91
  return;
87
92
  }
88
- writeLine(color.dim(` ${truncate(text, 80)}`));
93
+ writeLine(color.dim(` · ${truncate(text, 80)}`));
89
94
  }
90
95
  export function renderUsage(tokens) {
91
96
  const format = resolveOutputFormat();
@@ -109,7 +114,7 @@ export function renderUsage(tokens) {
109
114
  return;
110
115
  }
111
116
  writeLine("");
112
- writeLine(color.green(`✓ tokens: ${tokens.input} in${cached} → ${tokens.output} out${cost}`));
117
+ writeLine(color.dim( tokens: ${tokens.input} in${cached} → ${tokens.output} out${cost}`));
113
118
  }
114
119
  export function renderPermissionRejected(title) {
115
120
  const format = resolveOutputFormat();
@@ -1,3 +1,4 @@
1
1
  export { renderAgentMessage, renderToolStart, renderToolComplete, renderReasoning, renderUsage, renderError, renderPermissionRejected } from "./components.js";
2
+ export type { AcpOutputState } from "./components.js";
2
3
  export { getAcpWriter, withAcpWriter } from "./writer.js";
3
4
  export type { AcpLineWriter } from "./writer.js";
@@ -1,6 +1,7 @@
1
1
  export declare function formatCommandNotFound(input: {
2
2
  unknownCommand: string;
3
3
  helpCommand: string;
4
+ suggestions?: readonly string[];
4
5
  }): {
5
6
  label: string;
6
7
  hint: string;
@@ -8,6 +9,7 @@ export declare function formatCommandNotFound(input: {
8
9
  export declare function formatCommandNotFoundPanel(input: {
9
10
  unknownCommand: string;
10
11
  helpCommand: string;
12
+ suggestions?: readonly string[];
11
13
  title?: string;
12
14
  }): {
13
15
  title: string;
@@ -5,15 +5,21 @@ export function formatCommandNotFound(input) {
5
5
  const unknown = unknownInput.length > 0
6
6
  ? unknownInput
7
7
  : "<command>";
8
+ const suggestions = input.suggestions ?? [];
9
+ const didYouMean = suggestions.length > 0
10
+ ? `
11
+ ${text.muted("Did you mean:")} ${suggestions.map((suggestion) => text.command(suggestion)).join(text.muted(", "))}${text.muted("?")}`
12
+ : "";
8
13
  return {
9
- label: `${typography.bold("Unknown command:")} ${text.command(unknown)}`,
14
+ label: `${typography.bold("Unknown command:")} ${text.command(unknown)}${didYouMean}`,
10
15
  hint: `${text.muted("Run")} ${text.usageCommand(input.helpCommand)} ${text.muted("for available commands.")}`
11
16
  };
12
17
  }
13
18
  export function formatCommandNotFoundPanel(input) {
14
19
  const message = formatCommandNotFound({
15
20
  unknownCommand: input.unknownCommand,
16
- helpCommand: input.helpCommand
21
+ helpCommand: input.helpCommand,
22
+ suggestions: input.suggestions
17
23
  });
18
24
  return {
19
25
  title: input.title ?? "command not found",
@@ -8,7 +8,7 @@ export { helpFormatter, formatColumns, formatCommand, formatUsage, formatOption,
8
8
  export type { CommandInfo, OptionInfo, FormatColumnsOptions, HelpToken, HelpTokenRole } from "./help-formatter.js";
9
9
  export { formatCommandNotFound } from "./command-errors.js";
10
10
  export { formatCommandNotFoundPanel } from "./command-errors.js";
11
- export { renderTable } from "./table.js";
11
+ export { loggerTableWidth, renderTable } from "./table.js";
12
12
  export type { TableColumn, RenderTableOptions } from "./table.js";
13
13
  export { renderFileChanges } from "./file-changes.js";
14
14
  export type { FileChange, FileChangeDisplayMode, FileChangeKind, FileChangeOutputFormat, RenderFileChangesOptions } from "./file-changes.js";
@@ -5,7 +5,7 @@ export { createLogger, logger } from "./logger.js";
5
5
  export { helpFormatter, formatColumns, formatCommand, formatUsage, formatOption, formatCommandList, formatOptionList, styleHelpToken, joinHelpTokens, renderHelpTokens } from "./help-formatter.js";
6
6
  export { formatCommandNotFound } from "./command-errors.js";
7
7
  export { formatCommandNotFoundPanel } from "./command-errors.js";
8
- export { renderTable } from "./table.js";
8
+ export { loggerTableWidth, renderTable } from "./table.js";
9
9
  export { renderFileChanges } from "./file-changes.js";
10
10
  export { renderCatalog } from "./catalog.js";
11
11
  export { getTemplatePartialNames, renderTemplate, resolveTemplatePartials } from "./template.js";
@@ -12,4 +12,5 @@ export interface RenderTableOptions {
12
12
  variant?: "table" | "detail";
13
13
  maxWidth?: number;
14
14
  }
15
+ export declare function loggerTableWidth(): number | undefined;
15
16
  export declare function renderTable(options: RenderTableOptions): string;
@@ -3,6 +3,7 @@ import { resolveOutputFormat } from "../internal/output-format.js";
3
3
  import { stripAnsi } from "../internal/strip-ansi.js";
4
4
  const reset = "\x1b[0m";
5
5
  const ellipsis = "…";
6
+ const minCellWidth = 4;
6
7
  const graphemeSegmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
7
8
  function getCell(row, name) {
8
9
  return Object.prototype.hasOwnProperty.call(row, name) ? row[name] ?? "" : "";
@@ -161,6 +162,51 @@ function computeColumns(columns) {
161
162
  width: getColumnWidth(column)
162
163
  }));
163
164
  }
165
+ // Each column is framed as "│ cell ", plus the closing "│".
166
+ function frameWidth(columnCount) {
167
+ return columnCount * 3 + 1;
168
+ }
169
+ // Log output indents every line with a "│ " guide, so a table emitted through the
170
+ // logger has that much less room than the terminal. Undefined without a terminal:
171
+ // piped output has no width to fit.
172
+ export function loggerTableWidth() {
173
+ const columns = process.stdout.columns;
174
+ return columns === undefined ? undefined : columns - 3;
175
+ }
176
+ // Without an explicit budget or a TTY there is no width to fit: the consumer of the
177
+ // piped output decides, so columns keep their declared widths.
178
+ function budgetColumns(columns, maxWidth) {
179
+ if (maxWidth === undefined) {
180
+ return columns;
181
+ }
182
+ const available = maxWidth - frameWidth(columns.length);
183
+ const contentWidth = (cap) => columns.reduce((total, column) => total + Math.min(column.width, cap), 0);
184
+ if (columns.reduce((total, column) => total + column.width, 0) <= available) {
185
+ return columns;
186
+ }
187
+ // Widest-first: raise a shared cap as far as the budget allows, so narrow columns
188
+ // keep their declared width and only the columns above the cap lose room.
189
+ let cap = minCellWidth;
190
+ while (contentWidth(cap + 1) <= available) {
191
+ cap += 1;
192
+ }
193
+ const budgeted = columns.map((column) => ({ ...column, width: Math.min(column.width, cap) }));
194
+ let slack = available - contentWidth(cap);
195
+ while (slack > 0) {
196
+ const growable = budgeted.filter((column, index) => column.width < columns[index].width);
197
+ if (growable.length === 0) {
198
+ break;
199
+ }
200
+ for (const column of growable) {
201
+ if (slack === 0) {
202
+ break;
203
+ }
204
+ column.width += 1;
205
+ slack -= 1;
206
+ }
207
+ }
208
+ return budgeted;
209
+ }
164
210
  function renderBorder(columns, theme, parts) {
165
211
  const horizontal = theme.muted("─");
166
212
  const segments = columns.map((column) => horizontal.repeat(column.width + 2));
@@ -247,16 +293,17 @@ function renderTableTerminal(options) {
247
293
  }
248
294
  const separatorOptions = options;
249
295
  const includeRowSeparators = separatorOptions.rowSeparator === true || separatorOptions.rowSeparators === true;
250
- const top = renderBorder(computedColumns, theme, { left: "┌", mid: "┬", right: "┐" });
251
- const header = renderTerminalRow(computedColumns.map((column) => theme.header(column.title)), computedColumns, theme);
252
- const headerBottom = renderBorder(computedColumns, theme, { left: "├", mid: "┼", right: "┤" });
253
- const bottom = renderBorder(computedColumns, theme, { left: "", mid: "", right: "" });
296
+ const budgetedColumns = budgetColumns(computedColumns, options.maxWidth ?? process.stdout.columns);
297
+ const top = renderBorder(budgetedColumns, theme, { left: "┌", mid: "┬", right: "┐" });
298
+ const header = renderTerminalRow(budgetedColumns.map((column) => theme.header(column.title)), budgetedColumns, theme);
299
+ const headerBottom = renderBorder(budgetedColumns, theme, { left: "", mid: "", right: "" });
300
+ const bottom = renderBorder(budgetedColumns, theme, { left: "└", mid: "┴", right: "┘" });
254
301
  const renderedRows = [];
255
302
  for (const [index, row] of rows.entries()) {
256
303
  if (includeRowSeparators && index > 0) {
257
304
  renderedRows.push(headerBottom);
258
305
  }
259
- renderedRows.push(renderTerminalRow(computedColumns.map((column) => getCell(row, column.name)), computedColumns, theme));
306
+ renderedRows.push(renderTerminalRow(budgetedColumns.map((column) => getCell(row, column.name)), budgetedColumns, theme));
260
307
  }
261
308
  return [top, header, headerBottom, ...renderedRows, bottom].join("\n");
262
309
  }
@@ -5,6 +5,15 @@ export interface RenderTemplateOptions {
5
5
  validate?: boolean;
6
6
  yield?: string;
7
7
  }
8
+ export declare class TemplateParseError extends Error {
9
+ readonly description: string;
10
+ readonly line: number;
11
+ readonly column: number;
12
+ constructor(description: string, position: {
13
+ line: number;
14
+ column: number;
15
+ });
16
+ }
8
17
  export declare function renderTemplate(template: string, view: Record<string, unknown>, options?: RenderTemplateOptions): string;
9
18
  export declare function getTemplatePartialNames(template: string): string[];
10
19
  export declare function resolveTemplatePartials(template: string, partials: Record<string, string>): string;
@@ -1,4 +1,17 @@
1
1
  const MAX_PARTIAL_DEPTH = 100;
2
+ const MAX_TAG_EXCERPT_LENGTH = 40;
3
+ export class TemplateParseError extends Error {
4
+ description;
5
+ line;
6
+ column;
7
+ constructor(description, position) {
8
+ super(`${description} at line ${position.line}, column ${position.column}`);
9
+ this.name = "TemplateParseError";
10
+ this.description = description;
11
+ this.line = position.line;
12
+ this.column = position.column;
13
+ }
14
+ }
2
15
  const HTML_ESCAPE = {
3
16
  "&": "&amp;",
4
17
  "<": "&lt;",
@@ -114,13 +127,13 @@ function parseTag(template, open) {
114
127
  if (template.startsWith("{{{", open)) {
115
128
  const close = template.indexOf("}}}", open + 3);
116
129
  if (close === -1) {
117
- throw new Error("Unclosed unescaped tag");
130
+ throw unclosedTagError(template, open, "}}}");
118
131
  }
119
132
  return { kind: "unescaped", name: template.slice(open + 3, close).trim(), end: close + 3 };
120
133
  }
121
134
  const close = template.indexOf("}}", open + 2);
122
135
  if (close === -1) {
123
- throw new Error("Unclosed tag");
136
+ throw unclosedTagError(template, open, "}}");
124
137
  }
125
138
  const raw = template.slice(open + 2, close).trim();
126
139
  const sigil = raw[0];
@@ -142,6 +155,18 @@ function parseTag(template, open) {
142
155
  return { kind: "delimiter", name, end };
143
156
  return { kind: "name", name: raw, end };
144
157
  }
158
+ function unclosedTagError(template, open, expected) {
159
+ const before = template.slice(0, open);
160
+ const lineEnd = template.indexOf("\n", open);
161
+ const opened = template.slice(open, lineEnd === -1 ? template.length : lineEnd).trimEnd();
162
+ const tag = opened.length > MAX_TAG_EXCERPT_LENGTH
163
+ ? `${opened.slice(0, MAX_TAG_EXCERPT_LENGTH)}...`
164
+ : opened;
165
+ return new TemplateParseError(`Unclosed tag "${tag}": expected "${expected}"`, {
166
+ line: before.split("\n").length,
167
+ column: open - (before.lastIndexOf("\n") + 1) + 1
168
+ });
169
+ }
145
170
  function getStandalone(template, tagStart, tagEnd, kind) {
146
171
  if (!["section", "inverted", "close", "comment", "partial", "delimiter"].includes(kind)) {
147
172
  return undefined;
@@ -17,7 +17,7 @@ export * as helpFormatterPlain from "./components/help-formatter-plain.js";
17
17
  export type { CommandInfo, OptionInfo, FormatColumnsOptions, HelpToken, HelpTokenRole } from "./components/help-formatter.js";
18
18
  export { formatCommandNotFound } from "./components/command-errors.js";
19
19
  export { formatCommandNotFoundPanel } from "./components/command-errors.js";
20
- export { renderTable } from "./components/table.js";
20
+ export { loggerTableWidth, renderTable } from "./components/table.js";
21
21
  export type { TableColumn, RenderTableOptions } from "./components/table.js";
22
22
  export { renderFileChanges } from "./components/file-changes.js";
23
23
  export type { FileChange, FileChangeDisplayMode, FileChangeKind, FileChangeOutputFormat, RenderFileChangesOptions } from "./components/file-changes.js";
@@ -29,7 +29,7 @@ export { renderInspectorCard } from "./components/inspector-card.js";
29
29
  export type { InspectorField, InspectorSection, RenderInspectorCardOptions } from "./components/inspector-card.js";
30
30
  export { renderResourceBrowser } from "./components/resource-browser.js";
31
31
  export type { RenderResourceBrowserOptions, ResourceBrowserGroup, ResourceBrowserItem } from "./components/resource-browser.js";
32
- export { getTemplatePartialNames, renderTemplate, resolveTemplatePartials } from "./components/template.js";
32
+ export { TemplateParseError, getTemplatePartialNames, renderTemplate, resolveTemplatePartials } from "./components/template.js";
33
33
  export type { RenderTemplateOptions, TemplateEscape } from "./components/template.js";
34
34
  export { openExternal } from "./components/browser.js";
35
35
  export * as acp from "./acp/index.js";
@@ -14,13 +14,13 @@ export { helpFormatter, formatColumns, formatCommand, formatUsage, formatOption,
14
14
  export * as helpFormatterPlain from "./components/help-formatter-plain.js";
15
15
  export { formatCommandNotFound } from "./components/command-errors.js";
16
16
  export { formatCommandNotFoundPanel } from "./components/command-errors.js";
17
- export { renderTable } from "./components/table.js";
17
+ export { loggerTableWidth, renderTable } from "./components/table.js";
18
18
  export { renderFileChanges } from "./components/file-changes.js";
19
19
  export { renderCatalog } from "./components/catalog.js";
20
20
  export { renderDetailCard } from "./components/detail-card.js";
21
21
  export { renderInspectorCard } from "./components/inspector-card.js";
22
22
  export { renderResourceBrowser } from "./components/resource-browser.js";
23
- export { getTemplatePartialNames, renderTemplate, resolveTemplatePartials } from "./components/template.js";
23
+ export { TemplateParseError, getTemplatePartialNames, renderTemplate, resolveTemplatePartials } from "./components/template.js";
24
24
  export { openExternal } from "./components/browser.js";
25
25
  // ACP rendering
26
26
  export * as acp from "./acp/index.js";
@@ -1,6 +1,11 @@
1
1
  import { EventEmitter } from "node:events";
2
2
  import { CANCEL } from "./cancel-symbol.js";
3
3
  export type PromptStateName = "initial" | "active" | "submit" | "cancel" | "error";
4
+ /**
5
+ * Builds the non-TTY rejection message, naming the documented `--yes` flag for the
6
+ * command being run and keeping `POE_NO_PROMPT=1` as the secondary CI alternative.
7
+ */
8
+ export declare function nonTtyPromptMessage(argv?: string[]): string;
4
9
  export interface PromptState<Value> {
5
10
  state: PromptStateName;
6
11
  value: Value | undefined;
@@ -22,6 +22,20 @@ const cursor = {
22
22
  const erase = {
23
23
  down: "\x1b[J"
24
24
  };
25
+ /**
26
+ * Builds the non-TTY rejection message, naming the documented `--yes` flag for the
27
+ * command being run and keeping `POE_NO_PROMPT=1` as the secondary CI alternative.
28
+ */
29
+ export function nonTtyPromptMessage(argv = process.argv) {
30
+ const tokens = [];
31
+ for (const arg of argv.slice(2)) {
32
+ if (arg.startsWith("-"))
33
+ break;
34
+ tokens.push(arg);
35
+ }
36
+ const retry = [...tokens, "--yes"].join(" ");
37
+ return `Interactive prompt requires a TTY. Re-run with \`${retry}\` to accept defaults non-interactively, or set POE_NO_PROMPT=1 in CI.`;
38
+ }
25
39
  export class Prompt extends EventEmitter {
26
40
  state = "initial";
27
41
  value;
@@ -92,7 +106,7 @@ export class Prompt extends EventEmitter {
92
106
  });
93
107
  }
94
108
  promptNonTty() {
95
- return Promise.reject(new Error("Interactive prompt requires a TTY. Set POE_NO_PROMPT=1 to accept defaults non-interactively."));
109
+ return Promise.reject(new Error(nonTtyPromptMessage()));
96
110
  }
97
111
  readNonTtyLine() {
98
112
  return new Promise((resolve) => {
@@ -33,7 +33,7 @@ export function spinner() {
33
33
  }
34
34
  fallback = process.env.POE_NO_SPINNER === "1" || !process.stdout.isTTY;
35
35
  if (fallback) {
36
- process.stdout.write(`${currentMessage}\n`);
36
+ process.stdout.write(`${color.gray("│")} ${currentMessage}\n`);
37
37
  return;
38
38
  }
39
39
  frameIndex = 0;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft-schema",
3
- "version": "0.0.136",
3
+ "version": "0.0.137",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft-openapi",
3
- "version": "0.0.136",
3
+ "version": "0.0.137",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -30,7 +30,7 @@
30
30
  "toolcraft-openapi-generate": "dist/bin/generate.js"
31
31
  },
32
32
  "dependencies": {
33
- "toolcraft": "0.0.136",
33
+ "toolcraft": "0.0.137",
34
34
  "auth-store": "^0.0.1",
35
35
  "fast-string-width": "^3.0.2",
36
36
  "fast-wrap-ansi": "^0.2.0",
@@ -46,7 +46,7 @@
46
46
  "directory": "packages/toolcraft-openapi"
47
47
  },
48
48
  "optionalDependencies": {
49
- "toolcraft-schema": "0.0.136",
49
+ "toolcraft-schema": "0.0.137",
50
50
  "toolcraft-design": "*",
51
51
  "@poe-code/frontmatter": "*"
52
52
  },