dsh-plugin-opc 0.1.34 → 0.1.36
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/lib/client.js +526 -28
- package/lib/index.js +87 -76
- package/package.json +1 -1
- package/runtime/app_delivery/SKILL.md +21 -26
- package/runtime/app_delivery/references/contract.md +2 -1
- package/runtime/app_delivery/scripts/delivery.py +8 -1
- package/runtime/app_delivery_admin.py +3 -1
- package/runtime/app_delivery_auth.py +23 -12
- package/runtime/worker.py +15 -6
package/runtime/worker.py
CHANGED
|
@@ -75,7 +75,7 @@ def load_json_if_exists(path: Path, default):
|
|
|
75
75
|
return default
|
|
76
76
|
|
|
77
77
|
|
|
78
|
-
def validate_file_change(source: Path, change: dict):
|
|
78
|
+
def validate_file_change(source: Path, change: dict, dockerfile_only=False):
|
|
79
79
|
d.require(isinstance(change, dict), "修改项必须是对象")
|
|
80
80
|
d.require(isinstance(change.get("group", ""), str) and len(change.get("group", "")) <= 160, "修改分组必须是简短文字")
|
|
81
81
|
path = change.get("path")
|
|
@@ -87,6 +87,8 @@ def validate_file_change(source: Path, change: dict):
|
|
|
87
87
|
if not isinstance(change.get("path"), str) or not change["path"] or not isinstance(change.get("reason", "适配修改"), str) or not isinstance(change.get("content"), str):
|
|
88
88
|
raise ValueError("修改项必须有路径、原因和完整文件内容")
|
|
89
89
|
dockerfile = target.relative_to(source).as_posix() == "Dockerfile"
|
|
90
|
+
d.require(not dockerfile_only or dockerfile,
|
|
91
|
+
"AI 只能修改根目录 Dockerfile。确需修改应用代码时,请指出原文件位置和原因,由用户在源工程处理:" + path)
|
|
90
92
|
exists = target.is_file()
|
|
91
93
|
d.require(exists or dockerfile, "AI 只可新增根目录 Dockerfile;其余新增文件请由用户提供:" + path)
|
|
92
94
|
if not dockerfile:
|
|
@@ -162,6 +164,7 @@ def resolve_and_enrich_proposal(
|
|
|
162
164
|
feedback_text: str = "",
|
|
163
165
|
expected_port: int | None = None,
|
|
164
166
|
reuse_source_admin: bool = False,
|
|
167
|
+
dockerfile_only: bool = False,
|
|
165
168
|
) -> tuple[dict, dict | None, dict | None]:
|
|
166
169
|
d.require(isinstance(proposal, dict) and isinstance(proposal.get("summary"), str) and proposal["summary"].strip(), "提案缺少摘要")
|
|
167
170
|
for field in ("issues", "changes", "unresolved"):
|
|
@@ -195,7 +198,7 @@ def resolve_and_enrich_proposal(
|
|
|
195
198
|
change = {**change, "id": change.get("path") or f"change-{idx + 1}"}
|
|
196
199
|
if isinstance(change, dict) and not change.get("reason"):
|
|
197
200
|
change = {**change, "reason": "容器化与部署适配"}
|
|
198
|
-
validate_file_change(source, change)
|
|
201
|
+
validate_file_change(source, change, dockerfile_only)
|
|
199
202
|
resolved_changes.append(change)
|
|
200
203
|
except ValueError as exc:
|
|
201
204
|
change_errors.append(str(exc))
|
|
@@ -341,7 +344,8 @@ def resolve_and_enrich_proposal(
|
|
|
341
344
|
|
|
342
345
|
|
|
343
346
|
def apply_plan(root, proposal, target, *, repair=False, failed_revision="", failure_feedback="", expected_port=None,
|
|
344
|
-
revision_count=1, feedback_text="", admin_reply=None, previous_skill_markdown="", reuse_source_admin=False
|
|
347
|
+
revision_count=1, feedback_text="", admin_reply=None, previous_skill_markdown="", reuse_source_admin=False,
|
|
348
|
+
dockerfile_only=False):
|
|
345
349
|
original = root / "review"
|
|
346
350
|
d.require(d.inspect_source(original / "source")[0] == d.load(original / "inventory.json")["files"], "Source changed; import again")
|
|
347
351
|
d.require(isinstance(proposal.get("summary"), str) and proposal["summary"].strip(), "summary required")
|
|
@@ -355,6 +359,7 @@ def apply_plan(root, proposal, target, *, repair=False, failed_revision="", fail
|
|
|
355
359
|
revision_count=revision_count,
|
|
356
360
|
feedback_text=feedback_text,
|
|
357
361
|
reuse_source_admin=reuse_source_admin,
|
|
362
|
+
dockerfile_only=dockerfile_only,
|
|
358
363
|
)
|
|
359
364
|
d.require(not (proposal.get("unresolved") or proposal["contract"].get("unresolved")), "Resolve outstanding questions before preparation")
|
|
360
365
|
shutil.copytree(original, target)
|
|
@@ -714,8 +719,8 @@ def main(body):
|
|
|
714
719
|
d.save(root / "routes_scanned.json", {"scanned": True})
|
|
715
720
|
res["_auto_contract_enrichment"] = (
|
|
716
721
|
"提交方案时,系统会按同一规则复核 build_context 内的接口与页面并合并进契约。"
|
|
717
|
-
"
|
|
718
|
-
"
|
|
722
|
+
"只提交需覆盖或补充的正式路由。按扫描给出的文件和行号核对正式入口与共用中间件即可。"
|
|
723
|
+
"共用鉴权写一条含 auth.profile 的规则,公开入口按路径及方法声明例外。"
|
|
719
724
|
)
|
|
720
725
|
return res
|
|
721
726
|
if action == "inspect_local_storage":
|
|
@@ -744,7 +749,7 @@ def main(body):
|
|
|
744
749
|
"executable": bool(body.get("executable", False)),
|
|
745
750
|
"group": str(body.get("group") or ""),
|
|
746
751
|
}
|
|
747
|
-
validate_file_change(root / "review/source", change)
|
|
752
|
+
validate_file_change(root / "review/source", change, body.get("dockerfile_only") is True)
|
|
748
753
|
draft_path = root / "draft_files.json"
|
|
749
754
|
drafts = load_json_if_exists(draft_path, {})
|
|
750
755
|
cid = change["id"]
|
|
@@ -772,6 +777,7 @@ def main(body):
|
|
|
772
777
|
feedback_text=fb_text,
|
|
773
778
|
expected_port=body.get("expected_port"),
|
|
774
779
|
reuse_source_admin=body.get("reuse_source_admin") is True,
|
|
780
|
+
dockerfile_only=body.get("dockerfile_only") is True,
|
|
775
781
|
)
|
|
776
782
|
diffs = compute_change_diffs(source_dir, proposal.get("changes", []))
|
|
777
783
|
_, has_orig = extract_original_config_values(source_dir, (proposal.get("contract") or {}).get("configs", []))
|
|
@@ -799,6 +805,7 @@ def main(body):
|
|
|
799
805
|
admin_reply=body.get("admin_reply"),
|
|
800
806
|
previous_skill_markdown=body.get("previous_skill_markdown", ""),
|
|
801
807
|
reuse_source_admin=body.get("reuse_source_admin") is True,
|
|
808
|
+
dockerfile_only=body.get("dockerfile_only") is True,
|
|
802
809
|
)
|
|
803
810
|
d.bundle_work(temp_path / "approved", temp_path / "bundle", login)
|
|
804
811
|
syntax_check = check_archive_syntax(temp_path / "bundle/app.tar")
|
|
@@ -832,6 +839,8 @@ def main(body):
|
|
|
832
839
|
feedback_text=str(body.get("feedback") or ""),
|
|
833
840
|
admin_reply=body.get("admin_reply"),
|
|
834
841
|
previous_skill_markdown=body.get("previous_skill_markdown", ""),
|
|
842
|
+
reuse_source_admin=body.get("reuse_source_admin") is True,
|
|
843
|
+
dockerfile_only=body.get("dockerfile_only") is True,
|
|
835
844
|
)
|
|
836
845
|
result = d.bundle_work(dest / "approved", dest / "bundle", login)
|
|
837
846
|
syntax_check = check_archive_syntax(dest / "bundle/app.tar")
|