Packs のビルド
Packs は Greentic における配布単位です。このガイドでは、CLI ツールを使って packs を作成、ビルド、署名、公開する方法を説明します。
Pack CLI コマンド
Section titled “Pack CLI コマンド”gtc pack
Section titled “gtc pack”gtc pack <COMMAND>
Commands: build Build a pack from source directory verify Verify pack signature and contents info Display pack metadata extract Extract pack contents sign Sign a pack publish Publish pack to registryPack の作成
Section titled “Pack の作成”-
pack のディレクトリ構造を作成する
Terminal window mkdir -p my-pack/{flows,components,assets} -
pack マニフェストを作成する
my-pack/pack.toml [pack]name = "my-feature"version = "1.0.0"description = "My awesome feature pack"authors = ["Your Name <you@example.com>"][capabilities]id = "greentic.cap.app.v1"provides = ["my-feature"][flows]main = "flows/main.ygtc"[components]processor = "components/processor.wasm"[assets]templates = "assets/templates/" -
flows を追加する
my-pack/flows/main.ygtc name: mainversion: "1.0"description: Main flownodes:- id: processtype: replyconfig:message: "Hello from my pack!"triggers:- type: messagetarget: process -
components を追加する(ある場合)
WASM components をビルドし、
components/に配置します:Terminal window cd my-componentcargo build --target wasm32-wasip2 --releasecp target/wasm32-wasip2/release/my_component.wasm ../my-pack/components/
Packs のビルド
Section titled “Packs のビルド”基本的なビルド
Section titled “基本的なビルド”gtc pack build ./my-pack
# Output: my-feature-1.0.0.gtpackオプション付きビルド
Section titled “オプション付きビルド”# Specify output pathgtc pack build ./my-pack --output ./dist/my-feature.gtpack
# Skip WASM optimizationgtc pack build ./my-pack --no-optimize
# Include debug infogtc pack build ./my-pack --debugディレクトリmy-feature-1.0.0.gtpack
- manifest.cbor
ディレクトリflows/
- main.ygtc
ディレクトリcomponents/
- processor.wasm
ディレクトリassets/
ディレクトリtemplates/
- …
- sbom.json
Packs への署名
Section titled “Packs への署名”署名キーを生成する
Section titled “署名キーを生成する”# Generate new Ed25519 key pairgtc pack keygen --output my-signing-key
# Creates:# - my-signing-key.pem (private key - keep secret!)# - my-signing-key.pub (public key - distribute)Pack に署名する
Section titled “Pack に署名する”gtc pack sign my-feature-1.0.0.gtpack --key my-signing-key.pem
# Output: my-feature-1.0.0.gtpack (updated with signature)署名を検証する
Section titled “署名を検証する”gtc pack verify my-feature-1.0.0.gtpack --pubkey my-signing-key.pub
# Output: Signature validPack の確認
Section titled “Pack の確認”メタデータを表示する
Section titled “メタデータを表示する”gtc pack info my-feature-1.0.0.gtpack出力:
Pack: my-featureVersion: 1.0.0Description: My awesome feature packAuthors: Your Name <you@example.com>
Capabilities: ID: greentic.cap.app.v1 Provides: my-feature
Contents: Flows: 1 Components: 1 Assets: 2 directories
Signature: Valid (signed by: ABC123...)内容を一覧表示する
Section titled “内容を一覧表示する”gtc pack info my-feature-1.0.0.gtpack --list
# Lists all files in the packPack を展開する
Section titled “Pack を展開する”gtc pack extract my-feature-1.0.0.gtpack --output ./extracted/
# Extracts pack contents for inspectionFlow の検証
Section titled “Flow の検証”Flows を検証する
Section titled “Flows を検証する”# Validate all flows in a directorygtc flow doctor ./my-pack/flows/
# Validate specific flowgtc flow validate ./my-pack/flows/main.ygtcdoctor の出力
Section titled “doctor の出力”gtc flow doctor ./flows/
# Output:# Checking flows/main.ygtc... OK# Checking flows/helper.ygtc... OK## 2 flows checked, 0 errors, 0 warningsよくある検証エラー
Section titled “よくある検証エラー”| Error | 原因 | 修正方法 |
|---|---|---|
Unknown node type | 無効な node type | 利用可能な node types を確認する |
Missing target node | edge が存在しない node を指している | node ID の参照を修正する |
Circular dependency | nodes が循環を形成している | 循環を解消する |
No trigger defined | flow にエントリーポイントがない | trigger を追加する |
Packs の公開
Section titled “Packs の公開”OCI Registry に公開する
Section titled “OCI Registry に公開する”# Login to registrygtc pack login ghcr.io --username USER --password TOKEN
# Publish packgtc pack publish my-feature-1.0.0.gtpack --registry ghcr.io/greenticRegistry から pull する
Section titled “Registry から pull する”gtc pack pull ghcr.io/greentic/my-feature:1.0.0Bundle で使用する
Section titled “Bundle で使用する”apps: my-app: pack: "oci://ghcr.io/greentic/my-feature:1.0.0"Pack テンプレート
Section titled “Pack テンプレート”Provider Pack テンプレート
Section titled “Provider Pack テンプレート”[pack]name = "messaging-custom"version = "1.0.0"description = "Custom messaging provider"
[capabilities]id = "greentic.cap.messaging.provider.v1"provides = ["custom"]
[flows]setup_default = "flows/setup.ygtc"verify_webhooks = "flows/verify.ygtc"
[components]ingress = "components/ingress.wasm"egress = "components/egress.wasm"operator = "components/operator.wasm"
[secrets]required = ["api_key"]optional = ["webhook_secret"]Application Pack テンプレート
Section titled “Application Pack テンプレート”[pack]name = "helpdesk-bot"version = "1.0.0"description = "IT Helpdesk bot"
[capabilities]id = "greentic.cap.app.v1"provides = ["helpdesk"]
[dependencies]greentic-templates = "^0.4"greentic-llm-openai = "^0.4"
[flows]on_message = "flows/on_message.ygtc"on_ticket = "flows/on_ticket.ygtc"
[assets]cards = "assets/cards/"templates = "assets/templates/"ベストプラクティス
Section titled “ベストプラクティス”- セマンティックにバージョン管理する - semver(MAJOR.MINOR.PATCH)を使う
- すべてのリリースに署名する - 未署名の packs は配布しない
- SBOM を含める - セキュリティ監査のために依存関係を文書化する
- 公開前にテストする - flows を検証し、components をテストする
- 十分に文書化する - pack に README を含める
- packs は用途を絞る - 1つの pack につき 1つの機能または provider にする
- CI/CD を使う - ビルドと公開を自動化する
CI/CD の例
Section titled “CI/CD の例”name: Build and Publish Pack
on: push: tags: - 'v*'
jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4
- name: Install Rust uses: dtolnay/rust-toolchain@1.90.0
- name: Build Pack run: gtc pack build ./my-pack
- name: Sign Pack run: | echo "${{ secrets.SIGNING_KEY }}" > key.pem gtc pack sign my-feature-*.gtpack --key key.pem
- name: Publish run: | gtc pack login ghcr.io --username ${{ github.actor }} --password ${{ secrets.GITHUB_TOKEN }} gtc pack publish my-feature-*.gtpack --registry ghcr.io/${{ github.repository }}次のステップ
Section titled “次のステップ”- Pack Format Reference - 完全な仕様
- Flow Schema Reference - YAML schema
- Components Guide - WASM components の作成