No description
Find a file
2025-04-20 18:44:39 -04:00
assets update gif 2025-02-25 12:15:57 -05:00
.gitignore add release script 2024-12-10 10:41:56 -05:00
.npmrc update package/npm since migrating jsbrains to workspace 2025-04-20 18:44:39 -04:00
.scignore Updated README.md to clarify plugin functionality, emphasizing the streamlined copying of contents for AI tools like ChatGPT, and detailed usage instructions for new commands including copying with linked files. 2024-12-10 10:51:19 -05:00
esbuild.js Update esbuild script to use correct plugin name 'smart-context' 2025-02-20 12:06:28 -05:00
LICENSE Added README.md detailing plugin features, installation instructions, usage guidelines, settings configuration, and example usage for the Smart Context Plugin in Obsidian. 2024-12-10 09:51:22 -05:00
link_depth_modal.js update package/npm since migrating jsbrains to workspace 2025-04-20 18:44:39 -04:00
main.js update package/npm since migrating jsbrains to workspace 2025-04-20 18:44:39 -04:00
manifest.json increment_version_to_1.0.9_in_manifest_json 2025-04-02 08:00:55 -04:00
package-lock.json update package/npm since migrating jsbrains to workspace 2025-04-20 18:44:39 -04:00
package.json update package/npm since migrating jsbrains to workspace 2025-04-20 18:44:39 -04:00
README.md - Updated type annotations and comments in link_depth_modal.js 2025-02-24 13:28:51 -05:00
release.js update_archive_event_from_end_to_finish_in_release_js 2025-04-14 14:53:08 -04:00
settings.js - Extracted settings logic into a separate settings.js file 2025-02-19 21:14:22 -05:00
styles.css - Updated type annotations and comments in link_depth_modal.js 2025-02-24 13:28:51 -05:00

Smart Context Plugin for Obsidian

Smart Context is an Obsidian plugin that helps you copy contents from folders, open files, and linked notes, with advanced configuration like excluding specific heading sections. This is particularly useful when working with AI tools like ChatGPT, letting you feed large sets of project notes, research, or documentation as 'context' to improve AI responses and accuracy.

Features

  • Copy Folder Contents
    Copy all Markdown (and Canvas) files from a selected folder to your clipboard, optionally including the folder tree. Perfect for quickly giving AI models an entire project's context.

  • Copy Visible Open Files
    Copy content from only the currently visible open files, so you can provide precisely the subset of notes you are focusing on to ChatGPT or other tools.

  • Copy All Open Files
    Gather content from every open file in the workspace (regardless of visibility) at once.

  • Exclude Sections by Heading
    Configure specific headings (glob patterns) to exclude. For example, headings named 'Secret' or 'Confidential' can automatically be removed before the content is copied.

  • Copy folder contents to clipboard
    Right-click a folder in Obsidian's File Explorer and select 'Copy folder contents to clipboard' to quickly gather the folder's files.

Smart Context - Copy folder menu option

Getting Started

Smart Context Getting Started

Read the Getting Started Guide for more information.

Real-World Use Case

A developer wants to paste relevant code files, readme content, and design docs into ChatGPT for help. They do not want to manually open and copy each file, nor reveal sensitive or excluded headings. Smart Context solves it in a few clicks.

Settings

In Settings → Community Plugins → Smart Context, you can configure:

  • Excluded Headings
    Array of headings (supports glob patterns, e.g. 'Secret') to remove from the copied text.

  • In-links
    Whether to include notes that link into your selected file(s).

  • Before / After Context
    Custom text inserted at the very beginning or end of the final copied content. Supports placeholders like '{{FILE_TREE}}'.

  • Before / After Each Item
    Text inserted before/after each primary file's content. Useful placeholders include:

    • '{{ITEM_PATH}}'
    • '{{ITEM_NAME}}'
    • '{{ITEM_EXT}}'
    • '{{ITEM_DEPTH}}'

Formatting

When you copy folder contents, open files, or build a custom set of notes, the output might look like:

Folder Structure:
├── example-folder/
│   └── example-file.md
└── example-folder-2/
    └── example-file-2.md
## File Contents:
example-folder/example-file.md
\`\`\`md
# Example File

This is an example file.
\`\`\`

example-folder-2/example-file-2.md
\`\`\`md
# Example File 2

This is another example file.
\`\`\`

If you set 'Secret' as an excluded heading, the 'Secret' section will not appear when you copy this file's content.

Contributing

Feel free to open issues or submit pull requests. This plugin uses the MIT License.