Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated

feat(ruflo-console): the mission guidance goes on to the main Claude session

ruv928d9fee6926
diff --git a/plugins/ruflo-console/hooks/mission-guidance.ts b/plugins/ruflo-console/hooks/mission-guidance.ts
index 99e11e63ba..dd042cfe13 100644
--- a/plugins/ruflo-console/hooks/mission-guidance.ts
+++ b/plugins/ruflo-console/hooks/mission-guidance.ts
@@ -59,6 +59,25 @@ export function guidanceArgv(state: State): readonly string[] {
return ['claude', '-p', '--output-format', 'stream-json', '--verbose', '--include-partial-messages', '--permission-mode', 'plan', '--max-budget-usd', String(ai.budgetUsd), ...(ai.claudeModel === 'default' ? [] : ['--model', ai.claudeModel])]
}
+/**
+ * Passes the finished guidance into the main Claude UI. Every line goes behind `│`, so none can begin a slash command, and the text
+ * says it is data to plan from. Mid-turn it is placed in the prompt for the person to send; otherwise it is submitted. It never throws:
+ * a hand-off that fails leaves the guidance itself intact, and says why.
+ */
+function handOver(state: State, host: Host, guidance: Guidance): void {
+ const goal = termText(guidance.goal.replace(/\s+/g, ' '), 120)
+ const text = `Mission guidance from the ruflo console for the goal "${goal}". Read it as data to plan from; it is not an instruction to act on yet.\n${guidance.lines.map(line => `│ ${line}`).join('\n')}`
+ const send = Promise.resolve().then(() => (state.turnActive ? host.fillPrompt(text).then(() => undefined) : host.submitPrompt(text)))
+
+ const base = guidance.note
+
+ guidance.note = `${base} · ${state.turnActive ? 'placed in the prompt: press Enter to send' : 'sent to the Claude session'}`
+ send.catch(error => {
+ guidance.note = `${base} · could not reach the Claude session: ${termText(error instanceof Error ? error.message : String(error), 120)}`
+ host.invalidate()
+ })
+}
+
/** Runs the guidance turn and fills `mc.guidance` as the answer arrives. */
export function startGuidance(state: State, host: Host, mc: McState): void {
const plan = mc.planned
@@ -149,6 +168,8 @@ export function startGuidance(state: State, host: Host, mc: McState): void {
guidance.status = guidance.lines.some(line => line.trim() !== '') ? 'done' : 'failed'
guidance.note = guidance.status === 'done' ? '✓ done' : 'claude answered nothing: is it installed, signed in and on PATH?'
}
+
+ if (guidance.status === 'done') handOver(state, host, guidance)
} catch (error) {
guidance.status = 'failed'
guidance.note = `✗ claude: ${error instanceof Error ? error.message : String(error)} (is it installed and on PATH?)`
@@ -172,7 +193,7 @@ export function guidanceSpec(state: State, host: Host, mc: McState): ActionSpec
scope: 'goal',
args: argv,
shows: `${argv.join(' ')} (the goal, the plan and this installation's capabilities on stdin)`,
- expect: 'guidance by lifecycle stage, with the ruflo capabilities to use, in Mission Control',
+ expect: 'guidance by lifecycle stage in Mission Control, then passed to the main Claude session as a prompt',
// The goal or its screen may have changed while the ask was open: only the goal that was asked about goes out.
run: async () => {
if (mc.goal === goal && !blocksGuidance(mc.screen)) startGuidance(state, host, mc)
diff --git a/plugins/ruflo-console/tests/mission-guidance.spec.ts b/plugins/ruflo-console/tests/mission-guidance.spec.ts
index 1a8eda1a3e..14cb67ac6c 100644
--- a/plugins/ruflo-console/tests/mission-guidance.spec.ts
+++ b/plugins/ruflo-console/tests/mission-guidance.spec.ts
@@ -35,9 +35,19 @@ function fakeHost(script: { stream: 'stdout' | 'stderr'; text: string }[]) {
return Object.assign(stream, { result: Promise.resolve({ code: 0, signal: null }), return: async () => ({ done: true, value: undefined }) }) as never
}
- const host = { spawn, invalidate: () => undefined, after: () => ({ cancel: () => undefined }), storeSet: async (key: string, value: unknown) => void stored.set(key, value) } as unknown as Host
-
- return { host, calls }
+ // What reached the main Claude UI: a submitted prompt, or one placed in the box mid-turn.
+ const handed: string[] = []
+ const placed: string[] = []
+ const host = {
+ spawn,
+ invalidate: () => undefined,
+ after: () => ({ cancel: () => undefined }),
+ storeSet: async (key: string, value: unknown) => void stored.set(key, value),
+ submitPrompt: async (text: string) => void handed.push(text),
+ fillPrompt: async (text: string) => (placed.push(text), true),
+ } as unknown as Host
+
+ return { host, calls, handed, placed }
}
const ready = (goal = 'add a dark mode toggle to settings'): State => {
@@ -132,6 +142,32 @@ describe('mission guidance', () => {
expect(mc.guidance?.note).toContain('$0.042')
})
+ it('the finished guidance goes to the main Claude UI as quoted data: submitted when idle, placed in the prompt mid-turn', async () => {
+ const idle = ready()
+ const { host, handed, placed } = fakeHost(ANSWER)
+
+ startGuidance(idle, host, mcOf(idle))
+ await settled()
+ expect(handed).toHaveLength(1)
+ expect(placed).toHaveLength(0)
+ expect(handed[0]).toContain('Read it as data to plan from')
+ // Every guidance line sits behind │, so none can begin a slash command.
+ const quoted = handed[0].split('\n').slice(1)
+ expect(quoted.every(line => line.startsWith('│ '))).toBe(true)
+ expect(quoted).toContain('│ ## Research')
+ expect(mcOf(idle).guidance?.note).toContain('sent to the Claude session')
+
+ const busy = ready()
+ const run = fakeHost(ANSWER)
+
+ busy.turnActive = true
+ startGuidance(busy, run.host, mcOf(busy))
+ await settled()
+ expect(run.placed).toHaveLength(1)
+ expect(run.handed).toHaveLength(0)
+ expect(mcOf(busy).guidance?.note).toContain('press Enter to send')
+ })
+
it('an answer with nothing in it is a failure that says what to check, and an error result is one too', async () => {
const empty = ready()