dsh-nextsteps 1.3.2 → 1.3.3

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.
Files changed (2) hide show
  1. package/index.js +40 -16
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -124,17 +124,13 @@ const PARAMETER_SCHEMA = {
124
124
  required: ['followups']
125
125
  };
126
126
 
127
- function toolDescription(settings) {
128
- const language = LANGUAGE_NAMES[settings.lang] ?? LANGUAGE_NAMES.auto;
129
- const languageRule = settings.lang === 'auto'
130
- ? 'Write every prompt and label in the same language the conversation has been using.'
131
- : `LANGUAGE OVERRIDE, applies to this tool only: write every prompt and label in ${language} — even if the conversation or the session history is in another language. Never copy the conversation's language here.`;
127
+ function toolDescription() {
132
128
  return [
133
129
  'MANDATORY in every turn: once all real work and other tool calls are done, call this tool BEFORE writing your final answer — the answer must come after this tool returns, so the turn ends cleanly right after it. Never write your final answer before calling it.',
134
- `Suggest exactly ${settings.maxFollowups} followup prompts the user is likely to want next.`,
130
+ 'Suggest exactly the number of followup prompts stated in the nextsteps section of the system prompt.',
135
131
  'Good suggestions include alternatives to the latest implementation, related features, cleanup opportunities, tests to add, or verification steps you could run yourself; if plan steps remain, one suggestion may be continuing with the next step.',
136
132
  `Each prompt must be short (usually one sentence), goal-oriented — name the outcome, not the steps — stand alone without conversation context, and be phrased in the user's first-person voice.`,
137
- languageRule,
133
+ 'Write every prompt and label in the language the nextsteps section of the system prompt states.',
138
134
  'Never suggest actions the user would carry out themselves outside this session (e.g. "commit these changes"); judge by the tools you actually have.',
139
135
  'This never waits for an answer: its result only confirms the suggestions were recorded.',
140
136
  'Example input:',
@@ -142,12 +138,25 @@ function toolDescription(settings) {
142
138
  ].join('\n');
143
139
  }
144
140
 
141
+ function nextstepsSectionText() {
142
+ const settings = settingsLoad();
143
+ const language = LANGUAGE_NAMES[settings.lang] ?? LANGUAGE_NAMES.auto;
144
+ const languageRule = settings.lang === 'auto'
145
+ ? `Write every prompt and label in the same language the conversation has been using.`
146
+ : `LANGUAGE OVERRIDE, applies to the suggest_followups tool only: write every prompt and label in ${language} — even if the conversation or the session history is in another language. Never copy the conversation's language here.`;
147
+ return [
148
+ 'nextsteps (the followup suggestion cards):',
149
+ `- Suggest exactly ${settings.maxFollowups} followup prompts when you call suggest_followups.`,
150
+ `- ${languageRule}`
151
+ ].join('\n');
152
+ }
153
+
145
154
  const PLUGIN_REV = 'sf-2';
146
155
 
147
- function toolSpec(settings) {
156
+ function toolSpec() {
148
157
  return {
149
158
  name: TOOL_NAME,
150
- description: toolDescription(settings),
159
+ description: toolDescription(),
151
160
  parameters: PARAMETER_SCHEMA,
152
161
  output: {
153
162
  schema: { type: 'string' },
@@ -308,20 +317,35 @@ async function apply(ctx) {
308
317
  let settings = settingsLoad();
309
318
  const json = (value, status = 200) => new Response(JSON.stringify(value), { status, headers: { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' } });
310
319
  const isExternal = (next) => typeof next.model === 'string' && next.model !== '';
311
- try {
312
- if (!isExternal(settings)) ctx.tools.register(toolSpec(settings));
313
- } catch (error) {
314
- console.error('dsh-nextsteps: tool registration failed:', error);
315
- }
316
320
  const reapplyTool = (next) => {
317
321
  settings = next;
318
322
  try {
319
- if (isExternal(next)) ctx.tools.unregister(TOOL_NAME);
320
- else ctx.tools.register(toolSpec(settings));
323
+ try { ctx.tools.unregister(TOOL_NAME); } catch { /* not registered yet */ }
324
+ if (!isExternal(next)) ctx.tools.register(toolSpec());
321
325
  } catch (error) {
322
326
  console.error('dsh-nextsteps: tool re-registration failed:', error);
323
327
  }
324
328
  };
329
+ try {
330
+ if (!isExternal(settings)) ctx.tools.register(toolSpec());
331
+ } catch (error) {
332
+ console.error('dsh-nextsteps: tool registration failed:', error);
333
+ }
334
+ if (typeof ctx.inject === 'function') {
335
+ ctx.inject(['tools', 'systemPrompt'], (sub) => {
336
+ try {
337
+ try { sub.tools.unregister(TOOL_NAME); } catch { /* not registered yet */ }
338
+ if (!isExternal(settings)) sub.tools.register(toolSpec());
339
+ } catch (error) {
340
+ console.error('dsh-nextsteps: tool registration via inject failed:', error);
341
+ }
342
+ try {
343
+ sub.systemPrompt.section({ name: 'dsh-nextsteps', order: 640, interpolate: false, text: () => nextstepsSectionText() });
344
+ } catch (error) {
345
+ console.error('dsh-nextsteps: system prompt section rejected:', error);
346
+ }
347
+ });
348
+ }
325
349
  ctx.connection?.fetch?.register({
326
350
  path: '/api/dsh-nextsteps.settings',
327
351
  methods: ['GET', 'POST'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-nextsteps",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",