• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

knowledgepixels / nanodash / 29339875990

14 Jul 2026 02:13PM UTC coverage: 28.495% (-0.8%) from 29.306%
29339875990

Pull #557

github

web-flow
Merge 8ed1c6062 into e89f67f90
Pull Request #557: feat: chat with local Claude Code via MCP endpoint

1986 of 7652 branches covered (25.95%)

Branch coverage included in aggregate %.

3892 of 12976 relevant lines covered (29.99%)

4.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.07
src/main/java/com/knowledgepixels/nanodash/NanodashPreferences.java
1
package com.knowledgepixels.nanodash;
2

3
import org.slf4j.Logger;
4
import org.slf4j.LoggerFactory;
5
import tools.jackson.core.JacksonException;
6
import tools.jackson.databind.ObjectMapper;
7
import tools.jackson.dataformat.yaml.YAMLMapper;
8

9
import java.io.File;
10
import java.io.Serializable;
11
import java.util.ArrayList;
12
import java.util.Arrays;
13
import java.util.List;
14

15
/**
16
 * Class to manage Nanodash preferences.
17
 */
18
public class NanodashPreferences implements Serializable {
6✔
19

20
    private static NanodashPreferences obj;
21
    private static final Logger logger = LoggerFactory.getLogger(NanodashPreferences.class);
12✔
22

23
    /**
24
     * Get the singleton instance of NanodashPreferences.
25
     *
26
     * @return the NanodashPreferences instance
27
     */
28
    public static NanodashPreferences get() {
29
        if (obj == null) {
6✔
30
            File prefFile = new File(System.getProperty("user.home") + DEFAULT_SETTING_PATH);
21✔
31
            if (!prefFile.exists()) {
9✔
32
                return new NanodashPreferences();
12✔
33
            }
34
            ObjectMapper mapper = new YAMLMapper();
12✔
35
            try {
36
                obj = mapper.readValue(prefFile, NanodashPreferences.class);
18✔
37
            } catch (JacksonException ex) {
3✔
38
                obj = new NanodashPreferences();
12✔
39
                logger.error("Could not read preferences file at '{}' using defaults", DEFAULT_SETTING_PATH, ex);
15✔
40
            }
3✔
41
        }
42
        return obj;
6✔
43
    }
44

45
    private List<String> nanopubActions = new ArrayList<>();
15✔
46
    private boolean readOnlyMode = false;
9✔
47
    private String websiteUrl = "http://localhost:37373/";
9✔
48
    private boolean orcidLoginMode = false;
9✔
49
    private String orcidClientId;
50
    private String orcidClientSecret;
51
    private String settingUri;
52
    private String umamiScriptUrl;
53
    private String umamiWebsiteId;
54
    private String homeResource = "https://w3id.org/spaces/knowledgepixels/nanodash/r/home";
9✔
55
    private boolean claudeChatEnabled = false;
9✔
56
    private String claudeChatBinary = "claude";
12✔
57
    private String claudeChatModel;
58
    public static final String DEFAULT_SETTING_PATH = "/.nanopub/nanodash-preferences.yml";
59

60
    /**
61
     * Return the list of nanopub actions.
62
     *
63
     * @return list of nanopub actions
64
     */
65
    public List<String> getNanopubActions() {
66
        String s = System.getenv("NANODASH_NANOPUB_ACTIONS");
9✔
67
        if (s != null && !s.isBlank()) {
15✔
68
            return Arrays.asList(s.split(" "));
15✔
69
        }
70
        return nanopubActions;
9✔
71
    }
72

73
    /**
74
     * Set the list of nanopub actions.
75
     *
76
     * @param nanopubActions the list of nanopub actions
77
     */
78
    public void setNanopubActions(List<String> nanopubActions) {
79
        this.nanopubActions = nanopubActions;
9✔
80
    }
3✔
81

82
    /**
83
     * Check if the application is in read-only mode.
84
     *
85
     * @return true if in read-only mode, false otherwise
86
     */
87
    public boolean isReadOnlyMode() {
88
        if ("true".equals(System.getenv("NANODASH_READ_ONLY_MODE"))) {
15✔
89
            logger.debug("Found environment variable NANODASH_READ_ONLY_MODE with value: {}", true);
15✔
90
            return true;
6✔
91
        }
92
        logger.debug("Environment variable NANODASH_READ_ONLY_MODE not set, using default: {}", readOnlyMode);
18✔
93
        return readOnlyMode;
9✔
94
    }
95

96
    /**
97
     * Set the read-only mode.
98
     *
99
     * @param readOnlyMode true to enable read-only mode, false to disable
100
     */
101
    public void setReadOnlyMode(boolean readOnlyMode) {
102
        this.readOnlyMode = readOnlyMode;
9✔
103
    }
3✔
104

105
    /**
106
     * Get the website URL.
107
     *
108
     * @return the website URL
109
     */
110
    public String getWebsiteUrl() {
111
        String s = System.getenv("NANODASH_WEBSITE_URL");
9✔
112
        if (s != null && !s.isBlank()) {
15✔
113
            logger.debug("Found environment variable NANODASH_WEBSITE_URL with value: {}", s);
12✔
114
            return s;
6✔
115
        }
116
        logger.debug("Environment variable NANODASH_WEBSITE_URL not set, using default: {}", websiteUrl);
15✔
117
        return websiteUrl;
9✔
118
    }
119

120
    /**
121
     * Set the website URL.
122
     *
123
     * @param websiteUrl the website URL to set
124
     */
125
    public void setWebsiteUrl(String websiteUrl) {
126
        this.websiteUrl = websiteUrl;
9✔
127
    }
3✔
128

129
    /**
130
     * Check if the application is in ORCID login mode.
131
     *
132
     * @return true if in ORCID login mode, false otherwise
133
     */
134
    public boolean isOrcidLoginMode() {
135
        if ("true".equals(System.getenv("NANODASH_ORCID_LOGIN_MODE"))) {
15✔
136
            logger.debug("Found environment variable NANODASH_ORCID_LOGIN_MODE with value: {}", true);
15✔
137
            return true;
6✔
138
        }
139
        logger.debug("Environment variable NANODASH_ORCID_LOGIN_MODE not set, using default: {}", orcidLoginMode);
18✔
140
        return orcidLoginMode;
9✔
141
    }
142

143
    /**
144
     * Set the ORCID login mode.
145
     *
146
     * @param orcidLoginMode true to enable ORCID login mode, false to disable
147
     */
148
    public void setOrcidLoginMode(boolean orcidLoginMode) {
149
        this.orcidLoginMode = orcidLoginMode;
9✔
150
    }
3✔
151

152
    /**
153
     * Get the ORCID client ID.
154
     *
155
     * @return the ORCID client ID
156
     */
157
    public String getOrcidClientId() {
158
        String s = System.getenv("NANOPUB_ORCID_CLIENT_ID");
9✔
159
        if (s != null && !s.isBlank()) {
15✔
160
            logger.debug("Found environment variable NANOPUB_ORCID_CLIENT_ID with value: {}", s);
12✔
161
            return s;
6✔
162
        }
163
        logger.debug("Environment variable NANOPUB_ORCID_CLIENT_ID not set, using default: {}", orcidClientId);
15✔
164
        return orcidClientId;
9✔
165
    }
166

167
    /**
168
     * Set the ORCID client ID.
169
     *
170
     * @param orcidClientId the ORCID client ID to set
171
     */
172
    public void setOrcidClientId(String orcidClientId) {
173
        this.orcidClientId = orcidClientId;
9✔
174
    }
3✔
175

176
    /**
177
     * Get the ORCID client secret.
178
     * .
179
     *
180
     * @return the ORCID client secret
181
     */
182
    public String getOrcidClientSecret() {
183
        String s = System.getenv("NANOPUB_ORCID_CLIENT_SECRET");
9✔
184
        if (s != null && !s.isBlank()) {
15✔
185
            logger.debug("Found environment variable NANOPUB_ORCID_CLIENT_SECRET");
9✔
186
            return s;
6✔
187
        }
188
        logger.debug("Environment variable NANOPUB_ORCID_CLIENT_SECRET not set, using default");
9✔
189
        return orcidClientSecret;
9✔
190
    }
191

192
    /**
193
     * Set the ORCID client secret.
194
     *
195
     * @param orcidClientSecret the ORCID client secret to set
196
     */
197
    public void setOrcidClientSecret(String orcidClientSecret) {
198
        this.orcidClientSecret = orcidClientSecret;
9✔
199
    }
3✔
200

201
    /**
202
     * Get the setting URI.
203
     *
204
     * @return the setting URI
205
     */
206
    public String getSettingUri() {
207
        return settingUri;
9✔
208
    }
209

210
    /**
211
     * Set the setting URI.
212
     *
213
     * @param settingUri the setting URI to set
214
     */
215
    public void setSettingUri(String settingUri) {
216
        this.settingUri = settingUri;
9✔
217
    }
3✔
218

219
    /**
220
     * Get the Umami analytics script URL.
221
     *
222
     * @return the Umami script URL, or null if not configured
223
     */
224
    public String getUmamiScriptUrl() {
225
        String s = System.getenv("NANODASH_UMAMI_SCRIPT_URL");
9✔
226
        if (s != null && !s.isBlank()) return s;
6!
227
        return umamiScriptUrl;
9✔
228
    }
229

230
    /**
231
     * Set the Umami analytics script URL.
232
     *
233
     * @param umamiScriptUrl the Umami script URL to set
234
     */
235
    public void setUmamiScriptUrl(String umamiScriptUrl) {
236
        this.umamiScriptUrl = umamiScriptUrl;
×
237
    }
×
238

239
    /**
240
     * Get the Umami analytics website ID.
241
     *
242
     * @return the Umami website ID, or null if not configured
243
     */
244
    public String getUmamiWebsiteId() {
245
        String s = System.getenv("NANODASH_UMAMI_WEBSITE_ID");
×
246
        if (s != null && !s.isBlank()) return s;
×
247
        return umamiWebsiteId;
×
248
    }
249

250
    /**
251
     * Set the Umami analytics website ID.
252
     *
253
     * @param umamiWebsiteId the Umami website ID to set
254
     */
255
    public void setUmamiWebsiteId(String umamiWebsiteId) {
256
        this.umamiWebsiteId = umamiWebsiteId;
×
257
    }
×
258

259
    /**
260
     * Check whether the local Claude Code chat feature is enabled.
261
     *
262
     * Intended for locally running single-user instances only; see
263
     * docs/claude-code-chat.md.
264
     *
265
     * @return true if the Claude chat feature is enabled
266
     */
267
    public boolean isClaudeChatEnabled() {
268
        if ("true".equals(System.getenv("NANODASH_CLAUDE_CHAT_ENABLED"))) {
×
269
            return true;
×
270
        }
271
        return claudeChatEnabled;
×
272
    }
273

274
    /**
275
     * Set whether the local Claude Code chat feature is enabled.
276
     *
277
     * @param claudeChatEnabled true to enable
278
     */
279
    public void setClaudeChatEnabled(boolean claudeChatEnabled) {
280
        this.claudeChatEnabled = claudeChatEnabled;
×
281
    }
×
282

283
    /**
284
     * Get the command to run the Claude Code CLI.
285
     *
286
     * @return the binary name or path (default "claude")
287
     */
288
    public String getClaudeChatBinary() {
289
        String s = System.getenv("NANODASH_CLAUDE_CHAT_BINARY");
×
290
        if (s != null && !s.isBlank()) return s;
×
291
        return claudeChatBinary;
×
292
    }
293

294
    /**
295
     * Set the command to run the Claude Code CLI.
296
     *
297
     * @param claudeChatBinary the binary name or path
298
     */
299
    public void setClaudeChatBinary(String claudeChatBinary) {
300
        this.claudeChatBinary = claudeChatBinary;
×
301
    }
×
302

303
    /**
304
     * Get the model override for Claude Code chat sessions.
305
     *
306
     * @return the model name, or null to use the CLI's default
307
     */
308
    public String getClaudeChatModel() {
309
        String s = System.getenv("NANODASH_CLAUDE_CHAT_MODEL");
×
310
        if (s != null && !s.isBlank()) return s;
×
311
        return claudeChatModel;
×
312
    }
313

314
    /**
315
     * Set the model override for Claude Code chat sessions.
316
     *
317
     * @param claudeChatModel the model name
318
     */
319
    public void setClaudeChatModel(String claudeChatModel) {
320
        this.claudeChatModel = claudeChatModel;
×
321
    }
×
322

323
    public String getHomeResource() {
324
        String s = System.getenv("NANODASH_HOME_RESOURCE");
×
325
        if (s != null && !s.isBlank()) {
×
326
            logger.debug("Found environment variable NANODASH_HOME_RESOURCE with value: {}", s);
×
327
            return s;
×
328
        }
329
        logger.debug("Environment variable NANODASH_HOME_RESOURCE not set, using default: {}", homeResource);
×
330
        return homeResource;
×
331
    }
332

333
    public void setHomeResource(String homeResource) {
334
        this.homeResource = homeResource;
×
335
    }
×
336

337
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc