rs-init
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseYou are setting up a project to use RootSpec. Start by telling the developer what you're about to do:
"I'll set up RootSpec for this project — create the spec directory, copy the framework files, and configure prerequisites (dev server, test runner, etc.). This takes a minute or two."
你正在为项目配置RootSpec以使用该框架。首先告知开发者你即将执行的操作:
"我将为该项目设置RootSpec——创建spec目录、复制框架文件,并配置前置依赖(开发服务器、测试运行器等)。这需要一两分钟时间。"
Step 1: Scan the project
步骤1:扫描项目
Understand what exists. Run these from the project root:
bash
bash "$(dirname "$0")/../rs-shared/scripts/scan-spec.sh" .
bash "$(dirname "$0")/../rs-shared/scripts/scan-project.sh" .If these paths don't resolve, find the scripts by searching for in the skills directory.
scan-spec.shBased on the output, determine the situation:
- Fresh init — no , no
.rootspec.jsondirectory. Most common case.rootspec/ - Partial init — some files exist but others are missing (interrupted previous init).
- Re-init — exists. If the version is behind the bundled framework, suggest
.rootspec.jsoninstead. Otherwise, ask the developer what they want to update. Do NOT overwrite existing spec files (01-05). You may update/rs-updateand00.AXIOMS.mdto the latest bundled versions if the developer confirms.00.FRAMEWORK.md - Already initialized — everything exists. Tell the developer and suggest instead.
/rs-spec
Report what you found before proceeding.
了解现有项目情况。在项目根目录下执行以下命令:
bash
bash "$(dirname "$0")/../rs-shared/scripts/scan-spec.sh" .
bash "$(dirname "$0")/../rs-shared/scripts/scan-project.sh" .如果这些路径无法解析,请在skills目录中搜索找到对应脚本。
scan-spec.sh根据输出判断当前场景:
- 全新初始化——不存在,也没有
.rootspec.json目录,最常见的场景。rootspec/ - 部分初始化——部分文件已存在但缺失其他文件(之前的初始化被中断)。
- 重新初始化——已存在。如果版本低于捆绑的框架版本,建议使用
.rootspec.json命令。否则询问开发者想要更新的内容。请勿覆盖已有的spec文件(01-05)。如果开发者确认,你可以将/rs-update和00.AXIOMS.md更新为最新的捆绑版本。00.FRAMEWORK.md - 已完成初始化——所有文件都已存在。告知开发者并建议使用命令。
/rs-spec
继续操作前先报告你扫描到的情况。
Step 2: Create the spec directory and base files
步骤2:创建spec目录和基础文件
Create whatever is missing:
- directory —
rootspec/mkdir -p rootspec - — copy from the bundled version at
rootspec/00.AXIOMS.md(relative to this skill's directory). Read the source file and write it to the project.../rs-shared/00.AXIOMS.md - — copy from
rootspec/00.FRAMEWORK.md. Same approach.../rs-shared/00.FRAMEWORK.md - :
rootspec/spec-status.jsonjson{ "hash": null, "validatedAt": null, "valid": false, "version": "7.0.1" } - :
rootspec/tests-status.jsonjson{ "lastRun": null, "stories": {} }
创建所有缺失的内容:
- 目录——执行
rootspec/mkdir -p rootspec - ——从该skill目录下的
rootspec/00.AXIOMS.md捆绑版本复制。读取源文件并写入到项目中。../rs-shared/00.AXIOMS.md - ——从
rootspec/00.FRAMEWORK.md复制,操作方式同上。../rs-shared/00.FRAMEWORK.md - :
rootspec/spec-status.jsonjson{ "hash": null, "validatedAt": null, "valid": false, "version": "7.0.1" } - :
rootspec/tests-status.jsonjson{ "lastRun": null, "stories": {} }
Step 3: Detect or create prerequisites
步骤3:检测或创建前置依赖
Run the detection script:
bash
bash "$(dirname "$0")/../rs-shared/scripts/detect-prerequisites.sh" .The script outputs , , , lines with detected paths or .
DEV_SERVER=PRE_COMMIT_HOOK=RELEASE_SCRIPT=VALIDATION_SCRIPT=noneRead for the full reference on what each prerequisite is.
../rs-shared/fragments/prerequisites.mdReport what was found. For missing prerequisites, tell the developer you'll create all templates and proceed unless they object:
"I'll create templates for [list missing]. These are lightweight and needed by and . Let me know if you'd rather skip any."
/rs-impl/rs-validateThen create them all. Do not present a menu of options or ask which ones to create — just create them. The developer can always delete what they don't want. needs the dev server and validation script. needs both. The pre-commit hook catches problems early. The release script is the only truly optional one, but it's cheap to create.
/rs-impl/rs-validateFor each prerequisite:
- Found → confirm with developer, record the path
- Not found → create the template
- Skipped (only if developer explicitly asks) → record
null
运行检测脚本:
bash
bash "$(dirname "$0")/../rs-shared/scripts/detect-prerequisites.sh" .脚本会输出、、、行,内容为检测到的路径或。
DEV_SERVER=PRE_COMMIT_HOOK=RELEASE_SCRIPT=VALIDATION_SCRIPT=none阅读获取每个前置依赖的完整参考说明。
../rs-shared/fragments/prerequisites.md报告检测到的结果。对于缺失的前置依赖,告知开发者你将创建所有模板并继续操作,除非他们反对:
"我将为[缺失的依赖列表]创建模板。这些模板非常轻量,是和运行所需的依赖。如果你想跳过任何项请告知我。"
/rs-impl/rs-validate然后创建所有缺失的模板。不要展示选项菜单或者询问要创建哪些,直接创建即可。开发者随时可以删除不需要的内容。需要开发服务器和验证脚本,两者都需要。pre-commit钩子可以提前发现问题,发布脚本是唯一真正可选的依赖,但创建成本很低。
/rs-impl/rs-validate针对每个前置依赖:
- 已找到→向开发者确认,记录路径
- 未找到→创建模板
- 已跳过(仅开发者明确要求时)→记录为
null
Dev server template
开发服务器模板
When creating the dev server template:
- Copy the bundled template from to
../rs-shared/scripts/dev.shin the project. Make it executable. Read the source and write it — don't generate from scratch.scripts/dev.sh - Edit the variable at the top of the copied script to match the project's actual dev command (e.g.,
DEV_CMD,npm run dev, etc.).npx vite - Add package.json scripts if exists — add
package.json,dev:start, anddev:stopentries that delegate todev:restart:scripts/dev.shIfjson"dev:start": "./scripts/dev.sh start", "dev:stop": "./scripts/dev.sh stop", "dev:restart": "./scripts/dev.sh restart"doesn't exist, tell the developer: "No package.json found — runpackage.jsonfirst if you want convenience scripts."npm init - Update .gitignore — if exists, add
.gitignoreand.dev-server.pidif not already present..dev-server.log
创建开发服务器模板时:
- 复制捆绑模板:将复制到项目的
../rs-shared/scripts/dev.sh路径,设置为可执行权限。读取源文件内容写入,不要从头生成。scripts/dev.sh - 编辑复制的脚本顶部的变量,匹配项目实际的开发命令(例如
DEV_CMD、npm run dev等)。npx vite - 添加package.json脚本:如果存在,添加
package.json、dev:start和dev:stop条目,指向dev:restart:scripts/dev.sh如果不存在json"dev:start": "./scripts/dev.sh start", "dev:stop": "./scripts/dev.sh stop", "dev:restart": "./scripts/dev.sh restart",告知开发者:"未找到package.json——如果你需要便捷脚本请先执行package.json。"npm init - 更新.gitignore:如果存在,如果
.gitignore和.dev-server.pid不在其中则添加这两项。.dev-server.log
Cypress plugin setup
Cypress插件设置
When creating the validation script template, also set up the RootSpec Cypress reporter:
- Copy the reporter from to
../rs-shared/cypress/rootspec-reporter.tsin the project.cypress/support/rootspec-reporter.ts - Wire it into — if the config exists, add the
cypress.config.tshook with the reporter. If creating a new config, include it from the start. SeesetupNodeEventsfor the exact wiring.../rs-shared/fragments/prerequisites.md
This plugin automatically updates after every Cypress run — the agent doesn't need to parse results or call scripts.
rootspec/tests-status.json创建验证脚本模板时,同时设置RootSpec Cypress报告器:
- 复制报告器:将复制到项目的
../rs-shared/cypress/rootspec-reporter.ts路径。cypress/support/rootspec-reporter.ts - 接入:如果配置文件已存在,添加带有报告器的
cypress.config.ts钩子。如果是创建新配置,初始就包含该配置。查看setupNodeEvents获取准确的接入代码。../rs-shared/fragments/prerequisites.md
该插件会在每次Cypress运行后自动更新——agent无需解析结果或调用脚本。
rootspec/tests-status.jsonStep 4: Write .rootspec.json
.rootspec.json步骤4:写入.rootspec.json
.rootspec.jsonCreate (or update) at the project root:
.rootspec.jsonjson
{
"version": "7.0.1",
"specDirectory": "rootspec",
"prerequisites": {
"devServer": null,
"preCommitHook": null,
"releaseScript": null,
"validationScript": null
}
}Fill in prerequisite values with paths or commands discovered in Step 3.
在项目根目录创建(或更新):
.rootspec.jsonjson
{
"version": "7.0.1",
"specDirectory": "rootspec",
"prerequisites": {
"devServer": null,
"preCommitHook": null,
"releaseScript": null,
"validationScript": null
}
}用步骤3中发现的路径或命令填充前置依赖的值。
Step 5: Verify and hand off
步骤5:验证并移交
Run the verification script:
bash
bash "$(dirname "$0")/../rs-shared/scripts/verify-init.sh" .If anything is reported missing, create it. Then report:
"Project initialized. Here's what was set up:
- [list files created]
- [list prerequisites configured or skipped]
Run to create your specification."
/rs-spec运行验证脚本:
bash
bash "$(dirname "$0")/../rs-shared/scripts/verify-init.sh" .如果报告有缺失内容,创建对应的文件。然后报告:
"项目初始化完成。已设置的内容如下:
- [已创建的文件列表]
- [已配置或跳过的前置依赖列表]
运行创建你的规范。"
/rs-specFocus
特殊跳转逻辑
If the developer passes an argument:
- → skip to whatever step is incomplete
"resume" - → only run Steps 3-4 (detect/create prerequisites, update .rootspec.json)
"prerequisites"
如果开发者传入了参数:
- →直接跳转到未完成的步骤
"resume" - →仅执行步骤3-4(检测/创建前置依赖,更新.rootspec.json)
"prerequisites"
Scope
权限范围
- CAN read: all project files
- CAN write: directory (including
rootspec/,spec-status.json),tests-status.json, prerequisite templates (e.g.,.rootspec.json)scripts/dev.sh - SHOULD NOT write: application source code, existing test files
- 允许读取:所有项目文件
- 允许写入:目录(包括
rootspec/、spec-status.json)、tests-status.json、前置依赖模板(例如.rootspec.json)scripts/dev.sh - 禁止写入:应用源代码、已存在的测试文件