crewx 0.8.4 → 0.8.5-rc.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/package.json +1 -1
- package/packages/cli/package.json +1 -1
- package/dist-server/adapters/adapter.module.js +0 -35
- package/dist-server/adapters/adapter.service.js +0 -79
- package/dist-server/adapters/http-router.service.js +0 -91
- package/dist-server/app.module.js +0 -102
- package/dist-server/bootstrap/crewx-server.js +0 -79
- package/dist-server/common/cors.js +0 -15
- package/dist-server/common/decorators/project.decorator.js +0 -21
- package/dist-server/common/decorators/workspace.decorator.js +0 -24
- package/dist-server/common/interceptor/api-id-header.interceptor.js +0 -53
- package/dist-server/common/interceptor/http-logging.interceptor.js +0 -124
- package/dist-server/common/limits/defaults.js +0 -13
- package/dist-server/common/limits/limits-provider.js +0 -6
- package/dist-server/common/limits/limits.controller.js +0 -38
- package/dist-server/common/limits/limits.module.js +0 -24
- package/dist-server/common/limits/local-limits.provider.js +0 -27
- package/dist-server/common/middleware/workspace.middleware.js +0 -210
- package/dist-server/common/repository.exception-filter.js +0 -48
- package/dist-server/common/workspace-context.store.js +0 -25
- package/dist-server/domain/agent/agent.controller.js +0 -96
- package/dist-server/domain/agent/agent.module.js +0 -26
- package/dist-server/domain/agent/agent.service.js +0 -317
- package/dist-server/domain/agent/agent.types.js +0 -3
- package/dist-server/domain/agent/dto/create-agent.dto.js +0 -80
- package/dist-server/domain/agent/dto/preview-prompt.dto.js +0 -77
- package/dist-server/domain/agent/dto/provider-meta.dto.js +0 -2
- package/dist-server/domain/agent/dto/update-agent.dto.js +0 -92
- package/dist-server/domain/agent/provider.controller.js +0 -38
- package/dist-server/domain/agent/template-processor.service.js +0 -71
- package/dist-server/domain/auth/auth.constants.js +0 -4
- package/dist-server/domain/auth/auth.controller.js +0 -120
- package/dist-server/domain/auth/auth.module.js +0 -47
- package/dist-server/domain/auth/decorators/public.decorator.js +0 -7
- package/dist-server/domain/auth/guards/base-auth.guard.js +0 -62
- package/dist-server/domain/auth/utils/ip.utils.js +0 -31
- package/dist-server/domain/box/box.controller.js +0 -77
- package/dist-server/domain/box/box.module.js +0 -21
- package/dist-server/domain/box/box.service.js +0 -97
- package/dist-server/domain/box/dto/create-box.dto.js +0 -74
- package/dist-server/domain/cli/cli.controller.js +0 -88
- package/dist-server/domain/cli/cli.module.js +0 -21
- package/dist-server/domain/cli/cli.service.js +0 -435
- package/dist-server/domain/cli/dto/update-cli.dto.js +0 -31
- package/dist-server/domain/doc/doc.controller.js +0 -95
- package/dist-server/domain/doc/doc.module.js +0 -21
- package/dist-server/domain/doc/doc.service.js +0 -368
- package/dist-server/domain/doc/dto/doc.dto.js +0 -64
- package/dist-server/domain/document/document.controller.js +0 -57
- package/dist-server/domain/document/document.module.js +0 -22
- package/dist-server/domain/document/document.service.js +0 -271
- package/dist-server/domain/document/dto/register-document.dto.js +0 -24
- package/dist-server/domain/fs/dto/mkdir-request.dto.js +0 -47
- package/dist-server/domain/fs/dto/mkdir-response.dto.js +0 -2
- package/dist-server/domain/fs/dto/quick-access.dto.js +0 -2
- package/dist-server/domain/fs/dto/tree-node.dto.js +0 -2
- package/dist-server/domain/fs/dto/tree-query.dto.js +0 -35
- package/dist-server/domain/fs/fs.controller.js +0 -63
- package/dist-server/domain/fs/fs.module.js +0 -22
- package/dist-server/domain/fs/fs.service.js +0 -303
- package/dist-server/domain/git/git.module.js +0 -20
- package/dist-server/domain/git/git.service.js +0 -222
- package/dist-server/domain/health/health.controller.js +0 -57
- package/dist-server/domain/health/health.module.js +0 -19
- package/dist-server/domain/knowledge/dto/graph-knowledge.dto.js +0 -27
- package/dist-server/domain/knowledge/dto/knowledge.dto.js +0 -71
- package/dist-server/domain/knowledge/knowledge.controller.js +0 -122
- package/dist-server/domain/knowledge/knowledge.module.js +0 -21
- package/dist-server/domain/knowledge/knowledge.service.js +0 -538
- package/dist-server/domain/mcp/browser-session.store.js +0 -247
- package/dist-server/domain/mcp/crewx-tool.factory.js +0 -117
- package/dist-server/domain/mcp/mcp-auth.guard.js +0 -61
- package/dist-server/domain/mcp/mcp.constants.js +0 -4
- package/dist-server/domain/mcp/mcp.controller.js +0 -125
- package/dist-server/domain/mcp/mcp.dto.js +0 -12
- package/dist-server/domain/mcp/mcp.module.js +0 -49
- package/dist-server/domain/mcp/mcp.service.js +0 -682
- package/dist-server/domain/mcp/tool-router.service.js +0 -120
- package/dist-server/domain/message/dto/list-messages.dto.js +0 -57
- package/dist-server/domain/message/dto/send-message.dto.js +0 -45
- package/dist-server/domain/message/message.controller.js +0 -73
- package/dist-server/domain/message/message.module.js +0 -25
- package/dist-server/domain/message/message.service.js +0 -158
- package/dist-server/domain/onboarding/onboarding.controller.js +0 -97
- package/dist-server/domain/onboarding/onboarding.module.js +0 -23
- package/dist-server/domain/onboarding/onboarding.service.js +0 -106
- package/dist-server/domain/onboarding/onboarding.types.js +0 -2
- package/dist-server/domain/onboarding/presets/custom.js +0 -10
- package/dist-server/domain/onboarding/presets/dev-team.js +0 -41
- package/dist-server/domain/onboarding/presets/index.js +0 -15
- package/dist-server/domain/onboarding/presets/marketing-team.js +0 -29
- package/dist-server/domain/onboarding/presets/planning-team.js +0 -29
- package/dist-server/domain/onboarding/presets/solo.js +0 -17
- package/dist-server/domain/project/dto/create-project.dto.js +0 -46
- package/dist-server/domain/project/dto/update-project.dto.js +0 -60
- package/dist-server/domain/project/project.controller.js +0 -129
- package/dist-server/domain/project/project.module.js +0 -22
- package/dist-server/domain/project/project.service.js +0 -173
- package/dist-server/domain/skill/dto/add-registry.dto.js +0 -23
- package/dist-server/domain/skill/dto/install-skill.dto.js +0 -30
- package/dist-server/domain/skill/skill.controller.js +0 -136
- package/dist-server/domain/skill/skill.module.js +0 -22
- package/dist-server/domain/skill/skill.service.js +0 -632
- package/dist-server/domain/task/dto/all-tasks.dto.js +0 -55
- package/dist-server/domain/task/dto/list-tasks.dto.js +0 -69
- package/dist-server/domain/task/dto/search-tasks.dto.js +0 -66
- package/dist-server/domain/task/dto/send-message.dto.js +0 -31
- package/dist-server/domain/task/dto/task-status.dto.js +0 -34
- package/dist-server/domain/task/dto/workspace-usage.dto.js +0 -38
- package/dist-server/domain/task/task.constants.js +0 -5
- package/dist-server/domain/task/task.controller.js +0 -169
- package/dist-server/domain/task/task.module.js +0 -23
- package/dist-server/domain/task/task.service.js +0 -722
- package/dist-server/domain/thread/dto/build-context.dto.js +0 -42
- package/dist-server/domain/thread/dto/list-messages.dto.js +0 -49
- package/dist-server/domain/thread/dto/list-threads.dto.js +0 -70
- package/dist-server/domain/thread/dto/search-threads.dto.js +0 -13
- package/dist-server/domain/thread/dto/update-thread.dto.js +0 -23
- package/dist-server/domain/thread/thread.controller.js +0 -132
- package/dist-server/domain/thread/thread.module.js +0 -23
- package/dist-server/domain/thread/thread.service.js +0 -399
- package/dist-server/domain/usage/usage.controller.js +0 -118
- package/dist-server/domain/usage/usage.module.js +0 -21
- package/dist-server/domain/usage/usage.service.js +0 -343
- package/dist-server/domain/usage/usage.types.js +0 -4
- package/dist-server/domain/wbs/wbs.controller.js +0 -51
- package/dist-server/domain/wbs/wbs.module.js +0 -21
- package/dist-server/domain/wbs/wbs.service.js +0 -94
- package/dist-server/domain/workflow/workflow.controller.js +0 -53
- package/dist-server/domain/workflow/workflow.module.js +0 -21
- package/dist-server/domain/workflow/workflow.service.js +0 -209
- package/dist-server/domain/workspace/dto/create-workspace.dto.js +0 -45
- package/dist-server/domain/workspace/dto/switch-workspace.dto.js +0 -32
- package/dist-server/domain/workspace/dto/workspace-info.dto.js +0 -2
- package/dist-server/domain/workspace/workspace.controller.js +0 -98
- package/dist-server/domain/workspace/workspace.module.js +0 -22
- package/dist-server/domain/workspace/workspace.service.js +0 -216
- package/dist-server/main.js +0 -175
- package/dist-server/modules/crewx-pool.service.js +0 -70
- package/dist-server/modules/crewx.module.js +0 -47
- package/dist-server/package.json +0 -3
- package/dist-server/repository/base-sqlite.repository.js +0 -18
- package/dist-server/repository/box.repository.js +0 -99
- package/dist-server/repository/message.repository.js +0 -22
- package/dist-server/repository/project.repository.js +0 -48
- package/dist-server/repository/repository.module.js +0 -34
- package/dist-server/repository/request-log.repository.js +0 -96
- package/dist-server/repository/task.repository.js +0 -102
- package/dist-server/repository/thread.repository.js +0 -143
- package/dist-server/shared/crewx-home.js +0 -58
- package/dist-server/shared/crewx-state.js +0 -66
- package/dist-server/test-utils/compat-database.js +0 -30
- package/dist-server/utils/tokenizer.js +0 -8
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.DocumentService = void 0;
|
|
13
|
-
const common_1 = require("@nestjs/common");
|
|
14
|
-
const fs_1 = require("fs");
|
|
15
|
-
const path_1 = require("path");
|
|
16
|
-
const js_yaml_1 = require("js-yaml");
|
|
17
|
-
const unified_1 = require("unified");
|
|
18
|
-
const remark_parse_1 = __importDefault(require("remark-parse"));
|
|
19
|
-
const unist_util_visit_1 = require("unist-util-visit");
|
|
20
|
-
const workspace_context_store_js_1 = require("../../common/workspace-context.store.js");
|
|
21
|
-
const ALLOWED_EXTENSIONS = new Set(['.md', '.mdx']);
|
|
22
|
-
let DocumentService = class DocumentService {
|
|
23
|
-
get projectRoot() {
|
|
24
|
-
return (0, workspace_context_store_js_1.getWorkspacePath)();
|
|
25
|
-
}
|
|
26
|
-
/** Parse crewx.yaml and return metadata list (no file I/O for inline docs). */
|
|
27
|
-
getDocumentItems() {
|
|
28
|
-
const raw = this.loadRawDocuments();
|
|
29
|
-
if (!raw)
|
|
30
|
-
return [];
|
|
31
|
-
const items = [];
|
|
32
|
-
for (const [key, source] of Object.entries(raw)) {
|
|
33
|
-
if (typeof source === 'string') {
|
|
34
|
-
items.push({ key, type: 'inline' });
|
|
35
|
-
}
|
|
36
|
-
else if (source && typeof source === 'object') {
|
|
37
|
-
if ('path' in source && typeof source.path === 'string') {
|
|
38
|
-
// Return project-relative POSIX path (forward slashes) for cross-platform safety
|
|
39
|
-
const relPath = source.path.replace(/\\/g, '/').replace(/^\.?\//, '');
|
|
40
|
-
items.push({
|
|
41
|
-
key,
|
|
42
|
-
type: 'file',
|
|
43
|
-
path: relPath,
|
|
44
|
-
summary: source.summary,
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
// { content: "..." } form — inline object
|
|
49
|
-
items.push({ key, type: 'inline', summary: source.summary });
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return items;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Register a new file-based document entry in crewx.yaml.
|
|
57
|
-
* Idempotent: if the path is already registered, returns the existing key.
|
|
58
|
-
* Uses text-level append to preserve YAML comments and formatting.
|
|
59
|
-
*/
|
|
60
|
-
registerDocument(filePath) {
|
|
61
|
-
// Validate: no path traversal
|
|
62
|
-
if (filePath.includes('..')) {
|
|
63
|
-
throw new common_1.BadRequestException('Path traversal is not allowed');
|
|
64
|
-
}
|
|
65
|
-
// Validate: must be relative
|
|
66
|
-
if ((0, path_1.isAbsolute)(filePath)) {
|
|
67
|
-
throw new common_1.BadRequestException('Absolute paths are not allowed; use a project-relative path');
|
|
68
|
-
}
|
|
69
|
-
// Validate: only .md / .mdx
|
|
70
|
-
const ext = (0, path_1.extname)(filePath).toLowerCase();
|
|
71
|
-
if (!ALLOWED_EXTENSIONS.has(ext)) {
|
|
72
|
-
throw new common_1.BadRequestException(`Extension "${ext}" is not allowed; only .md and .mdx files are supported`);
|
|
73
|
-
}
|
|
74
|
-
// Validate: file must exist
|
|
75
|
-
const absPath = this.resolveDocPath(filePath);
|
|
76
|
-
if (!(0, fs_1.existsSync)(absPath)) {
|
|
77
|
-
throw new common_1.BadRequestException(`File not found: ${filePath}`);
|
|
78
|
-
}
|
|
79
|
-
// Idempotency: check if already registered
|
|
80
|
-
const existing = this.findRegisteredKey(filePath);
|
|
81
|
-
if (existing) {
|
|
82
|
-
return { key: existing, type: 'file', path: filePath.replace(/\\/g, '/').replace(/^\.?\//, '') };
|
|
83
|
-
}
|
|
84
|
-
// Find crewx.yaml
|
|
85
|
-
const configPath = this.resolveCrewxConfigPath();
|
|
86
|
-
if (!configPath) {
|
|
87
|
-
throw new common_1.BadRequestException('crewx.yaml not found in project root');
|
|
88
|
-
}
|
|
89
|
-
// Generate a unique key
|
|
90
|
-
const key = this.generateDocumentKey(filePath);
|
|
91
|
-
// Append to crewx.yaml using text-level manipulation (preserves comments/formatting)
|
|
92
|
-
this.appendToCrewxYaml(configPath, key, filePath);
|
|
93
|
-
return { key, type: 'file', path: filePath.replace(/\\/g, '/').replace(/^\.?\//, '') };
|
|
94
|
-
}
|
|
95
|
-
/** Load documents with their content for template rendering. */
|
|
96
|
-
loadDocumentEntries() {
|
|
97
|
-
const raw = this.loadRawDocuments();
|
|
98
|
-
const result = new Map();
|
|
99
|
-
if (!raw)
|
|
100
|
-
return result;
|
|
101
|
-
for (const [key, source] of Object.entries(raw)) {
|
|
102
|
-
try {
|
|
103
|
-
if (typeof source === 'string') {
|
|
104
|
-
result.set(key, { key, type: 'inline', content: source });
|
|
105
|
-
}
|
|
106
|
-
else if (source && typeof source === 'object') {
|
|
107
|
-
if ('path' in source && typeof source.path === 'string') {
|
|
108
|
-
const absPath = this.resolveDocPath(source.path);
|
|
109
|
-
if ((0, fs_1.existsSync)(absPath)) {
|
|
110
|
-
const content = (0, fs_1.readFileSync)(absPath, 'utf-8');
|
|
111
|
-
result.set(key, {
|
|
112
|
-
key,
|
|
113
|
-
type: 'file',
|
|
114
|
-
path: absPath,
|
|
115
|
-
summary: source.summary,
|
|
116
|
-
content,
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
else if ('content' in source && typeof source.content === 'string') {
|
|
121
|
-
result.set(key, {
|
|
122
|
-
key,
|
|
123
|
-
type: 'inline',
|
|
124
|
-
summary: source.summary,
|
|
125
|
-
content: source.content,
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
catch {
|
|
131
|
-
// Skip unloadable documents silently
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return result;
|
|
135
|
-
}
|
|
136
|
-
/** Extract TOC from markdown content as indented markdown list. */
|
|
137
|
-
extractToc(content) {
|
|
138
|
-
try {
|
|
139
|
-
// Strip YAML frontmatter (--- ... ---) before parsing to prevent
|
|
140
|
-
// frontmatter fields from being misinterpreted as setext headings
|
|
141
|
-
const stripped = content.replace(/^---[\r\n][\s\S]*?[\r\n]---[\r\n]?/, '');
|
|
142
|
-
const tree = (0, unified_1.unified)().use(remark_parse_1.default).parse(stripped);
|
|
143
|
-
const headings = [];
|
|
144
|
-
(0, unist_util_visit_1.visit)(tree, 'heading', (node) => {
|
|
145
|
-
const text = node.children
|
|
146
|
-
.map((child) => {
|
|
147
|
-
if (child.type === 'text')
|
|
148
|
-
return child.value;
|
|
149
|
-
if (child.type === 'inlineCode')
|
|
150
|
-
return child.value;
|
|
151
|
-
if ('children' in child) {
|
|
152
|
-
return child.children
|
|
153
|
-
.map((c) => c.value ?? '')
|
|
154
|
-
.join('');
|
|
155
|
-
}
|
|
156
|
-
return '';
|
|
157
|
-
})
|
|
158
|
-
.join('');
|
|
159
|
-
headings.push({ depth: node.depth, text: text.trim() });
|
|
160
|
-
});
|
|
161
|
-
if (headings.length === 0)
|
|
162
|
-
return '';
|
|
163
|
-
return headings.map(({ depth, text }) => `${' '.repeat(depth - 1)}- ${text}`).join('\n');
|
|
164
|
-
}
|
|
165
|
-
catch {
|
|
166
|
-
return '';
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
// ── Private helpers ──────────────────────────────────────
|
|
170
|
-
/** Check if a relative path is already registered; returns the key or undefined. */
|
|
171
|
-
findRegisteredKey(relPath) {
|
|
172
|
-
const items = this.getDocumentItems();
|
|
173
|
-
const normalizedRel = relPath.replace(/\\/g, '/').replace(/^\.?\//, '');
|
|
174
|
-
const absPath = this.resolveDocPath(relPath);
|
|
175
|
-
for (const item of items) {
|
|
176
|
-
if (item.type !== 'file' || !item.path)
|
|
177
|
-
continue;
|
|
178
|
-
const itemNorm = item.path.replace(/\\/g, '/').replace(/^\.?\//, '');
|
|
179
|
-
const absNorm = absPath.replace(/\\/g, '/');
|
|
180
|
-
if (itemNorm === absNorm
|
|
181
|
-
|| itemNorm.endsWith('/' + normalizedRel)
|
|
182
|
-
|| itemNorm === normalizedRel) {
|
|
183
|
-
return item.key;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return undefined;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Generate a unique YAML key from the file basename (no extension).
|
|
190
|
-
* Appends -2, -3, ... if the key already exists.
|
|
191
|
-
*/
|
|
192
|
-
generateDocumentKey(filePath) {
|
|
193
|
-
const base = (0, path_1.basename)(filePath, (0, path_1.extname)(filePath));
|
|
194
|
-
const existingKeys = new Set(this.getDocumentItems().map((d) => d.key));
|
|
195
|
-
if (!existingKeys.has(base))
|
|
196
|
-
return base;
|
|
197
|
-
let n = 2;
|
|
198
|
-
while (existingKeys.has(`${base}-${n}`)) {
|
|
199
|
-
n++;
|
|
200
|
-
}
|
|
201
|
-
return `${base}-${n}`;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Append a new file-based document entry to crewx.yaml using text-level manipulation.
|
|
205
|
-
* Preserves all existing comments and formatting.
|
|
206
|
-
*/
|
|
207
|
-
appendToCrewxYaml(yamlPath, key, relPath) {
|
|
208
|
-
const raw = (0, fs_1.readFileSync)(yamlPath, 'utf-8');
|
|
209
|
-
// Locate the documents: top-level key
|
|
210
|
-
const docsMatch = /^documents:\s*$/m.exec(raw);
|
|
211
|
-
if (!docsMatch || docsMatch.index === undefined) {
|
|
212
|
-
throw new common_1.BadRequestException('documents: section not found in crewx.yaml');
|
|
213
|
-
}
|
|
214
|
-
// Content starts right after "documents:\n"
|
|
215
|
-
const docsContentStart = docsMatch.index + docsMatch[0].length + 1; // +1 for '\n'
|
|
216
|
-
// Find the next top-level key (starts at column 0, letter/underscore, followed by ':')
|
|
217
|
-
const afterDocsContent = raw.slice(docsContentStart);
|
|
218
|
-
const nextTopLevelMatch = /^[a-zA-Z_][a-zA-Z0-9_-]*\s*:/m.exec(afterDocsContent);
|
|
219
|
-
// Insertion point is either before the next top-level key or at end of file
|
|
220
|
-
const sectionEnd = nextTopLevelMatch && nextTopLevelMatch.index !== undefined
|
|
221
|
-
? docsContentStart + nextTopLevelMatch.index
|
|
222
|
-
: raw.length;
|
|
223
|
-
// Detect indentation from the first indented entry in the section
|
|
224
|
-
const sectionText = raw.slice(docsContentStart, sectionEnd);
|
|
225
|
-
const indentMatch = /^(\s+)\S/m.exec(sectionText);
|
|
226
|
-
const indent = indentMatch ? indentMatch[1] : ' ';
|
|
227
|
-
const newEntry = `${indent}${key}:\n${indent} path: ${relPath}\n`;
|
|
228
|
-
// Insert just before sectionEnd (preserving any trailing content/newlines of the section)
|
|
229
|
-
const newRaw = raw.slice(0, sectionEnd) + newEntry + raw.slice(sectionEnd);
|
|
230
|
-
(0, fs_1.writeFileSync)(yamlPath, newRaw, 'utf-8');
|
|
231
|
-
}
|
|
232
|
-
loadRawDocuments() {
|
|
233
|
-
const configPath = this.resolveCrewxConfigPath();
|
|
234
|
-
if (!configPath)
|
|
235
|
-
return null;
|
|
236
|
-
try {
|
|
237
|
-
const raw = (0, fs_1.readFileSync)(configPath, 'utf-8');
|
|
238
|
-
const config = (0, js_yaml_1.load)(raw);
|
|
239
|
-
if (!config || typeof config !== 'object')
|
|
240
|
-
return null;
|
|
241
|
-
const docs = config.documents;
|
|
242
|
-
if (!docs || typeof docs !== 'object')
|
|
243
|
-
return null;
|
|
244
|
-
return docs;
|
|
245
|
-
}
|
|
246
|
-
catch {
|
|
247
|
-
return null;
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
resolveDocPath(filePath) {
|
|
251
|
-
if ((0, path_1.isAbsolute)(filePath))
|
|
252
|
-
return (0, path_1.resolve)(filePath);
|
|
253
|
-
return (0, path_1.resolve)((0, path_1.join)(this.projectRoot, filePath));
|
|
254
|
-
}
|
|
255
|
-
resolveCrewxConfigPath() {
|
|
256
|
-
const envPath = process.env.CREWX_CONFIG;
|
|
257
|
-
if (envPath && (0, fs_1.existsSync)(envPath))
|
|
258
|
-
return envPath;
|
|
259
|
-
const base = this.projectRoot;
|
|
260
|
-
for (const name of ['crewx.yaml', 'crewx.yml']) {
|
|
261
|
-
const p = (0, path_1.join)(base, name);
|
|
262
|
-
if ((0, fs_1.existsSync)(p))
|
|
263
|
-
return p;
|
|
264
|
-
}
|
|
265
|
-
return null;
|
|
266
|
-
}
|
|
267
|
-
};
|
|
268
|
-
exports.DocumentService = DocumentService;
|
|
269
|
-
exports.DocumentService = DocumentService = __decorate([
|
|
270
|
-
(0, common_1.Injectable)()
|
|
271
|
-
], DocumentService);
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.RegisterDocumentDto = void 0;
|
|
13
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
-
const class_validator_1 = require("class-validator");
|
|
15
|
-
class RegisterDocumentDto {
|
|
16
|
-
path;
|
|
17
|
-
}
|
|
18
|
-
exports.RegisterDocumentDto = RegisterDocumentDto;
|
|
19
|
-
__decorate([
|
|
20
|
-
(0, swagger_1.ApiProperty)({ description: 'Project-relative path to the .md file (e.g. docs/guide.md)' }),
|
|
21
|
-
(0, class_validator_1.IsString)(),
|
|
22
|
-
(0, class_validator_1.IsNotEmpty)(),
|
|
23
|
-
__metadata("design:type", String)
|
|
24
|
-
], RegisterDocumentDto.prototype, "path", void 0);
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.MkdirRequestDto = void 0;
|
|
13
|
-
const class_validator_1 = require("class-validator");
|
|
14
|
-
/**
|
|
15
|
-
* Filesystem MKDIR request body.
|
|
16
|
-
*
|
|
17
|
-
* Security model:
|
|
18
|
-
* - parentPath must be absolute and pass FsService.assertPathAllowed (BLOCKED_PREFIXES)
|
|
19
|
-
* - name must NOT contain path separators ('/' or '\\'), '..', null bytes, or control chars
|
|
20
|
-
* - Recursive parent creation is NOT supported — parent must already exist
|
|
21
|
-
*/
|
|
22
|
-
class MkdirRequestDto {
|
|
23
|
-
/** Absolute path of the parent directory under which the new folder is created. */
|
|
24
|
-
parentPath;
|
|
25
|
-
/**
|
|
26
|
-
* New folder name (no path separators, no '..', no control chars).
|
|
27
|
-
* Length: 1–255. Disallows: '/', '\\', ':', null bytes, control chars (0x00–0x1f).
|
|
28
|
-
* security_reviewer Medium-3: ':' 차단 (NTFS ADS, cross-platform regex로 강화)
|
|
29
|
-
*/
|
|
30
|
-
name;
|
|
31
|
-
}
|
|
32
|
-
exports.MkdirRequestDto = MkdirRequestDto;
|
|
33
|
-
__decorate([
|
|
34
|
-
(0, class_validator_1.IsString)(),
|
|
35
|
-
(0, class_validator_1.IsNotEmpty)(),
|
|
36
|
-
(0, class_validator_1.MaxLength)(4096),
|
|
37
|
-
__metadata("design:type", String)
|
|
38
|
-
], MkdirRequestDto.prototype, "parentPath", void 0);
|
|
39
|
-
__decorate([
|
|
40
|
-
(0, class_validator_1.IsString)(),
|
|
41
|
-
(0, class_validator_1.IsNotEmpty)(),
|
|
42
|
-
(0, class_validator_1.MaxLength)(255),
|
|
43
|
-
(0, class_validator_1.Matches)(/^[^\\/:\x00-\x1f]+$/, {
|
|
44
|
-
message: 'name must not contain path separators, colon, or control characters',
|
|
45
|
-
}),
|
|
46
|
-
__metadata("design:type", String)
|
|
47
|
-
], MkdirRequestDto.prototype, "name", void 0);
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.TreeQueryDto = void 0;
|
|
13
|
-
const class_validator_1 = require("class-validator");
|
|
14
|
-
const class_transformer_1 = require("class-transformer");
|
|
15
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
16
|
-
class TreeQueryDto {
|
|
17
|
-
path;
|
|
18
|
-
maxDepth;
|
|
19
|
-
}
|
|
20
|
-
exports.TreeQueryDto = TreeQueryDto;
|
|
21
|
-
__decorate([
|
|
22
|
-
(0, swagger_1.ApiProperty)({ description: 'Absolute path to list (must be absolute)' }),
|
|
23
|
-
(0, class_validator_1.IsString)(),
|
|
24
|
-
(0, class_validator_1.IsNotEmpty)(),
|
|
25
|
-
__metadata("design:type", String)
|
|
26
|
-
], TreeQueryDto.prototype, "path", void 0);
|
|
27
|
-
__decorate([
|
|
28
|
-
(0, swagger_1.ApiPropertyOptional)({ description: 'Max depth to traverse (1–5, default 3)', minimum: 1, maximum: 5 }),
|
|
29
|
-
(0, class_validator_1.IsOptional)(),
|
|
30
|
-
(0, class_transformer_1.Type)(() => Number),
|
|
31
|
-
(0, class_validator_1.IsInt)(),
|
|
32
|
-
(0, class_validator_1.Min)(1),
|
|
33
|
-
(0, class_validator_1.Max)(5),
|
|
34
|
-
__metadata("design:type", Number)
|
|
35
|
-
], TreeQueryDto.prototype, "maxDepth", void 0);
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.FsController = void 0;
|
|
16
|
-
const common_1 = require("@nestjs/common");
|
|
17
|
-
const swagger_1 = require("@nestjs/swagger");
|
|
18
|
-
const throttler_1 = require("@nestjs/throttler");
|
|
19
|
-
const fs_service_js_1 = require("./fs.service.js");
|
|
20
|
-
const mkdir_request_dto_js_1 = require("./dto/mkdir-request.dto.js");
|
|
21
|
-
const tree_query_dto_js_1 = require("./dto/tree-query.dto.js");
|
|
22
|
-
let FsController = class FsController {
|
|
23
|
-
fsService;
|
|
24
|
-
constructor(fsService) {
|
|
25
|
-
this.fsService = fsService;
|
|
26
|
-
}
|
|
27
|
-
// FS.TREE: Filesystem directory tree
|
|
28
|
-
async getTree(query) {
|
|
29
|
-
const data = await this.fsService.getTree(query.path, query.maxDepth ?? 3);
|
|
30
|
-
const quickAccess = this.fsService.resolveQuickAccess();
|
|
31
|
-
return { success: true, data, quickAccess };
|
|
32
|
-
}
|
|
33
|
-
// FS.MKDIR: Create a new directory
|
|
34
|
-
async mkdir(dto) {
|
|
35
|
-
const data = await this.fsService.mkdir(dto.parentPath, dto.name);
|
|
36
|
-
return { success: true, data };
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
exports.FsController = FsController;
|
|
40
|
-
__decorate([
|
|
41
|
-
(0, swagger_1.ApiOperation)({ operationId: 'FS.TREE', summary: 'List filesystem tree under path' }),
|
|
42
|
-
(0, common_1.Get)('tree'),
|
|
43
|
-
__param(0, (0, common_1.Query)()),
|
|
44
|
-
__metadata("design:type", Function),
|
|
45
|
-
__metadata("design:paramtypes", [tree_query_dto_js_1.TreeQueryDto]),
|
|
46
|
-
__metadata("design:returntype", Promise)
|
|
47
|
-
], FsController.prototype, "getTree", null);
|
|
48
|
-
__decorate([
|
|
49
|
-
(0, swagger_1.ApiOperation)({ operationId: 'FS.MKDIR', summary: 'Create a new directory under parentPath' }),
|
|
50
|
-
(0, throttler_1.Throttle)({ default: { ttl: 60000, limit: 20 } }) // security_reviewer Medium-6: write API용 낮은 한도
|
|
51
|
-
,
|
|
52
|
-
(0, common_1.Post)('mkdir'),
|
|
53
|
-
(0, common_1.HttpCode)(201),
|
|
54
|
-
__param(0, (0, common_1.Body)()),
|
|
55
|
-
__metadata("design:type", Function),
|
|
56
|
-
__metadata("design:paramtypes", [mkdir_request_dto_js_1.MkdirRequestDto]),
|
|
57
|
-
__metadata("design:returntype", Promise)
|
|
58
|
-
], FsController.prototype, "mkdir", null);
|
|
59
|
-
exports.FsController = FsController = __decorate([
|
|
60
|
-
(0, swagger_1.ApiTags)('fs'),
|
|
61
|
-
(0, common_1.Controller)('ws/:slug/fs'),
|
|
62
|
-
__metadata("design:paramtypes", [fs_service_js_1.FsService])
|
|
63
|
-
], FsController);
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.FsModule = void 0;
|
|
10
|
-
const common_1 = require("@nestjs/common");
|
|
11
|
-
const fs_controller_js_1 = require("./fs.controller.js");
|
|
12
|
-
const fs_service_js_1 = require("./fs.service.js");
|
|
13
|
-
let FsModule = class FsModule {
|
|
14
|
-
};
|
|
15
|
-
exports.FsModule = FsModule;
|
|
16
|
-
exports.FsModule = FsModule = __decorate([
|
|
17
|
-
(0, common_1.Module)({
|
|
18
|
-
controllers: [fs_controller_js_1.FsController],
|
|
19
|
-
providers: [fs_service_js_1.FsService],
|
|
20
|
-
exports: [fs_service_js_1.FsService],
|
|
21
|
-
})
|
|
22
|
-
], FsModule);
|