pi-next-steps 1.0.0 → 1.1.0

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/CHANGELOG.md CHANGED
@@ -1,9 +1,16 @@
1
1
  # Changelog
2
2
 
3
- ## 0.1.0 — 2026-11-16
3
+ ## 1.1.0 — 2026-11-16
4
+
5
+ - Added `rewriteProseOffers` setting (default off): detects a trailing offer in the last assistant message and registers it as next steps.
6
+ - Turn-end hook for prose-offer rewrite.
7
+
8
+ ## 1.0.0 — 2026-11-16
4
9
 
5
10
  - Initial release.
6
- - `next_steps` tool with options, multi, rec, risky, subtitles.
7
- - `/ns` and `/nextsteps` commands for picking and sending.
8
- - Auto-classification of recommended/risky via the session model (best-effort).
9
- - System-prompt guidance to call `next_steps` at choice points.
11
+ - `next_steps` tool with options, multi, rec, risky, subtitles, alternates, carry.
12
+ - `/ns` and `/nextsteps` commands.
13
+ - Settings file support.
14
+ - Carry-forward queue, steer on click, alternate groups.
15
+ - Auto-classification (best-effort).
16
+ - System-prompt guidance.
package/README.md CHANGED
@@ -19,8 +19,8 @@ A Pi port of the Hermes **Next Steps** plugin, adapted for the Pi coding agent's
19
19
  ## Install
20
20
 
21
21
  ```bash
22
- pi install /absolute/path/to/pi-next-steps
23
- # or, once published:
22
+ pi install npm:pi-next-steps
23
+ # or from git:
24
24
  pi install git:github.com/apoapostolov/pi-next-steps
25
25
  ```
26
26
 
package/next-steps.ts CHANGED
@@ -27,12 +27,13 @@ interface Settings {
27
27
  carryForward: boolean;
28
28
  steerOnClick: boolean;
29
29
  accentRecommended: boolean;
30
+ rewriteProseOffers: boolean;
30
31
  }
31
32
 
32
33
  const SETTINGS_PATH = join(process.env.HOME || process.env.USERPROFILE || ".", ".pi", "agent", "next-steps.json");
33
34
 
34
35
  function loadSettings(): Settings {
35
- const defaults: Settings = { markRisky: false, carryForward: false, steerOnClick: false, accentRecommended: true };
36
+ const defaults: Settings = { markRisky: false, carryForward: false, steerOnClick: false, accentRecommended: true, rewriteProseOffers: false };
36
37
  try {
37
38
  if (existsSync(SETTINGS_PATH)) {
38
39
  const raw = JSON.parse(readFileSync(SETTINGS_PATH, "utf8"));
@@ -68,7 +69,50 @@ When a reply naturally ends with a choice or "say the word and I'll...", call th
68
69
  return { systemPrompt: sp };
69
70
  });
70
71
 
71
- pi.on("turn_end", async () => {
72
+ // Prose-offer parser: detect a trailing offer in the last assistant message.
73
+ function planOffer(text: string): string[] | null {
74
+ if (!text || !text.trim()) return null;
75
+ const TRIGGER = /(?:want me to|should i|shall i|do you want|pick one|choose one)\b/i;
76
+ const blocks = text.split("\n\n");
77
+ let last = -1;
78
+ for (let i = blocks.length - 1; i >= 0; i--) {
79
+ if (blocks[i].trim()) { last = i; break; }
80
+ }
81
+ if (last < 0) return null;
82
+ const lastBlock = blocks[last].trim();
83
+ if (!TRIGGER.test(lastBlock)) return null;
84
+ // extract bullets
85
+ const bullets: string[] = [];
86
+ for (const line of lastBlock.split("\n")) {
87
+ const m = line.match(/^[-*•]\s+(.+)$/);
88
+ if (m) bullets.push(m[1].trim());
89
+ }
90
+ if (bullets.length >= 2) return bullets.slice(0, 6);
91
+ // single sentence option
92
+ const sentence = lastBlock.replace(TRIGGER, "").trim();
93
+ if (sentence.length > 0 && sentence.length < 120) return [sentence];
94
+ return null;
95
+ }
96
+
97
+ pi.on("turn_end", async (event: any) => {
98
+ // prose-offer rewrite
99
+ if (settings.rewriteProseOffers && !state) {
100
+ try {
101
+ const msgs = event?.messages ?? [];
102
+ const lastAssistant = [...msgs].reverse().find((m: any) => m?.role === "assistant");
103
+ const text = typeof lastAssistant?.content === "string"
104
+ ? lastAssistant.content
105
+ : Array.isArray(lastAssistant?.content)
106
+ ? lastAssistant.content.map((c: any) => c?.text ?? "").join("")
107
+ : "";
108
+ const opts = planOffer(text);
109
+ if (opts && opts.length >= 2) {
110
+ state = { options: opts, multi: true, rec: "", risky: "", subtitles: [], alternates: "" };
111
+ }
112
+ } catch {
113
+ // ignore
114
+ }
115
+ }
72
116
  if (state && state.options.length > 0) {
73
117
  // age existing queue
74
118
  for (const q of queue) q.age++;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-next-steps",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Next Steps extension for the Pi coding agent",
5
5
  "type": "module",
6
6
  "main": "next-steps.ts",