Steps 263-265: Phase 9e — save buffer to disk, undo/redo, integration tests
Step 263: saveBuffer/saveAllBuffers RPC methods write editBuf to disk with workspace path resolution and parent dir creation. 12/12 tests. Step 264: State-based undo/redo via HeadlessUndoStack. Snapshots recorded automatically before mutations; undo/redo restore AST + editBuf. 12/12 tests. Step 265: Phase 9e integration tests — save after undo/redo, mixed undo states across buffers, full open→mutate→diagnose→undo→redo→save. 8/8 tests. Phase 9e complete: 32/32 tests. Sprint 9 total: 244/244 across 5 phases. 34 MCP tools. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -879,6 +879,61 @@ private:
|
||||
};
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Save and undo/redo tools
|
||||
// ---------------------------------------------------------------
|
||||
void registerSaveUndoTools() {
|
||||
// whetstone_save_buffer
|
||||
tools_.push_back({"whetstone_save_buffer",
|
||||
"Save a buffer to disk. Writes the current editBuf (code "
|
||||
"regenerated from AST) to the file path. Clears the "
|
||||
"modified flag. Defaults to active buffer if no path given.",
|
||||
{{"type", "object"}, {"properties", {
|
||||
{"path", {{"type", "string"},
|
||||
{"description",
|
||||
"Buffer path to save (optional, defaults to active)"}}}
|
||||
}}}
|
||||
});
|
||||
toolHandlers_["whetstone_save_buffer"] =
|
||||
[this](const json& args) {
|
||||
return callWhetstone("saveBuffer", args);
|
||||
};
|
||||
|
||||
// whetstone_save_all_buffers
|
||||
tools_.push_back({"whetstone_save_all_buffers",
|
||||
"Save all modified buffers to disk. Skips unmodified "
|
||||
"buffers. Returns count of saved and skipped files.",
|
||||
{{"type", "object"}, {"properties", json::object()}}
|
||||
});
|
||||
toolHandlers_["whetstone_save_all_buffers"] =
|
||||
[this](const json& args) {
|
||||
return callWhetstone("saveAllBuffers", args);
|
||||
};
|
||||
|
||||
// whetstone_undo
|
||||
tools_.push_back({"whetstone_undo",
|
||||
"Undo the last mutation on the active buffer. Restores "
|
||||
"the previous AST and regenerated code from the snapshot "
|
||||
"journal. Returns the new undo/redo depths.",
|
||||
{{"type", "object"}, {"properties", json::object()}}
|
||||
});
|
||||
toolHandlers_["whetstone_undo"] =
|
||||
[this](const json& args) {
|
||||
return callWhetstone("undo", args);
|
||||
};
|
||||
|
||||
// whetstone_redo
|
||||
tools_.push_back({"whetstone_redo",
|
||||
"Redo the last undone mutation on the active buffer. "
|
||||
"Returns the new undo/redo depths.",
|
||||
{{"type", "object"}, {"properties", json::object()}}
|
||||
});
|
||||
toolHandlers_["whetstone_redo"] =
|
||||
[this](const json& args) {
|
||||
return callWhetstone("redo", args);
|
||||
};
|
||||
}
|
||||
|
||||
void registerWhetstoneTools() {
|
||||
registerASTTools();
|
||||
registerAnnotationTools();
|
||||
@@ -886,5 +941,6 @@ private:
|
||||
registerDiagnosticTools();
|
||||
registerBatchTools();
|
||||
registerProjectTools();
|
||||
registerSaveUndoTools();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user