bascik-migrate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseMigrating to Bascik
迁移到 Bascik
Requires the skill for component rules and the skill for build-time data.
bascikbascik-scriptsTo have coding agents refactor a live site to production parity at every breakpoint and 100 in all five Lighthouse categories, install the opt-in skill () and read .
bascik-refactornpx skills add bascikdev/bascik --skill bascik-refactornode <skills-dir>/bascik/scripts/read-doc.mjs /how-to/agent-migration需要 skill 提供 component 规则,并需要 skill 提供构建时数据。
bascikbascik-scripts如需让编码 Agent 重构线上网站,使其在每个断点都达到生产级一致性,并在 Lighthouse 的全部五个类别中取得 100 分,请安装需要主动启用的 skill(),并阅读 。
bascik-refactornpx skills add bascikdev/bascik --skill bascik-refactornode <skills-dir>/bascik/scripts/read-doc.mjs /how-to/agent-migrationProcedure
步骤
- Inventory. List every URL, shared layout region (tags, header, footer, nav), repeated widget, data source, and client behavior. Run
<head>if Bascik components already exist.node <skills-dir>/bascik/scripts/list-components.mjs - Read the framework guide. (
node <skills-dir>/bascik/scripts/read-doc.mjs /switch/from-<framework>,react,next,vue,svelte,astro,eleventy,hugo). Read it before writing any code; it maps each framework feature to its Bascik equivalent.wordpress - Pages first. One per URL in
.html, each with its ownsrc/pages/,<html>, and<head>. Parameterized URLs become dynamic route templates.<body> - Extract components. Each page ends up as a list of tags, not a pasted block of the old site's HTML. Shared head becomes ; header, footer, and nav become components; each section with a nameable job (hero, pricing, reviews, signup form) becomes a component; repeated widgets become one component with props and slots. Follow the old site's component boundaries where they are sound, but do not copy wrappers that only existed for the framework (providers, layout shells, one-element components) or props threaded through layers: use a slot instead. Use
<site-head />(in thenew-component.mjsskill) for the folder layout, and thebascikskill for where to split. Keep or improve the semantics. Carry over every semantic element the old site has (bascik-components,<nav>,<header>,<main>,<article>,<button>, heading levels), and never turn semantic markup into<label>s to make a component fit. Make each component's root the element for its job (a nav component's root is the<div>, not a<nav>around it), and replace framework div soup with the right element where it is safe: a clickable<div>becomes a<div>, a list of links becomes a<button type="button">. Checklist:<ul>.node <skills-dir>/bascik/scripts/read-doc.mjs /component-best-practices#use-htmls-elements - Keep TypeScript. A TypeScript source site stays TypeScript: component logic moves to a companion or an inline
.tsand keeps its types (prop types become the<script type="text/typescript">comment and the types of what the script reads), and data loaders become typed@bascikhelpers (beside the component or page that uses them, or in.tswhen several share them, step 8). A JavaScript site gets TypeScript for every new file unless the person says otherwise. Erasable syntax works with no setup; forsrc/lib/, decorators, or npm packages in the browser, use esbuild (theenumsnippet in thescripts.typescriptskill). Docs:bascik,/scoped-javascript#typescript-in-component-scripts,/configuration#scriptstypescript./how-to/bundling-npm-packages - Move styles. Delete framework scoped-style mechanisms and put the CSS in each component's companion . Class names stay the same; Bascik scopes them. Global styles go to
.css.src/pages/css/styles.css - Move behavior. Replace state and effects with a TypeScript script per component, targeting elements by . Prefer HTML and CSS solutions where they exist: a framework disclosure becomes
id, a modal becomes<details>, a dropdown becomes<dialog>. Attach click handlers topopoverand<button>elements, not to<a>s, and put state a screen reader needs in ARIA attributes (<div>,aria-expanded).aria-pressed - Move data. Framework data loaders become scripts that call typed helpers. Put each module (data, helper, types) next to its one user: in the component's folder, imported with
data-bascik-build, or beside the one page that uses it as a./faqs.tsfile. Content lives with the component that renders it; a page that also needs it (JSON-LD) imports it from the component's folder. Only modules several components or pages share go in.ts. Do not copy the old site'ssrc/lib/orlib/folder as it is: per-route data parked there moves beside its user, anddata/reports aaudit-components.mjsmodule with one user. Every script and helper builds its markup withsrc/lib/fromhtml(@bascik/bascik/htmlfor trusted or sanitized HTML,raw()for JSON-LD); never port or write an escaper of your own.json() - Verify. and
node <skills-dir>/bascik/scripts/verify.mjs --build(exit 0, or each kept warning explained), then compare old and new pages URL by URL. Do not copy confirmed responsive defects: test short portrait and landscape heights, measure text/header/section/CTA bounds, fix the owning constraint and add failing-before/passing-after tests across shared routes. Preserve unaffected layouts and record each intentional correction. Readnode <skills-dir>/bascik/scripts/audit-components.mjsfor the investigation and parity-review procedure.read-doc.mjs /how-to/agent-migration#finding-responsive-defects
- 盘点。 列出所有 URL、共享布局区域(标签、header、footer、nav)、重复使用的 widget、数据源和客户端行为。如果已经存在 Bascik component,请运行
<head>。node <skills-dir>/bascik/scripts/list-components.mjs - 阅读框架指南。 运行 (
node <skills-dir>/bascik/scripts/read-doc.mjs /switch/from-<framework>、react、next、vue、svelte、astro、eleventy、hugo)。编写任何代码前先阅读该指南;它会将每个框架特性映射到对应的 Bascik 等价机制。wordpress - 先处理页面。 在 中为每个 URL 创建一个
src/pages/文件,每个文件都包含自己的.html、<html>和<head>。带参数的 URL 转换为动态路由模板。<body> - 提取 component。 最终每个页面应由一组 tag 组成,而不是直接粘贴旧站点的 HTML。共享的 head 变为 ;header、footer 和 nav 变为 component;每个承担明确任务的 section(hero、pricing、reviews、signup form)变为 component;重复使用的 widget 变为一个带 props 和 slots 的 component。旧站点中合理的 component 边界应予以沿用,但不要复制仅因框架而存在的 wrapper(providers、layout shell、单元素 component),也不要复制跨多层传递的 props:应改用 slot。使用
<site-head />(位于new-component.mjsskill 中)创建文件夹结构,并使用bascikskill 确定拆分位置。 保留或改进语义。 迁移旧站点中的每个语义元素(bascik-components、<nav>、<header>、<main>、<article>、<button>、标题层级),绝不能为了适配 component 而将语义化 markup 改成<label>。让每个 component 的根元素成为与其职责对应的元素(nav component 的根元素应为<div>,而不是在外面包一个<nav>),并在安全的情况下用正确元素替换框架式 div 堆叠:可点击的<div>改为<div>,链接列表改为<button type="button">。检查清单:<ul>。node <skills-dir>/bascik/scripts/read-doc.mjs /component-best-practices#use-htmls-elements - 保留 TypeScript。 TypeScript 源站继续保持 TypeScript:component 逻辑移至配套 文件,或内联
.ts,并保留其类型(prop 类型变为<script type="text/typescript">注释以及脚本所读取内容的类型),data loader 变为带类型的@bascikhelper(放在使用它的 component 或页面旁;若多个位置共享,则依据步骤 8 放入.ts)。JavaScript 站点中的每个新文件都应使用 TypeScript,除非用户另有说明。TypeScript 的可擦除语法无需任何配置即可使用;对于浏览器中的src/lib/、decorators 或 npm 包,使用 esbuild(enumskill 中的bascik片段)。文档:scripts.typescript、/scoped-javascript#typescript-in-component-scripts、/configuration#scriptstypescript。/how-to/bundling-npm-packages - 迁移样式。 删除框架的作用域样式机制,将 CSS 放入每个 component 的配套 文件。class 名称保持不变;Bascik 会自动限定其作用域。全局样式放入
.css。src/pages/css/styles.css - 迁移行为。 用每个 component 专属的 TypeScript 脚本替换 state 和 effects,并通过 定位元素。只要 HTML 和 CSS 提供了相应方案,就优先使用:框架中的 disclosure 改为
id,modal 改为<details>,dropdown 改为<dialog>。将 click handler 绑定到popover和<button>,不要绑定到<a>;屏幕阅读器需要感知的状态放入 ARIA 属性(<div>、aria-expanded)。aria-pressed - 迁移数据。 框架 data loader 变为调用带类型 helper 的 脚本。将每个模块(data、helper、types)放在其唯一使用方旁边:放在 component 文件夹中并通过
data-bascik-build导入,或作为./faqs.ts文件放在使用它的页面旁。内容与渲染它的 component 放在一起;如果页面也需要该内容(例如 JSON-LD),则从 component 文件夹导入。只有被多个 component 或页面共享的模块才放入.ts。不要原样复制旧站点的src/lib/或lib/目录:停放在该目录中的单路由数据应移到其使用方旁边,而data/会报告只有一个使用方的audit-components.mjs模块。每个脚本和 helper 都应使用src/lib/中的@bascik/bascik/html构建 markup(可信或经过安全净化的 HTML 使用html,JSON-LD 使用raw());绝不要移植或自行编写 escaper。json() - 验证。 运行 和
node <skills-dir>/bascik/scripts/verify.mjs --build(退出码为 0,或逐项说明保留 warning 的原因),然后逐个 URL 对比新旧页面。不要复制已确认存在的响应式缺陷:测试高度较小的纵向和横向视口,测量文本、header、section 和 CTA 的边界,修复引发问题的约束条件,并在共享路由上添加修复前失败、修复后通过的测试。保留未受影响的布局,并记录每项有意进行的修正。阅读node <skills-dir>/bascik/scripts/audit-components.mjs,了解调查和一致性审查流程。read-doc.mjs /how-to/agent-migration#finding-responsive-defects
Cross-framework mapping
跨框架映射
| Concept | Bascik |
|---|---|
Component file ( | |
| Typed |
Scoped styles ( | Companion |
| |
| Named slots, render props, snippets | |
Props ( | |
| Prop bound to an attribute | |
| Object, array, or function props | Not possible: print one component per item from a build script, or embed JSON with |
| Typed variables in the component script, applied to the DOM by a function |
Callback props, | |
| Build time: a build script prints one branch. Runtime: toggle |
| Build-time loop in a build script, or clone a |
| File-system routing | One |
| |
| |
| Layouts | Pages keep |
| Template includes with variables, filters, loops (Nunjucks, Liquid, Go templates) | TypeScript helpers returning |
Content collections ( | One helper ( |
API routes ( | |
| |
| RSS/Atom feeds | A |
| Image optimization, syntax highlighting | Not built in; add your own build step |
| 概念 | Bascik |
|---|---|
Component 文件( | |
| 带类型的 |
作用域样式( | 自动限定作用域的配套 |
| |
| 具名 slot、render props、snippets | 在模板中使用 |
Props( | |
| Prop 绑定到 attribute | |
| 对象、数组或函数 props | 不支持:在 build script 中为每个 item 输出一个 component,或嵌入 JSON: |
| component script 中带类型的变量,再由函数将其应用到 DOM |
Callback props、 | |
| 构建时:由 build script 输出一个分支。运行时:切换 |
| 在 build script 中执行构建时循环,或在运行时克隆 |
| 文件系统路由 | 在 |
| |
| 共享数据使用 |
| 布局 | 页面保留 |
| 带变量、过滤器和循环的模板 include(Nunjucks、Liquid、Go templates) | TypeScript helper 返回 |
Content collections( | 使用一个 helper(多个页面读取时放在 |
API routes( | |
| |
| RSS/Atom feeds | 使用带 |
| 图片优化、语法高亮 | 不内置;添加自己的 build step |
Gotchas that apply everywhere
适用于所有框架的注意事项
- Build every template with in scripts and helpers; JSX and Vue templates escaped for you, and
htmldoes the same for each value (and blockshtmlURLs). Delete a projectjavascript:instead of porting it;escapeHtmlreports one.audit-components.mjs - Component tag names need a hyphen.
- Named-slot wrappers are removed, so wrap headings and links in a .
<div data-bascik-slot="x"> - Elements created with get no element-selector styles. Clone a
document.createElementin the component instead.<template> - Production moves component scripts to the end of the document. Look up elements inside handlers or after ; keep pre-paint scripts (theme) in
DOMContentLoaded.<head> - Re-sync form state on after Back/Forward or reload.
pageshow - reports components printed only by build scripts as unused. That is expected.
bascik --check - Add to
"html.validate.scripts": false(or run.vscode/settings.json, which merges it in). Otherwise VS Code joins a page'sbascik initblocks into one file and reports false errors such as "A module cannot have multiple default exports".<script> - Adapt existing editor linters; do not introduce new ones by default. Once the head moves into a component and a build script, webhint and axe report a missing charset, viewport, and on source pages.
<title>leaves third-party linter configs alone. If the person uses one, preserve its settings and adapt the source exceptions inbascik init. Never add head tags back to source pages to quiet them.read-doc.mjs /testing/linting#editor-linters-read-source - Do not generate page files into . Use dynamic routes.
src/pages/ - Exclude data-reading build scripts from the cache () and watch
scripts.cache.exclude(content/).pipeline.watchPaths - Tailwind: run it as a exec script with
pre; seescoping.attributes.class: false.read-doc.mjs /libraries - Start from the examples for layout, SEO tags, a blog, and interactive widgets: in the
add-example.mjs --listskill.bascik
- 在脚本和 helper 中使用 构建所有模板。 JSX 和 Vue template 会自动进行转义,
html也会对每个值执行同样的转义(并阻止htmlURL)。删除项目中的javascript:,而不是移植它;escapeHtml会报告该函数。audit-components.mjs - Component tag 名称必须包含连字符。
- 具名 slot wrapper 会被移除,因此请使用 包裹 heading 和 link。
<div data-bascik-slot="x"> - 通过 创建的元素不会获得基于元素选择器的样式。 请改为在 component 中克隆
document.createElement。<template> - 生产环境会将 component 脚本移到文档末尾。 在 handler 内部或 之后查找元素;将 pre-paint 脚本(如 theme)保留在
DOMContentLoaded中。<head> - 在 Back/Forward 操作或 reload 后,于 事件中重新同步表单状态。
pageshow - 会将仅由 build script 输出的 component 报告为 unused。 这是预期行为。
bascik --check - 在 中添加
.vscode/settings.json(或运行"html.validate.scripts": false,它会合并此设置)。否则 VS Code 会将一个页面中的多个bascik init块合并为一个文件,并报告类似<script>的误报。"A module cannot have multiple default exports" - 调整现有编辑器 linter;默认不要引入新的 linter。 当 被移入 component 和 build script 后,webhint 和 axe 会针对源页面报告缺少 charset、viewport 和
<head>。<title>不会改动第三方 linter 配置。如果用户使用某个 linter,请保留其设置,并按bascik init调整源文件例外。不要为了消除警告而将 head 标签重新加回源页面。read-doc.mjs /testing/linting#editor-linters-read-source - 不要在 中生成页面文件。 请使用动态路由。
src/pages/ - 将读取数据的 build script 排除在 cache 之外(),并监视
scripts.cache.exclude(content/)。pipeline.watchPaths - Tailwind: 将其作为 exec script 运行,并设置
pre;参见scoping.attributes.class: false。read-doc.mjs /libraries - 从示例开始,了解布局、SEO 标签、博客和交互式 widget:使用 skill 中的
bascik。add-example.mjs --list
Existing sitemap.xml
and robots.txt
sitemap.xmlrobots.txt现有的 sitemap.xml
和 robots.txt
sitemap.xmlrobots.txt- Read both files.
- If they contain nothing Bascik would not generate (no hand-curated URLs, live rules, external sitemap index pointer, or bot-specific directives), delete them. Bascik generates fresh ones at build time. Do not copy them into
Disallowand do not disablesrc/pages/orgenerate.sitemap.generate.robots - If they contain custom directives, keep the authored file in , set the matching
src/pages/flag togenerate, and add a config comment explaining why.false - Exclude redirect-only pages from the generated sitemap with .
<meta name="bascik-sitemap" content="exclude">
Copying old files while disabling generation looks correct but freezes the sitemap at the old URL list forever.
For Astro, Eleventy, and Hugo, read the live guide with (or , ).
read-doc.mjs /switch/from-astrofrom-eleventyfrom-hugo- 读取这两个文件。
- 如果其中不包含任何 Bascik 无法自行生成的内容(没有人工维护的 URL、当前有效的 规则、外部 sitemap index 指针或针对特定 bot 的指令),则删除它们。Bascik 会在构建时生成全新的文件。不要将它们复制到
Disallow,也不要禁用src/pages/或generate.sitemap。generate.robots - 如果其中包含自定义指令,则将原有文件保留在 中,将对应的
src/pages/标志设为generate,并添加一条说明原因的 config 注释。false - 使用 将仅用于重定向的页面排除在生成的 sitemap 之外。
<meta name="bascik-sitemap" content="exclude">
复制旧文件同时禁用生成功能看似正确,但会将 sitemap 永久冻结在旧 URL 列表上。
对于 Astro、Eleventy 和 Hugo,请通过 (或 、)阅读当前指南。
read-doc.mjs /switch/from-astrofrom-eleventyfrom-hugo