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.
package/src/tmux.ts ADDED
@@ -0,0 +1,27 @@
1
+ // ─────────────────────────────────────────────────────────────
2
+ // Pure tmux wrapper - send-keys, capture-pane
3
+ // ─────────────────────────────────────────────────────────────
4
+
5
+ import { execSync } from 'child_process';
6
+ import type { Tmux } from './types.js';
7
+
8
+ export function createTmux(): Tmux {
9
+ return {
10
+ send(paneId: string, message: string): void {
11
+ execSync(`tmux send-keys -t "${paneId}" ${JSON.stringify(message)}`, {
12
+ stdio: 'pipe',
13
+ });
14
+ execSync(`tmux send-keys -t "${paneId}" Enter`, {
15
+ stdio: 'pipe',
16
+ });
17
+ },
18
+
19
+ capture(paneId: string, lines: number): string {
20
+ const output = execSync(`tmux capture-pane -t "${paneId}" -p -S -${lines}`, {
21
+ encoding: 'utf-8',
22
+ stdio: ['pipe', 'pipe', 'pipe'],
23
+ });
24
+ return output;
25
+ },
26
+ };
27
+ }
package/src/types.ts ADDED
@@ -0,0 +1,97 @@
1
+ // ─────────────────────────────────────────────────────────────
2
+ // Shared TypeScript interfaces for tmux-team
3
+ // ─────────────────────────────────────────────────────────────
4
+
5
+ export interface AgentConfig {
6
+ preamble?: string;
7
+ deny?: string[]; // Permission deny patterns, e.g., ["pm:task:update(status)"]
8
+ }
9
+
10
+ export interface PaneEntry {
11
+ pane: string;
12
+ remark?: string;
13
+ }
14
+
15
+ export interface ConfigDefaults {
16
+ timeout: number; // seconds
17
+ pollInterval: number; // seconds
18
+ captureLines: number;
19
+ }
20
+
21
+ export interface GlobalConfig {
22
+ mode: 'polling' | 'wait';
23
+ preambleMode: 'always' | 'disabled';
24
+ defaults: ConfigDefaults;
25
+ agents: Record<string, AgentConfig>;
26
+ }
27
+
28
+ export interface LocalSettings {
29
+ mode?: 'polling' | 'wait';
30
+ preambleMode?: 'always' | 'disabled';
31
+ }
32
+
33
+ export interface LocalConfigFile {
34
+ $config?: LocalSettings;
35
+ [agentName: string]: PaneEntry | LocalSettings | undefined;
36
+ }
37
+
38
+ export interface LocalConfig {
39
+ [agentName: string]: PaneEntry;
40
+ }
41
+
42
+ export interface ResolvedConfig {
43
+ mode: 'polling' | 'wait';
44
+ preambleMode: 'always' | 'disabled';
45
+ defaults: ConfigDefaults;
46
+ agents: Record<string, AgentConfig>;
47
+ paneRegistry: Record<string, PaneEntry>;
48
+ }
49
+
50
+ export interface Flags {
51
+ json: boolean;
52
+ verbose: boolean;
53
+ config?: string;
54
+ force?: boolean;
55
+ delay?: number; // seconds
56
+ wait?: boolean;
57
+ timeout?: number; // seconds
58
+ noPreamble?: boolean;
59
+ }
60
+
61
+ export interface Paths {
62
+ globalDir: string;
63
+ globalConfig: string;
64
+ localConfig: string;
65
+ stateFile: string;
66
+ }
67
+
68
+ export interface UI {
69
+ info: (msg: string) => void;
70
+ success: (msg: string) => void;
71
+ warn: (msg: string) => void;
72
+ error: (msg: string) => void;
73
+ table: (headers: string[], rows: string[][]) => void;
74
+ json: (data: unknown) => void;
75
+ }
76
+
77
+ export interface Tmux {
78
+ send: (paneId: string, message: string) => void;
79
+ capture: (paneId: string, lines: number) => string;
80
+ }
81
+
82
+ export interface WaitResult {
83
+ requestId: string;
84
+ nonce: string;
85
+ marker: string;
86
+ response: string;
87
+ }
88
+
89
+ export interface Context {
90
+ argv: string[];
91
+ flags: Flags;
92
+ ui: UI;
93
+ config: ResolvedConfig;
94
+ tmux: Tmux;
95
+ paths: Paths;
96
+ exit: (code: number) => never;
97
+ }
package/src/ui.ts ADDED
@@ -0,0 +1,76 @@
1
+ // ─────────────────────────────────────────────────────────────
2
+ // UI utilities - colors, logging, output formatting
3
+ // ─────────────────────────────────────────────────────────────
4
+
5
+ import type { UI } from './types.js';
6
+
7
+ const isTTY = process.stdout.isTTY;
8
+
9
+ // Strip ANSI escape codes for accurate length calculation
10
+ const stripAnsi = (s: string) => s.replace(/\x1b\[[0-9;]*m/g, '');
11
+
12
+ export const colors = {
13
+ red: (s: string) => (isTTY ? `\x1b[31m${s}\x1b[0m` : s),
14
+ green: (s: string) => (isTTY ? `\x1b[32m${s}\x1b[0m` : s),
15
+ yellow: (s: string) => (isTTY ? `\x1b[33m${s}\x1b[0m` : s),
16
+ blue: (s: string) => (isTTY ? `\x1b[34m${s}\x1b[0m` : s),
17
+ cyan: (s: string) => (isTTY ? `\x1b[36m${s}\x1b[0m` : s),
18
+ dim: (s: string) => (isTTY ? `\x1b[2m${s}\x1b[0m` : s),
19
+ };
20
+
21
+ export function createUI(jsonMode: boolean): UI {
22
+ if (jsonMode) {
23
+ // In JSON mode, suppress all human-friendly output
24
+ return {
25
+ info: () => {},
26
+ success: () => {},
27
+ warn: () => {},
28
+ error: (msg: string) => {
29
+ console.error(JSON.stringify({ error: msg }));
30
+ },
31
+ table: () => {},
32
+ json: (data: unknown) => {
33
+ console.log(JSON.stringify(data, null, 2));
34
+ },
35
+ };
36
+ }
37
+
38
+ return {
39
+ info: (msg: string) => {
40
+ console.log(`${colors.blue('ℹ')} ${msg}`);
41
+ },
42
+ success: (msg: string) => {
43
+ console.log(`${colors.green('✓')} ${msg}`);
44
+ },
45
+ warn: (msg: string) => {
46
+ console.log(`${colors.yellow('⚠')} ${msg}`);
47
+ },
48
+ error: (msg: string) => {
49
+ console.error(`${colors.red('✗')} ${msg}`);
50
+ },
51
+ table: (headers: string[], rows: string[][]) => {
52
+ // Calculate column widths (strip ANSI codes for accurate length)
53
+ const widths = headers.map((h, i) =>
54
+ Math.max(h.length, ...rows.map((r) => stripAnsi(r[i] || '').length))
55
+ );
56
+
57
+ // Print header
58
+ console.log(' ' + headers.map((h, i) => colors.yellow(h.padEnd(widths[i]))).join(' '));
59
+ console.log(' ' + widths.map((w) => '─'.repeat(w)).join(' '));
60
+
61
+ // Print rows (pad based on visible length, not byte length)
62
+ for (const row of rows) {
63
+ const cells = row.map((c, i) => {
64
+ const cell = c || '-';
65
+ const visibleLen = stripAnsi(cell).length;
66
+ const padding = ' '.repeat(Math.max(0, widths[i] - visibleLen));
67
+ return cell + padding;
68
+ });
69
+ console.log(' ' + cells.join(' '));
70
+ }
71
+ },
72
+ json: (data: unknown) => {
73
+ console.log(JSON.stringify(data, null, 2));
74
+ },
75
+ };
76
+ }
package/src/version.ts ADDED
@@ -0,0 +1,21 @@
1
+ // ─────────────────────────────────────────────────────────────
2
+ // Version - read from package.json
3
+ // ─────────────────────────────────────────────────────────────
4
+
5
+ import fs from 'fs';
6
+ import path from 'path';
7
+ import { fileURLToPath } from 'url';
8
+
9
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
+
11
+ function getVersion(): string {
12
+ try {
13
+ const pkgPath = path.join(__dirname, '..', 'package.json');
14
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
15
+ return pkg.version;
16
+ } catch {
17
+ return '2.0.0';
18
+ }
19
+ }
20
+
21
+ export const VERSION = getVersion();