@christang/keel 5.231.3 → 5.231.4

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.231.3",
3
+ "version": "5.231.4",
4
4
  "description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
5
5
  "author": {
6
6
  "name": "TanglmChris",
package/README.md CHANGED
@@ -1098,6 +1098,7 @@ keel shift request | check | ready [--wake] | start | resume | status
1098
1098
  keel lock acquire | release | list # see docs/resource-lock.md
1099
1099
  keel lock acquire | release --branch <b> [--break <reason>] [--push] # a branch lock on the remote
1100
1100
  keel worktrees [--repo <path>] [--issues <file>] [--json]
1101
+ keel worktrees add [--repo <path>] --path <path> --branch <new-branch> [--base <ref>] [--json]
1101
1102
  keel sync status [--repo <path>] [--verify] [--remote <name>] [--json] # what exists only on this machine
1102
1103
 
1103
1104
  # Unattended triage — may this issue start work without asking?
package/README.zh-CN.md CHANGED
@@ -924,6 +924,7 @@ keel shift request | check | ready [--wake] | start | resume | status
924
924
  keel lock acquire | release | list # 见 docs/resource-lock.md
925
925
  keel lock acquire | release --branch <b> [--break <reason>] [--push] # 远端上的分支锁
926
926
  keel worktrees [--repo <path>] [--issues <file>] [--json]
927
+ keel worktrees add [--repo <path>] --path <path> --branch <new-branch> [--base <ref>] [--json]
927
928
  keel sync status [--repo <path>] [--verify] [--remote <name>] [--json] # 只在本机的工作
928
929
 
929
930
  # 无人值守 triage —— 这个 issue 能否不经询问就开工?
@@ -1,4 +1,4 @@
1
- <!-- keel:start version=5.231.3 -->
1
+ <!-- keel:start version=5.231.4 -->
2
2
  ## Keel Bootstrap
3
3
 
4
4
  - Start every session with `keel context`; OpenSpec artifacts and Git are the durable authority, and memory or transcripts may only inform.
package/bin/keel.js CHANGED
@@ -105,6 +105,7 @@ Usage:
105
105
  keel lock acquire|release|list ... (shared resource leases; see keel lock --help)
106
106
  keel lock acquire|release --branch <b> [--break <reason>] [--push] (a branch lock kept on the remote; device-sync)
107
107
  keel worktrees [--repo <path>] [--issues <file>] [--json] (read-only worktree overview)
108
+ keel worktrees add [--repo <path>] --path <path> --branch <new-branch> [--base <ref>] [--json]
108
109
  keel sync status [--repo <path>] [--verify] [--remote <name>] [--json] (what exists only on this machine; fetches nothing, --verify asks the remote its sha)
109
110
  keel patrol [--issues <file>] [--idle <dur>] [--since-last [--notify]] [--nudge] [--json] [--repo <path>] (the coordinator's patrol; keel patrol task prints its schedule)
110
111
  keel codex status|start|deliver|handover|drain|recover [--repo <path>] [--role <role>] [--socket <path>] [--json] (managed Codex roles; explicit host identity)
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@christang/keel",
3
- "version": "5.231.3",
3
+ "version": "5.231.4",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@christang/keel",
9
- "version": "5.231.3",
9
+ "version": "5.231.4",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@fission-ai/openspec": "1.14.0"
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@christang/keel",
3
3
  "displayName": "Keel",
4
4
  "description": "Keel OpenSpec execution discipline CLI for Claude Code, Codex, and OpenCode.",
5
- "version": "5.231.3",
5
+ "version": "5.231.4",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.231.3",
3
+ "version": "5.231.4",
4
4
  "description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
5
5
  "author": {
6
6
  "name": "TanglmChris",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keel",
3
- "version": "5.231.3",
3
+ "version": "5.231.4",
4
4
  "description": "Keel OpenSpec execution discipline: stateless continuity, task capsules, deterministic gates, and expectation alignment for Codex and Claude Code.",
5
5
  "author": {
6
6
  "name": "TanglmChris",
@@ -35,10 +35,10 @@ os.environ["KEEL_UPDATE_CLAUDE"] = str(Path(tempfile.gettempdir()) / "keel-suite
35
35
  os.environ["KEEL_UPDATE_CODEX"] = str(Path(tempfile.gettempdir()) / "keel-suite-has-no-codex")
36
36
 
37
37
 
38
- PACKAGE_VERSION = "5.231.3"
38
+ PACKAGE_VERSION = "5.231.4"
39
39
 
40
40
 
41
- PROTOCOL_VERSION = "5.231.3"
41
+ PROTOCOL_VERSION = "5.231.4"
42
42
 
43
43
 
44
44
  LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
@@ -535,6 +535,7 @@ SCENARIOS: tuple = (
535
535
  ("chat-direct-participants-json", chat.validate_chat_direct_participants_json_scenario),
536
536
  ("chat-wakes-without-no-wake", chat.validate_chat_wakes_without_no_wake_scenario),
537
537
  ("worktree-overview", shift.validate_worktree_overview_scenario),
538
+ ("project-local-worktree", shift.validate_project_local_worktree_scenario),
538
539
  ("sync-status-lists-local-only", sync.validate_sync_status_lists_local_only_scenario),
539
540
  ("sync-status-read-only-exit-codes", sync.validate_sync_status_read_only_exit_codes_scenario),
540
541
  ("sync-status-verify-classifies", sync.validate_sync_status_verify_classifies_scenario),
@@ -2371,6 +2371,70 @@ def validate_patrol_issue_label_set_unreadable_scenario() -> int:
2371
2371
  return 0
2372
2372
 
2373
2373
 
2374
+ def validate_project_local_worktree_scenario() -> int:
2375
+ """Create and reuse project-local Git worktrees through the public CLI."""
2376
+ with tempfile.TemporaryDirectory(prefix="keel-project-worktree-") as raw:
2377
+ root = Path(raw).resolve()
2378
+ env = os.environ.copy()
2379
+ env.pop("KEEL_CHAT_ROLE", None)
2380
+ env.pop("KEEL_MAIL_ROLE", None)
2381
+
2382
+ def git(cwd: Path, *args: str, check: bool = True):
2383
+ return subprocess.run(["git", *args], cwd=cwd, env=env, check=check,
2384
+ capture_output=True, text=True)
2385
+
2386
+ for project in ("project one", "project two"):
2387
+ repo = root / project / "repo"
2388
+ repo.mkdir(parents=True)
2389
+ git(repo, "init", "-qb", "main")
2390
+ git(repo, "-c", "user.name=Test", "-c", "user.email=test@example.invalid",
2391
+ "commit", "--allow-empty", "-qm", project)
2392
+ first = git(repo, "rev-parse", "HEAD").stdout.strip()
2393
+ git(repo, "-c", "user.name=Test", "-c", "user.email=test@example.invalid",
2394
+ "commit", "--allow-empty", "-qm", "second commit")
2395
+ head = git(repo, "rev-parse", "HEAD").stdout.strip()
2396
+ local = repo / "local-edit"
2397
+ local.write_text(project, encoding="utf-8")
2398
+ review = repo.parent / "worktrees" / "review"
2399
+ other = review.parent / "another"
2400
+
2401
+ def add(*args):
2402
+ return run_keel(root, "worktrees", "add", "--repo", str(repo), "--json", *args, env=env)
2403
+
2404
+ opened = add("--path", "../worktrees/review", "--branch", "codex/review")
2405
+ assert opened.returncode == 0, opened.stderr
2406
+ assert json.loads(opened.stdout) == {"path": str(review), "branch": "codex/review", "base": head}
2407
+ assert not (review / local.name).exists()
2408
+ bound = run_keel(review, "chat", "role", "--set", "review", env=env)
2409
+ assert bound.returncode == 0, bound.stderr
2410
+
2411
+ opened = add("--path", str(other), "--branch", "codex/another", "--base", first)
2412
+ assert opened.returncode == 0, opened.stderr
2413
+ assert json.loads(opened.stdout)["base"] == first
2414
+ assert git(other, "rev-parse", "HEAD").stdout.strip() == first
2415
+ listed = run_keel(repo, "worktrees", "--json", env=env)
2416
+ assert listed.returncode == 0, listed.stderr
2417
+ rows = {row["path"]: row for row in json.loads(listed.stdout)["worktrees"]}
2418
+ assert set(rows) == {str(repo), str(review), str(other)}, rows
2419
+ assert rows[str(review)]["role"] == "review"
2420
+
2421
+ edit = review / "uncommitted"
2422
+ edit.write_text("retain", encoding="utf-8")
2423
+ conflict = add("--path", str(review), "--branch", "codex/occupied")
2424
+ assert conflict.returncode != 0 and str(review) in conflict.stderr, conflict
2425
+ assert not git(repo, "branch", "--list", "codex/occupied").stdout.strip()
2426
+ conflict = add("--path", str(review.parent / "unused"), "--branch", "codex/review")
2427
+ assert conflict.returncode != 0 and "codex/review" in conflict.stderr, conflict
2428
+ assert not (review.parent / "unused").exists()
2429
+ assert git(repo, "worktree", "remove", str(review), check=False).returncode != 0
2430
+ assert edit.read_text(encoding="utf-8") == "retain"
2431
+ assert local.read_text(encoding="utf-8") == project
2432
+ git(repo, "worktree", "remove", str(other))
2433
+ assert git(repo, "rev-parse", "codex/another").stdout.strip() == first
2434
+ report("project-local-worktree scenario passed.")
2435
+ return 0
2436
+
2437
+
2374
2438
  def validate_worktree_overview_scenario() -> int:
2375
2439
  """Read every worktree through the CLI without fetching or changing chat."""
2376
2440
  label = "worktree-overview:"
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
 
3
- // Worktree-overview D1-D5: local Git and chat reads only. In particular,
4
- // status must not refresh the index, and role overrides belong to the caller,
5
- // not to every worktree it is inspecting.
3
+ // The overview only reads Git and chat state. Status must not refresh the
4
+ // index, and role overrides belong to the caller rather than every worktree.
6
5
  const fs = require("fs");
7
6
  const path = require("path");
8
7
  const { spawnSync } = require("child_process");
@@ -10,6 +9,7 @@ const store = require("./chat/store");
10
9
  const notice = require("./chat/notice");
11
10
 
12
11
  const USAGE = "keel worktrees [--repo <path>] [--issues <file>] [--json]";
12
+ const ADD_USAGE = "keel worktrees add [--repo <path>] --path <path> --branch <new-branch> [--base <ref>] [--json]";
13
13
  class WorktreesError extends Error {}
14
14
 
15
15
  function git(cwd, args, optional = false) {
@@ -146,25 +146,44 @@ function render(result) {
146
146
  return lines.join("\n");
147
147
  }
148
148
 
149
+ function addWorktree(where, options) {
150
+ if (!options.path || !options.branch) throw new WorktreesError(ADD_USAGE);
151
+ const target = path.resolve(where.worktree, options.path);
152
+ if (fs.lstatSync(target, { throwIfNoEntry: false })) {
153
+ throw new WorktreesError(`Worktree destination already exists: ${target}`);
154
+ }
155
+ const base = git(where.worktree, ["rev-parse", "--verify", "--end-of-options", `${options.base || "HEAD"}^{commit}`]);
156
+ git(where.worktree, ["worktree", "add", "-b", options.branch, "--", target, base]);
157
+ const created = fs.realpathSync(target);
158
+ process.stdout.write(options.json
159
+ ? JSON.stringify({ path: created, branch: options.branch, base }) + "\n"
160
+ : `Created worktree ${created} on ${options.branch} at ${base}\n`);
161
+ return 0;
162
+ }
163
+
149
164
  function runWorktrees(argv) {
165
+ const add = argv[0] === "add";
166
+ const optionNames = add ? ["--repo", "--path", "--branch", "--base"] : ["--repo", "--issues"];
150
167
  const options = { repo: process.cwd(), issues: null, json: false };
151
168
  try {
152
- for (let index = 0; index < argv.length; index += 1) {
169
+ for (let index = add ? 1 : 0; index < argv.length; index += 1) {
153
170
  const arg = argv[index];
154
171
  if (arg === "--json") options.json = true;
155
172
  else if (arg === "--help" || arg === "-h") {
156
- process.stdout.write(`${USAGE}\nIssue times come only from --issues (a JSON array with number and updatedAt).\n`);
173
+ process.stdout.write(add ? `${ADD_USAGE}\n`
174
+ : `${USAGE}\n${ADD_USAGE}\nIssue times come only from --issues (a JSON array with number and updatedAt).\n`);
157
175
  return 0;
158
- } else if (arg === "--repo" || arg === "--issues") {
176
+ } else if (optionNames.includes(arg)) {
159
177
  const value = argv[++index];
160
178
  if (!value || value.startsWith("--")) throw new WorktreesError(`${arg} needs a value.`);
161
- options[arg === "--repo" ? "repo" : "issues"] = value;
162
- } else throw new WorktreesError(`Unknown argument ${arg}. ${USAGE}`);
179
+ options[arg.slice(2)] = value;
180
+ } else throw new WorktreesError(`Unknown argument ${arg}. ${add ? ADD_USAGE : USAGE}`);
163
181
  }
164
182
  // Refuse a bad file before collecting or printing any repository state.
165
183
  const times = readIssues(options.issues);
166
184
  const where = store.locate(options.repo);
167
185
  if (!where) throw new WorktreesError(`Not a git repository: ${options.repo}`);
186
+ if (add) return addWorktree(where, options);
168
187
  const base = defaultBranch(where.worktree);
169
188
  const roles = store.readJsonFile(path.join(where.root, "roles.json"));
170
189
  const result = {