linkshell-cli 0.5.42 → 0.6.0

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 (135) hide show
  1. package/dist/cli/src/commands/host.d.ts +23 -0
  2. package/dist/cli/src/commands/host.js +264 -0
  3. package/dist/cli/src/commands/host.js.map +1 -0
  4. package/dist/cli/src/commands/pair.d.ts +1 -0
  5. package/dist/cli/src/commands/pair.js +48 -0
  6. package/dist/cli/src/commands/pair.js.map +1 -0
  7. package/dist/cli/src/index.js +68 -0
  8. package/dist/cli/src/index.js.map +1 -1
  9. package/dist/cli/src/utils/daemon.d.ts +1 -1
  10. package/dist/cli/src/utils/daemon.js +3 -2
  11. package/dist/cli/src/utils/daemon.js.map +1 -1
  12. package/dist/cli/tsconfig.tsbuildinfo +1 -1
  13. package/dist/host/src/drivers/acp/connection.d.ts +61 -0
  14. package/dist/host/src/drivers/acp/connection.js +121 -0
  15. package/dist/host/src/drivers/acp/connection.js.map +1 -0
  16. package/dist/host/src/drivers/acp/driver.d.ts +110 -0
  17. package/dist/host/src/drivers/acp/driver.js +438 -0
  18. package/dist/host/src/drivers/acp/driver.js.map +1 -0
  19. package/dist/host/src/drivers/acp/mapper.d.ts +49 -0
  20. package/dist/host/src/drivers/acp/mapper.js +411 -0
  21. package/dist/host/src/drivers/acp/mapper.js.map +1 -0
  22. package/dist/host/src/drivers/auth.d.ts +7 -0
  23. package/dist/host/src/drivers/auth.js +57 -0
  24. package/dist/host/src/drivers/auth.js.map +1 -0
  25. package/dist/host/src/drivers/claude/driver.d.ts +76 -0
  26. package/dist/host/src/drivers/claude/driver.js +331 -0
  27. package/dist/host/src/drivers/claude/driver.js.map +1 -0
  28. package/dist/host/src/drivers/claude/transcript.d.ts +335 -0
  29. package/dist/host/src/drivers/claude/transcript.js +516 -0
  30. package/dist/host/src/drivers/claude/transcript.js.map +1 -0
  31. package/dist/host/src/drivers/codex/app-server.d.ts +36 -0
  32. package/dist/host/src/drivers/codex/app-server.js +144 -0
  33. package/dist/host/src/drivers/codex/app-server.js.map +1 -0
  34. package/dist/host/src/drivers/codex/driver.d.ts +89 -0
  35. package/dist/host/src/drivers/codex/driver.js +452 -0
  36. package/dist/host/src/drivers/codex/driver.js.map +1 -0
  37. package/dist/host/src/drivers/codex/mapper.d.ts +61 -0
  38. package/dist/host/src/drivers/codex/mapper.js +623 -0
  39. package/dist/host/src/drivers/codex/mapper.js.map +1 -0
  40. package/dist/host/src/drivers/codex/settings.d.ts +51 -0
  41. package/dist/host/src/drivers/codex/settings.js +107 -0
  42. package/dist/host/src/drivers/codex/settings.js.map +1 -0
  43. package/dist/host/src/drivers/images.d.ts +11 -0
  44. package/dist/host/src/drivers/images.js +34 -0
  45. package/dist/host/src/drivers/images.js.map +1 -0
  46. package/dist/host/src/drivers/nesting.d.ts +6 -0
  47. package/dist/host/src/drivers/nesting.js +25 -0
  48. package/dist/host/src/drivers/nesting.js.map +1 -0
  49. package/dist/host/src/drivers/registry.d.ts +21 -0
  50. package/dist/host/src/drivers/registry.js +30 -0
  51. package/dist/host/src/drivers/registry.js.map +1 -0
  52. package/dist/host/src/drivers/types.d.ts +105 -0
  53. package/dist/host/src/drivers/types.js +2 -0
  54. package/dist/host/src/drivers/types.js.map +1 -0
  55. package/dist/host/src/fs.d.ts +69 -0
  56. package/dist/host/src/fs.js +198 -0
  57. package/dist/host/src/fs.js.map +1 -0
  58. package/dist/host/src/gateway.d.ts +55 -0
  59. package/dist/host/src/gateway.js +263 -0
  60. package/dist/host/src/gateway.js.map +1 -0
  61. package/dist/host/src/host.d.ts +51 -0
  62. package/dist/host/src/host.js +133 -0
  63. package/dist/host/src/host.js.map +1 -0
  64. package/dist/host/src/hub.d.ts +89 -0
  65. package/dist/host/src/hub.js +592 -0
  66. package/dist/host/src/hub.js.map +1 -0
  67. package/dist/host/src/index.d.ts +10 -0
  68. package/dist/host/src/index.js +10 -0
  69. package/dist/host/src/index.js.map +1 -0
  70. package/dist/host/src/ports.d.ts +24 -0
  71. package/dist/host/src/ports.js +201 -0
  72. package/dist/host/src/ports.js.map +1 -0
  73. package/dist/host/src/rpc/client.d.ts +9 -0
  74. package/dist/host/src/rpc/client.js +42 -0
  75. package/dist/host/src/rpc/client.js.map +1 -0
  76. package/dist/host/src/rpc/server.d.ts +52 -0
  77. package/dist/host/src/rpc/server.js +293 -0
  78. package/dist/host/src/rpc/server.js.map +1 -0
  79. package/dist/host/src/screen.d.ts +30 -0
  80. package/dist/host/src/screen.js +230 -0
  81. package/dist/host/src/screen.js.map +1 -0
  82. package/dist/host/src/shell-env.d.ts +8 -0
  83. package/dist/host/src/shell-env.js +39 -0
  84. package/dist/host/src/shell-env.js.map +1 -0
  85. package/dist/host/src/store.d.ts +75 -0
  86. package/dist/host/src/store.js +265 -0
  87. package/dist/host/src/store.js.map +1 -0
  88. package/dist/host/src/terminals.d.ts +55 -0
  89. package/dist/host/src/terminals.js +367 -0
  90. package/dist/host/src/terminals.js.map +1 -0
  91. package/dist/shared-protocol/src/index.d.ts +3345 -3345
  92. package/dist/wire/src/crypto.d.ts +65 -0
  93. package/dist/wire/src/crypto.js +253 -0
  94. package/dist/wire/src/crypto.js.map +1 -0
  95. package/dist/wire/src/index.d.ts +8 -0
  96. package/dist/wire/src/index.js +9 -0
  97. package/dist/wire/src/index.js.map +1 -0
  98. package/dist/wire/src/model.d.ts +704 -0
  99. package/dist/wire/src/model.js +163 -0
  100. package/dist/wire/src/model.js.map +1 -0
  101. package/dist/wire/src/peer.d.ts +42 -0
  102. package/dist/wire/src/peer.js +143 -0
  103. package/dist/wire/src/peer.js.map +1 -0
  104. package/dist/wire/src/relay-client.d.ts +82 -0
  105. package/dist/wire/src/relay-client.js +259 -0
  106. package/dist/wire/src/relay-client.js.map +1 -0
  107. package/dist/wire/src/relay.d.ts +481 -0
  108. package/dist/wire/src/relay.js +129 -0
  109. package/dist/wire/src/relay.js.map +1 -0
  110. package/dist/wire/src/rpc.d.ts +4170 -0
  111. package/dist/wire/src/rpc.js +332 -0
  112. package/dist/wire/src/rpc.js.map +1 -0
  113. package/dist/wire/src/shell.d.ts +2 -0
  114. package/dist/wire/src/shell.js +62 -0
  115. package/dist/wire/src/shell.js.map +1 -0
  116. package/dist/wire/src/updates.d.ts +3325 -0
  117. package/dist/wire/src/updates.js +210 -0
  118. package/dist/wire/src/updates.js.map +1 -0
  119. package/package.json +8 -3
  120. package/src/commands/host.ts +283 -0
  121. package/src/commands/pair.ts +47 -0
  122. package/src/index.ts +73 -0
  123. package/src/utils/daemon.ts +4 -3
  124. package/dist/cli/src/commands/hook.d.ts +0 -6
  125. package/dist/cli/src/commands/hook.js +0 -120
  126. package/dist/cli/src/commands/hook.js.map +0 -1
  127. package/dist/cli/src/runtime/acp/agent-workspace-git.d.ts +0 -63
  128. package/dist/cli/src/runtime/acp/agent-workspace-git.js +0 -297
  129. package/dist/cli/src/runtime/acp/agent-workspace-git.js.map +0 -1
  130. package/dist/cli/src/runtime/acp-relay.d.ts +0 -23
  131. package/dist/cli/src/runtime/acp-relay.js +0 -73
  132. package/dist/cli/src/runtime/acp-relay.js.map +0 -1
  133. package/dist/cli/src/runtime/hook-permission-server.d.ts +0 -36
  134. package/dist/cli/src/runtime/hook-permission-server.js +0 -147
  135. package/dist/cli/src/runtime/hook-permission-server.js.map +0 -1
