diff --git a/README.md b/README.md index ca6fe66..b06fab6 100644 --- a/README.md +++ b/README.md @@ -73,14 +73,13 @@ Then say: `Create a new folder and help me learn [any topic]` /plugin install bloom@li-evan ``` -**Or use it in [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)**: the same skills ship as the `bloomtutor-dsh` plugin. Until it is on npm, build it from this clone: +**Or use it in [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)**: this repository is also the `bloomtutor-dsh` plugin, with the same skills: ```bash -node integrations/deepseek-harness/scripts/pack.mjs -dsh plugin --profile web add "$PWD/integrations/deepseek-harness/bloomtutor-dsh-0.1.0.tgz" +dsh plugin --profile web add github:Li-Evan/BloomTutor ``` -Details in [integrations/deepseek-harness](./integrations/deepseek-harness/PACKAGE_README.md). +Details in [integrations/deepseek-harness](./integrations/deepseek-harness/README.md). See [GUIDE.md](./GUIDE.md) for the full walkthrough. @@ -231,6 +230,7 @@ make up / make down # docker compose start / stop ``` ├── GUIDE.md # CLI usage guide +├── package.json # makes the repo the bloomtutor-dsh DeepSeek Harness plugin (no app code) ├── .env.example # configuration template ├── backend/ │ ├── app/ # FastAPI app: courses.py (course engine), knowledge*.py / coordinate.py (knowledge map), diff --git a/README.zh.md b/README.zh.md index 06dfa45..1095ca2 100644 --- a/README.zh.md +++ b/README.zh.md @@ -73,14 +73,13 @@ claude /plugin install bloom@li-evan ``` -**也可以在 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 里用**:同一套 skill 打包成了 `bloomtutor-dsh` 插件。发布到 npm 之前,先从这个 clone 打包安装: +**也可以在 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) 里用**:这个仓库本身也是 `bloomtutor-dsh` 插件,带同一套 skill: ```bash -node integrations/deepseek-harness/scripts/pack.mjs -dsh plugin --profile web add "$PWD/integrations/deepseek-harness/bloomtutor-dsh-0.1.0.tgz" +dsh plugin --profile web add github:Li-Evan/BloomTutor ``` -详见 [integrations/deepseek-harness](./integrations/deepseek-harness/PACKAGE_README.md#中文)。 +详见 [integrations/deepseek-harness](./integrations/deepseek-harness/README.md#中文)。 详见 [GUIDE.zh.md](./GUIDE.zh.md)。 @@ -230,6 +229,7 @@ make up / make down # docker compose 启动 / 停止 ``` ├── GUIDE.zh.md # CLI 模式使用说明 +├── package.json # 让仓库本身成为 DeepSeek Harness 插件 bloomtutor-dsh(不含应用代码) ├── .env.example # 配置模板 ├── backend/ │ ├── app/ # FastAPI 应用:courses.py(课程引擎)、knowledge*.py / coordinate.py(知识地图)、 diff --git a/integrations/deepseek-harness/PACKAGE_README.md b/integrations/deepseek-harness/PACKAGE_README.md deleted file mode 100644 index 6cab75e..0000000 --- a/integrations/deepseek-harness/PACKAGE_README.md +++ /dev/null @@ -1,82 +0,0 @@ -# bloomtutor-dsh - -[BloomTutor](https://github.com/Li-Evan/BloomTutor) for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness): a one-on-one AI tutor that writes a syllabus, teaches one adaptive lesson at a time, and shapes the next lesson from your notes and feedback. - -This is a community plugin. It is not made or endorsed by DeepSeek. - -[中文说明](#中文) - -## Install - -```bash -dsh plugin --profile web add bloomtutor-dsh@0.1.0 -``` - -Use `npx @deepseek-ai/dsh plugin …` if `dsh` is not on your PATH. Run the command once for each profile you use. Running it again with a newer version upgrades the plugin. - -Tested with DeepSeek Harness `0.2.2-rc.1` on Node 24. DeepSeek Harness is a developer preview; other versions may work but have not been tested. - -## Use - -Say in a chat: - -```text -Create a new folder and help me learn Rust ownership -``` - -Or name a skill: - -```text -Use the learn-feynman skill to check whether I really understand TCP congestion control -``` - -| Skill | What it does | -|-------|-------------| -| `bloom-tutor` | The full tutoring loop: syllabus → one lesson at a time → your `???` marks and feedback → next lesson → review → summary | -| `learn-deep` | Explains a new concept through all five lenses below in one pass | -| `learn-crossover` | Learn something new through what you already know | -| `learn-occam` | Decide whether something is worth learning, and how deep | -| `learn-graph` | Map a field and plan a learning path | -| `learn-prototype` | Learn by building the roughest working version, then improving it | -| `learn-feynman` | Check your understanding by explaining it back | - -The tutor keeps everything as Markdown in your workspace: a folder per topic with `syllabus.md`, `01.md`, `02.md` … and a `learning-log.jsonl` at the workspace root. - -## Which copy loads - -Skills you installed yourself win over this package when they have the same name. DeepSeek Harness looks in `/.dsh/skills`, `/.agents/skills`, `~/.dsh/skills` and `~/.agents/skills` before it looks here. If you copied `bloom-tutor` into one of those folders earlier, that copy is the one that loads. - -## Uninstall - -```bash -dsh plugin --profile web remove bloomtutor-dsh -``` - -## What it changes in DeepSeek Harness - -- `cordis.patch.yml` adds one `@deepseek-ai/dsh-skill-filesystem` provider, named `bloomtutor-plugin`, over the package's `skills/` folder. It keeps your own project and personal skill folders in view. -- Its `bundledSkillDir` value is a `!!js` expression that DeepSeek Harness runs in the host process. It only uses Node's built-in `path` and `module` helpers to find this installed package. -- The package has no tools, dependencies, install scripts, network requests or telemetry. -- The skills read and write Markdown files in your workspace. - -## 中文 - -在 DeepSeek Harness 里用 BloomTutor:一位一对一的 AI 导师,先出学习大纲,每次只讲一篇,下一篇按你的批注和反馈来调整。这是社区插件,不是 DeepSeek 官方出品。 - -安装: - -```bash -dsh plugin --profile web add bloomtutor-dsh@0.1.0 -``` - -`dsh` 不在 PATH 里时,用 `npx @deepseek-ai/dsh plugin …`。每个要用的 profile 各装一次;换成新版本号再运行一次就是升级。已在 DeepSeek Harness `0.2.2-rc.1`、Node 24 上测过。 - -装好后在对话里说「开个文件夹,帮我学 Rust 的所有权」,或者点名某个 Skill,比如「用 learn-feynman 检验一下我是不是真懂了 TCP 拥塞控制」。读课时在没看懂的地方标 `???`,读完在文末写反馈,然后说「我读完了」。 - -你自己装过的同名 Skill(`<项目>/.dsh/skills`、`<项目>/.agents/skills`、`~/.dsh/skills`、`~/.agents/skills`)优先于插件里的版本。 - -卸载:`dsh plugin --profile web remove bloomtutor-dsh`。 - -## License - -MIT diff --git a/integrations/deepseek-harness/README.md b/integrations/deepseek-harness/README.md index 631c907..06ade8d 100644 --- a/integrations/deepseek-harness/README.md +++ b/integrations/deepseek-harness/README.md @@ -1,25 +1,98 @@ -# DeepSeek Harness plugin +# BloomTutor for DeepSeek Harness -This folder builds `bloomtutor-dsh`, the npm package that brings BloomTutor's skills to [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH). Users install it with `dsh plugin --profile web add bloomtutor-dsh`; what they see is in [PACKAGE_README.md](PACKAGE_README.md), which becomes the package's README. +The BloomTutor skills as a [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH) plugin, `bloomtutor-dsh`: a one-on-one AI tutor that writes a syllabus, teaches one adaptive lesson at a time, and shapes the next lesson from your notes and feedback. -## How it works +This is a community plugin. It is not made or endorsed by DeepSeek. -The package is skills only. `package.json` declares `"dsh": { "bundle": { "patch": "./cordis.patch.yml" } }`, and the patch inserts one `@deepseek-ai/dsh-skill-filesystem` provider named `bloomtutor-plugin` whose `bundledSkillDir` is the package's `skills/` folder. DSH then lists those skills in its catalog and loads one when the model calls `skill({ name })`. +[中文说明](#中文) -The skills are not stored here. `scripts/pack.mjs` copies every folder with a `SKILL.md` from the repository's top-level [`skills/`](../../skills/) into the package at pack time, so editing a skill there changes the next release. +## Install + +```bash +dsh plugin --profile web add github:Li-Evan/BloomTutor +``` + +Use `npx @deepseek-ai/dsh plugin …` if `dsh` is not on your PATH. Run the command once for each profile you use; running it again picks up the latest version. + +Tested with DeepSeek Harness `0.2.2-rc.1` and `0.2.2-rc.3` on Node 24. DeepSeek Harness is a developer preview; other versions may work but have not been tested. + +## Use + +Say in a chat: + +```text +Create a new folder and help me learn Rust ownership +``` + +Or name a skill: + +```text +Use the learn-feynman skill to check whether I really understand TCP congestion control +``` + +| Skill | What it does | +|-------|-------------| +| `bloom-tutor` | The full tutoring loop: syllabus → one lesson at a time → your `???` marks and feedback → next lesson → review → summary | +| `learn-deep` | Explains a new concept through all five lenses below in one pass | +| `learn-crossover` | Learn something new through what you already know | +| `learn-occam` | Decide whether something is worth learning, and how deep | +| `learn-graph` | Map a field and plan a learning path | +| `learn-prototype` | Learn by building the roughest working version, then improving it | +| `learn-feynman` | Check your understanding by explaining it back | + +The tutor keeps everything as Markdown in your workspace: a folder per topic with `syllabus.md`, `01.md`, `02.md` … and a `learning-log.jsonl` at the workspace root. + +## Which copy loads + +Skills you installed yourself win over this plugin when they have the same name. DeepSeek Harness looks in `/.dsh/skills`, `/.agents/skills`, `~/.dsh/skills` and `~/.agents/skills` before it looks here. If you copied `bloom-tutor` into one of those folders earlier, that copy is the one that loads. + +## Uninstall + +```bash +dsh plugin --profile web remove bloomtutor-dsh +``` + +## What it changes in DeepSeek Harness + +- [`cordis.patch.yml`](cordis.patch.yml) adds one `@deepseek-ai/dsh-skill-filesystem` provider, named `bloomtutor-plugin`, over the repository's top-level [`skills/`](../../skills/) folder. It keeps your own project and personal skill folders in view. +- Its `bundledSkillDir` value is a `!!js` expression that DeepSeek Harness runs in the host process. It only uses Node's built-in `path` and `module` helpers to find this installed package. +- The plugin has no tools, dependencies, install scripts, network requests or telemetry. +- The skills read and write Markdown files in your workspace. + +## 中文 + +在 DeepSeek Harness 里用 BloomTutor:一位一对一的 AI 导师,先出学习大纲,每次只讲一篇,下一篇按你的批注和反馈来调整。这是社区插件,不是 DeepSeek 官方出品。 + +安装: + +```bash +dsh plugin --profile web add github:Li-Evan/BloomTutor +``` + +`dsh` 不在 PATH 里时,用 `npx @deepseek-ai/dsh plugin …`。每个要用的 profile 各装一次;再运行一次就会更新到最新版。已在 DeepSeek Harness `0.2.2-rc.1` 和 `0.2.2-rc.3`、Node 24 上测过。 + +装好后在对话里说「开个文件夹,帮我学 Rust 的所有权」,或者点名某个 Skill,比如「用 learn-feynman 检验一下我是不是真懂了 TCP 拥塞控制」。读课时在没看懂的地方标 `???`,读完在文末写反馈,然后说「我读完了」。 + +你自己装过的同名 Skill(`<项目>/.dsh/skills`、`<项目>/.agents/skills`、`~/.dsh/skills`、`~/.agents/skills`)优先于插件里的版本。 + +卸载:`dsh plugin --profile web remove bloomtutor-dsh`。 + +## For maintainers + +The package is the repository root. The root [`package.json`](../../package.json) declares `"dsh": { "bundle": { "patch": "./integrations/deepseek-harness/cordis.patch.yml" } }`, and its `files` list ships the top-level `skills/` plus this folder's patch, locale, docs and SVG icon. Installing from GitHub and installing a packed tarball therefore get the same files, and editing a skill in `skills/` changes the plugin directly. + +The root `package.json` deliberately has no `"type"` field, scripts or dependencies: it applies to the whole repository, and a `"type": "module"` there would change how Node treats every `.js` file outside `frontend/` and `site/`. | File | Role | |------|------| -| `package.json` | Package identity, the bundle declaration, display icon | +| `../../package.json` | Package identity, the bundle declaration, display icon, shipped files | | `cordis.patch.yml` | The one provider row DSH adds to a profile | -| `locale/*.json`, `docs/DETAIL*.md`, `icon.svg` | Title, description and detail page in DSH's plugin manager | -| `PACKAGE_README.md` | Published as the package README | -| `scripts/pack.mjs` | Stages the files and skills, runs `npm pack` | +| `locale/*.json`, `docs/DETAIL*.md`, `icon.svg` | Title, description, detail page and icon in DSH's plugin manager | +| `icon-180.png` | Tile image for plugin markets that only take raster icons (not shipped) | +| `scripts/pack.mjs` | Runs `npm pack` at the repository root | | `scripts/acceptance.mjs` | Installs a real DSH and checks install, load, precedence and uninstall | | `test/` | Package contract tests and the probe plugin the acceptance script mounts | -## Check it - Contract tests (no network, run in CI): ```bash @@ -30,24 +103,9 @@ Real host (downloads DSH from npm, never calls a model, needs a Node version DSH ```bash node integrations/deepseek-harness/scripts/acceptance.mjs +node integrations/deepseek-harness/scripts/acceptance.mjs --source github:Li-Evan/BloomTutor # the install-from-GitHub path markets offer ``` It works in a temporary directory with its own `DSH_HOME` and `DSH_AGENTS_HOME`, and prints a JSON receipt. If registry.npmjs.org is slow from your network, set `npm_config_registry=https://registry.npmmirror.com/`. -## Try it before it is on npm - -```bash -node integrations/deepseek-harness/scripts/pack.mjs -dsh plugin --profile web add "$PWD/integrations/deepseek-harness/bloomtutor-dsh-0.1.0.tgz" -``` - -`dsh plugin add` needs an absolute path to the tarball. - -## Release - -1. Bump `version` in `package.json` and the version in `PACKAGE_README.md`'s install commands. -2. Run the contract tests and the acceptance script. Update the tested DSH version in `PACKAGE_README.md` and `TESTED_DSH_VERSION` in `scripts/acceptance.mjs` if you tested a newer host. -3. `node integrations/deepseek-harness/scripts/pack.mjs`, then `npm publish integrations/deepseek-harness/bloomtutor-dsh-.tgz`. -4. Tag the commit `bloomtutor-dsh-v`. - -A published version never changes; ship fixes as a new version. +To release a version: bump `version` in the root `package.json`, run both checks (update `TESTED_DSH_VERSION` in `scripts/acceptance.mjs` and the tested versions above if you tested a newer host), then publish to npm from the repository root if the package is on npm. diff --git a/integrations/deepseek-harness/icon-180.png b/integrations/deepseek-harness/icon-180.png new file mode 100644 index 0000000..e27a926 Binary files /dev/null and b/integrations/deepseek-harness/icon-180.png differ diff --git a/integrations/deepseek-harness/locale/en.json b/integrations/deepseek-harness/locale/en.json index 1dd3506..4f7d423 100644 --- a/integrations/deepseek-harness/locale/en.json +++ b/integrations/deepseek-harness/locale/en.json @@ -2,6 +2,6 @@ "meta": { "title": "BloomTutor", "description": "A personal AI tutor based on Bloom's 2-sigma research: it writes a syllabus, teaches one adaptive lesson at a time, and shapes the next lesson from your notes and feedback.", - "detail": "docs/DETAIL.md" + "detail": "integrations/deepseek-harness/docs/DETAIL.md" } } diff --git a/integrations/deepseek-harness/locale/zh.json b/integrations/deepseek-harness/locale/zh.json index 330012e..fe886d2 100644 --- a/integrations/deepseek-harness/locale/zh.json +++ b/integrations/deepseek-harness/locale/zh.json @@ -2,6 +2,6 @@ "meta": { "title": "BloomTutor", "description": "基于 Bloom 2 Sigma 研究的 AI 私人导师:先给你出学习大纲,每次只讲一篇,下一篇按你的批注和反馈来调整。", - "detail": "docs/DETAIL.zh.md" + "detail": "integrations/deepseek-harness/docs/DETAIL.zh.md" } } diff --git a/integrations/deepseek-harness/scripts/acceptance.mjs b/integrations/deepseek-harness/scripts/acceptance.mjs index 417bdec..c5d820d 100644 --- a/integrations/deepseek-harness/scripts/acceptance.mjs +++ b/integrations/deepseek-harness/scripts/acceptance.mjs @@ -13,6 +13,7 @@ // DSH_VERSION=0.2.2-rc.3 node integrations/deepseek-harness/scripts/acceptance.mjs // node integrations/deepseek-harness/scripts/acceptance.mjs --dsh-runtime /abs/dir # reuse a dir where @deepseek-ai/dsh is installed // node integrations/deepseek-harness/scripts/acceptance.mjs --keep # keep the temporary directory +// node integrations/deepseek-harness/scripts/acceptance.mjs --source github:Li-Evan/BloomTutor # install from GitHub instead of the packed tarball // // Prints a JSON receipt on stdout; progress goes to stderr. @@ -22,14 +23,14 @@ import os from 'node:os'; import path from 'node:path'; import { pathToFileURL } from 'node:url'; -import { integrationRoot, listSkillNames, pack } from './pack.mjs'; +import { integrationRoot, listSkillNames, manifestPath, pack } from './pack.mjs'; export const TESTED_DSH_VERSION = '0.2.2-rc.1'; const DSH_VERSION = process.env.DSH_VERSION || TESTED_DSH_VERSION; const PROFILE = 'bloomtutor-dsh-acceptance'; const PROVIDER = 'bloomtutor-plugin'; const ROW_ID = 'bloomtutor-skill-filesystem'; -const manifest = JSON.parse(fs.readFileSync(path.join(integrationRoot, 'package.json'), 'utf8')); +const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')); const PACKAGE_NAME = manifest.name; const SKILLS = listSkillNames(); @@ -39,6 +40,10 @@ const argValue = (flag) => { }; const keep = process.argv.includes('--keep'); const reuseRuntime = argValue('--dsh-runtime'); +// What `dsh plugin add` receives: the freshly packed tarball by default, or a +// spec such as github:Li-Evan/BloomTutor to check the install-from-source path +// that plugin markets offer. +const sourceSpec = argValue('--source'); const steps = []; const scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'bloomtutor-dsh-acceptance-')); @@ -166,14 +171,14 @@ const resourceDir = (definition) => { return path.dirname(definition.path); }; -// 3. Install the tarball with the same command users run. -requireOk('plugin-add', dsh(['plugin', '--profile', PROFILE, 'add', tarball]), 'dsh plugin add'); +// 3. Install with the same command users run. +requireOk('plugin-add', dsh(['plugin', '--profile', PROFILE, 'add', sourceSpec || tarball]), 'dsh plugin add'); const profileDir = path.join(dshHome, 'profiles', PROFILE); const profileManifest = JSON.parse(fs.readFileSync(path.join(profileDir, 'package.json'), 'utf8')); if (!profileManifest.dependencies?.[PACKAGE_NAME]) { fail('plugin-add', 'profile does not depend on the package', { dependencies: profileManifest.dependencies }); } -pass('plugin-add', { profile: PROFILE, dependency: profileManifest.dependencies[PACKAGE_NAME] }); +pass('plugin-add', { profile: PROFILE, source: sourceSpec || 'packed tarball', dependency: profileManifest.dependencies[PACKAGE_NAME] }); // 4. The composed profile carries our provider row with the expected config. const dump = dsh(['--profile', PROFILE, '--dump-config']); diff --git a/integrations/deepseek-harness/scripts/pack.mjs b/integrations/deepseek-harness/scripts/pack.mjs index 3eb19d1..3aa366e 100644 --- a/integrations/deepseek-harness/scripts/pack.mjs +++ b/integrations/deepseek-harness/scripts/pack.mjs @@ -1,12 +1,13 @@ #!/usr/bin/env node // Build the bloomtutor-dsh npm tarball. // -// The skills live once, in the repository's top-level skills/ directory. This -// script stages the adapter files plus a copy of those skills in a temporary -// directory and runs `npm pack` there, so the repository never holds a second -// copy that could drift. +// The package is the repository root: its package.json declares the DSH +// bundle, and its `files` list ships the top-level skills/ plus this folder's +// patch, locale, docs and icon. So `npm pack` at the root is the whole build, +// and installing straight from GitHub (`github:Li-Evan/BloomTutor`) gets the +// same files. // -// node integrations/deepseek-harness/scripts/pack.mjs # writes ./bloomtutor-dsh-.tgz next to package.json +// node integrations/deepseek-harness/scripts/pack.mjs # writes bloomtutor-dsh-.tgz in this folder // node integrations/deepseek-harness/scripts/pack.mjs --out /abs/path.tgz --json import { spawnSync } from 'node:child_process'; @@ -18,10 +19,9 @@ import { fileURLToPath } from 'node:url'; export const integrationRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); export const repoRoot = path.resolve(integrationRoot, '..', '..'); export const skillsRoot = path.join(repoRoot, 'skills'); +export const manifestPath = path.join(repoRoot, 'package.json'); -const manifest = JSON.parse(fs.readFileSync(path.join(integrationRoot, 'package.json'), 'utf8')); - -// Every directory under skills/ that holds a SKILL.md ships in the package. +// Every directory under skills/ that holds a SKILL.md is a skill the package ships. export function listSkillNames() { return fs.readdirSync(skillsRoot, { withFileTypes: true }) .filter((entry) => entry.isDirectory() && !entry.name.startsWith('.')) @@ -30,21 +30,6 @@ export function listSkillNames() { .sort(); } -const skipHidden = (source) => !path.basename(source).startsWith('.'); - -function stage(destination) { - for (const file of ['package.json', 'cordis.patch.yml', 'icon.svg']) { - fs.copyFileSync(path.join(integrationRoot, file), path.join(destination, file)); - } - fs.copyFileSync(path.join(integrationRoot, 'PACKAGE_README.md'), path.join(destination, 'README.md')); - fs.copyFileSync(path.join(repoRoot, 'LICENSE'), path.join(destination, 'LICENSE')); - fs.cpSync(path.join(integrationRoot, 'locale'), path.join(destination, 'locale'), { recursive: true, filter: skipHidden }); - fs.cpSync(path.join(integrationRoot, 'docs'), path.join(destination, 'docs'), { recursive: true, filter: skipHidden }); - for (const name of listSkillNames()) { - fs.cpSync(path.join(skillsRoot, name), path.join(destination, 'skills', name), { recursive: true, filter: skipHidden }); - } -} - function parsePackJson(stdout) { const start = stdout.indexOf('['); if (start === -1) throw new Error(`npm pack printed no JSON:\n${stdout}`); @@ -56,11 +41,8 @@ function parsePackJson(stdout) { export function pack({ out } = {}) { const work = fs.mkdtempSync(path.join(os.tmpdir(), 'bloomtutor-dsh-pack-')); try { - const staged = path.join(work, 'package'); - fs.mkdirSync(staged); - stage(staged); const result = spawnSync('npm', ['pack', '--json', '--ignore-scripts', '--pack-destination', work], { - cwd: staged, + cwd: repoRoot, encoding: 'utf8', shell: process.platform === 'win32', }); @@ -86,9 +68,6 @@ if (process.argv[1] && path.resolve(process.argv[1]) === fileURLToPath(import.me const outIndex = process.argv.indexOf('--out'); const out = outIndex === -1 ? undefined : process.argv[outIndex + 1]; const packed = pack({ out }); - if (packed.name !== manifest.name || packed.version !== manifest.version) { - throw new Error(`packed ${packed.name}@${packed.version}, expected ${manifest.name}@${manifest.version}`); - } if (process.argv.includes('--json')) process.stdout.write(`${JSON.stringify(packed, null, 2)}\n`); else process.stdout.write(`${packed.destination}\n`); } diff --git a/integrations/deepseek-harness/test/package.test.mjs b/integrations/deepseek-harness/test/package.test.mjs index 13feca4..0b94127 100644 --- a/integrations/deepseek-harness/test/package.test.mjs +++ b/integrations/deepseek-harness/test/package.test.mjs @@ -1,6 +1,9 @@ // Contract tests for the bloomtutor-dsh package. No network, no DSH install: // node --test integrations/deepseek-harness/test/*.test.mjs // scripts/acceptance.mjs covers the real host. +// +// The package is the repository root (package.json there), so installing from +// GitHub source and installing the npm tarball ship the same files. import assert from 'node:assert/strict'; import fs from 'node:fs'; @@ -8,11 +11,11 @@ import os from 'node:os'; import path from 'node:path'; import test from 'node:test'; -import { integrationRoot, listSkillNames, pack, skillsRoot } from '../scripts/pack.mjs'; +import { integrationRoot, listSkillNames, manifestPath, pack, repoRoot, skillsRoot } from '../scripts/pack.mjs'; -const read = (file) => fs.readFileSync(path.join(integrationRoot, file), 'utf8'); -const manifest = JSON.parse(read('package.json')); -const patch = read('cordis.patch.yml'); +const HERE = 'integrations/deepseek-harness'; +const manifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8')); +const patch = fs.readFileSync(path.join(integrationRoot, 'cordis.patch.yml'), 'utf8'); // DSH's skill catalog truncates descriptions past this many UTF-16 units (catalogDescriptionMaxLength). const CATALOG_DESCRIPTION_MAX = 500; @@ -29,20 +32,27 @@ function frontmatter(text) { return fields; } -test('manifest declares a DSH bundle and nothing that runs on install', () => { +test('root manifest declares a DSH bundle and nothing that runs on install', () => { assert.equal(manifest.name, 'bloomtutor-dsh'); assert.match(manifest.version, /^\d+\.\d+\.\d+$/); - assert.equal(manifest.type, 'module'); assert.equal(manifest.license, 'MIT'); - assert.equal(manifest.private, undefined, 'a private package cannot be published'); - assert.deepEqual(manifest.dsh, { bundle: { patch: './cordis.patch.yml' } }); + assert.equal(manifest.private, undefined, 'a private package cannot be published or listed'); + // A root "type" would turn every .js file in the repo without a nearer package.json into ESM. + assert.equal(manifest.type, undefined); + assert.deepEqual(manifest.dsh, { bundle: { patch: `./${HERE}/cordis.patch.yml` } }); assert.ok(manifest.keywords.includes('dsh-plugin')); + // Published under the GitHub handle, not a legal name. + assert.equal(manifest.author?.name, 'Evan'); // The patch resolves /package.json; locale lookup needs the locale export. assert.equal(manifest.exports['./package.json'], './package.json'); - assert.equal(manifest.exports['./locale/*.json'], './locale/*.json'); - for (const field of ['scripts', 'dependencies', 'peerDependencies', 'optionalDependencies', 'bin', 'main']) { + assert.equal(manifest.exports['./locale/*.json'], `./${HERE}/locale/*.json`); + for (const field of ['scripts', 'dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies', 'bin', 'main', 'workspaces']) { assert.equal(manifest[field], undefined, `${field} must stay empty`); } + for (const entry of manifest.files) { + const literal = entry.replace(/\/\*\.json$/, ''); + assert.ok(fs.existsSync(path.join(repoRoot, literal)), `files entry ${entry} exists`); + } }); test('patch mounts one filesystem provider over the packaged skills', () => { @@ -56,6 +66,7 @@ test('patch mounts one filesystem provider over the packaged skills', () => { const expression = patch.match(/^\s+bundledSkillDir: !!js (.+)$/m)?.[1]; assert.ok(expression, 'bundledSkillDir is a host-evaluated expression'); assert.ok(expression.includes(`resolve('${manifest.name}/package.json')`), 'resolves this package from the profile baseUrl'); + // /skills is the repository's top-level skills/. assert.ok(expression.endsWith(", 'skills')")); // The expression runs in the host process: only the path and module built-ins are allowed. const builtins = [...expression.matchAll(/getBuiltinModule\('([^']+)'\)/g)].map((m) => m[1]); @@ -77,50 +88,55 @@ test('every skill loads under DSH naming and catalog rules', () => { }); test('locale metadata and detail documents are complete', () => { - for (const [language, detail] of [['en', 'docs/DETAIL.md'], ['zh', 'docs/DETAIL.zh.md']]) { - const { meta } = JSON.parse(read(`locale/${language}.json`)); + for (const [language, detail] of [['en', `${HERE}/docs/DETAIL.md`], ['zh', `${HERE}/docs/DETAIL.zh.md`]]) { + const { meta } = JSON.parse(fs.readFileSync(path.join(integrationRoot, 'locale', `${language}.json`), 'utf8')); assert.equal(meta.title, 'BloomTutor'); assert.ok(meta.description?.trim(), `${language}: description`); assert.match(meta.description, /[.。]$/, `${language}: description ends with punctuation`); + // meta.detail is relative to the package root, which is the repository root. assert.equal(meta.detail, detail); - assert.ok(fs.existsSync(path.join(integrationRoot, detail)), `${detail} exists`); + assert.ok(fs.existsSync(path.join(repoRoot, detail)), `${detail} exists`); } }); -test('icon is a small self-contained SVG', () => { - const icon = read('icon.svg'); - assert.equal(manifest.icon, './icon.svg'); - assert.ok(Buffer.byteLength(icon) < 256 * 1024); - assert.doesNotMatch(icon, / { + assert.equal(manifest.icon, `./${HERE}/icon.svg`); + const svg = fs.readFileSync(path.join(integrationRoot, 'icon.svg'), 'utf8'); + assert.ok(Buffer.byteLength(svg) < 256 * 1024); + assert.doesNotMatch(svg, / { +test('the tarball holds the plugin files and exactly the repository skills', () => { const out = path.join(fs.mkdtempSync(path.join(os.tmpdir(), 'bloomtutor-dsh-test-')), 'package.tgz'); const packed = pack({ out }); assert.equal(packed.name, manifest.name); assert.equal(packed.version, manifest.version); const skillFiles = []; - for (const name of listSkillNames()) { - const walk = (dir) => { - for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { - if (entry.name.startsWith('.')) continue; - const full = path.join(dir, entry.name); - if (entry.isDirectory()) walk(full); - else skillFiles.push(path.relative(path.join(skillsRoot, '..'), full).split(path.sep).join('/')); - } - }; - walk(path.join(skillsRoot, name)); - } + const walk = (dir) => { + for (const entry of fs.readdirSync(dir, { withFileTypes: true })) { + if (entry.name.startsWith('.')) continue; + const full = path.join(dir, entry.name); + if (entry.isDirectory()) walk(full); + else skillFiles.push(path.relative(repoRoot, full).split(path.sep).join('/')); + } + }; + for (const name of listSkillNames()) walk(path.join(skillsRoot, name)); const expected = [ + // npm always adds LICENSE and every README* at the package root. 'LICENSE', 'README.md', - 'cordis.patch.yml', - 'docs/DETAIL.md', - 'docs/DETAIL.zh.md', - 'icon.svg', - 'locale/en.json', - 'locale/zh.json', + 'README.zh.md', 'package.json', + `${HERE}/cordis.patch.yml`, + `${HERE}/docs/DETAIL.md`, + `${HERE}/docs/DETAIL.zh.md`, + `${HERE}/icon.svg`, + `${HERE}/locale/en.json`, + `${HERE}/locale/zh.json`, ...skillFiles, ].sort(); assert.deepEqual(packed.files, expected); diff --git a/integrations/deepseek-harness/package.json b/package.json similarity index 63% rename from integrations/deepseek-harness/package.json rename to package.json index 832afce..c2865ae 100644 --- a/integrations/deepseek-harness/package.json +++ b/package.json @@ -3,20 +3,17 @@ "version": "0.1.0", "description": "BloomTutor's AI tutor skills for DeepSeek Harness: a syllabus, one adaptive lesson at a time, and six learning-method skills.", "license": "MIT", - "type": "module", - "icon": "./icon.svg", + "icon": "./integrations/deepseek-harness/icon.svg", "exports": { "./package.json": "./package.json", - "./locale/*.json": "./locale/*.json" + "./locale/*.json": "./integrations/deepseek-harness/locale/*.json" }, "files": [ - "locale/*.json", - "docs", - "cordis.patch.yml", - "icon.svg", "skills", - "README.md", - "LICENSE" + "integrations/deepseek-harness/cordis.patch.yml", + "integrations/deepseek-harness/icon.svg", + "integrations/deepseek-harness/locale/*.json", + "integrations/deepseek-harness/docs" ], "keywords": [ "dsh-plugin", @@ -28,14 +25,13 @@ "education" ], "author": { - "name": "Li Zhengping", + "name": "Evan", "url": "https://github.com/Li-Evan" }, "homepage": "https://github.com/Li-Evan/BloomTutor/tree/main/integrations/deepseek-harness", "repository": { "type": "git", - "url": "git+https://github.com/Li-Evan/BloomTutor.git", - "directory": "integrations/deepseek-harness" + "url": "git+https://github.com/Li-Evan/BloomTutor.git" }, "bugs": "https://github.com/Li-Evan/BloomTutor/issues", "publishConfig": { @@ -43,7 +39,7 @@ }, "dsh": { "bundle": { - "patch": "./cordis.patch.yml" + "patch": "./integrations/deepseek-harness/cordis.patch.yml" } } }