@sylix/coworker 1.0.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.
- package/README.md +191 -0
- package/dist/api/sylix.d.ts +51 -0
- package/dist/api/sylix.d.ts.map +1 -0
- package/dist/api/sylix.js +234 -0
- package/dist/api/sylix.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +235 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/ask.d.ts +2 -0
- package/dist/commands/ask.d.ts.map +1 -0
- package/dist/commands/ask.js +55 -0
- package/dist/commands/ask.js.map +1 -0
- package/dist/commands/chat.d.ts +2 -0
- package/dist/commands/chat.d.ts.map +1 -0
- package/dist/commands/chat.js +292 -0
- package/dist/commands/chat.js.map +1 -0
- package/dist/commands/commit.d.ts +2 -0
- package/dist/commands/commit.d.ts.map +1 -0
- package/dist/commands/commit.js +163 -0
- package/dist/commands/commit.js.map +1 -0
- package/dist/commands/config.d.ts +3 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +101 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/edit.d.ts +2 -0
- package/dist/commands/edit.d.ts.map +1 -0
- package/dist/commands/edit.js +112 -0
- package/dist/commands/edit.js.map +1 -0
- package/dist/commands/explain.d.ts +2 -0
- package/dist/commands/explain.d.ts.map +1 -0
- package/dist/commands/explain.js +99 -0
- package/dist/commands/explain.js.map +1 -0
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +151 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/review.d.ts +2 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +137 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/run.d.ts +2 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/commands/run.js +136 -0
- package/dist/commands/run.js.map +1 -0
- package/dist/context/reader.d.ts +24 -0
- package/dist/context/reader.d.ts.map +1 -0
- package/dist/context/reader.js +209 -0
- package/dist/context/reader.js.map +1 -0
- package/dist/memory/loader.d.ts +41 -0
- package/dist/memory/loader.d.ts.map +1 -0
- package/dist/memory/loader.js +249 -0
- package/dist/memory/loader.js.map +1 -0
- package/dist/scripts/postinstall.d.ts +7 -0
- package/dist/scripts/postinstall.d.ts.map +1 -0
- package/dist/scripts/postinstall.js +23 -0
- package/dist/scripts/postinstall.js.map +1 -0
- package/dist/tools/bash.d.ts +2 -0
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +40 -0
- package/dist/tools/bash.js.map +1 -0
- package/dist/tools/chrome.d.ts +10 -0
- package/dist/tools/chrome.d.ts.map +1 -0
- package/dist/tools/chrome.js +228 -0
- package/dist/tools/chrome.js.map +1 -0
- package/dist/tools/edit.d.ts +2 -0
- package/dist/tools/edit.d.ts.map +1 -0
- package/dist/tools/edit.js +67 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/ls.d.ts +2 -0
- package/dist/tools/ls.d.ts.map +1 -0
- package/dist/tools/ls.js +75 -0
- package/dist/tools/ls.js.map +1 -0
- package/dist/tools/read.d.ts +2 -0
- package/dist/tools/read.d.ts.map +1 -0
- package/dist/tools/read.js +72 -0
- package/dist/tools/read.js.map +1 -0
- package/dist/tools/registry.d.ts +2 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +64 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/utils/output.d.ts +62 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +487 -0
- package/dist/utils/output.js.map +1 -0
- package/package.json +54 -0
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.loginCommand = loginCommand;
|
|
37
|
+
const os = __importStar(require("os"));
|
|
38
|
+
const output_1 = require("../utils/output");
|
|
39
|
+
const sylix_1 = require("../api/sylix");
|
|
40
|
+
const API_BASE = 'https://api.sylixide.com';
|
|
41
|
+
async function loginCommand() {
|
|
42
|
+
await (0, output_1.printHeader)();
|
|
43
|
+
console.log('Authenticate CoWorker with your Sylix account');
|
|
44
|
+
console.log();
|
|
45
|
+
console.log(output_1.theme.dim('This will open your browser to authorize the CLI.'));
|
|
46
|
+
console.log();
|
|
47
|
+
try {
|
|
48
|
+
// 1. Generate Device Code
|
|
49
|
+
const deviceName = `CoWorker CLI on ${os.hostname()}`;
|
|
50
|
+
const codeRes = await fetch(`${API_BASE}/v1/auth/device/code`, {
|
|
51
|
+
method: 'POST',
|
|
52
|
+
headers: { 'Content-Type': 'application/json' },
|
|
53
|
+
body: JSON.stringify({
|
|
54
|
+
device_id: `coworker-${os.hostname()}-${Date.now()}`,
|
|
55
|
+
device_name: deviceName,
|
|
56
|
+
})
|
|
57
|
+
});
|
|
58
|
+
if (!codeRes.ok) {
|
|
59
|
+
const errorData = await codeRes.json().catch(() => ({}));
|
|
60
|
+
throw new Error(errorData.error_description || 'Failed to generate device code from Sylix API');
|
|
61
|
+
}
|
|
62
|
+
const codeData = await codeRes.json();
|
|
63
|
+
if (!codeData.success) {
|
|
64
|
+
throw new Error(codeData.error_description || 'Unknown API error');
|
|
65
|
+
}
|
|
66
|
+
const device_code = codeData.device_code;
|
|
67
|
+
const user_code = codeData.user_code;
|
|
68
|
+
const verification_uri_complete = codeData.verification_uri_complete;
|
|
69
|
+
const interval = codeData.interval || 5;
|
|
70
|
+
const urlLength = verification_uri_complete.length;
|
|
71
|
+
const innerWidth = Math.max(46, urlLength + 4);
|
|
72
|
+
const pad = (len) => ' '.repeat(Math.max(0, innerWidth - len));
|
|
73
|
+
console.log(output_1.theme.brand('╭─ Device Authorization ─' + '─'.repeat(Math.max(0, innerWidth - 23)) + '╮'));
|
|
74
|
+
console.log(output_1.theme.brand('│') + pad(0) + output_1.theme.brand('│'));
|
|
75
|
+
console.log(output_1.theme.brand('│') + ' ' + output_1.theme.white('Your authorization code: ') + output_1.theme.accent(user_code) + pad(27 + user_code.length) + output_1.theme.brand('│'));
|
|
76
|
+
console.log(output_1.theme.brand('│') + pad(0) + output_1.theme.brand('│'));
|
|
77
|
+
console.log(output_1.theme.brand('│') + ' Opening browser...' + pad(20) + output_1.theme.brand('│'));
|
|
78
|
+
console.log(output_1.theme.brand('│') + pad(0) + output_1.theme.brand('│'));
|
|
79
|
+
console.log(output_1.theme.brand('│') + ' ' + output_1.theme.dim('If browser does not open, visit:') + pad(34) + output_1.theme.brand('│'));
|
|
80
|
+
console.log(output_1.theme.brand('│') + ' ' + output_1.theme.accent(verification_uri_complete) + pad(2 + urlLength) + output_1.theme.brand('│'));
|
|
81
|
+
console.log(output_1.theme.brand('│') + pad(0) + output_1.theme.brand('│'));
|
|
82
|
+
console.log(output_1.theme.brand('╰' + '─'.repeat(innerWidth) + '╯'));
|
|
83
|
+
console.log();
|
|
84
|
+
// Attempt to auto-open browser
|
|
85
|
+
try {
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
const open = (await Promise.resolve().then(() => __importStar(require('open')))).default;
|
|
88
|
+
await open(verification_uri_complete);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// Ignore if 'open' fails or is not installed
|
|
92
|
+
}
|
|
93
|
+
// 2. Poll for Token
|
|
94
|
+
console.log(output_1.theme.dim('Waiting for authorization...'));
|
|
95
|
+
(0, output_1.startLoadingAnimation)();
|
|
96
|
+
const token = await pollForToken(device_code, interval || 5);
|
|
97
|
+
(0, output_1.stopLoadingAnimation)();
|
|
98
|
+
// 3. Save to Config
|
|
99
|
+
let config = await (0, sylix_1.loadConfig)();
|
|
100
|
+
if (!config) {
|
|
101
|
+
// Default to coworker-backend
|
|
102
|
+
config = {
|
|
103
|
+
baseUrl: 'https://api.sylixide.com',
|
|
104
|
+
apiKey: token,
|
|
105
|
+
defaultModel: 'sylix-4'
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
config.apiKey = token;
|
|
110
|
+
}
|
|
111
|
+
await (0, sylix_1.saveConfig)(config);
|
|
112
|
+
console.log();
|
|
113
|
+
(0, output_1.printSuccess)('Successfully logged in!');
|
|
114
|
+
console.log();
|
|
115
|
+
console.log(output_1.theme.dim(' Config saved to:') + ' ' + output_1.theme.white((0, sylix_1.getConfigPath)()));
|
|
116
|
+
console.log();
|
|
117
|
+
console.log(output_1.theme.dim(' Try:') + ' ' + output_1.theme.code('coworker ask "What does this project do?"'));
|
|
118
|
+
console.log();
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
(0, output_1.stopLoadingAnimation)();
|
|
122
|
+
console.log();
|
|
123
|
+
(0, output_1.printError)('Login failed');
|
|
124
|
+
if (error instanceof Error) {
|
|
125
|
+
console.error(output_1.theme.error(error.message));
|
|
126
|
+
}
|
|
127
|
+
process.exit(1);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
async function pollForToken(deviceCode, intervalSeconds) {
|
|
131
|
+
const pollIntervalMs = intervalSeconds * 1000;
|
|
132
|
+
while (true) {
|
|
133
|
+
await new Promise(resolve => setTimeout(resolve, pollIntervalMs));
|
|
134
|
+
const tokenRes = await fetch(`${API_BASE}/v1/auth/device/token`, {
|
|
135
|
+
method: 'POST',
|
|
136
|
+
headers: { 'Content-Type': 'application/json' },
|
|
137
|
+
body: JSON.stringify({ device_code: deviceCode })
|
|
138
|
+
});
|
|
139
|
+
const tokenData = await tokenRes.json();
|
|
140
|
+
if (tokenRes.ok && tokenData.success && tokenData.access_token) {
|
|
141
|
+
return tokenData.access_token;
|
|
142
|
+
}
|
|
143
|
+
if (tokenData.error === 'authorization_pending') {
|
|
144
|
+
// continue polling
|
|
145
|
+
process.stdout.write('.');
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
throw new Error(tokenData.error_description || 'Token polling failed');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
//# sourceMappingURL=login.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,oCA0GC;AAxHD,uCAAyB;AACzB,4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0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review.d.ts","sourceRoot":"","sources":["../../src/commands/review.ts"],"names":[],"mappings":"AAeA,wBAAsB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAsG7F"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.reviewCommand = reviewCommand;
|
|
37
|
+
const sylix_1 = require("../api/sylix");
|
|
38
|
+
const reader_1 = require("../context/reader");
|
|
39
|
+
const output_1 = require("../utils/output");
|
|
40
|
+
const fs = __importStar(require("fs-extra"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
async function reviewCommand(filePath, verbose = false) {
|
|
43
|
+
const timer = new output_1.Timer();
|
|
44
|
+
const absolutePath = path.resolve(filePath);
|
|
45
|
+
// Check if file exists
|
|
46
|
+
if (!(await fs.pathExists(absolutePath))) {
|
|
47
|
+
(0, output_1.printError)(`File not found: ${filePath}`);
|
|
48
|
+
process.exit(1);
|
|
49
|
+
}
|
|
50
|
+
try {
|
|
51
|
+
(0, output_1.startLoadingAnimation)();
|
|
52
|
+
const content = await (0, reader_1.readFileContext)(absolutePath);
|
|
53
|
+
const ext = path.extname(filePath).slice(1) || 'text';
|
|
54
|
+
const fileName = path.basename(filePath);
|
|
55
|
+
const messages = [
|
|
56
|
+
{
|
|
57
|
+
role: 'system',
|
|
58
|
+
content: `You are CoWorker, an AI coding assistant by Sylix specializing in code review.
|
|
59
|
+
Analyze the code and provide:
|
|
60
|
+
1. A quality score (1-10) for code quality
|
|
61
|
+
2. A security score (1-10) for security vulnerabilities
|
|
62
|
+
3. A performance score (1-10) for performance considerations
|
|
63
|
+
4. A readability score (1-10) for code clarity and documentation
|
|
64
|
+
|
|
65
|
+
Return your response as JSON in this exact format:
|
|
66
|
+
{
|
|
67
|
+
"quality": <number>,
|
|
68
|
+
"security": <number>,
|
|
69
|
+
"performance": <number>,
|
|
70
|
+
"readability": <number>,
|
|
71
|
+
"summary": "<brief summary of findings>",
|
|
72
|
+
"suggestions": ["<suggestion 1>", "<suggestion 2>", ...]
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
Be thorough but fair in your assessment.`
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
role: 'user',
|
|
79
|
+
content: `Review this file: ${fileName}\n\n\`\`\`${ext}\n${content}\n\`\`\``
|
|
80
|
+
}
|
|
81
|
+
];
|
|
82
|
+
const chatResponse = await (0, sylix_1.chat)(messages);
|
|
83
|
+
const responseText = chatResponse.content;
|
|
84
|
+
(0, output_1.stopLoadingAnimation)();
|
|
85
|
+
// Parse the response
|
|
86
|
+
let review;
|
|
87
|
+
try {
|
|
88
|
+
// Try to extract JSON from response
|
|
89
|
+
const jsonMatch = responseText.match(/\{[\s\S]*\}/);
|
|
90
|
+
if (jsonMatch) {
|
|
91
|
+
review = JSON.parse(jsonMatch[0]);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
throw new Error('No JSON found');
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// If parsing fails, show the response as-is
|
|
99
|
+
console.log();
|
|
100
|
+
console.log(responseText);
|
|
101
|
+
console.log();
|
|
102
|
+
(0, output_1.printResponseStats)(timer.elapsed());
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
// Print score card
|
|
106
|
+
(0, output_1.printReviewCard)(fileName, {
|
|
107
|
+
quality: review.quality || 7,
|
|
108
|
+
security: review.security || 7,
|
|
109
|
+
performance: review.performance || 7,
|
|
110
|
+
readability: review.readability || 7
|
|
111
|
+
});
|
|
112
|
+
// Print summary
|
|
113
|
+
if (review.summary) {
|
|
114
|
+
console.log(output_1.theme.brand('Summary:'));
|
|
115
|
+
console.log(output_1.theme.dim(review.summary));
|
|
116
|
+
console.log();
|
|
117
|
+
}
|
|
118
|
+
// Print suggestions
|
|
119
|
+
if (review.suggestions && review.suggestions.length > 0) {
|
|
120
|
+
console.log(output_1.theme.brand('Suggestions:'));
|
|
121
|
+
review.suggestions.forEach((suggestion, i) => {
|
|
122
|
+
console.log(` ${output_1.theme.accent(String(i + 1))}. ${suggestion}`);
|
|
123
|
+
});
|
|
124
|
+
console.log();
|
|
125
|
+
}
|
|
126
|
+
(0, output_1.printResponseStats)(timer.elapsed());
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
(0, output_1.stopLoadingAnimation)();
|
|
130
|
+
(0, output_1.printError)('Failed to review file');
|
|
131
|
+
if (error instanceof Error) {
|
|
132
|
+
console.error(error.message);
|
|
133
|
+
}
|
|
134
|
+
process.exit(1);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=review.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"review.js","sourceRoot":"","sources":["../../src/commands/review.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA,sCAsGC;AArHD,wCAAoC;AACpC,8CAAoD;AACpD,4CASyB;AACzB,6CAA+B;AAC/B,2CAA6B;AAEtB,KAAK,UAAU,aAAa,CAAC,QAAgB,EAAE,UAAmB,KAAK;IAC5E,MAAM,KAAK,GAAG,IAAI,cAAK,EAAE,CAAC;IAC1B,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE5C,uBAAuB;IACvB,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC;QACzC,IAAA,mBAAU,EAAC,mBAAmB,QAAQ,EAAE,CAAC,CAAC;QAC1C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,CAAC;QACH,IAAA,8BAAqB,GAAE,CAAC;QAExB,MAAM,OAAO,GAAG,MAAM,IAAA,wBAAe,EAAC,YAAY,CAAC,CAAC;QACpD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC;QACtD,MAAM,QAAQ,GAAG,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],"mappings":"AAwDA,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAyG5F"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.runCommandTask = runCommandTask;
|
|
7
|
+
const sylix_1 = require("../api/sylix");
|
|
8
|
+
const reader_1 = require("../context/reader");
|
|
9
|
+
const output_1 = require("../utils/output");
|
|
10
|
+
const child_process_1 = require("child_process");
|
|
11
|
+
const util_1 = require("util");
|
|
12
|
+
const prompts_1 = __importDefault(require("prompts"));
|
|
13
|
+
const execAsync = (0, util_1.promisify)(child_process_1.exec);
|
|
14
|
+
function extractCommands(response) {
|
|
15
|
+
const commands = [];
|
|
16
|
+
// Extract commands from code blocks
|
|
17
|
+
const codeBlockRegex = /```(?:bash|sh|shell|cmd|powershell)?\n([\s\S]*?)```/g;
|
|
18
|
+
let match;
|
|
19
|
+
while ((match = codeBlockRegex.exec(response)) !== null) {
|
|
20
|
+
const code = match[1].trim();
|
|
21
|
+
// Split by newlines and filter out comments/empty lines
|
|
22
|
+
const lines = code.split('\n')
|
|
23
|
+
.map(line => line.trim())
|
|
24
|
+
.filter(line => line && !line.startsWith('#') && !line.startsWith('//'));
|
|
25
|
+
commands.push(...lines);
|
|
26
|
+
}
|
|
27
|
+
return commands;
|
|
28
|
+
}
|
|
29
|
+
async function runCommand(cmd) {
|
|
30
|
+
try {
|
|
31
|
+
const { stdout, stderr } = await execAsync(cmd, {
|
|
32
|
+
cwd: process.cwd(),
|
|
33
|
+
timeout: 60000
|
|
34
|
+
});
|
|
35
|
+
return { stdout, stderr, code: 0 };
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
return {
|
|
39
|
+
stdout: error.stdout || '',
|
|
40
|
+
stderr: error.stderr || error.message,
|
|
41
|
+
code: error.code || 1
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async function runCommandTask(prompt, verbose = false) {
|
|
46
|
+
const timer = new output_1.Timer();
|
|
47
|
+
try {
|
|
48
|
+
(0, output_1.startLoadingAnimation)();
|
|
49
|
+
const cwd = process.cwd();
|
|
50
|
+
const context = await (0, reader_1.getContextString)(cwd, prompt);
|
|
51
|
+
const messages = [
|
|
52
|
+
{
|
|
53
|
+
role: 'system',
|
|
54
|
+
content: `You are CoWorker, an AI coding assistant by Sylix. You help developers run tasks and suggest terminal commands.
|
|
55
|
+
Analyze the user's request and suggest specific terminal commands to accomplish it.
|
|
56
|
+
|
|
57
|
+
For each command you suggest:
|
|
58
|
+
1. Wrap it in a bash code block
|
|
59
|
+
2. Provide a brief explanation of what it does
|
|
60
|
+
3. Consider cross-platform compatibility when possible
|
|
61
|
+
|
|
62
|
+
Be practical and focus on the most direct approach. If multiple commands are needed, list them in order.
|
|
63
|
+
If the user asks you to run potentially dangerous commands (like deleting files), warn them.`
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
role: 'user',
|
|
67
|
+
content: context
|
|
68
|
+
}
|
|
69
|
+
];
|
|
70
|
+
const chatResponse = await (0, sylix_1.chat)(messages);
|
|
71
|
+
const responseText = chatResponse.content;
|
|
72
|
+
(0, output_1.stopLoadingAnimation)();
|
|
73
|
+
// Print response
|
|
74
|
+
console.log(output_1.theme.ai(responseText));
|
|
75
|
+
console.log();
|
|
76
|
+
// Extract and offer to run commands
|
|
77
|
+
const commands = extractCommands(responseText);
|
|
78
|
+
if (commands.length > 0) {
|
|
79
|
+
console.log(output_1.theme.dim('─'.repeat(50)));
|
|
80
|
+
console.log();
|
|
81
|
+
console.log('Detected commands:');
|
|
82
|
+
console.log();
|
|
83
|
+
commands.forEach((cmd, i) => {
|
|
84
|
+
console.log(` ${output_1.theme.accent(String(i + 1))}. ${output_1.theme.code(cmd)}`);
|
|
85
|
+
});
|
|
86
|
+
console.log();
|
|
87
|
+
// Ask which commands to run
|
|
88
|
+
const response2 = await (0, prompts_1.default)({
|
|
89
|
+
type: 'multiselect',
|
|
90
|
+
name: 'commands',
|
|
91
|
+
message: 'Select commands to run',
|
|
92
|
+
choices: commands.map((cmd, i) => ({
|
|
93
|
+
title: cmd,
|
|
94
|
+
value: i,
|
|
95
|
+
selected: false
|
|
96
|
+
})),
|
|
97
|
+
instructions: false
|
|
98
|
+
});
|
|
99
|
+
if (response2.commands && response2.commands.length > 0) {
|
|
100
|
+
console.log();
|
|
101
|
+
for (const idx of response2.commands) {
|
|
102
|
+
const cmd = commands[idx];
|
|
103
|
+
console.log(`Running: ${output_1.theme.code(cmd)}`);
|
|
104
|
+
console.log();
|
|
105
|
+
const result = await runCommand(cmd);
|
|
106
|
+
if (result.stdout) {
|
|
107
|
+
console.log(result.stdout);
|
|
108
|
+
}
|
|
109
|
+
if (result.stderr) {
|
|
110
|
+
console.log(result.stderr);
|
|
111
|
+
}
|
|
112
|
+
if (result.code === 0) {
|
|
113
|
+
(0, output_1.printSuccess)(`Command completed`, cmd);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
(0, output_1.printError)(`Command failed with exit code ${result.code}`);
|
|
117
|
+
}
|
|
118
|
+
console.log();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
(0, output_1.printWarning)('No commands detected in response');
|
|
124
|
+
}
|
|
125
|
+
(0, output_1.printResponseStats)(timer.elapsed());
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
(0, output_1.stopLoadingAnimation)();
|
|
129
|
+
(0, output_1.printError)('Failed to process your request');
|
|
130
|
+
if (error instanceof Error) {
|
|
131
|
+
console.error(error.message);
|
|
132
|
+
}
|
|
133
|
+
process.exit(1);
|
|
134
|
+
}
|
|
135
|
+
}
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AE,CAAC;oBAEd,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;oBAErC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;wBAClB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;oBAC7B,CAAC;oBACD,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;wBAClB,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;oBAC7B,CAAC;oBAED,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;wBACtB,IAAA,qBAAY,EAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;oBACzC,CAAC;yBAAM,CAAC;wBACN,IAAA,mBAAU,EAAC,iCAAiC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;oBAC7D,CAAC;oBAED,OAAO,CAAC,GAAG,EAAE,CAAC;gBAChB,CAAC;YACH,CAAC;QACH,CAAC;aAAM,CAAC;YACN,IAAA,qBAAY,EAAC,kCAAkC,CAAC,CAAC;QACnD,CAAC;QAED,IAAA,2BAAkB,EAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACtC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAA,6BAAoB,GAAE,CAAC;QACvB,IAAA,mBAAU,EAAC,gCAAgC,CAAC,CAAC;QAC7C,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC/B,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface FileInfo {
|
|
2
|
+
path: string;
|
|
3
|
+
relativePath: string;
|
|
4
|
+
content?: string;
|
|
5
|
+
preview?: string;
|
|
6
|
+
lineCount: number;
|
|
7
|
+
isLarge: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface DirectoryInfo {
|
|
10
|
+
name: string;
|
|
11
|
+
path: string;
|
|
12
|
+
files: FileInfo[];
|
|
13
|
+
subdirectories: DirectoryInfo[];
|
|
14
|
+
}
|
|
15
|
+
export declare function getFileTree(dir: string, maxDepth?: number): Promise<string>;
|
|
16
|
+
export declare function getFileInfo(filePath: string): Promise<FileInfo>;
|
|
17
|
+
export declare function readDirectory(dir: string, options?: {
|
|
18
|
+
includeContent?: boolean;
|
|
19
|
+
maxFiles?: number;
|
|
20
|
+
extensions?: string[];
|
|
21
|
+
}): Promise<DirectoryInfo>;
|
|
22
|
+
export declare function getContextString(dir: string, prompt: string): Promise<string>;
|
|
23
|
+
export declare function readFileContext(filePath: string): Promise<string>;
|
|
24
|
+
//# sourceMappingURL=reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../../src/context/reader.ts"],"names":[],"mappings":"AAgCA,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,QAAQ,EAAE,CAAC;IAClB,cAAc,EAAE,aAAa,EAAE,CAAC;CACjC;AAED,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,GAAE,MAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CA4BpF;AAcD,wBAAsB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAerE;AAED,wBAAsB,aAAa,CACjC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IACP,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB,GACL,OAAO,CAAC,aAAa,CAAC,CAyDxB;AAED,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,CA4BjB;AAED,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAavE"}
|