@wrongstack/core 0.32.0 → 0.41.0

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 (33) hide show
  1. package/dist/{agent-subagent-runner-DpZTLdBe.d.ts → agent-subagent-runner-C66vi4Gq.d.ts} +1 -1
  2. package/dist/{config-BUEGM4JP.d.ts → config-ZRCf7sTu.d.ts} +21 -1
  3. package/dist/coordination/index.d.ts +7 -7
  4. package/dist/coordination/index.js +3028 -2976
  5. package/dist/coordination/index.js.map +1 -1
  6. package/dist/defaults/index.d.ts +8 -8
  7. package/dist/defaults/index.js +1166 -1104
  8. package/dist/defaults/index.js.map +1 -1
  9. package/dist/execution/index.d.ts +5 -5
  10. package/dist/extension/index.d.ts +2 -2
  11. package/dist/{index-ysfO_DlX.d.ts → index-6_csX32J.d.ts} +1 -1
  12. package/dist/{index-pXJdVLe0.d.ts → index-DkVgH3wC.d.ts} +31 -1
  13. package/dist/index.d.ts +135 -15
  14. package/dist/index.js +1467 -1214
  15. package/dist/index.js.map +1 -1
  16. package/dist/infrastructure/index.d.ts +2 -2
  17. package/dist/infrastructure/index.js +17 -3
  18. package/dist/infrastructure/index.js.map +1 -1
  19. package/dist/kernel/index.d.ts +2 -2
  20. package/dist/{mcp-servers-BzB3r7_c.d.ts → mcp-servers-DONdo-XM.d.ts} +1 -1
  21. package/dist/{multi-agent-coordinator-DOXSgtom.d.ts → multi-agent-coordinator-BUsjiRWl.d.ts} +1 -1
  22. package/dist/{null-fleet-bus-DLsUjOyB.d.ts → null-fleet-bus-FvgHnZah.d.ts} +150 -131
  23. package/dist/{plan-templates-BZMi-VpU.d.ts → plan-templates-DYCeRCDN.d.ts} +1 -1
  24. package/dist/sdd/index.d.ts +3 -3
  25. package/dist/storage/index.d.ts +2 -2
  26. package/dist/{tool-executor-BAi4WI2d.d.ts → tool-executor-BpK-SWtJ.d.ts} +1 -1
  27. package/dist/types/index.d.ts +3 -3
  28. package/dist/types/index.js +17 -3
  29. package/dist/types/index.js.map +1 -1
  30. package/dist/utils/index.d.ts +107 -1
  31. package/dist/utils/index.js +53 -2
  32. package/dist/utils/index.js.map +1 -1
  33. package/package.json +1 -1
@@ -53,6 +53,112 @@ declare const color: {
53
53
  };
54
54
  declare function stripAnsi(s: string): string;
55
55
 
