feat(init): bridge to APM during init for cross-team distribution#94
Conversation
139fd2d to
fa4e3c7
Compare
There was a problem hiding this comment.
Pull request overview
Adds an APM “bridge” to agentrc init so that, after scaffolding instructions/configs, the command can detect APM and optionally run apm init --yes to enable cross-team distribution via apm install.
Changes:
- Detects whether
apmis available and whetherapm.ymlalready exists. - In interactive mode, prompts to initialize APM and shells out to
apm init --yes. - When APM isn’t installed, prints an informational tip (subject to logging flags).
fa4e3c7 to
6aff6e2
Compare
6aff6e2 to
22bdb5f
Compare
3dc9b87 to
8492e8a
Compare
8492e8a to
c01c6d4
Compare
|
Part of epic #96 |
|
Design question for @digitarald: Should Currently Option A (current): Option B: I lean toward B but wanted your call since it means auto-running an external CLI in non-interactive mode. |
After generating instructions and configs, agentrc init now detects APM and offers to initialize it: - APM installed + no apm.yml: interactive prompt to run `apm init --yes` - APM installed + apm.yml exists: skip (already set up) - APM not installed: light tip suggesting APM with link to repo - --yes/--json mode: skip APM step entirely (non-interactive) This respects tool boundaries — agentrc never writes apm.yml directly, it delegates to `apm init` which handles auto-detection of project metadata. The prompt follows the same @inquirer/prompts pattern already used throughout the init command. Closes microsoft#93 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
c01c6d4 to
6414a53
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/commands/init.ts:327
- In the
apm-not-installed branch, the tip is gated byshouldLog(options)but not byoptions.yes. Per the documented behavior,--yes/headless should skip quietly, soofferApmInit()should avoid emitting this tip whenoptions.yesis true.
} else if (shouldLog(options)) {
process.stderr.write(
"\nTip: use APM to install shared agent packages and distribute your instructions across repos.\n" +
" https://github.com/microsoft/apm\n"
);
| if (apmAvailable) { | ||
| const accepted = options.yes | ||
| ? true | ||
| : await confirm({ | ||
| message: "Set up APM to install and share agent packages across your team?", | ||
| default: false | ||
| }); | ||
| if (accepted) { |
There was a problem hiding this comment.
offerApmInit() currently treats --yes as implicit acceptance (accepted = options.yes ? true : …), which causes agentrc init --yes to run apm init --yes. This conflicts with the documented behavior for --yes/headless mode (skip APM entirely) and introduces unexpected side effects in non-interactive runs. Consider returning early when options.yes is set so APM is neither prompted nor executed in headless mode.
This issue also appears on line 323 of the same file.
| it("auto-initializes APM when --yes is set and apm is installed", async () => { | ||
| mockApmInstalled(); | ||
| await offerApmInit(repoPath, { yes: true }); | ||
| expect(mockConfirm).not.toHaveBeenCalled(); | ||
| expect(mockExecFile).toHaveBeenCalledTimes(2); // --version + init --yes | ||
| }); |
There was a problem hiding this comment.
This test encodes behavior that contradicts the PR description: it expects --yes to auto-initialize APM when installed. The documented behavior says --yes/headless mode should skip APM entirely, so the expectation (and likely the implementation) should be updated accordingly.
Summary
After generating instructions and configs,
agentrc initnow detects APM and bridges to it — enabling cross-team distribution of agent packages viaapm install.Closes #93
Part of #96
Behavior
--yes(headless)apminstalled + noapm.ymlapm init --yesapm init --yes(yes to everything)apminstalled +apm.ymlexistsapmnot installed--json--yesincludes APM when installed — consistent with its "accept all defaults" semantic (same asnpm init --yes). If APM is not installed,--yessilently skips.Design
apm.yml— shells out toapm init --yes@inquirer/promptsconfirm(), same as existing init promptsWarning:prefix--jsonskips entirely,--quietsuppresses tipChanges
src/commands/init.ts— APM detection, conditional prompt/auto-init, tip message (+62 lines)src/services/__tests__/apm-init.test.ts— 7 unit tests covering all paths (new file)