cards2pack
Overview
Sección titulada «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
Sección titulada «Installation»cargo install greentic-cards2packRequired tools:
gtc installcargo install greentic-i18n-translator # optional, for --auto-translateQuick Start
Sección titulada «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
Ventana de terminal 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
Sección titulada «CLI Reference»generate
Sección titulada «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
Sección titulada «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
Sección titulada «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
Sección titulada «i18n & Auto-Translation»Extract strings
Sección titulada «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
Sección titulada «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)
Sección titulada «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
Sección titulada «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
Sección titulada «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
Sección titulada «Strict mode»With --strict:
- Missing route targets cause errors (instead of stub nodes)
- Duplicate
cardIdvalues cause errors - Invalid JSON causes errors
Template Variables
Sección titulada «Template Variables»Use Handlebars syntax for dynamic content:
{ "type": "TextBlock", "text": "Hello, {{name}}!"}Example: Multi-Step Form with Translation
Sección titulada «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.