56
+ /**
57
+ * TTY detection helpers — the single source of truth for "is this process
58
+ * running against a real terminal?". Replaces ad-hoc `process.stdin.isTTY`
59
+ * / `process.stdout.isTTY` checks scattered across the codebase so that:
60
+ *
61
+ * 1. test code can mock a single module instead of stubbing `isTTY` on
62
+ * every ReadStream/WriteStream the test happens to touch;
63
+ * 2. a future TTY-detection source (an env var override, a Windows
64
+ * ConPTY workaround, …) lands in one place;
65
+ * 3. `isInteractive()` encodes the rule the project already used inline
66
+ * ("both streams are TTYs AND we're not running under CI") in one
67
+ * testable helper instead of the same 3-condition check in two
68
+ * different files.
69
+ *
70
+ * Scope: detection only. Raw-mode control (`setRawMode`), resize
71
+ * subscriptions, and write-injection belong to a future, larger TTY
72
+ * abstraction; this module is the smallest pull that gives us a
73
+ * testable seam and dedups 20+ call sites.
74
+ */
75
+ /** True when `process.stdout` is attached to a terminal (not a pipe/file). */
76
+ declare function isStdoutTTY(): boolean;
77
+ /** True when `process.stdin` is attached to a terminal (not a pipe/file). */
78
+ declare function isStdinTTY(): boolean;
79
+ /**
80
+ * True when the current process is an interactive session: both stdin and
81
+ * stdout are TTYs. Callers that also need a "not a single-shot invocation"
82
+ * or "not under CI" check should layer that on top — keeping this helper
83
+ * minimal preserves the original inline checks it replaces.
84
+ */
85
+ declare function isInteractive(): boolean;
86
+ /** Current terminal size in characters, with a 24×80 fallback for non-TTYs. */
87
+ declare function getTermSize(): {
88
+ rows: number;
89
+ cols: number;
90
+ };
91
+ /**
92
+ * Subscribe to terminal resize events. `cb` is called with the new size each
93
+ * time the underlying stream emits `resize`. Returns a cleanup function the
94
+ * caller MUST call on dispose to remove the listener — leaving a stale
95
+ * `resize` listener on a disposed component leaks the closure (and the
96
+ * component itself, transitively) until the process exits.
97
+ *
98
+ * The stream argument defaults to `process.stdout`. Pass an explicit
99
+ * `NodeJS.WriteStream` when the caller already owns one (e.g. a status line
100
+ * that targets an injected `out` for testability). For non-TTY streams no
101
+ * listener is registered and the returned cleanup is a no-op.
102
+ */
103
+ declare function onResize(cb: (size: {
104
+ rows: number;
105
+ cols: number;
106
+ }) => void, stream?: NodeJS.WriteStream): () => void;
107
+ /**
108
+ * Toggle raw mode on a TTY stdin stream. Returns `true` when the toggle was
109
+ * applied, `false` when the stream is null, not a TTY, or doesn't expose
110
+ * `setRawMode` (pipes, file descriptors, Windows ConPTY edge cases). Callers
111
+ * that need to restore the previous mode should snapshot `input.isRaw`
112
+ * BEFORE the call and pass the value to a second call to flip back.
113
+ *
114
+ * Use this helper to drop the now-redundant
115
+ * `if (input.isTTY) input.setRawMode(...)` ceremony at every call site.
116
+ */
117
+ declare function setRawMode(input: NodeJS.ReadStream, mode: boolean): boolean;
118
+ /**
119
+ * Write `s` to `stream` (defaults to `process.stdout`). Returns `false`
120
+ * when the stream is missing or doesn't expose `write` so callers can
121
+ * degrade silently under hostile host environments (closed pipe, mock
122
+ * injects `null`, test replaces the stream with a stub).
123
+ *
124
+ * Why a helper:
125
+ * 1. **Single seam for output capture in tests** — stub `writeOut` once
126
+ * and assert on what the rest of the codebase intended to print,
127
+ * without spying on `process.stdout.write` (which is brittle and
128
+ * leaks across parallel test files).
129
+ * 2. **Stream swap without grep** — routing the CLI's output to a
130
+ * logger or `out.log` becomes a one-line change at process boot.
131
+ * 3. **Defensive default** — closes the "what if `process.stdout` is
132
+ * `null`" gap that currently exists at ~50 call sites that just
133
+ * call `process.stdout.write(s)` and crash on certain Windows
134
+ * redirect invocations.
135
+ *
136
+ * Call-site migration is staged: this commit introduces the helper, a
137
+ * follow-up commit replaces the 50+ `process.stdout.write(...)` sites
138
+ * with `writeOut(...)`. Until that migration lands, both forms coexist
139
+ * and `writeOut` is the preferred form for new code.
140
+ */
141
+ declare function writeOut(s: string, stream?: NodeJS.WriteStream): boolean;
142
+ /**
143
+ * Symmetric partner of `writeOut` for the standard error stream. Same shape,
144
+ * same defensive contract, same single-seam-for-tests story — just defaults to
145
+ * `process.stderr` instead of `process.stdout`.
146
+ *
147
+ * Use this in code paths that emit error/diagnostic/warning text. Keeping
148
+ * these two helpers split (rather than a single `writeTo(s, stream)`) means
149
+ * the call site reads as a clear intent signal: "I am writing an error" vs.
150
+ * "I am writing a result" — which matters for callers that decide between
151
+ * stdout/stderr routing (e.g. `--quiet` flags, log-level filtering,
152
+ * structured-log rewriters that fork on stream).
153
+ *
154
+ * Stderr writes from the core logger (see `infrastructure/logger.ts`) and from
155
+ * the TUI guard (see `tui/run-tui.ts`) used to call `process.stderr.write`
156
+ * directly. Routing them through this helper lets tests stub the stream at
157
+ * one boundary and lets future logging middleware (e.g. a JSON-line rewriter)
158
+ * swap the destination for the entire process in one place.
159
+ */
160
+ declare function writeErr(s: string, stream?: NodeJS.WriteStream): boolean;
161
+
56
162
  /**
57
163
  * Canonical text rendering of the live todo list, shared by the CLI's
58
164
  * `/todos` slash command and the TUI's auto-echo (which prints the same
@@ -371,4 +477,4 @@ declare function completePartialObject(s: string): string;
371
477
  */
