@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.
@@ -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
- // Capture the most informative assistant message for context passing
881
- // The last message is often trivial ("Good, file created."). Find the longest
882
- // text-only assistant message instead that's usually the real analysis/plan.
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 assistantMessages = messages.filter(m => m.role === 'assistant');
885
- let bestOutput = '';
886
- let bestLength = 0;
887
- for (const msg of assistantMessages) {
888
- if (!msg.content) continue;
889
- const textParts = Array.isArray(msg.content)
890
- ? msg.content.filter((c: any) => c.type === 'text').map((c: any) => c.text)
891
- : [String(msg.content)];
892
- const combined = textParts.join('\n');
893
- if (combined.length > bestLength) {
894
- bestLength = combined.length;
895
- bestOutput = combined;
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
- // Inject previous phase output into next phase
901
- if (lastOutput && phaseQueue.length > 0) {
902
- phaseQueue[0].instruction += `\n\n**Previous phase output (summary):**\n${lastOutput}`;
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@phi-code-admin/phi-code",
3
- "version": "0.71.0",
3
+ "version": "0.71.1",
4
4
  "description": "Coding agent CLI with read, bash, edit, write tools and session management",
5
5
  "type": "module",
6
6
  "piConfig": {