@elasto/nyx-cli 0.1.0

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.
Files changed (167) hide show
  1. package/README.md +136 -0
  2. package/bin/nyx.js +3 -0
  3. package/dist/agent/index.d.ts +29 -0
  4. package/dist/agent/index.d.ts.map +1 -0
  5. package/dist/agent/index.js +362 -0
  6. package/dist/agent/index.js.map +1 -0
  7. package/dist/agent/prompt.d.ts +16 -0
  8. package/dist/agent/prompt.d.ts.map +1 -0
  9. package/dist/agent/prompt.js +487 -0
  10. package/dist/agent/prompt.js.map +1 -0
  11. package/dist/agent/templates/index.d.ts +2 -0
  12. package/dist/agent/templates/index.d.ts.map +1 -0
  13. package/dist/agent/templates/index.js +44 -0
  14. package/dist/agent/templates/index.js.map +1 -0
  15. package/dist/auth/index.d.ts +23 -0
  16. package/dist/auth/index.d.ts.map +1 -0
  17. package/dist/auth/index.js +161 -0
  18. package/dist/auth/index.js.map +1 -0
  19. package/dist/commands/login.d.ts +3 -0
  20. package/dist/commands/login.d.ts.map +1 -0
  21. package/dist/commands/login.js +32 -0
  22. package/dist/commands/login.js.map +1 -0
  23. package/dist/commands/logout.d.ts +3 -0
  24. package/dist/commands/logout.d.ts.map +1 -0
  25. package/dist/commands/logout.js +13 -0
  26. package/dist/commands/logout.js.map +1 -0
  27. package/dist/commands/logs.d.ts +3 -0
  28. package/dist/commands/logs.d.ts.map +1 -0
  29. package/dist/commands/logs.js +29 -0
  30. package/dist/commands/logs.js.map +1 -0
  31. package/dist/commands/root.d.ts +3 -0
  32. package/dist/commands/root.d.ts.map +1 -0
  33. package/dist/commands/root.js +27 -0
  34. package/dist/commands/root.js.map +1 -0
  35. package/dist/commands/run.d.ts +3 -0
  36. package/dist/commands/run.d.ts.map +1 -0
  37. package/dist/commands/run.js +74 -0
  38. package/dist/commands/run.js.map +1 -0
  39. package/dist/commands/session.d.ts +3 -0
  40. package/dist/commands/session.d.ts.map +1 -0
  41. package/dist/commands/session.js +61 -0
  42. package/dist/commands/session.js.map +1 -0
  43. package/dist/config/index.d.ts +22 -0
  44. package/dist/config/index.d.ts.map +1 -0
  45. package/dist/config/index.js +110 -0
  46. package/dist/config/index.js.map +1 -0
  47. package/dist/db/index.d.ts +5 -0
  48. package/dist/db/index.d.ts.map +1 -0
  49. package/dist/db/index.js +72 -0
  50. package/dist/db/index.js.map +1 -0
  51. package/dist/events/index.d.ts +3 -0
  52. package/dist/events/index.d.ts.map +1 -0
  53. package/dist/events/index.js +45 -0
  54. package/dist/events/index.js.map +1 -0
  55. package/dist/filetracker/index.d.ts +8 -0
  56. package/dist/filetracker/index.d.ts.map +1 -0
  57. package/dist/filetracker/index.js +21 -0
  58. package/dist/filetracker/index.js.map +1 -0
  59. package/dist/hooks/index.d.ts +13 -0
  60. package/dist/hooks/index.d.ts.map +1 -0
  61. package/dist/hooks/index.js +42 -0
  62. package/dist/hooks/index.js.map +1 -0
  63. package/dist/index.d.ts +2 -0
  64. package/dist/index.d.ts.map +1 -0
  65. package/dist/index.js +140 -0
  66. package/dist/index.js.map +1 -0
  67. package/dist/logging/index.d.ts +16 -0
  68. package/dist/logging/index.d.ts.map +1 -0
  69. package/dist/logging/index.js +76 -0
  70. package/dist/logging/index.js.map +1 -0
  71. package/dist/lsp/index.d.ts +10 -0
  72. package/dist/lsp/index.d.ts.map +1 -0
  73. package/dist/lsp/index.js +130 -0
  74. package/dist/lsp/index.js.map +1 -0
  75. package/dist/mcp/index.d.ts +11 -0
  76. package/dist/mcp/index.d.ts.map +1 -0
  77. package/dist/mcp/index.js +102 -0
  78. package/dist/mcp/index.js.map +1 -0
  79. package/dist/permissions/index.d.ts +13 -0
  80. package/dist/permissions/index.d.ts.map +1 -0
  81. package/dist/permissions/index.js +96 -0
  82. package/dist/permissions/index.js.map +1 -0
  83. package/dist/session/index.d.ts +25 -0
  84. package/dist/session/index.d.ts.map +1 -0
  85. package/dist/session/index.js +100 -0
  86. package/dist/session/index.js.map +1 -0
  87. package/dist/shell/index.d.ts +8 -0
  88. package/dist/shell/index.d.ts.map +1 -0
  89. package/dist/shell/index.js +29 -0
  90. package/dist/shell/index.js.map +1 -0
  91. package/dist/skills/index.d.ts +9 -0
  92. package/dist/skills/index.d.ts.map +1 -0
  93. package/dist/skills/index.js +53 -0
  94. package/dist/skills/index.js.map +1 -0
  95. package/dist/tools/bash.d.ts +35 -0
  96. package/dist/tools/bash.d.ts.map +1 -0
  97. package/dist/tools/bash.js +44 -0
  98. package/dist/tools/bash.js.map +1 -0
  99. package/dist/tools/diagnostics.d.ts +19 -0
  100. package/dist/tools/diagnostics.d.ts.map +1 -0
  101. package/dist/tools/diagnostics.js +45 -0
  102. package/dist/tools/diagnostics.js.map +1 -0
  103. package/dist/tools/edit.d.ts +31 -0
  104. package/dist/tools/edit.d.ts.map +1 -0
  105. package/dist/tools/edit.js +72 -0
  106. package/dist/tools/edit.js.map +1 -0
  107. package/dist/tools/glob.d.ts +23 -0
  108. package/dist/tools/glob.d.ts.map +1 -0
  109. package/dist/tools/glob.js +40 -0
  110. package/dist/tools/glob.js.map +1 -0
  111. package/dist/tools/grep.d.ts +31 -0
  112. package/dist/tools/grep.d.ts.map +1 -0
  113. package/dist/tools/grep.js +72 -0
  114. package/dist/tools/grep.js.map +1 -0
  115. package/dist/tools/index.d.ts +9 -0
  116. package/dist/tools/index.d.ts.map +1 -0
  117. package/dist/tools/index.js +78 -0
  118. package/dist/tools/index.js.map +1 -0
  119. package/dist/tools/job_output.d.ts +49 -0
  120. package/dist/tools/job_output.d.ts.map +1 -0
  121. package/dist/tools/job_output.js +57 -0
  122. package/dist/tools/job_output.js.map +1 -0
  123. package/dist/tools/ls.d.ts +19 -0
  124. package/dist/tools/ls.d.ts.map +1 -0
  125. package/dist/tools/ls.js +55 -0
  126. package/dist/tools/ls.js.map +1 -0
  127. package/dist/tools/todos.d.ts +41 -0
  128. package/dist/tools/todos.d.ts.map +1 -0
  129. package/dist/tools/todos.js +54 -0
  130. package/dist/tools/todos.js.map +1 -0
  131. package/dist/tools/view.d.ts +27 -0
  132. package/dist/tools/view.d.ts.map +1 -0
  133. package/dist/tools/view.js +59 -0
  134. package/dist/tools/view.js.map +1 -0
  135. package/dist/tools/web_fetch.d.ts +24 -0
  136. package/dist/tools/web_fetch.d.ts.map +1 -0
  137. package/dist/tools/web_fetch.js +43 -0
  138. package/dist/tools/web_fetch.js.map +1 -0
  139. package/dist/tools/web_search.d.ts +23 -0
  140. package/dist/tools/web_search.d.ts.map +1 -0
  141. package/dist/tools/web_search.js +41 -0
  142. package/dist/tools/web_search.js.map +1 -0
  143. package/dist/tools/write.d.ts +23 -0
  144. package/dist/tools/write.d.ts.map +1 -0
  145. package/dist/tools/write.js +39 -0
  146. package/dist/tools/write.js.map +1 -0
  147. package/dist/types/index.d.ts +136 -0
  148. package/dist/types/index.d.ts.map +1 -0
  149. package/dist/types/index.js +3 -0
  150. package/dist/types/index.js.map +1 -0
  151. package/dist/ui/index.d.ts +3 -0
  152. package/dist/ui/index.d.ts.map +1 -0
  153. package/dist/ui/index.js +318 -0
  154. package/dist/ui/index.js.map +1 -0
  155. package/dist/util/diff.d.ts +17 -0
  156. package/dist/util/diff.d.ts.map +1 -0
  157. package/dist/util/diff.js +74 -0
  158. package/dist/util/diff.js.map +1 -0
  159. package/dist/util/index.d.ts +6 -0
  160. package/dist/util/index.d.ts.map +1 -0
  161. package/dist/util/index.js +33 -0
  162. package/dist/util/index.js.map +1 -0
  163. package/dist/workspace/index.d.ts +6 -0
  164. package/dist/workspace/index.d.ts.map +1 -0
  165. package/dist/workspace/index.js +133 -0
  166. package/dist/workspace/index.js.map +1 -0
  167. package/package.json +47 -0
