-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
3155 lines (3137 loc) · 121 KB
/
Copy pathmain.js
File metadata and controls
3155 lines (3137 loc) · 121 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
// If the importer is in node compatibility mode or this is not an ESM
// file that has been converted to a CommonJS file using a Babel-
// compatible transform (i.e. "__esModule" has not been set), then set
// "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// main.ts
var main_exports = {};
__export(main_exports, {
default: () => main_default
});
module.exports = __toCommonJS(main_exports);
// src/plugin.ts
var import_obsidian5 = require("obsidian");
// src/constants.ts
var VIEW_TYPE_CLAUDE = "niki-ai-sidebar-view";
// src/i18n.ts
var I18N = {
"zh-CN": {
openSidebarCommand: "\u6253\u5F00 Niki AI \u4FA7\u8FB9\u680F",
sidebarTitle: "Niki AI Sidebar",
includeCurrentNote: "\u5305\u542B\u5F53\u524D\u7B14\u8BB0",
send: "\u53D1\u9001",
clear: "\u6E05\u7A7A",
inputPlaceholder: "\u5411 Niki AI \u63D0\u95EE...",
emptyState: "\u5F00\u59CB\u548C Niki AI \u5BF9\u8BDD\u5427\u3002",
emptyResponse: "(\u65E0\u56DE\u590D)",
thinkingPending: "Niki \u6B63\u5728\u601D\u8003...",
thinkingInline: "Niki \u6B63\u5728\u601D\u8003",
failedRunCommand: "\u8FD0\u884C Claude \u547D\u4EE4\u5931\u8D25\u3002",
claudeConnectionError: "\u9519\u8BEF\uFF1A\u65E0\u6CD5\u8FDE\u63A5\u5230 Claude CLI\u3002\n\n\u8BF7\u68C0\u67E5\uFF1A\n1. Claude CLI \u662F\u5426\u5DF2\u6B63\u786E\u5B89\u88C5\uFF1A\n npm install -g @anthropic-ai/claude-code\n2. \u547D\u4EE4\u662F\u5426\u5728\u7EC8\u7AEF\u4E2D\u53EF\u4EE5\u6B63\u5E38\u8FD0\u884C\n3. \u63D2\u4EF6\u8BBE\u7F6E\u4E2D\u7684 Claude command \u914D\u7F6E\n\n\u8BE6\u7EC6\u9519\u8BEF\uFF1A{message}",
claudeNotFoundNotice: "\u672A\u627E\u5230 Claude CLI\u3002\u8BF7\u5728\u8BBE\u7F6E\u91CC\u586B\u5199 Claude command\uFF0C\u6216\u628A claude \u52A0\u5165 PATH\u3002",
claudeNotFoundReply: "\u672A\u627E\u5230 Claude CLI\u3002\u8BF7\u5728\u8BBE\u7F6E\u91CC\u586B\u5199 Claude command\uFF0C\u6216\u628A claude \u52A0\u5165 PATH\u3002",
noActiveNote: "\u5F53\u524D\u6CA1\u6709\u53EF\u63D2\u5165\u7684\u7B14\u8BB0\u3002",
insertedInto: "\u5DF2\u63D2\u5165\u5230 {path}",
addedFile: "\u5DF2\u6DFB\u52A0: {name}",
unsupportedFileType: "\u4E0D\u652F\u6301\u7684\u6587\u4EF6\u7C7B\u578B\u3002\u53EA\u652F\u6301\u6587\u672C\u6587\u4EF6\uFF08\u5982 .md, .txt, .js \u7B49\uFF09\u3002",
roleYou: "\u4F60",
roleNiki: "Niki",
viewChanges: "\u67E5\u770B\u53D8\u66F4",
changesApplied: "\u5DF2\u5E94\u7528\u53D8\u66F4",
changesAppliedTo: "\u5DF2\u5E94\u7528\u53D8\u66F4\u5230 {path}",
applyAllChanges: "\u5E94\u7528\u5168\u90E8\u53D8\u66F4",
insertToNote: "\u63D2\u5165\u5230\u7B14\u8BB0",
copy: "\u590D\u5236",
copied: "\u5DF2\u590D\u5236",
noTargetFile: "\u6CA1\u6709\u53EF\u5E94\u7528\u53D8\u66F4\u7684\u76EE\u6807\u6587\u4EF6\u3002",
failedApplyChanges: "\u5E94\u7528\u53D8\u66F4\u5931\u8D25\uFF1A{message}",
unknownError: "\u672A\u77E5\u9519\u8BEF",
searchFilesPlaceholder: "\u641C\u7D22\u6587\u4EF6...",
settingTitle: "Niki AI Sidebar",
settingClaudeCommandName: "Claude command",
settingClaudeCommandDesc: "\u7528\u4E8E\u8FD0\u884C Claude Code \u7684\u547D\u4EE4\u3002\u4F7F\u7528 {prompt} \u5185\u8054\u63D0\u793A\u8BCD\uFF0C\u6216\u7559\u7A7A\u4EE5\u901A\u8FC7 stdin \u53D1\u9001\u3002",
settingClaudeCommandPlaceholder: 'claude -p "{prompt}"',
settingClaudePathName: "Claude path",
settingClaudePathDesc: "Claude CLI \u53EF\u6267\u884C\u6587\u4EF6\u7684\u5B8C\u6574\u8DEF\u5F84\uFF08Windows \u53EF\u586B claude.cmd\uFF09\u3002\u7559\u7A7A\u5219\u81EA\u52A8\u68C0\u6D4B\u3002",
settingNodePathName: "Node path",
settingNodePathDesc: "Node \u53EF\u6267\u884C\u6587\u4EF6\u7684\u5B8C\u6574\u8DEF\u5F84\uFF08Windows \u53EF\u586B node.exe\uFF09\u3002\u7559\u7A7A\u5219\u81EA\u52A8\u68C0\u6D4B\u3002",
settingGitBashPathName: "Git Bash path",
settingGitBashPathDesc: "Git Bash \u53EF\u6267\u884C\u6587\u4EF6\u7684\u5B8C\u6574\u8DEF\u5F84\uFF08Windows \u4F7F\u7528 shell \u6267\u884C\u65F6\u9700\u8981\uFF09\u3002\u7559\u7A7A\u5219\u81EA\u52A8\u68C0\u6D4B\u3002",
settingClaudeEditionName: "Claude \u7248\u672C\u9009\u62E9",
settingClaudeEditionDesc: "\u9009\u62E9\u4F7F\u7528\u54EA\u4E2A\u7248\u672C\u7684 Claude CLI\u3002auto=\u81EA\u52A8\u68C0\u6D4B\uFF0Cnpm=npm \u5B89\u88C5\u7248\u672C\uFF0Cnative=\u539F\u751F\u4E8C\u8FDB\u5236\u7248\u672C\uFF0Ccustom=\u81EA\u5B9A\u4E49\u8DEF\u5F84\u3002",
settingModelName: "\u6A21\u578B\u9009\u62E9",
settingModelDesc: "\u6307\u5B9A Claude CLI \u4F7F\u7528\u7684\u6A21\u578B\uFF08\u7B49\u4EF7\u4E8E --model\uFF09\u3002",
settingThinkingBudgetName: "\u601D\u8003\u6DF1\u5EA6",
settingThinkingBudgetDesc: "\u8BBE\u7F6E\u6269\u5C55\u601D\u8003\u6DF1\u5EA6\uFF08CLI \u4E0D\u652F\u6301\u65F6\u4EC5\u4F5C\u63D0\u793A\uFF09\u3002",
editionAuto: "\u81EA\u52A8\u68C0\u6D4B",
editionNpm: "npm \u7248\u672C",
editionNative: "\u539F\u751F\u7248\u672C",
editionCustom: "\u81EA\u5B9A\u4E49\u8DEF\u5F84",
pathHelpButton: "\u5E2E\u52A9",
pathHelpTitle: "\u8DEF\u5F84\u5E2E\u52A9",
pathHelpBody: "\u5982\u4F55\u627E\u5230 Claude / Node \u7684\u5B8C\u6574\u8DEF\u5F84\uFF1A\n\nWindows\uFF08\u63A8\u8350\uFF09:\n1) \u6253\u5F00 cmd \u6216 PowerShell\n2) \u8FD0\u884C: where claude\n3) \u8FD0\u884C: where node\n\n\u5982\u679C\u6CA1\u6709\u8F93\u51FA\uFF0C\u53EF\u5C1D\u8BD5\u4EE5\u4E0B\u5E38\u89C1\u8DEF\u5F84\uFF1A\n- %APPDATA%\\npm\\claude.cmd\n- C:\\Program Files\\nodejs\\node.exe\n- C:\\Program Files (x86)\\nodejs\\node.exe\n- %LOCALAPPDATA%\\Programs\\nodejs\\node.exe\n- %NVM_SYMLINK%\\node.exe\n\nmacOS/Linux:\n- \u8FD0\u884C: which claude\n- \u8FD0\u884C: which node",
settingDefaultPromptName: "Default prompt",
settingDefaultPromptDesc: "\u6BCF\u6B21\u8BF7\u6C42\u524D\u81EA\u52A8\u9644\u52A0\u7684\u7CFB\u7EDF\u63D0\u793A\u8BCD\u3002",
settingDefaultPromptPlaceholder: "\u4F60\u662F\u5D4C\u5165 Obsidian \u7684 Claude Code...",
settingWorkingDirName: "Working directory",
settingWorkingDirDesc: "Claude \u547D\u4EE4\u7684\u53EF\u9009\u5DE5\u4F5C\u76EE\u5F55\uFF0C\u9ED8\u8BA4\u4E3A vault \u8DEF\u5F84\u3002",
settingLanguageName: "Language",
settingLanguageDesc: "\u754C\u9762\u663E\u793A\u8BED\u8A00\u3002",
settingTaskTrackingName: "\u4EFB\u52A1\u8DDF\u8E2A",
settingTaskTrackingDesc: "\u5F15\u5BFC Niki \u8F93\u51FA\u7ED3\u6784\u5316\u4EFB\u52A1\u5217\u8868\uFF0C\u4EE5\u66F4\u65B0 Tasks \u9762\u677F\u3002",
taskTrackingPrompt: '\u5F53\u8BF7\u6C42\u5305\u542B\u591A\u4E2A\u6B65\u9AA4\u65F6\uFF0C\u8BF7\u5728\u56DE\u590D\u672B\u5C3E\u8FFD\u52A0\u4E00\u4E2A\u4EFB\u52A1\u5757\uFF0C\u683C\u5F0F\u5FC5\u987B\u5982\u4E0B\uFF1A\n```todo\n{"todos":[{"content":"...","status":"pending","activeForm":"..."}]}\n```\nstatus \u4EC5\u4F7F\u7528\uFF1Apending\u3001in_progress\u3001completed\u3002\u82E5\u65E0\u9700\u4EFB\u52A1\u5217\u8868\uFF0C\u8BF7\u7701\u7565\u8BE5\u5757\u3002',
undoChanges: "\u64A4\u9500\u4FEE\u6539",
undoSuccess: "\u5DF2\u64A4\u9500 {path} \u7684\u4FEE\u6539",
undoFailed: "\u64A4\u9500\u5931\u8D25\uFF1A{message}",
aboutSectionName: "\u5173\u4E8E\u672C\u63D2\u4EF6",
aboutVersion: "\u7248\u672C",
aboutAuthor: "\u4F5C\u8005",
aboutEmail: "\u90AE\u7BB1",
aboutLicense: "\u5F00\u6E90\u534F\u8BAE",
aboutRepository: "\u4EE3\u7801\u4ED3\u5E93",
aboutDescription: "\u7B80\u4ECB",
aboutDescriptionText: "Niki AI \u662F\u4E00\u4E2A Obsidian \u63D2\u4EF6\uFF0C\u96C6\u6210\u4E86 Claude Code CLI \u4F5C\u4E3A\u5BF9\u8BDD\u5F0F AI \u52A9\u624B\u3002\u4F60\u53EF\u4EE5\u5728\u4FA7\u8FB9\u680F\u4E0E Claude \u804A\u5929\uFF0C\u5305\u542B\u5F53\u524D\u7B14\u8BB0\u5185\u5BB9\u4F5C\u4E3A\u4E0A\u4E0B\u6587\uFF0C\u5E76\u5C06\u56DE\u590D\u76F4\u63A5\u63D2\u5165\u5230\u7B14\u8BB0\u4E2D\u3002",
assistantSectionName: "\u52A9\u624B\u9884\u8BBE",
assistantSectionDesc: "\u7BA1\u7406\u548C\u5207\u6362\u4E0D\u540C\u7684 AI \u52A9\u624B\uFF0C\u6BCF\u4E2A\u52A9\u624B\u6709\u72EC\u7ACB\u7684\u63D0\u793A\u8BCD\u914D\u7F6E\u3002",
assistantName: "\u52A9\u624B\u540D\u79F0",
assistantSystemPrompt: "\u7CFB\u7EDF\u63D0\u793A\u8BCD",
assistantAddNew: "\u6DFB\u52A0\u65B0\u52A9\u624B",
assistantDelete: "\u5220\u9664\u52A9\u624B",
assistantEdit: "\u7F16\u8F91\u52A9\u624B",
assistantDefaultName: "\u65B0\u52A9\u624B",
assistantDefaultPrompt: "\u4F60\u662F\u4E00\u4E2A AI \u52A9\u624B\u3002",
assistantCannotDeleteLast: "\u4E0D\u80FD\u5220\u9664\u6700\u540E\u4E00\u4E2A\u52A9\u624B\u9884\u8BBE",
currentAssistant: "\u5F53\u524D\u52A9\u624B",
sendInterrupt: "\u4E2D\u65AD",
sendSending: "\u53D1\u9001\u4E2D...",
tasksLabel: "\u4EFB\u52A1",
tasksExpandAria: "\u5C55\u5F00\u4EFB\u52A1\u5217\u8868 - \u5DF2\u5B8C\u6210 {completed}/{total}",
tasksCollapseAria: "\u6536\u8D77\u4EFB\u52A1\u5217\u8868 - \u5DF2\u5B8C\u6210 {completed}/{total}",
thinkingBudgetLabel: "\u601D\u8003:",
thinkingLabel: "Thought for {duration}s",
thinkingLabelShort: "Thought",
thinkingLive: "Thinking {duration}s...",
thinkingIndicatorHint: "esc to interrupt",
thinkingBlockAria: "\u6269\u5C55\u601D\u8003\u5185\u5BB9 - \u70B9\u51FB\u5C55\u5F00"
},
"en-US": {
openSidebarCommand: "Open Niki AI Sidebar",
sidebarTitle: "Niki AI Sidebar",
includeCurrentNote: "Include current note",
send: "Send",
clear: "Clear",
inputPlaceholder: "Ask Niki AI...",
emptyState: "Start a conversation with Niki AI.",
emptyResponse: "(empty response)",
thinkingPending: "Niki is thinking...",
thinkingInline: "Niki is thinking",
failedRunCommand: "Failed to run Claude command.",
claudeConnectionError: "Error: Unable to connect to Claude CLI.\n\nPlease check:\n1. Claude CLI is installed:\n npm install -g @anthropic-ai/claude-code\n2. Command works in terminal\n3. Claude command in settings\n\nDetails: {message}",
claudeNotFoundNotice: "Claude CLI not found. Configure Claude command or add claude to PATH.",
claudeNotFoundReply: "Claude CLI not found. Configure Claude command or add claude to PATH.",
noActiveNote: "No active note to insert into.",
insertedInto: "Inserted into {path}",
addedFile: "Added: {name}",
unsupportedFileType: "Unsupported file type. Only text files are supported (e.g., .md, .txt, .js, etc.).",
roleYou: "You",
roleNiki: "Niki",
viewChanges: "View changes",
changesApplied: "Changes applied",
changesAppliedTo: "Changes applied to {path}",
applyAllChanges: "Apply all changes",
insertToNote: "Insert to note",
copy: "Copy",
copied: "Copied",
noTargetFile: "No target file to apply changes to.",
failedApplyChanges: "Failed to apply changes: {message}",
unknownError: "Unknown error",
searchFilesPlaceholder: "Search files...",
settingTitle: "Niki AI Sidebar",
settingClaudeCommandName: "Claude command",
settingClaudeCommandDesc: "Command to run Claude Code. Use {prompt} to inline the prompt, or leave it out to send via stdin.",
settingClaudeCommandPlaceholder: 'claude -p "{prompt}"',
settingClaudePathName: "Claude path",
settingClaudePathDesc: "Full path to the Claude CLI executable (on Windows, use claude.cmd). Leave empty to auto-detect.",
settingNodePathName: "Node path",
settingNodePathDesc: "Full path to the Node executable (on Windows, use node.exe). Leave empty to auto-detect.",
settingGitBashPathName: "Git Bash path",
settingGitBashPathDesc: "Full path to the Git Bash executable (needed for shell execution on Windows). Leave empty to auto-detect.",
settingClaudeEditionName: "Claude Edition",
settingClaudeEditionDesc: "Choose which Claude CLI version to use. auto=auto-detect, npm=npm installed version, native=native binary, custom=custom path.",
settingModelName: "Model",
settingModelDesc: "Model to use for Claude CLI (equivalent to --model).",
settingThinkingBudgetName: "Thinking depth",
settingThinkingBudgetDesc: "Controls extended thinking budget (hint only when CLI doesn't support it).",
editionAuto: "Auto-detect",
editionNpm: "npm version",
editionNative: "Native version",
editionCustom: "Custom path",
pathHelpButton: "Help",
pathHelpTitle: "Path Help",
pathHelpBody: "How to find the full paths for Claude / Node:\n\nWindows (recommended):\n1) Open cmd or PowerShell\n2) Run: where claude\n3) Run: where node\n\nIf there is no output, try these common locations:\n- %APPDATA%\\npm\\claude.cmd\n- C:\\Program Files\\nodejs\\node.exe\n- C:\\Program Files (x86)\\nodejs\\node.exe\n- %LOCALAPPDATA%\\Programs\\nodejs\\node.exe\n- %NVM_SYMLINK%\\node.exe\n\nmacOS/Linux:\n- Run: which claude\n- Run: which node",
settingDefaultPromptName: "Default prompt",
settingDefaultPromptDesc: "Prepended to every request.",
settingDefaultPromptPlaceholder: "You are Claude Code embedded in Obsidian...",
settingWorkingDirName: "Working directory",
settingWorkingDirDesc: "Optional cwd for the Claude command. Defaults to vault path.",
settingLanguageName: "Language",
settingLanguageDesc: "Language for the UI.",
settingTaskTrackingName: "Task tracking",
settingTaskTrackingDesc: "Ask Niki to output a structured task list so the Tasks panel can update.",
taskTrackingPrompt: 'When the request has multiple steps, append a task block at the end of your reply using this exact format:\n```todo\n{"todos":[{"content":"...","status":"pending","activeForm":"..."}]}\n```\nUse status values: pending, in_progress, completed. Omit the block if no task list is needed.',
undoChanges: "Undo changes",
undoSuccess: "Undone changes to {path}",
undoFailed: "Undo failed: {message}",
aboutSectionName: "About",
aboutVersion: "Version",
aboutAuthor: "Author",
aboutEmail: "Email",
aboutLicense: "License",
aboutRepository: "Repository",
aboutDescription: "Description",
aboutDescriptionText: "Niki AI is an Obsidian plugin that integrates Claude Code CLI as a conversational AI assistant. You can chat with Claude in the sidebar, include current note content as context, and insert responses directly into your notes.",
assistantSectionName: "Assistant Presets",
assistantSectionDesc: "Manage and switch between different AI assistants, each with independent prompt configuration.",
assistantName: "Assistant Name",
assistantSystemPrompt: "System Prompt",
assistantAddNew: "Add New Assistant",
assistantDelete: "Delete Assistant",
assistantEdit: "Edit Assistant",
assistantDefaultName: "New Assistant",
assistantDefaultPrompt: "You are an AI assistant.",
assistantCannotDeleteLast: "Cannot delete the last assistant preset",
currentAssistant: "Current Assistant",
sendInterrupt: "Stop",
sendSending: "Sending...",
tasksLabel: "Tasks",
tasksExpandAria: "Expand task list - {completed} of {total} completed",
tasksCollapseAria: "Collapse task list - {completed} of {total} completed",
thinkingBudgetLabel: "Thinking:",
thinkingLabel: "Thought for {duration}s",
thinkingLabelShort: "Thought",
thinkingLive: "Thinking {duration}s...",
thinkingIndicatorHint: "esc to interrupt",
thinkingBlockAria: "Extended thinking - click to expand"
}
};
function t(language, key) {
var _a, _b;
return (_b = ((_a = I18N[language]) != null ? _a : I18N["zh-CN"])[key]) != null ? _b : I18N["zh-CN"][key];
}
function format(template, vars) {
return template.replace(/\{(\w+)\}/g, (_, key) => {
var _a;
return (_a = vars[key]) != null ? _a : "";
});
}
// src/settings/defaults.ts
var DEFAULT_SETTINGS = {
claudeCommand: "",
claudePath: "",
claudeEdition: "auto",
nodePath: "",
gitBashPath: "",
model: "haiku",
thinkingBudget: "off",
defaultPrompt: "You are Niki AI embedded in Obsidian (powered by Claude Code). Help me edit Markdown notes.\nWhen you propose changes, be explicit and keep the style consistent.",
workingDir: "",
language: "zh-CN",
includeCurrentNote: false,
enableTaskTracking: true,
topics: [],
currentTopicId: null,
assistantPresets: [
{
id: "assistant_default",
name: "\u9ED8\u8BA4\u52A9\u624B",
systemPrompt: "You are Niki AI embedded in Obsidian (powered by Claude Code). Help me edit Markdown notes.\nWhen you propose changes, be explicit and keep the style consistent."
}
],
currentAssistantId: "assistant_default"
};
// src/view/ClaudeSidebarView.ts
var import_obsidian2 = require("obsidian");
var import_child_process = require("child_process");
// src/utils/claudeCli.ts
var import_fs = __toESM(require("fs"), 1);
var import_os = __toESM(require("os"), 1);
var import_path = __toESM(require("path"), 1);
var ANSI_REGEX = new RegExp("[\x1B\x9B][[]()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]", "g");
function sanitizeStreamOutput(input) {
return input.replace(ANSI_REGEX, "").replace(/\r\n/g, "\n").replace(/\r/g, "\n");
}
function normalizeCommand(command) {
if (!command) {
return "";
}
const trimmed = command.trim();
if (!trimmed) {
return "";
}
const firstToken = trimmed.split(/\s+/)[0];
if (firstToken && isDirectory(firstToken)) {
const resolved = import_path.default.join(firstToken, "claude");
return trimmed.replace(firstToken, resolved);
}
return trimmed;
}
function findClaudeBinary(preferredPath, edition = "auto") {
const home = import_os.default.homedir();
const isWindows = process.platform === "win32";
if (edition === "custom") {
if (preferredPath) {
const candidate = preferredPath.trim();
if (candidate && isExecutable(candidate)) {
return candidate;
}
}
return "";
}
const npmCandidates = [];
const nativeCandidates = [];
if (isWindows) {
const appData = process.env.APPDATA || import_path.default.join(home, "AppData", "Roaming");
npmCandidates.push(
import_path.default.join(appData, "npm", "claude.cmd"),
import_path.default.join(appData, "npm", "claude")
);
nativeCandidates.push(
import_path.default.join(home, ".claude", "bin", "claude.exe"),
import_path.default.join(home, ".claude", "bin", "claude.cmd")
);
} else {
npmCandidates.push(import_path.default.join(home, ".npm-global", "bin", "claude"));
nativeCandidates.push(
import_path.default.join(home, ".local", "bin", "claude"),
import_path.default.join(home, ".claude", "bin", "claude")
);
}
nativeCandidates.push(
"/opt/homebrew/bin/claude",
"/usr/local/bin/claude",
"/usr/bin/claude"
);
let candidates = [];
if (edition === "custom") {
if (preferredPath) {
const candidate = preferredPath.trim();
if (candidate && isExecutable(candidate)) {
return candidate;
}
}
return "";
} else if (edition === "npm") {
candidates = [...npmCandidates, ...nativeCandidates];
} else if (edition === "native") {
candidates = [...nativeCandidates, ...npmCandidates];
} else {
if (preferredPath) {
const candidate = preferredPath.trim();
if (candidate && isExecutable(candidate)) {
return candidate;
}
}
candidates = [...npmCandidates, ...nativeCandidates];
}
for (const candidate of candidates) {
if (isExecutable(candidate)) {
return candidate;
}
}
return "";
}
function windowsPathToGitBash(windowsPath) {
const match = windowsPath.match(/^([A-Za-z]):\\(.*)$/);
if (match) {
const drive = match[1].toLowerCase();
const rest = match[2].replace(/\\/g, "/");
return `/${drive}/${rest}`;
}
return windowsPath.replace(/\\/g, "/");
}
function buildEnv(preferredNodePath, gitBashPath) {
const env = { ...process.env };
const home = import_os.default.homedir();
env.HOME = env.HOME || home;
const nodeBinary = findNodeBinary(preferredNodePath);
const nodeDir = nodeBinary ? import_path.default.dirname(nodeBinary) : "";
const isWindows = process.platform === "win32";
const usingGitBash = isWindows && gitBashPath && gitBashPath.trim();
let extra = [];
if (isWindows) {
const appData = process.env.APPDATA || import_path.default.join(home, "AppData", "Roaming");
const localAppData = process.env.LOCALAPPDATA || import_path.default.join(home, "AppData", "Local");
const programFiles = process.env.ProgramFiles || "C:\\Program Files";
const programFilesX86 = process.env["ProgramFiles(x86)"] || "C:\\Program Files (x86)";
const nvmHome = process.env.NVM_HOME;
const nvmSymlink = process.env.NVM_SYMLINK;
extra = [
import_path.default.join(appData, "npm"),
import_path.default.join(programFiles, "nodejs"),
import_path.default.join(programFilesX86, "nodejs"),
import_path.default.join(localAppData, "Programs", "nodejs"),
...nvmSymlink ? [nvmSymlink] : [],
...nvmHome ? [nvmHome] : []
];
} else {
extra = [
import_path.default.join(home, ".npm-global", "bin"),
import_path.default.join(home, ".local", "bin"),
import_path.default.join(home, ".volta", "bin"),
import_path.default.join(home, ".asdf", "shims"),
import_path.default.join(home, ".nvm", "versions", "node"),
"/opt/homebrew/bin",
"/usr/local/bin",
"/usr/bin"
];
}
const currentPath = env.PATH || "";
const parts = currentPath.split(import_path.default.delimiter).filter(Boolean);
const merged = [...nodeDir ? [nodeDir] : [], ...extra, ...parts];
if (usingGitBash) {
const convertedPaths = Array.from(new Set(merged)).map(windowsPathToGitBash);
env.PATH = convertedPaths.join(":");
} else {
env.PATH = Array.from(new Set(merged)).join(import_path.default.delimiter);
}
return env;
}
function resolveClaudeTimeoutMs(env) {
const defaultTimeout = 3e5;
const settingsTimeout = readClaudeSettingsTimeoutMs();
if (settingsTimeout !== null) {
return settingsTimeout;
}
const envTimeout = parseTimeoutMs(env.API_TIMEOUT_MS);
return envTimeout != null ? envTimeout : defaultTimeout;
}
function readClaudeSettingsTimeoutMs() {
var _a;
const home = import_os.default.homedir();
const settingsPath = import_path.default.join(home, ".claude", "settings.json");
try {
const raw = import_fs.default.readFileSync(settingsPath, "utf8");
const parsed = JSON.parse(raw);
const value = (_a = parsed.env) == null ? void 0 : _a.API_TIMEOUT_MS;
return parseTimeoutMs(value === void 0 ? void 0 : String(value));
} catch (e) {
return null;
}
}
function parseTimeoutMs(value) {
if (!value) {
return null;
}
const parsed = Number.parseInt(value, 10);
if (!Number.isFinite(parsed) || parsed <= 0) {
return null;
}
return parsed;
}
function isExecutable(target) {
try {
if (process.platform === "win32") {
import_fs.default.accessSync(target, import_fs.default.constants.F_OK);
return true;
}
import_fs.default.accessSync(target, import_fs.default.constants.X_OK);
return true;
} catch (e) {
return false;
}
}
function isDirectory(target) {
try {
return import_fs.default.statSync(target).isDirectory();
} catch (e) {
return false;
}
}
function isNodeScript(target) {
try {
const fd = import_fs.default.openSync(target, "r");
const buffer = Buffer.alloc(200);
const bytes = import_fs.default.readSync(fd, buffer, 0, buffer.length, 0);
import_fs.default.closeSync(fd);
const firstLine = buffer.toString("utf8", 0, bytes).split("\n")[0];
return firstLine.includes("node");
} catch (e) {
return false;
}
}
function findNodeBinary(preferredPath) {
if (preferredPath) {
const candidate = preferredPath.trim();
if (candidate && isExecutable(candidate)) {
return candidate;
}
}
const home = import_os.default.homedir();
const isWindows = process.platform === "win32";
const localAppData = process.env.LOCALAPPDATA || import_path.default.join(home, "AppData", "Local");
const programFiles = process.env.ProgramFiles || "C:\\Program Files";
const programFilesX86 = process.env["ProgramFiles(x86)"] || "C:\\Program Files (x86)";
const nvmHome = process.env.NVM_HOME;
const nvmSymlink = process.env.NVM_SYMLINK;
const direct = isWindows ? [
nvmSymlink ? import_path.default.join(nvmSymlink, "node.exe") : "",
nvmHome ? import_path.default.join(nvmHome, "node.exe") : "",
import_path.default.join(programFiles, "nodejs", "node.exe"),
import_path.default.join(programFilesX86, "nodejs", "node.exe"),
import_path.default.join(localAppData, "Programs", "nodejs", "node.exe")
].filter(Boolean) : [
import_path.default.join(home, ".volta", "bin", "node"),
import_path.default.join(home, ".asdf", "shims", "node"),
import_path.default.join(home, ".nvm", "versions", "node", "bin", "node"),
"/opt/homebrew/bin/node",
"/usr/local/bin/node",
"/usr/bin/node"
];
for (const candidate of direct) {
if (isExecutable(candidate)) {
return candidate;
}
}
if (!isWindows) {
const nvmRoot = import_path.default.join(home, ".nvm", "versions", "node");
try {
const versions = import_fs.default.readdirSync(nvmRoot).map((entry) => import_path.default.join(nvmRoot, entry, "bin", "node")).filter((candidate) => isExecutable(candidate)).sort();
if (versions.length > 0) {
return versions[versions.length - 1];
}
} catch (e) {
}
}
return "";
}
function replacePlaceholder(command, prompt) {
if (/"\{prompt\}"/.test(command)) {
const escaped2 = prompt.replace(/\\/g, "\\\\").replace(/\$/g, "\\$").replace(/`/g, "\\`").replace(/"/g, '\\"').replace(/\n/g, " ").replace(/\r/g, " ");
return command.replace(/"\{prompt\}"/g, `"${escaped2}"`);
}
if (/'\{prompt\}'/.test(command)) {
const escaped2 = prompt.replace(/'/g, "'\\''");
return command.replace(/'\{prompt\}'/g, `'${escaped2}'`);
}
const escaped = prompt.replace(/'/g, "'\\''");
return command.replace(/\{prompt\}/g, `'${escaped}'`);
}
function attachStreamBuffers(child, onChunk) {
const combined = [];
const append = (chunk) => {
const sanitized = sanitizeStreamOutput(chunk);
if (!sanitized) {
return;
}
combined.push(sanitized);
if (onChunk) {
onChunk(sanitized);
}
};
if (child.stdout) {
child.stdout.setEncoding("utf8");
child.stdout.on("data", (chunk) => append(String(chunk)));
}
if (child.stderr) {
child.stderr.setEncoding("utf8");
child.stderr.on("data", (chunk) => append(String(chunk)));
}
return {
getCombined: () => combined.join("")
};
}
// src/utils/diff.ts
function computeDiff(original, modified) {
const originalLines = original.split("\n");
const modifiedLines = modified.split("\n");
const changes = [];
const lcs = longestCommonSubsequence(originalLines, modifiedLines);
let origIdx = 0;
let modIdx = 0;
for (const line of lcs) {
while (origIdx < originalLines.length && originalLines[origIdx] !== line) {
changes.push({
type: "removed",
originalLine: origIdx + 1,
content: originalLines[origIdx]
});
origIdx++;
}
while (modIdx < modifiedLines.length && modifiedLines[modIdx] !== line) {
changes.push({
type: "added",
newLine: modIdx + 1,
content: modifiedLines[modIdx]
});
modIdx++;
}
if (origIdx < originalLines.length && modIdx < modifiedLines.length) {
changes.push({
type: "unchanged",
originalLine: origIdx + 1,
newLine: modIdx + 1,
content: line
});
origIdx++;
modIdx++;
}
}
while (origIdx < originalLines.length) {
changes.push({
type: "removed",
originalLine: origIdx + 1,
content: originalLines[origIdx]
});
origIdx++;
}
while (modIdx < modifiedLines.length) {
changes.push({
type: "added",
newLine: modIdx + 1,
content: modifiedLines[modIdx]
});
modIdx++;
}
return { changes };
}
function longestCommonSubsequence(arr1, arr2) {
const m = arr1.length;
const n = arr2.length;
const dp = Array(m + 1).fill(0).map(() => Array(n + 1).fill(0));
for (let i2 = 1; i2 <= m; i2++) {
for (let j2 = 1; j2 <= n; j2++) {
dp[i2][j2] = arr1[i2 - 1] === arr2[j2 - 1] ? dp[i2 - 1][j2 - 1] + 1 : Math.max(dp[i2 - 1][j2], dp[i2][j2 - 1]);
}
}
const lcs = [];
let i = m;
let j = n;
while (i > 0 && j > 0) {
if (arr1[i - 1] === arr2[j - 1]) {
lcs.unshift(arr1[i - 1]);
i--;
j--;
} else if (dp[i - 1][j] > dp[i][j - 1]) {
i--;
} else {
j--;
}
}
return lcs;
}
// src/utils/tasks.ts
var import_obsidian = require("obsidian");
function extractTasksFromReply(reply) {
const parsed = parseTasksFromText(reply);
if (parsed.tasks && parsed.block) {
const cleaned = reply.replace(parsed.block, "").replace(/\n{3,}/g, "\n\n").trim();
return { content: cleaned, tasks: parsed.tasks };
}
return { content: reply.trim(), tasks: parsed.tasks };
}
function parseTasksFromText(text) {
var _a;
const codeBlockRegex = /```(todo|tasks|tasklist|json)\s*\n([\s\S]*?)```/gi;
let match;
while ((match = codeBlockRegex.exec(text)) !== null) {
const raw = match[2].trim();
const tasks = parseTodoJson(raw);
if (tasks && tasks.length > 0) {
return { tasks, block: match[0] };
}
}
const tagMatch = text.match(/<tasks>([\s\S]*?)<\/tasks>/i);
if (tagMatch) {
const raw = tagMatch[1].trim();
const tasks = (_a = parseTodoJson(raw)) != null ? _a : parseMarkdownTasks(raw);
if (tasks && tasks.length > 0) {
return { tasks, block: tagMatch[0] };
}
}
const markdownTasks = parseMarkdownTasks(text);
if (markdownTasks.length > 0) {
return { tasks: markdownTasks };
}
return { tasks: null };
}
function renderTaskItems(container, tasks) {
container.empty();
for (const task of tasks) {
const item = container.createDiv({
cls: `claude-code-task-item claude-code-task-${task.status}`
});
const icon = item.createSpan({ cls: "claude-code-task-status-icon" });
icon.setAttribute("aria-hidden", "true");
(0, import_obsidian.setIcon)(icon, task.status === "completed" ? "check" : "dot");
const text = item.createSpan({ cls: "claude-code-task-text" });
text.setText(task.status === "in_progress" && task.activeForm ? task.activeForm : task.content);
}
}
function parseTodoJson(raw) {
var _a, _b, _c, _d, _e;
const payload = extractJsonPayload(raw);
let parsed;
try {
parsed = JSON.parse(payload);
} catch (e) {
return null;
}
const items = Array.isArray(parsed) ? parsed : (_b = (_a = parsed.todos) != null ? _a : parsed.tasks) != null ? _b : parsed.items;
if (!Array.isArray(items)) {
return null;
}
const tasks = [];
for (const item of items) {
if (typeof item === "string") {
const content2 = item.trim();
if (content2) {
tasks.push({ content: content2, status: "pending" });
}
continue;
}
if (!item || typeof item !== "object") {
continue;
}
const record = item;
const rawContent = (_e = (_d = (_c = record.content) != null ? _c : record.text) != null ? _d : record.title) != null ? _e : "";
const content = (typeof rawContent === "string" ? rawContent : "").trim();
if (!content) {
continue;
}
const activeForm = typeof record.activeForm === "string" ? record.activeForm : typeof record.active_form === "string" ? record.active_form : void 0;
const rawStatus = typeof record.status === "string" ? record.status : typeof record.state === "string" ? record.state : void 0;
const status = normalizeTaskStatus(
rawStatus,
record.done === true ? "x" : void 0,
Boolean(activeForm)
);
tasks.push({ content, status, activeForm });
}
return tasks.length > 0 ? tasks : null;
}
function extractJsonPayload(raw) {
const trimmed = raw.trim();
const firstBrace = trimmed.indexOf("{");
const lastBrace = trimmed.lastIndexOf("}");
if (firstBrace !== -1 && lastBrace > firstBrace) {
return trimmed.slice(firstBrace, lastBrace + 1);
}
const firstBracket = trimmed.indexOf("[");
const lastBracket = trimmed.lastIndexOf("]");
if (firstBracket !== -1 && lastBracket > firstBracket) {
return trimmed.slice(firstBracket, lastBracket + 1);
}
return trimmed;
}
function normalizeTaskStatus(value, checkbox, hasActiveForm) {
var _a;
const normalized = (_a = value == null ? void 0 : value.toLowerCase().replace(/[\s-]+/g, "_")) != null ? _a : "";
if (normalized === "completed" || normalized === "done" || normalized === "finished") {
return "completed";
}
if (normalized === "in_progress" || normalized === "inprogress" || normalized === "doing" || normalized === "working") {
return "in_progress";
}
if (normalized === "pending" || normalized === "todo" || normalized === "queued") {
return "pending";
}
if (checkbox) {
if (checkbox.toLowerCase() === "x") {
return "completed";
}
if (checkbox === ">" || checkbox === "~") {
return "in_progress";
}
}
return hasActiveForm ? "in_progress" : "pending";
}
function parseMarkdownTasks(text) {
const tasks = [];
const lines = text.split(/\r?\n/);
let inCodeBlock = false;
for (const line of lines) {
if (/^\s*```/.test(line)) {
inCodeBlock = !inCodeBlock;
continue;
}
if (inCodeBlock) {
continue;
}
const match = line.match(/^\s*[-*]\s+\[(.)\]\s+(.*)$/);
if (!match) {
continue;
}
const content = match[2].trim();
if (!content) {
continue;
}
tasks.push({
content,
status: normalizeTaskStatus(void 0, match[1])
});
}
return tasks;
}
// src/models.ts
var DEFAULT_CLAUDE_MODELS = [
{ value: "haiku", label: "Haiku", description: "Fast and efficient" },
{ value: "sonnet", label: "Sonnet", description: "Balanced performance" },
{ value: "opus", label: "Opus", description: "Most capable" }
];
var THINKING_BUDGETS = [
{ value: "off", label: "Off", tokens: 0 },
{ value: "low", label: "Low", tokens: 4e3 },
{ value: "medium", label: "Med", tokens: 8e3 },
{ value: "high", label: "High", tokens: 16e3 },
{ value: "xhigh", label: "Ultra", tokens: 32e3 }
];
var DEFAULT_THINKING_BUDGET = {
haiku: "off",
sonnet: "low",
opus: "medium"
};
// src/view/ClaudeSidebarView.ts
var LOGO_SVG = {
viewBox: "0 -.01 39.5 39.53",
width: "18",
height: "18",
path: "m7.75 26.27 7.77-4.36.13-.38-.13-.21h-.38l-1.3-.08-4.44-.12-3.85-.16-3.73-.2-.94-.2-.88-1.16.09-.58.79-.53 1.13.1 2.5.17 3.75.26 2.72.16 4.03.42h.64l.09-.26-.22-.16-.17-.16-3.88-2.63-4.2-2.78-2.2-1.6-1.19-.81-.6-.76-.26-1.66 1.08-1.19 1.45.1.37.1 1.47 1.13 3.14 2.43 4.1 3.02.6.5.24-.17.03-.12-.27-.45-2.23-4.03-2.38-4.1-1.06-1.7-.28-1.02c-.1-.42-.17-.77-.17-1.2l1.23-1.67.68-.22 1.64.22.69.6 1.02 2.33 1.65 3.67 2.56 4.99.75 1.48.4 1.37.15.42h.26v-.24l.21-2.81.39-3.45.38-4.44.13-1.25.62-1.5 1.23-.81.96.46.79 1.13-.11.73-.47 3.05-.92 4.78-.6 3.2h.35l.4-.4 1.62-2.15 2.72-3.4 1.2-1.35 1.4-1.49.9-.71h1.7l1.25 1.86-.56 1.92-1.75 2.22-1.45 1.88-2.08 2.8-1.3 2.24.12.18.31-.03 4.7-1 2.54-.46 3.03-.52 1.37.64.15.65-.54 1.33-3.24.8-3.8.76-5.66 1.34-.07.05.08.1 2.55.24 1.09.06h2.67l4.97.37 1.3.86.78 1.05-.13.8-2 1.02-2.7-.64-6.3-1.5-2.16-.54h-.3v.18l1.8 1.76 3.3 2.98 4.13 3.84.21.95-.53.75-.56-.08-3.63-2.73-1.4-1.23-3.17-2.67h-.21v.28l.73 1.07 3.86 5.8.2 1.78-.28.58-1 .35-1.1-.2-2.26-3.17-2.33-3.57-1.88-3.2-.23.13-1.11 11.95-.52.61-1.2.46-1-.76-.53-1.23.53-2.43.64-3.17.52-2.52.47-3.13.28-1.04-.02-.07-.23.03-2.36 3.24-3.59 4.85-2.84 3.04-.68.27-1.18-.61.11-1.09.66-.97 3.93-5 2.37-3.1 1.53-1.79-.01-.26h-.09l-10.44 6.78-1.86.24-.8-.75.1-1.23.38-.4 3.14-2.16z",
fill: "#d97757"
};
var FLAVOR_TEXTS = [
// Classic
"Thinking...",
"Pondering...",
"Processing...",
"Analyzing...",
"Considering...",
"Working on it...",
"One moment...",
"On it...",
// Thoughtful
"Ruminating...",
"Contemplating...",
"Reflecting...",
"Mulling it over...",
"Let me think...",
"Hmm...",
"Cogitating...",
"Deliberating...",
"Weighing options...",
"Gathering thoughts...",
// Playful
"Brewing ideas...",
"Connecting dots...",
"Assembling thoughts...",
"Spinning up neurons...",
"Loading brilliance...",
"Consulting the oracle...",
"Summoning knowledge...",
"Crunching thoughts...",
"Dusting off neurons...",
"Wrangling ideas...",
"Herding thoughts...",
"Juggling concepts...",
"Untangling this...",
"Piecing it together...",
// Cozy
"Sipping coffee...",
"Warming up...",
"Getting cozy with this...",
"Settling in...",
"Making tea...",
"Grabbing a snack...",
// Technical
"Parsing...",
"Compiling thoughts...",
"Running inference...",
"Querying the void...",
"Defragmenting brain...",
"Allocating memory...",
"Optimizing...",
"Indexing...",
"Syncing neurons...",
// Zen
"Breathing...",
"Finding clarity...",
"Channeling focus...",
"Centering...",
"Aligning chakras...",
"Meditating on this...",
// Whimsical
"Asking the stars...",
"Reading tea leaves...",
"Shaking the magic 8-ball...",
"Consulting ancient scrolls...",
"Decoding the matrix...",
"Communing with the ether...",
"Peering into the abyss...",
"Channeling the cosmos...",
// Action
"Diving in...",
"Rolling up sleeves...",
"Getting to work...",
"Tackling this...",
"On the case...",
"Investigating...",
"Exploring...",
"Digging deeper...",
// Casual
"Bear with me...",
"Hang tight...",
"Just a sec...",
"Working my magic...",
"Almost there...",
"Give me a moment..."
];
var ClaudeSidebarView = class extends import_obsidian2.ItemView {
// 上次更新时间
constructor(leaf, plugin) {
super(leaf);
this.messages = [];
this.loaded = false;
this.mentionedItems = [];
this.isSending = false;
this.currentProcess = null;
this.isTasksExpanded = false;
this.streamRenderScheduled = false;
this.streamRenderTimer = null;
this.boundEscKeyHandler = null;
this.currentStreamingContentEl = null;
// 打字机效果相关
this.typewriterBuffer = [];
// 待显示的字符队列
this.typewriterTimer = null;
this.typewriterLastTime = 0;
this.handleOutsideClick = (e) => {
if (this.filePickerEl && !this.filePickerEl.contains(e.target) && !this.inputEl.contains(e.target)) {
this.hideFilePicker();
}
};
this.plugin = plugin;
}
getViewType() {
return VIEW_TYPE_CLAUDE;
}
getDisplayText() {
return "Niki AI";
}
async onOpen() {
const container = this.containerEl;
container.empty();
container.addClass("claude-code-sidebar");
const shell = container.createDiv("claude-code-shell");
const header = shell.createDiv("claude-code-header");
header.createDiv({ text: "Niki AI" }).addClass("claude-code-title");
const topicControl = header.createDiv("claude-code-topic-control-inline");
const topicSelector = topicControl.createDiv("claude-code-topic-selector-inline");
this.topicSelectEl = topicSelector.createEl("select", {
cls: "claude-code-topic-select-inline"
});
const topicActions = topicControl.createDiv("claude-code-topic-actions-inline");
this.newTopicBtn = topicActions.createEl("button", {
text: "+",
cls: "claude-code-topic-btn-inline claude-code-topic-new"
});
this.newTopicBtn.setAttribute("aria-label", "\u65B0\u5EFA\u8BDD\u9898");
this.deleteTopicBtn = topicActions.createEl("button", {
text: "\xD7",
cls: "claude-code-topic-btn-inline claude-code-topic-delete"
});
this.deleteTopicBtn.setAttribute("aria-label", "\u5220\u9664\u8BDD\u9898");
const body = shell.createDiv("claude-code-body");
const messagesWrapper = body.createDiv("claude-code-messages-wrapper");
this.messagesEl = messagesWrapper.createDiv("claude-code-messages");
const composerShell = body.createDiv("claude-code-composer-shell");
this.composerEl = composerShell.createDiv("claude-code-composer");
const composer = this.composerEl;
this.mentionTagsEl = composer.createDiv("claude-code-mention-tags");
const topRow = composer.createDiv("claude-code-top-row");
const controls = topRow.createDiv("claude-code-controls");
const includeNoteWrap = controls.createDiv("claude-code-toggle");
this.includeNoteEl = includeNoteWrap.createEl("input", {
type: "checkbox"
});
this.includeNoteEl.checked = this.plugin.settings.includeCurrentNote;
includeNoteWrap.createEl("span", { text: this.plugin.t("includeCurrentNote") });
const actions = topRow.createDiv("claude-code-actions");
this.assistantSelectEl = actions.createEl("select", {
cls: "claude-code-assistant-select"
});
this.sendBtn = actions.createEl("button", {
text: this.plugin.t("send"),
cls: "mod-cta"
});
const clearBtn = actions.createEl("button", { text: this.plugin.t("clear") });
const toolbarRow = composer.createDiv("claude-code-toolbar");