pi-agent-flow 2.0.1 → 2.0.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/README.md +126 -489
- package/agents/audit.md +24 -15
- package/agents/build.md +4 -3
- package/agents/craft.md +4 -4
- package/agents/debug.md +5 -4
- package/agents/ideas.md +6 -5
- package/agents/scout.md +10 -8
- package/agents/trace.md +23 -0
- 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 +10 -6
- package/dist/batch/batch-bash.d.ts.map +1 -1
- package/dist/batch/batch-bash.js +59 -11
- package/dist/batch/batch-bash.js.map +1 -1
- package/dist/batch/constants.d.ts +38 -6
- package/dist/batch/constants.d.ts.map +1 -1
- package/dist/batch/constants.js +26 -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 +222 -67
- 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 +10 -24
- package/dist/batch/index.d.ts.map +1 -1
- package/dist/batch/index.js +120 -120
- package/dist/batch/index.js.map +1 -1
- package/dist/batch/render.d.ts +22 -5
- package/dist/batch/render.d.ts.map +1 -1
- package/dist/batch/render.js +353 -15
- package/dist/batch/render.js.map +1 -1
- package/dist/batch/summary.d.ts.map +1 -1
- package/dist/batch/summary.js +26 -4
- package/dist/batch/summary.js.map +1 -1
- package/dist/config/config.d.ts +5 -4
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +15 -5
- package/dist/config/config.js.map +1 -1
- package/dist/config/models.d.ts.map +1 -1
- package/dist/config/models.js +7 -1
- package/dist/config/models.js.map +1 -1
- package/dist/config/settings-resolver.d.ts +5 -4
- package/dist/config/settings-resolver.d.ts.map +1 -1
- package/dist/config/settings-resolver.js +50 -21
- package/dist/config/settings-resolver.js.map +1 -1
- package/dist/core2/snapshot.d.ts +21 -0
- package/dist/core2/snapshot.d.ts.map +1 -0
- package/dist/core2/snapshot.js +214 -0
- package/dist/core2/snapshot.js.map +1 -0
- package/dist/{core → flow}/agents.d.ts.map +1 -1
- package/dist/{core → flow}/agents.js +5 -2
- package/dist/{core → flow}/agents.js.map +1 -1
- package/dist/flow/auto-warp.d.ts +1 -1
- package/dist/flow/auto-warp.js +1 -1
- package/dist/flow/command.d.ts +1 -1
- package/dist/flow/command.d.ts.map +1 -1
- package/dist/flow/complexity.d.ts +20 -0
- package/dist/flow/complexity.d.ts.map +1 -0
- package/dist/flow/complexity.js +34 -0
- package/dist/flow/complexity.js.map +1 -0
- package/dist/flow/continuation.d.ts +1 -1
- package/dist/flow/continuation.d.ts.map +1 -1
- package/dist/flow/continuation.js +4 -3
- package/dist/flow/continuation.js.map +1 -1
- package/dist/{core → flow}/depth.d.ts +4 -4
- package/dist/{core → flow}/depth.d.ts.map +1 -1
- package/dist/{core → flow}/depth.js +5 -5
- package/dist/{core → flow}/depth.js.map +1 -1
- package/dist/{core → flow}/executor.d.ts +42 -22
- package/dist/flow/executor.d.ts.map +1 -0
- package/dist/flow/executor.js +727 -0
- package/dist/flow/executor.js.map +1 -0
- package/dist/flow/index.d.ts +4 -4
- package/dist/flow/index.d.ts.map +1 -1
- package/dist/flow/index.js +4 -4
- package/dist/flow/index.js.map +1 -1
- package/dist/flow/loop-command.d.ts +1 -1
- package/dist/flow/loop-command.d.ts.map +1 -1
- package/dist/flow/loop-command.js +3 -0
- package/dist/flow/loop-command.js.map +1 -1
- package/dist/{core/flow.d.ts → flow/runner.d.ts} +20 -16
- package/dist/flow/runner.d.ts.map +1 -0
- package/dist/{core/flow.js → flow/runner.js} +105 -61
- package/dist/flow/runner.js.map +1 -0
- package/dist/{core → flow}/session-registry.d.ts.map +1 -1
- package/dist/{core → flow}/session-registry.js.map +1 -1
- package/dist/flow/settings-command.d.ts +3 -3
- package/dist/flow/settings-command.d.ts.map +1 -1
- package/dist/flow/settings-command.js +43 -22
- package/dist/flow/settings-command.js.map +1 -1
- package/dist/{core/delegation.d.ts → flow/transition.d.ts} +8 -8
- package/dist/{core/delegation.d.ts.map → flow/transition.d.ts.map} +1 -1
- package/dist/{core/delegation.js → flow/transition.js} +12 -12
- package/dist/{core/delegation.js.map → flow/transition.js.map} +1 -1
- package/dist/flow/types.d.ts +4 -0
- 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 +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +237 -89
- package/dist/index.js.map +1 -1
- package/dist/notify/notify.d.ts +1 -1
- package/dist/notify/notify.d.ts.map +1 -1
- package/dist/notify/notify.js +1 -1
- package/dist/snapshot/cli-args.d.ts +2 -2
- package/dist/snapshot/cli-args.d.ts.map +1 -1
- package/dist/snapshot/cli-args.js +21 -5
- package/dist/snapshot/cli-args.js.map +1 -1
- package/dist/snapshot/runner-events.d.ts +7 -2
- package/dist/snapshot/runner-events.d.ts.map +1 -1
- package/dist/snapshot/runner-events.js +137 -19
- package/dist/snapshot/runner-events.js.map +1 -1
- package/dist/snapshot/structured-output.d.ts +1 -1
- package/dist/snapshot/structured-output.d.ts.map +1 -1
- package/dist/snapshot/structured-output.js +20 -2
- package/dist/snapshot/structured-output.js.map +1 -1
- package/dist/steering/flow-prompt.d.ts +4 -4
- package/dist/steering/flow-prompt.d.ts.map +1 -1
- package/dist/steering/flow-prompt.js +18 -37
- 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 +8 -7
- 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 +2 -19
- package/dist/tools/ask-user.d.ts.map +1 -1
- package/dist/tools/ask-user.js +14 -38
- 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 +11 -9
- package/dist/tools/timed-bash.js.map +1 -1
- package/dist/tools/trace.d.ts +34 -0
- package/dist/tools/trace.d.ts.map +1 -0
- package/dist/tools/trace.js +180 -0
- package/dist/tools/trace.js.map +1 -0
- package/dist/tools/web-ops.d.ts +85 -0
- package/dist/tools/web-ops.d.ts.map +1 -0
- package/dist/tools/{web-tool.js → web-ops.js} +51 -127
- package/dist/tools/web-ops.js.map +1 -0
- package/dist/tui/flow-colors.d.ts +1 -0
- package/dist/tui/flow-colors.d.ts.map +1 -1
- package/dist/tui/flow-colors.js +2 -2
- package/dist/tui/flow-colors.js.map +1 -1
- package/dist/tui/render-utils.d.ts.map +1 -1
- package/dist/tui/render-utils.js +2 -4
- package/dist/tui/render-utils.js.map +1 -1
- package/dist/tui/render.d.ts +41 -1
- package/dist/tui/render.d.ts.map +1 -1
- package/dist/tui/render.js +724 -189
- package/dist/tui/render.js.map +1 -1
- package/dist/tui/scramble/algorithm.d.ts +4 -2
- package/dist/tui/scramble/algorithm.d.ts.map +1 -1
- package/dist/tui/scramble/algorithm.js +44 -12
- package/dist/tui/scramble/algorithm.js.map +1 -1
- package/dist/tui/scramble/constants.d.ts +3 -0
- package/dist/tui/scramble/constants.d.ts.map +1 -1
- package/dist/tui/scramble/constants.js +4 -1
- package/dist/tui/scramble/constants.js.map +1 -1
- package/dist/tui/scramble/index.d.ts +3 -2
- package/dist/tui/scramble/index.d.ts.map +1 -1
- package/dist/tui/scramble/index.js +2 -2
- package/dist/tui/scramble/index.js.map +1 -1
- package/dist/tui/scramble/manager.d.ts +2 -2
- package/dist/tui/scramble/manager.d.ts.map +1 -1
- package/dist/tui/scramble/manager.js +37 -20
- 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 +17 -1
- 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 +11 -36
- package/dist/types/output.d.ts.map +1 -1
- package/dist/types/output.js +1 -1
- package/dist/types/ui.d.ts +1 -1
- package/dist/types/ui.d.ts.map +1 -1
- package/package.json +10 -10
- package/dist/core/executor.d.ts.map +0 -1
- package/dist/core/executor.js +0 -378
- package/dist/core/executor.js.map +0 -1
- package/dist/core/flow.d.ts.map +0 -1
- package/dist/core/flow.js.map +0 -1
- package/dist/core/session-mode.d.ts +0 -11
- package/dist/core/session-mode.d.ts.map +0 -1
- package/dist/core/session-mode.js +0 -26
- package/dist/core/session-mode.js.map +0 -1
- package/dist/core/transitions.d.ts +0 -39
- package/dist/core/transitions.d.ts.map +0 -1
- package/dist/core/transitions.js +0 -59
- package/dist/core/transitions.js.map +0 -1
- package/dist/flow/perform-warp.d.ts +0 -28
- package/dist/flow/perform-warp.d.ts.map +0 -1
- package/dist/flow/perform-warp.js +0 -127
- package/dist/flow/perform-warp.js.map +0 -1
- package/dist/flow/warp-command.d.ts +0 -8
- package/dist/flow/warp-command.d.ts.map +0 -1
- package/dist/flow/warp-command.js +0 -144
- package/dist/flow/warp-command.js.map +0 -1
- package/dist/flow/warp-utils.d.ts +0 -11
- package/dist/flow/warp-utils.d.ts.map +0 -1
- package/dist/flow/warp-utils.js +0 -187
- package/dist/flow/warp-utils.js.map +0 -1
- package/dist/snapshot/index.d.ts +0 -2
- package/dist/snapshot/index.d.ts.map +0 -1
- package/dist/snapshot/index.js +0 -2
- package/dist/snapshot/index.js.map +0 -1
- package/dist/snapshot/reasoning-strip.d.ts +0 -22
- package/dist/snapshot/reasoning-strip.d.ts.map +0 -1
- package/dist/snapshot/reasoning-strip.js +0 -58
- package/dist/snapshot/reasoning-strip.js.map +0 -1
- package/dist/snapshot/snapshot.d.ts +0 -77
- package/dist/snapshot/snapshot.d.ts.map +0 -1
- package/dist/snapshot/snapshot.js +0 -1791
- package/dist/snapshot/snapshot.js.map +0 -1
- package/dist/tools/web-tool.d.ts +0 -46
- package/dist/tools/web-tool.d.ts.map +0 -1
- package/dist/tools/web-tool.js.map +0 -1
- /package/dist/{core → flow}/agents.d.ts +0 -0
- /package/dist/{core → flow}/session-registry.d.ts +0 -0
- /package/dist/{core → flow}/session-registry.js +0 -0
package/dist/core/transitions.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Declarative transition matrix for post-flow advisory messages.
|
|
3
|
-
*
|
|
4
|
-
* Defines a data-driven transition map. Each entry describes a recommended
|
|
5
|
-
* follow-up flow given a source flow's outcome. The matrix is used by
|
|
6
|
-
* getTransitionAdvice() to generate advisory strings.
|
|
7
|
-
*/
|
|
8
|
-
import { isFlowSuccess } from "../types/flow.js";
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
// Default transition matrix
|
|
11
|
-
// ---------------------------------------------------------------------------
|
|
12
|
-
export const DEFAULT_TRANSITIONS = [
|
|
13
|
-
{ from: "scout", to: "build", on: "success", advice: "Context mapped. Consider running a [build] flow to implement changes, or [debug] if investigating an issue." },
|
|
14
|
-
{ from: "scout", to: "debug", on: "success", advice: "Context mapped. Consider running a [debug] flow if investigating an issue." },
|
|
15
|
-
{ from: "debug", to: "build", on: "success", advice: "The root cause has been identified. Consider running a [build] flow to implement the fix." },
|
|
16
|
-
{ from: "debug", to: "audit", on: "success", advice: "Root cause identified. Consider running an [audit] flow to verify the fix area for related issues." },
|
|
17
|
-
{ from: "build", to: "audit", on: "success", advice: "Consider running an [audit] flow to audit the changes for security, correctness, and code quality." },
|
|
18
|
-
{ from: "build", to: "debug", on: "failure", advice: "Build failed. Consider running a [debug] flow to investigate the root cause." },
|
|
19
|
-
{ from: "audit", to: "scout", on: "success", advice: "Audit complete. Consider running a [scout] flow to trace the audit findings across the codebase." },
|
|
20
|
-
{ from: "audit", to: "build", on: "failure", advice: "Audit found issues. Consider running a [build] flow to fix them." },
|
|
21
|
-
{ from: "craft", to: "build", on: "success", advice: "Plan ready. Consider running a [build] flow to implement the design." },
|
|
22
|
-
{ from: "ideas", to: "craft", on: "success", advice: "Ideas explored. Consider running a [craft] flow to design the approach, or [build] to implement directly." },
|
|
23
|
-
];
|
|
24
|
-
// ---------------------------------------------------------------------------
|
|
25
|
-
// Advice generation
|
|
26
|
-
// ---------------------------------------------------------------------------
|
|
27
|
-
/**
|
|
28
|
-
* Get advisory messages for completed flows based on the transition matrix.
|
|
29
|
-
*
|
|
30
|
-
* For each flow result, finds matching transitions where:
|
|
31
|
-
* 1. The source flow type matches
|
|
32
|
-
* 2. The outcome matches the `on` condition
|
|
33
|
-
* 3. The target flow was not already in the batch
|
|
34
|
-
*
|
|
35
|
-
* Returns advisory strings in matrix order.
|
|
36
|
-
*/
|
|
37
|
-
export function getTransitionAdvice(params, results, transitions = DEFAULT_TRANSITIONS) {
|
|
38
|
-
const requestedTypes = new Set(params.map((p) => p.type.toLowerCase()));
|
|
39
|
-
const advisors = [];
|
|
40
|
-
for (const result of results) {
|
|
41
|
-
const resultType = result.type.toLowerCase();
|
|
42
|
-
const succeeded = isFlowSuccess(result);
|
|
43
|
-
for (const t of transitions) {
|
|
44
|
-
if (t.from.toLowerCase() !== resultType)
|
|
45
|
-
continue;
|
|
46
|
-
// Check outcome condition
|
|
47
|
-
if (t.on === "success" && !succeeded)
|
|
48
|
-
continue;
|
|
49
|
-
if (t.on === "failure" && succeeded)
|
|
50
|
-
continue;
|
|
51
|
-
// Suppress if target already in the batch
|
|
52
|
-
if (requestedTypes.has(t.to.toLowerCase()))
|
|
53
|
-
continue;
|
|
54
|
-
advisors.push(t.advice);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return advisors;
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=transitions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transitions.js","sourceRoot":"","sources":["../../src/core/transitions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAiBjD,8EAA8E;AAC9E,4BAA4B;AAC5B,8EAA8E;AAE9E,MAAM,CAAC,MAAM,mBAAmB,GAAqB;IACpD,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,6GAA6G,EAAE;IACpK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,4EAA4E,EAAE;IACnI,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,2FAA2F,EAAE;IAClJ,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,oGAAoG,EAAE;IAC3J,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,oGAAoG,EAAE;IAC3J,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,8EAA8E,EAAE;IACrI,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,kGAAkG,EAAE;IACzJ,EAAE,IAAI,EAAE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C,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACzB,CAAC;IACF,CAAC;IAED,OAAO,QAAQ,CAAC;AACjB,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auto-warp pipeline for the endless loop.
|
|
3
|
-
*
|
|
4
|
-
* performWarp — distill context, create a new session, seed it.
|
|
5
|
-
* distillForWarp — shared LLM distillation logic.
|
|
6
|
-
*/
|
|
7
|
-
import type { ExtensionCommandContext } from "@mariozechner/pi-coding-agent";
|
|
8
|
-
import type { GoalEntry, LoopState } from "./types.js";
|
|
9
|
-
export interface WarpFlow {
|
|
10
|
-
type: string;
|
|
11
|
-
intent: string;
|
|
12
|
-
aim: string;
|
|
13
|
-
}
|
|
14
|
-
export interface DistillOptions {
|
|
15
|
-
signal?: AbortSignal;
|
|
16
|
-
userGoalOverride?: string;
|
|
17
|
-
}
|
|
18
|
-
export declare function distillForWarp(ctx: ExtensionCommandContext, goalEntry: GoalEntry | undefined, loop: LoopState | undefined, opts?: DistillOptions): Promise<string>;
|
|
19
|
-
export interface PerformWarpOptions {
|
|
20
|
-
reviewedPrompt?: string;
|
|
21
|
-
signal?: AbortSignal;
|
|
22
|
-
goalOverride?: string;
|
|
23
|
-
}
|
|
24
|
-
export declare function performWarp(ctx: ExtensionCommandContext, warpFlow: WarpFlow, opts?: PerformWarpOptions): Promise<{
|
|
25
|
-
success: boolean;
|
|
26
|
-
error?: string;
|
|
27
|
-
}>;
|
|
28
|
-
//# sourceMappingURL=perform-warp.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"perform-warp.d.ts","sourceRoot":"","sources":["../../src/flow/perform-warp.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAO7E,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAsB,cAAc,CAClC,GAAG,EAAE,uBAAuB,EAC5B,SAAS,EAAE,SAAS,GAAG,SAAS,EAChC,IAAI,EAAE,SAAS,GAAG,SAAS,EAC3B,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAAC,MAAM,CAAC,CAsEjB;AAED,MAAM,WAAW,kBAAkB;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAsB,WAAW,CAC/B,GAAG,EAAE,uBAAuB,EAC5B,QAAQ,EAAE,QAAQ,EAClB,IAAI,CAAC,EAAE,kBAAkB,GACxB,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAgE/C"}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auto-warp pipeline for the endless loop.
|
|
3
|
-
*
|
|
4
|
-
* performWarp — distill context, create a new session, seed it.
|
|
5
|
-
* distillForWarp — shared LLM distillation logic.
|
|
6
|
-
*/
|
|
7
|
-
import { complete } from "@mariozechner/pi-ai";
|
|
8
|
-
import { convertToLlm, serializeConversation } from "@mariozechner/pi-coding-agent";
|
|
9
|
-
import { getGoalForSession, getGoal } from "./store.js";
|
|
10
|
-
import { getLoop, recordSessionWarp, terminateLoop, setPendingWarpSessionId, clearPendingWarpSessionId } from "./loop.js";
|
|
11
|
-
import { sanitizeBranchForWarp, SYSTEM_PROMPT, extractGoalFromPrompt, MAX_CONVERSATION_CHARS } from "./warp-utils.js";
|
|
12
|
-
import { logWarn } from "../config/log.js";
|
|
13
|
-
export async function distillForWarp(ctx, goalEntry, loop, opts) {
|
|
14
|
-
const model = ctx.model ?? ctx.modelRegistry?.getAvailable()?.[0];
|
|
15
|
-
if (!model) {
|
|
16
|
-
throw new Error("No model selected. Configure a model in Pi settings first.");
|
|
17
|
-
}
|
|
18
|
-
const branch = ctx.sessionManager.getBranch();
|
|
19
|
-
if (!branch || branch.length === 0) {
|
|
20
|
-
throw new Error("Empty conversation — nothing to warp.");
|
|
21
|
-
}
|
|
22
|
-
const agentMessages = branch
|
|
23
|
-
.map((entry) => (entry.type === "message" ? entry.message : undefined))
|
|
24
|
-
.filter((m) => m != null);
|
|
25
|
-
const { messages: sanitizedMessages, passesApplied } = sanitizeBranchForWarp(agentMessages);
|
|
26
|
-
if (process.env.PI_FLOW_DUMP_SNAPSHOT) {
|
|
27
|
-
logWarn(`[warp-sanitize] passes applied: ${passesApplied.join(", ")}`);
|
|
28
|
-
}
|
|
29
|
-
const messages = convertToLlm(sanitizedMessages);
|
|
30
|
-
let conversation = serializeConversation(messages);
|
|
31
|
-
// Truncate if too large (middle truncation: keep first 20% + last 80% of max)
|
|
32
|
-
if (conversation.length > MAX_CONVERSATION_CHARS) {
|
|
33
|
-
const headChars = Math.floor(MAX_CONVERSATION_CHARS * 0.2);
|
|
34
|
-
const tailChars = Math.floor(MAX_CONVERSATION_CHARS * 0.8);
|
|
35
|
-
conversation =
|
|
36
|
-
conversation.slice(0, headChars) +
|
|
37
|
-
"\n\n[... warp context truncated from the middle ...]\n\n" +
|
|
38
|
-
conversation.slice(conversation.length - tailChars);
|
|
39
|
-
}
|
|
40
|
-
// Inject active goal context (session-guarded)
|
|
41
|
-
let preWarpContext = "";
|
|
42
|
-
if (goalEntry) {
|
|
43
|
-
preWarpContext = `\nPre-warp active goal: ${goalEntry.objective}${goalEntry.acceptance ? ` (Acceptance: ${goalEntry.acceptance})` : ""}\n`;
|
|
44
|
-
}
|
|
45
|
-
const auth = await ctx.modelRegistry.getApiKeyAndHeaders(model);
|
|
46
|
-
if (!auth.ok || !auth.apiKey) {
|
|
47
|
-
throw new Error(auth.ok ? `No API key for ${model.provider}` : (auth.error ?? "Auth error"));
|
|
48
|
-
}
|
|
49
|
-
const userContent = opts?.userGoalOverride
|
|
50
|
-
? `Conversation history:\n${conversation}\n${preWarpContext}\nUser's goal for new thread: ${opts.userGoalOverride}`
|
|
51
|
-
: `Conversation history:\n${conversation}\n${preWarpContext}`;
|
|
52
|
-
const response = await complete(model, {
|
|
53
|
-
systemPrompt: SYSTEM_PROMPT,
|
|
54
|
-
messages: [{ role: "user", content: userContent }],
|
|
55
|
-
}, { apiKey: auth.apiKey, headers: auth.headers, signal: opts?.signal });
|
|
56
|
-
if (response.stopReason === "aborted") {
|
|
57
|
-
throw new Error("Warp aborted.");
|
|
58
|
-
}
|
|
59
|
-
if (response.stopReason === "error" || response.errorMessage) {
|
|
60
|
-
throw new Error(response.errorMessage || "Unknown error");
|
|
61
|
-
}
|
|
62
|
-
return response.content
|
|
63
|
-
.filter((c) => c.type === "text")
|
|
64
|
-
.map((c) => c.text)
|
|
65
|
-
.join("\n")
|
|
66
|
-
.trim();
|
|
67
|
-
}
|
|
68
|
-
export async function performWarp(ctx, warpFlow, opts) {
|
|
69
|
-
const cwd = ctx.cwd;
|
|
70
|
-
const loop = getLoop(cwd);
|
|
71
|
-
const goal = getGoalForSession(cwd, ctx.sessionManager.getSessionId()) ?? getGoal(cwd);
|
|
72
|
-
const isLoopActive = loop?.status === "active";
|
|
73
|
-
if (isLoopActive && !goal) {
|
|
74
|
-
return { success: false, error: "No active goal to warp with." };
|
|
75
|
-
}
|
|
76
|
-
const currentSessionId = ctx.sessionManager.getSessionId();
|
|
77
|
-
if (isLoopActive) {
|
|
78
|
-
setPendingWarpSessionId(cwd, currentSessionId);
|
|
79
|
-
}
|
|
80
|
-
try {
|
|
81
|
-
let bridgeArtifact;
|
|
82
|
-
if (opts?.reviewedPrompt) {
|
|
83
|
-
bridgeArtifact = opts.reviewedPrompt;
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
bridgeArtifact = await distillForWarp(ctx, goal, loop, { signal: opts?.signal });
|
|
87
|
-
}
|
|
88
|
-
let warpedPrompt = bridgeArtifact;
|
|
89
|
-
if (isLoopActive) {
|
|
90
|
-
warpedPrompt += `\n\n[Loop: session ${loop.sessionCount}, total tokens ≈ ${loop.totalTokensAcrossSessions}]`;
|
|
91
|
-
}
|
|
92
|
-
const result = await ctx.newSession({
|
|
93
|
-
parentSession: ctx.sessionManager.getSessionFile(),
|
|
94
|
-
withSession: async (newCtx) => {
|
|
95
|
-
if (isLoopActive) {
|
|
96
|
-
recordSessionWarp(cwd);
|
|
97
|
-
}
|
|
98
|
-
newCtx.ui.notify?.("Warped to new session.", "info");
|
|
99
|
-
await newCtx.sendUserMessage(warpedPrompt);
|
|
100
|
-
const effectiveGoal = opts?.goalOverride ??
|
|
101
|
-
(isLoopActive
|
|
102
|
-
? loop.objective
|
|
103
|
-
: (extractGoalFromPrompt(warpedPrompt) || goal?.objective || "Continue the work from the warped context"));
|
|
104
|
-
newCtx.sendUserMessage(`/flow:goal set ${effectiveGoal}`);
|
|
105
|
-
},
|
|
106
|
-
});
|
|
107
|
-
if (result.cancelled) {
|
|
108
|
-
return { success: false, error: "Warp cancelled." };
|
|
109
|
-
}
|
|
110
|
-
return { success: true };
|
|
111
|
-
}
|
|
112
|
-
catch (err) {
|
|
113
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
114
|
-
// Only terminate the loop for auto-warp paths (no reviewedPrompt).
|
|
115
|
-
// Manual warps should not destroy loop state on transient errors.
|
|
116
|
-
if (isLoopActive && !opts?.reviewedPrompt) {
|
|
117
|
-
terminateLoop(cwd, "budget_exhausted");
|
|
118
|
-
}
|
|
119
|
-
return { success: false, error: message };
|
|
120
|
-
}
|
|
121
|
-
finally {
|
|
122
|
-
if (isLoopActive) {
|
|
123
|
-
clearPendingWarpSessionId(cwd);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
//# sourceMappingURL=perform-warp.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"perform-warp.js","sourceRoot":"","sources":["../../src/flow/perform-warp.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAC1H,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACtH,OAAO,EAAE,OAAO,EAAY,MAAM,kBAAkB,CAAC;AAcrD,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAA4B,EAC5B,SAAgC,EAChC,IAA2B,EAC3B,IAAqB;IAErB,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,aAAa,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAClE,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,4DAA4D,CAAC,CAAC;IAChF,CAAC;IAED,MAAM,MAAM,GAAG,GAAG,CAAC,cAAc,CAAC,SAAS,EAAE,CAAC;IAC9C,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,aAAa,GAAG,MAAM;SACzB,GAAG,CAAC,CAAC,KAAU,EAAE,EAAE,CAAC,CAAC,KA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AAC;IAC5C,CAAC;YAAS,CAAC;QACT,IAAI,YAAY,EAAE,CAAC;YACjB,yBAAyB,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* /flow:warp slash command registration.
|
|
3
|
-
*
|
|
4
|
-
* Distills conversation context and spawns a new session with the warped prompt.
|
|
5
|
-
*/
|
|
6
|
-
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
7
|
-
export declare function setupWarpCommand(pi: ExtensionAPI): void;
|
|
8
|
-
//# sourceMappingURL=warp-command.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"warp-command.d.ts","sourceRoot":"","sources":["../../src/flow/warp-command.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,YAAY,EAA2B,MAAM,+BAA+B,CAAC;AAO3F,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAmJvD"}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* /flow:warp slash command registration.
|
|
3
|
-
*
|
|
4
|
-
* Distills conversation context and spawns a new session with the warped prompt.
|
|
5
|
-
*/
|
|
6
|
-
import { DynamicScrambleText, scrambleManager } from "../tui/scramble/index.js";
|
|
7
|
-
import { getGoalForSession } from "./store.js";
|
|
8
|
-
import { getLoop } from "./loop.js";
|
|
9
|
-
import { distillForWarp, performWarp } from "./perform-warp.js";
|
|
10
|
-
export function setupWarpCommand(pi) {
|
|
11
|
-
pi.registerCommand("flow:warp", {
|
|
12
|
-
description: "Warp to a new session with distilled context. Usage: /flow:warp [goal]",
|
|
13
|
-
handler: async (args, ctx) => {
|
|
14
|
-
const DEFAULT_WARP_GOAL = "Continue where we left off — summarize what we've done, where we are, and what the natural next step is.";
|
|
15
|
-
const goal = args.trim() || DEFAULT_WARP_GOAL;
|
|
16
|
-
const cwd = ctx.cwd;
|
|
17
|
-
// Ensure a model is available
|
|
18
|
-
const model = ctx.model ?? ctx.modelRegistry?.getAvailable()?.[0];
|
|
19
|
-
if (!model) {
|
|
20
|
-
ctx.ui.notify?.("No model selected. Configure a model in Pi settings first.", "error");
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
// Gather conversation
|
|
24
|
-
const branch = ctx.sessionManager.getBranch();
|
|
25
|
-
if (!branch || branch.length === 0) {
|
|
26
|
-
ctx.ui.notify?.("Empty conversation — nothing to warp.", "error");
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
const activeGoal = getGoalForSession(cwd, ctx.sessionManager.getSessionId());
|
|
30
|
-
const loop = getLoop(cwd);
|
|
31
|
-
let warpError;
|
|
32
|
-
const distilledPrompt = await ctx.ui.custom((tui, _theme, _kb, done) => {
|
|
33
|
-
const abortController = new AbortController();
|
|
34
|
-
const id = `warp-${Date.now()}`;
|
|
35
|
-
let completed = false;
|
|
36
|
-
const RESTART_DELAY_MS = 1500;
|
|
37
|
-
class WarpingComponent {
|
|
38
|
-
scramble;
|
|
39
|
-
timer;
|
|
40
|
-
onAbort;
|
|
41
|
-
constructor() {
|
|
42
|
-
this.scramble = new DynamicScrambleText("warping...", () => {
|
|
43
|
-
const now = Date.now();
|
|
44
|
-
const result = scrambleManager.updateText(id, "warp", "warping...", now, completed);
|
|
45
|
-
return result.content;
|
|
46
|
-
});
|
|
47
|
-
this.onAbort = () => {
|
|
48
|
-
abortController.abort();
|
|
49
|
-
this.cleanup();
|
|
50
|
-
done(null);
|
|
51
|
-
};
|
|
52
|
-
this.scheduleNext();
|
|
53
|
-
}
|
|
54
|
-
scheduleNext() {
|
|
55
|
-
if (this.timer)
|
|
56
|
-
clearTimeout(this.timer);
|
|
57
|
-
if (completed)
|
|
58
|
-
return;
|
|
59
|
-
const now = Date.now();
|
|
60
|
-
const result = scrambleManager.updateText(id, "warp", "warping...", now, completed);
|
|
61
|
-
if (result.isAnimating) {
|
|
62
|
-
this.timer = setTimeout(() => {
|
|
63
|
-
this.timer = undefined;
|
|
64
|
-
tui.requestRender();
|
|
65
|
-
this.scheduleNext();
|
|
66
|
-
}, 100);
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
this.timer = setTimeout(() => {
|
|
70
|
-
this.timer = undefined;
|
|
71
|
-
if (completed)
|
|
72
|
-
return;
|
|
73
|
-
// Reset scramble state and restart animation
|
|
74
|
-
scrambleManager.completeFlow(id);
|
|
75
|
-
const restartNow = Date.now();
|
|
76
|
-
scrambleManager.updateText(id, "warp", "warping...", restartNow, false);
|
|
77
|
-
tui.requestRender();
|
|
78
|
-
this.scheduleNext();
|
|
79
|
-
}, RESTART_DELAY_MS);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
render(width) {
|
|
83
|
-
const now = Date.now();
|
|
84
|
-
const result = scrambleManager.updateText(id, "warp", "warping...", now, completed);
|
|
85
|
-
if (result.isAnimating && !this.timer && !completed) {
|
|
86
|
-
this.scheduleNext();
|
|
87
|
-
}
|
|
88
|
-
return this.scramble.render(width);
|
|
89
|
-
}
|
|
90
|
-
cleanup() {
|
|
91
|
-
if (this.timer) {
|
|
92
|
-
clearTimeout(this.timer);
|
|
93
|
-
this.timer = undefined;
|
|
94
|
-
}
|
|
95
|
-
this.scramble.invalidate();
|
|
96
|
-
scrambleManager.completeFlow(id);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
const component = new WarpingComponent();
|
|
100
|
-
distillForWarp(ctx, activeGoal, loop, { signal: abortController.signal, userGoalOverride: args.trim() || undefined })
|
|
101
|
-
.then((result) => {
|
|
102
|
-
completed = true;
|
|
103
|
-
component.cleanup();
|
|
104
|
-
done(result);
|
|
105
|
-
})
|
|
106
|
-
.catch((err) => {
|
|
107
|
-
completed = true;
|
|
108
|
-
warpError = err instanceof Error ? err.message : "Unknown error";
|
|
109
|
-
component.cleanup();
|
|
110
|
-
done(null);
|
|
111
|
-
});
|
|
112
|
-
return component;
|
|
113
|
-
});
|
|
114
|
-
if (distilledPrompt === null || distilledPrompt === undefined) {
|
|
115
|
-
if (warpError) {
|
|
116
|
-
ctx.ui.notify?.(`Warp generation failed: ${warpError}`, "error");
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
ctx.ui.notify?.("Warp cancelled.", "info");
|
|
120
|
-
}
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
let reviewedPrompt;
|
|
124
|
-
if (loop?.status !== "active") {
|
|
125
|
-
// Present for review
|
|
126
|
-
reviewedPrompt = await ctx.ui.editor("Edit warp prompt", distilledPrompt);
|
|
127
|
-
if (reviewedPrompt === undefined) {
|
|
128
|
-
ctx.ui.notify?.("Warp cancelled by user.", "info");
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
reviewedPrompt = (reviewedPrompt ?? distilledPrompt).trim();
|
|
132
|
-
}
|
|
133
|
-
const warpedPrompt = reviewedPrompt ?? distilledPrompt.trim();
|
|
134
|
-
const result = await performWarp(ctx, { type: "warp", intent: "Manual warp", aim: "Warp to fresh session" }, {
|
|
135
|
-
reviewedPrompt: warpedPrompt,
|
|
136
|
-
goalOverride: args.trim() ? goal : undefined,
|
|
137
|
-
});
|
|
138
|
-
if (!result.success) {
|
|
139
|
-
ctx.ui.notify?.(`Warp failed: ${result.error}`, "error");
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
//# sourceMappingURL=warp-command.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"warp-command.js","sourceRoot":"","sources":["../../src/flow/warp-command.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAwF,MAAM,WAAW,CAAC;AAE1H,OAAO,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qBAAqB;gBACrB,cAAc,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CAAC,kBAAkB,EAAE,eAAe,CAAC,CAAC;gBAC1E,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;oBACjC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,yBAAyB,EAAE,MAAM,CAAC,CAAC;oBACnD,OAAO;gBACT,CAAC;gBACD,cAAc,GAAG,CAAC,cAAc,IAAI,eAAe,CAAC,CAAC,IAAI,EAAE,CAAC;YAC9D,CAAC;YAED,MAAM,YAAY,GAAG,cAAc,IAAI,eAAe,CAAC,IAAI,EAAE,CAAC;YAE9D,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,uBAAuB,EAAE,EAAE;gBAC3G,cAAc,EAAE,YAAY;gBAC5B,YAAY,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS;aAC7C,CAAC,CAAC;YAEH,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBACpB,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,gBAAgB,MAAM,CAAC,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared warp utilities — sanitization, system prompt, and goal extraction.
|
|
3
|
-
*/
|
|
4
|
-
export declare const MAX_CONVERSATION_CHARS = 15000;
|
|
5
|
-
export declare function sanitizeBranchForWarp(messages: any[]): {
|
|
6
|
-
messages: any[];
|
|
7
|
-
passesApplied: string[];
|
|
8
|
-
};
|
|
9
|
-
export declare const SYSTEM_PROMPT = "You are a context transfer and execution planning assistant. Given a conversation history and the user's goal, generate a structured warp prompt that serves as a ready-to-execute project brief for a new session.\n\nYour output MUST use this exact format:\n\nFRONTMATTER (YAML between --- delimiters):\n context \u2014 1-2 sentence orientation summary\n end_goal \u2014 The finish line, not the next step\n decisions \u2014 Key choices already made (list)\n files \u2014 Files touched with what changed (list)\n open_items \u2014 Unresolved work or questions (list)\n watch_out \u2014 Edge cases, gotchas, fragile assumptions (list)\n uncertain_areas \u2014 Areas of the codebase or design that need re-assessment before proceeding (list)\n context_gathering:\n aim \u2014 What the initial scout/discovery should accomplish\n scope \u2014 Specific things to explore or map (list)\n execution_plan:\n - phase \u2014 Phase name\n parallel \u2014 true/false, can this run alongside other phases?\n group \u2014 If parallel, which execution group (A, B, C...)\n flow \u2014 Which flow type to use (scout, build, audit, craft...)\n flows \u2014 OR multiple flows if parallel within the phase\n task \u2014 Clear, actionable task for this phase\n depends_on \u2014 Phase(s) that must complete first\n produces \u2014 What \"done\" means for this phase\n success_criteria \u2014 How to know the overall work is complete (list)\n\nBODY (after the closing ---):\n A concise Task section restating the immediate next action.\n\nRULES:\n1. Always start with a context_gathering phase \u2014 the new session has no context yet, so discovery comes first.\n2. Mark phases parallel:true when they have no data dependencies on each other. Use group labels (A, B, C) to cluster parallel work.\n3. Each phase should produce a concrete artifact, evidence of completion before moving on to the next.\n4. Respect the given plan scaffold.\n5. Use flow types from: scout, build, audit, craft, debug, ideas.\n6. Success criteria should be the final state, i.e. integration test pass, code coverage with verified output, etc.\n7. If an active goal from the prior session exists, include it in the frontmatter context.\n8. Preserve unresolved blockers, open questions, or \"not done\" items from prior flow results in open_items.\n9. Flag any uncertain areas \u2014 parts of the codebase, design decisions, or assumptions that may have shifted since the conversation and need re-assessment via a scout or audit flow before committing to a plan.\n10. No tool calls, all attemps that you need to discover, note it to the watch_out list or uncertain_areas list.\n11. Your entire response must be the warp prompt starting with '---' (YAML frontmatter opening). No preamble, no explanations, no tool calls.\n\nFormat your response as a prompt the user can send to start the new thread. Be concise but include all necessary context. Do not include any preamble like \"Here is the prompt\" \u2014 just output the prompt itself.\n\nIMPORTANT: You are a text generation assistant, not an agent. Do NOT attempt tool calls, file operations, code execution, or any actions. Output ONLY the structured prompt text.";
|
|
10
|
-
export declare function extractGoalFromPrompt(prompt: string): string;
|
|
11
|
-
//# sourceMappingURL=warp-utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"warp-utils.d.ts","sourceRoot":"","sources":["../../src/flow/warp-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAWH,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAE5C,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAG;IAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,CAqGnG;AAED,eAAO,MAAM,aAAa,suGA4CwJ,CAAC;AAEnL,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAyC5D"}
|
package/dist/flow/warp-utils.js
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared warp utilities — sanitization, system prompt, and goal extraction.
|
|
3
|
-
*/
|
|
4
|
-
import { stripReasoningFromAssistantMessage } from "../snapshot/reasoning-strip.js";
|
|
5
|
-
import { stripSteeringHintFromContent, isJsonEqual, contentContainsSteeringHintTag, } from "../steering/sliding-prompt.js";
|
|
6
|
-
import { stripStrategicHintsFromContent } from "../steering/tool-utils.js";
|
|
7
|
-
export const MAX_CONVERSATION_CHARS = 15000;
|
|
8
|
-
export function sanitizeBranchForWarp(messages) {
|
|
9
|
-
const passesApplied = new Set();
|
|
10
|
-
const sanitized = [];
|
|
11
|
-
for (const message of messages) {
|
|
12
|
-
if (!message)
|
|
13
|
-
continue;
|
|
14
|
-
// Drop messages with role: 'custom' (hidden orchestrator messages that convertToLlm would promote to user)
|
|
15
|
-
if (message.role === "custom") {
|
|
16
|
-
passesApplied.add("dropCustomMessages");
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
// Drop messages with role: 'system' that contain steering hint tags
|
|
20
|
-
if (message.role === "system" && contentContainsSteeringHintTag(message.content)) {
|
|
21
|
-
passesApplied.add("dropSlidingSystemPrompts");
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
let changed = false;
|
|
25
|
-
let sanitizedMessage = message;
|
|
26
|
-
// Strip reasoning/thinking from assistant messages
|
|
27
|
-
if (message.role === "assistant" || message.role === "system" || message.role === "tool") {
|
|
28
|
-
const stripped = stripReasoningFromAssistantMessage(message);
|
|
29
|
-
if (stripped.changed) {
|
|
30
|
-
sanitizedMessage = stripped.message;
|
|
31
|
-
changed = true;
|
|
32
|
-
passesApplied.add("stripReasoning");
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
// Strip timestamp from message objects
|
|
36
|
-
if ("timestamp" in sanitizedMessage) {
|
|
37
|
-
const { timestamp, ...rest } = sanitizedMessage;
|
|
38
|
-
sanitizedMessage = rest;
|
|
39
|
-
changed = true;
|
|
40
|
-
passesApplied.add("stripTimestamps");
|
|
41
|
-
}
|
|
42
|
-
// Strip API metadata from assistant messages (keep usage but strip cost)
|
|
43
|
-
if (sanitizedMessage.role === "assistant") {
|
|
44
|
-
const { api, provider, model, stopReason, responseId, responseModel, usage, ...rest } = sanitizedMessage;
|
|
45
|
-
let stripped = false;
|
|
46
|
-
if (api !== undefined || provider !== undefined || model !== undefined ||
|
|
47
|
-
stopReason !== undefined || responseId !== undefined || responseModel !== undefined) {
|
|
48
|
-
stripped = true;
|
|
49
|
-
}
|
|
50
|
-
let cleanedUsage = usage;
|
|
51
|
-
if (usage && typeof usage === "object" && "cost" in usage) {
|
|
52
|
-
const { cost, ...usageWithoutCost } = usage;
|
|
53
|
-
cleanedUsage = usageWithoutCost;
|
|
54
|
-
stripped = true;
|
|
55
|
-
}
|
|
56
|
-
if (stripped) {
|
|
57
|
-
sanitizedMessage = { ...rest, ...(cleanedUsage !== undefined ? { usage: cleanedUsage } : {}) };
|
|
58
|
-
changed = true;
|
|
59
|
-
passesApplied.add("stripApiMetadata");
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// Strip 'details' from tool/toolResult messages
|
|
63
|
-
if (sanitizedMessage.role === "tool" || sanitizedMessage.role === "toolResult") {
|
|
64
|
-
if ("details" in sanitizedMessage) {
|
|
65
|
-
const { details, ...rest } = sanitizedMessage;
|
|
66
|
-
sanitizedMessage = rest;
|
|
67
|
-
changed = true;
|
|
68
|
-
passesApplied.add("stripDetails");
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if ("content" in sanitizedMessage) {
|
|
72
|
-
let modifiedContent = sanitizedMessage.content;
|
|
73
|
-
// Strip steering hints from message content
|
|
74
|
-
const afterSliding = stripSteeringHintFromContent(modifiedContent);
|
|
75
|
-
if (!isJsonEqual(afterSliding, modifiedContent)) {
|
|
76
|
-
modifiedContent = afterSliding;
|
|
77
|
-
changed = true;
|
|
78
|
-
passesApplied.add("stripSteeringHints");
|
|
79
|
-
}
|
|
80
|
-
// Strip strategic hints from tool result content
|
|
81
|
-
if (sanitizedMessage.role === "tool" || sanitizedMessage.role === "toolResult") {
|
|
82
|
-
const afterHints = stripStrategicHintsFromContent(modifiedContent);
|
|
83
|
-
if (!isJsonEqual(afterHints, modifiedContent)) {
|
|
84
|
-
modifiedContent = afterHints;
|
|
85
|
-
changed = true;
|
|
86
|
-
passesApplied.add("stripStrategicHints");
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
if (changed) {
|
|
90
|
-
sanitizedMessage = { ...sanitizedMessage, content: modifiedContent };
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
sanitized.push(sanitizedMessage);
|
|
94
|
-
}
|
|
95
|
-
return { messages: sanitized, passesApplied: Array.from(passesApplied) };
|
|
96
|
-
}
|
|
97
|
-
export const SYSTEM_PROMPT = `You are a context transfer and execution planning assistant. Given a conversation history and the user's goal, generate a structured warp prompt that serves as a ready-to-execute project brief for a new session.
|
|
98
|
-
|
|
99
|
-
Your output MUST use this exact format:
|
|
100
|
-
|
|
101
|
-
FRONTMATTER (YAML between --- delimiters):
|
|
102
|
-
context — 1-2 sentence orientation summary
|
|
103
|
-
end_goal — The finish line, not the next step
|
|
104
|
-
decisions — Key choices already made (list)
|
|
105
|
-
files — Files touched with what changed (list)
|
|
106
|
-
open_items — Unresolved work or questions (list)
|
|
107
|
-
watch_out — Edge cases, gotchas, fragile assumptions (list)
|
|
108
|
-
uncertain_areas — Areas of the codebase or design that need re-assessment before proceeding (list)
|
|
109
|
-
context_gathering:
|
|
110
|
-
aim — What the initial scout/discovery should accomplish
|
|
111
|
-
scope — Specific things to explore or map (list)
|
|
112
|
-
execution_plan:
|
|
113
|
-
- phase — Phase name
|
|
114
|
-
parallel — true/false, can this run alongside other phases?
|
|
115
|
-
group — If parallel, which execution group (A, B, C...)
|
|
116
|
-
flow — Which flow type to use (scout, build, audit, craft...)
|
|
117
|
-
flows — OR multiple flows if parallel within the phase
|
|
118
|
-
task — Clear, actionable task for this phase
|
|
119
|
-
depends_on — Phase(s) that must complete first
|
|
120
|
-
produces — What "done" means for this phase
|
|
121
|
-
success_criteria — How to know the overall work is complete (list)
|
|
122
|
-
|
|
123
|
-
BODY (after the closing ---):
|
|
124
|
-
A concise Task section restating the immediate next action.
|
|
125
|
-
|
|
126
|
-
RULES:
|
|
127
|
-
1. Always start with a context_gathering phase — the new session has no context yet, so discovery comes first.
|
|
128
|
-
2. Mark phases parallel:true when they have no data dependencies on each other. Use group labels (A, B, C) to cluster parallel work.
|
|
129
|
-
3. Each phase should produce a concrete artifact, evidence of completion before moving on to the next.
|
|
130
|
-
4. Respect the given plan scaffold.
|
|
131
|
-
5. Use flow types from: scout, build, audit, craft, debug, ideas.
|
|
132
|
-
6. Success criteria should be the final state, i.e. integration test pass, code coverage with verified output, etc.
|
|
133
|
-
7. If an active goal from the prior session exists, include it in the frontmatter context.
|
|
134
|
-
8. Preserve unresolved blockers, open questions, or "not done" items from prior flow results in open_items.
|
|
135
|
-
9. Flag any uncertain areas — parts of the codebase, design decisions, or assumptions that may have shifted since the conversation and need re-assessment via a scout or audit flow before committing to a plan.
|
|
136
|
-
10. No tool calls, all attemps that you need to discover, note it to the watch_out list or uncertain_areas list.
|
|
137
|
-
11. Your entire response must be the warp prompt starting with '---' (YAML frontmatter opening). No preamble, no explanations, no tool calls.
|
|
138
|
-
|
|
139
|
-
Format your response as a prompt the user can send to start the new thread. Be concise but include all necessary context. Do not include any preamble like "Here is the prompt" — just output the prompt itself.
|
|
140
|
-
|
|
141
|
-
IMPORTANT: You are a text generation assistant, not an agent. Do NOT attempt tool calls, file operations, code execution, or any actions. Output ONLY the structured prompt text.`;
|
|
142
|
-
export function extractGoalFromPrompt(prompt) {
|
|
143
|
-
const MAX_GOAL_LEN = 200;
|
|
144
|
-
// Helper: find first meaningful line and strip bullet/numbered prefixes
|
|
145
|
-
const pickFirstLine = (text) => {
|
|
146
|
-
const lines = text.split('\n');
|
|
147
|
-
for (const raw of lines) {
|
|
148
|
-
const trimmed = raw.trim();
|
|
149
|
-
if (!trimmed || trimmed.startsWith('#'))
|
|
150
|
-
continue;
|
|
151
|
-
const cleaned = trimmed.replace(/^[-*•]\s+|^\d+\.\s+/, '');
|
|
152
|
-
if (cleaned)
|
|
153
|
-
return cleaned.length > MAX_GOAL_LEN ? cleaned.slice(0, MAX_GOAL_LEN).trimEnd() : cleaned;
|
|
154
|
-
}
|
|
155
|
-
return undefined;
|
|
156
|
-
};
|
|
157
|
-
// Strategy 1: Parse end_goal from YAML frontmatter
|
|
158
|
-
const endGoalMatch = prompt.match(/^end_goal:\s*["']?(.+?)["']?\s*$/m);
|
|
159
|
-
if (endGoalMatch?.[1]) {
|
|
160
|
-
const endGoal = endGoalMatch[1].trim();
|
|
161
|
-
const contextMatch = prompt.match(/^context:\s*["']?(.+?)["']?\s*$/m);
|
|
162
|
-
if (contextMatch?.[1]) {
|
|
163
|
-
const context = contextMatch[1].trim();
|
|
164
|
-
const combined = `${endGoal}. Context: ${context}`;
|
|
165
|
-
if (combined.length <= MAX_GOAL_LEN)
|
|
166
|
-
return combined;
|
|
167
|
-
}
|
|
168
|
-
return endGoal.length > MAX_GOAL_LEN ? endGoal.slice(0, MAX_GOAL_LEN).trimEnd() : endGoal;
|
|
169
|
-
}
|
|
170
|
-
// Try to find ## Task section
|
|
171
|
-
const taskMatch = prompt.match(/##\s*Task\s*\n([\s\S]*?)(?=\n##|$)/i);
|
|
172
|
-
if (taskMatch?.[1]) {
|
|
173
|
-
const picked = pickFirstLine(taskMatch[1]);
|
|
174
|
-
if (picked)
|
|
175
|
-
return picked;
|
|
176
|
-
}
|
|
177
|
-
// Fallback: first non-empty, non-header, non-bullet line after ---
|
|
178
|
-
const bodyStart = prompt.indexOf('---', 3);
|
|
179
|
-
if (bodyStart !== -1) {
|
|
180
|
-
const body = prompt.slice(bodyStart + 3);
|
|
181
|
-
const picked = pickFirstLine(body);
|
|
182
|
-
if (picked)
|
|
183
|
-
return picked;
|
|
184
|
-
}
|
|
185
|
-
return 'Continue the work from the warped context';
|
|
186
|
-
}
|
|
187
|
-
//# sourceMappingURL=warp-utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"warp-utils.js","sourceRoot":"","sources":["../../src/flow/warp-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kCAAkC,EAAE,MAAM,gCAAgC,CAAC;AACpF,OAAO,EACL,4BAA4B,EAC5B,WAAW,EACX,8BAA8B,GAC/B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AAG3E,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAE5C,MAAM,UAAU,qBAAqB,CAAC,QAAe;IACnD,MAAM,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;IACxC,MAAM,SAAS,GAAU,EAAE,CAAC;IAE5B,KAAK,MAAM,OAAO,IAAI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AAG,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;IAC5F,CAAC;IAED,8BAA8B;IAC9B,MAAM,SAAS,GAAG,MAAM,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACtE,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACnB,MAAM,MAAM,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;IAC5B,CAAC;IACD,mEAAmE;IACnE,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;IAC3C,IAAI,SAAS,KAAK,CAAC,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;QACzC,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;QACnC,IAAI,MAAM;YAAE,OAAO,MAAM,CAAC;IAC5B,CAAC;IACD,OAAO,2CAA2C,CAAC;AACrD,CAAC"}
|
package/dist/snapshot/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/snapshot/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/snapshot/index.js
DELETED