Skip to content

fix(pi): launch hooks through the installed Node entry - #1365

Merged
SaulMoro merged 1 commit into
Tencent:mainfrom
nateEc:fix/1221-pi-installed-launcher
Oct 25, 2026
Merged

SaulMoro merged 1 commit into
Tencent:mainfrom
nateEc:fix/1221-pi-installed-launcher

Conversation

@nateEc

@nateEc nateEc commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

A Pi session launched without teamai on PATH silently lost lifecycle dispatch and project instructions. Generate the extension with the installed Node executable and CLI entry, and launch both lifecycle events and the instructions request directly without a shell. Existing marker ownership, stdin payloads, timeouts and fail-open behavior remain.

Refs #1221 (the Pi PATH finding). This PR addresses only that finding, not the full descriptor roadmap.

Validation on main f3cd0425 plus this change:

  • Regression sensitivity: the same built-CLI test on pristine main returns undefined instead of the project context; it passes with the fix.
  • npx vitest run src/__tests__/pi-hooks.test.ts src/__tests__/recall-attribution.test.ts: 191 passed. The unit-only extension host strips Node's entry argument before its existing dispatcher assertions.
  • npm run build, npx tsc --noEmit, npm run lint: passed.
  • After build, npx vitest run --config vitest.e2e.config.ts src/__tests__/e2e/pi-installed-launcher.test.ts: 1 passed. The real CLI writes the extension; a fixture Pi host loads that generated extension with PATH restricted to /usr/bin:/bin, receives project culture through the real CLI, and joins detached fixture processes before cleanup.
  • Pi itself and a Windows host were not run; the generated source uses argv with shell: false. Reinject/pull and restart Pi after relocating Node or TeamAI, as documented in both language guides.

- 在生成的 Pi 扩展中记录绝对 Node 与 TeamAI 入口,生命周期事件和项目上下文均直接启动该入口,避免依赖服务 PATH 或 Windows 命令包装器。
- 保留超时、标准输入、会话身份与失败放行行为,更新中英文重装后的刷新说明。
- 受限 PATH 的真实扩展回归在原始主干返回空上下文,修复后成功注入项目内容;191 项相关单测、CLI E2E、构建、类型检查和 lint 通过。
@github-actions

Copy link
Copy Markdown

No findings in the specified PR diff.

The PR description satisfies the testing requirement: it records a post-build real-CLI run that generates the Pi extension and verifies project instructions with restricted PATH. The disclosed lack of actual Pi and Windows-host testing is not blocking.

Review was read-only; I did not run, build, or install PR code.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was generated by AI during triage.

@nateEc Approving at c8cae2c. With teamai off PATH (PATH /usr/bin:/bin), the extension generated by a build of main (f3cd042) returns nothing from before_agent_start and starts no process. The one from this head returns the team context and dispatches session-start, prompt-submit and instructions. A local Pi 0.99.2 in print mode shows the same before it stops for lack of a model key: no dispatches on main, and session-start plus instructions here. Build, tsc, lint and the PR's unit and e2e files pass, and the new e2e test and the shell: false assertion fail on main. The launcher reuses resolveCliEntry() like OpenClaw and OpenCode, and adds no new home resolver.

  • [P2 non-blocking] The Pi readiness check in channelReadiness (src/instruction-targets.ts:202) compares the whole generated file, which now embeds process.execPath and the CLI entry. doctor run from a copy of the same build at another path reports ✖ pi adds the team instructions and rules to its prompt and exits 1, and hooks inject from that copy flips the original install's doctor to ✖. Dispatch still works. OpenCode's plugin has had the same comparison since #1336, so one fix in the readiness check (compare without the two path constants) would cover both.
  • [P3 nit] No caller passes the entry parameter of buildPiExtensionSource.
  • [P3 nit] Unlike the OpenCode and OpenClaw injectors, injectPiHooks does not warn and return when resolveCliEntry() is null. The shipped layout always has dist/index.js, so this is not reachable today.

#1367 (the Hermes half) appends to the end of both diagnostics.md files too, so whichever lands second needs a rebase.

The CI review reports no findings. We agree that nothing blocks, and add the readiness note above, which it did not consider. All CI jobs pass; the GitHub-provider job is skipped by the fork policy.

@SaulMoro
SaulMoro merged commit a982cec into Tencent:main Oct 25, 2026
18 checks passed

@jeff-r2026 jeff-r2026 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and verified on latest main (f3cd042) stacked with the other PRs in this batch: tsc / lint / build pass, related unit and E2E tests pass.

@nateEc

nateEc commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

The cross-install readiness note is addressed in #1409: only generated launcher metadata is normalized; saved paths must still exist and handler bodies/manifests remain checked. The two new readiness regressions fail before the fix; 328 focused tests and a built-CLI cross-entry doctor scenario pass. This keeps the completed launcher fix here separate from the doctor follow-up.

Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
- 在生成的 Pi 扩展中记录绝对 Node 与 TeamAI 入口,生命周期事件和项目上下文均直接启动该入口,避免依赖服务 PATH 或 Windows 命令包装器。
- 保留超时、标准输入、会话身份与失败放行行为,更新中英文重装后的刷新说明。
- 受限 PATH 的真实扩展回归在原始主干返回空上下文,修复后成功注入项目内容;191 项相关单测、CLI E2E、构建、类型检查和 lint 通过。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants