Skip to content

Commit a94ae8b

Browse files
committed
initial attempt from copilot
1 parent 4f97ce7 commit a94ae8b

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

.github/copilot-instructions.md

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Copilot Instructions for microcode-v2
2+
3+
These instructions orient AI coding agents to be immediately productive in this repo.
4+
Keep changes minimal, consistent with existing patterns, and validate by building.
5+
6+
## Big Picture
7+
- MicroCode is a MakeCode extension app for the micro:bit V2, providing an icon-based editor that runs on-device and in web sim.
8+
- Core TypeScript sources live at repo root (e.g., `app.ts`, `editor.ts`, `interpreter.ts`, `tiles.ts`). UI assets under `assets/` drive the web UX (`assets/index.html`, `assets/css/style.scss`, loader and custom JS).
9+
- Runtime and hardware APIs come from MakeCode `pxt_modules/*` dependencies and targets configured by `pxt.json`.
10+
- The language/editor flow: tiles → parse/compile (`exprparser.ts`, `jacs.ts`) → runtime execution (`interpreter.ts`) → sensors/robot integrations (`sensors.ts`, `robot.ts`) → host/UI (`host.ts`, `navigator.ts`).
11+
12+
## Build, Serve, Deploy
13+
- Primary toolchain: MakeCode (`pxt`). Target site in `mkc.json` is `https://makecode.microbit.org/beta`.
14+
- Make targets:
15+
- `make build``pxt build`
16+
- `make deploy``pxt deploy`
17+
- `make test``pxt test` (no `testFiles` currently)
18+
- VS Code tasks:
19+
- `makecode build -d` via task "build & deploy"
20+
- `makecode serve` via task "watch & serve" (starts local web server)
21+
- Built artifacts in `built/` (e.g., `binary.js`, `codal.json`) are generated; do not hand-edit.
22+
23+
## Project Conventions
24+
- Keep one-feature-per-file changes; avoid broad refactors. Follow existing naming and file organization in `pxt.json.files`.
25+
- No inline comments unless requested; prefer small, focused PRs.
26+
- UI strings and localization live in `assets/strings/*` and `locales/tooltips.json`. Add keys consistently; avoid hardcoded text in TS.
27+
- Styles: edit `assets/css/style.scss` then ensure any pipeline that compiles CSS remains compatible with current loaders.
28+
- Assets loading: `assets/js/loader.js` initializes web assets; avoid breaking load order (`binary-en.js`, `custom.js`).
29+
30+
## Integration Points
31+
- Hardware APIs via `pxt_modules/core/*` and related modules (`radio`, `microphone`, `settings`, `datalogger`, `microgui`). Respect shim boundaries (`*.d.ts`, `*.cpp`/`*.ts`).
32+
- Display Shield is an external MakeCode package; MicroCode UI assumes that accessory when running on-device.
33+
- Jacscript/DeviceScript note: `scripts/README.md` pins to `devicescript` branch `jacs_for_microcode` at commit `66237c5b09...`. Maintain compatibility if touching `jacs.ts`/compiler-related code.
34+
35+
## Editing Patterns
36+
- Editor flow:
37+
- Tiles/blocks: `tiles.ts` and `gallery.ts` define available actions.
38+
- Editing UI: `editor.ts`, `fieldeditors.ts`, `ruleeditor.ts` manage interactions.
39+
- Parsing/Expressions: `exprparser.ts`, `decimal.ts` convert UI to runtime forms.
40+
- Execution: `interpreter.ts` coordinates evaluation, sensors (`sensors.ts`), and host (`host.ts`).
41+
- Configuration: `config.ts`, `options.ts`, `settings.ts` drive feature flags and persistence.
42+
- Navigation/UX: `home.ts`, `navigator.ts`, `tooltips.ts`, `assets/index.html` and `assets/js/*` scripts.
43+
44+
## External Workflows (Agents)
45+
- Agentic workflows in `.github/workflows/*.md` use GitHub Agentic Workflows. After editing, compile:
46+
- `gh aw compile` (or `gh aw compile <workflow-id>`) to emit `.lock.yml`.
47+
- Use `--strict` and scanners when modifying workflows: `--actionlint --zizmor --poutine`.
48+
49+
## Examples
50+
- Adding a new sensor tile:
51+
- Define tile in `tiles.ts` and `gallery.ts`.
52+
- Map to runtime in `sensors.ts` and ensure `interpreter.ts` dispatches events.
53+
- Provide localized label in `assets/strings/<lang>/` and tooltips in `locales/tooltips.json`.
54+
- Tweaking editor behavior:
55+
- Update `fieldeditors.ts` for input handling; ensure `exprparser.ts` accepts resulting tokens.
56+
- If decimal vs dots mode: see `decimal.ts` and related config in `settings.ts`.
57+
58+
## Gotchas
59+
- Do not edit `pxt_modules/*` unless you understand MakeCode shims; changes may require rebuilding native parts and break compatibility.
60+
- `pxt.json.files` list controls bundling; new TS files must be added there to be built.
61+
- Built `assets/microcode-v2.hex` is a distribution artifact; maintain via normal build/deploy workflows.
62+
- Localization folders contain many locales; keep keys aligned across languages and fallback to `en`.
63+
64+
## Quick Commands
65+
```sh
66+
make build
67+
make deploy
68+
# VS Code tasks: "build & deploy" and "watch & serve"
69+
# Compile agentic workflows after edits
70+
gh aw compile --strict --actionlint --zizmor --poutine
71+
```
72+
73+
If any section is unclear or missing (e.g., testing strategy, CSS build specifics), tell me which part you want expanded and we’ll iterate.

0 commit comments

Comments
 (0)