"""Run the original DSH argument parser with inert, owned inputs. No DSH application starts."""
from pathlib import Path
from tempfile import TemporaryDirectory
import argparse,hashlib,json,os,subprocess,shutil
def digest(path):
return hashlib.sha256(path.read_bytes()).hexdigest()
def main():
cli=argparse.ArgumentParser();cli.add_argument("--node",required=True,help="Absolute Node24.22.3 executable")
args=cli.parse_args();node=Path(args.node).resolve();root=Path(__file__).resolve().parent
samples=json.loads((root/"parser-samples.json").read_bytes())
assert len(samples)==26 and node.is_file()
env={k:os.environ[k] for k in ["SystemRoot","WINDIR"] if k in os.environ}
env["PATH"]=str(node.parent)+os.pathsep+str(Path(env.get("SystemRoot","C:/Windows"))/"System32")
options=dict(capture_output=True,encoding="utf8",timeout=20)
if os.name=="nt":options["creationflags"]=subprocess.CREATE_NO_WINDOW
version=subprocess.run([str(node),"-p","process.versions.node"],env=env,**options)
assert version.returncode==0 and version.stdout.strip()=="24.22.3","Use exactly Node24.22.3 for this recorded matrix"
cases=[]
with TemporaryDirectory(prefix="owned-parser-",dir=root) as temporary:
own=Path(temporary).resolve();assert own.is_relative_to(root)
runtime=own/"runtime";runtime.mkdir()
shutil.copyfile(root/"vendor/dsh-args.ts",runtime/"dsh-args.ts")
shutil.copytree(root/"vendor/commander",runtime/"node_modules/commander")
(runtime/"package.json").write_bytes(b'{"private":true,"type":"module"}\n')
assert digest(runtime/"dsh-args.ts")==digest(root/"vendor/dsh-args.ts")
for p in (root/"vendor/commander").rglob("*"):
if p.is_file():assert digest(p)==digest(runtime/"node_modules/commander"/p.relative_to(root/"vendor/commander"))
env.update(HOME=str(own),USERPROFILE=str(own),DSH_HOME=str(own/"dsh"),APPDATA=str(own/"roaming"),LOCALAPPDATA=str(own/"local"),TEMP=str(own),TMP=str(own))
for sample in samples:
proc=subprocess.run([str(node),"--permission","--allow-fs-read="+str(root),
str(root/"parser_child.mjs"),"--samples",str(root/"parser-samples.json"),"--case",sample["name"],"--native",str(runtime/"dsh-args.ts")],
cwd=own,env=env,**options)
if "expected" in sample:
expected=dict(exit_code=0,result=sample["expected"])
actual=dict(exit_code=proc.returncode,result=json.loads(proc.stdout)["result"] if proc.returncode==0 else None)
else:
expected=dict(exit_code=sample["exit"],requested_channel_contains=True)
actual=dict(exit_code=proc.returncode,requested_channel_contains=sample.get("stdout",sample.get("stderr")) in (proc.stdout if "stdout" in sample else proc.stderr))
assert expected==actual,(sample["name"],expected,actual,proc.stdout,proc.stderr)
cases.append(dict(name=sample["name"],input=dict(argv=sample["argv"],manageDesktop=sample.get("manageDesktop",False),supplied_version="owned-parser-version"),
operation="Actual unmodified parseDshArgs and commander15 in a separate read-only Node process; native exit remains real",
expected=expected,actual=actual,stdout=proc.stdout,stderr=proc.stderr,
conditions=["Node24.22.3","original MIT DSH software module","commander15.0.0","inert argv only","no native launcher handlers or app"],
native_module_sha256=digest(root/"vendor/dsh-args.ts")))
print(json.dumps(dict(node=version.stdout.strip(),node_binary_sha256=digest(node),commander="15.0.0",cases=cases,
test_source_sha256=digest(Path(__file__)),input_sha256=digest(root/"parser-samples.json"),
DSH_application_executed=False,package_manager_executed=False,model_requests=0,
scope="26 bounded native parser and genuine process-exit cases. Version value and desktop carrier flag are supplied test inputs; not installed app version or carrier proof."),ensure_ascii=False))
if __name__=="__main__":main()
本例需在 Windows、Python3.12、Node24.22.3;ZIP内原MIT软件模块与commander15,未安装完整DSH。 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程
运行环境:Windows、Python3.12、Node24.22.3;ZIP内原MIT软件模块与commander15,未安装完整DSH。
入口文件:projects/deepseek-harness-install/parser_matrix.py
本地运行步骤快速上手
- 点击上方“保存源码”保存为
parser_matrix.py,或下载右侧课程工程包。 - 确认本地已准备 Windows、Python3.12、Node24.22.3;ZIP内原MIT软件模块与commander15,未安装完整DSH。。
- 按对应章节命令执行,结合正文核对实际输出。
附件与关联工程包下载
课程关联工程包(登记关联1章) · 含当前章节或实例 · mbskycom202612a141.zip
课程关联工程包(登记关联33章) · 含当前章节或实例 · mbskycom202612a128.zip