tarsk 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Tarsk
2
2
 
3
- Tarsk is an AI tool editor.
3
+ Tarsk is an AI tool available at https://tarsk.io.
4
4
 
5
- Run `npx tarsk`
5
+ Run `npx tarsk` to launch it.
6
6
 
7
7
  ## Details
8
8
 
@@ -0,0 +1 @@
1
+ ZFkdBv23EIOiqPE5DA1g0Q==:B5Nkd/BgquDAp5/PR1HrgnW4DfJkBVknC3WHAh625GN+2RgPV4sQNrs6MryEYeO4CIhgPJ5SKT2SFhsiMInVlN4eK/VFS+UpjkJtIOb9w4PU4vahU73Eg5WYu+paIEdRdJYE5x7zi19CPCiIGZ2R0JMPJlBrmINKHC8PPwMqReg=
@@ -31,9 +31,11 @@ export async function api_save_settings(c) {
31
31
  return c.json(getSettings());
32
32
  }
33
33
  export function getSettings() {
34
- const settings = getJSON("settings", {
34
+ const defaultSettings = {
35
35
  openRouterApiKey: "",
36
36
  openRouterURL: defaultOpenRouterURL,
37
- });
37
+ defaultModel: defaultModel
38
+ };
39
+ const settings = getJSON("settings", defaultSettings);
38
40
  return settings;
39
41
  }
@@ -1,16 +1,26 @@
1
1
  import { join } from "path";
2
2
  import { tarskFolder } from "../api/utils.js";
3
- import { existsSync, readFileSync, writeFileSync } from "fs";
3
+ import { existsSync, mkdir, mkdirSync, readFileSync, writeFileSync } from "fs";
4
4
  import { decryptString, encryptString } from "../api/encryption.js";
5
5
  export function getJSON(name, defaultValue) {
6
6
  const filename = join(tarskFolder(), name + '.json');
7
7
  if (!existsSync(filename)) {
8
- writeFileSync(filename, JSON.stringify(defaultValue));
8
+ if (!existsSync(tarskFolder())) {
9
+ mkdirSync(tarskFolder(), { recursive: true });
10
+ }
11
+ setJSON(name, defaultValue);
9
12
  return defaultValue;
10
13
  }
11
14
  else {
12
- const data = JSON.parse(decryptString(readFileSync(filename, 'utf-8')));
13
- return data;
15
+ try {
16
+ const data = readFileSync(filename, 'utf-8');
17
+ return JSON.parse(decryptString(data));
18
+ }
19
+ catch (e) {
20
+ setJSON(name, defaultValue);
21
+ //console.error(`Error reading ${name}.json: ${e}`);
22
+ return defaultValue;
23
+ }
14
24
  }
15
25
  }
16
26
  export function setJSON(name, value) {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "tarsk",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "author": "WebNative LLC",
5
- "description": "Tarsk is a AI tool.",
5
+ "description": "Tarsk is a AI tool available at https://tarsk.io",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "scripts": {