Skip to content

Add CLI tools for SPARQL parsers, generators, and algebra transformers#106

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-cli-for-parsers-generators
Draft

Add CLI tools for SPARQL parsers, generators, and algebra transformers#106
Copilot wants to merge 3 commits intomainfrom
copilot/add-cli-for-parsers-generators

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 13, 2026

Plan: SPARQL 1.1 CLI and System Service Implementation

Starting from clean main branch to implement:

Phase 1: CLI Utilities Package

  • Create @traqula/cli-utils package
    • I/O utilities (stdin, file reading)
    • Error handling utilities
    • Shared types and interfaces

Phase 2: SPARQL 1.1 Parser CLI

  • Create CLI for @traqula/parser-sparql-1-1
    • bin/ directory with executable
    • Support --help, --rule, --base, --prefix, --skip-validation
    • Input from stdin, file, or argument
    • JSON AST output to stdout
    • Package.json bin entry
    • TypeScript build configuration

Phase 3: SPARQL 1.1 Generator CLI

  • Create CLI for @traqula/generator-sparql-1-1
    • Command-line interface
    • JSON AST input (stdin/file/argument)
    • SPARQL query string output
    • Support indentation options

Phase 4: SPARQL 1.1 Algebra CLI

  • Create CLI for @traqula/algebra-sparql-1-1
    • Support --to-algebra (SPARQL/AST → Algebra)
    • Support --to-ast (Algebra → AST)
    • Support --to-sparql (Algebra → SPARQL)
    • Options: --quads, --blank-to-variable

Phase 5: System Service Implementation

  • Design service architecture
    • HTTP server with JSON API
    • Parser/generator instance pooling
    • Request/response schema
  • Implement service endpoints
    • /parse - Parse SPARQL to AST
    • /generate - Generate SPARQL from AST
    • /algebra/to-algebra - Convert to algebra
    • /algebra/to-ast - Convert from algebra
    • /algebra/to-sparql - Convert algebra to SPARQL
  • Instance reuse/caching mechanism
  • Error handling and validation
  • Service startup script

Phase 6: Documentation & Testing

  • CLI documentation with examples
  • Service API documentation
  • Usage examples for different languages (Python, Java, etc.)
  • CLI tests
  • Service integration tests

This will enable efficient cross-language integration by reusing parser instances across invocations.

Original prompt

This section details on the original issue you should resolve

<issue_title>CLI for parsers, transformers and generators</issue_title>
<issue_description>A CLI can help others interact with Traqula from within their own workflow. This can mean checking the validity of a query from within a terminal, but also allowing other software to invoke Traqula though a separate process and parsing JSON output.
This feature depends on the fact that Traqula's algebra and AST components are simple DTOs and therefore completely serializable (good job belly feeling).

Creating a binary and installing it to the system is as easy as adding a "bin" key to package.json (see Comunica), and adding a CLI parser, which many packages can help us with.</issue_description>

<agent_instructions>Be sure to look at Traqula's architecture and goal. Using Traqula, parsers and generator can be created by simply modifying an existing one. Our CLI should be implemented in a way that respects this approach and facilitates others to also create a CLI for their modified parser and generator. Furthermore, our parsers allow you to start at any rule, so a CLI option should be added specifying what rule you would like generation/ parsing from.

Finally: for each CLI created, there should be TS test files that test by executing the CLI and validating the result.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@jitsedesmet 1. For `engines/parser-sparql-1-1` and `engines/parsers-sparql-1-2` we should look at the CLI options supported by the `Parser` exposed in https://github.com/RubenVerborgh/SPARQL.js/ 2. 1. For `engines/generator-sparql-1-1` and `engines/generator-sparql-1-2` we should look at the CLI options supported by the `Generator` exposed in https://github.com/RubenVerborgh/SPARQL.js/ 3. For `engines/algebra-sparql-1-1` and `engines/algebra-sparql-1-2` we should look at the CLI options supported by https://github.com/joachimvh/SPARQLAlgebra.js

Needless to say, support should reflect the design choices of Traqula and not blindly be copied from those projects. Especially taking care of the modularity Traqula provides, therefore, if necessary, a new package should be created under the package directory facilitating the creation of CLIs that are related to traqula's core package (@traqula/core).


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add CLI for parsers, transformers, and generators Add CLI tools for SPARQL parsers, generators, and algebra transformers Feb 13, 2026
Copilot AI requested a review from jitsedesmet February 13, 2026 18:07
Comment on lines +31 to +39
/**
* Format output as JSON with proper indentation.
* @param data - The data to format
* @param pretty - Whether to pretty print (default: true)
* @returns Formatted JSON string
*/
export function formatJson(data: any, pretty = true): string {
return JSON.stringify(data, null, pretty ? 2 : undefined);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the formatJson function. Commits f10f1df

Copy link
Copy Markdown
Member

@jitsedesmet jitsedesmet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Overall I believe the current approach with the util package does not cut it since the package does not really do anything. Furthermore, you should sync this branch with main. I have provided some more reviews. I think this is version is a starting point but requires more attention. Specifically to how we can generalize enough for the sparql based CLI components.

Copy link
Copy Markdown
Author

Copilot AI commented Feb 16, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • w3c.github.io
    • Triggering command: /opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node /home/REDACTED/work/traqula/traqula/engines/parser-sparql-1-1/node_modules/.bin/rdf-test-suite dist/cjs/spec/parser.js REDACTED -c ../../.rdf-test-suite-cache/ --skip (syn-bad-GRAPH-breaks-BGP|syn-bad-UNION-breaks-BGP|syn-bad-OPT-breaks-BGP|syn-bad-38|syn-bad-37|syn-bad-36|syn-bad-35|syn-bad-34|blabel-cross-union-bad|blabel-cross-optional-bad|blabel-cross-graph-bad) (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLI for parsers, transformers and generators

2 participants