372
478
  declare function mergeModelsPayload(base: ModelsDevPayload, overlay: ModelsDevPayload): ModelsDevPayload;
373
479
 
374
- export { type AtomicWriteOptions, type BuildChildEnvOptions, type CompileFail, type CompileResult, type MessageRepairReport, type MessageRepairResult, type NewlineStyle, type RequestTokenBreakdown, type SafeParseResult, type ToolOutputSerializerOptions, type UnifiedDiffOptions, type ValidationError, type ValidationResult, atomicWrite, buildChildEnv, color, compileGlob, compileUserRegex, completePartialObject, createToolOutputSerializer, detectNewlineStyle, ensureDir, estimateRequestTokens, estimateRequestTokensCalibrated, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, expandGlob, formatTodosList, getCalibrationState, matchAny, matchGlob, mergeModelsPayload, normalizeToLf, recordActualUsage, repairToolUseAdjacency, resetCalibration, safeParse, safeStringify, sanitizeJsonString, stripAnsi, toStyle, unifiedDiff, validateAgainstSchema };
480
+ export { type AtomicWriteOptions, type BuildChildEnvOptions, type CompileFail, type CompileResult, type MessageRepairReport, type MessageRepairResult, type NewlineStyle, type RequestTokenBreakdown, type SafeParseResult, type ToolOutputSerializerOptions, type UnifiedDiffOptions, type ValidationError, type ValidationResult, atomicWrite, buildChildEnv, color, compileGlob, compileUserRegex, completePartialObject, createToolOutputSerializer, detectNewlineStyle, ensureDir, estimateRequestTokens, estimateRequestTokensCalibrated, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, expandGlob, formatTodosList, getCalibrationState, getTermSize, isInteractive, isStdinTTY, isStdoutTTY, matchAny, matchGlob, mergeModelsPayload, normalizeToLf, onResize, recordActualUsage, repairToolUseAdjacency, resetCalibration, safeParse, safeStringify, sanitizeJsonString, setRawMode, stripAnsi, toStyle, unifiedDiff, validateAgainstSchema, writeErr, writeOut };
@@ -205,11 +205,62 @@ function normalizeToLf(text) {
205
205
  return text.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
206
206
  }
207
207
 
