mlai-code 0.3.2 → 0.3.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.
Files changed (157) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/src/checkpoints.mjs +217 -0
  4. package/src/cli.mjs +178 -31
  5. package/src/cloud.mjs +2 -0
  6. package/src/engine.mjs +1 -1
  7. package/src/headless.mjs +25 -9
  8. package/src/home.mjs +3 -2
  9. package/src/host.mjs +141 -13
  10. package/src/ide-quick.mjs +147 -0
  11. package/src/ide.mjs +182 -0
  12. package/src/netbox.mjs +1 -1
  13. package/src/parity.mjs +20 -1
  14. package/src/relay.mjs +1 -1
  15. package/src/render.mjs +12 -3
  16. package/src/runtime.mjs +23 -1
  17. package/src/sandbox.mjs +19 -3
  18. package/src/server.mjs +46 -7
  19. package/src/session.mjs +53 -10
  20. package/src/shared-data.mjs +1 -1
  21. package/src/tui/acp.mjs +121 -19
  22. package/src/tui/app.mjs +24 -5
  23. package/src/tui/chat.mjs +43 -16
  24. package/src/tui/cmd-config.mjs +3 -1
  25. package/src/tui/cmd-core.mjs +11 -7
  26. package/src/tui/cmd-extensibility.mjs +13 -2
  27. package/src/tui/commands.mjs +2 -1
  28. package/src/tui/extensions-local.mjs +2 -0
  29. package/src/tui/mcp-config.mjs +22 -4
  30. package/src/tui/review-cli.mjs +15 -4
  31. package/src/tui/snapshots.mjs +57 -16
  32. package/src/tui/statusline.mjs +2 -1
  33. package/src/two-words.mjs +14 -8
  34. package/src/view-sync.mjs +48 -0
  35. package/src/wakeups.mjs +2 -2
  36. package/src/winenv.mjs +1 -1
  37. package/src/workspace-api.mjs +21 -4
  38. package/vendor/client-sdk/index.cjs +5 -4
  39. package/vendor/cloud-cli/mlai.mjs +184 -28
  40. package/worker/architecture_worker.py +33 -4
  41. package/worker/browser_tool.py +19 -1
  42. package/worker/build_planner.py +75 -7
  43. package/worker/chat_fork.py +4 -1
  44. package/worker/checkpoints.py +71 -8
  45. package/worker/cloud_pty.py +91 -2
  46. package/worker/command_safety.py +80 -3
  47. package/worker/compaction_brief.py +186 -0
  48. package/worker/connected_turn.py +30 -0
  49. package/worker/context_manager.py +6 -0
  50. package/worker/conversation.py +139 -12
  51. package/worker/deck_render.js +11 -0
  52. package/worker/deck_tools.py +825 -0
  53. package/worker/git_sync.py +42 -17
  54. package/worker/goals.py +4 -0
  55. package/worker/image_generation.py +102 -23
  56. package/worker/kimi_bridge.py +580 -52
  57. package/worker/kimi_gates.py +74 -6
  58. package/worker/kimi_hook.py +213 -19
  59. package/worker/media_tools.py +182 -0
  60. package/worker/memory.py +2 -2
  61. package/worker/mlai_hooks.py +314 -5
  62. package/worker/mlai_mcp.py +49 -11
  63. package/worker/mlai_review/README.md +35 -0
  64. package/worker/mlai_review/__init__.py +1 -0
  65. package/worker/mlai_review/__main__.py +261 -0
  66. package/worker/mlai_review/_compat.py +29 -0
  67. package/worker/mlai_review/analysis/__init__.py +3 -0
  68. package/worker/mlai_review/analysis/detect.py +50 -0
  69. package/worker/mlai_review/analysis/main.py +128 -0
  70. package/worker/mlai_review/analysis/messages.py +8 -0
  71. package/worker/mlai_review/analysis/tools.py +194 -0
  72. package/worker/mlai_review/application/__init__.py +1 -0
  73. package/worker/mlai_review/application/asking.py +53 -0
  74. package/worker/mlai_review/application/challengers.py +142 -0
  75. package/worker/mlai_review/application/context_builder.py +194 -0
  76. package/worker/mlai_review/application/errors.py +17 -0
  77. package/worker/mlai_review/application/feedback.py +52 -0
  78. package/worker/mlai_review/application/matching.py +46 -0
  79. package/worker/mlai_review/application/messages.py +41 -0
  80. package/worker/mlai_review/application/ports.py +222 -0
  81. package/worker/mlai_review/application/prompts.py +342 -0
  82. package/worker/mlai_review/application/review_service.py +200 -0
  83. package/worker/mlai_review/application/reviewers.py +438 -0
  84. package/worker/mlai_review/application/streaming.py +91 -0
  85. package/worker/mlai_review/application/tools.py +138 -0
  86. package/worker/mlai_review/application/usage.py +145 -0
  87. package/worker/mlai_review/application/write_check.py +46 -0
  88. package/worker/mlai_review/contracts/__init__.py +5 -0
  89. package/worker/mlai_review/contracts/analysis.py +57 -0
  90. package/worker/mlai_review/contracts/review.py +42 -0
  91. package/worker/mlai_review/domain/__init__.py +4 -0
  92. package/worker/mlai_review/domain/changes.py +77 -0
  93. package/worker/mlai_review/domain/context.py +147 -0
  94. package/worker/mlai_review/domain/diagnostics.py +239 -0
  95. package/worker/mlai_review/domain/feedback.py +216 -0
  96. package/worker/mlai_review/domain/findings.py +505 -0
  97. package/worker/mlai_review/domain/lifecycle.py +85 -0
  98. package/worker/mlai_review/domain/partition.py +42 -0
  99. package/worker/mlai_review/domain/relations.py +166 -0
  100. package/worker/mlai_review/domain/relevance.py +202 -0
  101. package/worker/mlai_review/domain/report.py +99 -0
  102. package/worker/mlai_review/domain/structure.py +56 -0
  103. package/worker/mlai_review/domain/writes.py +86 -0
  104. package/worker/mlai_review/eval.py +221 -0
  105. package/worker/mlai_review/eval_cases/clean-rename.json +11 -0
  106. package/worker/mlai_review/eval_cases/missing-ownership-check.json +22 -0
  107. package/worker/mlai_review/eval_cases/off-by-one.json +22 -0
  108. package/worker/mlai_review/eval_cases/sql-injection.json +20 -0
  109. package/worker/mlai_review/feedback_report.py +60 -0
  110. package/worker/mlai_review/infrastructure/__init__.py +1 -0
  111. package/worker/mlai_review/infrastructure/analysis/__init__.py +1 -0
  112. package/worker/mlai_review/infrastructure/analysis/none.py +12 -0
  113. package/worker/mlai_review/infrastructure/analysis/translate.py +17 -0
  114. package/worker/mlai_review/infrastructure/github/__init__.py +0 -0
  115. package/worker/mlai_review/infrastructure/github/client.py +445 -0
  116. package/worker/mlai_review/infrastructure/github/feedback.py +212 -0
  117. package/worker/mlai_review/infrastructure/github/http.py +31 -0
  118. package/worker/mlai_review/infrastructure/github/rendering.py +398 -0
  119. package/worker/mlai_review/infrastructure/github/token.py +20 -0
  120. package/worker/mlai_review/infrastructure/local/__init__.py +1 -0
  121. package/worker/mlai_review/infrastructure/local/analyzer.py +48 -0
  122. package/worker/mlai_review/infrastructure/local/events.py +100 -0
  123. package/worker/mlai_review/infrastructure/local/git_reader.py +233 -0
  124. package/worker/mlai_review/infrastructure/local/publisher.py +138 -0
  125. package/worker/mlai_review/infrastructure/messages.py +54 -0
  126. package/worker/mlai_review/infrastructure/models/__init__.py +0 -0
  127. package/worker/mlai_review/infrastructure/models/openai_compatible.py +269 -0
  128. package/worker/mlai_review/infrastructure/structure/__init__.py +1 -0
  129. package/worker/mlai_review/infrastructure/structure/heuristic.py +186 -0
  130. package/worker/mlai_review/infrastructure/structure/tree_sitter.py +186 -0
  131. package/worker/mlai_review/infrastructure/workspace/__init__.py +1 -0
  132. package/worker/mlai_review/infrastructure/workspace/local.py +105 -0
  133. package/worker/mlai_review/infrastructure/workspace/memory.py +77 -0
  134. package/worker/mlai_review/infrastructure/workspace/paths.py +17 -0
  135. package/worker/mlai_review/pipeline.py +89 -0
  136. package/worker/mlai_review/runtime.py +194 -0
  137. package/worker/mlai_review/settings.py +139 -0
  138. package/worker/model_stream.py +21 -7
  139. package/worker/offline_guard.py +1 -1
  140. package/worker/preview.py +62 -4
  141. package/worker/product_facts.py +20 -0
  142. package/worker/project_context.py +33 -7
  143. package/worker/reply_language.py +92 -10
  144. package/worker/repo_policy.py +5 -0
  145. package/worker/roles.json +199 -37
  146. package/worker/roles.py +271 -9
  147. package/worker/runner.py +366 -53
  148. package/worker/runtime_control.py +64 -3
  149. package/worker/secret_scan.py +3 -2
  150. package/worker/server_memory.py +122 -0
  151. package/worker/site_check.py +279 -0
  152. package/worker/skill_library.py +15 -3
  153. package/worker/skill_pack.py +170 -16
  154. package/worker/subagents.py +6 -2
  155. package/worker/tool_catalog.py +4 -3
  156. package/worker/verification.py +156 -19
  157. package/worker/wakeups.py +56 -4
