@pithos-kit/squiggle 0.0.0 → 0.4.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/README.md +1 -1
- package/extensions/squiggle.ts +9 -13
- package/package.json +7 -31
package/README.md
CHANGED
package/extensions/squiggle.ts
CHANGED
|
@@ -17,7 +17,10 @@ Show whether Squiggle is enabled and which correction model it uses.
|
|
|
17
17
|
Options:
|
|
18
18
|
--help, -h Show this help`;
|
|
19
19
|
|
|
20
|
-
export
|
|
20
|
+
export function registerSquiggle(
|
|
21
|
+
pi: ExtensionAPI,
|
|
22
|
+
correctPrompt: (input: string, ctx: ExtensionContext, config: SquiggleConfig) => Promise<string | null> = correctWithModel,
|
|
23
|
+
) {
|
|
21
24
|
let runtimeMode: SquiggleConfig["mode"] | undefined;
|
|
22
25
|
|
|
23
26
|
pi.on("session_start", async (_event, ctx) => {
|
|
@@ -58,25 +61,18 @@ export default function squiggle(pi: ExtensionAPI) {
|
|
|
58
61
|
if (!event.text.trim()) return { action: "continue" };
|
|
59
62
|
|
|
60
63
|
const stopIndicator = startSquiggleIndicator(ctx);
|
|
61
|
-
const corrected = await
|
|
64
|
+
const corrected = await correctPrompt(event.text, ctx, config).finally(stopIndicator);
|
|
62
65
|
if (!corrected || corrected === event.text) return { action: "continue" };
|
|
63
66
|
|
|
64
67
|
if (ctx.hasUI) ctx.ui.notify(formatColoredDiff(event.text, corrected), "info");
|
|
65
|
-
|
|
66
|
-
// In interactive mode, `transform` changes what the agent receives, but the
|
|
67
|
-
// already-submitted prompt may still be rendered as originally typed. To make
|
|
68
|
-
// the visible user message corrected too, swallow the original input and
|
|
69
|
-
// resubmit the corrected text as an extension-originated user message. The
|
|
70
|
-
// source guard above prevents a correction loop.
|
|
71
|
-
if (event.source === "interactive") {
|
|
72
|
-
pi.sendUserMessage(corrected);
|
|
73
|
-
return { action: "handled" };
|
|
74
|
-
}
|
|
75
|
-
|
|
76
68
|
return { action: "transform", text: corrected };
|
|
77
69
|
});
|
|
78
70
|
}
|
|
79
71
|
|
|
72
|
+
export default function squiggle(pi: ExtensionAPI): void {
|
|
73
|
+
registerSquiggle(pi);
|
|
74
|
+
}
|
|
75
|
+
|
|
80
76
|
function isHelpRequest(args: string): boolean {
|
|
81
77
|
const normalized = args.trim();
|
|
82
78
|
return normalized === "--help" || normalized === "-h";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pithos-kit/squiggle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Quietly polish grammar and spelling in your Pi prompts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -31,16 +31,8 @@
|
|
|
31
31
|
"summary": "Quietly polish grammar and spelling in user prompts.",
|
|
32
32
|
"minimumPi": ">=0.83.0",
|
|
33
33
|
"commands": [
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
"usage": "/squiggle [toggle|--help]",
|
|
37
|
-
"summary": "Toggle prompt correction."
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"name": "squiggle-status",
|
|
41
|
-
"usage": "/squiggle-status [--help]",
|
|
42
|
-
"summary": "Show correction status and configuration."
|
|
43
|
-
}
|
|
34
|
+
{ "name": "squiggle", "usage": "/squiggle [toggle|--help]", "summary": "Toggle prompt correction." },
|
|
35
|
+
{ "name": "squiggle-status", "usage": "/squiggle-status [--help]", "summary": "Show correction status and configuration." }
|
|
44
36
|
],
|
|
45
37
|
"tools": [],
|
|
46
38
|
"prompts": [],
|
|
@@ -48,26 +40,10 @@
|
|
|
48
40
|
"themes": [],
|
|
49
41
|
"agents": [],
|
|
50
42
|
"configuration": [
|
|
51
|
-
{
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
"kind": "environment",
|
|
58
|
-
"key": "SQUIGGLE_MODE",
|
|
59
|
-
"summary": "Override correction mode."
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
"kind": "environment",
|
|
63
|
-
"key": "SQUIGGLE_MODEL",
|
|
64
|
-
"summary": "Override the correction model."
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
"kind": "environment",
|
|
68
|
-
"key": "SQUIGGLE_MAX_CHARS",
|
|
69
|
-
"summary": "Override the maximum corrected input length."
|
|
70
|
-
}
|
|
43
|
+
{ "kind": "file", "key": ".pi/squiggle.json", "summary": "Project correction mode, model, and input limit." },
|
|
44
|
+
{ "kind": "environment", "key": "SQUIGGLE_MODE", "summary": "Override correction mode." },
|
|
45
|
+
{ "kind": "environment", "key": "SQUIGGLE_MODEL", "summary": "Override the correction model." },
|
|
46
|
+
{ "kind": "environment", "key": "SQUIGGLE_MAX_CHARS", "summary": "Override the maximum corrected input length." }
|
|
71
47
|
]
|
|
72
48
|
},
|
|
73
49
|
"pi": {
|