glad-web 1.0.7
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/LICENSE +21 -0
- package/README.md +182 -0
- package/README.zh-CN.md +182 -0
- package/assets/logo.svg +40 -0
- package/bin/cli.js +65 -0
- package/lib/ai-tools/demo/enhanced-demo.js +625 -0
- package/lib/ai-tools/demo/index.js +24 -0
- package/lib/ai-tools/demo/responses.js +88 -0
- package/lib/ai-tools/detector.js +76 -0
- package/lib/ai-tools/registry.js +300 -0
- package/lib/commands/config.js +78 -0
- package/lib/commands/tools.js +128 -0
- package/lib/commands/web.js +454 -0
- package/lib/config/constants.js +17 -0
- package/lib/config/manager.js +71 -0
- package/lib/git/service.js +79 -0
- package/lib/schedule/job-runner.js +162 -0
- package/lib/schedule/job-store.js +150 -0
- package/lib/schedule/key-sequences.js +49 -0
- package/lib/schedule/scheduler-service.js +39 -0
- package/lib/session/buffer.js +102 -0
- package/lib/session/pty-manager.js +241 -0
- package/lib/session/rendered-history.js +225 -0
- package/lib/session/session-manager.js +382 -0
- package/lib/session/text-history.js +274 -0
- package/lib/utils/logger.js +74 -0
- package/lib/utils/pid.js +67 -0
- package/lib/utils/validation.js +53 -0
- package/lib/web/gitgraph.js +273 -0
- package/lib/web/index.html +1470 -0
- package/lib/workspace/service.js +76 -0
- package/package.json +60 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
class WorkspaceService {
|
|
5
|
+
constructor({ gitService } = {}) {
|
|
6
|
+
this.gitService = gitService || null;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
resolveInside(rootDir, targetPath = '') {
|
|
10
|
+
const root = path.resolve(rootDir);
|
|
11
|
+
const fullPath = path.resolve(root, String(targetPath || ''));
|
|
12
|
+
const relative = path.relative(root, fullPath);
|
|
13
|
+
|
|
14
|
+
if (relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative))) {
|
|
15
|
+
return fullPath;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const error = new Error('Access denied');
|
|
19
|
+
error.statusCode = 403;
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
readFile(rootDir, filePath) {
|
|
24
|
+
const fullPath = this.resolveInside(rootDir, filePath);
|
|
25
|
+
return fs.readFileSync(fullPath, 'utf8');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async listDirectory(rootDir, dirPath = '') {
|
|
29
|
+
const fullPath = this.resolveInside(rootDir, dirPath);
|
|
30
|
+
const entries = fs.readdirSync(fullPath, { withFileTypes: true });
|
|
31
|
+
let files = entries.map(entry => ({
|
|
32
|
+
name: entry.name,
|
|
33
|
+
isDirectory: entry.isDirectory()
|
|
34
|
+
})).sort((a, b) => {
|
|
35
|
+
if (a.isDirectory && !b.isDirectory) return -1;
|
|
36
|
+
if (!a.isDirectory && b.isDirectory) return 1;
|
|
37
|
+
return a.name.localeCompare(b.name);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
if (!this.gitService) return files;
|
|
41
|
+
|
|
42
|
+
try {
|
|
43
|
+
const gitResult = await this.gitService.status(rootDir);
|
|
44
|
+
if (!gitResult.success || !Array.isArray(gitResult.files)) return files;
|
|
45
|
+
|
|
46
|
+
const gitMap = new Map();
|
|
47
|
+
gitResult.files.forEach(entry => {
|
|
48
|
+
gitMap.set(entry.path, entry.status);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
files = files.map(file => {
|
|
52
|
+
const relativePath = dirPath ? `${dirPath}/${file.name}` : file.name;
|
|
53
|
+
let gitStatus = null;
|
|
54
|
+
|
|
55
|
+
if (file.isDirectory) {
|
|
56
|
+
for (const [gitFile] of gitMap.entries()) {
|
|
57
|
+
if (gitFile.startsWith(relativePath + '/')) {
|
|
58
|
+
gitStatus = 'M';
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
} else if (gitMap.has(relativePath)) {
|
|
63
|
+
gitStatus = gitMap.get(relativePath);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return { ...file, gitStatus };
|
|
67
|
+
});
|
|
68
|
+
} catch (_) {
|
|
69
|
+
return files;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return files;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
module.exports = WorkspaceService;
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "glad-web",
|
|
3
|
+
"version": "1.0.7",
|
|
4
|
+
"description": "Glad transforms terminal-based AI coding tools into a polished, mobile-friendly local Web interface.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"glad": "bin/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"start": "node bin/cli.js",
|
|
11
|
+
"build:linux": "npx caxa -i . -e \".git\" \".github\" \"assets/Demo.mp4\" \"assets/demo.gif\" \"assets/demo.jpg\" \"assets/wechat.jpg\" \"glad-*\" \"*.tgz\" -m \"Extracting Glad...\" --output \"glad-linux-amd64\" -- \"{{caxa}}/node_modules/.bin/node\" \"{{caxa}}/bin/cli.js\"",
|
|
12
|
+
"build:macos:x64": "npx caxa -i . -e \".git\" \".github\" \"assets/Demo.mp4\" \"assets/demo.gif\" \"assets/demo.jpg\" \"assets/wechat.jpg\" \"glad-*\" \"*.tgz\" -m \"Extracting Glad...\" --output \"glad-macos-x64\" -- \"{{caxa}}/node_modules/.bin/node\" \"{{caxa}}/bin/cli.js\"",
|
|
13
|
+
"build:macos:arm64": "npx caxa -i . -e \".git\" \".github\" \"assets/Demo.mp4\" \"assets/demo.gif\" \"assets/demo.jpg\" \"assets/wechat.jpg\" \"glad-*\" \"*.tgz\" -m \"Extracting Glad...\" --output \"glad-macos-arm64\" -- \"{{caxa}}/node_modules/.bin/node\" \"{{caxa}}/bin/cli.js\"",
|
|
14
|
+
"build:windows": "npx caxa -i . -e \".git\" \".github\" \"assets/Demo.mp4\" \"assets/demo.gif\" \"assets/demo.jpg\" \"assets/wechat.jpg\" \"glad-*\" \"*.tgz\" -m \"Extracting Glad...\" --output \"glad-windows-amd64.exe\" -- \"{{caxa}}/node_modules/.bin/node\" \"{{caxa}}/bin/cli.js\"",
|
|
15
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"terminal",
|
|
19
|
+
"remote",
|
|
20
|
+
"ai",
|
|
21
|
+
"coding",
|
|
22
|
+
"assistant",
|
|
23
|
+
"claude",
|
|
24
|
+
"aider",
|
|
25
|
+
"copilot",
|
|
26
|
+
"web-ui"
|
|
27
|
+
],
|
|
28
|
+
"author": "Glad Team",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"homepage": "https://github.com/Next2012/Glad",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/Next2012/Glad.git"
|
|
34
|
+
},
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/Next2012/Glad/issues"
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18.0.0"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"bin/",
|
|
43
|
+
"lib/",
|
|
44
|
+
"assets/logo.svg",
|
|
45
|
+
"README.md"
|
|
46
|
+
],
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"chalk": "^4.1.2",
|
|
49
|
+
"commander": "^11.0.0",
|
|
50
|
+
"conf": "^10.2.0",
|
|
51
|
+
"express": "^5.2.1",
|
|
52
|
+
"node-pty": "npm:@lydell/node-pty@^1.1.0",
|
|
53
|
+
"uuid": "^9.0.0",
|
|
54
|
+
"ws": "^8.19.0",
|
|
55
|
+
"xterm-headless": "^5.3.0"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"caxa": "^3.0.1"
|
|
59
|
+
}
|
|
60
|
+
}
|