doukui 0.0.0-stage → 0.3.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.
Files changed (135) hide show
  1. package/LICENSE +21 -0
  2. package/README.en.md +42 -0
  3. package/README.md +147 -2
  4. package/bin/commands/build.js +178 -0
  5. package/bin/commands/config.js +88 -0
  6. package/bin/commands/help.js +83 -0
  7. package/bin/commands/init.js +194 -0
  8. package/bin/commands/install.js +202 -0
  9. package/bin/commands/interactive.js +352 -0
  10. package/bin/commands/list.js +108 -0
  11. package/bin/commands/loop-server.js +357 -0
  12. package/bin/commands/loop.js +1398 -0
  13. package/bin/commands/migrate.js +120 -0
  14. package/bin/commands/setup-global.js +81 -0
  15. package/bin/commands/status.js +140 -0
  16. package/bin/commands/team-cleanup.js +190 -0
  17. package/bin/commands/validate-config.js +35 -0
  18. package/bin/commands/validate.js +21 -0
  19. package/bin/commands/version.js +22 -0
  20. package/bin/context.js +143 -0
  21. package/bin/doukui.js +216 -0
  22. package/package.json +47 -4
  23. package/plugins/contracts/capabilities.js +268 -0
  24. package/plugins/contracts/checkresult-schema.json +75 -0
  25. package/plugins/contracts/config-schema.json +179 -0
  26. package/plugins/contracts/plugin-interface.js +262 -0
  27. package/plugins/contracts/plugin-schema.json +104 -0
  28. package/plugins/core/hook-session-start/index.js +281 -0
  29. package/plugins/core/hook-session-start/plugin.json +7 -0
  30. package/plugins/core/hook-skill-gate/index.js +661 -0
  31. package/plugins/core/hook-skill-gate/plugin.json +12 -0
  32. package/plugins/core/provider-loop-engine/index.js +1397 -0
  33. package/plugins/core/provider-loop-engine/plugin.json +15 -0
  34. package/plugins/core/provider-memory-store/index.js +510 -0
  35. package/plugins/core/provider-memory-store/plugin.json +9 -0
  36. package/plugins/core/provider-role-registry/index.js +376 -0
  37. package/plugins/core/provider-role-registry/plugin.json +9 -0
  38. package/plugins/core/provider-state-store/index.js +244 -0
  39. package/plugins/core/provider-state-store/plugin.json +9 -0
  40. package/plugins/core/provider-watchdog/assets/daemon-config.template.json +32 -0
  41. package/plugins/core/provider-watchdog/assets/lib/watchdog-multi-window.js +676 -0
  42. package/plugins/core/provider-watchdog/assets/watchdog.js +754 -0
  43. package/plugins/core/provider-watchdog/index.js +151 -0
  44. package/plugins/core/provider-watchdog/plugin.json +13 -0
  45. package/plugins/core/skill-agent-dispatcher/cleanup-reference.md +214 -0
  46. package/plugins/core/skill-agent-dispatcher/daemon-helpers-reference.md +249 -0
  47. package/plugins/core/skill-agent-dispatcher/plugin.json +13 -0
  48. package/plugins/core/skill-agent-dispatcher/roles-reference.md +253 -0
  49. package/plugins/core/skill-agent-dispatcher/skill.md +1291 -0
  50. package/plugins/core/skill-agentic-loop/plugin.json +20 -0
  51. package/plugins/core/skill-agentic-loop/skill.md +572 -0
  52. package/plugins/core/skill-batch-task-creator/plugin.json +15 -0
  53. package/plugins/core/skill-batch-task-creator/skill.md +620 -0
  54. package/plugins/core/skill-checklist/plugin.json +10 -0
  55. package/plugins/core/skill-checklist/skill.md +171 -0
  56. package/plugins/core/skill-completion-report/plugin.json +10 -0
  57. package/plugins/core/skill-completion-report/skill.md +331 -0
  58. package/plugins/core/skill-doukui-plan/plugin.json +15 -0
  59. package/plugins/core/skill-doukui-plan/skill.md +233 -0
  60. package/plugins/core/skill-doukui-sync/plugin.json +10 -0
  61. package/plugins/core/skill-doukui-sync/skill.md +76 -0
  62. package/plugins/core/skill-experience-logger/plugin.json +10 -0
  63. package/plugins/core/skill-experience-logger/skill.md +235 -0
  64. package/plugins/core/skill-human-checkpoint/plugin.json +10 -0
  65. package/plugins/core/skill-human-checkpoint/skill.md +194 -0
  66. package/plugins/core/skill-progress-tracker/plugin.json +10 -0
  67. package/plugins/core/skill-progress-tracker/skill.md +228 -0
  68. package/plugins/core/skill-role-manager/plugin.json +10 -0
  69. package/plugins/core/skill-role-manager/skill.md +252 -0
  70. package/plugins/core/skill-split-work-package/plugin.json +15 -0
  71. package/plugins/core/skill-split-work-package/skill.md +441 -0
  72. package/plugins/core/skill-task-archive/plugin.json +10 -0
  73. package/plugins/core/skill-task-archive/skill.md +116 -0
  74. package/plugins/core/skill-task-creator/plugin.json +15 -0
  75. package/plugins/core/skill-task-creator/skill.md +886 -0
  76. package/plugins/core/skill-team-cleanup/plugin.json +10 -0
  77. package/plugins/core/skill-team-cleanup/skill.md +266 -0
  78. package/plugins/core/skill-watchdog-manager/plugin.json +10 -0
  79. package/plugins/core/skill-watchdog-manager/skill.md +143 -0
  80. package/plugins/core/skill-workflow-orchestrator/plugin.json +13 -0
  81. package/plugins/core/skill-workflow-orchestrator/skill.md +273 -0
  82. package/plugins/core/validator-doc-sync/index.js +248 -0
  83. package/plugins/core/validator-doc-sync/plugin.json +12 -0
  84. package/plugins/core/validator-work-package/index.js +300 -0
  85. package/plugins/core/validator-work-package/plugin.json +12 -0
  86. package/plugins/plugin-registry.json +186 -0
  87. package/plugins/runtime/agent-def-generator.js +150 -0
  88. package/plugins/runtime/audit-logger.js +311 -0
  89. package/plugins/runtime/build-cli.js +89 -0
  90. package/plugins/runtime/checkresult-validator.js +131 -0
  91. package/plugins/runtime/claude-md-injector.js +159 -0
  92. package/plugins/runtime/cleanup-utils.js +293 -0
  93. package/plugins/runtime/config-manager.js +317 -0
  94. package/plugins/runtime/config-validator.js +320 -0
  95. package/plugins/runtime/context-window.js +81 -0
  96. package/plugins/runtime/event-bus.js +207 -0
  97. package/plugins/runtime/executor-claude.js +828 -0
  98. package/plugins/runtime/executor-default.js +448 -0
  99. package/plugins/runtime/executor-local.js +178 -0
  100. package/plugins/runtime/executor-sdk.js +390 -0
  101. package/plugins/runtime/harness-build.js +1037 -0
  102. package/plugins/runtime/hook-dispatcher.js +315 -0
  103. package/plugins/runtime/logger.js +192 -0
  104. package/plugins/runtime/loop-actuator.js +292 -0
  105. package/plugins/runtime/loop-coordinator.js +347 -0
  106. package/plugins/runtime/loop-defaults.js +29 -0
  107. package/plugins/runtime/loop-dispatch-batch.js +247 -0
  108. package/plugins/runtime/loop-executor.js +120 -0
  109. package/plugins/runtime/loop-report.js +327 -0
  110. package/plugins/runtime/loop-server-core.js +750 -0
  111. package/plugins/runtime/loop-snapshot.js +581 -0
  112. package/plugins/runtime/loop-trace.js +242 -0
  113. package/plugins/runtime/loop-worktree.js +404 -0
  114. package/plugins/runtime/manifest-resolver.js +457 -0
  115. package/plugins/runtime/multi-window-coordinator.js +560 -0
  116. package/plugins/runtime/objective-verifier.js +136 -0
  117. package/plugins/runtime/plan-reader.js +763 -0
  118. package/plugins/runtime/plugin-loader.js +798 -0
  119. package/plugins/runtime/plugin-trust.js +182 -0
  120. package/plugins/runtime/plugin-validator.js +491 -0
  121. package/plugins/runtime/provider-failover.js +114 -0
  122. package/plugins/runtime/provider-resolver.js +342 -0
  123. package/plugins/runtime/reflection-evaluator.js +540 -0
  124. package/plugins/runtime/resolve-plugin-path.js +297 -0
  125. package/plugins/runtime/safe-path.js +119 -0
  126. package/plugins/runtime/sandbox-context.js +235 -0
  127. package/plugins/runtime/sandbox-manager.js +609 -0
  128. package/plugins/runtime/sandbox-worker.js +215 -0
  129. package/plugins/runtime/settings-merger.js +172 -0
  130. package/plugins/runtime/state-store.js +527 -0
  131. package/plugins/runtime/team-cleanup.js +497 -0
  132. package/plugins/runtime/text-tokenize.js +25 -0
  133. package/plugins/runtime/validator-pipeline.js +475 -0
  134. package/plugins/runtime/yaml-parser.js +692 -0
  135. package/templates/harness-config.yaml +388 -0
