dsh-pstack-deck 0.5.0 → 0.5.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/package.json +1 -1
- package/src/host.js +5 -2
- package/src/tools.js +16 -2
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|

|
|
6
6
|

|
|
7
7
|

|
|
8
|
-

|
|
9
9
|

|
|
10
10
|
|
|
11
11
|
- 插件名:`dsh-pstack-deck`
|
package/package.json
CHANGED
package/src/host.js
CHANGED
|
@@ -249,7 +249,7 @@ export function apply(ctx) {
|
|
|
249
249
|
* 跟着 cwd 走会看见一块和根目录不相通的空板)。
|
|
250
250
|
* 拿不到会话就退回进程 cwd —— 宁可落在错的地方让人看见,也不要静悄悄写到别处去。
|
|
251
251
|
*/
|
|
252
|
-
export function workspaceOf(ctx, sessionId) {
|
|
252
|
+
export function workspaceOf(ctx, sessionId, fallbackCwd) {
|
|
253
253
|
try {
|
|
254
254
|
const sessions = ctx.get('sessions')
|
|
255
255
|
const session = sessionId && sessions && typeof sessions.get === 'function' ? sessions.get(sessionId) : null
|
|
@@ -258,7 +258,10 @@ export function workspaceOf(ctx, sessionId) {
|
|
|
258
258
|
} catch {
|
|
259
259
|
/* sessions 服务不在就往下退 */
|
|
260
260
|
}
|
|
261
|
-
//
|
|
261
|
+
// 工具调用拿得到 exec.cwd(宿主给的当前工作目录),面板调用拿不到 sessions 时才退回它。
|
|
262
|
+
// 少了这一步,工具会把卡写进一个叫 unbound 的假项目里——人点开看板发现是空的。
|
|
263
|
+
if (typeof fallbackCwd === 'string' && fallbackCwd) return projectRoot(fallbackCwd)
|
|
264
|
+
// 最后的兜底也不能写进应用包里:那个目录是只读的,而且不是人的项目
|
|
262
265
|
return join(homedir(), '.dsh', 'pstack-board', 'unbound')
|
|
263
266
|
}
|
|
264
267
|
|
package/src/tools.js
CHANGED
|
@@ -151,12 +151,25 @@ async function install(args) {
|
|
|
151
151
|
].filter(Boolean).join('\n')
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
+
/**
|
|
155
|
+
* 卡写进哪个项目。工具拿不到 exec.cwd——宿主的 exec 里只有 `agent`,
|
|
156
|
+
* 会话工作目录在 `exec.agent.session.header.cwd`(这是宿主自己的形状,不是我们编的)。
|
|
157
|
+
* 少了这一条,工具会把卡写进一个叫 unbound 的假项目,人点开面板只看到空板。
|
|
158
|
+
*/
|
|
159
|
+
function boardDir(args, exec, ctx) {
|
|
160
|
+
const explicit = String(args?.dir ?? '').trim()
|
|
161
|
+
if (explicit) return projectRoot(explicit)
|
|
162
|
+
const header = exec?.agent?.session?.header
|
|
163
|
+
const cwd = typeof header?.cwd === 'string' ? header.cwd : ''
|
|
164
|
+
return workspaceOf(ctx, header?.id ?? exec?.sessionId, cwd || process.cwd())
|
|
165
|
+
}
|
|
166
|
+
|
|
154
167
|
/**
|
|
155
168
|
* 看板。agent 得知道自己在哪个项目里,所以 dir 优先:不给就退回这个会话的工作目录。
|
|
156
169
|
*/
|
|
157
170
|
async function boardTool(args, exec, ctx) {
|
|
158
171
|
const op = String(args?.op ?? 'list').trim()
|
|
159
|
-
const dir =
|
|
172
|
+
const dir = boardDir(args, exec, ctx)
|
|
160
173
|
if (op === 'add') {
|
|
161
174
|
const title = String(args?.title ?? '').trim()
|
|
162
175
|
if (!title) throw new Error('写一句这张卡要干什么')
|
|
@@ -255,7 +268,8 @@ async function boardTool(args, exec, ctx) {
|
|
|
255
268
|
return lines.join('\n')
|
|
256
269
|
}
|
|
257
270
|
|
|
258
|
-
export function apply(ctx) {
|
|
271
|
+
export function apply(ctx) {
|
|
272
|
+
const tools = ctx?.tools
|
|
259
273
|
if (!tools || typeof tools.register !== 'function') {
|
|
260
274
|
throw new Error('[pstack] tools 服务不在,工具行起不来')
|
|
261
275
|
}
|