@cortexkit/aft 0.35.2 → 0.35.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.
Files changed (2) hide show
  1. package/dist/index.js +77 -63
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -326,6 +326,9 @@ var init_bridge = __esm(() => {
326
326
  hasPendingRequests() {
327
327
  return this.pending.size > 0;
328
328
  }
329
+ getCwd() {
330
+ return this.cwd;
331
+ }
329
332
  getCachedStatus() {
330
333
  return this.cachedStatus;
331
334
  }
@@ -523,7 +526,6 @@ var init_bridge = __esm(() => {
523
526
  if (!snapshot || typeof snapshot !== "object" || Array.isArray(snapshot))
524
527
  return;
525
528
  this.cachedStatus = snapshot;
526
- this.logVia("Received status_changed push frame; cached AFT status snapshot");
527
529
  for (const listener of this.statusListeners) {
528
530
  this.deliverStatusSnapshot(listener, this.cachedStatus);
529
531
  }
@@ -670,6 +672,7 @@ var init_bridge = __esm(() => {
670
672
  const remaining = stdoutDecoder.end();
671
673
  if (remaining)
672
674
  this.onStdoutData(remaining);
675
+ this.flushStdoutBuffer();
673
676
  });
674
677
  const stderrDecoder = new StringDecoder("utf8");
675
678
  child.stderr?.on("data", (chunk) => {
@@ -692,6 +695,7 @@ var init_bridge = __esm(() => {
692
695
  return;
693
696
  if (this._shuttingDown)
694
697
  return;
698
+ this.flushStdoutBuffer();
695
699
  this.logVia(`Process exited: code=${code}, signal=${signal}`);
696
700
  if (signal === "SIGTERM" || signal === "SIGKILL" || signal === "SIGHUP" || signal === "SIGINT") {
697
701
  this.process = null;
@@ -760,71 +764,81 @@ var init_bridge = __esm(() => {
760
764
  this.stdoutBuffer = this.stdoutBuffer.slice(newlineIdx + 1);
761
765
  if (!line)
762
766
  continue;
763
- try {
764
- const response = JSON.parse(line);
765
- this.lastChildActivityAt = Date.now();
766
- if (response.type === "progress") {
767
- const requestId = response.request_id;
768
- const entry = requestId ? this.pending.get(requestId) : undefined;
769
- const kind = response.kind === "stderr" ? "stderr" : "stdout";
770
- const text = typeof response.chunk === "string" ? response.chunk : "";
771
- entry?.onProgress?.({ kind, text });
772
- continue;
773
- }
774
- if (response.type === "permission_ask") {
775
- const requestId = response.request_id;
776
- const entry = requestId ? this.pending.get(requestId) : undefined;
777
- if (requestId && entry) {
778
- this.pending.delete(requestId);
779
- clearTimeout(entry.timer);
780
- entry.resolve({
781
- success: false,
782
- code: "permission_required",
783
- message: "bash command requires permission",
784
- asks: response.asks
785
- });
786
- }
787
- continue;
788
- }
789
- if (response.type === "bash_completed") {
790
- this.onBashCompletion?.(response, this);
791
- continue;
792
- }
793
- if (response.type === "bash_long_running") {
794
- this.onBashLongRunning?.(response, this);
795
- continue;
796
- }
797
- if (response.type === "bash_pattern_match") {
798
- this.onBashPatternMatch?.(response, this);
799
- continue;
800
- }
801
- if (response.type === "configure_warnings") {
802
- this.handleConfigureWarningsFrame(response).catch((err) => {
803
- this.warnVia(`configure warning delivery failed: ${err instanceof Error ? err.message : String(err)}`);
767
+ this.processStdoutLine(line);
768
+ }
769
+ }
770
+ flushStdoutBuffer() {
771
+ const line = this.stdoutBuffer.trim();
772
+ this.stdoutBuffer = "";
773
+ if (!line)
774
+ return;
775
+ this.processStdoutLine(line);
776
+ }
777
+ processStdoutLine(line) {
778
+ try {
779
+ const response = JSON.parse(line);
780
+ this.lastChildActivityAt = Date.now();
781
+ if (response.type === "progress") {
782
+ const requestId = response.request_id;
783
+ const entry = requestId ? this.pending.get(requestId) : undefined;
784
+ const kind = response.kind === "stderr" ? "stderr" : "stdout";
785
+ const text = typeof response.chunk === "string" ? response.chunk : "";
786
+ entry?.onProgress?.({ kind, text });
787
+ return;
788
+ }
789
+ if (response.type === "permission_ask") {
790
+ const requestId = response.request_id;
791
+ const entry = requestId ? this.pending.get(requestId) : undefined;
792
+ if (requestId && entry) {
793
+ this.pending.delete(requestId);
794
+ clearTimeout(entry.timer);
795
+ entry.resolve({
796
+ success: false,
797
+ code: "permission_required",
798
+ message: "bash command requires permission",
799
+ asks: response.asks
804
800
  });
805
- continue;
806
- }
807
- if (response.type === "status_changed") {
808
- this.handleStatusChangedFrame(response);
809
- continue;
810
801
  }
811
- const id = response.id;
812
- if (id && this.pending.has(id)) {
813
- const entry = this.pending.get(id);
814
- if (!entry)
815
- continue;
816
- this.pending.delete(id);
817
- clearTimeout(entry.timer);
818
- this.consecutiveRequestTimeouts = 0;
819
- this.scheduleRestartCountReset();
820
- this.captureStatusBar(response);
821
- entry.resolve(response);
822
- } else if (typeof response.type === "string") {
823
- this.logVia(`Ignoring unknown stdout push frame type: ${response.type}`);
824
- }
825
- } catch (_err) {
826
- this.warnVia(`Failed to parse stdout line: ${line}`);
802
+ return;
803
+ }
804
+ if (response.type === "bash_completed") {
805
+ this.onBashCompletion?.(response, this);
806
+ return;
807
+ }
808
+ if (response.type === "bash_long_running") {
809
+ this.onBashLongRunning?.(response, this);
810
+ return;
811
+ }
812
+ if (response.type === "bash_pattern_match") {
813
+ this.onBashPatternMatch?.(response, this);
814
+ return;
815
+ }
816
+ if (response.type === "configure_warnings") {
817
+ this.handleConfigureWarningsFrame(response).catch((err) => {
818
+ this.warnVia(`configure warning delivery failed: ${err instanceof Error ? err.message : String(err)}`);
819
+ });
820
+ return;
821
+ }
822
+ if (response.type === "status_changed") {
823
+ this.handleStatusChangedFrame(response);
824
+ return;
825
+ }
826
+ const id = response.id;
827
+ if (id && this.pending.has(id)) {
828
+ const entry = this.pending.get(id);
829
+ if (!entry)
830
+ return;
831
+ this.pending.delete(id);
832
+ clearTimeout(entry.timer);
833
+ this.consecutiveRequestTimeouts = 0;
834
+ this.scheduleRestartCountReset();
835
+ this.captureStatusBar(response);
836
+ entry.resolve(response);
837
+ } else if (typeof response.type === "string") {
838
+ this.logVia(`Ignoring unknown stdout push frame type: ${response.type}`);
827
839
  }
840
+ } catch (_err) {
841
+ this.warnVia(`Failed to parse stdout line: ${line}`);
828
842
  }
829
843
  }
830
844
  captureStatusBar(response) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/aft",
3
- "version": "0.35.2",
3
+ "version": "0.35.4",
4
4
  "type": "module",
5
5
  "description": "Unified CLI for Agent File Tools (AFT) — setup, doctor, and diagnostics across supported agent harnesses (OpenCode, Pi)",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@clack/prompts": "^1.2.0",
27
- "@cortexkit/aft-bridge": "0.35.2",
27
+ "@cortexkit/aft-bridge": "0.35.4",
28
28
  "comment-json": "^4.6.2"
29
29
  },
30
30
  "devDependencies": {