@antoneeo/course-creator 0.1.0-beta.18 → 0.1.0-beta.19
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/CHANGELOG.md +17 -0
- package/README.md +3 -7
- package/gemini-extension.json +1 -1
- package/package.json +12 -3
- package/scripts/init.js +62 -62
- package/scripts/lib.js +98 -98
- package/scripts/postinstall.js +16 -16
- package/scripts/preuninstall.js +12 -12
- package/skills/course-creator/SKILL.md +1 -1
- package/skills/course-creator/scripts/sdlc_core.py +317 -22
- package/skills/course-creator/scripts/shared_manifest.json +6 -6
- package/skills/course-creator/vision.md +308 -308
|
@@ -35,6 +35,7 @@ but are deprecated: new documents should use the English forms.
|
|
|
35
35
|
Standard library only (Python >= 3.8). Windows and POSIX compatible.
|
|
36
36
|
"""
|
|
37
37
|
import argparse
|
|
38
|
+
import base64
|
|
38
39
|
import hashlib
|
|
39
40
|
import json
|
|
40
41
|
import os
|
|
@@ -2317,6 +2318,29 @@ ORIENT_HOOK_CONFIG_CAP = 1024 * 1024 # settings are tiny; cap pathological file
|
|
|
2317
2318
|
_ORIENT_HOOK_CMD_RE = re.compile(r" orient(\s|$)")
|
|
2318
2319
|
_ORIENT_HOOK_TOKEN_RE = re.compile(r'"([^"]*)"|(\S+)')
|
|
2319
2320
|
|
|
2321
|
+
# Same fixed, versioned carrier as scripts/lib.js; only JSON data is decoded.
|
|
2322
|
+
_CODEX_HOOK_WRAPPER = "import base64,json,subprocess,sys;d=json.loads(base64.b64decode(sys.argv[2]));subprocess.run([sys.executable,d['validator'],*d['argv']],input=sys.stdin.buffer.read())"
|
|
2323
|
+
|
|
2324
|
+
|
|
2325
|
+
def _decode_hook_invocation(command):
|
|
2326
|
+
middle = ' -c "' + _CODEX_HOOK_WRAPPER + '" agentic-sdlc-hook-v1 '
|
|
2327
|
+
if not isinstance(command, str) or middle not in command:
|
|
2328
|
+
return None
|
|
2329
|
+
prefix, encoded = command.split(middle, 1)
|
|
2330
|
+
if not re.fullmatch(r'[\w.-]+|"[^"$`\r\n]+"', prefix):
|
|
2331
|
+
return None
|
|
2332
|
+
try:
|
|
2333
|
+
data = json.loads(base64.b64decode(encoded, validate=True))
|
|
2334
|
+
if (not isinstance(data, dict) or data.get("client") != "codex"
|
|
2335
|
+
or not isinstance(data.get("validator"), str)
|
|
2336
|
+
or not isinstance(data.get("argv"), list) or not data["argv"]
|
|
2337
|
+
or not all(isinstance(a, str) for a in data["argv"])
|
|
2338
|
+
or data["argv"][0] not in ("orient", "remind", "verdict", "constraints")):
|
|
2339
|
+
return None
|
|
2340
|
+
return data
|
|
2341
|
+
except (ValueError, TypeError):
|
|
2342
|
+
return None
|
|
2343
|
+
|
|
2320
2344
|
|
|
2321
2345
|
def _orient_entries_in(p):
|
|
2322
2346
|
"""Yield the SessionStart commands invoking an orient entry point from ONE
|
|
@@ -2327,11 +2351,20 @@ def _orient_entries_in(p):
|
|
|
2327
2351
|
try:
|
|
2328
2352
|
if not p.is_file() or p.stat().st_size > ORIENT_HOOK_CONFIG_CAP:
|
|
2329
2353
|
return
|
|
2330
|
-
|
|
2354
|
+
if p.suffix == ".toml":
|
|
2355
|
+
import tomllib
|
|
2356
|
+
data = tomllib.loads(p.read_text(encoding="utf-8-sig"))
|
|
2357
|
+
else:
|
|
2358
|
+
data = json.loads(p.read_text(encoding="utf-8-sig"))
|
|
2331
2359
|
except Exception:
|
|
2332
2360
|
return
|
|
2333
2361
|
if not isinstance(data, dict):
|
|
2334
2362
|
return
|
|
2363
|
+
features = data.get("features")
|
|
2364
|
+
if p.name in ("hooks.json", "config.toml") and (
|
|
2365
|
+
isinstance(features, dict) and features.get("hooks") is False
|
|
2366
|
+
or data.get("allow_managed_hooks_only") is True):
|
|
2367
|
+
return
|
|
2335
2368
|
hooks = data.get("hooks")
|
|
2336
2369
|
groups = hooks.get("SessionStart") if isinstance(hooks, dict) else None
|
|
2337
2370
|
if groups is None:
|
|
@@ -2341,12 +2374,20 @@ def _orient_entries_in(p):
|
|
|
2341
2374
|
for group in groups:
|
|
2342
2375
|
if not isinstance(group, dict):
|
|
2343
2376
|
continue
|
|
2377
|
+
codex = p.name in ("hooks.json", "config.toml")
|
|
2378
|
+
if codex and group.get("enabled") is False:
|
|
2379
|
+
continue
|
|
2344
2380
|
inner = group.get("hooks")
|
|
2345
2381
|
for h in inner if isinstance(inner, list) else [group]:
|
|
2382
|
+
if codex and (not isinstance(h, dict) or h.get("enabled") is False or h.get("type") != "command"):
|
|
2383
|
+
continue
|
|
2346
2384
|
cmd = h.get("command") if isinstance(h, dict) else None
|
|
2347
|
-
if
|
|
2348
|
-
|
|
2349
|
-
|
|
2385
|
+
if isinstance(h, dict) and p.name in ("hooks.json", "config.toml") and os.name == "nt":
|
|
2386
|
+
cmd = h.get("commandWindows") or h.get("command_windows") or cmd
|
|
2387
|
+
invocation = _decode_hook_invocation(cmd)
|
|
2388
|
+
if ((invocation and invocation["argv"][0] == "orient") or
|
|
2389
|
+
(isinstance(cmd, str) and any(n in cmd for n in ORIENT_HOOK_ENTRY_POINTS)
|
|
2390
|
+
and _ORIENT_HOOK_CMD_RE.search(cmd))):
|
|
2350
2391
|
yield cmd
|
|
2351
2392
|
|
|
2352
2393
|
|
|
@@ -2365,17 +2406,69 @@ def _orient_user_settings_path():
|
|
|
2365
2406
|
return (Path(cfg) if cfg else Path.home() / ".claude") / "settings.json"
|
|
2366
2407
|
|
|
2367
2408
|
|
|
2409
|
+
def _codex_hook_config(root):
|
|
2410
|
+
"""Observable Codex policy across sources; no trust or execution assertion."""
|
|
2411
|
+
home = Path(os.environ.get("CODEX_HOME") or Path.home() / ".codex")
|
|
2412
|
+
disabled, unverified, disabled_entries = False, False, False
|
|
2413
|
+
for directory in (home, Path(root) / ".codex"):
|
|
2414
|
+
for name in ("hooks.json", "config.toml"):
|
|
2415
|
+
p = directory / name
|
|
2416
|
+
if not p.exists():
|
|
2417
|
+
continue
|
|
2418
|
+
try:
|
|
2419
|
+
if not p.is_file() or p.stat().st_size > ORIENT_HOOK_CONFIG_CAP:
|
|
2420
|
+
raise ValueError("unreadable configuration")
|
|
2421
|
+
text = p.read_text(encoding="utf-8-sig")
|
|
2422
|
+
if p.suffix == ".toml":
|
|
2423
|
+
import tomllib
|
|
2424
|
+
data = tomllib.loads(text)
|
|
2425
|
+
else:
|
|
2426
|
+
data = json.loads(text)
|
|
2427
|
+
if not isinstance(data, dict):
|
|
2428
|
+
raise ValueError("unknown configuration shape")
|
|
2429
|
+
features = data.get("features", {})
|
|
2430
|
+
hooks = data.get("hooks", {})
|
|
2431
|
+
if not isinstance(features, dict) or not isinstance(hooks, dict):
|
|
2432
|
+
raise ValueError("unknown policy or hooks shape")
|
|
2433
|
+
disabled |= features.get("hooks") is False or data.get("allow_managed_hooks_only") is True
|
|
2434
|
+
groups = hooks.get("SessionStart", data.get("SessionStart", []))
|
|
2435
|
+
if not isinstance(groups, list):
|
|
2436
|
+
raise ValueError("unknown hook groups")
|
|
2437
|
+
for group in groups:
|
|
2438
|
+
if not isinstance(group, dict):
|
|
2439
|
+
raise ValueError("unknown hook group")
|
|
2440
|
+
inner = group.get("hooks", [group])
|
|
2441
|
+
if not isinstance(inner, list) or not all(isinstance(h, dict) for h in inner):
|
|
2442
|
+
raise ValueError("unknown handlers")
|
|
2443
|
+
disabled_entries |= group.get("enabled") is False or any(h.get("enabled") is False for h in inner)
|
|
2444
|
+
except Exception:
|
|
2445
|
+
unverified = True
|
|
2446
|
+
policy = "disabled-by-policy" if disabled else "unverified" if unverified else "enabled"
|
|
2447
|
+
return {"policy": policy, "disabled_entries": disabled_entries}
|
|
2448
|
+
|
|
2449
|
+
|
|
2368
2450
|
def _orient_hook_commands(root):
|
|
2369
2451
|
"""Yield (command, at_user_level, place) across every known client config:
|
|
2370
2452
|
the three project-relative files, then the machine-global user settings --
|
|
2371
2453
|
the file the installer wires (F-042), without which a fixed machine's
|
|
2372
2454
|
projects would read as unwired forever. `place` is a display label, never a
|
|
2373
2455
|
home path (F-075 prints it)."""
|
|
2456
|
+
codex_policy = _codex_hook_config(root)["policy"]
|
|
2374
2457
|
for rel in ORIENT_HOOK_CONFIG_FILES:
|
|
2458
|
+
if rel.startswith(".codex/") and codex_policy != "enabled":
|
|
2459
|
+
continue
|
|
2375
2460
|
for cmd in _orient_entries_in(Path(root) / rel):
|
|
2376
2461
|
yield cmd, False, rel
|
|
2377
2462
|
for cmd in _orient_entries_in(_orient_user_settings_path()):
|
|
2378
2463
|
yield cmd, True, "user settings"
|
|
2464
|
+
if codex_policy != "enabled":
|
|
2465
|
+
return
|
|
2466
|
+
home = Path(os.environ.get("CODEX_HOME") or Path.home() / ".codex")
|
|
2467
|
+
for name in ("hooks.json", "config.toml"):
|
|
2468
|
+
for cmd in _orient_entries_in(home / name):
|
|
2469
|
+
yield cmd, True, "codex user " + name
|
|
2470
|
+
for cmd in _orient_entries_in(Path(root) / ".codex" / name) if name == "config.toml" else ():
|
|
2471
|
+
yield cmd, False, ".codex/" + name
|
|
2379
2472
|
|
|
2380
2473
|
|
|
2381
2474
|
def _orient_entry_live(root, cmd, at_user_level):
|
|
@@ -2386,7 +2479,8 @@ def _orient_entry_live(root, cmd, at_user_level):
|
|
|
2386
2479
|
tokens resolve against the project root (the vendored-validator
|
|
2387
2480
|
convention); a USER-level relative token has no cwd to resolve against and
|
|
2388
2481
|
is treated as cannot-tell."""
|
|
2389
|
-
|
|
2482
|
+
invocation = _decode_hook_invocation(cmd)
|
|
2483
|
+
token = invocation["validator"] if invocation else None
|
|
2390
2484
|
for m in _ORIENT_HOOK_TOKEN_RE.finditer(cmd):
|
|
2391
2485
|
tok = m.group(1) if m.group(1) is not None else m.group(2)
|
|
2392
2486
|
if any(tok.endswith(n) for n in ORIENT_HOOK_ENTRY_POINTS):
|
|
@@ -2413,7 +2507,7 @@ def orient_wiring(root):
|
|
|
2413
2507
|
for cmd, at_user_level, place in _orient_hook_commands(root):
|
|
2414
2508
|
if not _orient_entry_live(root, cmd, at_user_level):
|
|
2415
2509
|
continue
|
|
2416
|
-
client = "codex" if place.startswith(".codex") else "claude"
|
|
2510
|
+
client = "codex" if place.startswith((".codex", "codex ")) else "claude"
|
|
2417
2511
|
out.setdefault(client, {}).setdefault(cmd.strip(), place)
|
|
2418
2512
|
return out
|
|
2419
2513
|
|
|
@@ -2447,6 +2541,13 @@ def print_orient_hook_note(root):
|
|
|
2447
2541
|
does): the note is check-layer behaviour, whoever owns the check."""
|
|
2448
2542
|
try:
|
|
2449
2543
|
state = orient_hook_state(root)
|
|
2544
|
+
codex = _codex_hook_config(root)
|
|
2545
|
+
if codex["policy"] != "enabled" or codex["disabled_entries"]:
|
|
2546
|
+
detail = codex["policy"] if codex["policy"] != "enabled" else "disabled definitions present"
|
|
2547
|
+
print(f"[note] Codex hook configuration: {detail}. Disabled or unverified "
|
|
2548
|
+
"definitions are excluded from wiring counts; trust and native delivery are not verified.")
|
|
2549
|
+
if state == "unwired":
|
|
2550
|
+
return
|
|
2450
2551
|
if state == "unwired":
|
|
2451
2552
|
print("[note] agent sessions start without automatic orientation on this "
|
|
2452
2553
|
"machine (no session-orientation hook found at project or user level). "
|
|
@@ -2700,6 +2801,192 @@ _DECLARATION_RE = re.compile(
|
|
|
2700
2801
|
_GUIDE_NAME_RE = re.compile(r"GUIDE_[A-Za-z0-9_-]+\.md")
|
|
2701
2802
|
|
|
2702
2803
|
|
|
2804
|
+
def _hint_path(value, cwd):
|
|
2805
|
+
if not isinstance(value, str) or not value:
|
|
2806
|
+
return None
|
|
2807
|
+
p = Path(value)
|
|
2808
|
+
if not p.is_absolute():
|
|
2809
|
+
if not cwd or not Path(cwd).is_absolute():
|
|
2810
|
+
return None
|
|
2811
|
+
p = Path(cwd) / p
|
|
2812
|
+
return str(p.resolve())
|
|
2813
|
+
|
|
2814
|
+
|
|
2815
|
+
def hook_edits(payload):
|
|
2816
|
+
"""Parse the complete native apply_patch syntax without executing it.
|
|
2817
|
+
|
|
2818
|
+
Unknown or incomplete input yields no partial target set. Move checks both
|
|
2819
|
+
the old and new paths; file membership is evaluated by the existing gate.
|
|
2820
|
+
"""
|
|
2821
|
+
command = (payload.get("tool_input") or {}).get("command")
|
|
2822
|
+
if not isinstance(command, str) or len(command.encode("utf-8")) > VERDICT_LINE_MAX:
|
|
2823
|
+
return None
|
|
2824
|
+
lines = command.strip().splitlines()
|
|
2825
|
+
if not lines or lines[0] != "*** Begin Patch" or lines[-1] != "*** End Patch":
|
|
2826
|
+
return None
|
|
2827
|
+
edits, current, mode, changed = [], None, None, False
|
|
2828
|
+
for line in lines[1:-1]:
|
|
2829
|
+
match = re.fullmatch(r"\*\*\* (Add|Update|Delete) File: (.+)", line)
|
|
2830
|
+
if match:
|
|
2831
|
+
if current is not None and mode != "Delete" and not changed:
|
|
2832
|
+
return None
|
|
2833
|
+
mode, value = match.groups()
|
|
2834
|
+
target = _hint_path(value, payload.get("cwd"))
|
|
2835
|
+
if not target:
|
|
2836
|
+
return None
|
|
2837
|
+
current = {"path": target, "new_text": ""}
|
|
2838
|
+
edits.append(current)
|
|
2839
|
+
changed = False
|
|
2840
|
+
elif line.startswith("*** Move to: ") and current is not None and mode == "Update" and not changed:
|
|
2841
|
+
target = _hint_path(line[len("*** Move to: "):], payload.get("cwd"))
|
|
2842
|
+
if not target:
|
|
2843
|
+
return None
|
|
2844
|
+
current = {"path": target, "new_text": ""}
|
|
2845
|
+
edits.append(current)
|
|
2846
|
+
elif current is not None and mode != "Delete" and (
|
|
2847
|
+
line.startswith(("+", "-", " ", "@@")) or line == "*** End of File"):
|
|
2848
|
+
if mode == "Add" and not line.startswith("+"):
|
|
2849
|
+
return None
|
|
2850
|
+
if line.startswith(("+", "-")):
|
|
2851
|
+
changed = True
|
|
2852
|
+
if line.startswith("+"):
|
|
2853
|
+
current["new_text"] += line[1:] + "\n"
|
|
2854
|
+
else:
|
|
2855
|
+
return None
|
|
2856
|
+
if current is not None and mode != "Delete" and not changed:
|
|
2857
|
+
return None
|
|
2858
|
+
return edits or None
|
|
2859
|
+
|
|
2860
|
+
|
|
2861
|
+
def shell_read_paths(command, cwd, workdir=None):
|
|
2862
|
+
"""Literal Get-Content/cat reads only: no shell expansion or execution."""
|
|
2863
|
+
if not isinstance(command, str) or re.search(r"[$`\r\n;|&<>\x00]", command):
|
|
2864
|
+
return None
|
|
2865
|
+
token_re = re.compile(r"\s*(?:'([^']*)'|\"([^\"]*)\"|([^\s'\"]+))")
|
|
2866
|
+
tokens, pos = [], 0
|
|
2867
|
+
while pos < len(command.rstrip()):
|
|
2868
|
+
match = token_re.match(command, pos)
|
|
2869
|
+
if not match:
|
|
2870
|
+
return None
|
|
2871
|
+
token = next(x for x in match.groups() if x is not None)
|
|
2872
|
+
tokens.append(token)
|
|
2873
|
+
pos = match.end()
|
|
2874
|
+
if not tokens or tokens[0].lower() not in ("get-content", "cat"):
|
|
2875
|
+
return None
|
|
2876
|
+
paths, i = [], 1
|
|
2877
|
+
while i < len(tokens):
|
|
2878
|
+
token = tokens[i]
|
|
2879
|
+
if tokens[0].lower() == "get-content" and token.lower() in ("-literalpath", "-path", "-raw"):
|
|
2880
|
+
if token.lower() != "-raw" and i + 1 == len(tokens):
|
|
2881
|
+
return None
|
|
2882
|
+
elif tokens[0].lower() == "get-content" and token.lower() == "-totalcount":
|
|
2883
|
+
i += 1
|
|
2884
|
+
if i == len(tokens) or not tokens[i].isdigit():
|
|
2885
|
+
return None
|
|
2886
|
+
elif tokens[0] == "cat" and token == "--":
|
|
2887
|
+
pass
|
|
2888
|
+
elif token.startswith("-") or re.search(r"[*?\[\],]", token):
|
|
2889
|
+
return None
|
|
2890
|
+
else:
|
|
2891
|
+
base = _hint_path(workdir, cwd) if workdir else cwd
|
|
2892
|
+
resolved = _hint_path(token, base)
|
|
2893
|
+
if not resolved:
|
|
2894
|
+
return None
|
|
2895
|
+
paths.append(resolved)
|
|
2896
|
+
i += 1
|
|
2897
|
+
return paths or None
|
|
2898
|
+
|
|
2899
|
+
|
|
2900
|
+
def _codex_literal_calls(code):
|
|
2901
|
+
"""Recognize a small non-executable JS carrier grammar, otherwise nothing."""
|
|
2902
|
+
if not isinstance(code, str):
|
|
2903
|
+
return []
|
|
2904
|
+
calls, pos = [], 0
|
|
2905
|
+
pattern = re.compile(r"\s*(?:text\(\s*)?await\s+tools\.exec_command\((\{.*?\})\)\s*\)?\s*;?", re.DOTALL)
|
|
2906
|
+
field = re.compile(r'\s*(?:"(cmd|workdir)"|(cmd|workdir))\s*:\s*("(?:[^"\\]|\\.)*")\s*(,|$)')
|
|
2907
|
+
while pos < len(code.rstrip()):
|
|
2908
|
+
match = pattern.match(code, pos)
|
|
2909
|
+
if not match:
|
|
2910
|
+
return []
|
|
2911
|
+
obj, off, args = match[1][1:-1], 0, {}
|
|
2912
|
+
while off < len(obj.rstrip()):
|
|
2913
|
+
item = field.match(obj, off)
|
|
2914
|
+
if not item or (item[1] or item[2]) in args:
|
|
2915
|
+
return []
|
|
2916
|
+
try:
|
|
2917
|
+
args[item[1] or item[2]] = json.loads(item[3])
|
|
2918
|
+
except ValueError:
|
|
2919
|
+
return []
|
|
2920
|
+
off = item.end()
|
|
2921
|
+
if "cmd" not in args:
|
|
2922
|
+
return []
|
|
2923
|
+
calls.append(args)
|
|
2924
|
+
pos = match.end()
|
|
2925
|
+
return calls
|
|
2926
|
+
|
|
2927
|
+
|
|
2928
|
+
def transcript_events(path):
|
|
2929
|
+
"""Yield legacy assistant blocks, plus normalized recognized Codex blocks.
|
|
2930
|
+
|
|
2931
|
+
This is read-only and bounded by the existing transcript limits. Historical
|
|
2932
|
+
cwd is taken from host metadata, never guessed from the present process.
|
|
2933
|
+
"""
|
|
2934
|
+
cwd = None
|
|
2935
|
+
with Path(path).open("rb") as fh:
|
|
2936
|
+
for raw in fh:
|
|
2937
|
+
if len(raw) > VERDICT_LINE_MAX:
|
|
2938
|
+
continue
|
|
2939
|
+
try:
|
|
2940
|
+
entry = json.loads(raw.decode("utf-8", errors="replace"))
|
|
2941
|
+
except ValueError:
|
|
2942
|
+
continue
|
|
2943
|
+
if not isinstance(entry, dict):
|
|
2944
|
+
continue
|
|
2945
|
+
if entry.get("type") == "assistant":
|
|
2946
|
+
yield entry
|
|
2947
|
+
continue
|
|
2948
|
+
data = entry.get("payload")
|
|
2949
|
+
if not isinstance(data, dict):
|
|
2950
|
+
continue
|
|
2951
|
+
if entry.get("type") in ("session_meta", "turn_context"):
|
|
2952
|
+
if isinstance(data.get("cwd"), str):
|
|
2953
|
+
cwd = data["cwd"]
|
|
2954
|
+
continue
|
|
2955
|
+
if entry.get("type") != "response_item":
|
|
2956
|
+
continue
|
|
2957
|
+
blocks = []
|
|
2958
|
+
if data.get("type") == "message" and data.get("role") == "assistant":
|
|
2959
|
+
blocks = [{"type": "text", "text": x.get("text", "")}
|
|
2960
|
+
for x in (data.get("content") if isinstance(data.get("content"), list) else []) if isinstance(x, dict) and x.get("type") == "output_text"]
|
|
2961
|
+
elif data.get("type") in ("function_call", "custom_tool_call"):
|
|
2962
|
+
name = data.get("name")
|
|
2963
|
+
calls = []
|
|
2964
|
+
if name in ("exec_command", "Bash"):
|
|
2965
|
+
try:
|
|
2966
|
+
args = json.loads(data.get("arguments", "{}"))
|
|
2967
|
+
except (ValueError, TypeError):
|
|
2968
|
+
args = None
|
|
2969
|
+
if isinstance(args, dict):
|
|
2970
|
+
calls = [args]
|
|
2971
|
+
elif name == "exec":
|
|
2972
|
+
calls = _codex_literal_calls(data.get("input"))
|
|
2973
|
+
elif name == "apply_patch":
|
|
2974
|
+
command = data.get("input")
|
|
2975
|
+
if command is None:
|
|
2976
|
+
try:
|
|
2977
|
+
command = json.loads(data.get("arguments", "{}" )).get("command")
|
|
2978
|
+
except (ValueError, TypeError, AttributeError):
|
|
2979
|
+
pass
|
|
2980
|
+
for edit in hook_edits({"tool_input": {"command": command}, "cwd": cwd}) or []:
|
|
2981
|
+
blocks.append({"type": "tool_use", "name": "Write", "input": {"file_path": edit["path"]}})
|
|
2982
|
+
for args in calls:
|
|
2983
|
+
for target in shell_read_paths(args.get("cmd", args.get("command")), cwd, args.get("workdir")) or []:
|
|
2984
|
+
blocks.append({"type": "tool_use", "name": "Read", "input": {"file_path": target}})
|
|
2985
|
+
if blocks:
|
|
2986
|
+
yield {"type": "assistant", "isSidechain": bool(entry.get("agent_id") or data.get("agent_id")),
|
|
2987
|
+
"message": {"content": blocks}}
|
|
2988
|
+
|
|
2989
|
+
|
|
2703
2990
|
def transcript_facts(path):
|
|
2704
2991
|
"""What the session transcript shows about the verdict duty, or None when it
|
|
2705
2992
|
cannot be read within the bounds.
|
|
@@ -2714,14 +3001,7 @@ def transcript_facts(path):
|
|
|
2714
3001
|
p = Path(path)
|
|
2715
3002
|
if not p.is_file() or p.stat().st_size > VERDICT_MAX_BYTES:
|
|
2716
3003
|
return None
|
|
2717
|
-
|
|
2718
|
-
for raw in fh:
|
|
2719
|
-
if len(raw) > VERDICT_LINE_MAX or b'"assistant"' not in raw:
|
|
2720
|
-
continue
|
|
2721
|
-
try:
|
|
2722
|
-
entry = json.loads(raw.decode("utf-8", errors="replace"))
|
|
2723
|
-
except ValueError:
|
|
2724
|
-
continue
|
|
3004
|
+
for entry in transcript_events(p):
|
|
2725
3005
|
if not isinstance(entry, dict) or entry.get("type") != "assistant":
|
|
2726
3006
|
continue
|
|
2727
3007
|
content = (entry.get("message") or {}).get("content")
|
|
@@ -2755,6 +3035,13 @@ def transcript_facts(path):
|
|
|
2755
3035
|
def verdict_reason(payload, root=None, docs_name=None):
|
|
2756
3036
|
"""The refusal line for this edit event, or None when the edit may proceed.
|
|
2757
3037
|
Without a root, the project is the one holding the edited file (hook_project)."""
|
|
3038
|
+
if payload.get("tool_name") == "apply_patch" and not payload.get("agent_id"):
|
|
3039
|
+
for edit in hook_edits(payload) or []:
|
|
3040
|
+
reason = verdict_reason({**payload, "tool_name": "Edit", "tool_input": {
|
|
3041
|
+
"file_path": edit["path"], "new_string": edit["new_text"]}}, root, docs_name)
|
|
3042
|
+
if reason:
|
|
3043
|
+
return reason
|
|
3044
|
+
return None
|
|
2758
3045
|
if payload.get("tool_name") not in VERDICT_EDIT_TOOLS or payload.get("agent_id"):
|
|
2759
3046
|
return None
|
|
2760
3047
|
tool_input = payload.get("tool_input") or {}
|
|
@@ -3113,14 +3400,7 @@ def transcript_work(path):
|
|
|
3113
3400
|
p = Path(path)
|
|
3114
3401
|
if not p.is_file() or p.stat().st_size > VERDICT_MAX_BYTES:
|
|
3115
3402
|
return None
|
|
3116
|
-
|
|
3117
|
-
for raw in fh:
|
|
3118
|
-
if len(raw) > VERDICT_LINE_MAX or b'"assistant"' not in raw:
|
|
3119
|
-
continue
|
|
3120
|
-
try:
|
|
3121
|
-
entry = json.loads(raw.decode("utf-8", errors="replace"))
|
|
3122
|
-
except ValueError:
|
|
3123
|
-
continue
|
|
3403
|
+
for entry in transcript_events(p):
|
|
3124
3404
|
if not isinstance(entry, dict) or entry.get("type") != "assistant":
|
|
3125
3405
|
continue
|
|
3126
3406
|
content = (entry.get("message") or {}).get("content")
|
|
@@ -3175,6 +3455,17 @@ def constraints_hook_context(payload, root=None, docs_name=None):
|
|
|
3175
3455
|
a subagent, on a file of a project whose open L3 code unit binds it (or the
|
|
3176
3456
|
unit's own ANALYSIS, about to name a path a P row binds -- UC6), by a session
|
|
3177
3457
|
that worked on that unit and last declared L3."""
|
|
3458
|
+
if payload.get("tool_name") == "apply_patch" and not payload.get("agent_id"):
|
|
3459
|
+
lines = []
|
|
3460
|
+
for edit in hook_edits(payload) or []:
|
|
3461
|
+
context = constraints_hook_context({**payload, "tool_name": "Edit", "tool_input": {
|
|
3462
|
+
"file_path": edit["path"], "new_string": edit["new_text"]}}, root, docs_name)
|
|
3463
|
+
for line in (context or "").splitlines():
|
|
3464
|
+
if line not in lines:
|
|
3465
|
+
lines.append(line)
|
|
3466
|
+
if len(lines) > CONSTRAINTS_HOOK_LINES:
|
|
3467
|
+
lines = lines[:CONSTRAINTS_HOOK_LINES - 1] + [lines[-1]]
|
|
3468
|
+
return "\n".join(lines) or None
|
|
3178
3469
|
if payload.get("tool_name") not in VERDICT_EDIT_TOOLS or payload.get("agent_id"):
|
|
3179
3470
|
return None
|
|
3180
3471
|
tool_input = payload.get("tool_input") or {}
|
|
@@ -3865,6 +4156,10 @@ def cmd_orient(args):
|
|
|
3865
4156
|
for client, entries in sorted(orient_wiring(root).items()):
|
|
3866
4157
|
if len(entries) > 1:
|
|
3867
4158
|
places = ", ".join(sorted(set(entries.values())))
|
|
4159
|
+
if client == "codex":
|
|
4160
|
+
tail.append(f"[note] Codex has {len(entries)} configured orientation definitions "
|
|
4161
|
+
f"({places}); trust and runtime policy determine delivery. Keep one equivalent definition.")
|
|
4162
|
+
continue
|
|
3868
4163
|
tail.append(f"[note] session orientation is wired {len(entries)} times for one "
|
|
3869
4164
|
f"client ({places}): each session receives every copy. Keep one "
|
|
3870
4165
|
"entry and remove the others.")
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"scripts/docs_site.py": "bfc7a521142251b85b229e1873ccf2e375bb5c7f1990cef574e1a78ef14f0091",
|
|
16
16
|
"scripts/entry_point.py": "4a560d4d41db989d3426182f1b24270cbb934b3db0f3246c700578a4ed93089b",
|
|
17
17
|
"scripts/knowledge.py": "6047deb7a2be4cf9ef2949cbcf8a52a8ea61500f4e12d203f1c58076540d50ab",
|
|
18
|
-
"scripts/sdlc_core.py": "
|
|
18
|
+
"scripts/sdlc_core.py": "189be3dc498341f45b2c4233c916255fefda0ea9d46754d8ed99dc59a01224d8",
|
|
19
19
|
"scripts/shared_files.py": "d360c6018c602788dd96194bcc0f8e8409b140671857ae50ec15acee882eb51e",
|
|
20
20
|
"scripts/test_audit_refs.py": "5c207be46da566db47069b08373195e748fca19c047418f09cc2f78841dfd9a5",
|
|
21
|
-
"scripts/test_chronology.py": "
|
|
22
|
-
"scripts/test_constraints.py": "
|
|
21
|
+
"scripts/test_chronology.py": "cd595dcfa6d75b44c3b37483dec2c678c87dab9874ad3f6a60a28f9ec361cdc7",
|
|
22
|
+
"scripts/test_constraints.py": "cf174c4f001bf889428efb19c671b004bf1a85fdea8649acf5d5419d7bafa079",
|
|
23
23
|
"scripts/test_design_approval.py": "191856214cb0b4ab8606b57496cf54742568e3bb4bfa0d8f0c64889f2e2d1e63",
|
|
24
24
|
"scripts/test_docs_root.py": "19753e0316c0df63ed321d24b411a9ff36eea2058421fd69fc57e507d75566d0",
|
|
25
25
|
"scripts/test_docs_site.py": "391ec5c635c67f0fbefe458426e352b5b1ef626ae65c099b1e8e1db491d0a5f9",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"scripts/test_migrate.py": "c129823bf4feb0614acd975351632a6ae62d7896a0ef32724419a8e9335e3110",
|
|
31
31
|
"scripts/test_plan.py": "4c011a63aa834b55e9c5d13fb4ea76b131b742356001364b0a508435ba013e27",
|
|
32
32
|
"scripts/test_project_memory.py": "2cb85cef01161d881a11d84cfe9ebb72915104e8d1822e4de739f7d00ae6cd59",
|
|
33
|
-
"scripts/test_session_start.py": "
|
|
34
|
-
"scripts/test_skill_invariants.py": "
|
|
35
|
-
"scripts/test_verdict.py": "
|
|
33
|
+
"scripts/test_session_start.py": "d834e66adb3ccc26d8ef664be870e18ca41fd4c10dc4e5870827d24385f40abf",
|
|
34
|
+
"scripts/test_skill_invariants.py": "3433c45c83bc2a3a56a23a49e8de7aa3c1e14ae2919f29b86f7e3eae1c289e62",
|
|
35
|
+
"scripts/test_verdict.py": "6d0e56093e7cdfcec65769259fd91287a6bae071418953fb817b02b84d94f592",
|
|
36
36
|
"vision.md": "a19a7d7d5044215b726b66f74e422c9cdedcc856c0a53151f20a6d9840b8f6c4"
|
|
37
37
|
}
|
|
38
38
|
}
|