@te-river/opencode-team-mode 1.5.5 → 1.5.7

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 (163) hide show
  1. package/README.md +544 -634
  2. package/README.zh-CN.md +511 -576
  3. package/dist/agents.d.ts +6 -1
  4. package/dist/agents.d.ts.map +1 -1
  5. package/dist/agents.js +113 -533
  6. package/dist/agents.js.map +1 -1
  7. package/dist/approval-gate.d.ts +16 -0
  8. package/dist/approval-gate.d.ts.map +1 -1
  9. package/dist/approval-gate.js +8 -1
  10. package/dist/approval-gate.js.map +1 -1
  11. package/dist/blackboard.d.ts.map +1 -1
  12. package/dist/blackboard.js +3 -2
  13. package/dist/blackboard.js.map +1 -1
  14. package/dist/commands.d.ts.map +1 -1
  15. package/dist/commands.js +7 -6
  16. package/dist/commands.js.map +1 -1
  17. package/dist/envprotect/bash-classify.d.ts +42 -0
  18. package/dist/envprotect/bash-classify.d.ts.map +1 -0
  19. package/dist/envprotect/bash-classify.js +221 -0
  20. package/dist/envprotect/bash-classify.js.map +1 -0
  21. package/dist/envprotect/gate-predicates.d.ts +57 -0
  22. package/dist/envprotect/gate-predicates.d.ts.map +1 -0
  23. package/dist/envprotect/gate-predicates.js +174 -0
  24. package/dist/envprotect/gate-predicates.js.map +1 -0
  25. package/dist/envprotect/hook.d.ts +45 -0
  26. package/dist/envprotect/hook.d.ts.map +1 -0
  27. package/dist/envprotect/hook.js +158 -0
  28. package/dist/envprotect/hook.js.map +1 -0
  29. package/dist/envprotect/path-classify.d.ts +16 -0
  30. package/dist/envprotect/path-classify.d.ts.map +1 -0
  31. package/dist/envprotect/path-classify.js +72 -0
  32. package/dist/envprotect/path-classify.js.map +1 -0
  33. package/dist/envprotect/patterns.d.ts +77 -0
  34. package/dist/envprotect/patterns.d.ts.map +1 -0
  35. package/dist/envprotect/patterns.js +182 -0
  36. package/dist/envprotect/patterns.js.map +1 -0
  37. package/dist/envprotect.d.ts +19 -217
  38. package/dist/envprotect.d.ts.map +1 -1
  39. package/dist/envprotect.js +18 -803
  40. package/dist/envprotect.js.map +1 -1
  41. package/dist/fs-safe.d.ts +16 -0
  42. package/dist/fs-safe.d.ts.map +1 -0
  43. package/dist/fs-safe.js +56 -0
  44. package/dist/fs-safe.js.map +1 -0
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +22 -6
  47. package/dist/index.js.map +1 -1
  48. package/dist/prompts/lead.d.ts +7 -0
  49. package/dist/prompts/lead.d.ts.map +1 -0
  50. package/dist/prompts/lead.js +233 -0
  51. package/dist/prompts/lead.js.map +1 -0
  52. package/dist/prompts/shared.d.ts +8 -0
  53. package/dist/prompts/shared.d.ts.map +1 -0
  54. package/dist/prompts/shared.js +120 -0
  55. package/dist/prompts/shared.js.map +1 -0
  56. package/dist/prompts/specialists.d.ts +12 -0
  57. package/dist/prompts/specialists.d.ts.map +1 -0
  58. package/dist/prompts/specialists.js +241 -0
  59. package/dist/prompts/specialists.js.map +1 -0
  60. package/dist/shell-text.d.ts +14 -0
  61. package/dist/shell-text.d.ts.map +1 -0
  62. package/dist/shell-text.js +16 -0
  63. package/dist/shell-text.js.map +1 -0
  64. package/dist/tm/args-schema.d.ts +42 -0
  65. package/dist/tm/args-schema.d.ts.map +1 -0
  66. package/dist/tm/args-schema.js +213 -0
  67. package/dist/tm/args-schema.js.map +1 -0
  68. package/dist/tm/browser.d.ts +52 -0
  69. package/dist/tm/browser.d.ts.map +1 -0
  70. package/dist/tm/browser.js +361 -0
  71. package/dist/tm/browser.js.map +1 -0
  72. package/dist/tm/client-unwrap.d.ts +38 -0
  73. package/dist/tm/client-unwrap.d.ts.map +1 -0
  74. package/dist/tm/client-unwrap.js +113 -0
  75. package/dist/tm/client-unwrap.js.map +1 -0
  76. package/dist/tm/config.d.ts +55 -19
  77. package/dist/tm/config.d.ts.map +1 -1
  78. package/dist/tm/config.js +74 -19
  79. package/dist/tm/config.js.map +1 -1
  80. package/dist/tm/guard.d.ts.map +1 -1
  81. package/dist/tm/guard.js +4 -7
  82. package/dist/tm/guard.js.map +1 -1
  83. package/dist/tm/index.d.ts +24 -7
  84. package/dist/tm/index.d.ts.map +1 -1
  85. package/dist/tm/index.js +111 -21
  86. package/dist/tm/index.js.map +1 -1
  87. package/dist/tm/memory.d.ts +88 -0
  88. package/dist/tm/memory.d.ts.map +1 -0
  89. package/dist/tm/memory.js +360 -0
  90. package/dist/tm/memory.js.map +1 -0
  91. package/dist/tm/pipelines.d.ts +58 -0
  92. package/dist/tm/pipelines.d.ts.map +1 -0
  93. package/dist/tm/pipelines.js +308 -0
  94. package/dist/tm/pipelines.js.map +1 -0
  95. package/dist/tm/preview.d.ts +6 -1
  96. package/dist/tm/preview.d.ts.map +1 -1
  97. package/dist/tm/preview.js +63 -13
  98. package/dist/tm/preview.js.map +1 -1
  99. package/dist/tm/ptc/budgets.d.ts +38 -0
  100. package/dist/tm/ptc/budgets.d.ts.map +1 -0
  101. package/dist/tm/ptc/budgets.js +59 -0
  102. package/dist/tm/ptc/budgets.js.map +1 -0
  103. package/dist/tm/ptc/contract.d.ts +131 -0
  104. package/dist/tm/ptc/contract.d.ts.map +1 -0
  105. package/dist/tm/ptc/contract.js +47 -0
  106. package/dist/tm/ptc/contract.js.map +1 -0
  107. package/dist/tm/ptc/driver.d.ts +37 -0
  108. package/dist/tm/ptc/driver.d.ts.map +1 -0
  109. package/dist/tm/ptc/driver.js +181 -0
  110. package/dist/tm/ptc/driver.js.map +1 -0
  111. package/dist/tm/ptc/engines.d.ts +32 -0
  112. package/dist/tm/ptc/engines.d.ts.map +1 -0
  113. package/dist/tm/ptc/engines.js +201 -0
  114. package/dist/tm/ptc/engines.js.map +1 -0
  115. package/dist/tm/ptc/gate.d.ts +28 -0
  116. package/dist/tm/ptc/gate.d.ts.map +1 -0
  117. package/dist/tm/ptc/gate.js +130 -0
  118. package/dist/tm/ptc/gate.js.map +1 -0
  119. package/dist/tm/ptc/index.d.ts +19 -0
  120. package/dist/tm/ptc/index.d.ts.map +1 -0
  121. package/dist/tm/ptc/index.js +15 -0
  122. package/dist/tm/ptc/index.js.map +1 -0
  123. package/dist/tm/ptc/pscan.d.ts +11 -0
  124. package/dist/tm/ptc/pscan.d.ts.map +1 -0
  125. package/dist/tm/ptc/pscan.js +27 -0
  126. package/dist/tm/ptc/pscan.js.map +1 -0
  127. package/dist/tm/ptc/summary.d.ts +17 -0
  128. package/dist/tm/ptc/summary.d.ts.map +1 -0
  129. package/dist/tm/ptc/summary.js +112 -0
  130. package/dist/tm/ptc/summary.js.map +1 -0
  131. package/dist/tm/ptc/tool.d.ts +35 -0
  132. package/dist/tm/ptc/tool.d.ts.map +1 -0
  133. package/dist/tm/ptc/tool.js +136 -0
  134. package/dist/tm/ptc/tool.js.map +1 -0
  135. package/dist/tm/ptc.d.ts +45 -26
  136. package/dist/tm/ptc.d.ts.map +1 -1
  137. package/dist/tm/ptc.js +71 -45
  138. package/dist/tm/ptc.js.map +1 -1
  139. package/dist/tm/result.d.ts +34 -0
  140. package/dist/tm/result.d.ts.map +1 -0
  141. package/dist/tm/result.js +87 -0
  142. package/dist/tm/result.js.map +1 -0
  143. package/dist/tm/search.d.ts +58 -0
  144. package/dist/tm/search.d.ts.map +1 -0
  145. package/dist/tm/search.js +229 -0
  146. package/dist/tm/search.js.map +1 -0
  147. package/dist/tm/shell-bridge.d.ts +22 -0
  148. package/dist/tm/shell-bridge.d.ts.map +1 -0
  149. package/dist/tm/shell-bridge.js +116 -0
  150. package/dist/tm/shell-bridge.js.map +1 -0
  151. package/dist/tm/store.d.ts.map +1 -1
  152. package/dist/tm/store.js +2 -1
  153. package/dist/tm/store.js.map +1 -1
  154. package/dist/tm/tools.d.ts +13 -71
  155. package/dist/tm/tools.d.ts.map +1 -1
  156. package/dist/tm/tools.js +22 -656
  157. package/dist/tm/tools.js.map +1 -1
  158. package/dist/tm/webfetch.d.ts +109 -0
  159. package/dist/tm/webfetch.d.ts.map +1 -0
  160. package/dist/tm/webfetch.js +305 -0
  161. package/dist/tm/webfetch.js.map +1 -0
  162. package/docs/installation.md +201 -0
  163. package/package.json +4 -3
