{"modulePath":"github.com/OpenSIN-Code/SIN-Code-Bundle","version":"v1.0.1-sin-code","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package internal\n\nSPDX-License-Identifier: MIT Purpose: adw — Architectural Debt Watchdogs. Delegates to the Python \\`adw\\` module in SIN-Code-ADW-Tool (source of truth).\n\nSPDX-License-Identifier: MIT Purpose: Shared utilities for the sin-code unified binary (error printing, shared flags, output formatting). All subcommands import this package.\n\nSPDX-License-Identifier: MIT Purpose: discover — file discovery. Thin wrapper that calls the standalone SIN-Code-Discover-Tool binary if installed (preserves its Go implementation without duplicating logic).\n\nSPDX-License-Identifier: MIT Purpose: efm — Ephemeral Full-Stack Mocking. Delegates to the Python \\`efm\\` module in SIN-Code-Ephemeral-Full-Stack-Mocking-Orchestration (source of truth).\n\nSPDX-License-Identifier: MIT Purpose: execute — safe command execution. Thin wrapper around the standalone SIN-Code-Execute-Tool binary if installed.\n\nSPDX-License-Identifier: MIT Purpose: grasp — deep code understanding. Thin wrapper around standalone SIN-Code-Grasp-Tool binary if installed.\n\nSPDX-License-Identifier: MIT Purpose: harvest — URL fetching. Thin wrapper around standalone SIN-Code-Harvest-Tool.\n\nSPDX-License-Identifier: MIT Purpose: ibd — Intent-Based Diffing. Delegates to the Python \\`ibd\\` module in SIN-Code-IBD-Tool (source of truth). Provides Go CLI surface + MCP registration.\n\nSPDX-License-Identifier: MIT Purpose: map — architecture analysis. Thin wrapper around standalone SIN-Code-Map-Tool binary if installed.\n\nSPDX-License-Identifier: MIT Purpose: oracle — Verification Oracle. Delegates to the Python \\`oracle\\` module in SIN-Code-Oracle-Tool (source of truth). The Python oracle actually checks test coverage of a source file against an existing test file (subcommand: check).\n\nSPDX-License-Identifier: MIT Purpose: orchestrate — task management. Thin wrapper around standalone SIN-Code-Orchestrate-Tool.\n\nSPDX-License-Identifier: MIT Purpose: poc — Proof-of-Correctness. Delegates to the Python \\`poc\\` module in SIN-Code-PoC-Tool (source of truth).\n\nSPDX-License-Identifier: MIT Purpose: sckg — Semantic Codebase Knowledge Graphs. Delegates to the Python \\`sckg\\` module in SIN-Code-SCKG-Tool (source of truth).\n\nSPDX-License-Identifier: MIT Purpose: scout — code search. Thin wrapper around standalone SIN-Code-Scout-Tool.\n\nSPDX-License-Identifier: MIT Purpose: serve — start an MCP (Model Context Protocol) server that exposes all 13 sin-code subcommands as MCP tools. This replaces the 7 separate MCP server registrations in opencode.json with a single one.\n\n## Variables\n\n```go\nvar AdwCmd = \u0026cobra.Command{\n\tUse:   \"adw\",\n\tShort: \"Architectural Debt Watchdogs — detect god modules, circular deps, etc.\",\n\tLong: `Detect and report architectural debt in a codebase. Delegates to the Python\n` + \"`adw`\" + ` module.\n\nExamples:\n  sin-code adw .\n  sin-code adw ./src --strict\n  sin-code adw . --format json`,\n\tArgs: cobra.ArbitraryArgs,\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tpath := \".\"\n\t\tif len(args) \u003e 0 {\n\t\t\tpath = args[0]\n\t\t}\n\t\tabsPath, err := filepath.Abs(path)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid path: %w\", err)\n\t\t}\n\t\tif _, err := os.Stat(absPath); err != nil {\n\t\t\treturn fmt.Errorf(\"path not found: %w\", err)\n\t\t}\n\n\t\tpythonArgs := []string{\"-m\", \"adw.cli\", \"scan\", absPath}\n\t\tif adwStrict {\n\t\t\tpythonArgs = append(pythonArgs, \"--strict\")\n\t\t}\n\n\t\tc := exec.Command(\"python3\", pythonArgs...)\n\t\tc.Stderr = os.Stderr\n\t\tout, err := c.Output()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"adw execution failed: %w\", err)\n\t\t}\n\n\t\tif adwFormat == \"json\" {\n\t\t\tvar pretty map[string]any\n\t\t\tif err := json.Unmarshal(out, \u0026pretty); err == nil {\n\t\t\t\tenc := json.NewEncoder(os.Stdout)\n\t\t\t\tenc.SetIndent(\"\", \"  \")\n\t\t\t\treturn enc.Encode(pretty)\n\t\t\t}\n\t\t}\n\t\tfmt.Print(string(out))\n\t\treturn nil\n\t},\n}\n```\n\n```go\nvar DiscoverCmd = \u0026cobra.Command{\n\tUse:   \"discover [path]\",\n\tShort: \"Discover files with relevance scoring and pattern matching\",\n\tLong: `Discover files in a directory with relevance scoring, pattern matching,\nand dependency analysis. Delegates to the standalone SIN-Code-Discover-Tool\nbinary if installed; otherwise uses built-in implementation.\n\nExample:\n  sin-code discover . -pattern \"**/*.py\" -sort_by relevance -format json`,\n\tArgs: cobra.ArbitraryArgs,\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tpath := \".\"\n\t\tif len(args) \u003e 0 {\n\t\t\tpath = args[0]\n\t\t}\n\t\tabsPath, err := filepath.Abs(path)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid path: %w\", err)\n\t\t}\n\t\tif _, err := os.Stat(absPath); err != nil {\n\t\t\treturn fmt.Errorf(\"path not found: %w\", err)\n\t\t}\n\n\t\tbinary, err := lookupStandalone(\"discover\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tcArgs := []string{\n\t\t\t\"-path\", absPath,\n\t\t\t\"-pattern\", discoverPattern,\n\t\t\t\"-sort_by\", discoverSort,\n\t\t\t\"-format\", discoverFormat,\n\t\t\t\"-max_results\", fmt.Sprintf(\"%d\", discoverLimit),\n\t\t}\n\t\tc := exec.Command(binary, cArgs...)\n\t\tc.Stderr = os.Stderr\n\t\tc.Stdout = os.Stdout\n\t\treturn c.Run()\n\t},\n}\n```\n\n```go\nvar EfmCmd = \u0026cobra.Command{\n\tUse:   \"efm\",\n\tShort: \"Ephemeral Full-Stack Mocking — spin up disposable test environments\",\n\tLong: `Spin up disposable full-stack environments (backend, DB, frontend) for\ntesting. Delegates to the Python ` + \"`efm`\" + ` module.\n\nExamples:\n  sin-code efm --action list\n  sin-code efm --action up --stack docker-compose.yml --ttl 3600\n  sin-code efm --action down\n  sin-code efm --action status`,\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tif efmStack == \"\" \u0026\u0026 efmAction != \"list\" {\n\t\t\treturn fmt.Errorf(\"--stack is required for actions other than 'list'\")\n\t\t}\n\n\t\tpythonArgs := []string{\"-m\", \"efm.cli\"}\n\t\tswitch efmAction {\n\t\tcase \"up\":\n\t\t\tpythonArgs = append(pythonArgs, \"up\", efmStack, \"--ttl\", fmt.Sprintf(\"%d\", efmTTL))\n\t\tcase \"down\":\n\t\t\tpythonArgs = append(pythonArgs, \"down\")\n\t\tcase \"list\":\n\t\t\tpythonArgs = append(pythonArgs, \"status\")\n\t\tcase \"status\":\n\t\t\tpythonArgs = append(pythonArgs, \"status\")\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unknown action: %s (use up|down|list|status)\", efmAction)\n\t\t}\n\n\t\tc := exec.Command(\"python3\", pythonArgs...)\n\t\tc.Stderr = os.Stderr\n\t\tout, err := c.Output()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"efm execution failed: %w\", err)\n\t\t}\n\n\t\tif efmFormat == \"json\" {\n\t\t\tvar pretty map[string]any\n\t\t\tif err := json.Unmarshal(out, \u0026pretty); err == nil {\n\t\t\t\tenc := json.NewEncoder(os.Stdout)\n\t\t\t\tenc.SetIndent(\"\", \"  \")\n\t\t\t\treturn enc.Encode(pretty)\n\t\t\t}\n\t\t}\n\t\tfmt.Print(string(out))\n\t\treturn nil\n\t},\n}\n```\n\n```go\nvar ExecuteCmd = \u0026cobra.Command{\n\tUse:   \"execute\",\n\tShort: \"Execute shell commands safely with secret redaction and timeout\",\n\tLong: `Execute shell commands with safety checks, secret redaction, timeout\nhandling, and error analysis. Delegates to standalone SIN-Code-Execute-Tool.`,\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tif execCommand == \"\" {\n\t\t\treturn fmt.Errorf(\"--command is required\")\n\t\t}\n\t\tbinary, err := lookupStandalone(\"execute\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcArgs := []string{\n\t\t\t\"-command\", execCommand,\n\t\t\t\"-timeout\", fmt.Sprintf(\"%d\", execTimeout),\n\t\t\t\"-format\", execFormat,\n\t\t}\n\t\tif execStream {\n\t\t\tcArgs = append(cArgs, \"-stream\")\n\t\t}\n\t\tc := exec.Command(binary, cArgs...)\n\t\tc.Stderr = os.Stderr\n\t\tc.Stdout = os.Stdout\n\t\treturn c.Run()\n\t},\n}\n```\n\n```go\nvar GraspCmd = \u0026cobra.Command{\n\tUse:   \"grasp [path]\",\n\tShort: \"Deep code understanding for a single file\",\n\tLong: `Deep code understanding for individual files — structure, dependencies,\nusage, and related context. Delegates to standalone SIN-Code-Grasp-Tool.`,\n\tArgs: cobra.ExactArgs(1),\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tabsPath, err := filepath.Abs(args[0])\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid path: %w\", err)\n\t\t}\n\t\tif _, err := os.Stat(absPath); err != nil {\n\t\t\treturn fmt.Errorf(\"file not found: %w\", err)\n\t\t}\n\t\tbinary, err := lookupStandalone(\"grasp\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcArgs := []string{\"-file\", absPath, \"-format\", graspFormat}\n\t\tc := exec.Command(binary, cArgs...)\n\t\tc.Stderr = os.Stderr\n\t\tc.Stdout = os.Stdout\n\t\treturn c.Run()\n\t},\n}\n```\n\n```go\nvar HarvestCmd = \u0026cobra.Command{\n\tUse:   \"harvest\",\n\tShort: \"Fetch URLs with caching, structure extraction, and change detection\",\n\tLong: `Fetch URLs with caching, structure extraction, change detection, and\nauth management. Delegates to standalone SIN-Code-Harvest-Tool.\n\nIf the standalone binary is not installed, falls back to a built-in HTTP client.`,\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tif harvestURL == \"\" {\n\t\t\treturn fmt.Errorf(\"--url is required\")\n\t\t}\n\n\t\tbinary, binErr := lookupStandalone(\"harvest\")\n\t\tif binErr == nil {\n\t\t\tcArgs := []string{\n\t\t\t\t\"-url\", harvestURL,\n\t\t\t\t\"-method\", harvestMethod,\n\t\t\t\t\"-format\", harvestFormat,\n\t\t\t}\n\t\t\tc := exec.Command(binary, cArgs...)\n\t\t\tc.Stderr = os.Stderr\n\t\t\tc.Stdout = os.Stdout\n\t\t\treturn c.Run()\n\t\t}\n\n\t\tclient := \u0026http.Client{Timeout: time.Duration(harvestTimeout) * time.Second}\n\t\treq, err := http.NewRequest(harvestMethod, harvestURL, nil)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid request: %w\", err)\n\t\t}\n\t\treq.Header.Set(\"User-Agent\", \"sin-code/1.0\")\n\t\tresp, err := client.Do(req)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"request failed: %w\", err)\n\t\t}\n\t\tdefer resp.Body.Close()\n\t\t_, err = io.Copy(os.Stdout, resp.Body)\n\t\treturn err\n\t},\n}\n```\n\n```go\nvar IbdCmd = \u0026cobra.Command{\n\tUse:   \"ibd\",\n\tShort: \"Intent-Based Diffing — compare code changes against stated intent\",\n\tLong: `Compare two versions of code and determine if the changes match the\nstated intent. Delegates to the Python ` + \"`ibd`\" + ` module.\n\nExamples:\n  sin-code ibd --before v1.0 --after HEAD --intent \"add retry logic\"\n  sin-code ibd path/to/file.py --from main --to feature-branch\n  sin-code ibd --before old.py --after new.py --intent \"refactor\"`,\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tpythonModule := \"ibd.cli\"\n\t\tpythonArgs := []string{\"-m\", pythonModule, \"diff\"}\n\n\t\tif ibdBefore != \"\" \u0026\u0026 ibdAfter != \"\" {\n\t\t\tpythonArgs = append(pythonArgs, ibdBefore, \"--before\", ibdBefore, \"--after\", ibdAfter)\n\t\t} else if len(args) \u003e 0 {\n\t\t\tpythonArgs = append(pythonArgs, args[0])\n\t\t\tif ibdFrom != \"\" {\n\t\t\t\tpythonArgs = append(pythonArgs, \"--from\", ibdFrom)\n\t\t\t}\n\t\t\tif ibdTo != \"\" {\n\t\t\t\tpythonArgs = append(pythonArgs, \"--to\", ibdTo)\n\t\t\t}\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"either --before/--after or a target path with --from/--to is required\")\n\t\t}\n\n\t\tif ibdIntent != \"\" {\n\t\t\tpythonArgs = append(pythonArgs, \"--intent\", ibdIntent)\n\t\t}\n\t\tif ibdOutput != \"\" {\n\t\t\tpythonArgs = append(pythonArgs, \"--output\", ibdOutput)\n\t\t}\n\n\t\tc := exec.Command(\"python3\", pythonArgs...)\n\t\tc.Env = append(os.Environ(), \"PYTHONPATH=pythonPath\")\n\t\tc.Stderr = os.Stderr\n\t\tout, err := c.Output()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"ibd execution failed: %w\", err)\n\t\t}\n\n\t\tif ibdFormat == \"json\" {\n\t\t\tvar pretty map[string]any\n\t\t\tif err := json.Unmarshal(out, \u0026pretty); err == nil {\n\t\t\t\tenc := json.NewEncoder(os.Stdout)\n\t\t\t\tenc.SetIndent(\"\", \"  \")\n\t\t\t\treturn enc.Encode(pretty)\n\t\t\t}\n\t\t}\n\t\tfmt.Print(string(out))\n\t\treturn nil\n\t},\n}\n```\n\n```go\nvar MapCmd = \u0026cobra.Command{\n\tUse:   \"map [path]\",\n\tShort: \"Map code architecture with dependency graphs and hot-path analysis\",\n\tLong: `Map code architecture with dependency graphs, entry points, hot paths,\nand module-level analysis. Delegates to standalone SIN-Code-Map-Tool.`,\n\tArgs: cobra.ArbitraryArgs,\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tpath := \".\"\n\t\tif len(args) \u003e 0 {\n\t\t\tpath = args[0]\n\t\t}\n\t\tabsPath, err := filepath.Abs(path)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid path: %w\", err)\n\t\t}\n\t\tif _, err := os.Stat(absPath); err != nil {\n\t\t\treturn fmt.Errorf(\"path not found: %w\", err)\n\t\t}\n\t\tbinary, err := lookupStandalone(\"map\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcArgs := []string{\"-path\", absPath, \"-action\", mapAction, \"-format\", mapFormat}\n\t\tc := exec.Command(binary, cArgs...)\n\t\tc.Stderr = os.Stderr\n\t\tc.Stdout = os.Stdout\n\t\treturn c.Run()\n\t},\n}\n```\n\n```go\nvar OracleCmd = \u0026cobra.Command{\n\tUse:   \"oracle\",\n\tShort: \"Verification Oracle — test coverage check (delegates to oracle.cli check)\",\n\tLong: `The Python oracle module checks test coverage of a source file against\nan existing test file. Use --claim to specify the source file and\n--evidence to specify the test file.\n\nExamples:\n  sin-code oracle --claim src/main.py --evidence tests/test_main.py\n  sin-code oracle --claim src/auth.py --evidence tests/test_auth.py`,\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tif oracleClaim == \"\" {\n\t\t\treturn fmt.Errorf(\"--claim (source file) is required\")\n\t\t}\n\t\tif oracleEvidence == \"\" {\n\t\t\treturn fmt.Errorf(\"--evidence (test file) is required\")\n\t\t}\n\n\t\tpythonArgs := []string{\"-m\", \"oracle.cli\", \"check\", oracleClaim, \"--against\", oracleEvidence}\n\n\t\tc := exec.Command(\"python3\", pythonArgs...)\n\t\tc.Stderr = os.Stderr\n\t\tout, err := c.Output()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"oracle execution failed: %w\", err)\n\t\t}\n\n\t\tif oracleFormat == \"json\" {\n\t\t\tvar pretty map[string]any\n\t\t\tif err := json.Unmarshal(out, \u0026pretty); err == nil {\n\t\t\t\tenc := json.NewEncoder(os.Stdout)\n\t\t\t\tenc.SetIndent(\"\", \"  \")\n\t\t\t\treturn enc.Encode(pretty)\n\t\t\t}\n\t\t}\n\t\tfmt.Print(string(out))\n\t\treturn nil\n\t},\n}\n```\n\n```go\nvar OrchestrateCmd = \u0026cobra.Command{\n\tUse:   \"orchestrate\",\n\tShort: \"Manage tasks with dependencies, parallel execution, and rollback plans\",\n\tLong: `Manage tasks with dependencies, parallel execution plans, blocker\ndetection, and rollback plans. Delegates to standalone SIN-Code-Orchestrate-Tool.`,\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tbinary, err := lookupStandalone(\"orchestrate\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcArgs := []string{\"-action\", orchAction, \"-format\", orchFormat}\n\t\tif orchTitle != \"\" {\n\t\t\tcArgs = append(cArgs, \"-title\", orchTitle)\n\t\t}\n\t\tif orchTags != \"\" {\n\t\t\tcArgs = append(cArgs, \"-tags\", orchTags)\n\t\t}\n\t\tif orchID != \"\" {\n\t\t\tcArgs = append(cArgs, \"-id\", orchID)\n\t\t}\n\t\tc := exec.Command(binary, cArgs...)\n\t\tc.Stderr = os.Stderr\n\t\tc.Stdout = os.Stdout\n\t\treturn c.Run()\n\t},\n}\n```\n\n```go\nvar PocCmd = \u0026cobra.Command{\n\tUse:   \"poc\",\n\tShort: \"Proof-of-Correctness — verify code satisfies its specification\",\n\tLong: `Verify that code satisfies its specification. Delegates to the Python\n` + \"`poc`\" + ` module.\n\nExamples:\n  sin-code poc --spec spec.md --code src/main.py\n  sin-code poc --spec spec.json --code src/`,\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\ttarget := pocCode\n\t\tif target == \"\" {\n\t\t\ttarget = pocSpec\n\t\t}\n\t\tif target == \"\" {\n\t\t\treturn fmt.Errorf(\"--code (or --spec for back-compat) is required\")\n\t\t}\n\n\t\tpythonArgs := []string{\"-m\", \"poc.cli\", \"verify\", target}\n\t\tif pocSpec != \"\" \u0026\u0026 pocSpec != target {\n\t\t\tpythonArgs = append(pythonArgs, \"--config\", pocSpec)\n\t\t}\n\n\t\tc := exec.Command(\"python3\", pythonArgs...)\n\t\tc.Stderr = os.Stderr\n\t\tout, err := c.Output()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"poc execution failed: %w\", err)\n\t\t}\n\n\t\tif pocFormat == \"json\" {\n\t\t\tvar pretty map[string]any\n\t\t\tif err := json.Unmarshal(out, \u0026pretty); err == nil {\n\t\t\t\tenc := json.NewEncoder(os.Stdout)\n\t\t\t\tenc.SetIndent(\"\", \"  \")\n\t\t\t\treturn enc.Encode(pretty)\n\t\t\t}\n\t\t}\n\t\tfmt.Print(string(out))\n\t\treturn nil\n\t},\n}\n```\n\n```go\nvar SckgCmd = \u0026cobra.Command{\n\tUse:   \"sckg\",\n\tShort: \"Semantic Codebase Knowledge Graphs — build \u0026 query code graph\",\n\tLong: `Build and query a semantic graph of a codebase. Delegates to the Python\n` + \"`sckg`\" + ` module.\n\nExamples:\n  sin-code sckg . --action build\n  sin-code sckg . --action query --query \"auth module dependencies\"\n  sin-code sckg . --action stats\n  sin-code sckg . --action export --output graph.json`,\n\tArgs: cobra.ArbitraryArgs,\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tpath := \".\"\n\t\tif len(args) \u003e 0 {\n\t\t\tpath = args[0]\n\t\t}\n\t\tabsPath, err := filepath.Abs(path)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid path: %w\", err)\n\t\t}\n\t\tif _, err := os.Stat(absPath); err != nil {\n\t\t\treturn fmt.Errorf(\"path not found: %w\", err)\n\t\t}\n\n\t\tpythonArgs := []string{\"-m\", \"sckg.cli\"}\n\t\tswitch sckgAction {\n\t\tcase \"build\":\n\t\t\tpythonArgs = append(pythonArgs, \"build\", absPath)\n\t\tcase \"query\":\n\t\t\tif sckgQuery == \"\" {\n\t\t\t\treturn fmt.Errorf(\"--query is required for action=query\")\n\t\t\t}\n\t\t\tpythonArgs = append(pythonArgs, \"query\", sckgQuery)\n\t\tcase \"stats\":\n\t\t\tpythonArgs = append(pythonArgs, \"stats\", absPath)\n\t\tcase \"export\":\n\t\t\tpythonArgs = append(pythonArgs, \"export\", absPath)\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unknown action: %s (use build|query|stats|export)\", sckgAction)\n\t\t}\n\n\t\tc := exec.Command(\"python3\", pythonArgs...)\n\t\tc.Stderr = os.Stderr\n\t\tout, err := c.Output()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"sckg execution failed: %w\", err)\n\t\t}\n\n\t\tif sckgFormat == \"json\" {\n\t\t\tvar pretty map[string]any\n\t\t\tif err := json.Unmarshal(out, \u0026pretty); err == nil {\n\t\t\t\tenc := json.NewEncoder(os.Stdout)\n\t\t\t\tenc.SetIndent(\"\", \"  \")\n\t\t\t\treturn enc.Encode(pretty)\n\t\t\t}\n\t\t}\n\t\tfmt.Print(string(out))\n\t\treturn nil\n\t},\n}\n```\n\n```go\nvar ScoutCmd = \u0026cobra.Command{\n\tUse:   \"scout\",\n\tShort: \"Search code with regex, semantic, symbol, and usage search\",\n\tLong: `Search code with regex, semantic, symbol, and usage search. Includes\ndead-code detection. Delegates to standalone SIN-Code-Scout-Tool.`,\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tif scoutQuery == \"\" {\n\t\t\treturn fmt.Errorf(\"--query is required\")\n\t\t}\n\t\tabsPath, err := filepath.Abs(scoutPath)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"invalid path: %w\", err)\n\t\t}\n\t\tif _, err := os.Stat(absPath); err != nil {\n\t\t\treturn fmt.Errorf(\"path not found: %w\", err)\n\t\t}\n\t\tbinary, err := lookupStandalone(\"scout\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcArgs := []string{\n\t\t\t\"-query\", scoutQuery,\n\t\t\t\"-path\", absPath,\n\t\t\t\"-search_type\", scoutType,\n\t\t\t\"-format\", scoutFormat,\n\t\t\t\"-max_results\", fmt.Sprintf(\"%d\", scoutMax),\n\t\t}\n\t\tc := exec.Command(binary, cArgs...)\n\t\tc.Stderr = os.Stderr\n\t\tc.Stdout = os.Stdout\n\t\treturn c.Run()\n\t},\n}\n```\n\n```go\nvar ServeCmd = \u0026cobra.Command{\n\tUse:   \"serve\",\n\tShort: \"Start an MCP server exposing all 13 sin-code tools\",\n\tLong: `Start a Model Context Protocol (MCP) server that exposes all 13 sin-code\nsubcommands as MCP tools. This allows opencode (and any MCP-compatible client)\nto use sin-code as a single registered MCP server instead of registering 13\nseparate binaries.\n\nExample opencode.json entry:\n\n  \"sin-code\": {\n    \"command\": [\"/Users/jeremy/.local/bin/sin-code\", \"serve\"],\n    \"description\": \"SIN-Code unified toolchain (13 tools)\",\n    \"enabled\": true,\n    \"type\": \"local\"\n  }\n\nThen use sin_discover, sin_execute, sin_map, sin_grasp, sin_scout, sin_harvest,\nsin_orchestrate, sin_ibd, sin_poc, sin_sckg, sin_adw, sin_oracle, sin_efm as\nMCP tools.`,\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tctx, cancel := context.WithCancel(context.Background())\n\t\tdefer cancel()\n\n\t\tserver := mcp.NewServer(\u0026mcp.Implementation{\n\t\t\tName:    \"sin-code\",\n\t\t\tVersion: \"1.0.0\",\n\t\t}, \u0026mcp.ServerOptions{\n\t\t\tCapabilities: \u0026mcp.ServerCapabilities{\n\t\t\t\tTools: \u0026mcp.ToolCapabilities{},\n\t\t\t},\n\t\t})\n\n\t\tregisterAllMCPTools(server)\n\n\t\tif serveTransport == \"stdio\" {\n\t\t\treturn server.Run(ctx, \u0026mcp.StdioTransport{})\n\t\t}\n\t\treturn fmt.Errorf(\"unsupported transport: %s (only stdio supported)\", serveTransport)\n\t},\n}\n```\n\n## Functions\n\n```go\nfunc PrintError(err error)\n```\nPrintError prints an error to stderr in a consistent format and exits with code 1.\n\n","path":"github.com/OpenSIN-Code/SIN-Code-Bundle/cmd/sin-code/internal","name":"internal","synopsis":"SPDX-License-Identifier: MIT Purpose: adw — Architectural Debt Watchdogs.","isRedistributable":true}
