210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
# File 'lib/obsidian_fetch.rb', line 210
def tool_list name
name = Vault.normalize_note_name(name)
split_name = name.split(/[\s ]+/)
if split_name.empty?
return " It cannot be listed in a blank string.\n EOS\n end\n matched_notes = @notes.select do |note_name, _file_pathes|\n split_name.map {|name_part| note_name.include?(name_part) }.all?\n end\n # \u540D\u524D\u3067\u691C\u7D22\u3057\u305F\u304C\u898B\u3064\u304B\u3089\u306A\u3044\u5834\u5408\n if matched_notes.empty?\n has_found_link = @links_by_file_name[name] && !@links_by_file_name[name].empty?\n return <<~EOS unless has_found_link\n Note not found: \#{name}\n Search again with a substring or a string with a different notation.\n EOS\n return <<~EOS\n Note not found: \#{name}\n However, I found other notes linked to this note.\n \#{@links_by_file_name[name].shuffle.map { |file_path| \"- \#{File.basename(file_path, '.md')}\" }.join(\"\\n\")}\n EOS\n end\n # \u30DE\u30C3\u30C1\u3057\u305F\u540D\u524D\u306E\u6570\u304C\u591A\u3059\u304E\u308B\u5834\u5408\u306F\u3001\u30E9\u30F3\u30C0\u30E0\u306BMAX_LIST_SIZE\u500B\u9078\u3076\n preface = \"Notes matching '\#{name}' are as follows.\\n\"\n if matched_notes.size > MAX_LIST_SIZE\n matched_notes = matched_notes.to_a.sample(MAX_LIST_SIZE).to_h\n preface = \"Too many notes matched. I will show you only \#{MAX_LIST_SIZE} of them.\\n\" + preface\n end\n # \u30DE\u30C3\u30C1\u3057\u305F\u540D\u524D\u306E\u30EA\u30B9\u30C8\u3067\u8FD4\u3059\n list = matched_notes.keys.shuffle.map do |note_name|\n \"- \#{note_name}\"\n end.join(\"\\n\")\n preface + list\nend\n"
|