tmux-team 1.1.0 → 2.0.0-alpha.3

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.
@@ -0,0 +1,27 @@
1
+ // ─────────────────────────────────────────────────────────────
2
+ // list command - show configured agents
3
+ // ─────────────────────────────────────────────────────────────
4
+
5
+ import type { Context } from '../types.js';
6
+
7
+ export function cmdList(ctx: Context): void {
8
+ const { ui, config, flags } = ctx;
9
+ const agents = Object.entries(config.paneRegistry);
10
+
11
+ if (flags.json) {
12
+ ui.json(config.paneRegistry);
13
+ return;
14
+ }
15
+
16
+ if (agents.length === 0) {
17
+ ui.info("No agents configured. Use 'tmux-team add <name> <pane>' to add one.");
18
+ return;
19
+ }
20
+
21
+ console.log();
22
+ ui.table(
23
+ ['NAME', 'PANE', 'REMARK'],
24
+ agents.map(([name, data]) => [name, data.pane, data.remark || '-'])
25
+ );
26
+ console.log();
27
+ }
@@ -0,0 +1,153 @@
1
+ // ─────────────────────────────────────────────────────────────
2
+ // Preamble command - manage agent preambles
3
+ // ─────────────────────────────────────────────────────────────
4
+
5
+ import type { Context } from '../types.js';
6
+ import { ExitCodes } from '../context.js';
7
+ import { loadGlobalConfig, saveGlobalConfig } from '../config.js';
8
+
9
+ /**
10
+ * Show preamble(s) for agent(s).
11
+ */
12
+ function showPreamble(ctx: Context, agentName?: string): void {
13
+ const { ui, config, flags } = ctx;
14
+
15
+ if (agentName) {
16
+ // Show specific agent's preamble
17
+ const agentConfig = config.agents[agentName];
18
+ const preamble = agentConfig?.preamble;
19
+
20
+ if (flags.json) {
21
+ ui.json({ agent: agentName, preamble: preamble ?? null });
22
+ return;
23
+ }
24
+
25
+ if (preamble) {
26
+ ui.info(`Preamble for ${agentName}:`);
27
+ console.log(preamble);
28
+ } else {
29
+ ui.info(`No preamble set for ${agentName}`);
30
+ }
31
+ } else {
32
+ // Show all preambles
33
+ const preambles: { agent: string; preamble: string }[] = [];
34
+
35
+ for (const [name, agentConfig] of Object.entries(config.agents)) {
36
+ if (agentConfig.preamble) {
37
+ preambles.push({ agent: name, preamble: agentConfig.preamble });
38
+ }
39
+ }
40
+
41
+ if (flags.json) {
42
+ ui.json({ preambles });
43
+ return;
44
+ }
45
+
46
+ if (preambles.length === 0) {
47
+ ui.info('No preambles configured');
48
+ return;
49
+ }
50
+
51
+ for (const { agent, preamble } of preambles) {
52
+ console.log(`─── ${agent} ───`);
53
+ console.log(preamble);
54
+ console.log();
55
+ }
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Set preamble for an agent.
61
+ */
62
+ function setPreamble(ctx: Context, agentName: string, preamble: string): void {
63
+ const { ui, paths, flags } = ctx;
64
+
65
+ const globalConfig = loadGlobalConfig(paths);
66
+
67
+ // Ensure agents object exists
68
+ if (!globalConfig.agents) {
69
+ globalConfig.agents = {};
70
+ }
71
+
72
+ // Ensure agent config exists
73
+ if (!globalConfig.agents[agentName]) {
74
+ globalConfig.agents[agentName] = {};
75
+ }
76
+
77
+ globalConfig.agents[agentName].preamble = preamble;
78
+ saveGlobalConfig(paths, globalConfig);
79
+
80
+ if (flags.json) {
81
+ ui.json({ agent: agentName, preamble, status: 'set' });
82
+ } else {
83
+ ui.success(`Set preamble for ${agentName}`);
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Clear preamble for an agent.
89
+ */
90
+ function clearPreamble(ctx: Context, agentName: string): void {
91
+ const { ui, paths, flags } = ctx;
92
+
93
+ const globalConfig = loadGlobalConfig(paths);
94
+
95
+ if (globalConfig.agents?.[agentName]?.preamble) {
96
+ delete globalConfig.agents[agentName].preamble;
97
+
98
+ // Clean up empty agent config
99
+ if (Object.keys(globalConfig.agents[agentName]).length === 0) {
100
+ delete globalConfig.agents[agentName];
101
+ }
102
+
103
+ saveGlobalConfig(paths, globalConfig);
104
+
105
+ if (flags.json) {
106
+ ui.json({ agent: agentName, status: 'cleared' });
107
+ } else {
108
+ ui.success(`Cleared preamble for ${agentName}`);
109
+ }
110
+ } else {
111
+ if (flags.json) {
112
+ ui.json({ agent: agentName, status: 'not_set' });
113
+ } else {
114
+ ui.info(`No preamble was set for ${agentName}`);
115
+ }
116
+ }
117
+ }
118
+
119
+ /**
120
+ * Preamble command entry point.
121
+ */
122
+ export function cmdPreamble(ctx: Context, args: string[]): void {
123
+ const subcommand = args[0];
124
+
125
+ switch (subcommand) {
126
+ case undefined:
127
+ case 'show':
128
+ showPreamble(ctx, args[1]);
129
+ break;
130
+
131
+ case 'set':
132
+ if (args.length < 3) {
133
+ ctx.ui.error('Usage: tmux-team preamble set <agent> <preamble>');
134
+ ctx.exit(ExitCodes.ERROR);
135
+ }
136
+ // Join remaining args as preamble (allows spaces without quotes)
137
+ setPreamble(ctx, args[1], args.slice(2).join(' '));
138
+ break;
139
+
140
+ case 'clear':
141
+ if (args.length < 2) {
142
+ ctx.ui.error('Usage: tmux-team preamble clear <agent>');
143
+ ctx.exit(ExitCodes.ERROR);
144
+ }
145
+ clearPreamble(ctx, args[1]);
146
+ break;
147
+
148
+ default:
149
+ ctx.ui.error(`Unknown preamble subcommand: ${subcommand}`);
150
+ ctx.ui.error('Usage: tmux-team preamble [show|set|clear]');
151
+ ctx.exit(ExitCodes.ERROR);
152
+ }
153
+ }
@@ -0,0 +1,25 @@
1
+ // ─────────────────────────────────────────────────────────────
2
+ // remove command - unregister an agent
3
+ // ─────────────────────────────────────────────────────────────
4
+
5
+ import type { Context } from '../types.js';
6
+ import { ExitCodes } from '../exits.js';
7
+ import { saveLocalConfig } from '../config.js';
8
+
9
+ export function cmdRemove(ctx: Context, name: string): void {
10
+ const { ui, config, paths, flags, exit } = ctx;
11
+
12
+ if (!config.paneRegistry[name]) {
13
+ ui.error(`Agent '${name}' not found.`);
14
+ exit(ExitCodes.PANE_NOT_FOUND);
15
+ }
16
+
17
+ delete config.paneRegistry[name];
18
+ saveLocalConfig(paths, config.paneRegistry);
19
+
20
+ if (flags.json) {
21
+ ui.json({ removed: name });
22
+ } else {
23
+ ui.success(`Removed agent '${name}'`);
24
+ }
25
+ }