@bragduck/mcp 1.6.0 → 1.7.1
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/dist/index.js +1856 -117
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
- package/dist/api-client.d.ts +0 -29
- package/dist/api-client.js +0 -146
- package/dist/api-client.js.map +0 -1
- package/dist/auth.d.ts +0 -8
- package/dist/auth.js +0 -202
- package/dist/auth.js.map +0 -1
- package/dist/credentials.d.ts +0 -31
- package/dist/credentials.js +0 -150
- package/dist/credentials.js.map +0 -1
- package/dist/index.d.ts +0 -2
- package/dist/org-preference.d.ts +0 -7
- package/dist/org-preference.js +0 -22
- package/dist/org-preference.js.map +0 -1
- package/dist/tools/link-brag-to-key-result.d.ts +0 -30
- package/dist/tools/link-brag-to-key-result.js +0 -81
- package/dist/tools/link-brag-to-key-result.js.map +0 -1
- package/dist/tools/list-brags.d.ts +0 -53
- package/dist/tools/list-brags.js +0 -110
- package/dist/tools/list-brags.js.map +0 -1
- package/dist/tools/list-objectives.d.ts +0 -15
- package/dist/tools/list-objectives.js +0 -66
- package/dist/tools/list-objectives.js.map +0 -1
- package/dist/tools/list-organisations.d.ts +0 -15
- package/dist/tools/list-organisations.js +0 -73
- package/dist/tools/list-organisations.js.map +0 -1
- package/dist/tools/log-brag.d.ts +0 -88
- package/dist/tools/log-brag.js +0 -175
- package/dist/tools/log-brag.js.map +0 -1
- package/dist/tools/log-story.d.ts +0 -76
- package/dist/tools/log-story.js +0 -116
- package/dist/tools/log-story.js.map +0 -1
- package/dist/tools/login.d.ts +0 -24
- package/dist/tools/login.js +0 -46
- package/dist/tools/login.js.map +0 -1
- package/dist/tools/preview-brag.d.ts +0 -71
- package/dist/tools/preview-brag.js +0 -103
- package/dist/tools/preview-brag.js.map +0 -1
- package/dist/tools/quick-brag.d.ts +0 -38
- package/dist/tools/quick-brag.js +0 -143
- package/dist/tools/quick-brag.js.map +0 -1
- package/dist/tools/save-org-preference.d.ts +0 -30
- package/dist/tools/save-org-preference.js +0 -47
- package/dist/tools/save-org-preference.js.map +0 -1
package/dist/auth.js
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import { randomBytes } from 'crypto';
|
|
2
|
-
import { createServer } from 'http';
|
|
3
|
-
import { parse } from 'url';
|
|
4
|
-
import { exec } from 'child_process';
|
|
5
|
-
import { promisify } from 'util';
|
|
6
|
-
import { storeCredentials, storeUserInfo } from './credentials.js';
|
|
7
|
-
const execAsync = promisify(exec);
|
|
8
|
-
const API_BASE_URL = process.env.BRAGDUCK_API_URL || 'https://api.bragduck.com';
|
|
9
|
-
const OAUTH_CLIENT_ID = 'bragduck-cli';
|
|
10
|
-
const CALLBACK_PATH = '/callback';
|
|
11
|
-
const TIMEOUT_MS = 120000;
|
|
12
|
-
const MIN_PORT = 8010;
|
|
13
|
-
const MAX_PORT = 8014;
|
|
14
|
-
async function findAvailablePort() {
|
|
15
|
-
for (let port = MIN_PORT; port <= MAX_PORT; port++) {
|
|
16
|
-
try {
|
|
17
|
-
await new Promise((resolve, reject) => {
|
|
18
|
-
const testServer = createServer();
|
|
19
|
-
testServer.once('error', reject);
|
|
20
|
-
testServer.once('listening', () => {
|
|
21
|
-
testServer.close(() => resolve());
|
|
22
|
-
});
|
|
23
|
-
testServer.listen(port, '127.0.0.1');
|
|
24
|
-
});
|
|
25
|
-
return port;
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
throw new Error(`No available ports found in range ${MIN_PORT}-${MAX_PORT}`);
|
|
32
|
-
}
|
|
33
|
-
async function openBrowser(url) {
|
|
34
|
-
const platform = process.platform;
|
|
35
|
-
let command;
|
|
36
|
-
switch (platform) {
|
|
37
|
-
case 'darwin':
|
|
38
|
-
command = `open "${url}"`;
|
|
39
|
-
break;
|
|
40
|
-
case 'win32':
|
|
41
|
-
command = `start "" "${url}"`;
|
|
42
|
-
break;
|
|
43
|
-
default:
|
|
44
|
-
command = `xdg-open "${url}"`;
|
|
45
|
-
break;
|
|
46
|
-
}
|
|
47
|
-
await execAsync(command);
|
|
48
|
-
}
|
|
49
|
-
const SUCCESS_HTML = `<!DOCTYPE html>
|
|
50
|
-
<html><head><meta charset="UTF-8"><title>BragDuck - Authenticated</title>
|
|
51
|
-
<style>
|
|
52
|
-
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
53
|
-
display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0;
|
|
54
|
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; }
|
|
55
|
-
.container { text-align: center; padding: 2rem; background: rgba(255,255,255,0.1);
|
|
56
|
-
border-radius: 1rem; backdrop-filter: blur(10px); max-width: 500px; }
|
|
57
|
-
h1 { font-size: 2rem; margin: 0 0 1rem; }
|
|
58
|
-
.check { font-size: 4rem; animation: pop 0.3s ease-out; }
|
|
59
|
-
p { font-size: 1.1rem; opacity: 0.9; }
|
|
60
|
-
@keyframes pop { from { transform: scale(0); } to { transform: scale(1); } }
|
|
61
|
-
</style></head><body>
|
|
62
|
-
<div class="container">
|
|
63
|
-
<div class="check">✓</div>
|
|
64
|
-
<h1>Authentication Successful</h1>
|
|
65
|
-
<p>You can close this window and return to your editor.</p>
|
|
66
|
-
</div></body></html>`;
|
|
67
|
-
const ERROR_HTML = (error) => `<!DOCTYPE html>
|
|
68
|
-
<html><head><meta charset="UTF-8"><title>BragDuck - Auth Failed</title>
|
|
69
|
-
<style>
|
|
70
|
-
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
71
|
-
display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0;
|
|
72
|
-
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); color: white; }
|
|
73
|
-
.container { text-align: center; padding: 2rem; background: rgba(255,255,255,0.1);
|
|
74
|
-
border-radius: 1rem; backdrop-filter: blur(10px); max-width: 500px; }
|
|
75
|
-
h1 { font-size: 2rem; margin: 0 0 1rem; }
|
|
76
|
-
.err { font-size: 4rem; }
|
|
77
|
-
p { font-size: 1.1rem; opacity: 0.9; }
|
|
78
|
-
.details { background: rgba(0,0,0,0.2); padding: 1rem; border-radius: 0.5rem;
|
|
79
|
-
font-family: monospace; font-size: 0.9rem; margin-top: 1rem; }
|
|
80
|
-
</style></head><body>
|
|
81
|
-
<div class="container">
|
|
82
|
-
<div class="err">✗</div>
|
|
83
|
-
<h1>Authentication Failed</h1>
|
|
84
|
-
<p>Please try again.</p>
|
|
85
|
-
<div class="details">${error}</div>
|
|
86
|
-
</div></body></html>`;
|
|
87
|
-
async function exchangeCodeForToken(code, callbackUrl) {
|
|
88
|
-
const response = await fetch(`${API_BASE_URL}/v1/auth/cli/token`, {
|
|
89
|
-
method: 'POST',
|
|
90
|
-
headers: { 'Content-Type': 'application/json' },
|
|
91
|
-
body: JSON.stringify({
|
|
92
|
-
code,
|
|
93
|
-
redirect_uri: callbackUrl,
|
|
94
|
-
client_id: OAUTH_CLIENT_ID,
|
|
95
|
-
grant_type: 'authorization_code',
|
|
96
|
-
}),
|
|
97
|
-
});
|
|
98
|
-
if (!response.ok) {
|
|
99
|
-
const errorData = await response.json().catch(() => ({}));
|
|
100
|
-
throw new Error(errorData.message || `Token exchange failed: ${response.statusText}`);
|
|
101
|
-
}
|
|
102
|
-
return response.json();
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Run the full OAuth login flow: start callback server, open browser, wait for auth.
|
|
106
|
-
* Returns user info on success.
|
|
107
|
-
*/
|
|
108
|
-
export async function login() {
|
|
109
|
-
const state = randomBytes(32).toString('hex');
|
|
110
|
-
const port = await findAvailablePort();
|
|
111
|
-
const callbackUrl = `http://127.0.0.1:${port}${CALLBACK_PATH}`;
|
|
112
|
-
const authParams = new URLSearchParams({
|
|
113
|
-
client_id: OAUTH_CLIENT_ID,
|
|
114
|
-
redirect_uri: callbackUrl,
|
|
115
|
-
state,
|
|
116
|
-
});
|
|
117
|
-
const authUrl = `${API_BASE_URL}/v1/auth/cli/initiate?${authParams.toString()}`;
|
|
118
|
-
return new Promise((resolve, reject) => {
|
|
119
|
-
let server = null;
|
|
120
|
-
let timeoutId = null;
|
|
121
|
-
const cleanup = () => {
|
|
122
|
-
if (timeoutId)
|
|
123
|
-
globalThis.clearTimeout(timeoutId);
|
|
124
|
-
if (server) {
|
|
125
|
-
if (typeof server.closeAllConnections === 'function') {
|
|
126
|
-
server.closeAllConnections();
|
|
127
|
-
}
|
|
128
|
-
server.close();
|
|
129
|
-
server.unref();
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
const handleRequest = async (req, res) => {
|
|
133
|
-
const parsedUrl = parse(req.url || '', true);
|
|
134
|
-
if (parsedUrl.pathname !== CALLBACK_PATH) {
|
|
135
|
-
res.writeHead(404, { 'Content-Type': 'text/plain' });
|
|
136
|
-
res.end('Not Found');
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
const { code, state: returnedState, error, error_description } = parsedUrl.query;
|
|
140
|
-
if (error) {
|
|
141
|
-
const errorMsg = String(error_description || error);
|
|
142
|
-
res.writeHead(400, { 'Content-Type': 'text/html' });
|
|
143
|
-
res.end(ERROR_HTML(errorMsg));
|
|
144
|
-
cleanup();
|
|
145
|
-
reject(new Error(`OAuth error: ${errorMsg}`));
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
if (!code || !returnedState) {
|
|
149
|
-
res.writeHead(400, { 'Content-Type': 'text/html' });
|
|
150
|
-
res.end(ERROR_HTML('Missing code or state parameter'));
|
|
151
|
-
cleanup();
|
|
152
|
-
reject(new Error('Missing code or state parameter'));
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
if (returnedState !== state) {
|
|
156
|
-
res.writeHead(400, { 'Content-Type': 'text/html' });
|
|
157
|
-
res.end(ERROR_HTML('Invalid state parameter'));
|
|
158
|
-
cleanup();
|
|
159
|
-
reject(new Error('Invalid state parameter (possible CSRF)'));
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
163
|
-
res.end(SUCCESS_HTML);
|
|
164
|
-
try {
|
|
165
|
-
const tokenResponse = await exchangeCodeForToken(String(code), callbackUrl);
|
|
166
|
-
const expiresAt = tokenResponse.expires_in
|
|
167
|
-
? Date.now() + tokenResponse.expires_in * 1000
|
|
168
|
-
: undefined;
|
|
169
|
-
storeCredentials({
|
|
170
|
-
accessToken: tokenResponse.access_token,
|
|
171
|
-
refreshToken: tokenResponse.refresh_token,
|
|
172
|
-
expiresAt,
|
|
173
|
-
});
|
|
174
|
-
const user = tokenResponse.user || { id: 'unknown', email: 'unknown', name: 'Unknown' };
|
|
175
|
-
storeUserInfo(user);
|
|
176
|
-
globalThis.setTimeout(() => {
|
|
177
|
-
cleanup();
|
|
178
|
-
resolve({ email: user.email, name: user.name });
|
|
179
|
-
}, 100);
|
|
180
|
-
}
|
|
181
|
-
catch (err) {
|
|
182
|
-
cleanup();
|
|
183
|
-
reject(err);
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
server = createServer(handleRequest);
|
|
187
|
-
server.on('error', (err) => {
|
|
188
|
-
cleanup();
|
|
189
|
-
reject(new Error(`OAuth server error: ${err.message}`));
|
|
190
|
-
});
|
|
191
|
-
server.listen(port, '127.0.0.1', () => {
|
|
192
|
-
openBrowser(authUrl).catch(() => {
|
|
193
|
-
// If browser opening fails, we'll report it but keep the server running
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
timeoutId = globalThis.setTimeout(() => {
|
|
197
|
-
cleanup();
|
|
198
|
-
reject(new Error('Authentication timed out. No callback received within 2 minutes.'));
|
|
199
|
-
}, TIMEOUT_MS);
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
//# sourceMappingURL=auth.js.map
|
package/dist/auth.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth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G,YAAY,CAAC,aAAa,CAAC,CAAC;QAErC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACzB,OAAO,EAAE,CAAC;YACV,MAAM,CAAC,IAAI,KAAK,CAAC,uBAAuB,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE;YACpC,WAAW,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE;gBAC9B,wEAAwE;YAC1E,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,SAAS,GAAG,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE;YACrC,OAAO,EAAE,CAAC;YACV,MAAM,CAAC,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC,CAAC;QACxF,CAAC,EAAE,UAAU,CAAC,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/credentials.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
interface ServiceCredentials {
|
|
2
|
-
accessToken: string;
|
|
3
|
-
refreshToken?: string;
|
|
4
|
-
expiresAt?: number;
|
|
5
|
-
}
|
|
6
|
-
interface UserInfo {
|
|
7
|
-
id: string;
|
|
8
|
-
email: string;
|
|
9
|
-
name: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Get the bragduck access token from stored credentials
|
|
13
|
-
*/
|
|
14
|
-
export declare function getAccessToken(): string | null;
|
|
15
|
-
/**
|
|
16
|
-
* Get the refresh token from stored credentials
|
|
17
|
-
*/
|
|
18
|
-
export declare function getRefreshToken(): string | null;
|
|
19
|
-
/**
|
|
20
|
-
* Store credentials after login or token refresh
|
|
21
|
-
*/
|
|
22
|
-
export declare function storeCredentials(creds: ServiceCredentials): void;
|
|
23
|
-
/**
|
|
24
|
-
* Get stored user info from the Conf config store (shared with CLI)
|
|
25
|
-
*/
|
|
26
|
-
export declare function getUserInfo(): UserInfo | null;
|
|
27
|
-
/**
|
|
28
|
-
* Store user info in the Conf config store (shared with CLI)
|
|
29
|
-
*/
|
|
30
|
-
export declare function storeUserInfo(userInfo: UserInfo): void;
|
|
31
|
-
export {};
|
package/dist/credentials.js
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { createDecipheriv, scryptSync, randomBytes, createCipheriv } from 'crypto';
|
|
2
|
-
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'fs';
|
|
3
|
-
import { homedir } from 'os';
|
|
4
|
-
import { join } from 'path';
|
|
5
|
-
import Conf from 'conf';
|
|
6
|
-
const APP_NAME = 'bragduck';
|
|
7
|
-
const CREDENTIALS_DIR = '.bragduck';
|
|
8
|
-
const CREDENTIALS_FILE = 'credentials.enc';
|
|
9
|
-
const ENCRYPTION = {
|
|
10
|
-
ALGORITHM: 'aes-256-gcm',
|
|
11
|
-
KEY_LENGTH: 32,
|
|
12
|
-
IV_LENGTH: 16,
|
|
13
|
-
AUTH_TAG_LENGTH: 16,
|
|
14
|
-
SALT_LENGTH: 32,
|
|
15
|
-
};
|
|
16
|
-
function deriveEncryptionKey(salt) {
|
|
17
|
-
const password = `${APP_NAME}-${homedir()}-${process.platform}`;
|
|
18
|
-
return scryptSync(password, salt, ENCRYPTION.KEY_LENGTH);
|
|
19
|
-
}
|
|
20
|
-
function decrypt(encryptedData, key) {
|
|
21
|
-
const decipher = createDecipheriv(ENCRYPTION.ALGORITHM, key, Buffer.from(encryptedData.iv, 'hex'), { authTagLength: ENCRYPTION.AUTH_TAG_LENGTH });
|
|
22
|
-
decipher.setAuthTag(Buffer.from(encryptedData.authTag, 'hex'));
|
|
23
|
-
let decrypted = decipher.update(encryptedData.encrypted, 'hex', 'utf8');
|
|
24
|
-
decrypted += decipher.final('utf8');
|
|
25
|
-
return decrypted;
|
|
26
|
-
}
|
|
27
|
-
function encrypt(data, key) {
|
|
28
|
-
const iv = randomBytes(ENCRYPTION.IV_LENGTH);
|
|
29
|
-
const cipher = createCipheriv(ENCRYPTION.ALGORITHM, key, iv, {
|
|
30
|
-
authTagLength: ENCRYPTION.AUTH_TAG_LENGTH,
|
|
31
|
-
});
|
|
32
|
-
let encrypted = cipher.update(data, 'utf8', 'hex');
|
|
33
|
-
encrypted += cipher.final('hex');
|
|
34
|
-
const authTag = cipher.getAuthTag();
|
|
35
|
-
return {
|
|
36
|
-
encrypted,
|
|
37
|
-
iv: iv.toString('hex'),
|
|
38
|
-
authTag: authTag.toString('hex'),
|
|
39
|
-
salt: '',
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Read stored credentials from the CLI's encrypted file
|
|
44
|
-
*/
|
|
45
|
-
function readStoredCredentials() {
|
|
46
|
-
const credentialsPath = join(homedir(), CREDENTIALS_DIR, CREDENTIALS_FILE);
|
|
47
|
-
if (!existsSync(credentialsPath)) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
try {
|
|
51
|
-
const encryptedData = JSON.parse(readFileSync(credentialsPath, 'utf8'));
|
|
52
|
-
const salt = Buffer.from(encryptedData.salt, 'hex');
|
|
53
|
-
const key = deriveEncryptionKey(salt);
|
|
54
|
-
const decrypted = decrypt(encryptedData, key);
|
|
55
|
-
return JSON.parse(decrypted);
|
|
56
|
-
}
|
|
57
|
-
catch {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Write credentials to the encrypted file (shared with CLI)
|
|
63
|
-
*/
|
|
64
|
-
function writeStoredCredentials(credentials) {
|
|
65
|
-
const credentialsDir = join(homedir(), CREDENTIALS_DIR);
|
|
66
|
-
const credentialsPath = join(credentialsDir, CREDENTIALS_FILE);
|
|
67
|
-
if (!existsSync(credentialsDir)) {
|
|
68
|
-
mkdirSync(credentialsDir, { recursive: true, mode: 0o700 });
|
|
69
|
-
}
|
|
70
|
-
const data = JSON.stringify(credentials);
|
|
71
|
-
const salt = randomBytes(ENCRYPTION.SALT_LENGTH);
|
|
72
|
-
const key = deriveEncryptionKey(salt);
|
|
73
|
-
const encrypted = encrypt(data, key);
|
|
74
|
-
encrypted.salt = salt.toString('hex');
|
|
75
|
-
writeFileSync(credentialsPath, JSON.stringify(encrypted), {
|
|
76
|
-
mode: 0o600,
|
|
77
|
-
encoding: 'utf8',
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Get the bragduck access token from stored credentials
|
|
82
|
-
*/
|
|
83
|
-
export function getAccessToken() {
|
|
84
|
-
const credentials = readStoredCredentials();
|
|
85
|
-
if (!credentials)
|
|
86
|
-
return null;
|
|
87
|
-
// Handle legacy format
|
|
88
|
-
if (credentials.accessToken && !credentials.services) {
|
|
89
|
-
return credentials.accessToken;
|
|
90
|
-
}
|
|
91
|
-
return credentials.services?.bragduck?.accessToken || null;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Get the refresh token from stored credentials
|
|
95
|
-
*/
|
|
96
|
-
export function getRefreshToken() {
|
|
97
|
-
const credentials = readStoredCredentials();
|
|
98
|
-
if (!credentials)
|
|
99
|
-
return null;
|
|
100
|
-
if (credentials.accessToken && !credentials.services) {
|
|
101
|
-
return credentials.refreshToken || null;
|
|
102
|
-
}
|
|
103
|
-
return credentials.services?.bragduck?.refreshToken || null;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Store credentials after login or token refresh
|
|
107
|
-
*/
|
|
108
|
-
export function storeCredentials(creds) {
|
|
109
|
-
let existing = readStoredCredentials();
|
|
110
|
-
// Migrate legacy format
|
|
111
|
-
if (existing && existing.accessToken && !existing.services) {
|
|
112
|
-
existing = {
|
|
113
|
-
services: {
|
|
114
|
-
bragduck: {
|
|
115
|
-
accessToken: existing.accessToken,
|
|
116
|
-
refreshToken: existing.refreshToken,
|
|
117
|
-
expiresAt: existing.expiresAt,
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
const updated = {
|
|
123
|
-
...existing,
|
|
124
|
-
services: {
|
|
125
|
-
...existing?.services,
|
|
126
|
-
bragduck: creds,
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
writeStoredCredentials(updated);
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Get stored user info from the Conf config store (shared with CLI)
|
|
133
|
-
*/
|
|
134
|
-
export function getUserInfo() {
|
|
135
|
-
try {
|
|
136
|
-
const config = new Conf({ projectName: APP_NAME });
|
|
137
|
-
return config.get('userInfo') || null;
|
|
138
|
-
}
|
|
139
|
-
catch {
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Store user info in the Conf config store (shared with CLI)
|
|
145
|
-
*/
|
|
146
|
-
export function storeUserInfo(userInfo) {
|
|
147
|
-
const config = new Conf({ projectName: APP_NAME });
|
|
148
|
-
config.set('userInfo', userInfo);
|
|
149
|
-
}
|
|
150
|
-
//# sourceMappingURL=credentials.js.map
|
package/dist/credentials.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAC;AAC5B,MAAM,eAAe,GAAG,WAAW,CAAC;AACpC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAE3C,MAAM,UAA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f from 'conf';
|
|
2
|
-
const APP_NAME = 'bragduck';
|
|
3
|
-
function getConfig() {
|
|
4
|
-
return new Conf({ projectName: APP_NAME });
|
|
5
|
-
}
|
|
6
|
-
export function getOrgPreference(cwd) {
|
|
7
|
-
try {
|
|
8
|
-
const config = getConfig();
|
|
9
|
-
const prefs = config.get('orgPreferences') || {};
|
|
10
|
-
return prefs[cwd] || null;
|
|
11
|
-
}
|
|
12
|
-
catch {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
export function saveOrgPreference(cwd, orgId, orgName) {
|
|
17
|
-
const config = getConfig();
|
|
18
|
-
const prefs = config.get('orgPreferences') || {};
|
|
19
|
-
prefs[cwd] = { orgId, orgName };
|
|
20
|
-
config.set('orgPreferences', prefs);
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=org-preference.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"org-preference.js","sourceRoot":"","sources":["../src/org-preference.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,QAAQ,GAAG,UAAU,CAAC;AAS5B,SAAS,SAAS;IAChB,OAAO,IAAI,IAAI,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC7C,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAI,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAoB,IAAI,EAAE,CAAC;QACrE,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;IAC5B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,GAAW,EAAE,KAAa,EAAE,OAAe;IAC3E,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,MAAM,KAAK,GAAI,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAoB,IAAI,EAAE,CAAC;IACrE,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;IAChC,MAAM,CAAC,GAAG,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export declare const linkBragToKeyResultTool: {
|
|
2
|
-
name: string;
|
|
3
|
-
description: string;
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object";
|
|
6
|
-
properties: {
|
|
7
|
-
bragId: {
|
|
8
|
-
type: string;
|
|
9
|
-
description: string;
|
|
10
|
-
};
|
|
11
|
-
keyResultId: {
|
|
12
|
-
type: string;
|
|
13
|
-
description: string;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
required: string[];
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
interface LinkBragInput {
|
|
20
|
-
bragId: string;
|
|
21
|
-
keyResultId: string;
|
|
22
|
-
}
|
|
23
|
-
export declare function handleLinkBragToKeyResult(input: LinkBragInput): Promise<{
|
|
24
|
-
content: Array<{
|
|
25
|
-
type: string;
|
|
26
|
-
text: string;
|
|
27
|
-
}>;
|
|
28
|
-
isError?: boolean;
|
|
29
|
-
}>;
|
|
30
|
-
export {};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { apiRequest, requirePaidPlan } from '../api-client.js';
|
|
2
|
-
import { getUserInfo } from '../credentials.js';
|
|
3
|
-
export const linkBragToKeyResultTool = {
|
|
4
|
-
name: 'link_brag_to_key_result',
|
|
5
|
-
description: 'Add a keyResult/key-result to a brag (supports multiple keyResults per brag). ' +
|
|
6
|
-
'Use list_objectives to find keyResult IDs and list_brags to find brag IDs.',
|
|
7
|
-
inputSchema: {
|
|
8
|
-
type: 'object',
|
|
9
|
-
properties: {
|
|
10
|
-
bragId: {
|
|
11
|
-
type: 'string',
|
|
12
|
-
description: 'The ID of the brag to update',
|
|
13
|
-
},
|
|
14
|
-
keyResultId: {
|
|
15
|
-
type: 'string',
|
|
16
|
-
description: 'The ID of the keyResult to link the brag to',
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
required: ['bragId', 'keyResultId'],
|
|
20
|
-
},
|
|
21
|
-
};
|
|
22
|
-
export async function handleLinkBragToKeyResult(input) {
|
|
23
|
-
const planError = await requirePaidPlan();
|
|
24
|
-
if (planError)
|
|
25
|
-
return planError;
|
|
26
|
-
try {
|
|
27
|
-
const userInfo = getUserInfo();
|
|
28
|
-
if (!userInfo) {
|
|
29
|
-
return {
|
|
30
|
-
content: [{
|
|
31
|
-
type: 'text',
|
|
32
|
-
text: 'Not authenticated with BragDuck. Please call the "login" tool first.',
|
|
33
|
-
}],
|
|
34
|
-
isError: true,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
// Fetch current brag to read existing keyResultIds
|
|
38
|
-
const currentBrag = await apiRequest(`/v1/users/${userInfo.id}/brags/${input.bragId}`);
|
|
39
|
-
const existingKeyResultIds = currentBrag.keyResultIds || [];
|
|
40
|
-
// Skip if already linked
|
|
41
|
-
if (existingKeyResultIds.includes(input.keyResultId)) {
|
|
42
|
-
return {
|
|
43
|
-
content: [{
|
|
44
|
-
type: 'text',
|
|
45
|
-
text: `Brag ${input.bragId} is already linked to keyResult ${input.keyResultId}.`,
|
|
46
|
-
}],
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
// Append new keyResult (deduplicated via the check above)
|
|
50
|
-
const updatedKeyResultIds = [...existingKeyResultIds, input.keyResultId];
|
|
51
|
-
await apiRequest(`/v1/users/${userInfo.id}/brags/${input.bragId}`, {
|
|
52
|
-
method: 'PATCH',
|
|
53
|
-
body: { keyResultIds: updatedKeyResultIds },
|
|
54
|
-
});
|
|
55
|
-
return {
|
|
56
|
-
content: [{
|
|
57
|
-
type: 'text',
|
|
58
|
-
text: `KeyResult ${input.keyResultId} added to brag ${input.bragId} (now linked to ${updatedKeyResultIds.length} keyResult${updatedKeyResultIds.length === 1 ? '' : 's'}).`,
|
|
59
|
-
}],
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
catch (error) {
|
|
63
|
-
if (error instanceof Error && (error.message === 'NOT_AUTHENTICATED' || error.message === 'TOKEN_EXPIRED')) {
|
|
64
|
-
return {
|
|
65
|
-
content: [{
|
|
66
|
-
type: 'text',
|
|
67
|
-
text: 'Not authenticated with BragDuck. Please call the "login" tool first.',
|
|
68
|
-
}],
|
|
69
|
-
isError: true,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
content: [{
|
|
74
|
-
type: 'text',
|
|
75
|
-
text: `Failed to link brag to keyResult: ${error instanceof Error ? error.message : String(error)}`,
|
|
76
|
-
}],
|
|
77
|
-
isError: true,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=link-brag-to-key-result.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"link-brag-to-key-result.js","sourceRoot":"","sources":["../../src/tools/link-brag-to-key-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,IAAI,EAAE,yBAAyB;IAC/B,WAAW,EACT,gFAAgF;QAChF,4EAA4E;IAC9E,WAAW,EAAE;QACX,IAAI,EAAE,QAAiB;QACvB,UAAU,EAAE;YACV,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,8BAA8B;aAC5C;YACD,WAAW,EAAE;gBACX,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,6CAA6C;aAC3D;SACF;QACD,QAAQ,EAAE,CAAC,QAAQ,EAAE,aAAa,CAAC;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,WAAW,kBAAkB,KAAK,CAAC,MAAM,mBAAmB,mBAAmB,CAAC,MAAM,aAAa,mBAAmB,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI;iBAC5K,CAAC;SACH,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,IAAI,CAAC,KAAK,CAAC,OAAO,KAAK,mBAAmB,IAAI,KAAK,CAAC,OAAO,KAAK,eAAe,CAAC,EAAE,CAAC;YAC3G,OAAO;gBACL,OAAO,EAAE,CAAC;wBACR,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,sEAAsE;qBAC7E,CAAC;gBACF,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;QACD,OAAO;YACL,OAAO,EAAE,CAAC;oBACR,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,qCAAqC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE;iBACpG,CAAC;YACF,OAAO,EAAE,IAAI;SACd,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
export declare const listBragsTool: {
|
|
2
|
-
name: string;
|
|
3
|
-
description: string;
|
|
4
|
-
inputSchema: {
|
|
5
|
-
type: "object";
|
|
6
|
-
properties: {
|
|
7
|
-
limit: {
|
|
8
|
-
type: string;
|
|
9
|
-
description: string;
|
|
10
|
-
};
|
|
11
|
-
search: {
|
|
12
|
-
type: string;
|
|
13
|
-
description: string;
|
|
14
|
-
};
|
|
15
|
-
tags: {
|
|
16
|
-
type: string;
|
|
17
|
-
items: {
|
|
18
|
-
type: string;
|
|
19
|
-
};
|
|
20
|
-
description: string;
|
|
21
|
-
};
|
|
22
|
-
date_from: {
|
|
23
|
-
type: string;
|
|
24
|
-
description: string;
|
|
25
|
-
};
|
|
26
|
-
date_to: {
|
|
27
|
-
type: string;
|
|
28
|
-
description: string;
|
|
29
|
-
};
|
|
30
|
-
sort: {
|
|
31
|
-
type: string;
|
|
32
|
-
enum: string[];
|
|
33
|
-
description: string;
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
interface ListBragsInput {
|
|
39
|
-
limit?: number;
|
|
40
|
-
search?: string;
|
|
41
|
-
tags?: string[];
|
|
42
|
-
date_from?: string;
|
|
43
|
-
date_to?: string;
|
|
44
|
-
sort?: string;
|
|
45
|
-
}
|
|
46
|
-
export declare function handleListBrags(input: ListBragsInput): Promise<{
|
|
47
|
-
content: Array<{
|
|
48
|
-
type: string;
|
|
49
|
-
text: string;
|
|
50
|
-
}>;
|
|
51
|
-
isError?: boolean;
|
|
52
|
-
}>;
|
|
53
|
-
export {};
|