accompany 0.0.0-stage → 0.25.2
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/LICENSE +21 -0
- package/README.md +11 -2
- package/bin/accompany.js +106 -0
- package/dist/apple-touch-icon-ehhpc4a9.png +0 -0
- package/dist/cli.js +144 -0
- package/dist/cli.js.map +60 -0
- package/dist/favicon-0wwf4h3c.png +0 -0
- package/dist/index-175hbfqz.css +1 -0
- package/dist/index-5mraxvns.js +70 -0
- package/dist/index-5mraxvns.js.map +30 -0
- package/dist/public/index.html +18 -0
- package/package.json +41 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Itsuki Yamada
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
#
|
|
1
|
+
# accompany
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
AI コーディングエージェントのターミナルをブラウザで共有する Web UI サーバー。Bun(1.4.0 以上)があれば Bun で動き、なければ同梱の実行ファイルで動く(Bun を入れなくても起動できる)。
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npx accompany # 最初のターミナルで $SHELL を動かす
|
|
7
|
+
npx accompany -- claude # 最初のターミナルで動かすコマンドを指定する
|
|
8
|
+
npx accompany --port 4000 # 待ち受けるポートを変える
|
|
9
|
+
npx accompany --help # 使い方を表示する
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
macOS(Apple Silicon・Intel)と Linux(x64・arm64、glibc)に対応する。Bun があっても実行ファイルで動かしたいときは、`ACCOMPANY_USE_BINARY=1` を付けて起動する。使い方の詳細は [GitHub](https://github.com/itsuki-yamada/accompany) を参照。
|
package/bin/accompany.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// npm で入れた Accompany の起動役(docs/adr/132-npm.md、191-run-on-bun.md)。
|
|
3
|
+
// Bun(1.4.0 以上)があれば、同梱した JS(dist/cli.js。Release の tarball と同じもの)を Bun で動かす。
|
|
4
|
+
// 署名のない実行ファイルより、広く使われている Bun が動かすほうが、セキュリティの製品に止められにくいため。
|
|
5
|
+
// Bun がなければ(または ACCOMPANY_USE_BINARY=1 を付けると)、このマシンの OS と CPU のパッケージ
|
|
6
|
+
// (@itsuki-yamada/accompany-<OS>-<CPU>)に入っている実行ファイルを起動する。
|
|
7
|
+
// 引数と標準入出力はそのまま渡す。止める合図は起動したものに伝え、その終了コード(または合図)で終わる。
|
|
8
|
+
// Node の古い版でも動くよう、CommonJS と古くからある API だけを使う
|
|
9
|
+
"use strict";
|
|
10
|
+
|
|
11
|
+
const { spawn, spawnSync } = require("child_process");
|
|
12
|
+
const fs = require("fs");
|
|
13
|
+
const path = require("path");
|
|
14
|
+
|
|
15
|
+
const supported = ["darwin-arm64", "darwin-x64", "linux-x64", "linux-arm64"];
|
|
16
|
+
const platform = `${process.platform}-${process.arch}`;
|
|
17
|
+
const releases = "https://github.com/itsuki-yamada/accompany/releases";
|
|
18
|
+
// app/server/src/require-bun.ts の required と同じ版。これより古い Bun では動かさず、実行ファイルを起動する
|
|
19
|
+
const requiredBun = [1, 4, 0];
|
|
20
|
+
const script = path.join(__dirname, "..", "dist", "cli.js");
|
|
21
|
+
|
|
22
|
+
function fail(message) {
|
|
23
|
+
console.error(`Accompany: ${message}`);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// PATH の bun(起動役そのものを Bun が動かしているときは、その Bun)。見つからなければ undefined。
|
|
28
|
+
// 相対のディレクトリ(. や空の要素など)は飛ばす。起動したディレクトリによって変わり、そこに置かれた bun を動かしてしまうため
|
|
29
|
+
function findBun() {
|
|
30
|
+
if (process.versions.bun) return process.execPath;
|
|
31
|
+
for (const dir of (process.env.PATH || "").split(path.delimiter)) {
|
|
32
|
+
if (!path.isAbsolute(dir)) continue;
|
|
33
|
+
const file = path.join(dir, "bun");
|
|
34
|
+
try {
|
|
35
|
+
fs.accessSync(file, fs.constants.X_OK);
|
|
36
|
+
if (fs.statSync(file).isFile()) return file;
|
|
37
|
+
} catch {
|
|
38
|
+
// 次のディレクトリを探す
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// bun の版が requiredBun 以上か
|
|
45
|
+
function isNewEnough(bun) {
|
|
46
|
+
const result = spawnSync(bun, ["--version"], { encoding: "utf8", timeout: 10000 });
|
|
47
|
+
const match = /^(\d+)\.(\d+)\.(\d+)/.exec((result.stdout || "").trim());
|
|
48
|
+
if (result.status !== 0 || !match) return false;
|
|
49
|
+
for (let i = 0; i < 3; i++) {
|
|
50
|
+
const n = Number(match[i + 1]);
|
|
51
|
+
if (n !== requiredBun[i]) return n > requiredBun[i];
|
|
52
|
+
}
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 起動するもの(コマンドと、その前に付ける引数)
|
|
57
|
+
function choose() {
|
|
58
|
+
if (process.env.ACCOMPANY_USE_BINARY !== "1" && fs.existsSync(script)) {
|
|
59
|
+
const bun = findBun();
|
|
60
|
+
if (bun && isNewEnough(bun)) return { command: bun, args: [script] };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if (!supported.includes(platform)) {
|
|
64
|
+
fail(
|
|
65
|
+
`この OS と CPU(${platform})の実行ファイルはありません。対応しているのは ${supported.join("、")} です。` +
|
|
66
|
+
`Bun 1.4.0 以上を入れると、Bun で動かせます: ${releases}`,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
// Linux 向けの実行ファイルは glibc の上で動く。glibc の版が分からなければ、musl(Alpine など)とみなす
|
|
70
|
+
if (process.platform === "linux" && !process.report.getReport().header.glibcVersionRuntime) {
|
|
71
|
+
fail(`musl の Linux(Alpine など)では、実行ファイルは動きません。Bun 1.4.0 以上を入れると、Bun で動かせます: ${releases}`);
|
|
72
|
+
}
|
|
73
|
+
const pkg = `@itsuki-yamada/accompany-${platform}`;
|
|
74
|
+
try {
|
|
75
|
+
return { command: require.resolve(`${pkg}/bin/accompany`), args: [] };
|
|
76
|
+
} catch {
|
|
77
|
+
return fail(
|
|
78
|
+
`${pkg} が入っていません。optionalDependencies を入れない設定(--omit=optional など)を外して入れ直すか、` +
|
|
79
|
+
"Bun 1.4.0 以上を入れてください",
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const { command, args } = choose();
|
|
85
|
+
const child = spawn(command, args.concat(process.argv.slice(2)), { stdio: "inherit" });
|
|
86
|
+
|
|
87
|
+
// 端末の Ctrl+C はプロセスグループ全体に届くので、起動したもの(Bun か実行ファイル)にも直接届く。kill などで起動役だけに
|
|
88
|
+
// 送られたときも伝える(Accompany は、二度目以降の合図を無視する)。起動役は、Accompany が保存して終わるまで待つ
|
|
89
|
+
const signals = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
90
|
+
for (const signal of signals) {
|
|
91
|
+
process.on(signal, () => child.kill(signal));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
child.on("error", (error) => fail(`${command} を起動できませんでした: ${error.message}`));
|
|
95
|
+
|
|
96
|
+
child.on("exit", (code, signal) => {
|
|
97
|
+
if (signal) {
|
|
98
|
+
// 起動したものと同じ合図で終わり、呼び出し元(シェルなど)に合図で終わったことを伝える
|
|
99
|
+
for (const s of signals) process.removeAllListeners(s);
|
|
100
|
+
process.kill(process.pid, signal);
|
|
101
|
+
// 合図を無視する設定を受け継いでいて終わらなかったときは、終了コードで伝える
|
|
102
|
+
setTimeout(() => process.exit(1), 1000);
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
process.exit(code);
|
|
106
|
+
});
|
|
Binary file
|