Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ go 1.26.2

require (
dappco.re/go/io v0.9.0
dappco.re/go/log v0.9.0
dappco.re/go/process v0.10.0
dappco.re/go/rag v0.10.0
dappco.re/go/ws v0.5.0
Expand All @@ -15,6 +14,7 @@ require (
)

require (
dappco.re/go/log v0.9.0 // indirect
github.com/bahlo/generic-list-go v0.2.0 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
Expand Down
57 changes: 36 additions & 21 deletions go/pkg/mcp/agentic/coreio_compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,19 @@
Local: &localCoreFS{fs: (&core.Fs{}).New("/")},
}

func localCoreFSErr(
r core.Result,
) (
_ error, // result
) {
if r.OK {
return nil
}
if err, ok := r.Value.(error); ok && err != nil {
return err
}
if r.Value != nil {
return core.E("localCoreFS", core.Sprint(r.Value), nil)
}
return core.E("localCoreFS", "operation failed", nil)
}

func (l *localCoreFS) Read(path string) (
string,
error,
) {
r := l.fs.Read(path)
if !r.OK {
return "", localCoreFSErr(r)
if err, ok := r.Value.(error); ok && err != nil {
return "", err
}
if r.Value != nil {
return "", core.E("localCoreFS", core.Sprint(r.Value), nil)
}
return "", core.E("localCoreFS", "operation failed", nil)

Check failure on line 29 in go/pkg/mcp/agentic/coreio_compat.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "operation failed" 4 times.

See more on https://sonarcloud.io/project/issues?id=dAppCore_mcp&issues=AZ3gXAasowgOU9yVjRyv&open=AZ3gXAasowgOU9yVjRyv&pullRequest=9
}
content, ok := r.Value.(string)
if !ok {
Expand All @@ -51,7 +40,17 @@
) (
_ error, // result
) {
return localCoreFSErr(l.fs.EnsureDir(path))
r := l.fs.EnsureDir(path)
if r.OK {
return nil
}
if err, ok := r.Value.(error); ok && err != nil {
return err
}
if r.Value != nil {
return core.E("localCoreFS", core.Sprint(r.Value), nil)
}
return core.E("localCoreFS", "operation failed", nil)
}

func (l *localCoreFS) List(path string) (
Expand All @@ -60,7 +59,13 @@
) {
r := l.fs.List(path)
if !r.OK {
return nil, localCoreFSErr(r)
if err, ok := r.Value.(error); ok && err != nil {
return nil, err
}
if r.Value != nil {
return nil, core.E("localCoreFS", core.Sprint(r.Value), nil)
}
return nil, core.E("localCoreFS", "operation failed", nil)
}
entries, ok := r.Value.([]core.FsDirEntry)
if !ok {
Expand All @@ -78,5 +83,15 @@
) (
_ error, // result
) {
return localCoreFSErr(l.fs.Delete(path))
r := l.fs.Delete(path)
if r.OK {
return nil
}
if err, ok := r.Value.(error); ok && err != nil {
return err
}
if r.Value != nil {
return core.E("localCoreFS", core.Sprint(r.Value), nil)
}
return core.E("localCoreFS", "operation failed", nil)
}
45 changes: 25 additions & 20 deletions go/pkg/mcp/brain/client/coreio_compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,19 @@
Local: &localCoreFS{fs: (&core.Fs{}).New("/")},
}

func localCoreFSErr(
r core.Result,
) (
_ error, // result
) {
if r.OK {
return nil
}
if err, ok := r.Value.(error); ok && err != nil {
return err
}
if r.Value != nil {
return core.E("localCoreFS", core.Sprint(r.Value), nil)
}
return core.E("localCoreFS", "operation failed", nil)
}

func (l *localCoreFS) Stat(path string) (
core.FsFileInfo,
error,
) {
r := l.fs.Stat(path)
if !r.OK {
return nil, localCoreFSErr(r)
if err, ok := r.Value.(error); ok && err != nil {
return nil, err
}
if r.Value != nil {
return nil, core.E("localCoreFS", core.Sprint(r.Value), nil)
}
return nil, core.E("localCoreFS", "operation failed", nil)

Check failure on line 29 in go/pkg/mcp/brain/client/coreio_compat.go

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "operation failed" 3 times.

See more on https://sonarcloud.io/project/issues?id=dAppCore_mcp&issues=AZ3gXAXuowgOU9yVjRyu&open=AZ3gXAXuowgOU9yVjRyu&pullRequest=9
}
info, ok := r.Value.(core.FsFileInfo)
if !ok {
Expand All @@ -52,7 +41,13 @@
) {
r := l.fs.Read(path)
if !r.OK {
return "", localCoreFSErr(r)
if err, ok := r.Value.(error); ok && err != nil {
return "", err
}
if r.Value != nil {
return "", core.E("localCoreFS", core.Sprint(r.Value), nil)
}
return "", core.E("localCoreFS", "operation failed", nil)
}
content, ok := r.Value.(string)
if !ok {
Expand All @@ -68,5 +63,15 @@
) (
_ error, // result
) {
return localCoreFSErr(l.fs.WriteMode(path, content, mode))
r := l.fs.WriteMode(path, content, mode)
if r.OK {
return nil
}
if err, ok := r.Value.(error); ok && err != nil {
return err
}
if r.Value != nil {
return core.E("localCoreFS", core.Sprint(r.Value), nil)
}
return core.E("localCoreFS", "operation failed", nil)
}
Loading