Files
deepseek-harness/examples/desktop/fixtures/hub-samples/scripts/dedup_exact.py
ZiyaZhang e8f5c0b51b feat(desktop): DSH Electron desktop shell — harness internals visualized
Minimal Electron shell over the DSH JSON-RPC runtime — a first-look at
what a ChatGPT.app-style host on top of the DeepSeek Harness looks
like, with the harness's normally-invisible internals (trace timeline,
context surface, subagent tree, compaction, plugin registry, rubrics)
brought forward as first-class UI surfaces so plugin authors and
researchers can see what the agent is actually doing.

Runs against three keyless-to-live profiles (stdio-echo works on
master out of the box; daemon-echo / daemon-vibe-echo activate once
the daemon-demo lands; stdio-deepseek and daemon-vibe hit the real
DeepSeek API when you supply a key). HARNESS_DEV auto-resolves to the
in-repo runtime when this shell ships under examples/desktop/, so a
fresh clone launches without config; env DSH_DEV_ROOT overrides for
custom layouts, and a sibling deepseek-harness-dev/ checkout is the
original dev workflow.

Cold-clone gate (P0 fixes for first-time-clone usability):
- HARNESS_DEV: 3-candidate resolver (env → walk-up in-repo marker →
  sibling), unit-tested via mock fs so ordering is locked without
  needing either real layout on disk.
- config yml leaves rewritten at assemble time so the sibling-clone
  paths (../../deepseek-harness-dev/examples/echo-agent/…) become
  the in-repo paths (../../echo-agent/…) in the released tree —
  source yml stays usable for local dev, released tree ships a
  working shape.
- pnpm-workspace.yaml allowBuilds.electron = true (was placeholder).
- missing-key card in stdio-deepseek offers a one-click switch to
  stdio-echo (the keyless profile that works on master) rather than
  daemon-echo (blocked on the not-yet-shipped daemon-demo).
- assemble-oss-release.sh rewrites the source-side breadcrumb name
  'dsh-desktop-demo' → 'dsh-desktop' for the released package.json.

FOUC guard on the onboarding gate (41fc5df carried) keeps the
first-launch splash from flashing before the runtime probe finishes.

Test suite (1634 tests in source, 3990 in the runtime repo) covers
resolver ordering, renderer classifiers, trace timeline shape,
compaction diff rendering, rubric parity, and the missing-key
onboarding paths.
2026-07-18 12:59:34 -07:00

73 lines
2.4 KiB
Python

#!/usr/bin/env python3
# dedup_exact.py — exact-match dedup over a JSONL stream of chat messages.
#
# Contract (see docs/design-refs/rl-workflow-needs.md §3):
# argv[1] = input JSONL path (one row per turn)
# argv[2] = output JSONL path (dedup'd)
# The last line of stdout is a JSON summary `{written, dropped, notes}` so the
# Hub can render the diff chip without inspecting the output file directly.
#
# The dedup key is the SHA1 of the row's `messages` list (or the whole row if
# `messages` is absent). Rows that fail to parse are dropped and counted.
# This is a demo script — a researcher would fork it, swap the key function,
# and save the new version.
import hashlib
import json
import sys
def key_of(row):
if isinstance(row, dict) and "messages" in row:
return hashlib.sha1(
json.dumps(row["messages"], sort_keys=True).encode("utf-8")
).hexdigest()
return hashlib.sha1(json.dumps(row, sort_keys=True).encode("utf-8")).hexdigest()
def main():
if len(sys.argv) < 3:
print(json.dumps({"written": 0, "dropped": 0, "notes": "usage: dedup_exact.py in.jsonl out.jsonl"}))
sys.exit(2)
input_path = sys.argv[1]
output_path = sys.argv[2]
seen = set()
written = 0
dropped_dup = 0
dropped_bad = 0
with open(input_path, "r", encoding="utf-8") as fin, \
open(output_path, "w", encoding="utf-8") as fout:
for i, raw in enumerate(fin):
line = raw.strip()
if not line:
continue
try:
row = json.loads(line)
except json.JSONDecodeError:
dropped_bad += 1
continue
k = key_of(row)
if k in seen:
dropped_dup += 1
continue
seen.add(k)
fout.write(json.dumps(row, ensure_ascii=False) + "\n")
written += 1
if (i + 1) % 1000 == 0:
print(f"processed {i + 1} rows, kept {written}, dedup dropped {dropped_dup}")
total_dropped = dropped_dup + dropped_bad
notes_bits = []
if dropped_dup:
notes_bits.append(f"{dropped_dup} exact duplicates")
if dropped_bad:
notes_bits.append(f"{dropped_bad} malformed rows")
notes = "; ".join(notes_bits) if notes_bits else "no duplicates found"
print(json.dumps({"written": written, "dropped": total_dropped, "notes": notes}))
if __name__ == "__main__":
main()