Skip to content

Switch from Devlooped.JQ to Devlooped.JQSharp#162

Merged
kzu merged 2 commits intomainfrom
copilot/switch-to-devlooped-jqsharp
Apr 22, 2026
Merged

Switch from Devlooped.JQ to Devlooped.JQSharp#162
kzu merged 2 commits intomainfrom
copilot/switch-to-devlooped-jqsharp

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 22, 2026

Replaces the external jq binary dependency (Devlooped.JQ) with Devlooped.JQSharp, a pure .NET in-process implementation of the jq filter language.

Changes

  • dotnet-openai.csproj: Swap Devlooped.JQ v1.8.1.1 → Devlooped.JQSharp v1.0.1
  • JsonOutput.cs: Replace process-spawning logic with Jq.Evaluate():
    • Removes process management, SHA256 temp-file workaround for multiline queries, and stdin/stdout piping
    • Raw string output (-r flag equivalent): JsonValueKind.String results unquoted via GetString() ?? string.Empty, everything else via GetRawText()
    • JqException replaces process exit code checks for error reporting
    • Cancellation checked between results rather than on a process wait loop
using var doc = JsonDocument.Parse(json);
var results = Jq.Evaluate(jq.Trim(), doc.RootElement);
var lines = new List<string>();
foreach (var result in results)
{
    if (cancellation.IsCancellationRequested) return -1;
    lines.Add(result.ValueKind == JsonValueKind.String
        ? result.GetString() ?? string.Empty
        : result.GetRawText());
}
if (lines.Count > 0)
    WriteJson(console, monochrome, string.Join(Environment.NewLine, lines));

Eliminates the requirement for jq to be installed on the host and is ~140× faster per call (no process spawn overhead).

Copilot AI and others added 2 commits April 22, 2026 22:04
Replace the external jq process spawning with the in-process JQSharp
.NET implementation. This eliminates the dependency on a jq binary and
uses Jq.Evaluate() for filtering, which is ~140x faster than spawning
a process per call.

Agent-Logs-Url: https://github.com/devlooped/dotnet-openai/sessions/734e73ba-194e-42c3-ad81-e9b2395dcd89

Co-authored-by: kzu <169707+kzu@users.noreply.github.com>
Copilot AI assigned Copilot and kzu Apr 22, 2026
@kzu kzu marked this pull request as ready for review April 22, 2026 22:09
@kzu kzu enabled auto-merge (rebase) April 22, 2026 22:09
@kzu kzu added the enhancement New feature or request label Apr 22, 2026
@kzu
Copy link
Copy Markdown
Member

kzu commented Apr 22, 2026

8 passed 8 passed 1 skipped

🧪 Details on Ubuntu 24.04.4 LTS

from retest v1.1.0 on .NET 10.0.7 with 💜 by @devlooped

@kzu kzu merged commit 717dc83 into main Apr 22, 2026
4 checks passed
@kzu kzu deleted the copilot/switch-to-devlooped-jqsharp branch April 22, 2026 22:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants