* @brief Writes content to an 'AI/' file, replacing it atomically. */
| 607 | * @brief Writes content to an 'AI/' file, replacing it atomically. |
| 608 | */ |
| 609 | QJsonObject AI::FileSandbox::write(const QJsonObject& args) const |
| 610 | { |
| 611 | const auto resolved = resolveWrite(args.value(QStringLiteral("path")).toString()); |
| 612 | if (!resolved.ok) |
| 613 | return failure(resolved.error, resolved.hint); |
| 614 | |
| 615 | const auto payload = args.value(QStringLiteral("content")).toString().toUtf8(); |
| 616 | if (payload.size() > kMaxWriteBytes) |
| 617 | return failure(QStringLiteral("too_large"), |
| 618 | QStringLiteral("Content exceeds the 4 MB write cap; split it into parts.")); |
| 619 | |
| 620 | return writeBytes(resolved.path, payload, false, workspaceRoot()); |
| 621 | } |
| 622 | |
| 623 | /** |
| 624 | * @brief Appends content to an 'AI/' file, creating it if needed. |
no test coverage detected