mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-29 12:11:09 +00:00
feat(core): add plan file persistence to disk
Save approved plans to ~/.qwen/plans/{sessionId}.md so they can be
referenced later in the session or reviewed outside the CLI.
Changes:
- Storage: add getPlansDir() and getPlanFilePath()
- Config: add savePlan(), loadPlan(), getPlanFilePath() methods
- ExitPlanModeTool: persist plan to disk when user approves
- Tests: 4 new Config tests, 2 new ExitPlanModeTool assertions
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
c597847bc3
commit
b8e81c02b4
5 changed files with 106 additions and 0 deletions
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
// Node built-ins
|
||||
import type { EventEmitter } from 'node:events';
|
||||
import * as fs from 'node:fs';
|
||||
import * as path from 'node:path';
|
||||
import process from 'node:process';
|
||||
|
||||
|
|
@ -1665,6 +1666,35 @@ export class Config {
|
|||
this.approvalMode = mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the file path for this session's plan file.
|
||||
*/
|
||||
getPlanFilePath(): string {
|
||||
return Storage.getPlanFilePath(this.sessionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a plan to disk for the current session.
|
||||
*/
|
||||
savePlan(plan: string): void {
|
||||
const filePath = this.getPlanFilePath();
|
||||
const dir = path.dirname(filePath);
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
fs.writeFileSync(filePath, plan, 'utf-8');
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the plan for the current session, or returns undefined if none exists.
|
||||
*/
|
||||
loadPlan(): string | undefined {
|
||||
const filePath = this.getPlanFilePath();
|
||||
try {
|
||||
return fs.readFileSync(filePath, 'utf-8');
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
getInputFormat(): 'text' | 'stream-json' {
|
||||
return this.inputFormat;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue