thinkncollab-shell 0.0.15 → 0.0.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thinkncollab-shell",
3
- "version": "0.0.15",
3
+ "version": "0.0.17",
4
4
  "description": "ThinkNCollab Custom Shell with WebSocket collaboration",
5
5
  "main": "src/core/shell.js",
6
6
  "bin": {
@@ -47,6 +47,7 @@ const load = (path, category) => {
47
47
  // Shell
48
48
  load('./shell/status', 'shell');
49
49
  load('./shell/notify', 'shell');
50
+ load('./shell/version', 'shell');
50
51
 
51
52
  // Tasks
52
53
  load('./tasks/tasks', 'tasks');
@@ -0,0 +1,18 @@
1
+ /*
2
+ Version Command
3
+
4
+ Usage: version
5
+ */
6
+ const chalk = require('chalk');
7
+
8
+ module.exports = {
9
+ name: 'version',
10
+ description: 'Show shell CLI version',
11
+ aliases: ['v', '-v', '--version'],
12
+ requiresAuth: false,
13
+
14
+ async execute(args, shell) {
15
+ const pkg = require('../../../package.json');
16
+ console.log(`\n ${chalk.yellow('ThinkNCollab CLI Version:')} ${chalk.green(pkg.version)}\n`);
17
+ }
18
+ };
@@ -115,7 +115,7 @@ async function submitResult(apiUrl, taskId, webhookSecret, result) {
115
115
  * Main entry — triggered when server emits task:run-local to CLI socket.
116
116
  * @param {Object} opts { taskId, webhookSecret, apiUrl, chalk, shell }
117
117
  */
118
- async function runLocal({ taskId, webhookSecret, apiUrl, chalk, shell }) {
118
+ async function runLocal({ taskId, webhookSecret, apiUrl, chalk, shell, onLog }) {
119
119
  const projectRoot = process.cwd();
120
120
  const workflowsDir = path.join(projectRoot, '.tnc', 'workflows');
121
121
 
@@ -147,6 +147,16 @@ async function runLocal({ taskId, webhookSecret, apiUrl, chalk, shell }) {
147
147
  console.log(chalk.cyan(`\nšŸš€ [TNC Actions] Running: "${workflowName}" (${workflowFile})`));
148
148
  console.log(chalk.dim(` ${steps.length} step(s)\n`));
149
149
 
150
+ // Stream initial workflow setup
151
+ if (onLog) {
152
+ onLog({
153
+ workflowName,
154
+ file: workflowFile,
155
+ steps: steps.map(st => ({ name: st.name })),
156
+ data: `\nšŸš€ [TNC Actions] Starting Local Workflow: "${workflowName}" (${workflowFile})\n`
157
+ });
158
+ }
159
+
150
160
  // 2. Execute each step
151
161
  const stepResults = [];
152
162
  let overallPassed = true;
@@ -157,9 +167,27 @@ async function runLocal({ taskId, webhookSecret, apiUrl, chalk, shell }) {
157
167
  console.log(chalk.cyan(`āš™ļø [Step ${s + 1}/${steps.length}] "${step.name}"`));
158
168
  console.log(chalk.gray(`$ ${step.run}\n`));
159
169
 
170
+ const stepHeader = `\nāš™ļø [Step ${s + 1}/${steps.length}] "${step.name}"\n$ ${step.run}\n`;
171
+ logsBuffer += stepHeader;
172
+
173
+ if (onLog) {
174
+ onLog({
175
+ stepIndex: s,
176
+ state: 'running',
177
+ data: stepHeader
178
+ });
179
+ }
180
+
160
181
  const onData = chunk => {
161
182
  process.stdout.write(chunk);
162
183
  logsBuffer += chunk;
184
+ if (onLog) {
185
+ onLog({
186
+ stepIndex: s,
187
+ state: 'running',
188
+ data: chunk
189
+ });
190
+ }
163
191
  };
164
192
 
165
193
  const exitCode = await runStep(step.run, projectRoot, onData);
@@ -169,9 +197,27 @@ async function runLocal({ taskId, webhookSecret, apiUrl, chalk, shell }) {
169
197
 
170
198
  if (stepPassed) {
171
199
  console.log(chalk.green(`\nāœ… "${step.name}" passed\n`));
200
+ const passMsg = `\nāœ… Step "${step.name}" passed successfully.\n`;
201
+ logsBuffer += passMsg;
202
+ if (onLog) {
203
+ onLog({
204
+ stepIndex: s,
205
+ state: 'passed',
206
+ data: passMsg
207
+ });
208
+ }
172
209
  } else {
173
210
  overallPassed = false;
174
211
  console.log(chalk.red(`\nāŒ "${step.name}" failed (exit ${exitCode}). Aborting.\n`));
212
+ const failMsg = `\nāŒ Step "${step.name}" failed with exit code: ${exitCode}. Aborting workflow.\n`;
213
+ logsBuffer += failMsg;
214
+ if (onLog) {
215
+ onLog({
216
+ stepIndex: s,
217
+ state: 'failed',
218
+ data: failMsg
219
+ });
220
+ }
175
221
  break;
176
222
  }
177
223
  }
@@ -86,6 +86,15 @@ function printNotification(data) {
86
86
  console.log(`${ts} šŸ“¢ ${color(`${data.title}: ${data.message}`)}`);
87
87
  break;
88
88
  }
89
+ case 'verdict':
90
+ beep();
91
+ {
92
+ const color = data.passed ? chalk.green : chalk.red;
93
+ const icon = data.passed ? 'āœ…' : 'āŒ';
94
+ const label = data.passed ? 'PASSED' : 'FAILED';
95
+ console.log(`${ts} ${icon} ${color(`Build Verdict [${label}]`)}: ${chalk.white(data.reason || '')}`);
96
+ }
97
+ break;
89
98
  case 'typing':
90
99
  beep();
91
100
  process.stdout.write(`\r${chalk.dim(`āœļø ${data.username} is typing... `)}`);
@@ -114,6 +114,14 @@ class WebSocketManager extends EventEmitter {
114
114
  apiUrl: this.config.serverUrl || 'https://thinkncollab.com',
115
115
  chalk,
116
116
  shell: shellRef,
117
+ onLog: (logData) => {
118
+ // Emit log stream to server via the terminal socket
119
+ this.socket.emit('task:log', {
120
+ taskId,
121
+ boardId: task.boardId,
122
+ ...logData
123
+ });
124
+ }
117
125
  });
118
126
  } catch (err) {
119
127
  console.error('task:run-local error:', err.message);