Skip to content

Commit c16abc7

Browse files
philoserfclaude
andcommitted
fix: address review followup findings
- Remove "Claude AI" from manifest.json and package.json descriptions to match vendor-neutral policy - Disable title field name setting alongside title prompt when enableTitle is toggled off - Remove unreachable null/undefined guard in updateFrontMatter - Remove duplicate console.error in generateMetadata catch block - Revert JSON regex back to greedy — safer for single-object responses where values may contain braces - Fix AGENTS.md test script statement accuracy Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 495beab commit c16abc7

File tree

7 files changed

+12
-14
lines changed

7 files changed

+12
-14
lines changed

AGENTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ bun run validate # Full validation (types, checks, build)
3030
bun run version # Sync manifest.json and versions.json from package.json
3131
```
3232

33-
No unit tests exist. The `test` script is not configured.
33+
No unit tests exist.
3434

3535
## Architecture
3636

3737
### Source Files
3838

3939
- **[src/main.ts](src/main.ts)** — Plugin entry point. Registers the `generate-metadata` command, loads/saves settings, migrates legacy `updateMethod` values.
40-
- **[src/metadata.ts](src/metadata.ts)** — Orchestrates metadata generation. Checks whether fields need updating, builds the prompt dynamically (omitting title when disabled), calls Claude, parses JSON from the response with non-greedy regex (`/{[\s\S]*?}/`), and writes tags/description/title to frontmatter.
40+
- **[src/metadata.ts](src/metadata.ts)** — Orchestrates metadata generation. Checks whether fields need updating, builds the prompt dynamically (omitting title when disabled), calls Claude, parses JSON from the response with regex (`/{[\s\S]*}/`), and writes tags/description/title to frontmatter.
4141
- **[src/settings.ts](src/settings.ts)**`MetadataToolSettings` interface and `DEFAULT_SETTINGS`. Field names: `anthropicApiKey`, `anthropicModel`, `tagsFieldName`, `descriptionFieldName`, `titleFieldName`, `enableTitle`, `truncateContent`, `maxTokens`, `truncateMethod`, `updateMethod`, plus per-field prompt strings.
4242
- **[src/settingsTab.ts](src/settingsTab.ts)** — Settings UI (`PluginSettingTab`). Password-masked API key, model dropdown, toggles, and text inputs for field names and prompts.
4343
- **[src/utils.ts](src/utils.ts)**`callClaude()` (Anthropic SDK call with `dangerouslyAllowBrowser: true`), `getContent()` (content extraction and truncation), `updateFrontMatter()` (async writes via `app.fileManager.processFrontMatter()`).

main.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "Metadator",
44
"version": "1.1.0",
55
"minAppVersion": "1.0.0",
6-
"description": "Automatically generate metadata for your notes using Claude AI",
6+
"description": "Automatically generate metadata for your notes using AI",
77
"author": "Mark Ayers",
88
"authorUrl": "https://github.com/philoserf",
99
"isDesktopOnly": false

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "metadator",
33
"version": "1.1.0",
4-
"description": "Automatically generate metadata for Obsidian notes using Claude AI",
4+
"description": "Automatically generate metadata for Obsidian notes using AI",
55
"main": "main.js",
66
"type": "module",
77
"scripts": {

src/metadata.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export async function generateMetadata(
6060
if (hasChanges) {
6161
new Notice("Metadata updated successfully");
6262
}
63-
} catch (error) {
64-
console.error("Error generating metadata with Claude:", error);
63+
} catch {
64+
// Error already logged and shown to user by callClaude
6565
}
6666
}
6767
}
@@ -134,7 +134,7 @@ async function addMetadataWithClaude(
134134

135135
let metadata: MetadataResponse = {};
136136
try {
137-
const jsonMatch = response.match(/{[\s\S]*?}/);
137+
const jsonMatch = response.match(/{[\s\S]*}/);
138138
if (jsonMatch) {
139139
metadata = JSON.parse(jsonMatch[0]) as MetadataResponse;
140140
}

src/settingsTab.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,11 +185,12 @@ export class MetadataToolSettingTab extends PluginSettingTab {
185185
.onChange(async (value) => {
186186
this.plugin.settings.enableTitle = value;
187187
await this.plugin.saveSettings();
188+
titleFieldNameSetting.setDisabled(!value);
188189
titlePromptSetting.setDisabled(!value);
189190
}),
190191
);
191192

192-
new Setting(containerEl)
193+
const titleFieldNameSetting = new Setting(containerEl)
193194
.setName("Title Field Name")
194195
.setDesc("Frontmatter field name for title")
195196
.addText((text) =>
@@ -214,6 +215,7 @@ export class MetadataToolSettingTab extends PluginSettingTab {
214215
text.inputEl.setAttr("rows", "3");
215216
});
216217

218+
titleFieldNameSetting.setDisabled(!this.plugin.settings.enableTitle);
217219
titlePromptSetting.setDisabled(!this.plugin.settings.enableTitle);
218220
}
219221
}

src/utils.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ export async function updateFrontMatter(
143143
method: "append" | "update" | "keep",
144144
): Promise<void> {
145145
await app.fileManager.processFrontMatter(file, (frontmatter) => {
146-
if (value === undefined || value === null) {
147-
return;
148-
}
149-
150146
if (method === "append") {
151147
let oldValue = frontmatter[key];
152148
if (typeof value === "string") {

0 commit comments

Comments
 (0)