draftgo-cli 2.0.5 → 3.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/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((a) => ({ id: a.id, name: a.name || '', type: a.type || '', status: a.status })),
158
- external_apis: indexes.external_apis.items.map((a) => ({ id: a.id, name: a.name || '', status: a.status })),
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]])),