dsh-thesis 1.0.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.
- package/DESIGN.md +390 -0
- package/LICENSE +21 -0
- package/NOTICE.md +10 -0
- package/README.md +253 -0
- package/cordis.patch.yml +17 -0
- package/docs/host-api.md +640 -0
- package/lib/codewalk/commands.d.ts +23 -0
- package/lib/codewalk/commands.js +168 -0
- package/lib/codewalk/engine.d.ts +108 -0
- package/lib/codewalk/engine.js +449 -0
- package/lib/codewalk/errors.d.ts +31 -0
- package/lib/codewalk/errors.js +20 -0
- package/lib/codewalk/fs-types.d.ts +34 -0
- package/lib/codewalk/fs-types.js +10 -0
- package/lib/codewalk/gate.d.ts +30 -0
- package/lib/codewalk/gate.js +60 -0
- package/lib/codewalk/host-types.d.ts +198 -0
- package/lib/codewalk/host-types.js +11 -0
- package/lib/codewalk/prestep.d.ts +17 -0
- package/lib/codewalk/prestep.js +62 -0
- package/lib/codewalk/register.d.ts +23 -0
- package/lib/codewalk/register.js +31 -0
- package/lib/codewalk/skill.d.ts +15 -0
- package/lib/codewalk/skill.js +57 -0
- package/lib/codewalk/tools.d.ts +18 -0
- package/lib/codewalk/tools.js +314 -0
- package/lib/codewalk/types.d.ts +151 -0
- package/lib/codewalk/types.js +9 -0
- package/lib/commands.d.ts +33 -0
- package/lib/commands.js +60 -0
- package/lib/config.d.ts +125 -0
- package/lib/config.js +139 -0
- package/lib/dedup/commands.d.ts +21 -0
- package/lib/dedup/commands.js +93 -0
- package/lib/dedup/index.d.ts +75 -0
- package/lib/dedup/index.js +331 -0
- package/lib/dedup/normalize.d.ts +125 -0
- package/lib/dedup/normalize.js +329 -0
- package/lib/dedup/report.d.ts +114 -0
- package/lib/dedup/report.js +309 -0
- package/lib/dedup/rewrite.d.ts +71 -0
- package/lib/dedup/rewrite.js +228 -0
- package/lib/dedup/similarity.d.ts +169 -0
- package/lib/dedup/similarity.js +323 -0
- package/lib/gates/dangerous.d.ts +22 -0
- package/lib/gates/dangerous.js +47 -0
- package/lib/gates/detect.d.ts +54 -0
- package/lib/gates/detect.js +106 -0
- package/lib/gates/messages.d.ts +39 -0
- package/lib/gates/messages.js +74 -0
- package/lib/gates/prompt.d.ts +21 -0
- package/lib/gates/prompt.js +56 -0
- package/lib/gates/writing-intent.d.ts +49 -0
- package/lib/gates/writing-intent.js +68 -0
- package/lib/index.d.ts +36 -0
- package/lib/index.js +76 -0
- package/lib/ingest/code.d.ts +71 -0
- package/lib/ingest/code.js +356 -0
- package/lib/ingest/commands.d.ts +23 -0
- package/lib/ingest/commands.js +74 -0
- package/lib/ingest/docx.d.ts +29 -0
- package/lib/ingest/docx.js +92 -0
- package/lib/ingest/index.d.ts +179 -0
- package/lib/ingest/index.js +640 -0
- package/lib/ingest/ooxml.d.ts +58 -0
- package/lib/ingest/ooxml.js +393 -0
- package/lib/ingest/pdf.d.ts +86 -0
- package/lib/ingest/pdf.js +1016 -0
- package/lib/ingest/pptx.d.ts +32 -0
- package/lib/ingest/pptx.js +116 -0
- package/lib/ingest/text.d.ts +25 -0
- package/lib/ingest/text.js +180 -0
- package/lib/ingest/types.d.ts +48 -0
- package/lib/ingest/types.js +47 -0
- package/lib/ingest/xlsx.d.ts +72 -0
- package/lib/ingest/xlsx.js +411 -0
- package/lib/ingest/zip.d.ts +76 -0
- package/lib/ingest/zip.js +393 -0
- package/lib/intake/definitions.d.ts +65 -0
- package/lib/intake/definitions.js +42 -0
- package/lib/intake/gate-rules.d.ts +57 -0
- package/lib/intake/gate-rules.js +118 -0
- package/lib/intake/gate.d.ts +24 -0
- package/lib/intake/gate.js +86 -0
- package/lib/intake/index.d.ts +76 -0
- package/lib/intake/index.js +468 -0
- package/lib/intake/questions.d.ts +169 -0
- package/lib/intake/questions.js +720 -0
- package/lib/intake/spec.d.ts +66 -0
- package/lib/intake/spec.js +221 -0
- package/lib/intake/state.d.ts +192 -0
- package/lib/intake/state.js +420 -0
- package/lib/memory/recall.d.ts +69 -0
- package/lib/memory/recall.js +177 -0
- package/lib/memory/register.d.ts +37 -0
- package/lib/memory/register.js +52 -0
- package/lib/memory/service.d.ts +39 -0
- package/lib/memory/service.js +39 -0
- package/lib/memory/store.d.ts +45 -0
- package/lib/memory/store.js +123 -0
- package/lib/memory/tools.d.ts +19 -0
- package/lib/memory/tools.js +195 -0
- package/lib/memory/types.d.ts +55 -0
- package/lib/memory/types.js +6 -0
- package/lib/paper/commands.d.ts +13 -0
- package/lib/paper/commands.js +84 -0
- package/lib/paper/lib/aicheck.d.ts +38 -0
- package/lib/paper/lib/aicheck.js +241 -0
- package/lib/paper/lib/bibtex.d.ts +21 -0
- package/lib/paper/lib/bibtex.js +114 -0
- package/lib/paper/lib/check.d.ts +32 -0
- package/lib/paper/lib/check.js +215 -0
- package/lib/paper/lib/defense.d.ts +48 -0
- package/lib/paper/lib/defense.js +220 -0
- package/lib/paper/lib/docx.d.ts +35 -0
- package/lib/paper/lib/docx.js +213 -0
- package/lib/paper/lib/layout.d.ts +41 -0
- package/lib/paper/lib/layout.js +572 -0
- package/lib/paper/lib/ledger.d.ts +112 -0
- package/lib/paper/lib/ledger.js +349 -0
- package/lib/paper/lib/lit-api.d.ts +59 -0
- package/lib/paper/lib/lit-api.js +296 -0
- package/lib/paper/lib/lit-cache.d.ts +32 -0
- package/lib/paper/lib/lit-cache.js +91 -0
- package/lib/paper/lib/project.d.ts +29 -0
- package/lib/paper/lib/project.js +93 -0
- package/lib/paper/lib/review.d.ts +37 -0
- package/lib/paper/lib/review.js +194 -0
- package/lib/paper/lib/zip.d.ts +14 -0
- package/lib/paper/lib/zip.js +124 -0
- package/lib/paper/register.d.ts +20 -0
- package/lib/paper/register.js +183 -0
- package/lib/paper/tools/aicheck.d.ts +6 -0
- package/lib/paper/tools/aicheck.js +38 -0
- package/lib/paper/tools/build.d.ts +27 -0
- package/lib/paper/tools/build.js +166 -0
- package/lib/paper/tools/check.d.ts +7 -0
- package/lib/paper/tools/check.js +79 -0
- package/lib/paper/tools/decision.d.ts +13 -0
- package/lib/paper/tools/decision.js +53 -0
- package/lib/paper/tools/defense.d.ts +11 -0
- package/lib/paper/tools/defense.js +74 -0
- package/lib/paper/tools/init.d.ts +23 -0
- package/lib/paper/tools/init.js +99 -0
- package/lib/paper/tools/lit.d.ts +27 -0
- package/lib/paper/tools/lit.js +236 -0
- package/lib/paper/tools/progress.d.ts +18 -0
- package/lib/paper/tools/progress.js +77 -0
- package/lib/paper/tools/review.d.ts +11 -0
- package/lib/paper/tools/review.js +41 -0
- package/lib/ppt/actions.d.ts +97 -0
- package/lib/ppt/actions.js +263 -0
- package/lib/ppt/check.d.ts +64 -0
- package/lib/ppt/check.js +185 -0
- package/lib/ppt/commands.d.ts +28 -0
- package/lib/ppt/commands.js +71 -0
- package/lib/ppt/convert.d.ts +146 -0
- package/lib/ppt/convert.js +423 -0
- package/lib/ppt/index.d.ts +45 -0
- package/lib/ppt/index.js +57 -0
- package/lib/ppt/marp.d.ts +74 -0
- package/lib/ppt/marp.js +165 -0
- package/lib/ppt/outline.d.ts +206 -0
- package/lib/ppt/outline.js +695 -0
- package/lib/shared/define-tool.d.ts +77 -0
- package/lib/shared/define-tool.js +235 -0
- package/lib/shared/fs-errors.d.ts +50 -0
- package/lib/shared/fs-errors.js +90 -0
- package/lib/shared/index.d.ts +31 -0
- package/lib/shared/index.js +32 -0
- package/lib/shared/spawn.d.ts +38 -0
- package/lib/shared/spawn.js +50 -0
- package/lib/shared/text.d.ts +14 -0
- package/lib/shared/text.js +26 -0
- package/package.json +82 -0
- package/skills/code-walkthrough/SKILL.md +94 -0
- package/skills/code-walkthrough/references/examples.md +129 -0
- package/skills/paper-dedup/SKILL.md +58 -0
- package/skills/paper-intake/SKILL.md +64 -0
- package/skills/thesis-citation/SKILL.md +67 -0
- package/skills/thesis-defense/SKILL.md +87 -0
- package/skills/thesis-eng-design/SKILL.md +97 -0
- package/skills/thesis-inquiry/SKILL.md +55 -0
- package/skills/thesis-inquiry/references/intent-spec-template.md +39 -0
- package/skills/thesis-literature/SKILL.md +56 -0
- package/skills/thesis-opener/SKILL.md +77 -0
- package/skills/thesis-pipeline/SKILL.md +121 -0
- package/skills/thesis-writing/SKILL.md +86 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 材料摄取模块门面:类型判定 → 各格式抽取 → 统一的 `thesis_ingest` 工具。
|
|
3
|
+
*
|
|
4
|
+
* 设计要点:
|
|
5
|
+
* - `extractDocument` 是**纯函数**(字节 + 类型 + 选项 → 结果),不碰磁盘;
|
|
6
|
+
* - `extractText` 是统一入口(按文件名判定类型),供其它模块编程调用;
|
|
7
|
+
* - `thesis_ingest` 负责磁盘/工作区落盘:读文件(二进制走 `node:fs` 例外)、
|
|
8
|
+
* 递归枚举目录、把摘要写到 `00-管理/材料/`,**绝不覆盖已存在的摘要**;
|
|
9
|
+
* - I/O 通过 {@link IngestIO} 注入,便于测试注入自定义读取器与假文件系统。
|
|
10
|
+
*
|
|
11
|
+
* @module dsh-thesis/ingest
|
|
12
|
+
*/
|
|
13
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
14
|
+
import type { FileSystem } from '@deepseek-ai/dsh-fs';
|
|
15
|
+
import type { IngestOptions } from '../config.ts';
|
|
16
|
+
import { type CodeFileSummary, type CodeLanguage } from './code.ts';
|
|
17
|
+
/** 摄取类型:可抽取的文档格式 + 源码结构摘要 + 不支持。 */
|
|
18
|
+
export type IngestKind = 'docx' | 'xlsx' | 'pptx' | 'pdf' | 'text' | 'code' | 'unsupported';
|
|
19
|
+
/** 递归枚举时跳过的目录名(版本库/依赖/产出,避免把仓库翻个底朝天)。 */
|
|
20
|
+
export declare const SKIP_DIRS: string[];
|
|
21
|
+
/**
|
|
22
|
+
* 按扩展名判定摄取类型。
|
|
23
|
+
*
|
|
24
|
+
* 顺序有讲究:源码扩展名先判为 `code`(`.md/.json/.yaml/.html` 仍走 `text`,
|
|
25
|
+
* 依赖清单也走 `text`——清单原文对写"技术选型"有用)。
|
|
26
|
+
*/
|
|
27
|
+
export declare function detectKind(path: string): IngestKind;
|
|
28
|
+
/** 不支持时的解释(`.doc`/`.xls`/`.ppt` 走专门提示)。 */
|
|
29
|
+
export declare function unsupportedReason(path: string): string;
|
|
30
|
+
/** 抽取结果(工具与其它模块共用的公开形状)。 */
|
|
31
|
+
export interface IngestExtract {
|
|
32
|
+
/** 是否抽取成功。 */
|
|
33
|
+
readonly ok: boolean;
|
|
34
|
+
/** 判定出的类型。 */
|
|
35
|
+
readonly kind: IngestKind;
|
|
36
|
+
/** 抽取到的文本(失败时为空串)。 */
|
|
37
|
+
readonly text: string;
|
|
38
|
+
/** 文本字符数。 */
|
|
39
|
+
readonly chars: number;
|
|
40
|
+
/** 是否因 `maxChars` 截断。 */
|
|
41
|
+
readonly truncated: boolean;
|
|
42
|
+
/** 文档标题(docx/pptx 的文档属性)。 */
|
|
43
|
+
readonly title?: string;
|
|
44
|
+
/** 说明/失败原因。 */
|
|
45
|
+
readonly note?: string;
|
|
46
|
+
/** 低置信标记(文本量明显偏少)。 */
|
|
47
|
+
readonly lowConfidence?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* 按类型抽取字节 → 文本(纯函数)。
|
|
51
|
+
*
|
|
52
|
+
* - `unsupported` 返回 `ok: false` 与明确的另存为提示,绝不静默返回空文本;
|
|
53
|
+
* - `code` **不返回源码正文**,只给该文件的结构摘要(语言/行数/声明)。
|
|
54
|
+
*/
|
|
55
|
+
export declare function extractDocument(bytes: Uint8Array, kind: IngestKind, options: {
|
|
56
|
+
maxChars: number;
|
|
57
|
+
}): IngestExtract;
|
|
58
|
+
/** 单文件代码结构摘要(不返回源码正文)。 */
|
|
59
|
+
export declare function codeFileExtract(rel: string, text: string, options: {
|
|
60
|
+
maxChars: number;
|
|
61
|
+
}): IngestExtract;
|
|
62
|
+
/** 统一入口:字节 + 文件名 → 结果(内部判定类型)。 */
|
|
63
|
+
export declare function extractText(bytes: Uint8Array, filename: string, options: {
|
|
64
|
+
maxChars: number;
|
|
65
|
+
}): IngestExtract;
|
|
66
|
+
/** 一个待摄取的文件(绝对路径 + 工作区相对路径 + 判定类型)。 */
|
|
67
|
+
export interface IngestFile {
|
|
68
|
+
readonly absolute: string;
|
|
69
|
+
/** 字节数;无法取得时(测试注入的 IO)缺省为 -1。 */
|
|
70
|
+
readonly size: number;
|
|
71
|
+
readonly rel: string;
|
|
72
|
+
/** 判定出的摄取类型(`code` 只做结构摘要,不返回源码正文)。 */
|
|
73
|
+
readonly kind: IngestKind;
|
|
74
|
+
}
|
|
75
|
+
/** 清单文件超过该字节数就不纳入技术栈指纹(只如实列出跳过)。 */
|
|
76
|
+
export declare const MAX_MANIFEST_BYTES: number;
|
|
77
|
+
/** 摄取所需的 I/O:真实实现走 node:fs + ctx.fs,测试可注入内存实现。 */
|
|
78
|
+
export interface IngestIO {
|
|
79
|
+
/** 指定路径是文件还是目录(不存在返回 undefined)。 */
|
|
80
|
+
kind(target: string): Promise<'file' | 'dir' | undefined>;
|
|
81
|
+
/** 目录下的直接子项(不存在/无权限抛错)。 */
|
|
82
|
+
list(target: string): Promise<readonly {
|
|
83
|
+
name: string;
|
|
84
|
+
isDirectory: boolean;
|
|
85
|
+
}[]>;
|
|
86
|
+
/** 读文件字节。 */
|
|
87
|
+
read(target: string): Promise<Uint8Array>;
|
|
88
|
+
}
|
|
89
|
+
/** 真实磁盘 I/O(二进制读取是文档化的例外:ctx.fs 只有 readText)。 */
|
|
90
|
+
export declare const diskIO: IngestIO;
|
|
91
|
+
/** 一次摄取最多处理的文件数(防止把整个磁盘拖进来)。 */
|
|
92
|
+
export declare const MAX_FILES = 200;
|
|
93
|
+
/** 递归深度上限。 */
|
|
94
|
+
export declare const MAX_DEPTH = 6;
|
|
95
|
+
/** 后缀过滤:`docx,pdf,md` → 匹配集合(空 = 不过滤)。 */
|
|
96
|
+
export declare function parseGlobFilter(glob: string | undefined): Set<string>;
|
|
97
|
+
/** 是否跳过该目录(名称命中 SKIP_DIRS 尾段或整体相对路径)。 */
|
|
98
|
+
export declare function shouldSkipDir(name: string, rel: string): boolean;
|
|
99
|
+
/** 递归枚举待摄取文件(目录)或单个文件。 */
|
|
100
|
+
export declare function collectFiles(io: IngestIO, target: string, filter: Set<string>): Promise<IngestFile[]>;
|
|
101
|
+
/** 目录名 → 代码摘要文件名(`<目录名>-代码结构.md`)。 */
|
|
102
|
+
export declare function codeSummaryFileName(target: string): string;
|
|
103
|
+
/** 代码结构汇总(清单里单独一节 + 一份摘要文件)。 */
|
|
104
|
+
export interface CodeStructure {
|
|
105
|
+
/** 参与摘要的源码文件数。 */
|
|
106
|
+
readonly files: number;
|
|
107
|
+
/** 总行数 / 代码行数。 */
|
|
108
|
+
readonly lines: number;
|
|
109
|
+
readonly codeLines: number;
|
|
110
|
+
/** 语言分布(语言 → 文件数/行数),按行数降序。 */
|
|
111
|
+
readonly languages: ReadonlyArray<{
|
|
112
|
+
readonly language: CodeLanguage;
|
|
113
|
+
readonly files: number;
|
|
114
|
+
readonly lines: number;
|
|
115
|
+
}>;
|
|
116
|
+
/** 技术栈(由依赖清单推断)。 */
|
|
117
|
+
readonly stack: ReadonlyArray<{
|
|
118
|
+
readonly name: string;
|
|
119
|
+
readonly evidence: string;
|
|
120
|
+
}>;
|
|
121
|
+
/** 摘要文件在工作区内的相对路径。 */
|
|
122
|
+
readonly summaryPath: string;
|
|
123
|
+
/** 未能摘要的文件(超大/读取失败),如实列出。 */
|
|
124
|
+
readonly skipped: readonly string[];
|
|
125
|
+
}
|
|
126
|
+
/** 汇总一组单文件摘要。 */
|
|
127
|
+
export declare function buildCodeStructure(files: readonly CodeFileSummary[], manifests: Readonly<Record<string, string>>, summaryPath: string, skipped: readonly string[]): CodeStructure;
|
|
128
|
+
/** 摘要目录(相对论文工作区根)。 */
|
|
129
|
+
export declare const MATERIAL_DIR = "00-\u7BA1\u7406/\u6750\u6599";
|
|
130
|
+
/** 清单文件(相对论文工作区根)。 */
|
|
131
|
+
export declare const MANIFEST_REL = "00-\u7BA1\u7406/\u6750\u6599\u6E05\u5355.md";
|
|
132
|
+
/** 文件名 → 安全的摘要文件名(去扩展名,替换非法字符)。 */
|
|
133
|
+
export declare function summaryFileName(rel: string): string;
|
|
134
|
+
/**
|
|
135
|
+
* 生成单个文件的摘要 Markdown。
|
|
136
|
+
* 含:原文件名、类型、字节数、字符数、是否截断/低置信、正文。
|
|
137
|
+
*/
|
|
138
|
+
export declare function buildSummary(rel: string, size: number, result: IngestExtract): string;
|
|
139
|
+
/** 生成工作区清单文件内容。 */
|
|
140
|
+
export declare function buildManifest(files: readonly IngestFile[], results: readonly IngestExtract[], written: readonly string[], skipped: readonly string[], code: CodeStructure | undefined): string;
|
|
141
|
+
/** `thesis_ingest` 的参数。 */
|
|
142
|
+
export interface IngestArgs {
|
|
143
|
+
/** 文件或目录的绝对路径(必填)。 */
|
|
144
|
+
path: string;
|
|
145
|
+
/** 可选后缀过滤,如 `docx,pdf,md`。 */
|
|
146
|
+
glob?: string;
|
|
147
|
+
/** 是否把摘要落到论文工作区,默认 true。 */
|
|
148
|
+
write?: boolean;
|
|
149
|
+
}
|
|
150
|
+
/** 摄取结果(供测试与渲染共用)。 */
|
|
151
|
+
export interface IngestOutcome {
|
|
152
|
+
readonly root: string | undefined;
|
|
153
|
+
readonly files: readonly IngestFile[];
|
|
154
|
+
readonly results: readonly IngestExtract[];
|
|
155
|
+
readonly written: readonly string[];
|
|
156
|
+
readonly skipped: readonly string[];
|
|
157
|
+
readonly failed: readonly {
|
|
158
|
+
readonly rel: string;
|
|
159
|
+
readonly reason: string;
|
|
160
|
+
}[];
|
|
161
|
+
readonly truncatedCount: number;
|
|
162
|
+
readonly lowConfidence: readonly string[];
|
|
163
|
+
/** 代码结构汇总(没有源码文件时为 undefined)。 */
|
|
164
|
+
readonly code: CodeStructure | undefined;
|
|
165
|
+
readonly note: string | undefined;
|
|
166
|
+
}
|
|
167
|
+
/** 执行摄取(I/O 注入;工具与测试共用)。 */
|
|
168
|
+
export declare function runIngest(fs: FileSystem, io: IngestIO, args: IngestArgs, cwd: string | undefined, options: IngestOptions, signal?: AbortSignal): Promise<IngestOutcome>;
|
|
169
|
+
/** 按优先级给出"该带进追问的关键材料"建议。 */
|
|
170
|
+
export declare function suggestNextSteps(files: readonly IngestFile[], results: readonly IngestExtract[]): string[];
|
|
171
|
+
/** 渲染工具返回值(有界字符串,遵守 maxChars)。 */
|
|
172
|
+
export declare function renderOutcome(outcome: IngestOutcome, maxChars: number): string;
|
|
173
|
+
/** `thesis_ingest` 工具的装配参数。 */
|
|
174
|
+
export interface RegisterIngestOptions {
|
|
175
|
+
/** 摄取配置(`maxBytes`/`maxChars`,来自 `src/config.ts`)。 */
|
|
176
|
+
readonly ingest: IngestOptions;
|
|
177
|
+
}
|
|
178
|
+
/** 注册 `thesis_ingest`(同步注册,走仓库统一的 `definePaperTool`;斜杠命令见 `commands.ts`)。 */
|
|
179
|
+
export declare function registerIngest(ctx: Context, options: RegisterIngestOptions): void;
|