Skip to content

Add CLI prompt for unknown variable descriptions#48

Open
Mandyx22 wants to merge 1 commit into
mainfrom
unknown-descriptions
Open

Add CLI prompt for unknown variable descriptions#48
Mandyx22 wants to merge 1 commit into
mainfrom
unknown-descriptions

Conversation

@Mandyx22
Copy link
Copy Markdown

@Mandyx22 Mandyx22 commented Jun 1, 2026

Summary

  • After data processing and metadata options, the CLI now detects user-data variables whose descriptions could not be resolved from plugin source
  • Shows an optional gate prompt: users can skip the entire step or fill in descriptions one by one (pressing Enter skips an individual variable)
  • Suppressed automatically when all three flags (--psych-ds-dir, --data-dir, --metadata-options) are provided (non-interactive mode)

Test plan

  • Run CLI interactively against a data directory — confirm gate prompt appears with correct variable count
  • Choose "Fill in descriptions", type a description for one variable, press Enter to skip another — verify dataset_description.json reflects filled-in and "unknown" values correctly
  • Choose "Skip" at the gate — verify no per-variable prompts appear and all descriptions remain "unknown"
  • Run with all three flags — confirm no prompt appears and CLI completes silently

🤖 Generated with Claude Code

After data processing and metadata options, detect user-data variables
with unresolved descriptions and offer an optional interactive step to
fill them in. Users can skip the whole prompt or skip individual
variables by pressing Enter. Prompt is suppressed in fully non-interactive
(all-flags) mode.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jun 1, 2026

🦋 Changeset detected

Latest commit: 58ebde8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@jspsych/metadata-cli Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@jodeleeuw
Copy link
Copy Markdown
Member

🔴 Stale "unknown" value persists after filling in a description

When a user fills in a description via the new prompt, the old "unknown" value isn't removed — the output ends up containing both.

promptUnknownDescriptions calls:

metadata.updateVariable(name, "description", { user: description.trim() });

This routes into VariablesMap.updateDescription, which is append-only by design (it accumulates descriptions across plugins). Tracing a typical user-data variable:

  • Its description ends up as e.g. { "default, html-keyboard-response": "unknown" }.
  • After fill-in, Object.assign adds the new key without touching the old one → { "default, html-keyboard-response": "unknown", "user": "my desc" }.

So the resulting dataset_description.json contains both the new description and the stale "unknown". The user's input doesn't actually resolve the unknown — it just sits alongside it.

If the intent is for the user value to replace "unknown", clear the existing description first, e.g.:

const variable = metadata.getVariable(name) as any;
variable["description"] = {}; // or delete the unknown-valued keys
metadata.updateVariable(name, "description", { user: description.trim() });

(Worth a comment too, since the append semantics of updateDescription are non-obvious.)

Side effect: because the unknown key survives, the description becomes a mixed map (one "unknown", one real value), so hasUnknownDescription returns false on a re-run (every(v => v === "unknown") is false) and a partially-filled variable won't be re-prompted.

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.

2 participants