mirror of
https://github.com/catlog22/Claude-Code-Workflow.git
synced 2026-03-06 16:31:12 +08:00
feat: Enhance team messaging system with new operations and data handling
- Added support for new message type 'state_update' in TeamMessageType. - Updated TeamMessageFeed component to handle both legacy and new reference formats. - Modified CLI options to clarify usage and added new commands for broadcasting messages and retrieving role states. - Implemented new command 'get_state' to read role state from meta.json. - Enhanced team message logging to auto-generate summaries and handle structured data. - Improved backward compatibility by enriching team metadata from legacy files. - Refactored message handling functions to streamline operations and improve clarity.
This commit is contained in:
@@ -3,12 +3,14 @@
|
||||
* Delegates to team-msg.ts handler for JSONL-based persistent messaging
|
||||
*
|
||||
* Commands:
|
||||
* ccw team log --team <session-id> --from <role> --to <role> --type <type> --summary "..."
|
||||
* ccw team read --team <session-id> --id <MSG-NNN>
|
||||
* ccw team list --team <session-id> [--from <role>] [--to <role>] [--type <type>] [--last <n>]
|
||||
* ccw team status --team <session-id>
|
||||
* ccw team delete --team <session-id> --id <MSG-NNN>
|
||||
* ccw team clear --team <session-id>
|
||||
* ccw team log --team <session-id> --from <role> [--to <role>] [--type <type>] [--summary "..."]
|
||||
* ccw team broadcast --team <session-id> --from <role> [--type <type>] [--summary "..."]
|
||||
* ccw team get_state --team <session-id> [--role <role>]
|
||||
* ccw team read --team <session-id> --id <MSG-NNN>
|
||||
* ccw team list --team <session-id> [--from <role>] [--to <role>] [--type <type>] [--last <n>]
|
||||
* ccw team status --team <session-id>
|
||||
* ccw team delete --team <session-id> --id <MSG-NNN>
|
||||
* ccw team clear --team <session-id>
|
||||
*/
|
||||
|
||||
import chalk from 'chalk';
|
||||
@@ -24,6 +26,7 @@ interface TeamOptions {
|
||||
data?: string;
|
||||
id?: string;
|
||||
last?: string;
|
||||
role?: string;
|
||||
json?: boolean;
|
||||
}
|
||||
|
||||
@@ -55,6 +58,7 @@ export async function teamCommand(
|
||||
if (options.ref) params.ref = options.ref;
|
||||
if (options.id) params.id = options.id;
|
||||
if (options.last) params.last = parseInt(options.last, 10);
|
||||
if (options.role) params.role = options.role;
|
||||
|
||||
// Parse --data as JSON
|
||||
if (options.data) {
|
||||
@@ -82,17 +86,19 @@ export async function teamCommand(
|
||||
|
||||
// Formatted output by operation
|
||||
switch (subcommand) {
|
||||
case 'log': {
|
||||
case 'log':
|
||||
case 'broadcast': {
|
||||
const r = result.result as { id: string; message: string };
|
||||
console.log(chalk.green(`✓ ${r.message}`));
|
||||
break;
|
||||
}
|
||||
case 'read': {
|
||||
const msg = result.result as { id: string; ts: string; from: string; to: string; type: string; summary: string; ref?: string; data?: unknown };
|
||||
const msg = result.result as { id: string; ts: string; from: string; to: string; type: string; summary: string; ref?: string; data?: Record<string, unknown> };
|
||||
console.log(chalk.bold(`${msg.id} [${msg.ts}]`));
|
||||
console.log(` ${chalk.cyan(msg.from)} → ${chalk.yellow(msg.to)} (${msg.type})`);
|
||||
console.log(` ${msg.summary}`);
|
||||
if (msg.ref) console.log(chalk.gray(` ref: ${msg.ref}`));
|
||||
const refPath = msg.ref || (msg.data?.ref as string | undefined);
|
||||
if (refPath) console.log(chalk.gray(` ref: ${refPath}`));
|
||||
if (msg.data) console.log(chalk.gray(` data: ${JSON.stringify(msg.data)}`));
|
||||
break;
|
||||
}
|
||||
@@ -122,6 +128,18 @@ export async function teamCommand(
|
||||
console.log(chalk.green(`✓ ${r.message}`));
|
||||
break;
|
||||
}
|
||||
case 'get_state': {
|
||||
const r = result.result as { role?: string; state?: unknown; role_state?: unknown; message?: string };
|
||||
if (r.message) {
|
||||
console.log(chalk.yellow(r.message));
|
||||
} else if (r.role) {
|
||||
console.log(chalk.bold(`Role: ${r.role}`));
|
||||
console.log(JSON.stringify(r.state, null, 2));
|
||||
} else {
|
||||
console.log(JSON.stringify(r.role_state, null, 2));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
console.error(chalk.red(`Unknown subcommand: ${subcommand}`));
|
||||
printHelp();
|
||||
@@ -137,7 +155,9 @@ function printHelp(): void {
|
||||
console.log(chalk.bold.cyan('\n CCW Team Message Bus\n'));
|
||||
console.log(' CLI interface for team message logging and retrieval.\n');
|
||||
console.log(' Subcommands:');
|
||||
console.log(chalk.gray(' log Log a team message'));
|
||||
console.log(chalk.gray(' log Log a team message (to defaults to "coordinator", summary auto-generated)'));
|
||||
console.log(chalk.gray(' broadcast Broadcast message to all team members (to="all")'));
|
||||
console.log(chalk.gray(' get_state Read role state from meta.json'));
|
||||
console.log(chalk.gray(' read Read a specific message by ID'));
|
||||
console.log(chalk.gray(' list List recent messages with filters'));
|
||||
console.log(chalk.gray(' status Show team member activity summary'));
|
||||
@@ -147,13 +167,15 @@ function printHelp(): void {
|
||||
console.log(' Required:');
|
||||
console.log(chalk.gray(' --team <session-id> Session ID (e.g., TLS-my-project-2026-02-27), NOT team name'));
|
||||
console.log();
|
||||
console.log(' Log Options:');
|
||||
console.log(chalk.gray(' --from <role> Sender role name'));
|
||||
console.log(chalk.gray(' --to <role> Recipient role name'));
|
||||
console.log(chalk.gray(' --type <type> Message type (plan_ready, impl_complete, etc.)'));
|
||||
console.log(chalk.gray(' --summary <text> One-line summary'));
|
||||
console.log(chalk.gray(' --ref <path> File path reference'));
|
||||
console.log(chalk.gray(' --data <json> JSON structured data'));
|
||||
console.log(' Log/Broadcast Options:');
|
||||
console.log(chalk.gray(' --from <role> Sender role name (required)'));
|
||||
console.log(chalk.gray(' --to <role> Recipient role (default: "coordinator")'));
|
||||
console.log(chalk.gray(' --type <type> Message type (state_update, plan_ready, shutdown, etc.)'));
|
||||
console.log(chalk.gray(' --summary <text> One-line summary (auto-generated if omitted)'));
|
||||
console.log(chalk.gray(' --data <json> JSON structured data. Use data.ref for file paths'));
|
||||
console.log();
|
||||
console.log(' Get State Options:');
|
||||
console.log(chalk.gray(' --role <role> Role name to query (omit for all roles)'));
|
||||
console.log();
|
||||
console.log(' Read/Delete Options:');
|
||||
console.log(chalk.gray(' --id <MSG-NNN> Message ID'));
|
||||
@@ -168,12 +190,11 @@ function printHelp(): void {
|
||||
console.log(chalk.gray(' --json Output as JSON'));
|
||||
console.log();
|
||||
console.log(' Examples:');
|
||||
console.log(chalk.gray(' ccw team log --team TLS-my-project-2026-02-27 --from executor --to coordinator --type impl_complete --summary "Task done"'));
|
||||
console.log(chalk.gray(' ccw team list --team TLS-my-project-2026-02-27 --last 5'));
|
||||
console.log(chalk.gray(' ccw team read --team TLS-my-project-2026-02-27 --id MSG-003'));
|
||||
console.log(chalk.gray(' ccw team status --team TLS-my-project-2026-02-27'));
|
||||
console.log(chalk.gray(' ccw team delete --team TLS-my-project-2026-02-27 --id MSG-003'));
|
||||
console.log(chalk.gray(' ccw team clear --team TLS-my-project-2026-02-27'));
|
||||
console.log(chalk.gray(' ccw team log --team TLS-my-project-2026-02-27 --from planner --to coordinator --type plan_ready --summary "Plan ready" --json'));
|
||||
console.log(chalk.gray(' ccw team log --team TLS-xxx --from executor --type state_update --data \'{"status":"done"}\''));
|
||||
console.log(chalk.gray(' ccw team broadcast --team TLS-xxx --from coordinator --type shutdown'));
|
||||
console.log(chalk.gray(' ccw team get_state --team TLS-xxx --role executor'));
|
||||
console.log(chalk.gray(' ccw team list --team TLS-xxx --last 5'));
|
||||
console.log(chalk.gray(' ccw team read --team TLS-xxx --id MSG-003'));
|
||||
console.log(chalk.gray(' ccw team status --team TLS-xxx'));
|
||||
console.log();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user