ln-724-artifact-cleaner

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

ln-724-artifact-cleaner

ln-724-artifact-cleaner

Type: L3 Worker Category: 7XX Project Bootstrap Parent: ln-720-structure-migrator
Removes platform-specific artifacts from projects exported from online platforms, preparing them for production deployment.

类型: L3 Worker 分类: 7XX 项目初始化工具 父工具: ln-720-structure-migrator
从在线平台导出的项目中移除平台特定的产物,为生产部署做好准备。

Overview

概述

AspectDetails
InputProject directory, platform (auto-detect or manual)
OutputClean project without platform dependencies
PlatformsReplit, StackBlitz, CodeSandbox, Glitch
Duration~2-5 minutes
InvocationCalled from ln-720 (TRANSFORM mode, conditional) or user-invocable
Invocation conditions:
  • TRANSFORM mode only (SKIP in CREATE mode)
  • At least one platform detected
  • User confirmation before cleanup

方面详情
输入项目目录、平台(自动检测或手动指定)
输出移除平台依赖的干净项目
支持平台Replit、StackBlitz、CodeSandbox、Glitch
执行时长约2-5分钟
调用方式由ln-720在TRANSFORM模式下条件调用,或用户直接调用
调用条件:
  • 仅在TRANSFORM模式下运行(CREATE模式下跳过)
  • 检测到至少一个平台
  • 清理前需用户确认

Platform Support Matrix

平台支持矩阵

