@@ -23,9 +23,9 @@ import nijigenerate.api.acp.types;
2323import nijigenerate.api.acp.transport.stdio;
2424import nijigenerate.core.settings : incSettingsGet;
2525
26- // / Editor側からCoding Agentと対話する最小クライアント。
27- // / - OS依存を避けるため、コマンドはシェル文字列ではなく string[] で渡す。
28- // / - 既存の Transport を注入することも可能。
26+ // / Minimal client for interacting with the Coding Agent from the editor.
27+ // / - Pass commands as string[] (not a shell string) to avoid OS-specific behavior.
28+ // / - You can also inject an existing Transport.
2929class ACPClient {
3030 private {
3131 StdioTransport transport;
@@ -78,18 +78,18 @@ class ACPClient {
7878 return pr;
7979 }
8080
81- // / 既存Transportを使うコンストラクタ(同一プロセス内など)。
81+ // / Constructor using an existing Transport (e.g. same process).
8282 this (StdioTransport transport) {
8383 this .transport = transport;
8484 this .ownsProcess = false ;
8585 startReader();
8686 }
8787
88- // / Coding Agent 実行ファイルを子プロセスとして起動(OS非依存)。
89- // / `command` は ["./out/nijigenerate-agent"] や ["node","agent.js"] のように分割済みで渡す。
88+ // / Launch the Coding Agent executable as a child process (OS-agnostic).
89+ // / `command` should be split, e.g. ["./out/nijigenerate-agent"] or ["node","agent.js"].
9090 this (string [] command, string cwd = null ) {
91- // pipeProcess は内部でプラットフォーム毎の適切なCreateProcess /posix spawnを使用し、
92- // シェル解釈を行わないため安全かつOS依存が少ない。
91+ // pipeProcess uses CreateProcess /posix spawn internally and avoids shell parsing,
92+ // which is safer and less OS-dependent.
9393 // pipeProcess creates stdin/stdout pipes by default
9494 auto proc = pipeProcess(command, Redirect.all, null , Config.none, cwd);
9595 pid = proc.pid;
@@ -101,22 +101,22 @@ class ACPClient {
101101 startStderrReader();
102102 }
103103
104- // / stdoutをそのままホスト側に表示するかどうかを切り替える(デバッグ用)。
104+ // / Toggle whether to show stdout on the host side (debug).
105105 void setDebugStdout (bool enabled) {
106106 debugStdout = enabled;
107107 }
108108
109- // / 子プロセス stdout/stderr の生ログを logger に流す(デフォルトON)
109+ // / Forward raw child stdout/stderr logs to logger (default ON).
110110 void setDebugEcho (bool enabled) {
111111 debugEchoPipes = enabled;
112112 }
113113
114- // / ログ出力先(Agentパネルなど)を設定
114+ // / Set log output target (e.g. Agent panel).
115115 void setLogger (void delegate (string ) cb) {
116116 logger = cb;
117117 }
118118
119- // / キャンセルチェック(外部フラグを参照するデリゲート)を設定
119+ // / Set a cancel-check delegate (reads an external flag).
120120 void setCancelCheck (bool delegate () cb) {
121121 cancelCheck = cb;
122122 }
@@ -125,12 +125,12 @@ class ACPClient {
125125 if (logger) logger(msg);
126126 }
127127
128- // / 送信モードを指定 ("line" または "content-length")
128+ // / Set send mode ("line" or "content-length").
129129 void setSendMode (string mode) {
130130 preferredSendMode = (mode == " content-length" ) ? " content-length" : " line" ;
131131 }
132132
133- // / 行JSONをそのまま送る( Content-Lengthなし)
133+ // / Send line-delimited JSON as-is (no Content-Length).
134134 void sendRawLine (string raw) {
135135 try {
136136 pipes.stdin.write(raw ~ " \n " );
@@ -167,7 +167,7 @@ class ACPClient {
167167 return w.data;
168168 }
169169
170- // / 任意のユーザ入力テキストを session/prompt で送る。
170+ // / Send arbitrary user input text via session/prompt.
171171 string sendPrompt (string text) {
172172 if (sessionId.length == 0 ) {
173173 newSession();
@@ -222,14 +222,14 @@ class ACPClient {
222222 return res;
223223 }
224224
225- // / initializeを送り、サーバ情報を受け取る。
225+ // / Send initialize and receive server info.
226226 JSONValue initialize () {
227227 auto req = Request(ACP_METHOD_INITIALIZE , buildInitParams(), JSONValue(nextId++ ));
228228 send(req.toJSON());
229229 return waitResponse ();
230230 }
231231
232- // / 新規セッション作成( session/new)
232+ // / Create a new session (session /new).
233233 void newSession () {
234234 auto idStr = nextId++ .to! string ;
235235 import std.file : getcwd;
@@ -253,7 +253,7 @@ class ACPClient {
253253 }
254254 }
255255
256- // / ノンブロッキング版 initialize: 送信だけ行い、結果は pollInitialize で取得
256+ // / Non-blocking initialize: send only, get the result via pollInitialize.
257257 void initializeAsync () {
258258 initPending = true ;
259259 initResult = JSONValue.init;
@@ -262,7 +262,7 @@ class ACPClient {
262262 send(req.toJSON());
263263 }
264264
265- // / initialize の結果をポーリング。返値 : true=完了/失敗いずれも終了 , false=まだ
265+ // / Poll initialize result. Returns : true=done (success or failure) , false=not yet.
266266 bool pollInitialize () {
267267 if (! initPending) return true ;
268268 auto maybe = popInbound();
@@ -324,14 +324,14 @@ class ACPClient {
324324 return parseJSON (jsonStr);
325325 }
326326
327- // / pingを送る(例外が出なければ成功)。
327+ // / Send ping (success if no exception).
328328 void ping () {
329329 auto req = Request(ACP_METHOD_PING , parseJSON(" {}" ), JSONValue(nextId++ ));
330330 send(req.toJSON());
331331 waitResponse();
332332 }
333333
334- // / 子プロセスを持っている場合に終了処理を行う。
334+ // / Perform shutdown when owning a child process.
335335 void close () {
336336 readerRunning = false ;
337337 stderrRunning = false ;
0 commit comments