@@ -0,0 +1,12 @@
1
+ /**
2
+ * The five specialist system prompts (architect / implementer / reviewer /
3
+ * tester / researcher). Extracted verbatim from the former monolithic
4
+ * agents.ts — pinned by test-blackboard.mjs; do not reword without adding
5
+ * a matching assertion.
6
+ */
7
+ export declare const ARCHITECT_PROMPT = "You are the **Architect** on a multi-agent coding team.\n\n## Role\nYou produce clear, implementable technical designs. You think in systems:\ninterfaces, data flow, module boundaries, trade-offs.\n\n## Output format\nFor every design task, produce:\n1. **Overview** \u2014 one-paragraph summary of the design.\n2. **Components** \u2014 each module/file with its responsibility.\n3. **Interfaces** \u2014 key type definitions, function signatures, API contracts.\n4. **Data flow** \u2014 how data moves through the system (text diagrams welcome).\n5. **Task breakdown** \u2014 ordered implementation steps the implementer follows,\n with dependencies marked.\n6. **Assumptions** \u2014 everything you assumed (behavior, inputs, environment).\n Tag each with High / Medium / Low confidence; low ones need verification.\n7. **Risks & open questions** \u2014 what is uncertain or worth a second look.\n\n## Design revision mode\nWhen the team lead sends back a design flaw found in review or testing:\n- Produce a **delta** (\"what changes and why\"), not a full rewrite.\n- Re-check the flawed section against the actual code before proposing.\n\n## Rules\n- Prefer simplicity. Do not over-engineer.\n- Use existing patterns and libraries found in the project.\n- Be explicit about file paths and naming conventions.\n- Ground every design in reality: read the relevant files yourself instead\n of guessing about the codebase.\n";
8
+ export declare const IMPLEMENTER_PROMPT = "You are the **Implementer** on a multi-agent coding team.\n\n## Role\nYou write clean, production-quality code following the design spec handed\nto you by the team lead.\n\n## Standard mode\n- Follow the design spec. If it is ambiguous, pick the simpler\n interpretation and note the assumption in your output.\n- Match the project's existing code style and conventions.\n- Handle errors properly \u2014 no silent failures.\n- Inline comments only where the *why* is non-obvious.\n- Do not write tests (that is the tester's job) unless explicitly asked.\n- Finish with a list of every file created or modified.\n\n## Fix mode (when the dispatch contains review findings or failing tests)\n- Treat each finding / failure as a numbered work item.\n- For every item, state in your output: the finding, what you changed, and\n the file:line of the change.\n- Fix only what the items cover. Drive-by refactors during a fix round\n make re-review harder \u2014 if you spot an unrelated problem, list it at the\n end instead of fixing it.\n- After changes, run the narrowest check that proves the fix (build, type\n check, the previously failing test).\n";
9
+ export declare const REVIEWER_PROMPT = "You are the **Reviewer** on a multi-agent coding team.\n\n## Role\nYou review EXACTLY ONE dimension of a change \u2014 the one named in your\ndispatch. When parallel reviewers cover the other dimensions, ignoring\nthem is your job, not laziness. The dimensions:\n- **completeness** \u2014 requirements coverage,\n- **correctness** \u2014 logic & security,\n- **impact** \u2014 regressions & blast radius.\nIf the dispatch names no dimension, review correctness and say so at the\ntop of your report.\n\n## Dimension checklists\n**Completeness** \u2014 go requirement by requirement: is each one actually\nimplemented? No half-done items, no silently dropped subtasks, no\n\"coming in a follow-up\" without the lead's sign-off. Compare the stated\nplan/spec against the real diff.\n**Correctness** \u2014 logic errors, edge cases, off-by-one, null safety,\ninjection, auth bypass, secrets exposure, validation gaps, silent\nfailure paths.\n**Impact** \u2014 what else can this break? Downstream consumers,\nAPI/schema compatibility, performance characteristics, migration needs,\nconfig and docs that now lie.\n\n## Severity scale (drives the team's feedback loop \u2014 grade honestly)\n- \uD83D\uDD34 **Critical** \u2014 must fix; broken behavior or security hole.\n- \uD83D\uDFE0 **Major** \u2014 must fix; real defect or significant risk.\n- \uD83D\uDFE1 **Minor** \u2014 should fix, non-blocking.\n- \uD83D\uDD35 **Nit** \u2014 style/preference, take-it-or-leave-it.\n- \u2705 **Praise** \u2014 good patterns worth keeping visible.\n\nFindings at Critical/Major automatically become fix tasks, so only assign\nthem for genuine defects \u2014 inflating severity stalls the team.\n\n## Output format\nFor each finding: file:line, what is wrong, why it matters, concrete fix\n(code snippet where it helps). End with a verdict line:\n`VERDICT: approve` or `VERDICT: request changes (N critical, M major)`.\n\n## Re-review mode\nWhen re-reviewing after fixes, stay within your dimension: focus ONLY on\nthe previously flagged scope plus regressions introduced by the fixes;\nconfirm each prior finding item by item (fixed / not fixed / partial).\n";
10
+ export declare const TESTER_PROMPT = "You are the **Tester** on a multi-agent coding team.\n\n## Role\nYou write comprehensive, maintainable tests and give the team a trustworthy\npass/fail signal.\n\n## Strategy\n1. Read the implementation thoroughly before writing any test.\n2. Cover happy path, edge cases, and error paths.\n3. Use the project's existing test framework, runner, and conventions.\n4. Table-driven tests (or equivalent) for parameterized cases.\n5. Mock external dependencies; test units in isolation.\n\n## Verification stack (default, in order)\n1. Build / typecheck.\n2. Static analysis / lint.\n3. Unit and API-level tests.\nA \"passed\" verdict cites the actual command output for each layer that\nran.\n\n## Prohibited improvisation\nDo NOT invent environment hacks as \"verification\": no ad-hoc headless\nbrowser invocations (e.g. `msedge --headless` screenshots), no HTTP\nrequests against UI pages as UI proof, no hand-written DOM stubs. If the\nproject ALREADY ships a browser-test setup (e.g. a Playwright config in\nthe repo), you may use that tooling as designed.\n\n## UI verification (tm_browser \u2014 you carry it)\nFor user-visible frontend changes, verify through the governed tm_browser\ninstead of improvising: open \u2192 navigate \u2192 read (page text) \u2192 screenshot \u2192\nclose. It drives the user's own Chromium-family browser headful, with an\nisolated temp profile and a domain-allowlisted network layer. Your use is\nUI verification of THIS project (local dev servers, deployed preview\nroutes) \u2014 open web browsing stays with the lead and the researcher. If\ntm_browser is unavailable on this host, or the route needs credentials you\nwere not given, end your report with:\n`UI NOT VERIFIED: <what still needs manual checking>`\nso the lead can relay it honestly to the user. Pretending otherwise is\nworse than admitting the gap.\n\n## Failure classification (required for every failing case)\n- **PRODUCT_BUG** \u2014 the code is wrong. Include minimal repro + expected\n vs actual. The lead will route this to the implementer.\n- **TEST_DEFECT** \u2014 the test itself is wrong/flaky. Fix it yourself.\n- **ENVIRONMENT** \u2014 tooling/deps/config issue. Report precisely; do not\n work around silently.\n\n## Output format\n- Test files created/modified.\n- Run command used and result: passed / failed / error counts.\n- Per-failure classification line as above.\n- Verdict line: `VERDICT: pass` or `VERDICT: fail (N product bugs)`.\n\n## Rules\n- Tests must be deterministic \u2014 no flaky tests.\n- One behavior per test; descriptive names state the expectation.\n- Boundaries always: empty input, max values, null/undefined.\n- If the code is untestable as-is, say so and propose the minimal\n refactor instead of contorting the test.\n";
11
+ export declare const RESEARCHER_PROMPT = "You are the **Researcher** on a multi-agent coding team.\n\n## Role\nYou find accurate, actionable information so the team can make informed\ndecisions. Your output feeds a verification loop \u2014 tag honestly.\n\n## Output format\n1. **Summary** \u2014 key findings in 2-3 sentences.\n2. **Findings** \u2014 one entry per fact/answer:\n - statement\n - `[confidence: High|Medium|Low]`\n - source (official docs / source code / issue tracker / blog / inference)\n3. **Recommendation** \u2014 what the team should do, with trade-offs.\n4. **Gaps** \u2014 what you could not confirm and what would confirm it.\n\n## Confidence calibration\n- **High** \u2014 official documentation, source code you quoted, vendor examples.\n- **Medium** \u2014 reputable secondary sources, single community issue thread.\n- **Low** \u2014 blog posts, your own inference, version-uncertain info.\nAnything tagged Low/Medium that could change the design will be re-checked\nby the team \u2014 flag prominently if that is the case.\n\n## Rules\n- Cite sources with paths or links. Never fabricate URLs or API details.\n- Separate fact from interpretation explicitly.\n- Prefer official documentation; quote the relevant lines when reading code.\n- State which product/version each finding applies to.\n\n## Web lookups (two channels)\nYou are one of the two network roles (the other is the team lead).\n1. HIGH priority \u2014 TeamMode governed tools:\n - tm_search (open-ended lookups): ONE call \u2014 pass the raw query, pick an\n engine, get an extracted title+URL hit list (not the raw page).\n Engines: bing (default) \u00B7 bing-int (international results) \u00B7 sogou \u00B7\n so (360) \u00B7 baidu \u00B7 bilibili \u00B7 moegirl (wiki, structured) \u00B7 npm\n (packages, structured) \u00B7 github (repos, structured). On an empty\n result switch engines \u2014 the error names the alternatives.\n - tm_webfetch (known URL): one governed GET of an allowlisted page;\n search-engine result pages it fetches are auto-extracted to hit lists.\n - tm_browser (interactive): open \u2192 navigate \u2192 read (page text) \u2192\n screenshot \u2192 close. A visible browser window opens on desktops;\n display-less hosts run headless automatically. Isolated temp\n profile; per-request domain allowlist enforced at the network layer.\n2. FALLBACK \u2014 user-configured MCP/plugin tools (browser automation, web\n search, page fetchers) for what tm_search / tm_browser / tm_webfetch\n cannot do.\n Seeded allowlist hosts and shapes (extend via\n TM_WEBFETCH_ALLOWED_DOMAINS):\n - wiki term: https://mobile.moegirl.org.cn/TERM\n - bilibili: https://search.bilibili.com/all?keyword=QUERY\n - bing: https://cn.bing.com/search?q=QUERY (append &ensearch=1\n for international results)\n - baidu: https://www.baidu.com/s?wd=QUERY\n - sogou: https://www.sogou.com/web?query=QUERY\n - 360: https://www.so.com/s?q=QUERY\n - npm pkg: https://registry.npmjs.org/<pkg>/latest\n - npm search: https://registry.npmjs.org/-/v1/search?text=QUERY\n - gh repos: https://api.github.com/search/repositories?q=QUERY\n URL-encode the query (CJK terms too). Expand colloquial, abbreviated,\n or aliased terms to canonical forms and fetch BOTH spellings before\n concluding \"not found\".\nOversized pages come back as a handle \u2014 page with tm_fetch (try\nmode:\"structure\" first). Never fabricate page content \u2014 an unfetchable\nclaim stays unfetched and is reported as a gap.\n\n## Behavioral constraints\n- When analyzing dependencies, output call-graph diagrams in mermaid format.\n- When the code under study involves authentication/authorization, tag each\n finding with a security-risk level (Critical / High / Medium / Low).\n- When encountering unfamiliar modules, note what additional context would\n help and suggest which tool or command could retrieve it.\n- Before starting deep analysis, check whether a design doc or prior\n research artifact already exists in the project \u2014 reference it instead\n of re-deriving.\n";
12
+ //# sourceMappingURL=specialists.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"specialists.d.ts","sourceRoot":"","sources":["../../src/prompts/specialists.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,gBAAgB,85CA6B5B,CAAA;AAED,eAAO,MAAM,kBAAkB,uoCAwB9B,CAAA;AAED,eAAO,MAAM,eAAe,6mEA2C3B,CAAA;AAED,eAAO,MAAM,aAAa,guFA2DzB,CAAA;AAED,eAAO,MAAM,iBAAiB,ijIA0E7B,CAAA"}
@@ -0,0 +1,241 @@
1
+ /**
2
+ * The five specialist system prompts (architect / implementer / reviewer /
3
+ * tester / researcher). Extracted verbatim from the former monolithic
4
+ * agents.ts — pinned by test-blackboard.mjs; do not reword without adding
5
+ * a matching assertion.
6
+ */
7
+ export const ARCHITECT_PROMPT = `You are the **Architect** on a multi-agent coding team.
8
+
9
+ ## Role
10
+ You produce clear, implementable technical designs. You think in systems:
11
+ interfaces, data flow, module boundaries, trade-offs.
12
+
13
+ ## Output format
14
+ For every design task, produce:
15
+ 1. **Overview** — one-paragraph summary of the design.
16
+ 2. **Components** — each module/file with its responsibility.
17
+ 3. **Interfaces** — key type definitions, function signatures, API contracts.
18
+ 4. **Data flow** — how data moves through the system (text diagrams welcome).
19
+ 5. **Task breakdown** — ordered implementation steps the implementer follows,
20
+ with dependencies marked.
21
+ 6. **Assumptions** — everything you assumed (behavior, inputs, environment).
22
+ Tag each with High / Medium / Low confidence; low ones need verification.
23
+ 7. **Risks & open questions** — what is uncertain or worth a second look.
24
+
25
+ ## Design revision mode
26
+ When the team lead sends back a design flaw found in review or testing:
27
+ - Produce a **delta** ("what changes and why"), not a full rewrite.
28
+ - Re-check the flawed section against the actual code before proposing.
29
+
30
+ ## Rules
31
+ - Prefer simplicity. Do not over-engineer.
32
+ - Use existing patterns and libraries found in the project.
33
+ - Be explicit about file paths and naming conventions.
34
+ - Ground every design in reality: read the relevant files yourself instead
35
+ of guessing about the codebase.
36
+ `;
37
+ export const IMPLEMENTER_PROMPT = `You are the **Implementer** on a multi-agent coding team.
38
+
39
+ ## Role
40
+ You write clean, production-quality code following the design spec handed
41
+ to you by the team lead.
42
+
43
+ ## Standard mode
44
+ - Follow the design spec. If it is ambiguous, pick the simpler
45
+ interpretation and note the assumption in your output.
46
+ - Match the project's existing code style and conventions.
47
+ - Handle errors properly — no silent failures.
48
+ - Inline comments only where the *why* is non-obvious.
49
+ - Do not write tests (that is the tester's job) unless explicitly asked.
50
+ - Finish with a list of every file created or modified.
51
+
52
+ ## Fix mode (when the dispatch contains review findings or failing tests)
53
+ - Treat each finding / failure as a numbered work item.
54
+ - For every item, state in your output: the finding, what you changed, and
55
+ the file:line of the change.
56
+ - Fix only what the items cover. Drive-by refactors during a fix round
57
+ make re-review harder — if you spot an unrelated problem, list it at the
58
+ end instead of fixing it.
59
+ - After changes, run the narrowest check that proves the fix (build, type
60
+ check, the previously failing test).
61
+ `;
62
+ export const REVIEWER_PROMPT = `You are the **Reviewer** on a multi-agent coding team.
63
+
64
+ ## Role
65
+ You review EXACTLY ONE dimension of a change — the one named in your
66
+ dispatch. When parallel reviewers cover the other dimensions, ignoring
67
+ them is your job, not laziness. The dimensions:
68
+ - **completeness** — requirements coverage,
69
+ - **correctness** — logic & security,
70
+ - **impact** — regressions & blast radius.
71
+ If the dispatch names no dimension, review correctness and say so at the
72
+ top of your report.
73
+
74
+ ## Dimension checklists
75
+ **Completeness** — go requirement by requirement: is each one actually
76
+ implemented? No half-done items, no silently dropped subtasks, no
77
+ "coming in a follow-up" without the lead's sign-off. Compare the stated
78
+ plan/spec against the real diff.
79
+ **Correctness** — logic errors, edge cases, off-by-one, null safety,
80
+ injection, auth bypass, secrets exposure, validation gaps, silent
81
+ failure paths.
82
+ **Impact** — what else can this break? Downstream consumers,
83
+ API/schema compatibility, performance characteristics, migration needs,
84
+ config and docs that now lie.
85
+
86
+ ## Severity scale (drives the team's feedback loop — grade honestly)
87
+ - 🔴 **Critical** — must fix; broken behavior or security hole.
88
+ - 🟠 **Major** — must fix; real defect or significant risk.
89
+ - 🟡 **Minor** — should fix, non-blocking.
90
+ - 🔵 **Nit** — style/preference, take-it-or-leave-it.
91
+ - ✅ **Praise** — good patterns worth keeping visible.
92
+
93
+ Findings at Critical/Major automatically become fix tasks, so only assign
94
+ them for genuine defects — inflating severity stalls the team.
95
+
96
+ ## Output format
97
+ For each finding: file:line, what is wrong, why it matters, concrete fix
98
+ (code snippet where it helps). End with a verdict line:
99
+ \`VERDICT: approve\` or \`VERDICT: request changes (N critical, M major)\`.
100
+
101
+ ## Re-review mode
102
+ When re-reviewing after fixes, stay within your dimension: focus ONLY on
103
+ the previously flagged scope plus regressions introduced by the fixes;
104
+ confirm each prior finding item by item (fixed / not fixed / partial).
105
+ `;
106
+ export const TESTER_PROMPT = `You are the **Tester** on a multi-agent coding team.
107
+
108
+ ## Role
109
+ You write comprehensive, maintainable tests and give the team a trustworthy
110
+ pass/fail signal.
111
+
112
+ ## Strategy
113
+ 1. Read the implementation thoroughly before writing any test.
114
+ 2. Cover happy path, edge cases, and error paths.
115
+ 3. Use the project's existing test framework, runner, and conventions.
116
+ 4. Table-driven tests (or equivalent) for parameterized cases.
117
+ 5. Mock external dependencies; test units in isolation.
118
+
119
+ ## Verification stack (default, in order)
120
+ 1. Build / typecheck.
121
+ 2. Static analysis / lint.
122
+ 3. Unit and API-level tests.
123
+ A "passed" verdict cites the actual command output for each layer that
124
+ ran.
125
+
126
+ ## Prohibited improvisation
127
+ Do NOT invent environment hacks as "verification": no ad-hoc headless
128
+ browser invocations (e.g. \`msedge --headless\` screenshots), no HTTP
129
+ requests against UI pages as UI proof, no hand-written DOM stubs. If the
130
+ project ALREADY ships a browser-test setup (e.g. a Playwright config in
131
+ the repo), you may use that tooling as designed.
132
+
133
+ ## UI verification (tm_browser — you carry it)
134
+ For user-visible frontend changes, verify through the governed tm_browser
135
+ instead of improvising: open → navigate → read (page text) → screenshot →
136
+ close. It drives the user's own Chromium-family browser headful, with an
137
+ isolated temp profile and a domain-allowlisted network layer. Your use is
138
+ UI verification of THIS project (local dev servers, deployed preview
139
+ routes) — open web browsing stays with the lead and the researcher. If
140
+ tm_browser is unavailable on this host, or the route needs credentials you
141
+ were not given, end your report with:
142
+ \`UI NOT VERIFIED: <what still needs manual checking>\`
143
+ so the lead can relay it honestly to the user. Pretending otherwise is
144
+ worse than admitting the gap.
145
+
146
+ ## Failure classification (required for every failing case)
147
+ - **PRODUCT_BUG** — the code is wrong. Include minimal repro + expected
148
+ vs actual. The lead will route this to the implementer.
149
+ - **TEST_DEFECT** — the test itself is wrong/flaky. Fix it yourself.
150
+ - **ENVIRONMENT** — tooling/deps/config issue. Report precisely; do not
151
+ work around silently.
152
+
153
+ ## Output format
154
+ - Test files created/modified.
155
+ - Run command used and result: passed / failed / error counts.
156
+ - Per-failure classification line as above.
157
+ - Verdict line: \`VERDICT: pass\` or \`VERDICT: fail (N product bugs)\`.
158
+
159
+ ## Rules
160
+ - Tests must be deterministic — no flaky tests.
161
+ - One behavior per test; descriptive names state the expectation.
162
+ - Boundaries always: empty input, max values, null/undefined.
163
+ - If the code is untestable as-is, say so and propose the minimal
164
+ refactor instead of contorting the test.
165
+ `;
166
+ export const RESEARCHER_PROMPT = `You are the **Researcher** on a multi-agent coding team.
167
+
168
+ ## Role
169
+ You find accurate, actionable information so the team can make informed
170
+ decisions. Your output feeds a verification loop — tag honestly.
171
+
172
+ ## Output format
173
+ 1. **Summary** — key findings in 2-3 sentences.
174
+ 2. **Findings** — one entry per fact/answer:
175
+ - statement
176
+ - \`[confidence: High|Medium|Low]\`
177
+ - source (official docs / source code / issue tracker / blog / inference)
178
+ 3. **Recommendation** — what the team should do, with trade-offs.
179
+ 4. **Gaps** — what you could not confirm and what would confirm it.
180
+
181
+ ## Confidence calibration
182
+ - **High** — official documentation, source code you quoted, vendor examples.
183
+ - **Medium** — reputable secondary sources, single community issue thread.
184
+ - **Low** — blog posts, your own inference, version-uncertain info.
185
+ Anything tagged Low/Medium that could change the design will be re-checked
186
+ by the team — flag prominently if that is the case.
187
+
188
+ ## Rules
189
+ - Cite sources with paths or links. Never fabricate URLs or API details.
190
+ - Separate fact from interpretation explicitly.
191
+ - Prefer official documentation; quote the relevant lines when reading code.
192
+ - State which product/version each finding applies to.
193
+
194
+ ## Web lookups (two channels)
195
+ You are one of the two network roles (the other is the team lead).
196
+ 1. HIGH priority — TeamMode governed tools:
197
+ - tm_search (open-ended lookups): ONE call — pass the raw query, pick an
198
+ engine, get an extracted title+URL hit list (not the raw page).
199
+ Engines: bing (default) · bing-int (international results) · sogou ·
200
+ so (360) · baidu · bilibili · moegirl (wiki, structured) · npm
201
+ (packages, structured) · github (repos, structured). On an empty
202
+ result switch engines — the error names the alternatives.
203
+ - tm_webfetch (known URL): one governed GET of an allowlisted page;
204
+ search-engine result pages it fetches are auto-extracted to hit lists.
205
+ - tm_browser (interactive): open → navigate → read (page text) →
206
+ screenshot → close. A visible browser window opens on desktops;
207
+ display-less hosts run headless automatically. Isolated temp
208
+ profile; per-request domain allowlist enforced at the network layer.
209
+ 2. FALLBACK — user-configured MCP/plugin tools (browser automation, web
210
+ search, page fetchers) for what tm_search / tm_browser / tm_webfetch
211
+ cannot do.
212
+ Seeded allowlist hosts and shapes (extend via
213
+ TM_WEBFETCH_ALLOWED_DOMAINS):
214
+ - wiki term: https://mobile.moegirl.org.cn/TERM
215
+ - bilibili: https://search.bilibili.com/all?keyword=QUERY
216
+ - bing: https://cn.bing.com/search?q=QUERY (append &ensearch=1
217
+ for international results)
218
+ - baidu: https://www.baidu.com/s?wd=QUERY
219
+ - sogou: https://www.sogou.com/web?query=QUERY
220
+ - 360: https://www.so.com/s?q=QUERY
221
+ - npm pkg: https://registry.npmjs.org/<pkg>/latest
222
+ - npm search: https://registry.npmjs.org/-/v1/search?text=QUERY
223
+ - gh repos: https://api.github.com/search/repositories?q=QUERY
224
+ URL-encode the query (CJK terms too). Expand colloquial, abbreviated,
225
+ or aliased terms to canonical forms and fetch BOTH spellings before
226
+ concluding "not found".
227
+ Oversized pages come back as a handle — page with tm_fetch (try
228
+ mode:"structure" first). Never fabricate page content — an unfetchable
229
+ claim stays unfetched and is reported as a gap.
230
+
231
+ ## Behavioral constraints
232
+ - When analyzing dependencies, output call-graph diagrams in mermaid format.
233
+ - When the code under study involves authentication/authorization, tag each
234
+ finding with a security-risk level (Critical / High / Medium / Low).
235
+ - When encountering unfamiliar modules, note what additional context would
236
+ help and suggest which tool or command could retrieve it.
237
+ - Before starting deep analysis, check whether a design doc or prior
238
+ research artifact already exists in the project — reference it instead
239
+ of re-deriving.
240
+ `;
241
+ //# sourceMappingURL=specialists.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"specialists.js","sourceRoot":"","sources":["../../src/prompts/specialists.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6B/B,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;CAwBjC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2C9B,CAAA;AAED,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2D5B,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0EhC,CAAA"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Shared shell statement segmentation — the ONE implementation of "split a
3
+ * command into shell segments" (compound statements and pipelines are
4
+ * checked at every boundary). Previously duplicated between
5
+ * envprotect/bash-classify.ts and tm/guard.ts; behavior identical in both.
6
+ */
7
+ /**
8
+ * Split a command into shell segments so compound statements like
9
+ * `cd /x && printenv` are checked at every statement boundary.
10
+ * NOTE: quoted `|`/`;` are literal text — callers that must not split on
11
+ * them blank quoted spans FIRST (see tm/guard.ts blankQuoted).
12
+ */
13
+ export declare function splitShellSegments(command: string): string[];
14
+ //# sourceMappingURL=shell-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell-text.d.ts","sourceRoot":"","sources":["../src/shell-text.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAE5D"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Shared shell statement segmentation — the ONE implementation of "split a
3
+ * command into shell segments" (compound statements and pipelines are
4
+ * checked at every boundary). Previously duplicated between
5
+ * envprotect/bash-classify.ts and tm/guard.ts; behavior identical in both.
6
+ */
7
+ /**
8
+ * Split a command into shell segments so compound statements like
9
+ * `cd /x && printenv` are checked at every statement boundary.
10
+ * NOTE: quoted `|`/`;` are literal text — callers that must not split on
11
+ * them blank quoted spans FIRST (see tm/guard.ts blankQuoted).
12
+ */
13
+ export function splitShellSegments(command) {
14
+ return command.split(/&&|\|\||[;\n|&]/);
15
+ }
16
+ //# sourceMappingURL=shell-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell-text.js","sourceRoot":"","sources":["../src/shell-text.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,OAAO,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;AACzC,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * tm layer — zod arg schemas (ZodRawShape) with descriptor fallback.
3
+ * Split out of the former tools.ts hub; behavior unchanged.
4
+ *
5
+ * Per-tool `args` — a ZodRawShape (plain `{key: validator}` object, official
6
+ * tool.d.ts:47-50), NOT a z.object(): the host serializes the raw shape into
7
+ * the LLM parameter spec. Wrapping it in z.object produced `{def:{command:
8
+ * ...}}` garbage args in real sessions (the model wrapped its args 3/3
9
+ * times), even though flat args reached execute fine.
10
+ */
11
+ declare function buildArgsSchemas(): Promise<Record<string, Record<string, unknown>>>;
12
+ export { buildArgsSchemas };
13
+ /**
14
+ * tm_ptc_run args — same ZodRawShape treatment (BUG#3 class): a raw shape
15
+ * when zod is available, descriptors otherwise. Kept separate from
16
+ * buildArgsSchemas because buildPtcRunTool is sync; tm/index awaits this
17
+ * once and passes the result in as `deps.args`.
18
+ */
19
+ export declare function buildPtcArgsSchema(): Promise<Record<string, unknown>>;
20
+ /**
21
+ * tm_webfetch args — same ZodRawShape treatment (BUG#3 class); descriptor
22
+ * fallback when zod is absent. tm/index awaits this and passes the result
23
+ * into buildTmWebfetchTool as `deps.args`.
24
+ */
25
+ export declare function buildWebfetchArgsSchema(): Promise<Record<string, unknown>>;
26
+ /**
27
+ * tm_search args — same ZodRawShape treatment (BUG#3 class); descriptor
28
+ * fallback when zod is absent. tm/index awaits this and passes the result
29
+ * into buildTmSearchTool as `deps.args`.
30
+ */
31
+ export declare function buildSearchArgsSchema(): Promise<Record<string, unknown>>;
32
+ /**
33
+ * tm_memory args — same ZodRawShape treatment (BUG#3 class); descriptor
34
+ * fallback when zod is absent.
35
+ */
36
+ export declare function buildMemoryArgsSchema(): Promise<Record<string, unknown>>;
37
+ /**
38
+ * tm_browser args — same ZodRawShape treatment (BUG#3 class); descriptor
39
+ * fallback when zod is absent.
40
+ */
41
+ export declare function buildBrowserArgsSchema(): Promise<Record<string, unknown>>;
42
+ //# sourceMappingURL=args-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args-schema.d.ts","sourceRoot":"","sources":["../../src/tm/args-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAkCH,iBAAe,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CA2ElF;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAA;AAE3B;;;;;GAKG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA+B3E;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAiBhF;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAoB9E;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA2B9E;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAkB/E"}
@@ -0,0 +1,213 @@
1
+ /**
2
+ * tm layer — zod arg schemas (ZodRawShape) with descriptor fallback.
3
+ * Split out of the former tools.ts hub; behavior unchanged.
4
+ *
5
+ * Per-tool `args` — a ZodRawShape (plain `{key: validator}` object, official
6
+ * tool.d.ts:47-50), NOT a z.object(): the host serializes the raw shape into
7
+ * the LLM parameter spec. Wrapping it in z.object produced `{def:{command:
8
+ * ...}}` garbage args in real sessions (the model wrapped its args 3/3
9
+ * times), even though flat args reached execute fine.
10
+ */
11
+ /**
12
+ * Load zod when the host environment provides it (opencode ships it as a
13
+ * peer); fall back to plain arg descriptors so the plugin never hard-depends
14
+ * on it. execute() is defensive either way — it coerces raw args itself.
15
+ */
16
+ async function loadZod() {
17
+ try {
18
+ const spec = "zod";
19
+ const mod = await import(spec);
20
+ const z = mod?.z ??
21
+ mod?.default?.z ??
22
+ null;
23
+ return z && typeof z.object === "function"
24
+ ? z
25
+ : null;
26
+ }
27
+ catch {
28
+ return null;
29
+ }
30
+ }
31
+ function describe(z, schema, fallback) {
32
+ if (z && typeof z.string === "function") {
33
+ return schema;
34
+ }
35
+ return { descriptor: fallback };
36
+ }
37
+ async function buildArgsSchemas() {
38
+ const z = await loadZod();
39
+ if (!z) {
40
+ return {
41
+ tm_read: describe(null, null, "path: string (required)"),
42
+ tm_grep: describe(null, null, "pattern: string (required), path: string (optional)"),
43
+ tm_bash: describe(null, null, "command: string (required, read-only allowlisted)"),
44
+ tm_fetch: describe(null, null, "ref: string (required), access_token: string, offset: int, limit: int, mode: lines|structure"),
45
+ };
46
+ }
47
+ const zz = z;
48
+ // RAW SHAPES — no zz.object() wrapper (BUG#3).
49
+ return {
50
+ tm_read: {
51
+ path: zz
52
+ .string()
53
+ .describe("File path, relative to the project root (or absolute within it). Env files (.env, *.env, .bashrc family) are rejected — same R6 source as the built-in read."),
54
+ },
55
+ tm_grep: {
56
+ pattern: zz.string().describe("Regex to search (ripgrep syntax)."),
57
+ path: zz
58
+ .string()
59
+ .describe("Optional directory scope, relative to the project root.")
60
+ .optional(),
61
+ },
62
+ tm_bash: {
63
+ command: zz
64
+ .string()
65
+ .describe("Read-only shell command (allowlisted heads only). bash on POSIX, PowerShell-like on Windows."),
66
+ },
67
+ tm_fetch: {
68
+ ref: zz
69
+ .string()
70
+ .describe("Offload handle ref: tm://runs/{run_id}/steps/{step_id}/result"),
71
+ access_token: zz
72
+ .string()
73
+ .describe("HMAC token from the offload handle (may also ride the ref fragment).")
74
+ .optional(),
75
+ offset: zz
76
+ .number()
77
+ .int()
78
+ .min(0)
79
+ .describe("0-based line offset of the first line to return.")
80
+ .optional(),
81
+ limit: zz
82
+ .number()
83
+ .int()
84
+ .min(1)
85
+ .describe("Max lines per fetch, capped at TM_FETCH_MAX_LINES (default 2000).")
86
+ .optional(),
87
+ mode: zz
88
+ .enum(["lines", "structure"])
89
+ .describe("structure = ~100-token TOC / key tree / error-line map; try it first.")
90
+ .optional(),
91
+ },
92
+ };
93
+ }
94
+ export { buildArgsSchemas };
95
+ /**
96
+ * tm_ptc_run args — same ZodRawShape treatment (BUG#3 class): a raw shape
97
+ * when zod is available, descriptors otherwise. Kept separate from
98
+ * buildArgsSchemas because buildPtcRunTool is sync; tm/index awaits this
99
+ * once and passes the result in as `deps.args`.
100
+ */
101
+ export async function buildPtcArgsSchema() {
102
+ const z = await loadZod();
103
+ if (!z) {
104
+ return {
105
+ program: { descriptor: "program: string (required, async fn body, ≤TM_PTC_MAX_PROGRAM_CHARS)" },
106
+ label: { descriptor: "label: string (optional, ≤80 chars)" },
107
+ budgets: { descriptor: "budgets: { max_calls?, max_errors?, timeout_ms? } (optional, tighten-only)" },
108
+ };
109
+ }
110
+ const zz = z;
111
+ return {
112
+ program: zz
113
+ .string()
114
+ .describe("Async function body. Available: tm.read(args), tm.grep(args), tm.bash(args), tm.fetch(args) — each returns {ok:true, data} or {ok:false, error:{tool,phase,line?,message}}. `return` a value for the aggregation summary."),
115
+ label: zz.string().describe("Optional run label (≤80 chars).").optional(),
116
+ budgets: zz
117
+ .any()
118
+ .describe("Optional budgets object { max_calls?, max_errors?, timeout_ms? } — tighten-only, clamped to the TM_PTC_* ceilings.")
119
+ .optional(),
120
+ };
121
+ }
122
+ /**
123
+ * tm_webfetch args — same ZodRawShape treatment (BUG#3 class); descriptor
124
+ * fallback when zod is absent. tm/index awaits this and passes the result
125
+ * into buildTmWebfetchTool as `deps.args`.
126
+ */
127
+ export async function buildWebfetchArgsSchema() {
128
+ const z = await loadZod();
129
+ if (!z) {
130
+ return {
131
+ url: { descriptor: "url: string (required, absolute https URL on an allowlisted host, query URL-encoded)" },
132
+ };
133
+ }
134
+ const zz = z;
135
+ return {
136
+ url: zz
137
+ .string()
138
+ .describe("Absolute https URL on an allowlisted host (seeded: mobile.moegirl.org.cn, search.bilibili.com, cn.bing.com, www.baidu.com, www.sogou.com, www.so.com, registry.npmjs.org, api.github.com). URL-encode the query (CJK terms too)."),
139
+ };
140
+ }
141
+ /**
142
+ * tm_search args — same ZodRawShape treatment (BUG#3 class); descriptor
143
+ * fallback when zod is absent. tm/index awaits this and passes the result
144
+ * into buildTmSearchTool as `deps.args`.
145
+ */
146
+ export async function buildSearchArgsSchema() {
147
+ const z = await loadZod();
148
+ if (!z) {
149
+ return {
150
+ query: { descriptor: "query: string (required, raw text — CJK fine, encoded here)" },
151
+ engine: { descriptor: "engine: bing|bing-int|sogou|so|baidu|bilibili|npm|github (optional, default bing)" },
152
+ };
153
+ }
154
+ const zz = z;
155
+ return {
156
+ query: zz.string().describe("Raw search query — pass text as-is; the tool URL-encodes it (CJK included)."),
157
+ engine: zz
158
+ .string()
159
+ .describe("bing (default) | bing-int (international results) | sogou | so (360) | baidu | bilibili | moegirl (wiki search API, structured) | npm (registry search, structured) | github (repo search API, structured).")
160
+ .optional(),
161
+ };
162
+ }
163
+ /**
164
+ * tm_memory args — same ZodRawShape treatment (BUG#3 class); descriptor
165
+ * fallback when zod is absent.
166
+ */
167
+ export async function buildMemoryArgsSchema() {
168
+ const z = await loadZod();
169
+ if (!z) {
170
+ return {
171
+ action: { descriptor: "action: add|search|list|forget (required)" },
172
+ title: { descriptor: "title: string (add/forget)" },
173
+ content: { descriptor: "content: string (add, ≤4000 chars)" },
174
+ category: { descriptor: "category: string (add, optional)" },
175
+ keywords: { descriptor: "keywords: string[] or comma string (add, optional)" },
176
+ usage_scenario: { descriptor: "usage_scenario: string[] or comma string (add, optional)" },
177
+ query: { descriptor: "query: string (search)" },
178
+ scope: { descriptor: "scope: project|global (optional, default project)" },
179
+ };
180
+ }
181
+ const zz = z;
182
+ return {
183
+ action: zz.string().describe("add | search | list | forget."),
184
+ title: zz.string().describe("Memory title (add/forget).").optional(),
185
+ content: zz.string().describe("One condensed fact, ≤4000 chars (add).").optional(),
186
+ category: zz.string().describe("Category slug, e.g. project_tech_stack (add, optional).").optional(),
187
+ keywords: zz.string().describe("Comma-separated keywords (add, optional).").optional(),
188
+ usage_scenario: zz.string().describe("Comma-separated when-to-use scenarios (add, optional).").optional(),
189
+ query: zz.string().describe("Search query (search).").optional(),
190
+ scope: zz.string().describe("project (default) | global.").optional(),
191
+ };
192
+ }
193
+ /**
194
+ * tm_browser args — same ZodRawShape treatment (BUG#3 class); descriptor
195
+ * fallback when zod is absent.
196
+ */
197
+ export async function buildBrowserArgsSchema() {
198
+ const z = await loadZod();
199
+ if (!z) {
200
+ return {
201
+ action: { descriptor: 'action: open|navigate|read|screenshot|close (required)' },
202
+ url: { descriptor: 'url: string (open/navigate, allowlisted https)' },
203
+ headless: { descriptor: 'headless: boolean (open, optional — default auto)' },
204
+ };
205
+ }
206
+ const zz = z;
207
+ return {
208
+ action: zz.string().describe('open | navigate | read | screenshot | close.'),
209
+ url: zz.string().describe('Absolute https URL on an allowlisted host (open/navigate). URL-encode the query (CJK terms too).').optional(),
210
+ headless: zz.boolean().describe('Force headless/headful on open (optional — default auto by display availability).').optional(),
211
+ };
212
+ }
213
+ //# sourceMappingURL=args-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args-schema.js","sourceRoot":"","sources":["../../src/tm/args-schema.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;GAIG;AACH,KAAK,UAAU,OAAO;IACpB,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,KAAK,CAAA;QAClB,MAAM,GAAG,GAAY,MAAM,MAAM,CAAC,IAAI,CAAC,CAAA;QACvC,MAAM,CAAC,GACJ,GAAuB,EAAE,CAAC;YAC1B,GAAqC,EAAE,OAAO,EAAE,CAAC;YAClD,IAAI,CAAA;QACN,OAAO,CAAC,IAAI,OAAQ,CAA0B,CAAC,MAAM,KAAK,UAAU;YAClE,CAAC,CAAE,CAA6B;YAChC,CAAC,CAAC,IAAI,CAAA;IACV,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CACf,CAAiC,EACjC,MAAe,EACf,QAAgB;IAEhB,IAAI,CAAC,IAAI,OAAQ,CAA0B,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;QAClE,OAAO,MAAiC,CAAA;IAC1C,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAA;AACjC,CAAC;AAED,KAAK,UAAU,gBAAgB;IAC7B,MAAM,CAAC,GAAG,MAAM,OAAO,EAAE,CAAA;IACzB,IAAI,CAAC,CAAC,EAAE,CAAC;QACP,OAAO;YACL,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,yBAAyB,CAAC;YACxD,OAAO,EAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,qDAAqD,CAAC;YACp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Chromium-family browser driven headful over the CDP pipe protocol).
4
+ *
5
+ * Feasibility proven by smoke (Edge + --remote-debugging-pipe + JSON/NUL
6
+ * framing over fds 3/4 — zero deps, no WebSocket implementation). Qoder's
7
+ * hardening ideas are ported where the plugin can reach them:
8
+ * - isolated temp user-data-dir (never the user's real profile);
9
+ * - per-navigation allowlist enforced at the NETWORK layer via CDP
10
+ * Fetch.requestPaused (non-allowlisted hosts get BlockedByClient —
11
+ * the per-hop re-check analog);
12
+ * - hardened webPreferences are the spawn's own flags (no-first-run,
13
+ * no-extensions, mute);
14
+ * - hard per-command timeout + explicit close; dispose kills the child.
15
+ *
16
+ * Environment adaptivity (different OpenCode hosts):
17
+ * - headful by default (Plan C); display-less Linux (no DISPLAY/
18
+ * WAYLAND_DISPLAY) automatically falls back to headless; TM_BROWSER_
19
+ * HEADLESS=1|0 forces either way;
20
+ * - browser discovery: TM_BROWSER_PATH override, then per-OS candidate
21
+ * paths (Edge first on Windows — it is always there; Chrome/Chromium
22
+ * elsewhere). No browser → structured error, the agent falls back to
23
+ * tm_webfetch / user MCP tools per the priority ladder.
24
+ *
25
+ * Role access mirrors tm_webfetch: network roles (team + researcher) only.
26
+ */
27
+ import type { ToolResult } from "../types.js";
28
+ import type { TmConfig } from "./config.js";
29
+ import type { TmPipelines } from "./pipelines.js";
30
+ /** Resolve the browser executable: TM_BROWSER_PATH override, then per-OS
31
+ * candidates. %LOCALAPPDATA% style vars are expanded on win32. */
32
+ export declare function findBrowserExecutable(env?: Record<string, string | undefined>): string | null;
33
+ /**
34
+ * Headless resolution (Plan C = headful by default):
35
+ * TM_BROWSER_HEADLESS=1|true|force → headless (servers/CI)
36
+ * TM_BROWSER_HEADLESS=0|false|never → headful
37
+ * auto (default) → headless ONLY when there is no
38
+ * display possible (Linux without DISPLAY/WAYLAND_DISPLAY).
39
+ */
40
+ export declare function resolveHeadless(env?: Record<string, string | undefined>): boolean;
41
+ export declare function buildTmBrowserTool(deps: {
42
+ pipelines: TmPipelines;
43
+ cfg: TmConfig;
44
+ env?: Record<string, string | undefined>;
45
+ args?: Record<string, unknown>;
46
+ }): {
47
+ description: string;
48
+ args: Record<string, unknown>;
49
+ execute: (rawArgs: Record<string, unknown>, ctx: unknown) => Promise<ToolResult>;
50
+ dispose: () => void;
51
+ };
52
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/tm/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAOH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AA0BjD;oEACoE;AACpE,wBAAgB,qBAAqB,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GAAG,MAAM,GAAG,IAAI,CAgB1G;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GAAG,OAAO,CAM9F;AA0FD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,SAAS,EAAE,WAAW,CAAA;IACtB,GAAG,EAAE,QAAQ,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC/B,GAAG;IACF,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,OAAO,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,OAAO,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;IAChF,OAAO,EAAE,MAAM,IAAI,CAAA;CACpB,CA2MA"}