PlatformConfig FilesDirectoriesNPM PackagesBuild ConfigComments
Replit
.replit
,
replit.nix
.local/
,
.cache/
,
.upm/
@replit/*
REPL_ID
checks
// @replit
StackBlitz
.stackblitzrc
.turbo/
--Port overrides--
CodeSandbox
sandbox.config.json
.codesandbox/
--CSB env checks--
Glitch
glitch.json
,
.glitch-assets
.glitch/
,
.data/
--Glitch env vars--
Reference: platform_artifacts.md

平台配置文件目录NPM包构建配置备注
Replit
.replit
,
replit.nix
.local/
,
.cache/
,
.upm/
@replit/*
检查
REPL_ID
识别
// @replit
注释
StackBlitz
.stackblitzrc
.turbo/
--端口覆盖配置--
CodeSandbox
sandbox.config.json
.codesandbox/
--检查CSB环境变量--
Glitch
glitch.json
,
.glitch-assets
.glitch/
,
.data/
--检查Glitch环境变量--
参考文档: platform_artifacts.md

Workflow

工作流程

Phase 1: Detect & Scan
    |
    +---> 1.0 Detect platforms (auto-detect by config files)
    +---> 1.1 Scan platform-specific artifacts
    |
    v
Phase 2: Preview
    |
    v
Phase 3: Confirm
    |
    v
Phase 4: Execute (per detected platform)
    |
    +---> 4.1 Delete files/directories
    +---> 4.2 Modify package.json
    +---> 4.3 Modify build config (vite/webpack)
    +---> 4.4 Remove platform comments
    +---> 4.5 Modify .gitignore
    |
    v
Phase 5: Verify & Report

阶段1: 检测与扫描
    |
    +---> 1.0 自动检测平台(通过配置文件识别)
    +---> 1.1 扫描平台特定产物
    |
    v
阶段2: 变更预览
    |
    v
阶段3: 用户确认
    |
    v
阶段4: 执行清理(按检测到的平台)
    |
    +---> 4.1 删除文件/目录
    +---> 4.2 修改package.json
    +---> 4.3 修改构建配置(Vite/Webpack)
    +---> 4.4 移除平台专属注释
    +---> 4.5 修改.gitignore
    |
    v
阶段5: 验证与生成报告

Phase 1: Detect & Scan

阶段1:检测与扫描

Step 1.0: Platform Detection

步骤1.0:平台检测

PlatformPrimary IndicatorConfidence
Replit
.replit
file
100%
StackBlitz
.stackblitzrc
100%
CodeSandbox
sandbox.config.json
100%
Glitch
glitch.json
100%
Output:
yaml
Detected Platforms:
  - replit (confidence: 100%)
平台核心识别标识识别置信度
Replit
.replit
文件
100%
StackBlitz
.stackblitzrc
100%
CodeSandbox
sandbox.config.json
100%
Glitch
glitch.json
100%
输出示例:
yaml
Detected Platforms:
  - replit (confidence: 100%)

Step 1.1: Scan Artifacts

步骤1.1:产物扫描

Per detected platform, scan for artifacts using platform-specific detection rules.
Replit Detection Rules:
yaml
Files:
  - Glob: .replit, replit.nix, .replit.nix
  - Glob: vite-plugin-meta-images.ts (if uses REPLIT_* env vars)
Directories:
  - Glob: .local/, .cache/, .upm/, .breakpoints
Package.json:
  - Grep: "@replit/" in devDependencies
Vite Config:
  - Grep: "@replit/" imports
  - Grep: "REPL_ID" or "REPLIT_" environment checks
Code:
  - Grep: "// @replit" comments in *.tsx, *.ts, *.jsx, *.js
.gitignore:
  - Grep: "^\.replit$" line
StackBlitz/CodeSandbox/Glitch: See platform_artifacts.md for detection rules.
针对每个检测到的平台,使用平台特定的识别规则扫描产物。
Replit识别规则:
yaml
Files:
  - Glob: .replit, replit.nix, .replit.nix
  - Glob: vite-plugin-meta-images.ts (if uses REPLIT_* env vars)
Directories:
  - Glob: .local/, .cache/, .upm/, .breakpoints
Package.json:
  - Grep: "@replit/" in devDependencies
Vite Config:
  - Grep: "@replit/" imports
  - Grep: "REPL_ID" or "REPLIT_" environment checks
Code:
  - Grep: "// @replit" comments in *.tsx, *.ts, *.jsx, *.js
.gitignore:
  - Grep: "^\.replit$" line
StackBlitz/CodeSandbox/Glitch识别规则: 详见platform_artifacts.md

Scan Output Format

扫描结果格式

yaml
Scan Results:
  Platform: Replit
  Files Found: 2
    - .replit (729 bytes)
    - vite-plugin-meta-images.ts (2333 bytes)
  Directories Found: 1
    - .local/ (6 files, 589KB)
  Package Dependencies: 3
    - @replit/vite-plugin-cartographer
    - @replit/vite-plugin-dev-banner
    - @replit/vite-plugin-runtime-error-modal
  Build Config Modifications: 4
    - Import: runtimeErrorOverlay
    - Import: metaImagesPlugin
    - Plugin: runtimeErrorOverlay()
    - Block: REPL_ID conditional (lines 14-24)
  Code Comments: 10
    - button.tsx: 5 comments
    - badge.tsx: 5 comments
  Gitignore Entries: 1
    - .replit

yaml
Scan Results:
  Platform: Replit
  Files Found: 2
    - .replit (729 bytes)
    - vite-plugin-meta-images.ts (2333 bytes)
  Directories Found: 1
    - .local/ (6 files, 589KB)
  Package Dependencies: 3
    - @replit/vite-plugin-cartographer
    - @replit/vite-plugin-dev-banner
    - @replit/vite-plugin-runtime-error-modal
  Build Config Modifications: 4
    - Import: runtimeErrorOverlay
    - Import: metaImagesPlugin
    - Plugin: runtimeErrorOverlay()
    - Block: REPL_ID conditional (lines 14-24)
  Code Comments: 10
    - button.tsx: 5 comments
    - badge.tsx: 5 comments
  Gitignore Entries: 1
    - .replit

Phase 2: Preview

阶段2:变更预览

Show detailed preview of changes per platform.
yaml
Will DELETE files:
  - .replit (729 bytes)
  - vite-plugin-meta-images.ts (2333 bytes)
Will DELETE directories:
  - .local/ (6 files, 589KB)
Will MODIFY files:
  - package.json: Remove 3 @replit/* devDependencies
  - vite.config.ts: Remove 4 imports/plugins/blocks
  - 2 UI files: Remove 10 @replit comments
  - .gitignore: Remove ".replit" line

Summary: 2 files deleted, 1 directory deleted, 5 files modified

展示每个平台的详细变更预览。
yaml
将删除文件:
  - .replit (729 bytes)
  - vite-plugin-meta-images.ts (2333 bytes)
将删除目录:
  - .local/ (6 files, 589KB)
将修改文件:
  - package.json: 移除3个@replit/*开发依赖
  - vite.config.ts: 移除4个导入/插件/代码块
  - 2个UI文件: 移除10条@replit注释
  - .gitignore: 移除".replit"行

摘要: 删除2个文件,1个目录,修改5个文件

Phase 3: Confirm

阶段3:用户确认

Proceed with platform cleanup (Replit)? [Y/n]
Options:
  • Y (default): Execute cleanup
  • n: Cancel operation
  • Custom exclusions: User can specify files to skip

是否继续执行平台清理(Replit)? [Y/n]
选项:
  • Y(默认): 执行清理
  • n: 取消操作
  • 自定义排除项: 用户可指定需跳过的文件

Phase 4: Execute

阶段4:执行清理

Platform Router

平台路由

Based on detected platforms, dispatch to platform-specific cleanup. Execute sequentially if multiple platforms detected.
根据检测到的平台,分发到对应平台的清理逻辑。若检测到多个平台,则按顺序执行。

4.1 Replit Cleanup (Primary)

4.1 Replit清理(核心)

Delete files/directories:
bash
rm -f .replit replit.nix .replit.nix
rm -f vite-plugin-meta-images.ts
rm -rf .local/ .cache/ .upm/ .breakpoints
Modify package.json: Remove keys starting with
@replit/
from devDependencies.
Modify vite.config.ts:
  • Remove
    @replit/*
    imports
  • Remove Replit plugins from plugins array
  • Remove
    REPL_ID
    conditional blocks
Remove
// @replit
comments:
Grep
// @replit.*$
in
**/*.tsx
,
**/*.ts
,
**/*.jsx
,
**/*.js
.
Modify .gitignore: Remove
.replit
line.
删除文件/目录:
bash
rm -f .replit replit.nix .replit.nix
rm -f vite-plugin-meta-images.ts
rm -rf .local/ .cache/ .upm/ .breakpoints
修改package.json: 从devDependencies中移除所有以
@replit/
开头的依赖项。
修改vite.config.ts:
  • 移除
    @replit/*
    相关导入
  • 从plugins数组中移除Replit插件
  • 移除
    REPL_ID
    相关条件代码块
移除
// @replit
注释:
**/*.tsx
**/*.ts
**/*.jsx
**/*.js
文件中查找并移除
// @replit.*$
注释。
修改.gitignore: 移除
.replit
对应的行。

4.2 StackBlitz Cleanup

4.2 StackBlitz清理

bash
rm -f .stackblitzrc
rm -rf .turbo/  # Only if not used in production
bash
rm -f .stackblitzrc
rm -rf .turbo/  # 仅在未用于生产环境时删除

4.3 CodeSandbox Cleanup

4.3 CodeSandbox清理

bash
rm -f sandbox.config.json
rm -rf .codesandbox/
Remove
"sandbox"
field from package.json (if exists).
bash
rm -f sandbox.config.json
rm -rf .codesandbox/
从package.json中移除
sandbox
字段(若存在)。

4.4 Glitch Cleanup

4.4 Glitch清理

bash
rm -f glitch.json .glitch-assets
rm -rf .glitch/
bash
rm -f glitch.json .glitch-assets
rm -rf .glitch/

.data/ - ASK USER before deleting (may contain important data)

.data/ - 删除前需询问用户(可能包含重要数据)

Remove Glitch env var checks (`PROJECT_DOMAIN`, `ASSETS_URL`) from server code.

---
从服务端代码中移除Glitch环境变量检查(`PROJECT_DOMAIN`、`ASSETS_URL`)。

---

Phase 5: Verify & Report

阶段5:验证与生成报告

yaml
Cleanup Complete!

Platforms Cleaned: Replit

Deleted:
  - .replit
  - vite-plugin-meta-images.ts
  - .local/ (6 files)

Modified:
  - package.json (removed 3 dependencies)
  - vite.config.ts (removed 4 imports/plugins)
  - button.tsx (removed 5 comments)
  - badge.tsx (removed 5 comments)
  - .gitignore (removed 1 line)

Next Steps:
  1. Run `npm install` to update package-lock.json
  2. Run `npm run build` to verify build works
  3. Commit: git add . && git commit -m "chore: remove platform artifacts"

yaml
清理完成!

已清理平台: Replit

已删除:
  - .replit
  - vite-plugin-meta-images.ts
  - .local/ (6 files)

已修改:
  - package.json (移除3个依赖)
  - vite.config.ts (移除4个导入/插件)
  - button.tsx (移除5条注释)
  - badge.tsx (移除5条注释)
  - .gitignore (移除1行)

后续步骤:
  1. 执行`npm install`更新package-lock.json
  2. 执行`npm run build`验证构建正常
  3. 提交变更: git add . && git commit -m "chore: remove platform artifacts"

Edge Cases

边缘情况处理

CaseHandling
No platform artifacts foundReport "Project is clean" and exit
Multiple platforms detectedClean each sequentially, separate reports
Project uses Webpack (not Vite)Search
webpack.config.*
instead
No package.jsonSkip NPM cleanup phase
.data/
directory (Glitch)
Ask user before deleting (may contain data)

场景处理方式
未检测到平台产物报告“项目已清理完成”并退出
检测到多个平台按顺序清理每个平台,生成独立报告
项目使用Webpack(而非Vite)搜索
webpack.config.*
文件进行处理
无package.json文件跳过NPM依赖清理阶段
存在
.data/
目录(Glitch)
删除前询问用户(可能包含用户数据)

Error Handling

错误处理

ErrorAction
Permission deniedLog error, suggest
chmod
or admin rights
File in useRetry after delay, then warn user
JSON parse errorLog error, suggest manual fix
Build config syntax errorLog error, suggest manual fix

错误类型处理措施
权限不足记录错误,建议用户使用
chmod
提升权限或使用管理员权限运行
文件被占用延迟后重试,若仍失败则向用户发出警告
JSON解析错误记录错误,建议用户手动修复
构建配置语法错误记录错误,建议用户手动修复

Integration

集成方式

With ln-720-structure-migrator

与ln-720-structure-migrator集成

Called conditionally in TRANSFORM mode:
yaml
ln-720-structure-migrator:
  Phase 1: Detect project type + platform
  Phase 2: Clean artifacts (ln-724-artifact-cleaner)  # CONDITIONAL
    Condition: Platform detected (Replit/StackBlitz/CodeSandbox/Glitch)
    Skipped if: CREATE mode OR no platform markers
  Phase 3: Restructure frontend (ln-721)
  Phase 4: Generate backend (ln-722)
  Phase 5: Generate seed data (ln-723)
在TRANSFORM模式下有条件调用:
yaml
ln-720-structure-migrator:
  阶段1: 检测项目类型与平台
  阶段2: 清理产物(调用ln-724-artifact-cleaner)  # 条件触发
    触发条件: 检测到平台(Replit/StackBlitz/CodeSandbox/Glitch)
    跳过场景: CREATE模式或未检测到平台标识
  阶段3: 重构前端(调用ln-721)
  阶段4: 生成后端(调用ln-722)
  阶段5: 生成种子数据(调用ln-723)

Standalone Usage

独立使用

User: Clean my project from platform artifacts
Claude: Invokes ln-724-artifact-cleaner

用户: 清理我的项目中的平台产物
Claude: 调用ln-724-artifact-cleaner

Critical Rules

核心规则

  • Conditional Invocation: Only run when platform artifacts detected, SKIP in CREATE mode
  • User Confirmation: Always preview and confirm before deleting
  • No Data Loss: Ask user before deleting directories that may contain user data (.data/)
  • Build Verification: Recommend
    npm run build
    after cleanup
  • Idempotent: Re-running on clean project reports "no artifacts found"

  • 条件调用: 仅在检测到平台产物时运行,CREATE模式下跳过
  • 用户确认: 清理前始终展示预览并获取用户确认
  • 无数据丢失: 删除可能包含用户数据的目录(如.data/)前需询问用户
  • 构建验证: 建议清理后执行
    npm run build
  • 幂等性: 在已清理的项目上重新运行会提示“未发现产物”

References

参考文档

  • platform_artifacts.md - Per-platform artifact catalog

Version: 2.0.0 Last Updated: 2026-02-07
  • platform_artifacts.md - 各平台产物目录

版本: 2.0.0 最后更新时间: 2026-02-07