claude-task-worker 0.87.0 → 0.89.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 (3) hide show
  1. package/README.md +20 -1
  2. package/dist/index.js +47 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -66,7 +66,7 @@ CLI が GitHub ラベルを検知してタスクを起動し、プラグイン
66
66
  | [Git](https://git-scm.com/) | worktree の作成・ブランチ操作 |
67
67
  | [jq](https://jqlang.org/) | プラグインスキル内での JSON 加工 |
68
68
  | [CodeGraph](https://www.npmjs.com/package/@colbymchenry/codegraph) | コード探索用インデックス。任意(未導入でも探索がテキスト検索に落ちるだけ) |
69
- | [Pencil CLI](https://docs.pencil.dev/for-developers/pencil-cli) | `.pen` デザインファイルの編集・参照。UIデザイン先行ワークフロー使用時のみ(呼び出しは `claude-task-worker pencil` 経由) |
69
+ | [Pen CLI](https://docs.pencil.dev/for-developers/pen-cli) | `.pen` デザインファイルの編集・参照。UIデザイン先行ワークフロー使用時のみ(要ログイン。呼び出しは `claude-task-worker pencil` 経由) |
70
70
  | [herdr](https://herdr.dev) | `--project` / `mode: "herdr"` 使用時のみ |
71
71
 
72
72
  CLI 本体に npm の実行時依存はない(esbuild で `dist/index.js` に単一バンドルされ、Node.js 標準モジュールのみで動作する)。
@@ -89,6 +89,25 @@ claude plugin install claude-task-worker@claude-task-worker
89
89
 
90
90
  herdr が必要な場合は `curl -fsSL https://herdr.dev/install.sh | sh` または `brew install herdr`([ドキュメント](https://herdr.dev/docs/install/))。
91
91
 
92
+ ### Pen CLI のログイン
93
+
94
+ `.pen` を扱うスキル(`edit-pencil-design` / `inspect-pencil-node` / `resolve-pencil-conflict`)は Pen CLI の認証を必要とする。未ログインだと `.pen` の読み書きが失敗するため、UIデザイン先行ワークフローを使うなら**インストール後に一度ログインしておく**(`.pen` を触らないので `claude-task-worker pencil` ラッパー経由でなくてよい)。
95
+
96
+ ```bash
97
+ pencil login # メールアドレス + パスワード、またはメールアドレス + OTP コード
98
+ pencil status # 認証状態の確認
99
+ ```
100
+
101
+ セッショントークンは `~/.pencil/session-cli.json` に保存され、以降のコマンドで再利用される。
102
+
103
+ CI やワーカーを実行するマシンなど対話ログインできない環境では、環境変数 `PEN_CLI_KEY`(pen.dev の組織設定 > Developer Keys で発行)を使う。保存済みトークンより優先される。
104
+
105
+ ```bash
106
+ export PEN_CLI_KEY=pencil_cli_...
107
+ ```
108
+
109
+ 詳細は [Pen CLI のドキュメント](https://docs.pencil.dev/for-developers/pen-cli)を参照。
110
+
92
111
  ### 更新
93
112
 
94
113
  ```bash
package/dist/index.js CHANGED
@@ -583,6 +583,8 @@ __export(herdr_runner_exports, {
583
583
  PANE_OUTPUT_LINES: () => PANE_OUTPUT_LINES,
584
584
  PANE_READY_POLL_INTERVAL_MS: () => PANE_READY_POLL_INTERVAL_MS,
585
585
  PANE_READY_TIMEOUT_MS: () => PANE_READY_TIMEOUT_MS,
586
+ PROMPT_ACCEPT_POLL_INTERVAL_MS: () => PROMPT_ACCEPT_POLL_INTERVAL_MS,
587
+ PROMPT_ACCEPT_TIMEOUT_MS: () => PROMPT_ACCEPT_TIMEOUT_MS,
586
588
  buildHerdrTaskResult: () => buildHerdrTaskResult,
587
589
  createCompletionTracker: () => createCompletionTracker,
588
590
  observeAgentStatus: () => observeAgentStatus,
@@ -657,13 +659,43 @@ async function startHerdrTask({
657
659
  }
658
660
  await mod.agentStart(paneId, { name: toAgentName(label), args, readyTimeoutMs: timing?.agentStartReadyTimeoutMs });
659
661
  await mod.agentPrompt(paneId, prompt);
662
+ await ensurePromptAccepted(paneId, prompt, mod, timing);
660
663
  } catch (err) {
664
+ console.error(`[herdr-runner] failed to start task in pane ${paneId}: ${err}`);
661
665
  await mod.tabClose(tabId).catch(() => {
662
666
  });
663
667
  throw err;
664
668
  }
665
669
  return { paneId, tabId };
666
670
  }
671
+ async function ensurePromptAccepted(paneId, prompt, mod, timing) {
672
+ if (await waitForPromptAccepted(paneId, mod, timing)) return;
673
+ console.warn(`[herdr-runner] the prompt was not accepted in pane ${paneId} (claude stayed idle); resending it`);
674
+ await mod.agentPrompt(paneId, prompt);
675
+ if (await waitForPromptAccepted(paneId, mod, timing)) return;
676
+ throw new Error(
677
+ `the claude session in pane ${paneId} did not start the task after the prompt was submitted twice (a startup dialog most likely swallowed it)`
678
+ );
679
+ }
680
+ async function waitForPromptAccepted(paneId, mod, timing) {
681
+ const timeoutMs = timing?.promptAcceptTimeoutMs ?? PROMPT_ACCEPT_TIMEOUT_MS;
682
+ const pollIntervalMs = timing?.promptAcceptPollIntervalMs ?? PROMPT_ACCEPT_POLL_INTERVAL_MS;
683
+ const deadline = Date.now() + timeoutMs;
684
+ let loggedError = false;
685
+ for (; ; ) {
686
+ try {
687
+ const { agentStatus } = await mod.agentGet(paneId);
688
+ if (agentStatus === "working" || agentStatus === "done") return true;
689
+ } catch (err) {
690
+ if (!loggedError) {
691
+ console.error(`[herdr-runner] failed to read agent status for pane ${paneId} after the prompt: ${err}`);
692
+ loggedError = true;
693
+ }
694
+ }
695
+ if (Date.now() >= deadline) return false;
696
+ await sleep(pollIntervalMs);
697
+ }
698
+ }
667
699
  async function waitForPaneReady(paneId, mod, options) {
668
700
  const timeoutMs = options?.timeoutMs ?? PANE_READY_TIMEOUT_MS;
669
701
  const pollIntervalMs = options?.pollIntervalMs ?? PANE_READY_POLL_INTERVAL_MS;
@@ -769,7 +801,7 @@ async function stopHerdrTask(task, herdr, options) {
769
801
  function sleep(ms) {
770
802
  return new Promise((resolve3) => setTimeout(resolve3, ms));
771
803
  }
772
- var AGENT_POLL_INTERVAL_MS, PANE_OUTPUT_LINES, PANE_READY_TIMEOUT_MS, PANE_READY_POLL_INTERVAL_MS, CLAUDE_EXIT_TIMEOUT_MS, CLAUDE_EXIT_POLL_INTERVAL_MS;
804
+ var AGENT_POLL_INTERVAL_MS, PANE_OUTPUT_LINES, PANE_READY_TIMEOUT_MS, PANE_READY_POLL_INTERVAL_MS, PROMPT_ACCEPT_TIMEOUT_MS, PROMPT_ACCEPT_POLL_INTERVAL_MS, CLAUDE_EXIT_TIMEOUT_MS, CLAUDE_EXIT_POLL_INTERVAL_MS;
773
805
  var init_herdr_runner = __esm({
774
806
  "src/herdr-runner.ts"() {
775
807
  "use strict";
@@ -778,6 +810,8 @@ var init_herdr_runner = __esm({
778
810
  PANE_OUTPUT_LINES = 300;
779
811
  PANE_READY_TIMEOUT_MS = 30 * 1e3;
780
812
  PANE_READY_POLL_INTERVAL_MS = 200;
813
+ PROMPT_ACCEPT_TIMEOUT_MS = 20 * 1e3;
814
+ PROMPT_ACCEPT_POLL_INTERVAL_MS = 500;
781
815
  CLAUDE_EXIT_TIMEOUT_MS = 15 * 1e3;
782
816
  CLAUDE_EXIT_POLL_INTERVAL_MS = 200;
783
817
  }
@@ -4231,11 +4265,22 @@ async function installPenCli(logPrefix) {
4231
4265
  try {
4232
4266
  await runCommand2("npm", ["install", "-g", `${PEN_PACKAGE}@latest`]);
4233
4267
  console.log(`[${logPrefix}] Pen CLI installed.`);
4234
- return true;
4235
4268
  } catch (err) {
4236
4269
  console.error(`[${logPrefix}] Failed to install Pen CLI: ${err.message}`);
4237
4270
  return false;
4238
4271
  }
4272
+ await warnIfPenLoggedOut(logPrefix);
4273
+ return true;
4274
+ }
4275
+ async function warnIfPenLoggedOut(logPrefix) {
4276
+ const { runCommand: runCommand2 } = await loadRunCommand3();
4277
+ try {
4278
+ await runCommand2("pencil", ["status"]);
4279
+ } catch {
4280
+ console.log(
4281
+ `[${logPrefix}] Pen CLI is not authenticated. Run \`pencil login\` (or set PEN_CLI_KEY) before using .pen designs.`
4282
+ );
4283
+ }
4239
4284
  }
4240
4285
 
4241
4286
  // src/commands/install.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-task-worker",
3
- "version": "0.87.0",
3
+ "version": "0.89.0",
4
4
  "description": "CLI tool that polls GitHub Issues/PRs and delegates work to Claude CLI",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",