cards2pack
Overview
Section titled “Overview”cards2pack is a CLI tool that converts Adaptive Card JSON files into Greentic packs. It:
- Scans cards, builds a dependency graph, generates
.ygtcflows - Extracts translatable strings for i18n
- Auto-translates cards via
greentic-i18n-translator - Packages everything into a deployable
.gtpack
Installation
Section titled “Installation”cargo install greentic-cards2packRequired tools:
cargo install greentic-flow greentic-packcargo install greentic-i18n-translator # optional, for --auto-translateQuick Start
Section titled “Quick Start”-
Create Adaptive Cards
cards/welcome.json {"type": "AdaptiveCard","version": "1.4","body": [{ "type": "TextBlock", "text": "Welcome!", "size": "Large" },{ "type": "TextBlock", "text": "How can I help you today?" }],"actions": [{"type": "Action.Submit","title": "Get Started","data": { "flow": "demo", "step": "next-card" }}]} -
Generate pack
Terminal window greentic-cards2pack generate \--cards ./cards \--out ./my-pack \--name my-pack -
Output
my-pack/pack.yamlflows/main.ygtcassets/cards/welcome.jsondist/my-pack.gtpack.cards2pack/manifest.json
CLI Reference
Section titled “CLI Reference”generate
Section titled “generate”Main command — scan cards, generate flows, build pack.
greentic-cards2pack generate [OPTIONS]| Flag | Description |
|---|---|
--cards <DIR> | Directory of Adaptive Card JSON files (required) |
--out <DIR> | Output workspace directory (required) |
--name <NAME> | Pack name (required) |
--strict | Errors on missing targets, duplicates, invalid JSON |
--group-by <MODE> | Flow grouping: folder or flow-field |
--default-flow <NAME> | Default flow name for ungrouped cards |
--prompt | Enable prompt-based routing (adds prompt2flow node) |
--prompt-json <FILE> | Answers JSON for prompt routing (requires --prompt) |
--auto-translate | Auto-translate cards with up to 8 parallel threads (requires greentic-i18n-translator) |
--langs <CODES> | Comma-separated language codes; omit to translate to all 65+ supported locales |
--glossary <FILE> | Glossary JSON for consistent translations |
--verbose | Print detailed output |
extract-i18n
Section titled “extract-i18n”Extract translatable strings from cards into a JSON bundle.
greentic-cards2pack extract-i18n [OPTIONS]| Flag | Description |
|---|---|
--input <DIR> | Directory of card JSON files (required) |
--output <FILE> | Output JSON path (default: i18n/en.json) |
--prefix <PREFIX> | Key prefix (default: card) |
--include-existing | Include strings that already contain $t() patterns |
--verbose | Print extraction report |
Card Identification
Section titled “Card Identification”Cards are identified by (in order of priority):
greentic.cardIdfield in the card JSON- Filename stem (e.g.,
welcome.json→welcome)
Cards are grouped into flows by:
flowfield in action data--group-by folder(directory structure)--default-flowfallback
i18n & Auto-Translation
Section titled “i18n & Auto-Translation”Extract strings
Section titled “Extract strings”greentic-cards2pack extract-i18n \ --input ./cards \ --output i18n/en.json \ --verboseOutput:
{ "card.welcome.body_0.text": "Welcome!", "card.welcome.body_1.text": "How can I help you today?", "card.welcome.actions_0.title": "Get Started"}Extracted field types
Section titled “Extracted field types”| Field | Source |
|---|---|
text | TextBlock content |
title | Action titles, card titles, toggle titles |
label | Input labels |
placeholder | Input placeholders |
errorMessage | Validation errors |
altText | Image alt text |
fallbackText | Fallback content |
FactSet title/value | Fact entries |
ChoiceSet title | Choice options |
Auto-translate (one command)
Section titled “Auto-translate (one command)”greentic-cards2pack generate \ --cards ./cards \ --out ./my-pack \ --name my-pack \ --auto-translate \ --langs fr,deThis extracts strings from the original card files, translates via greentic-i18n-translator using up to 8 concurrent threads, and bundles everything:
my-pack/assets/i18n/ en.json # English (source) fr.json # French de.json # GermanGlossary
Section titled “Glossary”Use a glossary to keep brand names and technical terms consistent:
{ "Greentic": "Greentic", "Dashboard": "Dashboard"}greentic-cards2pack generate \ --cards ./cards --out ./pack --name demo \ --auto-translate --langs fr,de \ --glossary glossary.jsonFlow Generation
Section titled “Flow Generation”Generated flow sections are wrapped in markers:
# BEGIN GENERATED (cards2pack)# ... generated nodes ...# END GENERATED (cards2pack)
# Developer space below (preserved on regen)Content outside the markers is preserved when you regenerate.
Strict mode
Section titled “Strict mode”With --strict:
- Missing route targets cause errors (instead of stub nodes)
- Duplicate
cardIdvalues cause errors - Invalid JSON causes errors
Template Variables
Section titled “Template Variables”Use Handlebars syntax for dynamic content:
{ "type": "TextBlock", "text": "Hello, {{name}}!"}Example: Multi-Step Form with Translation
Section titled “Example: Multi-Step Form with Translation”# Create cards in cards/ directory, then:greentic-cards2pack generate \ --cards ./cards \ --out ./checkout-pack \ --name checkout \ --auto-translate \ --langs fr,ja,es \ --glossary glossary.json \ --strictSee the translate-demo example for a complete walkthrough.