authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-02-17 19:46:34-08:00
committergravatar for jmarminge@gmail.comJulius Marminge <jmarminge@gmail.com> 2026-02-17 19:47:09-08:00
log9e877f592bad913a5d6e9168becab35a5d78605d
tree046d338cede7fefde696be0cdebf6eba70a0824d
parentf719aea0479a3de107d50e7e6559e88df239109b

rm unused


2 files changed, 1 insertions(+), 60 deletions(-)

apps/web/src/composer-logic.test.ts+1-22
......@@ -1,11 +1,6 @@
11import { describe, expect, it } from "vitest";
22
3import {
4 buildPromptInput,
5 buildUserVisiblePrompt,
6 detectComposerTrigger,
7 replaceTextRange,
8} from "./composer-logic";
3import { detectComposerTrigger, replaceTextRange } from "./composer-logic";
94
105describe("detectComposerTrigger", () => {
116 it("detects @path trigger at cursor", () => {
......@@ -54,19 +49,3 @@ describe("replaceTextRange", () => {
5449 });
5550 });
5651});
57
58describe("tagged path prompt helpers", () => {
59 it("builds model input with tagged paths", () => {
60 const result = buildPromptInput("Fix this", ["src/app.tsx", "src/app.tsx", "README.md"]);
61 expect(result).toContain("Fix this");
62 expect(result).toContain("Referenced paths:");
63 expect(result).toContain("- src/app.tsx");
64 expect(result).toContain("- README.md");
65 expect(result).not.toContain("- src/app.tsx\n- src/app.tsx");
66 });
67
68 it("builds user-visible prompt from tags only", () => {
69 const result = buildUserVisiblePrompt(" ", ["src/app.tsx", "README.md"]);
70 expect(result).toBe("@src/app.tsx @README.md");
71 });
72});
apps/web/src/composer-logic.ts-38
......@@ -24,16 +24,6 @@ function tokenStartForCursor(text: string, cursor: number): number {
2424 return index + 1;
2525}
2626
27function dedupePaths(paths: string[]): string[] {
28 const unique = new Set<string>();
29 for (const rawPath of paths) {
30 const normalized = rawPath.trim();
31 if (!normalized) continue;
32 unique.add(normalized);
33 }
34 return [...unique];
35}
36
3727export function detectComposerTrigger(text: string, cursorInput: number): ComposerTrigger | null {
3828 const cursor = clampCursor(text, cursorInput);
3929 const lineStart = text.lastIndexOf("\n", Math.max(0, cursor - 1)) + 1;
......@@ -98,31 +88,3 @@ export function replaceTextRange(
9888 const nextText = `${text.slice(0, safeStart)}${replacement}${text.slice(safeEnd)}`;
9989 return { text: nextText, cursor: safeStart + replacement.length };
10090}
101
102export function buildPromptInput(text: string, taggedPaths: string[]): string {
103 const trimmedPrompt = text.trim();
104 const normalizedPaths = dedupePaths(taggedPaths);
105 if (normalizedPaths.length === 0) {
106 return trimmedPrompt;
107 }
108
109 const tagBlock = `Referenced paths:\n${normalizedPaths.map((entry) => `- ${entry}`).join("\n")}`;
110 if (!trimmedPrompt) {
111 return tagBlock;
112 }
113 return `${trimmedPrompt}\n\n${tagBlock}`;
114}
115
116export function buildUserVisiblePrompt(text: string, taggedPaths: string[]): string {
117 const trimmedPrompt = text.trim();
118 const normalizedPaths = dedupePaths(taggedPaths);
119 if (normalizedPaths.length === 0) {
120 return trimmedPrompt;
121 }
122
123 const tagsSummary = normalizedPaths.map((entry) => `@${entry}`).join(" ");
124 if (!trimmedPrompt) {
125 return tagsSummary;
126 }
127 return `${trimmedPrompt}\n\n${tagsSummary}`;
128}