@christang/keel 5.123.0 → 5.124.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/README.md +1 -1
- package/assets/bootstrap/AGENTS.md +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/mail-hook.js +1 -1
- package/scripts/validate_plugin.py +60 -2
- package/src/core/chat/notice.js +54 -0
package/README.md
CHANGED
|
@@ -847,7 +847,7 @@ session, so it neither marks the role offline nor fires a `keel shift ready --wa
|
|
|
847
847
|
|
|
848
848
|
## The owner's language
|
|
849
849
|
|
|
850
|
-
An agent reads mostly English — tool output, issues, specs, Keel's own output — and drifts into it when it answers you. Declare the language you want to be addressed in, and the rule is restated where replies are written: in `keel context`, the session-start note, and the chat hook on every prompt, in every worktree (#305). The agent may still work in any language; identifiers, commands, paths, and quoted output stay as they are.
|
|
850
|
+
An agent reads mostly English — tool output, issues, specs, Keel's own output — and drifts into it when it answers you. Declare the language you want to be addressed in, and the rule is restated where replies are written: in `keel context`, the session-start note, and the chat hook on every prompt, in every worktree (#305) — and, on Claude, after every 15 tool calls or 10 minutes of them, since a status update written mid-turn follows no prompt (#311). The agent may still work in any language; identifiers, commands, paths, and quoted output stay as they are.
|
|
851
851
|
|
|
852
852
|
```yaml
|
|
853
853
|
owner_language: zh
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@christang/keel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.124.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.124.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.124.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.124.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",
|
|
@@ -28,7 +28,7 @@ try {
|
|
|
28
28
|
// Copied on its own: no hand-off.
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
const EVENTS = new Set(["session-start", "user-prompt-submit", "file-changed", "session-end"]);
|
|
31
|
+
const EVENTS = new Set(["session-start", "user-prompt-submit", "post-tool-use", "file-changed", "session-end"]);
|
|
32
32
|
const TIMEOUT_MS = Number(process.env.KEEL_HOOK_TIMEOUT_MS || 8000) || 8000;
|
|
33
33
|
|
|
34
34
|
function readStdin() {
|
|
@@ -47,8 +47,8 @@ REQUIRED_SCRIPTS = [
|
|
|
47
47
|
"scripts/validate_plugin.py",
|
|
48
48
|
]
|
|
49
49
|
|
|
50
|
-
PACKAGE_VERSION = "5.
|
|
51
|
-
PROTOCOL_VERSION = "5.
|
|
50
|
+
PACKAGE_VERSION = "5.124.0"
|
|
51
|
+
PROTOCOL_VERSION = "5.124.0"
|
|
52
52
|
LEGACY_MANAGED_START = "<!-- keel:start version=2.1 -->"
|
|
53
53
|
OPENSPEC_SCHEMA_NAME = "keel-spec-driven"
|
|
54
54
|
# Mirrors KEEL_PACKAGE_NAME in scripts/install_to_repo.py, one of the two
|
|
@@ -6405,6 +6405,62 @@ def validate_owner_language_scenario() -> int:
|
|
|
6405
6405
|
return 0
|
|
6406
6406
|
|
|
6407
6407
|
|
|
6408
|
+
def validate_owner_language_after_tools_scenario() -> int:
|
|
6409
|
+
"""Issue #311: the owner's language is restated after runs of tool calls."""
|
|
6410
|
+
label = "owner-language-after-tools:"
|
|
6411
|
+
manifest = json.loads((ROOT / ".claude-plugin" / "plugin.json").read_text(encoding="utf-8"))
|
|
6412
|
+
post = json.dumps(manifest.get("hooks", {}).get("PostToolUse", []))
|
|
6413
|
+
if "mail-hook.js" not in post or "post-tool-use" not in post:
|
|
6414
|
+
report(f"{label} .claude-plugin/plugin.json does not register PostToolUse on mail-hook.js post-tool-use: {post}")
|
|
6415
|
+
return 1
|
|
6416
|
+
with tempfile.TemporaryDirectory(prefix="keel-language-tools-") as raw:
|
|
6417
|
+
base = Path(raw)
|
|
6418
|
+
rtl, _verify, env = chat_scratch_group(base)
|
|
6419
|
+
env = {**env, "KEEL_CLI": f'node "{ROOT / "bin" / "keel.js"}"'}
|
|
6420
|
+
write_authorize_config(rtl, "owner_language: zh\n")
|
|
6421
|
+
|
|
6422
|
+
def hook(event: str, payload: dict) -> str:
|
|
6423
|
+
result = subprocess.run(
|
|
6424
|
+
["node", str(ROOT / PLUGIN_ROOT / "scripts/mail-hook.js"), event],
|
|
6425
|
+
cwd=rtl, env=env, text=True, capture_output=True, check=False,
|
|
6426
|
+
input=json.dumps({"cwd": str(rtl), **payload}),
|
|
6427
|
+
)
|
|
6428
|
+
if not result.stdout.strip():
|
|
6429
|
+
return ""
|
|
6430
|
+
return json.loads(result.stdout).get("hookSpecificOutput", {}).get("additionalContext", "")
|
|
6431
|
+
|
|
6432
|
+
def tool(session: str) -> str:
|
|
6433
|
+
return hook("post-tool-use", {"hook_event_name": "PostToolUse", "session_id": session, "tool_name": "Bash"})
|
|
6434
|
+
|
|
6435
|
+
hook("user-prompt-submit", {"hook_event_name": "UserPromptSubmit", "session_id": "t1", "prompt": "go on"})
|
|
6436
|
+
outputs = [tool("t1") for _ in range(16)]
|
|
6437
|
+
early = [n + 1 for n, text in enumerate(outputs[:14]) if text]
|
|
6438
|
+
if early:
|
|
6439
|
+
report(f"{label} PostToolUse calls {early} restated the rule before the 15th.")
|
|
6440
|
+
return 1
|
|
6441
|
+
if "中文" not in outputs[14]:
|
|
6442
|
+
report(f"{label} the 15th PostToolUse did not restate the rule: {outputs[14]!r}")
|
|
6443
|
+
return 1
|
|
6444
|
+
if outputs[15]:
|
|
6445
|
+
report(f"{label} the 16th PostToolUse restated the rule again: {outputs[15]!r}")
|
|
6446
|
+
return 1
|
|
6447
|
+
hook("user-prompt-submit", {"hook_event_name": "UserPromptSubmit", "session_id": "t1", "prompt": "next"})
|
|
6448
|
+
if tool("t1"):
|
|
6449
|
+
report(f"{label} the first tool call after a prompt restated the rule.")
|
|
6450
|
+
return 1
|
|
6451
|
+
hook("session-start", {"hook_event_name": "SessionStart", "source": "startup", "session_id": "run1"})
|
|
6452
|
+
hook("user-prompt-submit", {"hook_event_name": "UserPromptSubmit", "session_id": "run1", "prompt": '<scheduled-task name="patrol">run'})
|
|
6453
|
+
if any(tool("run1") for _ in range(16)):
|
|
6454
|
+
report(f"{label} a host-run session was reminded.")
|
|
6455
|
+
return 1
|
|
6456
|
+
write_authorize_config(rtl, "")
|
|
6457
|
+
if any(tool("t2") for _ in range(16)):
|
|
6458
|
+
report(f"{label} a repository without owner_language was reminded.")
|
|
6459
|
+
return 1
|
|
6460
|
+
report("owner-language-after-tools scenario passed.")
|
|
6461
|
+
return 0
|
|
6462
|
+
|
|
6463
|
+
|
|
6408
6464
|
def validate_shift_coordinator_last_scenario() -> int:
|
|
6409
6465
|
"""Issue #289: the coordinator starts the others before its own shift ends.
|
|
6410
6466
|
|
|
@@ -21107,6 +21163,7 @@ def validate_native_plugin_manifests_scenario() -> int:
|
|
|
21107
21163
|
{"hooks": [mail_hook("session-start")]},
|
|
21108
21164
|
]
|
|
21109
21165
|
expected_hooks["UserPromptSubmit"] = [{"hooks": [mail_hook("user-prompt-submit")]}]
|
|
21166
|
+
expected_hooks["PostToolUse"] = [{"hooks": [mail_hook("post-tool-use")]}]
|
|
21110
21167
|
expected_hooks["FileChanged"] = [
|
|
21111
21168
|
{"hooks": [mail_hook("file-changed", asyncRewake=True)]}
|
|
21112
21169
|
]
|
|
@@ -40085,6 +40142,7 @@ SCENARIOS: tuple = (
|
|
|
40085
40142
|
("shift-self", validate_shift_self_scenario),
|
|
40086
40143
|
("shift-self-wake", validate_shift_self_wake_scenario),
|
|
40087
40144
|
("owner-language", validate_owner_language_scenario),
|
|
40145
|
+
("owner-language-after-tools", validate_owner_language_after_tools_scenario),
|
|
40088
40146
|
("shift-history", validate_shift_history_scenario),
|
|
40089
40147
|
("role-drift", validate_role_drift_scenario),
|
|
40090
40148
|
("host-run-session", validate_host_run_session_scenario),
|
package/src/core/chat/notice.js
CHANGED
|
@@ -161,6 +161,7 @@ const OWNER_RULE = "Slack notifies the owner only for messages that write `@owne
|
|
|
161
161
|
const HOST_EVENTS = {
|
|
162
162
|
"session-start": "SessionStart",
|
|
163
163
|
"user-prompt-submit": "UserPromptSubmit",
|
|
164
|
+
"post-tool-use": "PostToolUse",
|
|
164
165
|
"file-changed": "FileChanged",
|
|
165
166
|
"session-end": "SessionEnd",
|
|
166
167
|
};
|
|
@@ -237,6 +238,55 @@ function decideSession(where, file, session, prompt) {
|
|
|
237
238
|
return hostRun;
|
|
238
239
|
}
|
|
239
240
|
|
|
241
|
+
// --- the owner's language after tool calls (#311) ---------------------------------------
|
|
242
|
+
|
|
243
|
+
function languageFile(where, payload) {
|
|
244
|
+
const file = sessionFile(where, payload);
|
|
245
|
+
return file ? file.replace(/\.json$/, ".language.json") : null;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function resetLanguageCount(where, payload) {
|
|
249
|
+
const file = languageFile(where, payload);
|
|
250
|
+
if (!file) return;
|
|
251
|
+
try {
|
|
252
|
+
store.writeJsonAtomic(where, file, { count: 0, at: Date.now() });
|
|
253
|
+
} catch {
|
|
254
|
+
// A convenience: never fail the hook.
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Once 15 tool calls or 10 minutes have passed since the rule was last stated
|
|
259
|
+
// in this session, it is stated again (D2); a host run gets nothing (D4).
|
|
260
|
+
function languageAfterTools(where, payload) {
|
|
261
|
+
const file = languageFile(where, payload);
|
|
262
|
+
if (!file) return { code: 0 };
|
|
263
|
+
try {
|
|
264
|
+
const session = sessionFile(where, payload);
|
|
265
|
+
if (fs.existsSync(session) && store.readJsonFile(session).host_run) return { code: 0 };
|
|
266
|
+
const { readOwnerLanguage, ownerLanguageRule } = require("../config");
|
|
267
|
+
const language = readOwnerLanguage(where.worktree);
|
|
268
|
+
if (!language.tag) return { code: 0 };
|
|
269
|
+
const everyTools = Number(process.env.KEEL_LANGUAGE_EVERY_TOOLS) > 0 ? Number(process.env.KEEL_LANGUAGE_EVERY_TOOLS) : 15;
|
|
270
|
+
const everyMs = Number(process.env.KEEL_LANGUAGE_EVERY_MS) > 0 ? Number(process.env.KEEL_LANGUAGE_EVERY_MS) : 10 * 60 * 1000;
|
|
271
|
+
const now = Date.now();
|
|
272
|
+
const record = fs.existsSync(file) ? store.readJsonFile(file) : null;
|
|
273
|
+
if (!record || typeof record.count !== "number") {
|
|
274
|
+
store.writeJsonAtomic(where, file, { count: 1, at: now });
|
|
275
|
+
return { code: 0 };
|
|
276
|
+
}
|
|
277
|
+
const count = record.count + 1;
|
|
278
|
+
if (count >= everyTools || now - Number(record.at || 0) >= everyMs) {
|
|
279
|
+
store.writeJsonAtomic(where, file, { count: 0, at: now });
|
|
280
|
+
const output = { hookSpecificOutput: { hookEventName: "PostToolUse", additionalContext: ownerLanguageRule(language.tag) } };
|
|
281
|
+
return { code: 0, stdout: `${JSON.stringify(output)}\n` };
|
|
282
|
+
}
|
|
283
|
+
store.writeJsonAtomic(where, file, { count, at: record.at });
|
|
284
|
+
} catch {
|
|
285
|
+
// Never fail a tool call over a reminder.
|
|
286
|
+
}
|
|
287
|
+
return { code: 0 };
|
|
288
|
+
}
|
|
289
|
+
|
|
240
290
|
function hook(event, input, { mail = false } = {}) {
|
|
241
291
|
if (!(event in HOST_EVENTS)) return { code: 0 };
|
|
242
292
|
let payload = {};
|
|
@@ -256,6 +306,8 @@ function hook(event, input, { mail = false } = {}) {
|
|
|
256
306
|
// A session's watch list is fixed at SessionStart, so a worktree with no role
|
|
257
307
|
// yet still watches its own signal, which a role bound later will touch
|
|
258
308
|
// (chat-wake-late-binding D1). Nothing else is said until there is a role.
|
|
309
|
+
// After a run of tool calls the owner's language is restated too (#311).
|
|
310
|
+
if (event === "post-tool-use") return where ? languageAfterTools(where, payload) : { code: 0 };
|
|
259
311
|
// The owner's language is restated on every prompt, role or not (#305 D4).
|
|
260
312
|
let languageLine = null;
|
|
261
313
|
if (where && event === "user-prompt-submit") {
|
|
@@ -266,6 +318,8 @@ function hook(event, input, { mail = false } = {}) {
|
|
|
266
318
|
} catch {
|
|
267
319
|
languageLine = null;
|
|
268
320
|
}
|
|
321
|
+
// A prompt that states the rule starts the tool count over (#311 D3).
|
|
322
|
+
if (languageLine) resetLanguageCount(where, payload);
|
|
269
323
|
}
|
|
270
324
|
const promptOutput = (text) => ({
|
|
271
325
|
code: 0,
|