Skip to content

feat!: rewrite Motoko recipe to delegate compilation to mops build#26

Draft
marc0olo wants to merge 5 commits into
mainfrom
fix/motoko-mops-moc-args
Draft

feat!: rewrite Motoko recipe to delegate compilation to mops build#26
marc0olo wants to merge 5 commits into
mainfrom
fix/motoko-mops-moc-args

Conversation

@marc0olo
Copy link
Copy Markdown
Member

@marc0olo marc0olo commented May 22, 2026

Summary

  • Replaces direct moc invocation with mops build, aligning the Motoko recipe with how the Rust recipe delegates to cargo build
  • Toolchain, dependencies, compiler flags, candid, and per-canister args all move to mops.toml — the recipe retains only icp-specific concerns (output path, moc:version/template:type metadata, shrink, compress)
  • Removes main, candid, and args recipe params — no replacement needed, the canister name is injected automatically via {{_.canister.name}}

Breaking change

Removed from icp.yaml Moves to mops.toml
main: src/main.mo [canisters.backend] main = "src/main.mo"
candid: backend.did [canisters.backend] candid = "backend.did"
args: --default-persistent-actors [canisters.backend] args = ["--default-persistent-actors"]

New icp.yaml — no configuration: block needed:

canisters:
  - name: backend
    recipe:
      type: "@dfinity/motoko@<version>"

New mops.toml — canister name must match icp.yaml:

[toolchain]
moc = "1.8.2"

[canisters.backend]
main = "src/main.mo"
candid = "backend.did"

Blocked on

dfinity/icp-cli#567 — provides {{_.canister.name}} built-in variable

Test plan

  • Build a canister using mops build with a matching [canisters] entry in mops.toml
  • Confirm moc:version and template:type metadata are present in the output WASM
  • Confirm [moc] args from mops.toml are respected (e.g. --default-persistent-actors)
  • Confirm shrink and compress options still work
  • Confirm a clear error is shown when the [canisters] entry is missing

Note: icp-cli-templates needs a follow-up update to add [canisters] to all Motoko mops.toml files. Tracked in dfinity/icp-cli-templates#27 / dfinity/icp-cli-templates#28.

🤖 Generated with Claude Code

Compiler flags defined in the [moc] section of mops.toml were silently
ignored because the recipe never called `mops moc-args`. Adding it to
the compile command ensures those flags are respected alongside the
recipe-level `args` parameter.
@marc0olo marc0olo requested a review from a team as a code owner May 22, 2026 10:37
marc0olo added a commit to dfinity/examples that referenced this pull request May 22, 2026
… branch

- moc 1.5.1 → 1.8.2, core 2.4.0 → 2.5.0
- Add --default-persistent-actors to moc args so the persistent keyword
  is no longer needed in main.mo
- Pin Motoko recipe to fix/motoko-mops-moc-args branch until
  dfinity/icp-cli-recipes#26 merges and a stable release is cut

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace direct moc invocation with `mops build`, aligning the Motoko
recipe with how the Rust recipe delegates to `cargo build`. Toolchain,
dependencies, compiler flags, candid, and per-canister args all move to
mops.toml — the recipe retains only icp-specific concerns (output path,
moc:version / template:type metadata, shrink, compress).

BREAKING CHANGE: `main`, `candid`, and `args` params removed. Add a
`name` param matching the [canisters] key in mops.toml.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@marc0olo marc0olo changed the title fix: pass mops moc-args to moc in Motoko recipe feat!: rewrite Motoko recipe to delegate compilation to mops build May 26, 2026
Follow the same pattern as the Rust recipe: let the build tool write to
its natural output directory and cp from there. Always pass --output
.mops/.build so the path is stable regardless of any [build].outputDir
set in mops.toml.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
marc0olo added a commit to dfinity/examples that referenced this pull request May 26, 2026
Both Motoko examples now point to the specific commit of the fix branch
rather than the branch name, which is mutable. Swap to a stable
@dfinity/motoko release tag once dfinity/icp-cli-recipes#26 ships.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
marc0olo added a commit to dfinity/examples that referenced this pull request May 26, 2026
… branch

- moc 1.5.1 → 1.8.2, core 2.4.0 → 2.5.0
- Add --default-persistent-actors to moc args so the persistent keyword
  is no longer needed in main.mo
