input-kanban 0.0.5 → 0.0.6

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/ENVIRONMENT.md CHANGED
@@ -8,7 +8,7 @@ CLI options take precedence over environment variables. Environment variables ta
8
8
 
9
9
  - `PORT`: HTTP server port. Default: `8787`. CLI option: `--port`.
10
10
  - `HOST`: HTTP bind host. Default: `127.0.0.1`. CLI option: `--host`.
11
- - `KANBAN_DEFAULT_REPO`: Default target repository path for new runs. Default: the current working directory when `input-kanban` is launched. CLI option: `--repo`.
11
+ - `KANBAN_DEFAULT_REPO`: Default target repository path for new runs. Default: the current working directory when `input-kanban` is launched. CLI option: `--repo`. Creating a run validates that this path is inside a Git work tree.
12
12
  - `KANBAN_RUNS_DIR`: Directory for run state, logs, and artifacts. Default: `.input-kanban/runs` under the user's home directory. CLI option: `--runs-dir`.
13
13
  - `KANBAN_CODEX_BIN`: Codex CLI executable name or path. Default: `codex`. CLI option: `--codex-bin`.
14
14
  - `KANBAN_RUNNER`: Runner mode. Supported values: `headless`, `tmux`. Default: `headless`. CLI option: `--runner`.
package/PROJECT_GUIDE.md CHANGED
@@ -67,7 +67,7 @@ Supported options:
67
67
 
68
68
  Default behavior:
69
69
 
70
- - default repo: current working directory when `input-kanban` is launched;
70
+ - default repo: current working directory when `input-kanban` is launched; run creation validates that the selected repo is inside a Git work tree;
71
71
  - default host: `127.0.0.1`;
72
72
  - default port: `8787`;
73
73
  - default runs directory: `~/.input-kanban/runs`;
package/README.en.md CHANGED
@@ -56,7 +56,7 @@ input-kanban --open
56
56
 
57
57
  Defaults:
58
58
 
59
- - target repository: the current directory where `input-kanban` is launched
59
+ - target repository: the current directory where `input-kanban` is launched; creating a run validates that it is inside a Git work tree
60
60
  - host: `127.0.0.1`
61
61
  - port: `8787`
62
62
  - runs directory: `~/.input-kanban/runs`
package/README.md CHANGED
@@ -56,7 +56,7 @@ input-kanban --open
56
56
 
57
57
  默认值:
58
58
 
59
- - 目标仓库:启动 `input-kanban` 时的当前目录
59
+ - 目标仓库:启动 `input-kanban` 时的当前目录;创建批次时会校验它必须位于 Git work tree 内
60
60
  - host:`127.0.0.1`
61
61
  - port:`8787`
62
62
  - runs 目录:`~/.input-kanban/runs`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "input-kanban",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "input-kanban": "bin/input-kanban.js"
