Skip to content

Commit 830fee7

Browse files
sgx-labsclaude
andcommitted
Add local web dashboard (same web)
Read-only localhost dashboard for browsing, searching, and inspecting vaults. Single embedded HTML file, no build step, no dependencies. Security hardened: localhost-only binding, CSP headers, path traversal protection, private path filtering, safe markdown rendering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8ad49fd commit 830fee7

6 files changed

Lines changed: 2033 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ Comprehensive upgrade to session handoffs based on real-world user feedback. Ric
2626

2727
### Added
2828

29+
- **Web dashboard**`same web` launches a local read-only dashboard at `127.0.0.1:4078`. Browse notes, search semantically, view vault composition, read decisions and handoffs, see related notes. Single embedded HTML file, no external dependencies. Localhost-only with security headers (CSP, X-Frame-Options DENY, DNS rebinding protection). Works without Ollama (keyword fallback). `--port` and `--open` flags available
30+
- **Dashboard insights** — contextual tips based on vault state: index staleness warnings, search mode guidance, seed install suggestions, content type coaching, pinned notes tips
2931
- **Bug reporting** — "Report a Bug" link in README and npm package, GitHub issue templates (bug report + feature request), `same doctor` shows issues URL when checks fail, MCP `index_stats` description guides agents to `same doctor` and GitHub Issues
3032
- **Stop hook message control** — handoff creation message shows once per session; subsequent updates are silent
3133

cmd/same/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ Need help? https://discord.gg/9KfTkcGs7g`,
158158
searchCmd(),
159159
askCmd(),
160160
relatedCmd(),
161+
webCmd(),
161162
)
162163

163164
addGrouped("knowledge",

cmd/same/web_cmd.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"os/exec"
6+
"runtime"
7+
"time"
8+
9+
"github.com/spf13/cobra"
10+
11+
"github.com/sgx-labs/statelessagent/internal/config"
12+
"github.com/sgx-labs/statelessagent/internal/web"
13+
)
14+
15+
func webCmd() *cobra.Command {
16+
var (
17+
port int
18+
openFlag bool
19+
)
20+
cmd := &cobra.Command{
21+
Use: "web",
22+
Short: "Open the vault dashboard in your browser",
23+
Long: `Start a local web server for the vault dashboard.
24+
25+
The dashboard is read-only and only accessible from localhost.
26+
27+
Examples:
28+
same web # Start on port 4078
29+
same web --port 8080 # Custom port
30+
same web --open # Auto-open browser`,
31+
RunE: func(cmd *cobra.Command, args []string) error {
32+
vp := config.VaultPath()
33+
if vp == "" {
34+
return config.ErrNoVault
35+
}
36+
37+
// Create embed provider (nil is fine — keyword fallback)
38+
embedClient, _ := newEmbedProvider()
39+
40+
addr := fmt.Sprintf("127.0.0.1:%d", port)
41+
42+
if openFlag {
43+
go func() {
44+
time.Sleep(300 * time.Millisecond)
45+
openBrowser(fmt.Sprintf("http://%s", addr))
46+
}()
47+
}
48+
49+
return web.Serve(addr, embedClient, Version, vp)
50+
},
51+
}
52+
cmd.Flags().IntVar(&port, "port", 4078, "Port to listen on")
53+
cmd.Flags().BoolVar(&openFlag, "open", false, "Auto-open browser")
54+
return cmd
55+
}
56+
57+
func openBrowser(url string) {
58+
var cmd *exec.Cmd
59+
switch runtime.GOOS {
60+
case "darwin":
61+
cmd = exec.Command("open", url)
62+
case "linux":
63+
cmd = exec.Command("xdg-open", url)
64+
case "windows":
65+
cmd = exec.Command("rundll32", "url.dll,FileProtocolHandler", url)
66+
default:
67+
return
68+
}
69+
cmd.Run()
70+
}

0 commit comments

Comments
 (0)