{"id":32789492,"url":"https://github.com/lgladysz/opencode-ignore","last_synced_at":"2026-05-17T19:06:40.651Z","repository":{"id":321969264,"uuid":"1087605305","full_name":"lgladysz/opencode-ignore","owner":"lgladysz","description":"OpenCode plugin to restrict AI access to files and directories using .ignore patterns (gitignore-style).","archived":false,"fork":false,"pushed_at":"2025-11-02T00:01:40.000Z","size":50,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-11-23T16:24:37.431Z","etag":null,"topics":["opencode"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lgladysz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-11-01T08:59:05.000Z","updated_at":"2025-11-19T08:58:06.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/lgladysz/opencode-ignore","commit_stats":null,"previous_names":["lgladysz/opencode-ignore"],"tags_count":2,"template":false,"template_full_name":"lgladysz/opencode-plugin-template","purl":"pkg:github/lgladysz/opencode-ignore","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgladysz%2Fopencode-ignore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgladysz%2Fopencode-ignore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgladysz%2Fopencode-ignore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgladysz%2Fopencode-ignore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lgladysz","download_url":"https://codeload.github.com/lgladysz/opencode-ignore/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lgladysz%2Fopencode-ignore/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33151625,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T09:28:26.183Z","status":"ssl_error","status_checked_at":"2026-05-17T09:27:52.702Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["opencode"],"created_at":"2025-11-05T11:00:20.419Z","updated_at":"2026-05-17T19:06:40.632Z","avatar_url":"https://github.com/lgladysz.png","language":"TypeScript","funding_links":[],"categories":["Plugins"],"sub_categories":[],"readme":"# opencode-ignore\n\nOpenCode plugin to restrict AI access to files and directories using `.ignore` patterns (gitignore-style).\n\n## Usage\n\nAdd to your OpenCode configuration (`~/.config/opencode/opencode.json`):\n\n```json\n{\n  \"$schema\": \"https://opencode.ai/config.json\",\n  \"plugin\": [\n    \"opencode-ignore\"\n  ]\n}\n```\n\nCreate a `.ignore` file in your project root with patterns to block:\n\n```gitignore\n# Block specific directory\n/secrets/**\n\n# Block all certificate files\n*.crt\n*.key\n*.pem\n\n# Block environment files\n.env*\n\n# Allow exception with negation\n!config.local.json\n```\n\n## `.ignore` Format\n\nThe `.ignore` file follows gitignore-style syntax powered by the [`ignore`](https://github.com/kaelzhang/node-ignore) package.\n\n### Pattern Types\n\n#### Absolute Paths\nBlock specific paths from project root:\n```gitignore\n/to/ignore\n/somedir/toignore/**\n```\n\n#### Glob Patterns\nBlock files matching patterns anywhere in project:\n```gitignore\n**/node_modules/**\n**/dist/**\n**/build/**\n**/.cache/**\n```\n\n#### Wildcards\nBlock files by extension or name pattern:\n```gitignore\n*.crt              # All certificate files\n*.key              # All private keys\n*.pem              # All PEM files\n*-secret.json      # Files ending with \"-secret.json\"\ntemp*.log          # Temp log files\n```\n\n#### Negation Patterns\nAllow exceptions to blocked patterns:\n```gitignore\n*.json              # Block all JSON files\n!*.local.json       # But allow *.local.json files\n\n**/target/**        # Block target directory\n!**/target/**       # Re-allow it (negation)\n```\n\n### Directory vs File Matching\n\nThe `ignore` library automatically detects whether paths are files or directories:\n\n```gitignore\nfoo      # Blocks file \"foo\" OR directory \"foo/\"\nfoo/     # Only blocks directory \"foo/\"\n```\n\n**Important**: Pattern `**/node_modules/**` blocks files *inside* the directory, not the directory itself.\n\n## Example Patterns\n\nSee `example/.ignore` for comprehensive examples:\n\n```gitignore\n# Block specific paths\n/secrets/**\n/private/**\n!/private/public-config.json\n\n# Block directories anywhere\n**/node_modules/**\n**/dist/**\n**/build/**\n**/.cache/**\n\n# Block sensitive files\n*-secret.json\ntemp*.log\n*.crt\n*.key\n*.pem\n.env*\n.env\n*.env\nid_rsa\nid_ed25519\nsecrets.json\ncredentials.json\napi-keys.json\n\n# Allow build artifacts in specific cases (negation)\n!**/dist/public/**\n\n# Allow local development files\n!*.local.json\n!*.dev.json\n!config.development.json\n!/.local/\n```\n\n## Supported Tools\n\nThe plugin protects the following OpenCode native tools:\n\n### File Operations (Pre-execution blocking)\n- `read` - Blocks reading blocked files\n- `write` - Blocks writing to blocked paths\n- `edit` - Blocks editing blocked files\n\n### Search Operations (Pre-execution + Post-execution filtering)\n- `glob` - Blocks searching in blocked directories, filters blocked files from results\n- `grep` - Blocks searching in blocked directories, filters matches from blocked files\n\n### List Operations (Pre-execution blocking)\n- `list` - Blocks listing blocked directories\n\n**Protection Levels**:\n- **Pre-execution**: Prevents tool from accessing blocked paths entirely (read, write, edit, list)\n- **Post-execution**: Allows search but filters blocked files from results (glob, grep)\n- This two-phase approach prevents both direct access and information disclosure\n\n**Note**: Project root (`.`) is always accessible to prevent blocking entire project.\n\n## How It Works\n\n### Pre-execution Protection\n1. Plugin loads `.ignore` file from project root before tool execution\n2. Tool paths are normalized to relative paths from project root\n3. Paths are checked against ignore patterns using the `ignore` library\n4. If matched, tool execution is blocked with clear error message\n\n### Post-execution Filtering (glob/grep)\nFor `glob` and `grep` tools, additional protection filters results:\n1. Tool executes normally (searching allowed directories)\n2. Results are filtered to remove any files matching `.ignore` patterns\n3. Blocked files are completely removed from output (no partial data leakage)\n4. Empty results returned if all matches are filtered\n\n### Graceful Degradation\n- If `.ignore` missing, all access is allowed\n- Project root (`.`) is always accessible\n\n### Error Messages\n\nWhen a path is blocked:\n```\nAccess denied: path/to/file blocked by ignore file. Do NOT try to read this. Access restricted.\n```\n\n## Path Normalization\n\nThe plugin handles various path formats:\n\n- **Absolute paths**: Converted to relative from project root\n- **Relative paths**: Used directly\n- **Paths with `./`**: Prefix removed (ignore library requirement)\n- **Win32 backslashes**: Auto-converted to forward slashes\n- **Directory paths**: Trailing `/` added when needed\n\n## Testing\n\nRun tests with:\n```bash\nbun test\n```\n\nTests cover:\n- Absolute path patterns\n- Glob patterns\n- Negation patterns\n- Wildcard patterns\n- Directory vs file matching\n- Path normalization edge cases\n- All supported native tools\n- Missing `.ignore` graceful degradation\n\n## Development\n\n```bash\n# Install dependencies\nbun install\n\n# Run tests\nbun test\n\n# Build (if needed)\nbun build index.ts\n```\n\n## License\n\nMIT\n\n## Related\n\n- [`ignore`](https://github.com/kaelzhang/node-ignore) - The underlying pattern matching library\n- [OpenCode Plugin Documentation](https://opencode.ai/docs/plugins)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flgladysz%2Fopencode-ignore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flgladysz%2Fopencode-ignore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flgladysz%2Fopencode-ignore/lists"}