Skip to content

fix: make F5 work again and support koishi.yaml - #9

Merged
MaikoTan merged 3 commits into
masterfrom
maikotan-fix-launch-json-f5
Oct 5, 2026
Merged

MaikoTan merged 3 commits into
masterfrom
maikotan-fix-launch-json-f5

Conversation

@MaikoTan

@MaikoTan MaikoTan commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Why

Pressing F5 failed with Task '${defaultBuildTask}' not found, and after fixing that the Extension Development Host crashed on startup with Schema not found: .../schemata/koishi-yml.json. Separately, projects using the koishi.yaml spelling got no validation, completion, hover or go to definition at all.

Both of the F5 problems had been present since the initial commit, so nobody could run the extension locally.

Approach

Make F5 generate the schemata before compiling. schemata/*.json and snippets/*.json are generated from their .yaml sources and are gitignored, so a fresh clone has none of them. The default build task only ran tsc, so the Extension Development Host started against a missing schema. A generate schemata task now runs ahead of the watcher via dependsOn.

Stop using the ${defaultBuildTask} variable. VS Code removed support for it, so launch.json names the task directly now.

Two details worth a look during review:

  • The task label is watch: compile, not npm: watch. VS Code auto-detects package.json scripts under that exact identifier, and a duplicate makes F5 prompt for a task picker instead of running the task directly.
  • A prewatch script would not have worked. This project is on Yarn 4, which no longer runs pre/post scripts; only npm does. I verified this empirically, which is why the fix is a task chain rather than a script hook.

Widen the file matching to both spellings. The document selector and the yamlValidation fileMatch both listed only koishi.yml. Both are now brace globs (koishi.{yml,yaml}).

The obvious alternative spelling, **/koishi*.yml or **/*.yml, would have been wrong: it would apply Koishi's schema to every YAML file in a user's project. I verified the brace form against my-koishi.yml, other.yml, koishiyaml and koishi.yml.bak to confirm it stays narrow.

Test note

The existing test the selector targets koishi.yml only asserted a literal pattern string, so it would have kept passing after the glob change and silently stopped testing anything. It now asserts the new pattern, plus a check that the pattern is not widened to *.yml.

Verification

  • yarn test: 63 passing (includes a real VS Code instance), confirmed the updated selector test actually runs
  • yarn run lint and yarn run compile: clean
  • Simulated a fresh clone (removed out/ and the generated JSON) and ran the full dependsOn chain: schema generated, compiled, activate() loads successfully

One caveat: I could not launch the Extension Development Host directly to press F5 myself, so the task resolution was verified by simulating the chain VS Code runs rather than by clicking F5.

Note that a third error some people hit, Configured debug type 'extensionHost' is not supported, is unrelated to this repo: it means the built-in js-debug extension is disabled, not that launch.json is wrong. extensionHost is a valid type and is what the official generator and 63 samples in vscode-extension-samples use.

The schemata/*.json and snippets/*.json files are generated from their .yaml
sources and are gitignored, so a fresh clone has none of them. The default
build task only ran `yarn run watch` (tsc), so the Extension Development Host
started with the JSON missing and activate() threw "Schema not found".

Chain a `generate schemata` task ahead of the watcher. Note that Yarn 4 no
longer runs pre/post scripts, so a prewatch script would not have worked.
VS Code no longer supports the `${defaultBuildTask}` variable, so pressing F5
reported "Task '${defaultBuildTask}' not found". Name the task directly.

The label is "watch: compile" rather than "npm: watch" because VS Code
auto-detects package.json scripts under that same identifier; a duplicate
identifier makes F5 prompt for a task picker instead of running the task.
The document selector and the yamlValidation fileMatch both only listed
koishi.yml, so a project using the .yaml spelling got no schema validation,
completion, hover or go to definition at all.

Widen both patterns to a brace glob. Verified the brace form matches
koishi.yml and koishi.yaml in any directory while still rejecting
my-koishi.yml, other.yml and koishi.yml.bak.
@MaikoTan
MaikoTan merged commit 121f442 into master Oct 5, 2026
2 checks passed
@MaikoTan
MaikoTan deleted the maikotan-fix-launch-json-f5 branch October 5, 2026 12:27
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.

1 participant