@kangyishuai/dsh-projects 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +73 -2
- package/README.zh-CN.md +73 -0
- package/cordis.patch.yml +3 -0
- package/lib/attach.js +89 -0
- package/lib/autofix.js +111 -0
- package/lib/autopr.js +115 -0
- package/lib/budget.js +95 -0
- package/lib/client.js +1841 -0
- package/lib/context.js +99 -0
- package/lib/exec.js +36 -0
- package/lib/executor.js +167 -0
- package/lib/index.js +5 -0
- package/lib/memory.js +53 -0
- package/lib/notify.js +50 -0
- package/lib/overview.js +199 -0
- package/lib/paths.js +28 -0
- package/lib/persona.js +49 -0
- package/lib/project-files.js +37 -0
- package/lib/routing.js +155 -0
- package/lib/service.js +1698 -0
- package/lib/store.js +547 -0
- package/lib/thread.js +245 -0
- package/lib/tools.js +277 -0
- package/lib/trash.js +71 -0
- package/lib/untrusted.js +98 -0
- package/lib/wake.js +195 -0
- package/lib/worktree.js +161 -0
- package/locale/en.json +94 -0
- package/locale/zh.json +94 -0
- package/package.json +61 -4
package/lib/wake.js
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// wake 信封:纯函数、零 I/O。
|
|
3
|
+
// 设计依据 notes/projects/m3-design.md §1:
|
|
4
|
+
// - 信封必须带线程结果摘要(M0 实测:不带时协调器说「读不到它的输出」)
|
|
5
|
+
// - 一次 wake 只注入一次(M0 实测:agent/pre-step 每步都触发,同一封信被注入 3 次)
|
|
6
|
+
// - 只有 trust: principal 算授权;模型/外部内容/peer 都不算
|
|
7
|
+
|
|
8
|
+
import { wrapUntrusted } from "./untrusted.js";
|
|
9
|
+
|
|
10
|
+
/** 只有这个信任级别能构成授权。 */
|
|
11
|
+
export const AUTHORIZING_TRUST = "principal";
|
|
12
|
+
|
|
13
|
+
/** 允许的唤醒原因。 */
|
|
14
|
+
export const WAKE_REASONS = Object.freeze([
|
|
15
|
+
"mention",
|
|
16
|
+
"thread-activity",
|
|
17
|
+
"settled",
|
|
18
|
+
"reminder",
|
|
19
|
+
"budget",
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
/** 信封里报告的最大字符数(太长会白烧上下文)。 */
|
|
23
|
+
export const REPORT_MAX_CHARS = 800;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 信封里「项目上下文摘要」的最大字符数。
|
|
27
|
+
* 用途:协调器会话拿不到宿主的 runtime context(runtime §11.24),
|
|
28
|
+
* 所以项目规则与记忆摘要随信封一起送达——信封这条路已被证明能到达协调器(§11.8)。
|
|
29
|
+
*/
|
|
30
|
+
export const CONTEXT_MAX_CHARS = 2000;
|
|
31
|
+
|
|
32
|
+
/** 人格段落上限(人格本应短小;过长会挤占任务信息)。 */
|
|
33
|
+
export const PERSONA_MAX_CHARS = 1200;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 信任级别是否构成授权。
|
|
37
|
+
* 模型输出、外部网页内容、另一个 agent 的消息都不能授权——它们只能是 peer/relay。
|
|
38
|
+
* @param {unknown} trust
|
|
39
|
+
* @returns {boolean}
|
|
40
|
+
*/
|
|
41
|
+
export function isAuthorizingTrust(trust) {
|
|
42
|
+
return String(trust ?? "") === AUTHORIZING_TRUST;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 截断报告文本(先按行保留头部,避免把一句话截半)。
|
|
47
|
+
* @param {unknown} text
|
|
48
|
+
* @param {number} [max]
|
|
49
|
+
* @returns {string}
|
|
50
|
+
*/
|
|
51
|
+
export function clipReport(text, max = REPORT_MAX_CHARS) {
|
|
52
|
+
const value = String(text ?? "").trim();
|
|
53
|
+
if (value === "") return "";
|
|
54
|
+
if (value.length <= max) return value;
|
|
55
|
+
const head = value.slice(0, max);
|
|
56
|
+
const lastBreak = head.lastIndexOf("\n");
|
|
57
|
+
const cut = lastBreak > max * 0.6 ? head.slice(0, lastBreak) : head;
|
|
58
|
+
return `${cut.trimEnd()}\n…(truncated, ${value.length} chars total)`;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 构造一封 wake 信封。
|
|
63
|
+
* @param {object} input
|
|
64
|
+
* @param {string} input.reason
|
|
65
|
+
* @param {string} [input.trust]
|
|
66
|
+
* @param {{id: string, name: string}} input.project
|
|
67
|
+
* @param {{sessionId: string, state?: string, turn?: number, branch?: string|null}} input.thread
|
|
68
|
+
* @param {string} input.report
|
|
69
|
+
* @param {string} [input.context] 项目规则/记忆摘要(随信封送达协调器)
|
|
70
|
+
* @param {string} [input.persona] 协调器人格(同样随信封送达)
|
|
71
|
+
* @param {string} input.next
|
|
72
|
+
* @param {string} [input.wakeId]
|
|
73
|
+
* @returns {{ wakeId: string, text: string, sections: {name: string, text: string}[], trust: string, authorized: boolean }}
|
|
74
|
+
*/
|
|
75
|
+
export function buildEnvelope(input) {
|
|
76
|
+
const reason = WAKE_REASONS.includes(String(input?.reason))
|
|
77
|
+
? String(input.reason)
|
|
78
|
+
: "thread-activity";
|
|
79
|
+
const trust = String(input?.trust ?? AUTHORIZING_TRUST);
|
|
80
|
+
const project = input?.project ?? { id: "", name: "" };
|
|
81
|
+
const thread = input?.thread ?? { sessionId: "" };
|
|
82
|
+
// 非 principal 来源的报告一律当作**数据**包装(不可信输入隔离,见 m4-design.md §4)
|
|
83
|
+
const rawReport = input?.report;
|
|
84
|
+
const report = isAuthorizingTrust(trust)
|
|
85
|
+
? clipReport(rawReport)
|
|
86
|
+
: wrapUntrusted(clipReport(rawReport), { source: trust, maxChars: REPORT_MAX_CHARS });
|
|
87
|
+
const next = String(input?.next ?? "").trim() || "summarize what changed for the user";
|
|
88
|
+
const wakeId = String(input?.wakeId ?? `${reason}:${thread.sessionId}:${thread.turn ?? 0}`);
|
|
89
|
+
|
|
90
|
+
const head = [
|
|
91
|
+
"[project-wake v1]",
|
|
92
|
+
`wake: ${wakeId}`,
|
|
93
|
+
`reason: ${reason}`,
|
|
94
|
+
`trust: ${trust}`,
|
|
95
|
+
`project: ${project.id} (${project.name})`,
|
|
96
|
+
`thread: ${thread.sessionId} (state=${thread.state ?? "unknown"}, turn=${thread.turn ?? 0}${
|
|
97
|
+
thread.branch ? `, branch=${thread.branch}` : ""
|
|
98
|
+
})`,
|
|
99
|
+
].join("\n");
|
|
100
|
+
|
|
101
|
+
const context = clipReport(input?.context, CONTEXT_MAX_CHARS);
|
|
102
|
+
const persona = clipReport(input?.persona, PERSONA_MAX_CHARS);
|
|
103
|
+
const sections = [
|
|
104
|
+
{ name: "wake", text: head },
|
|
105
|
+
...(context === "" ? [] : [{ name: "project", text: `project-context:\n${context}` }]),
|
|
106
|
+
...(persona === "" ? [] : [{ name: "persona", text: `persona:\n${persona}` }]),
|
|
107
|
+
...(report === "" ? [] : [{ name: "report", text: `report:\n${report}` }]),
|
|
108
|
+
{ name: "next", text: `next: ${next}` },
|
|
109
|
+
];
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
wakeId,
|
|
113
|
+
text: sections.map((section) => section.text).join("\n\n"),
|
|
114
|
+
sections,
|
|
115
|
+
trust,
|
|
116
|
+
authorized: isAuthorizingTrust(trust),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* 一次 turn 内的注入去重器。
|
|
122
|
+
* agent/pre-step 每个 step 都会触发,所以「这封信注入过没有」必须记在这里。
|
|
123
|
+
* @returns {{ shouldInject: (wakeId: string) => boolean, reset: () => void, size: () => number }}
|
|
124
|
+
*/
|
|
125
|
+
export function createInjectionGuard() {
|
|
126
|
+
/** @type {Set<string>} */
|
|
127
|
+
let seen = new Set();
|
|
128
|
+
return {
|
|
129
|
+
shouldInject: (wakeId) => {
|
|
130
|
+
const key = String(wakeId ?? "");
|
|
131
|
+
if (key === "" || seen.has(key)) return false;
|
|
132
|
+
seen.add(key);
|
|
133
|
+
return true;
|
|
134
|
+
},
|
|
135
|
+
reset: () => {
|
|
136
|
+
seen = new Set();
|
|
137
|
+
},
|
|
138
|
+
size: () => seen.size,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 序列化给持久 UserMessage 用的 source(宿主要求 form: "snapshot" + sections)。
|
|
144
|
+
* @param {{ sections: {name: string, text: string}[] }} envelope
|
|
145
|
+
* @returns {{ kind: string, form: string, sections: {name: string, text: string}[] }}
|
|
146
|
+
*/
|
|
147
|
+
export function toMessageSource(envelope) {
|
|
148
|
+
return {
|
|
149
|
+
kind: "projects-wake",
|
|
150
|
+
form: "snapshot",
|
|
151
|
+
sections: envelope.sections.map((section) => ({ name: section.name, text: section.text })),
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* 决定这次线程活动要不要给协调器发信封。三条分支都有明确理由,纯函数便于单测:
|
|
157
|
+
* - `skip-turn`:这一轮之前已经通知过(水位),最常见的正常重复;
|
|
158
|
+
* - `skip-dedupe`:两个 turn/end 并发到达,水位还没写回,靠同步 guard 挡第二个;
|
|
159
|
+
* - `send`:真正要发。
|
|
160
|
+
* @param {{ turn: number, lastWakeTurn: number, wakeId: string, guard: { shouldInject: (wakeId: string) => boolean } }} input
|
|
161
|
+
* @returns {"send"|"skip-turn"|"skip-dedupe"}
|
|
162
|
+
*/
|
|
163
|
+
export function decideWake(input) {
|
|
164
|
+
const turn = Number(input?.turn ?? 0);
|
|
165
|
+
const last = Number(input?.lastWakeTurn ?? 0);
|
|
166
|
+
if (turn <= last) return "skip-turn";
|
|
167
|
+
if (!input?.guard?.shouldInject(String(input?.wakeId ?? ""))) return "skip-dedupe";
|
|
168
|
+
return "send";
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* 冷会话唤醒:应用关着时线程可能已经跑完(或失败),协调器却从没收到信封。
|
|
173
|
+
* 启动时用这个纯函数算出「欠了哪些唤醒」——只算需要人关注的终态,避免把 idle 也算进来。
|
|
174
|
+
* @param {Array<{ sessionId: string, lastWakeTurn?: number }>|null|undefined} threads
|
|
175
|
+
* @param {Map<string, { turn?: number, state?: string }>} views
|
|
176
|
+
* @returns {Array<{ sessionId: string, turn: number, state: string }>}
|
|
177
|
+
*/
|
|
178
|
+
export function pendingWakes(threads, views) {
|
|
179
|
+
const list = Array.isArray(threads) ? threads : [];
|
|
180
|
+
/** @type {Array<{ sessionId: string, turn: number, state: string }>} */
|
|
181
|
+
const out = [];
|
|
182
|
+
for (const thread of list) {
|
|
183
|
+
const sessionId = String(thread?.sessionId ?? "");
|
|
184
|
+
if (sessionId === "") continue;
|
|
185
|
+
const view = views?.get?.(sessionId);
|
|
186
|
+
if (!view) continue;
|
|
187
|
+
const state = String(view.state ?? "");
|
|
188
|
+
// 只有需要人看的终态才补唤醒:working/idle 补了也没信息量
|
|
189
|
+
if (state !== "done" && state !== "failed" && state !== "waiting-user") continue;
|
|
190
|
+
const turn = Number(view.turn ?? 0);
|
|
191
|
+
if (turn <= Number(thread?.lastWakeTurn ?? 0)) continue;
|
|
192
|
+
out.push({ sessionId, turn, state });
|
|
193
|
+
}
|
|
194
|
+
return out;
|
|
195
|
+
}
|
package/lib/worktree.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// worktree 隔离的纯逻辑:命名、命令计划、判据。**不做 I/O**——
|
|
3
|
+
// 真正的 exec/spawn 由调用方注入,所以这里每条规则都能单测。
|
|
4
|
+
// 设计依据见 notes/projects/m2-design.md §1。
|
|
5
|
+
|
|
6
|
+
/** worktree 的工作目录名(放在仓库同级,不污染仓库、也不进 .git)。 */
|
|
7
|
+
export const WORKTREE_DIR = ".dsh-worktrees";
|
|
8
|
+
|
|
9
|
+
/** 分支前缀:一眼能看出是插件建的。 */
|
|
10
|
+
export const BRANCH_PREFIX = "dsh";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 把项目名压成 git 分支/目录能用的 slug。
|
|
14
|
+
* 中文等项目名会退化成一串连字符,所以调用方还要拼 index 保证唯一。
|
|
15
|
+
* @param {string} name
|
|
16
|
+
* @returns {string}
|
|
17
|
+
*/
|
|
18
|
+
export function slug(name) {
|
|
19
|
+
const normalized = String(name ?? "")
|
|
20
|
+
.trim()
|
|
21
|
+
.toLowerCase()
|
|
22
|
+
.replace(/[^a-z0-9]+/gu, "-")
|
|
23
|
+
.replace(/^-+|-+$/gu, "");
|
|
24
|
+
return normalized === "" ? "project" : normalized.slice(0, 40);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 分支名:`dsh/<project>-<n>`。
|
|
29
|
+
* @param {{ projectName: string, index: number }} input
|
|
30
|
+
* @returns {string}
|
|
31
|
+
*/
|
|
32
|
+
export function branchName(input) {
|
|
33
|
+
const index = Number.isFinite(input?.index) ? Math.max(1, Math.trunc(Number(input.index))) : 1;
|
|
34
|
+
return `${BRANCH_PREFIX}/${slug(input?.projectName)}-${index}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* worktree 路径:`<repoParent>/.dsh-worktrees/<repoName>/<projectId>-<n>`。
|
|
39
|
+
* @param {{ repoRoot: string, projectId: string, index: number }} input
|
|
40
|
+
* @returns {string}
|
|
41
|
+
*/
|
|
42
|
+
export function worktreePath(input) {
|
|
43
|
+
const repoRoot = String(input?.repoRoot ?? "").replace(/\/+$/u, "");
|
|
44
|
+
if (repoRoot === "") throw new Error("projects: worktreePath requires repoRoot");
|
|
45
|
+
const parts = repoRoot.split("/");
|
|
46
|
+
const repoName = parts[parts.length - 1] || "repo";
|
|
47
|
+
const parent = parts.slice(0, -1).join("/") || "/";
|
|
48
|
+
const index = Number.isFinite(input?.index) ? Math.max(1, Math.trunc(Number(input.index))) : 1;
|
|
49
|
+
const projectId = String(input?.projectId ?? "project").replace(/[^A-Za-z0-9_-]/gu, "");
|
|
50
|
+
return `${parent}/${WORKTREE_DIR}/${repoName}/${projectId}-${index}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 生成建 worktree 的参数(不含可执行文件本身)。
|
|
55
|
+
* @param {{ path: string, branch: string, base?: string }} input
|
|
56
|
+
* @returns {string[]}
|
|
57
|
+
*/
|
|
58
|
+
export function planCreate(input) {
|
|
59
|
+
const args = ["worktree", "add", "-b", input.branch];
|
|
60
|
+
if (typeof input.base === "string" && input.base !== "") args.push(input.base);
|
|
61
|
+
args.push(input.path);
|
|
62
|
+
return args;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 生成删 worktree 的参数。
|
|
67
|
+
* @param {{ path: string, force?: boolean }} input
|
|
68
|
+
* @returns {string[]}
|
|
69
|
+
*/
|
|
70
|
+
export function planRemove(input) {
|
|
71
|
+
return input?.force === true
|
|
72
|
+
? ["worktree", "remove", "--force", input.path]
|
|
73
|
+
: ["worktree", "remove", input.path];
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 解析 `git worktree list --porcelain`。
|
|
78
|
+
* @param {string} text
|
|
79
|
+
* @returns {{ path: string, head: string, branch: string }[]}
|
|
80
|
+
*/
|
|
81
|
+
export function parseWorktreeList(text) {
|
|
82
|
+
/** @type {{ path: string, head: string, branch: string }[]} */
|
|
83
|
+
const out = [];
|
|
84
|
+
/** @type {{ path: string, head: string, branch: string }} */
|
|
85
|
+
let current = { path: "", head: "", branch: "" };
|
|
86
|
+
for (const rawLine of String(text ?? "").split("\n")) {
|
|
87
|
+
const line = rawLine.trim();
|
|
88
|
+
if (line === "") {
|
|
89
|
+
if (current.path !== "") out.push(current);
|
|
90
|
+
current = { path: "", head: "", branch: "" };
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (line.startsWith("worktree ")) current.path = line.slice("worktree ".length);
|
|
94
|
+
else if (line.startsWith("HEAD ")) current.head = line.slice("HEAD ".length);
|
|
95
|
+
else if (line.startsWith("branch ")) current.branch = line.slice("branch ".length);
|
|
96
|
+
}
|
|
97
|
+
if (current.path !== "") out.push(current);
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* `git status --porcelain` 是否干净(空输出即干净)。
|
|
103
|
+
* @param {string} statusText
|
|
104
|
+
* @returns {boolean}
|
|
105
|
+
*/
|
|
106
|
+
export function isCleanStatus(statusText) {
|
|
107
|
+
return String(statusText ?? "").trim() === "";
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 是否允许回收一个 worktree:三重判据,任一不满足就保留。
|
|
112
|
+
* 宁可留垃圾,也不删用户的东西(ADR 0002)。
|
|
113
|
+
* @param {{ statusText: string, unpushedCommits: number, isCurrentSession: boolean }} input
|
|
114
|
+
* @returns {{ ok: boolean, reason: string }}
|
|
115
|
+
*/
|
|
116
|
+
export function shouldReclaim(input) {
|
|
117
|
+
if (input?.isCurrentSession === true) return { ok: false, reason: "current-session" };
|
|
118
|
+
if (!isCleanStatus(input?.statusText ?? "")) return { ok: false, reason: "dirty" };
|
|
119
|
+
const unpushed = Number(input?.unpushedCommits ?? 0);
|
|
120
|
+
if (!Number.isFinite(unpushed) || unpushed > 0) return { ok: false, reason: "unpushed-commits" };
|
|
121
|
+
return { ok: true, reason: "" };
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 解析 `git branch --merged <base>` 的输出(每行一个分支,可能带 `*` 前缀)。
|
|
126
|
+
* @param {string} text
|
|
127
|
+
* @returns {string[]}
|
|
128
|
+
*/
|
|
129
|
+
export function parseMergedBranches(text) {
|
|
130
|
+
return String(text ?? "")
|
|
131
|
+
.split("\n")
|
|
132
|
+
.map((line) => line.replace(/^\*\s*/u, "").trim())
|
|
133
|
+
.filter((line) => line !== "");
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* 是否允许删除一个本地分支。
|
|
138
|
+
* 四条都要满足:是我们建的、已合并、不是当前分支、没有未推送提交。
|
|
139
|
+
* @param {{ branch: string, mergedBranches: string[], currentBranch: string, unpushedCommits?: number }} input
|
|
140
|
+
* @returns {{ ok: boolean, reason: string }}
|
|
141
|
+
*/
|
|
142
|
+
export function shouldDeleteBranch(input) {
|
|
143
|
+
const branch = String(input?.branch ?? "").trim();
|
|
144
|
+
if (branch === "") return { ok: false, reason: "no-branch" };
|
|
145
|
+
if (!branch.startsWith(`${BRANCH_PREFIX}/`)) return { ok: false, reason: "branch-not-ours" };
|
|
146
|
+
if (String(input?.currentBranch ?? "") === branch) return { ok: false, reason: "current-branch" };
|
|
147
|
+
const unpushed = Number(input?.unpushedCommits ?? 0);
|
|
148
|
+
if (!Number.isFinite(unpushed) || unpushed > 0) return { ok: false, reason: "unpushed-commits" };
|
|
149
|
+
const merged = Array.isArray(input?.mergedBranches) ? input.mergedBranches : [];
|
|
150
|
+
if (!merged.includes(branch)) return { ok: false, reason: "not-merged" };
|
|
151
|
+
return { ok: true, reason: "" };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* 生成删分支的参数(默认 `-d`,**不用 `-D`**:宁可失败也不强删未合并内容)。
|
|
156
|
+
* @param {string} branch
|
|
157
|
+
* @returns {string[]}
|
|
158
|
+
*/
|
|
159
|
+
export function planDeleteBranch(branch) {
|
|
160
|
+
return ["branch", "-d", String(branch)];
|
|
161
|
+
}
|
package/locale/en.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"projects": {
|
|
3
|
+
"title": "Projects",
|
|
4
|
+
"panel.title": "Projects",
|
|
5
|
+
"panel.summary": "{projects} projects · {active} active · {attached} sessions attached",
|
|
6
|
+
"panel.empty": "No projects yet. Create one, drop sessions into it, and stop restating the background.",
|
|
7
|
+
"panel.createPlaceholder": "Project name, e.g. payments-api",
|
|
8
|
+
"panel.create": "New project",
|
|
9
|
+
"panel.creating": "Creating…",
|
|
10
|
+
"panel.refresh": "Refresh",
|
|
11
|
+
"panel.threads": "{count} threads",
|
|
12
|
+
"panel.goalEmpty": "No goal set",
|
|
13
|
+
"panel.unavailable": "Project data unavailable: {reason}",
|
|
14
|
+
"panel.errorCreate": "Create failed: {reason}",
|
|
15
|
+
"panel.state.active": "active",
|
|
16
|
+
"panel.state.archived": "archived",
|
|
17
|
+
"settings.section": "Projects",
|
|
18
|
+
"settings.dataRoot": "Data root",
|
|
19
|
+
"settings.summary": "{count} projects",
|
|
20
|
+
"settings.diag": "Diagnostics",
|
|
21
|
+
"settings.unavailable": "Unavailable",
|
|
22
|
+
"settings.hint": "Project metadata and content files stay local; no remote repository is written.",
|
|
23
|
+
"menu.attach": "Add to project…",
|
|
24
|
+
"menu.loading": "Loading…",
|
|
25
|
+
"menu.empty": "No projects yet — create one in the Projects panel first",
|
|
26
|
+
"detail.back": "Back",
|
|
27
|
+
"detail.loading": "Loading…",
|
|
28
|
+
"detail.tab.threads": "Threads ({count})",
|
|
29
|
+
"detail.tab.memory": "Memory",
|
|
30
|
+
"detail.tab.audit": "Audit",
|
|
31
|
+
"detail.threadsEmpty": "No sessions belong to this project yet. Use “Add to project…” in a session's … menu.",
|
|
32
|
+
"detail.threadState": "state: {state}",
|
|
33
|
+
"detail.instructions": "Standing rules (instructions.md)",
|
|
34
|
+
"detail.memoryIndex": "Memory index (MEMORY.md)",
|
|
35
|
+
"detail.emptyFile": "(empty)",
|
|
36
|
+
"detail.auditEmpty": "No audit entries yet.",
|
|
37
|
+
"detail.state.waiting-user": "Waiting on you",
|
|
38
|
+
"detail.state.failed": "Failed",
|
|
39
|
+
"detail.state.working": "Working",
|
|
40
|
+
"detail.state.done": "Done",
|
|
41
|
+
"detail.state.idle": "Idle",
|
|
42
|
+
"detail.threadPlaceholder": "Describe a task for a new thread (Enter to create)",
|
|
43
|
+
"detail.threadCreate": "New thread",
|
|
44
|
+
"detail.threadCreating": "Creating…",
|
|
45
|
+
"detail.dirLabel": "Project dir",
|
|
46
|
+
"detail.dirPlaceholder": "Absolute path; threads create worktrees here",
|
|
47
|
+
"detail.dirSave": "Bind",
|
|
48
|
+
"detail.pause": "Pause project",
|
|
49
|
+
"detail.resume": "Resume project",
|
|
50
|
+
"detail.budget": "{today} threads today · {running} running",
|
|
51
|
+
"detail.delete": "Delete project",
|
|
52
|
+
"detail.deleting": "Deleting…",
|
|
53
|
+
"detail.deleteConfirm": "Delete",
|
|
54
|
+
"detail.deleteCancel": "Cancel",
|
|
55
|
+
"detail.deleteDetails": "Details (path and restore location)",
|
|
56
|
+
"detail.deleteImpact": "{summary}",
|
|
57
|
+
"notify.failed": "{count} threads failed",
|
|
58
|
+
"notify.waiting": "{count} threads waiting on you",
|
|
59
|
+
"detail.routePlaceholder": "Dispatch by rule: describe the task and let rules decide",
|
|
60
|
+
"detail.routeDispatch": "Dispatch by rule",
|
|
61
|
+
"detail.routeBusy": "Working…",
|
|
62
|
+
"detail.routeDecision": "by {by} → {action}",
|
|
63
|
+
"detail.routeExecuted": "executed",
|
|
64
|
+
"detail.routeRejected": "blocked",
|
|
65
|
+
"detail.approvalsTitle": "Actions waiting for your approval",
|
|
66
|
+
"detail.approve": "Approve",
|
|
67
|
+
"detail.reject": "Reject",
|
|
68
|
+
"settings.policyTitle": "Project policy (autonomy / persona / fallback)",
|
|
69
|
+
"settings.noProjects": "No projects yet",
|
|
70
|
+
"settings.autonomy": "Autonomy",
|
|
71
|
+
"settings.level.L0": "observe only",
|
|
72
|
+
"settings.level.L1": "propose only (default)",
|
|
73
|
+
"settings.level.L2": "may act",
|
|
74
|
+
"settings.level.L3": "full",
|
|
75
|
+
"settings.persona": "Persona (empty = built-in default)",
|
|
76
|
+
"settings.fallback": "Allow the model to propose when no rule matches",
|
|
77
|
+
"settings.dangerTitle": "Danger switches (all off by default)",
|
|
78
|
+
"settings.dangerHint": "Every switch needs your explicit consent; the plugin never turns one on by itself.",
|
|
79
|
+
"settings.danger.forcePushOwnBranch.label": "Allow pushing your own dsh/ branches (normal push, not force)",
|
|
80
|
+
"settings.danger.forcePushOwnBranch.risk": "Writes to the remote; only branches starting with dsh/. **Force push (--force) is not implemented yet** — turning this on does not enable force push.",
|
|
81
|
+
"settings.danger.pushProtectedBranch.label": "Allow pushing to protected branches (not implemented yet)",
|
|
82
|
+
"settings.danger.pushProtectedBranch.risk": "No execution path exists in this version, so turning it on has no effect; the key is kept for future alignment.",
|
|
83
|
+
"settings.danger.autoMerge.label": "auto-merge PRs",
|
|
84
|
+
"settings.danger.autoMerge.risk": "merging is irreversible (revert only); still gated by diff limits and human approval",
|
|
85
|
+
"settings.danger.trashAuto.label": "auto archive/delete into trash",
|
|
86
|
+
"settings.danger.trashAuto.risk": "moves content into trash/; restorable from manifest, but not free",
|
|
87
|
+
"settings.danger.purgeAfterRetention.label": "Allow purging the trash after retention (not implemented yet)",
|
|
88
|
+
"settings.danger.purgeAfterRetention.risk": "No execution path exists in this version, so turning it on has no effect; the trash is never emptied automatically.",
|
|
89
|
+
"settings.danger.editProfile.label": "edit project policy itself",
|
|
90
|
+
"settings.danger.editProfile.risk": "the coordinator could loosen its own limits; highest risk",
|
|
91
|
+
"detail.archive": "Archive project",
|
|
92
|
+
"detail.unarchive": "Unarchive project"
|
|
93
|
+
}
|
|
94
|
+
}
|
package/locale/zh.json
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"projects": {
|
|
3
|
+
"title": "项目",
|
|
4
|
+
"panel.title": "项目",
|
|
5
|
+
"panel.summary": "{projects} 个项目 · {active} 个活跃 · {attached} 个会话已挂上下文",
|
|
6
|
+
"panel.empty": "还没有项目。建一个,把会话丢进去,下次就不用重复交代背景。",
|
|
7
|
+
"panel.createPlaceholder": "项目名,例如 payments-api",
|
|
8
|
+
"panel.create": "新建项目",
|
|
9
|
+
"panel.creating": "正在新建…",
|
|
10
|
+
"panel.refresh": "刷新",
|
|
11
|
+
"panel.threads": "{count} 个线程",
|
|
12
|
+
"panel.goalEmpty": "未设置目标",
|
|
13
|
+
"panel.unavailable": "项目数据不可用:{reason}",
|
|
14
|
+
"panel.errorCreate": "新建失败:{reason}",
|
|
15
|
+
"panel.state.active": "活跃",
|
|
16
|
+
"panel.state.archived": "已归档",
|
|
17
|
+
"settings.section": "项目",
|
|
18
|
+
"settings.dataRoot": "数据根目录",
|
|
19
|
+
"settings.summary": "{count} 个项目",
|
|
20
|
+
"settings.diag": "诊断",
|
|
21
|
+
"settings.unavailable": "不可用",
|
|
22
|
+
"settings.hint": "项目元数据与内容文件都在本机;不会写任何远端仓库。",
|
|
23
|
+
"menu.attach": "归属到项目…",
|
|
24
|
+
"menu.loading": "加载中…",
|
|
25
|
+
"menu.empty": "还没有项目,先在项目面板里建一个",
|
|
26
|
+
"detail.back": "返回",
|
|
27
|
+
"detail.loading": "加载中…",
|
|
28
|
+
"detail.tab.threads": "线程 ({count})",
|
|
29
|
+
"detail.tab.memory": "记忆",
|
|
30
|
+
"detail.tab.audit": "审计",
|
|
31
|
+
"detail.threadsEmpty": "还没有会话归属到这个项目。在会话行的「…」菜单里选择「归属到项目…」。",
|
|
32
|
+
"detail.threadState": "状态:{state}",
|
|
33
|
+
"detail.instructions": "常设规则(instructions.md)",
|
|
34
|
+
"detail.memoryIndex": "记忆索引(MEMORY.md)",
|
|
35
|
+
"detail.emptyFile": "(空)",
|
|
36
|
+
"detail.auditEmpty": "还没有审计记录。",
|
|
37
|
+
"detail.state.waiting-user": "待你处理",
|
|
38
|
+
"detail.state.failed": "失败",
|
|
39
|
+
"detail.state.working": "进行中",
|
|
40
|
+
"detail.state.done": "已完成",
|
|
41
|
+
"detail.state.idle": "空闲",
|
|
42
|
+
"detail.threadPlaceholder": "给这个线程一个任务,回车即建",
|
|
43
|
+
"detail.threadCreate": "新建线程",
|
|
44
|
+
"detail.threadCreating": "正在建…",
|
|
45
|
+
"detail.dirLabel": "项目目录",
|
|
46
|
+
"detail.dirPlaceholder": "绝对路径;线程会在这里建 worktree",
|
|
47
|
+
"detail.dirSave": "绑定",
|
|
48
|
+
"detail.pause": "暂停项目",
|
|
49
|
+
"detail.resume": "恢复项目",
|
|
50
|
+
"detail.budget": "今日 {today} 个线程 · 进行中 {running}",
|
|
51
|
+
"detail.delete": "删除项目",
|
|
52
|
+
"detail.deleting": "正在删除…",
|
|
53
|
+
"detail.deleteConfirm": "确认删除",
|
|
54
|
+
"detail.deleteCancel": "取消",
|
|
55
|
+
"detail.deleteDetails": "详情(路径与恢复位置)",
|
|
56
|
+
"detail.deleteImpact": "{summary}",
|
|
57
|
+
"notify.failed": "{count} 个线程失败",
|
|
58
|
+
"notify.waiting": "{count} 个线程在等你",
|
|
59
|
+
"detail.routePlaceholder": "按规则派活:输入一句话,由规则决定怎么做",
|
|
60
|
+
"detail.routeDispatch": "按规则派活",
|
|
61
|
+
"detail.routeBusy": "处理中…",
|
|
62
|
+
"detail.routeDecision": "按 {by} → {action}",
|
|
63
|
+
"detail.routeExecuted": "已执行",
|
|
64
|
+
"detail.routeRejected": "被拦",
|
|
65
|
+
"detail.approvalsTitle": "待你批准的动作",
|
|
66
|
+
"detail.approve": "批准",
|
|
67
|
+
"detail.reject": "拒绝",
|
|
68
|
+
"settings.policyTitle": "项目策略(自治级别 / 人格 / 兜底)",
|
|
69
|
+
"settings.noProjects": "还没有项目",
|
|
70
|
+
"settings.autonomy": "自治级别",
|
|
71
|
+
"settings.level.L0": "只观察",
|
|
72
|
+
"settings.level.L1": "只提议(默认)",
|
|
73
|
+
"settings.level.L2": "可代办",
|
|
74
|
+
"settings.level.L3": "全权",
|
|
75
|
+
"settings.persona": "人格(留空用默认)",
|
|
76
|
+
"settings.fallback": "规则都不命中时允许模型兜底提议",
|
|
77
|
+
"settings.dangerTitle": "危险动作开关(默认全关)",
|
|
78
|
+
"settings.dangerHint": "打开任何一个开关都需要你明确同意;插件不会自行打开。",
|
|
79
|
+
"settings.danger.forcePushOwnBranch.label": "允许推送自己的 dsh/ 分支(普通推送,非强推)",
|
|
80
|
+
"settings.danger.forcePushOwnBranch.risk": "会写远端仓库;只推 dsh/ 开头的分支。**强推(--force)尚未实现**,打开此开关不会产生强推。",
|
|
81
|
+
"settings.danger.pushProtectedBranch.label": "允许推送受保护分支(暂未实现)",
|
|
82
|
+
"settings.danger.pushProtectedBranch.risk": "当前版本没有对应执行路径,打开也不会生效;保留此键是为了将来对齐。",
|
|
83
|
+
"settings.danger.autoMerge.label": "允许自动合并 PR",
|
|
84
|
+
"settings.danger.autoMerge.risk": "合并不可逆(只能用 revert 回退);仍受 diff 阈值与人工批准约束",
|
|
85
|
+
"settings.danger.trashAuto.label": "允许自动归档/删除到回收站",
|
|
86
|
+
"settings.danger.trashAuto.risk": "会把内容移入 trash/;可从 manifest 恢复,但不是零成本",
|
|
87
|
+
"settings.danger.purgeAfterRetention.label": "允许保留期后清理回收站(暂未实现)",
|
|
88
|
+
"settings.danger.purgeAfterRetention.risk": "当前版本没有对应执行路径,打开也不会生效;回收站不会被自动清空。",
|
|
89
|
+
"settings.danger.editProfile.label": "允许修改项目策略本身",
|
|
90
|
+
"settings.danger.editProfile.risk": "协调器可能借此放宽自己的限制;风险最高",
|
|
91
|
+
"detail.archive": "归档项目",
|
|
92
|
+
"detail.unarchive": "取消归档"
|
|
93
|
+
}
|
|
94
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,63 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kangyishuai/dsh-projects",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
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
|
+
"keywords": [
|
|
6
|
+
"dsh",
|
|
7
|
+
"dsh-plugin",
|
|
8
|
+
"deepseek-harness"
|
|
9
|
+
],
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"author": "nano (https://github.com/kangyishuai)",
|
|
12
|
+
"homepage": "https://github.com/kangyishuai/dsh-plugins/tree/main/packages/projects#readme",
|
|
13
|
+
"bugs": "https://github.com/kangyishuai/dsh-plugins/issues",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/kangyishuai/dsh-plugins.git",
|
|
17
|
+
"directory": "packages/projects"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"main": "lib/index.js",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./lib/index.js",
|
|
23
|
+
"./client": "./lib/client.js",
|
|
24
|
+
"./package.json": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"cordis.patch.yml",
|
|
28
|
+
"lib",
|
|
29
|
+
"locale",
|
|
30
|
+
"README.md",
|
|
31
|
+
"README.zh-CN.md",
|
|
32
|
+
"LICENSE"
|
|
33
|
+
],
|
|
34
|
+
"scripts": {
|
|
35
|
+
"test": "node --test"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
},
|
|
40
|
+
"dsh": {
|
|
41
|
+
"bundle": {
|
|
42
|
+
"patch": "./cordis.patch.yml"
|
|
43
|
+
},
|
|
44
|
+
"client": {
|
|
45
|
+
"platform": "web",
|
|
46
|
+
"inject": [
|
|
47
|
+
"@deepseek-ai/dsh-api-remotes",
|
|
48
|
+
"@deepseek-ai/dsh-api-session-controller",
|
|
49
|
+
"@deepseek-ai/dsh-api-workspace-controller",
|
|
50
|
+
"@deepseek-ai/dsh-client-connection",
|
|
51
|
+
"@deepseek-ai/dsh-client-locale",
|
|
52
|
+
"@deepseek-ai/dsh-client-shortcuts",
|
|
53
|
+
"@deepseek-ai/dsh-client-ui-context-menu",
|
|
54
|
+
"@deepseek-ai/dsh-client-ui-conversation",
|
|
55
|
+
"@deepseek-ai/dsh-client-ui-layout",
|
|
56
|
+
"@deepseek-ai/dsh-client-ui-renderer",
|
|
57
|
+
"@deepseek-ai/dsh-client-ui-session",
|
|
58
|
+
"@deepseek-ai/dsh-client-ui-sidebar",
|
|
59
|
+
"@deepseek-ai/dsh-client-ui-workspace"
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|