* @brief Returns the current project state assembled from safe list commands. */
| 790 | * @brief Returns the current project state assembled from safe list commands. |
| 791 | */ |
| 792 | QString AI::ContextBuilder::liveProjectStateBlock() |
| 793 | { |
| 794 | static constexpr int kMaxStateBytes = 24 * 1024; |
| 795 | |
| 796 | ToolDispatcher dispatcher; |
| 797 | const auto state = dispatcher.getProjectState(); |
| 798 | const auto scrubbed = AI::Redactor::scrubObject(state); |
| 799 | auto pretty = QJsonDocument(scrubbed).toJson(QJsonDocument::Indented); |
| 800 | |
| 801 | QString tail; |
| 802 | if (pretty.size() > kMaxStateBytes) { |
| 803 | pretty.truncate(kMaxStateBytes); |
| 804 | tail = QStringLiteral("\n... [project state truncated to fit the model context; ask for " |
| 805 | "specific items via list commands]\n"); |
| 806 | } |
| 807 | |
| 808 | QString out; |
| 809 | out += QStringLiteral("# Current project state\n\n"); |
| 810 | out += QStringLiteral("<untrusted source=\"project_state\">\n"); |
| 811 | out += neutralizeUntrustedDelimiter(QString::fromUtf8(pretty)); |
| 812 | out += tail; |
| 813 | out += QStringLiteral("\n</untrusted>\n"); |
| 814 | return out; |
| 815 | } |
| 816 | |
| 817 | //-------------------------------------------------------------------------------------------------- |
| 818 | // Composer |
nothing calls this directly
no test coverage detected