Class AbstractTextResourceWrite
java.lang.Object
uno.anahata.asi.toolkit.resources.text.AbstractTextResourceWrite
- Direct Known Subclasses:
CodeRefinementBatch, CodeRefinementBatchPolymorphic, FullTextResourceUpdate, TextResourceLineEdits, TextResourceReplacements
Base DTO for text file operations, providing common fields for path,
historical content preservation, and optimistic locking.
- Author:
- anahata
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longOptimistic locking: the expected last modified timestamp of the file on disk.protected StringA manual override of the resulting content.protected StringThe original content of the file before this operation was applied.protected StringThe name of the resource at the time of capture.protected StringThe absolute path to the file to be updated.protected StringThe final content of the file after the operation was successfully applied. -
Constructor Summary
ConstructorsConstructorDescriptionAbstractTextResourceWrite(String uuid, long lastModified) Minimal constructor for standard tool invocation and builder support. -
Method Summary
Modifier and TypeMethodDescriptionfinal StringCalculates the resulting content of the resource based on the capturedoriginalContent.voidAuthoritatively captures the current state of the resource from the resource manager.protected abstract StringPerforms the actual, tool-specific calculation of the resulting content.getUnifiedDiff(Agi agi) Generates a unified diff of the proposed changes against the captured original content.voidPerforms pre-flight validation of the update operation.protected voidValidates that the resulting content is not identical to the original.protected voidValidates the basic structural requirements and optimistic locking.
-
Field Details
-
resourceUuid
The absolute path to the file to be updated. -
lastModified
protected long lastModifiedOptimistic locking: the expected last modified timestamp of the file on disk. -
originalContent
The original content of the file before this operation was applied. This is captured during the first render to support historical diff views. -
originalResourceName
The name of the resource at the time of capture. -
resultingContent
The final content of the file after the operation was successfully applied. Captured during execution to support static historical diff views. -
manualOverride
A manual override of the resulting content. If provided, the standard calculation logic is bypassed.
-
-
Constructor Details
-
AbstractTextResourceWrite
Minimal constructor for standard tool invocation and builder support.- Parameters:
uuid- The resource uuid.lastModified- The locking timestamp.
-
-
Method Details
-
captureOriginalContent
Authoritatively captures the current state of the resource from the resource manager. This is the mandatory first step before validation, calculation, or diffing.- Parameters:
agi- The parent agi session.- Throws:
Exception- if the resource cannot be resolved or is not textual.
-
calculateResultingContent
Calculates the resulting content of the resource based on the capturedoriginalContent.This base implementation handles the primary short-circuits: 1. If resultingContent is set (Historical view), it is returned. 2. If manualOverride is set (User tweak), it is returned. 3. Otherwise, it delegates to
doCalculateResultingContent(Agi)for tool-specific logic.- Parameters:
agi- The parent agi session.- Returns:
- The resulting content.
- Throws:
Exception- if the calculation fails or original content is missing.
-
doCalculateResultingContent
Performs the actual, tool-specific calculation of the resulting content.- Parameters:
agi- The parent agi session.- Returns:
- The calculated resulting content as a String.
- Throws:
Exception- if the calculation logic fails.
-
getUnifiedDiff
-
validate
-
validateStructuralState
-
validateIdenticalContent
-

