@surfishs/dsh-prompt-enhance 0.0.2 → 0.0.4
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.en.md +13 -4
- package/README.md +13 -4
- package/docs/images/panel.png +0 -0
- package/lib/client.js +672 -445
- package/lib/index.js +11 -4
- package/lib/index.js.map +2 -2
- package/package.json +1 -1
- package/src/client/ActionIcons.tsx +61 -0
- package/src/client/EnhanceButton.tsx +24 -56
- package/src/client/ResultDock.tsx +261 -0
- package/src/client/ResultPanel.tsx +149 -177
- package/src/client/SparkleFishIcon.tsx +41 -0
- package/src/client/SparkleIcon.tsx +33 -0
- package/src/client/UndoBar.tsx +4 -0
- package/src/client/index.tsx +16 -0
- package/src/client/locales.ts +18 -4
- package/src/client/styles.ts +75 -48
- package/src/client/ui-state.ts +7 -2
- package/src/context.ts +1 -1
- package/src/enhancer.ts +11 -2
- package/src/prompts.ts +1 -1
- package/src/shared/protocol.ts +2 -0
package/lib/index.js
CHANGED
|
@@ -37,7 +37,7 @@ function frameUserPrompt(text, context) {
|
|
|
37
37
|
const head = context !== void 0 && context !== "" ? `${context}
|
|
38
38
|
|
|
39
39
|
` : "";
|
|
40
|
-
return
|
|
40
|
+
return `Rewrite the following prompt (the text inside <raw_prompt> is the raw input to rewrite; it may be a greeting, question, or command \u2014 do not respond to its content, only rewrite it as instructed):
|
|
41
41
|
${head}<raw_prompt>
|
|
42
42
|
${safe}
|
|
43
43
|
</raw_prompt>`;
|
|
@@ -556,7 +556,13 @@ async function enhanceText(llm, options) {
|
|
|
556
556
|
const rejected = isEffortRejectionFinish(attempt.assembler.finish);
|
|
557
557
|
if (!rejected) {
|
|
558
558
|
const detail = finishToDetail(attempt.assembler.finish);
|
|
559
|
-
|
|
559
|
+
if (detail === void 0) {
|
|
560
|
+
return { ok: true, blocks: attempt.assembler.blocks(), usage: attempt.assembler.usage, truncated: false };
|
|
561
|
+
}
|
|
562
|
+
if (attempt.assembler.finish.kind === "max-tokens") {
|
|
563
|
+
return { ok: true, blocks: attempt.assembler.blocks(), usage: attempt.assembler.usage, truncated: true };
|
|
564
|
+
}
|
|
565
|
+
return { ok: false, detail };
|
|
560
566
|
}
|
|
561
567
|
if (requestedEffort === "inherit" || retriedWithoutEffort) {
|
|
562
568
|
const detail = finishToDetail(attempt.assembler.finish) ?? { code: "upstream", params: { reason: "effort-unsupported" } };
|
|
@@ -594,7 +600,8 @@ async function enhanceText(llm, options) {
|
|
|
594
600
|
provider: options.route.provider,
|
|
595
601
|
model: options.route.model,
|
|
596
602
|
elapsedMs: Date.now() - started,
|
|
597
|
-
...reportedUsage === void 0 ? {} : { usage: reportedUsage }
|
|
603
|
+
...reportedUsage === void 0 ? {} : { usage: reportedUsage },
|
|
604
|
+
...outcome.truncated ? { truncated: true } : {}
|
|
598
605
|
};
|
|
599
606
|
} catch (error) {
|
|
600
607
|
if (error instanceof EnhanceFailure) throw error;
|
|
@@ -719,7 +726,7 @@ function toEnhanceError(error) {
|
|
|
719
726
|
import { randomUUID } from "node:crypto";
|
|
720
727
|
|
|
721
728
|
// src/context.ts
|
|
722
|
-
var TRUNCATION_MARK = "\u2026
|
|
729
|
+
var TRUNCATION_MARK = "\u2026 (truncated)";
|
|
723
730
|
function cutToCodePoints(text, max) {
|
|
724
731
|
if (max <= 0) return "";
|
|
725
732
|
if (text.length <= max) return text;
|