Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions external_plugins/offline-site-packer/.zcode-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"name": "offline-site-packer",
"version": "0.1.0",
"description": "Turn a built static website into an offline copy that opens by double-clicking index.html: crawls every internal page from the home page, rewrites root-relative, pretty and extension-less links (and CSS url()/@import, srcset) to relative file paths, copies only the files used, adds an offline full-text search box (MiniSearch, ⌘K) to every page, and reports broken links, missing files, external links and pages nothing links to. Writes a folder and a zip. No server, no network.",
"description_i18n": {
"en": "Turn a built static website into an offline copy that opens by double-clicking index.html: crawls every internal page from the home page, rewrites root-relative, pretty and extension-less links (and CSS url()/@import, srcset) to relative file paths, copies only the files used, adds an offline full-text search box (MiniSearch, ⌘K) to every page, and reports broken links, missing files, external links and pages nothing links to. Writes a folder and a zip. No server, no network.",
"zh-CN": "把构建好的静态网站做成离线版,双击 index.html 就能浏览:从首页出发爬取所有站内页面,把根路径、目录式和省略扩展名的链接(以及 CSS 的 url()/@import、srcset)改成相对文件路径,只复制用到的文件,给每个页面加上离线全文搜索(MiniSearch,⌘K),并报告坏链、缺失文件、外部链接和没被链接的页面。输出文件夹和 zip。不需要服务器,不联网。"
},
"author": {
"name": "Penova",
"url": "https://github.com/ppppp2005-p"
},
"license": "MIT",
"keywords": [
"offline",
"static site",
"documentation",
"zip",
"file://",
"search",
"broken links",
"minisearch",
"离线",
"网站打包",
"文档",
"坏链检查"
],
"skills": "skills",
"mcpServers": {
"offline-site-packer": {
"type": "stdio",
"command": "node",
"args": [
"${ZCODE_PLUGIN_ROOT}/dist/server.mjs"
],
"cwd": "${ZCODE_PROJECT_DIR}",
"timeoutMs": 900000,
"env": {
"ZCODE_WORKSPACE_ROOT": "${ZCODE_PROJECT_DIR}"
}
}
},
"ui": {
"surfaces": [
{
"id": "editor",
"title": {
"zh-CN": "网站离线打包",
"en-US": "Offline Site Packer"
},
"icon": "archive",
"server": "offline-site-packer",
"resourceUri": "ui://offline-site-packer/panel.html",
"availability": "session"
}
]
}
}
21 changes: 21 additions & 0 deletions external_plugins/offline-site-packer/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 Penova

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
47 changes: 47 additions & 0 deletions external_plugins/offline-site-packer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Offline Site Packer

Turn a built **static website** (docs, help centre, product site) into an offline copy that opens by double-clicking `index.html`, with no server and no internet.

## What it does

- **Crawl**: starts at `index.html` and follows every internal link (`<a>`, `<link>`, `<script>`, `<img>`, `srcset`, `<source>`, `<video poster>`, `<iframe>`, inline styles, `<style>` blocks, CSS `url()` and `@import`).
- **Fix links for file://**:
- Root-relative (`/css/site.css`), pretty (`/guide/`) and extension-less (`/guide/install`) URLs become relative file paths (`../css/site.css`, `guide/index.html`, `guide/install.html`). Anchors are kept.
- With **Public URL** set, absolute links to the live site (`https://docs.example.com/…`) are made local too.
- **Collect files**: only pages and files that are actually used are copied. Pages and files nothing links to are listed, and can be included on request.
- **Offline search**: every page gets a search box (button or ⌘K / Ctrl+K) backed by a **MiniSearch** index stored as a JS file, so it works from `file://`.
- **Report**:
- Broken links and missing files (with the page they are on).
- External links (which need internet).
- Orphan pages and unused files.
- Scripts that use `fetch()`, which browsers block on `file://`.
- **Output**: `<site>-offline/` plus `<site>-offline.zip`. The original site is never changed.

## Usage