@@ -3,9 +3,9 @@ import { join } from "node:path";
3
3
  import { homedir } from "node:os";
4
4
  import { spawn } from "node:child_process";
5
5
 
6
- const LINKSHELL_DIR = join(homedir(), ".linkshell");
6
+ const LINKSHELL_DIR = process.env.LINKSHELL_HOME || join(homedir(), ".linkshell");
7
7
 
8
- type ServiceName = "gateway" | "bridge";
8
+ type ServiceName = "gateway" | "bridge" | "host";
9
9
 
10
10
  export interface ServiceMetadata {
11
11
  keepAwake?: boolean;
@@ -92,7 +92,8 @@ export function spawnDaemon(service: ServiceName, args: string[]): number {
92
92
  {
93
93
  detached: true,
94
94
  stdio: ["ignore", out, err],
95
- env: process.env,
95
+ // The launching terminal's environment is the most faithful one agents can get.
96
+ env: { ...process.env, LINKSHELL_ENV_FROM_TERMINAL: "1" },
96
97
  },
97
98
  );
98
99
 
@@ -1,6 +0,0 @@
1
- export declare const HOOK_SOCKET_PATH: string;
2
- /** `linkshell hook` — invoked by Claude Code's PreToolUse / Notification hooks.
3
- * Reads the hook event JSON on stdin, relays it to the local bridge over a Unix
4
- * socket, and (for PreToolUse) prints the permission decision the user made
5
- * remotely. Fail-open everywhere. */
6
- export declare function runHook(event: string): Promise<void>;
@@ -1,120 +0,0 @@
1
- import { createConnection } from "node:net";
2
- import { homedir } from "node:os";
3
- import { join } from "node:path";
4
- // Path of the local Unix socket the running `linkshell` bridge listens on to
5
- // relay external-session permission requests to phone/web clients. Kept under
6
- // the same ~/.linkshell dir as the daemon pid/log files.
7
- export const HOOK_SOCKET_PATH = join(homedir(), ".linkshell", "hook.sock");
8
- // How long the hook waits for a remote decision before giving up. On timeout we
9
- // fail OPEN (emit no decision → Claude's normal permission flow takes over), so
10
- // an unattended phone never blocks a tool call forever.
11
- const DECISION_TIMEOUT_MS = 25_000;
12
- // Connecting to the socket must be near-instant; if the bridge isn't running
13
- // the socket file may exist stale, so cap the connect attempt tightly.
14
- const CONNECT_TIMEOUT_MS = 1_500;
15
- /** Emit "no decision" and exit 0. Claude Code treats an empty stdout on exit 0
16
- * as "the hook abstained", so the normal permission flow (terminal prompt /
17
- * configured mode) proceeds. This is the fail-open path taken on ANY error —
18
- * bridge not running, socket refused, timeout, malformed input — so installing
19
- * the hook can never break or block a session that LinkShell isn't watching. */
20
- function passThrough() {
21
- process.exit(0);
22
- }
23
- function readStdin() {
24
- return new Promise((resolve) => {
25
- let data = "";
26
- let done = false;
27
- const finish = () => { if (!done) {
28
- done = true;
29
- resolve(data);
30
- } };
31
- process.stdin.setEncoding("utf8");
32
- process.stdin.on("data", (chunk) => { data += chunk; });
33
- process.stdin.on("end", finish);
34
- process.stdin.on("error", finish);
35
- // Hooks always get stdin, but never hang forever waiting for it.
36
- setTimeout(finish, 1_000);
37
- });
38
- }
39
- /** `linkshell hook` — invoked by Claude Code's PreToolUse / Notification hooks.
40
- * Reads the hook event JSON on stdin, relays it to the local bridge over a Unix
41
- * socket, and (for PreToolUse) prints the permission decision the user made
42
- * remotely. Fail-open everywhere. */
43
- export async function runHook(event) {
44
- let payload = {};
45
- try {
46
- const raw = (await readStdin()).trim();
47
- if (raw)
48
- payload = JSON.parse(raw);
49
- }
50
- catch {
51
- return passThrough(); // unparseable stdin — abstain
52
- }
53
- const decision = await requestDecision(event, payload);
54
- // Notification events (and any non-decision) produce no stdout — they're
55
- // fire-and-forget "session needs attention" signals, not gates.
56
- if (event === "PreToolUse" && decision && (decision === "allow" || decision === "deny" || decision === "ask")) {
57
- process.stdout.write(JSON.stringify({
58
- hookSpecificOutput: {
59
- hookEventName: "PreToolUse",
60
- permissionDecision: decision,
61
- permissionDecisionReason: "LinkShell remote decision",
62
- },
63
- }));
64
- }
65
- process.exit(0);
66
- }
67
- /** Connect to the bridge socket, send the event, wait for a decision line.
68
- * Resolves to "allow"|"deny"|"ask" on success, or undefined on any failure
69
- * (caller then abstains). Never throws. */
70
- function requestDecision(event, payload) {
71
- return new Promise((resolve) => {
72
- let settled = false;
73
- const done = (v) => {
74
- if (settled)
75
- return;
76
- settled = true;
77
- try {
78
- socket.destroy();
79
- }
80
- catch { /* ignore */ }
81
- clearTimeout(connectTimer);
82
- clearTimeout(decisionTimer);
83
- resolve(v);
84
- };
85
- const socket = createConnection(HOOK_SOCKET_PATH);
86
- let buffer = "";
87
- const connectTimer = setTimeout(() => done(undefined), CONNECT_TIMEOUT_MS);
88
- // For Notification we don't need a decision; a short window to deliver the
89
- // message is enough. For PreToolUse we wait for the human.
90
- const decisionTimer = setTimeout(() => done(undefined), event === "PreToolUse" ? DECISION_TIMEOUT_MS : 2_000);
91
- socket.on("connect", () => {
92
- clearTimeout(connectTimer);
93
- try {
94
- socket.write(JSON.stringify({ type: "hook", event, payload }) + "\n");
95
- }
96
- catch {
97
- done(undefined);
98
- }
99
- // Notification: deliver and go; don't wait for a reply.
100
- if (event !== "PreToolUse")
101
- setTimeout(() => done(undefined), 300);
102
- });
103
- socket.on("data", (chunk) => {
104
- buffer += chunk.toString("utf8");
105
- const nl = buffer.indexOf("\n");
106
- if (nl === -1)
107
- return;
108
- try {
109
- const msg = JSON.parse(buffer.slice(0, nl));
110
- done(typeof msg.decision === "string" ? msg.decision : undefined);
111
- }
112
- catch {
113
- done(undefined);
114
- }
115
- });
116
- socket.on("error", () => done(undefined));
117
- socket.on("close", () => done(undefined));
118
- });
119
- }
120
- //# sourceMappingURL=hook.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hook.js","sourceRoot":"","sources":["../../../../src/commands/hook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,6EAA6E;AAC7E,8EAA8E;AAC9E,yDAAyD;AACzD,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC;AAE3E,gFAAgF;AAChF,gFAAgF;AAChF,wDAAwD;AACxD,MAAM,mBAAmB,GAAG,MAAM,CAAC;AACnC,6EAA6E;AAC7E,uEAAuE;AACvE,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAEjC;;;;iFAIiF;AACjF,SAAS,WAAW;IAClB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,SAAS,SAAS;IAChB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,IAAI,IAAI,GAAG,EAAE,CAAC;QACd,IAAI,IAAI,GAAG,KAAK,CAAC;QACjB,MAAM,MAAM,GAAG,GAAG,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YAA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| "stash" | "stashPop" | "resetToRemote" | "remoteUrl" | "diff";
2
- export interface GitArgs {
3
- message?: string;
4
- branch?: string;
5
- remote?: string;
6
- paths?: string[];
7
- limit?: number;
8
- confirmed?: boolean;
9
- force?: boolean;
10
- hard?: boolean;
11
- addAll?: boolean;
12
- targetRef?: string;
13
- staged?: boolean;
14
- }
15
- export interface GitFile {
16
- path: string;
17
- status: string;
18
- staged: boolean;
19
- untracked: boolean;
20
- }
21
- export interface GitCommit {
22
- hash: string;
23
- shortHash: string;
24
- author?: string;
25
- date?: string;
26
- subject: string;
27
- body?: string;
28
- }
29
- export interface GitBranch {
30
- name: string;
31
- current: boolean;
32
- remote?: string;
33
- ahead?: number;
34
- behind?: number;
35
- }
36
- export interface GitResultData {
37
- branch?: string;
38
- upstream?: string;
39
- ahead?: number;
40
- behind?: number;
41
- dirty?: boolean;
42
- files?: GitFile[];
43
- diff?: string;
44
- branches?: GitBranch[];
45
- commits?: GitCommit[];
46
- remoteUrl?: string;
47
- remoteOwner?: string;
48
- remoteRepo?: string;
49
- stdout?: string;
50
- stderr?: string;
51
- }
52
- export interface GitResult {
53
- ok: boolean;
54
- data?: GitResultData;
55
- error?: string;
56
- }
57
- export declare function runGitAction(cwd: string, action: GitAction, args?: GitArgs): Promise<GitResult>;
58
- export declare function applyReversePatch(cwd: string, unifiedDiff: string, mode: "preview" | "apply"): Promise<{
59
- ok: boolean;
60
- conflicts?: string[];
61
- appliedPaths?: string[];
62
- error?: string;
63
- }>;
@@ -1,297 +0,0 @@
1
- import { execFile } from "node:child_process";
2
- import { promisify } from "node:util";
3
- const execFileAsync = promisify(execFile);
4
- const GIT_TIMEOUT_MS = 30_000;
5
- const MAX_BUFFER = 2 * 1024 * 1024; // 2 MiB stdout cap — enough for large diffs without OOM
6
- class GitError extends Error {
7
- constructor(message) {
8
- super(message);
9
- this.name = "GitError";
10
- }
11
- }
12
- async function git(cwd, args) {
13
- try {
14
- const { stdout, stderr } = await execFileAsync("git", args, {
15
- cwd,
16
- timeout: GIT_TIMEOUT_MS,
17
- maxBuffer: MAX_BUFFER,
18
- env: { ...process.env, GIT_TERMINAL_PROMPT: "0", LC_ALL: "C" },
19
- });
20
- return { stdout: stdout.toString(), stderr: stderr.toString() };
21
- }
22
- catch (err) {
23
- if (err && typeof err === "object" && "stderr" in err) {
24
- const stderr = String(err.stderr ?? "");
25
- const stdout = String(err.stdout ?? "");
26
- const msg = stderr.trim() || err.message || "git failed";
27
- const e = new GitError(msg);
28
- e.stdout = stdout;
29
- e.stderr = stderr;
30
- throw e;
31
- }
32
- throw new GitError(err.message ?? String(err));
33
- }
34
- }
35
- function parsePorcelainStatus(porcelain) {
36
- const files = [];
37
- const lines = porcelain.split("\n").filter(Boolean);
38
- for (const line of lines) {
39
- if (line.length < 3)
40
- continue;
41
- const status = line.slice(0, 2);
42
- const rest = line.slice(3);
43
- // Rename: `R old -> new`
44
- const path = rest.includes(" -> ") ? rest.split(" -> ")[1] ?? rest : rest;
45
- files.push({
46
- path,
47
- status,
48
- staged: status[0] !== " " && status[0] !== "?",
49
- untracked: status === "??",
50
- });
51
- }
52
- return files;
53
- }
54
- function parseLogPretty(stdout) {
55
- // Format: %H%x1f%h%x1f%an%x1f%aI%x1f%s%x1f%b%x1e
56
- const records = stdout.split("\x1e").map((r) => r.trim()).filter(Boolean);
57
- return records.map((record) => {
58
- const [hash, shortHash, author, date, subject, body] = record.split("\x1f");
59
- return {
60
- hash: hash ?? "",
61
- shortHash: shortHash ?? "",
62
- author: author || undefined,
63
- date: date || undefined,
64
- subject: subject ?? "",
65
- body: body || undefined,
66
- };
67
- });
68
- }
69
- async function readBranches(cwd) {
70
- // Format: name|current(*/space)|upstream|ahead|behind
71
- const fmt = "%(refname:short)%00%(HEAD)%00%(upstream:short)%00%(upstream:track,nobracket)";
72
- const { stdout } = await git(cwd, ["for-each-ref", `--format=${fmt}`, "refs/heads"]);
73
- const branches = [];
74
- for (const line of stdout.split("\n").filter(Boolean)) {
75
- const [name, head, upstream, track] = line.split("\x00");
76
- if (!name)
77
- continue;
78
- let ahead;
79
- let behind;
80
- if (track) {
81
- const aheadMatch = track.match(/ahead (\d+)/);
82
- const behindMatch = track.match(/behind (\d+)/);
83
- if (aheadMatch)
84
- ahead = Number(aheadMatch[1]);
85
- if (behindMatch)
86
- behind = Number(behindMatch[1]);
87
- }
88
- branches.push({
89
- name,
90
- current: head === "*",
91
- remote: upstream || undefined,
92
- ahead,
93
- behind,
94
- });
95
- }
96
- return branches;
97
- }
98
- async function readUpstreamCounts(cwd) {
99
- try {
100
- const { stdout: upstream } = await git(cwd, ["rev-parse", "--abbrev-ref", "@{upstream}"]);
101
- const upstreamRef = upstream.trim();
102
- if (!upstreamRef)
103
- return {};
104
- const { stdout } = await git(cwd, ["rev-list", "--left-right", "--count", `${upstreamRef}...HEAD`]);
105
- const [behindStr, aheadStr] = stdout.trim().split(/\s+/);
106
- return {
107
- upstream: upstreamRef,
108
- ahead: Number.isFinite(Number(aheadStr)) ? Number(aheadStr) : undefined,
109
- behind: Number.isFinite(Number(behindStr)) ? Number(behindStr) : undefined,
110
- };
111
- }
112
- catch {
113
- return {};
114
- }
115
- }
116
- async function actionStatus(cwd) {
117
- const [{ stdout: branchOut }, { stdout: porcelainOut }, { stdout: diffOut }] = await Promise.all([
118
- git(cwd, ["rev-parse", "--abbrev-ref", "HEAD"]),
119
- git(cwd, ["status", "--porcelain"]),
120
- git(cwd, ["diff", "--no-color"]).catch(() => ({ stdout: "" })),
121
- ]);
122
- const upstreamCounts = await readUpstreamCounts(cwd);
123
- const files = parsePorcelainStatus(porcelainOut);
124
- return {
125
- branch: branchOut.trim(),
126
- upstream: upstreamCounts.upstream,
127
- ahead: upstreamCounts.ahead,
128
- behind: upstreamCounts.behind,
129
- dirty: files.length > 0,
130
- files,
131
- diff: diffOut || undefined,
132
- };
133
- }
134
- async function actionCommit(cwd, args) {
135
- const message = args?.message?.trim();
136
- if (!message)
137
- throw new GitError("commit message is required");
138
- if (args?.addAll)
139
- await git(cwd, ["add", "-A"]);
140
- const { stdout, stderr } = await git(cwd, ["commit", "-m", message]);
141
- return { stdout, stderr };
142
- }
143
- async function actionPush(cwd, args) {
144
- if (args?.force && !args.confirmed) {
145
- throw new GitError("force push requires confirmed: true");
146
- }
147
- const remote = args?.remote ?? "origin";
148
- const branch = args?.branch;
149
- const cmd = ["push"];
150
- if (args?.force)
151
- cmd.push("--force-with-lease");
152
- cmd.push(remote);
153
- if (branch)
154
- cmd.push(branch);
155
- const { stdout, stderr } = await git(cwd, cmd);
156
- return { stdout, stderr };
157
- }
158
- async function actionPull(cwd, args) {
159
- const remote = args?.remote ?? "origin";
160
- const cmd = ["pull", "--ff-only", remote];
161
- if (args?.branch)
162
- cmd.push(args.branch);
163
- const { stdout, stderr } = await git(cwd, cmd);
164
- return { stdout, stderr };
165
- }
166
- async function actionBranches(cwd) {
167
- return { branches: await readBranches(cwd) };
168
- }
169
- async function actionCheckout(cwd, args) {
170
- const branch = args?.branch;
171
- if (!branch)
172
- throw new GitError("branch is required");
173
- const { stdout, stderr } = await git(cwd, ["checkout", branch]);
174
- return { stdout, stderr, branch };
175
- }
176
- async function actionCreateBranch(cwd, args) {
177
- const branch = args?.branch;
178
- if (!branch)
179
- throw new GitError("branch is required");
180
- const { stdout, stderr } = await git(cwd, ["checkout", "-b", branch]);
181
- return { stdout, stderr, branch };
182
- }
183
- async function actionLog(cwd, args) {
184
- const limit = Math.min(Math.max(args?.limit ?? 30, 1), 200);
185
- const fmt = "%H%x1f%h%x1f%an%x1f%aI%x1f%s%x1f%b%x1e";
186
- const { stdout } = await git(cwd, ["log", `-n${limit}`, `--pretty=format:${fmt}`]);
187
- return { commits: parseLogPretty(stdout) };
188
- }
189
- async function actionStash(cwd, args) {
190
- const cmd = ["stash", "push"];
191
- if (args?.message)
192
- cmd.push("-m", args.message);
193
- const { stdout, stderr } = await git(cwd, cmd);
194
- return { stdout, stderr };
195
- }
196
- async function actionStashPop(cwd) {
197
- const { stdout, stderr } = await git(cwd, ["stash", "pop"]);
198
- return { stdout, stderr };
199
- }
200
- async function actionResetToRemote(cwd, args) {
201
- if (!args?.confirmed)
202
- throw new GitError("resetToRemote requires confirmed: true");
203
- const upstream = await readUpstreamCounts(cwd);
204
- if (!upstream.upstream)
205
- throw new GitError("no upstream branch configured");
206
- await git(cwd, ["fetch", "--prune"]);
207
- const { stdout, stderr } = await git(cwd, ["reset", "--hard", upstream.upstream]);
208
- return { stdout, stderr };
209
- }
210
- async function actionRemoteUrl(cwd, args) {
211
- const remote = args?.remote ?? "origin";
212
- const { stdout } = await git(cwd, ["remote", "get-url", remote]);
213
- const url = stdout.trim();
214
- // Best-effort owner/repo parsing for both ssh and https forms.
215
- let owner;
216
- let repo;
217
- const match = url.match(/[:/]([^:/]+)\/([^/]+?)(?:\.git)?$/);
218
- if (match) {
219
- owner = match[1];
220
- repo = match[2];
221
- }
222
- return { remoteUrl: url, remoteOwner: owner, remoteRepo: repo };
223
- }
224
- async function actionDiff(cwd, args) {
225
- const cmd = ["diff", "--no-color"];
226
- if (args?.staged)
227
- cmd.push("--cached");
228
- if (args?.targetRef)
229
- cmd.push(args.targetRef);
230
- if (args?.paths && args.paths.length > 0) {
231
- cmd.push("--", ...args.paths);
232
- }
233
- const { stdout } = await git(cwd, cmd);
234
- return { diff: stdout };
235
- }
236
- export async function runGitAction(cwd, action, args) {
237
- try {
238
- switch (action) {
239
- case "status": return { ok: true, data: await actionStatus(cwd) };
240
- case "commit": return { ok: true, data: await actionCommit(cwd, args) };
241
- case "push": return { ok: true, data: await actionPush(cwd, args) };
242
- case "pull": return { ok: true, data: await actionPull(cwd, args) };
243
- case "branches": return { ok: true, data: await actionBranches(cwd) };
244
- case "checkout": return { ok: true, data: await actionCheckout(cwd, args) };
245
- case "createBranch": return { ok: true, data: await actionCreateBranch(cwd, args) };
246
- case "log": return { ok: true, data: await actionLog(cwd, args) };
247
- case "stash": return { ok: true, data: await actionStash(cwd, args) };
248
- case "stashPop": return { ok: true, data: await actionStashPop(cwd) };
249
- case "resetToRemote": return { ok: true, data: await actionResetToRemote(cwd, args) };
250
- case "remoteUrl": return { ok: true, data: await actionRemoteUrl(cwd, args) };
251
- case "diff": return { ok: true, data: await actionDiff(cwd, args) };
252
- default: {
253
- const _exhaustive = action;
254
- return { ok: false, error: `unknown action: ${String(_exhaustive)}` };
255
- }
256
- }
257
- }
258
- catch (err) {
259
- return { ok: false, error: err instanceof Error ? err.message : String(err) };
260
- }
261
- }
262
- export async function applyReversePatch(cwd, unifiedDiff, mode) {
263
- if (!unifiedDiff || !unifiedDiff.trim()) {
264
- return { ok: false, error: "empty diff" };
265
- }
266
- const args = ["apply", "-R"];
267
- if (mode === "preview")
268
- args.push("--check");
269
- args.push("--unidiff-zero", "-p1");
270
- return new Promise((resolve) => {
271
- const child = execFile("git", args, {
272
- cwd,
273
- timeout: GIT_TIMEOUT_MS,
274
- maxBuffer: MAX_BUFFER,
275
- env: { ...process.env, GIT_TERMINAL_PROMPT: "0", LC_ALL: "C" },
276
- }, (err, _stdout, stderrBuf) => {
277
- const stderr = stderrBuf?.toString() ?? "";
278
- if (!err) {
279
- const paths = [...stderr.matchAll(/error: patch failed: (\S+)/g)]
280
- .map((m) => m[1])
281
- .filter((p) => typeof p === "string");
282
- resolve({ ok: true, appliedPaths: paths });
283
- return;
284
- }
285
- const conflicts = [...stderr.matchAll(/error: patch failed: (\S+)/g)]
286
- .map((m) => m[1])
287
- .filter((p) => typeof p === "string");
288
- resolve({
289
- ok: false,
290
- conflicts: conflicts.length > 0 ? conflicts : undefined,
291
- error: stderr.trim() || err.message,
292
- });
293
- });
294
- child.stdin?.end(unifiedDiff);
295
- });
296
- }
297
- //# sourceMappingURL=agent-workspace-git.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"agent-workspace-git.js","sourceRoot":"","sources":["../../../../../src/runtime/acp/agent-workspace-git.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SA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C,EAAE,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC;gBAC3C,OAAO;YACT,CAAC;YACD,MAAM,SAAS,GAAG,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,6BAA6B,CAAC,CAAC;iBAClE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;iBAChB,MAAM,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC;YACrD,OAAO,CAAC;gBACN,EAAE,EAAE,KAAK;gBACT,SAAS,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;gBACvD,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,OAAO;aACpC,CAAC,CAAC;QACL,CAAC,CACF,CAAC;QACF,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,23 +0,0 @@
1
- import type { Envelope } from "@linkshell/protocol";
2
- export interface AcpRelayOptions {
3
- command: string;
4
- args: string[];
5
- cwd: string;
6
- env: Record<string, string>;
7
- sessionId: string;
8
- terminalId: string;
9
- send: (envelope: Envelope) => void;
10
- log: (msg: string) => void;
11
- }
12
- export declare class AcpRelay {
13
- private child;
14
- private readonly options;
15
- private exited;
16
- constructor(options: AcpRelayOptions);
17
- /** Forward an acp.rpc envelope payload to the child's stdin */
18
- write(payload: unknown): void;
19
- kill(): void;
20
- get isExited(): boolean;
21
- get pid(): number | undefined;
22
- onExit(cb: (code: number | null, signal: string | null) => void): void;
23
- }
@@ -1,73 +0,0 @@
1
- import { spawn } from "node:child_process";
2
- import { createInterface } from "node:readline";
3
- import { createEnvelope } from "@linkshell/protocol";
4
- export class AcpRelay {
5
- child;
6
- options;
7
- exited = false;
8
- constructor(options) {
9
- this.options = options;
10
- this.child = spawn(options.command, options.args, {
11
- cwd: options.cwd,
12
- env: options.env,
13
- stdio: ["pipe", "pipe", "pipe"],
14
- });
15
- // Read newline-delimited JSON from stdout
16
- const rl = createInterface({ input: this.child.stdout });
17
- rl.on("line", (line) => {
18
- if (!line.trim())
19
- return;
20
- try {
21
- const msg = JSON.parse(line);
22
- // Wrap JSON-RPC message in acp.rpc envelope and send to gateway
23
- this.options.send(createEnvelope({
24
- type: "acp.rpc",
25
- sessionId: this.options.sessionId,
26
- terminalId: this.options.terminalId,
27
- payload: msg,
28
- }));
29
- }
30
- catch (e) {
31
- this.options.log(`acp-relay: failed to parse stdout line: ${e}`);
32
- }
33
- });
34
- // Log stderr
35
- this.child.stderr?.on("data", (chunk) => {
36
- this.options.log(`acp-relay stderr: ${chunk.toString().trimEnd()}`);
37
- });
38
- this.child.on("exit", (code, signal) => {
39
- this.exited = true;
40
- this.options.log(`acp-relay: process exited (code=${code}, signal=${signal})`);
41
- });
42
- this.child.on("error", (err) => {
43
- this.options.log(`acp-relay: process error: ${err.message}`);
44
- });
45
- }
46
- /** Forward an acp.rpc envelope payload to the child's stdin */
47
- write(payload) {
48
- if (this.exited || !this.child.stdin?.writable)
49
- return;
50
- try {
51
- const line = JSON.stringify(payload) + "\n";
52
- this.child.stdin.write(line);
53
- }
54
- catch (e) {
55
- this.options.log(`acp-relay: failed to write to stdin: ${e}`);
56
- }
57
- }
58
- kill() {
59
- if (!this.exited) {
60
- this.child.kill("SIGTERM");
61
- }
62
- }
63
- get isExited() {
64
- return this.exited;
65
- }
66
- get pid() {
67
- return this.child.pid;
68
- }
69
- onExit(cb) {
70
- this.child.on("exit", cb);
71
- }
72
- }
73
- //# sourceMappingURL=acp-relay.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"acp-relay.js","sourceRoot":"","sources":["../../../../src/runtime/acp-relay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,oBAAoB,CAAC;AA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