pi-agent-flow 2.0.0 → 2.0.2
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 +126 -489
- package/agents/audit.md +7 -2
- package/agents/build.md +6 -2
- package/agents/craft.md +6 -3
- package/agents/debug.md +7 -3
- package/agents/ideas.md +8 -4
- package/agents/scout.md +8 -1
- package/dist/batch/apply-patch.d.ts +60 -0
- package/dist/batch/apply-patch.d.ts.map +1 -0
- package/dist/batch/apply-patch.js +477 -0
- package/dist/batch/apply-patch.js.map +1 -0
- package/dist/batch/batch-bash.d.ts +0 -6
- package/dist/batch/batch-bash.d.ts.map +1 -1
- package/dist/batch/batch-bash.js +52 -14
- package/dist/batch/batch-bash.js.map +1 -1
- package/dist/batch/constants.d.ts +45 -4
- package/dist/batch/constants.d.ts.map +1 -1
- package/dist/batch/constants.js +72 -4
- package/dist/batch/constants.js.map +1 -1
- package/dist/batch/execute.d.ts +8 -2
- package/dist/batch/execute.d.ts.map +1 -1
- package/dist/batch/execute.js +338 -70
- package/dist/batch/execute.js.map +1 -1
- package/dist/batch/fuzzy-edit.d.ts +4 -1
- package/dist/batch/fuzzy-edit.d.ts.map +1 -1
- package/dist/batch/fuzzy-edit.js +7 -2
- package/dist/batch/fuzzy-edit.js.map +1 -1
- package/dist/batch/index.d.ts +3 -15
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/batch/index.js +48 -78
- package/dist/batch/index.js.map +1 -1
- package/dist/batch/render.d.ts.map +1 -1
- package/dist/batch/render.js +30 -7
- package/dist/batch/render.js.map +1 -1
- package/dist/batch/shell-compress.d.ts +25 -0
- package/dist/batch/shell-compress.d.ts.map +1 -0
- package/dist/batch/shell-compress.js +602 -0
- package/dist/batch/shell-compress.js.map +1 -0
- package/dist/batch/summary.d.ts.map +1 -1
- package/dist/batch/summary.js +4 -0
- package/dist/batch/summary.js.map +1 -1
- package/dist/batch/symbols.d.ts.map +1 -1
- package/dist/batch/symbols.js +12 -7
- package/dist/batch/symbols.js.map +1 -1
- package/dist/config/config.d.ts +5 -0
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +63 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/models.d.ts +2 -0
- package/dist/config/models.d.ts.map +1 -0
- package/dist/config/models.js +49 -0
- package/dist/config/models.js.map +1 -0
- package/dist/config/settings-resolver.js +2 -2
- package/dist/config/settings-resolver.js.map +1 -1
- package/dist/core/agents.js +2 -2
- package/dist/core/agents.js.map +1 -1
- package/dist/core/depth.d.ts +3 -3
- package/dist/core/depth.d.ts.map +1 -1
- package/dist/core/depth.js +5 -5
- package/dist/core/depth.js.map +1 -1
- package/dist/core/executor.d.ts +10 -3
- package/dist/core/executor.d.ts.map +1 -1
- package/dist/core/executor.js +7 -3
- package/dist/core/executor.js.map +1 -1
- package/dist/core/flow.d.ts +19 -3
- package/dist/core/flow.d.ts.map +1 -1
- package/dist/core/flow.js +97 -58
- package/dist/core/flow.js.map +1 -1
- package/dist/core/session-mode.d.ts +1 -1
- package/dist/core/session-mode.d.ts.map +1 -1
- package/dist/core/session-mode.js +2 -1
- package/dist/core/session-mode.js.map +1 -1
- package/dist/core/{delegation.d.ts → transition.d.ts} +9 -9
- package/dist/core/transition.d.ts.map +1 -0
- package/dist/core/{delegation.js → transition.js} +17 -24
- package/dist/core/transition.js.map +1 -0
- package/dist/flow/auto-warp.d.ts +12 -0
- package/dist/flow/auto-warp.d.ts.map +1 -0
- package/dist/flow/auto-warp.js +29 -0
- package/dist/flow/auto-warp.js.map +1 -0
- package/dist/flow/command.d.ts.map +1 -1
- package/dist/flow/command.js +7 -2
- package/dist/flow/command.js.map +1 -1
- package/dist/flow/continuation.d.ts.map +1 -1
- package/dist/flow/continuation.js +52 -15
- package/dist/flow/continuation.js.map +1 -1
- package/dist/flow/index.d.ts +5 -2
- package/dist/flow/index.d.ts.map +1 -1
- package/dist/flow/index.js +6 -3
- package/dist/flow/index.js.map +1 -1
- package/dist/flow/loop-command.d.ts +8 -0
- package/dist/flow/loop-command.d.ts.map +1 -0
- package/dist/flow/loop-command.js +102 -0
- package/dist/flow/loop-command.js.map +1 -0
- package/dist/flow/loop-templates.d.ts +7 -0
- package/dist/flow/loop-templates.d.ts.map +1 -0
- package/dist/flow/loop-templates.js +38 -0
- package/dist/flow/loop-templates.js.map +1 -0
- package/dist/flow/loop.d.ts +19 -0
- package/dist/flow/loop.d.ts.map +1 -0
- package/dist/flow/loop.js +95 -0
- package/dist/flow/loop.js.map +1 -0
- package/dist/flow/settings-command.d.ts.map +1 -1
- package/dist/flow/settings-command.js +93 -4
- package/dist/flow/settings-command.js.map +1 -1
- package/dist/flow/store.d.ts +3 -3
- package/dist/flow/store.d.ts.map +1 -1
- package/dist/flow/store.js +24 -16
- package/dist/flow/store.js.map +1 -1
- package/dist/flow/template-shared.d.ts +9 -0
- package/dist/flow/template-shared.d.ts.map +1 -0
- package/dist/flow/template-shared.js +13 -0
- package/dist/flow/template-shared.js.map +1 -0
- package/dist/flow/template-strings.d.ts.map +1 -1
- package/dist/flow/template-strings.js +2 -5
- package/dist/flow/template-strings.js.map +1 -1
- package/dist/flow/types.d.ts +15 -9
- package/dist/flow/types.d.ts.map +1 -1
- package/dist/flow/warp.d.ts +15 -0
- package/dist/flow/warp.d.ts.map +1 -0
- package/dist/flow/warp.js +207 -0
- package/dist/flow/warp.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +185 -28
- package/dist/index.js.map +1 -1
- package/dist/snapshot/cli-args.d.ts +1 -0
- package/dist/snapshot/cli-args.d.ts.map +1 -1
- package/dist/snapshot/cli-args.js +12 -0
- package/dist/snapshot/cli-args.js.map +1 -1
- package/dist/snapshot/runner-events.d.ts +5 -0
- package/dist/snapshot/runner-events.d.ts.map +1 -1
- package/dist/snapshot/runner-events.js +89 -15
- package/dist/snapshot/runner-events.js.map +1 -1
- package/dist/snapshot/snapshot.d.ts +22 -19
- package/dist/snapshot/snapshot.d.ts.map +1 -1
- package/dist/snapshot/snapshot.js +1063 -167
- package/dist/snapshot/snapshot.js.map +1 -1
- package/dist/steering/flow-prompt.d.ts +2 -2
- package/dist/steering/flow-prompt.d.ts.map +1 -1
- package/dist/steering/flow-prompt.js +4 -4
- package/dist/steering/flow-prompt.js.map +1 -1
- package/dist/steering/sliding-prompt.d.ts.map +1 -1
- package/dist/steering/sliding-prompt.js +9 -6
- package/dist/steering/sliding-prompt.js.map +1 -1
- package/dist/steering/tool-utils.d.ts +31 -8
- package/dist/steering/tool-utils.d.ts.map +1 -1
- package/dist/steering/tool-utils.js +63 -30
- package/dist/steering/tool-utils.js.map +1 -1
- package/dist/tools/ask-user.d.ts +0 -17
- package/dist/tools/ask-user.d.ts.map +1 -1
- package/dist/tools/ask-user.js +13 -37
- package/dist/tools/ask-user.js.map +1 -1
- package/dist/tools/timed-bash.d.ts +1 -1
- package/dist/tools/timed-bash.d.ts.map +1 -1
- package/dist/tools/timed-bash.js +19 -8
- package/dist/tools/timed-bash.js.map +1 -1
- package/dist/tools/web-tool.d.ts.map +1 -1
- package/dist/tools/web-tool.js +11 -13
- package/dist/tools/web-tool.js.map +1 -1
- package/dist/tui/render-utils.d.ts +5 -1
- package/dist/tui/render-utils.d.ts.map +1 -1
- package/dist/tui/render-utils.js +36 -10
- package/dist/tui/render-utils.js.map +1 -1
- package/dist/tui/render.d.ts +9 -0
- package/dist/tui/render.d.ts.map +1 -1
- package/dist/tui/render.js +112 -100
- package/dist/tui/render.js.map +1 -1
- package/dist/tui/scramble/constants.d.ts +8 -8
- package/dist/tui/scramble/constants.d.ts.map +1 -1
- package/dist/tui/scramble/constants.js +7 -7
- package/dist/tui/scramble/constants.js.map +1 -1
- package/dist/tui/scramble/index.d.ts +1 -1
- package/dist/tui/scramble/index.d.ts.map +1 -1
- package/dist/tui/scramble/index.js +1 -1
- package/dist/tui/scramble/index.js.map +1 -1
- package/dist/tui/scramble/manager.d.ts +1 -5
- package/dist/tui/scramble/manager.d.ts.map +1 -1
- package/dist/tui/scramble/manager.js +16 -64
- package/dist/tui/scramble/manager.js.map +1 -1
- package/dist/tui/scramble/utils.js +1 -1
- package/dist/tui/scramble/utils.js.map +1 -1
- package/dist/types/flow.d.ts +2 -0
- package/dist/types/flow.d.ts.map +1 -1
- package/dist/types/flow.js +11 -2
- package/dist/types/flow.js.map +1 -1
- package/dist/types/output.d.ts +6 -0
- package/dist/types/output.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/core/delegation.d.ts.map +0 -1
- package/dist/core/delegation.js.map +0 -1
- package/dist/flow/warp-command.d.ts +0 -9
- package/dist/flow/warp-command.d.ts.map +0 -1
- package/dist/flow/warp-command.js +0 -405
- package/dist/flow/warp-command.js.map +0 -1
package/dist/flow/index.d.ts
CHANGED
|
@@ -3,12 +3,15 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
5
5
|
import { setupFlowCommand } from "./command.js";
|
|
6
|
-
import
|
|
6
|
+
import setupWarp from "./warp.js";
|
|
7
|
+
import { setupLoopCommand } from "./loop-command.js";
|
|
7
8
|
import { setupContinuation } from "./continuation.js";
|
|
8
9
|
import * as sessionRegistry from "../core/session-registry.js";
|
|
9
10
|
export type { GoalState, GoalEntry, GoalStatus, GoalContext, } from "./types.js";
|
|
11
|
+
export type { LoopState, LoopStatus, LoopTerminationReason } from "./types.js";
|
|
10
12
|
export { getGoal, getGoalForSession, setGoal, clearGoal, updateGoalStatus, updateGoalObjective, recordFlowCompletion, addTokens, } from "./store.js";
|
|
11
|
-
export {
|
|
13
|
+
export { getLoop, enableLoop, disableLoop, resetLoop, terminateLoop, recordSessionWarp, setPendingWarpSessionId, clearPendingWarpSessionId, } from "./loop.js";
|
|
14
|
+
export { setupFlowCommand, setupContinuation, setupWarp, setupLoopCommand };
|
|
12
15
|
export { markFlowCompleted, shutdownWakeup } from "./continuation.js";
|
|
13
16
|
export { sessionRegistry };
|
|
14
17
|
export declare function registerFlow(pi: ExtensionAPI): void;
|
package/dist/flow/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/flow/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,+BAA+B,CAAC;AAEpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,eAAe,MAAM,6BAA6B,CAAC;AAE/D,YAAY,EACV,SAAS,EACT,SAAS,EACT,UAAU,EACV,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/flow/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAoB,MAAM,+BAA+B,CAAC;AAEpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,eAAe,MAAM,6BAA6B,CAAC;AAE/D,YAAY,EACV,SAAS,EACT,SAAS,EACT,UAAU,EACV,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,SAAS,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE/E,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,OAAO,EACP,UAAU,EACV,WAAW,EACX,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,wBAAgB,YAAY,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAUnD"}
|
package/dist/flow/index.js
CHANGED
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { setupFlowCommand } from "./command.js";
|
|
5
5
|
import { setupSettingsCommand } from "./settings-command.js";
|
|
6
|
-
import
|
|
6
|
+
import setupWarp from "./warp.js";
|
|
7
|
+
import { setupLoopCommand } from "./loop-command.js";
|
|
7
8
|
import { setupContinuation } from "./continuation.js";
|
|
8
9
|
import * as sessionRegistry from "../core/session-registry.js";
|
|
9
10
|
export { getGoal, getGoalForSession, setGoal, clearGoal, updateGoalStatus, updateGoalObjective, recordFlowCompletion, addTokens, } from "./store.js";
|
|
10
|
-
export {
|
|
11
|
+
export { getLoop, enableLoop, disableLoop, resetLoop, terminateLoop, recordSessionWarp, setPendingWarpSessionId, clearPendingWarpSessionId, } from "./loop.js";
|
|
12
|
+
export { setupFlowCommand, setupContinuation, setupWarp, setupLoopCommand };
|
|
11
13
|
export { markFlowCompleted, shutdownWakeup } from "./continuation.js";
|
|
12
14
|
export { sessionRegistry };
|
|
13
15
|
export function registerFlow(pi) {
|
|
@@ -16,7 +18,8 @@ export function registerFlow(pi) {
|
|
|
16
18
|
});
|
|
17
19
|
setupFlowCommand(pi);
|
|
18
20
|
setupSettingsCommand(pi);
|
|
19
|
-
|
|
21
|
+
setupWarp(pi);
|
|
22
|
+
setupLoopCommand(pi);
|
|
20
23
|
setupContinuation(pi);
|
|
21
24
|
}
|
|
22
25
|
//# sourceMappingURL=index.js.map
|
package/dist/flow/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/flow/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,eAAe,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/flow/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,KAAK,eAAe,MAAM,6BAA6B,CAAC;AAW/D,OAAO,EACL,OAAO,EACP,iBAAiB,EACjB,OAAO,EACP,SAAS,EACT,gBAAgB,EAChB,mBAAmB,EACnB,oBAAoB,EACpB,SAAS,GACV,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,OAAO,EACP,UAAU,EACV,WAAW,EACX,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,SAAS,EAAE,gBAAgB,EAAE,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,CAAC;AAE3B,MAAM,UAAU,YAAY,CAAC,EAAgB;IAC3C,EAAE,CAAC,EAAE,CAAC,eAAe,EAAE,CAAC,MAAM,EAAE,GAAqB,EAAE,EAAE;QACvD,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,gBAAgB,CAAC,EAAE,CAAC,CAAC;IACrB,oBAAoB,CAAC,EAAE,CAAC,CAAC;IACzB,SAAS,CAAC,EAAE,CAAC,CAAC;IACd,gBAAgB,CAAC,EAAE,CAAC,CAAC;IACrB,iBAAiB,CAAC,EAAE,CAAC,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /flow:loop slash command registration.
|
|
3
|
+
*
|
|
4
|
+
* Subcommands: enable, disable, status, stop, reset
|
|
5
|
+
*/
|
|
6
|
+
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
7
|
+
export declare function setupLoopCommand(pi: ExtensionAPI): void;
|
|
8
|
+
//# sourceMappingURL=loop-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-command.d.ts","sourceRoot":"","sources":["../../src/flow/loop-command.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAA2B,MAAM,+BAA+B,CAAC;AAuB3F,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAgFvD"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* /flow:loop slash command registration.
|
|
3
|
+
*
|
|
4
|
+
* Subcommands: enable, disable, status, stop, reset
|
|
5
|
+
*/
|
|
6
|
+
import { getGoal } from "./store.js";
|
|
7
|
+
import { getLoop, enableLoop, disableLoop, resetLoop, terminateLoop, } from "./loop.js";
|
|
8
|
+
function formatLoop(loop) {
|
|
9
|
+
const lines = [
|
|
10
|
+
`**Status:** ${loop.status}`,
|
|
11
|
+
`**Objective:** ${loop.objective}`,
|
|
12
|
+
`**Sessions:** ${loop.sessionCount}`,
|
|
13
|
+
`**Tokens across sessions:** ${loop.totalTokensAcrossSessions}`,
|
|
14
|
+
`**Flows across sessions:** ${loop.totalFlowsAcrossSessions}`,
|
|
15
|
+
];
|
|
16
|
+
if (loop.terminatedAt)
|
|
17
|
+
lines.push(`**Terminated at:** ${loop.terminatedAt}`);
|
|
18
|
+
if (loop.terminationReason)
|
|
19
|
+
lines.push(`**Termination reason:** ${loop.terminationReason}`);
|
|
20
|
+
return lines.join("\n");
|
|
21
|
+
}
|
|
22
|
+
export function setupLoopCommand(pi) {
|
|
23
|
+
pi.registerCommand("flow:loop", {
|
|
24
|
+
description: "Manage endless loop. Subcommands: enable, disable, status, stop, reset",
|
|
25
|
+
handler: async (args, ctx) => {
|
|
26
|
+
if (!ctx.ui) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const trimmed = args.trim();
|
|
30
|
+
const firstSpace = trimmed.indexOf(" ");
|
|
31
|
+
const sub = (firstSpace === -1 ? trimmed : trimmed.slice(0, firstSpace)).toLowerCase();
|
|
32
|
+
const rest = firstSpace === -1 ? "" : trimmed.slice(firstSpace + 1).trim();
|
|
33
|
+
const cwd = ctx.cwd;
|
|
34
|
+
switch (sub) {
|
|
35
|
+
case "enable": {
|
|
36
|
+
const goal = getGoal(cwd);
|
|
37
|
+
if (!goal) {
|
|
38
|
+
ctx.ui.notify?.("Cannot enable loop: no active goal. Set a goal first with /flow:goal set.", "error");
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const objective = rest || goal.objective;
|
|
42
|
+
try {
|
|
43
|
+
const loop = enableLoop(cwd, objective);
|
|
44
|
+
ctx.ui.notify?.(`Loop enabled: ${loop.objective}`, "info");
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
ctx.ui.notify?.(err instanceof Error ? err.message : "Failed to enable loop", "error");
|
|
48
|
+
}
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
case "disable": {
|
|
52
|
+
const loop = disableLoop(cwd);
|
|
53
|
+
if (loop) {
|
|
54
|
+
ctx.ui.notify?.("Loop disabled", "info");
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
ctx.ui.notify?.("No active loop to disable", "error");
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
case "status": {
|
|
62
|
+
const loop = getLoop(cwd);
|
|
63
|
+
if (loop) {
|
|
64
|
+
ctx.ui.notify?.(formatLoop(loop), "info");
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
ctx.ui.notify?.("No loop active", "info");
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
case "stop": {
|
|
72
|
+
const loop = getLoop(cwd);
|
|
73
|
+
if (!loop) {
|
|
74
|
+
ctx.ui.notify?.("No loop active", "error");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (loop.status === "terminated") {
|
|
78
|
+
ctx.ui.notify?.("Loop already terminated", "info");
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
terminateLoop(cwd, "user_disabled");
|
|
82
|
+
ctx.ui.notify?.("Loop stopped", "info");
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
case "reset": {
|
|
86
|
+
const loop = resetLoop(cwd);
|
|
87
|
+
if (loop) {
|
|
88
|
+
ctx.ui.notify?.("Loop reset", "info");
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
ctx.ui.notify?.("No loop to reset", "error");
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
default: {
|
|
96
|
+
ctx.ui.notify?.("Unknown subcommand. Usage: /flow:loop {enable|disable|status|stop|reset}", "error");
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=loop-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-command.js","sourceRoot":"","sources":["../../src/flow/loop-command.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACrC,OAAO,EACL,OAAO,EACP,UAAU,EACV,WAAW,EACX,SAAS,EACT,aAAa,GACd,MAAM,WAAW,CAAC;AAEnB,SAAS,UAAU,CAAC,IAA6C;IAC/D,MAAM,KAAK,GAAG;QACZ,eAAe,IAAI,CAAC,MAAM,EAAE;QAC5B,kBAAkB,IAAI,CAAC,SAAS,EAAE;QAClC,iBAAiB,IAAI,CAAC,YAAY,EAAE;QACpC,+BAA+B,IAAI,CAAC,yBAAyB,EAAE;QAC/D,8BAA8B,IAAI,CAAC,wBAAwB,EAAE;KAC9D,CAAC;IACF,IAAI,IAAI,CAAC,YAAY;QAAE,KAAK,CAAC,IAAI,CAAC,sBAAsB,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;IAC7E,IAAI,IAAI,CAAC,iBAAiB;QAAE,KAAK,CAAC,IAAI,CAAC,2BAA2B,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC;IAC5F,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,EAAgB;IAC/C,EAAE,CAAC,eAAe,CAAC,WAAW,EAAE;QAC9B,WAAW,EACT,wEAAwE;QAC1E,OAAO,EAAE,KAAK,EAAE,IAAY,E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T,CAAC;oBACD,aAAa,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;oBACpC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;oBACxC,MAAM;gBACR,CAAC;gBACD,KAAK,OAAO,CAAC,CAAC,CAAC;oBACb,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;oBAC5B,IAAI,IAAI,EAAE,CAAC;wBACT,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;oBACxC,CAAC;yBAAM,CAAC;wBACN,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;oBAC/C,CAAC;oBACD,MAAM;gBACR,CAAC;gBACD,OAAO,CAAC,CAAC,CAAC;oBACR,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CACb,0EAA0E,EAC1E,OAAO,CACR,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime template strings for endless loop prompts.
|
|
3
|
+
*/
|
|
4
|
+
export declare const autoWarpTriggerTemplate = "<flow-loop-warp>\nThe active goal has exceeded its budget, but the endless loop is active. Call the warp tool to continue in a new session.\n\nObjective: {{objective}}\n{{acceptanceClause}}\nLoop progress: {{sessionCount}} sessions, {{totalFlowsAcrossSessions}} flows, {{totalTokensAcrossSessions}}/{{maxTokens}} tokens.\n\nThe new session should inherit this context and resume work toward the objective.\n</flow-loop-warp>";
|
|
5
|
+
export declare const loopContinuationPromptTemplate = "<flow-continuation>\nContinue execution toward the active goal. This is an endless loop session.\n\nObjective: {{objective}}\n{{acceptanceClause}}\nProgress: {{flowCount}}{{maxFlowsClause}} flows in this session, {{tokenInfo}} tokens.\nLoop overall: {{sessionCount}} sessions, {{totalTokensAcrossSessions}} tokens total.\n\nLatest user message: {{userMessage}}\n\nCall the flow tool with an appropriate type to advance, or call the warp tool to hand off to a fresh session if budget is exceeded. Only the user can end a goal. Keep finding improvements that advance the objective.\n</flow-continuation>";
|
|
6
|
+
export declare const loopWakeupTemplate = "<flow-wakeup>\nThe user has been idle. Review the active goal and find safe, conservative improvements that advance it. This is an endless loop session.\n\nObjective: {{objective}}\n{{acceptanceClause}}\nProgress: {{flowCount}}/{{maxFlows}} flows in this session, {{totalTokens}} tokens.\nLoop overall: {{sessionCount}} sessions, {{totalTokensAcrossSessions}} tokens total.\n\nGuidance:\n- Focus on safe, incremental improvements \u2014 do not refactor large areas or make risky changes.\n- Prefer verification, testing, and documentation over new features.\n- If you find potential issues, investigate with scout or audit before making changes.\n- You cannot end this goal. Only the user can end a goal.\n\nCall the flow tool with the appropriate flow type to continue, or call the warp tool to hand off to a fresh session if budget is exceeded.\n</flow-wakeup>";
|
|
7
|
+
//# sourceMappingURL=loop-templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-templates.d.ts","sourceRoot":"","sources":["../../src/flow/loop-templates.ts"],"names":[],"mappings":"AAEA;;GAEG;AAEH,eAAO,MAAM,uBAAuB,6aAQlB,CAAC;AAEnB,eAAO,MAAM,8BAA8B,8lBAWtB,CAAC;AAEtB,eAAO,MAAM,kBAAkB,m2BAWhB,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { loopOverallClause, sharedWakeupGuidance } from "./template-shared.js";
|
|
2
|
+
/**
|
|
3
|
+
* Runtime template strings for endless loop prompts.
|
|
4
|
+
*/
|
|
5
|
+
export const autoWarpTriggerTemplate = `<flow-loop-warp>
|
|
6
|
+
The active goal has exceeded its budget, but the endless loop is active. Call the warp tool to continue in a new session.
|
|
7
|
+
|
|
8
|
+
Objective: {{objective}}
|
|
9
|
+
{{acceptanceClause}}
|
|
10
|
+
Loop progress: {{sessionCount}} sessions, {{totalFlowsAcrossSessions}} flows, {{totalTokensAcrossSessions}}/{{maxTokens}} tokens.
|
|
11
|
+
|
|
12
|
+
The new session should inherit this context and resume work toward the objective.
|
|
13
|
+
</flow-loop-warp>`;
|
|
14
|
+
export const loopContinuationPromptTemplate = `<flow-continuation>
|
|
15
|
+
Continue execution toward the active goal. This is an endless loop session.
|
|
16
|
+
|
|
17
|
+
Objective: {{objective}}
|
|
18
|
+
{{acceptanceClause}}
|
|
19
|
+
Progress: {{flowCount}}{{maxFlowsClause}} flows in this session, {{tokenInfo}} tokens.
|
|
20
|
+
${loopOverallClause}
|
|
21
|
+
|
|
22
|
+
Latest user message: {{userMessage}}
|
|
23
|
+
|
|
24
|
+
Call the flow tool with an appropriate type to advance, or call the warp tool to hand off to a fresh session if budget is exceeded. Only the user can end a goal. Keep finding improvements that advance the objective.
|
|
25
|
+
</flow-continuation>`;
|
|
26
|
+
export const loopWakeupTemplate = `<flow-wakeup>
|
|
27
|
+
The user has been idle. Review the active goal and find safe, conservative improvements that advance it. This is an endless loop session.
|
|
28
|
+
|
|
29
|
+
Objective: {{objective}}
|
|
30
|
+
{{acceptanceClause}}
|
|
31
|
+
Progress: {{flowCount}}/{{maxFlows}} flows in this session, {{totalTokens}} tokens.
|
|
32
|
+
${loopOverallClause}
|
|
33
|
+
|
|
34
|
+
${sharedWakeupGuidance}
|
|
35
|
+
|
|
36
|
+
Call the flow tool with the appropriate flow type to continue, or call the warp tool to hand off to a fresh session if budget is exceeded.
|
|
37
|
+
</flow-wakeup>`;
|
|
38
|
+
//# sourceMappingURL=loop-templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-templates.js","sourceRoot":"","sources":["../../src/flow/loop-templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAE/E;;GAEG;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;kBAQrB,CAAC;AAEnB,MAAM,CAAC,MAAM,8BAA8B,GAAG;;;;;;EAM5C,iBAAiB;;;;;qBAKE,CAAC;AAEtB,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;EAMhC,iBAAiB;;EAEjB,oBAAoB;;;eAGP,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Endless loop state management.
|
|
3
|
+
*
|
|
4
|
+
* A loop spans multiple sessions toward a persistent objective.
|
|
5
|
+
*/
|
|
6
|
+
import type { LoopState, LoopTerminationReason } from "./types.js";
|
|
7
|
+
export declare function getLoop(cwd: string): LoopState | undefined;
|
|
8
|
+
export declare function enableLoop(cwd: string, objective: string): LoopState;
|
|
9
|
+
export declare function disableLoop(cwd: string): LoopState | undefined;
|
|
10
|
+
export declare function resetLoop(cwd: string): LoopState | undefined;
|
|
11
|
+
export declare function terminateLoop(cwd: string, reason: LoopTerminationReason): LoopState | undefined;
|
|
12
|
+
export declare function recordSessionWarp(cwd: string): LoopState | undefined;
|
|
13
|
+
export declare function setPendingWarpSessionId(cwd: string, sessionId: string): LoopState | undefined;
|
|
14
|
+
export declare function clearPendingWarpSessionId(cwd: string): LoopState | undefined;
|
|
15
|
+
/** Directly set loop state (test helper). */
|
|
16
|
+
export declare function setLoop(cwd: string, loop: LoopState): void;
|
|
17
|
+
/** Remove loop state (test helper). */
|
|
18
|
+
export declare function clearLoop(cwd: string): void;
|
|
19
|
+
//# sourceMappingURL=loop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../src/flow/loop.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEnE,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAG1D;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,CAepE;AAED,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAM9D;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAW5D;AAED,wBAAgB,aAAa,CAC3B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,qBAAqB,GAC5B,SAAS,GAAG,SAAS,CAQvB;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAMpE;AAED,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAO7F;AAED,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAM5E;AAED,6CAA6C;AAC7C,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI,CAI1D;AAED,uCAAuC;AACvC,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAI3C"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Endless loop state management.
|
|
3
|
+
*
|
|
4
|
+
* A loop spans multiple sessions toward a persistent objective.
|
|
5
|
+
*/
|
|
6
|
+
import { readState, writeState } from "./store.js";
|
|
7
|
+
export function getLoop(cwd) {
|
|
8
|
+
const state = readState(cwd);
|
|
9
|
+
return state.loop;
|
|
10
|
+
}
|
|
11
|
+
export function enableLoop(cwd, objective) {
|
|
12
|
+
const state = readState(cwd);
|
|
13
|
+
if (!state.current) {
|
|
14
|
+
throw new Error("Cannot enable loop: no active goal.");
|
|
15
|
+
}
|
|
16
|
+
const loop = {
|
|
17
|
+
objective,
|
|
18
|
+
status: "active",
|
|
19
|
+
sessionCount: 1,
|
|
20
|
+
totalTokensAcrossSessions: 0,
|
|
21
|
+
totalFlowsAcrossSessions: 0,
|
|
22
|
+
};
|
|
23
|
+
state.loop = loop;
|
|
24
|
+
writeState(cwd, state);
|
|
25
|
+
return loop;
|
|
26
|
+
}
|
|
27
|
+
export function disableLoop(cwd) {
|
|
28
|
+
const state = readState(cwd);
|
|
29
|
+
if (!state.loop)
|
|
30
|
+
return undefined;
|
|
31
|
+
state.loop.status = "paused";
|
|
32
|
+
writeState(cwd, state);
|
|
33
|
+
return state.loop;
|
|
34
|
+
}
|
|
35
|
+
export function resetLoop(cwd) {
|
|
36
|
+
const state = readState(cwd);
|
|
37
|
+
if (!state.loop)
|
|
38
|
+
return undefined;
|
|
39
|
+
state.loop.status = "active";
|
|
40
|
+
state.loop.sessionCount = 0;
|
|
41
|
+
state.loop.totalTokensAcrossSessions = 0;
|
|
42
|
+
state.loop.totalFlowsAcrossSessions = 0;
|
|
43
|
+
delete state.loop.terminatedAt;
|
|
44
|
+
delete state.loop.terminationReason;
|
|
45
|
+
writeState(cwd, state);
|
|
46
|
+
return state.loop;
|
|
47
|
+
}
|
|
48
|
+
export function terminateLoop(cwd, reason) {
|
|
49
|
+
const state = readState(cwd);
|
|
50
|
+
if (!state.loop)
|
|
51
|
+
return undefined;
|
|
52
|
+
state.loop.status = "terminated";
|
|
53
|
+
state.loop.terminationReason = reason;
|
|
54
|
+
state.loop.terminatedAt = new Date().toISOString();
|
|
55
|
+
writeState(cwd, state);
|
|
56
|
+
return state.loop;
|
|
57
|
+
}
|
|
58
|
+
export function recordSessionWarp(cwd) {
|
|
59
|
+
const state = readState(cwd);
|
|
60
|
+
if (!state.loop || state.loop.status !== "active")
|
|
61
|
+
return undefined;
|
|
62
|
+
state.loop.sessionCount += 1;
|
|
63
|
+
writeState(cwd, state);
|
|
64
|
+
return state.loop;
|
|
65
|
+
}
|
|
66
|
+
export function setPendingWarpSessionId(cwd, sessionId) {
|
|
67
|
+
const state = readState(cwd);
|
|
68
|
+
if (!state.loop)
|
|
69
|
+
return undefined;
|
|
70
|
+
state.loop.pendingWarpSessionId = sessionId;
|
|
71
|
+
state.loop.status = "active";
|
|
72
|
+
writeState(cwd, state);
|
|
73
|
+
return state.loop;
|
|
74
|
+
}
|
|
75
|
+
export function clearPendingWarpSessionId(cwd) {
|
|
76
|
+
const state = readState(cwd);
|
|
77
|
+
if (!state.loop)
|
|
78
|
+
return undefined;
|
|
79
|
+
delete state.loop.pendingWarpSessionId;
|
|
80
|
+
writeState(cwd, state);
|
|
81
|
+
return state.loop;
|
|
82
|
+
}
|
|
83
|
+
/** Directly set loop state (test helper). */
|
|
84
|
+
export function setLoop(cwd, loop) {
|
|
85
|
+
const state = readState(cwd);
|
|
86
|
+
state.loop = loop;
|
|
87
|
+
writeState(cwd, state);
|
|
88
|
+
}
|
|
89
|
+
/** Remove loop state (test helper). */
|
|
90
|
+
export function clearLoop(cwd) {
|
|
91
|
+
const state = readState(cwd);
|
|
92
|
+
delete state.loop;
|
|
93
|
+
writeState(cwd, state);
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=loop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop.js","sourceRoot":"","sources":["../../src/flow/loop.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGnD,MAAM,UAAU,OAAO,CAAC,GAAW;IACjC,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IAC7B,OAAO,KAAK,CAAC,IAAI,CAAC;AACpB,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,GAAW,EAAE,SAAiB;IACvD,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IAC7B,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IACD,MAAM,IAAI,GAAc;QACtB,SAAS;QACT,MAAM,EAAE,QAAQ;QAChB,YAAY,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AC;IACvC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACvB,OAAO,KAAK,CAAC,IAAI,CAAC;AACpB,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,OAAO,CAAC,GAAW,EAAE,IAAe;IAClD,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IAC7B,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACzB,CAAC;AAED,uCAAuC;AACvC,MAAM,UAAU,SAAS,CAAC,GAAW;IACnC,MAAM,KAAK,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC;IAC7B,OAAO,KAAK,CAAC,IAAI,CAAC;IAClB,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-command.d.ts","sourceRoot":"","sources":["../../src/flow/settings-command.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAkC,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"settings-command.d.ts","sourceRoot":"","sources":["../../src/flow/settings-command.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAkC,MAAM,+BAA+B,CAAC;AAMlG,OAAO,EAEN,KAAK,SAAS,EAEd,KAAK,kBAAkB,EAUvB,MAAM,sBAAsB,CAAC;AAW9B,MAAM,WAAW,WAAW;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,aAAa,CAAC,EAAE,M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IAcjB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,mBAAmB;IAU3B,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,WAAW;CAInB;AAkXD,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAob3D"}
|
|
@@ -11,6 +11,7 @@ import { loadFlowSettings, writeFlowSetting, loadFlowModelConfigs, writeGlobalFl
|
|
|
11
11
|
import { configureSteering } from "../steering/sliding-prompt.js";
|
|
12
12
|
import { configureStrategicHint } from "../steering/tool-utils.js";
|
|
13
13
|
import { scrambleManager } from "../tui/scramble/index.js";
|
|
14
|
+
import { getLoop } from "./loop.js";
|
|
14
15
|
import { Container, Input, matchesKey, SelectList, Key, Spacer, Text, truncateToWidth, visibleWidth, wrapTextWithAnsi, } from "@mariozechner/pi-tui";
|
|
15
16
|
// Module-level refs for submenu builders (set during handler call)
|
|
16
17
|
let _modelRegistry = null;
|
|
@@ -201,12 +202,14 @@ function getMainMenuItems(settings, cwd) {
|
|
|
201
202
|
const strategyName = loaded.selectedName;
|
|
202
203
|
const litePrimary = loaded.strategy.lite?.primary ?? "(default)";
|
|
203
204
|
const primaryModelShort = litePrimary.includes("/") ? litePrimary.split("/").pop() : litePrimary;
|
|
205
|
+
const loop = getLoop(cwd);
|
|
206
|
+
const loopDescription = loop ? `${loop.status} • ${loop.sessionCount} sessions` : "none";
|
|
204
207
|
return [
|
|
205
208
|
{
|
|
206
209
|
value: "steering",
|
|
207
210
|
label: "Steering Settings",
|
|
208
211
|
description: steeringEnabled ? "enabled" : "disabled",
|
|
209
|
-
tooltip: "Configure
|
|
212
|
+
tooltip: "Configure root state steering and strategic hints",
|
|
210
213
|
},
|
|
211
214
|
{
|
|
212
215
|
value: "animation",
|
|
@@ -238,6 +241,12 @@ function getMainMenuItems(settings, cwd) {
|
|
|
238
241
|
description: `${strategyName} ▸ lite: ${primaryModelShort}`,
|
|
239
242
|
tooltip: "Configure LLM models for lite, flash, and full flow tiers",
|
|
240
243
|
},
|
|
244
|
+
{
|
|
245
|
+
value: "loop",
|
|
246
|
+
label: "Loop Status",
|
|
247
|
+
description: loopDescription,
|
|
248
|
+
tooltip: "Endless loop state and statistics",
|
|
249
|
+
},
|
|
241
250
|
{
|
|
242
251
|
value: "reset",
|
|
243
252
|
label: "Reset to Defaults",
|
|
@@ -363,6 +372,51 @@ function getAskUserItems(settings) {
|
|
|
363
372
|
},
|
|
364
373
|
];
|
|
365
374
|
}
|
|
375
|
+
function getLoopItems(_settings, cwd) {
|
|
376
|
+
const loop = getLoop(cwd);
|
|
377
|
+
if (!loop) {
|
|
378
|
+
return [
|
|
379
|
+
{
|
|
380
|
+
id: "loop.status",
|
|
381
|
+
label: "status",
|
|
382
|
+
description: "No active loop",
|
|
383
|
+
currentValue: "none",
|
|
384
|
+
},
|
|
385
|
+
];
|
|
386
|
+
}
|
|
387
|
+
return [
|
|
388
|
+
{
|
|
389
|
+
id: "loop.status",
|
|
390
|
+
label: "status",
|
|
391
|
+
description: "Current loop status",
|
|
392
|
+
currentValue: loop.status,
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
id: "loop.objective",
|
|
396
|
+
label: "objective",
|
|
397
|
+
description: "Loop objective",
|
|
398
|
+
currentValue: loop.objective,
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
id: "loop.sessions",
|
|
402
|
+
label: "sessions",
|
|
403
|
+
description: "Number of warped sessions",
|
|
404
|
+
currentValue: String(loop.sessionCount),
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
id: "loop.flows",
|
|
408
|
+
label: "flows",
|
|
409
|
+
description: "Total flows across sessions",
|
|
410
|
+
currentValue: String(loop.totalFlowsAcrossSessions),
|
|
411
|
+
},
|
|
412
|
+
{
|
|
413
|
+
id: "loop.tokens",
|
|
414
|
+
label: "tokens",
|
|
415
|
+
description: "Total tokens across sessions",
|
|
416
|
+
currentValue: String(loop.totalTokensAcrossSessions),
|
|
417
|
+
},
|
|
418
|
+
];
|
|
419
|
+
}
|
|
366
420
|
function getModelConfigItems(settings, cwd) {
|
|
367
421
|
const loaded = loadFlowModelConfigs(cwd);
|
|
368
422
|
const strategyName = loaded.selectedName;
|
|
@@ -467,6 +521,9 @@ export function setupSettingsCommand(pi) {
|
|
|
467
521
|
pi.registerCommand("flow:settings", {
|
|
468
522
|
description: "Manage flow settings. Subcommands: steering <on|off>, strategic-hint <on|off>, animation <on|off>, glitch <on|off>, tool-optimize <on|off>, structured-output <on|off>, session-mode <mode>, max-concurrency <n>, ask-user {enabled <on|off> | timeout <seconds>}, reset. Call with no args for interactive TUI.",
|
|
469
523
|
handler: async (args, ctx) => {
|
|
524
|
+
if (!ctx.ui) {
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
470
527
|
const cwd = ctx.cwd;
|
|
471
528
|
const trimmed = args.trim().toLowerCase();
|
|
472
529
|
const parts = trimmed.split(/\s+/);
|
|
@@ -675,6 +732,10 @@ export function setupSettingsCommand(pi) {
|
|
|
675
732
|
tui.requestRender();
|
|
676
733
|
};
|
|
677
734
|
}
|
|
735
|
+
else if (currentCategory === "loop") {
|
|
736
|
+
items = getLoopItems(currentSettings, cwd);
|
|
737
|
+
handleChange = () => { };
|
|
738
|
+
}
|
|
678
739
|
else {
|
|
679
740
|
items = [];
|
|
680
741
|
handleChange = () => { };
|
|
@@ -790,9 +851,9 @@ export function setupSettingsCommand(pi) {
|
|
|
790
851
|
break;
|
|
791
852
|
}
|
|
792
853
|
case "session-mode": {
|
|
793
|
-
const validModes = ["fast", "default", "long", "extreme_long"];
|
|
854
|
+
const validModes = ["snap", "fast", "default", "long", "extreme_long"];
|
|
794
855
|
if (!validModes.includes(value)) {
|
|
795
|
-
ctx.ui.notify?.("Usage: /flow:settings session-mode <fast|default|long|extreme_long>", "error");
|
|
856
|
+
ctx.ui.notify?.("Usage: /flow:settings session-mode <snap|fast|default|long|extreme_long>", "error");
|
|
796
857
|
return;
|
|
797
858
|
}
|
|
798
859
|
writeFlowSetting(cwd, "sessionMode", value);
|
|
@@ -841,8 +902,36 @@ export function setupSettingsCommand(pi) {
|
|
|
841
902
|
ctx.ui.notify?.("Flow settings reset to defaults", "info");
|
|
842
903
|
break;
|
|
843
904
|
}
|
|
905
|
+
case "show": {
|
|
906
|
+
const currentSettings = loadFlowSettings(cwd);
|
|
907
|
+
const loop = getLoop(cwd);
|
|
908
|
+
const lines = [
|
|
909
|
+
`toolOptimize: ${currentSettings.toolOptimize ?? true}`,
|
|
910
|
+
`structuredOutput: ${currentSettings.structuredOutput ?? true}`,
|
|
911
|
+
`sessionMode: ${currentSettings.sessionMode ?? "default"}`,
|
|
912
|
+
`maxConcurrency: ${currentSettings.maxConcurrency ?? 4}`,
|
|
913
|
+
`steering.enabled: ${currentSettings.steering?.enabled ?? true}`,
|
|
914
|
+
`steering.strategicHint: ${currentSettings.steering?.strategicHint ?? true}`,
|
|
915
|
+
`animation.enabled: ${currentSettings.animation?.enabled ?? true}`,
|
|
916
|
+
`animation.glitch: ${currentSettings.animation?.glitch ?? true}`,
|
|
917
|
+
`askUser.enabled: ${currentSettings.askUser?.enabled ?? false}`,
|
|
918
|
+
`askUser.timeout: ${currentSettings.askUser?.timeout ?? 300}`,
|
|
919
|
+
];
|
|
920
|
+
if (loop) {
|
|
921
|
+
lines.push("");
|
|
922
|
+
lines.push(`loop.status: ${loop.status}`);
|
|
923
|
+
lines.push(`loop.objective: ${loop.objective}`);
|
|
924
|
+
lines.push(`loop.sessions: ${loop.sessionCount}`);
|
|
925
|
+
lines.push(`loop.flows: ${loop.totalFlowsAcrossSessions}`);
|
|
926
|
+
lines.push(`loop.tokens: ${loop.totalTokensAcrossSessions}`);
|
|
927
|
+
if (loop.terminationReason)
|
|
928
|
+
lines.push(`loop.terminationReason: ${loop.terminationReason}`);
|
|
929
|
+
}
|
|
930
|
+
ctx.ui.notify?.(lines.join("\n"), "info");
|
|
931
|
+
break;
|
|
932
|
+
}
|
|
844
933
|
default: {
|
|
845
|
-
ctx.ui.notify?.("Unknown subcommand. Usage: /flow:settings {steering|strategic-hint|animation|glitch|tool-optimize|structured-output|session-mode|max-concurrency|ask-user|reset}", "error");
|
|
934
|
+
ctx.ui.notify?.("Unknown subcommand. Usage: /flow:settings {steering|strategic-hint|animation|glitch|tool-optimize|structured-output|session-mode|max-concurrency|ask-user|reset|show}", "error");
|
|
846
935
|
}
|
|
847
936
|
}
|
|
848
937
|
},
|