m3triq 0.2.8 → 0.2.9

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/dist/cli.js CHANGED
@@ -24,7 +24,7 @@ const program = new Command();
24
24
  program
25
25
  .name('m3t')
26
26
  .description('M3TRIQ — protein-ligand analysis from the terminal')
27
- .version('0.2.8')
27
+ .version('0.2.9')
28
28
  .option('--json', 'Output as JSON (machine-readable)')
29
29
  .hook('preAction', (thisCommand) => {
30
30
  const opts = thisCommand.optsWithGlobals();
@@ -61,29 +61,63 @@ export function registerJobCommands(program) {
61
61
  .command('job')
62
62
  .argument('<id>', 'Job ID (full or short 8-char)')
63
63
  .description('Get job status and results')
64
- .action(async (id) => {
64
+ .option('-w, --watch', 'Poll until the job completes (or fails), redrawing in place every 5s')
65
+ .option('--interval <sec>', 'Poll interval in seconds when --watch (default 5)', (v) => parseInt(v, 10), 5)
66
+ .action(async (id, opts) => {
65
67
  const project = requireProject();
66
68
  const client = createClient();
67
69
  const fullId = await resolveJobId(client, project.id, id);
68
- const job = await client.getJob(fullId);
69
70
  const consoleUrl = getConsoleUrl();
70
- const url = jobUrl(consoleUrl, project.id, job.id);
71
- const lines = [
72
- `Job: ${job.title || job.id}`,
73
- `Type: ${job.job_type}`,
74
- `Status: ${job.status}`,
75
- `Progress: ${job.progress_percentage}%`,
76
- ];
77
- if (job.current_step)
78
- lines.push(`Step: ${job.current_step}`);
79
- if (job.completed_at)
80
- lines.push(`Done: ${job.completed_at}`);
81
- if (job.result_data && job.status === 'completed') {
82
- const summary = summarizeResults(job.job_type, job.result_data);
83
- if (summary)
84
- lines.push(summary);
71
+ const renderJob = (job) => {
72
+ const url = jobUrl(consoleUrl, project.id, job.id);
73
+ const lines = [
74
+ `Job: ${job.title || job.id}`,
75
+ `Type: ${job.job_type}`,
76
+ `Status: ${job.status}`,
77
+ `Progress: ${job.progress_percentage}%`,
78
+ ];
79
+ if (job.current_step)
80
+ lines.push(`Step: ${job.current_step}`);
81
+ if (job.completed_at)
82
+ lines.push(`Done: ${job.completed_at}`);
83
+ if (job.result_data && job.status === 'completed') {
84
+ const summary = summarizeResults(job.job_type, job.result_data);
85
+ if (summary)
86
+ lines.push(summary);
87
+ }
88
+ lines.push(`View: ${url}`);
89
+ return lines.join('\n');
90
+ };
91
+ // Single snapshot (default) — matches previous behavior
92
+ if (!opts.watch) {
93
+ const job = await client.getJob(fullId);
94
+ output(job, renderJob(job));
95
+ return;
96
+ }
97
+ // Watch mode: redraw in place until terminal status. Falls back to
98
+ // append-only output when stdout isn't a TTY (e.g. piped to a file).
99
+ const terminalStatuses = new Set(['completed', 'failed', 'cancelled']);
100
+ const intervalMs = Math.max(2, opts.interval) * 1000;
101
+ const isTty = !!process.stdout.isTTY;
102
+ let lastLineCount = 0;
103
+ // Disable JSON mode in watch — we're emitting frames, not a single result.
104
+ while (true) {
105
+ const job = await client.getJob(fullId);
106
+ const frame = renderJob(job);
107
+ if (isTty) {
108
+ // Move cursor up + clear the previous render before printing the new one.
109
+ if (lastLineCount > 0) {
110
+ process.stdout.write(`\x1b[${lastLineCount}A\x1b[0J`);
111
+ }
112
+ process.stdout.write(frame + '\n');
113
+ lastLineCount = frame.split('\n').length;
114
+ }
115
+ else {
116
+ process.stdout.write(`---\n${frame}\n`);
117
+ }
118
+ if (terminalStatuses.has(job.status))
119
+ return;
120
+ await new Promise((r) => setTimeout(r, intervalMs));
85
121
  }
86
- lines.push(`View: ${url}`);
87
- output(job, lines.join('\n'));
88
122
  });
89
123
  }
package/dist/config.d.ts CHANGED
@@ -16,16 +16,6 @@ export declare function saveConfig(config: M3triqConfig): void;
16
16
  export declare function loadLocalProject(): LocalProjectConfig | null;
17
17
  /** Save .m3triq in the current working directory */
18
18
  export declare function saveLocalProject(projectId: string, projectName?: string): void;
19
- /**
20
- * Resolution order for project:
21
- * 1. Local .m3triq (cwd or parent)
22
- * 2. Global ~/.m3triq/config.json
23
- *
24
- * Resolution order for api_key/urls:
25
- * 1. Environment variables
26
- * 2. Global config
27
- * 3. Defaults
28
- */
29
19
  export declare function getEffectiveConfig(): M3triqConfig;
30
20
  export declare function requireApiKey(): string;
31
21
  export declare function requireProject(): {
package/dist/config.js CHANGED
@@ -70,6 +70,18 @@ export function saveLocalProject(projectId, projectName) {
70
70
  * 2. Global config
71
71
  * 3. Defaults
72
72
  */
73
+ // Stale console URLs that earlier CLI versions wrote to user configs. Silently
74
+ // upgrade these to the current default so users see correct links without
75
+ // having to manually re-run `m3t config --console ...`.
76
+ const STALE_CONSOLE_URLS = new Set([
77
+ 'https://app.m3triq.com',
78
+ 'http://app.m3triq.com',
79
+ ]);
80
+ function migrateConsoleUrl(fromFile) {
81
+ if (!fromFile)
82
+ return undefined;
83
+ return STALE_CONSOLE_URLS.has(fromFile) ? undefined : fromFile;
84
+ }
73
85
  export function getEffectiveConfig() {
74
86
  const file = loadConfig();
75
87
  const local = loadLocalProject();
@@ -77,7 +89,7 @@ export function getEffectiveConfig() {
77
89
  api_key: process.env.M3TRIQ_API_KEY || file.api_key,
78
90
  api_url: process.env.M3TRIQ_API_URL || file.api_url || 'https://server.m3triq.com',
79
91
  agents_url: process.env.M3TRIQ_AGENTS_URL || file.agents_url || 'https://agents.m3triq.com',
80
- console_url: process.env.M3TRIQ_CONSOLE_URL || file.console_url || 'https://console.m3triq.com',
92
+ console_url: process.env.M3TRIQ_CONSOLE_URL || migrateConsoleUrl(file.console_url) || 'https://console.m3triq.com',
81
93
  // Local project takes precedence over global
82
94
  active_project: local?.project_id || file.active_project,
83
95
  active_project_name: local?.project_name || file.active_project_name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "m3triq",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "M3TRIQ \u2014 protein-ligand analysis from the terminal",
5
5
  "type": "module",
6
6
  "bin": {