@@ -1,5 +1,5 @@
1
1
  """Cancelable inference and factual completion evidence; no automatic effect replay."""
2
- import json, queue, re, shlex, threading, time, urllib.request
2
+ import json, os, queue, re, shlex, threading, time, urllib.request
3
3
  from pathlib import Path
4
4
 
5
5
  # Keep this classification aligned with lib/conversation-view.ts. A command's exit
@@ -38,14 +38,50 @@ def latest_checks(checks):
38
38
  broader = [c for k, c in items[n + 1:] if k[0] == key[0] and isinstance(k[1], str) and isinstance(key[1], str)
39
39
  and key[1].startswith(k[1] + ' ') and NARROWING.search(key[1][len(k[1]):]) and check_status(c) == 'passed']
40
40
  if broader and check_status(check) == 'failed': continue
41
+ if check_status(check) == 'failed' and isinstance(key[1], str) and _rerun_inside(key, items[n + 1:]): continue
41
42
  out.append(check)
42
43
  return out
43
44
 
45
+ # BUG-0256: `npm test` failed during development, then `until curl -sf localhost:3000; do sleep 1; done && npm test`
46
+ # passed at the end. The combined check reran the same steps, so the earlier failure is history, not the current state.
47
+ _SEGMENT_SPLIT = re.compile(r'\s*(?:&&|\|\||;|\n)\s*')
48
+ _SEGMENT_LEAD = re.compile(r'^(?:(?:until|while|if|then|do|else|elif)\s+|\(\s*)+')
49
+ _TRIVIAL_SEGMENT = re.compile(r'^(?:sleep\b.*|cd\b.*|echo\b.*|printf\b.*|export\b.*|true|false|wait|done|fi|then|do|else|\)|\(|exit\b.*|set\b.*)?$')
50
+
51
+ def check_segments(command):
52
+ """The meaningful steps of a check command, each normalised like check_key."""
53
+ out = []
54
+ for part in _SEGMENT_SPLIT.split(str(command or '')):
55
+ part = check_key(_SEGMENT_LEAD.sub('', part.strip()).rstrip(') ').strip())
56
+ if part and not _TRIVIAL_SEGMENT.match(part): out.append(part)
57
+ return out
58
+
59
+ def _rerun_inside(key, later):
60
+ """Every step of a failing check was rerun by later passing checks in the same scope."""
61
+ steps = check_segments(key[1])
62
+ if not steps: return False
63
+ rerun = set()
64
+ for k, c in later:
65
+ if k[0] == key[0] and isinstance(k[1], str) and check_status(c) == 'passed': rerun.update(check_segments(k[1]))
66
+ return all(s in rerun for s in steps)
67
+
68
+ _ECHO_STATUS = re.compile(r'(?:;|&&|\|\||\n)\s*echo\b[^;&|\n]*\$\{?(?:\?|PIPESTATUS)', re.I)
69
+ _PRINTED_EXIT = re.compile(r'\b(?:exit(?:[ _-]?code)?|exit[ _-]?status|status|rc|code)\s*[=:]\s*(-?\d+)\b', re.I)
70
+ def masked_exit(command, output):
71
+ """`npm test; echo "exit=$?"` exits 0 because echo ran last, while the output says exit=1. Returns the printed failing
72
+ exit code, or None (CLI bug list: such a line was marked "Check passed" and the task ended Done)."""
73
+ if not _ECHO_STATUS.search(str(command or '')): return None
74
+ found = _PRINTED_EXIT.findall(str(output or '')[-4000:])
75
+ if not found: return None
76
+ code = int(found[-1])
77
+ return code if code != 0 else None
78
+
44
79
  def check_status(check):
