@christang/keel 5.211.0 → 5.213.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.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +2 -1
- package/README.zh-CN.md +2 -1
- package/assets/bootstrap/AGENTS.md +1 -1
- package/bin/keel.js +1 -1
- 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/plugins/keel/scripts/pretooluse-guard.js +23 -4
- package/scripts/validation/common.py +2 -2
- package/scripts/validation/guard.py +59 -0
- package/scripts/validation/registry.py +2 -0
- package/scripts/validation/shift.py +60 -0
- package/src/core/chat/notice.js +13 -1
- package/src/core/guard.js +40 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.213.0",
|
|
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
|
@@ -209,7 +209,8 @@ The write guard is a disposable manifest, `keel/guard.json`. On Claude a passing
|
|
|
209
209
|
it (`--no-guard` opts out); `keel guard start` writes it explicitly and `keel guard clear` removes it.
|
|
210
210
|
It records the change and task, the capsule fingerprint, the normalized `Touch`, and hashes of the
|
|
211
211
|
authority files, and it fails closed: a manifest Keel cannot read refuses edits rather than allowing
|
|
212
|
-
them
|
|
212
|
+
them, and so does one whose change is gone, unless the change was archived with the guarded task
|
|
213
|
+
checked — that task has finished, and the manifest then enforces nothing (#491). The guard checks the file-editing tools. A write made by a `Bash` command is not checked,
|
|
213
214
|
except `git push` where a `push:` scope is declared.
|
|
214
215
|
|
|
215
216
|
### Standing authorization
|
package/README.zh-CN.md
CHANGED
|
@@ -178,7 +178,8 @@ Keel: add-user-auth#2.1 — next: task-start. Disposable projection; OpenSpec an
|
|
|
178
178
|
|
|
179
179
|
写入守卫是一份一次性 manifest:`keel/guard.json`。在 Claude 上,通过的 `task-start` 会写入它(`--no-guard` 退出);
|
|
180
180
|
`keel guard start` 显式写入,`keel guard clear` 删除。它记录 change 与 task、capsule 指纹、规范化后的 `Touch`
|
|
181
|
-
和权威文件的哈希,并且失败即关闭:Keel 读不了的 manifest
|
|
181
|
+
和权威文件的哈希,并且失败即关闭:Keel 读不了的 manifest 会拒绝编辑,而不是放行;它守的 change 不见了也一样拒绝,
|
|
182
|
+
除非那个 change 是在所守任务已勾选完成后归档的——那个任务已经结束,manifest 就不再拦任何写入(#491)。守卫检查文件编辑工具;
|
|
182
183
|
`Bash` 命令造成的写入不检查,只有声明了 `push:` 范围时会检查 `git push`。
|
|
183
184
|
|
|
184
185
|
### 常设授权
|
package/bin/keel.js
CHANGED
|
@@ -3111,7 +3111,7 @@ function runAction(options) {
|
|
|
3111
3111
|
process.stdout.write(
|
|
3112
3112
|
options.json ? `${JSON.stringify(result, null, 2)}\n` : renderGuard(result)
|
|
3113
3113
|
);
|
|
3114
|
-
return ["started", "active", "absent", "cleared"].includes(result.status)
|
|
3114
|
+
return ["started", "active", "absent", "cleared", "archived"].includes(result.status)
|
|
3115
3115
|
? 0
|
|
3116
3116
|
: 3;
|
|
3117
3117
|
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.213.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@christang/keel",
|
|
9
|
-
"version": "5.
|
|
9
|
+
"version": "5.213.0",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@fission-ai/openspec": "^1.4.1"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.213.0",
|
|
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.
|
|
3
|
+
"version": "5.213.0",
|
|
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",
|
|
@@ -120,9 +120,9 @@ function pathAllowed(candidate, touch) {
|
|
|
120
120
|
// tasks.md; now it is stated. An unreadable or unmatched tasks.md is not read as
|
|
121
121
|
// checked — every gate that compiles the capsule catches that, and denying
|
|
122
122
|
// product writes on a parse miss would trade a real capability for a guess.
|
|
123
|
-
function taskIsChecked(repo, manifest) {
|
|
123
|
+
function taskIsChecked(repo, manifest, changeDir = null) {
|
|
124
124
|
const file = path.join(
|
|
125
|
-
repo, "openspec", "changes", manifest.change, "tasks.md"
|
|
125
|
+
changeDir || path.join(repo, "openspec", "changes", manifest.change), "tasks.md"
|
|
126
126
|
);
|
|
127
127
|
let content = "";
|
|
128
128
|
try {
|
|
@@ -137,6 +137,21 @@ function taskIsChecked(repo, manifest) {
|
|
|
137
137
|
return Boolean(match && match[1].toLowerCase() === "x");
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
+
// The archived copy `openspec archive` moved the change to, the lexically last
|
|
141
|
+
// `<YYYY-MM-DD>-<change>` under openspec/changes/archive/, or null (#491 D1).
|
|
142
|
+
// `src/core/guard.js` makes the same test for `keel guard status`.
|
|
143
|
+
function archivedChangeDir(repo, change) {
|
|
144
|
+
const root = path.join(repo, "openspec", "changes", "archive");
|
|
145
|
+
let names = [];
|
|
146
|
+
try {
|
|
147
|
+
names = fs.readdirSync(root);
|
|
148
|
+
} catch {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
const own = names.filter((name) => /^\d{4}-\d{2}-\d{2}-/.test(name) && name.slice(11) === change).sort();
|
|
152
|
+
return own.length ? path.join(root, own[own.length - 1]) : null;
|
|
153
|
+
}
|
|
154
|
+
|
|
140
155
|
// A path is not the file it names. `path.resolve` never follows a symbolic
|
|
141
156
|
// link, while the `cwd` the operating system reports usually already has, so
|
|
142
157
|
// one file could be spelled two ways and get two containment answers: measured
|
|
@@ -713,10 +728,14 @@ function main() {
|
|
|
713
728
|
// the stale Touch was denied by a message naming a task in an archived change
|
|
714
729
|
// and telling the reader to reauthorize it, which cannot be done; a write
|
|
715
730
|
// *inside* it passed silently, so an archived task went on granting write
|
|
716
|
-
// authority. Denying here fixes both, and denying
|
|
717
|
-
// what stops `openspec archive` from quietly disabling the
|
|
731
|
+
// authority. Denying here fixes both, and denying an archived task that was
|
|
732
|
+
// never checked is what stops `openspec archive` from quietly disabling the
|
|
733
|
+
// guard. A task archived checked has finished: the manifest then guards
|
|
734
|
+
// nothing, as if it were absent (#491).
|
|
718
735
|
const changeDir = path.join(repo, "openspec", "changes", manifest.change);
|
|
719
736
|
if (!fs.existsSync(changeDir)) {
|
|
737
|
+
const archived = archivedChangeDir(repo, manifest.change);
|
|
738
|
+
if (archived && taskIsChecked(repo, manifest, archived)) return 0;
|
|
720
739
|
deny(
|
|
721
740
|
`Keel write guard: this manifest is stale — it guards ${pointer}, but `
|
|
722
741
|
+ `openspec/changes/${manifest.change} no longer exists, so the task it `
|
|
@@ -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.
|
|
38
|
+
PACKAGE_VERSION = "5.213.0"
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
PROTOCOL_VERSION = "5.
|
|
41
|
+
PROTOCOL_VERSION = "5.213.0"
|
|
42
42
|
|
|
43
43
|
|
|
44
44
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
|
@@ -4891,6 +4891,65 @@ def guard_status_payload(repo: Path, cell: str) -> tuple[dict, str]:
|
|
|
4891
4891
|
return payload, (problems[0].get("message", "") if problems else "")
|
|
4892
4892
|
|
|
4893
4893
|
|
|
4894
|
+
def validate_guard_archived_complete_task_scenario() -> int:
|
|
4895
|
+
"""Issue #491: a manifest over a task checked and then archived enforces nothing.
|
|
4896
|
+
|
|
4897
|
+
In ChipSTRIDE under auto mode, the write after an authorized archive — the
|
|
4898
|
+
next change's proposal — was refused as a stale manifest, and the
|
|
4899
|
+
permission classifier refused `keel guard clear`, so every change after the
|
|
4900
|
+
first needed a person. A task archived checked has finished; the guard
|
|
4901
|
+
stands down, while an archived unchecked task still fails closed.
|
|
4902
|
+
"""
|
|
4903
|
+
label = "guard-archived-complete-task:"
|
|
4904
|
+
with tempfile.TemporaryDirectory(prefix="keel-guard-491-", ignore_cleanup_errors=True) as raw_tmp:
|
|
4905
|
+
repo = Path(raw_tmp) / "repo"
|
|
4906
|
+
repo.mkdir()
|
|
4907
|
+
change_dir = repo / "openspec/changes/demo"
|
|
4908
|
+
write_text(change_dir / "tasks.md", guard_task_fixture())
|
|
4909
|
+
write_text(repo / "src/feature.js", "// fixture\n")
|
|
4910
|
+
started = run_keel(repo, "guard", "start", "--change", "demo", "--task", "1.1", "--json")
|
|
4911
|
+
if started.returncode != 0:
|
|
4912
|
+
report(f"{label} guard start failed: {(started.stderr or started.stdout).strip()}")
|
|
4913
|
+
return 1
|
|
4914
|
+
write_text(change_dir / "tasks.md", guard_task_fixture(checked=True))
|
|
4915
|
+
archived_dir = repo / "openspec/changes/archive/2026-10-27-demo"
|
|
4916
|
+
archived_dir.parent.mkdir(parents=True, exist_ok=True)
|
|
4917
|
+
shutil.move(str(change_dir), str(archived_dir))
|
|
4918
|
+
for what, target, tool in (
|
|
4919
|
+
("an edit of a product file", repo / "src/feature.js", "Edit"),
|
|
4920
|
+
("the next change's proposal", repo / "openspec/changes/next/proposal.md", "Write"),
|
|
4921
|
+
):
|
|
4922
|
+
decision = pretooluse_decision(run_pretooluse_guard_hook(repo, edit_event(repo, target, tool)))
|
|
4923
|
+
if decision is not None:
|
|
4924
|
+
report(f"{label} {what} got a decision from a manifest over an archived, checked task: {decision!r}")
|
|
4925
|
+
return 1
|
|
4926
|
+
status = run_keel(repo, "guard", "status", "--json")
|
|
4927
|
+
if status.returncode != 0:
|
|
4928
|
+
report(f"{label} keel guard status exited {status.returncode}: {status.stdout!r} {status.stderr!r}")
|
|
4929
|
+
return 1
|
|
4930
|
+
try:
|
|
4931
|
+
result = json.loads(status.stdout)
|
|
4932
|
+
except json.JSONDecodeError:
|
|
4933
|
+
report(f"{label} keel guard status --json printed no JSON: {status.stdout!r}")
|
|
4934
|
+
return 1
|
|
4935
|
+
if result.get("status") != "archived":
|
|
4936
|
+
report(f"{label} keel guard status reports {result.get('status')!r}, not 'archived'.")
|
|
4937
|
+
return 1
|
|
4938
|
+
problem = next((p for p in result.get("problems", []) if p.get("code") == "task-archived"), None)
|
|
4939
|
+
if problem is None:
|
|
4940
|
+
report(f"{label} keel guard status carries no task-archived problem: {result.get('problems')!r}")
|
|
4941
|
+
return 1
|
|
4942
|
+
for needle in ("openspec/changes/archive/2026-10-27-demo", "keel guard clear"):
|
|
4943
|
+
if needle not in problem.get("message", ""):
|
|
4944
|
+
report(f"{label} the task-archived message does not name {needle!r}: {problem!r}")
|
|
4945
|
+
return 1
|
|
4946
|
+
if label.rstrip(":") not in {name for name, _ in registry.SCENARIOS}:
|
|
4947
|
+
report(f"{label} the scenario registry does not include it.")
|
|
4948
|
+
return 1
|
|
4949
|
+
report(f"{label.rstrip(':')} scenario passed.")
|
|
4950
|
+
return 0
|
|
4951
|
+
|
|
4952
|
+
|
|
4894
4953
|
def validate_guard_status_stale_manifest_scenario() -> int:
|
|
4895
4954
|
"""`keel guard status` says which of two states the manifest is in.
|
|
4896
4955
|
|
|
@@ -363,6 +363,7 @@ SCENARIOS: tuple = (
|
|
|
363
363
|
("tracker-durable-owner", contract.validate_tracker_durable_owner_scenario),
|
|
364
364
|
("findings-resolved-here", contract.validate_findings_resolved_here_scenario),
|
|
365
365
|
("guard-stale-manifest", guard.validate_guard_stale_manifest_scenario),
|
|
366
|
+
("guard-archived-complete-task", guard.validate_guard_archived_complete_task_scenario),
|
|
366
367
|
(
|
|
367
368
|
"guard-status-stale-manifest",
|
|
368
369
|
guard.validate_guard_status_stale_manifest_scenario,
|
|
@@ -458,6 +459,7 @@ SCENARIOS: tuple = (
|
|
|
458
459
|
("chat-supersedes", chat.validate_chat_supersedes_scenario),
|
|
459
460
|
("chat-mention-skips-code", chat.validate_chat_mention_skips_code_scenario),
|
|
460
461
|
("two-live-sessions-on-one-role", shift.validate_two_live_sessions_on_one_role_scenario),
|
|
462
|
+
("moved-session-is-not-a-twin", shift.validate_moved_session_is_not_a_twin_scenario),
|
|
461
463
|
("chat-role-rename", chat.validate_chat_role_rename_scenario),
|
|
462
464
|
("chat-wake-now-cli", chat.validate_chat_wake_now_cli_scenario),
|
|
463
465
|
("chat-hook-follows-session-worktree", chat.validate_chat_hook_follows_session_worktree_scenario),
|
|
@@ -112,6 +112,66 @@ def validate_two_live_sessions_on_one_role_scenario() -> int:
|
|
|
112
112
|
return 0
|
|
113
113
|
|
|
114
114
|
|
|
115
|
+
def validate_moved_session_is_not_a_twin_scenario() -> int:
|
|
116
|
+
"""Issue #490: a session that bound another role is not a twin of the first.
|
|
117
|
+
|
|
118
|
+
In ChipSTRIDE three sessions started in the main checkout, bound to
|
|
119
|
+
`chipstride`; two then entered their own worktrees and ran `keel chat role
|
|
120
|
+
--set`. `chipstride.sessions.json` kept all three, so every command warned
|
|
121
|
+
of three live `chipstride` sessions when there was one.
|
|
122
|
+
"""
|
|
123
|
+
label = "moved-session-is-not-a-twin:"
|
|
124
|
+
with tempfile.TemporaryDirectory(prefix="keel-twins-490-") as raw:
|
|
125
|
+
base = Path(raw)
|
|
126
|
+
rtl, verify, env, _ = shift_scratch(base)
|
|
127
|
+
write_text(verify / "openspec/specs/.keep", "")
|
|
128
|
+
fe = base / "fe"
|
|
129
|
+
subprocess.run(["git", "worktree", "add", "-q", "-b", "fe", str(fe)], cwd=rtl, check=True, capture_output=True)
|
|
130
|
+
# Each session's transcript starts in the worktree it started in;
|
|
131
|
+
# `EnterWorktree` later gives sess-b one in fe as well.
|
|
132
|
+
config = base / "claude-config"
|
|
133
|
+
for sid in ("sess-a", "sess-b"):
|
|
134
|
+
write_text(config / "projects" / host_project_name(verify) / f"{sid}.jsonl", "{}\n")
|
|
135
|
+
other = subprocess.Popen(["sleep", "300"])
|
|
136
|
+
try:
|
|
137
|
+
def as_session(sid: str, pid: int) -> dict:
|
|
138
|
+
return {**env, "CLAUDE_CODE_ENTRYPOINT": "cli", "CLAUDE_CODE_SESSION_ID": sid, "CLAUDE_PID": str(pid),
|
|
139
|
+
"CLAUDE_CONFIG_DIR": str(config)}
|
|
140
|
+
|
|
141
|
+
for sid, pid in (("sess-a", os.getpid()), ("sess-b", other.pid)):
|
|
142
|
+
subprocess.run(["node", str(ROOT / "bin" / "keel.js"), "chat", "hook", "session-start"], cwd=verify,
|
|
143
|
+
env=as_session(sid, pid), text=True, capture_output=True, check=False,
|
|
144
|
+
input=json.dumps({"cwd": str(verify), "hook_event_name": "SessionStart", "session_id": sid, "source": "startup"}))
|
|
145
|
+
before = json.loads(run_keel(verify, "context", "--json", env=as_session("sess-a", os.getpid())).stdout)
|
|
146
|
+
if not any("live sessions" in w for w in before.get("warnings", [])):
|
|
147
|
+
report(f"{label} the fixture does not list two live verify sessions before sess-b moves: {before.get('warnings')!r}")
|
|
148
|
+
return 1
|
|
149
|
+
write_text(config / "projects" / host_project_name(fe) / "sess-b.jsonl", "{}\n")
|
|
150
|
+
moved = run_keel(fe, "chat", "role", "--set", "fe", env=as_session("sess-b", other.pid))
|
|
151
|
+
if moved.returncode != 0:
|
|
152
|
+
report(f"{label} keel chat role --set fe exited {moved.returncode}: {moved.stderr!r}")
|
|
153
|
+
return 1
|
|
154
|
+
if "Recorded this session" not in moved.stdout:
|
|
155
|
+
report(f"{label} sess-b's --set fe did not record it as fe's session: {moved.stdout!r}")
|
|
156
|
+
return 1
|
|
157
|
+
context = json.loads(run_keel(verify, "context", "--json", env=as_session("sess-a", os.getpid())).stdout)
|
|
158
|
+
twins = [w for w in context.get("warnings", []) if "live sessions" in w]
|
|
159
|
+
if twins:
|
|
160
|
+
report(f"{label} sess-b, now fe's, is still reported as a second verify session: {twins!r}")
|
|
161
|
+
return 1
|
|
162
|
+
if other.poll() is not None:
|
|
163
|
+
report(f"{label} sess-b's process ended before the check, so it proves nothing.")
|
|
164
|
+
return 1
|
|
165
|
+
finally:
|
|
166
|
+
if other.poll() is None:
|
|
167
|
+
other.kill()
|
|
168
|
+
if label.rstrip(":") not in {name for name, _ in registry.SCENARIOS}:
|
|
169
|
+
report(f"{label} the scenario registry does not include it.")
|
|
170
|
+
return 1
|
|
171
|
+
report(f"{label.rstrip(':')} scenario passed.")
|
|
172
|
+
return 0
|
|
173
|
+
|
|
174
|
+
|
|
115
175
|
def validate_patrol_rearm_scenario() -> int:
|
|
116
176
|
"""Issue #260: the patrolling role is reminded to re-arm its schedule.
|
|
117
177
|
|
package/src/core/chat/notice.js
CHANGED
|
@@ -154,9 +154,21 @@ function touchSession(where, role, state) {
|
|
|
154
154
|
store.writeJsonAtomic(where, file, sessions);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
// Whether a listed session is still the role's: one whose own record names
|
|
158
|
+
// another role has bound that one since, and is no twin here (#490 D1). With
|
|
159
|
+
// no record it cannot be told from a twin, so it counts (D2).
|
|
160
|
+
function sessionStillRole(where, role, id) {
|
|
161
|
+
if (!/^[A-Za-z0-9._-]{1,128}$/.test(id)) return true;
|
|
162
|
+
const file = path.join(where.root, "sessions", `${id}.json`);
|
|
163
|
+
if (!fs.existsSync(file)) return true;
|
|
164
|
+
const recorded = store.readJsonFile(file).role;
|
|
165
|
+
return !recorded || recorded === role;
|
|
166
|
+
}
|
|
167
|
+
|
|
157
168
|
// The warning for two or more live sessions on a role (D3), or null.
|
|
158
169
|
function twinWarning(where, role, now = Date.now()) {
|
|
159
|
-
const live = Object.entries(store.readJsonFile(sessionsFile(where, role)))
|
|
170
|
+
const live = Object.entries(store.readJsonFile(sessionsFile(where, role)))
|
|
171
|
+
.filter(([id, entry]) => sessionLive(entry, now) && sessionStillRole(where, role, id));
|
|
160
172
|
if (live.length < 2) return null;
|
|
161
173
|
const named = live.map(([id, entry]) => `${id} (pid ${entry.pid || "unknown"}, ${entry.worktree || "unknown worktree"})`).join(", ");
|
|
162
174
|
return `${live.length} live sessions are bound to role ${role}: ${named}. They post under one name and share one read cursor, `
|
package/src/core/guard.js
CHANGED
|
@@ -283,6 +283,31 @@ function startGuard(repo, options) {
|
|
|
283
283
|
return guardResult("start", "started", { manifest });
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
+
// The archived copy of a change, the lexically last `<YYYY-MM-DD>-<change>`
|
|
287
|
+
// under openspec/changes/archive/, when its tasks.md shows the task checked;
|
|
288
|
+
// otherwise null. The write guard hook makes the same test (#491 D1).
|
|
289
|
+
function archivedCheckedChange(repo, change, task) {
|
|
290
|
+
const root = path.join(repo, "openspec", "changes", "archive");
|
|
291
|
+
let names = [];
|
|
292
|
+
try {
|
|
293
|
+
names = fs.readdirSync(root);
|
|
294
|
+
} catch {
|
|
295
|
+
return null;
|
|
296
|
+
}
|
|
297
|
+
const own = names.filter((name) => /^\d{4}-\d{2}-\d{2}-/.test(name) && name.slice(11) === change).sort();
|
|
298
|
+
if (!own.length) return null;
|
|
299
|
+
const dir = path.join(root, own[own.length - 1]);
|
|
300
|
+
let content = "";
|
|
301
|
+
try {
|
|
302
|
+
content = fs.readFileSync(path.join(dir, "tasks.md"), "utf8");
|
|
303
|
+
} catch {
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
const id = task.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
307
|
+
const match = content.match(new RegExp(`^\\s*-\\s*\\[([ xX])\\]\\s*${id}(?![0-9.])`, "m"));
|
|
308
|
+
return match && match[1].toLowerCase() === "x" ? path.relative(repo, dir).split(path.sep).join("/") : null;
|
|
309
|
+
}
|
|
310
|
+
|
|
286
311
|
function guardStatus(repo) {
|
|
287
312
|
const existing = readManifest(repo);
|
|
288
313
|
if (existing.state === "absent") {
|
|
@@ -312,6 +337,21 @@ function guardStatus(repo) {
|
|
|
312
337
|
// also leaves a live change whose tasks.md is absent — mid-authoring — on
|
|
313
338
|
// the reauthorize path, where reauthorizing genuinely is the way out.
|
|
314
339
|
const changeDir = path.join(repo, "openspec", "changes", manifest.change);
|
|
340
|
+
const archived = fs.existsSync(changeDir) ? null : archivedCheckedChange(repo, manifest.change, manifest.task);
|
|
341
|
+
if (archived) {
|
|
342
|
+
const finished = guardResult("status", "archived", { manifest });
|
|
343
|
+
finished.problems = [
|
|
344
|
+
{
|
|
345
|
+
code: "task-archived",
|
|
346
|
+
message:
|
|
347
|
+
`Guarded task ${manifest.change}#${manifest.task} is checked complete `
|
|
348
|
+
+ `and its change is archived at ${archived}, so this manifest `
|
|
349
|
+
+ "enforces nothing. `keel guard clear` removes it, and the next "
|
|
350
|
+
+ "`keel gate task-start` replaces it.",
|
|
351
|
+
},
|
|
352
|
+
];
|
|
353
|
+
return finished;
|
|
354
|
+
}
|
|
315
355
|
problems.push(
|
|
316
356
|
fs.existsSync(changeDir)
|
|
317
357
|
? {
|