惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

TaoSecurity Blog
TaoSecurity Blog
L
LINUX DO - 最新话题
Help Net Security
Help Net Security
N
News | PayPal Newsroom
www.infosecurity-magazine.com
www.infosecurity-magazine.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
The Last Watchdog
The Last Watchdog
S
Security @ Cisco Blogs
W
WeLiveSecurity
C
CXSECURITY Database RSS Feed - CXSecurity.com
Webroot Blog
Webroot Blog
T
Troy Hunt's Blog
V
Vulnerabilities – Threatpost
Google Online Security Blog
Google Online Security Blog
N
News and Events Feed by Topic
T
Threat Research - Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tor Project blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
D
Darknet – Hacking Tools, Hacker News & Cyber Security
PCI Perspectives
PCI Perspectives
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Apple Machine Learning Research
Apple Machine Learning Research
IT之家
IT之家
S
SegmentFault 最新的问题
J
Java Code Geeks
P
Privacy & Cybersecurity Law Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 【当耐特】
博客园_首页
H
Hacker News: Front Page
T
Threatpost
Jina AI
Jina AI
博客园 - Franky
月光博客
月光博客
L
LINUX DO - 热门话题
The Cloudflare Blog
H
Heimdal Security Blog
博客园 - 司徒正美
酷 壳 – CoolShell
酷 壳 – CoolShell
Cloudbric
Cloudbric
雷峰网
雷峰网
Hugging Face - Blog
Hugging Face - Blog
S
Secure Thoughts
T
Tenable Blog
I
Intezer
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

博客园 - 尘梦

centos6 安装gcc 多版本 自定义编译bulma 神通mysql模式转 mysql ai数学书籍 chromedriver 网络安全渗透测试写法 编译php需要的扩展 python 合并同列数据 组合 新的excel vue table 表格记录选中 linux wktohtmlpdf 结合/tmp路径 无法创建问题 c语言开发 php扩展 sm4 macos php 如何链接神通数据库aci layui table tr a标签倒计时 操作 刷新以后继续倒计时 使用c# 开发 php的com组件 世界级地图数据处理 及 联动效果 php 结合pcntl_fork导出excel数据 使用 python 部署chatglm2b macos 下连接php 人大金仓pdo_kdb问题 php curl 多次发送
calude code 2.188 根据cli.map还原
尘梦 · 2026-04-02 · via 博客园 - 尘梦

得益于 cli.map的sourcesContent

然后还原脚本:

const fs = require('fs');
const path = require('path');
const { execSync } = require('child_process');

const MAP_FILE = './cli.js.map';
const OUTPUT_DIR = './restored_source';

function safeWriteFile(filePath, content) {
  fs.mkdirSync(path.dirname(filePath), { recursive: true });
  fs.writeFileSync(filePath, content, 'utf8');
}

function normalizeSourcePath(source, index) {
  if (!source || typeof source !== 'string') {
    return `unknown_${index}.js`;
  }

  let normalized = source
    .replace(/^webpack:\/\//, '')
    .replace(/^file:\/\//, '')
    .replace(/^\//, '')
    .replace(/[<>:"|?*]/g, '_');

  if (!normalized.trim()) {
    normalized = `unknown_${index}.js`;
  }

  return normalized;
}

function restoreMap() {
  if (!fs.existsSync(MAP_FILE)) {
    throw new Error(`找不到文件: ${MAP_FILE}`);
  }

  const map = JSON.parse(fs.readFileSync(MAP_FILE, 'utf8'));
  const sources = Array.isArray(map.sources) ? map.sources : [];
  const sourcesContent = Array.isArray(map.sourcesContent) ? map.sourcesContent : null;

  console.log(`sources 数量: ${sources.length}`);
  console.log(`包含 sourcesContent: ${!!sourcesContent}`);

  if (!sources.length) {
    throw new Error('map 文件里没有 sources');
  }

  if (!sourcesContent) {
    throw new Error('map 文件里没有 sourcesContent,无法直接还原完整源码');
  }

  let restoredCount = 0;

  sources.forEach((source, index) => {
    const content = sourcesContent[index];

    if (content == null) {
      console.warn(`跳过 ${source},因为没有对应内容`);
      return;
    }

    const relativePath = normalizeSourcePath(source, index);
    const outputPath = path.join(OUTPUT_DIR, relativePath);

    safeWriteFile(outputPath, content);
    restoredCount++;
    console.log(`已还原: ${outputPath}`);
  });

  console.log(`完成,共还原 ${restoredCount} 个文件`);
}

function formatFiles() {
  try {
    execSync(`npx prettier --write "${OUTPUT_DIR}/**/*.{js,ts,jsx,tsx,json,css,scss,vue}"`, {
      stdio: 'inherit'
    });
  } catch (err) {
    console.warn('格式化失败');
  }
}

function main() {
  try {
    restoreMap();
    formatFiles();
  } catch (err) {
    console.error('执行失败:', err.message);
    process.exit(1);
  }
}

main();

已还原: src\utils\zodToJsonSchema.ts
已还原: src\utils\toolSearch.ts
已还原: src\services\vcr.ts
已还原: src\services\tokenEstimation.ts
已还原: src\utils\pdf.ts
已还原: src\tools\FileReadTool\limits.ts
已还原: src\tools\FileReadTool\UI.tsx
已还原: src\tools\FileReadTool\FileReadTool.ts
已还原: src\types\textInputTypes.ts
已还原: src\utils\mcpInstructionsDelta.ts
已还原: src\utils\claudeInChrome\prompt.ts
已还原: src\utils\hooks\hookEvents.ts
已还原: src\utils\hooks\AsyncHookRegistry.ts
已还原: src\utils\messagePredicates.ts
已还原: src\memdir\findRelevantMemories.ts
已还原: src\utils\attachments.ts