208
+ // src/utils/term.ts
209
+ var hasStdout = () => typeof process !== "undefined" && !!process.stdout;
210
+ var hasStdin = () => typeof process !== "undefined" && !!process.stdin;
211
+ function isStdoutTTY() {
212
+ return hasStdout() && Boolean(process.stdout.isTTY);
213
+ }
214
+ function isStdinTTY() {
215
+ return hasStdin() && Boolean(process.stdin.isTTY);
216
+ }
217
+ function isInteractive() {
218
+ return isStdinTTY() && isStdoutTTY();
219
+ }
220
+ function getTermSize() {
221
+ if (!hasStdout()) return { rows: 24, cols: 80 };
222
+ return {
223
+ rows: process.stdout.rows ?? 24,
224
+ cols: process.stdout.columns ?? 80
225
+ };
226
+ }
227
+ function onResize(cb, stream = process.stdout) {
228
+ if (!stream || typeof stream.on !== "function") return () => {
229
+ };
230
+ const handler = () => {
231
+ cb({
232
+ rows: stream.rows ?? 24,
233
+ cols: stream.columns ?? 80
234
+ });
235
+ };
236
+ stream.on("resize", handler);
237
+ return () => {
238
+ stream.off("resize", handler);
239
+ };
240
+ }
241
+ function setRawMode(input, mode) {
242
+ if (!input || input.isTTY !== true) return false;
243
+ if (typeof input.setRawMode !== "function") return false;
244
+ input.setRawMode(mode);
245
+ return true;
246
+ }
247
+ function writeTo(s, stream) {
248
+ if (!stream || typeof stream.write !== "function") return false;
249
+ stream.write(s);
250
+ return true;
251
+ }
252
+ function writeOut(s, stream = process.stdout) {
253
+ return writeTo(s, stream);
254
+ }
255
+ function writeErr(s, stream = process.stderr) {
256
+ return writeTo(s, stream);
257
+ }
258
+
208
259
  // src/utils/color.ts
209
260
  var isColorTty = () => {
210
261
  if (process.env.NO_COLOR) return false;
211
262
  if (process.env.FORCE_COLOR) return true;
212
- return Boolean(process.stdout?.isTTY);
263
+ return isStdoutTTY();
213
264
  };
214
265
  var COLOR = isColorTty();
215
266
  var wrap = (open2, close) => (s) => COLOR ? `\x1B[${open2}m${s}\x1B[${close}m` : s;
@@ -1277,6 +1328,6 @@ function stripUndefined(obj) {
1277
1328
  return out;
1278
1329
  }
1279
1330
 
1280
- export { atomicWrite, buildChildEnv, color, compileGlob, compileUserRegex, completePartialObject, createToolOutputSerializer, detectNewlineStyle, ensureDir, estimateRequestTokens, estimateRequestTokensCalibrated, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, expandGlob, formatTodosList, getCalibrationState, matchAny, matchGlob, mergeModelsPayload, normalizeToLf, projectHash, recordActualUsage, repairToolUseAdjacency, resetCalibration, resolveWstackPaths, safeParse, safeStringify, sanitizeJsonString, stripAnsi, toStyle, unifiedDiff, validateAgainstSchema };
1331
+ export { atomicWrite, buildChildEnv, color, compileGlob, compileUserRegex, completePartialObject, createToolOutputSerializer, detectNewlineStyle, ensureDir, estimateRequestTokens, estimateRequestTokensCalibrated, estimateTextTokens, estimateToolDefTokens, estimateToolInputTokens, estimateToolResultTokens, expandGlob, formatTodosList, getCalibrationState, getTermSize, isInteractive, isStdinTTY, isStdoutTTY, matchAny, matchGlob, mergeModelsPayload, normalizeToLf, onResize, projectHash, recordActualUsage, repairToolUseAdjacency, resetCalibration, resolveWstackPaths, safeParse, safeStringify, sanitizeJsonString, setRawMode, stripAnsi, toStyle, unifiedDiff, validateAgainstSchema, writeErr, writeOut };
1281
1332
  //# sourceMappingURL=index.js.map
1282
1333
  //# sourceMappingURL=index.js.map