Skip to content

Commit 66d8819

Browse files
committed
nuke all module related code. this sucks, but we need to rewrite the entire thing. Ouch!!
1 parent 2a0acd8 commit 66d8819

File tree

14 files changed

+6
-887
lines changed

14 files changed

+6
-887
lines changed

cmd/memex/main.go

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"os"
77
"path/filepath"
8-
"strings"
98

109
"github.com/systemshift/memex/pkg/memex"
1110
)
@@ -25,16 +24,6 @@ Built-in Commands:
2524
export <path> Export repository to tar archive
2625
import <path> Import repository from tar archive
2726
28-
Module Management:
29-
module list List installed modules
30-
module install <path> Install module from path
31-
module install --dev <path> Install module in development mode
32-
module remove <name> Remove installed module
33-
34-
Module Commands:
35-
<module> <command> [args] Run module command (e.g., ast add main.go)
36-
module help <name> Show module help
37-
3827
Export options:
3928
--nodes <id1,id2,...> Export specific nodes and their subgraph
4029
--depth <n> Maximum depth for subgraph export
@@ -55,10 +44,6 @@ func main() {
5544
merge := importFlags.Bool("merge", false, "Merge with existing content")
5645
prefix := importFlags.String("prefix", "", "Add prefix to imported node IDs")
5746

58-
// Module install flags
59-
moduleInstallFlags := flag.NewFlagSet("module install", flag.ExitOnError)
60-
devMode := moduleInstallFlags.Bool("dev", false, "Install module in development mode")
61-
6247
flag.Usage = usage
6348
flag.Parse()
6449

@@ -182,58 +167,7 @@ func main() {
182167

183168
err = cmds.Import(args[0], opts)
184169

185-
case "module":
186-
if len(args) < 1 {
187-
usage()
188-
}
189-
190-
switch args[0] {
191-
case "help":
192-
if len(args) < 2 {
193-
usage()
194-
}
195-
// Show module help
196-
err = cmds.ModuleHelp(args[1])
197-
198-
case "install":
199-
if len(args) < 2 {
200-
usage()
201-
}
202-
// Parse install flags
203-
moduleInstallFlags.Parse(args[1:])
204-
remainingArgs := moduleInstallFlags.Args()
205-
if len(remainingArgs) < 1 {
206-
usage()
207-
}
208-
209-
// Install module
210-
err = cmds.Module(append([]string{"install", "--dev=" + fmt.Sprint(*devMode)}, remainingArgs...)...)
211-
212-
default:
213-
// Handle other module commands
214-
err = cmds.Module(args...)
215-
}
216-
217170
default:
218-
// Check if it's a module command
219-
if err := cmds.AutoConnect(); err != nil {
220-
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
221-
os.Exit(1)
222-
}
223-
224-
// Try to handle as module command (e.g., "ast add main.go")
225-
if len(args) > 0 {
226-
moduleArgs := append([]string{cmd, args[0]}, args[1:]...)
227-
if err := cmds.Module(moduleArgs...); err != nil {
228-
if strings.Contains(err.Error(), "module not found") {
229-
usage()
230-
}
231-
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
232-
os.Exit(1)
233-
}
234-
os.Exit(0)
235-
}
236-
237171
usage()
238172
}
239173

internal/memex/commands.go

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@ package memex
33
import (
44
"fmt"
55
"os"
6-
"os/exec"
76
"path/filepath"
87
"strconv"
98
"strings"
109

1110
"github.com/systemshift/memex/internal/memex/core"
1211
"github.com/systemshift/memex/internal/memex/migration"
13-
"github.com/systemshift/memex/internal/memex/modules"
1412
"github.com/systemshift/memex/internal/memex/repository"
1513
)
1614

@@ -25,105 +23,6 @@ func SetRepository(repo core.Repository) {
2523
repoPath = "test.mx"
2624
}
2725

28-
// ModuleCommand handles module operations
29-
func ModuleCommand(args ...string) error {
30-
if len(args) < 1 {
31-
return fmt.Errorf("module command requires subcommand (list, run)")
32-
}
33-
34-
cmd := args[0]
35-
switch cmd {
36-
case "list":
37-
// List installed modules
38-
modules := modules.ListModules()
39-
if len(modules) == 0 {
40-
fmt.Println("No modules installed")
41-
return nil
42-
}
43-
44-
fmt.Println("Installed modules:")
45-
for _, module := range modules {
46-
fmt.Printf(" %s - %s\n", module.ID(), module.Name())
47-
fmt.Printf(" Description: %s\n", module.Description())
48-
49-
// Show available commands
50-
commands := module.Commands()
51-
if len(commands) > 0 {
52-
fmt.Println(" Commands:")
53-
for _, cmd := range commands {
54-
fmt.Printf(" %s - %s\n", cmd.Name, cmd.Description)
55-
}
56-
}
57-
}
58-
return nil
59-
60-
case "install":
61-
if len(args) < 2 {
62-
return fmt.Errorf("install requires module path")
63-
}
64-
modulePath := args[1]
65-
fullPath := fmt.Sprintf("github.com/systemshift/%s", modulePath)
66-
67-
// Run go get to download the module
68-
cmd := exec.Command("go", "get", fullPath)
69-
cmd.Dir = "."
70-
if err := cmd.Run(); err != nil {
71-
return fmt.Errorf("installing module: %w", err)
72-
}
73-
74-
// Run go mod tidy
75-
cmd = exec.Command("go", "mod", "tidy")
76-
cmd.Dir = "."
77-
if err := cmd.Run(); err != nil {
78-
return fmt.Errorf("tidying modules: %w", err)
79-
}
80-
81-
fmt.Printf("Module %s installed successfully\n", modulePath)
82-
return nil
83-
84-
case "install-dev":
85-
if len(args) < 2 {
86-
return fmt.Errorf("install-dev requires module path")
87-
}
88-
modulePath := args[1]
89-
90-
// Add replace directive to use local module
91-
cmd := exec.Command("go", "mod", "edit", "-replace", fmt.Sprintf("github.com/systemshift/%s=./%s", modulePath, modulePath))
92-
cmd.Dir = "."
93-
if err := cmd.Run(); err != nil {
94-
return fmt.Errorf("adding replace directive: %w", err)
95-
}
96-
97-
// Run go mod tidy
98-
cmd = exec.Command("go", "mod", "tidy")
99-
cmd.Dir = "."
100-
if err := cmd.Run(); err != nil {
101-
return fmt.Errorf("tidying modules: %w", err)
102-
}
103-
104-
fmt.Printf("Module %s installed in development mode\n", modulePath)
105-
return nil
106-
107-
default:
108-
// Try to handle as module command (e.g., ast parse main.go)
109-
moduleID := args[0]
110-
if len(args) < 2 {
111-
return fmt.Errorf("module command required")
112-
}
113-
114-
cmd := args[1]
115-
cmdArgs := args[2:]
116-
117-
// Get current repository for module commands
118-
repo, err := GetRepository()
119-
if err != nil {
120-
return fmt.Errorf("getting repository: %w", err)
121-
}
122-
123-
return HandleModuleCommand(moduleID, cmd, cmdArgs, repo)
124-
}
125-
}
126-
12726
// StatusCommand shows repository status
12827
func StatusCommand(args ...string) error {
12928
repo, err := GetRepository()

internal/memex/core/types.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
package core
22

33
import (
4-
"errors"
54
"time"
65
)
76

8-
// Common errors
9-
var (
10-
ErrNotInitialized = errors.New("module not initialized")
11-
)
12-
137
// Node represents a node in the graph
148
type Node struct {
159
ID string
@@ -30,27 +24,6 @@ type Link struct {
3024
Modified time.Time
3125
}
3226

33-
// Command represents a module command
34-
type Command struct {
35-
Name string // Command name (e.g., "add", "status")
36-
Description string // Command description
37-
Usage string // Usage example (e.g., "git add <file>")
38-
Args []string // Expected arguments
39-
}
40-
41-
// Module defines the interface that all memex modules must implement
42-
type Module interface {
43-
// Identity
44-
ID() string // Unique identifier (e.g., "git", "ast")
45-
Name() string // Human-readable name
46-
Description() string // Module description
47-
48-
// Core functionality
49-
Init(repo Repository) error // Initialize module with repository
50-
Commands() []Command // Available commands
51-
HandleCommand(cmd string, args []string) error // Execute a command
52-
}
53-
5427
// Repository defines the interface for repository operations
5528
type Repository interface {
5629
// Node operations

internal/memex/module/loader.go

Lines changed: 0 additions & 26 deletions
This file was deleted.

internal/memex/modules.go

Lines changed: 0 additions & 30 deletions
This file was deleted.

internal/memex/modules/registry.go

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)