feat(agent): 增强开放平台文档自省与端点检索引导

- 规约硬化:在 SKILL.md 新增第 18 条执行原则,严禁 Agent 盲目翻找源码或用脚本暴力解析底层 specs JSON,确立 hose-use docs search/show 为唯一合法第一入口;
- 参考专卷:新增 skills/hose-use/references/docs.md,系统阐述 4 大文档子命令、加权搜索机制与售前方案调研 SOP;
- 内嵌打包:在 src/packaging/embedded-skill.ts 注册 references/docs.md,确保二进制与全局 Skill 分发无遗漏;
- 上下文自省:在 hose-use context (及 --json) 注入开放平台文档库就绪指标 (330 篇文档 / 279 个端点),并在诊断提示中显式引导 docs search 用法;
- 架构总纲:在 AGENTS.md 登记 docs 领域说明与零原始 JSON 侵入原则。
This commit is contained in:
gitea committed 2026-11-17 14:29:50 +08:00
1 parent 54382ae7ce
commit b787130880
6 files changed
+152 -1

No files matched your search

+16
View File
@@ -7,6 +7,7 @@ import {
getEnterprisesDirCandidates,
} from "../../core/config/loader.js";
import { ApprovalRepository } from "../../domains/approval/index.js";
import { getDocsCatalog } from "../../domains/docs/tools.js";
import { VERSION } from "../../version.js";
import { formatExpiresAt, formatSourceLabel, formatCorpEnvLabel, printJson } from "../printer.js";
import type { CliParsedArgs, CliResult, CliRuntime } from "../types.js";
@@ -53,6 +54,18 @@ export async function handleContextCommand(
// 容错处理(如 SQLite 尚未初始化等场景)
}
let docsStats = { totalDocs: 0, totalEndpoints: 0, ready: false };
try {
const catalog = await getDocsCatalog();
docsStats = {
totalDocs: catalog.totalDocs,
totalEndpoints: catalog.totalEndpoints,
ready: true,
};
} catch {
// 容错处理
}
const now = Date.now();
const validCorps = allCorps.filter((c) => c.persistent || !c.expiresAt || c.expiresAt > now);
const expiredCorps = allCorps.filter((c) => !c.persistent && c.expiresAt && c.expiresAt <= now);
@@ -114,6 +127,7 @@ export async function handleContextCommand(
pendingRunsCount,
totalRunsCount,
},
docsCatalog: docsStats,
runtime: {
mode: isStateful ? "stateful" : "stateless",
configFile,
@@ -152,6 +166,7 @@ export async function handleContextCommand(
` 凭证有效状态 : ${currentCorp ? formatExpiresAt(corpExpiresAt, currentPersistent, hasOpenApiPersistentCredentials(currentCorp) ? "openapi" : currentCorp.source) : "-"}`,
` 主站 BaseURL : ${currentCorp?.baseUrl || "-"}`,
` 已配置企业总数: ${allCorps.length} 家 (🏭 正式: ${prodCount} 家, 🧪 测试: ${testCount} 家, 🎪 演示: ${demoCount} 家)`,
` 开放平台接口库: ${docsStats.ready ? `已就绪 (${docsStats.totalDocs} 篇文档 / ${docsStats.totalEndpoints} 个端点,可用 hose-use docs search 检索)` : "未就绪"}`,
` AI PRO 规约库 : ${scopesStr}`,
` AI PRO 待决断 : ${pendingRunsCount} 个待决断会话 (当前企业历史总会话: ${totalRunsCount} 个)`,
` 运行模式设置 : ${isStateful ? "有状态模式 (Stateful - 自动记忆当前企业)" : "无状态模式 (Stateless)"}`,
@@ -160,6 +175,7 @@ export async function handleContextCommand(
"",
"提示:",
" - hose-use 与 hose-aipro 默认共享同一套企业与身份凭证上下文,无须重复配置。",
" - 调研合思开放接口与参数规范: hose-use docs search <关键词> 或 hose-use docs show <Path>",
" - 切换全局默认企业: hose-use corps switch <企业ID>",
" - 单次临时指定企业: hose-use --corp=<企业ID> <命令> 或 hose-aipro --corp=<企业ID> <子命令>",
" - AI PRO 专属上下文: hose-aipro status",