dsh-plugin-opc 0.0.0-stage → 0.1.7

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.
Files changed (69) hide show
  1. package/README.md +257 -2
  2. package/config/overlay.example.yml +9 -0
  3. package/docs/acceptance-matrix.md +30 -0
  4. package/docs/images/01-plugins.png +0 -0
  5. package/docs/images/02-install-menu.png +0 -0
  6. package/docs/images/03-install-address.png +0 -0
  7. package/docs/images/04-installed.png +0 -0
  8. package/docs/images/05-open-sidebar.png +0 -0
  9. package/docs/images/06-opc-entries.png +0 -0
  10. package/docs/images/07-space-and-knowledge.png +0 -0
  11. package/docs/images/08-search-results.png +0 -0
  12. package/docs/images/09-document.png +0 -0
  13. package/docs/images/10-mention-menu.png +0 -0
  14. package/docs/images/11-mention-question.png +0 -0
  15. package/docs/images/12-answer-sources.png +0 -0
  16. package/docs/images/13-skills-install.png +0 -0
  17. package/docs/images/14-skill-enabled.png +0 -0
  18. package/docs/images/15-skill-slash.png +0 -0
  19. package/docs/images/16-mcp-list.png +0 -0
  20. package/docs/images/17-mcp-tool.png +0 -0
  21. package/docs/images/chat-mention.png +0 -0
  22. package/docs/images/git-source.png +0 -0
  23. package/docs/images/mcp-services.png +0 -0
  24. package/docs/implementation-status.md +40 -0
  25. package/lib/client.js +31892 -0
  26. package/lib/index.js +3477 -0
  27. package/package.json +90 -4
  28. package/runtime/app_delivery/LICENSE +18 -0
  29. package/runtime/app_delivery/PROVENANCE.md +1 -0
  30. package/runtime/app_delivery/SKILL.md +38 -0
  31. package/runtime/app_delivery/__init__.py +1 -0
  32. package/runtime/app_delivery/assets/invoke_api.py.txt +269 -0
  33. package/runtime/app_delivery/references/contract.md +90 -0
  34. package/runtime/app_delivery/references/framework-checks.md +59 -0
  35. package/runtime/app_delivery/references/integration.md +23 -0
  36. package/runtime/app_delivery/references/preparation-checks.md +26 -0
  37. package/runtime/app_delivery/scripts/__init__.py +1 -0
  38. package/runtime/app_delivery/scripts/delivery.py +650 -0
  39. package/runtime/app_delivery/scripts/invoke_api.py +269 -0
  40. package/runtime/app_delivery/scripts/sqlite_snapshot.py +139 -0
  41. package/runtime/app_delivery_auth.py +113 -0
  42. package/runtime/app_delivery_config.py +108 -0
  43. package/runtime/app_delivery_migration.py +2452 -0
  44. package/runtime/app_delivery_repair.py +48 -0
  45. package/runtime/app_delivery_sources.py +39 -0
  46. package/runtime/vendor/tomli/LICENSE +21 -0
  47. package/runtime/vendor/tomli/__init__.py +8 -0
  48. package/runtime/vendor/tomli/_parser.py +793 -0
  49. package/runtime/vendor/tomli/_re.py +119 -0
  50. package/runtime/vendor/tomli/_types.py +10 -0
  51. package/runtime/vendor/yaml/LICENSE +20 -0
  52. package/runtime/vendor/yaml/__init__.py +389 -0
  53. package/runtime/vendor/yaml/composer.py +138 -0
  54. package/runtime/vendor/yaml/constructor.py +748 -0
  55. package/runtime/vendor/yaml/cyaml.py +100 -0
  56. package/runtime/vendor/yaml/dumper.py +61 -0
  57. package/runtime/vendor/yaml/emitter.py +1137 -0
  58. package/runtime/vendor/yaml/error.py +74 -0
  59. package/runtime/vendor/yaml/events.py +85 -0
  60. package/runtime/vendor/yaml/loader.py +63 -0
  61. package/runtime/vendor/yaml/nodes.py +48 -0
  62. package/runtime/vendor/yaml/parser.py +588 -0
  63. package/runtime/vendor/yaml/reader.py +185 -0
  64. package/runtime/vendor/yaml/representer.py +388 -0
  65. package/runtime/vendor/yaml/resolver.py +226 -0
  66. package/runtime/vendor/yaml/scanner.py +1435 -0
  67. package/runtime/vendor/yaml/serializer.py +110 -0
  68. package/runtime/vendor/yaml/tokens.py +103 -0
  69. package/runtime/worker.py +574 -0
