dsh-thesis 1.0.0 → 1.0.1
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 +27 -1
- package/LICENSE +21 -21
- package/README.md +64 -185
- package/docs/host-api.md +692 -640
- package/lib/codewalk/host-types.d.ts +4 -2
- package/lib/gates/messages.d.ts +7 -3
- package/lib/gates/messages.js +7 -4
- package/lib/intake/gate-rules.d.ts +6 -5
- package/lib/intake/gate-rules.js +6 -2
- package/lib/paper/lib/docx.js +70 -70
- package/lib/paper/lib/layout.js +371 -371
- package/lib/paper/lib/lit-cache.js +7 -7
- package/lib/paper/tools/decision.js +5 -5
- package/lib/paper/tools/lit.js +32 -32
- package/package.json +10 -5
|
@@ -122,8 +122,10 @@ export interface InjectedUserMessageShape {
|
|
|
122
122
|
readonly source: {
|
|
123
123
|
readonly kind: 'plugin';
|
|
124
124
|
readonly plugin: string;
|
|
125
|
-
|
|
126
|
-
readonly
|
|
125
|
+
/** 上下文形态:instructions / catalog / snapshot / notice / relay / recall(可缺省 = 不透明)。 */
|
|
126
|
+
readonly form?: string;
|
|
127
|
+
/** 只有 `form: 'snapshot'` 携带分节;`instructions` 形态的有效字段是 `changes`。 */
|
|
128
|
+
readonly sections?: readonly {
|
|
127
129
|
readonly name: string;
|
|
128
130
|
readonly text: string;
|
|
129
131
|
}[];
|
package/lib/gates/messages.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 闸门注入消息与决策理由的模板。
|
|
3
3
|
*
|
|
4
|
-
* 注入消息的 source 采用 `{ kind: 'plugin', plugin: 'dsh-thesis' }`:
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
4
|
+
* 注入消息的 source 采用 `{ kind: 'plugin', plugin: 'dsh-thesis', form: 'instructions' }`:
|
|
5
|
+
* - `plugin` 是生产者标识(GUI 用它做行首标签,也用于防重入识别"这已经是闸门消息");
|
|
6
|
+
* - `form` 声明这条上下文的语义形态(当前契约的取值域:instructions / catalog /
|
|
7
|
+
* snapshot / notice / relay / recall);
|
|
8
|
+
* - **不带 `sections`**:`sections` 只属于 `snapshot` 形态(见
|
|
9
|
+
* `ContextFormed`:`{ form: 'snapshot'; sections }`),instructions 形态的
|
|
10
|
+
* 渲染依据是 `changes`(工作区指令文件的改动清单),本闸门没有文件改动可报。
|
|
7
11
|
*
|
|
8
12
|
* 消息对象直接构造而不调用宿主的 `createUserMessage`:与共享层
|
|
9
13
|
* `definePaperTool` 同一取舍——生产环境的行为由宿主消费该结构时决定,
|
package/lib/gates/messages.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 闸门注入消息与决策理由的模板。
|
|
3
3
|
*
|
|
4
|
-
* 注入消息的 source 采用 `{ kind: 'plugin', plugin: 'dsh-thesis' }`:
|
|
5
|
-
* -
|
|
6
|
-
* -
|
|
4
|
+
* 注入消息的 source 采用 `{ kind: 'plugin', plugin: 'dsh-thesis', form: 'instructions' }`:
|
|
5
|
+
* - `plugin` 是生产者标识(GUI 用它做行首标签,也用于防重入识别"这已经是闸门消息");
|
|
6
|
+
* - `form` 声明这条上下文的语义形态(当前契约的取值域:instructions / catalog /
|
|
7
|
+
* snapshot / notice / relay / recall);
|
|
8
|
+
* - **不带 `sections`**:`sections` 只属于 `snapshot` 形态(见
|
|
9
|
+
* `ContextFormed`:`{ form: 'snapshot'; sections }`),instructions 形态的
|
|
10
|
+
* 渲染依据是 `changes`(工作区指令文件的改动清单),本闸门没有文件改动可报。
|
|
7
11
|
*
|
|
8
12
|
* 消息对象直接构造而不调用宿主的 `createUserMessage`:与共享层
|
|
9
13
|
* `definePaperTool` 同一取舍——生产环境的行为由宿主消费该结构时决定,
|
|
@@ -51,7 +55,6 @@ export function makeGateMessage(intentExcerpt, maxQuestions) {
|
|
|
51
55
|
source: {
|
|
52
56
|
...PLUGIN_SOURCE,
|
|
53
57
|
form: 'instructions',
|
|
54
|
-
sections: [{ name: '写作意图闸门', text }],
|
|
55
58
|
},
|
|
56
59
|
};
|
|
57
60
|
}
|
|
@@ -37,7 +37,12 @@ export type SpecStatus = {
|
|
|
37
37
|
export declare function judgeSpec(specText: string | undefined): SpecStatus;
|
|
38
38
|
/** 闸门注入给模型的指令(自包含:即使 intake 技能没加载也能执行最小流程)。 */
|
|
39
39
|
export declare function intakeGateInstruction(status: SpecStatus, specRel: string): string;
|
|
40
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* 构造注入消息(user 角色、插件来源、instructions 形态)。
|
|
42
|
+
*
|
|
43
|
+
* 与 `gates/messages.ts` 同源:`sections` 只属于 `snapshot` 形态,
|
|
44
|
+
* instructions 形态不带它(渲染依据是 `changes`,本闸门没有文件改动可报)。
|
|
45
|
+
*/
|
|
41
46
|
export declare function makeIntakeGateMessage(status: SpecStatus, specRel: string, id: string): {
|
|
42
47
|
id: string;
|
|
43
48
|
role: 'user';
|
|
@@ -49,9 +54,5 @@ export declare function makeIntakeGateMessage(status: SpecStatus, specRel: strin
|
|
|
49
54
|
kind: string;
|
|
50
55
|
plugin: string;
|
|
51
56
|
form: string;
|
|
52
|
-
sections: Array<{
|
|
53
|
-
name: string;
|
|
54
|
-
text: string;
|
|
55
|
-
}>;
|
|
56
57
|
};
|
|
57
58
|
};
|
package/lib/intake/gate-rules.js
CHANGED
|
@@ -101,7 +101,12 @@ export function intakeGateInstruction(status, specRel) {
|
|
|
101
101
|
'这条消息由插件闸门注入,不是用户需求的一部分,不得当作需求内容。',
|
|
102
102
|
].join('\n');
|
|
103
103
|
}
|
|
104
|
-
/**
|
|
104
|
+
/**
|
|
105
|
+
* 构造注入消息(user 角色、插件来源、instructions 形态)。
|
|
106
|
+
*
|
|
107
|
+
* 与 `gates/messages.ts` 同源:`sections` 只属于 `snapshot` 形态,
|
|
108
|
+
* instructions 形态不带它(渲染依据是 `changes`,本闸门没有文件改动可报)。
|
|
109
|
+
*/
|
|
105
110
|
export function makeIntakeGateMessage(status, specRel, id) {
|
|
106
111
|
const text = intakeGateInstruction(status, specRel);
|
|
107
112
|
return {
|
|
@@ -112,7 +117,6 @@ export function makeIntakeGateMessage(status, specRel, id) {
|
|
|
112
117
|
kind: 'plugin',
|
|
113
118
|
plugin: 'dsh-thesis',
|
|
114
119
|
form: 'instructions',
|
|
115
|
-
sections: [{ name: '意图规格闸门', text }],
|
|
116
120
|
},
|
|
117
121
|
};
|
|
118
122
|
}
|
package/lib/paper/lib/docx.js
CHANGED
|
@@ -116,72 +116,72 @@ function blockXml(block) {
|
|
|
116
116
|
// ---------------------------------------------------------------------------
|
|
117
117
|
// 文档装配
|
|
118
118
|
// ---------------------------------------------------------------------------
|
|
119
|
-
const CONTENT_TYPES = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
120
|
-
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
|
|
121
|
-
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
|
|
122
|
-
<Default Extension="xml" ContentType="application/xml"/>
|
|
123
|
-
<Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>
|
|
124
|
-
<Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/>
|
|
125
|
-
</Types>
|
|
119
|
+
const CONTENT_TYPES = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
120
|
+
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
|
|
121
|
+
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>
|
|
122
|
+
<Default Extension="xml" ContentType="application/xml"/>
|
|
123
|
+
<Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>
|
|
124
|
+
<Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/>
|
|
125
|
+
</Types>
|
|
126
126
|
`;
|
|
127
|
-
const ROOT_RELS = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
128
|
-
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
129
|
-
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/>
|
|
130
|
-
</Relationships>
|
|
127
|
+
const ROOT_RELS = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
128
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
129
|
+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/>
|
|
130
|
+
</Relationships>
|
|
131
131
|
`;
|
|
132
|
-
const DOCUMENT_RELS = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
133
|
-
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"/>
|
|
132
|
+
const DOCUMENT_RELS = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
133
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"/>
|
|
134
134
|
`;
|
|
135
|
-
const STYLES = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
136
|
-
<w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
|
|
137
|
-
<w:docDefaults>
|
|
138
|
-
<w:rPrDefault><w:rPr>
|
|
139
|
-
<w:rFonts w:ascii="Times New Roman" w:eastAsia="宋体" w:hAnsi="Times New Roman"/>
|
|
140
|
-
<w:sz w:val="24"/><w:szCs w:val="24"/>
|
|
141
|
-
</w:rPr></w:rPrDefault>
|
|
142
|
-
<w:pPrDefault><w:pPr><w:spacing w:line="360" w:lineRule="auto"/></w:pPr></w:pPrDefault>
|
|
143
|
-
</w:docDefaults>
|
|
144
|
-
<w:style w:type="paragraph" w:styleId="Normal"><w:name w:val="Normal"/></w:style>
|
|
145
|
-
<w:style w:type="paragraph" w:styleId="TitlePage">
|
|
146
|
-
<w:name w:val="Title Page"/>
|
|
147
|
-
<w:pPr><w:jc w:val="center"/><w:spacing w:before="1200" w:after="240"/></w:pPr>
|
|
148
|
-
<w:rPr><w:rFonts w:eastAsia="黑体"/><w:b/><w:sz w:val="44"/><w:szCs w:val="44"/></w:rPr>
|
|
149
|
-
</w:style>
|
|
150
|
-
<w:style w:type="paragraph" w:styleId="Subtitle">
|
|
151
|
-
<w:name w:val="Subtitle"/>
|
|
152
|
-
<w:pPr><w:jc w:val="center"/><w:spacing w:after="240"/></w:pPr>
|
|
153
|
-
<w:rPr><w:sz w:val="28"/><w:szCs w:val="28"/></w:rPr>
|
|
154
|
-
</w:style>
|
|
155
|
-
<w:style w:type="paragraph" w:styleId="Heading1">
|
|
156
|
-
<w:name w:val="heading 1"/>
|
|
157
|
-
<w:pPr><w:spacing w:before="240" w:after="120"/></w:pPr>
|
|
158
|
-
<w:rPr><w:rFonts w:eastAsia="黑体"/><w:b/><w:sz w:val="32"/><w:szCs w:val="32"/></w:rPr>
|
|
159
|
-
</w:style>
|
|
160
|
-
<w:style w:type="paragraph" w:styleId="Heading2">
|
|
161
|
-
<w:name w:val="heading 2"/>
|
|
162
|
-
<w:pPr><w:spacing w:before="200" w:after="100"/></w:pPr>
|
|
163
|
-
<w:rPr><w:rFonts w:eastAsia="黑体"/><w:b/><w:sz w:val="28"/><w:szCs w:val="28"/></w:rPr>
|
|
164
|
-
</w:style>
|
|
165
|
-
<w:style w:type="paragraph" w:styleId="Heading3">
|
|
166
|
-
<w:name w:val="heading 3"/>
|
|
167
|
-
<w:pPr><w:spacing w:before="160" w:after="80"/></w:pPr>
|
|
168
|
-
<w:rPr><w:rFonts w:eastAsia="黑体"/><w:b/><w:sz w:val="26"/><w:szCs w:val="26"/></w:rPr>
|
|
169
|
-
</w:style>
|
|
170
|
-
<w:style w:type="paragraph" w:styleId="ListBullet"><w:name w:val="List Bullet"/></w:style>
|
|
171
|
-
<w:style w:type="table" w:styleId="TableGrid">
|
|
172
|
-
<w:name w:val="Table Grid"/>
|
|
173
|
-
<w:tblPr>
|
|
174
|
-
<w:tblBorders>
|
|
175
|
-
<w:top w:val="single" w:sz="4" w:color="000000"/>
|
|
176
|
-
<w:left w:val="single" w:sz="4" w:color="000000"/>
|
|
177
|
-
<w:bottom w:val="single" w:sz="4" w:color="000000"/>
|
|
178
|
-
<w:right w:val="single" w:sz="4" w:color="000000"/>
|
|
179
|
-
<w:insideH w:val="single" w:sz="4" w:color="000000"/>
|
|
180
|
-
<w:insideV w:val="single" w:sz="4" w:color="000000"/>
|
|
181
|
-
</w:tblBorders>
|
|
182
|
-
</w:tblPr>
|
|
183
|
-
</w:style>
|
|
184
|
-
</w:styles>
|
|
135
|
+
const STYLES = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
136
|
+
<w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
|
|
137
|
+
<w:docDefaults>
|
|
138
|
+
<w:rPrDefault><w:rPr>
|
|
139
|
+
<w:rFonts w:ascii="Times New Roman" w:eastAsia="宋体" w:hAnsi="Times New Roman"/>
|
|
140
|
+
<w:sz w:val="24"/><w:szCs w:val="24"/>
|
|
141
|
+
</w:rPr></w:rPrDefault>
|
|
142
|
+
<w:pPrDefault><w:pPr><w:spacing w:line="360" w:lineRule="auto"/></w:pPr></w:pPrDefault>
|
|
143
|
+
</w:docDefaults>
|
|
144
|
+
<w:style w:type="paragraph" w:styleId="Normal"><w:name w:val="Normal"/></w:style>
|
|
145
|
+
<w:style w:type="paragraph" w:styleId="TitlePage">
|
|
146
|
+
<w:name w:val="Title Page"/>
|
|
147
|
+
<w:pPr><w:jc w:val="center"/><w:spacing w:before="1200" w:after="240"/></w:pPr>
|
|
148
|
+
<w:rPr><w:rFonts w:eastAsia="黑体"/><w:b/><w:sz w:val="44"/><w:szCs w:val="44"/></w:rPr>
|
|
149
|
+
</w:style>
|
|
150
|
+
<w:style w:type="paragraph" w:styleId="Subtitle">
|
|
151
|
+
<w:name w:val="Subtitle"/>
|
|
152
|
+
<w:pPr><w:jc w:val="center"/><w:spacing w:after="240"/></w:pPr>
|
|
153
|
+
<w:rPr><w:sz w:val="28"/><w:szCs w:val="28"/></w:rPr>
|
|
154
|
+
</w:style>
|
|
155
|
+
<w:style w:type="paragraph" w:styleId="Heading1">
|
|
156
|
+
<w:name w:val="heading 1"/>
|
|
157
|
+
<w:pPr><w:spacing w:before="240" w:after="120"/></w:pPr>
|
|
158
|
+
<w:rPr><w:rFonts w:eastAsia="黑体"/><w:b/><w:sz w:val="32"/><w:szCs w:val="32"/></w:rPr>
|
|
159
|
+
</w:style>
|
|
160
|
+
<w:style w:type="paragraph" w:styleId="Heading2">
|
|
161
|
+
<w:name w:val="heading 2"/>
|
|
162
|
+
<w:pPr><w:spacing w:before="200" w:after="100"/></w:pPr>
|
|
163
|
+
<w:rPr><w:rFonts w:eastAsia="黑体"/><w:b/><w:sz w:val="28"/><w:szCs w:val="28"/></w:rPr>
|
|
164
|
+
</w:style>
|
|
165
|
+
<w:style w:type="paragraph" w:styleId="Heading3">
|
|
166
|
+
<w:name w:val="heading 3"/>
|
|
167
|
+
<w:pPr><w:spacing w:before="160" w:after="80"/></w:pPr>
|
|
168
|
+
<w:rPr><w:rFonts w:eastAsia="黑体"/><w:b/><w:sz w:val="26"/><w:szCs w:val="26"/></w:rPr>
|
|
169
|
+
</w:style>
|
|
170
|
+
<w:style w:type="paragraph" w:styleId="ListBullet"><w:name w:val="List Bullet"/></w:style>
|
|
171
|
+
<w:style w:type="table" w:styleId="TableGrid">
|
|
172
|
+
<w:name w:val="Table Grid"/>
|
|
173
|
+
<w:tblPr>
|
|
174
|
+
<w:tblBorders>
|
|
175
|
+
<w:top w:val="single" w:sz="4" w:color="000000"/>
|
|
176
|
+
<w:left w:val="single" w:sz="4" w:color="000000"/>
|
|
177
|
+
<w:bottom w:val="single" w:sz="4" w:color="000000"/>
|
|
178
|
+
<w:right w:val="single" w:sz="4" w:color="000000"/>
|
|
179
|
+
<w:insideH w:val="single" w:sz="4" w:color="000000"/>
|
|
180
|
+
<w:insideV w:val="single" w:sz="4" w:color="000000"/>
|
|
181
|
+
</w:tblBorders>
|
|
182
|
+
</w:tblPr>
|
|
183
|
+
</w:style>
|
|
184
|
+
</w:styles>
|
|
185
185
|
`;
|
|
186
186
|
/**
|
|
187
187
|
* 生成完整 .docx 字节。title 渲染为封面页;markdown 为正文(章节合并内容)。
|
|
@@ -194,13 +194,13 @@ export function buildDocx(opts) {
|
|
|
194
194
|
body.push('<w:p/>');
|
|
195
195
|
for (const block of blocks)
|
|
196
196
|
body.push(blockXml(block));
|
|
197
|
-
const document = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
198
|
-
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
|
|
199
|
-
<w:body>
|
|
200
|
-
${body.join('')}
|
|
201
|
-
<w:sectPr><w:pgSz w:w="11906" w:h="16838"/><w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440"/></w:sectPr>
|
|
202
|
-
</w:body>
|
|
203
|
-
</w:document>
|
|
197
|
+
const document = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
198
|
+
<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
|
|
199
|
+
<w:body>
|
|
200
|
+
${body.join('')}
|
|
201
|
+
<w:sectPr><w:pgSz w:w="11906" w:h="16838"/><w:pgMar w:top="1440" w:right="1440" w:bottom="1440" w:left="1440"/></w:sectPr>
|
|
202
|
+
</w:body>
|
|
203
|
+
</w:document>
|
|
204
204
|
`;
|
|
205
205
|
const entries = [
|
|
206
206
|
{ name: '[Content_Types].xml', data: encoder.encode(CONTENT_TYPES) },
|