From 8a2bd9baf92d5180c3dbfc4cb45e1b036857b7e7 Mon Sep 17 00:00:00 2001 From: RAIT-09 <51452399+RAIT-09@users.noreply.github.com> Date: Wed, 29 Oct 2025 20:26:01 +0900 Subject: [PATCH] Add prettier and editor settings --- .prettierignore | 10 ++++++ .prettierrc | 13 +++++++ .zed/settings.json | 36 +++++++++++++++++++ README.ja.md | 9 +++++ README.md | 9 +++++ package-lock.json | 17 +++++++++ package.json | 5 ++- src/adapters/obsidian/vault.adapter.ts | 5 ++- .../use-cases/handle-permission.use-case.ts | 8 +++-- src/shared/settings-utils.ts | 5 ++- 10 files changed, 111 insertions(+), 6 deletions(-) create mode 100644 .prettierignore create mode 100644 .prettierrc create mode 100644 .zed/settings.json diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..d0661e9 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,10 @@ +node_modules/ +.git/ +.github/ +.serena/ +.claude/ +main.js +*.json +*.md +*.css +data.json diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..419e1dc --- /dev/null +++ b/.prettierrc @@ -0,0 +1,13 @@ +{ + "useTabs": true, + "tabWidth": 4, + "semi": true, + "singleQuote": false, + "quoteProps": "as-needed", + "trailingComma": "all", + "bracketSpacing": true, + "arrowParens": "always", + "endOfLine": "lf", + "printWidth": 80, + "proseWrap": "preserve" +} diff --git a/.zed/settings.json b/.zed/settings.json new file mode 100644 index 0000000..9812784 --- /dev/null +++ b/.zed/settings.json @@ -0,0 +1,36 @@ +{ + "tab_size": 4, + "hard_tabs": true, + "format_on_save": "on", + "remove_trailing_whitespace_on_save": true, + "ensure_final_newline_on_save": true, + "languages": { + "TypeScript": { + "tab_size": 4, + "hard_tabs": true, + "formatter": "prettier", + "code_actions_on_format": { + "source.fixAll.eslint": false + }, + "format_on_save": "on" + }, + "TSX": { + "tab_size": 4, + "hard_tabs": true, + "formatter": "prettier", + "code_actions_on_format": { + "source.fixAll.eslint": false + }, + "format_on_save": "on" + }, + "JavaScript": { + "tab_size": 4, + "hard_tabs": true, + "formatter": "prettier", + "code_actions_on_format": { + "source.fixAll.eslint": false + }, + "format_on_save": "on" + } + } +} diff --git a/README.ja.md b/README.ja.md index 80a03c5..49bc364 100644 --- a/README.ja.md +++ b/README.ja.md @@ -170,6 +170,15 @@ npm run dev npm run build ``` +コードフォーマット(Prettier): +```bash +# コードのフォーマットをチェック +npm run format:check + +# フォーマットを自動修正 +npm run format +``` + ## 🗺️ ロードマップ - **モデル切り替え機能**: チャット画面から各エージェントのモデルを直接変更する diff --git a/README.md b/README.md index ff4c40d..c4e9e9d 100644 --- a/README.md +++ b/README.md @@ -172,6 +172,15 @@ For production builds: npm run build ``` +Code formatting with Prettier: +```bash +# Check code formatting +npm run format:check + +# Auto-fix formatting issues +npm run format +``` + ## 🗺️ Roadmap - **Model Switching Support**: Change the active model for each agent directly from the chat interface diff --git a/package-lock.json b/package-lock.json index 47c266f..c5084b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "builtin-modules": "3.3.0", "esbuild": "0.17.3", "obsidian": "latest", + "prettier": "^3.4.2", "tslib": "2.4.0", "typescript": "4.7.4" } @@ -2076,6 +2077,22 @@ "node": ">= 0.8.0" } }, + "node_modules/prettier": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.6.2.tgz", + "integrity": "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", diff --git a/package.json b/package.json index 57a2d6a..d2e3545 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,9 @@ "scripts": { "dev": "node esbuild.config.mjs", "build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", - "version": "node version-bump.mjs && git add manifest.json versions.json" + "version": "node version-bump.mjs && git add manifest.json versions.json", + "format": "prettier --write \"src/**/*.{ts,tsx}\"", + "format:check": "prettier --check \"src/**/*.{ts,tsx}\"" }, "keywords": [], "author": "", @@ -20,6 +22,7 @@ "builtin-modules": "3.3.0", "esbuild": "0.17.3", "obsidian": "latest", + "prettier": "^3.4.2", "tslib": "2.4.0", "typescript": "4.7.4" }, diff --git a/src/adapters/obsidian/vault.adapter.ts b/src/adapters/obsidian/vault.adapter.ts index ad998a4..29cfded 100644 --- a/src/adapters/obsidian/vault.adapter.ts +++ b/src/adapters/obsidian/vault.adapter.ts @@ -6,7 +6,10 @@ * wraps Obsidian's file access APIs with domain-friendly interface. */ -import type { IVaultAccess, NoteMetadata } from "../../core/domain/ports/vault-access.port"; +import type { + IVaultAccess, + NoteMetadata, +} from "../../core/domain/ports/vault-access.port"; import { NoteMentionService } from "./mention-service"; import type AgentClientPlugin from "../../infrastructure/obsidian-plugin/plugin"; import { TFile } from "obsidian"; diff --git a/src/core/use-cases/handle-permission.use-case.ts b/src/core/use-cases/handle-permission.use-case.ts index e8242d1..9c7780a 100644 --- a/src/core/use-cases/handle-permission.use-case.ts +++ b/src/core/use-cases/handle-permission.use-case.ts @@ -91,7 +91,9 @@ export class HandlePermissionUseCase { /** * Deny a permission request by selecting the reject option */ - async denyPermission(requestId: string): Promise { + async denyPermission( + requestId: string, + ): Promise { // For denial, we typically select a "reject" option // The actual option ID would need to be determined from the permission request // This is a simplified implementation @@ -146,8 +148,8 @@ export class HandlePermissionUseCase { } // Fall back to any option with "allow" in the name - const allowByName = request.options.find( - (option) => option.name.toLowerCase().includes("allow"), + const allowByName = request.options.find((option) => + option.name.toLowerCase().includes("allow"), ); if (allowByName) { return allowByName; diff --git a/src/shared/settings-utils.ts b/src/shared/settings-utils.ts index 2e917a7..d3d3145 100644 --- a/src/shared/settings-utils.ts +++ b/src/shared/settings-utils.ts @@ -1,4 +1,7 @@ -import type { AgentEnvVar, CustomAgentSettings } from "../infrastructure/obsidian-plugin/plugin"; +import type { + AgentEnvVar, + CustomAgentSettings, +} from "../infrastructure/obsidian-plugin/plugin"; import type { BaseAgentSettings } from "../core/domain/models/agent-config"; import type { AgentConfig } from "../core/domain/ports/agent-client.port";