@@ -0,0 +1,161 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Auth = void 0;
4
+ const fs_1 = require("fs");
5
+ const http_1 = require("http");
6
+ const path_1 = require("path");
7
+ const index_js_1 = require("../config/index.js");
8
+ class Auth {
9
+ tokenPath;
10
+ webUrl;
11
+ apiUrl;
12
+ constructor(webUrl, apiUrl) {
13
+ (0, fs_1.mkdirSync)((0, path_1.join)(index_js_1.GLOBAL_DATA_DIR, 'auth'), { recursive: true });
14
+ this.tokenPath = (0, path_1.join)(index_js_1.GLOBAL_DATA_DIR, 'auth', 'token.json');
15
+ this.webUrl = webUrl || process.env.NYX_WEB_URL || 'https://nyx.elasto.ng';
16
+ this.apiUrl = apiUrl || process.env.NYX_API_URL || 'https://api.nyx.elasto.ng';
17
+ }
18
+ async login() {
19
+ const token = await this.browserAuth('login');
20
+ await this.fetchAndSaveProfile(token.token);
21
+ }
22
+ async signup() {
23
+ const token = await this.browserAuth('signup');
24
+ await this.fetchAndSaveProfile(token.token);
25
+ }
26
+ async fetchAndSaveProfile(token) {
27
+ try {
28
+ const res = await fetch(`${this.apiUrl}/api/auth/me`, {
29
+ headers: { Authorization: `Bearer ${token}` },
30
+ });
31
+ if (res.ok) {
32
+ const data = await res.json();
33
+ const user = data.user || data;
34
+ this.saveToken({
35
+ token,
36
+ user: { id: user.id, email: user.email, name: user.name },
37
+ plan: user.plan,
38
+ tokensUsed: user.tokensUsed,
39
+ tokenLimit: user.tokenLimit,
40
+ subscriptionStatus: user.subscriptionStatus,
41
+ expiresAt: Date.now() + 7 * 24 * 60 * 60 * 1000,
42
+ });
43
+ return;
44
+ }
45
+ }
46
+ catch (e) {
47
+ console.error('Warning: Could not fetch user profile:', e instanceof Error ? e.message : String(e));
48
+ }
49
+ // Fallback: save token without profile details
50
+ const parts = token.split('.');
51
+ try {
52
+ const payload = JSON.parse(Buffer.from(parts[1], 'base64url').toString());
53
+ this.saveToken({
54
+ token,
55
+ user: { id: payload.sub || '', email: payload.email || '', name: '' },
56
+ expiresAt: Date.now() + 7 * 24 * 60 * 60 * 1000,
57
+ });
58
+ }
59
+ catch {
60
+ this.saveToken({ token, user: { id: '', email: '', name: '' }, expiresAt: Date.now() + 7 * 24 * 60 * 60 * 1000 });
61
+ }
62
+ }
63
+ async browserAuth(mode) {
64
+ return new Promise((resolve, reject) => {
65
+ const server = (0, http_1.createServer)((req, res) => {
66
+ const url = new URL(req.url || '/', `http://${req.headers.host || 'localhost'}`);
67
+ const tokenParam = url.searchParams.get('token');
68
+ if (url.pathname === '/callback' && tokenParam) {
69
+ res.writeHead(200, { 'Content-Type': 'text/html' });
70
+ res.end('<html><body><p>Authentication successful! You can close this tab.</p><script>window.close()</script></body></html>');
71
+ server.close();
72
+ try {
73
+ const parts = tokenParam.split('.');
74
+ const payload = JSON.parse(Buffer.from(parts[1], 'base64url').toString());
75
+ resolve({
76
+ token: tokenParam,
77
+ user: { id: payload.sub || payload.id || '', email: payload.email || '', name: payload.name || '' },
78
+ expiresAt: (payload.exp || 0) * 1000,
79
+ });
80
+ }
81
+ catch {
82
+ resolve({
83
+ token: tokenParam,
84
+ user: { id: '', email: '', name: '' },
85
+ expiresAt: Date.now() + 7 * 24 * 60 * 60 * 1000,
86
+ });
87
+ }
88
+ }
89
+ else {
90
+ res.writeHead(204);
91
+ res.end();
92
+ }
93
+ });
94
+ // Find available port
95
+ server.listen(0, () => {
96
+ const port = server.address().port;
97
+ const redirectUri = `http://localhost:${port}/callback`;
98
+ const webUrl = `${this.webUrl}/${mode}?redirect=${encodeURIComponent(redirectUri)}`;
99
+ console.log(`Opening browser to ${this.webUrl}/${mode} ...`);
100
+ import('open').then((open) => {
101
+ open.default(webUrl).catch(() => {
102
+ console.log(`If browser doesn't open, visit:\n ${webUrl}`);
103
+ });
104
+ }).catch(() => {
105
+ console.log(`Please visit:\n ${webUrl}`);
106
+ });
107
+ // Timeout after 5 minutes
108
+ setTimeout(() => {
109
+ server.close();
110
+ reject(new Error('Authentication timed out. Please try again.'));
111
+ }, 5 * 60 * 1000);
112
+ });
113
+ server.on('error', (err) => reject(err));
114
+ });
115
+ }
116
+ saveToken(token) {
117
+ (0, fs_1.writeFileSync)(this.tokenPath, JSON.stringify(token, null, 2));
118
+ }
119
+ getToken() {
120
+ try {
121
+ if (!(0, fs_1.existsSync)(this.tokenPath))
122
+ return null;
123
+ const data = JSON.parse((0, fs_1.readFileSync)(this.tokenPath, 'utf-8'));
124
+ if (!data.token || data.expiresAt < Date.now()) {
125
+ this.logout();
126
+ return null;
127
+ }
128
+ return data;
129
+ }
130
+ catch {
131
+ return null;
132
+ }
133
+ }
134
+ isLoggedIn() {
135
+ return this.getToken() !== null;
136
+ }
137
+ getUser() {
138
+ const t = this.getToken();
139
+ return t?.user || null;
140
+ }
141
+ getHeaders() {
142
+ const t = this.getToken();
143
+ if (!t)
144
+ return {};
145
+ return {
146
+ 'Content-Type': 'application/json',
147
+ 'Authorization': `Bearer ${t.token}`,
148
+ };
149
+ }
150
+ getApiUrl() {
151
+ return this.apiUrl;
152
+ }
153
+ logout() {
154
+ try {
155
+ (0, fs_1.writeFileSync)(this.tokenPath, JSON.stringify({}));
156
+ }
157
+ catch { }
158
+ }
159
+ }
160
+ exports.Auth = Auth;
161
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":";;;AAAA,2BAAuE;AACvE,+BAAmC;AACnC,+BAA2B;AAC3B,iDAAoD;AAGpD,MAAa,IAAI;IACP,SAAS,CAAQ;IACjB,MAAM,CAAQ;IACd,MAAM,CAAQ;IAEtB,YAAY,MAAe,EAAE,MAAe;QAC1C,IAAA,cAAS,EAAC,IAAA,WAAI,EAAC,0BAAe,EAAE,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;QAC7D,IAAI,CAAC,SAAS,GAAG,IAAA,WAAI,EAAC,0BAAe,EAAE,MAAM,EAAE,YAAY,CAAC,CAAA;QAC5D,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,uBAAuB,CAAA;QAC1E,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,2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C,CAAC,KAAK,EAAE;SACrC,CAAA;IACH,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAED,MAAM;QACJ,IAAI,CAAC;YACH,IAAA,kBAAa,EAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAA;QACnD,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;IACZ,CAAC;CACF;AAnKD,oBAmKC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const loginCmd: Command;
3
+ //# sourceMappingURL=login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,eAAO,MAAM,QAAQ,SAwBjB,CAAA"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loginCmd = void 0;
4
+ const commander_1 = require("commander");
5
+ const index_js_1 = require("../auth/index.js");
6
+ const index_js_2 = require("../logging/index.js");
7
+ exports.loginCmd = new commander_1.Command('login')
8
+ .description('Log in to your Nyx account')
9
+ .option('--signup', 'Create a new account')
10
+ .action(async (options) => {
11
+ const auth = new index_js_1.Auth();
12
+ if (auth.isLoggedIn()) {
13
+ const user = auth.getUser();
14
+ console.log(`Already logged in as ${user?.email || '(unknown)'}`);
15
+ return;
16
+ }
17
+ try {
18
+ if (options.signup) {
19
+ await auth.signup();
20
+ console.log('Account created and logged in!');
21
+ }
22
+ else {
23
+ await auth.login();
24
+ console.log('Logged in successfully!');
25
+ }
26
+ }
27
+ catch (err) {
28
+ index_js_2.logger.error('Auth failed:', err.message);
29
+ process.exit(1);
30
+ }
31
+ });
32
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":";;;AAAA,yCAAmC;AACnC,+CAAuC;AACvC,kDAA4C;AAE/B,QAAA,QAAQ,GAAG,IAAI,mBAAO,CAAC,OAAO,CAAC;KACzC,WAAW,CAAC,4BAA4B,CAAC;KACzC,MAAM,CAAC,UAAU,EAAE,sBAAsB,CAAC;KAC1C,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACxB,MAAM,IAAI,GAAG,IAAI,eAAI,EAAE,CAAA;IAEvB,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;QACtB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;QAC3B,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,EAAE,KAAK,IAAI,WAAW,EAAE,CAAC,CAAA;QACjE,OAAM;IACR,CAAC;IAED,IAAI,CAAC;QACH,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA;YACnB,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAA;QAC/C,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;YAClB,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAA;QACxC,CAAC;IACH,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,iBAAM,CAAC,KAAK,CAAC,cAAc,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;QACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const logoutCmd: Command;
3
+ //# sourceMappingURL=logout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,eAAO,MAAM,SAAS,SAMlB,CAAA"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logoutCmd = void 0;
4
+ const commander_1 = require("commander");
5
+ const index_js_1 = require("../auth/index.js");
6
+ exports.logoutCmd = new commander_1.Command('logout')
7
+ .description('Log out of your Nyx account')
8
+ .action(() => {
9
+ const auth = new index_js_1.Auth();
10
+ auth.logout();
11
+ console.log('Logged out');
12
+ });
13
+ //# sourceMappingURL=logout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logout.js","sourceRoot":"","sources":["../../src/commands/logout.ts"],"names":[],"mappings":";;;AAAA,yCAAmC;AACnC,+CAAuC;AAE1B,QAAA,SAAS,GAAG,IAAI,mBAAO,CAAC,QAAQ,CAAC;KAC3C,WAAW,CAAC,6BAA6B,CAAC;KAC1C,MAAM,CAAC,GAAG,EAAE;IACX,MAAM,IAAI,GAAG,IAAI,eAAI,EAAE,CAAA;IACvB,IAAI,CAAC,MAAM,EAAE,CAAA;IACb,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;AAC3B,CAAC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const logsCmd: Command;
3
+ //# sourceMappingURL=logs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAInC,eAAO,MAAM,OAAO,SAuBhB,CAAA"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.logsCmd = void 0;
4
+ const commander_1 = require("commander");
5
+ const index_js_1 = require("../config/index.js");
6
+ const index_js_2 = require("../logging/index.js");
7
+ exports.logsCmd = new commander_1.Command('logs')
8
+ .description('View session logs')
9
+ .option('-t, --tail <lines>', 'Number of lines to show', '100')
10
+ .option('-f, --follow', 'Follow logs in real time')
11
+ .action((options) => {
12
+ const config = new index_js_1.Config();
13
+ index_js_2.logger.init(config.dataDirectory, config.isDebug());
14
+ const lines = parseInt(options.tail);
15
+ if (isNaN(lines) || lines < 1) {
16
+ console.error('Invalid --tail value. Must be a positive number.');
17
+ process.exit(1);
18
+ }
19
+ const entries = index_js_2.logger.tail(lines);
20
+ for (const entry of entries) {
21
+ console.log(entry);
22
+ }
23
+ if (options.follow) {
24
+ const cleanup = index_js_2.logger.follow((line) => console.log(line));
25
+ process.on('SIGINT', () => { cleanup(); process.exit(0); });
26
+ process.on('SIGTERM', () => { cleanup(); process.exit(0); });
27
+ }
28
+ });
29
+ //# sourceMappingURL=logs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logs.js","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":";;;AAAA,yCAAmC;AACnC,iDAA2C;AAC3C,kDAA4C;AAE/B,QAAA,OAAO,GAAG,IAAI,mBAAO,CAAC,MAAM,CAAC;KACvC,WAAW,CAAC,mBAAmB,CAAC;KAChC,MAAM,CAAC,oBAAoB,EAAE,yBAAyB,EAAE,KAAK,CAAC;KAC9D,MAAM,CAAC,cAAc,EAAE,0BAA0B,CAAC;KAClD,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE;IAClB,MAAM,MAAM,GAAG,IAAI,iBAAM,EAAE,CAAA;IAC3B,iBAAM,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,OAAO,EAAE,CAAC,CAAA;IAEnD,MAAM,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IACpC,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC9B,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAA;QACjE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IACjB,CAAC;IACD,MAAM,OAAO,GAAG,iBAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAClC,KAAK,MAAM,KAAK,IAAI,OAAO,EAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IACpB,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,MAAM,OAAO,GAAG,iBAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;QAC1D,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC,CAAA;QAC1D,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA,CAAC,CAAC,CAAC,CAAA;IAC7D,CAAC;AACH,CAAC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const rootCmd: Command;
3
+ //# sourceMappingURL=root.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/commands/root.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAUnC,eAAO,MAAM,OAAO,SAaE,CAAA"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rootCmd = void 0;
4
+ const commander_1 = require("commander");
5
+ const fs_1 = require("fs");
6
+ const path_1 = require("path");
7
+ const { version } = JSON.parse((0, fs_1.readFileSync)((0, path_1.resolve)(__dirname, '../../package.json'), 'utf-8'));
8
+ const run_js_1 = require("./run.js");
9
+ const login_js_1 = require("./login.js");
10
+ const logout_js_1 = require("./logout.js");
11
+ const session_js_1 = require("./session.js");
12
+ const logs_js_1 = require("./logs.js");
13
+ exports.rootCmd = new commander_1.Command()
14
+ .name('nyx')
15
+ .description('A terminal-first AI assistant for software development')
16
+ .version(version, '-v, --version', 'Display version')
17
+ .option('-d, --debug', 'Enable debug mode')
18
+ .option('-c, --cwd <path>', 'Current working directory')
19
+ .option('-y, --yolo', 'Auto-accept all permissions')
20
+ .option('-S, --sid <id>', 'Continue a previous session by ID')
21
+ .option('-C, --continue', 'Continue the most recent session')
22
+ .addCommand(run_js_1.runCmd)
23
+ .addCommand(login_js_1.loginCmd)
24
+ .addCommand(logout_js_1.logoutCmd)
25
+ .addCommand(session_js_1.sessionCmd)
26
+ .addCommand(logs_js_1.logsCmd);
27
+ //# sourceMappingURL=root.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"root.js","sourceRoot":"","sources":["../../src/commands/root.ts"],"names":[],"mappings":";;;AAAA,yCAAmC;AACnC,2BAAiC;AACjC,+BAA8B;AAC9B,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,IAAA,cAAO,EAAC,SAAS,EAAE,oBAAoB,CAAC,EAAE,OAAO,CAAC,CAAC,CAAA;AAC/F,qCAAiC;AACjC,yCAAqC;AACrC,2CAAuC;AACvC,6CAAyC;AACzC,uCAAmC;AAEtB,QAAA,OAAO,GAAG,IAAI,mBAAO,EAAE;KACjC,IAAI,CAAC,KAAK,CAAC;KACX,WAAW,CAAC,wDAAwD,CAAC;KACrE,OAAO,CAAC,OAAO,EAAE,eAAe,EAAE,iBAAiB,CAAC;KACpD,MAAM,CAAC,aAAa,EAAE,mBAAmB,CAAC;KAC1C,MAAM,CAAC,kBAAkB,EAAE,2BAA2B,CAAC;KACvD,MAAM,CAAC,YAAY,EAAE,6BAA6B,CAAC;KACnD,MAAM,CAAC,gBAAgB,EAAE,mCAAmC,CAAC;KAC7D,MAAM,CAAC,gBAAgB,EAAE,kCAAkC,CAAC;KAC5D,UAAU,CAAC,eAAM,CAAC;KAClB,UAAU,CAAC,mBAAQ,CAAC;KACpB,UAAU,CAAC,qBAAS,CAAC;KACrB,UAAU,CAAC,uBAAU,CAAC;KACtB,UAAU,CAAC,iBAAO,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const runCmd: Command;
3
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAQnC,eAAO,MAAM,MAAM,SAiEf,CAAA"}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runCmd = void 0;
4
+ const commander_1 = require("commander");
5
+ const index_js_1 = require("../config/index.js");
6
+ const index_js_2 = require("../auth/index.js");
7
+ const index_js_3 = require("../db/index.js");
8
+ const index_js_4 = require("../logging/index.js");
9
+ const index_js_5 = require("../agent/index.js");
10
+ exports.runCmd = new commander_1.Command('run')
11
+ .description('Run a prompt non-interactively')
12
+ .argument('[prompt]', 'The prompt to execute')
13
+ .option('-s, --session <id>', 'Session ID to continue')
14
+ .option('-C, --continue', 'Continue the most recent session')
15
+ .option('-y, --yolo', 'Auto-accept all permissions')
16
+ .action(async (prompt, options) => {
17
+ const config = new index_js_1.Config();
18
+ index_js_4.logger.init(config.dataDirectory, config.isDebug());
19
+ (0, index_js_3.connect)(config.dataDirectory);
20
+ const auth = new index_js_2.Auth();
21
+ if (!auth.isLoggedIn()) {
22
+ console.error('Not logged in. Run `nyx login` first.');
23
+ process.exit(1);
24
+ }
25
+ if (!prompt) {
26
+ const chunks = [];
27
+ if (!process.stdin.isTTY) {
28
+ for await (const chunk of process.stdin)
29
+ chunks.push(chunk);
30
+ prompt = Buffer.concat(chunks).toString('utf-8').trim();
31
+ }
32
+ if (!prompt) {
33
+ console.error('No prompt provided');
34
+ process.exit(1);
35
+ }
36
+ }
37
+ const isYolo = options.yolo || process.argv.includes('--yolo');
38
+ const agent = new index_js_5.Agent(config, isYolo);
39
+ let sessionId = options.session;
40
+ const shouldContinue = options.continue || process.argv.includes('-C') || process.argv.includes('--continue');
41
+ if (shouldContinue && !sessionId) {
42
+ const { SessionService } = await import('../session/index.js');
43
+ const sessions = new SessionService();
44
+ const recent = sessions.list(1);
45
+ if (recent.length > 0)
46
+ sessionId = recent[0].id;
47
+ }
48
+ const events = [];
49
+ await agent.execute({
50
+ prompt,
51
+ projectPath: process.cwd(),
52
+ sessionId,
53
+ onEvent: (event) => {
54
+ events.push(event);
55
+ switch (event.type) {
56
+ case 'content':
57
+ process.stdout.write(event.data.text || '');
58
+ break;
59
+ case 'tool_call':
60
+ process.stderr.write(`\n🔧 ${event.data.tool}: ${JSON.stringify(event.data.args)}\n`);
61
+ break;
62
+ case 'tool_result':
63
+ if (!event.data.success) {
64
+ process.stderr.write(` Error: ${event.data.error}\n`);
65
+ }
66
+ break;
67
+ case 'error':
68
+ process.stderr.write(`\n❌ ${event.data.message}\n`);
69
+ break;
70
+ }
71
+ },
72
+ });
73
+ });
74
+ //# sourceMappingURL=run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.js","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":";;;AAAA,yCAAmC;AACnC,iDAA2C;AAC3C,+CAAuC;AACvC,6CAAwC;AACxC,kDAA4C;AAC5C,gDAAyC;AAG5B,QAAA,MAAM,GAAG,IAAI,mBAAO,CAAC,KAAK,CAAC;KACrC,WAAW,CAAC,gCAAgC,CAAC;KAC7C,QAAQ,CAAC,UAAU,EAAE,uBAAuB,CAAC;KAC7C,MAAM,CAAC,oBAAoB,EAAE,wBAAwB,CAAC;KACtD,MAAM,CAAC,gBAAgB,EAAE,kCAAkC,CAAC;KAC5D,MAAM,CAAC,YAAY,EAAE,6BAA6B,CAAC;KACnD,MAAM,CAA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I,CAAC,KAAK,IAAI,CAAC,CAAA;oBACzD,CAAC;oBACD,MAAK;gBACP,KAAK,OAAO;oBACV,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,KAAK,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,CAAA;oBACnD,MAAK;YACT,CAAC;QACH,CAAC;KACF,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const sessionCmd: Command;
3
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/commands/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAKnC,eAAO,MAAM,UAAU,SACU,CAAA"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sessionCmd = void 0;
4
+ const commander_1 = require("commander");
5
+ const index_js_1 = require("../db/index.js");
6
+ const index_js_2 = require("../session/index.js");
7
+ const index_js_3 = require("../config/index.js");
8
+ exports.sessionCmd = new commander_1.Command('session')
9
+ .description('Manage sessions');
10
+ exports.sessionCmd.addCommand(new commander_1.Command('list')
11
+ .description('List recent sessions')
12
+ .option('-n, --number <count>', 'Number of sessions to show', '10')
13
+ .action((options) => {
14
+ const config = new index_js_3.Config();
15
+ (0, index_js_1.connect)(config.dataDirectory);
16
+ const sessions = new index_js_2.SessionService();
17
+ const list = sessions.list(parseInt(options.number));
18
+ if (list.length === 0) {
19
+ console.log('No sessions found');
20
+ return;
21
+ }
22
+ for (const s of list) {
23
+ const date = new Date(s.updatedAt + 'Z').toLocaleString();
24
+ console.log(`${s.id.substring(0, 8)} ${s.title} (${date})`);
25
+ }
26
+ }));
27
+ exports.sessionCmd.addCommand(new commander_1.Command('show')
28
+ .description('Show session details')
29
+ .argument('<id>', 'Session ID')
30
+ .action((id) => {
31
+ const config = new index_js_3.Config();
32
+ (0, index_js_1.connect)(config.dataDirectory);
33
+ const sessions = new index_js_2.SessionService();
34
+ const session = sessions.get(id);
35
+ if (!session) {
36
+ console.log('Session not found');
37
+ return;
38
+ }
39
+ console.log(`ID: ${session.id}`);
40
+ console.log(`Title: ${session.title}`);
41
+ console.log(`Created: ${session.createdAt}`);
42
+ console.log(`Tokens: ${session.promptTokens} prompt / ${session.completionTokens} completion`);
43
+ console.log(`Cost: $${session.cost.toFixed(6)}`);
44
+ const msgs = sessions.getMessages(id);
45
+ console.log(`\nMessages: ${msgs.length}`);
46
+ for (const m of msgs.slice(-5)) {
47
+ const preview = m.content.substring(0, 100).replace(/\n/g, ' ');
48
+ console.log(` [${m.role}] ${preview}...`);
49
+ }
50
+ }));
51
+ exports.sessionCmd.addCommand(new commander_1.Command('delete')
52
+ .description('Delete a session')
53
+ .argument('<id>', 'Session ID')
54
+ .action((id) => {
55
+ const config = new index_js_3.Config();
56
+ (0, index_js_1.connect)(config.dataDirectory);
57
+ const sessions = new index_js_2.SessionService();
58
+ sessions.delete(id);
59
+ console.log(`Deleted session ${id}`);
60
+ }));
61
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/commands/session.ts"],"names":[],"mappings":";;;AAAA,yCAAmC;AACnC,6CAAwC;AACxC,kDAAoD;AACpD,iDAA2C;AAE9B,QAAA,UAAU,GAAG,IAAI,mBAAO,CAAC,SAAS,CAAC;KAC7C,WAAW,CAAC,iBAAiB,CAAC,CAAA;AAEjC,kBAAU,CAAC,UAAU,CACnB,IAAI,mBAAO,CAAC,MAAM,CAAC;KAChB,WAAW,CAAC,sBAAsB,CAAC;KACnC,MAAM,CAAC,sBAAsB,EAAE,4BAA4B,EAAE,IAAI,CAAC;KAClE,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE;IAClB,MAAM,MAAM,GAAG,IAAI,iBAAM,EAAE,CAAA;IAC3B,IAAA,kBAAO,E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AAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAA;AACtC,CAAC,CAAC,CACL,CAAA"}
@@ -0,0 +1,22 @@
1
+ import type { NyxConfig, OptionsConfig } from '../types/index.js';
2
+ declare const GLOBAL_CONFIG_DIR: string;
3
+ declare const GLOBAL_DATA_DIR: string;
4
+ export declare class Config {
5
+ raw: NyxConfig;
6
+ options: OptionsConfig;
7
+ dataDirectory: string;
8
+ webUrl: string;
9
+ apiUrl: string;
10
+ private configDir;
11
+ constructor(cwd?: string);
12
+ private load;
13
+ private findAndLoad;
14
+ getGlobalConfigDir(): string;
15
+ isDebug(): boolean;
16
+ getDisabledTools(): string[];
17
+ getDisabledSkills(): string[];
18
+ getSkillsPaths(): string[];
19
+ saveConfig(data: Partial<NyxConfig>): void;
20
+ }
21
+ export { GLOBAL_CONFIG_DIR, GLOBAL_DATA_DIR };
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAGjE,QAAA,MAAM,iBAAiB,QAKnB,CAAA;AAEJ,QAAA,MAAM,eAAe,QAKjB,CAAA;AAEJ,qBAAa,MAAM;IACV,GAAG,EAAE,SAAS,CAAK;IACnB,OAAO,EAAE,aAAa,CAAK;IAC3B,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,SAAS,CAAQ;gBAEb,GAAG,CAAC,EAAE,MAAM;IAQxB,OAAO,CAAC,IAAI;IAmBZ,OAAO,CAAC,WAAW;IAenB,kBAAkB,IAAI,MAAM;IAI5B,OAAO,IAAI,OAAO;IAIlB,gBAAgB,IAAI,MAAM,EAAE;IAI5B,iBAAiB,IAAI,MAAM,EAAE;IAI7B,cAAc,IAAI,MAAM,EAAE;IAe1B,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,CAAC;CAMpC;AAED,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,CAAA"}
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GLOBAL_DATA_DIR = exports.GLOBAL_CONFIG_DIR = exports.Config = void 0;
4
+ const fs_1 = require("fs");
5
+ const os_1 = require("os");
6
+ const path_1 = require("path");
7
+ const CONFIG_FILENAMES = ['.nyx.json', 'nyx.json'];
8
+ const GLOBAL_CONFIG_DIR = (() => {
9
+ if ((0, os_1.platform)() === 'win32') {
10
+ return (0, path_1.join)(process.env.LOCALAPPDATA || (0, path_1.join)((0, os_1.homedir)(), 'AppData', 'Local'), 'nyx');
11
+ }
12
+ return (0, path_1.join)(process.env.XDG_CONFIG_HOME || (0, path_1.join)((0, os_1.homedir)(), '.config'), 'nyx');
13
+ })();
14
+ exports.GLOBAL_CONFIG_DIR = GLOBAL_CONFIG_DIR;
15
+ const GLOBAL_DATA_DIR = (() => {
16
+ if ((0, os_1.platform)() === 'win32') {
17
+ return (0, path_1.join)(process.env.LOCALAPPDATA || (0, path_1.join)((0, os_1.homedir)(), 'AppData', 'Local'), 'nyx');
18
+ }
19
+ return (0, path_1.join)(process.env.XDG_DATA_HOME || (0, path_1.join)((0, os_1.homedir)(), '.local', 'share'), 'nyx');
20
+ })();
21
+ exports.GLOBAL_DATA_DIR = GLOBAL_DATA_DIR;
22
+ class Config {
23
+ raw = {};
24
+ options = {};
25
+ dataDirectory;
26
+ webUrl;
27
+ apiUrl;
28
+ configDir;
29
+ constructor(cwd) {
30
+ this.configDir = (0, path_1.resolve)(cwd || process.cwd());
31
+ this.dataDirectory = process.env.NYX_GLOBAL_DATA || GLOBAL_DATA_DIR;
32
+ this.webUrl = process.env.NYX_WEB_URL || 'https://nyx.elasto.ng';
33
+ this.apiUrl = process.env.NYX_API_URL || 'https://api.nyx.elasto.ng';
34
+ this.load();
35
+ }
36
+ load() {
37
+ const cfg = this.findAndLoad();
38
+ if (cfg) {
39
+ this.raw = cfg;
40
+ if (cfg.web_url)
41
+ this.webUrl = cfg.web_url;
42
+ if (cfg.api_url)
43
+ this.apiUrl = cfg.api_url;
44
+ }
45
+ this.options = this.raw.options || {};
46
+ // env vars override config file
47
+ if (process.env.NYX_WEB_URL)
48
+ this.webUrl = process.env.NYX_WEB_URL;
49
+ if (process.env.NYX_API_URL)
50
+ this.apiUrl = process.env.NYX_API_URL;
51
+ if (this.options.data_directory) {
52
+ this.dataDirectory = (0, path_1.resolve)(this.configDir, this.options.data_directory);
53
+ }
54
+ (0, fs_1.mkdirSync)(this.dataDirectory, { recursive: true });
55
+ (0, fs_1.mkdirSync)((0, path_1.join)(this.dataDirectory, 'logs'), { recursive: true });
56
+ (0, fs_1.mkdirSync)((0, path_1.join)(this.dataDirectory, 'sessions'), { recursive: true });
57
+ }
58
+ findAndLoad() {
59
+ const paths = [
60
+ ...CONFIG_FILENAMES.map((f) => (0, path_1.join)(this.configDir, f)),
61
+ (0, path_1.join)(GLOBAL_CONFIG_DIR, 'nyx.json'),
62
+ ];
63
+ for (const p of paths) {
64
+ if ((0, fs_1.existsSync)(p)) {
65
+ try {
66
+ return JSON.parse((0, fs_1.readFileSync)(p, 'utf-8'));
67
+ }
68
+ catch {
69
+ continue;
70
+ }
71
+ }
72
+ }
73
+ return null;
74
+ }
75
+ getGlobalConfigDir() {
76
+ return process.env.NYX_GLOBAL_CONFIG || GLOBAL_CONFIG_DIR;
77
+ }
78
+ isDebug() {
79
+ return this.options.debug || false;
80
+ }
81
+ getDisabledTools() {
82
+ return this.options.disabled_tools || [];
83
+ }
84
+ getDisabledSkills() {
85
+ return this.options.disabled_skills || [];
86
+ }
87
+ getSkillsPaths() {
88
+ const paths = this.options.skills_paths || [];
89
+ const home = (0, os_1.homedir)();
90
+ if ((0, os_1.platform)() === 'win32') {
91
+ const local = process.env.LOCALAPPDATA || (0, path_1.join)(home, 'AppData', 'Local');
92
+ paths.push((0, path_1.join)(local, 'agents', 'skills'));
93
+ paths.push((0, path_1.join)(local, 'nyx', 'skills'));
94
+ }
95
+ else {
96
+ const xdgConfig = process.env.XDG_CONFIG_HOME || (0, path_1.join)(home, '.config');
97
+ paths.push((0, path_1.join)(xdgConfig, 'agents', 'skills'));
98
+ paths.push((0, path_1.join)(xdgConfig, 'nyx', 'skills'));
99
+ }
100
+ return [...new Set(paths)];
101
+ }
102
+ saveConfig(data) {
103
+ this.raw = { ...this.raw, ...data };
104
+ const configDir = this.getGlobalConfigDir();
105
+ (0, fs_1.mkdirSync)(configDir, { recursive: true });
106
+ (0, fs_1.writeFileSync)((0, path_1.join)(configDir, 'nyx.json'), JSON.stringify(this.raw, null, 2));
107
+ }
108
+ }
109
+ exports.Config = Config;
110
+ //# sourceMappingURL=index.js.map