Draft
Conversation
… coverage
- Replace cli-utils monolithic index.ts with focused modules:
io.ts (file I/O), service.ts (JSONL service), prefixes.ts (prefix parsing)
- Remove parseCliArgs / getFlag* helpers from cli-utils public API;
these are now handled by commander in each engine's bin script
- Add injectable streams parameter to runJsonlService for testability
- Rewrite all three bin scripts (parser, generator, algebra) to use
commander instead of manual argument parsing; commander provides
built-in --help generation and cleaner option handling
- Fix bug in parser mergeContext: explicitly setting parseMode:undefined
overwrites the parser's built-in default Set via spread, producing an
empty parseMode Set and disabling variable/blank-node parsing for any
request that carries a per-request context override
- Add comprehensive tests:
- packages/cli-utils: service mode (valid requests, invalid JSON,
handler errors, ID propagation, blank lines, non-Error throws)
- packages/cli-utils: I/O utilities (file read/write, JSON parse)
- All three engine CLIs: service mode round-trips, error responses,
batched requests, missing-field validation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
CLI + Service Mode (SPARQL 1.1): Implemented Scope
What was added
1) New shared package:
@traqula/cli-utilsA dedicated package was added at
packages/cli-utilsto keep Node-specific CLI concerns out of@traqula/core.It provides shared helpers for:
parseCliArgs,getFlagAsString,getFlagAsBoolean, etc.)readTextInput,writeTextOutput,readJsonInput,writeJsonOutput)runJsonlService)parsePrefixMappings)2) New SPARQL 1.1 binaries
The following engine packages now expose CLI binaries via
binin theirpackage.jsonfiles:@traqula/parser-sparql-1-1traqula-parser-sparql-1-1@traqula/generator-sparql-1-1traqula-generator-sparql-1-1@traqula/algebra-sparql-1-1traqula-algebra-sparql-1-1Each package also includes bin build artifacts in
files(for publish) and compilesbin/**/*.tsvia updated engine tsconfigs.3) Runtime reuse for service mode
Each engine now has a reusable CLI runtime module:
engines/parser-sparql-1-1/lib/cli.tsengines/generator-sparql-1-1/lib/cli.tsengines/algebra-sparql-1-1/lib/cli.tsThese expose
create...CliRuntime+handle...CliRequest, enabling long-lived service processes to reuse expensive parser/transformer instances across calls.4) JSONL long-running service mode (stdio)
All three binaries support
--service(JSONL over stdin/stdout), allowing external processes (including non-JS environments) to send requests and parse structured JSON responses.Response envelope:
{ "id": ..., "ok": true, "result": ... }{ "id": ..., "ok": false, "error": { "message": "..." } }5) CLI docs and tests
Updated READMEs:
engines/parser-sparql-1-1/README.mdengines/generator-sparql-1-1/README.mdengines/algebra-sparql-1-1/README.mdAdded focused runtime tests:
engines/parser-sparql-1-1/test/cli.test.tsengines/generator-sparql-1-1/test/cli.test.tsengines/algebra-sparql-1-1/test/cli.test.tsMonorepo/build wiring updates
packages/cli-utilsto root references:tsconfig.jsontsconfig.cjs.json@traqula/cli-utilsdependency to the three SPARQL 1.1 engine packages above.cli-utils.Verification performed
Notes on design alignment
This implementation follows Traqula modularity: