Skip to content

chore: add svelte best practices skills#1158

Open
bmahabirbu wants to merge 2 commits intokortex-hub:mainfrom
bmahabirbu:svelte-skills
Open

chore: add svelte best practices skills#1158
bmahabirbu wants to merge 2 commits intokortex-hub:mainfrom
bmahabirbu:svelte-skills

Conversation

@bmahabirbu
Copy link
Copy Markdown
Contributor

Summary

  • Add @sveltejs/opencode as a dev dependency to provide Svelte best practices skills
  • Update postinstall script to copy skills (svelte-code-writer, svelte-core-bestpractices) from node_modules/@sveltejs/opencode/skills/ into .agents/skills/
  • Skills include Svelte 5 coding guidelines, reactivity patterns, snippets, and reference docs

Fixes #1118

Test plan

  • Run pnpm install and verify skills are copied to .agents/skills/
  • Verify svelte-code-writer/SKILL.md and svelte-core-bestpractices/SKILL.md exist after install
  • Confirm existing playwright-testing skill is unaffected

🤖 Generated with Claude Code

@bmahabirbu bmahabirbu requested a review from a team as a code owner March 24, 2026 06:05
@bmahabirbu bmahabirbu requested review from fbricon and gastoner and removed request for a team March 24, 2026 06:05
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 24, 2026

📝 Walkthrough

Walkthrough

The pull request integrates Svelte best-practices skills into the project by adding a post-install script that copies them from the @sveltejs/opencode npm package into a local .agents/skills directory, with appropriate version control exclusions configured.

Changes

Cohort / File(s) Summary
Package Configuration
package.json
Updated postinstall script to chain electron-builder install-app-deps with node scripts/copy-svelte-skills.js; added @sveltejs/opencode at ^0.1.6 to devDependencies.
Post-install Script
scripts/copy-svelte-skills.js
New Node.js script that copies Svelte skills from node_modules/@sveltejs/opencode/skills to .agents/skills using recursive filesystem copy; logs completion or skips gracefully if source does not exist.
Version Control Configuration
.gitignore
Added ignore patterns for generated skill directories: .agents/skills/svelte-code-writer/ and .agents/skills/svelte-core-bestpractices/.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding Svelte best practices skills as a development task.
Description check ✅ Passed The description is directly related to the changeset, detailing the dependency addition, postinstall script update, and skill implementation.
Linked Issues check ✅ Passed All coding requirements from issue #1118 are met: @sveltejs/opencode dependency added, postinstall script copies svelte-code-writer and svelte-core-bestpractices skills to .agents/skills.
Out of Scope Changes check ✅ Passed All changes are in scope: package.json updates, postinstall script, copy script, and .gitignore updates directly support the linked issue objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 8

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.agents/skills/svelte-core-bestpractices/references/@attach.md:
- Around line 149-155: The code example for function foo contains accidental
diff markers around the parameter and the $effect block; remove the `+++` tokens
so the signature reads `function foo(getBar)` and the inner block uses
`$effect(() => { update(node, getBar()); });` while preserving the existing
calls to veryExpensiveSetupWork(node), $effect, update, and getBar to restore a
valid, copy/pasteable example.
- Around line 28-147: Search the file for stray "(demo:" placeholders (e.g. in
the tooltip example, inline attachments block, wrapper component/Button example
and other occurrences) and replace each with a proper link to the demo page or
remove the "demo:" label entirely so the sentence reads correctly; ensure the
surrounding examples (functions like tooltip(content), the inline canvas
attachment, and the Button wrapper example) remain unchanged except for fixing
the broken "demo:" text.

In @.agents/skills/svelte-core-bestpractices/references/$inspect.md:
- Line 3: The sentence explaining $inspect is truncated and ends with "(demo:";
update the text in
.agents/skills/svelte-core-bestpractices/references/$inspect.md to complete the
sentence by either adding the missing demo link or removing the unfinished
parenthetical. Specifically, edit the paragraph mentioning the $inspect rune so
it reads as a complete statement (e.g., include a working demo URL or a
reference to an example component) and ensure the description of $inspect
tracking reactive state deeply remains clear and grammatically correct.
- Line 21: The sentence describing `$inspect` is truncated at "(demo:"—either
complete the sentence by adding the missing demo link or example code reference,
or remove the dangling "(demo:" phrase; update the markdown for `$inspect` so it
ends with a complete clause and, if adding a demo, include a valid link or
inline example that demonstrates `with` callbacks and the `"init"`/`"update"`
arguments.

In @.agents/skills/svelte-core-bestpractices/references/await-expressions.md:
- Line 117: The SSR example contains a stray diff marker around await; update
the expression in the example so the destructuring uses a plain await with the
render function (i.e., change the tokenized "+++await+++" to just await) so the
line reads the destructuring of { head, body } from await render(App)
referencing the render function and App component.
- Line 180: The sentence about effects running differently when the
experimental.async option is true is truncated; finish the thought to state the
concrete consequence (or remove the fragment). For example, update the sentence
referencing experimental.async, block effects like {`#if`} and {`#each`}, and hooks
$effect.pre / beforeUpdate to read something like: "Specifically, block effects
like {`#if` ...} and {`#each` ...} now run before an $effect.pre or beforeUpdate in
the same component, which means that in very rare situations a block effect may
observe or update DOM/state before those hooks run, potentially changing
timing-sensitive behavior." Alternatively, remove the trailing clause entirely
so the paragraph ends cleanly.

In @.agents/skills/svelte-core-bestpractices/references/snippet.md:
- Around line 56-255: Several occurrences of the placeholder text "(demo:" are
left incomplete in the snippet examples (e.g., near the {`#snippet` hello(name)}
example, the nested snippet visibility example, the countdown/blastoff examples,
the "Passing snippets to components" section with Table, the "Optional snippet
props" section, and the "Exporting snippets" section) — locate those occurrences
and either replace each "(demo:" with the correct target URL or example
reference (or a working inline demo link) or remove the stray "(demo:" text
entirely so the sentences read correctly; ensure you inspect examples
referencing snippet names like hello, x/y, blastoff/countdown, Table/header/row,
children, and the Snippet typing examples so no placeholder remains.

In `@package.json`:
- Line 67: The postinstall script in package.json currently uses the Unix-only
"cp -r"; replace it with a cross-platform copy tool (e.g., add cpx as a
devDependency) and update the "postinstall" npm script to use that tool to copy
node_modules/@sveltejs/opencode/skills/**/* into .agents/skills/ (keep the
existing electron-builder install-app-deps part). Modify the "postinstall"
script string in package.json (the "postinstall" key) and add the chosen package
to devDependencies so the copy works on Windows, macOS, and Linux.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f46f0c3b-a4b7-43d3-ad07-3c28d1b08703

📥 Commits

Reviewing files that changed from the base of the PR and between 5e429b2 and c409b2e.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • .agents/skills/svelte-code-writer/SKILL.md
  • .agents/skills/svelte-core-bestpractices/SKILL.md
  • .agents/skills/svelte-core-bestpractices/references/$inspect.md
  • .agents/skills/svelte-core-bestpractices/references/@attach.md
  • .agents/skills/svelte-core-bestpractices/references/@render.md
  • .agents/skills/svelte-core-bestpractices/references/await-expressions.md
  • .agents/skills/svelte-core-bestpractices/references/bind.md
  • .agents/skills/svelte-core-bestpractices/references/each.md
  • .agents/skills/svelte-core-bestpractices/references/hydratable.md
  • .agents/skills/svelte-core-bestpractices/references/snippet.md
  • .agents/skills/svelte-core-bestpractices/references/svelte-reactivity.md
  • package.json

@@ -0,0 +1,53 @@
> [!NOTE] `$inspect` only works during development. In a production build it becomes a noop.

The `$inspect` rune is roughly equivalent to `console.log`, with the exception that it will re-run whenever its argument changes. `$inspect` tracks reactive state deeply, meaning that updating something inside an object or array using fine-grained reactivity will cause it to re-fire (demo:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Incomplete sentence - truncated demo link.

The sentence ends abruptly with "(demo:" which appears to be a truncated reference to a demo link. This incomplete text may confuse readers.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/skills/svelte-core-bestpractices/references/$inspect.md at line 3,
The sentence explaining $inspect is truncated and ends with "(demo:"; update the
text in .agents/skills/svelte-core-bestpractices/references/$inspect.md to
complete the sentence by either adding the missing demo link or removing the
unfinished parenthetical. Specifically, edit the paragraph mentioning the
$inspect rune so it reads as a complete statement (e.g., include a working demo
URL or a reference to an example component) and ensure the description of
$inspect tracking reactive state deeply remains clear and grammatically correct.

import { render } from 'svelte/server';
import App from './App.svelte';

const { head, body } = +++await+++ render(App);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Fix the SSR example tokenization.

Line 117 contains +++await+++, which looks like a stray diff marker. The sample should use plain await.

Suggested fix
-const { head, body } = +++await+++ render(App);
+const { head, body } = await render(App);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { head, body } = +++await+++ render(App);
const { head, body } = await render(App);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/skills/svelte-core-bestpractices/references/await-expressions.md at
line 117, The SSR example contains a stray diff marker around await; update the
expression in the example so the destructuring uses a plain await with the
render function (i.e., change the tokenized "+++await+++" to just await) so the
line reads the destructuring of { head, body } from await render(App)
referencing the render function and App component.


## Breaking changes

Effects run in a slightly different order when the `experimental.async` option is `true`. Specifically, _block_ effects like `{#if ...}` and `{#each ...}` now run before an `$effect.pre` or `beforeUpdate` in the same component, which means that in very rare situations.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Complete the truncated sentence.

Line 180 ends mid-thought (...which means that in very rare situations.), which makes the section unclear. Please complete or remove the trailing clause.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/skills/svelte-core-bestpractices/references/await-expressions.md at
line 180, The sentence about effects running differently when the
experimental.async option is true is truncated; finish the thought to state the
concrete consequence (or remove the fragment). For example, update the sentence
referencing experimental.async, block effects like {`#if`} and {`#each`}, and hooks
$effect.pre / beforeUpdate to read something like: "Specifically, block effects
like {`#if` ...} and {`#each` ...} now run before an $effect.pre or beforeUpdate in
the same component, which means that in very rare situations a block effect may
observe or update DOM/state before those hooks run, potentially changing
timing-sensitive behavior." Alternatively, remove the trailing clause entirely
so the paragraph ends cleanly.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Add @sveltejs/opencode as a dev dependency and copy its skills
(svelte-code-writer, svelte-core-bestpractices) into .agents/skills/
as a postinstall step.

Fixes kortex-hub#1118

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Brian <bmahabir@bu.edu>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (2)
.agents/skills/svelte-core-bestpractices/references/await-expressions.md (2)

180-180: ⚠️ Potential issue | 🟡 Minor

Complete the truncated sentence.

Line 180 ends mid-thought (...which means that in very rare situations.), leaving the consequence unclear. Please complete or remove the trailing clause.

Note: This file is copied from @sveltejs/opencode. Consider either applying a patch during postinstall, fixing upstream, or reporting the issue to the package maintainers.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/skills/svelte-core-bestpractices/references/await-expressions.md at
line 180, The sentence ending with "which means that in very rare situations."
is incomplete; update the sentence in await-expressions.md to finish the thought
or remove the trailing clause — e.g., clarify the consequence by completing it
to: "which means that in very rare situations, DOM updates from block effects
may occur before `$effect.pre` or `beforeUpdate` handlers run, potentially
changing the timing assumptions in your component." Ensure you reference the
`experimental.async` option and the behavior of block effects (`{`#if` ...}`,
`{`#each` ...}`), `$effect.pre`, and `beforeUpdate` when making the change.

117-117: ⚠️ Potential issue | 🟡 Minor

Fix the SSR example tokenization.

Line 117 contains +++await+++, which appears to be stray diff markers. The example should use plain await.

🔧 Proposed fix
-const { head, body } = +++await+++ render(App);
+const { head, body } = await render(App);

Note: This file is copied from @sveltejs/opencode. Consider either applying a patch during postinstall, fixing upstream, or reporting the issue to the package maintainers.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.agents/skills/svelte-core-bestpractices/references/await-expressions.md at
line 117, Replace the stray diff markers around the await token in the SSR
example so the expression reads a normal await call; specifically, in the
example that destructures const { head, body } = +++await+++ render(App); remove
the "+++...+++" tokens so it becomes a plain await before calling render(App)
(look for the tokens "+++await+++" and the render(App) expression to locate the
exact spot).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In @.agents/skills/svelte-core-bestpractices/references/await-expressions.md:
- Line 180: The sentence ending with "which means that in very rare situations."
is incomplete; update the sentence in await-expressions.md to finish the thought
or remove the trailing clause — e.g., clarify the consequence by completing it
to: "which means that in very rare situations, DOM updates from block effects
may occur before `$effect.pre` or `beforeUpdate` handlers run, potentially
changing the timing assumptions in your component." Ensure you reference the
`experimental.async` option and the behavior of block effects (`{`#if` ...}`,
`{`#each` ...}`), `$effect.pre`, and `beforeUpdate` when making the change.
- Line 117: Replace the stray diff markers around the await token in the SSR
example so the expression reads a normal await call; specifically, in the
example that destructures const { head, body } = +++await+++ render(App); remove
the "+++...+++" tokens so it becomes a plain await before calling render(App)
(look for the tokens "+++await+++" and the render(App) expression to locate the
exact spot).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0d7264c6-0c3d-4398-b7fd-02faa03347ae

📥 Commits

Reviewing files that changed from the base of the PR and between c409b2e and 37ed7a4.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (12)
  • .agents/skills/svelte-code-writer/SKILL.md
  • .agents/skills/svelte-core-bestpractices/SKILL.md
  • .agents/skills/svelte-core-bestpractices/references/$inspect.md
  • .agents/skills/svelte-core-bestpractices/references/@attach.md
  • .agents/skills/svelte-core-bestpractices/references/@render.md
  • .agents/skills/svelte-core-bestpractices/references/await-expressions.md
  • .agents/skills/svelte-core-bestpractices/references/bind.md
  • .agents/skills/svelte-core-bestpractices/references/each.md
  • .agents/skills/svelte-core-bestpractices/references/hydratable.md
  • .agents/skills/svelte-core-bestpractices/references/snippet.md
  • .agents/skills/svelte-core-bestpractices/references/svelte-reactivity.md
  • package.json
✅ Files skipped from review due to trivial changes (9)
  • .agents/skills/svelte-core-bestpractices/references/bind.md
  • .agents/skills/svelte-core-bestpractices/references/@render.md
  • .agents/skills/svelte-core-bestpractices/references/each.md
  • .agents/skills/svelte-code-writer/SKILL.md
  • .agents/skills/svelte-core-bestpractices/references/svelte-reactivity.md
  • .agents/skills/svelte-core-bestpractices/references/$inspect.md
  • .agents/skills/svelte-core-bestpractices/references/hydratable.md
  • .agents/skills/svelte-core-bestpractices/references/@attach.md
  • .agents/skills/svelte-core-bestpractices/references/snippet.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

Copy link
Copy Markdown
Contributor

@benoitf benoitf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK the files should not be committed

as it's done as post-install step, it's done locally

package.json Outdated
"typecheck": "pnpm run typecheck:main && pnpm run typecheck:preload && pnpm run typecheck:renderer && pnpm run typecheck:preload-webview && pnpm run typecheck:extensions && pnpm run typecheck:extension-api",
"prepare": "husky install",
"postinstall": "electron-builder install-app-deps"
"postinstall": "electron-builder install-app-deps && node -e \"const fs=require('fs');fs.cpSync('node_modules/@sveltejs/opencode/skills','.agents/skills',{recursive:true})\""
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is cpy npmjs command or add a script to the scripts folder. Usually we don't inline stuff inside a script

(also require should no longer import 'fs' but 'node:fs')

… generated files

The svelte skill files from @sveltejs/opencode are generated during
postinstall and should not be committed. This replaces the inline
cp command with a proper Node.js script in scripts/ and adds the
generated directories to .gitignore.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
scripts/copy-svelte-skills.js (1)

13-22: Scope copying to the two required skills to avoid future repo drift

Lines 13-22 currently copy the entire upstream skills tree. If @sveltejs/opencode adds more skill folders, postinstall may generate new local artifacts outside your explicit ignore list.

💡 Proposed refactor (copy only required skills + validate presence)
-const source = path.resolve(__dirname, '..', 'node_modules', '@sveltejs', 'opencode', 'skills');
-const destination = path.resolve(__dirname, '..', '.agents', 'skills');
+const sourceRoot = path.resolve(__dirname, '..', 'node_modules', '@sveltejs', 'opencode', 'skills');
+const destinationRoot = path.resolve(__dirname, '..', '.agents', 'skills');
+const requiredSkills = ['svelte-code-writer', 'svelte-core-bestpractices'];

-if (!existsSync(source)) {
+if (!existsSync(sourceRoot)) {
   console.log('Skipping svelte skills copy: `@sveltejs/opencode` not installed.');
   process.exit(0);
 }

-cpSync(source, destination, { recursive: true });
-console.log('Copied svelte skills to .agents/skills/');
+for (const skill of requiredSkills) {
+  const source = path.join(sourceRoot, skill);
+  if (!existsSync(source)) {
+    throw new Error(`Missing expected skill in `@sveltejs/opencode`: ${skill}`);
+  }
+  cpSync(source, path.join(destinationRoot, skill), { recursive: true });
+}
+console.log(`Copied ${requiredSkills.join(', ')} to .agents/skills/`);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/copy-svelte-skills.js` around lines 13 - 22, The current script
copies the entire skills tree (variables source/destination and cpSync call);
change it to only copy the two required skill folders by defining an array of
required skill names, for each skill construct its source path (using
path.resolve with source base) and validate existence via existsSync, log and
exit with non-zero if any required folder is missing, and copy each required
folder individually to the destination (using cpSync or equivalent) instead of
copying the whole source folder; keep existing console messages but make them
specific per-skill and ensure destination directories are created as needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/copy-svelte-skills.js`:
- Around line 10-11: The script currently uses CommonJS require(...) for cpSync
and existsSync and path which breaks when package.json declares "type":
"module"; replace the require calls with ESM import syntax (e.g., import {
cpSync, existsSync } from 'node:fs' and import path from 'node:path' or import {
dirname } from 'node:path' as needed) so the script runs as an ES module; update
any other CommonJS usages in the file (exports/module.exports or require) to ESM
equivalents if present.

---

Nitpick comments:
In `@scripts/copy-svelte-skills.js`:
- Around line 13-22: The current script copies the entire skills tree (variables
source/destination and cpSync call); change it to only copy the two required
skill folders by defining an array of required skill names, for each skill
construct its source path (using path.resolve with source base) and validate
existence via existsSync, log and exit with non-zero if any required folder is
missing, and copy each required folder individually to the destination (using
cpSync or equivalent) instead of copying the whole source folder; keep existing
console messages but make them specific per-skill and ensure destination
directories are created as needed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7ef75154-4a3d-41fe-be8b-554c3d75464f

📥 Commits

Reviewing files that changed from the base of the PR and between 37ed7a4 and 93cb08b.

📒 Files selected for processing (3)
  • .gitignore
  • package.json
  • scripts/copy-svelte-skills.js
✅ Files skipped from review due to trivial changes (1)
  • .gitignore

Comment on lines +10 to +11
const { cpSync, existsSync } = require('node:fs');
const path = require('node:path');
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Checking module type and postinstall hook:"
jq -r '.type, .scripts.postinstall' package.json

echo
echo "Checking CommonJS usage in scripts/copy-svelte-skills.js:"
rg -n '^\s*const .*require\(' scripts/copy-svelte-skills.js

Repository: kortex-hub/kortex

Length of output: 333


Fix ESM/CJS mismatch blocking postinstall

Lines 10-11 use CommonJS require(...) in a .js file while package.json sets "type": "module", causing the install lifecycle to fail with ReferenceError: require is not defined.

💡 Proposed fix (convert script to ESM)
-const { cpSync, existsSync } = require('node:fs');
-const path = require('node:path');
+import { cpSync, existsSync } from 'node:fs';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const __filename = fileURLToPath(import.meta.url);
+const __dirname = path.dirname(__filename);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const { cpSync, existsSync } = require('node:fs');
const path = require('node:path');
import { cpSync, existsSync } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
🧰 Tools
🪛 GitHub Actions: pr-check

[error] 10-10: Postinstall failed due to ESM/CJS mismatch. ReferenceError: require is not defined in ES module scope (package.json has type: "module"). Use import or rename to .cjs.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/copy-svelte-skills.js` around lines 10 - 11, The script currently
uses CommonJS require(...) for cpSync and existsSync and path which breaks when
package.json declares "type": "module"; replace the require calls with ESM
import syntax (e.g., import { cpSync, existsSync } from 'node:fs' and import
path from 'node:path' or import { dirname } from 'node:path' as needed) so the
script runs as an ES module; update any other CommonJS usages in the file
(exports/module.exports or require) to ESM equivalents if present.

Comment on lines +10 to +11
const { cpSync, existsSync } = require('node:fs');
const path = require('node:path');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should use import + copyright

const source = path.resolve(__dirname, '..', 'node_modules', '@sveltejs', 'opencode', 'skills');
const destination = path.resolve(__dirname, '..', '.agents', 'skills');

if (!existsSync(source)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it use await / promise ?

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.

include svelte best practices skills

2 participants