@te-river/opencode-team-mode 1.5.5 → 1.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +732 -634
- package/README.zh-CN.md +655 -576
- package/dist/agents.d.ts +6 -1
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +103 -531
- package/dist/agents.js.map +1 -1
- package/dist/approval-gate.d.ts +16 -0
- package/dist/approval-gate.d.ts.map +1 -1
- package/dist/approval-gate.js +8 -1
- package/dist/approval-gate.js.map +1 -1
- package/dist/blackboard.d.ts.map +1 -1
- package/dist/blackboard.js +3 -2
- package/dist/blackboard.js.map +1 -1
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +7 -6
- package/dist/commands.js.map +1 -1
- package/dist/envprotect/bash-classify.d.ts +42 -0
- package/dist/envprotect/bash-classify.d.ts.map +1 -0
- package/dist/envprotect/bash-classify.js +221 -0
- package/dist/envprotect/bash-classify.js.map +1 -0
- package/dist/envprotect/gate-predicates.d.ts +57 -0
- package/dist/envprotect/gate-predicates.d.ts.map +1 -0
- package/dist/envprotect/gate-predicates.js +174 -0
- package/dist/envprotect/gate-predicates.js.map +1 -0
- package/dist/envprotect/hook.d.ts +45 -0
- package/dist/envprotect/hook.d.ts.map +1 -0
- package/dist/envprotect/hook.js +158 -0
- package/dist/envprotect/hook.js.map +1 -0
- package/dist/envprotect/path-classify.d.ts +16 -0
- package/dist/envprotect/path-classify.d.ts.map +1 -0
- package/dist/envprotect/path-classify.js +72 -0
- package/dist/envprotect/path-classify.js.map +1 -0
- package/dist/envprotect/patterns.d.ts +77 -0
- package/dist/envprotect/patterns.d.ts.map +1 -0
- package/dist/envprotect/patterns.js +182 -0
- package/dist/envprotect/patterns.js.map +1 -0
- package/dist/envprotect.d.ts +19 -217
- package/dist/envprotect.d.ts.map +1 -1
- package/dist/envprotect.js +18 -803
- package/dist/envprotect.js.map +1 -1
- package/dist/fs-safe.d.ts +16 -0
- package/dist/fs-safe.d.ts.map +1 -0
- package/dist/fs-safe.js +56 -0
- package/dist/fs-safe.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -6
- package/dist/index.js.map +1 -1
- package/dist/prompts/lead.d.ts +7 -0
- package/dist/prompts/lead.d.ts.map +1 -0
- package/dist/prompts/lead.js +230 -0
- package/dist/prompts/lead.js.map +1 -0
- package/dist/prompts/shared.d.ts +8 -0
- package/dist/prompts/shared.d.ts.map +1 -0
- package/dist/prompts/shared.js +118 -0
- package/dist/prompts/shared.js.map +1 -0
- package/dist/prompts/specialists.d.ts +12 -0
- package/dist/prompts/specialists.d.ts.map +1 -0
- package/dist/prompts/specialists.js +218 -0
- package/dist/prompts/specialists.js.map +1 -0
- package/dist/shell-text.d.ts +14 -0
- package/dist/shell-text.d.ts.map +1 -0
- package/dist/shell-text.js +16 -0
- package/dist/shell-text.js.map +1 -0
- package/dist/tm/args-schema.d.ts +36 -0
- package/dist/tm/args-schema.d.ts.map +1 -0
- package/dist/tm/args-schema.js +191 -0
- package/dist/tm/args-schema.js.map +1 -0
- package/dist/tm/browser.d.ts +52 -0
- package/dist/tm/browser.d.ts.map +1 -0
- package/dist/tm/browser.js +361 -0
- package/dist/tm/browser.js.map +1 -0
- package/dist/tm/client-unwrap.d.ts +38 -0
- package/dist/tm/client-unwrap.d.ts.map +1 -0
- package/dist/tm/client-unwrap.js +113 -0
- package/dist/tm/client-unwrap.js.map +1 -0
- package/dist/tm/config.d.ts +46 -18
- package/dist/tm/config.d.ts.map +1 -1
- package/dist/tm/config.js +60 -17
- package/dist/tm/config.js.map +1 -1
- package/dist/tm/guard.d.ts.map +1 -1
- package/dist/tm/guard.js +4 -7
- package/dist/tm/guard.js.map +1 -1
- package/dist/tm/index.d.ts +15 -5
- package/dist/tm/index.d.ts.map +1 -1
- package/dist/tm/index.js +95 -19
- package/dist/tm/index.js.map +1 -1
- package/dist/tm/memory.d.ts +82 -0
- package/dist/tm/memory.d.ts.map +1 -0
- package/dist/tm/memory.js +350 -0
- package/dist/tm/memory.js.map +1 -0
- package/dist/tm/pipelines.d.ts +58 -0
- package/dist/tm/pipelines.d.ts.map +1 -0
- package/dist/tm/pipelines.js +301 -0
- package/dist/tm/pipelines.js.map +1 -0
- package/dist/tm/preview.d.ts +6 -1
- package/dist/tm/preview.d.ts.map +1 -1
- package/dist/tm/preview.js +31 -8
- package/dist/tm/preview.js.map +1 -1
- package/dist/tm/ptc/budgets.d.ts +38 -0
- package/dist/tm/ptc/budgets.d.ts.map +1 -0
- package/dist/tm/ptc/budgets.js +59 -0
- package/dist/tm/ptc/budgets.js.map +1 -0
- package/dist/tm/ptc/contract.d.ts +131 -0
- package/dist/tm/ptc/contract.d.ts.map +1 -0
- package/dist/tm/ptc/contract.js +47 -0
- package/dist/tm/ptc/contract.js.map +1 -0
- package/dist/tm/ptc/driver.d.ts +37 -0
- package/dist/tm/ptc/driver.d.ts.map +1 -0
- package/dist/tm/ptc/driver.js +181 -0
- package/dist/tm/ptc/driver.js.map +1 -0
- package/dist/tm/ptc/engines.d.ts +32 -0
- package/dist/tm/ptc/engines.d.ts.map +1 -0
- package/dist/tm/ptc/engines.js +201 -0
- package/dist/tm/ptc/engines.js.map +1 -0
- package/dist/tm/ptc/gate.d.ts +28 -0
- package/dist/tm/ptc/gate.d.ts.map +1 -0
- package/dist/tm/ptc/gate.js +127 -0
- package/dist/tm/ptc/gate.js.map +1 -0
- package/dist/tm/ptc/index.d.ts +19 -0
- package/dist/tm/ptc/index.d.ts.map +1 -0
- package/dist/tm/ptc/index.js +15 -0
- package/dist/tm/ptc/index.js.map +1 -0
- package/dist/tm/ptc/pscan.d.ts +11 -0
- package/dist/tm/ptc/pscan.d.ts.map +1 -0
- package/dist/tm/ptc/pscan.js +27 -0
- package/dist/tm/ptc/pscan.js.map +1 -0
- package/dist/tm/ptc/summary.d.ts +17 -0
- package/dist/tm/ptc/summary.d.ts.map +1 -0
- package/dist/tm/ptc/summary.js +107 -0
- package/dist/tm/ptc/summary.js.map +1 -0
- package/dist/tm/ptc/tool.d.ts +35 -0
- package/dist/tm/ptc/tool.d.ts.map +1 -0
- package/dist/tm/ptc/tool.js +135 -0
- package/dist/tm/ptc/tool.js.map +1 -0
- package/dist/tm/ptc.d.ts +45 -26
- package/dist/tm/ptc.d.ts.map +1 -1
- package/dist/tm/ptc.js +71 -45
- package/dist/tm/ptc.js.map +1 -1
- package/dist/tm/result.d.ts +34 -0
- package/dist/tm/result.d.ts.map +1 -0
- package/dist/tm/result.js +87 -0
- package/dist/tm/result.js.map +1 -0
- package/dist/tm/shell-bridge.d.ts +22 -0
- package/dist/tm/shell-bridge.d.ts.map +1 -0
- package/dist/tm/shell-bridge.js +70 -0
- package/dist/tm/shell-bridge.js.map +1 -0
- package/dist/tm/store.d.ts.map +1 -1
- package/dist/tm/store.js +2 -1
- package/dist/tm/store.js.map +1 -1
- package/dist/tm/tools.d.ts +13 -71
- package/dist/tm/tools.d.ts.map +1 -1
- package/dist/tm/tools.js +21 -655
- package/dist/tm/tools.js.map +1 -1
- package/dist/tm/webfetch.d.ts +94 -0
- package/dist/tm/webfetch.d.ts.map +1 -0
- package/dist/tm/webfetch.js +225 -0
- package/dist/tm/webfetch.js.map +1 -0
- package/package.json +2 -2
|
@@ -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. Otherwise, for\nuser-visible frontend changes, 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_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.\n - tm_webfetch (single fetch): one governed GET of an allowlisted page.\n2. FALLBACK \u2014 user-configured MCP/plugin tools (browser automation, web\n search, page fetchers) for what tm_browser / tm_webfetch 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\n - baidu: https://www.baidu.com/s?wd=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,uqEAkDzB,CAAA;AAED,eAAO,MAAM,iBAAiB,+oGA4D7B,CAAA"}
|
|
@@ -0,0 +1,218 @@
|
|
|
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. Otherwise, for
|
|
132
|
+
user-visible frontend changes, end your report with:
|
|
133
|
+
\`UI NOT VERIFIED: <what still needs manual checking>\`
|
|
134
|
+
so the lead can relay it honestly to the user. Pretending otherwise is
|
|
135
|
+
worse than admitting the gap.
|
|
136
|
+
|
|
137
|
+
## Failure classification (required for every failing case)
|
|
138
|
+
- **PRODUCT_BUG** — the code is wrong. Include minimal repro + expected
|
|
139
|
+
vs actual. The lead will route this to the implementer.
|
|
140
|
+
- **TEST_DEFECT** — the test itself is wrong/flaky. Fix it yourself.
|
|
141
|
+
- **ENVIRONMENT** — tooling/deps/config issue. Report precisely; do not
|
|
142
|
+
work around silently.
|
|
143
|
+
|
|
144
|
+
## Output format
|
|
145
|
+
- Test files created/modified.
|
|
146
|
+
- Run command used and result: passed / failed / error counts.
|
|
147
|
+
- Per-failure classification line as above.
|
|
148
|
+
- Verdict line: \`VERDICT: pass\` or \`VERDICT: fail (N product bugs)\`.
|
|
149
|
+
|
|
150
|
+
## Rules
|
|
151
|
+
- Tests must be deterministic — no flaky tests.
|
|
152
|
+
- One behavior per test; descriptive names state the expectation.
|
|
153
|
+
- Boundaries always: empty input, max values, null/undefined.
|
|
154
|
+
- If the code is untestable as-is, say so and propose the minimal
|
|
155
|
+
refactor instead of contorting the test.
|
|
156
|
+
`;
|
|
157
|
+
export const RESEARCHER_PROMPT = `You are the **Researcher** on a multi-agent coding team.
|
|
158
|
+
|
|
159
|
+
## Role
|
|
160
|
+
You find accurate, actionable information so the team can make informed
|
|
161
|
+
decisions. Your output feeds a verification loop — tag honestly.
|
|
162
|
+
|
|
163
|
+
## Output format
|
|
164
|
+
1. **Summary** — key findings in 2-3 sentences.
|
|
165
|
+
2. **Findings** — one entry per fact/answer:
|
|
166
|
+
- statement
|
|
167
|
+
- \`[confidence: High|Medium|Low]\`
|
|
168
|
+
- source (official docs / source code / issue tracker / blog / inference)
|
|
169
|
+
3. **Recommendation** — what the team should do, with trade-offs.
|
|
170
|
+
4. **Gaps** — what you could not confirm and what would confirm it.
|
|
171
|
+
|
|
172
|
+
## Confidence calibration
|
|
173
|
+
- **High** — official documentation, source code you quoted, vendor examples.
|
|
174
|
+
- **Medium** — reputable secondary sources, single community issue thread.
|
|
175
|
+
- **Low** — blog posts, your own inference, version-uncertain info.
|
|
176
|
+
Anything tagged Low/Medium that could change the design will be re-checked
|
|
177
|
+
by the team — flag prominently if that is the case.
|
|
178
|
+
|
|
179
|
+
## Rules
|
|
180
|
+
- Cite sources with paths or links. Never fabricate URLs or API details.
|
|
181
|
+
- Separate fact from interpretation explicitly.
|
|
182
|
+
- Prefer official documentation; quote the relevant lines when reading code.
|
|
183
|
+
- State which product/version each finding applies to.
|
|
184
|
+
|
|
185
|
+
## Web lookups (two channels)
|
|
186
|
+
You are one of the two network roles (the other is the team lead).
|
|
187
|
+
1. HIGH priority — TeamMode governed tools:
|
|
188
|
+
- tm_browser (interactive): open → navigate → read (page text) →
|
|
189
|
+
screenshot → close. A visible browser window opens on desktops;
|
|
190
|
+
display-less hosts run headless automatically. Isolated temp
|
|
191
|
+
profile; per-request domain allowlist enforced at the network layer.
|
|
192
|
+
- tm_webfetch (single fetch): one governed GET of an allowlisted page.
|
|
193
|
+
2. FALLBACK — user-configured MCP/plugin tools (browser automation, web
|
|
194
|
+
search, page fetchers) for what tm_browser / tm_webfetch cannot do.
|
|
195
|
+
Seeded allowlist hosts and shapes (extend via
|
|
196
|
+
TM_WEBFETCH_ALLOWED_DOMAINS):
|
|
197
|
+
- wiki term: https://mobile.moegirl.org.cn/TERM
|
|
198
|
+
- bilibili: https://search.bilibili.com/all?keyword=QUERY
|
|
199
|
+
- bing: https://cn.bing.com/search?q=QUERY
|
|
200
|
+
- baidu: https://www.baidu.com/s?wd=QUERY
|
|
201
|
+
URL-encode the query (CJK terms too). Expand colloquial, abbreviated,
|
|
202
|
+
or aliased terms to canonical forms and fetch BOTH spellings before
|
|
203
|
+
concluding "not found".
|
|
204
|
+
Oversized pages come back as a handle — page with tm_fetch (try
|
|
205
|
+
mode:"structure" first). Never fabricate page content — an unfetchable
|
|
206
|
+
claim stays unfetched and is reported as a gap.
|
|
207
|
+
|
|
208
|
+
## Behavioral constraints
|
|
209
|
+
- When analyzing dependencies, output call-graph diagrams in mermaid format.
|
|
210
|
+
- When the code under study involves authentication/authorization, tag each
|
|
211
|
+
finding with a security-risk level (Critical / High / Medium / Low).
|
|
212
|
+
- When encountering unfamiliar modules, note what additional context would
|
|
213
|
+
help and suggest which tool or command could retrieve it.
|
|
214
|
+
- Before starting deep analysis, check whether a design doc or prior
|
|
215
|
+
research artifact already exists in the project — reference it instead
|
|
216
|
+
of re-deriving.
|
|
217
|
+
`;
|
|
218
|
+
//# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkD5B,CAAA;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4DhC,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,36 @@
|
|
|
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_memory args — same ZodRawShape treatment (BUG#3 class); descriptor
|
|
28
|
+
* fallback when zod is absent.
|
|
29
|
+
*/
|
|
30
|
+
export declare function buildMemoryArgsSchema(): Promise<Record<string, unknown>>;
|
|
31
|
+
/**
|
|
32
|
+
* tm_browser args — same ZodRawShape treatment (BUG#3 class); descriptor
|
|
33
|
+
* fallback when zod is absent.
|
|
34
|
+
*/
|
|
35
|
+
export declare function buildBrowserArgsSchema(): Promise<Record<string, unknown>>;
|
|
36
|
+
//# 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;;;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,191 @@
|
|
|
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). URL-encode the query (CJK terms too)."),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* tm_memory args — same ZodRawShape treatment (BUG#3 class); descriptor
|
|
143
|
+
* fallback when zod is absent.
|
|
144
|
+
*/
|
|
145
|
+
export async function buildMemoryArgsSchema() {
|
|
146
|
+
const z = await loadZod();
|
|
147
|
+
if (!z) {
|
|
148
|
+
return {
|
|
149
|
+
action: { descriptor: "action: add|search|list|forget (required)" },
|
|
150
|
+
title: { descriptor: "title: string (add/forget)" },
|
|
151
|
+
content: { descriptor: "content: string (add, ≤4000 chars)" },
|
|
152
|
+
category: { descriptor: "category: string (add, optional)" },
|
|
153
|
+
keywords: { descriptor: "keywords: string[] or comma string (add, optional)" },
|
|
154
|
+
usage_scenario: { descriptor: "usage_scenario: string[] or comma string (add, optional)" },
|
|
155
|
+
query: { descriptor: "query: string (search)" },
|
|
156
|
+
scope: { descriptor: "scope: project|global (optional, default project)" },
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
const zz = z;
|
|
160
|
+
return {
|
|
161
|
+
action: zz.string().describe("add | search | list | forget."),
|
|
162
|
+
title: zz.string().describe("Memory title (add/forget).").optional(),
|
|
163
|
+
content: zz.string().describe("One condensed fact, ≤4000 chars (add).").optional(),
|
|
164
|
+
category: zz.string().describe("Category slug, e.g. project_tech_stack (add, optional).").optional(),
|
|
165
|
+
keywords: zz.string().describe("Comma-separated keywords (add, optional).").optional(),
|
|
166
|
+
usage_scenario: zz.string().describe("Comma-separated when-to-use scenarios (add, optional).").optional(),
|
|
167
|
+
query: zz.string().describe("Search query (search).").optional(),
|
|
168
|
+
scope: zz.string().describe("project (default) | global.").optional(),
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* tm_browser args — same ZodRawShape treatment (BUG#3 class); descriptor
|
|
173
|
+
* fallback when zod is absent.
|
|
174
|
+
*/
|
|
175
|
+
export async function buildBrowserArgsSchema() {
|
|
176
|
+
const z = await loadZod();
|
|
177
|
+
if (!z) {
|
|
178
|
+
return {
|
|
179
|
+
action: { descriptor: 'action: open|navigate|read|screenshot|close (required)' },
|
|
180
|
+
url: { descriptor: 'url: string (open/navigate, allowlisted https)' },
|
|
181
|
+
headless: { descriptor: 'headless: boolean (open, optional — default auto)' },
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
const zz = z;
|
|
185
|
+
return {
|
|
186
|
+
action: zz.string().describe('open | navigate | read | screenshot | close.'),
|
|
187
|
+
url: zz.string().describe('Absolute https URL on an allowlisted host (open/navigate). URL-encode the query (CJK terms too).').optional(),
|
|
188
|
+
headless: zz.boolean().describe('Force headless/headful on open (optional — default auto by display availability).').optional(),
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
//# 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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,8CAA8C,CAAC;QAC5E,GAAG,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,kGAAkG,CAAC,CAAC,QAAQ,EAAE;QACxI,QAAQ,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,mFAAmF,CAAC,CAAC,QAAQ,EAAE;KAChI,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* tm_browser — governed interactive browser (Plan C: the user's own
|
|
3
|
+
* 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"}
|