@@ -0,0 +1,48 @@
1
+ """Read-only inspection of the exact deployment archive; never execute app code."""
2
+ import os
3
+ from pathlib import PurePosixPath
4
+ import shutil
5
+ import subprocess
6
+ import tarfile
7
+
8
+
9
+ def read_archive_file(archive, path):
10
+ if not archive.is_file():
11
+ raise ValueError("没有已打包制品,请先检查原始源码与提案")
12
+ with tarfile.open(archive) as tar:
13
+ matches = [m for m in tar if str(PurePosixPath(m.name)) == str(PurePosixPath(path))]
14
+ if len(matches) != 1 or not matches[0].isfile() or matches[0].size > 2_000_000:
15
+ raise ValueError("制品文件不存在、重复、非普通文件或超过读取限制")
16
+ return tar.extractfile(matches[0]).read().decode('utf-8')
17
+
18
+
19
+ def check_archive_syntax(archive):
20
+ node = shutil.which('node')
21
+ checked = 0
22
+ with tarfile.open(archive) as tar:
23
+ for member in tar:
24
+ path = PurePosixPath(member.name)
25
+ if not member.isfile() or 'node_modules' in path.parts:
26
+ continue
27
+ # Plain .js can contain JSX or depend on package type; do not guess.
28
+ if path.suffix not in {'.mjs', '.cjs'}:
29
+ continue
30
+ if not node:
31
+ return {'label': '交付包 JavaScript 语法', 'status': 'pending', 'detail': '本机缺少 Node.js,未执行语法检查;仍需目标环境验证'}
32
+ if member.size > 2_000_000:
33
+ raise ValueError(f'语法检查未完成:{member.name} 超过 2 MB 限制')
34
+ source = tar.extractfile(member).read()
35
+ try:
36
+ result = subprocess.run(
37
+ [node, '--input-type=' + ('module' if path.suffix == '.mjs' else 'commonjs'), '--check'],
38
+ input=source, capture_output=True, timeout=10,
39
+ env={k: v for k, v in os.environ.items() if k not in {'NODE_OPTIONS', 'NODE_PATH'}},
40
+ )
41
+ except subprocess.TimeoutExpired as exc:
42
+ raise ValueError(f'语法检查超时:{member.name}') from exc
43
+ if result.returncode:
44
+ # Do not expose source lines or embedded credentials in parser output.
45
+ error = next((s.strip() for s in result.stderr.decode(errors='replace').splitlines() if 'SyntaxError:' in s), 'Node.js 解析失败')
46
+ raise ValueError(f'交付包语法检查失败:{member.name}:{error};请修复完整文件后重新打包')
47
+ checked += 1
48
+ return {'label': '交付包 JavaScript 语法', 'status': 'passed' if checked else 'pending', 'detail': f'已检查 {checked} 个 .mjs/.cjs 文件;不代表目标版本兼容、启动或业务验证通过' if checked else '没有可用此检查器验证的 .mjs/.cjs 文件;其他语言及 .js/TS/JSX 未检查'}
@@ -0,0 +1,39 @@
1
+ """Read only exact Go module versions declared by the uploaded application."""
2
+
3
+ import os
4
+ from pathlib import Path
5
+ import re
6
+
7
+ from app_delivery.scripts import delivery
8
+
9
+
10
+ def dependency_path(source: Path, module: str = "", name: str = ""):
11
+ mod = source / "go.mod"
12
+ if not mod.is_file():
13
+ raise ValueError("当前源码没有 go.mod;请提供缺失依赖的源码或接口说明")
14
+ contents = mod.read_text()
15
+ declarations = re.findall(r"^\s*(?:require\s+)?([A-Za-z0-9_.!/-]+)\s+(v[0-9][A-Za-z0-9.+-]*)\s*(?://[^\n]*)?$", contents, re.M)
16
+ replaced = set(re.findall(r"^\s*(?:replace\s+)?([A-Za-z0-9_.!/-]+)(?:\s+v[^\s]+)?\s*=>", contents, re.M))
17
+ cache = Path(os.environ.get("GOMODCACHE") or str(Path(os.environ.get("GOPATH", str(Path.home() / "go")).split(os.pathsep)[0]) / "pkg/mod"))
18
+ modules = {}
19
+ for dependency, version in declarations:
20
+ if dependency.startswith("/") or any(part in {"", ".", ".."} for part in dependency.split("/")):
21
+ continue
22
+ # Go's module-cache encoding uses !lowercase for uppercase letters.
23
+ escaped = re.sub(r"[A-Z]", lambda m: "!" + m[0].lower(), dependency)
24
+ modules[dependency] = (version, cache / (escaped + "@" + version))
25
+ if not module:
26
+ return [{"module": key, "version": version, "cached": path.is_dir() and key not in replaced} for key, (version, path) in modules.items()]
27
+ if module not in modules:
28
+ raise ValueError("只能查看 go.mod 声明的依赖,不能读取任意宿主目录")
29
+ if module in replaced:
30
+ raise ValueError("该依赖被 replace 替换;请读取上传包内的替换源码或提供实际版本,不使用旧缓存推断")
31
+ version, root = modules[module]
32
+ if not root.is_dir() or root.is_symlink():
33
+ raise ValueError("该版本依赖尚未缓存;请提供源码或先由用户准备依赖,不自动下载")
34
+ if not name:
35
+ return [{"path": path.name, "directory": path.is_dir()} for path in sorted(root.iterdir()) if not path.is_symlink() and path.name not in delivery.EXCLUDED][:100]
36
+ target = delivery.relative(root, name)
37
+ if target.is_dir():
38
+ return [{"path": path.relative_to(root).as_posix(), "directory": path.is_dir()} for path in sorted(target.iterdir()) if not path.is_symlink() and path.name not in delivery.EXCLUDED][:100]
39
+ return target
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Taneli Hukkinen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,8 @@
1
+ # SPDX-License-Identifier: MIT
2
+ # SPDX-FileCopyrightText: 2021 Taneli Hukkinen
3
+ # Licensed to PSF under a Contributor Agreement.
4
+
5
+ __all__ = ("loads", "load", "TOMLDecodeError")
6
+ __version__ = "2.4.1" # DO NOT EDIT THIS LINE MANUALLY. LET bump2version UTILITY DO IT
7
+
8
+ from ._parser import TOMLDecodeError, load, loads