@christang/keel 5.231.3 → 5.231.5
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/.claude-plugin/plugin.json +1 -1
- package/README.md +1 -0
- package/README.zh-CN.md +1 -0
- package/assets/bootstrap/AGENTS.md +1 -1
- package/bin/keel.js +1 -0
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/plugins/keel/.claude-plugin/plugin.json +1 -1
- package/plugins/keel/.codex-plugin/plugin.json +1 -1
- package/scripts/validation/chat.py +46 -1
- package/scripts/validation/common.py +2 -2
- package/scripts/validation/registry.py +1 -0
- package/scripts/validation/shift.py +64 -0
- package/src/core/chat/cli.js +8 -2
- package/src/core/chat/store.js +6 -4
- package/src/core/worktrees.js +27 -8
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.231.
|
|
3
|
+
"version": "5.231.5",
|
|
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 能否不经询问就开工?
|
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)
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.231.
|
|
3
|
+
"version": "5.231.5",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@christang/keel",
|
|
9
|
-
"version": "5.231.
|
|
9
|
+
"version": "5.231.5",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@fission-ai/openspec": "1.14.0"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.231.
|
|
3
|
+
"version": "5.231.5",
|
|
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
|
+
"version": "5.231.5",
|
|
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",
|
|
@@ -1605,6 +1605,30 @@ def validate_chat_records_scenario() -> int:
|
|
|
1605
1605
|
if not todo_id:
|
|
1606
1606
|
report(f"{label} keel chat todo did not report an id: {todo.stdout.strip()} {todo.stderr.strip()}")
|
|
1607
1607
|
return 1
|
|
1608
|
+
chat(verify, "read", "soc")
|
|
1609
|
+
store = mailbox_common_dir(rtl) / "keel-chat"
|
|
1610
|
+
|
|
1611
|
+
def snapshot():
|
|
1612
|
+
return {
|
|
1613
|
+
file.relative_to(store): file.read_bytes()
|
|
1614
|
+
for directory in (store / "groups", store / "cursors")
|
|
1615
|
+
for file in directory.rglob("*") if file.is_file()
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
def show(record_id):
|
|
1619
|
+
result = chat(verify, "show", record_id, "--json")
|
|
1620
|
+
assert result.returncode == 0, result.stderr
|
|
1621
|
+
return chat_json(result)
|
|
1622
|
+
|
|
1623
|
+
before = snapshot()
|
|
1624
|
+
active = show(todo_id)
|
|
1625
|
+
assert active.get("task") == {
|
|
1626
|
+
"id": todo_id,
|
|
1627
|
+
"state": "open",
|
|
1628
|
+
"closureRecordId": None,
|
|
1629
|
+
}, "task view missing for open todo"
|
|
1630
|
+
assert active["record"]["id"] == todo_id and "readers" in active
|
|
1631
|
+
assert snapshot() == before, "open task query wrote to chat"
|
|
1608
1632
|
mine = chat_json(chat(verify, "todos", "--mine", "--json")).get("todos", [])
|
|
1609
1633
|
listed = [t for t in mine if t.get("id") == todo_id]
|
|
1610
1634
|
if not listed:
|
|
@@ -1621,8 +1645,20 @@ def validate_chat_records_scenario() -> int:
|
|
|
1621
1645
|
if todo_id in open_ids:
|
|
1622
1646
|
report(f"{label} a todo answered with ✅ is still listed: {open_ids!r}")
|
|
1623
1647
|
return 1
|
|
1648
|
+
before = snapshot()
|
|
1649
|
+
completed = show(todo_id)["task"]
|
|
1650
|
+
assert completed == {
|
|
1651
|
+
"id": todo_id,
|
|
1652
|
+
"state": "closed",
|
|
1653
|
+
"closureRecordId": completed["closureRecordId"],
|
|
1654
|
+
}
|
|
1655
|
+
receipt = show(completed["closureRecordId"])
|
|
1656
|
+
assert receipt["record"]["kind"] == "done" and receipt["record"]["target"] == todo_id
|
|
1657
|
+
assert "task" not in receipt
|
|
1658
|
+
assert show(todo_id)["task"] == completed
|
|
1659
|
+
assert snapshot() == before, "closed task query wrote to chat"
|
|
1624
1660
|
second_id = chat_json(chat(rtl, "todo", "soc", "--assignee", "verify", "Update the spec", "--json")).get("id", "")
|
|
1625
|
-
done = chat(verify, "done", second_id)
|
|
1661
|
+
done = chat(verify, "done", second_id, "--json")
|
|
1626
1662
|
if done.returncode != 0:
|
|
1627
1663
|
report(f"{label} keel chat done failed: {done.stderr.strip()}")
|
|
1628
1664
|
return 1
|
|
@@ -1630,9 +1666,12 @@ def validate_chat_records_scenario() -> int:
|
|
|
1630
1666
|
if second_id in open_ids:
|
|
1631
1667
|
report(f"{label} a todo closed with keel chat done is still listed: {open_ids!r}")
|
|
1632
1668
|
return 1
|
|
1669
|
+
explicit = {"id": second_id, "state": "closed", "closureRecordId": chat_json(done)["id"]}
|
|
1670
|
+
assert show(second_id)["task"] == explicit
|
|
1633
1671
|
|
|
1634
1672
|
message_id = chat_json(chat(rtl, "post", "soc", "Clock is 100MHz", "--json")).get("id", "")
|
|
1635
1673
|
message_file = chat_log(rtl, "soc") / f"{message_id}.md"
|
|
1674
|
+
assert "task" not in show(message_id)
|
|
1636
1675
|
original = message_file.read_bytes()
|
|
1637
1676
|
foreign = chat(verify, "edit", message_id, "Clock is 50MHz")
|
|
1638
1677
|
if foreign.returncode == 0:
|
|
@@ -1683,6 +1722,12 @@ def validate_chat_records_scenario() -> int:
|
|
|
1683
1722
|
if "06:00:00+00:00" in local.stdout:
|
|
1684
1723
|
report(f"{label} the view prints the raw stored stamp.")
|
|
1685
1724
|
return 1
|
|
1725
|
+
archived = chat(rtl, "group", "archive", "soc")
|
|
1726
|
+
assert archived.returncode == 0, archived.stderr
|
|
1727
|
+
before = snapshot()
|
|
1728
|
+
assert show(second_id)["task"] == explicit
|
|
1729
|
+
assert show(todo_id)["task"] == completed
|
|
1730
|
+
assert snapshot() == before, "archived task query wrote to chat"
|
|
1686
1731
|
|
|
1687
1732
|
if "chat-records" not in {name for name, _ in registry.SCENARIOS}:
|
|
1688
1733
|
report(f"{label} scenario is not registered.")
|
|
@@ -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.
|
|
38
|
+
PACKAGE_VERSION = "5.231.5"
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
PROTOCOL_VERSION = "5.231.
|
|
41
|
+
PROTOCOL_VERSION = "5.231.5"
|
|
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:"
|
package/src/core/chat/cli.js
CHANGED
|
@@ -493,8 +493,14 @@ function dispatch(where, options) {
|
|
|
493
493
|
if (!record) throw new ChatError(`No record ${id}.`);
|
|
494
494
|
const readers = store.readersOf(where, record);
|
|
495
495
|
const acks = record.ack === "requested" ? store.ackStatus(where, record) : null;
|
|
496
|
-
if (options.json)
|
|
497
|
-
|
|
496
|
+
if (options.json) {
|
|
497
|
+
const result = { record: publicRecord(record), readers, ...(acks ? { acks } : {}) };
|
|
498
|
+
if (record.kind === "todo") {
|
|
499
|
+
const closure = store.todoClosure(where, record);
|
|
500
|
+
result.task = { id: record.id, state: closure ? "closed" : "open", closureRecordId: closure ? closure.id : null };
|
|
501
|
+
}
|
|
502
|
+
out(JSON.stringify(result));
|
|
503
|
+
} else out([`${record.group} ${formatLine(record)}`, `read by: ${readers.join(", ") || "nobody yet"}`, ...(acks ? ackLines(acks) : [])].join("\n"));
|
|
498
504
|
return 0;
|
|
499
505
|
}
|
|
500
506
|
case "todo": {
|
package/src/core/chat/store.js
CHANGED
|
@@ -689,7 +689,7 @@ function post(where, options) {
|
|
|
689
689
|
text: text.replace(/\s+$/, ""),
|
|
690
690
|
});
|
|
691
691
|
// A reply that opens with `done` or ✅ closes the todo it answers (D6).
|
|
692
|
-
if (parent && parent.kind === "todo" && DONE_REPLY.test(text) && !
|
|
692
|
+
if (parent && parent.kind === "todo" && DONE_REPLY.test(text) && !todoClosure(where, parent)) {
|
|
693
693
|
writeRecord(where, { group, kind: "done", from, target: parent.id });
|
|
694
694
|
}
|
|
695
695
|
// Answering a record marks it read for the one who answered (#201): a woken
|
|
@@ -795,8 +795,9 @@ function supersededIds(records) {
|
|
|
795
795
|
return ids;
|
|
796
796
|
}
|
|
797
797
|
|
|
798
|
-
function
|
|
799
|
-
|
|
798
|
+
function todoClosure(where, todo) {
|
|
799
|
+
checkGroup(todo.group);
|
|
800
|
+
return readLog(where, todo.group).find((record) => record.kind === "done" && record.target === todo.id);
|
|
800
801
|
}
|
|
801
802
|
|
|
802
803
|
function normalizeIssue(issue) {
|
|
@@ -831,7 +832,7 @@ function targetFor(where, id, actor, kinds) {
|
|
|
831
832
|
function done(where, id) {
|
|
832
833
|
const from = requireRole(where);
|
|
833
834
|
const target = targetFor(where, id, from, ["todo"]);
|
|
834
|
-
if (
|
|
835
|
+
if (todoClosure(where, target)) throw new ChatError(`Todo ${id} is already done.`);
|
|
835
836
|
const record = writeRecord(where, { group: target.group, kind: "done", from, target: id });
|
|
836
837
|
advanceCursor(where, from, target.group, id);
|
|
837
838
|
return record;
|
|
@@ -1137,6 +1138,7 @@ module.exports = {
|
|
|
1137
1138
|
amend,
|
|
1138
1139
|
done,
|
|
1139
1140
|
openTodos,
|
|
1141
|
+
todoClosure,
|
|
1140
1142
|
search,
|
|
1141
1143
|
todo,
|
|
1142
1144
|
archiveGroup,
|
package/src/core/worktrees.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
//
|
|
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(`${
|
|
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
|
|
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
|
|
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 = {
|