- Pin Motoko recipe to fix/motoko-mops-moc-args branch until
  dfinity/icp-cli-recipes#26 merges and a stable release is cut

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
marc0olo added a commit to dfinity/examples that referenced this pull request May 26, 2026
Both Motoko examples now point to the specific commit of the fix branch
rather than the branch name, which is mutable. Swap to a stable
@dfinity/motoko release tag once dfinity/icp-cli-recipes#26 ships.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Drop the `name` configuration parameter — the canister name is now
injected automatically via {{_.canister.name}} (requires icp-cli#567).
The [canisters] key in mops.toml must still match the canister name in
icp.yaml, but no extra recipe configuration is needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@marc0olo marc0olo marked this pull request as draft May 26, 2026 16:51
Comment thread recipes/motoko/README.md Outdated
--incremental-gc is the default GC in recent moc versions, so showing
it in the example implies it does something meaningful when it doesn't.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Kamirus added a commit to caffeinelabs/mops that referenced this pull request Jun 1, 2026
<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
Proposal spec for a new `mops deployed` command group that produces the
committed **deployed snapshot** (`.most` + `.did`) for a Motoko
canister.

## Why

`mops build` emits `<name>.wasm`, `<name>.did`, `<name>.most` from one
compilation. The wasm is deployed; the other two must be committed as
the deployed snapshot:

- `.most` — consumed by `mops check-stable` to guard upgrades against
state loss; must match what's on-chain.
- `.did` — a committed record of the deployed interface for icp tooling
(`@icp-sdk/bindgen`, `icp canister call`) and the repo. **Not consumed
by mops** — placed at the icp-cli team's request.

Today this is copied by hand after deploy; forgetting it means the
snapshot drifts from on-chain reality. This enables the in-progress
[icp-cli Motoko
recipe](dfinity/icp-cli-recipes#26) to snapshot
both files in its post-install `sync` phase, reusing the exact artifacts
that produced the deployed wasm.

## Key decisions

- **`update`, not `sync`** — `sync` is taken (deps reconciliation) and
clashes with `icp`'s sync phase; the action is advancing a snapshot
forward.
- **Copy-or-error, never regenerate** — strictly reuses `mops build`
output so the snapshot can't decouple from the deployed wasm.
- **A configurable snapshot directory** (`[deployed].dir`, default
`deployed/`, `--dir` override) is the *only* thing that determines
output paths. Both `.most` and `.did` go to `<dir>/<name>.*`.
- **Decoupled from `check-stable.path`** — `mops deployed` never reads
it. `init` points `[check-stable].path` at `<dir>/<name>.most` so the
file `update` writes is the file `check-stable` reads. If a user points
it elsewhere, `update`/`init` warn (no hard coupling).
- **The `.did` is a pure output artifact** — mops doesn't consume it; no
Candid compat check (`check-candid` deferred). `--no-did` opts out.
- **The existing `candid` field is ignored** — it's a curated
*ahead-of-code* interface that the build embeds; the snapshot is a
generated *lags-code* record (see spec appendix).
- **`init` configures `mops.toml`** — writes the empty-actor `.most`
baseline and sets `check-stable.path` to coincide; no `.did` baseline
needed. Flags the whole-file TOML rewrite caveat.
- **Canister selection** follows `mops build`/`mops check` (no arg =
all; named = strict). `update` doesn't require `check-stable`
configured. Multi-canister `icp` deploys work because `icp` expands the
recipe per canister.

Design proposal only — no implementation. Open questions: directory
config surface (global vs per-canister), per-environment snapshots,
future `check-candid`, optional deployed manifest.
<!-- CURSOR_AGENT_PR_BODY_END -->

<div><a
href="https://cursor.com/agents/bc-1491e925-7575-4a68-8d63-9be3c9f21691"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-1491e925-7575-4a68-8d63-9be3c9f21691"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
marc0olo added a commit to dfinity/examples that referenced this pull request Jun 2, 2026
* feat: add Codespaces support to who_am_i examples (pilot)

Updates both Motoko and Rust who_am_i examples to use GitHub Codespaces
instead of ICP Ninja for the one-click browser experience.

devcontainer.json changes:
- Image: marc0olo/icp-dev-env-motoko:dev / icp-dev-env-rust:dev
- workspaceFolder: opens VS Code directly in the example directory
- Port 8000 (icp-cli gateway) replaces port 4943 (dfx)
- postStartCommand: icp network start -d (auto-starts on every resume)
- postCreateCommand: mops install (Motoko only)
- Adds stateful.runme extension for interactive README buttons

README changes:
- Replaces ICP Ninja badge with Open in GitHub Codespaces badge
- Adds note that authentication uses production id.ai (PocketIC accepts
  mainnet signatures, so no local II needed)
- Adds Runme action buttons: deploy, frontend, reset-deploy, info
- Removes icp network stop (lifecycle handled by Codespace suspension)
- Adds mainnet guidance section

See #1345

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: add postAttachCommand to open README with Runme buttons on attach

Adds `"postAttachCommand": "code README.md"` to both who_am_i devcontainer
configs so the README with Runme action buttons opens automatically every
time a Codespace is attached. Also adds a resume note to the Motoko README
pointing users to github.com/codespaces.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: improve Codespace resume guidance in both who_am_i READMEs

Clarifies that returning users should look for the "Open existing
codespace" banner on the creation page, and adds the github.com/codespaces
link to the Rust README (was already in Motoko).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: use code -r to scope VS Code window to example subdirectory

workspaceFolder doesn't scope the Explorer in Codespaces; code -r
reopens the current window rooted at the example folder, fixing both
the sidebar view and the terminal working directory.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: move Codespaces devcontainers to repo root .devcontainer/

GitHub Codespaces only discovers devcontainer.json under .devcontainer/
at the repo root — per-example subdirectory .devcontainer/ folders are
silently ignored, causing the devcontainer_path URL param to be discarded.

Adds root-level .devcontainer/motoko-who-am-i/ and /rust-who-am-i/ configs
and updates the Codespaces badge URLs in both READMEs accordingly.
The per-example .devcontainer/ files are kept for local dev container use.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: replace code -r with code README.md, suppress noisy notifications

- Removes code -r (caused double window reload since workspaceFolder now
  works correctly once devcontainer is properly discovered)
- Opens README.md on attach so Runme buttons are immediately visible
- Suppresses port 7865 (PocketIC internal port) auto-forward notification
- Sets git.openRepositoryInParentFolders=always to avoid parent-repo prompt

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: remove per-example .devcontainer directories

Root-level .devcontainer/<name>/ configs handle both Codespaces and
local dev container use. Per-example configs are redundant and create
maintenance overhead across 46+ examples.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: Codespaces DX improvements for who_am_i examples

- Fix ICP gateway rejecting API calls from Codespaces: override origin
  header in Vite proxy to localhost:8000 so the network launcher accepts
  requests from non-localhost forwarded domains
- Add "Show URLs" Runme cell that constructs correct Codespaces-aware
  frontend and Candid UI URLs using $CODESPACE_NAME
- Rename "Local development" section to "Codespace actions" and remove
  redundant "Install dependencies" cell (handled by postCreateCommand)
- Set workbench.editorAssociations to open .md files in Runme directly,
  preventing the double README tab (preview + notebook)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: route agent to port 8000 in Codespaces, use ?canisterId= URLs

- actor.js: detect .app.github.dev and route API calls directly to the
  port-8000 forwarded URL, bypassing the Vite proxy host check
- README: reorder Codespace actions (Show URLs before dev server),
  use ?canisterId= query-param routing (works with Codespaces port
  forwarding), derive Candid UI URL from icp network status --json,
  remove icp environment cell

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: auto-deploy and open frontend URL on Codespace attach

Add postAttach.sh scripts for both who_am_i devcontainers:
- deploys canisters on first attach (guarded by canister status check,
  skipped on reconnects)
- prints Frontend + Candid UI URLs to terminal
- opens frontend in browser via `code --open-url`
- opens README in editor

Update README to reflect automatic deploy/open behaviour; simplify
Codespace actions section accordingly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: improve postAttach transparency with status messages

Add clear echo output at each stage: network confirmation, deploy
progress (with timing hint), deployment complete/skipped, URL building,
and browser open notification.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: re-add redeploy cell to Codespace actions (preserves state)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: suppress port 7863 notification (PocketIC internal port)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: suppress port 7864 notification (Runme extension process)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: remove code --open-url (browser blocks programmatic tabs)

URLs are printed to the terminal and are clickable via Cmd/Ctrl+click.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: root key fetch and broken-pipe in Codespaces

actor.js: create HttpAgent explicitly and call fetchRootKey() when
  accessed via the ICP gateway directly (no ic_env cookie). Extend
  isLocalNetwork() to cover .app.github.dev so Codespaces URLs are
  treated as local. Make createBackendActor async accordingly.
App.jsx: await createBackendActor.
postAttach.sh: capture icp network status --json into a variable before
  piping to jq to avoid the broken-pipe panic; add __Candid_UI fallback
  for candid_ui_principal.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: use echo to pipe JSON to jq (printf omits trailing newline)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* revert: remove fetchRootKey logic from actor.js

The asset canister serves the ic_env cookie (containing the root key)
when the frontend is loaded directly from the ICP gateway, so the agent
already has the correct root key. The explicit fetchRootKey call and
async createBackendActor were unnecessary.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: add *.app.github.dev to gateway domains for Codespaces support

Allows the ICP HTTP gateway to accept requests with Codespaces
forwarded Host headers. If the gateway doesn't support wildcards,
we'll need a dynamic postStart.sh approach instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* revert: remove Codespaces host workarounds from actor.js and vite.config.js

getNetworkHost() and the origin header override were workarounds for the
gateway rejecting non-localhost Host headers. The root cause is now fixed
via gateway.domains in icp.yaml, so these are no longer needed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: inject Codespaces domain into icp.yaml via postStart.sh

The wildcard *.app.github.dev caused the gateway to hang (PocketIC
doesn't support wildcards). Replace with a postStart.sh script that
injects the exact ${CODESPACE_NAME}-8000.app.github.dev domain into
icp.yaml before starting the network. The modification is workspace-
local and not committed.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: centralize devcontainer scripts and add generic CODESPACE.md

- Move postStart.sh and postAttach.sh to .devcontainer/scripts/ (shared
  by all examples); both devcontainer.json files now reference them directly
- postStart.sh: generic gateway domain injection — handles both ii:true and
  non-ii icp.yaml layouts
- postAttach.sh: fully generic via `icp project show` + jq — detects
  frontend vs backend canisters by recipe/sync type, shows correct URLs
  for each (frontend URL or Candid UI link)
- Add .devcontainer/CODESPACE.md with Show URLs / Redeploy / Reset cells;
  symlinked into motoko/who_am_i and rust/who_am_i
- Scope workbench.editorAssociations to CODESPACE.md only (not *.md)
- Remove postCreateCommand (mops install) from motoko devcontainer
- Use icp deploy --mode reinstall -y for reset instead of network restart

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor: extract URL display to show-urls.sh

Move URL detection logic from postAttach.sh and CODESPACE.md into a
dedicated script. All three cells in CODESPACE.md are now one-liners.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: clean up Codespace section in who_am_i READMEs

Remove incorrect "open existing codespace" claim, drop Codespace actions
(moved to CODESPACE.md), and remove em-dashes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: remove Runme, add startup editor suppression, document URL limitations

- Remove stateful.runme extension from both devcontainer configs
- Remove workbench.editorAssociations (no longer needed)
- Add workbench.startupEditor: none to suppress auto-opening README.md
- CODESPACE.md is now plain markdown: warns that icp deploy URLs do not
  work in Codespaces and explains the ?canisterId= limitation for
  non-SPA frontends

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: improve Codespace UX for who_am_i examples

- Open CODESPACE.md immediately on attach (before deploy) and in preview mode
- Always run icp deploy on attach (idempotent, accurate for both first start and resume)
- Add setup-in-progress disclaimer to CODESPACE.md
- Move non-SPA note to bottom, rename Redeploy section to Deploy / Redeploy
- Replace invalid workbench.commandPalette.showAskInChat with editorAssociations for markdown preview

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: update port labels to ICP and Vite

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: add root devcontainer for local multi-example development

Uses the combined Motoko + Rust image for contributors and explorers who
clone the full repo. No lifecycle scripts — intended for local Dev Containers
use, not Codespaces.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: use fully qualified rust-lang.rust-analyzer extension ID

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: update README with icp-cli, Codespaces, and Dev Containers

- Replace dfx install instructions with icp-cli
- Document GitHub Codespaces (per-example badges) and root Dev Container
- Remove Gitpod reference
- Fix all docs URLs to docs.internetcomputer.org
- Demote ICP Ninja to a brief mention

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: remove ICP Ninja section and fix security best practices URL

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: remove NINJA_CONTRIBUTING.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: refurbish ADDING_AN_EXAMPLE.md

- Remove ICP Ninja reference (NINJA_CONTRIBUTING.md deleted)
- Replace dfx references with icp-cli
- Add Codespaces devcontainer guidance for new examples

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: remove outdated portal submodule documentation section

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: remove ICP Ninja reference and update example submission guidance

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: add Codespaces support to hello_world examples

- Add devcontainer configs for motoko-hello-world and rust-hello-world
- Add CODESPACE.md symlinks
- Replace ICP Ninja sections with Codespaces badge in both READMEs
- Remove dfx.json, BUILD.md, and old .devcontainer from each example
- Add hello_world.yml CI workflow using icp-cli
- Remove hello_world entries from ninja_pr_checks.yml
- Fix security best practices and icp-cli URLs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: add Makefiles with tests and CI workflows for hello_world and who_am_i

hello_world: tests default greeting, setGreeting/set_greeting + updated output
who_am_i: tests whoami returns a principal and is deterministic

Creates who_am_i.yml CI workflow; removes hello_world and who_am_i from
ninja_pr_checks.yml to avoid duplicate runs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: add workflow template, clarify npm run dev, update contributing guide

- Add .github/workflow-template.yml as canonical starting point for new examples
- Remove mops install from who_am_i CI (handled by icp deploy)
- Separate npm run dev from deploy steps in who_am_i READMEs with explanation
- Update ADDING_AN_EXAMPLE.md to reference template and Makefile pattern

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: handle icp.yaml without a network section in postStart.sh

Fall back to appending a network block when neither ii: true nor
mode: managed is present. Fixes gateway injection for examples like
hello_world that have no network section in their icp.yaml.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: use correct networks.local structure when appending to icp.yaml

The icp.yaml schema expects 'networks' (plural) with named entries,
not a top-level 'network' field.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: networks is a sequence not a map in icp.yaml

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: add Vite devserver domain to gateway domains in postStart.sh

Includes the port 5173 forwarded domain so the ICP gateway accepts
requests proxied through the Vite dev server in Codespaces.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: ensure network is running in postAttach.sh

Adds a defensive icp network start -d before deploy so the Codespace
recovers if postStart.sh failed or the network process didn't survive.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: wait for ICP network to be ready before deploying

icp network start -d returns immediately but the replica takes a moment
to be ready. Poll localhost:8000/api/v2/status until it responds before
running icp deploy.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: remove redundant network start and polling from postAttach.sh

postStartCommand completes before postAttachCommand runs, so the network
is guaranteed ready by postStart.sh. The band-aid was masking errors.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: wait for network readiness in postStart.sh before returning

icp network start -d may return before the replica is ready to accept
connections. Poll /api/v2/status so postStartCommand only completes
once the network is actually up, guaranteeing postAttach can deploy.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: add set -e to lifecycle scripts and remove unnecessary polling

icp network start -d already blocks until the network is ready.
set -e ensures failures are visible immediately rather than silently
continuing to the next command.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor: rename canisters to backend/frontend in who_am_i examples

Rename internet_identity_app_backend → backend and
internet_identity_app_frontend → frontend in both Motoko and Rust
who_am_i examples, including src directories, .did files, icp.yaml,
Cargo.toml, Makefile, vite.config.js, actor.js, package.json,
.gitignore, and README. Also removes ICP Ninja artifacts (dfx.json,
BUILD.md) and simplifies vite.config.js by dropping the dfx fallback.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: bump moc/core, use --default-persistent-actors, pin recipe fix branch

- moc 1.5.1 → 1.8.2, core 2.4.0 → 2.5.0
- Add --default-persistent-actors to moc args so the persistent keyword
  is no longer needed in main.mo
- Pin Motoko recipe to fix/motoko-mops-moc-args branch until
  dfinity/icp-cli-recipes#26 merges and a stable release is cut

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: add AGENTS.md and CLAUDE.md with example structure guidelines

AGENTS.md is the primary source of agent instructions covering:
canonical example layout, icp.yaml / mops.toml / Cargo.toml patterns,
Makefile requirements, devcontainer and CI workflow templates, README
structure, dfx→icp-cli migration checklist, and pending items (images,
Motoko recipe version).

CLAUDE.md delegates to AGENTS.md.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: instruct agents to fetch ICP skills before working

Adds a Skills section at the top of AGENTS.md pointing to the live
skills registry at skills.internetcomputer.org. Lists the relevant
skills (icp-cli, icp-cli/dfx-migration, motoko, mops-cli,
internet-identity, asset-canister) and establishes that skills take
precedence over general knowledge where they overlap.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: add paths filter to ninja_pr_checks workflow

Without a paths filter, changing the workflow file (e.g. removing
hello_world and who_am_i which now use icp-cli) triggers the
run_all_examples self-trigger, causing all ninja examples to run on
unrelated PRs. Enumerating the exact ninja-managed paths ensures the
workflow only fires when relevant example code or the workflow file
itself changes.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: pin Motoko recipe to immutable commit SHA

Both Motoko examples now point to the specific commit of the fix branch
rather than the branch name, which is mutable. Swap to a stable
@dfinity/motoko release tag once dfinity/icp-cli-recipes#26 ships.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* refactor: adopt new Motoko recipe format (v5 schema)

The new recipe only needs `name` in icp.yaml. Move `main`, `candid`,
and per-canister args into mops.toml under [canisters.<name>].

- hello_world: bump moc 1.5.1→1.8.2, core 2.4.0→2.5.0, add
  --default-persistent-actors, add [canisters.backend], drop
  `persistent` keyword from app.mo
- who_am_i: add [canisters.backend] to existing mops.toml
- Both READMEs: update .did regeneration command to `mops build backend --idl`
- AGENTS.md: update icp.yaml and mops.toml reference examples

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: remove deleted examples from ninja_pr_checks paths filter

tokenmania, nft-creator (Motoko) and tokenmania (Rust) were removed
from master; drop their path entries to keep the filter in sync.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* chore: switch to official dfinity icp-dev-env images v0.1.0

Replace ghcr.io/marc0olo/icp-dev-env-*:dev with the now-published
ghcr.io/dfinity/icp-dev-env-*:0.1.0 in all devcontainer configs and
CI workflows. Update AGENTS.md to reflect images are live.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: clarify why icp deploy URLs don't work in Codespaces

Be specific that it's the subdomain form (<canister-id>.localhost:8000)
that breaks, and why: GitHub's TLS certificate only covers one subdomain
level. Link to the open GitHub community issue tracking this limitation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: improve URL command wording in CODESPACE.md

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat: migrate hello_world and who_am_i to icp-cli, drop Codespaces support

- dfx → icp-cli: icp.yaml, mops.toml, canister renames to backend/frontend,
  README deploy instructions updated throughout
- Remove Codespaces: drop 4 per-example devcontainers, CODESPACE.md, lifecycle
  scripts; remove Codespaces badges and references from all READMEs
- Keep root devcontainer (.devcontainer/devcontainer.json) for local VS Code use
- CI: hello_world.yml and who_am_i.yml workflows using official
  ghcr.io/dfinity/icp-dev-env-{motoko,rust}:0.1.0 images
- Makefiles with test targets for all four examples
- README improvements: icp-cli-templates pointer, example references,
  language-specific prerequisites, correct Candid regeneration commands,
  icp network stop guidance, npm run dev guidance
- AGENTS.md: updated structure, removed Codespaces instructions, fixed
  Motoko recipe SHA, added reference examples section
- ninja_pr_checks.yml: scoped to ninja-managed paths only

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: add devcontainer removal step to migration checklist

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: remove hardcoded workspaceFolder from root devcontainer

/workspaces/examples only works if the repo is cloned into a folder
named exactly "examples". Omitting it lets VS Code use whatever path
it mounts the project at, which is correct for local use.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix: remove CODESPACE.md files, fix AGENTS.md recipe SHA and prerequisites

- Remove CODESPACE.md from all four examples (Codespaces support dropped)
- Show actual pinned SHA in AGENTS.md Motoko recipe template with TODO
  comment, replacing misleading @dfinity/motoko@vX.Y.Z placeholder
- Fix prerequisite checkboxes in README template: [ ] -> [x]

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* style: use plain bullets for prerequisites instead of checkboxes

Checkbox syntax is for task tracking, not requirements lists.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* docs: clarify educational focus and acceptance criteria for new examples

New examples must demonstrate a specific ICP concept, have a clear home
in the developer documentation, and be agreed with the DX team. Random
or general-purpose examples are not accepted.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
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