Skip to content

Commit e2fa057

Browse files
wherka-amaWaldek Herka
andauthored
fix(sync): handle copied files cleanup in WSL/Remote environments (#39)
* fix(sync): handle copied files cleanup in WSL/Remote environments - Fixes issue where agents persisted after profile switching in WSL - Updates unsyncBundle to safely delete copied files if content matches source - Handles line ending normalization for cross-platform compatibility - Adds regression tests * fix(arch): align extension execution with UI side and cleanup legacy code - Set extensionKind to ['ui', 'workspace'] to run on Host (fixes WSL/SSH path issues) - Refactor file operations to use vscode.workspace.fs for remote compatibility - Remove legacy uninstall commands and 'Prompt Registry Uninstall' output channel - Fix quick-check script to compile tests before running * test: add remote ssh testing infrastructure Introduce Docker-based environment for validating remote SSH scenarios. Includes Dockerfile, management scripts, and usage documentation. * feat(auth): add command to force GitHub authentication refresh Implements promptregistry.forceGitHubAuth command to handle token expiration or account switching by clearing internal adapter cache and forcing a new VS Code authentication session. - Adds forceAuthentication to IRepositoryAdapter - Implements cache clearing in AwesomeCopilotAdapter - Adds RegistryManager.forceAuthentication to propagate request - Registers new command in extension and package.json * fix(package): exclude git and docker files from vsix * fix(auth): remove incompatible createIfNone option when using forceNewSession --------- Co-authored-by: Waldek Herka <waldek.herka@no.reply>
1 parent 3bb7551 commit e2fa057

27 files changed

+856
-2637
lines changed

.github/workflows/scripts/quick-check.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ npm run lint
1414
echo "▶ Compiling..."
1515
npm run compile
1616

17-
# 3. Unit tests only
17+
# 3. Compile Tests
18+
echo "▶ Compiling tests..."
19+
npm run compile-tests
20+
21+
# 4. Unit tests only
1822
echo "▶ Unit tests..."
1923
npm run test:unit
2024

.vscodeignore.production

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,16 @@ secrets.json
113113
*.rar
114114
*.vsix
115115

116+
# Version control
117+
.gitignore
118+
.gitattributes
119+
.git/
120+
121+
# Docker
122+
Dockerfile*
123+
docker-compose*
124+
.dockerignore
125+
116126
# Integration test files
117127
INTEGRATION_TEST_*.md
118128

Dockerfile.ssh-test

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
FROM ubuntu:22.04
2+
3+
# Disable IPv6 to avoid connection issues
4+
RUN echo 'Acquire::ForceIPv4 "true";' > /etc/apt/apt.conf.d/99force-ipv4
5+
6+
# Install SSH server and dependencies with retries
7+
RUN apt-get update && \
8+
apt-get install -y \
9+
openssh-server \
10+
sudo \
11+
curl \
12+
git \
13+
vim \
14+
net-tools && \
15+
apt-get clean && \
16+
rm -rf /var/lib/apt/lists/*
17+
18+
# Create SSH directory
19+
RUN mkdir -p /var/run/sshd
20+
21+
# Create test user
22+
RUN useradd -rm -d /home/testuser -s /bin/bash -g users -G sudo -u 1001 testuser && \
23+
echo 'testuser:testpass' | chpasswd
24+
25+
# Allow password authentication
26+
RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
27+
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
28+
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
29+
30+
# Create .ssh directory with proper permissions
31+
RUN mkdir -p /home/testuser/.ssh && \
32+
chown -R testuser:users /home/testuser/.ssh && \
33+
chmod 700 /home/testuser/.ssh
34+
35+
# Expose SSH port
36+
EXPOSE 22
37+
38+
# Start SSH service
39+
CMD ["/usr/sbin/sshd", "-D"]

docs/TESTING_SSH_REMOTE.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Testing SSH Remote Support
2+
3+
This guide explains how to set up a Podman container with SSH to test the Prompt Registry extension in VS Code remote SSH scenarios.
4+
5+
## Prerequisites
6+
7+
- Podman installed
8+
- VS Code with Remote-SSH extension installed
9+
- SSH client on host machine
10+
11+
## Quick Start
12+
13+
### 1. Create SSH Test Container
14+
15+
Create a Dockerfile for the SSH-enabled container:
16+
17+
```bash
18+
cat > Dockerfile.ssh-test << 'EOF'
19+
FROM ubuntu:22.04
20+
21+
# Install SSH server and dependencies
22+
RUN apt-get update && \
23+
apt-get install -y openssh-server sudo curl git && \
24+
apt-get clean && \
25+
rm -rf /var/lib/apt/lists/*
26+
27+
# Create SSH directory
28+
RUN mkdir /var/run/sshd
29+
30+
# Create test user
31+
RUN useradd -rm -d /home/testuser -s /bin/bash -g users -G sudo -u 1001 testuser && \
32+
echo 'testuser:testpass' | chpasswd
33+
34+
# Allow password authentication
35+
RUN sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
36+
sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
37+
38+
# Allow root login (optional, for debugging)
39+
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
40+
41+
# Expose SSH port
42+
EXPOSE 22
43+
44+
# Start SSH service
45+
CMD ["/usr/sbin/sshd", "-D"]
46+
EOF
47+
```
48+
49+
### 2. Build the Container Image
50+
51+
```bash
52+
podman build -f Dockerfile.ssh-test -t vscode-ssh-test .
53+
```
54+
55+
### 3. Run the Container
56+
57+
```bash
58+
podman run -d \
59+
--name vscode-ssh-test \
60+
-p 2222:22 \
61+
vscode-ssh-test
62+
```
63+
64+
### 4. Verify SSH Access
65+
66+
```bash
67+
ssh -p 2222 testuser@localhost
68+
# Password: testpass
69+
```
70+
71+
### 5. Configure VS Code Remote-SSH
72+
73+
Edit `~/.ssh/config`:
74+
75+
```bash
76+
cat >> ~/.ssh/config << 'EOF'
77+
78+
Host vscode-ssh-test
79+
HostName localhost
80+
Port 2222
81+
User testuser
82+
StrictHostKeyChecking no
83+
UserKnownHostsFile /dev/null
84+
EOF
85+
```
86+
87+
### 6. Connect from VS Code
88+
89+
1. Install "Remote - SSH" extension in VS Code
90+
2. Press `F1` and select "Remote-SSH: Connect to Host..."
91+
3. Select "vscode-ssh-test"
92+
4. Enter password: `testpass`
93+
94+
### 7. Install Extension in Remote
95+
96+
Once connected:
97+
98+
```bash
99+
# Build VSIX first (on host)
100+
npm run package:vsix
101+
102+
# Copy to container
103+
podman cp prompt-registry-0.0.2.vsix vscode-ssh-test:/home/testuser/
104+
105+
# In VS Code remote terminal
106+
code --install-extension ~/prompt-registry-0.0.2.vsix
107+
```
108+
109+
### 8. Test the Extension
110+
111+
1. Check `vscode.env.remoteName` - should be `'ssh-remote'`
112+
2. Install a prompt collection
113+
3. Check Output → "Prompt Registry" for logs
114+
4. Verify prompts sync to remote filesystem
115+
116+
## Cleanup
117+
118+
```bash
119+
podman stop vscode-ssh-test
120+
podman rm vscode-ssh-test
121+
podman rmi vscode-ssh-test
122+
```
123+
124+
## Testing Checklist
125+
126+
- [ ] Container starts and SSH is accessible
127+
- [ ] VS Code connects to SSH remote
128+
- [ ] Extension installs in remote
129+
- [ ] Extension activates without errors
130+
- [ ] Can install prompt collections
131+
- [ ] Prompts sync to remote filesystem
132+
- [ ] No errors in Output panel

package.json

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
"engines": {
3535
"vscode": "^1.99.3"
3636
},
37+
"extensionKind": [
38+
"ui",
39+
"workspace"
40+
],
3741
"main": "./dist/extension.js",
3842
"icon": "icon.png",
3943
"activationEvents": [
@@ -56,11 +60,6 @@
5660
"title": "Update to Latest Version",
5761
"category": "Prompt Registry"
5862
},
59-
{
60-
"command": "promptregistry.uninstall",
61-
"title": "Uninstall Prompt Registry Components",
62-
"category": "Prompt Registry"
63-
},
6463
{
6564
"command": "promptregistry.showVersion",
6665
"title": "Show Version Information",
@@ -82,18 +81,8 @@
8281
"category": "Prompt Registry"
8382
},
8483
{
85-
"command": "promptregistry.uninstallAll",
86-
"title": "Uninstall All Prompt Registry Components",
87-
"category": "Prompt Registry"
88-
},
89-
{
90-
"command": "promptregistry.enhancedInstall",
91-
"title": "Install Prompt Registry Components",
92-
"category": "Prompt Registry"
93-
},
94-
{
95-
"command": "promptregistry.enhancedUninstall",
96-
"title": "Uninstall Prompt Registry Components",
84+
"command": "promptregistry.forceGitHubAuth",
85+
"title": "Force GitHub Authentication",
9786
"category": "Prompt Registry"
9887
},
9988
{
@@ -402,9 +391,6 @@
402391
{
403392
"command": "promptregistry.update"
404393
},
405-
{
406-
"command": "promptregistry.uninstall"
407-
},
408394
{
409395
"command": "promptregistry.showVersion"
410396
},
@@ -415,7 +401,7 @@
415401
"command": "promptregistry.validateAccess"
416402
},
417403
{
418-
"command": "promptregistry.uninstallAll"
404+
"command": "promptregistry.forceGitHubAuth"
419405
}
420406
],
421407
"view/title": [
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
echo "🧹 Cleaning up SSH test container..."
4+
5+
# Stop container
6+
if podman ps | grep -q vscode-ssh-test; then
7+
echo "⏹️ Stopping container..."
8+
podman stop vscode-ssh-test
9+
fi
10+
11+
# Remove container
12+
if podman ps -a | grep -q vscode-ssh-test; then
13+
echo "🗑️ Removing container..."
14+
podman rm vscode-ssh-test
15+
fi
16+
17+
# Remove image
18+
if podman images | grep -q vscode-ssh-test; then
19+
echo "🗑️ Removing image..."
20+
podman rmi vscode-ssh-test
21+
fi
22+
23+
echo ""
24+
echo "✅ Cleanup complete!"
25+
echo ""
26+
echo "Note: SSH config in ~/.ssh/config was not removed."
27+
echo "To remove it manually, edit ~/.ssh/config and delete the vscode-ssh-test section."
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
set -e
3+
4+
echo "🚀 Setting up SSH test container for VS Code remote testing..."
5+
6+
# Build the image with host network to avoid IPv6 issues
7+
echo ""
8+
echo "📦 Building container image..."
9+
podman build --network=host -f Dockerfile.ssh-test -t vscode-ssh-test .
10+
11+
# Stop and remove existing container if it exists
12+
if podman ps -a | grep -q vscode-ssh-test; then
13+
echo ""
14+
echo "🧹 Removing existing container..."
15+
podman rm -f vscode-ssh-test || true
16+
fi
17+
18+
# Run the container
19+
echo ""
20+
echo "🏃 Starting container..."
21+
podman run -d \
22+
--name vscode-ssh-test \
23+
-p 2222:22 \
24+
vscode-ssh-test
25+
26+
# Wait for SSH to be ready
27+
echo ""
28+
echo "⏳ Waiting for SSH service to start..."
29+
sleep 3
30+
31+
# Verify SSH is accessible
32+
echo ""
33+
echo "✅ Testing SSH connection..."
34+
if timeout 5 bash -c "echo | nc -w 1 localhost 2222" 2>/dev/null; then
35+
echo "✅ SSH port is accessible!"
36+
echo " Testing authentication..."
37+
sleep 2
38+
if sshpass -p testpass ssh -p 2222 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=5 testuser@localhost "echo 'SSH connection successful'" 2>/dev/null; then
39+
echo "✅ SSH connection verified!"
40+
else
41+
echo "⚠️ SSH connection works but authentication may need manual password entry"
42+
echo " Try: ssh -p 2222 testuser@localhost (password: testpass)"
43+
fi
44+
else
45+
echo "⚠️ SSH port check inconclusive. Try manually: ssh -p 2222 testuser@localhost"
46+
fi
47+
48+
# Add SSH config if not already present
49+
echo ""
50+
if ! grep -q "Host vscode-ssh-test" ~/.ssh/config 2>/dev/null; then
51+
echo "📝 Adding SSH config to ~/.ssh/config..."
52+
mkdir -p ~/.ssh
53+
cat >> ~/.ssh/config << 'EOF'
54+
55+
# VS Code SSH Test Container
56+
Host vscode-ssh-test
57+
HostName localhost
58+
Port 2222
59+
User testuser
60+
StrictHostKeyChecking no
61+
UserKnownHostsFile /dev/null
62+
EOF
63+
echo "✅ SSH config added"
64+
else
65+
echo "ℹ️ SSH config already exists"
66+
fi
67+
68+
echo ""
69+
echo "✅ Setup complete!"
70+
echo ""
71+
echo "Next steps:"
72+
echo "1. In VS Code, press F1 and select 'Remote-SSH: Connect to Host...'"
73+
echo "2. Select 'vscode-ssh-test'"
74+
echo "3. Enter password: testpass"
75+
echo "4. Install the Prompt Registry extension in the remote"
76+
echo ""
77+
echo "Container info:"
78+
echo " Name: vscode-ssh-test"
79+
echo " SSH: ssh -p 2222 testuser@localhost"
80+
echo " Password: testpass"
81+
echo ""
82+
echo "Useful commands:"
83+
echo " View logs: podman logs vscode-ssh-test"
84+
echo " Connect: ssh -p 2222 testuser@localhost"
85+
echo " Stop: podman stop vscode-ssh-test"
86+
echo " Restart: podman restart vscode-ssh-test"
87+
echo " Remove: ./scripts/cleanup-ssh-test-container.sh"

0 commit comments

Comments
 (0)