@agilemonster/mcp-server 1.0.15 → 1.0.21

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.
@@ -0,0 +1,151 @@
1
+ import type { ProjectMemory } from './deploy-memory.js';
2
+ /**
3
+ * Evidence-based deployment profile resolution.
4
+ *
5
+ * The old detector returned the first deploy-looking file it found (any compose file won), and the
6
+ * server kept that first guess forever. This module instead gathers every piece of evidence a project
7
+ * offers — how the running containers were actually started, which CI workflows really fire on a push
8
+ * to the current branch, deploy scripts, cloud CLI configs, the project's own docs, and what worked
9
+ * last time — ranks the candidates, and says how confident it is and why.
10
+ *
11
+ * Precedence: explicit project file > user-set binding > last verified success > ranked evidence.
12
+ */
13
+ export type DeployMethod = 'github_actions' | 'docker_compose' | 'deploy_script' | 'cloud_cli' | 'git_push' | 'manual' | 'none';
14
+ export type ProfileSource = 'explicit' | 'user' | 'learned' | 'verified' | 'detected';
15
+ export type Confidence = 'high' | 'medium' | 'low';
16
+ export interface PushTrigger {
17
+ branches: string[] | null;
18
+ branchesIgnore: string[] | null;
19
+ paths: string[] | null;
20
+ pathsIgnore: string[] | null;
21
+ tagsOnly: boolean;
22
+ }
23
+ export interface WorkflowInfo {
24
+ file: string;
25
+ name: string;
26
+ isDeploy: boolean;
27
+ events: string[];
28
+ push: PushTrigger | null;
29
+ dispatch: boolean;
30
+ workflowRun: {
31
+ workflows: string[];
32
+ branches: string[] | null;
33
+ } | null;
34
+ }
35
+ export interface ComposeFileInfo {
36
+ rel: string;
37
+ kind: 'default' | 'dev' | 'prod' | 'other';
38
+ hasBuild: boolean;
39
+ }
40
+ export interface ComposeStack {
41
+ projectName: string;
42
+ workingDir: string;
43
+ configFiles: string[];
44
+ services: string[];
45
+ runningCount: number;
46
+ }
47
+ export interface ComposeTarget {
48
+ projectName: string | null;
49
+ /** Compose files relative to the project root (or absolute when outside it). */
50
+ files: string[];
51
+ running: boolean;
52
+ }
53
+ export interface DeployCandidate {
54
+ method: DeployMethod;
55
+ command: string | null;
56
+ score: number;
57
+ evidence: string[];
58
+ compose?: ComposeTarget;
59
+ /** Deploy workflows that this candidate relies on. */
60
+ workflows?: WorkflowInfo[];
61
+ /** The deploy workflow only starts when dispatched (pushing alone does not deploy). */
62
+ dispatchOnly?: boolean;
63
+ }
64
+ export interface BoundProfile {
65
+ deploy_method?: string | null;
66
+ deploy_command?: string | null;
67
+ live_url?: string | null;
68
+ build_command?: string | null;
69
+ /** 'user' = set by a human, 'verified' = confirmed by a successful deploy, 'auto' = a guess. */
70
+ deploy_source?: string | null;
71
+ }
72
+ export interface GitInfo {
73
+ isRepo: boolean;
74
+ branch: string | null;
75
+ hasRemote: boolean;
76
+ remoteUrl: string | null;
77
+ }
78
+ export interface DeployProfile {
79
+ method: DeployMethod;
80
+ command: string | null;
81
+ source: ProfileSource;
82
+ confidence: Confidence;
83
+ evidence: string[];
84
+ liveUrl: string | null;
85
+ /** 'guessed' URLs are informational: an unreachable guess must never fail a deployment. */
86
+ liveUrlSource: 'explicit' | 'user' | 'learned' | 'guessed' | null;
87
+ buildCommand: string | null;
88
+ compose?: ComposeTarget;
89
+ workflows: WorkflowInfo[];
90
+ dispatchOnly: boolean;
91
+ /**
92
+ * The route was only inferred and would run something with production reach that nobody has confirmed
93
+ * (a deploy script, a cloud CLI, a manually-dispatched workflow). Ask once, then remember.
94
+ */
95
+ needsConfirmation: boolean;
96
+ alternatives: DeployCandidate[];
97
+ git: GitInfo;
98
+ deploymentNotes: string;
99
+ }
100
+ export interface ProfileProbes {
101
+ /** Output of the docker ps probe (see COMPOSE_PS_FORMAT), or null when docker is unavailable. */
102
+ dockerPs?: () => string | null;
103
+ git?: (projectPath: string) => GitInfo;
104
+ }
105
+ export interface ResolveOptions {
106
+ bound?: BoundProfile | null;
107
+ memory?: ProjectMemory | null;
108
+ probes?: ProfileProbes;
109
+ }
110
+ export declare function normalizeMethod(raw: string | null | undefined): DeployMethod | null;
111
+ /**
112
+ * Older versions stored descriptions such as "git push origin HEAD (GitHub Actions CI/CD)" in the command
113
+ * field. Those are not commands. (Real commands may contain parentheses, e.g. `TAG=$(git rev-parse HEAD)`.)
114
+ */
115
+ export declare function isRunnableCommand(cmd: string | null | undefined): boolean;
116
+ export declare function globToRegExp(glob: string): RegExp;
117
+ export declare function parseWorkflow(file: string, text: string): WorkflowInfo;
118
+ export declare function readWorkflows(projectPath: string): WorkflowInfo[];
119
+ /** Does a push to `branch` start this workflow, directly or through a `workflow_run` chain? */
120
+ export declare function workflowRunsOnPush(wf: WorkflowInfo, branch: string, all: WorkflowInfo[], depth?: number): boolean;
121
+ /** With `paths:` filters, a commit that touches none of them does not start the workflow. */
122
+ export declare function pushPathsMatch(push: PushTrigger | null, files: string[]): boolean;
123
+ export declare const COMPOSE_PS_FORMAT = "{{.Label \"com.docker.compose.project\"}}\t{{.Label \"com.docker.compose.project.working_dir\"}}\t{{.Label \"com.docker.compose.project.config_files\"}}\t{{.Label \"com.docker.compose.service\"}}\t{{.State}}";
124
+ export declare function findComposeFiles(projectPath: string): ComposeFileInfo[];
125
+ /** Parse the docker ps probe and keep the compose projects that were started from inside `projectPath`. */
126
+ export declare function parseComposeStacks(psOutput: string, projectPath: string): ComposeStack[];
127
+ export declare function composeCommand(target: ComposeTarget, tail?: string): string;
128
+ /** Arguments for `docker compose …` matching a target (no shell quoting needed). */
129
+ export declare function composeArgs(target: ComposeTarget): string[];
130
+ /** Pull the lines of the project docs that talk about deployment (compact, for the code model and for humans). */
131
+ export declare function extractDeploymentNotes(projectPath: string, maxChars?: number): string;
132
+ export declare function detectBuildCommand(projectPath: string): string | null;
133
+ /** "app.example.co.za" -> "example": the label a project name can be compared with. */
134
+ export declare function registrableLabel(host: string): string;
135
+ /**
136
+ * Best-effort production URL. Returns a URL only when something ties it to this project
137
+ * (an APP_URL-style env value, a doc URL whose host resembles the project/repo name, or a
138
+ * folder literally named like a domain) — never just "the first link in the README".
139
+ */
140
+ export declare function inferLiveUrl(projectPath: string, name: string, remoteUrl?: string | null): string | null;
141
+ export declare function gatherCandidates(projectPath: string, git: GitInfo, workflows: WorkflowInfo[], dockerPs: string | null): DeployCandidate[];
142
+ export declare function resolveDeployProfile(projectPath: string, options?: ResolveOptions): DeployProfile;
143
+ /**
144
+ * Pushing to the checked-out branch (and whatever pipeline the repo attached to that) and refreshing local
145
+ * containers are routine. Running a deploy script, a cloud CLI, or manually dispatching a workflow reaches
146
+ * production in ways the repository did not automate — so an unconfirmed guess must be confirmed once.
147
+ */
148
+ export declare function requiresConfirmation(candidate: Pick<DeployCandidate, 'method' | 'dispatchOnly'>): boolean;
149
+ export declare function methodLabel(method: DeployMethod): string;
150
+ /** Compact, human-readable description used in card comments, the code model's context, and MCP tool output. */
151
+ export declare function describeProfile(profile: DeployProfile): string;