[Feature]: expand expression evaluator filter set (upper, lower, length, split, sort, to_json)
Les mainteneurs répondent en général sous 2 jours
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 52/100
Piste de recherche
Start in src/specify_cli/workflows/expressions.py, reading the existing filter registration and _apply_filter() implementation around lines 20-26 and 419-484. Then inspect tests/test_workflows.py and the existing filter tests to understand input and error conventions. The work is done when the agreed filter set is registered, implemented, and covered by tests, including the unresolved length semantics and naming decisions.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Problem
The workflow expression evaluator currently supports only 5 filters: default, join, map, contains, and from_json. For a system marketed as "Jinja2-like," common string and collection operations are missing, forcing workflow authors to shell out for basic transformations.
Missing filters that workflow authors frequently need:
- String operations:
upper,lower,trim(whitespace),split(string to list) - Collection operations:
length,first,last,sort,unique - Serialization:
to_json(the reverse of existingfrom_json)
Example of current limitation:
# Cannot do this today — no `length` filter:
- id: check
type: shell
config:
command: "echo 'Found {{ items | length }} files'"
# Cannot do this today — no `split` filter:
- id: list
type: shell
config:
command: "echo '{{ file_list | split(\",\") | length }} files found'"
Proposed Solution
Add a batch of new filters to the expression evaluator, following the existing registration pattern.
String Filters
| Filter | Input | Output | Example |
|---|---|---|---|
upper |
"hello" |
"HELLO" |
{{ name | upper }} |
lower |
"HELLO" |
"hello" |
{{ name | lower }} |
trim |
" hi " |
"hi" |
{{ name | trim }} |
split |
"a,b,c" |
["a","b","c"] |
{{ csv | split(",") }} |
Collection Filters
| Filter | Input | Output | Example |
|---|---|---|---|
length |
["a","b"] |
2 |
{{ items | length }} |
first |
["a","b","c"] |
"a" |
{{ items | first }} |
last |
["a","b","c"] |
"c" |
{{ items | last }} |
sort |
[3,1,2] |
[1,2,3] |
{{ items | sort }} |
unique |
["a","a","b"] |
["a","b"] |
{{ items | unique }} |
Serialization Filter
| Filter | Input | Output | Example |
|---|---|---|---|
to_json |
{"key":"val"} |
"{\"key\":\"val\"}" |
{{ data | to_json }} |
Design Notes
- Follows existing pattern: Each filter is a standalone function registered in
_REGISTERED_FILTERSand dispatched in_apply_filter()(expressions.py lines 20-26, 419-484) - Safe by design: All operations are pure transformations — no arbitrary code execution, no side effects, consistent with the sandboxed evaluator model
lengthenables conditionals: Unlocks{% if items | length > 0 %}patterns that currently require shell workaroundssplitbridges shell output: Shell steps return newline/comma-separated strings;splitconverts them to lists for downstream processingto_jsoncompletes the round-trip:from_jsonexists;to_jsonis its natural pair for passing structured data back to shell commands
Affected Files
src/specify_cli/workflows/expressions.py— filter registration and implementation (lines 20-26, 419-484)tests/test_workflows.py— unit tests for each new filter
Questions
- Are there additional filters you would want in this batch, or should we start with a smaller set?
- Should
lengthwork on both lists and strings (Jinja2 behavior), or only collections? - Any naming preferences (e.g.,
lenvslength,flattenvsunique)?
Happy to implement if this aligns with your plans for the expression engine.
- Langage dominant
- Python
- Étoiles
- 138k
- Forks
- 12.4k
- Merge moyen
- 2 j 14 h
- PR mergées (30 j)
- 164
Préparer son environnement
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de github/spec-kit
-
triage-nice-to-have
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
Les mainteneurs répondent en général sous 2 jours
-
[Feature]: 给 slug 添加默认值Ouverteenhancement needs-triage triage-can-wait
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
github/spec-kit#4627 · 3 commentaires ·
Les mainteneurs répondent en général sous 2 jours
-
extension-submission triage-can-wait
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
github/spec-kit#4626 · 1 commentaire ·
Les mainteneurs répondent en général sous 2 jours
-
needs-triage triage-nice-to-have
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
github/spec-kit#4527 · 1 commentaire ·
Les mainteneurs répondent en général sous 2 jours
-
bug-assess severity-medium
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
github/spec-kit#4273 · 3 commentaires ·
Les mainteneurs répondent en général sous 2 jours
Toutes les issues de github/spec-kit
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
gradio-app/gradio#13895 ·
Les mainteneurs répondent en général sous 1 jour
-
build-error
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
spack/spack-packages#6713 ·
Les mainteneurs répondent en général sous 1 jour
-
Use issue templatesOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
ActivityWatch/activitywatch#1464 · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
[Bug]: The ckg tool drops the return type of every decorated Python method in class search resultsOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
bytedance/trae-agent#483 ·
Les mainteneurs répondent en général sous 1 jour