@pentoshi/clai 3.6.0 → 3.7.3

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 (322) hide show
  1. package/dist/agent/compaction-summary.d.ts +17 -0
  2. package/dist/agent/compaction-summary.js +64 -0
  3. package/dist/agent/compaction-summary.js.map +1 -0
  4. package/dist/agent/confirm-port.d.ts +3 -1
  5. package/dist/agent/confirm-port.js +5 -1
  6. package/dist/agent/confirm-port.js.map +1 -1
  7. package/dist/agent/context-manager.js +45 -22
  8. package/dist/agent/context-manager.js.map +1 -1
  9. package/dist/agent/events.d.ts +6 -0
  10. package/dist/agent/evidence-governor.d.ts +37 -0
  11. package/dist/agent/evidence-governor.js +70 -0
  12. package/dist/agent/evidence-governor.js.map +1 -0
  13. package/dist/agent/loop-guard.d.ts +29 -11
  14. package/dist/agent/loop-guard.js +93 -39
  15. package/dist/agent/loop-guard.js.map +1 -1
  16. package/dist/agent/must-continue.d.ts +56 -0
  17. package/dist/agent/must-continue.js +240 -0
  18. package/dist/agent/must-continue.js.map +1 -0
  19. package/dist/agent/outcomes.d.ts +101 -0
  20. package/dist/agent/outcomes.js +359 -0
  21. package/dist/agent/outcomes.js.map +1 -0
  22. package/dist/agent/plan-decision.d.ts +33 -0
  23. package/dist/agent/plan-decision.js +104 -0
  24. package/dist/agent/plan-decision.js.map +1 -0
  25. package/dist/agent/plan-tool.d.ts +12 -0
  26. package/dist/agent/plan-tool.js +312 -104
  27. package/dist/agent/plan-tool.js.map +1 -1
  28. package/dist/agent/project-root.js +3 -0
  29. package/dist/agent/project-root.js.map +1 -1
  30. package/dist/agent/prompt-composer.d.ts +21 -0
  31. package/dist/agent/prompt-composer.js +46 -0
  32. package/dist/agent/prompt-composer.js.map +1 -0
  33. package/dist/agent/runner.d.ts +11 -1
  34. package/dist/agent/runner.js +1226 -971
  35. package/dist/agent/runner.js.map +1 -1
  36. package/dist/agent/scope-context.d.ts +3 -0
  37. package/dist/agent/scope-context.js +24 -0
  38. package/dist/agent/scope-context.js.map +1 -0
  39. package/dist/agent/scratch-write.d.ts +4 -0
  40. package/dist/agent/scratch-write.js +54 -0
  41. package/dist/agent/scratch-write.js.map +1 -0
  42. package/dist/agent/session-policy.d.ts +7 -0
  43. package/dist/agent/session-policy.js +61 -0
  44. package/dist/agent/session-policy.js.map +1 -1
  45. package/dist/agent/session-state.d.ts +41 -0
  46. package/dist/agent/session-state.js +107 -0
  47. package/dist/agent/session-state.js.map +1 -0
  48. package/dist/agent/step-budget.d.ts +14 -0
  49. package/dist/agent/step-budget.js +26 -0
  50. package/dist/agent/step-budget.js.map +1 -0
  51. package/dist/agent/task-analyzer.d.ts +12 -3
  52. package/dist/agent/task-analyzer.js +263 -23
  53. package/dist/agent/task-analyzer.js.map +1 -1
  54. package/dist/agent/task-evidence.d.ts +111 -29
  55. package/dist/agent/task-evidence.js +519 -91
  56. package/dist/agent/task-evidence.js.map +1 -1
  57. package/dist/agent/task-plan.d.ts +57 -0
  58. package/dist/agent/task-plan.js +147 -1
  59. package/dist/agent/task-plan.js.map +1 -1
  60. package/dist/agent/tool-call-parser.d.ts +4 -12
  61. package/dist/agent/tool-call-parser.js +34 -67
  62. package/dist/agent/tool-call-parser.js.map +1 -1
  63. package/dist/agent/tool-history.d.ts +7 -0
  64. package/dist/agent/tool-history.js +50 -0
  65. package/dist/agent/tool-history.js.map +1 -1
  66. package/dist/agent/tool-output-formatting.d.ts +13 -1
  67. package/dist/agent/tool-output-formatting.js +75 -22
  68. package/dist/agent/tool-output-formatting.js.map +1 -1
  69. package/dist/agent/turn-outcome.d.ts +11 -0
  70. package/dist/agent/turn-outcome.js +17 -0
  71. package/dist/agent/turn-outcome.js.map +1 -0
  72. package/dist/agent/turn-state.d.ts +11 -0
  73. package/dist/agent/turn-state.js +28 -0
  74. package/dist/agent/turn-state.js.map +1 -0
  75. package/dist/agent/workspace-orient.d.ts +11 -0
  76. package/dist/agent/workspace-orient.js +103 -12
  77. package/dist/agent/workspace-orient.js.map +1 -1
  78. package/dist/app/adapters/agent-event-adapter.d.ts +2 -13
  79. package/dist/app/adapters/agent-event-adapter.js +63 -25
  80. package/dist/app/adapters/agent-event-adapter.js.map +1 -1
  81. package/dist/app/adapters/current-agent-adapter.d.ts +0 -5
  82. package/dist/app/adapters/current-agent-adapter.js +4 -7
  83. package/dist/app/adapters/current-agent-adapter.js.map +1 -1
  84. package/dist/app/adapters/current-jobs-adapter.js +1 -0
  85. package/dist/app/adapters/current-jobs-adapter.js.map +1 -1
  86. package/dist/app/adapters/current-terminal-adapter.d.ts +0 -7
  87. package/dist/app/adapters/current-terminal-adapter.js +0 -7
  88. package/dist/app/adapters/current-terminal-adapter.js.map +1 -1
  89. package/dist/app/adapters/current-updates-adapter.d.ts +0 -5
  90. package/dist/app/adapters/current-updates-adapter.js +0 -5
  91. package/dist/app/adapters/current-updates-adapter.js.map +1 -1
  92. package/dist/app/adapters/in-memory-clipboard-adapter.d.ts +0 -5
  93. package/dist/app/adapters/in-memory-clipboard-adapter.js +0 -5
  94. package/dist/app/adapters/in-memory-clipboard-adapter.js.map +1 -1
  95. package/dist/app/commands/command.d.ts +0 -5
  96. package/dist/app/commands/command.js.map +1 -1
  97. package/dist/app/commands/registry.d.ts +0 -14
  98. package/dist/app/commands/registry.js +0 -20
  99. package/dist/app/commands/registry.js.map +1 -1
  100. package/dist/app/controllers/disposable.d.ts +0 -5
  101. package/dist/app/controllers/disposable.js +0 -5
  102. package/dist/app/controllers/disposable.js.map +1 -1
  103. package/dist/app/controllers/job-controller.d.ts +1 -5
  104. package/dist/app/controllers/job-controller.js +0 -4
  105. package/dist/app/controllers/job-controller.js.map +1 -1
  106. package/dist/app/controllers/plan-controller.d.ts +5 -8
  107. package/dist/app/controllers/plan-controller.js +30 -12
  108. package/dist/app/controllers/plan-controller.js.map +1 -1
  109. package/dist/app/controllers/session-controller.d.ts +17 -32
  110. package/dist/app/controllers/session-controller.js +56 -35
  111. package/dist/app/controllers/session-controller.js.map +1 -1
  112. package/dist/app/controllers/turn-controller.d.ts +2 -6
  113. package/dist/app/controllers/turn-controller.js +8 -8
  114. package/dist/app/controllers/turn-controller.js.map +1 -1
  115. package/dist/app/events/app-event.d.ts +4 -7
  116. package/dist/app/events/app-event.js +0 -6
  117. package/dist/app/events/app-event.js.map +1 -1
  118. package/dist/app/events/event-buffer.d.ts +6 -17
  119. package/dist/app/events/event-buffer.js +27 -24
  120. package/dist/app/events/event-buffer.js.map +1 -1
  121. package/dist/app/events/sequencer.d.ts +0 -9
  122. package/dist/app/events/sequencer.js +0 -4
  123. package/dist/app/events/sequencer.js.map +1 -1
  124. package/dist/app/ports/agent-port.d.ts +13 -3
  125. package/dist/app/ports/clipboard-port.d.ts +0 -5
  126. package/dist/app/ports/confirm-port.d.ts +0 -7
  127. package/dist/app/ports/jobs-port.d.ts +2 -5
  128. package/dist/app/ports/persistence-port.d.ts +0 -4
  129. package/dist/app/ports/secret-port.d.ts +0 -5
  130. package/dist/app/ports/terminal-port.d.ts +0 -6
  131. package/dist/app/ports/updates-port.d.ts +0 -4
  132. package/dist/attachments/service.d.ts +29 -0
  133. package/dist/attachments/service.js +47 -0
  134. package/dist/attachments/service.js.map +1 -0
  135. package/dist/commands/providers.js +0 -3
  136. package/dist/commands/providers.js.map +1 -1
  137. package/dist/commands/search-providers.d.ts +0 -33
  138. package/dist/commands/search-providers.js +0 -33
  139. package/dist/commands/search-providers.js.map +1 -1
  140. package/dist/commands/update.js +1 -9
  141. package/dist/commands/update.js.map +1 -1
  142. package/dist/index.js +22 -42
  143. package/dist/index.js.map +1 -1
  144. package/dist/llm/adapters/ollama-tools.d.ts +0 -4
  145. package/dist/llm/adapters/ollama-tools.js +0 -4
  146. package/dist/llm/adapters/ollama-tools.js.map +1 -1
  147. package/dist/llm/capabilities.d.ts +10 -10
  148. package/dist/llm/capabilities.js +43 -17
  149. package/dist/llm/capabilities.js.map +1 -1
  150. package/dist/llm/groq.js +0 -6
  151. package/dist/llm/groq.js.map +1 -1
  152. package/dist/llm/http.d.ts +0 -17
  153. package/dist/llm/http.js +0 -45
  154. package/dist/llm/http.js.map +1 -1
  155. package/dist/llm/router.d.ts +0 -6
  156. package/dist/llm/router.js +0 -15
  157. package/dist/llm/router.js.map +1 -1
  158. package/dist/llm/tool-protocol.d.ts +0 -6
  159. package/dist/llm/tool-protocol.js +3 -7
  160. package/dist/llm/tool-protocol.js.map +1 -1
  161. package/dist/modes/agent.d.ts +2 -1
  162. package/dist/modes/agent.js +4 -2
  163. package/dist/modes/agent.js.map +1 -1
  164. package/dist/modes/ask.d.ts +0 -18
  165. package/dist/modes/ask.js +0 -49
  166. package/dist/modes/ask.js.map +1 -1
  167. package/dist/os/cwd.d.ts +0 -21
  168. package/dist/os/cwd.js +0 -24
  169. package/dist/os/cwd.js.map +1 -1
  170. package/dist/os/pkgmgr.js +0 -6
  171. package/dist/os/pkgmgr.js.map +1 -1
  172. package/dist/prompts/embedded.d.ts +1 -0
  173. package/dist/prompts/embedded.js +9 -0
  174. package/dist/prompts/embedded.js.map +1 -0
  175. package/dist/prompts/index.d.ts +6 -18
  176. package/dist/prompts/index.js +104 -293
  177. package/dist/prompts/index.js.map +1 -1
  178. package/dist/prompts/system.agent.md +228 -0
  179. package/dist/prompts/system.ask.md +56 -0
  180. package/dist/repl/prompt-line.js +0 -36
  181. package/dist/repl/prompt-line.js.map +1 -1
  182. package/dist/repl/slash-commands.d.ts +0 -9
  183. package/dist/repl/slash-commands.js +2 -23
  184. package/dist/repl/slash-commands.js.map +1 -1
  185. package/dist/repl.d.ts +5 -0
  186. package/dist/repl.js +169 -55
  187. package/dist/repl.js.map +1 -1
  188. package/dist/safety/classifier.js +17 -9
  189. package/dist/safety/classifier.js.map +1 -1
  190. package/dist/safety/engagement-policy.d.ts +46 -0
  191. package/dist/safety/engagement-policy.js +198 -0
  192. package/dist/safety/engagement-policy.js.map +1 -0
  193. package/dist/store/engagement.d.ts +115 -0
  194. package/dist/store/engagement.js +278 -0
  195. package/dist/store/engagement.js.map +1 -0
  196. package/dist/store/logs.d.ts +5 -0
  197. package/dist/store/logs.js +52 -2
  198. package/dist/store/logs.js.map +1 -1
  199. package/dist/store/plan.d.ts +57 -5
  200. package/dist/store/plan.js +182 -8
  201. package/dist/store/plan.js.map +1 -1
  202. package/dist/store/scope.d.ts +4 -1
  203. package/dist/store/scope.js +2 -2
  204. package/dist/store/scope.js.map +1 -1
  205. package/dist/tools/definitions.js +70 -1
  206. package/dist/tools/definitions.js.map +1 -1
  207. package/dist/tools/elevated-shell.d.ts +60 -0
  208. package/dist/tools/elevated-shell.js +233 -0
  209. package/dist/tools/elevated-shell.js.map +1 -0
  210. package/dist/tools/file-diff.d.ts +125 -0
  211. package/dist/tools/file-diff.js +495 -0
  212. package/dist/tools/file-diff.js.map +1 -0
  213. package/dist/tools/fs.d.ts +11 -13
  214. package/dist/tools/fs.js +269 -78
  215. package/dist/tools/fs.js.map +1 -1
  216. package/dist/tools/http.d.ts +15 -0
  217. package/dist/tools/http.js +202 -61
  218. package/dist/tools/http.js.map +1 -1
  219. package/dist/tools/jobs.d.ts +71 -10
  220. package/dist/tools/jobs.js +403 -124
  221. package/dist/tools/jobs.js.map +1 -1
  222. package/dist/tools/nmap-runner.d.ts +11 -0
  223. package/dist/tools/nmap-runner.js +115 -74
  224. package/dist/tools/nmap-runner.js.map +1 -1
  225. package/dist/tools/pentest-workflows.d.ts +8 -0
  226. package/dist/tools/pentest-workflows.js +71 -0
  227. package/dist/tools/pentest-workflows.js.map +1 -0
  228. package/dist/tools/registry.d.ts +9 -0
  229. package/dist/tools/registry.js +244 -57
  230. package/dist/tools/registry.js.map +1 -1
  231. package/dist/tools/shell.d.ts +3 -0
  232. package/dist/tools/shell.js +35 -13
  233. package/dist/tools/shell.js.map +1 -1
  234. package/dist/tools/tool-types.d.ts +11 -0
  235. package/dist/tools/web/fetch-core.d.ts +7 -0
  236. package/dist/tools/web/fetch-core.js +40 -1
  237. package/dist/tools/web/fetch-core.js.map +1 -1
  238. package/dist/tools/web/fetch.js +8 -1
  239. package/dist/tools/web/fetch.js.map +1 -1
  240. package/dist/tui-v2/app/App.js +34 -41
  241. package/dist/tui-v2/app/App.js.map +1 -1
  242. package/dist/tui-v2/app/command-handlers.js +20 -1
  243. package/dist/tui-v2/app/command-handlers.js.map +1 -1
  244. package/dist/tui-v2/app/commands/picker-commands.js +3 -0
  245. package/dist/tui-v2/app/commands/picker-commands.js.map +1 -1
  246. package/dist/tui-v2/app/commands/session-commands.js +5 -0
  247. package/dist/tui-v2/app/commands/session-commands.js.map +1 -1
  248. package/dist/tui-v2/app/plan-lifecycle.d.ts +25 -3
  249. package/dist/tui-v2/app/plan-lifecycle.js +87 -24
  250. package/dist/tui-v2/app/plan-lifecycle.js.map +1 -1
  251. package/dist/tui-v2/bootstrap/patch-opentui-text.d.ts +6 -0
  252. package/dist/tui-v2/bootstrap/patch-opentui-text.js +53 -0
  253. package/dist/tui-v2/bootstrap/patch-opentui-text.js.map +1 -0
  254. package/dist/tui-v2/bootstrap/start-tui-v2.js +7 -0
  255. package/dist/tui-v2/bootstrap/start-tui-v2.js.map +1 -1
  256. package/dist/tui-v2/components/jobs/jobs-panel.js +23 -14
  257. package/dist/tui-v2/components/jobs/jobs-panel.js.map +1 -1
  258. package/dist/tui-v2/components/modal/confirm-modal.d.ts +1 -1
  259. package/dist/tui-v2/components/modal/confirm-modal.js +18 -7
  260. package/dist/tui-v2/components/modal/confirm-modal.js.map +1 -1
  261. package/dist/tui-v2/components/overlay/overlay-host.js +1 -1
  262. package/dist/tui-v2/components/overlay/overlay-host.js.map +1 -1
  263. package/dist/tui-v2/components/pager/pager.d.ts +6 -0
  264. package/dist/tui-v2/components/pager/pager.js +313 -67
  265. package/dist/tui-v2/components/pager/pager.js.map +1 -1
  266. package/dist/tui-v2/components/status/status-line.d.ts +9 -0
  267. package/dist/tui-v2/components/status/status-line.js +17 -3
  268. package/dist/tui-v2/components/status/status-line.js.map +1 -1
  269. package/dist/tui-v2/components/transcript/assistant-message.js +1 -1
  270. package/dist/tui-v2/components/transcript/assistant-message.js.map +1 -1
  271. package/dist/tui-v2/components/transcript/compacted-row.js +1 -1
  272. package/dist/tui-v2/components/transcript/compacted-row.js.map +1 -1
  273. package/dist/tui-v2/components/transcript/tool-card.d.ts +9 -1
  274. package/dist/tui-v2/components/transcript/tool-card.js +114 -9
  275. package/dist/tui-v2/components/transcript/tool-card.js.map +1 -1
  276. package/dist/tui-v2/components/transcript/transcript-row.js +2 -2
  277. package/dist/tui-v2/components/transcript/transcript-row.js.map +1 -1
  278. package/dist/tui-v2/composer/composer-editor.js +16 -0
  279. package/dist/tui-v2/composer/composer-editor.js.map +1 -1
  280. package/dist/tui-v2/controllers/overlay-controller.d.ts +16 -2
  281. package/dist/tui-v2/controllers/overlay-controller.js +92 -12
  282. package/dist/tui-v2/controllers/overlay-controller.js.map +1 -1
  283. package/dist/tui-v2/rendering/artifact-pager-source.d.ts +19 -0
  284. package/dist/tui-v2/rendering/artifact-pager-source.js +103 -0
  285. package/dist/tui-v2/rendering/artifact-pager-source.js.map +1 -0
  286. package/dist/tui-v2/rendering/file-diff-view.d.ts +63 -0
  287. package/dist/tui-v2/rendering/file-diff-view.js +263 -0
  288. package/dist/tui-v2/rendering/file-diff-view.js.map +1 -0
  289. package/dist/tui-v2/rendering/open-tool-output.d.ts +9 -1
  290. package/dist/tui-v2/rendering/open-tool-output.js +65 -12
  291. package/dist/tui-v2/rendering/open-tool-output.js.map +1 -1
  292. package/dist/tui-v2/rendering/pager-chrome.d.ts +12 -0
  293. package/dist/tui-v2/rendering/pager-chrome.js +56 -0
  294. package/dist/tui-v2/rendering/pager-chrome.js.map +1 -0
  295. package/dist/tui-v2/rendering/plan-view.js +1 -1
  296. package/dist/tui-v2/rendering/plan-view.js.map +1 -1
  297. package/dist/tui-v2/rendering/syntax-highlight.d.ts +37 -0
  298. package/dist/tui-v2/rendering/syntax-highlight.js +1303 -0
  299. package/dist/tui-v2/rendering/syntax-highlight.js.map +1 -0
  300. package/dist/tui-v2/rendering/theme.d.ts +28 -0
  301. package/dist/tui-v2/rendering/theme.js +28 -0
  302. package/dist/tui-v2/rendering/theme.js.map +1 -1
  303. package/dist/tui-v2/rendering/tool-presenter.d.ts +5 -0
  304. package/dist/tui-v2/rendering/tool-presenter.js +35 -3
  305. package/dist/tui-v2/rendering/tool-presenter.js.map +1 -1
  306. package/dist/tui-v2/state/transcript-hydrate.js +5 -0
  307. package/dist/tui-v2/state/transcript-hydrate.js.map +1 -1
  308. package/dist/tui-v2/state/transcript-reducer.js +12 -2
  309. package/dist/tui-v2/state/transcript-reducer.js.map +1 -1
  310. package/dist/tui-v2/state/transcript-store.d.ts +7 -0
  311. package/dist/tui-v2/state/transcript-store.js +46 -0
  312. package/dist/tui-v2/state/transcript-store.js.map +1 -1
  313. package/dist/tui-v2/state/transcript-types.d.ts +12 -0
  314. package/dist/tui-v2/state/transcript-types.js +9 -0
  315. package/dist/tui-v2/state/transcript-types.js.map +1 -1
  316. package/dist/types.d.ts +17 -1
  317. package/dist/ui/mentions.d.ts +6 -0
  318. package/dist/ui/mentions.js +50 -12
  319. package/dist/ui/mentions.js.map +1 -1
  320. package/dist/ui/plan-pane.js +1 -1
  321. package/dist/ui/plan-pane.js.map +1 -1
  322. package/package.json +18 -12
