Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f258d21

Browse files
authored
Merge pull request #3 from mnismt/chore/add-docs-and-inspiration
2 parents b8976a6 + e07bd03 commit f258d21

5 files changed

Lines changed: 21 additions & 123 deletions

File tree

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
A concise VS Code extension to build high‑quality XML prompts from selected workspace files and apply LLM‑suggested changes back to your code.
88

99
<p align="center">
10-
<img src="https://github.com/user-attachments/assets/9701b7a7-5f39-4961-81ae-24d0b2d75157" alt="Overwrite extension interface showing the Context tab with file explorer, selected files, token counts, and copy buttons" width="800" />
10+
<img src="resources/screenshot-1.jpg" alt="Overwrite extension interface showing the Context tab with file explorer, selected files, token counts, and copy buttons" width="800" />
1111
</p>
1212

1313
## Features
@@ -26,7 +26,7 @@ A concise VS Code extension to build high‑quality XML prompts from selected wo
2626
- Privacy-preserving telemetry controls.
2727

2828
<p align="center">
29-
<img src="https://github.com/user-attachments/assets/b80f2319-19bb-43cd-9c10-4b15fe1ef4a6" alt="Overwrite extension interface showing the Context tab with file explorer, selected files, token counts, and copy buttons" width="800" />
29+
<img src="resources/screenshot-4.jpg" alt="Overwrite extension interface showing the Context tab with file explorer, selected files, token counts, and copy buttons" width="800" />
3030
</p>
3131

3232
## How to use
@@ -49,3 +49,7 @@ For complete details, see [TELEMETRY.md](TELEMETRY.md).
4949
## Requirements
5050

