dknowc-dsh 1.2.0 → 1.3.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/package.json +2 -2
- package/skills/dknowc-official-doc-writer/README.md +15 -38
- package/skills/dknowc-official-doc-writer/SKILL.md +111 -218
- package/skills/dknowc-official-doc-writer/reference/local_memory_guide.md +53 -0
- package/skills/dknowc-official-doc-writer/reference/material_usage_guidance.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/onboarding_scripts.md +132 -0
- package/skills/dknowc-official-doc-writer/reference/output_guide.md +4 -4
- package/skills/dknowc-official-doc-writer/reference/review_checklist.md +16 -16
- package/skills/dknowc-official-doc-writer/reference/revision_workflow.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/sample_search_result.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/sample_trace_report.html +226 -76
- package/skills/dknowc-official-doc-writer/reference/search_guide.md +35 -32
- package/skills/dknowc-official-doc-writer/reference/search_intro.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/search_policy.md +12 -12
- package/skills/dknowc-official-doc-writer/reference/standards/01_report.md +3 -2
- package/skills/dknowc-official-doc-writer/reference/standards/02_qingshi.md +3 -2
- package/skills/dknowc-official-doc-writer/reference/standards/03_pifu.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/04_tongzhi.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/standards/05_yijian.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/06_han.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/standards/08_tongbao.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/09_tonggao.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/10_gonggao.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/11_fuhan_approve.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/12_fuhan_objection.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/13_reminder.md +3 -3
- package/skills/dknowc-official-doc-writer/reference/standards/14_generic.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/16_decision.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/18_order.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/standards/19_gazette.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/standards/20_motion.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/22_application.md +2 -2
- package/skills/dknowc-official-doc-writer/reference/standards/23_publicity.md +1 -1
- package/skills/dknowc-official-doc-writer/reference/task_router.md +10 -10
- package/skills/dknowc-official-doc-writer/scripts/api_key.py +41 -0
- package/skills/dknowc-official-doc-writer/scripts/dkag_search.py +31 -6
- package/skills/dknowc-official-doc-writer/scripts/format_document.py +30 -26
- package/skills/dknowc-official-doc-writer/scripts/initialize.py +48 -18
- package/skills/dknowc-official-doc-writer/scripts/local_memory.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/mcp_direct.py +8 -0
- package/skills/dknowc-official-doc-writer/scripts/merge_search_results.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/outline_reference.py +7 -11
- package/skills/dknowc-official-doc-writer/scripts/register.mjs +49 -8
- package/skills/dknowc-official-doc-writer/scripts/render_trace_html.py +220 -125
- package/skills/dknowc-official-doc-writer/scripts/review_document.py +1 -1
- package/skills/dknowc-official-doc-writer/scripts/source_note_html.py +34 -44
- package/skills/dknowc-official-doc-writer/scripts/template_generator.py +3 -3
- package/skills/dknowc-ppt-assistant/README.md +4 -4
- package/skills/dknowc-ppt-assistant/SKILL.md +16 -20
- package/skills/dknowc-ppt-assistant/references/content-pack.md +3 -3
- package/skills/dknowc-ppt-assistant/references/material_usage.md +9 -6
- package/skills/dknowc-ppt-assistant/references/onboarding_scripts.md +120 -0
- package/skills/dknowc-ppt-assistant/references/sample_search_result.md +1 -1
- package/skills/dknowc-ppt-assistant/references/sample_trace_report.html +500 -0
- package/skills/dknowc-ppt-assistant/references/search_intro.md +1 -1
- package/skills/dknowc-ppt-assistant/scripts/api_key.py +41 -0
- package/skills/dknowc-ppt-assistant/scripts/initialize.py +54 -13
- package/skills/dknowc-ppt-assistant/scripts/mcp_direct.py +8 -0
- package/skills/dknowc-ppt-assistant/scripts/register_key.mjs +56 -9
- package/skills/dknowc-ppt-assistant/scripts/render_trace_html.py +260 -118
- package/skills/dknowc-ppt-assistant/scripts/trusted_search.py +65 -15
- package/skills/dknowc-ppt-assistant/workflows/generate-pptx.md +8 -8
- package/skills/dknowc-ppt-assistant/workflows/routing.md +1 -1
- package/skills/dknowc-trusted-consulting/README.md +8 -9
- package/skills/dknowc-trusted-consulting/SKILL.md +47 -32
- package/skills/dknowc-trusted-consulting/reference/consult_intro.md +3 -35
- package/skills/dknowc-trusted-consulting/reference/onboarding_scripts.md +132 -0
- package/skills/dknowc-trusted-consulting/reference/sample_trace_report.html +105 -60
- package/skills/dknowc-trusted-consulting/scripts/api_key.py +41 -0
- package/skills/dknowc-trusted-consulting/scripts/gov_chat.py +39 -19
- package/skills/dknowc-trusted-consulting/scripts/initialize.py +64 -20
- package/skills/dknowc-trusted-consulting/scripts/mcp_direct.py +8 -0
- package/skills/dknowc-trusted-consulting/scripts/register_key.mjs +120 -21
- package/skills/dknowc-trusted-consulting/scripts/render_trace_html.py +165 -161
- package/skills/dknowc-trusted-search/README.md +1 -1
- package/skills/dknowc-trusted-search/SKILL.md +32 -33
- package/skills/dknowc-trusted-search/reference/onboarding_scripts.md +132 -0
- package/skills/dknowc-trusted-search/reference/sample_trace_report.html +108 -52
- package/skills/dknowc-trusted-search/scripts/api_key.py +41 -0
- package/skills/dknowc-trusted-search/scripts/deep_query.py +81 -9
- package/skills/dknowc-trusted-search/scripts/initialize.py +65 -17
- package/skills/dknowc-trusted-search/scripts/mcp_direct.py +8 -0
- package/skills/dknowc-trusted-search/scripts/register_key.mjs +111 -24
- package/skills/dknowc-trusted-search/scripts/render_policy_visualization.py +2 -3
- package/skills/dknowc-trusted-search/scripts/render_trace_html.py +298 -226
- package/skills/dknowc-trusted-search/scripts/trusted_search.py +80 -11
- package/src/index.js +3 -3
- package/skills/dknowc-official-doc-writer/official-docs/input/mcp_intro_content.md +0 -61
- package/skills/dknowc-trusted-search/reference/search_intro.md +0 -79
|
@@ -15,6 +15,7 @@ Public 版统一只从环境变量 DKNOWC_API_KEY 读取 API Key。
|
|
|
15
15
|
import argparse
|
|
16
16
|
import json
|
|
17
17
|
import os
|
|
18
|
+
import sys
|
|
18
19
|
import platform
|
|
19
20
|
import shutil
|
|
20
21
|
|
|
@@ -47,46 +48,59 @@ def _looks_like_key(value: str) -> bool:
|
|
|
47
48
|
|
|
48
49
|
|
|
49
50
|
def _in_dsh() -> bool:
|
|
50
|
-
"""dsh 环境标志:dsh 的 bash 工具会注入 DSH_SHELL=1。
|
|
51
|
-
|
|
52
|
-
dsh 场景下,脚本子进程无法隐式继承 DKNOWC_API_KEY(dsh 安全机制会清理
|
|
53
|
-
名字含 KEY 的环境变量),但 dsh 插件会通过 shell-env 显式通道把该 Key
|
|
54
|
-
注入为 DSH_DKNOWC_API_KEY。检索子能力走 MCP 转接,无 Key 时仅暂停
|
|
55
|
-
检索,不阻断纯生成任务。
|
|
56
|
-
"""
|
|
51
|
+
"""dsh 环境标志:dsh 的 bash 工具会注入 DSH_SHELL=1。"""
|
|
57
52
|
return os.environ.get("DSH_SHELL") == "1"
|
|
58
53
|
|
|
59
54
|
|
|
60
55
|
def check_api_key_config():
|
|
61
56
|
if _in_dsh():
|
|
57
|
+
# dsh 场景:优先插件经 shell-env 注入的 DSH_DKNOWC_API_KEY(与 MCP Bearer 同源,
|
|
58
|
+
# 来源为 dsh 主进程环境变量 DKNOWC_API_KEY);缺失时 ~/.zshrc 兜底(注册成功
|
|
59
|
+
# 自动持久化后、dsh 重启前的窗口期不误报缺失)。无 Key 仅暂停检索,不阻断纯生成。
|
|
62
60
|
api_key = os.environ.get("DSH_DKNOWC_API_KEY", "").strip()
|
|
61
|
+
source = "environment"
|
|
62
|
+
if not _looks_like_key(api_key):
|
|
63
|
+
try:
|
|
64
|
+
from api_key import resolve_api_key as _rk
|
|
65
|
+
api_key2, source2 = _rk()
|
|
66
|
+
if _looks_like_key(api_key2):
|
|
67
|
+
api_key, source = api_key2, source2
|
|
68
|
+
except ImportError:
|
|
69
|
+
pass
|
|
63
70
|
if _looks_like_key(api_key):
|
|
64
71
|
return {
|
|
65
72
|
"api_key_configured": True,
|
|
66
73
|
"api_key_env": API_KEY_ENV,
|
|
67
|
-
"api_key_source":
|
|
74
|
+
"api_key_source": source,
|
|
68
75
|
"api_key_hint": None,
|
|
69
76
|
}
|
|
70
77
|
return {
|
|
71
78
|
"api_key_configured": False,
|
|
72
79
|
"api_key_env": API_KEY_ENV,
|
|
73
80
|
"api_key_source": None,
|
|
74
|
-
"api_key_hint": f"未检测到可用的 {API_KEY_ENV}(dsh
|
|
81
|
+
"api_key_hint": f"未检测到可用的 {API_KEY_ENV}(dsh 主进程环境变量与 ~/.zshrc 中均未找到)。需要先将有效的 API Key 配置到启动 dsh 的环境变量 {API_KEY_ENV}(如 ~/.zshrc),再重启 dsh 或新建会话。仅检索任务受影响,不涉及检索的生成任务可继续。",
|
|
75
82
|
}
|
|
76
83
|
|
|
77
|
-
|
|
84
|
+
# 环境变量优先,缺失时从 ~/.zshrc 兜底解析(宿主进程早于 key 写入启动、
|
|
85
|
+
# 或宿主不再加载 ~/.zshrc 导出变量时不误报缺失,与公文写作同源方案)
|
|
86
|
+
try:
|
|
87
|
+
from api_key import resolve_api_key
|
|
88
|
+
api_key, source = resolve_api_key()
|
|
89
|
+
except ImportError:
|
|
90
|
+
api_key = os.environ.get(API_KEY_ENV, "").strip()
|
|
91
|
+
source = "environment" if api_key else ""
|
|
78
92
|
if _looks_like_key(api_key):
|
|
79
93
|
return {
|
|
80
94
|
"api_key_configured": True,
|
|
81
95
|
"api_key_env": API_KEY_ENV,
|
|
82
|
-
"api_key_source":
|
|
96
|
+
"api_key_source": source,
|
|
83
97
|
"api_key_hint": None,
|
|
84
98
|
}
|
|
85
99
|
return {
|
|
86
100
|
"api_key_configured": False,
|
|
87
101
|
"api_key_env": API_KEY_ENV,
|
|
88
102
|
"api_key_source": None,
|
|
89
|
-
"api_key_hint": f"本 Skill 的素材检索需要通过环境变量 {API_KEY_ENV}
|
|
103
|
+
"api_key_hint": f"本 Skill 的素材检索需要通过环境变量 {API_KEY_ENV}(或 ~/.zshrc 持久化)连接深知可信智能服务。当前两处均未检测到可用 Key,请先注册或登录深知可信智能 MaaS 账号获取 API Key。",
|
|
90
104
|
}
|
|
91
105
|
|
|
92
106
|
|
|
@@ -131,8 +145,33 @@ def check_environment():
|
|
|
131
145
|
if not config_status["api_key_configured"]:
|
|
132
146
|
search_blocking_issues.append("api_key_missing")
|
|
133
147
|
|
|
148
|
+
# guide_message:需要检索但 Key 未配置时给用户的引导话术(S1 三段式:价值 / 权益+开通方式 / 退路+样例钩子)。
|
|
149
|
+
# Agent 结合当前任务语境转述(完整口径见 references/onboarding_scripts.md)。
|
|
150
|
+
guide_message = None if config_status["api_key_configured"] else (
|
|
151
|
+
"这份汇报 PPT 需要引用政策原文和权威数据,凭印象写政策名和数字,汇报场合被当场指出来最影响效果。"
|
|
152
|
+
"开通权威检索后,每条政策、数据都带原文出处、可点开核验,权威数据还能直接做成可编辑的原生图表。\n"
|
|
153
|
+
"开通是免费的:自带 300 次权威检索额度,完成实名认证还能再领 100 元体验金。"
|
|
154
|
+
"只需手机号收一次验证码——两步、约 10 秒,不用去网站,剩下的我来办;手机号仅用于本次验证,不会有营销骚扰。\n"
|
|
155
|
+
"也可以先不开通:我基于你手头的材料先把 PPT 做出来,政策和数据的位置先标注「数据待核验」。"
|
|
156
|
+
"想先看看开通后自动生成的核验报告长什么样,我可以发你一份示例看看。"
|
|
157
|
+
)
|
|
158
|
+
# env_message:依赖缺失时给用户的统一话术——不暴露组件名(requests/python-pptx 对用户无意义);
|
|
159
|
+
# 就绪时不输出任何环境话题。多 Python 环境下检测口径以 python_executable 为准。
|
|
160
|
+
missing_basic = [k for k, ok in (("小组件", requests_available),) if not ok]
|
|
161
|
+
missing_compile = 2 - int(python_pptx_available) - int(xlsxwriter_available)
|
|
162
|
+
if blocking_issues or pptx_blocking_issues:
|
|
163
|
+
total = len(missing_basic) + missing_compile
|
|
164
|
+
env_message = (
|
|
165
|
+
f"检测到本机制作环境需要补装 {'一个' if total == 1 else str(total)} 个小组件"
|
|
166
|
+
"(约 10 秒,只装一次),我现在装好可以吗?"
|
|
167
|
+
"(基础小组件影响检索,编译小组件影响最后的 PPT 导出,缺失时我会自动用隔离环境补齐)"
|
|
168
|
+
)
|
|
169
|
+
else:
|
|
170
|
+
env_message = None
|
|
171
|
+
|
|
134
172
|
return {
|
|
135
173
|
"python": platform.python_version(),
|
|
174
|
+
"python_executable": sys.executable,
|
|
136
175
|
"python3_available": python3_available,
|
|
137
176
|
"requests": requests_available,
|
|
138
177
|
"python_pptx": python_pptx_available,
|
|
@@ -152,7 +191,9 @@ def check_environment():
|
|
|
152
191
|
),
|
|
153
192
|
"blocking_issues": blocking_issues,
|
|
154
193
|
"ready": not blocking_issues,
|
|
155
|
-
"
|
|
194
|
+
"guide_message": guide_message,
|
|
195
|
+
"env_message": env_message,
|
|
196
|
+
"maas_platform_url": "https://platform.dknowc.cn/auth/#/login",
|
|
156
197
|
"environment_state": {
|
|
157
198
|
"dependency_install_declined": bool(state.get("dependency_install_declined")),
|
|
158
199
|
},
|
|
@@ -119,6 +119,14 @@ def main() -> int:
|
|
|
119
119
|
args = parser.parse_args()
|
|
120
120
|
|
|
121
121
|
api_key = os.environ.get(API_KEY_ENV, "").strip()
|
|
122
|
+
if not api_key:
|
|
123
|
+
# dsh 兜底:注册成功后 Key 已自动写入 ~/.zshrc(register_key.mjs 持久化),
|
|
124
|
+
# 本进程环境变量可能未注入——从 ~/.zshrc 解析(api_key.py 同源逻辑)。
|
|
125
|
+
try:
|
|
126
|
+
from api_key import resolve_api_key
|
|
127
|
+
api_key, _src = resolve_api_key()
|
|
128
|
+
except ImportError:
|
|
129
|
+
pass
|
|
122
130
|
if not api_key:
|
|
123
131
|
print(f"错误:缺少环境变量 {API_KEY_ENV}(请用 DKNOWC_API_KEY=<key> 前缀赋值方式传入)。", file=sys.stderr)
|
|
124
132
|
return 2
|
|
@@ -10,7 +10,7 @@ const DEFAULT_CHANNEL = "46A3BA1D-3E1A-4E8C-BD50-A6DCBEE1DB05";
|
|
|
10
10
|
const DEFAULT_TYPE = "11";
|
|
11
11
|
const DEFAULT_SOURCE = "agent";
|
|
12
12
|
const API_KEY_ENV = "DKNOWC_API_KEY";
|
|
13
|
-
const MAAS_PLATFORM_URL = "https://platform.dknowc.cn/";
|
|
13
|
+
const MAAS_PLATFORM_URL = "https://platform.dknowc.cn/auth/#/login";
|
|
14
14
|
|
|
15
15
|
function parseArgs(argv) {
|
|
16
16
|
const out = { _: [] };
|
|
@@ -85,6 +85,15 @@ async function createNewApiKey(openBase, existingApiKey, name, remark) {
|
|
|
85
85
|
return { result, apiKey };
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
+
function maskPhone(phone) {
|
|
89
|
+
const p = String(phone || "");
|
|
90
|
+
return p.length === 11 ? `${p.slice(0, 3)}****${p.slice(-4)}` : p;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function isValidCnPhone(phone) {
|
|
94
|
+
return /^1[3-9]\d{9}$/.test(String(phone || ""));
|
|
95
|
+
}
|
|
96
|
+
|
|
88
97
|
function maskKey(apiKey) {
|
|
89
98
|
if (!apiKey) return null;
|
|
90
99
|
if (apiKey.length <= 12) return "***";
|
|
@@ -102,12 +111,33 @@ async function main() {
|
|
|
102
111
|
process.exit(2);
|
|
103
112
|
}
|
|
104
113
|
const channel = args.channel && args.channel !== true ? args.channel : DEFAULT_CHANNEL;
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
114
|
+
if (!isValidCnPhone(args.phone)) {
|
|
115
|
+
console.log(JSON.stringify({
|
|
116
|
+
status: false,
|
|
117
|
+
msg: "手机号格式不正确",
|
|
118
|
+
user_message: "这个手机号格式好像不对,麻烦核对一下再发我。",
|
|
119
|
+
}));
|
|
120
|
+
process.exit(1);
|
|
121
|
+
}
|
|
122
|
+
let result;
|
|
123
|
+
try {
|
|
124
|
+
result = await postJson(`${base}/sendMessage`, {
|
|
125
|
+
phone: args.phone,
|
|
126
|
+
type: "register",
|
|
127
|
+
channel,
|
|
128
|
+
});
|
|
129
|
+
} catch (e) {
|
|
130
|
+
result = { status: false, msg: String((e && e.message) || e) };
|
|
131
|
+
}
|
|
132
|
+
// user_message:给用户的固定话术,Agent 必须原样转述,不得改写后发挥。
|
|
133
|
+
let userMessage;
|
|
134
|
+
if (result.status) {
|
|
135
|
+
userMessage = `验证码已发送到 ${maskPhone(args.phone)},请把最新一条短信里的 6 位验证码发我。`;
|
|
136
|
+
} else {
|
|
137
|
+
userMessage = `验证码发送没成功(可能是网络或短信通道问题),可以再试一次;如果连续失败,也可以用网页方式开通:${MAAS_PLATFORM_URL}`;
|
|
138
|
+
}
|
|
139
|
+
console.log(JSON.stringify({ ...result, user_message: userMessage }));
|
|
140
|
+
if (result.status) console.error("验证码已发送(话术见 user_message,请向用户转述后索取 6 位验证码)。");
|
|
111
141
|
process.exit(result.status ? 0 : 1);
|
|
112
142
|
}
|
|
113
143
|
|
|
@@ -152,13 +182,29 @@ async function main() {
|
|
|
152
182
|
apiKey = created.apiKey;
|
|
153
183
|
newKeyCreated = true;
|
|
154
184
|
} else {
|
|
155
|
-
|
|
185
|
+
// 新建失败:沿用原密钥继续并如实告知,不弃 key、不冒充新 Key
|
|
156
186
|
newKeyError = created.result.errmsg || created.result.msg || "新 API Key 创建失败";
|
|
157
187
|
}
|
|
158
188
|
}
|
|
159
189
|
|
|
190
|
+
// user_message:给用户的固定话术,Agent 必须原样转述,不得改写后发挥。
|
|
191
|
+
const registered = Boolean(apiKey);
|
|
192
|
+
let userMessage;
|
|
193
|
+
if (registered && data.existed) {
|
|
194
|
+
userMessage = "这个手机号之前开通过,已直接找回原来的密钥和额度,不用重新注册。我马上开始检索。";
|
|
195
|
+
} else if (registered) {
|
|
196
|
+
userMessage = "开通成功,访问密钥已写入本机,300 次免费检索额度已生效。我马上开始检索。";
|
|
197
|
+
} else if (/vcode|验证码/i.test(String(result.msg || ""))) {
|
|
198
|
+
userMessage = `验证码校验没通过(可能是输入有误或已过期)。请核对 ${maskPhone(args.phone)} 最新一条短信的 6 位验证码重新发我;需要我重新发送一条,直接说一声。`;
|
|
199
|
+
} else {
|
|
200
|
+
userMessage = `开通服务暂时没连上(${result.msg || "网络波动"}),可以稍后再试,或用网页方式开通:${MAAS_PLATFORM_URL}`;
|
|
201
|
+
}
|
|
202
|
+
if (registered && newKeyError) {
|
|
203
|
+
userMessage += ` 另外你要求的新密钥生成失败(${newKeyError}),已先沿用现有密钥继续,不影响使用;需要的话稍后再重新生成。`;
|
|
204
|
+
}
|
|
205
|
+
|
|
160
206
|
console.log(JSON.stringify({
|
|
161
|
-
status:
|
|
207
|
+
status: registered,
|
|
162
208
|
msg: result.msg,
|
|
163
209
|
url: data.url || null,
|
|
164
210
|
existed: Boolean(data.existed),
|
|
@@ -172,6 +218,7 @@ async function main() {
|
|
|
172
218
|
persistInstruction: `本次返回的 apiKey 仅供当前任务临时注入 ${API_KEY_ENV}。任务完成后,建议用户在 SkillHub/WorkBuddy 平台环境变量或密钥配置中保存 ${API_KEY_ENV}。`,
|
|
173
219
|
fallbackRegisterUrl: MAAS_PLATFORM_URL,
|
|
174
220
|
newKeyError,
|
|
221
|
+
user_message: userMessage,
|
|
175
222
|
}));
|
|
176
223
|
process.exit(apiKey && !newKeyError ? 0 : 1);
|
|
177
224
|
}
|