@@ -1,33 +1,273 @@
1
+ import { createPlanStep } from "./task-plan.js";
2
+ const PENTEST_RE = /\b(?:pentest|pen[\s-]?test|penetration|security\s*(?:test|audit|scan|assess)|vapt|csrf|xss|sqli|sql[\s-]?inject|rce|lfi|rfi|ssrf|idor|xxe|deserialization|brute[\s-]?force|enumerat|exploit|vulnerabilit|recon|bug[\s-]?bounty|ctf|capture[\s-]?the[\s-]?flag|red[\s-]?team|offensive|nmap|nikto|nuclei|ffuf|gobuster|sqlmap|hydra|metasploit)\b/i;
3
+ const BUILD_RE = /\b(?:build|scaffold|create|implement|refactor|migrate|bootstrap|set\s*up|setup)\b/i;
4
+ const APP_RE = /\b(?:app|application|project|website|api|service|cli|dashboard|todo|blog|frontend|backend)\b/i;
5
+ const FIX_RE = /\b(?:fix|debug|broken|error|failing|crash|bug|regression|not\s+work|doesn'?t\s+work|typeerror|exception)\b/i;
6
+ const RESEARCH_RE = /\b(?:what\s+is|how\s+(?:do|does|to)|explain|compare|difference|latest|current|who\s+is|when\s+did|why\s+(?:is|does))\b/i;
7
+ const NETWORK_RE = /\b(?:scan|nmap|ping|subnet|cidr|local\s*network|hosts?|ports?|dns|whois|http|https|url|domain|ip\s*address)\b/i;
8
+ const SHELL_RE = /\b(?:run|execute|install|upgrade|brew|apt|npm\s+i|docker|kubectl|chmod|chown|kill|restart|service)\b/i;
9
+ const FS_RE = /\b(?:read|write|edit|file|directory|folder|path|rename|delete|list\s+files?|open\s+)\b/i;
1
10
  /**
2
- * Pentest / security keywords these tasks are inherently multi-step and
3
- * always deserve the full step budget regardless of how terse the prompt is.
11
+ * A bounded, explicit nmap operation is not a request for a full pentest.
12
+ * Keep it to one net.scan call unless the user also asks for assessment,
13
+ * reconnaissance, enumeration, exploitation, or multiple named operations.
4
14
  */
5
- const PENTEST_RE = /\b(?:pentest|pen[\s-]?test|penetration|security\s*(?:test|audit|scan|assess)|csrf|xss|sqli|sql[\s-]?inject|rce|lfi|rfi|ssrf|idor|xxe|deserialization|brute[\s-]?force|enumerat|exploit|vulnerabilit|recon|bug[\s-]?bounty|ctf|capture[\s-]?the[\s-]?flag|red[\s-]?team|offensive|nmap|nikto|nuclei|ffuf|gobuster|sqlmap|hydra|metasploit)\b/i;
15
+ export function isNarrowExplicitNmapOperation(prompt) {
16
+ const text = prompt.replace(/\s+/g, " ").trim();
17
+ if (!/\bnmap\b/i.test(text))
18
+ return false;
19
+ const explicitRun = /^(?:sudo\s+)?nmap(?:\s|$)/i.test(text) ||
20
+ /\b(?:run|execute|start|perform)\b[\s\S]{0,40}\bnmap\b/i.test(text) ||
21
+ /\bnmap\b[\s\S]{0,20}\bscan\b/i.test(text) ||
22
+ /\bscan\b[\s\S]{0,40}\bwith\s+nmap\b/i.test(text);
23
+ if (!explicitRun)
24
+ return false;
25
+ if (/\b(?:pentest|pen[\s-]?test|penetration|security\s+(?:audit|assessment|test)|vapt|recon(?:naissance)?|enumerat\w*|attack\s+surface|vulnerabilit\w*|exploit\w*|bug\s*bounty|red\s*team|threat\s+model|web\s+assessment)\b/i.test(text)) {
26
+ return false;
27
+ }
28
+ if (/\b(?:and|then|also)\b[\s\S]{0,40}\b(?:whois|dns|dig|http|crawl|fuzz|nikto|nuclei|sqlmap|gobuster|ffuf)\b/i.test(text)) {
29
+ return false;
30
+ }
31
+ return true;
32
+ }
33
+ function wordCount(prompt) {
34
+ return prompt.trim().split(/\s+/).filter(Boolean).length;
35
+ }
36
+ function classifyCategory(prompt) {
37
+ if (PENTEST_RE.test(prompt)) {
38
+ if (/\b(?:dns|whois|subdomain)\b/i.test(prompt))
39
+ return "dns";
40
+ if (/\b(?:whois|registrar|owner)\b/i.test(prompt))
41
+ return "whois";
42
+ if (/\b(?:dir|fuzz|gobuster|ffuf|content\s*discover)\b/i.test(prompt)) {
43
+ return "web-enum";
44
+ }
45
+ if (/\b(?:recon|enumerat|osint|fingerprint)\b/i.test(prompt)) {
46
+ return "pentest-recon";
47
+ }
48
+ return "pentest-recon";
49
+ }
50
+ if (/\b(?:whois)\b/i.test(prompt))
51
+ return "whois";
52
+ if (/\b(?:dns|dig|nslookup|resolve)\b/i.test(prompt))
53
+ return "dns";
54
+ if (NETWORK_RE.test(prompt) && /\b(?:discover|sweep|live\s*hosts?)\b/i.test(prompt)) {
55
+ return "network-discovery";
56
+ }
57
+ if (/\b(?:pkg|package|brew\s+install|apt\s+install|install\s+\w+)\b/i.test(prompt)) {
58
+ return "package";
59
+ }
60
+ if (BUILD_RE.test(prompt) || FIX_RE.test(prompt) || FS_RE.test(prompt)) {
61
+ return "filesystem";
62
+ }
63
+ if (SHELL_RE.test(prompt))
64
+ return "shell";
65
+ if (RESEARCH_RE.test(prompt) || prompt.trim().endsWith("?"))
66
+ return "answer";
67
+ return "other";
68
+ }
69
+ function estimateComplexity(prompt, category, words) {
70
+ if (PENTEST_RE.test(prompt))
71
+ return "complex";
72
+ if (BUILD_RE.test(prompt) && APP_RE.test(prompt))
73
+ return "complex";
74
+ if (/\b(?:multi-?file|across\s+files|refactor|migrate|end-?to-?end|full\s+stack)\b/i.test(prompt)) {
75
+ return "complex";
76
+ }
77
+ if (FIX_RE.test(prompt)) {
78
+ return words > 40 ? "complex" : "standard";
79
+ }
80
+ if (category === "answer" && words <= 20)
81
+ return "simple";
82
+ if (words <= 6 && !BUILD_RE.test(prompt) && !PENTEST_RE.test(prompt)) {
83
+ return "simple";
84
+ }
85
+ if (words <= 28 && !BUILD_RE.test(prompt))
86
+ return "standard";
87
+ return words > 40 || BUILD_RE.test(prompt) ? "complex" : "standard";
88
+ }
89
+ function shouldPlanFor(prompt, complexity, category) {
90
+ if (complexity === "simple")
91
+ return false;
92
+ if (category === "answer")
93
+ return false;
94
+ if (PENTEST_RE.test(prompt))
95
+ return true;
96
+ if (BUILD_RE.test(prompt) && APP_RE.test(prompt))
97
+ return true;
98
+ if (/\b(?:implement|refactor|migrate|multi-?step|several\s+files|end-?to-?end)\b/i.test(prompt)) {
99
+ return true;
100
+ }
101
+ return complexity === "complex" && wordCount(prompt) > 25;
102
+ }
103
+ function inferLikelyTools(prompt, category) {
104
+ const tools = new Set();
105
+ if (category === "answer" || RESEARCH_RE.test(prompt)) {
106
+ tools.add("web.search");
107
+ tools.add("web.fetch");
108
+ }
109
+ if (category === "filesystem" || BUILD_RE.test(prompt) || FIX_RE.test(prompt)) {
110
+ tools.add("fs.list");
111
+ tools.add("fs.read");
112
+ tools.add("fs.write");
113
+ tools.add("fs.edit");
114
+ tools.add("shell.exec");
115
+ }
116
+ if (BUILD_RE.test(prompt) && APP_RE.test(prompt)) {
117
+ tools.add("plan.create");
118
+ tools.add("task.update");
119
+ tools.add("shell.start");
120
+ }
121
+ if (PENTEST_RE.test(prompt) || category.startsWith("pentest") || category === "web-enum") {
122
+ tools.add("dns.lookup");
123
+ tools.add("whois.lookup");
124
+ tools.add("http.fetch");
125
+ tools.add("net.scan");
126
+ tools.add("tool.check");
127
+ tools.add("plan.create");
128
+ }
129
+ if (category === "network-discovery") {
130
+ tools.add("net.context");
131
+ tools.add("net.pingSweep");
132
+ tools.add("net.scan");
133
+ }
134
+ if (category === "dns")
135
+ tools.add("dns.lookup");
136
+ if (category === "whois")
137
+ tools.add("whois.lookup");
138
+ if (category === "package")
139
+ tools.add("pkg.install");
140
+ if (SHELL_RE.test(prompt))
141
+ tools.add("shell.exec");
142
+ if (/\b(?:pdf)\b/i.test(prompt))
143
+ tools.add("pdf.read");
144
+ if (/\b(?:ocr|image|screenshot)\b/i.test(prompt))
145
+ tools.add("image.ocr");
146
+ return [...tools];
147
+ }
148
+ function softSteps(prompt, category) {
149
+ if (PENTEST_RE.test(prompt)) {
150
+ return [
151
+ createPlanStep("Recon and fingerprint stack", "pentest-recon", {
152
+ toolHint: "dns.lookup / http.fetch / net.scan",
153
+ successCriteria: "real findings from tool output",
154
+ }),
155
+ createPlanStep("Plan from findings", "other", {
156
+ toolHint: "plan.create",
157
+ successCriteria: "durable plan with verifiable tasks",
158
+ }),
159
+ createPlanStep("Test high-value vectors", "web-enum", {
160
+ successCriteria: "validated evidence or clean negatives",
161
+ }),
162
+ createPlanStep("Report with evidence", "other", {
163
+ successCriteria: "findings with repro + severity",
164
+ }),
165
+ ];
166
+ }
167
+ if (BUILD_RE.test(prompt) && APP_RE.test(prompt)) {
168
+ return [
169
+ createPlanStep("Explore destination and stack", "filesystem", {
170
+ toolHint: "fs.list / fs.read",
171
+ }),
172
+ createPlanStep("Plan multi-step build", "other", {
173
+ toolHint: "plan.create",
174
+ }),
175
+ createPlanStep("Implement requested feature", "filesystem", {
176
+ toolHint: "fs.write / fs.edit",
177
+ }),
178
+ createPlanStep("Verify (build and/or live server)", "shell", {
179
+ toolHint: "shell.start / shell.exec",
180
+ }),
181
+ ];
182
+ }
183
+ if (FIX_RE.test(prompt)) {
184
+ return [
185
+ createPlanStep("Reproduce and capture error", "shell"),
186
+ createPlanStep("Localize root cause", "filesystem", {
187
+ toolHint: "fs.read / fs.search",
188
+ }),
189
+ createPlanStep("Apply minimal fix", "filesystem", {
190
+ toolHint: "fs.edit",
191
+ }),
192
+ createPlanStep("Re-run failing check", "shell"),
193
+ ];
194
+ }
195
+ if (category === "network-discovery") {
196
+ return [
197
+ createPlanStep("Local network context", "network-discovery", {
198
+ toolHint: "net.context",
199
+ }),
200
+ createPlanStep("Discover live hosts", "network-discovery", {
201
+ toolHint: "net.pingSweep",
202
+ }),
203
+ createPlanStep("Summarize findings", "other"),
204
+ ];
205
+ }
206
+ return [];
207
+ }
208
+ function stopWhenFor(prompt, category) {
209
+ if (PENTEST_RE.test(prompt)) {
210
+ return "Findings report with evidence; no local dev server; scope respected.";
211
+ }
212
+ if (BUILD_RE.test(prompt) && APP_RE.test(prompt)) {
213
+ return "Requested feature works; verified via build and/or live localhost probe; server left running when applicable.";
214
+ }
215
+ if (FIX_RE.test(prompt)) {
216
+ return "Original failing check now passes; root cause addressed.";
217
+ }
218
+ if (category === "answer") {
219
+ return "Accurate answer grounded in tools when facts are volatile.";
220
+ }
221
+ return "User request completed with tool-backed evidence.";
222
+ }
6
223
  /**
7
- * Complexity estimator. Uses keyword detection for pentest/security tasks
8
- * (always complex) and falls back to word-count heuristic otherwise.
9
- * No pre-baked steps — the AI decides everything dynamically.
224
+ * Lightweight task analysis for step budgets and soft guidance.
225
+ * Does not execute or force a plan the agent still owns decisions.
10
226
  */
11
227
  export function analyzeTask(prompt) {
12
- const words = prompt.trim().split(/\s+/).length;
13
- // Pentest tasks are inherently multi-step — always complex.
14
- const complexity = PENTEST_RE.test(prompt)
15
- ? "complex"
16
- : words <= 5
17
- ? "simple"
18
- : words <= 30
19
- ? "standard"
20
- : "complex";
228
+ const text = prompt.replace(/\s+/g, " ").trim();
229
+ if (isNarrowExplicitNmapOperation(text)) {
230
+ return {
231
+ complexity: "standard",
232
+ shouldPlan: false,
233
+ category: "pentest-recon",
234
+ goal: text.slice(0, 100),
235
+ needsNetworkContext: false,
236
+ needsToolPreflight: true,
237
+ likelyTools: ["net.scan"],
238
+ stopWhen: "The requested nmap operation has started or completed and its canonical job ID, status, and output are reported; do not broaden scope.",
239
+ suggestedSteps: [],
240
+ };
241
+ }
242
+ const words = wordCount(text);
243
+ const category = classifyCategory(text);
244
+ const complexity = estimateComplexity(text, category, words);
245
+ const shouldPlan = shouldPlanFor(text, complexity, category);
246
+ const likelyTools = inferLikelyTools(text, category);
247
+ const suggestedSteps = complexity === "simple" || category === "answer" ? [] : softSteps(text, category);
21
248
  return {
22
249
  complexity,
23
- shouldPlan: false,
24
- category: "other",
25
- goal: prompt.slice(0, 100),
26
- needsNetworkContext: false,
27
- needsToolPreflight: false,
28
- likelyTools: [],
29
- stopWhen: "",
30
- suggestedSteps: [],
250
+ shouldPlan,
251
+ category,
252
+ goal: text.slice(0, 100),
253
+ needsNetworkContext: category === "network-discovery" ||
254
+ /\b(?:local\s*network|subnet|cidr|lan|my\s+network)\b/i.test(text),
255
+ needsToolPreflight: PENTEST_RE.test(text) ||
256
+ /\b(?:nmap|ffuf|gobuster|sqlmap|nuclei|hydra|nikto)\b/i.test(text),
257
+ likelyTools,
258
+ stopWhen: stopWhenFor(text, category),
259
+ suggestedSteps,
31
260
  };
32
261
  }
262
+ /** Compact one-liner for session/system context (optional inject). */
263
+ export function formatTaskAnalysisHint(analysis) {
264
+ const tools = analysis.likelyTools.length > 0
265
+ ? analysis.likelyTools.slice(0, 8).join(", ")
266
+ : "—";
267
+ const tracking = analysis.shouldPlan
268
+ ? "durable task tracking strongly recommended: create one concise plan before mutation, then keep task.update states aligned with real work"
269
+ : "direct execution ok";
270
+ return (`TASK ANALYSIS: category=${analysis.category} complexity=${analysis.complexity} (${tracking}). ` +
271
+ `Likely tools: ${tools}. Done when: ${analysis.stopWhen}`);
272
+ }
33
273
  //# sourceMappingURL=task-analyzer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"task-analyzer.js","sourceRoot":"","sources":["../../src/agent/task-analyzer.ts"],"names":[],"mappings":"AAkBA;;;GAGG;AACH,MAAM,UAAU,GACd,8UAA8U,CAAC;AAEjV;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;IAChD,4DAA4D;IAC5D,MAAM,UAAU,GAAmB,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;QACxD,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,KAAK,IAAI,CAAC;YACV,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,KAAK,IAAI,EAAE;gBACX,CAAC,CAAC,UAAU;gBACZ,CAAC,CAAC,SAAS,CAAC;IAClB,OAAO;QACL,UAAU;QACV,UAAU,EAAE,KAAK;QACjB,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC;QAC1B,mBAAmB,EAAE,KAAK;QAC1B,kBAAkB,EAAE,KAAK;QACzB,WAAW,EAAE,EAAE;QACf,QAAQ,EAAE,EAAE;QACZ,cAAc,EAAE,EAAE;KACnB,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"task-analyzer.js","sourceRoot":"","sources":["../../src/agent/task-analyzer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAgBhD,MAAM,UAAU,GACd,mVAAmV,CAAC;AAEtV,MAAM,QAAQ,GACZ,oFAAoF,CAAC;AAEvF,MAAM,MAAM,GACV,+FAA+F,CAAC;AAElG,MAAM,MAAM,GACV,6GAA6G,CAAC;AAEhH,MAAM,WAAW,GACf,yHAAyH,CAAC;AAE5H,MAAM,UAAU,GACd,gHAAgH,CAAC;AAEnH,MAAM,QAAQ,GACZ,uGAAuG,CAAC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AAO,CACL,2BAA2B,QAAQ,CAAC,QAAQ,eAAe,QAAQ,CAAC,UAAU,KAAK,QAAQ,KAAK;QAChG,iBAAiB,KAAK,gBAAgB,QAAQ,CAAC,QAAQ,EAAE,CAC1D,CAAC;AACJ,CAAC"}
@@ -1,26 +1,100 @@
1
1
  import type { ToolCall } from "../types.js";
2
- /**
3
- * Tracks successful non-meta tool work under the currently open plan task.
4
- * Models (esp. GPT-OSS) must not mark done or jump ahead without real
5
- * evidence from tool results this task has already received.
6
- */
7
- export interface TaskWorkLedger {
2
+ import type { TaskEvidence } from "../store/plan.js";
3
+ /** Successful non-meta work under the open plan task (typed evidence for done). */
4
+ export type TaskClass = "explore" | "scaffold" | "install" | "implement" | "verify" | "recon" | "exploit" | "report" | "generic";
5
+ export interface TaskWorkLedger extends TaskEvidence {
8
6
  taskId: string;
9
- /** Successful work tools since this task became in_progress. */
10
- successWorkCount: number;
11
- lastOkTool?: string | undefined;
7
+ }
8
+ /** Rehydrate the live task ledger from durable plan evidence after a resume. */
9
+ export declare function ledgerFromTaskEvidence(taskId: string, evidence?: TaskEvidence | undefined): TaskWorkLedger;
10
+ /** Store only serializable evidence on the plan; the task id is already its key. */
11
+ export declare function taskEvidenceFromLedger(ledger: TaskWorkLedger): TaskEvidence;
12
+ /** Optional signals recorded from a successful tool call. */
13
+ export interface TaskWorkSignals {
14
+ sourceWrite?: boolean;
15
+ featureWrite?: boolean;
16
+ installOk?: boolean;
17
+ scaffoldOk?: boolean;
18
+ devServerStart?: boolean;
19
+ localHttpProbeOk?: boolean;
20
+ serverReady?: boolean;
21
+ portListening?: boolean;
22
+ remoteReconOk?: boolean;
23
+ remoteActiveTestOk?: boolean;
12
24
  }
13
25
  export declare function isMetaPlanTool(name: string): boolean;
14
26
  /** Tools that count as real work/verify evidence for the open task. */
15
27
  export declare function isEvidenceWorkTool(name: string): boolean;
16
- export declare function recordTaskWorkSuccess(ledger: TaskWorkLedger | null, taskId: string | undefined, toolName: string): TaskWorkLedger | null;
28
+ export declare function isPentestPlanKind(kind: string | undefined): boolean;
29
+ export declare function classifyTaskTitle(title: string, opts?: {
30
+ planKind?: string | undefined;
31
+ }): TaskClass;
32
+ /** Successful work observed this turn without a credited open task. */
33
+ export interface LooseWorkReceipt {
34
+ readonly toolName: string;
35
+ readonly signals?: TaskWorkSignals | undefined;
36
+ }
37
+ /**
38
+ * Whether a successful tool can satisfy a task of the given class.
39
+ * Used to retroactively credit preflight work (tool.check before in_progress).
40
+ */
41
+ export declare function toolFitsTaskClass(toolName: string, taskTitle: string, opts?: {
42
+ planKind?: string | undefined;
43
+ signals?: TaskWorkSignals | undefined;
44
+ }): boolean;
45
+ /**
46
+ * Fold turn-level loose successes into a task ledger so preflight work
47
+ * (tool.check / fs.list before in_progress) can satisfy explore/check tasks.
48
+ */
49
+ export declare function absorbLooseWorkIntoLedger(ledger: TaskWorkLedger | null, taskId: string, taskTitle: string, loose: readonly LooseWorkReceipt[], opts?: {
50
+ planKind?: string | undefined;
51
+ }): TaskWorkLedger | null;
52
+ export declare function recordTaskWorkSuccess(ledger: TaskWorkLedger | null, taskId: string | undefined, toolName: string, signals?: TaskWorkSignals): TaskWorkLedger | null;
17
53
  export declare function openTaskLedger(taskId: string): TaskWorkLedger;
18
- export declare function canMarkTaskDone(ledger: TaskWorkLedger | null, taskId: string): {
54
+ export interface CanMarkTaskDoneOpts {
55
+ taskTitle?: string | undefined;
56
+ /** User asked for a product feature app (todo/blog/…). */
57
+ featureAppRequired?: boolean | undefined;
58
+ /** Session-level flag: feature write observed any time this turn. */
59
+ sessionFeatureSeen?: boolean | undefined;
60
+ /** A real project root was discovered, so a scaffold checkpoint is already satisfied. */
61
+ existingProject?: boolean | undefined;
62
+ /** An earlier plan task already proved the local server is ready and running. */
63
+ runtimeVerified?: boolean | undefined;
64
+ /** Plan kind: coding | pentest | general — selects domain gates. */
65
+ planKind?: string | undefined;
66
+ /** Any plan task already has successful remote recon/active test evidence. */
67
+ remoteWorkVerified?: boolean | undefined;
68
+ }
69
+ /** Local app runtime is proven by any strong independent signal. */
70
+ export declare function hasLocalRuntimeProof(evidence?: Pick<TaskEvidence, "sawDevServerStart" | "sawLocalHttpProbeOk" | "sawServerReady" | "sawPortListening"> | null): boolean;
71
+ export declare function hasRemoteWorkProof(evidence?: Pick<TaskEvidence, "sawRemoteReconOk" | "sawRemoteActiveTestOk"> | null): boolean;
72
+ /** Dev-server job log shows ready + local URL. */
73
+ export declare function isServerReadyOutput(output: string): boolean;
74
+ /** lsof/ss (or similar) shows a process LISTENing on a local port. */
75
+ export declare function isPortListeningOutput(command: string, output: string): boolean;
76
+ /**
77
+ * Leave/keep-running observational tasks may inherit already-proven runtime.
78
+ * "for user to test" must NOT block inheritance (prior brittle exclusion of "test").
79
+ */
80
+ export declare function isRuntimeObservationTask(title: string): boolean;
81
+ /** Report / residual documentation that can inherit prior remote evidence. */
82
+ export declare function isRemoteObservationTask(title: string): boolean;
83
+ /**
84
+ * Typed evidence gate: base rule is ≥1 successful work tool; implement/install/verify
85
+ * (and pentest recon) require stronger signals when classified. Existing project and
86
+ * already-proven runtime/remote facts satisfy corresponding observational tasks.
87
+ */
88
+ export declare function canMarkTaskDone(ledger: TaskWorkLedger | null, taskId: string, opts?: CanMarkTaskDoneOpts): {
19
89
  ok: true;
20
90
  } | {
21
91
  ok: false;
22
92
  reason: string;
23
93
  };
94
+ /** True when a tool call is remote recon (not local app tooling). */
95
+ export declare function isRemoteReconToolCall(call: ToolCall): boolean;
96
+ /** Active/offensive test (not passive recon). */
97
+ export declare function isRemoteActiveTestCall(call: ToolCall): boolean;
24
98
  /** One-shot scaffolders — must NEVER be treated as "start the dev server". Stack-agnostic. */
25
99
  export declare function isScaffoldCreateCommand(cmd: string): boolean;
26
100
  /**
@@ -28,12 +102,17 @@ export declare function isScaffoldCreateCommand(cmd: string): boolean;
28
102
  * npm create which merely contain the word "vite".
29
103
  */
30
104
  export declare function isDevServerCall(call: ToolCall): boolean;
31
- /** Preflight / inspect tools allowed before the model opens a task. */
105
+ /** Inspect tools allowed without opening a plan task. */
32
106
  export declare function isPlanPreflightTool(name: string): boolean;
107
+ /** Read-only recon tools that may run without an in_progress task on pentest plans. */
108
+ export declare function isReadOnlyReconTool(name: string): boolean;
33
109
  /**
34
- * Tools allowed on a coding BUILD turn before plan.create exists.
35
- * Explore + optional web research + plan — no scaffold/write/install freestyle.
110
+ * Tools whose failure must NOT cancel later siblings in the same model turn.
111
+ * Plan bookkeeping failures (task.update done-gate, etc.) and independent
112
+ * recon lookups should never wipe a whole batch of http.fetch / dns calls.
36
113
  */
114
+ export declare function isBatchSoftFailTool(name: string): boolean;
115
+ /** Tools allowed on a coding build turn before plan.create exists. */
37
116
  export declare function isBuildPrePlanAllowedTool(name: string): boolean;
38
117
  /**
39
118
  * Commands that legitimately sit quiet for minutes (npm install, create-next-app).
@@ -45,6 +124,18 @@ export declare function toolStallBudgetMs(call: {
45
124
  name: string;
46
125
  args: Record<string, unknown>;
47
126
  }): number;
127
+ /**
128
+ * Hard wall-clock budget for a tool call. When exceeded the runner aborts
129
+ * and force-settles even if the underlying promise never resolves (hung
130
+ * socket that ignored AbortSignal). Distinct from the stall watchdog
131
+ * (which fires on *silence*); this fires on total elapsed time.
132
+ */
133
+ export declare function toolHardBudgetMs(call: {
134
+ name: string;
135
+ args: Record<string, unknown>;
136
+ }): number;
137
+ /** Grace period after abort before force-settling a hung tool promise. */
138
+ export declare const TOOL_ABORT_GRACE_MS = 2500;
48
139
  /** Harmless version/which probes models use instead of tool.check before planning. */
49
140
  export declare function isReadOnlyVersionProbeCommand(cmd: string): boolean;
50
141
  /**
@@ -59,15 +150,6 @@ export declare function codingBuildRequiresPlan(prompt: string, opts?: {
59
150
  export declare function looksLikeInstallTaskTitle(title: string): boolean;
60
151
  export declare function looksLikeScaffoldTaskTitle(title: string): boolean;
61
152
  export declare function isPackageInstallCommand(cmd: string): boolean;
62
- /**
63
- * Soft scope check: refuse run/verify tools while the open task is only
64
- * scaffold / implement / install.
65
- * When `planTaskTitles` is provided, install is only blocked on implement
66
- * tasks if the plan actually has a dedicated install task (otherwise allow).
67
- */
68
- export declare function workOutOfScopeForTask(taskTitle: string, call: ToolCall, opts?: {
69
- planTaskTitles?: string[];
70
- }): string | undefined;
71
153
  /**
72
154
  * Choose which pending plan task should own this tool call (auto-start).
73
155
  * Prevents npm install from being attributed to "localStorage" / style tasks.
@@ -75,7 +157,7 @@ export declare function workOutOfScopeForTask(taskTitle: string, call: ToolCall,
75
157
  export declare function pickPendingTaskForToolCall<T extends {
76
158
  id: string;
77
159
  title: string;
78
- }>(pending: T[], call: ToolCall, allTitles?: string[]): T | undefined;
160
+ }>(pending: T[], call: ToolCall, _allTitles?: string[]): T | undefined;
79
161
  /**
80
162
  * User asked for a product feature app (todo, blog, …), not "just scaffold framework X".
81
163
  * Stack-agnostic: detects intent, not a particular framework.
@@ -84,15 +166,15 @@ export declare function userAskedForFeatureApp(prompt: string): boolean;
84
166
  /** Paths that look like application source (not lockfiles / build output). */
85
167
  export declare function isAppSourcePath(path: string): boolean;
86
168
  export declare function extractWritePathsFromCall(call: ToolCall): string[];
169
+ /** Default framework starter / marketing copy — not the product feature. */
170
+ export declare function looksLikeStarterBoilerplate(content: string): boolean;
171
+ /** Content that looks like real product UI/logic for common feature apps. */
172
+ export declare function looksLikeFeatureProductCode(content: string): boolean;
87
173
  /**
88
174
  * True when a successful tool call implements product feature code (not only scaffold).
175
+ * Starter boilerplate alone does not count.
89
176
  */
90
177
  export declare function isFeatureImplementationCall(call: ToolCall): boolean;
91
- /**
92
- * Soft block: don't start the local server until the product feature exists.
93
- * Returns a message when the open work is still scaffold-only for a feature ask.
94
- */
95
- export declare function incompleteFeatureBeforeServerMessage(userPrompt: string, sawFeatureImpl: boolean, call: ToolCall): string | undefined;
96
178
  /**
97
179
  * User said work belongs on the Desktop (or similar). Returns absolute path.
98
180
  */