@chengxianglibra/dsh-data-analysis 0.1.1
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 +72 -0
- package/cordis.patch.yml +11 -0
- package/lib/bin/environment.js +91 -0
- package/lib/bridges.js +11 -0
- package/lib/client.js +744 -0
- package/lib/compatibility.js +66 -0
- package/lib/datasource/access.js +60 -0
- package/lib/datasource/bridge-programs.js +80 -0
- package/lib/datasource/bridge.js +204 -0
- package/lib/datasource/credentials.js +24 -0
- package/lib/datasource/index.js +4 -0
- package/lib/datasource/shell-env.js +386 -0
- package/lib/datasource/test.js +65 -0
- package/lib/disclosure/activation.js +369 -0
- package/lib/disclosure/bridge-program.js +11 -0
- package/lib/disclosure/bridge.js +65 -0
- package/lib/disclosure/help.js +227 -0
- package/lib/disclosure/index.js +3 -0
- package/lib/environment/binding.js +273 -0
- package/lib/environment/doctor.js +123 -0
- package/lib/environment/errors.js +11 -0
- package/lib/environment/index.js +7 -0
- package/lib/environment/runtime.js +558 -0
- package/lib/environment/source.js +6 -0
- package/lib/environment/subprocess.js +178 -0
- package/lib/environment/summary.js +19 -0
- package/lib/environment/workspace.js +49 -0
- package/lib/evidence/bridge-program.js +153 -0
- package/lib/evidence/bridge.js +166 -0
- package/lib/evidence/index.js +2 -0
- package/lib/evidence/sources.js +263 -0
- package/lib/index.js +7 -0
- package/lib/plugin.js +179 -0
- package/lib/types/bridges.d.ts +11 -0
- package/lib/types/client.d.ts +125 -0
- package/lib/types/compatibility.d.ts +29 -0
- package/lib/types/datasource/access.d.ts +27 -0
- package/lib/types/datasource/bridge.d.ts +53 -0
- package/lib/types/datasource/index.d.ts +8 -0
- package/lib/types/datasource/shell-env.d.ts +38 -0
- package/lib/types/datasource/test.d.ts +32 -0
- package/lib/types/disclosure/activation.d.ts +73 -0
- package/lib/types/disclosure/bridge.d.ts +28 -0
- package/lib/types/disclosure/help.d.ts +64 -0
- package/lib/types/disclosure/index.d.ts +5 -0
- package/lib/types/environment/binding.d.ts +26 -0
- package/lib/types/environment/doctor.d.ts +8 -0
- package/lib/types/environment/errors.d.ts +7 -0
- package/lib/types/environment/index.d.ts +9 -0
- package/lib/types/environment/runtime.d.ts +17 -0
- package/lib/types/environment/source.d.ts +7 -0
- package/lib/types/environment/subprocess.d.ts +19 -0
- package/lib/types/environment/types.d.ts +96 -0
- package/lib/types/environment/workspace.d.ts +10 -0
- package/lib/types/evidence/bridge.d.ts +40 -0
- package/lib/types/evidence/index.d.ts +4 -0
- package/lib/types/evidence/sources.d.ts +57 -0
- package/lib/types/index.d.ts +9 -0
- package/lib/types/plugin.d.ts +43 -0
- package/package.json +149 -0
- package/python/report-kit/dist/dsh_data_analysis_report_kit-3.0.0-py3-none-any.whl +0 -0
- package/skills/dsh-data-analysis-report/SKILL.md +57 -0
- package/skills/dsh-data-analysis-report/assets/marivo-artifact.js +113 -0
- package/skills/dsh-data-analysis-report/assets/marivo-session-dag.js +1201 -0
- package/skills/dsh-data-analysis-report/assets/report-data.js +449 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/** Cordis lifecycle adapter for the Web-profile shared Marivo Runtime. */
|
|
2
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
+
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
4
|
+
import type { CredentialProvider } from '@deepseek-ai/dsh-credentials';
|
|
5
|
+
import z from '@deepseek-ai/schemastery';
|
|
6
|
+
import { type MarivoHelpBridgeSource } from './disclosure/bridge.ts';
|
|
7
|
+
import { type MarivoDisclosureOptions } from './disclosure/index.ts';
|
|
8
|
+
import { MarivoEnvironment } from './environment/index.ts';
|
|
9
|
+
/** Cordis plugin name used by loader diagnostics and lifecycle logs. */
|
|
10
|
+
export declare const name = "dsh-data-analysis";
|
|
11
|
+
/** Services that must exist before the plugin binds and watches Agent scopes. */
|
|
12
|
+
export declare const inject: string[];
|
|
13
|
+
export declare const MARIVO_DATASOURCE_CREDENTIAL_PROMPT: string;
|
|
14
|
+
export declare const MARIVO_EVIDENCE_SOURCES_PROMPT: string;
|
|
15
|
+
export declare const MARIVO_REPORT_PROMPT: string;
|
|
16
|
+
/** Loader-safe configuration for the shared Runtime and per-Workspace bindings. */
|
|
17
|
+
export interface Config {
|
|
18
|
+
/** Explicit project root override; otherwise each Agent uses session.header.cwd. */
|
|
19
|
+
readonly projectRoot?: string;
|
|
20
|
+
/** Administrator-provided shared interpreter; must already contain an importable Marivo. */
|
|
21
|
+
readonly pythonExecutable?: string;
|
|
22
|
+
/** Shared Runtime root; defaults below $DSH_HOME. */
|
|
23
|
+
readonly runtimeRoot?: string;
|
|
24
|
+
/** Local uv executable; an explicit value must be absolute. */
|
|
25
|
+
readonly uvExecutable?: string;
|
|
26
|
+
/** Maximum time for installation and lock acquisition. */
|
|
27
|
+
readonly installTimeoutMs?: number;
|
|
28
|
+
}
|
|
29
|
+
/** Cordis loader schema. Runtime defaults are resolved in {@link apply}. */
|
|
30
|
+
export declare const Config: z<Config>;
|
|
31
|
+
export type MarivoPluginEnvironmentResolver = (agent: Agent) => MarivoEnvironment | Promise<MarivoEnvironment>;
|
|
32
|
+
/**
|
|
33
|
+
* Install one already-bound environment into every live or subsequently published Agent scope.
|
|
34
|
+
* Installation is transactional for existing Agents and is disposed with the Cordis plugin.
|
|
35
|
+
*/
|
|
36
|
+
export declare function installMarivoPlugin(ctx: Context, environmentOrResolver: MarivoEnvironment | MarivoPluginEnvironmentResolver, options?: MarivoDisclosureOptions & {
|
|
37
|
+
/** Override used by focused tests; normal plugin installation uses ctx.credentials. */
|
|
38
|
+
credentials?: Pick<CredentialProvider, 'resolve'>;
|
|
39
|
+
/** Runtime-scoped Help source; normal plugin installation never binds Help to a Workspace. */
|
|
40
|
+
helpBridgeSource?: MarivoHelpBridgeSource;
|
|
41
|
+
}): () => void;
|
|
42
|
+
/** Ensure the shared Runtime once, mount its skills, then bind each Workspace lazily. */
|
|
43
|
+
export declare function apply(ctx: Context, config?: Config): Promise<() => void>;
|
package/package.json
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@chengxianglibra/dsh-data-analysis",
|
|
3
|
+
"description": "Marivo runtime, live-help, datasource, and on-demand Evidence source integration for DeepSeek Harness",
|
|
4
|
+
"version": "0.1.1",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/chengxianglibra/dsh-data-analysis.git",
|
|
8
|
+
"directory": "packages/dsh-data-analysis"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/chengxianglibra/dsh-data-analysis#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/chengxianglibra/dsh-data-analysis/issues"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=24"
|
|
18
|
+
},
|
|
19
|
+
"main": "lib/index.js",
|
|
20
|
+
"types": "lib/types/index.d.ts",
|
|
21
|
+
"bin": {
|
|
22
|
+
"dsh-data-analysis-env": "./lib/bin/environment.js"
|
|
23
|
+
},
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./lib/types/index.d.ts",
|
|
27
|
+
"default": "./lib/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./client": {
|
|
30
|
+
"types": "./lib/types/client.d.ts",
|
|
31
|
+
"default": "./lib/client.js"
|
|
32
|
+
},
|
|
33
|
+
"./environment": {
|
|
34
|
+
"types": "./lib/types/environment/index.d.ts",
|
|
35
|
+
"default": "./lib/environment/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./disclosure": {
|
|
38
|
+
"types": "./lib/types/disclosure/index.d.ts",
|
|
39
|
+
"default": "./lib/disclosure/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./datasource": {
|
|
42
|
+
"types": "./lib/types/datasource/index.d.ts",
|
|
43
|
+
"default": "./lib/datasource/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./evidence": {
|
|
46
|
+
"types": "./lib/types/evidence/index.d.ts",
|
|
47
|
+
"default": "./lib/evidence/index.js"
|
|
48
|
+
},
|
|
49
|
+
"./compatibility": {
|
|
50
|
+
"types": "./lib/types/compatibility.d.ts",
|
|
51
|
+
"default": "./lib/compatibility.js"
|
|
52
|
+
},
|
|
53
|
+
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
54
|
+
"./package.json": "./package.json"
|
|
55
|
+
},
|
|
56
|
+
"files": [
|
|
57
|
+
"lib/**/*.js",
|
|
58
|
+
"lib/types/**/*.d.ts",
|
|
59
|
+
"python/report-kit/dist/dsh_data_analysis_report_kit-3.0.0-py3-none-any.whl",
|
|
60
|
+
"skills/**/*",
|
|
61
|
+
"cordis.patch.yml",
|
|
62
|
+
"README.md"
|
|
63
|
+
],
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "npm run clean && tsc -p tsconfig.build.json && node scripts/finalize-build.mjs",
|
|
66
|
+
"build:report-kit": "node scripts/build-report-kit.mjs",
|
|
67
|
+
"clean": "node scripts/clean.mjs",
|
|
68
|
+
"prepack": "npm run build:report-kit && npm run build"
|
|
69
|
+
},
|
|
70
|
+
"publishConfig": {
|
|
71
|
+
"access": "public",
|
|
72
|
+
"registry": "https://registry.npmjs.org/"
|
|
73
|
+
},
|
|
74
|
+
"dshDataAnalysisCompatibility": {
|
|
75
|
+
"schema": "dsh-data-analysis-compatibility/v2",
|
|
76
|
+
"dsh": {
|
|
77
|
+
"distribution": "@deepseek-ai/dsh",
|
|
78
|
+
"peerRange": "0.1.1-rc.2"
|
|
79
|
+
},
|
|
80
|
+
"marivo": {
|
|
81
|
+
"version": "0.5.3",
|
|
82
|
+
"packageSpec": "marivo[duckdb,trino,clickhouse]==0.5.3"
|
|
83
|
+
},
|
|
84
|
+
"contracts": {
|
|
85
|
+
"runtimeInstallation": "dsh-data-analysis-runtime/v2",
|
|
86
|
+
"subprocessPolicy": "direct-argv-inherited-env-snapshot-overlay-v2"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"dsh": {
|
|
90
|
+
"client": {
|
|
91
|
+
"inject": [
|
|
92
|
+
"@deepseek-ai/dsh-client-connection",
|
|
93
|
+
"@deepseek-ai/dsh-client-locale",
|
|
94
|
+
"@deepseek-ai/dsh-client-runtime",
|
|
95
|
+
"@deepseek-ai/dsh-client-ui-conversation",
|
|
96
|
+
"@deepseek-ai/dsh-client-ui-tool"
|
|
97
|
+
],
|
|
98
|
+
"platform": "web"
|
|
99
|
+
},
|
|
100
|
+
"bundle": {
|
|
101
|
+
"patch": "./cordis.patch.yml"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"dependencies": {
|
|
105
|
+
"@deepseek-ai/schemastery": "^3.18.1"
|
|
106
|
+
},
|
|
107
|
+
"devDependencies": {
|
|
108
|
+
"@deepseek-ai/dsh-agent-loop": "^0.1.1-rc.2",
|
|
109
|
+
"@deepseek-ai/dsh-anonymous-user-id": "^0.1.1-rc.2",
|
|
110
|
+
"@deepseek-ai/dsh-bash-local": "^0.1.1-rc.2",
|
|
111
|
+
"@deepseek-ai/dsh-client-ui-primitives": "^0.1.1-rc.2",
|
|
112
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.1.1-rc.2",
|
|
113
|
+
"@deepseek-ai/dsh-code-runtime": "^0.1.1-rc.2",
|
|
114
|
+
"@deepseek-ai/dsh-code-runtime-worker-thread": "^0.1.1-rc.2",
|
|
115
|
+
"@deepseek-ai/dsh-credentials-local": "^0.1.1-rc.2",
|
|
116
|
+
"@deepseek-ai/dsh-fs-local": "^0.1.1-rc.2",
|
|
117
|
+
"@deepseek-ai/dsh-fs-observation-policy": "^0.1.1-rc.2",
|
|
118
|
+
"@deepseek-ai/dsh-llm-deepseek": "^0.1.1-rc.2",
|
|
119
|
+
"@deepseek-ai/dsh-scope": "^0.1.1-rc.2",
|
|
120
|
+
"@deepseek-ai/dsh-skill": "^0.1.1-rc.2",
|
|
121
|
+
"@deepseek-ai/dsh-subprocess-local": "^0.1.1-rc.2",
|
|
122
|
+
"@deepseek-ai/dsh-tool-bash": "^0.1.1-rc.2",
|
|
123
|
+
"@deepseek-ai/dsh-tool-fs": "^0.1.1-rc.2",
|
|
124
|
+
"ajv": "^8.20.0",
|
|
125
|
+
"@types/react": "^18.3.31",
|
|
126
|
+
"react": "^18.3.1",
|
|
127
|
+
"typescript": "^6.0.3"
|
|
128
|
+
},
|
|
129
|
+
"peerDependencies": {
|
|
130
|
+
"@deepseek-ai/dsh-agent": "0.1.1-rc.2",
|
|
131
|
+
"@deepseek-ai/dsh-client-connection": "0.1.1-rc.2",
|
|
132
|
+
"@deepseek-ai/dsh-client-locale": "0.1.1-rc.2",
|
|
133
|
+
"@deepseek-ai/dsh-client-runtime": "0.1.1-rc.2",
|
|
134
|
+
"@deepseek-ai/dsh-client-ui-conversation": "0.1.1-rc.2",
|
|
135
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.1.1-rc.2",
|
|
136
|
+
"@deepseek-ai/dsh-client-ui-tool": "0.1.1-rc.2",
|
|
137
|
+
"@deepseek-ai/dsh-credentials": "0.1.1-rc.2",
|
|
138
|
+
"@deepseek-ai/dsh-home-paths": "0.1.1-rc.2",
|
|
139
|
+
"@deepseek-ai/dsh-llm": "0.1.1-rc.2",
|
|
140
|
+
"@deepseek-ai/dsh-session": "0.1.1-rc.2",
|
|
141
|
+
"@deepseek-ai/dsh-shell-env": "0.1.1-rc.2",
|
|
142
|
+
"@deepseek-ai/dsh-skill-filesystem": "0.1.1-rc.2",
|
|
143
|
+
"@deepseek-ai/dsh-scope": "0.1.1-rc.2",
|
|
144
|
+
"@deepseek-ai/dsh-system-prompt": "0.1.1-rc.2",
|
|
145
|
+
"@deepseek-ai/cordis": "^4.0.1",
|
|
146
|
+
"@deepseek-ai/dsh-tools": "0.1.1-rc.2",
|
|
147
|
+
"react": "^18.3.1"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dsh-data-analysis-report
|
|
3
|
+
description: Create or revise a Workspace HTML analysis report only when the user explicitly requests HTML/web or a durable report file, accepts a proposal to create one, or asks to revise an existing report bundle.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# DSH data-analysis report
|
|
7
|
+
|
|
8
|
+
本 Skill 只提供报告原则、数据读取接线与 Marivo 专属组件。页面、图表、样式、交互和通用检查由 Agent 使用普通文件与代码能力完成;插件不提供模板、chart helper、可视化 DSL、HTML Checker、通用 renderer 或 publisher。
|
|
9
|
+
|
|
10
|
+
## 分析事实与 Marivo 投影
|
|
11
|
+
|
|
12
|
+
### 取得报告数据
|
|
13
|
+
|
|
14
|
+
先加载 `marivo-analysis`,按实时 Help 使用当前 Runtime。已有分析应恢复精确 persisted Artifacts;仅在当前有效性会影响结论时执行 identity-matched revalidation。不得只为生成页面或 DAG 重新执行 `observe`。
|
|
15
|
+
|
|
16
|
+
| 输入 | Python 发射入口 | 语义边界 |
|
|
17
|
+
| --- | --- | --- |
|
|
18
|
+
| Marivo `BaseFrame` Artifact | `emit_dataset(artifact, target, detail="reader", revalidation=...)` | `reader` 默认只保留读者摘要与实质提示;明确审计请求才使用 `detail="audit"` 投影公共详情。 |
|
|
19
|
+
| pandas `DataFrame` 计算结果 | `emit_computed(frame, target)` | 仅表示 computed snapshot,不声明 Artifact、Evidence、lineage、freshness 或 revalidation。 |
|
|
20
|
+
|
|
21
|
+
两个 emitter 都生成由 `ReportData` 注册的数据文件。不要把 DataFrame 传给 `emit_dataset`,不要手写 `ReportData.register(...)` payload,也不要从浏览器 validator 反推 schema。浏览器通过 `ReportData.get(...)` 读取快照,或通过 `ReportData.records(...)` 取得行对象;图表库和 DOM/SVG/Canvas 实现仍由 Agent 自主选择。
|
|
22
|
+
|
|
23
|
+
每个可见 KPI、图表和表格都要映射到一个已注册 dataset。Artifact 映射在轻量来源说明或审计区体现;computed 映射保留必要的输入与转换说明。机器 identity 不进入主叙事。
|
|
24
|
+
|
|
25
|
+
### 添加 Marivo 组件
|
|
26
|
+
|
|
27
|
+
- `MarivoArtifact.render(container, dataset_id)` 展示面向读者的 Artifact 摘要:正常状态仅含类型、semantic shape、行数和结果生成时间;仅在截断、Evidence 不完整、revalidation 异常、质量检查或 issues 会改变判断时追加提示。它不是 metadata inspector,不展示机器 identity、hash、Job、Finding 数量或完整 lineage。
|
|
28
|
+
- 对每个实质支撑报告内容的 Marivo Session,分别用公开 `session.graph(...)` 取得聚焦 `SessionGraph`,再调用 `emit_session_trace(graph, target, report_artifact_refs=[...], detail="reader")`。只有明确审计、Lineage、质量详情、可追溯性或 action SQL/Query 请求才改用 `detail="audit"`;DAG 详情只展示投影中已有的公开 Query,bind values 仍必须省略。`report_artifact_refs` 只列该 Graph 内实际支撑可见内容的本地 Artifacts;不得跨 Session 合并、读取私有 Store 或补造事实。
|
|
29
|
+
- DAG 中需要预览的本地 Frame,必须从所属精确 Session 恢复并 `emit_dataset(...)`。浏览器按 `session_id + artifact_ref` 关联;缺少快照时明确显示未注册。Artifact 详情复用 `MarivoArtifact`,Frame 节点只显示 family 与行数。
|
|
30
|
+
- Graph 超出 emitter 限制时,为同一 Session 输出多个具有唯一 `trace_id` 的聚焦 Graph。`ReportTrace.renderSessionGraphs(...)` 单次最多接收 20 个 trace;超出时分批渲染,不得静默遗漏实际使用的 Session。
|
|
31
|
+
|
|
32
|
+
### 装配浏览器资源
|
|
33
|
+
|
|
34
|
+
按需复制 `assets/report-data.js`、`assets/marivo-artifact.js`、`assets/marivo-session-dag.js`。经典脚本顺序固定为:`report-data.js` → dataset snapshots → Marivo components → trace snapshots → Agent 自有 chart/runtime/app。使用 DAG 时必须同时加载 Artifact component,最后调用 `ReportTrace.renderSessionGraphs(container[, trace_ids])`。页面内 `dataset_id` 与 `trace_id` 必须唯一。
|
|
35
|
+
|
|
36
|
+
## 内容组织
|
|
37
|
+
|
|
38
|
+
- 先明确受众、决策问题、范围和约束。开头直接给答案和最重要证据,正文解释驱动因素,结尾只保留影响行动的限制与后续步骤。
|
|
39
|
+
- 明确区分观测事实、Agent 推断和建议;因果与置信措辞必须匹配证据。不要用固定 KPI、摘要、方法或附录章节填充内容。
|
|
40
|
+
- 每张图只回答一个问题并在附近解释;详细表格、方法和 DAG 放在可展开或靠后的区域。
|
|
41
|
+
- 对范围、口径、单位、时间边界、freshness、coverage、null、截断、revalidation、失败检查和不确定性,只披露会改变解读或行动的部分。
|
|
42
|
+
|
|
43
|
+
## 布局与样式
|
|
44
|
+
|
|
45
|
+
- 建立清晰标题层级和阅读顺序;宽屏可分栏,窄屏回到单列。关键结论不能只靠颜色、位置、hover 或动画表达。
|
|
46
|
+
- Marivo 组件只输出语义化 DOM/SVG 与 class hooks,不携带页面主题;使用 `MarivoArtifact` 或 `ReportTrace` 时,必须为生成内容补齐可读的文本、节点 fill/stroke、连线、状态、键盘焦点、详情面板与窄屏样式,并保留组件对 audit SQL 的确定性格式化。
|
|
47
|
+
- 优先使用语义化结构、可读字号、充足行距、稳定留白和高对比度。颜色用于编码而非装饰;同一含义保持一致,并提供文字、图例或形状冗余。
|
|
48
|
+
- 图表必须有标题、单位、时间范围、刻度与数据缺失说明;表格提供明确表头和适合内容的对齐。避免 3D、双轴、过密标签和无解释的视觉噪声。
|
|
49
|
+
- 所有图表坐标轴在各目标宽度下都不得出现刻度标签彼此重叠、被裁切、侵入绘图区,或与轴标题、图例等元素重叠。按轴类型、标签长度与可用空间选择合适的格式、刻度密度、换行、方向、边距和图表尺寸;空间不足时不要强行显示每个刻度。只有保持可读时才旋转标签,完整标签与数值保留在数据表、可访问文本或按需提示中。
|
|
50
|
+
- 交互只在能降低认知负担时加入;核心结论、关键数值与限制在 JavaScript 失败时仍应可读。打印或导出场景不得截断关键内容。
|
|
51
|
+
|
|
52
|
+
## 生成与检查
|
|
53
|
+
|
|
54
|
+
1. 新报告使用新的 Workspace 目录;修订使用用户指定或已确认的现有目录,只有需要隔离构建时才另建 staging 目录。所有资源置于目录内并使用相对路径;先写数据与资源,最后写 `index.html`。
|
|
55
|
+
2. 自查内容:问题是否被直接回答;数字、单位、口径和时间是否一致;事实、推断和建议是否混淆;重要限制、截断和未知项是否可见。
|
|
56
|
+
3. 自查页面:资源能否离线解析;外部输入是否安全转义;是否意外包含 credential、环境值、私有路径或其他敏感查询内容;窄屏、键盘、无脚本、打印和空/错误状态是否可用。
|
|
57
|
+
4. Native/both 模式在所有资源完成后,以顶层文件 Tool 对 `index.html` 做 bundle 最后一次 mutation;资源再变化时须再次 mutation 入口。最终回答以 Markdown 行内代码逐字复制该调用使用的完整绝对 `file_path`,不得缩短为相对路径、basename、`file://` 或 Markdown 链接。Produced Files 与 Host opening 只是导航,不代表发布、不可变、可恢复或验证通过。
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
;(function installMarivoArtifact(scope) {
|
|
2
|
+
class MarivoArtifactError extends Error {
|
|
3
|
+
constructor(code, message) {
|
|
4
|
+
super(`${code}: ${message}`)
|
|
5
|
+
this.name = 'MarivoArtifactError'
|
|
6
|
+
this.code = code
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function fail(code, message) {
|
|
11
|
+
throw new MarivoArtifactError(code, message)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function text(tag, value, className) {
|
|
15
|
+
const element = document.createElement(tag)
|
|
16
|
+
if (className) element.className = className
|
|
17
|
+
element.textContent = String(value)
|
|
18
|
+
return element
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function notice(message, level) {
|
|
22
|
+
const item = text('li', message, 'marivo-artifact-notice')
|
|
23
|
+
item.dataset.level = level
|
|
24
|
+
return item
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function artifactDataset(datasetId) {
|
|
28
|
+
const registry = scope.ReportData
|
|
29
|
+
if (!registry || typeof registry.get !== 'function') {
|
|
30
|
+
fail('report-data-unavailable', 'ReportData must be loaded before MarivoArtifact')
|
|
31
|
+
}
|
|
32
|
+
const dataset = registry.get(datasetId)
|
|
33
|
+
if (dataset.source.kind !== 'marivo_artifact') {
|
|
34
|
+
fail('artifact-dataset-required', 'dataset must be a Marivo Artifact snapshot')
|
|
35
|
+
}
|
|
36
|
+
return dataset
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function summary(dataset) {
|
|
40
|
+
const parts = [dataset.source.artifact.kind]
|
|
41
|
+
if (dataset.table.semantic_shape !== null) parts.push(dataset.table.semantic_shape)
|
|
42
|
+
parts.push(`${dataset.table.total_rows} 行`)
|
|
43
|
+
parts.push(`结果生成于 ${dataset.source.artifact.created_at}`)
|
|
44
|
+
return parts.join(' · ')
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function notices(dataset) {
|
|
48
|
+
const source = dataset.source
|
|
49
|
+
const result = []
|
|
50
|
+
if (dataset.table.omitted_rows > 0) {
|
|
51
|
+
result.push(
|
|
52
|
+
notice(
|
|
53
|
+
`展示数据已截断:显示 ${dataset.table.written_rows} 行,共 ${dataset.table.total_rows} 行。`,
|
|
54
|
+
'warning',
|
|
55
|
+
),
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
if (source.artifact.evidence_status === 'partial') {
|
|
59
|
+
result.push(notice('分析依据不完整。', 'warning'))
|
|
60
|
+
} else if (source.artifact.evidence_status === 'unavailable') {
|
|
61
|
+
result.push(notice('分析依据不可用。', 'blocking'))
|
|
62
|
+
}
|
|
63
|
+
if (source.revalidation.status === 'checked') {
|
|
64
|
+
if (source.revalidation.result === 'stale') {
|
|
65
|
+
result.push(notice('当前有效性复核结果为 stale。', 'warning'))
|
|
66
|
+
} else if (source.revalidation.result === 'indeterminate') {
|
|
67
|
+
result.push(notice('当前有效性复核结果无法确定。', 'warning'))
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const quality = source.quality_summary
|
|
71
|
+
if (quality !== null) {
|
|
72
|
+
if (quality.failed_check_count > 0) {
|
|
73
|
+
result.push(notice(`存在 ${quality.failed_check_count} 项未通过的质量检查。`, 'blocking'))
|
|
74
|
+
}
|
|
75
|
+
if (quality.warning_check_count > 0) {
|
|
76
|
+
result.push(notice(`存在 ${quality.warning_check_count} 项质量警告。`, 'warning'))
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const blocking = source.issues.filter((issue) => issue.severity === 'blocking').length
|
|
80
|
+
const warnings = source.issues.filter((issue) => issue.severity === 'warning').length
|
|
81
|
+
if (blocking > 0) result.push(notice(`存在 ${blocking} 个阻断问题。`, 'blocking'))
|
|
82
|
+
if (warnings > 0) result.push(notice(`存在 ${warnings} 个警告问题。`, 'warning'))
|
|
83
|
+
if (source.issues_omitted > 0) {
|
|
84
|
+
result.push(notice(`另有 ${source.issues_omitted} 个问题未在快照中展开。`, 'warning'))
|
|
85
|
+
}
|
|
86
|
+
return result
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function render(container, datasetId) {
|
|
90
|
+
if (!(container instanceof Element)) fail('container-invalid', 'container must be an Element')
|
|
91
|
+
const dataset = artifactDataset(datasetId)
|
|
92
|
+
const article = document.createElement('article')
|
|
93
|
+
article.className = 'marivo-artifact'
|
|
94
|
+
article.append(text('p', summary(dataset), 'marivo-artifact-summary'))
|
|
95
|
+
const material = notices(dataset)
|
|
96
|
+
if (material.length > 0) {
|
|
97
|
+
const list = document.createElement('ul')
|
|
98
|
+
list.className = 'marivo-artifact-notices'
|
|
99
|
+
list.append(...material)
|
|
100
|
+
article.append(list)
|
|
101
|
+
}
|
|
102
|
+
container.replaceChildren(article)
|
|
103
|
+
return container
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const api = Object.freeze({ render })
|
|
107
|
+
Object.defineProperty(scope, 'MarivoArtifact', {
|
|
108
|
+
configurable: false,
|
|
109
|
+
enumerable: true,
|
|
110
|
+
value: api,
|
|
111
|
+
writable: false,
|
|
112
|
+
})
|
|
113
|
+
})(globalThis)
|