Fix GH#367: bd import defaulting to stdin is confusing
Changes: 1. Add TTY detection to bd import - prevents silent hang when run interactively without arguments. Shows helpful usage message instead. 2. Fix misleading error messages - change "Run 'bd import'" to "Run 'bd sync --import-only'" or explicit file path throughout. Technical details: - Added golang.org/x/term dependency for IsTerminal() - When stdin is a TTY and no -i flag: show usage and exit - When stdin is piped: works as before (supports script pipelines) - Preserved all legitimate stdin uses: * python gh2jsonl.py --repo owner/repo | bd import * python md2jsonl.py feature.md | bd import * git show HEAD:.beads/beads.jsonl | bd import -i /dev/stdin Updated error messages in: - cmd/bd/staleness.go - main "out of sync" error - cmd/bd/sync.go - merge completion suggestions - internal/rpc/server_export_import_auto.go - daemon warnings 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -219,7 +219,7 @@ func (s *Server) checkAndAutoImportIfStale(req *Request) error {
|
||||
s.importInProgress.Store(false)
|
||||
shouldDeferRelease = false
|
||||
|
||||
fmt.Fprintf(os.Stderr, "Warning: auto-import skipped - .beads files have uncommitted changes. Run 'bd import' manually after committing.\n")
|
||||
fmt.Fprintf(os.Stderr, "Warning: auto-import skipped - .beads files have uncommitted changes. Run 'bd sync' after committing.\n")
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -292,7 +292,7 @@ func (s *Server) checkAndAutoImportIfStale(req *Request) error {
|
||||
err = autoimport.AutoImportIfNewer(importCtx, store, dbPath, notify, importFunc, onChanged)
|
||||
if err != nil {
|
||||
if importCtx.Err() == context.DeadlineExceeded {
|
||||
fmt.Fprintf(os.Stderr, "Error: auto-import timed out after 5s. Run 'bd import' manually.\n")
|
||||
fmt.Fprintf(os.Stderr, "Error: auto-import timed out after 5s. Run 'bd sync --import-only' manually.\n")
|
||||
return fmt.Errorf("auto-import timed out")
|
||||
}
|
||||
// Log but don't fail the request - let it proceed with stale data
|
||||
|
||||
Reference in New Issue
Block a user