Skip to content

Commit b85a00e

Browse files
committed
Revert "feat: improve working with cwd"
This reverts commit 165ee18.
1 parent ed14eaf commit b85a00e

44 files changed

Lines changed: 66 additions & 3676 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.codex/config.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,3 @@ args = ["mcp"]
55

66
[mcp_servers.archcore.tools.create_document]
77
approval_mode = "approve"
8-
9-
[mcp_servers.archcore.tools.list_documents]
10-
approval_mode = "approve"
11-
12-
[mcp_servers.archcore.tools.get_document]
13-
approval_mode = "approve"

cmd/baseroot.go

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

cmd/baseroot_test.go

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

cmd/config.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ package cmd
22

33
import (
44
"fmt"
5+
"os"
56
"strconv"
67
"strings"
78

89
"archcore-cli/internal/config"
910
"archcore-cli/internal/display"
10-
"archcore-cli/internal/projectroot"
1111

1212
"github.com/spf13/cobra"
1313
)
@@ -22,11 +22,10 @@ func newConfigCmd() *cobra.Command {
2222
}
2323

2424
func runConfig(cmd *cobra.Command, args []string) error {
25-
res, err := resolveProjectRoot(cmd, projectroot.ModeRuntime)
25+
cwd, err := os.Getwd()
2626
if err != nil {
2727
return err
2828
}
29-
cwd := res.Path
3029
settings, err := config.Load(cwd)
3130
if err != nil {
3231
fmt.Println(display.FailLine("Settings not found or invalid"))

cmd/doctor.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ package cmd
22

33
import (
44
"fmt"
5+
"os"
56

67
"github.com/spf13/cobra"
78

89
"archcore-cli/internal/api"
910
"archcore-cli/internal/config"
1011
"archcore-cli/internal/display"
11-
"archcore-cli/internal/projectroot"
1212
)
1313

1414
func newDoctorCmd() *cobra.Command {
@@ -22,11 +22,10 @@ func newDoctorCmd() *cobra.Command {
2222
fmt.Println(display.Banner())
2323
fmt.Println()
2424

25-
res, err := resolveProjectRoot(cmd, projectroot.ModeRuntime)
25+
cwd, err := os.Getwd()
2626
if err != nil {
27-
return err
27+
return fmt.Errorf("getting working directory: %w", err)
2828
}
29-
cwd := res.Path
3029

3130
issues := 0
3231

cmd/doctor_test.go

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,12 @@ import (
1414

1515
func TestDoctor_NotInitialized(t *testing.T) {
1616
dir := t.TempDir()
17-
// Mark this as a project (so resolver passes) but without .archcore/.
18-
if err := os.MkdirAll(filepath.Join(dir, ".git"), 0o755); err != nil {
19-
t.Fatal(err)
20-
}
2117
out, _ := runCmdInDir(t, dir, "doctor")
2218
if !strings.Contains(out, "not found") {
2319
t.Errorf("expected 'not found' in output, got: %s", out)
2420
}
2521
}
2622

27-
func TestDoctor_NoProjectMarkers(t *testing.T) {
28-
dir := t.TempDir()
29-
// Plain directory, no .git, no .archcore — resolver should refuse.
30-
out, err := runCmdInDir(t, dir, "doctor")
31-
if err == nil {
32-
t.Fatal("expected error for no-markers directory, got nil")
33-
}
34-
combined := out + " " + err.Error()
35-
if !strings.Contains(combined, "ERR_NO_PROJECT") && !strings.Contains(combined, "ERR_NOT_PROJECT") {
36-
t.Errorf("expected ERR_NO_PROJECT or ERR_NOT_PROJECT in combined output/err, got: %q", combined)
37-
}
38-
}
39-
4023
func TestDoctor_FreeFormDirectoryAllowed(t *testing.T) {
4124
dir := t.TempDir()
4225
if err := config.InitDir(dir); err != nil {

cmd/hooks.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"archcore-cli/internal/agents"
1212
"archcore-cli/internal/config"
1313
"archcore-cli/internal/display"
14-
"archcore-cli/internal/projectroot"
1514

1615
"github.com/spf13/cobra"
1716
orderedmap "github.com/wk8/go-ordered-map/v2"
@@ -59,11 +58,10 @@ func newHooksInstallCmd() *cobra.Command {
5958
Use: "install",
6059
Short: "Install archcore hooks for coding agents",
6160
RunE: func(cmd *cobra.Command, args []string) error {
62-
res, err := resolveProjectRoot(cmd, projectroot.ModeRuntime)
61+
cwd, err := os.Getwd()
6362
if err != nil {
6463
return err
6564
}
66-
cwd := res.Path
6765
if !config.DirExists(cwd) {
6866
return fmt.Errorf(".archcore/ not found — run 'archcore init' first")
6967
}

cmd/hooks_claude_code.go

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"os"
88

99
"archcore-cli/internal/display"
10-
"archcore-cli/internal/projectroot"
1110

1211
"github.com/spf13/cobra"
1312
)
@@ -26,24 +25,12 @@ type hookOutput struct {
2625
SystemMessage string `json:"systemMessage,omitempty"`
2726
}
2827

29-
// resolveBaseDir returns the base directory for a hook, using the projectroot
30-
// resolver. The hook input's CWD (set by the host MCP integration) is treated
31-
// as an explicit signal and takes precedence over walk-up. ModeHooks lets us
32-
// accept the host-supplied directory even if it lacks markers, since the host
33-
// has explicitly chosen it.
34-
func resolveBaseDir(cmd *cobra.Command, input *hookInput) (string, error) {
35-
flagVal := baseDirFlag(cmd)
36-
if flagVal == "" {
37-
flagVal = input.CWD
28+
// resolveBaseDir returns the base directory from hook input, falling back to cwd.
29+
func resolveBaseDir(input *hookInput) (string, error) {
30+
if input.CWD != "" {
31+
return input.CWD, nil
3832
}
39-
res, err := projectroot.Resolve(projectroot.Options{
40-
Flag: flagVal,
41-
Mode: projectroot.ModeHooks,
42-
})
43-
if err != nil {
44-
return "", err
45-
}
46-
return res.Path, nil
33+
return os.Getwd()
4734
}
4835

4936
// readHookInput parses the hook input JSON from a reader.
@@ -87,7 +74,7 @@ func newSessionStartHookCmd(use, short, version string) *cobra.Command {
8774
if err != nil {
8875
return err
8976
}
90-
baseDir, err := resolveBaseDir(cmd, input)
77+
baseDir, err := resolveBaseDir(input)
9178
if err != nil {
9279
return err
9380
}

0 commit comments

Comments
 (0)