Ask the agent in ZCode Desktop:

- "Make an offline copy of the docs site in dist/"
- "Check this site for broken links"
- "Pack the help site into a zip that works without internet"

Or use the panel: choose the folder, optionally enter the public URL, then **Check only** or **Pack for offline**.

## Tools

| Tool | Purpose |
|---|---|
| `site_check` | Crawl and report without writing anything |
| `site_pack` | Write the offline folder (+ zip) with rewritten links and search |

## Scope (v0.1)

- Static, already-built sites only. Run your generator first (Hugo, Docusaurus, VitePress, Jekyll and so on). Sites that need a server (PHP, APIs, SPA routing without a static export) are out of scope.
- JavaScript is copied unchanged. Features that `fetch()` local data will not work from `file://`, and the report warns about them.
- External resources (CDN fonts and scripts, embedded videos) are not downloaded; they are listed as external links.
- The output folder must be outside the site folder. An existing output folder is replaced only if this plugin created it.

## Privacy, network and files

- Runs locally with no network access and no API keys.
- Reads the site folder. Writes the output folder, the zip, and `.offline-site-packer/last.json` (the last report).
47 changes: 47 additions & 0 deletions external_plugins/offline-site-packer/README_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# 网站离线打包

把构建好的**静态网站**(文档站、帮助中心、产品官网)做成离线版:双击 `index.html` 就能浏览,不需要服务器,也不需要联网。

## 功能

- **爬取**:从 `index.html` 出发,跟随所有站内链接,包括 `<a>`、`<link>`、`<script>`、`<img>`、`srcset`、`<source>`、`<video poster>`、`<iframe>`、行内样式、`<style>` 块,以及 CSS 里的 `url()` 和 `@import`。
- **修正链接,让 file:// 能打开**:
- 根路径(`/css/site.css`)、目录式(`/guide/`)和省略扩展名(`/guide/install`)的地址都改成相对文件路径,分别变成 `../css/site.css`、`guide/index.html`、`guide/install.html`;页内锚点保留。
- 填写“网站线上地址”后,指向线上站点的绝对链接(`https://docs.example.com/…`)也会改成本地路径。
- **收集文件**:只复制真正用到的页面和文件。没被链接的页面和文件会列出来,也可以选择一起打包。
- **离线搜索**:每个页面右上角都有搜索框(点击按钮或按 ⌘K / Ctrl+K)。搜索用 **MiniSearch**,索引存成 JS 文件,所以通过 `file://` 也能用。
- **报告**:
- 坏链和缺失的文件,并注明出现在哪个页面。
- 外部链接(离线时打不开)。
- 没被链接的页面和没用到的文件。
- 使用 `fetch()` 的脚本(浏览器在 `file://` 下会拦截这类请求)。
- **输出**:`<网站>-offline/` 文件夹和 `<网站>-offline.zip`。不会改动原网站。

## 用法

在 ZCode Desktop 里对 Agent 说:

- “把 dist 里的文档站做成离线版”
- “检查这个网站有没有坏链”
- “把帮助网站打包成不联网也能看的 zip”

也可以在面板里操作:选择目录,按需填写线上地址,然后点“只检查”或“生成离线包”。

## 工具

| 工具 | 作用 |
|---|---|
| `site_check` | 爬取并报告,不写入任何文件 |
| `site_pack` | 生成离线目录(和 zip),改写链接并加上搜索 |

## 范围(v0.1)

- 只支持已经构建好的静态网站。请先用你的生成器构建(Hugo、Docusaurus、VitePress、Jekyll 等)。需要服务器的网站(PHP、接口、没有静态导出的 SPA 路由)不在范围内。
- JavaScript 原样复制。脚本用 `fetch()` 读取本地数据的功能在 `file://` 下用不了,报告里会提醒。
- 外部资源(CDN 上的字体和脚本、嵌入的视频)不会下载,会作为外部链接列出。
- 输出目录必须在网站目录之外。已存在的输出目录只有在是本插件生成的情况下才会被覆盖。