package/public/index.html CHANGED
@@ -328,7 +328,11 @@ function renderSelectedHeader() {
328
328
  const sandbox = currentState.workerSandbox || 'workspace-write';
329
329
  const chips = [
330
330
  metaChip('Run ID', currentState.runId, { long: true }),
331
- metaChip('仓库', basenamePath(currentState.repo), { title: currentState.repo }),
331
+ metaChip('仓库', basenamePath(currentState.repo), {
332
+ title: currentState.repo,
333
+ long: true,
334
+ extra: `<button class="secondary copy-btn" title="复制仓库地址" onclick="copyRepoPath(event)">⧉</button>`
335
+ }),
332
336
  metaChip('沙箱', sandbox, { danger: sandbox === 'danger-full-access' }),
333
337
  metaChip('开始', formatDateTime(currentState.createdAt)),
334
338
  metaChip('用时', `${durationSeconds(currentState.createdAt, runDurationEnd(currentState))} 秒`)
@@ -516,6 +520,18 @@ function hideExecutionSummary() {
516
520
  el.classList.add('hidden');
517
521
  el.innerHTML = '';
518
522
  }
523
+ async function copyRepoPath(event) {
524
+ event.stopPropagation();
525
+ const repoPath = currentState?.repo || '';
526
+ if (!repoPath) return;
527
+ try {
528
+ await navigator.clipboard.writeText(repoPath);
529
+ event.currentTarget.textContent = '已复制';
530
+ setTimeout(() => { event.currentTarget.textContent = '⧉'; }, 900);
531
+ } catch {
532
+ prompt('复制仓库地址', repoPath);
533
+ }
534
+ }
519
535
  async function copyTmuxRunCommand(event) {
520
536
  event.stopPropagation();
521
537
  const command = runAttachCommand(currentState);
@@ -1,6 +1,8 @@
1
+ import { execFile } from 'node:child_process';
1
2
  import fs from 'node:fs';
2
3
  import fsp from 'node:fs/promises';
3
4
  import path from 'node:path';
5
+ import { promisify } from 'node:util';
4
6
  import {
5
7
  DEFAULT_REPO, RUNS_DIR, ensureDir, nowIso, makeRunId, readJson,
6
8
  writeJsonAtomic, fileInfo, readTextMaybe, extractFirstJsonObject, listRunDirs,
@@ -10,6 +12,7 @@ import { matchThreadToMarkers } from './appServerClient.js';
10
12
  import { formatCodexEventsJsonl } from './eventFormatter.js';
11
13
  import { defaultRunner } from './runners/index.js';
12
14
 
15
+ const execFileAsync = promisify(execFile);
13
16
  const runner = defaultRunner;
14
17
  const VALID_SANDBOXES = new Set(['read-only', 'workspace-write', 'danger-full-access']);
15
18
 
@@ -22,13 +25,33 @@ function normalizeSandbox(value, fallback = 'workspace-write') {
22
25
  function statePath(runDir) { return path.join(runDir, 'run_state.json'); }
23
26
  function planPath(runDir) { return path.join(runDir, 'plan.json'); }
24
27
 
28
+ function userInputError(message) {
29
+ const error = new Error(message);
30
+ error.statusCode = 400;
31
+ return error;
32
+ }
33
+
34
+ async function assertGitWorkTree(repo) {
35
+ const resolvedRepo = path.resolve(repo || DEFAULT_REPO);
36
+ let stat;
37
+ try { stat = await fsp.stat(resolvedRepo); }
38
+ catch { throw userInputError(`target repository does not exist: ${resolvedRepo}`); }
39
+ if (!stat.isDirectory()) throw userInputError(`target repository is not a directory: ${resolvedRepo}`);
40
+ try {
41
+ const { stdout } = await execFileAsync('git', ['-C', resolvedRepo, 'rev-parse', '--is-inside-work-tree'], { timeout: 5000 });
42
+ if (stdout.trim() === 'true') return resolvedRepo;
43
+ } catch {}
44
+ throw userInputError(`target repository is not a git work tree: ${resolvedRepo}`);
45
+ }
46
+
25
47
  export async function createRun({ label = 'task', taskText = '', repo = DEFAULT_REPO, maxParallel = 3, workerSandbox = 'workspace-write' } = {}) {
48
+ const resolvedRepo = await assertGitWorkTree(repo);
26
49
  const runId = makeRunId(label);
27
50
  const runDir = pathForRun(runId);
28
51
  await ensureDir(runDir);
29
52
  await fsp.writeFile(path.join(runDir, 'task.md'), taskText || '');
30
53
  const state = {
31
- runId, label, repo: path.resolve(repo), maxParallel: Number(maxParallel) || 3, workerSandbox: normalizeSandbox(workerSandbox),
54
+ runId, label, repo: resolvedRepo, maxParallel: Number(maxParallel) || 3, workerSandbox: normalizeSandbox(workerSandbox),
32
55
  runner: RUNNER,
33
56
  status: 'created', createdAt: nowIso(), updatedAt: nowIso(),
34
57
  planner: { status: 'pending' }, batches: [], tasks: [], judge: { status: 'pending' }
package/src/server.js CHANGED
@@ -78,7 +78,7 @@ async function handleApi(req, res, url, appClient) {
78
78
  }
79
79
  notFound(res);
80
80
  } catch (e) {
81
- send(res, 500, { error: e.message });
81
+ send(res, e.statusCode || 500, { error: e.message });
82
82
  }
83
83
  }
84
84