doukui 0.0.0-stage → 0.3.1
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.en.md +42 -0
- package/README.md +147 -2
- package/bin/commands/build.js +178 -0
- package/bin/commands/config.js +88 -0
- package/bin/commands/help.js +83 -0
- package/bin/commands/init.js +194 -0
- package/bin/commands/install.js +202 -0
- package/bin/commands/interactive.js +352 -0
- package/bin/commands/list.js +108 -0
- package/bin/commands/loop-server.js +357 -0
- package/bin/commands/loop.js +1443 -0
- package/bin/commands/migrate.js +120 -0
- package/bin/commands/setup-global.js +81 -0
- package/bin/commands/status.js +140 -0
- package/bin/commands/team-cleanup.js +190 -0
- package/bin/commands/validate-config.js +35 -0
- package/bin/commands/validate.js +21 -0
- package/bin/commands/version.js +22 -0
- package/bin/context.js +143 -0
- package/bin/doukui.js +216 -0
- package/package.json +47 -4
- package/plugins/contracts/capabilities.js +268 -0
- package/plugins/contracts/checkresult-schema.json +75 -0
- package/plugins/contracts/config-schema.json +179 -0
- package/plugins/contracts/plugin-interface.js +262 -0
- package/plugins/contracts/plugin-schema.json +104 -0
- package/plugins/core/hook-session-start/index.js +281 -0
- package/plugins/core/hook-session-start/plugin.json +7 -0
- package/plugins/core/hook-skill-gate/index.js +661 -0
- package/plugins/core/hook-skill-gate/plugin.json +12 -0
- package/plugins/core/provider-loop-engine/index.js +1411 -0
- package/plugins/core/provider-loop-engine/plugin.json +15 -0
- package/plugins/core/provider-memory-store/index.js +510 -0
- package/plugins/core/provider-memory-store/plugin.json +9 -0
- package/plugins/core/provider-role-registry/index.js +376 -0
- package/plugins/core/provider-role-registry/plugin.json +9 -0
- package/plugins/core/provider-state-store/index.js +244 -0
- package/plugins/core/provider-state-store/plugin.json +9 -0
- package/plugins/core/provider-watchdog/assets/daemon-config.template.json +32 -0
- package/plugins/core/provider-watchdog/assets/lib/watchdog-multi-window.js +676 -0
- package/plugins/core/provider-watchdog/assets/watchdog.js +754 -0
- package/plugins/core/provider-watchdog/index.js +151 -0
- package/plugins/core/provider-watchdog/plugin.json +13 -0
- package/plugins/core/skill-agent-dispatcher/cleanup-reference.md +214 -0
- package/plugins/core/skill-agent-dispatcher/daemon-helpers-reference.md +249 -0
- package/plugins/core/skill-agent-dispatcher/plugin.json +13 -0
- package/plugins/core/skill-agent-dispatcher/roles-reference.md +253 -0
- package/plugins/core/skill-agent-dispatcher/skill.md +1291 -0
- package/plugins/core/skill-agentic-loop/plugin.json +20 -0
- package/plugins/core/skill-agentic-loop/skill.md +588 -0
- package/plugins/core/skill-batch-task-creator/plugin.json +15 -0
- package/plugins/core/skill-batch-task-creator/skill.md +620 -0
- package/plugins/core/skill-checklist/plugin.json +10 -0
- package/plugins/core/skill-checklist/skill.md +171 -0
- package/plugins/core/skill-completion-report/plugin.json +10 -0
- package/plugins/core/skill-completion-report/skill.md +331 -0
- package/plugins/core/skill-doukui-plan/plugin.json +15 -0
- package/plugins/core/skill-doukui-plan/skill.md +233 -0
- package/plugins/core/skill-doukui-sync/plugin.json +10 -0
- package/plugins/core/skill-doukui-sync/skill.md +76 -0
- package/plugins/core/skill-experience-logger/plugin.json +10 -0
- package/plugins/core/skill-experience-logger/skill.md +235 -0
- package/plugins/core/skill-human-checkpoint/plugin.json +10 -0
- package/plugins/core/skill-human-checkpoint/skill.md +194 -0
- package/plugins/core/skill-progress-tracker/plugin.json +10 -0
- package/plugins/core/skill-progress-tracker/skill.md +228 -0
- package/plugins/core/skill-role-manager/plugin.json +10 -0
- package/plugins/core/skill-role-manager/skill.md +252 -0
- package/plugins/core/skill-split-work-package/plugin.json +15 -0
- package/plugins/core/skill-split-work-package/skill.md +441 -0
- package/plugins/core/skill-task-archive/plugin.json +10 -0
- package/plugins/core/skill-task-archive/skill.md +116 -0
- package/plugins/core/skill-task-creator/plugin.json +15 -0
- package/plugins/core/skill-task-creator/skill.md +886 -0
- package/plugins/core/skill-team-cleanup/plugin.json +10 -0
- package/plugins/core/skill-team-cleanup/skill.md +266 -0
- package/plugins/core/skill-watchdog-manager/plugin.json +10 -0
- package/plugins/core/skill-watchdog-manager/skill.md +143 -0
- package/plugins/core/skill-workflow-orchestrator/plugin.json +13 -0
- package/plugins/core/skill-workflow-orchestrator/skill.md +273 -0
- package/plugins/core/validator-doc-sync/index.js +248 -0
- package/plugins/core/validator-doc-sync/plugin.json +12 -0
- package/plugins/core/validator-work-package/index.js +300 -0
- package/plugins/core/validator-work-package/plugin.json +12 -0
- package/plugins/plugin-registry.json +186 -0
- package/plugins/runtime/agent-def-generator.js +150 -0
- package/plugins/runtime/audit-logger.js +311 -0
- package/plugins/runtime/build-cli.js +89 -0
- package/plugins/runtime/checkresult-validator.js +131 -0
- package/plugins/runtime/claude-md-injector.js +159 -0
- package/plugins/runtime/cleanup-utils.js +293 -0
- package/plugins/runtime/config-manager.js +317 -0
- package/plugins/runtime/config-validator.js +320 -0
- package/plugins/runtime/context-window.js +81 -0
- package/plugins/runtime/event-bus.js +207 -0
- package/plugins/runtime/executor-claude.js +828 -0
- package/plugins/runtime/executor-default.js +448 -0
- package/plugins/runtime/executor-local.js +178 -0
- package/plugins/runtime/executor-sdk.js +415 -0
- package/plugins/runtime/harness-build.js +1037 -0
- package/plugins/runtime/hook-dispatcher.js +315 -0
- package/plugins/runtime/logger.js +192 -0
- package/plugins/runtime/loop-actuator.js +292 -0
- package/plugins/runtime/loop-coordinator.js +347 -0
- package/plugins/runtime/loop-defaults.js +29 -0
- package/plugins/runtime/loop-dispatch-batch.js +247 -0
- package/plugins/runtime/loop-executor.js +120 -0
- package/plugins/runtime/loop-report.js +327 -0
- package/plugins/runtime/loop-server-core.js +750 -0
- package/plugins/runtime/loop-snapshot.js +581 -0
- package/plugins/runtime/loop-trace.js +242 -0
- package/plugins/runtime/loop-worktree.js +404 -0
- package/plugins/runtime/manifest-resolver.js +457 -0
- package/plugins/runtime/multi-window-coordinator.js +560 -0
- package/plugins/runtime/objective-verifier.js +136 -0
- package/plugins/runtime/plan-lint.js +100 -0
- package/plugins/runtime/plan-reader.js +763 -0
- package/plugins/runtime/plugin-loader.js +798 -0
- package/plugins/runtime/plugin-trust.js +182 -0
- package/plugins/runtime/plugin-validator.js +491 -0
- package/plugins/runtime/provider-failover.js +114 -0
- package/plugins/runtime/provider-resolver.js +342 -0
- package/plugins/runtime/reflection-evaluator.js +545 -0
- package/plugins/runtime/resolve-plugin-path.js +297 -0
- package/plugins/runtime/safe-path.js +119 -0
- package/plugins/runtime/sandbox-context.js +235 -0
- package/plugins/runtime/sandbox-manager.js +609 -0
- package/plugins/runtime/sandbox-worker.js +215 -0
- package/plugins/runtime/self-rescue-ladder.js +38 -0
- package/plugins/runtime/settings-merger.js +172 -0
- package/plugins/runtime/state-store.js +527 -0
- package/plugins/runtime/team-cleanup.js +497 -0
- package/plugins/runtime/text-tokenize.js +25 -0
- package/plugins/runtime/validator-pipeline.js +475 -0
- package/plugins/runtime/yaml-parser.js +692 -0
- package/templates/harness-config.yaml +394 -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
|
+
};
|