 Skill:analysis.md 參考文件結(jié)構(gòu)全解析)
人工智能AI 應(yīng)用AI 技能RAGMCP 服務(wù)網(wǎng)頁爬蟲【免費(fèi)下載鏈接】Skill_SeekersConvert documentation websites, GitHub repositories, and PDFs into Claude AI skills with automatic conflict detection項(xiàng)目地址https://gitcode.com/gh_mirrors/sk/Skill_Seekers點(diǎn)擊查看免費(fèi)下載Jupyter Notebook.ipynb是數(shù)據(jù)科學(xué)、機(jī)器學(xué)習(xí)與實(shí)驗(yàn)性分析中最常見的代碼載體而 Skill_Seekers 的 Jupyter 抓取器Jupyter Notebook Scraper負(fù)責(zé)將其轉(zhuǎn)換為結(jié)構(gòu)化的 Claude AI Skill。tests/golden/phase2/jupyter/references/analysis.md正是該轉(zhuǎn)換管線的黃金輸出golden output參考文件它逐節(jié)呈現(xiàn)了一個(gè)分析筆記本analysis.ipynb被解析后的最終形態(tài)。本文以該文件為骨架結(jié)合倉庫源碼 jupyter_scraper.py、scraper_utils.py 與黃金測(cè)試 test_phase2_golden_jupyter.py完整講解 notebook 到 Skill 的轉(zhuǎn)換流程、參考文件的每一節(jié)如何生成、各類單元格cell如何被編碼為 Markdown以及如何用一條命令復(fù)現(xiàn)同樣的產(chǎn)物。從 .ipynb 到 Skill轉(zhuǎn)換管線一覽Skill_Seekers 的 Jupyter 支持由JupyterToSkillConverter類實(shí)現(xiàn)jupyter_scraper.py它繼承自DocumentSkillBuilder復(fù)用其加載/構(gòu)建編排、參考文件封裝與文件名解析機(jī)制但針對(duì) notebook 單元結(jié)構(gòu)重寫了內(nèi)容分類、逐節(jié)參考體、index.md與SKILL.md的生成邏輯。一次典型的轉(zhuǎn)換分為四個(gè)階段提取Extractextract_notebook()使用nbformatv4讀取一個(gè)或多個(gè).ipynb文件逐 cell 解析為結(jié)構(gòu)化的 section 字典并把中間結(jié)果落盤為{name}_extracted.jsonjupyter_scraper.py。分類Categorizecategorize_content()將全部 section 歸入一個(gè)或多個(gè)分類category分類決定了參考文件的命名與數(shù)量jupyter_scraper.py。生成參考文件每個(gè)分類對(duì)應(yīng)一個(gè)references/*.md其中analysis.md就是本文解析的對(duì)象jupyter_scraper.py。生成索引與 Skill 主文件references/index.md提供分類導(dǎo)航與統(tǒng)計(jì)SKILL.md匯總?cè)恳c(diǎn)、依賴、代碼示例與導(dǎo)航j(luò)upyter_scraper.py。analysis.md之所以被命名為analysis源于分類規(guī)則當(dāng)notebook_path指向單個(gè)文件時(shí)分類名直接取筆記本文件名去掉.ipynb后綴的 stemcategorize_content中Path(self.notebook_path).stem因此analysis.ipynb生成references/analysis.md當(dāng)輸入是目錄時(shí)則退回通用的section_*.md命名jupyter_scraper.py。參考文件的骨架Source 分節(jié)與單元格類型編碼analysis.md的最外層結(jié)構(gòu)是 5 個(gè)被---分隔的區(qū)塊每節(jié)以** Source: Section N**開頭。這與_write_reference_section()的實(shí)現(xiàn)一一對(duì)應(yīng)每個(gè) section 以---開始寫入來源標(biāo)注、標(biāo)題層級(jí)、正文、代碼樣本、輸出、錯(cuò)誤、富輸出、表格與標(biāo)簽最后再以---收尾jupyter_scraper.py。來源標(biāo)注區(qū)分了三種 cell 類型分別對(duì)應(yīng)解析階段的三個(gè)分支_parse_single_notebook中的cell_type判斷jupyter_scraper.py標(biāo)注觸發(fā)條件對(duì)應(yīng)解析函數(shù)** Source: Section N**無后綴markdown 單元格可按標(biāo)題拆分為多節(jié)_parse_markdown_cell** Source: Section N** (Code Cell [In 2])code 單元格帶執(zhí)行序號(hào)_parse_code_cell** Source: Section N** (Raw Cell)raw 單元格未渲染文本_parse_raw_cellSection 1Markdown 單元格與代碼圍欄樣本analysis.md第一節(jié)由 markdown 單元格生成## Getting Started #### Verify Setup Welcome to the analysis notebook. Installation and setup steps. bash pip install pandasTags: intro, setup其生成過程_parse_markdown_cell[jupyter_scraper.py](https://link.gitcode.com/i/d765c0917207d4997c2370e032ccdc9b#L407-L449)值得注意 - 單元格源碼按標(biāo)題行^(#{1,6})\s(.)切分為多個(gè) section## Getting Started 被提升為該節(jié)的標(biāo)題#### Verify Setup 屬于三級(jí)以上標(biāo)題被單獨(dú)收錄進(jìn) headings 子標(biāo)題列表。 - 單元格內(nèi)嵌的 bash 代碼圍欄通過 (\w*)\n(.*?) 正則提取為 code_samples并調(diào)用 score_code_quality(code, notebook_modeTrue) 計(jì)算質(zhì)量分本例為 5.0見黃金測(cè)試 [test_phase2_golden_jupyter.py](https://link.gitcode.com/i/c0d2b075a14c91556689aadbac1d2e01#L22-L37)。 - cell 級(jí)標(biāo)簽 tagsintro、setup被原樣寫入文件末尾的 *Tags: ...* 行。 Markdown 單元格的標(biāo)題結(jié)構(gòu)隨后還會(huì)向上傳遞到 SKILL.md 的 Key Concepts 區(qū)一級(jí)標(biāo)題成為 Major Topics二級(jí)標(biāo)題成為 Subtopics[jupyter_scraper.py](https://link.gitcode.com/i/d765c0917207d4997c2370e032ccdc9b#L949-L970)。 ### Section 2代碼單元格、執(zhí)行序號(hào)與輸出 markdown #### Assign: df col1 col2 0 1 3 **In [2]:** python import pandas as pd df pd.read_csv(data.csv) df.head()Output:col1 col2 0 1 3Rich output: text/html這是 code cell 的完整編碼形態(tài)對(duì)應(yīng) _parse_code_cell[jupyter_scraper.py](https://link.gitcode.com/i/d765c0917207d4997c2370e032ccdc9b#L497-L562) - **標(biāo)題推斷**_infer_code_heading() 依據(jù)首行模式自動(dòng)命名。df pd.read_csv(...) 命中賦值模式 ^(\w)\s*生成 Assign: df。其他規(guī)則還包括# 注釋 直接作為標(biāo)題、def/class 生成 Define: x、% 魔術(shù)命令生成 Magic: %timeit、! 開頭生成 Shell: cmd[jupyter_scraper.py](https://link.gitcode.com/i/d765c0917207d4997c2370e032ccdc9b#L583-L605)。 - **執(zhí)行序號(hào)**execution_count 2 被寫入代碼樣本與 section 兩級(jí)結(jié)構(gòu)在參考文件中渲染為 **In [2]:** 標(biāo)簽。 - **輸出分類**execute_result/display_data 的 text/plain 匯總為 output_text即 **Output:** 下的表格而 text/html、image/png、image/svgxml 等 MIME 被記錄到 output_display渲染為 *Rich output: text/html* 行。stream 輸出中 stderr 會(huì)歸入錯(cuò)誤列表stdout 歸入正文輸出。 - **語言檢測(cè)**代碼樣本的語言來自內(nèi)核元數(shù)據(jù) kernelspec.language / language_info.name對(duì)于未標(biāo)注語言的代碼還會(huì)用 LanguageDetector最低置信度 0.15采納閾值 0.3自動(dòng)推斷[jupyter_scraper.py](https://link.gitcode.com/i/d765c0917207d4997c2370e032ccdc9b#L319-L333)。 ### Section 3魔術(shù)命令、無執(zhí)行序號(hào)與錯(cuò)誤輸出 markdown #### Magic: %timeit python %timeit broken()Errors:NameError: name broken is not defined Traceback line 1Tags: raises-exception該節(jié)由 code cell 生成但 execution_count 為 None單元格未執(zhí)行或執(zhí)行失敗因此參考文件中不出現(xiàn) In [...] 標(biāo)簽——_write_reference_section 中只有 if ec: 為真時(shí)才寫入[jupyter_scraper.py](https://link.gitcode.com/i/d765c0917207d4997c2370e032ccdc9b#L777-L780)。 %timeit 觸發(fā) Magic: 標(biāo)題規(guī)則。error 類型輸出被解析為 ename: evalue 加清理后的 traceback移除 ANSI 轉(zhuǎn)義序列 \x1b\[[0-9;]*m寫入 output_errors 并渲染為 **Errors:** 代碼塊[jupyter_scraper.py](https://link.gitcode.com/i/d765c0917207d4997c2370e032ccdc9b#L536-L543)。cell 標(biāo)簽 raises-exception 同樣被保留。這類帶錯(cuò)誤信息的代碼單元在 Skill 中具有特殊價(jià)值它讓 Agent 能直接看到哪些寫法會(huì)拋什么異??捎糜诮虒W(xué)與避坑。 ### Section 4Raw 單元格 markdown raw front-matter contentRaw cell 是不參與渲染的原始文本常用于 front-matter、LaTeX 片段等解析最為簡(jiǎn)單_parse_raw_cell直接把source作為正文文本標(biāo)題與代碼樣本為空jupyter_scraper.py。Section 5長(zhǎng)代碼截?cái)?、子?biāo)題與雙形態(tài)表格### Modeling Results ##### Confusion Matrix Model evaluation summary with accuracy and recall metrics. python def long_example(): x0 0 ... x59 59MetricValueaccuracy0.95recall0.91| a | b | | c | d |該節(jié)覆蓋了參考文件剩余的關(guān)鍵渲染路徑 - **長(zhǎng)代碼保留與截?cái)嗖呗?*long_example() 共 60 行、超過 500 字符測(cè)試中以 LONG_CODE 構(gòu)造[test_phase2_golden_jupyter.py](https://link.gitcode.com/i/c0d2b075a14c91556689aadbac1d2e01#L18)。參考文件中**完整保留**全部代碼_write_reference_section 不做截?cái)嗟?SKILL.md 的 Code Examples 區(qū)每個(gè)樣本只展示前 500 字符并追加 ...[jupyter_scraper.py](https://link.gitcode.com/i/d765c0917207d4997c2370e032ccdc9b#L913-L915)。該樣本質(zhì)量分 9.5/10在 SKILL.md 的代碼排序中位居榜首。 - **表格渲染**_write_markdown_table 支持帶表頭與無表頭兩種形態(tài)。Metric/Value 表來自 tables 中的 {headers: [...], rows: [...]} 結(jié)構(gòu)a/b/c/d 四格表則是無表頭headers: []表格的渲染路徑專門用于驗(yàn)證無表頭分支[test_phase2_golden_jupyter.py](https://link.gitcode.com/i/c0d2b075a14c91556689aadbac1d2e01#L115-L119)。 - **質(zhì)量評(píng)分的作用**score_code_quality(..., notebook_modeTrue) 按行數(shù)、定義、導(dǎo)入、縮進(jìn)、運(yùn)算符、docstring、魔術(shù)行等維度打分并對(duì)純 %/! 單元扣分、對(duì)短片段30 字符懲罰[scraper_utils.py](https://link.gitcode.com/i/76b717b5e1db021bfa865c0a00f7559b#L70-L132)。分?jǐn)?shù)進(jìn)入 SKILL.md 的代碼示例排序幫助 Agent 優(yōu)先參考更像正經(jīng)代碼的單元。 ## 參考文件之外的完整 Skill 產(chǎn)物 analysis.md 不是孤立的文件它與 references/index.md 和 SKILL.md 組成完整產(chǎn)物三者可在 [tests/golden/phase2/jupyter](https://link.gitcode.com/i/723e8b971234f0dae21df2c1cb9402f9) 目錄下對(duì)照查看 - **references/index.md**列出分類導(dǎo)航 [analysis](https://link.gitcode.com/i/c3d6ecebd904bd6852d5737e28d364ff) (5 sections, Sections 1-5)并輸出統(tǒng)計(jì)總節(jié)數(shù)、code/markdown/raw 單元格數(shù)、notebook 數(shù)、內(nèi)核 Python 3、語言版本 python 3.11.4、導(dǎo)入包 numpy/pandas/sklearn。索引中的鏈接通過共享的 _reference_filename 幫助函數(shù)生成與真實(shí)文件名永不漂移[jupyter_scraper.py](https://link.gitcode.com/i/d765c0917207d4997c2370e032ccdc9b#L796-L839)命名規(guī)則見 [scraper_utils.py](https://link.gitcode.com/i/76b717b5e1db021bfa865c0a00f7559b#L24-L52)。 - **SKILL.md**含 YAML front-mattername、description、Notebook 信息內(nèi)核/語言、When to Use、Section Overview、Key Concepts、Dependencies導(dǎo)入包列表、Quick Reference、按質(zhì)量分排序的 Code Examples、Notebook Statistics含語言分布與 Navigation 導(dǎo)航[jupyter_scraper.py](https://link.gitcode.com/i/d765c0917207d4997c2370e032ccdc9b#L841-L943)。 這套三文件結(jié)構(gòu)讓 Agent 可以先用 SKILL.md 快速判斷是否該用此 Skill再經(jīng)由索引或?qū)Ш竭M(jìn)入 analysis.md 這類逐節(jié)參考文件獲取完整細(xì)節(jié)。 ## 輸入分類單一筆記本、關(guān)鍵詞分類與主題自動(dòng)分桶 categorize_content() 依據(jù)輸入形態(tài)決定分類方式[jupyter_scraper.py](https://link.gitcode.com/i/d765c0917207d4997c2370e032ccdc9b#L656-L731) 1. **單一文件分支**notebook_path 是文件時(shí)以文件 stem 為唯一分類名——analysis.md 即由此產(chǎn)生黃金測(cè)試 test_jupyter_single_notebook_matches_golden 驗(yàn)證了這一分支[test_phase2_golden_jupyter.py](https://link.gitcode.com/i/c0d2b075a14c91556689aadbac1d2e01#L162-L170)。 2. **關(guān)鍵詞分類分支**配置了 categories 時(shí)按每個(gè)分類的關(guān)鍵詞在 標(biāo)題正文代碼 拼接文本中的命中次數(shù)打分section 歸屬得分最高的分類無命中則落入 other空分類會(huì)生成 section_NN.md 占位N/A 范圍。 3. **主題自動(dòng)分桶**無路徑無分類時(shí)使用內(nèi)置 _TOPIC_KEYWORDSdata_loading、data_cleaning、visualization、modeling、evaluation、feature_engineering、setup、analysis 八個(gè)主題計(jì)分得分 ≥2 才入桶否則歸入 other。測(cè)試 test_jupyter_topic_autocategorization_matches_golden 覆蓋了該分支[test_phase2_golden_jupyter.py](https://link.gitcode.com/i/c0d2b075a14c91556689aadbac1d2e01#L189-L194)。 目錄輸入還會(huì)遞歸收集所有 .ipynb自動(dòng)排除 .ipynb_checkpoints并把每個(gè) notebook 的單元格合并編號(hào)同時(shí)記錄每本 notebook 的貢獻(xiàn)與各語言代碼單元數(shù)[jupyter_scraper.py](https://link.gitcode.com/i/d765c0917207d4997c2370e032ccdc9b#L287-L314、L358-L367)。 ## 實(shí)戰(zhàn)命令行一鍵復(fù)現(xiàn) analysis.md 依據(jù) [CLI_REFERENCE.md](https://link.gitcode.com/i/7c906becd75c1682d5cb879db2e2ebdc) 與倉庫文檔Jupyter 抓取能力需要額外依賴可通過 pip install skill-seekers[jupyter] 或 pip install nbformat 安裝缺失時(shí) _check_jupyter_deps 會(huì)拋出明確指引[jupyter_scraper.py](https://link.gitcode.com/i/d765c0917207d4997c2370e032ccdc9b#L164-L171)。 bash # 單個(gè) notebook生成 references/analysis.md 同款產(chǎn)物 skill-seekers create analysis.ipynb --name>贊分享人工智能AI 應(yīng)用AI 技能RAGMCP 服務(wù)網(wǎng)頁爬蟲【免費(fèi)下載鏈接】Skill_SeekersConvert documentation websites, GitHub repositories, and PDFs into Claude AI skills with automatic conflict detection項(xiàng)目地址https://gitcode.com/gh_mirrors/sk/Skill_Seekers點(diǎn)擊查看免費(fèi)下載相關(guān)推薦Skill_Seekers Jupyter 筆記本轉(zhuǎn)換實(shí)戰(zhàn)Golden_Jupyter_Topics 參考索引與 SKILL.md 結(jié)構(gòu)解析Skill_Seekers Jupyter 筆記本轉(zhuǎn)換實(shí)戰(zhàn)Golden_Jupyter_Topics 參考索引與 SKILL.md 結(jié)構(gòu)解析 本篇技術(shù)指南以人工智能AI 應(yīng)用AI 技能RAGMCP 服務(wù)網(wǎng)頁爬蟲Skill_Seekers 的 Jupyter Notebook 轉(zhuǎn) Skill 參考索引references/index.md結(jié)構(gòu)全解析Skill_Seekers 的 Jupyter Notebook 轉(zhuǎn) Skill 參考索引references/index.md結(jié)構(gòu)全解析 Skill_Se人工智能AI 應(yīng)用AI 技能RAGMCP 服務(wù)網(wǎng)頁爬蟲Skill_Seekers 的 Jupyter 筆記本“Other”分類參考文件解析從落選內(nèi)容到完整 Skill 產(chǎn)物的構(gòu)建原理Skill_Seekers 的 Jupyter 筆記本“Other”分類參考文件解析從落選內(nèi)容到完整 Skill 產(chǎn)物的構(gòu)建原理 在 Skill_Seeker人工智能AI 應(yīng)用AI 技能RAGMCP 服務(wù)網(wǎng)頁爬蟲創(chuàng)作聲明:本文部分內(nèi)容由AI輔助生成(AIGC),僅供參考