Study the codebase and take note of the current implementation and suggest ways to improve the code without breaking functionality
Also look into adding the following enhancements:
The plugin is taking too long to take the user to the sketch.js file after initialization
The type definitions are broken, figure out a more robust way to fetch types or either we should rely on a method that fetches the types from another repo that is responsible for fetching them
The plugin must use the cached version when 1) No new version exists 2) The user is offline. If a new version exists, prompt the user about it
Make the template sketch.js allow the user to pick between instance and global mode during project creation, this should also be configurable in the plugin options
Analyze the relevancy of our generated vim help files and suggest a better fix that updates the help files via the prjctimg/automata repo
Assistant
I'll study the codebase and the areas you flagged, then propose a concrete improvement plan.
Assistant
Diving into project creation, types, caching, templates, and help generation next.
assets/types/ is still empty until automata sync lands — create still works; tsserver types appear after that sync/plugin update.
Yes on types: automata ships bundled defs into the plugin on its sync/release cycle, so fresher types come with a plugin update. Runtime p5.js stays versioned via CDN/cache and can still differ from the shipped types—worth documenting.
Goal: skeleton + buffer open in one tick; network is background.
code
create(name, mode)
→ mkdir + write index.html, sketch.js (mode), p5.json, tsconfig, libs.js, favicon
→ cd + edit sketch.js ← NOW
→ resolve_version (cache-first)
→ ensure p5.js from versioned cache / CDN
→ copy bundled types from plugin assets
Files:lua/p5/project.lua, lua/p5/commands.lua
Split create_project into:
P.scaffold(path, opts) — sync filesystem only
P.hydrate_assets(path, version, cb) — async p5.js only
Call nvim_set_current_dir + edit right after scaffold (restore the intent of the old v0.7 “create before download” fix that regressed).
Show a single status notify when assets finish (or offline fallback used).
Tests:tests/p5/project_spec.lua — scaffold creates files without network; edit path exists before hydrate completes (mock fetch).
2. Types: ship automata-bundled ambient defs
Strategy (your choice): plugin-shipped types from automata; no per-project CDN type download.
Confirming your question:
Yes — types refresh with plugin updates (automata p5-sync copies bundled assets/types/ into p5.nvim on schedule/release).
Runtime library version is independent (p5.json + CDN/cache). Document that mismatch is possible if user pins an old/new p5 without updating the plugin.
In plugin:
Stop downloading types/p5.d.ts and types/global.d.ts from jsDelivr in download_p5_assets.
On create/setup: uv.fs_copyfile from plugin_root/assets/types/* → project assets/types/.
Ensure automata-produced bundle is present in repo (single ambient p5.d.ts or whatever automata writes today).
Tighten tsconfig.json:
skipLibCheck: true (keep)
include only bundled ambient file(s)
optional: "types": [] + triple-slash or plain include so nothing else fights ambient globals
automata (follow-up, separate PR): keep scripts/p5/types.js as source of truth; ensure workflow still copies into p5.nvim assets/types/.
Tests: project scaffold copies types; no network call for .d.ts.
3. Cache + offline + version prompt (create/setup only)
Tests: both templates written; prompt invoked when mode unset; config mode skips prompt.
5. Vim help → automata only
Reality check on committed help:
Footer: “Autogenerated by automata”
Stale p5 1.7.7 content, emoji (noisy in 'ft'=help), dual TOC styles
Local scripts/vimhelp.lua is incomplete vs what landed in doc/
pre-push runs local gen — fights automata
In p5.nvim:
Remove (or move to wiki archive note): scripts/gen-docs.sh, scripts/json-to-md.mjs, scripts/vimhelp.lua
Soften/remove .githooks/pre-push doc regen (or make it a no-op / link to automata)
Keep doc/p5-nvim.txt as hand-maintained plugin help (update when commands/config change)
Leave doc/p5-*.txt + tags as automata-owned artifacts (do not hand-edit)
README “Doc Generation”: point to prjctimg/automatap5-sync workflow; delete local pipeline docs
Adjust tests/p5/docs_spec.lua — drop local pipeline tests; keep lightweight checks that automata tags/help files exist and p5-nvim.txt has expected tags
In automata (separate PR — recommended fixes):
Issue
Fix
Stale version in pages
Always stamp from cloned p5 package.json
Emoji / #### in help
Strip emoji; use vim help sections (PARAMETERS, RETURNS) not markdown ####
Sparse tags
Emit *tag* consistently; regenerate doc/tags (helptags) in workflow
Missing modules (shape, webgpu)
Align module list with current p5 source
Copy step
Already copies docs + types into p5.nvim — add PR body “chore(docs): sync p5 vX.Y.Z”
p5-nvim.txt
Do not overwrite from automata (plugin-owned)
Optional quality: generate from p5’s official reference JSON if more accurate than raw documentation dump.
6. General code quality (non-breaking)
Do these while touching the above files:
DRY templates — one module for sketch/html/tsconfig strings.
Fix write_json/read_json contract — either allow scalars or never write them; prefer structured meta.
ensure_assets — use pinned p5.json.version first; only call latest-check when check_update and online (setup path).
Shadowed version in ensure_assets (outer unused) — clean up.
libraries.validate_download — JS-oriented; don’t use for types.
README drift — config block still mentions old console; align with cdp/view/sketch/p5.