cckeep 0.1.0 → 0.1.1

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/README.ja.md CHANGED
@@ -28,18 +28,23 @@
28
28
  ## クイックスタート
29
29
 
30
30
  ```sh
31
- npx cckeep install
31
+ npm install -g cckeep
32
+ cckeep install
32
33
  ```
33
34
 
34
35
  バックグラウンドジョブを登録します(macOS は launchd、Linux は systemd user timer)。15秒ごとに確認し、死んでいるものを繋ぎ直します。
35
36
 
36
- 条件が一つあります。**Claude Code tmux の中で動いていること。** 素のターミナルで起動したセッションには別プロセスから入力を送る手段がなく、どんなツールでも手が出せません。→ [tmux Claude Code を動かす](#tmux-で-claude-code-を動かす)
37
+ `npx cckeep install` ではなくグローバルに入れてください。登録されたジョブはインストール先の cckeep を実行しますが、npx のキャッシュは使い捨てです。そこを指すジョブはキャッシュが消された瞬間に、黙って動かなくなります 監視ツールが持ってはいけない唯一の壊れ方です。そのため `cckeep install` は npx のパスからの登録を拒否します。
38
+
39
+ 入れる前に様子を見るだけなら `npx` で構いません。以下の2つは何も変更しません。
37
40
 
38
41
  ```sh
39
- npx cckeep # いま何が見えているか(何も変更しません)
42
+ npx cckeep # いま何が見えているか
40
43
  npx cckeep doctor # tmux・ペイン・スケジューラの確認
41
44
  ```
42
45
 
46
+ 条件が一つあります。**Claude Code が tmux の中で動いていること。** 素のターミナルで起動したセッションには別プロセスから入力を送る手段がなく、どんなツールでも手が出せません。→ [tmux で Claude Code を動かす](#tmux-で-claude-code-を動かす)
47
+
43
48
  > 机に戻る手間が省けたなら、⭐ が同じ問題を抱えている人に届く助けになります。
44
49
 
45
50
  ## 作業中のセッションには打ち込みません
package/README.md CHANGED
@@ -28,18 +28,23 @@ Either way you find out the same way: you reach for your phone, and the session
28
28
  ## Quick start
29
29
 
30
30
  ```sh
31
- npx cckeep install
31
+ npm install -g cckeep
32
+ cckeep install
32
33
  ```
33
34
 
34
35
  That registers a background job — launchd on macOS, a systemd user timer on Linux — that checks every 15 seconds and re-arms whatever went dead.
35
36
 
36
- One requirement: **Claude Code has to be running inside tmux.** A session started in a bare terminal cannot be reached from another process, so there is nothing any tool can do for it. See [Running Claude Code in tmux](#running-claude-code-in-tmux).
37
+ Install it globally rather than running `npx cckeep install`. The scheduled job runs cckeep from wherever it was installed, and npx's cache is throwaway: a job pointing into it keeps working until the cache is cleared and then stops, silently the one failure a watchdog must not have. `cckeep install` refuses to schedule from an npx path for that reason.
38
+
39
+ To look before installing anything, `npx` is fine — neither of these changes a thing:
37
40
 
38
41
  ```sh
39
- npx cckeep # what it sees right now — changes nothing
42
+ npx cckeep # what it sees right now
40
43
  npx cckeep doctor # check tmux, panes, and the scheduler
41
44
  ```
42
45
 
46
+ One requirement: **Claude Code has to be running inside tmux.** A session started in a bare terminal cannot be reached from another process, so there is nothing any tool can do for it. See [Running Claude Code in tmux](#running-claude-code-in-tmux).
47
+
43
48
  > If cckeep saved you a walk back to your desk, a ⭐ helps other Remote Control users find it.
44
49
 
45
50
  ## It will not type into a session that is working
package/bin/cckeep.js CHANGED
@@ -130,6 +130,10 @@ async function main() {
130
130
  }
131
131
  case 'install': {
132
132
  const res = scheduler.install({ interval: config.interval });
133
+ if (res.kind === 'ephemeral') {
134
+ console.error(t.ephemeral(res.path));
135
+ process.exit(1);
136
+ }
133
137
  if (res.kind === 'unsupported') {
134
138
  console.log(t.unsupported);
135
139
  process.exit(1);
@@ -155,6 +159,11 @@ async function main() {
155
159
  ['tmux server', bin && tmux.hasServer() ? t.doctorOk : t.doctorFail],
156
160
  ['claude panes', String(claudePanes.length)],
157
161
  ['scheduler', scheduler.isInstalled() ? t.doctorOk : t.doctorFail],
162
+ [t.scheduledPath, (() => {
163
+ const cli = scheduler.scheduledCli();
164
+ if (!cli) return '—';
165
+ return existsSync(cli) ? cli : `${cli} ${t.scheduledMissing}`;
166
+ })()],
158
167
  ['home', homeDir()],
159
168
  ['config', existsSync(configPath()) ? configPath() : `${configPath()} (defaults)`],
160
169
  ['state', statePath()],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cckeep",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Keeps Claude Code Remote Control from silently going dead. Re-arms the sessions its 31-second retry budget gives up on — local, tmux-native, zero dependencies.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/i18n.js CHANGED
@@ -21,6 +21,9 @@ const en = {
21
21
  installFailed: (kind) => `Wrote the ${kind} unit, but could not load it. Load it manually, or run \`cckeep watch\` in a terminal.`,
22
22
  uninstalled: (kind) => `Removed the ${kind} job.`,
23
23
  unsupported: 'Automatic scheduling supports macOS (launchd) and Linux (systemd user timers). Elsewhere, run `cckeep watch` under your own supervisor.',
24
+ ephemeral: (p) => `Refusing to schedule: this copy of cckeep lives in npm's throwaway npx cache\n ${p}\nA scheduled job pointing there stops working the moment the cache is cleared — silently. Install it properly first:\n\n npm install -g cckeep && cckeep install\n`,
25
+ scheduledPath: 'scheduled cmd',
26
+ scheduledMissing: 'MISSING — run `cckeep install` again',
24
27
  noLog: 'No log yet.',
25
28
  doctorOk: 'ok',
26
29
  doctorFail: 'missing',
@@ -49,6 +52,9 @@ const ja = {
49
52
  installFailed: (kind) => `${kind} の定義は書きましたが、読み込みに失敗しました。手動で読み込むか、ターミナルで \`cckeep watch\` を実行してください。`,
50
53
  uninstalled: (kind) => `${kind} のジョブを削除しました。`,
51
54
  unsupported: '自動スケジュール登録は macOS (launchd) と Linux (systemd user timer) に対応しています。それ以外では `cckeep watch` を任意の常駐手段で動かしてください。',
55
+ ephemeral: (p) => `登録を中止しました: この cckeep は npm の使い捨て npx キャッシュ内にあります\n ${p}\nここを指すジョブは、キャッシュが消された瞬間に黙って動かなくなります。先に正式にインストールしてください:\n\n npm install -g cckeep && cckeep install\n`,
56
+ scheduledPath: '登録先',
57
+ scheduledMissing: '見つかりません — `cckeep install` を再実行してください',
52
58
  noLog: 'ログはまだありません。',
53
59
  doctorOk: 'ok',
54
60
  doctorFail: '未検出',
package/src/scheduler.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { execFileSync } from 'node:child_process';
2
- import { mkdirSync, writeFileSync, existsSync, unlinkSync } from 'node:fs';
2
+ import { mkdirSync, writeFileSync, readFileSync, existsSync, unlinkSync } from 'node:fs';
3
3
  import { homedir, platform } from 'node:os';
4
4
  import { join } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
@@ -10,6 +10,16 @@ function cliPath() {
10
10
  return fileURLToPath(new URL('../bin/cckeep.js', import.meta.url));
11
11
  }
12
12
 
13
+ /**
14
+ * `npx cckeep` runs out of npm's throwaway cache. Baking that path into a
15
+ * launchd job or systemd unit produces a scheduler that works today and stops
16
+ * forever the first time the cache is evicted — silently, which is the one
17
+ * failure this tool must not have. Refuse instead, and ask for a real install.
18
+ */
19
+ export function isEphemeralPath(p) {
20
+ return /[\\/]_npx[\\/]/.test(p) || /[\\/]\.npm[\\/]_cacache[\\/]/.test(p);
21
+ }
22
+
13
23
  function nodePath() {
14
24
  return process.execPath;
15
25
  }
@@ -83,6 +93,9 @@ function run(cmd, args) {
83
93
  }
84
94
 
85
95
  export function install({ interval }) {
96
+ const cli = cliPath();
97
+ if (isEphemeralPath(cli)) return { kind: 'ephemeral', path: cli, ok: false };
98
+
86
99
  const os = platform();
87
100
  if (os === 'darwin') {
88
101
  const p = plistPath();
@@ -132,3 +145,29 @@ export function isInstalled() {
132
145
  if (os === 'linux') return existsSync(join(systemdDir(), 'cckeep.timer'));
133
146
  return false;
134
147
  }
148
+
149
+ /**
150
+ * The cckeep path the installed scheduler will actually run. Read back from the
151
+ * unit rather than recomputed, so `doctor` can catch a job left pointing at a
152
+ * copy that has since been moved or deleted.
153
+ */
154
+ export function scheduledCli() {
155
+ try {
156
+ const os = platform();
157
+ if (os === 'darwin') {
158
+ const p = plistPath();
159
+ if (!existsSync(p)) return null;
160
+ const xml = readFileSync(p, 'utf8');
161
+ const args = [...xml.matchAll(/<string>([^<]*)<\/string>/g)].map((m) => m[1]);
162
+ return args.find((a) => a.endsWith('cckeep.js')) ?? null;
163
+ }
164
+ if (os === 'linux') {
165
+ const p = join(systemdDir(), 'cckeep.service');
166
+ if (!existsSync(p)) return null;
167
+ const unit = readFileSync(p, 'utf8');
168
+ const line = unit.match(/^ExecStart=(.*)$/m)?.[1] ?? '';
169
+ return line.split(/\s+/).find((a) => a.endsWith('cckeep.js')) ?? null;
170
+ }
171
+ } catch {}
172
+ return null;
173
+ }