Skip to content

[pull] main from Tencent:main - #5

Merged
pull[bot] merged 4 commits into
Walternater:mainfrom
Tencent:main
Aug 26, 2026
Merged

pull[bot] merged 4 commits into
Walternater:mainfrom
Tencent:main

Conversation

@pull

@pull pull Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

jeff-r2026 and others added 4 commits August 26, 2026 13:05
teamai init reused an existing .teamai/team-repo clone whenever the path
was a git repo, without checking that its origin matched the requested
--repo. A leftover clone from a different team repo was served silently,
surfacing the wrong roles/skills manifest.

Compare the existing clone's origin against the requested repo (ignoring
credentials, protocol, scp-vs-URL form, .git suffix, port, and case). On
mismatch: --force replaces it, interactive prompts, otherwise abort and
keep the clone. Embedded credentials are redacted from the warning.
…326)

* feat(opencode): sync built-in and agent hooks as an OpenCode plugin

OpenCode has no settings.json hook list; it auto-loads JS/TS plugins from
.opencode/plugin (project) or ~/.config/opencode/plugin (user). Generate a
teamai-hooks.ts plugin there that subscribes to OpenCode's own events and
shells out to the same `teamai hook-dispatch` entry point every other tool
uses. Fire-and-forget (OpenCode cannot inject a hook's stdout back into the
session), matching the Hermes/OpenClaw adapters.

Event mapping mirrors the Claude built-in set:
  session.created    -> session-start
  session.idle       -> stop
  chat.message       -> prompt-submit
  tool.execute.after -> post-tool-use (Skill/TodoWrite matchers forwarded)

- new src/opencode-hooks.ts: plugin generator + inject/remove + agent-hook pair
- hooks.ts: route opencode through the plugin adapter in reconcile/inject-all,
  threading scope so project vs user lands in the right config dir
- hooks-cmd.ts: pass scope on inject/remove (global ~/.config/opencode/plugin)
- local-agent.ts: dispatch HTTP-source agent hooks to the opencode backend
- uninstall.ts: discover and remove opencode plugin files (main + agent hooks)
- pull.ts: thread scope through hook auto-migration
- docs: README (both langs) feature matrix hooks column, usage-guide OpenCode section

Closes #303 (final remaining piece: OpenCode hooks).

* fix(opencode): forward hook STDIN payload, map tool ids, gate & sanitize agent hooks

The OpenCode plugin adapter had four defects, all verified against a real
OpenCode 1.15.13 runtime (tool ids come back lowercase; named hooks are awaited):

1. Matcher casing: the plugin tested `tool === 'Skill' || 'TodoWrite'`, but
   OpenCode passes lowercase ids (`skill`/`todowrite`), so the Skill-usage and
   TodoWrite-hint handlers never fired. Map the id back to the PascalCase
   matcher the handler registry keys on.

2. Empty STDIN: the plugin shelled out with no payload, so track/track-slash/
   todowrite-hint (which read tool_name/tool_input/prompt) no-op'd, and the
   provider-config gate fell back to the user config because cwd was undefined.
   Forward a JSON payload on STDIN (cwd from the plugin ctx + per-event fields)
   via a Response (Bun shell can't redirect a bare string).

3. Agent-hook matcher ignored: applyOpencodeAgentHook dropped matcher/timeout,
   so a tool-scoped enterprise hook ran after every tool call. Thread matcher
   through and gate tool.execute.after on the (case-insensitive) tool id.

4. Slug path traversal: the agent-hook filename was built from an unsanitized
   backend slug, so `../../evil` wrote outside the plugin dir. Add assertSafeSlug.

Docs (both languages) corrected: OpenCode awaits its named hooks, so the
dispatch is not truly non-blocking for chat.message/tool.execute.after.

* fix(opencode): keep one plugin copy and fix uninstall sweep path

OpenCode auto-loads plugins from both ~/.config/opencode/plugin and
<project>/.opencode/plugin. pull/init wrote the plugin at the active
teamai scope while `hooks inject` and agent hooks always wrote the user
dir, so a project-scope setup ended up with two identical plugins loaded
in the same workspace — every event dispatched twice (sync, dashboard,
session-start pull).

Route every path through one reconciler that writes only the user plugin
dir and deletes a project-scope copy from the earlier layout, and drop
the now-unused scope plumbing. Uninstall inspects both locations, and its
agent-hook sweep joins the plugin dir onto the relative paths
listFilesRecursive returns instead of deleting cwd-relative ones.

Also make every user-facing uninstall string English, per the repo's
output-language rule.

Co-authored-by: Cursor <[email protected]>

---------

Co-authored-by: Cursor <[email protected]>
#326 translated the uninstall command's user-facing output to English, but
two e2e assertions still expected the old Chinese strings, so CI on main
went red:

  e2e.test.ts               '卸载完成'                    -> 'teamai uninstalled'
  scope-isolation-e2e.test.ts '正在卸载 project scope(项目级)' -> 'Uninstalling project scope'

The English output is the intended behavior (CLI output must be English);
only the stale assertions needed updating.

These never failed on #326's own runs because its PR-level e2e job was
queued behind the e2e-fixture-repo concurrency lock and got dropped on
merge, and its post-merge run on main was cancelled by the next push.

Co-authored-by: Cursor <[email protected]>
@pull pull Bot locked and limited conversation to collaborators Aug 26, 2026
@pull pull Bot added the ⤵️ pull label Aug 26, 2026
@pull
pull Bot merged commit 7723fab into Walternater:main Aug 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant