hub-launch 1.14.0 → 1.15.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.
@@ -1,139 +0,0 @@
1
- import axios from 'axios';
2
- import os from 'os';
3
- import path from 'path';
4
- import { logger } from '../utils/logger.js';
5
- import { HulaApiClient } from '../services/api/HulaApiClient.js';
6
- import { LogFormatterService } from '../services/logs/LogFormatterService.js';
7
- import { TempFileService } from '../services/logs/TempFileService.js';
8
- import { EditorService } from '../services/editor/EditorService.js';
9
- import { resolveProject } from '../utils/project-resolver.js';
10
- import { HULA_PROJECT_URL } from '../config/constants.js';
11
- /**
12
- * Resolve the `--logs` / `--lessons` / `--all` flags to a single `include`
13
- * query-param value for the logs endpoint.
14
- *
15
- * Precedence (highest first):
16
- * 1. `--all` → `'all'`
17
- * 2. `--lessons` AND `--logs` → `'all'`
18
- * 3. `--lessons` → `'lessons'`
19
- * 4. `--logs` → `'logs'`
20
- * 5. none → `undefined` (no `include` param sent;
21
- * preserves the default live-tail behavior)
22
- *
23
- * Only ONE effective value is ever returned, so the client never sends two
24
- * `include` params.
25
- */
26
- export function resolveInclude(options) {
27
- if (options.all)
28
- return 'all';
29
- if (options.lessons && options.logs)
30
- return 'all';
31
- if (options.lessons)
32
- return 'lessons';
33
- if (options.logs)
34
- return 'logs';
35
- return undefined;
36
- }
37
- /**
38
- * Logs command - View logs for a tracked plan
39
- *
40
- * Usage: hula logs <trackingName> [--lines N] [--raw] [--logs] [--lessons] [--all]
41
- */
42
- export function logsCommand(program, config) {
43
- program
44
- .command('logs <trackingName>')
45
- // .alias("g")
46
- .description('View logs for a tracked plan')
47
- .option('--lines <number>', 'Number of lines to show (default: 100)', '100')
48
- .option('-r, --raw', 'Show raw log output only', false)
49
- .option('--logs', 'Show the full stored run log (.txt content)', false)
50
- .option('--lessons', 'Show the stored lessons-learned content', false)
51
- .option('--all', 'Show lessons + full run log', false)
52
- .action(async (trackingName, options) => {
53
- await executeLogs(trackingName, options, config);
54
- });
55
- }
56
- /**
57
- * Execute logs command - fetch and display logs for a tracked plan
58
- *
59
- * @param trackingName - The plan's tracking name (e.g., "fix-button")
60
- * @param options - Command options (lines, raw, logs, lessons, all). The
61
- * logs/lessons/all flags resolve (via {@link resolveInclude}) to a single
62
- * `include` query param selecting the persisted run log, lessons, or both.
63
- * @param config - HubLaunch configuration
64
- */
65
- export async function executeLogs(trackingName, options, config) {
66
- const serverUrl = config.hulaProjectUrl || HULA_PROJECT_URL;
67
- const apiKey = config.hulaApiKey ?? process.env.HULA_API_KEY;
68
- const lines = parseInt(options.lines, 10) || 100;
69
- if (!serverUrl || !apiKey) {
70
- logger.error('Server URL and API key are required.');
71
- logger.info("Run 'hula login' to authenticate with hula-project.");
72
- process.exit(1);
73
- }
74
- logger.info(`📋 Fetching logs for: ${trackingName}`);
75
- logger.blank();
76
- const apiClient = new HulaApiClient({
77
- baseUrl: serverUrl.replace(/\/$/, ''),
78
- apiKey,
79
- timeout: 30000,
80
- });
81
- const project = await resolveProject(config);
82
- try {
83
- const include = resolveInclude(options);
84
- const content = await apiClient.fetchTaskLogs(trackingName, {
85
- type: 'log',
86
- lines,
87
- project,
88
- include,
89
- });
90
- if (options.raw) {
91
- process.stdout.write(content);
92
- return;
93
- }
94
- const formatter = new LogFormatterService();
95
- const formatted = formatter.formatPlainText(content, {
96
- trackingName,
97
- lines,
98
- });
99
- const tempFileService = new TempFileService(path.join(os.tmpdir(), 'hublaunch-logs'));
100
- const filePath = await tempFileService.createTempFile(formatted, trackingName);
101
- logger.info(`Log file created: ${filePath}`);
102
- const editorService = new EditorService(config.editorCommand);
103
- await editorService.openFile(filePath);
104
- logger.success('✓ Log file opened in editor');
105
- }
106
- catch (error) {
107
- handleApiError(error, serverUrl);
108
- process.exit(1);
109
- }
110
- }
111
- function handleApiError(error, serverUrl) {
112
- if (axios.isAxiosError(error)) {
113
- if (error.response) {
114
- const status = error.response.status;
115
- const data = error.response.data;
116
- switch (status) {
117
- case 401:
118
- logger.error('Authentication failed. Your API key may be invalid.');
119
- logger.info("Run 'hula login' to re-authenticate.");
120
- break;
121
- case 404:
122
- logger.error(data.error ?? 'Plan not found or no logs available');
123
- break;
124
- default:
125
- logger.error(data.error ?? `Request failed with status ${status}`);
126
- }
127
- }
128
- else if (error.code === 'ECONNREFUSED') {
129
- logger.error(`Cannot connect to server at ${serverUrl}`);
130
- }
131
- else {
132
- logger.error(`Network error: ${error.message}`);
133
- }
134
- }
135
- else {
136
- throw error;
137
- }
138
- }
139
- //# sourceMappingURL=logs.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logs.js","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAU1D;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,cAAc,CAAC,OAI9B;IACC,IAAI,OAAO,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IAC9B,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI;QAAE,OAAO,KAAK,CAAC;IAClD,IAAI,OAAO,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IACtC,IAAI,OAAO,CAAC,IAAI;QAAE,OAAO,MAAM,CAAC;IAChC,OAAO,SAAS,CAAC;AACn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AAC;QACf,cAAc,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;QACjC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,SAAS,cAAc,CAAC,KAAc,EAAE,SAAiB;IACvD,IAAI,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9B,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;YACrC,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,IAA0B,CAAC;YAEvD,QAAQ,MAAM,EAAE,CAAC;gBACf,KAAK,GAAG;oBACN,MAAM,CAAC,KAAK,CAAC,qDAAqD,CAAC,CAAC;oBACpE,MAAM,CAAC,IAAI,CAAC,sCAAsC,CAAC,CAAC;oBACpD,MAAM;gBACR,KAAK,GAAG;oBACN,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,qCAAqC,CAAC,CAAC;oBAClE,MAAM;gBACR;oBACE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,8BAA8B,MAAM,EAAE,CAAC,CAAC;YACvE,CAAC;QACH,CAAC;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;YACzC,MAAM,CAAC,KAAK,CAAC,+BAA+B,SAAS,EAAE,CAAC,CAAC;QAC3D,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,KAAK,CAAC,kBAAkB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;SAAM,CAAC;QACN,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
@@ -1,105 +0,0 @@
1
- ---
2
- name: hula-log
3
- description: View job logs for a tracked issue in an editor tab. Use when the user asks to see logs, check status, or view output.
4
- disable-model-invocation: true
5
- argument-hint: "[issue-name]"
6
- allowed-tools: Bash Read
7
- ---
8
-
9
- You are an expert HubLaunch workflow assistant responsible for fetching and displaying job logs for tracked plans.
10
-
11
- ## Instructions
12
-
13
- Your job is to:
14
-
15
- 1. **Determine the tracking name** from either:
16
- - The user's explicit input (e.g., `/hula-log fix-button`)
17
- - Auto-detection from the current Git branch using `git rev-parse --abbrev-ref HEAD`
18
-
19
- 2. **Run the CLI command** to fetch logs and open them in an editor tab
20
-
21
- 3. **Display the result** to the user
22
-
23
- ## Input Format
24
-
25
- User will provide:
26
-
27
- ```
28
- /hula-log [trackingName] [--lines N]
29
- ```
30
-
31
- Examples:
32
-
33
- - `/hula-log` — auto-detect tracking name from current branch
34
- - `/hula-log fix-button` — explicit tracking name
35
- - `/hula-log fix-button --lines 200` — show last 200 lines
36
-
37
- User input: $ARGUMENTS
38
-
39
- ## Workflow
40
-
41
- ### Step 1: Determine Tracking Name
42
-
43
- **If the user provided a tracking name** (e.g., `/hula-log fix-button`): use it directly.
44
-
45
- **If no tracking name was provided**: auto-detect from the current Git branch by running in the terminal:
46
-
47
- ```bash
48
- git rev-parse --abbrev-ref HEAD
49
- ```
50
-
51
- Use the branch name as the tracking name. If the command fails or returns `HEAD` (detached), show an error:
52
-
53
- ```
54
- ❌ Could not detect current branch. Please provide the tracking name explicitly:
55
- /hula-log <trackingName>
56
- ```
57
-
58
- ### Step 2: Build CLI Command
59
-
60
- Build the command:
61
-
62
- ```bash
63
- hula logs <trackingName>
64
- ```
65
-
66
- If the user provided `--lines <N>`, append it:
67
-
68
- ```bash
69
- hula logs <trackingName> --lines <N>
70
- ```
71
-
72
- ### Step 3: Run CLI Command
73
-
74
- Execute using the `#terminal` tool.
75
-
76
- ### Step 4: Display Result
77
-
78
- **Success output format:**
79
-
80
- ```
81
- ✅ Log file opened for tracking name `<trackingName>`
82
-
83
- 📋 **Tracking Name**: `<trackingName>`
84
- 📏 **Lines**: last <N> lines (default: 100)
85
- ```
86
-
87
- **Error handling:**
88
-
89
- If the CLI command fails:
90
-
91
- ```
92
- ❌ Failed to fetch logs: <error message>
93
-
94
- Common issues:
95
- - Tracking name not found on the server (check with `hula launch --show <trackingName>`)
96
- - Authentication error (run `hula login` to re-authenticate)
97
- - Server unreachable (check your network and server URL)
98
- ```
99
-
100
- ## Important Notes
101
-
102
- - The tracking name is the plan's tracking name (same as the Git branch name)
103
- - Logs are written to a temp file in the system's temp directory under `hublaunch-logs/<trackingName>.log` and opened in your configured editor
104
- - For running tasks, logs reflect the last heartbeat update (approximately every 60 seconds)
105
- - For completed/failed/cancelled tasks, logs are captured at completion time