45
80
  if check.get('executed') is not True: return 'not_run'
46
81
  verdict = check.get('verdict') or {}
47
82
  if verdict.get('status') in ('failed', 'blocked'): return 'failed'
48
83
  if check.get('returncode') not in (0, None): return 'failed'
84
+ if masked_exit(check.get('command'), check.get('output')): return 'failed'
49
85
  if check.get('returncode') is None or (verdict.get('status') not in (None, 'passed')) or ZERO_TEST_OUTPUT.search(str(check.get('output') or '')):
50
86
  return 'inconclusive'
51
87
  # A pass recorded before the last code edit describes code that no longer exists.
@@ -87,12 +123,20 @@ def request_json(request, cancelled, timeout=100):
87
123
  if not ok: raise value
88
124
  return value
89
125
 
90
- def completion_paths(repo,base=None):
126
+ def completion_paths(repo,base=None,since=None):
91
127
  import subprocess
92
128
  from repo_hygiene import change_path,is_noise
93
129
  # -uall lists new files individually instead of collapsing them into a bare folder name.
94
130
  git=subprocess.run(['git','status','--porcelain','-uall'],cwd=repo,capture_output=True,text=True,timeout=10)
95
131
  lines=git.stdout.splitlines() if git.returncode==0 else []
132
+ if since:
133
+ # BUG-0577: a new file that was already there before this run started (made by the person in the Terminal)
134
+ # is not this run's change, so the reply does not offer it as its document.
135
+ def fresh(line):
136
+ if not line.startswith('??'):return True
137
+ try:return os.path.getmtime(os.path.join(repo,change_path(line)))>=float(since)-1
138
+ except (OSError,ValueError,TypeError):return True
139
+ lines=[l for l in lines if fresh(l)]
96
140
  if base:
97
141
  diff=subprocess.run(['git','diff','--name-status',base],cwd=repo,capture_output=True,text=True,timeout=10)
98
142
  if diff.returncode==0:lines=diff.stdout.splitlines()+[line for line in lines if line.startswith('??')]
@@ -107,7 +151,7 @@ def completion_report(root,repo,base=None):
107
151
  try:return json.loads((root/name).read_text())
108
152
  except (OSError,ValueError):return fallback
109
153
  checks=read('checks.json',[]);todos=read('todos.json',[])
110
- changes=completion_paths(repo,base)
154
+ changes=completion_paths(repo,base,read('status.json',{}).get('started') if isinstance(read('status.json',{}),dict) else None)
111
155
  summary = check_summary(checks)
112
156
  unfinished = [t.get('text','') for t in todos if isinstance(t, dict) and t.get('status') not in ('done','cancelled')]
113
157
  note = ('Local checks: %(passed)d passed, %(failed)d failed, %(notRun)d not run, %(inconclusive)d inconclusive.' % summary) if checks else 'No verification checks recorded.'
@@ -147,6 +191,23 @@ def dirty_snapshot(repo,base=None,limit=400):
147
191
  return {p:_fingerprint(repo,p) for p in paths[:limit]}
148
192
 
149
193
 
194
+ START_DIRTY='start-dirty.json'
195
+
196
+ def save_start_dirty(root,repo,base=None):
197
+ """BUG-0495/0497: remember what was already changed or untracked when the turn started, so the checker and the
198
+ "N files changed" summary only count what this turn did. Best effort: a failure keeps the old behavior."""
199
+ try:
200
+ snap=dirty_snapshot(repo,base)
201
+ (Path(root)/START_DIRTY).write_text(json.dumps(snap))
202
+ return snap
203
+ except Exception:return None
204
+
205
+ def turn_changes(root,repo,changed):
206
+ """changed minus the paths that were already like this when the turn started (see save_start_dirty)."""
207
+ try:snap=json.loads((Path(root)/START_DIRTY).read_text())
208
+ except (OSError,ValueError):return list(changed or [])
209
+ return changed_during_turn(repo,changed,snap)
210
+
150
211
  def changed_during_turn(repo,changed,snapshot):
151
212
  """Of the paths changed now, the ones the turn itself changed: new, or different from the start snapshot."""
152
213
  if not isinstance(snapshot,dict):return list(changed or [])
