@kangyishuai/dsh-projects 0.1.0 → 0.1.1
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/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/lib/paths.js +28 -0
- package/lib/service.js +1 -13
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ Restart the DSH desktop app afterwards.
|
|
|
47
47
|
|
|
48
48
|
## Side effects & risks
|
|
49
49
|
|
|
50
|
-
- **Writes metadata** under `$DSH_HOME/projects/projects.json` (or `config.dataRoot` when set). Atomic replace via a temp file; a corrupt file is renamed aside and never deleted.
|
|
50
|
+
- **Writes metadata** under `$DSH_HOME/projects/projects.json` (or `config.dataRoot` when set; a desktop app that does not export `DSH_HOME` falls back to `~/.dsh/projects`). Atomic replace via a temp file; a corrupt file is renamed aside and never deleted.
|
|
51
51
|
- **Creates Git worktrees** next to your repository (never inside it and never inside `.git/`) when you create a thread for a project that has a Git directory. Archiving the thread removes the worktree again **only** when it is clean, has no unpushed commits, and is not the current session's directory; otherwise it is kept and reported.
|
|
52
52
|
- **Runs `git`** through `node:child_process` for worktree create/remove and the cleanliness checks. No network, no credentials.
|
|
53
53
|
- **Never touches session logs.** Detaching or archiving a project leaves every `session.v*.jsonl.zstd` untouched.
|
package/README.zh-CN.md
CHANGED
|
@@ -47,7 +47,7 @@ dsh plugin --profile desktop add @kangyishuai/dsh-projects
|
|
|
47
47
|
|
|
48
48
|
## 副作用与风险
|
|
49
49
|
|
|
50
|
-
- **写元数据**到 `$DSH_HOME/projects/projects.json`(配置了 `config.dataRoot`
|
|
50
|
+
- **写元数据**到 `$DSH_HOME/projects/projects.json`(配置了 `config.dataRoot` 时写到那里;桌面版不导出 `DSH_HOME` 时回落到 `~/.dsh/projects`)。用临时文件原子替换;文件损坏时**改名隔离**,绝不删除。
|
|
51
51
|
- **会创建 Git worktree**(在仓库同级、绝不进仓库或 `.git/` 内)。归档线程时**只有**同时满足"干净、无未推送提交、不是当前会话目录"才会删除它,否则保留并报告。
|
|
52
52
|
- **会调用 `git`**(`node:child_process`)做 worktree 创建/删除与干净度检查。不走网络、不读凭据。
|
|
53
53
|
- **不碰会话日志。** 解绑或归档项目不会改动任何 `session.v*.jsonl.zstd`。
|
package/lib/paths.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// 数据根解析(**纯函数**,便于 node --test 直接引用)。
|
|
3
|
+
//
|
|
4
|
+
// 优先级与 btw / session-delete 一致:config.dataRoot → DSH_HOME(+ /projects)→ ~/.dsh/projects。
|
|
5
|
+
//
|
|
6
|
+
// 为什么必须有 ~/.dsh 回落:DSH 桌面版的进程环境里**不导出 DSH_HOME**(实测 2026-11-18:
|
|
7
|
+
// 主进程 env 只有 HOME),此前这里直接抛错,结果 projects 面板在真实桌面里显示
|
|
8
|
+
// `projects: store is unavailable`,只有 web 冒烟(显式设了 DSH_HOME)才是好的。
|
|
9
|
+
import { homedir } from "node:os";
|
|
10
|
+
import { join, resolve } from "node:path";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 解析 projects 的数据根(`projects.json` 所在目录)。
|
|
14
|
+
* @param {{ dataRoot?: unknown } | Record<string, unknown> | undefined} [config]
|
|
15
|
+
* @param {NodeJS.ProcessEnv} [env]
|
|
16
|
+
* @param {string} [home]
|
|
17
|
+
* @returns {string}
|
|
18
|
+
*/
|
|
19
|
+
export function resolveDataRoot(config, env = process.env, home = homedir()) {
|
|
20
|
+
const configured =
|
|
21
|
+
config !== null && typeof config === "object" && "dataRoot" in config
|
|
22
|
+
? config.dataRoot
|
|
23
|
+
: undefined;
|
|
24
|
+
if (typeof configured === "string" && configured.trim() !== "") return resolve(configured);
|
|
25
|
+
const fromEnv = typeof env?.DSH_HOME === "string" ? env.DSH_HOME.trim() : "";
|
|
26
|
+
if (fromEnv !== "") return resolve(join(fromEnv, "projects"));
|
|
27
|
+
return resolve(join(home, ".dsh", "projects"));
|
|
28
|
+
}
|
package/lib/service.js
CHANGED
|
@@ -23,6 +23,7 @@ import { runCommand } from "./exec.js";
|
|
|
23
23
|
import { checkExecutable, planCommand, recoveryEvidence } from "./executor.js";
|
|
24
24
|
import { appendEntry } from "./memory.js";
|
|
25
25
|
import { initialView, reduce, sortRows } from "./overview.js";
|
|
26
|
+
import { resolveDataRoot } from "./paths.js";
|
|
26
27
|
import { buildPersona } from "./persona.js";
|
|
27
28
|
import { readProjectFiles } from "./project-files.js";
|
|
28
29
|
import { decideRoute } from "./routing.js";
|
|
@@ -110,19 +111,6 @@ function dirSize(dir) {
|
|
|
110
111
|
return total;
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
/**
|
|
114
|
-
* 数据根必须可注入:优先配置项,其次进程环境给的 DSH_HOME。
|
|
115
|
-
* @param {Record<string, unknown>|undefined} config
|
|
116
|
-
* @returns {string}
|
|
117
|
-
*/
|
|
118
|
-
export function resolveDataRoot(config) {
|
|
119
|
-
const configured = config?.dataRoot;
|
|
120
|
-
if (typeof configured === "string" && configured.trim() !== "") return configured;
|
|
121
|
-
const home = process.env.DSH_HOME;
|
|
122
|
-
if (typeof home === "string" && home !== "") return `${home}/projects`;
|
|
123
|
-
throw new Error("projects: no data root; set config.dataRoot or export DSH_HOME");
|
|
124
|
-
}
|
|
125
|
-
|
|
126
114
|
export class ProjectsService extends TypertRemoteService {
|
|
127
115
|
/**
|
|
128
116
|
* @param {any} ctx
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kangyishuai/dsh-projects",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Project-level context for DeepSeek Harness: group sessions into projects, inject instructions and memory, run isolated parallel threads, and coordinate them with an optional auditable coordinator.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|