{"modulePath":"github.com/OpenSIN-Code/SIN-Code-Bundle","version":"v1.0.6-sin-code","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package internal\n\nSPDX-License-Identifier: MIT Purpose: adw — Architectural Debt Watchdogs. Detects god modules, circular dependencies, high coupling, long functions, large files, and code smells. Pure Go implementation.\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: config — view and manage sin-code configuration files. Supports reading, setting, and listing configuration values. Docs: config.doc.md\n\nSPDX-License-Identifier: MIT Purpose: discover — file discovery with relevance scoring, pattern matching, and dependency analysis. Built-in Go implementation (no external binary dependency).\n\nSPDX-License-Identifier: MIT Purpose: efm — Ephemeral Full-Stack Mocking. Manages docker-compose stacks and ephemeral test environments. Pure Go implementation.\n\nSPDX-License-Identifier: MIT Purpose: execute — safe shell command execution with safety checks, secret redaction, timeout handling, and error analysis. Built-in Go implementation.\n\nSPDX-License-Identifier: MIT Purpose: grasp — deep code understanding for a single file. Built-in Go implementation providing structure, dependencies, and usage context.\n\nSPDX-License-Identifier: MIT Purpose: harvest — URL fetching with caching, structure extraction, and change detection. Built-in Go implementation using net/http with local disk cache.\n\nSPDX-License-Identifier: MIT Purpose: ibd — Intent-Based Diffing. Compare two versions of code and determine if the changes match the stated intent. Pure Go implementation.\n\nSPDX-License-Identifier: MIT Purpose: map — architecture mapping with dependency graphs, entry points, hot paths, and module-level analysis. Built-in Go implementation.\n\nSPDX-License-Identifier: MIT Purpose: oracle — Verification Oracle. Compares source files against test files to verify coverage. Pure Go implementation.\n\nSPDX-License-Identifier: MIT Purpose: orchestrate — task management with dependencies, parallel execution plans, blocker detection, and rollback plans. Built-in Go implementation with JSON file storage in ~/.local/state/sin-code/.\n\nSPDX-License-Identifier: MIT Purpose: poc — Proof-of-Correctness. Verifies that code satisfies its specification by comparing code against spec documents (markdown, text, or structured requirements). Pure Go implementation.\n\nSPDX-License-Identifier: MIT Purpose: sbom — generate SPDX or CycloneDX JSON SBOMs for Go, Python, Node, and generic projects. Docs: cmd/sin-code/internal/sbom.go.doc.md\n\nSPDX-License-Identifier: MIT Purpose: sckg — Semantic Codebase Knowledge Graphs. Builds a knowledge graph of a codebase: files, functions, imports, and their relationships. Pure Go implementation.\n\nSPDX-License-Identifier: MIT Purpose: scout — code search with regex, semantic, symbol, and usage search. Built-in Go implementation with file walking, context lines, and result ranking.\n\nSPDX-License-Identifier: MIT Purpose: security — fast security analysis for Go, Python, Node, and generic projects. Auto-detects project type, finds available security tools, and runs a targeted scan. Docs: security.doc.md\n\nSPDX-License-Identifier: MIT Purpose: self-update — check for and install new sin-code releases from GitHub. Auto-detects platform, downloads the correct binary, and replaces the current one. Docs: self-update.doc.md\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. Pure Go implementation.\n\nDetects:\n  - God modules (files with \u003e15 imports or \u003e500 lines)\n  - Circular dependencies (import cycles)\n  - High coupling (files imported by \u003e10 others)\n  - Long functions (\u003e100 lines)\n  - Large files (\u003e500 lines)\n  - TODO/FIXME comments\n  - Missing tests (source files without corresponding test files)\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 info, err := os.Stat(absPath); err != nil || !info.IsDir() {\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"path not found: %w\", err)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"path is not a directory: %s\", absPath)\n\t\t}\n\n\t\tresult := scanDebt(absPath, adwStrict)\n\n\t\tif adwFormat == \"json\" {\n\t\t\tenc := json.NewEncoder(os.Stdout)\n\t\t\tenc.SetIndent(\"\", \"  \")\n\t\t\treturn enc.Encode(result)\n\t\t}\n\t\treturn outputTextADW(result)\n\t},\n}\n```\n\n```go\nvar ConfigCmd = \u0026cobra.Command{\n\tUse:   \"config\",\n\tShort: \"View and manage sin-code configuration\",\n\tLong: `Manage sin-code configuration files and settings.\n\nConfiguration files:\n  ~/.config/sin/sin-code.toml    Main configuration (theme, defaults)\n  ~/.config/sin/tui.toml         TUI preferences (theme, keybindings)\n\nSubcommands:\n  config get \u003ckey\u003e          Get a configuration value\n  config set \u003ckey\u003e \u003cvalue\u003e  Set a configuration value\n  config list               List all configuration values\n  config path               Show configuration directory path\n  config init               Create default configuration files`,\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. Pure Go implementation — no external binary needed.\n\nExample:\n  sin-code discover . --pattern \"**/*.go\" --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 info, err := os.Stat(absPath); err != nil || !info.IsDir() {\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"path not found: %w\", err)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"path is not a directory: %s\", absPath)\n\t\t}\n\n\t\tresults, err := discoverFiles(absPath, discoverPattern, discoverLimit)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tsortResults(results, discoverSort)\n\t\tif len(results) \u003e discoverLimit {\n\t\t\tresults = results[:discoverLimit]\n\t\t}\n\n\t\tif discoverFormat == \"json\" {\n\t\t\treturn outputJSON(results)\n\t\t}\n\t\treturn outputText(results)\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: `Manage disposable full-stack environments (Docker Compose, ephemeral containers).\nPure Go implementation.\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 --stack docker-compose.yml\n  sin-code efm --action status`,\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\treturn runEFM(efmAction, efmStack, efmTTL, efmFormat)\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. Pure Go implementation — no external binary needed.\n\nExample:\n  sin-code execute --command \"ls -la\" --timeout 10 --format json`,\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\tif err := checkSafety(execCommand); err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn runCommand(execCommand, execTimeout, execFormat, execStream)\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. Pure Go implementation.\n\nExample:\n  sin-code grasp cmd/sin-code/main.go --format json`,\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\tinfo, err := os.Stat(absPath)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"file not found: %w\", err)\n\t\t}\n\t\tif info.IsDir() {\n\t\t\treturn fmt.Errorf(\"path is a directory, not a file: %s\", absPath)\n\t\t}\n\n\t\tresult, err := analyzeFile(absPath, info)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif graspFormat == \"json\" {\n\t\t\tenc := json.NewEncoder(os.Stdout)\n\t\t\tenc.SetIndent(\"\", \"  \")\n\t\t\treturn enc.Encode(result)\n\t\t}\n\t\treturn outputTextGrasp(result)\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. Pure Go implementation with local disk cache.\n\nExample:\n  sin-code harvest --url https://api.example.com/data --format json`,\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\t\treturn harvestURLFetch(harvestURL, harvestMethod, harvestTimeout, harvestFormat)\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. Pure Go implementation.\n\nExamples:\n  sin-code ibd --before old.py --after new.py --intent \"add retry logic\"\n  sin-code ibd --before v1.0 --after HEAD --intent \"refactor authentication\"\n  sin-code ibd file.go --from main --to feature-branch --intent \"add error handling\"`,\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tvar beforePath, afterPath string\n\n\t\tif ibdBefore != \"\" \u0026\u0026 ibdAfter != \"\" {\n\t\t\tbeforePath = ibdBefore\n\t\t\tafterPath = ibdAfter\n\t\t} else if len(args) \u003e 0 {\n\t\t\tbeforePath = args[0]\n\n\t\t\tif ibdFrom != \"\" \u0026\u0026 ibdTo != \"\" {\n\n\t\t\t\tfmt.Fprintf(os.Stderr, \"Note: Git diff (--from/--to) requires manual diff extraction. Reading file as-is.\\n\")\n\t\t\t}\n\t\t} else {\n\t\t\treturn fmt.Errorf(\"either --before/--after or a target path is required\")\n\t\t}\n\n\t\tresult, err := diffWithIntent(beforePath, afterPath, ibdIntent)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif ibdFormat == \"json\" {\n\t\t\tenc := json.NewEncoder(os.Stdout)\n\t\t\tenc.SetIndent(\"\", \"  \")\n\t\t\treturn enc.Encode(result)\n\t\t}\n\t\treturn outputTextIBD(result)\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. Pure Go implementation.\n\nExample:\n  sin-code map . --action map --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\tinfo, err := os.Stat(absPath)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"path not found: %w\", err)\n\t\t}\n\t\tif !info.IsDir() {\n\t\t\treturn fmt.Errorf(\"path is not a directory: %s\", absPath)\n\t\t}\n\n\t\tresult, err := mapArchitecture(absPath, mapAction)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif mapFormat == \"json\" {\n\t\t\tenc := json.NewEncoder(os.Stdout)\n\t\t\tenc.SetIndent(\"\", \"  \")\n\t\t\treturn enc.Encode(result)\n\t\t}\n\t\treturn outputTextMap(result)\n\t},\n}\n```\n\n```go\nvar OracleCmd = \u0026cobra.Command{\n\tUse:   \"oracle\",\n\tShort: \"Verification Oracle — verify claims with evidence\",\n\tLong: `Verify that source code has corresponding test coverage.\nCompares functions/methods in a source file with test cases in a test file.\n\nExamples:\n  sin-code oracle --claim src/main.py --evidence tests/test_main.py\n  sin-code oracle --claim cmd/sin-code/main.go --evidence cmd/sin-code/main_test.go`,\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\tresult, err := verifyCoverage(oracleClaim, oracleEvidence)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif oracleFormat == \"json\" {\n\t\t\tenc := json.NewEncoder(os.Stdout)\n\t\t\tenc.SetIndent(\"\", \"  \")\n\t\t\treturn enc.Encode(result)\n\t\t}\n\t\treturn outputTextOracle(result)\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. Pure Go implementation with JSON file storage.\n\nExample:\n  sin-code orchestrate --action add --title \"Implement feature X\" --tags \"urgent,backend\"\n  sin-code orchestrate --action list --format json\n  sin-code orchestrate --action complete --id 1`,\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\treturn runOrchestrate(orchAction, orchTitle, orchTags, orchID, orchFormat)\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. Compares code against\nspec documents (markdown, text, or structured requirements) and checks for\ncompliance.\n\nPure Go implementation. Checks:\n  - Required functions/classes mentioned in spec exist in code\n  - Function signatures match specification\n  - Required imports are present\n  - No forbidden patterns (e.g., os.Exit in library code)\n\nExamples:\n  sin-code poc --spec spec.md --code src/main.py\n  sin-code poc --spec requirements.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\tresult, err := verifyCorrectness(pocSpec, target)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif pocFormat == \"json\" {\n\t\t\tenc := json.NewEncoder(os.Stdout)\n\t\t\tenc.SetIndent(\"\", \"  \")\n\t\t\treturn enc.Encode(result)\n\t\t}\n\t\treturn outputTextPOC(result)\n\t},\n}\n```\n\n```go\nvar SbomCmd = \u0026cobra.Command{\n\tUse:   \"sbom [path]\",\n\tShort: \"Generate SPDX or CycloneDX JSON SBOM for a project\",\n\tLong: `sbom generates a Software Bill of Materials (SBOM) for the project at \u003cpath\u003e.\n\nSupported project types:\n  Go      → parses go.mod / go list -m -json all\n  Python  → parses requirements.txt or pyproject.toml\n  Node.js → parses package.json (+ package-lock.json for versions)\n  Generic → lists directory structure as a basic component tree\n\nOutput formats:\n  spdx-json      (default) SPDX 2.3 JSON\n  cyclonedx-json CycloneDX 1.5 JSON\n\nExamples:\n  sin-code sbom .\n  sin-code sbom ./my-project --format cyclonedx-json --output sbom.json`,\n\tArgs: cobra.MaximumNArgs(1),\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\tpath, _ = filepath.Abs(path)\n\n\t\tformat, _ := cmd.Flags().GetString(\"format\")\n\t\toutput, _ := cmd.Flags().GetString(\"output\")\n\n\t\tprojType := detectProjectType(path)\n\n\t\tsbom, err := generateSBOM(path, projType, format)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"sbom generation failed: %w\", err)\n\t\t}\n\n\t\tvar out io.Writer = os.Stdout\n\t\tif output != \"\" \u0026\u0026 output != \"-\" {\n\t\t\tf, err := os.Create(output)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"cannot create output file: %w\", err)\n\t\t\t}\n\t\t\tdefer f.Close()\n\t\t\tout = f\n\t\t}\n\n\t\tenc := json.NewEncoder(out)\n\t\tenc.SetIndent(\"\", \"  \")\n\t\treturn enc.Encode(sbom)\n\t},\n}\n```\nSbomCmd generates a Software Bill of Materials in SPDX or CycloneDX format.\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. Pure Go implementation.\n\nActions:\n  build  — Build the knowledge graph from source code\n  query  — Query the graph for relationships (requires --query)\n  stats  — Show graph statistics\n  export — Export graph as JSON\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 --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 info, err := os.Stat(absPath); err != nil || !info.IsDir() {\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"path not found: %w\", err)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"path is not a directory: %s\", absPath)\n\t\t}\n\n\t\tswitch sckgAction {\n\t\tcase \"build\":\n\t\t\tgraph, err := buildGraph(absPath)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif sckgFormat == \"json\" {\n\t\t\t\tenc := json.NewEncoder(os.Stdout)\n\t\t\t\tenc.SetIndent(\"\", \"  \")\n\t\t\t\treturn enc.Encode(graph)\n\t\t\t}\n\t\t\treturn outputTextSCKGBuild(graph)\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\tgraph, err := buildGraph(absPath)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tresults := queryGraph(graph, sckgQuery)\n\t\t\tif sckgFormat == \"json\" {\n\t\t\t\tenc := json.NewEncoder(os.Stdout)\n\t\t\t\tenc.SetIndent(\"\", \"  \")\n\t\t\t\treturn enc.Encode(results)\n\t\t\t}\n\t\t\treturn outputTextSCKGQuery(results)\n\t\tcase \"stats\":\n\t\t\tgraph, err := buildGraph(absPath)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tstats := graphStats(graph)\n\t\t\tif sckgFormat == \"json\" {\n\t\t\t\tenc := json.NewEncoder(os.Stdout)\n\t\t\t\tenc.SetIndent(\"\", \"  \")\n\t\t\t\treturn enc.Encode(stats)\n\t\t\t}\n\t\t\treturn outputTextSCKGStats(stats)\n\t\tcase \"export\":\n\t\t\tgraph, err := buildGraph(absPath)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tenc := json.NewEncoder(os.Stdout)\n\t\t\tenc.SetIndent(\"\", \"  \")\n\t\t\treturn enc.Encode(graph)\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unknown action: %s (use build|query|stats|export)\", sckgAction)\n\t\t}\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\nbasic dead-code detection. Pure Go implementation.\n\nExample:\n  sin-code scout --query \"func.*main\" --path . --search_type regex --format json`,\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 info, err := os.Stat(absPath); err != nil || !info.IsDir() {\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"path not found: %w\", err)\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"path is not a directory: %s\", absPath)\n\t\t}\n\n\t\tresults, err := searchFiles(absPath, scoutQuery, scoutType, scoutMax)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif scoutFormat == \"json\" {\n\t\t\tenc := json.NewEncoder(os.Stdout)\n\t\t\tenc.SetIndent(\"\", \"  \")\n\t\t\treturn enc.Encode(results)\n\t\t}\n\t\treturn outputTextScout(results)\n\t},\n}\n```\n\n```go\nvar SecurityCmd = \u0026cobra.Command{\n\tUse:   \"security [path]\",\n\tShort: \"Fast security analysis — auto-detects project type and runs available tools\",\n\tLong: `security runs a targeted security scan based on the project type detected at \u003cpath\u003e.\n\nSupported project types and tools:\n  Go        → govulncheck, gosec, go vet (if available)\n  Python    → bandit, safety (if available)\n  Node.js   → npm audit (if available)\n  Generic   → secrets scan (grep for high-entropy strings), file-permission checks\n\nThe scan is fast (defaults to 5-minute timeout) and produces a concise summary.\nUse --format json for machine-readable output.`,\n\tArgs: cobra.MaximumNArgs(1),\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\tpath, _ = filepath.Abs(path)\n\n\t\tprojType, _ := cmd.Flags().GetString(\"type\")\n\t\tif projType == \"\" || projType == \"auto\" {\n\t\t\tprojType = detectProjectType(path)\n\t\t}\n\n\t\ttoolFilter, _ := cmd.Flags().GetString(\"tools\")\n\t\tformat, _ := cmd.Flags().GetString(\"format\")\n\t\ttimeoutSec, _ := cmd.Flags().GetInt(\"timeout\")\n\t\tstrict, _ := cmd.Flags().GetBool(\"strict\")\n\n\t\tresult := runSecurityScan(path, projType, toolFilter, timeoutSec)\n\t\tresult.Strict = strict\n\n\t\tif format == \"json\" {\n\t\t\tout, _ := json.MarshalIndent(result, \"\", \"  \")\n\t\t\tfmt.Println(string(out))\n\t\t} else {\n\t\t\tprintSecurityResult(result)\n\t\t}\n\n\t\tif strict \u0026\u0026 result.Summary.Issues \u003e 0 {\n\t\t\treturn fmt.Errorf(\"security scan found %d issues (strict mode)\", result.Summary.Issues)\n\t\t}\n\t\treturn nil\n\t},\n}\n```\nSecurityCmd runs a fast security analysis tailored to the detected project type.\n\n```go\nvar SelfUpdateCmd = \u0026cobra.Command{\n\tUse:   \"self-update\",\n\tShort: \"Check for and install the latest sin-code release\",\n\tLong: `self-update checks GitHub releases for a newer version of sin-code,\ndownloads the correct binary for your platform, and installs it.\n\nThe current binary is backed up before replacement. If the update fails,\nthe backup is restored automatically.\n\nUsage:\n  sin-code self-update              # Check and install latest stable\n  sin-code self-update --version    # Show current version info\n  sin-code self-update --dry-run    # Check only, don't install\n\nSupported platforms: darwin/amd64, darwin/arm64, linux/amd64, linux/arm64, windows/amd64`,\n\tRunE: func(cmd *cobra.Command, args []string) error {\n\t\tdryRun, _ := cmd.Flags().GetBool(\"dry-run\")\n\t\tshowVersion, _ := cmd.Flags().GetBool(\"version\")\n\n\t\tif showVersion {\n\t\t\treturn printVersionInfo()\n\t\t}\n\n\t\treturn runSelfUpdate(dryRun)\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: ServerVersion,\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```go\nvar ServerVersion = \"dev\"\n```\nServerVersion is set at build time via -ldflags \"-X github.com/OpenSIN-Code/SIN-Code-Bundle/cmd/sin-code/internal.ServerVersion=...\"\n\n## Functions\n\n```go\nfunc CheckUpdateAvailable() (string, bool, error)\n```\nCheckUpdateAvailable queries GitHub for the latest release and reports whether the current binary is outdated.\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```go\nfunc SetCurrentVersion(v string)\n```\n\n## Types\n\n```go\ntype CycloneDXComponent struct {\n\tType    string `json:\"type\"`\n\tBomRef  string `json:\"bom-ref\"`\n\tName    string `json:\"name\"`\n\tVersion string `json:\"version,omitempty\"`\n\tPURL    string `json:\"purl,omitempty\"`\n\tScope   string `json:\"scope,omitempty\"`\n}\n```\n\n```go\ntype CycloneDXDocument struct {\n\tBomFormat    string               `json:\"bomFormat\"`\n\tSpecVersion  string               `json:\"specVersion\"`\n\tSerialNumber string               `json:\"serialNumber\"`\n\tVersion      int                  `json:\"version\"`\n\tMetadata     CycloneDXMetadata    `json:\"metadata\"`\n\tComponents   []CycloneDXComponent `json:\"components\"`\n}\n```\nCycloneDX 1.5 document\n\n```go\ntype CycloneDXMetadata struct {\n\tTimestamp string          `json:\"timestamp\"`\n\tTools     []CycloneDXTool `json:\"tools\"`\n}\n```\n\n```go\ntype CycloneDXTool struct {\n\tName    string `json:\"name\"`\n\tVersion string `json:\"version\"`\n}\n```\n\n```go\ntype GitHubRelease struct {\n\tTagName   string `json:\"tag_name\"`\n\tName      string `json:\"name\"`\n\tPublished string `json:\"published_at\"`\n\tBody      string `json:\"body\"`\n\tAssets    []struct {\n\t\tName string `json:\"name\"`\n\t\tSize int    `json:\"size\"`\n\t\tURL  string `json:\"browser_download_url\"`\n\t} `json:\"assets\"`\n}\n```\n\n```go\ntype SPDXCreationInfo struct {\n\tCreated  string   `json:\"created\"`\n\tCreators []string `json:\"creators\"`\n}\n```\n\n```go\ntype SPDXDocument struct {\n\tSPDXVersion       string           `json:\"spdxVersion\"`\n\tSPDXID            string           `json:\"SPDXID\"`\n\tName              string           `json:\"name\"`\n\tDocumentNamespace string           `json:\"documentNamespace\"`\n\tCreationInfo      SPDXCreationInfo `json:\"creationInfo\"`\n\tPackages          []SPDXPackage    `json:\"packages\"`\n}\n```\nSPDX 2.3 document\n\n```go\ntype SPDXPackage struct {\n\tSPDXID                string  `json:\"SPDXID\"`\n\tName                  string  `json:\"name\"`\n\tVersionInfo           string  `json:\"versionInfo\"`\n\tDownloadLocation      string  `json:\"downloadLocation\"`\n\tFilesAnalyzed         bool    `json:\"filesAnalyzed\"`\n\tVerificationCode      *string `json:\"verificationCode\"`\n\tLicenseConcluded      string  `json:\"licenseConcluded\"`\n\tLicenseDeclared       string  `json:\"licenseDeclared\"`\n\tCopyrightText         string  `json:\"copyrightText\"`\n\tPrimaryPackagePurpose string  `json:\"primaryPackagePurpose\"`\n}\n```\n\n```go\ntype SecurityResult struct {\n\tProjectType string          `json:\"project_type\"`\n\tPath        string          `json:\"path\"`\n\tDuration    time.Duration   `json:\"duration\"`\n\tStrict      bool            `json:\"strict\"`\n\tTools       []ToolResult    `json:\"tools\"`\n\tSummary     SecuritySummary `json:\"summary\"`\n}\n```\n\n```go\ntype SecuritySummary struct {\n\tToolsRun int `json:\"tools_run\"`\n\tIssues   int `json:\"issues\"`\n\tErrors   int `json:\"errors\"`\n\tSkipped  int `json:\"skipped\"`\n\tNotFound int `json:\"not_found\"`\n}\n```\n\n```go\ntype SinCodeConfig struct {\n\tTheme            string `toml:\"theme\"`\n\tDefaultTimeout   int    `toml:\"default_timeout\"`\n\tDefaultFormat    string `toml:\"default_format\"`\n\tMCPServerEnabled bool   `toml:\"mcp_server_enabled\"`\n}\n```\n\n```go\ntype ToolResult struct {\n\tName     string `json:\"name\"`\n\tStatus   string `json:\"status\"` // ok, issues, skipped, error, not_found\n\tIssues   int    `json:\"issues\"`\n\tDuration string `json:\"duration\"`\n\tOutput   string `json:\"output,omitempty\"`\n\tError    string `json:\"error,omitempty\"`\n}\n```\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}
