DeepSeek Harness Tauri 桌面版 | Only 8mb installer, zero environment setup, preset plugins, Windows / macOS / Linux.
style(turnrewind): normalize external contribution to repo lint rules
yingtianlande5870b116b4
diff --git a/plugins/dsh-tauri-turnrewind/README.md b/plugins/dsh-tauri-turnrewind/README.mdindex 270481a7..c2a90216 100644--- a/plugins/dsh-tauri-turnrewind/README.md+++ b/plugins/dsh-tauri-turnrewind/README.md@@ -271,11 +271,11 @@ notice 只消费一次。下一次模型 step 后不会重复注入。name: dsh-tauri-turnrewindconfig:guard:- maxFileCount: 10000 # 最多追踪文件数- maxTotalBytes: 536870912 # 总大小上限(512MB)- maxFileBytes: 52428800 # 单个文件上限(50MB)- maxDepth: 20 # 目录嵌套深度上限- maxDirs: 10000 # 目录数上限+ maxFileCount: 10000 # 最多追踪文件数+ maxTotalBytes: 536870912 # 总大小上限(512MB)+ maxFileBytes: 52428800 # 单个文件上限(50MB)+ maxDepth: 20 # 目录嵌套深度上限+ maxDirs: 10000 # 目录数上限```被护栏拒绝的工作区会在日志里输出 `turnrewind: skip snapshot tracking for <dir>: <reason>`,且结果被缓存(不会每回合重扫大目录)。与 `$HOME` 防护互为兜底:会话 cwd 为家目录时直接拒绝,其他大目录由本护栏拦截。diff --git a/plugins/dsh-tauri-turnrewind/lib/client.js b/plugins/dsh-tauri-turnrewind/lib/client.jsindex 263c04d1..0bec5e9e 100644--- a/plugins/dsh-tauri-turnrewind/lib/client.js+++ b/plugins/dsh-tauri-turnrewind/lib/client.js@@ -8,159 +8,168 @@// CommonJS-style `require` and must export `apply` (cordis plugin) + `inject`// (list of cordis services the apply() context needs).window.__ModuleLoader__.load({- id: "dsh-tauri-turnrewind/client",- factory: (require) => {- var module = { exports: {} };- var exports = module.exports;- var React = require("react");- var jsxRuntime = require("react/jsx-runtime");- var jsx = jsxRuntime.jsx;- var jsxs = jsxRuntime.jsxs;-- var inject = ["slots"];-- // ------------------------------------------------------------------- // Unified-diff line classification.- // ------------------------------------------------------------------- function classifyLine(raw) {- var line = raw;- if (/^\s*diff --git /.test(line)) return { kind: "meta", text: line.trim() };- if (/^\s*index /.test(line)) return { kind: "meta", text: line.trim() };- if (/^\s*---\s+a\//.test(line)) return { kind: "meta", text: line.trim() };- if (/^\s*\+\+\+\s+b\//.test(line)) return { kind: "meta", text: line.trim() };- if (/^\s*@@/.test(line)) return { kind: "hunk", text: line.trim() };- if (/^\s*-/.test(line)) return { kind: "del", text: line.replace(/^\s*-/, "") };- if (/^\s*\+/.test(line)) return { kind: "add", text: line.replace(/^\s*\+/, "") };- return { kind: "ctx", text: line.replace(/^\s+/, "") };- }-- function isDiffLine(raw) {- return /^\s*(diff --git |index |--- |\+\+\+ |@@|-[^-]|\+[^+]|-$|\+$)/.test(raw);- }-- // A "section separator" we emit in the preview, e.g. "--- undo-demo.txt".- function isFileSeparator(raw) {- return /^---\s+(?!a\/)\S/.test(raw);- }-- // ------------------------------------------------------------------- // Rendering.- // ------------------------------------------------------------------- var COLORS = {- delBg: "rgba(248,81,73,0.16)",- delSign: "#f85149",- addBg: "rgba(46,160,67,0.16)",- addSign: "#3fb950",- hunk: "#79b8ff",- meta: "#8b949e",- ctx: "#c9d1d9",- border: "#30363d",- bg: "var(--dsw-alias-markdown-code-block, #161b22)",- label: "var(--dsw-alias-label-tertiary, #8b949e)",- title: "var(--dsw-alias-label-secondary, #c9d1d9)",- };-- function diffLineStyle(kind) {- switch (kind) {- case "del": return { background: COLORS.delBg, color: COLORS.ctx };- case "add": return { background: COLORS.addBg, color: COLORS.ctx };- case "hunk": return { color: COLORS.hunk };- case "meta": return { color: COLORS.meta };- default: return { color: COLORS.ctx };- }- }-- function signFor(kind) {- if (kind === "del") return "-";- if (kind === "add") return "+";- return " ";- }-- function DiffLine(props) {- var entry = props.entry;- var style = diffLineStyle(entry.kind);- return jsxs("div", {- style: Object.assign(- { display: "flex", fontFamily: "var(--ds-font-family-code, monospace)", fontSize: "12.5px", lineHeight: "20px", paddingLeft: 8, paddingRight: 8, whiteSpace: "pre-wrap", wordBreak: "break-all" },- style- ),- children: [- jsx("span", {- style: { width: 16, flex: "none", color: entry.kind === "del" ? COLORS.delSign : entry.kind === "add" ? COLORS.addSign : COLORS.meta, userSelect: "none" },- children: signFor(entry.kind)- }),- jsx("span", { style: { flex: 1 }, children: entry.text })- ]- });- }-- function UndoCommandView(props) {- var node = props.node || {};- var outcome = node.outcome;- var text = outcome && typeof outcome.text === "string" ? outcome.text : "";- var state = outcome == null ? "running" : outcome.kind === "error" ? "error" : "ok";- var summary = text ? text.split("\n")[0] : (state === "error" ? "失败" : state === "running" ? "运行中" : "已完成");- var body = text.indexOf("\n") >= 0 ? text : null;- var expandedState = React.useState(body !== null);- var expanded = expandedState[0];- var setExpanded = expandedState[1];-- var lines = body ? body.split("\n") : [];- var rows = [];- for (var i = 0; i < lines.length; i++) {- var raw = lines[i];- if (isFileSeparator(raw)) {- rows.push(jsx("div", {- style: { fontFamily: "var(--ds-font-family-code, monospace)", fontSize: "12.5px", lineHeight: "20px", paddingLeft: 8, paddingRight: 8, color: COLORS.title, fontWeight: 600 },- children: raw.replace(/^---\s+/, "")- }, "fs" + i));- }- else if (isDiffLine(raw)) {- rows.push(jsx(DiffLine, { entry: classifyLine(raw) }, "l" + i));- }- else {- rows.push(jsx("div", {- style: { fontFamily: "var(--ds-font-family-code, monospace)", fontSize: "12.5px", lineHeight: "20px", paddingLeft: 8, paddingRight: 8, color: COLORS.label, whiteSpace: "pre-wrap", wordBreak: "break-word" },- children: raw- }, "p" + i));- }- }-- return jsxs("div", {- style: { border: "1px solid " + COLORS.border, background: COLORS.bg, borderRadius: 12, margin: "4px 0 4px 4px", overflow: "hidden", maxWidth: "100%" },- children: [- jsxs("button", {- type: "button",- onClick: function () { setExpanded(function (v) { return !v; }); },- style: { display: "flex", alignItems: "center", gap: 8, width: "100%", textAlign: "left", background: "transparent", border: "none", cursor: "pointer", padding: "8px 12px", color: COLORS.title, fontSize: 13 },- children: [- jsx("span", { style: { transform: expanded ? "rotate(90deg)" : "rotate(0deg)", transition: "transform .12s", display: "inline-block", color: COLORS.label }, children: "▸" }),- jsx("span", { style: { fontWeight: 500 }, children: node.name || "undo" }),- jsx("span", { style: { color: COLORS.label, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", flex: 1, minWidth: 0 }, children: summary })- ]- }),- expanded && body !== null ? jsx("div", {- style: { borderTop: "1px solid " + COLORS.border, paddingTop: 8, paddingBottom: 8, maxHeight: 340, overflow: "auto" },- children: rows- }) : null- ]- });- }-- function apply(ctx) {- ctx.slots.inject("conversation.chat.commandview", function () {- return ctx.slots.register({- name: "conversation.chat.commandview",- key: "undo"- }, UndoCommandView);- });- }-- exports.apply = apply;- exports.inject = inject;- return module.exports;- }-});+ id: 'dsh-tauri-turnrewind/client',+ factory: (require) => {+ const module = { exports: {} }+ const exports = module.exports+ const React = require('react')+ const jsxRuntime = require('react/jsx-runtime')+ const jsx = jsxRuntime.jsx+ const jsxs = jsxRuntime.jsxs++ const inject = ['slots']++ // ------------------------------------------------------------------+ // Unified-diff line classification.+ // ------------------------------------------------------------------+ function classifyLine(raw) {+ const line = raw+ if (/^\s*diff --git /.test(line))+ return { kind: 'meta', text: line.trim() }+ if (/^\s*index /.test(line))+ return { kind: 'meta', text: line.trim() }+ if (/^\s*---\s+a\//.test(line))+ return { kind: 'meta', text: line.trim() }+ if (/^\s*\+\+\+\s+b\//.test(line))+ return { kind: 'meta', text: line.trim() }+ if (/^\s*@@/.test(line))+ return { kind: 'hunk', text: line.trim() }+ if (/^\s*-/.test(line))+ return { kind: 'del', text: line.replace(/^\s*-/, '') }+ if (/^\s*\+/.test(line))+ return { kind: 'add', text: line.replace(/^\s*\+/, '') }+ return { kind: 'ctx', text: line.replace(/^\s+/, '') }+ }++ function isDiffLine(raw) {+ return /^\s*(?:diff --git |index |--- |\+\+\+ |@@|-[^-]|\+[^+]|-$|\+$)/.test(raw)+ }++ // A "section separator" we emit in the preview, e.g. "--- undo-demo.txt".+ function isFileSeparator(raw) {+ return /^---\s+(?!a\/)\S/.test(raw)+ }++ // ------------------------------------------------------------------+ // Rendering.+ // ------------------------------------------------------------------+ const COLORS = {+ delBg: 'rgba(248,81,73,0.16)',+ delSign: '#f85149',+ addBg: 'rgba(46,160,67,0.16)',+ addSign: '#3fb950',+ hunk: '#79b8ff',+ meta: '#8b949e',+ ctx: '#c9d1d9',+ border: '#30363d',+ bg: 'var(--dsw-alias-markdown-code-block, #161b22)',+ label: 'var(--dsw-alias-label-tertiary, #8b949e)',+ title: 'var(--dsw-alias-label-secondary, #c9d1d9)',+ }++ function diffLineStyle(kind) {+ switch (kind) {+ case 'del': return { background: COLORS.delBg, color: COLORS.ctx }+ case 'add': return { background: COLORS.addBg, color: COLORS.ctx }+ case 'hunk': return { color: COLORS.hunk }+ case 'meta': return { color: COLORS.meta }+ default: return { color: COLORS.ctx }+ }+ }++ function signFor(kind) {+ if (kind === 'del')+ return '-'+ if (kind === 'add')+ return '+'+ return ' '+ }++ function DiffLine(props) {+ const entry = props.entry+ const style = diffLineStyle(entry.kind)+ return jsxs('div', {+ style: Object.assign(+ { display: 'flex', fontFamily: 'var(--ds-font-family-code, monospace)', fontSize: '12.5px', lineHeight: '20px', paddingLeft: 8, paddingRight: 8, whiteSpace: 'pre-wrap', wordBreak: 'break-all' },+ style,+ ),+ children: [+ jsx('span', {+ style: { width: 16, flex: 'none', color: entry.kind === 'del' ? COLORS.delSign : entry.kind === 'add' ? COLORS.addSign : COLORS.meta, userSelect: 'none' },+ children: signFor(entry.kind),+ }),+ jsx('span', { style: { flex: 1 }, children: entry.text }),+ ],+ })+ }++ function UndoCommandView(props) {+ const node = props.node || {}+ const outcome = node.outcome+ const text = outcome && typeof outcome.text === 'string' ? outcome.text : ''+ const state = outcome == null ? 'running' : outcome.kind === 'error' ? 'error' : 'ok'+ const summary = text ? text.split('\n')[0] : (state === 'error' ? '失败' : state === 'running' ? '运行中' : '已完成')+ const body = text.includes('\n') ? text : null+ const [expanded, setExpanded] = React.useState(body !== null)++ const lines = body ? body.split('\n') : []+ const rows = []+ for (let i = 0; i < lines.length; i++) {+ const raw = lines[i]+ if (isFileSeparator(raw)) {+ rows.push(jsx('div', {+ style: { fontFamily: 'var(--ds-font-family-code, monospace)', fontSize: '12.5px', lineHeight: '20px', paddingLeft: 8, paddingRight: 8, color: COLORS.title, fontWeight: 600 },+ children: raw.replace(/^---\s+/, ''),+ }, `fs${i}`))+ }+ else if (isDiffLine(raw)) {+ rows.push(jsx(DiffLine, { entry: classifyLine(raw) }, `l${i}`))+ }+ else {+ rows.push(jsx('div', {+ style: { fontFamily: 'var(--ds-font-family-code, monospace)', fontSize: '12.5px', lineHeight: '20px', paddingLeft: 8, paddingRight: 8, color: COLORS.label, whiteSpace: 'pre-wrap', wordBreak: 'break-word' },+ children: raw,+ }, `p${i}`))+ }+ }++ return jsxs('div', {+ style: { border: `1px solid ${COLORS.border}`, background: COLORS.bg, borderRadius: 12, margin: '4px 0 4px 4px', overflow: 'hidden', maxWidth: '100%' },+ children: [+ jsxs('button', {+ type: 'button',+ onClick() { setExpanded(v => !v) },+ style: { display: 'flex', alignItems: 'center', gap: 8, width: '100%', textAlign: 'left', background: 'transparent', border: 'none', cursor: 'pointer', padding: '8px 12px', color: COLORS.title, fontSize: 13 },+ children: [+ jsx('span', { style: { transform: expanded ? 'rotate(90deg)' : 'rotate(0deg)', transition: 'transform .12s', display: 'inline-block', color: COLORS.label }, children: '▸' }),+ jsx('span', { style: { fontWeight: 500 }, children: node.name || 'undo' }),+ jsx('span', { style: { color: COLORS.label, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', flex: 1, minWidth: 0 }, children: summary }),+ ],+ }),+ expanded && body !== null+ ? jsx('div', {+ style: { borderTop: `1px solid ${COLORS.border}`, paddingTop: 8, paddingBottom: 8, maxHeight: 340, overflow: 'auto' },+ children: rows,+ })+ : null,+ ],+ })+ }++ function apply(ctx) {+ ctx.slots.inject('conversation.chat.commandview', () => {+ return ctx.slots.register({+ name: 'conversation.chat.commandview',+ key: 'undo',+ }, UndoCommandView)+ })+ }++ exports.apply = apply+ exports.inject = inject+ return module.exports+ },+})// Client half of dsh-tauri-turnrewind: raises an in-app dialog when the// current session carries an unsupported-workspace heads-up from the host.// Hand-wrapped in the dsh client ModuleLoader format (no build step): the webdiff --git a/plugins/dsh-tauri-turnrewind/lib/core/git-snapshot.js b/plugins/dsh-tauri-turnrewind/lib/core/git-snapshot.jsindex 2b4acac1..f9c26a56 100644--- a/plugins/dsh-tauri-turnrewind/lib/core/git-snapshot.js+++ b/plugins/dsh-tauri-turnrewind/lib/core/git-snapshot.js@@ -1,7 +1,7 @@import { Buffer } from 'node:buffer'import { spawn } from 'node:child_process'import { createHash, randomUUID } from 'node:crypto'-import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs'+import { existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs'import { basename, dirname, join, relative, resolve, sep } from 'node:path'import process from 'node:process'import { TextDecoder, TextEncoder } from 'node:util'@@ -184,11 +184,11 @@ function isExcludedPath(relPath, isDir) {return EXCLUDE_DIRS.has(base)// Files excluded by EXCLUDE_PATHS: .env, .env.*, *.pem, *.key, id_rsa*,// credentials.*, secrets.*- if (/^\.env($|\.)/.test(base))+ if (/^\.env(?:$|\.)/.test(base))return true- if (/\.(pem|key)$/i.test(base))+ if (/\.(?:pem|key)$/i.test(base))return true- if (/^id_rsa/.test(base) || /^credentials\./.test(base) || /^secrets\./.test(base))+ if (base.startsWith('id_rsa') || /^credentials\./.test(base) || /^secrets\./.test(base))return truereturn false}@@ -406,7 +406,12 @@ export async function diffAgainstDisk(store, commit, path, maxLines) {if (from === to)return ''const output = await runGit(store.repoDir, store.workspaceDir, [- 'diff', '--no-renames', '--src-prefix=snapshot/', '--dst-prefix=disk/', from, to,+ 'diff',+ '--no-renames',+ '--src-prefix=snapshot/',+ '--dst-prefix=disk/',+ from,+ to,])return truncateDiff(output.toString('utf8'), maxLines)}diff --git a/plugins/dsh-tauri-turnrewind/lib/index.js b/plugins/dsh-tauri-turnrewind/lib/index.jsindex 84a905fa..a1296dc9 100644--- a/plugins/dsh-tauri-turnrewind/lib/index.js+++ b/plugins/dsh-tauri-turnrewind/lib/index.js@@ -253,9 +253,11 @@ async function settleSessionTurns(ledger, active, sessionId, exceptKey, reason)}}-/** Redo the most recently applied undo. Restores each touched path to the turn's+/**+ * Redo the most recently applied undo. Restores each touched path to the turn's* after-snapshot (its post-image), but only if disk still matches the undone- * state — otherwise the undo result would silently clobber later human edits. */+ * state — otherwise the undo result would silently clobber later human edits.+ */async function applyRedo(runtime, invocation, workspaceDir, workspaceKey) {const op = getLatestAppliedUndo(runtime.db, invocation.agent.session.id, workspaceKey)if (!op) {diff --git a/plugins/dsh-tauri-turnrewind/package.json b/plugins/dsh-tauri-turnrewind/package.jsonindex 43edbece..de97bb81 100644--- a/plugins/dsh-tauri-turnrewind/package.json+++ b/plugins/dsh-tauri-turnrewind/package.json@@ -3,14 +3,14 @@"type": "module","version": "0.1.0-dev.4","description": "Local turn-aware workspace undo for DeepSeek Harness",- "main": "lib/index.js",- "files": ["README.md", "cordis.patch.yml", "lib"],"exports": {".": "./lib/index.js","./client": "./lib/client.js","./cordis.patch.yml": "./cordis.patch.yml","./package.json": "./package.json"},+ "main": "lib/index.js",+ "files": ["README.md", "cordis.patch.yml", "lib"],"dsh": {"runtime": "host","bundle": {diff --git a/plugins/dsh-tauri-turnrewind/test/git-snapshot.test.js b/plugins/dsh-tauri-turnrewind/test/git-snapshot.test.jsindex 709b470f..624d1a89 100644--- a/plugins/dsh-tauri-turnrewind/test/git-snapshot.test.js+++ b/plugins/dsh-tauri-turnrewind/test/git-snapshot.test.js@@ -1,4 +1,5 @@import assert from 'node:assert/strict'+import { Buffer } from 'node:buffer'import { mkdir, mkdtemp, readFile, rm, stat, writeFile } from 'node:fs/promises'import { tmpdir } from 'node:os'import { join } from 'node:path'@@ -228,7 +229,10 @@ it('probes a small workspace as trackable and refuses oversized / deep ones', as// deep nestinglet dir = workspace- for (let i = 0; i < 6; i++) { dir = join(dir, 'd'); await mkdir(dir) }+ for (let i = 0; i < 6; i++) {+ dir = join(dir, 'd')+ await mkdir(dir)+ }const deep = probeWorkspace(workspace, { maxDepth: 3 })assert.equal(deep.ok, false)assert.match(deep.reason, /nesting depth/)diff --git a/plugins/dsh-tauri-turnrewind/test/lifecycle.test.js b/plugins/dsh-tauri-turnrewind/test/lifecycle.test.jsindex 4733b2ba..a29d998a 100644--- a/plugins/dsh-tauri-turnrewind/test/lifecycle.test.js+++ b/plugins/dsh-tauri-turnrewind/test/lifecycle.test.js@@ -3,9 +3,9 @@ import { mkdir, mkdtemp, readFile, rm, stat, writeFile } from 'node:fs/promises'import { tmpdir } from 'node:os'import { join, resolve } from 'node:path'import { it } from 'vitest'-import { applyUndo } from '../lib/index.js'import { captureSnapshot, createSnapshotStore } from '../lib/core/git-snapshot.js'import { getTurn, insertTurn, openLedger, settleTurn } from '../lib/core/ledger.js'+import { applyUndo } from '../lib/index.js'async function setupTurn() {const root = await mkdtemp(join(tmpdir(), 'turnrewind-lifecycle-test-'))@@ -17,7 +17,7 @@ async function setupTurn() {const before = await captureSnapshot(store, 'refs/turnrewind/t1-before', 'before')await writeFile(join(workspace, 'a.txt'), 'v2\n')await writeFile(join(workspace, 'c.txt'), 'new\n')- const after = await captureSnapshot(store, 'refs/turnrewind/t1-after', 'after', before.commit)+ await captureSnapshot(store, 'refs/turnrewind/t1-after', 'after', before.commit)insertTurn(db, {turnId: 'session:1',sessionId: 'session',