5151
- VS Code 1.85.0+
52+
53+
## Acknowledgments
54+
55+
This project is heavily inspired by [RepoPrompt](https://repoprompt.com/) by @provencher.

resources/screenshot-1.jpg

-57.7 KB
Loading

resources/screenshot-4.jpg

147 KB
Loading

src/providers/file-explorer/html-generator.ts

Lines changed: 1 addition & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import * as fs from 'node:fs'
2-
import * as path from 'node:path'
31
import * as vscode from 'vscode'
42
import { getNonce } from '../../utils/webview'
53

64
const DEV_WEBVIEW_URL = 'http://localhost:5173'
7-
const DEV_TIMEOUT = 3000 // 3 seconds timeout for dev server connection
85

96
/**
107
* Generates the HTML content for the webview, choosing between dev and prod.
@@ -26,14 +23,6 @@ export function getHtmlForWebview(
2623
function getDevHtml(webview: vscode.Webview, extensionUri: vscode.Uri): string {
2724
const nonce = getNonce()
2825

29-
// Check if we have built webview assets for fallback
30-
const webviewAssetsDir = vscode.Uri.joinPath(
31-
extensionUri,
32-
'dist',
33-
'webview-ui',
34-
)
35-
const hasBuiltAssets = checkIfAssetsExist(webviewAssetsDir)
36-
3726
// Path to codicons from the extension's node_modules
3827
const codiconUri = webview.asWebviewUri(
3928
vscode.Uri.joinPath(
@@ -46,116 +35,10 @@ function getDevHtml(webview: vscode.Webview, extensionUri: vscode.Uri): string {
4635
),
4736
)
4837

49-
if (hasBuiltAssets) {
50-
// Use built assets with development features
51-
return getDevHtmlWithBuiltAssets(webview, extensionUri, nonce, codiconUri)
52-
}
53-
54-
// Use dev server (original behavior)
38+
// Use dev server (original behavior) - prefer dev server for development
5539
return getDevHtmlWithServer(webview, extensionUri, nonce, codiconUri)
5640
}
5741

58-
/**
59-
* Check if built webview assets exist and are valid.
60-
*/
61-
function checkIfAssetsExist(assetsDir: vscode.Uri): boolean {
62-
try {
63-
const assetsPath = assetsDir.fsPath
64-
65-
// Check if directory exists
66-
if (!fs.existsSync(assetsPath)) {
67-
return false
68-
}
69-
70-
// Check for required files
71-
const requiredFiles = [
72-
path.join(assetsPath, 'assets', 'index.js'),
73-
path.join(assetsPath, 'assets', 'index.css'),
74-
path.join(assetsPath, 'assets', 'codicon.css'),
75-
]
76-
77-
return requiredFiles.every((file) => fs.existsSync(file))
78-
} catch {
79-
return false
80-
}
81-
}
82-
83-
/**
84-
* Development HTML using built assets with hot reload capabilities.
85-
*/
86-
function getDevHtmlWithBuiltAssets(
87-
webview: vscode.Webview,
88-
extensionUri: vscode.Uri,
89-
nonce: string,
90-
codiconUri: vscode.Uri,
91-
): string {
92-
const cspSource = webview.cspSource
93-
94-
// Paths to built assets
95-
const scriptUri = webview.asWebviewUri(
96-
vscode.Uri.joinPath(
97-
extensionUri,
98-
'dist',
99-
'webview-ui',
100-
'assets',
101-
'index.js',
102-
),
103-
)
104-
const styleUri = webview.asWebviewUri(
105-
vscode.Uri.joinPath(
106-
extensionUri,
107-
'dist',
108-
'webview-ui',
109-
'assets',
110-
'index.css',
111-
),
112-
)
113-
114-
// CSP for development with built assets
115-
const csp = [
116-
`default-src 'none'`,
117-
`font-src ${cspSource} data:`,
118-
`connect-src ws://localhost:5173 ${cspSource}`, // Allow WebSocket for HMR
119-
`img-src ${cspSource} https: data:`,
120-
`script-src 'nonce-${nonce}' 'unsafe-eval' 'unsafe-inline'`, // Allow eval for HMR
121-
`style-src ${cspSource} 'unsafe-inline'`,
122-
].join('; ')
123-
124-
return `<!DOCTYPE html>
125-
<html lang="en">
126-
<head>
127-
<meta charset="UTF-8">
128-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
129-
<link href="${codiconUri}" rel="stylesheet" id="vscode-codicon-stylesheet" />
130-
<meta http-equiv="Content-Security-Policy" content="${csp}">
131-
<link rel="stylesheet" type="text/css" href="${styleUri}">
132-
<title>Overwrite (Dev)</title>
133-
</head>
134-
<body>
135-
<div id="root"></div>
136-
<script type="module" nonce="${nonce}" src="${scriptUri}"></script>
137-
<script nonce="${nonce}">
138-
// Pass vscode API and nonce to the webview
139-
window.nonce = "${nonce}"
140-
window.vscodeApi = acquireVsCodeApi()
141-
142-
// Attempt to connect to Vite dev server for HMR
143-
setTimeout(() => {
144-
try {
145-
const script = document.createElement('script')
146-
script.type = 'module'
147-
script.src = '${DEV_WEBVIEW_URL}/@vite/client'
148-
document.head.appendChild(script)
149-
console.log('[HMR] Attempting to connect to Vite dev server...')
150-
} catch (err) {
151-
console.log('[HMR] Could not connect to Vite dev server, using built assets')
152-
}
153-
}, ${DEV_TIMEOUT})
154-
</script>
155-
</body>
156-
</html>`
157-
}
158-
15942
/**
16043
* Development HTML using Vite dev server (original behavior).
16144
*/

src/webview-ui/src/components/context-tab/user-instructions.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,20 @@ const UserInstructions: React.FC<UserInstructionsProps> = ({
99
}) => {
1010
return (
1111
<div className="flex flex-col">
12-
<vscode-label htmlFor="user-instructions" className="block mb-1">
13-
User Instruction
14-
</vscode-label>
12+
<div className="flex items-center justify-between mb-1">
13+
<vscode-label htmlFor="user-instructions">
14+
User Instruction
15+
</vscode-label>
16+
<a
17+
className="text-[8px] text-muted hover:underline hover:text-fg flex items-center gap-1"
18+
href="https://mnismt.com/overwrite"
19+
target="_blank"
20+
rel="noreferrer"
21+
aria-label="Open Overwrite docs and video demo in your browser"
22+
>
23+
<span>Docs</span>
24+
</a>
25+
</div>
1526
<vscode-textarea
1627
id="user-instructions"
1728
resize="vertical"

0 commit comments

Comments
 (0)