@wangjunjian/dsh-github-trending 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Constants shared by the host half and the browser half of the plugin.
3
+ *
4
+ * The client bundle inlines this module (it is a local value import, not a
5
+ * `@deepseek-ai/*` import), so both halves always agree on these values.
6
+ *
7
+ * @module @wangjunjian/dsh-github-trending/constants
8
+ */
9
+ /** Default background refresh interval: 4 hours. Also the panel polling interval. */
10
+ export declare const DEFAULT_REFRESH_INTERVAL_MS: number;
11
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1,41 @@
1
+ /**
2
+ * `@wangjunjian/dsh-github-trending`: a DeepSeek Harness bundle plugin that
3
+ * registers a `github_trending` tool backed by https://github.com/trending.
4
+ *
5
+ * The plugin is a Cordis function/namespace plugin (no default export). It
6
+ * injects `tools` and `systemPrompt` and registers the tool through the
7
+ * harness tool registry.
8
+ *
9
+ * @module @wangjunjian/dsh-github-trending
10
+ */
11
+ import type { Context } from '@deepseek-ai/cordis';
12
+ import z from '@deepseek-ai/schemastery';
13
+ export { DEFAULT_REFRESH_INTERVAL_MS } from './constants.js';
14
+ export type { TrendingRepository } from './parser.js';
15
+ export type { GithubTrendingArgs, GithubTrendingResult } from './tool.js';
16
+ export { DEFAULT_MAX_RESULTS, MAX_RESULTS_LIMIT } from './tool.js';
17
+ /** Plugin config accepted from cordis.yml. */
18
+ export interface Config {
19
+ /** Whether to register the `github_trending` tool. Defaults to true. */
20
+ enabled?: boolean;
21
+ /** Cooperative timeout budget (ms) for the HTTP request. Defaults to 30000. */
22
+ timeoutMs?: number;
23
+ /** Maximum repositories the tool may return. Defaults to 10, hard cap 25. */
24
+ maxResults?: number;
25
+ /** Background refresh interval (ms) for the UI cache. Defaults to 14400000 (4 hours). */
26
+ refreshIntervalMs?: number;
27
+ }
28
+ /** Cordis plugin name used by loader diagnostics. */
29
+ export declare const name = "github-trending";
30
+ /** Services this plugin requires. */
31
+ export declare const inject: string[];
32
+ /** Schemastery config schema with defaults and bounds. */
33
+ export declare const Config: z<Config>;
34
+ /**
35
+ * Register the `github_trending` tool and its system-prompt guidance.
36
+ *
37
+ * @param ctx - the Cordis context.
38
+ * @param config - plugin config; schemastery has already applied defaults.
39
+ */
40
+ export declare function apply(ctx: Context, config: Config): void;
41
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,41 @@
1
+ /**
2
+ * HTML parser for the public GitHub Trending page (https://github.com/trending).
3
+ *
4
+ * GitHub Trending has no official API, so this module scrapes the server-rendered
5
+ * HTML. The selectors target the current `article.Box-row` layout and degrade
6
+ * gracefully when GitHub changes markup: missing fields become `undefined` or `0`
7
+ * rather than throwing.
8
+ *
9
+ * @module @wangjunjian/dsh-github-trending/parser
10
+ */
11
+ /** One trending repository extracted from the GitHub Trending page. */
12
+ export interface TrendingRepository {
13
+ /** 1-based position on the page. */
14
+ rank: number;
15
+ /** Repository owner login. */
16
+ owner: string;
17
+ /** Repository name. */
18
+ name: string;
19
+ /** `owner/name`. */
20
+ fullName: string;
21
+ /** Absolute GitHub URL. */
22
+ url: string;
23
+ /** Repository description, if present. */
24
+ description?: string;
25
+ /** Primary language, if present. */
26
+ language?: string;
27
+ /** Total star count, if present. */
28
+ stars: number;
29
+ /** Fork count, if present. */
30
+ forks: number;
31
+ /** Stars gained today (or this week/month), if present. */
32
+ starsToday: number;
33
+ }
34
+ /**
35
+ * Parse the GitHub Trending HTML and return the extracted repositories.
36
+ *
37
+ * @param html - the raw HTML body from https://github.com/trending.
38
+ * @returns the list of trending repositories in page order.
39
+ */
40
+ export declare function parseTrendingHtml(html: string): TrendingRepository[];
41
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1,118 @@
1
+ /**
2
+ * The model-facing `github_trending` tool.
3
+ *
4
+ * @module @wangjunjian/dsh-github-trending/tool
5
+ */
6
+ import type { Context } from '@deepseek-ai/cordis';
7
+ import type { GenericCallView, JsonValue, SearchResultView, ToolResult } from '@deepseek-ai/dsh-tools';
8
+ import { type TrendingRepository } from './parser.js';
9
+ /** Default cap on repositories returned by one tool call. */
10
+ export declare const DEFAULT_MAX_RESULTS = 10;
11
+ /** Hard upper bound on repositories returned by one tool call. */
12
+ export declare const MAX_RESULTS_LIMIT = 25;
13
+ /** Tool schema arguments after validation. */
14
+ export interface GithubTrendingArgs {
15
+ /** Optional programming language filter (e.g. "python", "typescript"). */
16
+ language?: string;
17
+ /** Time window for trending computation: "daily", "weekly", or "monthly". Defaults to "daily". */
18
+ since?: string;
19
+ /** Maximum number of repositories to return. */
20
+ maxResults?: number;
21
+ }
22
+ /** Canonical tool result value. */
23
+ export interface GithubTrendingResult {
24
+ /** Trending repositories in page order. */
25
+ repositories: TrendingRepository[];
26
+ /** True when the result was capped to `maxResults`. */
27
+ truncated: boolean;
28
+ }
29
+ /** User-Agent identifying this plugin's requests to GitHub. */
30
+ export declare const USER_AGENT = "@wangjunjian/dsh-github-trending/0.1.0 (+https://github.com/wang-junjian/dsh-github-trending)";
31
+ /**
32
+ * Resolve the GitHub Trending URL from tool arguments.
33
+ *
34
+ * @param args - validated tool arguments.
35
+ * @returns the HTTPS URL to fetch.
36
+ */
37
+ export declare function buildTrendingUrl(args: GithubTrendingArgs): string;
38
+ /**
39
+ * Validate and clamp `maxResults` to the configured cap.
40
+ *
41
+ * @param requested - the model-requested limit.
42
+ * @param configCap - the plugin-level cap from config.
43
+ * @returns a positive integer not exceeding the cap.
44
+ */
45
+ export declare function resolveMaxResults(requested: number | undefined, configCap: number): number;
46
+ /**
47
+ * Fetch the GitHub Trending page and parse it into repositories.
48
+ *
49
+ * @param url - the trending URL to fetch.
50
+ * @param signal - cancellation signal forwarded from the tool execution.
51
+ * @returns the parsed repositories.
52
+ */
53
+ export declare function fetchTrendingRepositories(url: string, signal?: AbortSignal): Promise<TrendingRepository[]>;
54
+ /**
55
+ * Format the canonical result as a concise markdown list for the model.
56
+ *
57
+ * @param result - the tool result value.
58
+ * @returns one text content block.
59
+ */
60
+ export declare function formatTrendingOutput(result: GithubTrendingResult): string;
61
+ /**
62
+ * Pending-call presentation: a search-style generic card titled by the language
63
+ * and time window.
64
+ *
65
+ * @param args - the raw tool arguments.
66
+ * @returns the generic pending card.
67
+ */
68
+ export declare function presentTrendingCall(args: GithubTrendingArgs): GenericCallView;
69
+ /** Replayable presentation metadata for one repository. */
70
+ interface TrendingRepoMeta {
71
+ fullName: string;
72
+ url: string;
73
+ starsToday: number;
74
+ }
75
+ /** Replayable presentation metadata for the completed call. */
76
+ interface TrendingMeta {
77
+ count: number;
78
+ truncated: boolean;
79
+ repositories: TrendingRepoMeta[];
80
+ }
81
+ /**
82
+ * Build replayable presentation metadata for the completed call.
83
+ *
84
+ * @param result - the canonical tool result.
85
+ * @returns a compact JSON summary for UI cards.
86
+ */
87
+ export declare function trendingMetaFromValue(result: GithubTrendingResult): JsonValue;
88
+ /**
89
+ * Narrow opaque replayed result metadata to the presentation shape.
90
+ *
91
+ * @param meta - result metadata.
92
+ * @returns the validated meta, or `undefined` for absent/malformed data.
93
+ */
94
+ export declare function trendingMetaFromResult(meta: unknown): TrendingMeta | undefined;
95
+ /**
96
+ * Completed-call presentation: a search result card with the repository list.
97
+ *
98
+ * @param args - the raw tool arguments.
99
+ * @param result - the final tool result.
100
+ * @returns the search result view, or `undefined` on error/malformed meta.
101
+ */
102
+ export declare function presentTrendingResult(args: GithubTrendingArgs, result: ToolResult): SearchResultView | undefined;
103
+ /** Plugin-level config received by {@link applyGithubTrendingTool}. */
104
+ export interface ToolConfig {
105
+ /** Cooperative timeout budget (ms) for the HTTP request. */
106
+ timeoutMs: number;
107
+ /** Maximum repositories the tool may return. */
108
+ maxResults: number;
109
+ }
110
+ /**
111
+ * Register the `github_trending` tool and its system-prompt guidance.
112
+ *
113
+ * @param ctx - the Cordis context whose `tools` and `systemPrompt` registries receive the registrations.
114
+ * @param config - resolved plugin config: timeout and result cap.
115
+ */
116
+ export declare function applyGithubTrendingTool(ctx: Context, config: ToolConfig): void;
117
+ export {};
118
+ //# sourceMappingURL=tool.d.ts.map
package/package.json ADDED
@@ -0,0 +1,121 @@
1
+ {
2
+ "name": "@wangjunjian/dsh-github-trending",
3
+ "version": "0.1.0",
4
+ "description": "DeepSeek Harness bundle plugin that exposes a github_trending tool backed by https://github.com/trending",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/wang-junjian/dsh-github-trending.git"
8
+ },
9
+ "homepage": "https://github.com/wang-junjian/dsh-github-trending#readme",
10
+ "bugs": {
11
+ "url": "https://github.com/wang-junjian/dsh-github-trending/issues"
12
+ },
13
+ "keywords": [
14
+ "deepseek-harness",
15
+ "dsh",
16
+ "plugin",
17
+ "github",
18
+ "trending"
19
+ ],
20
+ "type": "module",
21
+ "packageManager": "pnpm@10.33.2",
22
+ "main": "lib/index.js",
23
+ "types": "lib/types/index.d.ts",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./lib/types/index.d.ts",
27
+ "default": "./lib/index.js"
28
+ },
29
+ "./client": {
30
+ "types": "./lib/types/client/index.d.ts",
31
+ "default": "./lib/client.js"
32
+ },
33
+ "./cordis.patch.yml": "./cordis.patch.yml",
34
+ "./src/*": "./src/*",
35
+ "./package.json": "./package.json"
36
+ },
37
+ "files": [
38
+ "lib/index.js",
39
+ "lib/tool.js",
40
+ "lib/parser.js",
41
+ "lib/cache.js",
42
+ "lib/constants.js",
43
+ "lib/client.js",
44
+ "lib/types/**/*.d.ts",
45
+ "cordis.patch.yml",
46
+ "README.md",
47
+ "README.zh.md",
48
+ "LICENSE"
49
+ ],
50
+ "license": "MIT",
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "dsh": {
55
+ "bundle": {
56
+ "patch": "./cordis.patch.yml"
57
+ },
58
+ "client": {
59
+ "platform": "web",
60
+ "inject": [
61
+ "@deepseek-ai/dsh-client-runtime"
62
+ ],
63
+ "external": [
64
+ "@deepseek-ai/dsh-client-ui-primitives"
65
+ ]
66
+ }
67
+ },
68
+ "scripts": {
69
+ "build": "tsc -b tsconfig.json && tsdown",
70
+ "prepare": "tsc -b tsconfig.json && tsdown",
71
+ "test": "vitest run",
72
+ "test:watch": "vitest",
73
+ "typecheck": "tsc --noEmit",
74
+ "lint": "biome check .",
75
+ "lint:fix": "biome check --write .",
76
+ "format": "biome format --write ."
77
+ },
78
+ "peerDependencies": {
79
+ "@deepseek-ai/cordis": "^4.0.1",
80
+ "@deepseek-ai/dsh-client-locale": "^0.1.1-rc.2",
81
+ "@deepseek-ai/dsh-client-runtime": "^0.1.1-rc.2",
82
+ "@deepseek-ai/dsh-client-ui-layout": "^0.1.1-rc.2",
83
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.1.1-rc.2",
84
+ "@deepseek-ai/dsh-client-ui-sidebar": "^0.1.1-rc.2",
85
+ "@deepseek-ai/dsh-client-ui-slots": "^0.1.1-rc.2",
86
+ "@deepseek-ai/dsh-host-webserver": "^0.1.1-rc.2",
87
+ "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
88
+ "@deepseek-ai/dsh-system-prompt": "^0.1.1-rc.2",
89
+ "@deepseek-ai/dsh-tools": "^0.1.1-rc.2",
90
+ "react": "^18.2.0",
91
+ "react-dom": "^18.2.0"
92
+ },
93
+ "dependencies": {
94
+ "@deepseek-ai/schemastery": "^3.18.1",
95
+ "node-html-parser": "^7.0.1"
96
+ },
97
+ "devDependencies": {
98
+ "@biomejs/biome": "^2.5.10",
99
+ "@deepseek-ai/cordis": "^4.0.1",
100
+ "@deepseek-ai/dsh-client-locale": "^0.1.1-rc.2",
101
+ "@deepseek-ai/dsh-client-runtime": "^0.1.1-rc.2",
102
+ "@deepseek-ai/dsh-client-ui-layout": "^0.1.1-rc.2",
103
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.1.1-rc.2",
104
+ "@deepseek-ai/dsh-client-ui-sidebar": "^0.1.1-rc.2",
105
+ "@deepseek-ai/dsh-client-ui-slots": "^0.1.1-rc.2",
106
+ "@deepseek-ai/dsh-host-webserver": "^0.1.1-rc.2",
107
+ "@deepseek-ai/dsh-invariants": "^0.1.1-rc.2",
108
+ "@deepseek-ai/dsh-llm": "^0.1.1-rc.2",
109
+ "@deepseek-ai/dsh-system-prompt": "^0.1.1-rc.2",
110
+ "@deepseek-ai/dsh-tools": "^0.1.1-rc.2",
111
+ "@types/node": "^22.20.0",
112
+ "@types/react": "~18.3.1",
113
+ "@types/react-dom": "~18.3.1",
114
+ "lightningcss": "^1.32.0",
115
+ "react": "^18.2.0",
116
+ "react-dom": "^18.2.0",
117
+ "tsdown": "^0.22.2",
118
+ "typescript": "^6.0.3",
119
+ "vitest": "^4.1.8"
120
+ }
121
+ }