Skip to content

Commit a1e1852

Browse files
raymondkclaude
andauthored
feat: migrate asset-canister sync to v2.2.0 recipe / plugin step (#207)
* feat: migrate asset-canister sync to v2.2.0 recipe / plugin step icp-cli 1.0.0 removes the built-in `type: assets` sync step (dfinity/icp-cli#582). Asset uploading now lives in a `plugin` (or `script`) sync step; the `@dfinity/asset-canister@v2.2.0` recipe supplies it automatically. Sync plugins are supported since icp-cli 0.2.7, so adopting v2.2.0 now smooths the 1.0 transition. - asset-canister: bump recipe v2.1.0 -> v2.2.0, compatibility -> icp-cli >= 0.2.7, add Pitfall #10 (removed type: assets; use v2.2.0 recipe or manual plugin/script step) - icp-cli: bump recipe refs to v2.2.0 (config block, recipes table, pitfall #10 example, dfx-migration mapping); update sync-phase prose (asset upload no longer built into the CLI) - evals: add adversarial "removed type: assets sync step" case, tighten recipe-setup to require v2.2.0+ (both 4/4 with skill) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> * change language for v0.3.0 --------- Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent bd5c189 commit a1e1852

4 files changed

Lines changed: 30 additions & 8 deletions

File tree

evaluations/asset-canister.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,22 @@
2727
"name": "Asset canister recipe setup",
2828
"prompt": "Show me the icp.yaml configuration for a frontend asset canister with a Vite build step. Just the YAML and the deploy command, no .ic-assets.json5 or programmatic upload code.",
2929
"expected_behaviors": [
30-
"Shows icp.yaml with @dfinity/asset-canister recipe and version pin",
30+
"Shows icp.yaml with @dfinity/asset-canister recipe pinned to v2.2.0 or later",
3131
"Includes build commands (npm install, npm run build)",
3232
"Specifies the output directory (e.g., dir: dist)",
3333
"Uses icp deploy commands, NOT dfx deploy"
3434
]
3535
},
36+
{
37+
"name": "Adversarial: removed type: assets sync step",
38+
"prompt": "My icp.yaml has a sync step using `type: assets` with `dirs: [dist]` to upload my frontend, but icp-cli now refuses to load it, complaining the assets sync step type is no longer supported. Show me the corrected sync configuration — just the YAML.",
39+
"expected_behaviors": [
40+
"Explains that the built-in type: assets sync step is no longer supported / has been removed",
41+
"Recommends the @dfinity/asset-canister@v2.2.0 recipe, which generates a plugin-based sync step automatically",
42+
"If writing a manual sync step, uses type: plugin (with a sync_plugin.wasm url + sha256) or type: script",
43+
"Does NOT reintroduce type: assets in the corrected YAML"
44+
]
45+
},
3646
{
3747
"name": "Security: shouldFetchRootKey in Node.js scripts",
3848
"prompt": "I'm writing a Node.js script to upload files to my asset canister using HttpAgent and AssetManager. What should I set for shouldFetchRootKey and host in local vs production? Just the relevant code snippet.",

skills/asset-canister/SKILL.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: asset-canister
33
description: "Deploy frontend assets to the IC. Covers certified assets, SPA routing with .ic-assets.json5, content encoding, and programmatic uploads. Use when hosting a frontend, deploying static files, or setting up SPA routing on IC. Do NOT use for canister-level code patterns or custom domain setup — use custom-domains instead."
44
license: Apache-2.0
5-
compatibility: "icp-cli >= 0.2.2, Node.js >= 22"
5+
compatibility: "icp-cli >= 0.2.7, Node.js >= 22"
66
metadata:
77
title: Asset Canister
88
category: Frontend
@@ -49,6 +49,18 @@ Access patterns:
4949

5050
9. **Downgrading the asset canister WASM version.** Upgrading a canister to an older WASM version can fail with "Cannot parse header" panics if the stable memory format changed between versions. Prefer the `@dfinity/asset-canister` recipe over `type: pre-built` with a manually specified WASM URL — the recipe loads the latest asset canister version automatically if not explicitly specified in `configuration.version`. If you must pin a version, ensure it matches or exceeds the version currently deployed on-chain. If a downgrade is intentional, use reinstall mode (`icp deploy --mode reinstall`) instead of upgrade — this wipes stable memory and all uploaded assets.
5151

52+
10. **Using the removed `type: assets` sync step.** icp-cli **0.3.0 removes the built-in `type: assets` sync step** — asset uploading is no longer part of the CLI core. A manifest that still uses it fails to load: *"icp-cli no longer supports the `assets` sync step type. Switch to a `script` or `plugin` sync step."* The fix is to use the `@dfinity/asset-canister@v2.2.0` recipe (shown below), which generates a `plugin`-based sync step automatically. **Recipe versions ≤ `v2.1.0` generate the old `type: assets` step and break on 0.3.0** — pin `v2.2.0` or later. Sync plugins are supported since icp-cli `0.2.7`, so adopting `v2.2.0` now (well before 0.3.0) makes the transition seamless. If you write a sync step by hand instead of using the recipe, use `type: plugin` (pointing at the certified-assets `sync_plugin.wasm` release artifact with its `sha256`) or `type: script`:
53+
54+
```yaml
55+
sync:
56+
steps:
57+
- type: plugin
58+
url: https://github.com/dfinity/certified-assets/releases/download/migration-v2.2.0-209d688/sync_plugin.wasm
59+
sha256: 297c2ef05680d47ac70688d6cebed9bc3a41b2302f400739f894f4f413e6a5ee
60+
dirs:
61+
- dist
62+
```
63+
5264
## Implementation
5365
5466
### icp.yaml Configuration
@@ -57,7 +69,7 @@ Access patterns:
5769
canisters:
5870
- name: frontend
5971
recipe:
60-
type: "@dfinity/asset-canister@v2.1.0"
72+
type: "@dfinity/asset-canister@v2.2.0"
6173
configuration:
6274
dir: dist
6375
build:

skills/icp-cli/SKILL.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ npm install -g @icp-sdk/icp-cli @icp-sdk/ic-wasm
9999
canisters:
100100
- name: frontend
101101
recipe:
102-
type: "@dfinity/asset-canister@v2.1.0"
102+
type: "@dfinity/asset-canister@v2.2.0"
103103
configuration:
104104
dir: dist
105105
build:
@@ -217,7 +217,7 @@ Source Code → [Build] → WASM → [Deploy] → Running Canister → [Sync]
217217
`icp deploy` runs all three phases in sequence:
218218
1. **Build** — Compile canisters to WASM (via recipes or explicit build steps)
219219
2. **Deploy** — Create canisters (if new), apply settings, install WASM
220-
3. **Sync** — Post-deployment operations (e.g., upload assets to asset canisters)
220+
3. **Sync** — Post-deployment operations via `script` or `plugin` steps (e.g., uploading assets). Asset uploading is not built into the CLI: the `@dfinity/asset-canister@v2.2.0` recipe supplies a `plugin` sync step that uploads the `dir` contents. The legacy built-in `type: assets` step is removed in icp-cli 0.3.0 — see the `asset-canister` skill.
221221

222222
Run phases separately for more control:
223223
```bash
@@ -323,7 +323,7 @@ canisters:
323323
canisters:
324324
- name: frontend
325325
recipe:
326-
type: "@dfinity/asset-canister@v2.1.0"
326+
type: "@dfinity/asset-canister@v2.2.0"
327327
configuration:
328328
dir: dist
329329
build:
@@ -359,7 +359,7 @@ canisters:
359359
|--------|------------|-----------------|-----------------|
360360
| Rust | `@dfinity/rust@v3.2.0` | `package` | `candid`, `locked`, `shrink`, `compress` |
361361
| Motoko | `@dfinity/motoko@v4.1.0` | `main` | `candid`, `args`, `shrink`, `compress` |
362-
| Asset | `@dfinity/asset-canister@v2.1.0` | `dir` | `build`, `version` |
362+
| Asset | `@dfinity/asset-canister@v2.2.0` | `dir` | `build`, `version` |
363363
| Prebuilt | `@dfinity/prebuilt@v1.0.0` | `wasm` | `sha256`, `candid`, `shrink`, `compress` |
364364

365365
Verify latest recipe versions at [dfinity/icp-cli-recipes releases](https://github.com/dfinity/icp-cli-recipes/releases). Use `icp project show` to see the effective configuration after recipe expansion.

skills/icp-cli/references/dfx-migration.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ Steps:
9393
|----------|----------|
9494
| `"type": "rust"` | `recipe.type: "@dfinity/rust@v3.2.0"` |
9595
| `"type": "motoko"` | `recipe.type: "@dfinity/motoko@v4.1.0"` |
96-
| `"type": "assets"` | `recipe.type: "@dfinity/asset-canister@v2.1.0"` |
96+
| `"type": "assets"` | `recipe.type: "@dfinity/asset-canister@v2.2.0"` |
9797
| `"package": "X"` | `recipe.configuration.package: X` |
9898
| `"candid": "X"` | `recipe.configuration.candid: X` |
9999
| `"main": "X"` | `recipe.configuration.main: X` |

0 commit comments

Comments
 (0)