dknowc-dsh 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/LICENSE +21 -0
- package/README.md +131 -0
- package/cordis.patch.yml +17 -0
- package/package.json +33 -0
- package/skills/dknowc-official-doc-writer/README.md +156 -0
- package/skills/dknowc-official-doc-writer/SKILL.md +462 -0
- package/skills/dknowc-official-doc-writer/config/format.json +101 -0
- package/skills/dknowc-official-doc-writer/config/user_profile.json.example +6 -0
- package/skills/dknowc-official-doc-writer/official-docs/input/mcp_intro_content.md +61 -0
- package/skills/dknowc-official-doc-writer/reference/anti_ai_patterns.md +113 -0
- package/skills/dknowc-official-doc-writer/reference/fact_discipline.md +62 -0
- package/skills/dknowc-official-doc-writer/reference/material_usage_guidance.md +138 -0
- package/skills/dknowc-official-doc-writer/reference/output_guide.md +288 -0
- package/skills/dknowc-official-doc-writer/reference/review_checklist.md +156 -0
- package/skills/dknowc-official-doc-writer/reference/search_guide.md +317 -0
- package/skills/dknowc-official-doc-writer/reference/search_intro.md +15 -0
- package/skills/dknowc-official-doc-writer/reference/search_policy.md +284 -0
- package/skills/dknowc-official-doc-writer/reference/standards/00_index.md +151 -0
- package/skills/dknowc-official-doc-writer/reference/standards/01_report.md +51 -0
- package/skills/dknowc-official-doc-writer/reference/standards/02_qingshi.md +53 -0
- package/skills/dknowc-official-doc-writer/reference/standards/03_pifu.md +48 -0
- package/skills/dknowc-official-doc-writer/reference/standards/04_tongzhi.md +51 -0
- package/skills/dknowc-official-doc-writer/reference/standards/05_yijian.md +55 -0
- package/skills/dknowc-official-doc-writer/reference/standards/06_han.md +81 -0
- package/skills/dknowc-official-doc-writer/reference/standards/07_minutes.md +46 -0
- package/skills/dknowc-official-doc-writer/reference/standards/08_tongbao.md +53 -0
- package/skills/dknowc-official-doc-writer/reference/standards/09_tonggao.md +45 -0
- package/skills/dknowc-official-doc-writer/reference/standards/10_gonggao.md +44 -0
- package/skills/dknowc-official-doc-writer/reference/standards/11_fuhan_approve.md +46 -0
- package/skills/dknowc-official-doc-writer/reference/standards/12_fuhan_objection.md +46 -0
- package/skills/dknowc-official-doc-writer/reference/standards/13_reminder.md +46 -0
- package/skills/dknowc-official-doc-writer/reference/standards/14_generic.md +41 -0
- package/skills/dknowc-official-doc-writer/reference/standards/15_business_docs.md +47 -0
- package/skills/dknowc-official-doc-writer/reference/standards/16_decision.md +47 -0
- package/skills/dknowc-official-doc-writer/reference/standards/17_resolution.md +45 -0
- package/skills/dknowc-official-doc-writer/reference/standards/18_order.md +44 -0
- package/skills/dknowc-official-doc-writer/reference/standards/19_gazette.md +45 -0
- package/skills/dknowc-official-doc-writer/reference/standards/20_motion.md +45 -0
- package/skills/dknowc-official-doc-writer/reference/standards/21_explanation.md +40 -0
- package/skills/dknowc-official-doc-writer/reference/standards/22_application.md +47 -0
- package/skills/dknowc-official-doc-writer/reference/standards/23_publicity.md +46 -0
- package/skills/dknowc-official-doc-writer/reference/standards/24_procurement.md +40 -0
- package/skills/dknowc-official-doc-writer/reference/standards/25_plan.md +42 -0
- package/skills/dknowc-official-doc-writer/reference/standards/26_summary.md +42 -0
- package/skills/dknowc-official-doc-writer/reference/standards/27_speech.md +43 -0
- package/skills/dknowc-official-doc-writer/reference/standards/28_rules.md +40 -0
- package/skills/dknowc-official-doc-writer/reference/standards/29_research.md +42 -0
- package/skills/dknowc-official-doc-writer/reference/standards/30_feasibility.md +42 -0
- package/skills/dknowc-official-doc-writer/reference/standards/31_review_material.md +40 -0
- package/skills/dknowc-official-doc-writer/reference/standards/32_ai_compute.md +41 -0
- package/skills/dknowc-official-doc-writer/reference/standards/99_expressions.md +569 -0
- package/skills/dknowc-official-doc-writer/reference/task_router.md +119 -0
- package/skills/dknowc-official-doc-writer/scripts/adapt_mcp_result.py +241 -0
- package/skills/dknowc-official-doc-writer/scripts/check_release.py +78 -0
- package/skills/dknowc-official-doc-writer/scripts/dkag_search.py +575 -0
- package/skills/dknowc-official-doc-writer/scripts/format_document.py +1756 -0
- package/skills/dknowc-official-doc-writer/scripts/initialize.py +178 -0
- package/skills/dknowc-official-doc-writer/scripts/mcp_direct.py +158 -0
- package/skills/dknowc-official-doc-writer/scripts/merge_search_results.py +223 -0
- package/skills/dknowc-official-doc-writer/scripts/outline_reference.py +202 -0
- package/skills/dknowc-official-doc-writer/scripts/prose_lint.py +242 -0
- package/skills/dknowc-official-doc-writer/scripts/register.mjs +218 -0
- package/skills/dknowc-official-doc-writer/scripts/render_trace_html.py +966 -0
- package/skills/dknowc-official-doc-writer/scripts/review_document.py +127 -0
- package/skills/dknowc-official-doc-writer/scripts/source_note_html.py +180 -0
- package/skills/dknowc-official-doc-writer/scripts/template_generator.py +975 -0
- package/skills/dknowc-trusted-consulting/README.md +63 -0
- package/skills/dknowc-trusted-consulting/SKILL.md +172 -0
- package/skills/dknowc-trusted-consulting/scripts/adapt_mcp_result.py +241 -0
- package/skills/dknowc-trusted-consulting/scripts/check_release.py +66 -0
- package/skills/dknowc-trusted-consulting/scripts/gov_chat.py +475 -0
- package/skills/dknowc-trusted-consulting/scripts/initialize.py +89 -0
- package/skills/dknowc-trusted-consulting/scripts/mcp_direct.py +158 -0
- package/skills/dknowc-trusted-consulting/scripts/register_key.mjs +181 -0
- package/skills/dknowc-trusted-consulting/scripts/render_trace_html.py +990 -0
- package/skills/dknowc-trusted-search/README.md +63 -0
- package/skills/dknowc-trusted-search/SKILL.md +232 -0
- package/skills/dknowc-trusted-search/official-docs/output/.gitkeep +0 -0
- package/skills/dknowc-trusted-search/official-docs/search-results/.gitkeep +0 -0
- package/skills/dknowc-trusted-search/scripts/adapt_mcp_result.py +241 -0
- package/skills/dknowc-trusted-search/scripts/check_release.py +79 -0
- package/skills/dknowc-trusted-search/scripts/deep_query.py +266 -0
- package/skills/dknowc-trusted-search/scripts/initialize.py +89 -0
- package/skills/dknowc-trusted-search/scripts/mcp_direct.py +158 -0
- package/skills/dknowc-trusted-search/scripts/register_key.mjs +181 -0
- package/skills/dknowc-trusted-search/scripts/render_policy_visualization.py +889 -0
- package/skills/dknowc-trusted-search/scripts/render_trace_html.py +1011 -0
- package/skills/dknowc-trusted-search/scripts/trusted_search.py +325 -0
- package/src/index.js +103 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// MaaS key bootstrap helper for dsh distribution.
|
|
3
|
+
// It only requests/returns a key for the current task and never writes local files.
|
|
4
|
+
// node register_key.mjs send --phone <phone>
|
|
5
|
+
// node register_key.mjs register --phone <phone> --vcode <code> [--new-key]
|
|
6
|
+
|
|
7
|
+
const DEFAULT_BASE = "https://platform.dknowc.cn/auth/home/userAuto";
|
|
8
|
+
const DEFAULT_OPEN_BASE = "https://open.dknowc.cn";
|
|
9
|
+
const DEFAULT_CHANNEL = "46A3BA1D-3E1A-4E8C-BD50-A6DCBEE1DB05";
|
|
10
|
+
const DEFAULT_TYPE = "11";
|
|
11
|
+
const DEFAULT_SOURCE = "agent";
|
|
12
|
+
const API_KEY_ENV = "DKNOWC_API_KEY";
|
|
13
|
+
const MAAS_PLATFORM_URL = "https://platform.dknowc.cn/";
|
|
14
|
+
|
|
15
|
+
function parseArgs(argv) {
|
|
16
|
+
const out = { _: [] };
|
|
17
|
+
for (let i = 0; i < argv.length; i++) {
|
|
18
|
+
const arg = argv[i];
|
|
19
|
+
if (arg.startsWith("--")) {
|
|
20
|
+
const key = arg.slice(2);
|
|
21
|
+
const next = argv[i + 1];
|
|
22
|
+
if (next === undefined || next.startsWith("--")) {
|
|
23
|
+
out[key] = true;
|
|
24
|
+
} else {
|
|
25
|
+
out[key] = next;
|
|
26
|
+
i++;
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
out._.push(arg);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function postJson(url, payload, headers = {}) {
|
|
36
|
+
const controller = new AbortController();
|
|
37
|
+
const timer = setTimeout(() => controller.abort(), 30000);
|
|
38
|
+
try {
|
|
39
|
+
const response = await fetch(url, {
|
|
40
|
+
method: "POST",
|
|
41
|
+
headers: { "Content-Type": "application/json", ...headers },
|
|
42
|
+
body: JSON.stringify(payload),
|
|
43
|
+
signal: controller.signal,
|
|
44
|
+
});
|
|
45
|
+
const text = await response.text();
|
|
46
|
+
try {
|
|
47
|
+
return JSON.parse(text);
|
|
48
|
+
} catch {
|
|
49
|
+
return { status: false, msg: `非 JSON 响应:${text.slice(0, 200)}` };
|
|
50
|
+
}
|
|
51
|
+
} catch (error) {
|
|
52
|
+
const msg = error && error.message ? error.message : String(error);
|
|
53
|
+
return { status: false, msg: `请求异常:${msg}` };
|
|
54
|
+
} finally {
|
|
55
|
+
clearTimeout(timer);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function genPassword() {
|
|
60
|
+
const pools = [
|
|
61
|
+
"ABCDEFGHJKLMNPQRSTUVWXYZ",
|
|
62
|
+
"abcdefghijkmnpqrstuvwxyz",
|
|
63
|
+
"23456789",
|
|
64
|
+
"!@#$%^&*",
|
|
65
|
+
];
|
|
66
|
+
const pick = (value) => value[Math.floor(Math.random() * value.length)];
|
|
67
|
+
const chars = pools.map(pick);
|
|
68
|
+
const all = pools.join("");
|
|
69
|
+
for (let i = 0; i < 8; i++) chars.push(pick(all));
|
|
70
|
+
for (let i = chars.length - 1; i > 0; i--) {
|
|
71
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
72
|
+
[chars[i], chars[j]] = [chars[j], chars[i]];
|
|
73
|
+
}
|
|
74
|
+
return chars.join("");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async function createNewApiKey(openBase, existingApiKey, name, remark) {
|
|
78
|
+
const url = `${openBase.replace(/\/$/, "")}/open-api/maas/api-key/create`;
|
|
79
|
+
const result = await postJson(
|
|
80
|
+
url,
|
|
81
|
+
{ name, remark },
|
|
82
|
+
{ Authorization: `Bearer ${existingApiKey}` },
|
|
83
|
+
);
|
|
84
|
+
const apiKey = result && result.data ? result.data.appKey : "";
|
|
85
|
+
return { result, apiKey };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function maskKey(apiKey) {
|
|
89
|
+
if (!apiKey) return null;
|
|
90
|
+
if (apiKey.length <= 12) return "***";
|
|
91
|
+
return `${apiKey.slice(0, 7)}...${apiKey.slice(-4)}`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function main() {
|
|
95
|
+
const args = parseArgs(process.argv.slice(2));
|
|
96
|
+
const cmd = args._[0];
|
|
97
|
+
const base = args.base || DEFAULT_BASE;
|
|
98
|
+
|
|
99
|
+
if (cmd === "send") {
|
|
100
|
+
if (!args.phone) {
|
|
101
|
+
console.error("缺少 --phone");
|
|
102
|
+
process.exit(2);
|
|
103
|
+
}
|
|
104
|
+
const result = await postJson(`${base}/sendMessage`, {
|
|
105
|
+
phone: args.phone,
|
|
106
|
+
type: "register",
|
|
107
|
+
});
|
|
108
|
+
console.log(JSON.stringify(result));
|
|
109
|
+
process.exit(result.status ? 0 : 1);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (cmd === "register") {
|
|
113
|
+
if (!args.phone || !args.vcode) {
|
|
114
|
+
console.error("缺少 --phone 或 --vcode");
|
|
115
|
+
process.exit(2);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const payload = {
|
|
119
|
+
phone: args.phone,
|
|
120
|
+
vcode: args.vcode,
|
|
121
|
+
password: args.password && args.password !== true ? args.password : genPassword(),
|
|
122
|
+
type: args.type && args.type !== true ? args.type : DEFAULT_TYPE,
|
|
123
|
+
organ: args.organ && args.organ !== true ? args.organ : "个人",
|
|
124
|
+
name: args.name && args.name !== true ? args.name : "用户",
|
|
125
|
+
apiKeyName: args["apikey-name"] && args["apikey-name"] !== true ? args["apikey-name"] : "agent-key",
|
|
126
|
+
channel: args.channel && args.channel !== true ? args.channel : DEFAULT_CHANNEL,
|
|
127
|
+
source: args.source && args.source !== true ? args.source : DEFAULT_SOURCE,
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const result = await postJson(`${base}/register`, payload);
|
|
131
|
+
const data = result.data || {};
|
|
132
|
+
let apiKey = result.status && data.apiKey ? data.apiKey : "";
|
|
133
|
+
let newKeyCreated = false;
|
|
134
|
+
let newKeyError = null;
|
|
135
|
+
|
|
136
|
+
if (apiKey && args["new-key"]) {
|
|
137
|
+
const keyName = args["new-key-name"] && args["new-key-name"] !== true
|
|
138
|
+
? args["new-key-name"]
|
|
139
|
+
: payload.apiKeyName;
|
|
140
|
+
const keyRemark = args["new-key-remark"] && args["new-key-remark"] !== true
|
|
141
|
+
? args["new-key-remark"]
|
|
142
|
+
: "由 SkillHub 深知可信搜索按用户要求重新生成";
|
|
143
|
+
const created = await createNewApiKey(
|
|
144
|
+
args["open-base"] && args["open-base"] !== true ? args["open-base"] : DEFAULT_OPEN_BASE,
|
|
145
|
+
apiKey,
|
|
146
|
+
keyName,
|
|
147
|
+
keyRemark,
|
|
148
|
+
);
|
|
149
|
+
if (created.apiKey) {
|
|
150
|
+
apiKey = created.apiKey;
|
|
151
|
+
newKeyCreated = true;
|
|
152
|
+
} else {
|
|
153
|
+
apiKey = "";
|
|
154
|
+
newKeyError = created.result.errmsg || created.result.msg || "新 API Key 创建失败";
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
console.log(JSON.stringify({
|
|
159
|
+
status: Boolean(apiKey) && !newKeyError,
|
|
160
|
+
msg: result.msg,
|
|
161
|
+
url: data.url || null,
|
|
162
|
+
existed: Boolean(data.existed),
|
|
163
|
+
keyCreatedByRegister: Boolean(data.keyCreated),
|
|
164
|
+
newKeyRequested: Boolean(args["new-key"]),
|
|
165
|
+
newKeyCreated,
|
|
166
|
+
envName: API_KEY_ENV,
|
|
167
|
+
apiKey,
|
|
168
|
+
apiKeyMasked: maskKey(apiKey),
|
|
169
|
+
currentTaskOnly: true,
|
|
170
|
+
persistInstruction: `本次返回的 apiKey 仅供当前任务临时注入 ${API_KEY_ENV}。任务完成后,建议用户在 SkillHub/WorkBuddy 平台环境变量或密钥配置中保存 ${API_KEY_ENV}。`,
|
|
171
|
+
fallbackRegisterUrl: MAAS_PLATFORM_URL,
|
|
172
|
+
newKeyError,
|
|
173
|
+
}));
|
|
174
|
+
process.exit(apiKey && !newKeyError ? 0 : 1);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
console.error("用法: node register_key.mjs <send|register> ...");
|
|
178
|
+
process.exit(2);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
main();
|