@@ -0,0 +1,352 @@
1
+ 'use strict';
2
+
3
+ var path = require('path');
4
+ var fs = require('fs');
5
+ var readline = require('readline');
6
+
7
+ /**
8
+ * Interactive command - Interactive plugin management (alias: i)
9
+ * @public
10
+ */
11
+ module.exports = {
12
+ name: 'interactive',
13
+ aliases: ['i'],
14
+ description: 'Interactive plugin management (alias: i)',
15
+ /**
16
+ * Execute the interactive command.
17
+ * @public
18
+ * @param {object} ctx - CLI context object
19
+ */
20
+ execute: function (ctx) {
21
+ var rl = readline.createInterface({
22
+ input: process.stdin,
23
+ output: process.stdout
24
+ });
25
+
26
+ // Security check: prevent modifications to global registry
27
+ var projectRegistryPath = path.join(ctx.targetRoot, '.claude', 'plugin-registry.json');
28
+
29
+ // Warn if trying to modify global registry from project directory
30
+ // B17/S6: use isWithin for correct path containment (was indexOf===0) and
31
+ // explicit parens on the OR/AND precedence (was a || b && c — readable but
32
+ // relies on implicit precedence).
33
+ var safePath = require('../../plugins/runtime/safe-path');
34
+ if (ctx.targetRoot !== ctx.packageRoot && !safePath.isWithin(path.join(ctx.packageRoot, '..'), ctx.targetRoot)) {
35
+ var settingsPath = ctx.settingsPath;
36
+ if (fs.existsSync(settingsPath)) {
37
+ try {
38
+ var settings = JSON.parse(fs.readFileSync(settingsPath, 'utf-8'));
39
+ var hasGlobalRegistration = settings.globalRegistry ||
40
+ (settings.hooks && settings.hooks.global);
41
+ if (hasGlobalRegistration) {
42
+ console.warn(ctx.colorize('[doukui] Warning: Interactive mode should not modify global registry.', 'yellow'));
43
+ console.warn(ctx.colorize('[doukui] Use project manifest (.claude/harness-manifest.json) for project-specific overrides.', 'yellow'));
44
+ console.warn(ctx.colorize('[doukui] Global registry is managed by npm install -g doukui', 'yellow'));
45
+ console.log('');
46
+ }
47
+ } catch (e) {
48
+ // ignore parse errors
49
+ }
50
+ }
51
+ }
52
+
53
+ var registryPath = ctx.registryPath;
54
+ var registry;
55
+
56
+ try {
57
+ registry = JSON.parse(fs.readFileSync(registryPath, 'utf-8'));
58
+ } catch (e) {
59
+ console.error(ctx.colorize('Error: Failed to read plugin registry: ' + e.message, 'red'));
60
+ ctx.exit(1);
61
+ }
62
+
63
+ var plugins = registry.plugins || [];
64
+
65
+ function showMenu() {
66
+ console.log('');
67
+ console.log(ctx.colorize('=== Doukui - Interactive Mode ===', 'cyan'));
68
+ console.log('');
69
+ console.log(' [L] 列出插件 (List plugins)');
70
+ console.log(' [T] 切换插件 (Toggle plugin)');
71
+ console.log(' [V] 查看详情 (View details)');
72
+ console.log(' [R] 重新构建 (Rebuild)');
73
+ console.log(' [Q] 退出 (Quit)');
74
+ console.log('');
75
+ }
76
+
77
+ function listPlugins() {
78
+ console.log('');
79
+ console.log(ctx.colorize('--- 插件列表 (Plugin List) ---', 'cyan'));
80
+ console.log('');
81
+
82
+ var byType = {
83
+ skill: [],
84
+ hook: [],
85
+ validator: [],
86
+ provider: [],
87
+ unknown: []
88
+ };
89
+
90
+ for (var i = 0; i < plugins.length; i++) {
91
+ var p = plugins[i];
92
+ var pluginDir = path.join(ctx.packageRoot, 'plugins', 'core', p.source || p.name);
93
+ var metaPath = path.join(pluginDir, 'plugin.json');
94
+ var type = 'unknown';
95
+ var description = '';
96
+
97
+ if (fs.existsSync(metaPath)) {
98
+ try {
99
+ var meta = JSON.parse(fs.readFileSync(metaPath, 'utf-8'));
100
+ type = meta.type || 'unknown';
101
+ description = meta.description || '';
102
+ } catch (e) {
103
+ // use defaults
104
+ }
105
+ }
106
+
107
+ var enabled = p.enabled !== false;
108
+ var statusStr = enabled ? ctx.colorize('enabled', 'green') : ctx.colorize('disabled', 'dim');
109
+
110
+ byType[type].push({
111
+ name: p.name,
112
+ status: statusStr,
113
+ enabled: enabled,
114
+ description: description
115
+ });
116
+ }
117
+
118
+ var typeOrder = ['skill', 'hook', 'validator', 'provider'];
119
+ for (var t = 0; t < typeOrder.length; t++) {
120
+ var typeName = typeOrder[t];
121
+ var typePlugins = byType[typeName];
122
+
123
+ if (typePlugins.length > 0) {
124
+ console.log(ctx.colorize(typeName.charAt(0).toUpperCase() + typeName.slice(1) + ' Plugins:', 'cyan'));
125
+
126
+ var maxNameLen = 0;
127
+ for (var j = 0; j < typePlugins.length; j++) {
128
+ if (typePlugins[j].name.length > maxNameLen) {
129
+ maxNameLen = typePlugins[j].name.length;
130
+ }
131
+ }
132
+
133
+ for (var k = 0; k < typePlugins.length; k++) {
134
+ var plugin = typePlugins[k];
135
+ var namePadding = ' '.repeat(maxNameLen - plugin.name.length + 2);
136
+ console.log(' ' + plugin.name + namePadding + '[' + plugin.status + ']');
137
+ if (plugin.description) {
138
+ console.log(' ' + ctx.colorize(plugin.description, 'dim'));
139
+ }
140
+ }
141
+ console.log('');
142
+ }
143
+ }
144
+
145
+ var enabledCount = plugins.filter(function (p) { return p.enabled !== false; }).length;
146
+ console.log('Total: ' + plugins.length + ' plugins | Enabled: ' + ctx.colorize(enabledCount, 'green') + ', Disabled: ' + ctx.colorize(plugins.length - enabledCount, 'dim'));
147
+ }
148
+
149
+ function togglePlugin(pluginName) {
150
+ var plugin = null;
151
+
152
+ for (var i = 0; i < plugins.length; i++) {
153
+ if (plugins[i].name.toLowerCase() === pluginName.toLowerCase()) {
154
+ plugin = plugins[i];
155
+ break;
156
+ }
157
+ }
158
+
159
+ if (!plugin) {
160
+ console.log('');
161
+ console.log(ctx.colorize('Error: Plugin not found: ' + pluginName, 'red'));
162
+ return;
163
+ }
164
+
165
+ var newEnabled = plugin.enabled === false;
166
+
167
+ try {
168
+ var ManifestResolver = require('../../plugins/runtime/manifest-resolver');
169
+ var success = ManifestResolver.updatePluginInManifest(ctx.packageRoot, ctx.targetRoot, plugin.name, newEnabled);
170
+
171
+ if (!success) {
172
+ console.log('');
173
+ console.error(ctx.colorize('Error: Failed to update plugin manifest', 'red'));
174
+ return;
175
+ }
176
+
177
+ // Update in-memory registry for display
178
+ plugin.enabled = newEnabled;
179
+
180
+ console.log('');
181
+ console.log(ctx.colorize('Plugin "' + plugin.name + '" is now ' + (newEnabled ? 'enabled' : 'disabled'), 'green'));
182
+ console.log(ctx.colorize('(Updated project manifest: .claude/harness-manifest.json)', 'dim'));
183
+
184
+ rl.question(ctx.colorize('是否重新构建? (y/N): ', 'yellow'), function (answer) {
185
+ if (answer && answer.toLowerCase() === 'y') {
186
+ console.log('');
187
+ console.log(ctx.colorize('[doukui] Rebuilding plugins...', 'cyan'));
188
+ var builder = ctx.createBuilder();
189
+ var result = builder.build();
190
+
191
+ if (result.success) {
192
+ if (ctx.flags.verbose) {
193
+ console.log(ctx.colorize('[doukui] Updating settings.json...', 'dim'));
194
+ }
195
+ builder.updateSettings(ctx.targetRoot, ctx.packageRoot);
196
+ builder.injectClaudeMdRules(ctx.targetRoot);
197
+ }
198
+
199
+ var coloredSummary = result.summary
200
+ .replace(/Build SUCCEEDED/g, ctx.colorize('Build SUCCEEDED', 'green'))
201
+ .replace(/Build COMPLETED WITH ERRORS/g, ctx.colorize('Build COMPLETED WITH ERRORS', 'yellow'))
202
+ .replace(/Validation PASSED/g, ctx.colorize('Validation PASSED', 'green'))
203
+ .replace(/Validation FAILED/g, ctx.colorize('Validation FAILED', 'red'));
204
+
205
+ console.log(coloredSummary);
206
+ }
207
+ showMenu();
208
+ prompt();
209
+ });
210
+ } catch (e) {
211
+ console.log('');
212
+ console.error(ctx.colorize('Error: Failed to update manifest: ' + e.message, 'red'));
213
+ }
214
+ }
215
+
216
+ function viewDetails(pluginName) {
217
+ var plugin = null;
218
+
219
+ for (var i = 0; i < plugins.length; i++) {
220
+ if (plugins[i].name.toLowerCase() === pluginName.toLowerCase()) {
221
+ plugin = plugins[i];
222
+ break;
223
+ }
224
+ }
225
+
226
+ if (!plugin) {
227
+ console.log('');
228
+ console.log(ctx.colorize('Error: Plugin not found: ' + pluginName, 'red'));
229
+ return;
230
+ }
231
+
232
+ console.log('');
233
+ console.log(ctx.colorize('--- Plugin Details: ' + plugin.name + ' ---', 'cyan'));
234
+ console.log('');
235
+ console.log('Name: ' + plugin.name);
236
+ console.log('Source: ' + (plugin.source || '-'));
237
+ console.log('Status: ' + (plugin.enabled !== false ? ctx.colorize('enabled', 'green') : ctx.colorize('disabled', 'dim')));
238
+
239
+ var pluginDir = path.join(ctx.packageRoot, 'plugins', 'core', plugin.source || plugin.name);
240
+ var metaPath = path.join(pluginDir, 'plugin.json');
241
+
242
+ if (fs.existsSync(metaPath)) {
243
+ try {
244
+ var meta = JSON.parse(fs.readFileSync(metaPath, 'utf-8'));
245
+
246
+ if (meta.type) {
247
+ console.log('Type: ' + meta.type);
248
+ }
249
+ if (meta.version) {
250
+ console.log('Version: ' + meta.version);
251
+ }
252
+ if (meta.description) {
253
+ console.log('');
254
+ console.log('Description:');
255
+ console.log(' ' + meta.description);
256
+ }
257
+ if (meta.dependencies && meta.dependencies.length > 0) {
258
+ console.log('');
259
+ console.log('Dependencies:');
260
+ for (var i = 0; i < meta.dependencies.length; i++) {
261
+ console.log(' - ' + meta.dependencies[i]);
262
+ }
263
+ }
264
+ if (plugin.config && Object.keys(plugin.config).length > 0) {
265
+ console.log('');
266
+ console.log('Configuration:');
267
+ for (var key in plugin.config) {
268
+ if (plugin.config.hasOwnProperty(key)) {
269
+ var value = plugin.config[key];
270
+ if (typeof value === 'object') {
271
+ console.log(' ' + key + ': ' + JSON.stringify(value));
272
+ } else {
273
+ console.log(' ' + key + ': ' + value);
274
+ }
275
+ }
276
+ }
277
+ }
278
+ } catch (e) {
279
+ console.log('');
280
+ console.log(ctx.colorize('Warning: Failed to parse plugin metadata', 'yellow'));
281
+ }
282
+ }
283
+ }
284
+
285
+ function rebuild() {
286
+ console.log('');
287
+ console.log(ctx.colorize('[doukui] Rebuilding plugins...', 'cyan'));
288
+
289
+ var builder = ctx.createBuilder();
290
+ var result = builder.build();
291
+
292
+ if (result.success) {
293
+ if (ctx.flags.verbose) {
294
+ console.log(ctx.colorize('[doukui] Updating settings.json...', 'dim'));
295
+ }
296
+ builder.updateSettings(ctx.targetRoot, ctx.packageRoot);
297
+ builder.injectClaudeMdRules(ctx.targetRoot);
298
+ }
299
+
300
+ var coloredSummary = result.summary
301
+ .replace(/Build SUCCEEDED/g, ctx.colorize('Build SUCCEEDED', 'green'))
302
+ .replace(/Build COMPLETED WITH ERRORS/g, ctx.colorize('Build COMPLETED WITH ERRORS', 'yellow'))
303
+ .replace(/Validation PASSED/g, ctx.colorize('Validation PASSED', 'green'))
304
+ .replace(/Validation FAILED/g, ctx.colorize('Validation FAILED', 'red'));
305
+
306
+ console.log(coloredSummary);
307
+
308
+ if (result.success) {
309
+ console.log(ctx.colorize('[doukui] Done!', 'green'));
310
+ }
311
+ }
312
+
313
+ function prompt() {
314
+ rl.question(ctx.colorize('选择操作 (Enter choice): ', 'cyan'), function (answer) {
315
+ var cmd = answer.trim().toLowerCase();
316
+
317
+ if (!cmd || cmd === 'q' || cmd === 'quit' || cmd === 'exit') {
318
+ console.log('');
319
+ console.log(ctx.colorize('Goodbye!', 'green'));
320
+ rl.close();
321
+ process.exit(0);
322
+ } else if (cmd === 'l' || cmd === 'list') {
323
+ listPlugins();
324
+ showMenu();
325
+ prompt();
326
+ } else if (cmd === 'r' || cmd === 'rebuild') {
327
+ rebuild();
328
+ showMenu();
329
+ prompt();
330
+ } else if (cmd === 't' || cmd === 'toggle') {
331
+ rl.question(ctx.colorize('输入插件名称 (Enter plugin name): ', 'yellow'), function (name) {
332
+ togglePlugin(name.trim());
333
+ });
334
+ } else if (cmd === 'v' || cmd === 'view') {
335
+ rl.question(ctx.colorize('输入插件名称 (Enter plugin name): ', 'yellow'), function (name) {
336
+ viewDetails(name.trim());
337
+ showMenu();
338
+ prompt();
339
+ });
340
+ } else {
341
+ console.log('');
342
+ console.log(ctx.colorize('Unknown command: ' + cmd, 'red'));
343
+ showMenu();
344
+ prompt();
345
+ }
346
+ });
347
+ }
348
+
349
+ showMenu();
350
+ prompt();
351
+ },
352
+ };
@@ -0,0 +1,108 @@
1
+ 'use strict';
2
+
3
+ var path = require('path');
4
+ var fs = require('fs');
5
+
6
+ /**
7
+ * List command - List all registered plugins
8
+ * @public
9
+ */
10
+ module.exports = {
11
+ name: 'list',
12
+ description: 'List all registered plugins',
13
+ /**
14
+ * Execute the list command.
15
+ * @public
16
+ * @param {object} ctx - CLI context object
17
+ */
18
+ execute: function (ctx) {
19
+ console.log(ctx.colorize('=== Registered Plugins ===', 'cyan'));
20
+ console.log('');
21
+
22
+ var registry = ctx.createBuilder()._readRegistry();
23
+ var plugins = registry.plugins || [];
24
+
25
+ if (plugins.length === 0) {
26
+ console.log('No plugins registered.');
27
+ ctx.exit(0);
28
+ }
29
+
30
+ // Group by type
31
+ var byType = {
32
+ skill: [],
33
+ hook: [],
34
+ validator: [],
35
+ provider: [],
36
+ unknown: [],
37
+ };
38
+
39
+ for (var i = 0; i < plugins.length; i++) {
40
+ var p = plugins[i];
41
+ var pluginDir = path.join(ctx.packageRoot, 'plugins', 'core', p.source || p.name);
42
+ var metaPath = path.join(pluginDir, 'plugin.json');
43
+ var type = 'unknown';
44
+ var version = '-';
45
+
46
+ if (fs.existsSync(metaPath)) {
47
+ try {
48
+ var meta = JSON.parse(fs.readFileSync(metaPath, 'utf-8'));
49
+ type = meta.type || 'unknown';
50
+ version = meta.version || '-';
51
+ } catch (e) {
52
+ // use defaults
53
+ }
54
+ }
55
+
56
+ var status = p.enabled === false ? ctx.colorize('disabled', 'dim') : ctx.colorize('enabled', 'green');
57
+
58
+ byType[type].push({
59
+ name: p.name,
60
+ version: version,
61
+ status: status,
62
+ });
63
+ }
64
+
65
+ // Display by type
66
+ var typeOrder = ['skill', 'hook', 'validator', 'provider'];
67
+ for (var t = 0; t < typeOrder.length; t++) {
68
+ var typeName = typeOrder[t];
69
+ var typePlugins = byType[typeName];
70
+
71
+ if (typePlugins.length > 0) {
72
+ console.log(ctx.colorize(typeName.charAt(0).toUpperCase() + typeName.slice(1) + ' Plugins:', 'cyan'));
73
+ console.log('');
74
+
75
+ var maxNameLen = 0;
76
+ for (var j = 0; j < typePlugins.length; j++) {
77
+ if (typePlugins[j].name.length > maxNameLen) {
78
+ maxNameLen = typePlugins[j].name.length;
79
+ }
80
+ }
81
+
82
+ for (var k = 0; k < typePlugins.length; k++) {
83
+ var plugin = typePlugins[k];
84
+ var namePadding = ' '.repeat(maxNameLen - plugin.name.length + 2);
85
+ console.log(' ' + plugin.name + namePadding + '[' + plugin.status + '] ' + (plugin.version !== '-' ? 'v' : '') + plugin.version);
86
+ }
87
+ console.log('');
88
+ }
89
+ }
90
+
91
+ // Show unknown types
92
+ if (byType.unknown.length > 0) {
93
+ console.log(ctx.colorize('Unknown Plugins:', 'yellow'));
94
+ console.log('');
95
+ for (var u = 0; u < byType.unknown.length; u++) {
96
+ console.log(' ' + byType.unknown[u].name);
97
+ }
98
+ console.log('');
99
+ }
100
+
101
+ // Summary
102
+ console.log('Total: ' + plugins.length + ' plugins');
103
+ var enabledCount = plugins.filter(function (p) { return p.enabled !== false; }).length;
104
+ console.log('Enabled: ' + ctx.colorize(enabledCount, 'green') + ', Disabled: ' + ctx.colorize(plugins.length - enabledCount, 'dim'));
105
+
106
+ ctx.exit(0);
107
+ },
108
+ };