@@ -14,7 +14,8 @@ PATTERNS = [
14
14
  ('github', 'GITHUB_TOKEN', r'\b(?:github_pat_[A-Za-z0-9_]{40,255}|gh[pousr]_[A-Za-z0-9]{30,255})\b'),
15
15
  ('anthropic', 'ANTHROPIC_API_KEY', r'\bsk-ant-[A-Za-z0-9_-]{20,300}'),
16
16
  ('openrouter', 'OPENROUTER_API_KEY', r'\bsk-or-v1-[A-Za-z0-9]{32,128}\b'),
17
- ('openai', 'OPENAI_API_KEY', r'\bsk-(?:proj-|svcacct-|admin-)?[A-Za-z0-9_-]{20,300}'),
17
+ ('openai', 'OPENAI_API_KEY', r'\bsk-(?:proj-|svcacct-|admin-)[A-Za-z0-9_-]{20,300}'),
18
+ ('api_key', 'API_KEY', r'\bsk-[A-Za-z0-9_-]{20,300}'), # BUG-0549: bare sk- keys belong to many services
18
19
  ('stripe', 'STRIPE_SECRET_KEY', r'\b(?:sk|rk)_(?:live|test)_[A-Za-z0-9]{16,255}\b'),
19
20
  ('stripe_webhook', 'STRIPE_WEBHOOK_SECRET', r'\bwhsec_[A-Za-z0-9]{24,255}\b'),
20
21
  ('slack', 'SLACK_TOKEN', r'\bxox[abposr]-[A-Za-z0-9-]{10,255}\b'),
@@ -100,7 +101,7 @@ def findings_for(path, text, allow=()):
100
101
 
101
102
 
102
103
  def describe(f):
103
- label = {'stripe': 'a Stripe key', 'github': 'a GitHub token', 'aws': 'an AWS access key', 'openai': 'an OpenAI key', 'anthropic': 'an Anthropic key', 'pem': 'a private key', 'vercel': 'a Vercel token', 'jwt': 'a signed token (JWT)', 'mlai': 'an ML AI Code token'}.get(f['kind'], 'a credential (' + f['name'] + ')')
104
+ label = {'stripe': 'a Stripe key', 'github': 'a GitHub token', 'aws': 'an AWS access key', 'openai': 'an OpenAI key', 'api_key': 'an API key', 'anthropic': 'an Anthropic key', 'pem': 'a private key', 'vercel': 'a Vercel token', 'jwt': 'a signed token (JWT)', 'mlai': 'an ML AI Code token'}.get(f['kind'], 'a credential (' + f['name'] + ')')
104
105
  return label + ' at ' + f['file'] + ':' + str(f['line'])
105
106
 
106
107
 
@@ -0,0 +1,122 @@
1
+ """BUG-0203: remember the dev servers the agent left running, so a chat that wakes up on a new cloud computer
2
+ can say which servers stopped and offer a one-click Restart. Nothing is restarted by itself: the start
3
+ commands are stored in the run state (.mini/servers.json) and only run when the person clicks Restart.
4
+
5
+ CLI (used by app/api/workspace/route.ts):
6
+ python3 server_memory.py stopped -> JSON list of servers that ran on a previous computer
7
+ python3 server_memory.py restart <id> -> starts that server again in the background
8
+ python3 server_memory.py dismiss [<id>] -> stop showing the notice for one or all servers
9
+ """
10
+ import hashlib, json, os, pathlib, re, socket, subprocess, sys, time
11
+
12
+ FILE = 'servers.json'
13
+ LIMIT = 8
14
+ SERVER = re.compile(
15
+ r'\b(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?(?:dev|start|serve|preview)\b|\bnext\s+(?:dev|start)\b|\bvite(?:\s|$)|'
16
+ r'\bpython3?\s+-m\s+http\.server\b|\buvicorn\b|\bflask\s+run\b|\bgunicorn\b|manage\.py\s+runserver\b|'
17
+ r'\brails\s+s(?:erver)?\b|\bhttp-server\b|\bphp\s+-S\b|\bnode\s+\S*(?:server|app|index|main)\.[cm]?[jt]s\b|'
18
+ r'\bstreamlit\s+run\b|\bjupyter\s+(?:lab|notebook)\b', re.I)
19
+ PORT = re.compile(r'(?:--port[ =]|-p\s+|PORT=|localhost:|0\.0\.0\.0:|127\.0\.0\.1:)(\d{2,5})\b')
20
+
21
+
22
+ def boot_id():
23
+ try: return pathlib.Path('/proc/sys/kernel/random/boot_id').read_text().strip() or socket.gethostname()
24
+ except OSError: return socket.gethostname()
25
+
26
+
27
+ def is_server(command):
28
+ return bool(SERVER.search(str(command or '')))
29
+
30
+
31
+ def _path(root): return pathlib.Path(root) / FILE
32
+
33
+
34
+ def load(root):
35
+ try:
36
+ data = json.loads(_path(root).read_text())
37
+ return [s for s in data if isinstance(s, dict) and s.get('id') and s.get('command')] if isinstance(data, list) else []
38
+ except (OSError, ValueError): return []
39
+
40
+
41
+ def save(root, servers):
42
+ p = _path(root); p.parent.mkdir(parents=True, exist_ok=True)
43
+ tmp = p.with_suffix('.tmp'); tmp.write_text(json.dumps(servers[-LIMIT:])); os.replace(tmp, p)
44
+
45
+
46
+ def label(command):
47
+ m = PORT.search(command)
48
+ head = ' '.join(command.split()[:4])
49
+ return head[:60] + (' (port %s)' % m.group(1) if m else '')
50
+
51
+
52
+ def remember(root, command, cwd, boot=None):
53
+ """Record a server the agent started in the background on this computer."""
54
+ command = str(command or '').strip()
55
+ if not command or not is_server(command) or len(command) > 2000: return None
56
+ sid = hashlib.sha1(command.encode()).hexdigest()[:10]
57
+ port = PORT.search(command)
58
+ entry = {'id': sid, 'command': command, 'cwd': str(cwd or ''), 'label': label(command),
59
+ 'port': int(port.group(1)) if port else None, 'boot': boot or boot_id(), 'time': time.time()}
60
+ servers = [s for s in load(root) if s['id'] != sid] + [entry]
61
+ save(root, servers)
62
+ return entry
63
+
64
+
65
+ def stopped(root, boot=None):
66
+ """Servers recorded on a different computer (boot) that nobody restarted or dismissed."""
67
+ now = boot or boot_id()
68
+ return [{k: s.get(k) for k in ('id', 'command', 'label', 'port')} for s in load(root)
69
+ if s.get('boot') != now and not s.get('dismissed')]
70
+
71
+
72
+ def agent_note(root, boot=None):
73
+ """Once per new computer: tell the agent which servers stopped. It may suggest Restart; it must not assume they run."""
74
+ now = boot or boot_id()
75
+ servers = load(root)
76
+ gone = [s for s in servers if s.get('boot') != now and not s.get('dismissed') and s.get('noted') != now]
77
+ if not gone: return ''
78
+ for s in servers:
79
+ if s in gone: s['noted'] = now
80
+ save(root, servers)
81
+ return ('This chat is on a new cloud computer. Servers that were running before have stopped: '
82
+ + '; '.join(s['command'] for s in gone)
83
+ + '. They are not running now. Do not restart them unless the request needs them; the person can use Restart in the chat.')
84
+
85
+
86
+ def dismiss(root, sid=None):
87
+ servers = load(root)
88
+ for s in servers:
89
+ if sid is None or s['id'] == sid: s['dismissed'] = True
90
+ save(root, servers)
91
+ return {'dismissed': True}
92
+
93
+
94
+ def restart(root, sid, repo, boot=None):
95
+ """Start one remembered server again, detached, logging to .mini/server-<id>.log. Only on an explicit click."""
96
+ servers = load(root)
97
+ hit = next((s for s in servers if s['id'] == sid), None)
98
+ if not hit: return {'error': 'That server is no longer remembered.'}
99
+ try:
100
+ import command_safety
101
+ effect = command_safety.classify(hit['command'], str(repo)).effect
102
+ if effect in ('destructive', 'catastrophic', 'privilege', 'unknown', 'external'):
103
+ return {'error': 'This command needs the agent to run it, so it can ask first.'}
104
+ except Exception: pass
105
+ cwd = hit.get('cwd') or str(repo)
106
+ if not os.path.isdir(cwd): cwd = str(repo)
107
+ log = pathlib.Path(root) / ('server-%s.log' % sid)
108
+ with open(log, 'ab') as out:
109
+ subprocess.Popen(['bash', '-lc', hit['command']], cwd=cwd, stdout=out, stderr=subprocess.STDOUT,
110
+ stdin=subprocess.DEVNULL, start_new_session=True)
111
+ hit['boot'] = boot or boot_id(); hit['time'] = time.time(); hit.pop('dismissed', None)
112
+ save(root, servers)
113
+ return {'restarted': hit['id'], 'label': hit['label'], 'port': hit.get('port')}
114
+
115
+
116
+ if __name__ == '__main__':
117
+ root = pathlib.Path(__file__).resolve().parent
118
+ repo = root.parent / 'repo'
119
+ cmd = sys.argv[1] if len(sys.argv) > 1 else 'stopped'
120
+ if cmd == 'restart': print(json.dumps(restart(root, sys.argv[2] if len(sys.argv) > 2 else '', repo)))
121
+ elif cmd == 'dismiss': print(json.dumps(dismiss(root, sys.argv[2] if len(sys.argv) > 2 else None)))
122
+ else: print(json.dumps(stopped(root)))
@@ -0,0 +1,279 @@
1
+ """Site integrity checks for build runs: navigation that points at pages that do not exist, a preview that answers
2
+ with a server error, and a final message that reports an open error while calling the work verified.
3
+
4
+ Bug report (Nov 16 2026): asked for a 10-page marketing site, the agent built 2 pages, left 7 navigation links that
5
+ 404, wrote "The page itself is now 500ing" and then "Phase 1 is complete and verified". Each of these is now a
6
+ blocking finding, so the final gate sends the agent back to fix it (and the run continues automatically when the
7
+ repair rounds run out).
8
+
9
+ dead_links(repo, changed) -> findings for internal links in changed files whose route does not exist
10
+ live_routes(routes, base_url) -> [(route, status)] for routes the running preview answers with 404 or 5xx
11
+ open_error_claim(text) -> findings when the final message admits an open error yet claims done/verified
12
+ requested_scope(task) -> {'count', 'unit'} when the request names how many pages/screens it wants
13
+ """
14
+ import os, re, time, urllib.request, urllib.error
15
+ from pathlib import Path
16
+
17
+ SKIP_DIRS = frozenset(('.git', 'node_modules', '.next', 'dist', 'build', 'out', '.venv', 'venv', '__pycache__', '.mini', '.vercel', '.turbo', 'coverage', '.svelte-kit', '.astro', '.output'))
18
+ SOURCE = re.compile(r'\.(?:html?|[cm]?[jt]sx?|vue|svelte|astro|mdx?)$', re.I)
19
+ PAGE_EXT = r'(?:[cm]?[jt]sx?|mdx?)'
20
+ # href="/about", href='/about', href={'/about'}, href={"/about"}, href={`/about`}, to="/about", Link href: '/about' in nav arrays.
21
+ LINK = re.compile(r'''(?:\bhref|\bto)\s*=\s*\{?\s*["'`](/[^"'`\s{}$]*)["'`]|\b(?:href|path|url|link|to)\s*:\s*["'`](/[^"'`\s{}$]*)["'`]''')
22
+ ASSET = re.compile(r'\.(?:png|jpe?g|gif|svg|webp|avif|ico|css|js|mjs|map|json|xml|txt|pdf|woff2?|ttf|otf|mp4|webm|mp3|wav|zip|webmanifest)$', re.I)
23
+ MAX_FILES, MAX_BYTES = 600, 400000
24
+
25
+
26
+ def _walk(repo, limit=4000):
27
+ root = Path(repo)
28
+ count = 0
29
+ for base, dirs, files in os.walk(root):
30
+ dirs[:] = [d for d in dirs if d not in SKIP_DIRS and not d.startswith('.')]
31
+ for name in files:
32
+ count += 1
33
+ if count > limit: return
34
+ yield Path(base) / name
35
+
36
+
37
+ def _norm(route):
38
+ route = route.split('#', 1)[0].split('?', 1)[0]
39
+ route = re.sub(r'/{2,}', '/', route)
40
+ if len(route) > 1: route = route.rstrip('/')
41
+ return route or '/'
42
+
43
+
44
+ def _segment_pattern(seg):
45
+ if re.fullmatch(r'\[\[?\.\.\.[^\]]+\]\]?', seg): return '(?:/.*)?' if seg.startswith('[[') else '/.+'
46
+ if re.fullmatch(r'\[[^\]]+\]', seg) or re.fullmatch(r'\$[\w-]*', seg) or seg.startswith(':'): return '/[^/]+'
47
+ return '/' + re.escape(seg)
48
+
49
+
50
+ def _pattern(parts):
51
+ parts = [p for p in parts if p and not (p.startswith('(') and p.endswith(')')) and not p.startswith('@') and p != 'index']
52
+ if not parts: return '/'
53
+ return ''.join(_segment_pattern(p) for p in parts)
54
+
55
+
56
+ def known_routes(repo):
57
+ """(patterns, frameworks): regex patterns for routes the project defines, and which routers were recognised.
58
+ No recognised router means the check cannot judge links, so it reports nothing."""
59
+ root = Path(repo)
60
+ patterns, kinds = set(), set()
61
+ deps = _deps(root)
62
+ # A single-page app (React, Vue, Svelte without a file router) serves index.html for every route; its routes live
63
+ # in the client router, so only that router can say which links are real.
64
+ spa = bool(deps & {'react', 'vue', 'svelte', 'solid-js', 'preact', 'react-dom'}) and not (deps & {'next', 'astro', '@sveltejs/kit', '@remix-run/react', 'gatsby', 'nuxt', '@react-router/dev', 'vitepress'})
65
+ for path in _walk(repo):
66
+ rel = path.relative_to(root).as_posix()
67
+ parts = rel.split('/')
68
+ name = parts[-1]
69
+ # Next.js app router: app/**/page.tsx (also src/app). Route groups and parallel slots do not add a segment.
70
+ for prefix in ('app', 'src/app'):
71
+ pre = prefix.split('/')
72
+ if parts[:len(pre)] == pre and re.fullmatch(r'(?:page|route)\.' + PAGE_EXT, name):
73
+ segs = parts[len(pre):-1]
74
+ if segs[:1] == ['api']: continue
75
+ patterns.add(_pattern(segs)); kinds.add('next-app')
76
+ # Next.js pages router: pages/about.tsx, pages/blog/index.tsx (also src/pages). Astro: src/pages/*.astro.
77
+ for prefix in ('pages', 'src/pages'):
78
+ pre = prefix.split('/')
79
+ if parts[:len(pre)] == pre and re.search(r'\.(?:' + PAGE_EXT + r'|astro|html?)$', name, re.I):
80
+ segs = parts[len(pre):]
81
+ if segs[:1] == ['api'] or name.startswith('_'): continue
82
+ segs[-1] = re.sub(r'\.[^.]+$', '', segs[-1])
83
+ patterns.add(_pattern(segs)); kinds.add('pages')
84
+ # SvelteKit: src/routes/**/+page.svelte
85
+ if parts[:2] == ['src', 'routes'] and name.startswith('+page.'):
86
+ patterns.add(_pattern(parts[2:-1])); kinds.add('sveltekit')
87
+ # Remix flat routes: app/routes/about.tsx, app/routes/blog.$slug.tsx, app/routes/_index.tsx
88
+ if parts[:2] == ['app', 'routes'] and len(parts) == 3 and re.search(r'\.' + PAGE_EXT + '$', name):
89
+ stem = re.sub(r'\.[^.]+$', '', name)
90
+ segs = [s for s in stem.split('.') if s and not s.startswith('_')]
91
+ patterns.add(_pattern(segs)); kinds.add('remix')
92
+ # Static sites: about.html, about/index.html, public/about.html.
93
+ if re.search(r'\.html?$', name, re.I) and parts[0] not in ('src',) and 'node_modules' not in parts:
94
+ segs = parts[1:] if parts[0] in ('public', 'static', 'site', 'docs') else parts
95
+ stem = re.sub(r'\.html?$', '', segs[-1], flags=re.I)
96
+ if stem == '404' or stem.startswith('_'): continue
97
+ route = segs[:-1] + ([] if stem == 'index' else [stem])
98
+ patterns.add(_pattern(route))
99
+ if stem != 'index': patterns.add(_pattern(segs[:-1] + [segs[-1]]))
100
+ kinds.add('static')
101
+ # Client routers: <Route path="/about">, { path: '/about' } in a router file.
102
+ if SOURCE.search(name) and (spa and parts[0] == 'src' or re.search(r'route', rel, re.I) or name in ('App.tsx', 'App.jsx', 'main.tsx', 'main.jsx', 'router.ts', 'router.tsx')):
103
+ text = _read(path)
104
+ if text and re.search(r'react-router|createBrowserRouter|<Route\b|vue-router|createRouter', text):
105
+ for m in re.finditer(r'''\bpath\s*[:=]\s*\{?\s*["'`](/?[^"'`]*)["'`]''', text):
106
+ raw = m.group(1)
107
+ if raw in ('*', '/*'): patterns.add('/.*')
108
+ else: patterns.add(_pattern([s for s in raw.strip('/').split('/') if s != '*']) + ('(?:/.*)?' if raw.endswith('*') else ''))
109
+ kinds.add('client-router')
110
+ if spa and 'client-router' not in kinds:
111
+ return set(), set() # routes are decided at runtime somewhere we cannot read: do not judge links
112
+ # Rewrites and redirects make a source path real even without a page file.
113
+ for cfg in ('next.config.js', 'next.config.mjs', 'next.config.ts', 'next.config.cjs', 'vercel.json', 'netlify.toml', '_redirects', 'public/_redirects'):
114
+ text = _read(root / cfg)
115
+ if not text: continue
116
+ for m in re.finditer(r'''["']?(?:source|from)["']?\s*[:=]\s*["'](/[^"']*)["']''', text):
117
+ patterns.add(re.sub(r'/:[\w]+[*+?]?', '/[^/]+', re.escape(m.group(1)).replace('\\/', '/').replace('\\:', ':')).replace('\\(\\.\\*\\)', '.*') + '(?:/.*)?')
118
+ if cfg.endswith('_redirects'):
119
+ for line in text.splitlines():
120
+ bits = line.split()
121
+ if bits and bits[0].startswith('/'): patterns.add(re.escape(bits[0]).replace('\\*', '.*'))
122
+ return patterns, kinds
123
+
124
+
125
+ def _deps(root):
126
+ try:
127
+ import json
128
+ data = json.loads(_read(Path(root) / 'package.json') or '{}')
129
+ return {k for key in ('dependencies', 'devDependencies') for k in (data.get(key) or {})} if isinstance(data, dict) else set()
130
+ except ValueError:
131
+ return set()
132
+
133
+
134
+ def _read(path):
135
+ try:
136
+ path = Path(path)
137
+ if not path.is_file() or path.is_symlink() or path.stat().st_size > MAX_BYTES: return ''
138
+ return path.read_text(errors='replace')
139
+ except OSError:
140
+ return ''
141
+
142
+
143
+ def internal_links(repo, paths):
144
+ """{route: [files]} for site-internal links written in the given files."""
145
+ found = {}
146
+ for rel in list(paths or [])[:MAX_FILES]:
147
+ if not SOURCE.search(str(rel)) or re.search(r'(^|/)(tests?|__tests__|e2e|node_modules)/|\.(test|spec)\.', str(rel)): continue
148
+ text = _read(Path(repo) / rel)
149
+ for m in LINK.finditer(text):
150
+ raw = m.group(1) or m.group(2)
151
+ if not raw or raw.startswith('//'): continue
152
+ route = _norm(raw)
153
+ if route.startswith(('/api/', '/_next/', '/static/', '/assets/', '/images/', '/img/', '/fonts/')) or route == '/api' or ASSET.search(route): continue
154
+ if '[' in route or ':' in route: continue # a route template, not a link
155
+ found.setdefault(route, [])
156
+ if rel not in found[route]: found[route].append(rel)
157
+ return found
158
+
159
+
160
+ def missing_routes(repo, changed):
161
+ """[(route, files)] for links in changed files that no page, route or rewrite in the project serves."""
162
+ links = internal_links(repo, changed)
163
+ if not links: return []
164
+ patterns, kinds = known_routes(repo)
165
+ if not kinds: return []
166
+ compiled = [re.compile('^' + p + '$') for p in patterns]
167
+ out = []
168
+ for route, files in sorted(links.items()):
169
+ if any(c.match(route) for c in compiled): continue
170
+ # Static sites also serve files dropped in public/ (for example /resume.pdf is filtered above as an asset).
171
+ if 'static' in kinds and ((Path(repo) / route.lstrip('/')).exists() or (Path(repo) / 'public' / route.lstrip('/')).exists()): continue
172
+ out.append((route, files))
173
+ return out
174
+
175
+
176
+ def dead_links(repo, changed):
177
+ gone = missing_routes(repo, changed)
178
+ if not gone: return []
179
+ listed = ', '.join(r + ' (' + f[0] + ')' for r, f in gone[:10]) + (' and %d more' % (len(gone) - 10) if len(gone) > 10 else '')
180
+ return [{'kind': 'dead_link', 'severity': 'block', 'routes': [r for r, _ in gone][:40],
181
+ 'message': 'Links point to pages that do not exist: ' + listed + '. Build every page the user asked for, with real content, '
182
+ 'or remove the link until the page exists. Navigation must never lead to a 404. Then open each route in the preview to confirm it loads.'}]
183
+
184
+
185
+ def live_routes(routes, base_url='http://127.0.0.1:3000', timeout=25, budget=120):
186
+ """[(route, status)] for routes the running preview answers with 404 or a server error. Empty when nothing listens."""
187
+ class NoRedirect(urllib.request.HTTPRedirectHandler):
188
+ def redirect_request(self, *args, **kwargs): return None
189
+ opener = urllib.request.build_opener(urllib.request.ProxyHandler({}), NoRedirect())
190
+ def get(route):
191
+ try:
192
+ with opener.open(base_url + route, timeout=timeout) as r: return r.status
193
+ except urllib.error.HTTPError as e:
194
+ e.close(); return e.code
195
+ except (OSError, urllib.error.URLError, ValueError): return None
196
+ start = time.time()
197
+ first = get('/')
198
+ if first is None: return [] # no preview running: nothing to judge
199
+ bad = [('/', first)] if first >= 500 else []
200
+ for route in [r for r in routes if r != '/'][:20]:
201
+ if time.time() - start > budget: break
202
+ code = get(route)
203
+ if code is not None and (code == 404 or code >= 500): bad.append((route, code))
204
+ return bad
205
+
206
+
207
+ def live_findings(bad):
208
+ if not bad: return []
209
+ errors = [b for b in bad if b[1] >= 500]; missing = [b for b in bad if b[1] == 404]
210
+ parts = []
211
+ if errors: parts.append('server errors on ' + ', '.join('%s (HTTP %d)' % b for b in errors[:8]))
212
+ if missing: parts.append('404 on linked pages ' + ', '.join(r for r, _ in missing[:10]))
213
+ return [{'kind': 'preview_errors', 'severity': 'block', 'routes': [r for r, _ in bad][:40],
214
+ 'message': 'The running preview returns ' + '; '.join(parts) + '. Read the preview log, fix the cause, and load each route again until it answers 200. '
215
+ 'If it truly cannot be fixed in this run, say plainly that it is still broken; do not call the work complete or verified.'}]
216
+
217
+
218
+ # ------------------------------------------------------------------ final-message honesty
219
+ _OPEN_ERROR = re.compile(
220
+ r"\b(?:is|are|was|were|keeps?|still|now)?\s*(?:5\d\d(?:ing|s)\b|returns?\s+(?:an?\s+)?(?:HTTP\s+)?5\d\d|(?:HTTP\s+)?5\d\d\s+(?:error|status|response)s?|internal server error|"
221
+ r"404(?:s|ing)?\s+for\s+now|(?:still|now|currently)\s+(?:broken|crashing|crashes|failing|fails|erroring|errors|down|blank|404s?))\b", re.I)
222
+ _RESOLVED = re.compile(r"\b(?:fixed|resolved|no longer|used to|previously|before (?:the|my|this) fix|was causing|caused|turned out|root cause|now (?:returns?|loads?|answers?|serves?) (?:a )?(?:200|fine|correctly|ok))\b", re.I)
223
+ _DONE = re.compile(r"\b(?:complete[d]?|done|finished|verified|fully working|all working|ready (?:to|for)|shipped|all set|good to go|works? end[\s-]to[\s-]end)\b", re.I)
224
+ _NOT_DONE = re.compile(r"\b(?:not (?:yet )?(?:complete|done|finished|verified)|isn'?t (?:complete|done|verified)|unverified|incomplete|still open|remains? open|unresolved)\b", re.I)
225
+
226
+
227
+ def _sentences(text):
228
+ return [s.strip() for s in re.split(r'(?<=[.!?])\s+|\n+', str(text or '')) if s.strip()]
229
+
230
+
231
+ def open_error_claim(text):
232
+ """A final message that reports an unresolved error and also calls the work complete or verified."""
233
+ sentences = _sentences(text)
234
+ errors = [s for s in sentences if _OPEN_ERROR.search(s) and not _RESOLVED.search(s)]
235
+ if not errors: return []
236
+ if any(_NOT_DONE.search(s) for s in sentences): return [] # the message already reports it as open
237
+ done = [s for s in sentences if _DONE.search(s) and not _OPEN_ERROR.search(s)]
238
+ if not done: return []
239
+ return [{'kind': 'open_error_claim', 'severity': 'block',
240
+ 'message': 'The final message reports an open error ("' + errors[0][:160] + '") but also says the work is finished or verified ("' + done[0][:120] + '"). '
241
+ 'Fix the error and check the affected page again. If it cannot be fixed now, report it as unresolved and do not call the work complete or verified.'}]
242
+
243
+
244
+ # ------------------------------------------------------------------ requested scope
245
+ _NUMBERS = {'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9, 'ten': 10, 'eleven': 11, 'twelve': 12,
246
+ 'fifteen': 15, 'twenty': 20, 'a dozen': 12, 'dozen': 12}
247
+ _UNITS = r'(?:pages?|screens?|routes?|views?|sections?|landing\s+pages?|templates?|tabs?|steps?|endpoints?|components?|blog\s+posts?|posts?|articles?)'
248
+ _SCOPE = re.compile(r'\b(\d{1,3}|' + '|'.join(sorted(map(re.escape, _NUMBERS), key=len, reverse=True)) + r')[\s-]+(?:\w+[\s-]+){0,2}?(' + _UNITS + r')\b', re.I)
249
+ _LIST = re.compile(r'\bpages?\s*(?::|including|like|such as|for)\s*([^\n.]{3,300})', re.I)
250
+
251
+
252
+ def requested_scope(task):
253
+ """What the person explicitly asked for: {'count': 10, 'unit': 'pages', 'names': [...]}, or None."""
254
+ text = str(task or '')[-6000:]
255
+ best = None
256
+ for m in _SCOPE.finditer(text):
257
+ raw = m.group(1).lower()
258
+ count = int(raw) if raw.isdigit() else _NUMBERS.get(raw)
259
+ if not count or count < 2 or count > 200: continue
260
+ unit = re.sub(r'\s+', ' ', m.group(2).lower())
261
+ if not unit.endswith('s'): unit += 's'
262
+ if best is None or count > best['count']: best = {'count': count, 'unit': unit, 'names': []}
263
+ lst = _LIST.search(text)
264
+ if lst:
265
+ names = [n.strip(' "\'`') for n in re.split(r',|\band\b|/|;', lst.group(1)) if 1 < len(n.strip(' "\'`')) < 40][:40]
266
+ if len(names) >= 2:
267
+ if best is None: best = {'count': len(names), 'unit': 'pages', 'names': names}
268
+ else: best['names'] = names
269
+ return best
270
+
271
+
272
+ def scope_rule(scope):
273
+ """Prompt text that makes an explicit request binding for this run."""
274
+ if not scope: return ''
275
+ names = (' (' + ', '.join(scope['names']) + ')') if scope.get('names') else ''
276
+ return ('Requested scope: the user asked for %d %s%s. Deliver all %d in this run, each with real, finished content and working navigation; when you plan phases, Phase 1 contains every one of them. '
277
+ 'Do not split the requested %s across phases and do not stop after a subset; later phases may only add work beyond what was asked '
278
+ '(polish, integrations, extras). If it truly cannot fit, say so before you start and ask how to proceed; never decide on your own to deliver part of it. '
279
+ 'Before finishing, open every %s in the preview and confirm each loads without errors.' % (scope['count'], scope['unit'], names, scope['count'], scope['unit'], scope['unit'].rstrip('s')))
@@ -6,7 +6,7 @@ from pathlib import Path
6
6
 
7
7
  MAX_BODY = 20000
8
8
  MAX_AUTO = 3
9
- MAX_CATALOG = 60
9
+ MAX_CATALOG = 90
10
10
  _ID = re.compile(r'^[a-z0-9][a-z0-9-]{0,59}$')
11
11
 
12
12
  def _clean(skill, source):
@@ -17,6 +17,7 @@ def _clean(skill, source):
17
17
  return {'id': skill['id'], 'name': str(skill.get('name') or skill['id'])[:100], 'description': str(skill.get('description') or '')[:300],
18
18
  'content': skill['content'][:MAX_BODY], 'triggers': words('triggers'), 'paths': words('paths'),
19
19
  'files': {str(k)[:80]: str(v)[:MAX_BODY] for k, v in list(files.items())[:10] if isinstance(v, str)},
20
+ 'requires': [str(x)[:60] for x in (skill.get('requires') or []) if isinstance(x, str)][:3],
20
21
  'always': skill.get('always') is True, 'enabled': skill.get('enabled', True) is not False, 'source': source}
21
22
 
22
23
  def load_skills(root):
@@ -75,6 +76,16 @@ def select(task, skills, limit=MAX_AUTO, preferred=()):
75
76
  if hits:
76
77
  scored.append((hits, s))
77
78
  scored.sort(key=lambda x: (-x[0], x[1]['id']))
79
+ out = _select(explicit, always, scored, skills, limit, preferred)
80
+ # A companion skill brings the skill it builds on (deck-types needs presentations), ahead of it.
81
+ by_id = {s['id']: s for s in skills}
82
+ for s in list(out):
83
+ for need in s.get('requires') or ():
84
+ if need in by_id and by_id[need] not in out:
85
+ out.insert(out.index(s), by_id[need])
86
+ return out
87
+
88
+ def _select(explicit, always, scored, skills, limit, preferred):
78
89
  if preferred:
79
90
  # Role skills come first (up to 3), then the strongest trigger matches fill the remaining slots.
80
91
  by_id = {s['id']: s for s in skills}
@@ -85,7 +96,8 @@ def select(task, skills, limit=MAX_AUTO, preferred=()):
85
96
 
86
97
  def catalog(skills, loaded=()):
87
98
  names = {s['id'] for s in loaded}
88
- rows = ['- ' + s['id'] + ': ' + (s['description'] or s['name'])[:160] + (' (loaded)' if s['id'] in names else '') for s in skills[:MAX_CATALOG]]
99
+ ordered = [s for s in skills if s.get('source') != 'pack'] + [s for s in skills if s.get('source') == 'pack'] # the project's own skills never fall off the end
100
+ rows = ['- ' + s['id'] + ': ' + (s['description'] or s['name'])[:160] + (' (loaded)' if s['id'] in names else '') for s in ordered[:MAX_CATALOG]]
89
101
  return '\n'.join(rows)
90
102
 
91
103
  def body(skill):
@@ -108,7 +120,7 @@ def load(skills, args):
108
120
  raise ValueError('Provide a skill id')
109
121
  skill = next((s for s in skills if s['id'] == args['id']), None)
110
122
  if not skill:
111
- raise ValueError('Unknown or disabled skill. Available: ' + ', '.join(s['id'] for s in skills[:60]))
123
+ raise ValueError('Unknown or disabled skill. Available: ' + ', '.join(s['id'] for s in skills[:MAX_CATALOG]))
112
124
  name = args.get('file')
113
125
  if name is not None:
114
126
  if not isinstance(name, str) or name not in skill['files']: