You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Centralize shell output independently of MCP stdio - #254
Extract the independently useful CLI output improvements from #239 while deferring MCP stdio entirely.
Centralize text, markup, renderables, exceptions, and terminal clearing through ShellOutput and a category-based output policy.
Keep --quiet informational output silent while preserving command results, warnings, errors, and required authentication/confirmation instructions. Machine-mode stdout contains command results only; diagnostics use stderr without ANSI styling.
Route theme, help, and edit failures through the normal error path so machine-mode callers receive one structured error instead of an unexplained failure exit code.
Add analyzer CZ0003 to reject direct Console/AnsiConsole writes outside the output layer, with scoped exceptions for interactive line-editor drawing.
Preserve the concurrent import implementation already on main while migrating its diagnostic output.
Update command/navigation documentation, localized help, and the changelog.
Compatibility
Machine-mode watch now requires a positive --max and returns the collected changes as a bounded final result. Interactive mode still supports unbounded streaming until Ctrl+C. This intentional change is documented under Breaking changes.
Explicitly out of scope
No --mcp-stdio option or transport; no stdio startup buffering/timeouts, history lifecycle, authentication changes, command filtering, or MCP subscription/confirmation changes. HTTP MCP remains unchanged. This PR is based directly on main, not on the stdio branch, and does not modify #239.
Extract the output policy and command migrations from #239 without MCP stdio. Preserve diagnostics and required instructions in quiet mode, report command errors consistently, and require bounded machine-mode watch results.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Console.Clear() falls through this check without CZ0003. That allows terminal clearing outside ShellOutput.ClearScreen(), bypassing its machine-mode guard. Include Clear alongside Write* so the analyzer enforces the clearing policy as well.
When an editor is already running, this return skips Editor.History.Add(cmdString) for MCP commands executed with --quiet. The commands are recorded in shell history and saved when possible, but are missing from the editor's Up/Down history. Remove this guard and let the output policy suppress the echo without changing history behavior.
Address the previously missed overview findings in #254 and add focused analyzer and editor-history regression coverage.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This guard drops the import's per-item diagnostics in machine mode, including the line or item number, status, and service message. ExecuteAsync then throws only failure counts, so default -c callers cannot identify the failing input or distinguish a conflict from an authorization failure. Preserve these diagnostics through the import result and include them in the final structured error without changing concurrent scheduling.
Bulk insert and upsert failure details are discarded
The new machine-mode guards suppress bulk insert/upsert failure details as well as informational output. The final command-mkitem-error-array_failed exception contains only counts, so default -c callers lose the status and service message explaining a failure. Collect diagnostics from both failed-status responses and caught Cosmos exceptions, and include them in the final structured error.
This guard discards each bulk replacement's error in machine mode, while the final exception reports only failure counts. A default -c replacement therefore loses actionable details such as a missing ID or service failure. Retain the per-item messages and include them in the final structured error, while keeping interactive diagnostics unchanged.
Machine mode emits raw stack traces for output failures
In machine mode with --verbose, an output-formatting or file-redirection failure reaches WriteException, which now writes a raw multiline stack trace to stderr. This bypasses both the structured error contract and shell 2> redirection. For example, redirecting echo ok to a file in a missing directory triggers this path. Restrict the verbose renderer to non-machine mode so machine failures reach WriteMachineError below.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Cross-cutting output routing requires human review and build/test validation, alongside resolution of the retained correctness and resource-use concerns.
No open issues 🎉
2 previously missed issues
In code that hasn't changed since last review
Bulk write diagnostics are unbounded and collected interactively
Bulk replacement retains every failure diagnostic without a count or length limit. MakeItemCommand does the same for inserts/upserts. Both also collect messages during interactive execution, where the lists are never consumed. Large failing arrays therefore retain all diagnostic text until completion, with additional copies when machine-mode errors are joined and serialized. Collect only in machine mode and bound both count and message length, reporting omitted diagnostics as the import path does. Reuse a shared bounded collector and cover both bulk-write paths.
Shell stderr redirection does not capture validation warnings
Shell 2>/2>> sets ErrOutRedirect and AppendErrRedirection; it does not replace Console.Error. Consequently, machine-mode theme validate warning.toml 2> warnings.log sends validation warnings to process stderr instead of the requested file. Query warnings and required instructions take the same path. Supply a redirection-aware stderr writer from the interpreter, preserving all writes within a command and the overwrite/append behavior. Add coverage for successful commands that emit warnings under both redirects.
Cap per-item diagnostics for mkitem, replace, and import at 100 entries with an omitted count, skip collecting them in interactive mode, and route machine-mode ShellOutput stderr through 2>/2>> redirection.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The batch error renderer can overwrite diagnostic details or duplicate errors when stderr redirection is active because it writes an error already reported by PrintStateCore.
Use the executing shell for batch renderers and avoid rendering an error a second time after PrintState reports it to stderr redirection.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Format insert, upsert, and replacement item positions through the existing localization catalog entry.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed because client-selection messages can use the singleton’s output policy instead of the executing shell’s, corrupting machine-mode stdout with human-readable text.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Invalid option and argument values in query, watch, and bucket commands still produce exit code 1 instead of the documented usage-error code 2, preventing scripts from distinguishing input errors from operational failures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Extract the independently useful CLI output improvements from #239 while deferring MCP stdio entirely.
ShellOutputand a category-based output policy.--quietinformational output silent while preserving command results, warnings, errors, and required authentication/confirmation instructions. Machine-mode stdout contains command results only; diagnostics use stderr without ANSI styling.theme,help, andeditfailures through the normal error path so machine-mode callers receive one structured error instead of an unexplained failure exit code.Console/AnsiConsolewrites outside the output layer, with scoped exceptions for interactive line-editor drawing.Compatibility
Machine-mode
watchnow requires a positive--maxand returns the collected changes as a bounded final result. Interactive mode still supports unbounded streaming until Ctrl+C. This intentional change is documented under Breaking changes.Explicitly out of scope
No
--mcp-stdiooption or transport; no stdio startup buffering/timeouts, history lifecycle, authentication changes, command filtering, or MCP subscription/confirmation changes. HTTP MCP remains unchanged. This PR is based directly on main, not on the stdio branch, and does not modify #239.