Documentation
¶
Index ¶
- Constants
- func AppendDecisionResultsTable(content string, rows []DecisionExportRow) string
- func AppendToBody(body, chunk string) string
- func BodyHash(body string) string
- func BuildIndexMarkdown(workflowID string, entries []ExportEntry) string
- func CountBlueprintGaps(items []BlueprintItem) int
- func ExtractLinks(fromPath, body string) []string
- func ExtractTitle(body, fileName string) string
- func GetSection(body, section string) (string, bool)
- func NormalizePath(raw string) (string, error)
- func ParentPrefix(parent, child string) bool
- func PathBaseName(p string) string
- func PathDir(p string) string
- func PrependToBody(body, chunk string) string
- func ReplaceSection(body, section, newSection string) (string, error)
- func ScoreDocument(q, path, title, body string, tags []string) (float64, string, string)
- func UniqueDecisionIDs(decisions []ParsedDecision) []string
- type BlueprintItem
- type DecisionCard
- type DecisionExportRow
- type DecisionOption
- type ExportEntry
- type Heading
- type ParsedDecision
- type SearchHit
Constants ¶
const ( PathMaxLen = 512 BodyMaxBytes = 200 * 1024 TagMax = 8 TagItemMax = 24 DocsPerWFMax = 500 // DocsPerProjectMax 是项目范围列表一次最多取多少篇(设计稿 06 §3.3:每项目 2000)。 DocsPerProjectMax = 2000 ImportMaxFiles = 100 ImportMaxBytes = 2 * 1024 * 1024 RevisionKeep = 50 )
Variables ¶
This section is empty.
Functions ¶
func AppendDecisionResultsTable ¶
func AppendDecisionResultsTable(content string, rows []DecisionExportRow) string
AppendDecisionResultsTable 在 Markdown 末尾追加决策结果表。
func BuildIndexMarkdown ¶
func BuildIndexMarkdown(workflowID string, entries []ExportEntry) string
BuildIndexMarkdown 生成 INDEX.md 内容。
func CountBlueprintGaps ¶
func CountBlueprintGaps(items []BlueprintItem) int
CountBlueprintGaps 返回缺口数量。
func ExtractLinks ¶
ExtractLinks 从正文里取出指向其他文档的链接目标(已规范化为 .md 路径)。 识别 [path] / [[path|显示名]] / [[path#锚点]],以及 [文字](相对路径.md); 带协议的外链、纯锚点、绝对路径、Artifact 引用([[artifact:N]])都跳过。 fromPath 是当前文档路径,用来解析 ./ 和 ../ 开头的相对链接;结果去重并保持出现顺序。
func ExtractTitle ¶
ExtractTitle 取第一个 H1,否则用文件名(不含 .md)。
func GetSection ¶
GetSection 按标题文本或锚点取一节(从该标题到同级或更高级标题之前)。
func NormalizePath ¶
NormalizePath 规范化文档路径:去首尾空白、反斜杠转正斜杠、无扩展名补 .md。 不通过校验时返回 error。
func ParentPrefix ¶
ParentPrefix 若 prefix 是 parent 的前缀(按路径段),返回 true。
func ReplaceSection ¶
ReplaceSection 替换一节;找不到标题时返回 error。
func ScoreDocument ¶
ScoreDocument 对单篇文档打分(q 已在调用方 trim 并小写)。
func UniqueDecisionIDs ¶
func UniqueDecisionIDs(decisions []ParsedDecision) []string
UniqueDecisionIDs 检查文档内 decision id 是否唯一;返回重复的 id。
Types ¶
type BlueprintItem ¶
type BlueprintItem struct {
Path string `json:"path"`
Title string `json:"title"`
Hint string `json:"hint"`
Present bool `json:"present"`
SuggestedKind string `json:"suggested_kind,omitempty"`
Template string `json:"template,omitempty"`
}
BlueprintItem 是推荐文档结构里的一项。
func Blueprint ¶
func Blueprint(existingPaths map[string]bool, withTemplates bool) []BlueprintItem
Blueprint 对照已有路径指出缺口。
func ProjectBlueprint ¶
func ProjectBlueprint(existingPaths map[string]bool, modulePaths []string, withTemplates bool) []BlueprintItem
ProjectBlueprint 给出项目知识库的推荐结构与缺口(设计稿 06 §4):固定的几篇总览类文档,加上每个已建模块的总述与设计。
type DecisionCard ¶
type DecisionCard struct {
ID string `json:"id"`
Title string `json:"title"`
Body string `json:"body,omitempty"`
Options []DecisionOption `json:"options"`
Default string `json:"default"`
Multi bool `json:"multi,omitempty"`
Note bool `json:"note,omitempty"`
Risk string `json:"risk,omitempty"`
}
DecisionCard 是 ```decision 围栏内的结构化决策(本批只解析与展示,作答在第二波)。
type DecisionExportRow ¶
DecisionExportRow 供导出表使用的决策结果行。
type DecisionOption ¶
type DecisionOption struct {
ID string `json:"id"`
Label string `json:"label"`
Detail string `json:"detail,omitempty"`
Recommended bool `json:"recommended,omitempty"`
}
DecisionOption 是决策卡里的一个选项。
type ExportEntry ¶
type ExportEntry struct {
Path string `json:"path"`
Title string `json:"title"`
Kind string `json:"kind"`
Status string `json:"status"`
Rev int `json:"rev"`
Hash string `json:"hash"`
Updated string `json:"updated_at"`
}
ExportEntry 是导出清单里的一篇文档。
type Heading ¶
type Heading struct {
Level int `json:"level"`
Text string `json:"text"`
Anchor string `json:"anchor"`
Line int `json:"line"` // 1-based
}
Heading 是正文里的一级~六级标题(围栏代码块内的 # 不算)。
func ParseHeadings ¶
ParseHeadings 解析 Markdown 标题并生成锚点(中文友好 slug,同名加序号)。
type ParsedDecision ¶
type ParsedDecision struct {
Card DecisionCard `json:"card"`
StartLine int `json:"start_line"`
EndLine int `json:"end_line"`
RawJSON string `json:"-"`
Errors []string `json:"errors,omitempty"`
Status string `json:"status"` // 本批恒为 pending
StatusNote string `json:"status_note,omitempty"`
}
ParsedDecision 带围栏位置与校验结果。
func ParseDecisions ¶
func ParseDecisions(body string) []ParsedDecision
ParseDecisions 扫描正文中的 decision 围栏并校验 JSON。