Preface

In DSH intelligent agent conversations, CSV text often needs to be processed: exported snippets, tabular text in API responses, and data rows in reports. Having the model write parsing scripts on the fly each time can easily lead to errors with quoted fields, delimiters, and boundary inputs. Below, we introduce omdsh-dev/dsh-tool-csv. It consolidates the actions of parsing, querying, filtering, statistics, and converting CSV text into a single DSH plugin, uniformly outputting JSON text strings.

What It Is

omdsh-dev/dsh-tool-csv is a DSH CSV data utility plugin, maintained by omdsh-dev, released under the MIT license.

It is designed for DSH plugin scenarios, handling CSV data that already exists in text form, and provides four actions: parse, query, stats, and to_json. The plugin features a zero-dependency, pure function design, using an RFC 4180 state machine parser.

Core Features

The capabilities listed here all come from the plugin’s declared functionality:

  • Parse CSV text into structured results.
  • Query and filter by column and value.
  • Compute basic statistics such as row count and column count.
  • Provide a to_json action for JSON output scenarios.
  • Uniformly output JSON text strings.
  • Zero dependencies: does not introduce a CSV parsing library.
  • Pure functions: does not read files, write files, access the network, or use eval.
  • Uses an RFC 4180 state machine parser.
  • Query filtering performs only literal exact matches and does not support expression evaluation.

Common parameters include:

  • action: Specifies the action to execute; available options are parse, query, stats, and to_json.
  • csv: The CSV text to pass in.
  • column: The column to specify for query filtering.
  • value: The exact match value to specify for query filtering.
  • delimiter: Specifies the delimiter.
  • header: Specifies whether to treat the input as having a header row.
  • limit: Limits the number of returned rows; the default is 100 rows.

Runtime constraints include:

  • Input limit is 256,000 bytes; exceeding this causes an immediate error.
  • timeoutMs is 2000.
  • delimiter only supports a single UTF-16 code unit or "tab".
  • Rejects surrogate pairs and control characters, except \t.
  • Unclosed quotes or illegal characters after closing quotes will cause an error.

Installation and Activation

Below is the web profile installation command provided in the documentation:

dsh plugin --profile web add github:omdsh-dev/dsh-tool-csv

After installation, you can use the following command to confirm whether the plugin appears in the current profile configuration:

dsh --profile web --dump-config | grep tool-csv

Note that web and headless are different profiles: installing to web does not automatically cover headless; dsh run uses the headless profile by default. Therefore, if you want to use this plugin in the default runtime environment of dsh run, you should ensure that the headless profile also includes this plugin.

Typical Usage

The following examples come from the plugin documentation; \n in the input represents a newline.

parse

Parses CSV text into a JSON array of objects:

csv { action: 'parse', csv: 'name,city\nalice,nyc\nbob,la' }
→ [{"name":"alice","city":"nyc"}, {"name":"bob","city":"la"}]

query

Filters rows by column name and exact value:

csv { action: 'query', csv: 'name,city\nalice,nyc\nbob,la', column: 'city', value: 'la' }
→ [["name","city"],["bob","la"]]

Here, value: 'la' is a literal exact match, not a substring match, and does not perform expression evaluation.

stats

Computes basic structural statistics of the CSV text:

csv { action: 'stats', csv: 'name,city\nalice,nyc' }
→ {"rows":1,"columns":2,"columnNames":["name","city"],"emptyRows":0,"warnings":[]}

Applicable Scenarios and Considerations

This plugin is suitable for processing existing CSV text in DSH sessions, especially in scenarios that require deterministic parsing, filtering, statistics, or conversion to JSON. It delegates common edge cases to a fixed implementation, reducing the risk of the model writing ad hoc parsing code.

Things to note before use:

  • Tool parameters are recorded in the session log; do not pass sensitive data.
  • DSH plugins run with the permissions of the current dsh process; check the source code and MIT license before installation.
  • Query filtering only performs literal exact matches and cannot replace database queries or expression engines.
  • Inputs exceeding 256,000 bytes will cause an immediate error rather than being truncated.
  • web and headless are two different profiles; install the plugin to the target profile as needed.

Conclusion

The value of omdsh-dev/dsh-tool-csv is quite straightforward: it provides DSH with a zero-dependency, pure function tool that processes CSV text according to RFC 4180 and uniformly outputs JSON.

Project repository:

https://github.com/omdsh-dev/dsh-tool-csv

Community directory page (sourced from plugin leads, not verified in the captured materials for this article, and is an independent site, not equivalent to an official app store):

https://www.skillhub.cn/plugins/omdsh-dev/dsh-tool-csv