dsh-d365-kit 0.34.1 → 0.34.4
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/CHANGELOG.md +319 -308
- package/CHANGELOG.zh-CN.md +318 -307
- package/INSTALL.md +94 -94
- package/INSTALL.zh-CN.md +93 -93
- package/LICENSE +21 -21
- package/README.md +336 -327
- package/README.zh-CN.md +336 -327
- package/client.js +1818 -1818
- package/cordis.patch.yml +44 -44
- package/docs/en/architecture.md +172 -172
- package/docs/en/checks.md +184 -184
- package/docs/en/installation.md +151 -151
- package/docs/en/permissions.md +161 -161
- package/docs/en/scenarios.md +202 -202
- package/docs/en/tools.md +665 -665
- package/docs/en/troubleshooting.md +131 -131
- package/docs/zh/architecture.md +172 -172
- package/docs/zh/checks.md +184 -184
- package/docs/zh/installation.md +151 -151
- package/docs/zh/permissions.md +161 -161
- package/docs/zh/scenarios.md +202 -202
- package/docs/zh/tools.md +665 -665
- package/docs/zh/troubleshooting.md +131 -131
- package/examples/prompts.en.md +206 -206
- package/examples/prompts.zh-CN.md +206 -206
- package/examples/waivers.example.json +20 -20
- package/icon.svg +6 -6
- package/index.js +139 -139
- package/lib/auth.js +181 -181
- package/lib/client.js +496 -496
- package/lib/code-check.js +549 -549
- package/lib/config.js +323 -323
- package/lib/contract-history.js +49 -49
- package/lib/contract.js +583 -583
- package/lib/csharp-check.js +493 -493
- package/lib/data-migrate.js +1318 -1318
- package/lib/data-policy.js +78 -78
- package/lib/error-codes.js +80 -80
- package/lib/gitlab.js +161 -161
- package/lib/health.js +205 -205
- package/lib/migrate.js +732 -732
- package/lib/preflight.js +116 -116
- package/lib/refs.js +191 -191
- package/lib/resources.js +320 -320
- package/lib/retention-defaults.js +17 -17
- package/lib/retention.js +384 -384
- package/lib/runtime.js +232 -232
- package/lib/settings-http.js +512 -512
- package/lib/settings-store.js +371 -371
- package/lib/snapshot.js +149 -149
- package/lib/tool-code-check.js +133 -133
- package/lib/tool-configure.js +169 -169
- package/lib/tool-contract.js +376 -376
- package/lib/tool-data-sync.js +559 -559
- package/lib/tool-data-write.js +203 -203
- package/lib/tool-data.js +282 -282
- package/lib/tool-diff.js +484 -484
- package/lib/tool-environments.js +106 -106
- package/lib/tool-flows.js +540 -540
- package/lib/tool-health.js +127 -127
- package/lib/tool-layers.js +497 -497
- package/lib/tool-metadata.js +417 -417
- package/lib/tool-migrate.js +102 -102
- package/lib/tool-refs.js +206 -206
- package/lib/tool-reports.js +299 -299
- package/lib/tool-sync.js +430 -430
- package/lib/tool-write.js +563 -563
- package/lib/waivers.js +83 -83
- package/lib/write-actions.js +1374 -1374
- package/lib/write-policy.js +199 -199
- package/lib/write-store.js +167 -167
- package/locale/en.json +68 -68
- package/locale/zh.json +68 -68
- package/package.json +2 -2
- package/skills/d365-troubleshooting/SKILL.md +115 -115
package/lib/tool-environments.js
CHANGED
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `d365_envs` — what environments exist, and can they actually be reached.
|
|
3
|
-
*
|
|
4
|
-
* This is the first tool a person should call: it answers "what am I connected
|
|
5
|
-
* to" before any metadata question, and it separates "not configured" from
|
|
6
|
-
* "configured but the secret is missing" from "configured but unreachable".
|
|
7
|
-
*/
|
|
8
|
-
import { loadConfig } from './config.js'
|
|
9
|
-
import { environmentStatus } from './runtime.js'
|
|
10
|
-
|
|
11
|
-
export const definition = {
|
|
12
|
-
name: 'd365_envs',
|
|
13
|
-
description:
|
|
14
|
-
'列出已配置的 D365 CE 环境、凭据是否齐全,并在 check=true 时真实调用一次 Web API 验证连通性。'
|
|
15
|
-
+ '在回答任何"某个环境里有没有 X"之前先调用它,避免把"没配置"误说成"环境里没有"。',
|
|
16
|
-
parameters: {
|
|
17
|
-
type: 'object',
|
|
18
|
-
additionalProperties: false,
|
|
19
|
-
properties: {
|
|
20
|
-
check: {
|
|
21
|
-
type: 'boolean',
|
|
22
|
-
description: '是否真的连接每个环境验证(会消耗少量 Web API 请求)。默认 false,只做本地配置检查。',
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
output: {
|
|
27
|
-
schema: {
|
|
28
|
-
type: 'object',
|
|
29
|
-
additionalProperties: false,
|
|
30
|
-
required: ['text'],
|
|
31
|
-
properties: {
|
|
32
|
-
text: { type: 'string' },
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
render(_args, value) {
|
|
36
|
-
return [{ type: 'text', text: value?.text ?? '' }]
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Format the status report.
|
|
43
|
-
* @param config - normalized config.
|
|
44
|
-
* @param report - rows from `environmentStatus`.
|
|
45
|
-
* @returns printable text.
|
|
46
|
-
*/
|
|
47
|
-
function renderReport(config, report) {
|
|
48
|
-
const lines = []
|
|
49
|
-
lines.push(`已配置 ${report.length} 个环境,默认环境:${config.defaultEnvironment ?? '(无)'}`)
|
|
50
|
-
|
|
51
|
-
for (const row of report) {
|
|
52
|
-
const { env } = row
|
|
53
|
-
const tag = env.key === config.defaultEnvironment ? '(默认)' : ''
|
|
54
|
-
const auth = row.complete ? '凭据齐全' : '凭据不全'
|
|
55
|
-
const reach = row.reachable === undefined ? '' : row.reachable ? ',连接正常' : ',连接失败'
|
|
56
|
-
lines.push('')
|
|
57
|
-
lines.push(`### ${env.key}${tag}${env.label && env.label !== env.key ? ` — ${env.label}` : ''}`)
|
|
58
|
-
lines.push(`- URL:${env.url}`)
|
|
59
|
-
lines.push(`- 云:${env.cloud}${env.note ? `;备注:${env.note}` : ''}`)
|
|
60
|
-
lines.push(`- 状态:${auth}${reach}`)
|
|
61
|
-
if (!row.complete) {
|
|
62
|
-
const missing = Object.entries(row.credentials)
|
|
63
|
-
.filter(([, value]) => !value.ok)
|
|
64
|
-
.map(([kind, value]) => `${row.label[kind]}(未找到 ${value.missing.join(' / ')})`)
|
|
65
|
-
lines.push(`- 缺少:${missing.join(';')}`)
|
|
66
|
-
}
|
|
67
|
-
if (row.organization) {
|
|
68
|
-
const org = row.organization
|
|
69
|
-
lines.push(`- 组织:${org.name ?? '(未返回)'},版本 ${org.version ?? '?'},区域 ${org.organizationstructure ?? '?'}`)
|
|
70
|
-
}
|
|
71
|
-
if (row.error) lines.push(`- 错误:${row.error}`)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (config.issues.length) {
|
|
75
|
-
lines.push('')
|
|
76
|
-
lines.push('### 配置告警')
|
|
77
|
-
for (const issue of config.issues) lines.push(`- ${issue}`)
|
|
78
|
-
}
|
|
79
|
-
if (config.configFile) lines.push('', `配置文件:${config.configFile}`)
|
|
80
|
-
return lines.join('\n')
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Register the tool.
|
|
85
|
-
* @param ctx - host context.
|
|
86
|
-
* @param state - holds the raw patch config.
|
|
87
|
-
* @returns disposer.
|
|
88
|
-
*/
|
|
89
|
-
export function register(ctx, state) {
|
|
90
|
-
return ctx.tools.register({
|
|
91
|
-
...definition,
|
|
92
|
-
async execute(args = {}) {
|
|
93
|
-
const config = await loadConfig(state.rawConfig)
|
|
94
|
-
const report = await environmentStatus(config, { check: args.check === true })
|
|
95
|
-
return { text: renderReport(config, report) }
|
|
96
|
-
},
|
|
97
|
-
presentCall(args = {}) {
|
|
98
|
-
return {
|
|
99
|
-
card: 'generic',
|
|
100
|
-
title: args.check ? '检查 D365 环境' : '列出 D365 环境',
|
|
101
|
-
kind: 'other',
|
|
102
|
-
rawInput: args,
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
})
|
|
106
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* `d365_envs` — what environments exist, and can they actually be reached.
|
|
3
|
+
*
|
|
4
|
+
* This is the first tool a person should call: it answers "what am I connected
|
|
5
|
+
* to" before any metadata question, and it separates "not configured" from
|
|
6
|
+
* "configured but the secret is missing" from "configured but unreachable".
|
|
7
|
+
*/
|
|
8
|
+
import { loadConfig } from './config.js'
|
|
9
|
+
import { environmentStatus } from './runtime.js'
|
|
10
|
+
|
|
11
|
+
export const definition = {
|
|
12
|
+
name: 'd365_envs',
|
|
13
|
+
description:
|
|
14
|
+
'列出已配置的 D365 CE 环境、凭据是否齐全,并在 check=true 时真实调用一次 Web API 验证连通性。'
|
|
15
|
+
+ '在回答任何"某个环境里有没有 X"之前先调用它,避免把"没配置"误说成"环境里没有"。',
|
|
16
|
+
parameters: {
|
|
17
|
+
type: 'object',
|
|
18
|
+
additionalProperties: false,
|
|
19
|
+
properties: {
|
|
20
|
+
check: {
|
|
21
|
+
type: 'boolean',
|
|
22
|
+
description: '是否真的连接每个环境验证(会消耗少量 Web API 请求)。默认 false,只做本地配置检查。',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
output: {
|
|
27
|
+
schema: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
additionalProperties: false,
|
|
30
|
+
required: ['text'],
|
|
31
|
+
properties: {
|
|
32
|
+
text: { type: 'string' },
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
render(_args, value) {
|
|
36
|
+
return [{ type: 'text', text: value?.text ?? '' }]
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Format the status report.
|
|
43
|
+
* @param config - normalized config.
|
|
44
|
+
* @param report - rows from `environmentStatus`.
|
|
45
|
+
* @returns printable text.
|
|
46
|
+
*/
|
|
47
|
+
function renderReport(config, report) {
|
|
48
|
+
const lines = []
|
|
49
|
+
lines.push(`已配置 ${report.length} 个环境,默认环境:${config.defaultEnvironment ?? '(无)'}`)
|
|
50
|
+
|
|
51
|
+
for (const row of report) {
|
|
52
|
+
const { env } = row
|
|
53
|
+
const tag = env.key === config.defaultEnvironment ? '(默认)' : ''
|
|
54
|
+
const auth = row.complete ? '凭据齐全' : '凭据不全'
|
|
55
|
+
const reach = row.reachable === undefined ? '' : row.reachable ? ',连接正常' : ',连接失败'
|
|
56
|
+
lines.push('')
|
|
57
|
+
lines.push(`### ${env.key}${tag}${env.label && env.label !== env.key ? ` — ${env.label}` : ''}`)
|
|
58
|
+
lines.push(`- URL:${env.url}`)
|
|
59
|
+
lines.push(`- 云:${env.cloud}${env.note ? `;备注:${env.note}` : ''}`)
|
|
60
|
+
lines.push(`- 状态:${auth}${reach}`)
|
|
61
|
+
if (!row.complete) {
|
|
62
|
+
const missing = Object.entries(row.credentials)
|
|
63
|
+
.filter(([, value]) => !value.ok)
|
|
64
|
+
.map(([kind, value]) => `${row.label[kind]}(未找到 ${value.missing.join(' / ')})`)
|
|
65
|
+
lines.push(`- 缺少:${missing.join(';')}`)
|
|
66
|
+
}
|
|
67
|
+
if (row.organization) {
|
|
68
|
+
const org = row.organization
|
|
69
|
+
lines.push(`- 组织:${org.name ?? '(未返回)'},版本 ${org.version ?? '?'},区域 ${org.organizationstructure ?? '?'}`)
|
|
70
|
+
}
|
|
71
|
+
if (row.error) lines.push(`- 错误:${row.error}`)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (config.issues.length) {
|
|
75
|
+
lines.push('')
|
|
76
|
+
lines.push('### 配置告警')
|
|
77
|
+
for (const issue of config.issues) lines.push(`- ${issue}`)
|
|
78
|
+
}
|
|
79
|
+
if (config.configFile) lines.push('', `配置文件:${config.configFile}`)
|
|
80
|
+
return lines.join('\n')
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Register the tool.
|
|
85
|
+
* @param ctx - host context.
|
|
86
|
+
* @param state - holds the raw patch config.
|
|
87
|
+
* @returns disposer.
|
|
88
|
+
*/
|
|
89
|
+
export function register(ctx, state) {
|
|
90
|
+
return ctx.tools.register({
|
|
91
|
+
...definition,
|
|
92
|
+
async execute(args = {}) {
|
|
93
|
+
const config = await loadConfig(state.rawConfig)
|
|
94
|
+
const report = await environmentStatus(config, { check: args.check === true })
|
|
95
|
+
return { text: renderReport(config, report) }
|
|
96
|
+
},
|
|
97
|
+
presentCall(args = {}) {
|
|
98
|
+
return {
|
|
99
|
+
card: 'generic',
|
|
100
|
+
title: args.check ? '检查 D365 环境' : '列出 D365 环境',
|
|
101
|
+
kind: 'other',
|
|
102
|
+
rawInput: args,
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
})
|
|
106
|
+
}
|