@phi-code-admin/phi-code 0.71.0 → 0.71.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/extensions/phi/orchestrator.ts +48 -19
- package/package.json +1 -1
|
@@ -877,29 +877,58 @@ Tag the note with relevant keywords for vector search.`,
|
|
|
877
877
|
pi.on("agent_end", async (event, ctx) => {
|
|
878
878
|
if (!orchestrationActive || !phasePending) return;
|
|
879
879
|
|
|
880
|
-
//
|
|
881
|
-
//
|
|
882
|
-
//
|
|
880
|
+
// Build a structured summary of what happened in this phase
|
|
881
|
+
// Instead of raw LLM text, extract concrete actions: files created/modified,
|
|
882
|
+
// errors encountered, test results. This gives the next phase actionable context.
|
|
883
883
|
const messages = event.messages || [];
|
|
884
|
-
const
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
884
|
+
const filesWritten: string[] = [];
|
|
885
|
+
const filesEdited: string[] = [];
|
|
886
|
+
const errorsHit: string[] = [];
|
|
887
|
+
const testResults: string[] = [];
|
|
888
|
+
let toolCallCount = 0;
|
|
889
|
+
|
|
890
|
+
for (const msg of messages) {
|
|
891
|
+
if (msg.role === 'tool' || msg.role === 'function') {
|
|
892
|
+
toolCallCount++;
|
|
893
|
+
const content = Array.isArray(msg.content)
|
|
894
|
+
? msg.content.map((c: any) => c.text || '').join('')
|
|
895
|
+
: String(msg.content || '');
|
|
896
|
+
const name = (msg as any).name || '';
|
|
897
|
+
// Track writes
|
|
898
|
+
if (name === 'write' && content.includes('Successfully wrote')) {
|
|
899
|
+
const match = content.match(/wrote \d+ bytes to (.+)/);
|
|
900
|
+
if (match) filesWritten.push(match[1]);
|
|
901
|
+
}
|
|
902
|
+
// Track edits
|
|
903
|
+
if (name === 'edit' && !content.includes('ERR')) {
|
|
904
|
+
const match = content.match(/edited (.+)/) || content.match(/in (.+)/);
|
|
905
|
+
if (match) filesEdited.push(match[1]);
|
|
906
|
+
}
|
|
907
|
+
// Track errors
|
|
908
|
+
if (content.includes('ERR:') || content.includes('Error:') || content.includes('FAIL')) {
|
|
909
|
+
const preview = content.slice(0, 150).replace(/\n/g, ' ');
|
|
910
|
+
errorsHit.push(`${name}: ${preview}`);
|
|
911
|
+
}
|
|
912
|
+
// Track test results
|
|
913
|
+
if (content.includes('PASS') || content.includes('✅') || content.includes('✗') || content.includes('❌')) {
|
|
914
|
+
const lines = content.split('\n').filter(l => /PASS|FAIL|✅|❌|✗/.test(l));
|
|
915
|
+
testResults.push(...lines.slice(0, 10));
|
|
916
|
+
}
|
|
896
917
|
}
|
|
897
918
|
}
|
|
898
|
-
const lastOutput = bestOutput.slice(0, 4000);
|
|
899
919
|
|
|
900
|
-
//
|
|
901
|
-
|
|
902
|
-
|
|
920
|
+
// Build the summary
|
|
921
|
+
const summaryParts: string[] = [];
|
|
922
|
+
summaryParts.push(`Tool calls: ${toolCallCount}`);
|
|
923
|
+
if (filesWritten.length > 0) summaryParts.push(`Files created/written: ${filesWritten.join(', ')}`);
|
|
924
|
+
if (filesEdited.length > 0) summaryParts.push(`Files edited: ${filesEdited.join(', ')}`);
|
|
925
|
+
if (testResults.length > 0) summaryParts.push(`Test results:\n${testResults.join('\n')}`);
|
|
926
|
+
if (errorsHit.length > 0) summaryParts.push(`Errors encountered: ${errorsHit.length}\n${errorsHit.slice(0, 5).join('\n')}`);
|
|
927
|
+
const phaseSummary = summaryParts.join('\n');
|
|
928
|
+
|
|
929
|
+
// Inject structured summary into next phase
|
|
930
|
+
if (phaseSummary && phaseQueue.length > 0) {
|
|
931
|
+
phaseQueue[0].instruction += `\n\n**Previous phase summary:**\n${phaseSummary}`;
|
|
903
932
|
}
|
|
904
933
|
|
|
905
934
|
// Phase complete — chain to next
|