@haystackeditor/cli 0.14.2 → 0.14.4

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.
@@ -521,9 +521,16 @@ async function runUnifiedScan(repo, token) {
521
521
  try {
522
522
  statusResp = await fetch(`${HAYSTACK_API}/api/onboarding/scan/status?runId=${encodeURIComponent(runId)}`, { headers: { Authorization: `Bearer ${token}` } });
523
523
  }
524
- catch {
524
+ catch (err) {
525
525
  // Transient network blip — the KV state is authoritative and won't vanish
526
- // from one failed poll, so keep going.
526
+ // from one failed poll, so keep going. Record it (non-disruptive, no
527
+ // terminal noise) so a persistently-failing poll isn't invisible
528
+ // (PR001: no silent failure).
529
+ trackError('onboarding_scan_poll_network_error', {
530
+ repo,
531
+ run_id: runId,
532
+ error_message: err instanceof Error ? err.message : String(err),
533
+ });
527
534
  continue;
528
535
  }
529
536
  if (statusResp.status === 404) {
package/dist/index.js CHANGED
@@ -19,6 +19,9 @@
19
19
  * npx @haystackeditor/cli pr-status 123 # Show PR status in Haystack pipeline
20
20
  * npx @haystackeditor/cli config # Manage preferences
21
21
  */
22
+ import { readFileSync } from 'node:fs';
23
+ import { fileURLToPath } from 'node:url';
24
+ import { dirname, join } from 'node:path';
22
25
  import { Command } from 'commander';
23
26
  import { statusCommand } from './commands/status.js';
24
27
  import { initCommand } from './commands/init.js';
@@ -34,11 +37,27 @@ import { dismissCommand, markReviewedCommand, undismissCommand } from './command
34
37
  import { requestReviewCommand } from './commands/request-review.js';
35
38
  import { prStatusCommand } from './commands/pr-status.js';
36
39
  import { setupCommand } from './commands/setup.js';
40
+ /** Read the published version from package.json (dist/index.js → ../package.json)
41
+ * so `haystack --version` can't drift from the package version. Falls back
42
+ * gracefully so the flag never throws if the file can't be read. */
43
+ function getVersion() {
44
+ try {
45
+ const pkgPath = join(dirname(fileURLToPath(import.meta.url)), '..', 'package.json');
46
+ return JSON.parse(readFileSync(pkgPath, 'utf8')).version ?? '0.0.0';
47
+ }
48
+ catch (err) {
49
+ // package.json ships inside the npm tarball, so this should never happen —
50
+ // but log to stderr instead of silently reporting a wrong version
51
+ // (PR001: no silent fallback). stderr keeps the stdout `--version` clean.
52
+ console.error('haystack: could not read version from package.json:', err instanceof Error ? err.message : err);
53
+ return '0.0.0';
54
+ }
55
+ }
37
56
  const program = new Command();
38
57
  program
39
58
  .name('haystack')
40
59
  .description('Haystack CLI — automated PR review, triage, and merge queue')
41
- .version('0.14.1');
60
+ .version(getVersion());
42
61
  program
43
62
  .command('init')
44
63
  .description('Create .haystack.json configuration')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haystackeditor/cli",
3
- "version": "0.14.2",
3
+ "version": "0.14.4",
4
4
  "description": "Set up Haystack for your project — automated PR review, triage, and merge queue",
5
5
  "type": "module",
6
6
  "bin": {