draftgo-cli 2.0.5 → 2.0.9
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 +64 -15
- package/package.json +1 -1
- package/resources/skill/SKILL.md +75 -30
- package/resources/skill/push/SKILL.md +7 -4
- package/resources/skill/rules/dev-workflow.md +70 -70
- package/resources/skill/rules/frontend.md +10 -8
- package/resources/skill/scripts/draftgo_pull.py +1 -1
- package/resources/skill/scripts/draftgo_push.py +85 -16
- package/src/commands/check.js +1 -1
- package/src/commands/map.js +37 -1
- package/src/localdev/compose.js +19 -0
- package/src/projectMap.js +142 -2
package/src/commands/map.js
CHANGED
|
@@ -43,7 +43,43 @@ function mapCommand(projectDir, flags = {}) {
|
|
|
43
43
|
return `${s.slug || '(无 slug)'} ${s.mode || 'mode?'} ${s.name || ''}${s.code_file ? ` ${s.code_file}` : ''}`;
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
printList('
|
|
46
|
+
printList('外部 API', map.external_apis, (a) => {
|
|
47
|
+
const route = `${a.method || 'GET'} ${a.path || '/'}`;
|
|
48
|
+
const tags = a.tags && a.tags.length ? ` #${a.tags.join(',#')}` : '';
|
|
49
|
+
return `${a.id || 'new'} ${a.code || '(无 code)'} ${route} ${a.name || ''}${a.base_url ? ` ${a.base_url}` : ''}${tags}`;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
printList('文档', map.docs, (d) => {
|
|
53
|
+
return `${d.id || 'new'} ${d.slug || '(无 slug)'} ${d.title || '未命名'}${d.content_file ? ` ${d.content_file}` : ''}`;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
printList('文档分类', map.doc_categories, (c) => {
|
|
57
|
+
const parent = c.parent_id == null ? 'root' : `parent:${c.parent_id}`;
|
|
58
|
+
return `${c.id || 'new'} ${c.slug || '(无 slug)'} ${c.name || '未命名'} ${parent}`;
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
printList('系统配置', map.system_config, (c) => {
|
|
62
|
+
const sensitive = c.is_sensitive ? ' sensitive' : '';
|
|
63
|
+
return `${c.config_key || '(无 key)'} ${c.category || 'default'} ${c.value_type || 'value'}${sensitive}`;
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
printList('AIHub', map.aihub, (a) => {
|
|
67
|
+
const extra = [];
|
|
68
|
+
if (a.type === 'agent') {
|
|
69
|
+
if (a.mode) extra.push(a.mode);
|
|
70
|
+
if (a.output_format && a.output_format.mode === 'json') extra.push(`json:${a.output_format.json_strategy || 'auto'}`);
|
|
71
|
+
if (a.model_selection && a.model_selection.user_selectable) extra.push('user-model');
|
|
72
|
+
if (a.tools && a.tools.sources.length) extra.push(`tools:${a.tools.sources.length}`);
|
|
73
|
+
} else if (a.type === 'model') {
|
|
74
|
+
extra.push(`models:${a.models_count || 0}`);
|
|
75
|
+
if (a.supports_response_format === true) extra.push('response_format');
|
|
76
|
+
if (a.supports_json_schema === true) extra.push('json_schema');
|
|
77
|
+
} else if (a.type === 'mcp') {
|
|
78
|
+
extra.push(a.transport || 'transport?');
|
|
79
|
+
extra.push(`tools:${a.tools_count || 0}`);
|
|
80
|
+
}
|
|
81
|
+
return `${a.id || 'new'} ${a.type || ''} ${a.name || ''}${extra.length ? ` [${extra.join(', ')}]` : ''}`;
|
|
82
|
+
});
|
|
47
83
|
printList('角色', map.roles, (r) => `${r.code || r.id || 'new'} ${r.name || ''}`);
|
|
48
84
|
|
|
49
85
|
console.log('');
|
package/src/localdev/compose.js
CHANGED
|
@@ -101,6 +101,11 @@ function generate(projectDir, opts) {
|
|
|
101
101
|
' image: mysql:8.0',
|
|
102
102
|
` container_name: ${projectName}-mysql`,
|
|
103
103
|
' restart: unless-stopped',
|
|
104
|
+
' logging:',
|
|
105
|
+
' driver: json-file',
|
|
106
|
+
' options:',
|
|
107
|
+
' max-size: "10m"',
|
|
108
|
+
' max-file: "3"',
|
|
104
109
|
' environment:',
|
|
105
110
|
' MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}',
|
|
106
111
|
' MYSQL_DATABASE: ${MYSQL_DATABASE}',
|
|
@@ -138,6 +143,11 @@ function generate(projectDir, opts) {
|
|
|
138
143
|
' image: redis:7-alpine',
|
|
139
144
|
` container_name: ${projectName}-redis`,
|
|
140
145
|
' restart: unless-stopped',
|
|
146
|
+
' logging:',
|
|
147
|
+
' driver: json-file',
|
|
148
|
+
' options:',
|
|
149
|
+
' max-size: "10m"',
|
|
150
|
+
' max-file: "3"',
|
|
141
151
|
' command: ["redis-server", "--requirepass", "${REDIS_PASSWORD}", "--appendonly", "yes"]',
|
|
142
152
|
' volumes:',
|
|
143
153
|
' - ./data/redis:/data',
|
|
@@ -166,6 +176,11 @@ function generate(projectDir, opts) {
|
|
|
166
176
|
' image: cabinai/draftgo:latest',
|
|
167
177
|
` container_name: ${projectName}`,
|
|
168
178
|
' restart: unless-stopped',
|
|
179
|
+
' logging:',
|
|
180
|
+
' driver: json-file',
|
|
181
|
+
' options:',
|
|
182
|
+
' max-size: "10m"',
|
|
183
|
+
' max-file: "3"',
|
|
169
184
|
` ports:`,
|
|
170
185
|
` - "${appPort}:3000"`,
|
|
171
186
|
' environment:',
|
|
@@ -184,6 +199,10 @@ function generate(projectDir, opts) {
|
|
|
184
199
|
' LOG_LEVEL: INFO',
|
|
185
200
|
' LOG_MAX_BYTES: "5242880"',
|
|
186
201
|
' LOG_BACKUP_COUNT: "5"',
|
|
202
|
+
' LOG_TO_CONSOLE: "true"',
|
|
203
|
+
' LOG_CONSOLE_JSON: "true"',
|
|
204
|
+
' LOG_UVICORN_ACCESS: "true"',
|
|
205
|
+
' LOG_RUNTIME_HEARTBEAT_INTERVAL_SECONDS: "300"',
|
|
187
206
|
' UPLOAD_PROVIDER: local',
|
|
188
207
|
' UPLOAD_MAX_SIZE: "10485760"',
|
|
189
208
|
' LOCAL_UPLOAD_DIR: /app/backend/storage/uploads',
|
package/src/projectMap.js
CHANGED
|
@@ -109,6 +109,140 @@ function summarizeNav(projectDir, item) {
|
|
|
109
109
|
};
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
+
function summarizeAIHub(item) {
|
|
113
|
+
const data = item && typeof item.data === 'object' && item.data ? item.data : {};
|
|
114
|
+
const spec = data.spec && typeof data.spec === 'object' ? data.spec : {};
|
|
115
|
+
const base = {
|
|
116
|
+
id: item.id,
|
|
117
|
+
name: item.name || '',
|
|
118
|
+
type: item.type || '',
|
|
119
|
+
status: item.status,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
if (item.type === 'agent') {
|
|
123
|
+
const tools = spec.tools && typeof spec.tools === 'object' ? spec.tools : {};
|
|
124
|
+
const outputFormat = spec.output_format && typeof spec.output_format === 'object' ? spec.output_format : {};
|
|
125
|
+
const modelSelection = spec.model_selection && typeof spec.model_selection === 'object' ? spec.model_selection : {};
|
|
126
|
+
return {
|
|
127
|
+
...base,
|
|
128
|
+
mode: spec.mode || 'chat',
|
|
129
|
+
model_id: spec.model_id || null,
|
|
130
|
+
model: spec.model || data.model || '',
|
|
131
|
+
fallback_models: Array.isArray(spec.fallback_models) ? spec.fallback_models : [],
|
|
132
|
+
output_format: {
|
|
133
|
+
mode: outputFormat.mode || 'native',
|
|
134
|
+
json_strategy: outputFormat.json && outputFormat.json.strategy || null,
|
|
135
|
+
has_schema: Boolean(outputFormat.json && outputFormat.json.schema),
|
|
136
|
+
},
|
|
137
|
+
model_selection: {
|
|
138
|
+
user_selectable: Boolean(modelSelection.user_selectable),
|
|
139
|
+
on_invalid: modelSelection.on_invalid || 'ignore',
|
|
140
|
+
},
|
|
141
|
+
tools: {
|
|
142
|
+
enabled: Boolean(tools.enabled && Array.isArray(tools.sources) && tools.sources.length),
|
|
143
|
+
sources: Array.isArray(tools.sources)
|
|
144
|
+
? tools.sources.map((s) => ({
|
|
145
|
+
type: s.type || '',
|
|
146
|
+
id: s.id,
|
|
147
|
+
name: s.name || '',
|
|
148
|
+
tool_filter: Array.isArray(s.tool_filter) ? s.tool_filter : [],
|
|
149
|
+
}))
|
|
150
|
+
: [],
|
|
151
|
+
},
|
|
152
|
+
skills_count: Array.isArray(spec.skills) ? spec.skills.length : 0,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (item.type === 'model') {
|
|
157
|
+
return {
|
|
158
|
+
...base,
|
|
159
|
+
provider: data.provider || 'openai-compatible',
|
|
160
|
+
models_count: Array.isArray(data.models) ? data.models.length : 0,
|
|
161
|
+
supports_response_format: data.supports_response_format,
|
|
162
|
+
supports_json_schema: data.supports_json_schema,
|
|
163
|
+
image_generation_probe: data.image_generation_probe
|
|
164
|
+
? {
|
|
165
|
+
ok: Boolean(data.image_generation_probe.ok),
|
|
166
|
+
model: data.image_generation_probe.model || '',
|
|
167
|
+
tested_at: data.image_generation_probe.tested_at || '',
|
|
168
|
+
}
|
|
169
|
+
: null,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (item.type === 'mcp') {
|
|
174
|
+
return {
|
|
175
|
+
...base,
|
|
176
|
+
transport: data.transport || '',
|
|
177
|
+
tools_count: Array.isArray(data.tools) ? data.tools.length : 0,
|
|
178
|
+
enabled: data.enabled !== false,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (item.type === 'skill') {
|
|
183
|
+
return {
|
|
184
|
+
...base,
|
|
185
|
+
enabled: data.enabled !== false,
|
|
186
|
+
content_length: typeof data.content === 'string' ? data.content.length : 0,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (item.type === 'prompt') {
|
|
191
|
+
return {
|
|
192
|
+
...base,
|
|
193
|
+
tags: Array.isArray(item.tags) ? item.tags : [],
|
|
194
|
+
content_length: typeof data.content === 'string' ? data.content.length : 0,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return base;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function summarizeExternalAPI(item) {
|
|
202
|
+
return {
|
|
203
|
+
id: item.id,
|
|
204
|
+
code: item.code || '',
|
|
205
|
+
name: item.name || '',
|
|
206
|
+
method: item.method || 'GET',
|
|
207
|
+
path: item.path || '',
|
|
208
|
+
base_url: item.base_url || '',
|
|
209
|
+
status: item.status,
|
|
210
|
+
tags: Array.isArray(item.tags) ? item.tags : [],
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function summarizeDoc(item) {
|
|
215
|
+
return {
|
|
216
|
+
id: item.id,
|
|
217
|
+
title: item.title || '',
|
|
218
|
+
slug: item.slug || '',
|
|
219
|
+
category_id: item.category_id == null ? null : item.category_id,
|
|
220
|
+
status: item.status,
|
|
221
|
+
content_file: item.content_file || null,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function summarizeDocCategory(item) {
|
|
226
|
+
return {
|
|
227
|
+
id: item.id,
|
|
228
|
+
name: item.name || '',
|
|
229
|
+
slug: item.slug || '',
|
|
230
|
+
parent_id: item.parent_id == null ? null : item.parent_id,
|
|
231
|
+
sort_order: item.sort_order == null ? 0 : item.sort_order,
|
|
232
|
+
status: item.status,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function summarizeSystemConfig(item) {
|
|
237
|
+
return {
|
|
238
|
+
config_key: item.config_key || '',
|
|
239
|
+
category: item.category || '',
|
|
240
|
+
value_type: item.value_type || '',
|
|
241
|
+
is_sensitive: Boolean(item.is_sensitive),
|
|
242
|
+
status: item.status,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
112
246
|
function buildProjectMap(projectDir) {
|
|
113
247
|
const indexes = {
|
|
114
248
|
pages: readJsonSafe(projectDir, '.draftgo/pages/index.json'),
|
|
@@ -117,6 +251,9 @@ function buildProjectMap(projectDir) {
|
|
|
117
251
|
custom_scripts: readJsonSafe(projectDir, '.draftgo/custom_scripts/index.json'),
|
|
118
252
|
aihub: readJsonSafe(projectDir, '.draftgo/aihub/index.json'),
|
|
119
253
|
external_apis: readJsonSafe(projectDir, '.draftgo/external_apis/index.json'),
|
|
254
|
+
docs: readJsonSafe(projectDir, '.draftgo/docs/articles/index.json'),
|
|
255
|
+
doc_categories: readJsonSafe(projectDir, '.draftgo/doc_categories/index.json'),
|
|
256
|
+
system_config: readJsonSafe(projectDir, '.draftgo/system_config/index.json'),
|
|
120
257
|
roles: readJsonSafe(projectDir, '.draftgo/roles/index.json'),
|
|
121
258
|
users: readJsonSafe(projectDir, '.draftgo/users/index.json'),
|
|
122
259
|
};
|
|
@@ -154,8 +291,11 @@ function buildProjectMap(projectDir) {
|
|
|
154
291
|
status: s.status,
|
|
155
292
|
code_file: itemFile(projectDir, 'custom_scripts', s),
|
|
156
293
|
})),
|
|
157
|
-
aihub: indexes.aihub.items.map(
|
|
158
|
-
external_apis: indexes.external_apis.items.map(
|
|
294
|
+
aihub: indexes.aihub.items.map(summarizeAIHub),
|
|
295
|
+
external_apis: indexes.external_apis.items.map(summarizeExternalAPI),
|
|
296
|
+
docs: indexes.docs.items.map(summarizeDoc),
|
|
297
|
+
doc_categories: indexes.doc_categories.items.map(summarizeDocCategory),
|
|
298
|
+
system_config: indexes.system_config.items.map(summarizeSystemConfig),
|
|
159
299
|
roles: indexes.roles.items.map((r) => ({ id: r.id, code: r.code || '', name: r.name || '', status: r.status })),
|
|
160
300
|
users_count: indexes.users.items.length,
|
|
161
301
|
routeRefs: Object.fromEntries([...routeRefs.entries()].map(([route, sources]) => [route, [...sources]])),
|