@arizeai/phoenix-cli 1.8.1 → 1.9.1
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 +88 -7
- package/build/authFetch.d.ts +24 -0
- package/build/authFetch.d.ts.map +1 -0
- package/build/authFetch.js +44 -0
- package/build/authFetch.js.map +1 -0
- package/build/cli.d.ts.map +1 -1
- package/build/cli.js +2 -1
- package/build/cli.js.map +1 -1
- package/build/client.d.ts +5 -1
- package/build/client.d.ts.map +1 -1
- package/build/client.js +6 -1
- package/build/client.js.map +1 -1
- package/build/commands/annotationConfig.d.ts.map +1 -1
- package/build/commands/annotationConfig.js.map +1 -1
- package/build/commands/{annotationMutationUtils.d.ts → annotationMutations.d.ts} +1 -1
- package/build/commands/annotationMutations.d.ts.map +1 -0
- package/build/commands/{annotationMutationUtils.js → annotationMutations.js} +1 -1
- package/build/commands/annotationMutations.js.map +1 -0
- package/build/commands/api.d.ts.map +1 -1
- package/build/commands/api.js +12 -1
- package/build/commands/api.js.map +1 -1
- package/build/commands/auth.d.ts +5 -2
- package/build/commands/auth.d.ts.map +1 -1
- package/build/commands/auth.js +332 -25
- package/build/commands/auth.js.map +1 -1
- package/build/commands/dataset.d.ts.map +1 -1
- package/build/commands/dataset.js.map +1 -1
- package/build/commands/docs.d.ts +51 -0
- package/build/commands/docs.d.ts.map +1 -1
- package/build/commands/docs.js +86 -37
- package/build/commands/docs.js.map +1 -1
- package/build/commands/experiment.d.ts.map +1 -1
- package/build/commands/experiment.js.map +1 -1
- package/build/commands/fetchSpanAnnotations.d.ts +14 -0
- package/build/commands/fetchSpanAnnotations.d.ts.map +1 -0
- package/build/commands/fetchSpanAnnotations.js +57 -0
- package/build/commands/fetchSpanAnnotations.js.map +1 -0
- package/build/commands/fetchTraceAnnotations.d.ts +14 -0
- package/build/commands/fetchTraceAnnotations.d.ts.map +1 -0
- package/build/commands/fetchTraceAnnotations.js +57 -0
- package/build/commands/fetchTraceAnnotations.js.map +1 -0
- package/build/commands/formatAnnotationMutation.d.ts +1 -1
- package/build/commands/formatAnnotationMutation.d.ts.map +1 -1
- package/build/commands/formatNoteMutation.d.ts +1 -1
- package/build/commands/formatNoteMutation.d.ts.map +1 -1
- package/build/commands/formatSetup.d.ts +56 -0
- package/build/commands/formatSetup.d.ts.map +1 -0
- package/build/commands/formatSetup.js +73 -0
- package/build/commands/formatSetup.js.map +1 -0
- package/build/commands/index.d.ts +4 -3
- package/build/commands/index.d.ts.map +1 -1
- package/build/commands/index.js +4 -3
- package/build/commands/index.js.map +1 -1
- package/build/commands/{noteMutationUtils.d.ts → noteMutations.d.ts} +1 -1
- package/build/commands/noteMutations.d.ts.map +1 -0
- package/build/commands/{noteMutationUtils.js → noteMutations.js} +1 -1
- package/build/commands/noteMutations.js.map +1 -0
- package/build/commands/options.d.ts +248 -0
- package/build/commands/options.d.ts.map +1 -0
- package/build/commands/options.js +16 -0
- package/build/commands/options.js.map +1 -0
- package/build/commands/profile.d.ts.map +1 -1
- package/build/commands/profile.js +3 -11
- package/build/commands/profile.js.map +1 -1
- package/build/commands/project.d.ts.map +1 -1
- package/build/commands/project.js +0 -1
- package/build/commands/project.js.map +1 -1
- package/build/commands/prompt.d.ts.map +1 -1
- package/build/commands/prompt.js.map +1 -1
- package/build/commands/self.d.ts.map +1 -1
- package/build/commands/self.js.map +1 -1
- package/build/commands/session.d.ts.map +1 -1
- package/build/commands/session.js +4 -4
- package/build/commands/session.js.map +1 -1
- package/build/commands/{sessionAnnotationsCommand.d.ts → sessionAnnotations.d.ts} +1 -1
- package/build/commands/sessionAnnotations.d.ts.map +1 -0
- package/build/commands/{sessionAnnotationsCommand.js → sessionAnnotations.js} +1 -1
- package/build/commands/sessionAnnotations.js.map +1 -0
- package/build/commands/setup.d.ts +19 -0
- package/build/commands/setup.d.ts.map +1 -0
- package/build/commands/setup.js +249 -0
- package/build/commands/setup.js.map +1 -0
- package/build/commands/span.d.ts.map +1 -1
- package/build/commands/span.js +5 -5
- package/build/commands/span.js.map +1 -1
- package/build/commands/spanAnnotations.d.ts +6 -13
- package/build/commands/spanAnnotations.d.ts.map +1 -1
- package/build/commands/spanAnnotations.js +154 -47
- package/build/commands/spanAnnotations.js.map +1 -1
- package/build/commands/trace.d.ts.map +1 -1
- package/build/commands/trace.js +6 -6
- package/build/commands/trace.js.map +1 -1
- package/build/commands/traceAnnotations.d.ts +6 -13
- package/build/commands/traceAnnotations.d.ts.map +1 -1
- package/build/commands/traceAnnotations.js +157 -47
- package/build/commands/traceAnnotations.js.map +1 -1
- package/build/config.d.ts +15 -0
- package/build/config.d.ts.map +1 -1
- package/build/config.js +54 -7
- package/build/config.js.map +1 -1
- package/build/curl.d.ts +17 -0
- package/build/curl.d.ts.map +1 -1
- package/build/curl.js.map +1 -1
- package/build/exitCodes.d.ts +6 -0
- package/build/exitCodes.d.ts.map +1 -1
- package/build/exitCodes.js +18 -0
- package/build/exitCodes.js.map +1 -1
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/oauth.d.ts +138 -0
- package/build/oauth.d.ts.map +1 -0
- package/build/oauth.js +465 -0
- package/build/oauth.js.map +1 -0
- package/build/oauthCallbackPage.d.ts +9 -0
- package/build/oauthCallbackPage.d.ts.map +1 -0
- package/build/oauthCallbackPage.js +111 -0
- package/build/oauthCallbackPage.js.map +1 -0
- package/build/optionParsers.d.ts +12 -0
- package/build/optionParsers.d.ts.map +1 -1
- package/build/optionParsers.js +15 -0
- package/build/optionParsers.js.map +1 -1
- package/build/pxi/App.d.ts.map +1 -1
- package/build/pxi/App.js +4 -0
- package/build/pxi/App.js.map +1 -1
- package/build/pxi/client.d.ts.map +1 -1
- package/build/pxi/client.js +11 -2
- package/build/pxi/client.js.map +1 -1
- package/build/pxi/options.d.ts +98 -0
- package/build/pxi/options.d.ts.map +1 -1
- package/build/pxi/options.js.map +1 -1
- package/build/settings.d.ts +19 -0
- package/build/settings.d.ts.map +1 -1
- package/build/settings.js +25 -0
- package/build/settings.js.map +1 -1
- package/build/setup/agents/registry.d.ts +135 -0
- package/build/setup/agents/registry.d.ts.map +1 -0
- package/build/setup/agents/registry.js +174 -0
- package/build/setup/agents/registry.js.map +1 -0
- package/build/setup/copy.d.ts +199 -0
- package/build/setup/copy.d.ts.map +1 -0
- package/build/setup/copy.js +334 -0
- package/build/setup/copy.js.map +1 -0
- package/build/setup/deps/buildDefaultDeps.d.ts +13 -0
- package/build/setup/deps/buildDefaultDeps.d.ts.map +1 -0
- package/build/setup/deps/buildDefaultDeps.js +31 -0
- package/build/setup/deps/buildDefaultDeps.js.map +1 -0
- package/build/setup/deps/clipboard.d.ts +12 -0
- package/build/setup/deps/clipboard.d.ts.map +1 -0
- package/build/setup/deps/clipboard.js +30 -0
- package/build/setup/deps/clipboard.js.map +1 -0
- package/build/setup/deps/clock.d.ts +10 -0
- package/build/setup/deps/clock.d.ts.map +1 -0
- package/build/setup/deps/clock.js +11 -0
- package/build/setup/deps/clock.js.map +1 -0
- package/build/setup/deps/context.d.ts +28 -0
- package/build/setup/deps/context.d.ts.map +1 -0
- package/build/setup/deps/context.js +24 -0
- package/build/setup/deps/context.js.map +1 -0
- package/build/setup/deps/docs.d.ts +41 -0
- package/build/setup/deps/docs.d.ts.map +1 -0
- package/build/setup/deps/docs.js +33 -0
- package/build/setup/deps/docs.js.map +1 -0
- package/build/setup/deps/index.d.ts +46 -0
- package/build/setup/deps/index.d.ts.map +1 -0
- package/build/setup/deps/index.js +16 -0
- package/build/setup/deps/index.js.map +1 -0
- package/build/setup/deps/oauthLogin.d.ts +64 -0
- package/build/setup/deps/oauthLogin.d.ts.map +1 -0
- package/build/setup/deps/oauthLogin.js +82 -0
- package/build/setup/deps/oauthLogin.js.map +1 -0
- package/build/setup/deps/phoenixClient.d.ts +22 -0
- package/build/setup/deps/phoenixClient.d.ts.map +1 -0
- package/build/setup/deps/phoenixClient.js +17 -0
- package/build/setup/deps/phoenixClient.js.map +1 -0
- package/build/setup/deps/processes.d.ts +28 -0
- package/build/setup/deps/processes.d.ts.map +1 -0
- package/build/setup/deps/processes.js +58 -0
- package/build/setup/deps/processes.js.map +1 -0
- package/build/setup/deps/prompter.d.ts +49 -0
- package/build/setup/deps/prompter.d.ts.map +1 -0
- package/build/setup/deps/prompter.js +10 -0
- package/build/setup/deps/prompter.js.map +1 -0
- package/build/setup/errors.d.ts +27 -0
- package/build/setup/errors.d.ts.map +1 -0
- package/build/setup/errors.js +36 -0
- package/build/setup/errors.js.map +1 -0
- package/build/setup/options.d.ts +124 -0
- package/build/setup/options.d.ts.map +1 -0
- package/build/setup/options.js +64 -0
- package/build/setup/options.js.map +1 -0
- package/build/setup/prompts/instrumentationPrompt.d.ts +48 -0
- package/build/setup/prompts/instrumentationPrompt.d.ts.map +1 -0
- package/build/setup/prompts/instrumentationPrompt.js +68 -0
- package/build/setup/prompts/instrumentationPrompt.js.map +1 -0
- package/build/setup/runSetup.d.ts +48 -0
- package/build/setup/runSetup.d.ts.map +1 -0
- package/build/setup/runSetup.js +213 -0
- package/build/setup/runSetup.js.map +1 -0
- package/build/setup/steps/chooseEndpoint.d.ts +36 -0
- package/build/setup/steps/chooseEndpoint.d.ts.map +1 -0
- package/build/setup/steps/chooseEndpoint.js +125 -0
- package/build/setup/steps/chooseEndpoint.js.map +1 -0
- package/build/setup/steps/confirmGitSafety.d.ts +17 -0
- package/build/setup/steps/confirmGitSafety.d.ts.map +1 -0
- package/build/setup/steps/confirmGitSafety.js +73 -0
- package/build/setup/steps/confirmGitSafety.js.map +1 -0
- package/build/setup/steps/establishConnection.d.ts +32 -0
- package/build/setup/steps/establishConnection.d.ts.map +1 -0
- package/build/setup/steps/establishConnection.js +252 -0
- package/build/setup/steps/establishConnection.js.map +1 -0
- package/build/setup/steps/installTooling.d.ts +28 -0
- package/build/setup/steps/installTooling.d.ts.map +1 -0
- package/build/setup/steps/installTooling.js +79 -0
- package/build/setup/steps/installTooling.js.map +1 -0
- package/build/setup/steps/instrumentApp.d.ts +60 -0
- package/build/setup/steps/instrumentApp.d.ts.map +1 -0
- package/build/setup/steps/instrumentApp.js +179 -0
- package/build/setup/steps/instrumentApp.js.map +1 -0
- package/build/setup/steps/offerDocsMcp.d.ts +48 -0
- package/build/setup/steps/offerDocsMcp.d.ts.map +1 -0
- package/build/setup/steps/offerDocsMcp.js +133 -0
- package/build/setup/steps/offerDocsMcp.js.map +1 -0
- package/build/setup/steps/offerPxProfile.d.ts +20 -0
- package/build/setup/steps/offerPxProfile.d.ts.map +1 -0
- package/build/setup/steps/offerPxProfile.js +95 -0
- package/build/setup/steps/offerPxProfile.js.map +1 -0
- package/build/setup/steps/prefetchDocs.d.ts +24 -0
- package/build/setup/steps/prefetchDocs.d.ts.map +1 -0
- package/build/setup/steps/prefetchDocs.js +49 -0
- package/build/setup/steps/prefetchDocs.js.map +1 -0
- package/build/setup/steps/verifyTraces.d.ts +44 -0
- package/build/setup/steps/verifyTraces.d.ts.map +1 -0
- package/build/setup/steps/verifyTraces.js +119 -0
- package/build/setup/steps/verifyTraces.js.map +1 -0
- package/build/setup/steps/writeEnvFile.d.ts +19 -0
- package/build/setup/steps/writeEnvFile.d.ts.map +1 -0
- package/build/setup/steps/writeEnvFile.js +50 -0
- package/build/setup/steps/writeEnvFile.js.map +1 -0
- package/build/setup/ui/clackPrompter.d.ts +11 -0
- package/build/setup/ui/clackPrompter.d.ts.map +1 -0
- package/build/setup/ui/clackPrompter.js +122 -0
- package/build/setup/ui/clackPrompter.js.map +1 -0
- package/build/setup/ui/selectBoolean.d.ts +18 -0
- package/build/setup/ui/selectBoolean.d.ts.map +1 -0
- package/build/setup/ui/selectBoolean.js +14 -0
- package/build/setup/ui/selectBoolean.js.map +1 -0
- package/build/setup/util/gitignoreCoverage.d.ts +24 -0
- package/build/setup/util/gitignoreCoverage.d.ts.map +1 -0
- package/build/setup/util/gitignoreCoverage.js +43 -0
- package/build/setup/util/gitignoreCoverage.js.map +1 -0
- package/build/setup/util/mcpConfig.d.ts +31 -0
- package/build/setup/util/mcpConfig.d.ts.map +1 -0
- package/build/setup/util/mcpConfig.js +62 -0
- package/build/setup/util/mcpConfig.js.map +1 -0
- package/build/setup/util/paths.d.ts +6 -0
- package/build/setup/util/paths.d.ts.map +1 -0
- package/build/setup/util/paths.js +23 -0
- package/build/setup/util/paths.js.map +1 -0
- package/build/setup/util/redact.d.ts +12 -0
- package/build/setup/util/redact.d.ts.map +1 -0
- package/build/setup/util/redact.js +31 -0
- package/build/setup/util/redact.js.map +1 -0
- package/build/validation/endpoint.d.ts +19 -0
- package/build/validation/endpoint.d.ts.map +1 -0
- package/build/validation/endpoint.js +39 -0
- package/build/validation/endpoint.js.map +1 -0
- package/package.json +15 -12
- package/build/commands/annotationMutationUtils.d.ts.map +0 -1
- package/build/commands/annotationMutationUtils.js.map +0 -1
- package/build/commands/noteMutationUtils.d.ts.map +0 -1
- package/build/commands/noteMutationUtils.js.map +0 -1
- package/build/commands/sessionAnnotationsCommand.d.ts.map +0 -1
- package/build/commands/sessionAnnotationsCommand.js.map +0 -1
- package/build/commands/spanAnnotationsCommand.d.ts +0 -7
- package/build/commands/spanAnnotationsCommand.d.ts.map +0 -1
- package/build/commands/spanAnnotationsCommand.js +0 -164
- package/build/commands/spanAnnotationsCommand.js.map +0 -1
- package/build/commands/traceAnnotationsCommand.d.ts +0 -7
- package/build/commands/traceAnnotationsCommand.d.ts.map +0 -1
- package/build/commands/traceAnnotationsCommand.js +0 -167
- package/build/commands/traceAnnotationsCommand.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installTooling.js","sourceRoot":"","sources":["../../../src/setup/steps/installTooling.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,gBAAgB,GAA6B;IACjD,OAAO,EAAE,KAAK;IACd,IAAI,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,sBAAs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AC9E,uEAAuE;IACvE,MAAM,GAAG,GACP,CAAC,SAAS,IAAI,CAAC,MAAM,QAAQ,CAAC;QAC5B,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,MAAM,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IAEnE,0EAA0E;IAC1E,6EAA6E;IAC7E,8EAA8E;IAC9E,8BAA8B;IAC9B,MAAM,aAAa,GAAG,MAAM,YAAY,CACtC,IAAI,EACJ,IAAI,CAAC,OAAO,CAAC,MAAM,EACnB,aAAa,CAAC,CAAC,SAAS,CAAC,EACzB,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,IAAI,CAAC,CACtC,CAAC;IACF,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Instrumentation hand-off.
|
|
3
|
+
*
|
|
4
|
+
* Lanes, in order of preference: launch a detected coding agent directly
|
|
5
|
+
* (prompt pre-loaded, credentials injected via env), copy the prompt for an
|
|
6
|
+
* agent the user runs themselves, or manual via the quickstart docs. All
|
|
7
|
+
* lanes converge on the trace-verification step — setup's definition of
|
|
8
|
+
* done is API-verified data flow, not agent self-report.
|
|
9
|
+
*
|
|
10
|
+
* The lane is resolved before anything docs-related happens: the docs MCP
|
|
11
|
+
* offer targets exactly the agent being launched, and taking it replaces the
|
|
12
|
+
* `.px/docs` download outright — the agent searches the docs server on demand
|
|
13
|
+
* instead of reading prefetched pages. The clipboard and manual lanes have no
|
|
14
|
+
* known agent to configure, so they keep the prefetch.
|
|
15
|
+
*
|
|
16
|
+
* `--agent` pre-answers the lane, which is what makes an unattended run
|
|
17
|
+
* possible: with no TTY there is no prompt to pick a lane from, and the agent
|
|
18
|
+
* runs in background mode (no TUI to hand the terminal to).
|
|
19
|
+
*/
|
|
20
|
+
import { type AgentRunMode, type CodingAgent, type CodingAgentId } from "../agents/registry.js";
|
|
21
|
+
import type { DocsPrefetchOptions, DocsPrefetchResult, SetupDeps } from "../deps/index.js";
|
|
22
|
+
import type { Connection } from "./establishConnection.js";
|
|
23
|
+
import { type DocsMcpResult } from "./offerDocsMcp.js";
|
|
24
|
+
export interface InstrumentAppArgs {
|
|
25
|
+
authEnabled: boolean;
|
|
26
|
+
/** Started at setup launch so the probes never block this prompt. */
|
|
27
|
+
agentDetection: Promise<CodingAgent[]>;
|
|
28
|
+
/** `--agent`: skip the lane prompt and launch this agent. */
|
|
29
|
+
agent?: CodingAgentId;
|
|
30
|
+
/** `--language`: passed through so the agent skips its own detection. */
|
|
31
|
+
languages: string[];
|
|
32
|
+
/** How to run the agent — see {@link AgentRunMode}. */
|
|
33
|
+
mode: AgentRunMode;
|
|
34
|
+
/** Docs prefetch options; the download runs unless the MCP replaces it. */
|
|
35
|
+
docs: DocsPrefetchOptions;
|
|
36
|
+
/** `--docs-mcp` / `--no-docs-mcp`; undefined means ask (when we can). */
|
|
37
|
+
docsMcp?: boolean;
|
|
38
|
+
headless: boolean;
|
|
39
|
+
/** Gates the prefetch's .gitignore append, as in the docs step itself. */
|
|
40
|
+
isGitRepository: boolean;
|
|
41
|
+
}
|
|
42
|
+
/** Which lane instrumentation actually took — reported in the summary. */
|
|
43
|
+
export type InstrumentationLane = {
|
|
44
|
+
kind: "agent";
|
|
45
|
+
agent: CodingAgentId;
|
|
46
|
+
exitCode: number;
|
|
47
|
+
} | {
|
|
48
|
+
kind: "clipboard";
|
|
49
|
+
} | {
|
|
50
|
+
kind: "manual";
|
|
51
|
+
};
|
|
52
|
+
export interface InstrumentAppResult {
|
|
53
|
+
lane: InstrumentationLane;
|
|
54
|
+
/** The docs download, when it ran (the MCP taking its place omits it). */
|
|
55
|
+
docs?: DocsPrefetchResult;
|
|
56
|
+
/** The docs MCP offer, when a launched agent was there to make it to. */
|
|
57
|
+
docsMcp?: DocsMcpResult;
|
|
58
|
+
}
|
|
59
|
+
export declare function instrumentApp(deps: Pick<SetupDeps, "context" | "processes" | "prompter" | "writeClipboard" | "fetchDocs">, connection: Connection, args: InstrumentAppArgs): Promise<InstrumentAppResult>;
|
|
60
|
+
//# sourceMappingURL=instrumentApp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentApp.d.ts","sourceRoot":"","sources":["../../../src/setup/steps/instrumentApp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,aAAa,EACnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAElB,SAAS,EACV,MAAM,SAAS,CAAC;AAGjB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AASlE,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,OAAO,CAAC;IACrB,qEAAqE;IACrE,cAAc,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;IACvC,6DAA6D;IAC7D,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,yEAAyE;IACzE,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,uDAAuD;IACvD,IAAI,EAAE,YAAY,CAAC;IACnB,2EAA2E;IAC3E,IAAI,EAAE,mBAAmB,CAAC;IAC1B,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,0EAA0E;IAC1E,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,0EAA0E;AAC1E,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,aAAa,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACzD;IAAE,IAAI,EAAE,WAAW,CAAA;CAAE,GACrB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEvB,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,mBAAmB,CAAC;IAC1B,0EAA0E;IAC1E,IAAI,CAAC,EAAE,kBAAkB,CAAC;IAC1B,yEAAyE;IACzE,OAAO,CAAC,EAAE,aAAa,CAAC;CACzB;AAED,wBAAsB,aAAa,CACjC,IAAI,EAAE,IAAI,CACR,SAAS,EACT,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,gBAAgB,GAAG,WAAW,CACtE,EACD,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,mBAAmB,CAAC,CAuI9B"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Instrumentation hand-off.
|
|
3
|
+
*
|
|
4
|
+
* Lanes, in order of preference: launch a detected coding agent directly
|
|
5
|
+
* (prompt pre-loaded, credentials injected via env), copy the prompt for an
|
|
6
|
+
* agent the user runs themselves, or manual via the quickstart docs. All
|
|
7
|
+
* lanes converge on the trace-verification step — setup's definition of
|
|
8
|
+
* done is API-verified data flow, not agent self-report.
|
|
9
|
+
*
|
|
10
|
+
* The lane is resolved before anything docs-related happens: the docs MCP
|
|
11
|
+
* offer targets exactly the agent being launched, and taking it replaces the
|
|
12
|
+
* `.px/docs` download outright — the agent searches the docs server on demand
|
|
13
|
+
* instead of reading prefetched pages. The clipboard and manual lanes have no
|
|
14
|
+
* known agent to configure, so they keep the prefetch.
|
|
15
|
+
*
|
|
16
|
+
* `--agent` pre-answers the lane, which is what makes an unattended run
|
|
17
|
+
* possible: with no TTY there is no prompt to pick a lane from, and the agent
|
|
18
|
+
* runs in background mode (no TUI to hand the terminal to).
|
|
19
|
+
*/
|
|
20
|
+
import { buildLaunchSpec, getCodingAgent, probeBinary, } from "../agents/registry.js";
|
|
21
|
+
import * as COPY from "../copy.js";
|
|
22
|
+
import { SetupFatalError } from "../errors.js";
|
|
23
|
+
import { buildInstrumentationPrompt } from "../prompts/instrumentationPrompt.js";
|
|
24
|
+
import { offerDocsMcp } from "./offerDocsMcp.js";
|
|
25
|
+
import { prefetchDocs } from "./prefetchDocs.js";
|
|
26
|
+
import { tracesUrl } from "./verifyTraces.js";
|
|
27
|
+
const DEFAULT_LOCAL_ENDPOINT = "http://localhost:6006";
|
|
28
|
+
export async function instrumentApp(deps, connection, args) {
|
|
29
|
+
const { authEnabled, agentDetection, languages, mode } = args;
|
|
30
|
+
// Resolve the lane before the docs steps: the MCP offer needs to know which
|
|
31
|
+
// agent is doing the work, and only then can "skip the download" be decided.
|
|
32
|
+
let chosenAgent;
|
|
33
|
+
let fallbackLane = "manual";
|
|
34
|
+
if (args.agent) {
|
|
35
|
+
// `--agent` short-circuits the lane prompt. The binary is probed rather
|
|
36
|
+
// than taken from the detection sweep so a named-but-missing agent fails
|
|
37
|
+
// with "not on your PATH" instead of silently dropping to another lane.
|
|
38
|
+
const agent = getCodingAgent(args.agent);
|
|
39
|
+
if (!agent) {
|
|
40
|
+
throw new SetupFatalError(COPY.INSTRUMENTATION.unknownAgent(args.agent));
|
|
41
|
+
}
|
|
42
|
+
if (!(await probeBinary(deps, agent.binary))) {
|
|
43
|
+
throw new SetupFatalError(COPY.INSTRUMENTATION.agentNotFound(agent.label, agent.binary));
|
|
44
|
+
}
|
|
45
|
+
chosenAgent = agent;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const detectedAgents = await agentDetection;
|
|
49
|
+
const options = [
|
|
50
|
+
...detectedAgents.map((agent) => ({
|
|
51
|
+
value: `agent:${agent.id}`,
|
|
52
|
+
label: COPY.INSTRUMENTATION.launchLabel(agent.label),
|
|
53
|
+
hint: COPY.INSTRUMENTATION.launchHint,
|
|
54
|
+
})),
|
|
55
|
+
{
|
|
56
|
+
value: "clipboard",
|
|
57
|
+
label: COPY.INSTRUMENTATION.clipboardLabel,
|
|
58
|
+
hint: COPY.INSTRUMENTATION.clipboardHint,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
value: "manual",
|
|
62
|
+
label: COPY.INSTRUMENTATION.manualLabel,
|
|
63
|
+
hint: COPY.INSTRUMENTATION.manualHint,
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
const choice = await deps.prompter.select({
|
|
67
|
+
message: COPY.INSTRUMENTATION.modeMessage,
|
|
68
|
+
options,
|
|
69
|
+
});
|
|
70
|
+
chosenAgent = detectedAgents.find((agent) => choice === `agent:${agent.id}`);
|
|
71
|
+
fallbackLane = choice === "clipboard" ? "clipboard" : "manual";
|
|
72
|
+
}
|
|
73
|
+
// The offer is an optimization and never takes setup down with it — that
|
|
74
|
+
// contract lives inside offerDocsMcp, which reports any failure and returns
|
|
75
|
+
// "failed" instead of throwing. Only a user cancel unwinds.
|
|
76
|
+
let docsMcp;
|
|
77
|
+
if (chosenAgent) {
|
|
78
|
+
docsMcp = await offerDocsMcp(deps, {
|
|
79
|
+
docsMcp: args.docsMcp,
|
|
80
|
+
agent: chosenAgent,
|
|
81
|
+
headless: args.headless,
|
|
82
|
+
docsEnabled: args.docs.enabled,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
else if (args.docsMcp === true) {
|
|
86
|
+
// An explicit --docs-mcp deserves a word when the lane can't honor it,
|
|
87
|
+
// same as a pinned agent with no MCP install path.
|
|
88
|
+
deps.prompter.line(COPY.DOCS_MCP.noAgentLane);
|
|
89
|
+
}
|
|
90
|
+
const docs = docsMcp?.outcome === "configured"
|
|
91
|
+
? undefined
|
|
92
|
+
: await prefetchDocs(deps, {
|
|
93
|
+
docs: args.docs,
|
|
94
|
+
isGitRepository: args.isGitRepository,
|
|
95
|
+
});
|
|
96
|
+
const prompt = buildInstrumentationPrompt({
|
|
97
|
+
projectName: connection.projectName,
|
|
98
|
+
endpoint: connection.endpoint,
|
|
99
|
+
isDefaultEndpoint: connection.endpoint === DEFAULT_LOCAL_ENDPOINT,
|
|
100
|
+
docs: {
|
|
101
|
+
quickstartPython: COPY.DOCS.quickstartPython,
|
|
102
|
+
quickstartTypeScript: COPY.DOCS.quickstartTypeScript,
|
|
103
|
+
phoenixOtelSetup: COPY.DOCS.phoenixOtelSetup,
|
|
104
|
+
integrationsIndex: COPY.DOCS.integrationsIndex,
|
|
105
|
+
},
|
|
106
|
+
tracesUrl: tracesUrl(connection),
|
|
107
|
+
authEnabled,
|
|
108
|
+
languages,
|
|
109
|
+
// Only advertise the local docs dir when it holds pages — an empty one
|
|
110
|
+
// (docs site down, over-narrow workflow filter) would send the agent to
|
|
111
|
+
// read a directory with nothing in it instead of the web.
|
|
112
|
+
...(docs?.hasPagesOnDisk ? { localDocsDir: docs.outputDir } : {}),
|
|
113
|
+
...(docsMcp?.outcome === "configured" ? { docsMcpConfigured: true } : {}),
|
|
114
|
+
});
|
|
115
|
+
if (chosenAgent) {
|
|
116
|
+
const lane = await launchAgent(deps, connection, {
|
|
117
|
+
agent: chosenAgent,
|
|
118
|
+
prompt,
|
|
119
|
+
mode,
|
|
120
|
+
});
|
|
121
|
+
return {
|
|
122
|
+
lane,
|
|
123
|
+
...(docs ? { docs } : {}),
|
|
124
|
+
...(docsMcp ? { docsMcp } : {}),
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
if (fallbackLane === "clipboard") {
|
|
128
|
+
const copied = await deps.writeClipboard(prompt);
|
|
129
|
+
if (copied) {
|
|
130
|
+
deps.prompter.line(COPY.INSTRUMENTATION.promptCopied);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
deps.prompter.line(COPY.INSTRUMENTATION.promptCopyFailed);
|
|
134
|
+
deps.prompter.note(prompt);
|
|
135
|
+
}
|
|
136
|
+
await deps.prompter.select({
|
|
137
|
+
message: COPY.INSTRUMENTATION.clipboardDoneMessage,
|
|
138
|
+
options: [
|
|
139
|
+
{ value: true, label: COPY.INSTRUMENTATION.clipboardDoneLabel },
|
|
140
|
+
],
|
|
141
|
+
});
|
|
142
|
+
return { lane: { kind: "clipboard" }, ...(docs ? { docs } : {}) };
|
|
143
|
+
}
|
|
144
|
+
deps.prompter.line(COPY.INSTRUMENTATION.manualDocs(COPY.DOCS.instrumentationIndex));
|
|
145
|
+
await deps.prompter.select({
|
|
146
|
+
message: COPY.INSTRUMENTATION.manualDoneMessage,
|
|
147
|
+
options: [{ value: true, label: COPY.INSTRUMENTATION.manualDoneLabel }],
|
|
148
|
+
});
|
|
149
|
+
return { lane: { kind: "manual" }, ...(docs ? { docs } : {}) };
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Run the agent with the prompt pre-loaded. A non-zero exit is a warning, not
|
|
153
|
+
* a failure: the agent may have instrumented the app and then exited badly,
|
|
154
|
+
* and trace verification — not the agent's exit code — decides whether setup
|
|
155
|
+
* succeeded.
|
|
156
|
+
*/
|
|
157
|
+
async function launchAgent(deps, connection, { agent, prompt, mode, }) {
|
|
158
|
+
// Without its TUI *and* without permission bypass, an agent stalls on the
|
|
159
|
+
// first approval it wants, with no terminal to approve it on — the run then
|
|
160
|
+
// dies at the verification timeout with nothing to show. Say so up front.
|
|
161
|
+
if (mode.background && !mode.bypassPermissions) {
|
|
162
|
+
deps.prompter.line(COPY.INSTRUMENTATION.backgroundNeedsYolo(agent.label));
|
|
163
|
+
}
|
|
164
|
+
deps.prompter.line(mode.background
|
|
165
|
+
? COPY.INSTRUMENTATION.launchingBackground(agent.label)
|
|
166
|
+
: COPY.INSTRUMENTATION.launching(agent.label));
|
|
167
|
+
const spec = buildLaunchSpec(agent, {
|
|
168
|
+
prompt,
|
|
169
|
+
cwd: deps.context.cwd,
|
|
170
|
+
connection,
|
|
171
|
+
mode,
|
|
172
|
+
});
|
|
173
|
+
const { exitCode } = await deps.processes.spawnInteractive(spec);
|
|
174
|
+
if (exitCode !== 0) {
|
|
175
|
+
deps.prompter.line(COPY.INSTRUMENTATION.agentExitWarning(agent.label));
|
|
176
|
+
}
|
|
177
|
+
return { kind: "agent", agent: agent.id, exitCode };
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=instrumentApp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instrumentApp.js","sourceRoot":"","sources":["../../../src/setup/steps/instrumentApp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EACL,eAAe,EACf,cAAc,EACd,WAAW,GAIZ,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAOhC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AAE9E,OAAO,EAAE,YAAY,EAAsB,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,MAAM,sBAAsB,GAAG,uBAAuB,CAAC;AAsCvD,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,IAGC,EACD,UAAsB,EACtB,IAAuB;IAEvB,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IAE9D,4EAA4E;IAC5E,6EAA6E;IAC7E,IAAI,WAAoC,CAAC;IACzC,IAAI,YAAY,GAA2B,QAAQ,CAAC;IAEpD,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,wEAAwE;QACxE,yEAAyE;QACzE,wEAAwE;QACxE,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,IAAI,eAAe,CAAC,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3E,CAAC;QACD,IAAI,CAAC,CAAC,MAAM,WAAW,C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,CAAC,eAAe,CAAC,mBAAmB,CAAC,KAAK,CAAC,KAAK,CAAC;QACvD,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAChD,CAAC;IAEF,MAAM,IAAI,GAAG,eAAe,CAAC,KAAK,EAAE;QAClC,MAAM;QACN,GAAG,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG;QACrB,UAAU;QACV,IAAI;KACL,CAAC,CAAC;IACH,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACjE,IAAI,QAAQ,KAAK,CAAC,EAAE,CAAC;QACnB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Offer to connect the Phoenix docs MCP server to the coding agent taking the
|
|
3
|
+
* hand-off, instead of downloading the docs.
|
|
4
|
+
*
|
|
5
|
+
* Taking the offer is the fast path: one small config step replaces the
|
|
6
|
+
* ~100-page `.px/docs` download, and the agent then searches the docs server
|
|
7
|
+
* on demand — pulling only the sections it needs instead of reading whole
|
|
8
|
+
* pages. Declining (or any failure) degrades to the docs prefetch, which is
|
|
9
|
+
* what setup did before this step existed.
|
|
10
|
+
*
|
|
11
|
+
* The offer is an optimization and must never take setup down with it:
|
|
12
|
+
* whatever goes wrong (an agent CLI whose flags drifted, a config format we
|
|
13
|
+
* no longer understand), this step reports it, returns a "failed" result, and
|
|
14
|
+
* the caller carries on with the docs download. The only throw that leaves
|
|
15
|
+
* this function is a user cancel.
|
|
16
|
+
*
|
|
17
|
+
* The offer targets exactly one agent — the lane the user chose (or `--agent`
|
|
18
|
+
* pinned) — so setup never sprays MCP config for agents that aren't doing the
|
|
19
|
+
* work. How the entry lands is the agent's own affair ({@link DocsMcpInstall}):
|
|
20
|
+
* agents with an MCP subcommand register it through their own CLI, the rest
|
|
21
|
+
* get a merge into their documented config file. Headless runs never touch
|
|
22
|
+
* agent config unless `--docs-mcp` asked for it.
|
|
23
|
+
*/
|
|
24
|
+
import { type CodingAgent } from "../agents/registry.js";
|
|
25
|
+
import type { SetupDeps } from "../deps/index.js";
|
|
26
|
+
export type DocsMcpOutcome = "configured" | "declined" | "skipped" | "failed";
|
|
27
|
+
/** What the offer did — reported in the setup summary. */
|
|
28
|
+
export interface DocsMcpResult {
|
|
29
|
+
outcome: DocsMcpOutcome;
|
|
30
|
+
/** Agents whose config now names the server. */
|
|
31
|
+
agents: CodingAgent["id"][];
|
|
32
|
+
/** Repo-relative config files written (empty for a CLI-side install). */
|
|
33
|
+
files: string[];
|
|
34
|
+
}
|
|
35
|
+
export interface OfferDocsMcpArgs {
|
|
36
|
+
/** `--docs-mcp` / `--no-docs-mcp`; undefined means ask (when we can). */
|
|
37
|
+
docsMcp?: boolean;
|
|
38
|
+
/** The agent taking the hand-off — the only one the offer configures. */
|
|
39
|
+
agent: CodingAgent;
|
|
40
|
+
headless: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the docs prefetch would actually run on decline/failure — with
|
|
43
|
+
* `--no-docs` it won't, and the offer must not promise a download.
|
|
44
|
+
*/
|
|
45
|
+
docsEnabled: boolean;
|
|
46
|
+
}
|
|
47
|
+
export declare function offerDocsMcp(deps: Pick<SetupDeps, "context" | "prompter" | "processes">, args: OfferDocsMcpArgs): Promise<DocsMcpResult>;
|
|
48
|
+
//# sourceMappingURL=offerDocsMcp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offerDocsMcp.d.ts","sourceRoot":"","sources":["../../../src/setup/steps/offerDocsMcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAE3E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAKzC,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,UAAU,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE9E,0DAA0D;AAC1D,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,cAAc,CAAC;IACxB,gDAAgD;IAChD,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;IAC5B,yEAAyE;IACzE,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAOD,MAAM,WAAW,gBAAgB;IAC/B,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,yEAAyE;IACzE,KAAK,EAAE,WAAW,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,wBAAsB,YAAY,CAChC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,GAAG,UAAU,GAAG,WAAW,CAAC,EAC3D,IAAI,EAAE,gBAAgB,GACrB,OAAO,CAAC,aAAa,CAAC,CAaxB"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Offer to connect the Phoenix docs MCP server to the coding agent taking the
|
|
3
|
+
* hand-off, instead of downloading the docs.
|
|
4
|
+
*
|
|
5
|
+
* Taking the offer is the fast path: one small config step replaces the
|
|
6
|
+
* ~100-page `.px/docs` download, and the agent then searches the docs server
|
|
7
|
+
* on demand — pulling only the sections it needs instead of reading whole
|
|
8
|
+
* pages. Declining (or any failure) degrades to the docs prefetch, which is
|
|
9
|
+
* what setup did before this step existed.
|
|
10
|
+
*
|
|
11
|
+
* The offer is an optimization and must never take setup down with it:
|
|
12
|
+
* whatever goes wrong (an agent CLI whose flags drifted, a config format we
|
|
13
|
+
* no longer understand), this step reports it, returns a "failed" result, and
|
|
14
|
+
* the caller carries on with the docs download. The only throw that leaves
|
|
15
|
+
* this function is a user cancel.
|
|
16
|
+
*
|
|
17
|
+
* The offer targets exactly one agent — the lane the user chose (or `--agent`
|
|
18
|
+
* pinned) — so setup never sprays MCP config for agents that aren't doing the
|
|
19
|
+
* work. How the entry lands is the agent's own affair ({@link DocsMcpInstall}):
|
|
20
|
+
* agents with an MCP subcommand register it through their own CLI, the rest
|
|
21
|
+
* get a merge into their documented config file. Headless runs never touch
|
|
22
|
+
* agent config unless `--docs-mcp` asked for it.
|
|
23
|
+
*/
|
|
24
|
+
import { DOCS_MCP_SERVER_URL } from "../agents/registry.js";
|
|
25
|
+
import * as COPY from "../copy.js";
|
|
26
|
+
import { SetupCancelledError } from "../errors.js";
|
|
27
|
+
import { selectBoolean } from "../ui/selectBoolean.js";
|
|
28
|
+
import { writeMcpConfig } from "../util/mcpConfig.js";
|
|
29
|
+
const SKIPPED = { outcome: "skipped", agents: [], files: [] };
|
|
30
|
+
/** Registering a server is one config write; a slow CLI start is still fine. */
|
|
31
|
+
const CLI_INSTALL_TIMEOUT_MS = 30_000;
|
|
32
|
+
export async function offerDocsMcp(deps, args) {
|
|
33
|
+
try {
|
|
34
|
+
return await runOffer(deps, args);
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (error instanceof SetupCancelledError) {
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
return reportFailure(deps, args, error instanceof Error ? error.message : String(error));
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** The single failure path: say what broke, say what happens instead. */
|
|
44
|
+
function reportFailure(deps, { agent, docsEnabled }, reason) {
|
|
45
|
+
deps.prompter.line(COPY.DOCS_MCP.failedFor(agent.label, reason));
|
|
46
|
+
deps.prompter.line(docsEnabled ? COPY.DOCS_MCP.fallback : COPY.DOCS_MCP.fallbackWithoutDownload);
|
|
47
|
+
return { outcome: "failed", agents: [], files: [] };
|
|
48
|
+
}
|
|
49
|
+
async function runOffer(deps, args) {
|
|
50
|
+
const { docsMcp, agent, headless, docsEnabled } = args;
|
|
51
|
+
if (docsMcp === false) {
|
|
52
|
+
return SKIPPED;
|
|
53
|
+
}
|
|
54
|
+
const install = agent.docsMcpInstall;
|
|
55
|
+
if (!install) {
|
|
56
|
+
// Only worth a line when the caller asked by flag — a pinned agent with
|
|
57
|
+
// no MCP install path (Codex) would otherwise silently ignore it.
|
|
58
|
+
if (docsMcp === true) {
|
|
59
|
+
deps.prompter.line(COPY.DOCS_MCP.unsupported(agent.label));
|
|
60
|
+
}
|
|
61
|
+
return SKIPPED;
|
|
62
|
+
}
|
|
63
|
+
// An unattended run never edits agent config unless --docs-mcp said so.
|
|
64
|
+
if (docsMcp === undefined && headless) {
|
|
65
|
+
return SKIPPED;
|
|
66
|
+
}
|
|
67
|
+
const optedIn = docsMcp ??
|
|
68
|
+
(await selectBoolean({
|
|
69
|
+
prompter: deps.prompter,
|
|
70
|
+
message: COPY.DOCS_MCP.message(agent.label),
|
|
71
|
+
yesLabel: COPY.DOCS_MCP.yes,
|
|
72
|
+
yesHint: COPY.DOCS_MCP.yesHint,
|
|
73
|
+
noLabel: docsEnabled ? COPY.DOCS_MCP.no : COPY.DOCS_MCP.noWithoutDownload,
|
|
74
|
+
noHint: docsEnabled
|
|
75
|
+
? COPY.DOCS_MCP.noHint
|
|
76
|
+
: COPY.DOCS_MCP.noWithoutDownloadHint,
|
|
77
|
+
}));
|
|
78
|
+
if (!optedIn) {
|
|
79
|
+
return { outcome: "declined", agents: [], files: [] };
|
|
80
|
+
}
|
|
81
|
+
if (install.kind === "cli") {
|
|
82
|
+
const exec = (execArgs) => deps.processes.exec({
|
|
83
|
+
command: agent.binary,
|
|
84
|
+
args: execArgs,
|
|
85
|
+
cwd: deps.context.cwd,
|
|
86
|
+
timeoutMs: CLI_INSTALL_TIMEOUT_MS,
|
|
87
|
+
});
|
|
88
|
+
// `add` first: the clean path is one registration plus the read-back.
|
|
89
|
+
// Only when `add` is refused AND the agent's own listing shows an entry
|
|
90
|
+
// under our name is that entry removed and the add retried — removing
|
|
91
|
+
// before knowing the add works would destroy a working registration
|
|
92
|
+
// that a failed retry can't put back.
|
|
93
|
+
let added = await exec(install.addArgs(DOCS_MCP_SERVER_URL));
|
|
94
|
+
if (added.exitCode !== 0) {
|
|
95
|
+
const existing = await exec(install.verifyArgs);
|
|
96
|
+
if (existing.exitCode !== 0) {
|
|
97
|
+
return reportFailure(deps, args, added.stderr.trim() || `exit code ${added.exitCode}`);
|
|
98
|
+
}
|
|
99
|
+
await exec(install.removeArgs);
|
|
100
|
+
added = await exec(install.addArgs(DOCS_MCP_SERVER_URL));
|
|
101
|
+
if (added.exitCode !== 0) {
|
|
102
|
+
return reportFailure(deps, args, added.stderr.trim() || `exit code ${added.exitCode}`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
// Don't trust the add's exit code alone: read the entry back through the
|
|
106
|
+
// agent's own listing, so a drifted command that "succeeds" without
|
|
107
|
+
// registering anything is caught here instead of silently costing the
|
|
108
|
+
// agent its docs.
|
|
109
|
+
const verified = await exec(install.verifyArgs);
|
|
110
|
+
if (verified.exitCode !== 0) {
|
|
111
|
+
return reportFailure(deps, args, COPY.DOCS_MCP.verifyFailed);
|
|
112
|
+
}
|
|
113
|
+
deps.prompter.line(COPY.DOCS_MCP.configuredCli(agent.label));
|
|
114
|
+
return { outcome: "configured", agents: [agent.id], files: [] };
|
|
115
|
+
}
|
|
116
|
+
// A write that throws (unparseable existing file, permissions) is handled
|
|
117
|
+
// by the catch-all in offerDocsMcp.
|
|
118
|
+
writeMcpConfig({
|
|
119
|
+
directory: deps.context.cwd,
|
|
120
|
+
relativePath: install.relativePath,
|
|
121
|
+
patch: install.patch(DOCS_MCP_SERVER_URL),
|
|
122
|
+
...(install.createDefaults
|
|
123
|
+
? { createDefaults: install.createDefaults }
|
|
124
|
+
: {}),
|
|
125
|
+
});
|
|
126
|
+
deps.prompter.line(COPY.DOCS_MCP.configured([install.relativePath]));
|
|
127
|
+
return {
|
|
128
|
+
outcome: "configured",
|
|
129
|
+
agents: [agent.id],
|
|
130
|
+
files: [install.relativePath],
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=offerDocsMcp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offerDocsMcp.js","sourceRoot":"","sources":["../../../src/setup/steps/offerDocsMcp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,mBAAmB,EAAoB,MAAM,oBAAoB,CAAC;AAC3E,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAanD,MAAM,OAAO,GAAkB,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;AAE7E,gFAAgF;AAChF,MAAM,sBAAsB,GAAG,MAAM,CAAC;AAetC,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,IAA2D,EAC3D,IAAsB;IAEtB,IAAI,CAAC;QACH,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,mBAAmB,EAAE,CAAC;YACzC,MAAM,KAAK,CAAC;QACd,CAAC;QACD,OAAO,aAAa,CAClB,IAAI,EACJ,IAAI,EACJ,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACvD,CAAC;IACJ,CAAC;AACH,CAAC;A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mBAAmB,CAAC;QACzC,GAAG,CAAC,OAAO,CAAC,cAAc;YACxB,CAAC,CAAC,EAAE,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE;YAC5C,CAAC,CAAC,EAAE,CAAC;KACR,CAAC,CAAC;IACH,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IACrE,OAAO;QACL,OAAO,EAAE,YAAY;QACrB,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;QAClB,KAAK,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC;KAC9B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Offer to point `px` at the project setup just connected.
|
|
3
|
+
*
|
|
4
|
+
* Because setup *is* px, everything here is in-process — the profile
|
|
5
|
+
* (including the API key, when auth is on) is written through px's own
|
|
6
|
+
* settings module (`~/.px/settings.json`, dir 0700, file 0600). No argv or
|
|
7
|
+
* subprocess ever carries the secret. Any failure is a non-fatal warning;
|
|
8
|
+
* setup proceeds regardless.
|
|
9
|
+
*/
|
|
10
|
+
import type { SetupDeps } from "../deps/index.js";
|
|
11
|
+
import type { Connection } from "./establishConnection.js";
|
|
12
|
+
/** `local` for localhost, else the host with dots and colons → dashes. */
|
|
13
|
+
export declare function profileNameForEndpoint(endpoint: string): string;
|
|
14
|
+
export interface PxProfileArgs {
|
|
15
|
+
connection: Connection;
|
|
16
|
+
/** Override the settings file path (tests). */
|
|
17
|
+
settingsPath?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function offerPxProfile(deps: Pick<SetupDeps, "prompter">, { connection, settingsPath }: PxProfileArgs): Promise<void>;
|
|
20
|
+
//# sourceMappingURL=offerPxProfile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offerPxProfile.d.ts","sourceRoot":"","sources":["../../../src/setup/steps/offerPxProfile.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAYH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,0EAA0E;AAC1E,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAO/D;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,UAAU,CAAC;IACvB,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAsB,cAAc,CAClC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,EACjC,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,aAAa,GAC1C,OAAO,CAAC,IAAI,CAAC,CAoFf"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Offer to point `px` at the project setup just connected.
|
|
3
|
+
*
|
|
4
|
+
* Because setup *is* px, everything here is in-process — the profile
|
|
5
|
+
* (including the API key, when auth is on) is written through px's own
|
|
6
|
+
* settings module (`~/.px/settings.json`, dir 0700, file 0600). No argv or
|
|
7
|
+
* subprocess ever carries the secret. Any failure is a non-fatal warning;
|
|
8
|
+
* setup proceeds regardless.
|
|
9
|
+
*/
|
|
10
|
+
import { getSettingsPath, getStoredActiveProfile, loadSettings, saveSettings, SettingsFileError, } from "../../settings.js";
|
|
11
|
+
import * as COPY from "../copy.js";
|
|
12
|
+
import { SetupCancelledError } from "../errors.js";
|
|
13
|
+
import { redactForDisplay } from "../util/redact.js";
|
|
14
|
+
/** `local` for localhost, else the host with dots and colons → dashes. */
|
|
15
|
+
export function profileNameForEndpoint(endpoint) {
|
|
16
|
+
// URL.hostname keeps the brackets on IPv6 literals (e.g. "[::1]").
|
|
17
|
+
const host = new URL(endpoint).hostname;
|
|
18
|
+
if (host === "localhost" || host === "127.0.0.1" || host === "[::1]") {
|
|
19
|
+
return "local";
|
|
20
|
+
}
|
|
21
|
+
return host.replace(/^\[|\]$/g, "").replace(/[.:]/g, "-");
|
|
22
|
+
}
|
|
23
|
+
export async function offerPxProfile(deps, { connection, settingsPath }) {
|
|
24
|
+
// Strict, and on its own: a settings file whose contents don't parse must not
|
|
25
|
+
// degrade to the empty profiles record a lenient load returns, which the save
|
|
26
|
+
// below would then write over whatever the user had. A file that is simply
|
|
27
|
+
// absent is not an error — the load returns fresh settings for it.
|
|
28
|
+
let settings;
|
|
29
|
+
try {
|
|
30
|
+
settings = loadSettings({ settingsPath, strict: true });
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
// Only a file we can't parse gets sent here. `px profile create`, the
|
|
34
|
+
// remedy the generic failure suggests, loads the same file the same strict
|
|
35
|
+
// way — so for this one failure it is no remedy at all, and the file itself
|
|
36
|
+
// is what has to be dealt with.
|
|
37
|
+
if (error instanceof SettingsFileError) {
|
|
38
|
+
deps.prompter.line(COPY.PX_PROFILE.unreadableSettings(settingsPath ?? getSettingsPath(), redactForDisplay(error.message)));
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
deps.prompter.line(COPY.PX_PROFILE.failed(redactForDisplay(String(error))));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
const active = getStoredActiveProfile(settings);
|
|
46
|
+
// A fully-configured active profile pointing elsewhere is a conflict —
|
|
47
|
+
// ask before switching, never clobber silently. A partially configured
|
|
48
|
+
// profile (missing endpoint or project) is non-conflicting.
|
|
49
|
+
const conflicting = active !== undefined &&
|
|
50
|
+
Boolean(active.entry.endpoint) &&
|
|
51
|
+
Boolean(active.entry.project) &&
|
|
52
|
+
(active.entry.endpoint !== connection.endpoint ||
|
|
53
|
+
active.entry.project !== connection.projectName);
|
|
54
|
+
const optedIn = await deps.prompter.select(conflicting && active
|
|
55
|
+
? {
|
|
56
|
+
message: COPY.PX_PROFILE.conflictMessage(active.name, active.entry.endpoint ?? ""),
|
|
57
|
+
options: [
|
|
58
|
+
{ value: false, label: COPY.PX_PROFILE.conflictNo },
|
|
59
|
+
{ value: true, label: COPY.PX_PROFILE.conflictYes },
|
|
60
|
+
],
|
|
61
|
+
}
|
|
62
|
+
: {
|
|
63
|
+
message: COPY.PX_PROFILE.optInMessage,
|
|
64
|
+
options: [
|
|
65
|
+
{ value: true, label: COPY.PX_PROFILE.optInYes },
|
|
66
|
+
{ value: false, label: COPY.PX_PROFILE.optInNo },
|
|
67
|
+
],
|
|
68
|
+
});
|
|
69
|
+
if (!optedIn) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const profileName = profileNameForEndpoint(connection.endpoint);
|
|
73
|
+
const entry = {
|
|
74
|
+
endpoint: connection.endpoint,
|
|
75
|
+
project: connection.projectName,
|
|
76
|
+
};
|
|
77
|
+
if (connection.apiKey) {
|
|
78
|
+
entry.apiKey = connection.apiKey;
|
|
79
|
+
}
|
|
80
|
+
settings.profiles[profileName] = {
|
|
81
|
+
...settings.profiles[profileName],
|
|
82
|
+
...entry,
|
|
83
|
+
};
|
|
84
|
+
settings.activeProfile = profileName;
|
|
85
|
+
saveSettings(settings, { settingsPath });
|
|
86
|
+
deps.prompter.line(COPY.PX_PROFILE.created(profileName));
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
if (error instanceof SetupCancelledError) {
|
|
90
|
+
throw error;
|
|
91
|
+
}
|
|
92
|
+
deps.prompter.line(COPY.PX_PROFILE.failed(redactForDisplay(String(error))));
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=offerPxProfile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offerPxProfile.js","sourceRoot":"","sources":["../../../src/setup/steps/offerPxProfile.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,YAAY,EACZ,YAAY,EACZ,iBAAiB,GAG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;QACF,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,OAAO;QACT,CAAC;QAED,MAAM,WAAW,GAAG,sBAAsB,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAChE,MAAM,KAAK,GAAiB;YAC1B,QAAQ,EAAE,UAAU,CAAC,QAAQ;YAC7B,OAAO,EAAE,UAAU,CAAC,WAAW;SAChC,CAAC;QACF,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;YACtB,KAAK,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;QACnC,CAAC;QACD,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG;YAC/B,GAAG,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC;YACjC,GAAG,KAAK;SACT,CAAC;QACF,QAAQ,CAAC,aAAa,GAAG,WAAW,CAAC;QACrC,YAAY,CAAC,QAAQ,EAAE,EAAE,YAAY,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IAC3D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,mBAAmB,EAAE,CAAC;YACzC,MAAM,KAAK,CAAC;QACd,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9E,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prefetch the Phoenix docs into the repo, so the instrumentation agent reads
|
|
3
|
+
* package names and APIs from disk instead of fetching URLs mid-run.
|
|
4
|
+
*
|
|
5
|
+
* Runs only when instrumentation runs — the docs exist to serve the agent, so
|
|
6
|
+
* a registration-only run has no reason to write them. Never fatal: a docs
|
|
7
|
+
* site that is slow or down degrades to the agent fetching pages itself, which
|
|
8
|
+
* is what it did before this step existed.
|
|
9
|
+
*
|
|
10
|
+
* Must run after the git-safety gate: the download writes untracked files
|
|
11
|
+
* under `.px/`, which a fast headless run could otherwise mistake for
|
|
12
|
+
* pre-existing user changes.
|
|
13
|
+
*/
|
|
14
|
+
import { type DocsPrefetchOptions, type DocsPrefetchResult, type SetupDeps } from "../deps/index.js";
|
|
15
|
+
/**
|
|
16
|
+
* Download the docs and gitignore what they wrote. A failure is reported and
|
|
17
|
+
* dropped: the connection and hand-off files are real work worth keeping, and
|
|
18
|
+
* the agent can still read the docs from the web.
|
|
19
|
+
*/
|
|
20
|
+
export declare function prefetchDocs(deps: Pick<SetupDeps, "fetchDocs" | "prompter" | "context">, { docs, isGitRepository, }: {
|
|
21
|
+
docs: DocsPrefetchOptions;
|
|
22
|
+
isGitRepository: boolean;
|
|
23
|
+
}): Promise<DocsPrefetchResult | undefined>;
|
|
24
|
+
//# sourceMappingURL=prefetchDocs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefetchDocs.d.ts","sourceRoot":"","sources":["../../../src/setup/steps/prefetchDocs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACf,MAAM,SAAS,CAAC;AAMjB;;;;GAIG;AACH,wBAAsB,YAAY,CAChC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC,EAC3D,EACE,IAAI,EACJ,eAAe,GAChB,EAAE;IAAE,IAAI,EAAE,mBAAmB,CAAC;IAAC,eAAe,EAAE,OAAO,CAAA;CAAE,GACzD,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CA6BzC"}
|