From f9d8ae7c6face9c0a22f3bfd37157534273bf4c2 Mon Sep 17 00:00:00 2001 From: owo <17620121969@163.com> Date: Fri, 14 Aug 2026 15:57:41 +0800 Subject: [PATCH] chore: scaffold dsh-telegram-channel package Co-authored-by: Cursor --- .gitignore | 4 ++++ LICENSE | 21 +++++++++++++++++ cordis.patch.yml | 3 +++ package.json | 48 ++++++++++++++++++++++++++++++++++++++ src/index.ts | 31 ++++++++++++++++++++++++ tests/smoke-config.test.ts | 13 +++++++++++ tsconfig.json | 14 +++++++++++ 7 files changed, 134 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 cordis.patch.yml create mode 100644 package.json create mode 100644 src/index.ts create mode 100644 tests/smoke-config.test.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d6bb485 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +lib/ +*.log +.DS_Store diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..31c92ea --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 dsh-telegram-channel contributors + +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. diff --git a/cordis.patch.yml b/cordis.patch.yml new file mode 100644 index 0000000..3dba280 --- /dev/null +++ b/cordis.patch.yml @@ -0,0 +1,3 @@ +- insert: + - id: dsh-telegram-channel + name: dsh-telegram-channel diff --git a/package.json b/package.json new file mode 100644 index 0000000..b22a615 --- /dev/null +++ b/package.json @@ -0,0 +1,48 @@ +{ + "name": "dsh-telegram-channel", + "version": "0.1.0", + "description": "Telegram Bot API channel plugin for DeepSeek Harness (long poll, per-chat agents, HTML split)", + "type": "module", + "main": "lib/index.js", + "types": "lib/index.d.ts", + "exports": { + ".": { + "types": "./lib/index.d.ts", + "default": "./lib/index.js" + }, + "./package.json": "./package.json" + }, + "files": ["lib", "cordis.patch.yml", "README.md", "LICENSE"], + "license": "MIT", + "dsh": { + "bundle": { + "patch": "./cordis.patch.yml" + } + }, + "scripts": { + "build": "tsc -p tsconfig.json", + "test": "node --import tsx --test tests/**/*.test.ts", + "typecheck": "tsc -p tsconfig.json --noEmit", + "prepare": "npm run build" + }, + "peerDependencies": { + "@deepseek-ai/cordis": "^4.0.1", + "@deepseek-ai/schemastery": "^3.18.1", + "@deepseek-ai/dsh-agent": "^0.1.0-rc.6", + "@deepseek-ai/dsh-llm": "^0.0.1-rc.1", + "@deepseek-ai/dsh-session": "^0.0.1-rc.1" + }, + "devDependencies": { + "@types/node": "^22.0.0", + "tsx": "^4.19.0", + "typescript": "^5.9.0", + "@deepseek-ai/cordis": "^4.0.1", + "@deepseek-ai/schemastery": "^3.18.1", + "@deepseek-ai/dsh-agent": "^0.1.0-rc.6", + "@deepseek-ai/dsh-llm": "^0.0.1-rc.1", + "@deepseek-ai/dsh-session": "^0.0.1-rc.1" + }, + "engines": { + "node": ">=22" + } +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..e148d26 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,31 @@ +import type { Context } from '@deepseek-ai/cordis' +import Schema from '@deepseek-ai/schemastery' + +export const name = 'dsh-telegram-channel' +export const inject = ['agents'] + +export interface TelegramChannelConfig { + token?: string + allowedUserIds?: number[] + allowAllUsers?: boolean + provider?: string + model?: string + maxMessageLength?: number + pollingTimeoutSec?: number + cwd?: string +} + +export const Config: Schema = Schema.object({ + token: Schema.string().default(''), + allowedUserIds: Schema.array(Schema.number()).default([]), + allowAllUsers: Schema.boolean().default(false), + provider: Schema.string().default('deepseek-official'), + model: Schema.string().default('deepseek-v4-flash'), + maxMessageLength: Schema.number().default(4096), + pollingTimeoutSec: Schema.number().default(30), + cwd: Schema.string(), +}) + +export function apply(_ctx: Context, _config: TelegramChannelConfig): void { + // Task 6 fills this in +} diff --git a/tests/smoke-config.test.ts b/tests/smoke-config.test.ts new file mode 100644 index 0000000..45af1e4 --- /dev/null +++ b/tests/smoke-config.test.ts @@ -0,0 +1,13 @@ +import assert from 'node:assert/strict' +import test from 'node:test' +import { readFileSync } from 'node:fs' +import { fileURLToPath } from 'node:url' +import { dirname, join } from 'node:path' + +const root = join(dirname(fileURLToPath(import.meta.url)), '..') + +test('package name is dsh-telegram-channel', () => { + const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')) + assert.equal(pkg.name, 'dsh-telegram-channel') + assert.equal(pkg.dsh.bundle.patch, './cordis.patch.yml') +}) diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..f3559d0 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "NodeNext", + "moduleResolution": "NodeNext", + "declaration": true, + "outDir": "lib", + "rootDir": "src", + "strict": true, + "skipLibCheck": true, + "esModuleInterop": true + }, + "include": ["src/**/*.ts"] +}