MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / liveProjectStateBlock

Method liveProjectStateBlock

app/src/AI/ContextBuilder.cpp:792–815  ·  view source on GitHub ↗

* @brief Returns the current project state assembled from safe list commands. */

Source from the content-addressed store, hash-verified

790 * @brief Returns the current project state assembled from safe list commands.
791 */
792QString 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

Callers

nothing calls this directly

Calls 4

getProjectStateMethod · 0.80
toJsonMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected