feat(02-02): capture named sessions through a loopback proxy
Record Nuxt/MCP traffic as ordered flows via parity:proxy, pin loopback upstream, and refuse oversized or credential-shaped fixtures. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -9,6 +9,22 @@ import (
|
||||
"git.golem15.com/golem15/summercms/tide"
|
||||
)
|
||||
|
||||
func parityProxyCommand() bonfire.Command {
|
||||
return bonfire.Command{
|
||||
Name: "parity:proxy",
|
||||
Description: "Record named HTTP sessions through a loopback reverse proxy",
|
||||
Flags: []bonfire.Flag{
|
||||
{Name: "listen", Description: "Loopback bind address", Default: tide.DefaultListen},
|
||||
{Name: "upstream", Description: "Fixed loopback HTTP origin", Default: tide.DefaultUpstream},
|
||||
{Name: "session", Description: "Default session name when X-Parity-Session is absent"},
|
||||
{Name: "rules", Description: "Committed YAML capture rules"},
|
||||
{Name: "vars", Description: "Private mode-0600 variable store outside fixtures"},
|
||||
{Name: "fixtures", Description: "Directory for nuxt/ and mcp/ session flows"},
|
||||
},
|
||||
Run: runParityProxy,
|
||||
}
|
||||
}
|
||||
|
||||
func parityRecordCommand() bonfire.Command {
|
||||
return bonfire.Command{
|
||||
Name: "parity:record",
|
||||
@@ -34,6 +50,38 @@ func parityReplayCommand() bonfire.Command {
|
||||
}
|
||||
}
|
||||
|
||||
func runParityProxy(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
|
||||
rulesPath, err := requireFlag(in, "rules", "parity:proxy")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fixtures, err := requireFlag(in, "fixtures", "parity:proxy")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
rules, err := tide.LoadRules(rulesPath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
listen, _ := in.Flag("listen")
|
||||
upstream, _ := in.Flag("upstream")
|
||||
session, _ := in.Flag("session")
|
||||
varsPath, _ := in.Flag("vars")
|
||||
proxy, err := tide.NewProxy(tide.ProxyConfig{
|
||||
Listen: listen,
|
||||
Upstream: upstream,
|
||||
Session: session,
|
||||
Rules: rules,
|
||||
VarsPath: varsPath,
|
||||
Fixtures: fixtures,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
out.Info(fmt.Sprintf("proxy listening on %s → %s", listen, upstream))
|
||||
return proxy.ListenAndServe(ctx)
|
||||
}
|
||||
|
||||
func runParityRecord(ctx context.Context, in bonfire.Input, out bonfire.Output) error {
|
||||
specPath, err := requireFlag(in, "spec", "parity:record")
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user