Skip to content

Commit edb1add

Browse files
bigbansalclaude
andcommitted
style: apply Prettier to satisfy the format check
Formatting-only (whitespace/wrapping) across files touched in the recent @workspace / activity-panel / release-notes work, plus the JB chat webview. No behavior change. `pnpm format` now passes; core/vscode tests and the JetBrains build are green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BoaM7pH2oHwyzUGwLMZfMz
1 parent 37fa03a commit edb1add

14 files changed

Lines changed: 179 additions & 132 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ For human-friendly, themed highlights see [Release Notes](docs/RELEASE_NOTES.md)
4040
endpoint**, whether **Agent Mode** is on, an expandable **Tools available (N)**
4141
list, and the **@workspace** outcome (retrieved N chunks with the file hits, or
4242
the failure reason) plus pinned/retrieved counts — matching VS Code. (Tool
43-
calls actually *used* during a turn already stream inline as `🔧` lines.)
43+
calls actually _used_ during a turn already stream inline as `🔧` lines.)
4444
- **JetBrains: `@workspace` auto-builds the index on first use** (plugin 0.4.11):
4545
typing `@workspace …` when no index exists now builds it automatically before
4646
retrieving (off the EDT), instead of silently returning nothing — matching the
@@ -83,7 +83,7 @@ For human-friendly, themed highlights see [Release Notes](docs/RELEASE_NOTES.md)
8383
- **Agent tools are now visible** (VSCode): the "Context & activity" panel lists
8484
the exact tools the agent has this turn under an expandable **Tools available
8585
(N)** row (e.g. `read_file, write_file, edit_file, bash, list_dir, glob, grep,
86-
todo_write, get_diagnostics, find_symbol, find_references, search_workspace`).
86+
todo_write, get_diagnostics, find_symbol, find_references, search_workspace`).
8787
The Output → CodeSetu log also prints the tool names, not just the count.
8888

8989
---
@@ -184,14 +184,14 @@ For human-friendly, themed highlights see [Release Notes](docs/RELEASE_NOTES.md)
184184
- **On-prem Docker installer** (`deploy/docker/`): a turnkey self-hosted stack —
185185
one OpenAI-compatible server (Ollama) serving both the chat/agent model and the
186186
`@workspace` embedding model, fully inside your network. `cp .env.example .env
187-
&& docker compose up -d`, then `./print-settings.sh` emits the exact IDE
187+
&& docker compose up -d`, then `./print-settings.sh` emits the exact IDE
188188
config. Includes an air-gapped install path (save the image + model volume,
189189
restore offline), a `healthcheck.sh`, an optional GPU toggle, and a documented
190190
vLLM/TGI alternative. The IDE extensions are unchanged — they point at the
191191
endpoint.
192192
- **`@workspace` semantic indexing** (VSCode + JetBrains): build a local
193193
embeddings index of the repo (**CodeSetu: Index Workspace**) and retrieve code
194-
by *meaning*. Type `@workspace …` in chat to add the most relevant chunks to
194+
by _meaning_. Type `@workspace …` in chat to add the most relevant chunks to
195195
the turn's context, and in Agent Mode the model gets a `search_workspace` tool
196196
to retrieve on demand instead of guessing with grep/glob. Embeddings run
197197
against any OpenAI-compatible `/v1/embeddings` endpoint (VSCode:

‎apps/jetbrains/src/main/resources/webview/chat.html‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,9 @@ <h3>Try these prompts</h3>
10011001
<path d="M12 18v3" />
10021002
</svg>
10031003
</button>
1004-
<span id="version-chip" class="usage-chip" title="CodeSetu plugin version">v__VERSION__</span>
1004+
<span id="version-chip" class="usage-chip" title="CodeSetu plugin version"
1005+
>v__VERSION__</span
1006+
>
10051007
<button
10061008
id="model-chip"
10071009
class="model-chip"

‎apps/vscode/src/agentRunner.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,9 @@ export function agentToolNames(
156156
workspaceRoot: string | undefined,
157157
extraTools: AgentTool[] = [],
158158
): string[] {
159-
return [
160-
...DEFAULT_AGENT_TOOLS,
161-
...createVscodeNativeTools(workspaceRoot),
162-
...extraTools,
163-
].map((tool) => tool.name);
159+
return [...DEFAULT_AGENT_TOOLS, ...createVscodeNativeTools(workspaceRoot), ...extraTools].map(
160+
(tool) => tool.name,
161+
);
164162
}
165163

166164
/** Load the committable project agent policy from `.codesetu/agent.json`. */

‎apps/vscode/src/editCommand.ts‎

Lines changed: 107 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { applyHunks, computeHunks, getAssistantText, type DiffHunk, type LlmProvider } from "@codesetu/core";
17+
import {
18+
applyHunks,
19+
computeHunks,
20+
getAssistantText,
21+
type DiffHunk,
22+
type LlmProvider,
23+
} from "@codesetu/core";
1824
import * as vscode from "vscode";
1925

2026
import type { CodeSetuConfiguration } from "./configuration";
@@ -73,110 +79,115 @@ export function registerEditCommand(options: RegisterEditCommandOptions): vscode
7379
const command = vscode.commands.registerCommand(
7480
"codesetu.editSelection",
7581
async (presetInstruction?: unknown) => {
76-
const editor = getActiveOrLastEditor(vscode);
77-
if (editor === undefined) {
78-
void vscode.window.showWarningMessage(
79-
"CodeSetu: open a file (and optionally select code) before running Edit with CodeSetu.",
80-
);
81-
return;
82-
}
82+
const editor = getActiveOrLastEditor(vscode);
83+
if (editor === undefined) {
84+
void vscode.window.showWarningMessage(
85+
"CodeSetu: open a file (and optionally select code) before running Edit with CodeSetu.",
86+
);
87+
return;
88+
}
8389

84-
const document = editor.document;
85-
const range = editor.selection.isEmpty
86-
? fullRange(document)
87-
: new vscode.Range(editor.selection.start, editor.selection.end);
88-
const target = document.getText(range);
89-
if (target.trim().length === 0) {
90-
void vscode.window.showWarningMessage("CodeSetu: nothing to edit — the file is empty.");
91-
return;
92-
}
90+
const document = editor.document;
91+
const range = editor.selection.isEmpty
92+
? fullRange(document)
93+
: new vscode.Range(editor.selection.start, editor.selection.end);
94+
const target = document.getText(range);
95+
if (target.trim().length === 0) {
96+
void vscode.window.showWarningMessage("CodeSetu: nothing to edit — the file is empty.");
97+
return;
98+
}
9399

94-
// When invoked from the chat composer's `/edit <instruction>`, the
95-
// instruction is passed in and we skip the prompt; otherwise ask for it.
96-
const preset = typeof presetInstruction === "string" ? presetInstruction.trim() : "";
97-
const instruction =
98-
preset.length > 0
99-
? preset
100-
: await vscode.window.showInputBox({
101-
title: "Edit with CodeSetu",
102-
prompt: editor.selection.isEmpty
103-
? "Describe the change for the whole file"
104-
: "Describe the change for the selection",
105-
placeHolder: "e.g. add error handling and JSDoc",
106-
ignoreFocusOut: true,
107-
});
108-
if (instruction === undefined || instruction.trim().length === 0) {
109-
return;
110-
}
100+
// When invoked from the chat composer's `/edit <instruction>`, the
101+
// instruction is passed in and we skip the prompt; otherwise ask for it.
102+
const preset = typeof presetInstruction === "string" ? presetInstruction.trim() : "";
103+
const instruction =
104+
preset.length > 0
105+
? preset
106+
: await vscode.window.showInputBox({
107+
title: "Edit with CodeSetu",
108+
prompt: editor.selection.isEmpty
109+
? "Describe the change for the whole file"
110+
: "Describe the change for the selection",
111+
placeHolder: "e.g. add error handling and JSDoc",
112+
ignoreFocusOut: true,
113+
});
114+
if (instruction === undefined || instruction.trim().length === 0) {
115+
return;
116+
}
111117

112-
let newCode: string;
113-
try {
114-
newCode = await vscode.window.withProgress(
115-
{ location: vscode.ProgressLocation.Notification, title: "CodeSetu is editing…" },
116-
() => requestEdit(options, document.languageId, target, instruction),
117-
);
118-
} catch (error: unknown) {
119-
options.outputChannel.appendLine(`Edit failed: ${formatErrorMessage(error)}`);
120-
void vscode.window.showErrorMessage(`CodeSetu edit failed: ${formatErrorMessage(error)}`);
121-
return;
122-
}
118+
let newCode: string;
119+
try {
120+
newCode = await vscode.window.withProgress(
121+
{ location: vscode.ProgressLocation.Notification, title: "CodeSetu is editing…" },
122+
() => requestEdit(options, document.languageId, target, instruction),
123+
);
124+
} catch (error: unknown) {
125+
options.outputChannel.appendLine(`Edit failed: ${formatErrorMessage(error)}`);
126+
void vscode.window.showErrorMessage(`CodeSetu edit failed: ${formatErrorMessage(error)}`);
127+
return;
128+
}
123129

124-
if (newCode.trim().length === 0) {
125-
void vscode.window.showWarningMessage("CodeSetu returned no edit.");
126-
return;
127-
}
130+
if (newCode.trim().length === 0) {
131+
void vscode.window.showWarningMessage("CodeSetu returned no edit.");
132+
return;
133+
}
128134

129-
const proposedFull = spliceText(
130-
document.getText(),
131-
document.offsetAt(range.start),
132-
document.offsetAt(range.end),
133-
newCode,
134-
);
135+
const proposedFull = spliceText(
136+
document.getText(),
137+
document.offsetAt(range.start),
138+
document.offsetAt(range.end),
139+
newCode,
140+
);
135141

136-
counter += 1;
137-
const proposedUri = vscode.Uri.from({
138-
scheme: EDIT_SCHEME,
139-
path: `/${counter}/${baseName(document.uri)}`,
140-
});
141-
proposed.set(proposedUri, proposedFull);
142+
counter += 1;
143+
const proposedUri = vscode.Uri.from({
144+
scheme: EDIT_SCHEME,
145+
path: `/${counter}/${baseName(document.uri)}`,
146+
});
147+
proposed.set(proposedUri, proposedFull);
142148

143-
try {
144-
await vscode.commands.executeCommand(
145-
"vscode.diff",
146-
document.uri,
147-
proposedUri,
148-
`CodeSetu edit: ${baseName(document.uri)} (review)`,
149-
{ preview: true },
150-
);
149+
try {
150+
await vscode.commands.executeCommand(
151+
"vscode.diff",
152+
document.uri,
153+
proposedUri,
154+
`CodeSetu edit: ${baseName(document.uri)} (review)`,
155+
{ preview: true },
156+
);
151157

152-
const hunks = computeHunks(target, newCode);
153-
// Only offer per-hunk selection when there's more than one independent
154-
// change — a single hunk is just the all-or-nothing case.
155-
const canChooseHunks = hunks.length > 1;
156-
const actions = canChooseHunks ? ["Apply All", "Choose Hunks…", "Discard"] : ["Apply", "Discard"];
158+
const hunks = computeHunks(target, newCode);
159+
// Only offer per-hunk selection when there's more than one independent
160+
// change — a single hunk is just the all-or-nothing case.
161+
const canChooseHunks = hunks.length > 1;
162+
const actions = canChooseHunks
163+
? ["Apply All", "Choose Hunks…", "Discard"]
164+
: ["Apply", "Discard"];
157165

158-
const choice = await vscode.window.showInformationMessage(
159-
"Apply this CodeSetu edit?",
160-
{ modal: false },
161-
...actions,
162-
);
166+
const choice = await vscode.window.showInformationMessage(
167+
"Apply this CodeSetu edit?",
168+
{ modal: false },
169+
...actions,
170+
);
163171

164-
if (choice === "Apply" || choice === "Apply All") {
165-
await applyRangeEdit(document.uri, range, newCode);
166-
} else if (choice === "Choose Hunks…") {
167-
const accepted = await pickHunks(hunks);
168-
if (accepted !== undefined) {
169-
if (accepted.length === 0) {
170-
void vscode.window.showInformationMessage("CodeSetu: no hunks selected — nothing applied.");
171-
} else {
172-
await applyRangeEdit(document.uri, range, applyHunks(target, hunks, accepted));
172+
if (choice === "Apply" || choice === "Apply All") {
173+
await applyRangeEdit(document.uri, range, newCode);
174+
} else if (choice === "Choose Hunks…") {
175+
const accepted = await pickHunks(hunks);
176+
if (accepted !== undefined) {
177+
if (accepted.length === 0) {
178+
void vscode.window.showInformationMessage(
179+
"CodeSetu: no hunks selected — nothing applied.",
180+
);
181+
} else {
182+
await applyRangeEdit(document.uri, range, applyHunks(target, hunks, accepted));
183+
}
173184
}
174185
}
186+
} finally {
187+
proposed.delete(proposedUri);
175188
}
176-
} finally {
177-
proposed.delete(proposedUri);
178-
}
179-
});
189+
},
190+
);
180191

181192
return [command, providerRegistration];
182193
}
@@ -223,7 +234,10 @@ async function pickHunks(hunks: readonly DiffHunk[]): Promise<number[] | undefin
223234
function hunkPreview(hunk: DiffHunk): string {
224235
const removed = hunk.oldLines.length > 0 ? `− ${hunk.oldLines[0]!.trim()}` : "";
225236
const added = hunk.newLines.length > 0 ? `+ ${hunk.newLines[0]!.trim()}` : "";
226-
return [removed, added].filter((part) => part.length > 0).join(" ").slice(0, 120);
237+
return [removed, added]
238+
.filter((part) => part.length > 0)
239+
.join(" ")
240+
.slice(0, 120);
227241
}
228242

229243
async function requestEdit(

‎apps/vscode/src/extension.ts‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
103103
// it only refreshes an index the user already created.
104104
let reindexTimer: ReturnType<typeof setTimeout> | undefined;
105105
const autoReindexOnSave = vscode.workspace.onDidSaveTextDocument(() => {
106-
if (!vscode.workspace.getConfiguration("codesetu").get<boolean>("workspaceIndex.autoReindex", true)) {
106+
if (
107+
!vscode.workspace
108+
.getConfiguration("codesetu")
109+
.get<boolean>("workspaceIndex.autoReindex", true)
110+
) {
107111
return;
108112
}
109113
if (reindexTimer !== undefined) {
@@ -115,7 +119,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
115119
return;
116120
}
117121
try {
118-
outputChannel.appendLine(`[index] auto-reindex on save: ${await workspaceIndex.reindex()}`);
122+
outputChannel.appendLine(
123+
`[index] auto-reindex on save: ${await workspaceIndex.reindex()}`,
124+
);
119125
} catch (error) {
120126
outputChannel.appendLine(`[index] auto-reindex failed: ${formatErrorMessage(error)}`);
121127
}
@@ -198,7 +204,10 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
198204
if (folders.length === 0) {
199205
if (explicitWorkspace) {
200206
outputChannel.appendLine("[index] @workspace: no workspace folder is open.");
201-
workspaceInfo = { status: "no-folder", message: "No folder open — use File → Open Folder." };
207+
workspaceInfo = {
208+
status: "no-folder",
209+
message: "No folder open — use File → Open Folder.",
210+
};
202211
void vscode.window.showWarningMessage(
203212
"CodeSetu @workspace needs an open folder. Use File → Open Folder, then try again.",
204213
);

‎apps/vscode/src/workspaceIndex.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ export class WorkspaceIndexManager {
7575
private provider(): OpenAIEmbeddingProvider {
7676
const { baseURL, model } = this.embeddingConfig();
7777
const apiKey = this.getApiKey();
78-
return new OpenAIEmbeddingProvider({ baseURL, model, ...(apiKey === undefined ? {} : { apiKey }) });
78+
return new OpenAIEmbeddingProvider({
79+
baseURL,
80+
model,
81+
...(apiKey === undefined ? {} : { apiKey }),
82+
});
7983
}
8084

8185
/** Load the persisted index from disk (or start empty) for the current model. */
@@ -154,7 +158,9 @@ export class WorkspaceIndexManager {
154158
text: hit.text,
155159
}));
156160
} catch (error) {
157-
this.output.appendLine(`[index] retrieval failed: ${error instanceof Error ? error.message : String(error)}`);
161+
this.output.appendLine(
162+
`[index] retrieval failed: ${error instanceof Error ? error.message : String(error)}`,
163+
);
158164
return [];
159165
}
160166
}

‎deploy/docker/README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ Build the semantic index once with **CodeSetu: Index Workspace**.
4242

4343
## Configuration (`.env`)
4444

45-
| Variable | Default | Purpose |
46-
| ----------------- | -------------------- | -------------------------------------------------- |
47-
| `CODESETU_PORT` | `11434` | Host port for the OpenAI-compatible API. |
48-
| `CHAT_MODEL` | `qwen2.5-coder:7b` | Chat/agent model. **Must support tool calling** for Agent Mode. |
49-
| `EMBEDDING_MODEL` | `nomic-embed-text` | Embedding model for `@workspace` indexing. |
45+
| Variable | Default | Purpose |
46+
| ----------------- | ------------------ | --------------------------------------------------------------- |
47+
| `CODESETU_PORT` | `11434` | Host port for the OpenAI-compatible API. |
48+
| `CHAT_MODEL` | `qwen2.5-coder:7b` | Chat/agent model. **Must support tool calling** for Agent Mode. |
49+
| `EMBEDDING_MODEL` | `nomic-embed-text` | Embedding model for `@workspace` indexing. |
5050

5151
Bigger chat models (`qwen2.5-coder:14b`, `:32b`) are smarter but need more
5252
RAM/VRAM. `llama3.1:8b` is a solid general alternative.

‎docs/RELEASE_NOTES.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ aligned at the same version.
1717

1818
### 🧠 `@workspace` — semantic codebase search
1919

20-
Index your repo once and CodeSetu retrieves code by *meaning*, not just text.
20+
Index your repo once and CodeSetu retrieves code by _meaning_, not just text.
2121

2222
- Type `@workspace <question>` in chat, or let Agent Mode call the
2323
`search_workspace` tool.
2424
- **Auto-builds on first use** and **auto re-indexes a few seconds after you
2525
save** (incremental) — retrieval stays fresh with no manual step.
26-
- **Always-on retrieval** option: pull relevant code into *every* turn, not only
26+
- **Always-on retrieval** option: pull relevant code into _every_ turn, not only
2727
when you type `@workspace`.
2828
- Runs against any OpenAI-compatible embeddings endpoint (defaults to Ollama
2929
`nomic-embed-text`). The index persists under `.codesetu/`.

‎packages/core/src/retrieval/chunker.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ export function chunkFile(path: string, text: string, options: ChunkOptions = {}
3737
return [];
3838
}
3939
const maxLines = Math.max(1, Math.floor(options.maxLines ?? DEFAULT_CHUNK_MAX_LINES));
40-
const overlap = Math.max(0, Math.min(Math.floor(options.overlap ?? DEFAULT_CHUNK_OVERLAP), maxLines - 1));
40+
const overlap = Math.max(
41+
0,
42+
Math.min(Math.floor(options.overlap ?? DEFAULT_CHUNK_OVERLAP), maxLines - 1),
43+
);
4144
const step = maxLines - overlap;
4245

4346
const lines = text.split("\n");

0 commit comments

Comments
 (0)