@liuhange/dsh-data-circulation-assessor 3.1.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/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # @liuhange/dsh-data-circulation-assessor
2
+
3
+ ## 功能说明
4
+
5
+ Data circulation assessor plugin: trusted data space readiness and transaction compliance prediction
6
+
7
+ ## 安装
8
+
9
+ ```bash
10
+ dsh plugin --profile web add @liuhange/dsh-data-circulation-assessor
11
+ ```
12
+
13
+ ## 用法
14
+
15
+ ```javascript
16
+ import { apply } from '@liuhange/dsh-data-circulation-assessor';
17
+ apply(ctx); // 注册工具: assess_circulation
18
+ ```
19
+
20
+ ## License
21
+
22
+ MIT
package/lib/index.js ADDED
@@ -0,0 +1,98 @@
1
+ export const name = '@liuhange/dsh-data-circulation-assessor';
2
+ export const inject = ['tools'];
3
+ import { loadJsonConfig } from '@liuhange/dsh-data-asset-shared';
4
+ import { resolvePolicyBasis } from './policyBasis.js';
5
+ export function apply(ctx) {
6
+ ctx.tools.register({
7
+ name: 'assess_circulation',
8
+ description: '评估数据的可流通性,含可信数据空间接入就绪度和交易合规预判',
9
+ parameters: {
10
+ type: 'object',
11
+ properties: {
12
+ datasetId: { type: 'string', description: '数据集标识' },
13
+ targetSpace: { type: 'string', enum: ['enterprise', 'industry', 'city', 'cross-border'] },
14
+ complianceResultRef: { type: 'string', description: 'compliance-check工具输出引用(可选)' },
15
+ },
16
+ required: ['datasetId'],
17
+ },
18
+ async execute(args) {
19
+ try {
20
+ if (!args?.datasetId || typeof args.datasetId !== 'string') {
21
+ return JSON.stringify({ error: 'CIRCULATION_INPUT_INVALID', message: 'datasetId is required' });
22
+ }
23
+ let rulesConfig;
24
+ try {
25
+ rulesConfig = loadJsonConfig('BUSINESS_RULES_PATH', 'config/business-rules.json', '@liuhange/dsh-data-asset-shared/config/business-rules.json');
26
+ }
27
+ catch {
28
+ return JSON.stringify({ error: 'CIRCULATION_RULES_MISSING', message: '无法加载business-rules.json' });
29
+ }
30
+ const circConfig = rulesConfig.dataCirculationAssessment;
31
+ if (!circConfig) {
32
+ return JSON.stringify({ error: 'CIRCULATION_RULES_MISSING', message: 'dataCirculationAssessment配置段缺失' });
33
+ }
34
+ const policyBasis = resolvePolicyBasis('DATA_CIRCULATION_ASSESSMENT');
35
+ const trustedSpaceReadiness = assessTdsReadiness(circConfig.tdsAccessCriteria);
36
+ const transactionCompliance = assessTransactionCompliance(circConfig.tradeComplianceRules);
37
+ const circulationScore = computeCirculationScore(trustedSpaceReadiness, transactionCompliance, circConfig.weights);
38
+ const recommendations = generateRecommendations(trustedSpaceReadiness, transactionCompliance, circulationScore);
39
+ const result = {
40
+ datasetId: args.datasetId,
41
+ targetSpace: args.targetSpace ?? 'enterprise',
42
+ trustedSpaceReadiness,
43
+ transactionCompliance,
44
+ circulationScore,
45
+ circulationLevel: circulationScore >= 80 ? 'high' : circulationScore >= 50 ? 'medium' : 'low',
46
+ recommendations,
47
+ policyBasis,
48
+ timestamp: new Date().toISOString(),
49
+ };
50
+ return JSON.stringify(result, null, 2);
51
+ }
52
+ catch (e) {
53
+ return JSON.stringify({ error: 'UNKNOWN_ERROR', message: e.message });
54
+ }
55
+ },
56
+ });
57
+ }
58
+ function assessTdsReadiness(criteria) {
59
+ return {
60
+ identityVerified: criteria.tech.includes('身份认证'),
61
+ resourceEncapsulated: criteria.tech.includes('资源封装'),
62
+ directoryMaintained: criteria.tech.includes('目录维护'),
63
+ auditTrailAvailable: criteria.tech.includes('审计追溯'),
64
+ };
65
+ }
66
+ function assessTransactionCompliance(rules) {
67
+ return {
68
+ participantCompliant: rules.includes('参与方合规'),
69
+ platformCompliant: rules.includes('交易平台合规'),
70
+ subjectCompliant: rules.includes('交易标的合规'),
71
+ processCompliant: rules.includes('交易过程合规'),
72
+ };
73
+ }
74
+ function computeCirculationScore(readiness, compliance, weights) {
75
+ const readinessScore = Object.values(readiness).filter(Boolean).length / Object.keys(readiness).length;
76
+ const complianceScore = Object.values(compliance).filter(Boolean).length / Object.keys(compliance).length;
77
+ const score = complianceScore * (weights.compliance ?? 0.4) + readinessScore * (weights.tdsAccess ?? 0.3) + complianceScore * (weights.tradePrediction ?? 0.3);
78
+ return Math.round(score * 100);
79
+ }
80
+ function generateRecommendations(readiness, compliance, score) {
81
+ const recs = [];
82
+ if (!readiness.identityVerified)
83
+ recs.push('完成接入身份认证');
84
+ if (!readiness.resourceEncapsulated)
85
+ recs.push('完成数据资源封装');
86
+ if (!readiness.directoryMaintained)
87
+ recs.push('建立数据目录维护机制');
88
+ if (!readiness.auditTrailAvailable)
89
+ recs.push('建立审计追溯体系');
90
+ if (!compliance.participantCompliant)
91
+ recs.push('确认参与方合规资质');
92
+ if (!compliance.platformCompliant)
93
+ recs.push('确认交易平台合规资质');
94
+ if (score < 50)
95
+ recs.push('当前可流通性较低,建议优先完成合规基础建设');
96
+ return recs;
97
+ }
98
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,17 @@
1
+ import { loadJsonConfig } from '@liuhange/dsh-data-asset-shared';
2
+ export function resolvePolicyBasis(stage) {
3
+ try {
4
+ const config = loadJsonConfig('POLICY_REFS_PATH', 'config/policy-references.json', '@liuhange/dsh-data-asset-shared/config/policy-references.json');
5
+ const refs = config.policyReferences;
6
+ const stageEntry = refs?.find((s) => s.stage === stage);
7
+ if (!stageEntry) {
8
+ console.warn(`Policy stage "${stage}" not configured`);
9
+ return [`依据:政策依据未配置(stage=${stage})`];
10
+ }
11
+ return stageEntry.documents.map((d) => `依据:《${d.name}》(${d.docNumber})—${d.coreRequirement}`);
12
+ }
13
+ catch {
14
+ return ['依据:政策依据配置加载失败'];
15
+ }
16
+ }
17
+ //# sourceMappingURL=policyBasis.js.map
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@liuhange/dsh-data-circulation-assessor",
3
+ "description": "Data circulation assessor plugin: trusted data space readiness and transaction compliance prediction",
4
+ "version": "3.1.0",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/liuhange789/data-asset-inspector.git",
11
+ "directory": "packages/data-asset/data-circulation-assessor"
12
+ },
13
+ "type": "module",
14
+ "main": "lib/index.js",
15
+ "types": "lib/types/index.d.ts",
16
+ "exports": {
17
+ ".": {
18
+ "types": "./lib/types/index.d.ts",
19
+ "default": "./lib/index.js"
20
+ },
21
+ "./src/*": "./src/*",
22
+ "./package.json": "./package.json"
23
+ },
24
+ "files": [
25
+ "lib/**/*.js",
26
+ "lib/types/**/*.d.ts"
27
+ ],
28
+ "license": "MIT",
29
+ "scripts": {
30
+ "typecheck": "tsc --noEmit",
31
+ "test": "vitest run",
32
+ "build": "tsc"
33
+ },
34
+ "peerDependencies": {
35
+ "@deepseek-ai/cordis": "^4.0.0",
36
+ "@deepseek-ai/dsh-tools": "0.0.1-rc.1",
37
+ "@liuhange/dsh-data-asset-shared": "^3.0.0"
38
+ },
39
+ "dsh": {
40
+ "bundle": {
41
+ "patch": true
42
+ }
43
+ },
44
+ "keywords": [
45
+ "deepseek-harness",
46
+ "dsh-plugin",
47
+ "data-asset",
48
+ "data-asset-inspector",
49
+ "shujintong",
50
+ "数据资产",
51
+ "data-circulation",
52
+ "trusted-data-space",
53
+ "transaction-compliance",
54
+ "可流通性",
55
+ "可信数据空间",
56
+ "交易合规"
57
+ ],
58
+ "homepage": "https://github.com/liuhange789/data-asset-inspector#readme"
59
+ }