## 隐私、网络和文件

- 本地运行,不联网,不需要 API 密钥。
- 读取网站目录;写入输出目录、zip 和 `.offline-site-packer/last.json`(上次的报告)。
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: offline-site-packer
description: 把构建好的静态网站做成双击 index.html 就能看的离线版(改相对链接、收集资源、离线全文搜索、坏链与外链报告、输出文件夹 + zip)。用户提到“网站离线 / 离线文档 / 打包网站 / 检查坏链 / 不联网也能看”时使用。
---

# 网站离线打包

1. 找到构建好的网站目录(含 index.html,常见的是 `dist/`、`public/`、`build/`、`_site/`)。如果只有源码,先运行项目的构建命令。
2. 先用 `site_check({dir, baseUrl?})` 检查。如果知道网站的线上地址,就填到 `baseUrl`,这样指向线上站点的绝对链接会按站内链接处理。
3. 把报告里的问题告诉用户:坏链(在哪个页面、指向哪里)、缺失的文件、外部链接(离线时打不开)、没被链接的页面、用了 fetch() 的脚本。用户想修就修改源站,再重新构建。
4. 用 `site_pack({dir, baseUrl?, out?, includeUnlinked?, search?})` 生成 `<网站>-offline/` 文件夹和 zip。
5. 告诉用户:直接双击 `<网站>-offline/index.html` 就能浏览,按 ⌘K / Ctrl+K 搜索;要分享的话,发 zip 文件即可。
50 changes: 50 additions & 0 deletions marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -1673,6 +1673,56 @@
"把上一个 Hi3D 任务生成的模型按角色拆分成部件"
]
}
},
{
"name": "offline-site-packer",
"componentTypes": [
"ui"
],
"source": "./external_plugins/offline-site-packer",
"displayName": "Offline Site Packer",
"displayName_i18n": {
"en": "Offline Site Packer",
"zh-CN": "网站离线打包"
},
"description": "Turn a built static website into an offline copy that opens by double-clicking index.html: crawls every internal page from the home page, rewrites root-relative, pretty and extension-less links (and CSS url()/@import, srcset) to relative file paths, copies only the files used, adds an offline full-text search box (MiniSearch, ⌘K) to every page, and reports broken links, missing files, external links and pages nothing links to. Writes a folder and a zip. No server, no network.",
"description_i18n": {
"en": "Turn a built static website into an offline copy that opens by double-clicking index.html: crawls every internal page from the home page, rewrites root-relative, pretty and extension-less links (and CSS url()/@import, srcset) to relative file paths, copies only the files used, adds an offline full-text search box (MiniSearch, ⌘K) to every page, and reports broken links, missing files, external links and pages nothing links to. Writes a folder and a zip. No server, no network.",
"zh-CN": "把构建好的静态网站做成离线版,双击 index.html 就能浏览:从首页出发爬取所有站内页面,把根路径、目录式和省略扩展名的链接(以及 CSS 的 url()/@import、srcset)改成相对文件路径,只复制用到的文件,给每个页面加上离线全文搜索(MiniSearch,⌘K),并报告坏链、缺失文件、外部链接和没被链接的页面。输出文件夹和 zip。不需要服务器,不联网。"
},
"version": "0.1.0",
"author": {
"name": "Penova",
"url": "https://github.com/ppppp2005-p"
},
"license": "MIT",
"category": "utilities",
"keywords": [
"offline",
"static site",
"documentation",
"zip",
"file://",
"search",
"broken links",
"minisearch",
"离线",
"网站打包",
"文档",
"坏链检查"
],
"examplePrompts": [
"Make an offline copy of the docs site in dist/",
"Check this site for broken links",
"Pack the help site into a zip that works without internet"
],
"examplePrompts_i18n": {
"zh-CN": [
"把 dist 里的文档站做成离线版",
"检查这个网站有没有坏链",
"把帮助网站打包成不联网也能看的 zip"
]
}
}
]
}
Loading