portable-agent-layer 0.88.0 → 0.88.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/package.json
CHANGED
|
@@ -13,6 +13,7 @@ import { dueNudgeReminder } from "../lib/daily-nudge";
|
|
|
13
13
|
import { observeTurn } from "../lib/interaction";
|
|
14
14
|
import { logDebug, logError } from "../lib/log";
|
|
15
15
|
import { parkPromptContext } from "../lib/parked-context";
|
|
16
|
+
import { isSystemText } from "../lib/prompt-text";
|
|
16
17
|
import { getRepoStateReminder } from "../lib/repo-state";
|
|
17
18
|
import { runRetrieval } from "../lib/retrieval";
|
|
18
19
|
import { ensureIndex } from "../lib/retrieval-index";
|
|
@@ -81,15 +82,16 @@ export async function getPromptContext(
|
|
|
81
82
|
prompt: string,
|
|
82
83
|
sessionId?: string
|
|
83
84
|
): Promise<string | null> {
|
|
85
|
+
const userText = isSystemText(prompt) ? "" : prompt;
|
|
84
86
|
const parts = [
|
|
85
87
|
getWallClockReminder(),
|
|
86
|
-
withinBudget(() => promptRulesReminder(
|
|
88
|
+
userText && withinBudget(() => promptRulesReminder(userText, sessionId), BUDGET_MS),
|
|
87
89
|
withinBudget(() => getRepoStateReminder(), BUDGET_MS),
|
|
88
|
-
withinBudget(() => observeTurn(
|
|
90
|
+
userText && withinBudget(() => observeTurn(userText, sessionId), BUDGET_MS),
|
|
89
91
|
withinBudget(() => dueNudgeReminder(), BUDGET_MS),
|
|
90
|
-
getSteeringReminder(
|
|
91
|
-
getSkillReminder(
|
|
92
|
-
await getRetrievalReminder(
|
|
92
|
+
userText && getSteeringReminder(userText),
|
|
93
|
+
userText && getSkillReminder(userText),
|
|
94
|
+
userText && (await getRetrievalReminder(userText)),
|
|
93
95
|
].filter((p): p is string => Boolean(p));
|
|
94
96
|
|
|
95
97
|
return parts.length > 0 ? parts.join("\n\n") : null;
|
|
@@ -14,6 +14,7 @@ import { canInfer, inference } from "../lib/inference";
|
|
|
14
14
|
import { logDebug, logError } from "../lib/log";
|
|
15
15
|
import {
|
|
16
16
|
extractFallbackName,
|
|
17
|
+
labelFromModel,
|
|
17
18
|
readSessionNames,
|
|
18
19
|
writeSessionName,
|
|
19
20
|
} from "../lib/session-names";
|
|
@@ -78,18 +79,8 @@ async function upgradeWithInference(
|
|
|
78
79
|
if (result.usage) logTokenUsage("session-name", result.usage);
|
|
79
80
|
if (!result.success || !result.output) return;
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
.replace(/[.!?,;:]/g, "")
|
|
84
|
-
.trim();
|
|
85
|
-
|
|
86
|
-
const words = label.split(/\s+/).slice(0, 4);
|
|
87
|
-
label = words
|
|
88
|
-
.map((w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
|
|
89
|
-
.join(" ");
|
|
90
|
-
|
|
91
|
-
const allSubstantial = words.every((w) => w.length >= 3);
|
|
92
|
-
if (!label || words.length !== 4 || !allSubstantial) return;
|
|
82
|
+
const label = labelFromModel(result.output);
|
|
83
|
+
if (!label) return;
|
|
93
84
|
|
|
94
85
|
// Only write if name hasn't changed (re-read under guard)
|
|
95
86
|
const freshNames = readSessionNames();
|
|
@@ -220,10 +220,26 @@ export function extractFallbackName(prompt: string): string {
|
|
|
220
220
|
|
|
221
221
|
if (unique.length === 0) return "untitled session";
|
|
222
222
|
|
|
223
|
-
return unique
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
223
|
+
return unique.slice(0, 4).map(titleCase).join(" ");
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function titleCase(word: string): string {
|
|
227
|
+
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function firstLine(text: string): string {
|
|
231
|
+
return text.trim().split("\n")[0];
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export function labelFromModel(output: string): string | null {
|
|
235
|
+
const words = firstLine(output)
|
|
236
|
+
.replace(/[*_`#"']/g, "")
|
|
237
|
+
.replace(/[.!?,;:]/g, "")
|
|
238
|
+
.trim()
|
|
239
|
+
.split(/\s+/)
|
|
240
|
+
.slice(0, 4);
|
|
241
|
+
const substantial = words.length === 4 && words.every((w) => w.length >= 3);
|
|
242
|
+
return substantial ? words.map(titleCase).join(" ") : null;
|
|
227
243
|
}
|
|
228
244
|
|
|
229
245
|
function namesFilePath(): string {
|