u1s1-cli 0.16.4 → 0.16.5
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/dist/loop.js +9 -5
- package/package.json +1 -1
package/dist/loop.js
CHANGED
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
* /loop 20m /review-pr 1234 循环里也能跑其他斜杠命令
|
|
9
9
|
* /loop stop 停止当前循环
|
|
10
10
|
*
|
|
11
|
-
* 语义与 Claude Code 对齐:任务只活在当前会话,/clear
|
|
12
|
-
*
|
|
11
|
+
* 语义与 Claude Code 对齐:任务只活在当前会话,/clear 或退出即消失;
|
|
12
|
+
* 启动时立刻跑第一轮,之后每隔一个间隔再跑。
|
|
13
|
+
* 实现核心是 pi.sendUserMessage():到点就"替用户打字"发一轮,
|
|
13
14
|
* deliverAs: "followUp" 保证上一轮没跑完时排队等它结束,不硬插打断;
|
|
14
15
|
* expandPromptTemplates: true 让 prompt 里的斜杠命令也能被展开执行。
|
|
15
16
|
*/
|
|
@@ -116,7 +117,7 @@ export function registerLoopCommand(pi) {
|
|
|
116
117
|
stopLoop(ctx.ui);
|
|
117
118
|
activePrompt = parsed.prompt;
|
|
118
119
|
activeIntervalMs = parsed.intervalMs;
|
|
119
|
-
|
|
120
|
+
const fire = () => {
|
|
120
121
|
try {
|
|
121
122
|
pi.sendUserMessage(activePrompt, {
|
|
122
123
|
deliverAs: "followUp",
|
|
@@ -126,9 +127,12 @@ export function registerLoopCommand(pi) {
|
|
|
126
127
|
catch (e) {
|
|
127
128
|
ctx.ui.notify(`loop 执行失败: ${e instanceof Error ? e.message : String(e)}`, "error");
|
|
128
129
|
}
|
|
129
|
-
}
|
|
130
|
+
};
|
|
131
|
+
// 第一轮立刻跑:用户写完命令就想看到结果,不该干等一个间隔
|
|
132
|
+
fire();
|
|
133
|
+
timer = setInterval(fire, activeIntervalMs);
|
|
130
134
|
ctx.ui.setStatus(STATUS_KEY, `🔁 每${formatInterval(activeIntervalMs)} · ${preview(activePrompt)}`);
|
|
131
|
-
ctx.ui.notify(`🔁
|
|
135
|
+
ctx.ui.notify(`🔁 已开始:现在先跑第一轮,之后每${formatInterval(activeIntervalMs)}一次「${preview(activePrompt)}」`, "info");
|
|
132
136
|
},
|
|
133
137
|
});
|
|
134
138
|
}
|