Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
glowingjade committed Oct 11, 2024
0 parents commit c26bac8
Show file tree
Hide file tree
Showing 60 changed files with 15,515 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# top-most EditorConfig file
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = tab
indent_size = 4
tab_width = 4
46 changes: 46 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# compiled output
main.js
/node_modules

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# local env files
.env
.env*.local

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
esbuild.config.mjs
jest.config.js

# Obsidian
.obsidian
63 changes: 63 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/** @type {import("eslint").Linter.Config} */
const config = {
root: true,
env: {
node: true,
jest: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/strict',
'plugin:import/recommended',
'plugin:import/typescript',
'prettier',
],
rules: {
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/require-await': 'off',
'@typescript-eslint/consistent-type-definitions': ['warn', 'type'],
'@typescript-eslint/no-extraneous-class': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-useless-constructor': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-unnecessary-condition': 'off',
'@typescript-eslint/no-misused-promises': 'off',

'import/no-unresolved': 'off',

'sort-imports': [
'error',
{
ignoreCase: false,
ignoreDeclarationSort: true,
ignoreMemberSort: false,
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
allowSeparatedGroups: true,
},
],
'import/order': [
'error',
{
'newlines-between': 'always',
alphabetize: {
order: 'asc',
caseInsensitive: true,
},
},
],
},
ignorePatterns: ['.eslintrc.js'],
}

module.exports = config
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: CI

on:
pull_request:
branches: [main]

jobs:
check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- run: npm ci
- name: Type check
run: npm run type:check
- name: Lint check
run: npm run lint:check
- name: Test
run: npm test
22 changes: 22 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# vscode
.vscode

# Intellij
*.iml
.idea

# npm
node_modules

# Don't include the compiled main.js file in the repo.
# They should be uploaded to GitHub releases instead.
main.js

# Exclude sourcemaps
*.map

# obsidian
data.json

# Exclude macOS Finder (System Explorer) View States
.DS_Store
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tag-version-prefix=""
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20.13
42 changes: 42 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# compiled output
main.js
/node_modules

# Logs
logs
*.log
npm-debug.log*
pnpm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# local env files
.env
.env*.local

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# Obsidian
.obsidian
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"trailingComma": "all"
}
86 changes: 86 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Obsidian Smart Composer

`<GIF>`

Everytime we ask ChatGPT, we need to put so much context information for each query. Why spend time putting background infos that are already in your vault?

Obsidian Smart Composer is a plugin that helps you write efficiently with AI by easily referencing your vault content. Inspired by Cursor AI and ChatGPT Canvas, this plugin unifies your note-taking and content creation process within Obsidian.

## Features

### Contextual Chat

`<GIF>`

Upgrade your note-taking experience with our Contextual AI Assistant, inspired by Cursor AI. Unlike typical AI plugins, our assistant allows you to precisely select the context for your interactions:

- Type `@<filename>` to choose specific files as your conversation context
- Get responses based on selected vault content

### Apply Edit

`<GIF>`

Smart Composer suggests edits to your document, you can apply with a single click.

- Offers document change recommendations
- Apply suggested changes instantly

#### Additional Features

- **Custom Model Selection** : Use your own model by setting your API Key (stored locally).

## Getting Started

Currently, Obsidian Smart Composer is available through manual installation only. Community plugin support is coming soon.

### Manual Installation

1. Download `main.js`, `manifest.json`, and `styles.css` from the [latest release](https://github.com/glowingjade/obsidian-smart-composer/releases/latest).
2. Create a folder named `obsidian-smart-composer` in your vault's `<Vault>/.obsidian/plugins/` directory.
3. Place the downloaded files into this new folder.
4. Open Obsidian settings `Settings > Community plugins`, and enable Obsidian Smart Composer.

### Initial Setup

1. Obtain an API key from your preferred AI service provider.
2. In Obsidian, go to `Settings > Obsidian Smart Composer`.
3. Enter your API key in the designated field.

Note: The plugin requires a valid API key to work.


### Commands and Hotkeys

Obsidian Smart Composer adds a few commands to work with AI. You can set custom hotkeys for these commands by going to `Settings > Hotkeys` and searching for "Obsidian Smart Composer". (Note: Hotkeys are unset by default)

| Command | Description | Preferred Hotkey |
| --------------------- | ------------------------------------------ | ---------------- |
| Open Chat View | Opens the AI chat interface | Cmd+Shift+L |
| Add Selection to Chat | Adds the selected text to the current chat | Cmd+L |


## Roadmap

#### Expanded Context Support

- Folder context mentioning, and auto context selection (RAG)
- PDF, DOCX, and image understanding
- Web content browsing

#### Advanced Search

- Chat with AI to find specific notes or content

#### Prompt Presets

- Save and reuse custom prompts for common tasks

#### Tab Completion

- Copilot-like autocomplete
- Context-aware suggestions based on your writing style and vault content

## Contribution

All kinds of contributions are welcome, including bug reports, bug fixes, improvements to documentation, and general enhancements. If you have an idea for a major feature, please create an issue to discuss its feasibility and the best implementation approach.
49 changes: 49 additions & 0 deletions esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import esbuild from 'esbuild'
import process from 'process'
import builtins from 'builtin-modules'

const banner = `/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
`

const prod = process.argv[2] === 'production'

const context = await esbuild.context({
banner: {
js: banner,
},
entryPoints: ['src/main.ts'], // Change this line
bundle: true,
external: [
'obsidian',
'electron',
'@codemirror/autocomplete',
'@codemirror/collab',
'@codemirror/commands',
'@codemirror/language',
'@codemirror/lint',
'@codemirror/search',
'@codemirror/state',
'@codemirror/view',
'@lezer/common',
'@lezer/highlight',
'@lezer/lr',
...builtins,
],
format: 'cjs',
target: 'es2018',
logLevel: 'info',
sourcemap: prod ? false : 'inline',
treeShaking: true,
outfile: 'main.js', // Changed back to main.js
minify: prod,
})

if (prod) {
await context.rebuild()
process.exit(0)
} else {
await context.watch()
}
7 changes: 7 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/** @type {import('ts-jest').JestConfigWithTsJest} **/
module.exports = {
testEnvironment: 'node',
transform: {
'^.+.tsx?$': ['ts-jest', {}],
},
}
11 changes: 11 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"id": "smart-composer",
"name": "Smart Composer",
"version": "1.0.0",
"minAppVersion": "0.15.0",
"description": "AI chat with note context, smart writing assistance, and one-click edits for your Obsidian vault.",
"author": "Heesu Suh",
"authorUrl": "https://github.com/glowingjade",
"fundingUrl": "https://buymeacoffee.com/glowingjade",
"isDesktopOnly": false
}
Loading

0 comments on commit c26bac8

Please sign in to comment.