@averyyy/pi-coding-agent 0.85.1-piclient.1 → 0.85.1-piclient.2

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.
@@ -74,9 +74,6 @@ function estimateMessagesTokens(messages) {
74
74
  // ============================================================================
75
75
  const INTRA_TURN_COMPACTION_MARKER_TYPE = "pi:intra-turn-compaction";
76
76
  const INTRA_TURN_COMPACTION_MARKER_TEXT = "Continue from the compaction summary above. The previous tool loop was compacted before the next provider request; use the summary's Operational State, file lists, failures, last command, and next steps.";
77
- const VALIDATION_HINT_MESSAGE_TYPE = "pi:validation-hint";
78
- const VALIDATION_HINT_FILE_LIMIT = 12;
79
- const VALIDATION_HINT_FAILURE_CHAR_LIMIT = 1200;
80
77
  const AUTO_SESSION_NAME_INPUT_CHAR_LIMIT = 4000;
81
78
  const AUTO_SESSION_NAME_MAX_CHARS = 80;
82
79
  const AUTO_SESSION_NAME_PROMPT = "Name this coding session from the transcript below. Return only a concise title, in the user's language when clear. No quotes, no markdown, no explanation. Do not call tools.";
@@ -86,12 +83,6 @@ function isPiServerMode() {
86
83
  function toProviderReasoning(thinkingLevel) {
87
84
  return thinkingLevel === "off" ? undefined : thinkingLevel;
88
85
  }
89
- function getStringField(input, key) {
90
- if (!input || typeof input !== "object" || Array.isArray(input))
91
- return undefined;
92
- const value = input[key];
93
- return typeof value === "string" && value.trim().length > 0 ? value : undefined;
94
- }
95
86
  function getPiServerFailurePhase(message) {
96
87
  for (const diagnostic of message.diagnostics ?? []) {
97
88
  if (diagnostic.type !== "pi_server_failure")
@@ -112,19 +103,6 @@ function getPiServerFailureRetryable(message) {
112
103
  }
113
104
  return undefined;
114
105
  }
115
- function toolTextContent(content) {
116
- return content
117
- .filter((part) => part.type === "text")
118
- .map((part) => part.text)
119
- .join("\n")
120
- .trim();
121
- }
122
- function compactValidationSummary(text) {
123
- const trimmed = text.trim();
124
- if (trimmed.length <= VALIDATION_HINT_FAILURE_CHAR_LIMIT)
125
- return trimmed;
126
- return `...${trimmed.slice(trimmed.length - VALIDATION_HINT_FAILURE_CHAR_LIMIT + 3)}`;
127
- }
128
106
  function messageTextContent(message) {
129
107
  if (!("content" in message))
130
108
  return "";
@@ -195,8 +173,6 @@ export class AgentSession {
195
173
  // Bash execution state
196
174
  _bashAbortControllers = new Set();
197
175
  _pendingBashMessages = [];
198
- _validationModifiedFiles = new Set();
199
- _validationFailure = undefined;
200
176
  // Extension system
201
177
  _extensionRunner;
202
178
  _turnIndex = 0;
@@ -320,71 +296,6 @@ export class AgentSession {
320
296
  return { model };
321
297
  }
322
298
  }
323
- _resetValidationHintState() {
324
- this._validationModifiedFiles.clear();
325
- this._validationFailure = undefined;
326
- }
327
- _recordValidationToolResult(toolName, input, content, isError) {
328
- if ((toolName === "edit" || toolName === "write") && !isError) {
329
- const path = getStringField(input, "path") ?? getStringField(input, "file_path");
330
- if (path) {
331
- this._validationModifiedFiles.add(path);
332
- }
333
- return;
334
- }
335
- if (toolName !== "bash") {
336
- return;
337
- }
338
- const command = getStringField(input, "command");
339
- if (!command) {
340
- return;
341
- }
342
- if (isError) {
343
- this._validationFailure = {
344
- command,
345
- summary: compactValidationSummary(toolTextContent(content)),
346
- };
347
- }
348
- else if (this._validationFailure?.command === command) {
349
- this._resetValidationHintState();
350
- }
351
- else if (!this._validationFailure) {
352
- this._validationModifiedFiles.clear();
353
- }
354
- }
355
- _createValidationHintMessage() {
356
- const modifiedFiles = Array.from(this._validationModifiedFiles).slice(-VALIDATION_HINT_FILE_LIMIT);
357
- if (modifiedFiles.length === 0 && !this._validationFailure) {
358
- return undefined;
359
- }
360
- const lines = ["<validation-hint>"];
361
- if (modifiedFiles.length > 0) {
362
- lines.push("Recent modified files:", ...modifiedFiles.map((file) => `- ${file}`));
363
- }
364
- if (this._validationFailure) {
365
- lines.push("Recent failed command:", this._validationFailure.command, "Failure summary:", this._validationFailure.summary || "(no output)", "Suggested next validation command:", this._validationFailure.command);
366
- }
367
- else {
368
- lines.push("Suggested next step:", "Run the smallest project validation that covers the modified files.");
369
- }
370
- lines.push("Inspect failures, fix the root cause, then rerun validation before finalizing.", "</validation-hint>");
371
- return {
372
- role: "custom",
373
- customType: VALIDATION_HINT_MESSAGE_TYPE,
374
- content: [{ type: "text", text: lines.join("\n") }],
375
- display: false,
376
- details: { modifiedFiles, failedCommand: this._validationFailure?.command },
377
- timestamp: Date.now(),
378
- };
379
- }
380
- _withValidationHint(context) {
381
- const messages = context.messages.filter((message) => !(message.role === "custom" && message.customType === VALIDATION_HINT_MESSAGE_TYPE));
382
- const hint = this._createValidationHintMessage();
383
- return {
384
- ...context,
385
- messages: hint ? [...messages, hint] : messages,
386
- };
387
- }
388
299
  /**
389
300
  * Install tool hooks once on the Agent instance.
390
301
  *
@@ -433,8 +344,6 @@ export class AgentSession {
433
344
  const normalizedContent = await normalizeToolResultImages(content, {
434
345
  autoResizeImages: this.settingsManager.getImageAutoResize(),
435
346
  });
436
- const finalIsError = hookResult?.isError ?? isError;
437
- this._recordValidationToolResult(toolCall.name, args, normalizedContent, finalIsError);
438
347
  if (!hookResult && normalizedContent === content) {
439
348
  return undefined;
440
349
  }
@@ -458,11 +367,11 @@ export class AgentSession {
458
367
  const previousContext = previousSnapshot?.context ?? nextTurn.context;
459
368
  return {
460
369
  ...previousSnapshot,
461
- context: this._withValidationHint({
370
+ context: {
462
371
  ...previousContext,
463
372
  systemPrompt: this._systemPromptOverride ?? this._baseSystemPrompt,
464
373
  tools: this.agent.state.tools.slice(),
465
- }),
374
+ },
466
375
  model: this.agent.state.model,
467
376
  thinkingLevel: this.agent.state.thinkingLevel,
468
377
  };
@@ -988,7 +897,6 @@ export class AgentSession {
988
897
  // Prompting
989
898
  // =========================================================================
990
899
  async _runAgentPrompt(messages) {
991
- this._resetValidationHintState();
992
900
  this._isAgentRunActive = true;
993
901
  try {
994
902
  await this.agent.prompt(messages);