@juicesharp/rpiv-advisor 1.5.0 → 1.5.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.
- package/advisor.ts +35 -5
- package/package.json +1 -1
package/advisor.ts
CHANGED
|
@@ -91,9 +91,15 @@ const msgConsulting = (label: string, effort: ThinkingLevel | undefined) =>
|
|
|
91
91
|
// Config file persistence (cross-session)
|
|
92
92
|
// ---------------------------------------------------------------------------
|
|
93
93
|
|
|
94
|
+
interface GuidanceFields {
|
|
95
|
+
promptSnippet?: string;
|
|
96
|
+
promptGuidelines?: string[];
|
|
97
|
+
}
|
|
98
|
+
|
|
94
99
|
interface AdvisorConfig {
|
|
95
100
|
modelKey?: string;
|
|
96
101
|
effort?: ThinkingLevel;
|
|
102
|
+
guidance?: GuidanceFields;
|
|
97
103
|
}
|
|
98
104
|
|
|
99
105
|
export function loadAdvisorConfig(): AdvisorConfig {
|
|
@@ -105,10 +111,33 @@ export function loadAdvisorConfig(): AdvisorConfig {
|
|
|
105
111
|
}
|
|
106
112
|
}
|
|
107
113
|
|
|
114
|
+
function validateGuidanceFields(fields: unknown): GuidanceFields {
|
|
115
|
+
if (!fields || typeof fields !== "object") return {};
|
|
116
|
+
const g = fields as Record<string, unknown>;
|
|
117
|
+
const result: GuidanceFields = {};
|
|
118
|
+
if (typeof g.promptSnippet === "string" && g.promptSnippet.length > 0) {
|
|
119
|
+
result.promptSnippet = g.promptSnippet;
|
|
120
|
+
}
|
|
121
|
+
if (
|
|
122
|
+
Array.isArray(g.promptGuidelines) &&
|
|
123
|
+
g.promptGuidelines.length > 0 &&
|
|
124
|
+
g.promptGuidelines.every((s) => typeof s === "string" && s.length > 0)
|
|
125
|
+
) {
|
|
126
|
+
result.promptGuidelines = g.promptGuidelines;
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
|
|
108
131
|
export function saveAdvisorConfig(key: string | undefined, effort: ThinkingLevel | undefined): void {
|
|
109
|
-
const
|
|
132
|
+
const existing = loadAdvisorConfig();
|
|
133
|
+
const config: AdvisorConfig = { ...existing };
|
|
134
|
+
// Delete (rather than omit) to clear fields that may exist in the spread
|
|
135
|
+
// from a prior read. JSON.parse always produces configurable properties,
|
|
136
|
+
// so delete is safe in strict mode.
|
|
110
137
|
if (key) config.modelKey = key;
|
|
138
|
+
else delete config.modelKey;
|
|
111
139
|
if (effort) config.effort = effort;
|
|
140
|
+
else delete config.effort;
|
|
112
141
|
try {
|
|
113
142
|
mkdirSync(dirname(ADVISOR_CONFIG_PATH), { recursive: true });
|
|
114
143
|
writeFileSync(ADVISOR_CONFIG_PATH, `${JSON.stringify(config, null, 2)}\n`, "utf-8");
|
|
@@ -447,10 +476,10 @@ const ADVISOR_DESCRIPTION =
|
|
|
447
476
|
"your entire conversation history is automatically forwarded. The advisor " +
|
|
448
477
|
"sees the task, every tool call you've made, every result you've seen.";
|
|
449
478
|
|
|
450
|
-
const
|
|
479
|
+
export const DEFAULT_PROMPT_SNIPPET =
|
|
451
480
|
"Escalate to a stronger reviewer model for guidance when stuck, before substantive work, or before declaring done";
|
|
452
481
|
|
|
453
|
-
const
|
|
482
|
+
export const DEFAULT_PROMPT_GUIDELINES: string[] = [
|
|
454
483
|
"Call `advisor` BEFORE substantive work — before writing, before committing to an interpretation, before building on an assumption. Orientation (finding files, fetching a source, seeing what's there) is not substantive work; writing, editing, and declaring an answer are.",
|
|
455
484
|
"Also call `advisor` when you believe the task is complete. BEFORE this call, make your deliverable durable: write the file, save the result, commit the change. The advisor call takes time; if the session ends during it, a durable result persists and an unwritten one doesn't.",
|
|
456
485
|
"Also call `advisor` when stuck — errors recurring, approach not converging, results that don't fit — or when considering a change of approach.",
|
|
@@ -460,12 +489,13 @@ const ADVISOR_PROMPT_GUIDELINES: string[] = [
|
|
|
460
489
|
];
|
|
461
490
|
|
|
462
491
|
export function registerAdvisorTool(pi: ExtensionAPI): void {
|
|
492
|
+
const guidance = validateGuidanceFields(loadAdvisorConfig().guidance);
|
|
463
493
|
pi.registerTool({
|
|
464
494
|
name: ADVISOR_TOOL_NAME,
|
|
465
495
|
label: TOOL_LABEL,
|
|
466
496
|
description: ADVISOR_DESCRIPTION,
|
|
467
|
-
promptSnippet:
|
|
468
|
-
promptGuidelines:
|
|
497
|
+
promptSnippet: guidance.promptSnippet ?? DEFAULT_PROMPT_SNIPPET,
|
|
498
|
+
promptGuidelines: guidance.promptGuidelines ?? DEFAULT_PROMPT_GUIDELINES,
|
|
469
499
|
parameters: AdvisorParams,
|
|
470
500
|
|
|
471
501
|
async execute(_toolCallId, _params, signal, onUpdate, ctx) {
|