@made-by-moonlight/athene-cli 0.9.2
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/LICENSE +22 -0
- package/dist/assets/plugin-registry.json +67 -0
- package/dist/assets/scripts/athene-doctor.ps1 +352 -0
- package/dist/assets/scripts/athene-doctor.sh +552 -0
- package/dist/assets/scripts/athene-update.ps1 +224 -0
- package/dist/assets/scripts/athene-update.sh +252 -0
- package/dist/commands/completion.d.ts +3 -0
- package/dist/commands/completion.d.ts.map +1 -0
- package/dist/commands/completion.js +26 -0
- package/dist/commands/completion.js.map +1 -0
- package/dist/commands/config.d.ts +11 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +89 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/dashboard.d.ts +3 -0
- package/dist/commands/dashboard.d.ts.map +1 -0
- package/dist/commands/dashboard.js +103 -0
- package/dist/commands/dashboard.js.map +1 -0
- package/dist/commands/doctor.d.ts +3 -0
- package/dist/commands/doctor.d.ts.map +1 -0
- package/dist/commands/doctor.js +329 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/events.d.ts +3 -0
- package/dist/commands/events.d.ts.map +1 -0
- package/dist/commands/events.js +172 -0
- package/dist/commands/events.js.map +1 -0
- package/dist/commands/migrate-storage.d.ts +3 -0
- package/dist/commands/migrate-storage.d.ts.map +1 -0
- package/dist/commands/migrate-storage.js +78 -0
- package/dist/commands/migrate-storage.js.map +1 -0
- package/dist/commands/notify.d.ts +3 -0
- package/dist/commands/notify.d.ts.map +1 -0
- package/dist/commands/notify.js +143 -0
- package/dist/commands/notify.js.map +1 -0
- package/dist/commands/open.d.ts +3 -0
- package/dist/commands/open.d.ts.map +1 -0
- package/dist/commands/open.js +167 -0
- package/dist/commands/open.js.map +1 -0
- package/dist/commands/plugin.d.ts +3 -0
- package/dist/commands/plugin.d.ts.map +1 -0
- package/dist/commands/plugin.js +462 -0
- package/dist/commands/plugin.js.map +1 -0
- package/dist/commands/project.d.ts +3 -0
- package/dist/commands/project.d.ts.map +1 -0
- package/dist/commands/project.js +143 -0
- package/dist/commands/project.js.map +1 -0
- package/dist/commands/report.d.ts +19 -0
- package/dist/commands/report.d.ts.map +1 -0
- package/dist/commands/report.js +114 -0
- package/dist/commands/report.js.map +1 -0
- package/dist/commands/review-check.d.ts +3 -0
- package/dist/commands/review-check.d.ts.map +1 -0
- package/dist/commands/review-check.js +122 -0
- package/dist/commands/review-check.js.map +1 -0
- package/dist/commands/review.d.ts +3 -0
- package/dist/commands/review.d.ts.map +1 -0
- package/dist/commands/review.js +215 -0
- package/dist/commands/review.js.map +1 -0
- package/dist/commands/send.d.ts +3 -0
- package/dist/commands/send.d.ts.map +1 -0
- package/dist/commands/send.js +187 -0
- package/dist/commands/send.js.map +1 -0
- package/dist/commands/session.d.ts +3 -0
- package/dist/commands/session.d.ts.map +1 -0
- package/dist/commands/session.js +439 -0
- package/dist/commands/session.js.map +1 -0
- package/dist/commands/setup.d.ts +5 -0
- package/dist/commands/setup.d.ts.map +1 -0
- package/dist/commands/setup.js +297 -0
- package/dist/commands/setup.js.map +1 -0
- package/dist/commands/spawn.d.ts +4 -0
- package/dist/commands/spawn.d.ts.map +1 -0
- package/dist/commands/spawn.js +436 -0
- package/dist/commands/spawn.js.map +1 -0
- package/dist/commands/start.d.ts +21 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +1836 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/status.d.ts +3 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +556 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/update.d.ts +15 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +652 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/verify.d.ts +3 -0
- package/dist/commands/verify.d.ts.map +1 -0
- package/dist/commands/verify.js +131 -0
- package/dist/commands/verify.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/bun-tmp-janitor.d.ts +18 -0
- package/dist/lib/bun-tmp-janitor.d.ts.map +1 -0
- package/dist/lib/bun-tmp-janitor.js +127 -0
- package/dist/lib/bun-tmp-janitor.js.map +1 -0
- package/dist/lib/caller-context.d.ts +13 -0
- package/dist/lib/caller-context.d.ts.map +1 -0
- package/dist/lib/caller-context.js +20 -0
- package/dist/lib/caller-context.js.map +1 -0
- package/dist/lib/cli-errors.d.ts +8 -0
- package/dist/lib/cli-errors.d.ts.map +1 -0
- package/dist/lib/cli-errors.js +20 -0
- package/dist/lib/cli-errors.js.map +1 -0
- package/dist/lib/completion.d.ts +13 -0
- package/dist/lib/completion.d.ts.map +1 -0
- package/dist/lib/completion.js +428 -0
- package/dist/lib/completion.js.map +1 -0
- package/dist/lib/composio-setup.d.ts +65 -0
- package/dist/lib/composio-setup.d.ts.map +1 -0
- package/dist/lib/composio-setup.js +3255 -0
- package/dist/lib/composio-setup.js.map +1 -0
- package/dist/lib/config-instruction.d.ts +2 -0
- package/dist/lib/config-instruction.d.ts.map +1 -0
- package/dist/lib/config-instruction.js +193 -0
- package/dist/lib/config-instruction.js.map +1 -0
- package/dist/lib/constants.d.ts +3 -0
- package/dist/lib/constants.d.ts.map +1 -0
- package/dist/lib/constants.js +3 -0
- package/dist/lib/constants.js.map +1 -0
- package/dist/lib/create-session-manager.d.ts +26 -0
- package/dist/lib/create-session-manager.d.ts.map +1 -0
- package/dist/lib/create-session-manager.js +55 -0
- package/dist/lib/create-session-manager.js.map +1 -0
- package/dist/lib/credential-resolver.d.ts +37 -0
- package/dist/lib/credential-resolver.d.ts.map +1 -0
- package/dist/lib/credential-resolver.js +105 -0
- package/dist/lib/credential-resolver.js.map +1 -0
- package/dist/lib/daemon.d.ts +69 -0
- package/dist/lib/daemon.d.ts.map +1 -0
- package/dist/lib/daemon.js +77 -0
- package/dist/lib/daemon.js.map +1 -0
- package/dist/lib/dashboard-rebuild.d.ts +53 -0
- package/dist/lib/dashboard-rebuild.d.ts.map +1 -0
- package/dist/lib/dashboard-rebuild.js +188 -0
- package/dist/lib/dashboard-rebuild.js.map +1 -0
- package/dist/lib/dashboard-setup.d.ts +14 -0
- package/dist/lib/dashboard-setup.d.ts.map +1 -0
- package/dist/lib/dashboard-setup.js +192 -0
- package/dist/lib/dashboard-setup.js.map +1 -0
- package/dist/lib/dashboard-url.d.ts +19 -0
- package/dist/lib/dashboard-url.d.ts.map +1 -0
- package/dist/lib/dashboard-url.js +25 -0
- package/dist/lib/dashboard-url.js.map +1 -0
- package/dist/lib/desktop-setup.d.ts +21 -0
- package/dist/lib/desktop-setup.d.ts.map +1 -0
- package/dist/lib/desktop-setup.js +556 -0
- package/dist/lib/desktop-setup.js.map +1 -0
- package/dist/lib/detect-agent.d.ts +24 -0
- package/dist/lib/detect-agent.d.ts.map +1 -0
- package/dist/lib/detect-agent.js +69 -0
- package/dist/lib/detect-agent.js.map +1 -0
- package/dist/lib/detect-env.d.ts +14 -0
- package/dist/lib/detect-env.d.ts.map +1 -0
- package/dist/lib/detect-env.js +46 -0
- package/dist/lib/detect-env.js.map +1 -0
- package/dist/lib/discord-setup.d.ts +20 -0
- package/dist/lib/discord-setup.d.ts.map +1 -0
- package/dist/lib/discord-setup.js +584 -0
- package/dist/lib/discord-setup.js.map +1 -0
- package/dist/lib/format.d.ts +11 -0
- package/dist/lib/format.d.ts.map +1 -0
- package/dist/lib/format.js +116 -0
- package/dist/lib/format.js.map +1 -0
- package/dist/lib/git-utils.d.ts +14 -0
- package/dist/lib/git-utils.d.ts.map +1 -0
- package/dist/lib/git-utils.js +45 -0
- package/dist/lib/git-utils.js.map +1 -0
- package/dist/lib/install-helpers.d.ts +24 -0
- package/dist/lib/install-helpers.d.ts.map +1 -0
- package/dist/lib/install-helpers.js +76 -0
- package/dist/lib/install-helpers.js.map +1 -0
- package/dist/lib/lifecycle-service.d.ts +11 -0
- package/dist/lib/lifecycle-service.d.ts.map +1 -0
- package/dist/lib/lifecycle-service.js +65 -0
- package/dist/lib/lifecycle-service.js.map +1 -0
- package/dist/lib/notifier-routing.d.ts +35 -0
- package/dist/lib/notifier-routing.d.ts.map +1 -0
- package/dist/lib/notifier-routing.js +133 -0
- package/dist/lib/notifier-routing.js.map +1 -0
- package/dist/lib/notify-test.d.ts +72 -0
- package/dist/lib/notify-test.d.ts.map +1 -0
- package/dist/lib/notify-test.js +674 -0
- package/dist/lib/notify-test.js.map +1 -0
- package/dist/lib/openclaw-probe.d.ts +38 -0
- package/dist/lib/openclaw-probe.d.ts.map +1 -0
- package/dist/lib/openclaw-probe.js +146 -0
- package/dist/lib/openclaw-probe.js.map +1 -0
- package/dist/lib/openclaw-setup.d.ts +19 -0
- package/dist/lib/openclaw-setup.d.ts.map +1 -0
- package/dist/lib/openclaw-setup.js +684 -0
- package/dist/lib/openclaw-setup.js.map +1 -0
- package/dist/lib/path-equality.d.ts +29 -0
- package/dist/lib/path-equality.d.ts.map +1 -0
- package/dist/lib/path-equality.js +52 -0
- package/dist/lib/path-equality.js.map +1 -0
- package/dist/lib/plugin-marketplace.d.ts +24 -0
- package/dist/lib/plugin-marketplace.d.ts.map +1 -0
- package/dist/lib/plugin-marketplace.js +175 -0
- package/dist/lib/plugin-marketplace.js.map +1 -0
- package/dist/lib/plugin-scaffold.d.ts +14 -0
- package/dist/lib/plugin-scaffold.d.ts.map +1 -0
- package/dist/lib/plugin-scaffold.js +174 -0
- package/dist/lib/plugin-scaffold.js.map +1 -0
- package/dist/lib/plugin-store.d.ts +9 -0
- package/dist/lib/plugin-store.d.ts.map +1 -0
- package/dist/lib/plugin-store.js +121 -0
- package/dist/lib/plugin-store.js.map +1 -0
- package/dist/lib/plugins.d.ts +17 -0
- package/dist/lib/plugins.d.ts.map +1 -0
- package/dist/lib/plugins.js +65 -0
- package/dist/lib/plugins.js.map +1 -0
- package/dist/lib/portfolio-display.d.ts +10 -0
- package/dist/lib/portfolio-display.d.ts.map +1 -0
- package/dist/lib/portfolio-display.js +17 -0
- package/dist/lib/portfolio-display.js.map +1 -0
- package/dist/lib/preflight.d.ts +27 -0
- package/dist/lib/preflight.d.ts.map +1 -0
- package/dist/lib/preflight.js +77 -0
- package/dist/lib/preflight.js.map +1 -0
- package/dist/lib/prevent-sleep.d.ts +34 -0
- package/dist/lib/prevent-sleep.d.ts.map +1 -0
- package/dist/lib/prevent-sleep.js +65 -0
- package/dist/lib/prevent-sleep.js.map +1 -0
- package/dist/lib/project-detection.d.ts +11 -0
- package/dist/lib/project-detection.d.ts.map +1 -0
- package/dist/lib/project-detection.js +206 -0
- package/dist/lib/project-detection.js.map +1 -0
- package/dist/lib/project-resolution.d.ts +10 -0
- package/dist/lib/project-resolution.d.ts.map +1 -0
- package/dist/lib/project-resolution.js +17 -0
- package/dist/lib/project-resolution.js.map +1 -0
- package/dist/lib/project-supervisor.d.ts +28 -0
- package/dist/lib/project-supervisor.d.ts.map +1 -0
- package/dist/lib/project-supervisor.js +167 -0
- package/dist/lib/project-supervisor.js.map +1 -0
- package/dist/lib/prompts.d.ts +7 -0
- package/dist/lib/prompts.d.ts.map +1 -0
- package/dist/lib/prompts.js +37 -0
- package/dist/lib/prompts.js.map +1 -0
- package/dist/lib/repo-utils.d.ts +16 -0
- package/dist/lib/repo-utils.d.ts.map +1 -0
- package/dist/lib/repo-utils.js +26 -0
- package/dist/lib/repo-utils.js.map +1 -0
- package/dist/lib/resolve-project.d.ts +113 -0
- package/dist/lib/resolve-project.d.ts.map +1 -0
- package/dist/lib/resolve-project.js +433 -0
- package/dist/lib/resolve-project.js.map +1 -0
- package/dist/lib/routes.d.ts +2 -0
- package/dist/lib/routes.d.ts.map +1 -0
- package/dist/lib/routes.js +5 -0
- package/dist/lib/routes.js.map +1 -0
- package/dist/lib/running-state.d.ts +76 -0
- package/dist/lib/running-state.d.ts.map +1 -0
- package/dist/lib/running-state.js +338 -0
- package/dist/lib/running-state.js.map +1 -0
- package/dist/lib/script-runner.d.ts +10 -0
- package/dist/lib/script-runner.d.ts.map +1 -0
- package/dist/lib/script-runner.js +189 -0
- package/dist/lib/script-runner.js.map +1 -0
- package/dist/lib/session-utils.d.ts +14 -0
- package/dist/lib/session-utils.d.ts.map +1 -0
- package/dist/lib/session-utils.js +58 -0
- package/dist/lib/session-utils.js.map +1 -0
- package/dist/lib/shell.d.ts +17 -0
- package/dist/lib/shell.d.ts.map +1 -0
- package/dist/lib/shell.js +90 -0
- package/dist/lib/shell.js.map +1 -0
- package/dist/lib/shutdown.d.ts +30 -0
- package/dist/lib/shutdown.d.ts.map +1 -0
- package/dist/lib/shutdown.js +177 -0
- package/dist/lib/shutdown.js.map +1 -0
- package/dist/lib/slack-setup.d.ts +17 -0
- package/dist/lib/slack-setup.d.ts.map +1 -0
- package/dist/lib/slack-setup.js +485 -0
- package/dist/lib/slack-setup.js.map +1 -0
- package/dist/lib/startup-preflight.d.ts +36 -0
- package/dist/lib/startup-preflight.d.ts.map +1 -0
- package/dist/lib/startup-preflight.js +273 -0
- package/dist/lib/startup-preflight.js.map +1 -0
- package/dist/lib/update-channel-onboarding.d.ts +52 -0
- package/dist/lib/update-channel-onboarding.d.ts.map +1 -0
- package/dist/lib/update-channel-onboarding.js +107 -0
- package/dist/lib/update-channel-onboarding.js.map +1 -0
- package/dist/lib/update-check.d.ts +161 -0
- package/dist/lib/update-check.d.ts.map +1 -0
- package/dist/lib/update-check.js +504 -0
- package/dist/lib/update-check.js.map +1 -0
- package/dist/lib/web-dir.d.ts +47 -0
- package/dist/lib/web-dir.d.ts.map +1 -0
- package/dist/lib/web-dir.js +179 -0
- package/dist/lib/web-dir.js.map +1 -0
- package/dist/lib/webhook-setup.d.ts +16 -0
- package/dist/lib/webhook-setup.d.ts.map +1 -0
- package/dist/lib/webhook-setup.js +383 -0
- package/dist/lib/webhook-setup.js.map +1 -0
- package/dist/options/version.d.ts +2 -0
- package/dist/options/version.d.ts.map +1 -0
- package/dist/options/version.js +7 -0
- package/dist/options/version.js.map +1 -0
- package/dist/program.d.ts +3 -0
- package/dist/program.d.ts.map +1 -0
- package/dist/program.js +63 -0
- package/dist/program.js.map +1 -0
- package/package.json +80 -0
- package/templates/rules/base.md +4 -0
- package/templates/rules/go.md +8 -0
- package/templates/rules/javascript.md +4 -0
- package/templates/rules/nextjs.md +7 -0
- package/templates/rules/pnpm-workspaces.md +4 -0
- package/templates/rules/python.md +8 -0
- package/templates/rules/react.md +8 -0
- package/templates/rules/typescript.md +6 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified project resolution for `athene start`.
|
|
3
|
+
*
|
|
4
|
+
* Replaces the per-arg-shape dispatch that lived inline in start.ts (URL →
|
|
5
|
+
* handleUrlStart, path → addProjectToConfig, none → loadConfig/autoCreate +
|
|
6
|
+
* registerFlatConfig recovery, project-id → resolveProject). Each shape
|
|
7
|
+
* still has its own helper here, but they all return the same shape so
|
|
8
|
+
* the caller can treat them uniformly.
|
|
9
|
+
*
|
|
10
|
+
* The same resolver runs whether or not a daemon is already up. When a
|
|
11
|
+
* daemon is running, callers pass `targetGlobalRegistry: true` so URL/path
|
|
12
|
+
* args register the project in the global config (the daemon's source of
|
|
13
|
+
* truth) rather than into the cwd-local config a non-running fresh start
|
|
14
|
+
* would generate.
|
|
15
|
+
*/
|
|
16
|
+
import { type OrchestratorConfig, type ParsedRepoUrl, type ProjectConfig } from "@made-by-moonlight/athene-core";
|
|
17
|
+
export type ProjectSource = "url" | "path" | "cwd" | "existing-id";
|
|
18
|
+
export interface Resolved {
|
|
19
|
+
config: OrchestratorConfig;
|
|
20
|
+
projectId: string;
|
|
21
|
+
project: ProjectConfig;
|
|
22
|
+
source: ProjectSource;
|
|
23
|
+
/** True when this resolve call wrote new state to disk (cloned a repo,
|
|
24
|
+
* generated a config, or registered a project). False when the project
|
|
25
|
+
* was already known. Useful for dashboard cache invalidation hints. */
|
|
26
|
+
justCreated: boolean;
|
|
27
|
+
/** Populated only when source === "url". */
|
|
28
|
+
parsed?: ParsedRepoUrl;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Dependencies the resolver needs to delegate to existing start.ts helpers.
|
|
32
|
+
* Passed in rather than imported to keep this module decoupled from
|
|
33
|
+
* start.ts's other concerns (interactive prompts, agent detection, etc.).
|
|
34
|
+
*/
|
|
35
|
+
export interface ResolveDeps {
|
|
36
|
+
/**
|
|
37
|
+
* Add an unregistered local path as a new project. The signature matches
|
|
38
|
+
* start.ts's `addProjectToConfig`. Returns the registered project id.
|
|
39
|
+
*/
|
|
40
|
+
addProjectToConfig: (config: OrchestratorConfig, path: string) => Promise<string>;
|
|
41
|
+
/**
|
|
42
|
+
* Auto-create a config when none exists at `workingDir`. Matches
|
|
43
|
+
* start.ts's `autoCreateConfig`. Returns the loaded config.
|
|
44
|
+
*/
|
|
45
|
+
autoCreateConfig: (workingDir: string) => Promise<OrchestratorConfig>;
|
|
46
|
+
/**
|
|
47
|
+
* Resolve an existing project from a loaded config (handles single-
|
|
48
|
+
* project, explicit arg, multi-project prompt). Matches start.ts's
|
|
49
|
+
* `resolveProject`.
|
|
50
|
+
*/
|
|
51
|
+
resolveProject: (config: OrchestratorConfig, projectArg?: string) => Promise<{
|
|
52
|
+
projectId: string;
|
|
53
|
+
project: ProjectConfig;
|
|
54
|
+
config: OrchestratorConfig;
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Resolve a project from a loaded config by matching the URL's
|
|
58
|
+
* `ownerRepo`. Matches start.ts's `resolveProjectByRepo`.
|
|
59
|
+
*/
|
|
60
|
+
resolveProjectByRepo: (config: OrchestratorConfig, parsed: ParsedRepoUrl) => Promise<{
|
|
61
|
+
projectId: string;
|
|
62
|
+
project: ProjectConfig;
|
|
63
|
+
config: OrchestratorConfig;
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Recover a flat local config that exists but isn't registered globally.
|
|
67
|
+
* Matches start.ts's `registerFlatConfig`. Returns the registered id, or
|
|
68
|
+
* null if recovery is not possible.
|
|
69
|
+
*/
|
|
70
|
+
registerFlatConfig: (configPath: string) => Promise<string | null>;
|
|
71
|
+
/**
|
|
72
|
+
* Clone a repo into the target dir. Matches start.ts's `cloneRepo`.
|
|
73
|
+
*/
|
|
74
|
+
cloneRepo: (parsed: ParsedRepoUrl, targetDir: string, cwd: string) => Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Options that change how the resolver writes new state to disk.
|
|
78
|
+
*
|
|
79
|
+
* `targetGlobalRegistry`:
|
|
80
|
+
* When `true`, URL and path arguments resolve and register against the
|
|
81
|
+
* global config (`~/.agent-orchestrator/config.yaml`) rather than a cwd-
|
|
82
|
+
* local one. Used when an `ao` daemon is already running — the daemon's
|
|
83
|
+
* project supervisor reads from the global registry, so anything we
|
|
84
|
+
* freshly clone or add must land there to be visible.
|
|
85
|
+
*
|
|
86
|
+
* When `false` (default), the resolver behaves as if this were the very
|
|
87
|
+
* first `athene start`: URL clones generate a wrapped (`projects:`) yaml in
|
|
88
|
+
* the cloned repo, paths register against whatever config the cwd walks
|
|
89
|
+
* up to find.
|
|
90
|
+
*/
|
|
91
|
+
export interface ResolveOptions {
|
|
92
|
+
targetGlobalRegistry?: boolean;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Resolve (and create if necessary) the project a given `athene start [arg]`
|
|
96
|
+
* invocation refers to.
|
|
97
|
+
*
|
|
98
|
+
* Dispatches by arg shape:
|
|
99
|
+
* - `arg` is a URL → clone (or reuse), load/generate config, match by repo
|
|
100
|
+
* - `arg` is a local path → load existing or addProject or autoCreate
|
|
101
|
+
* - `arg` is a project id → load config, fall back to global if needed
|
|
102
|
+
* - `arg` is undefined → load cwd config, autoCreate on first run, register
|
|
103
|
+
* flat configs that exist but aren't globally known
|
|
104
|
+
*
|
|
105
|
+
* The same `Resolved` shape comes back regardless of source; callers use
|
|
106
|
+
* `source` and `justCreated` for hints (e.g. dashboard cache invalidation).
|
|
107
|
+
*
|
|
108
|
+
* Pass `opts.targetGlobalRegistry: true` when an `ao` daemon is already
|
|
109
|
+
* running so URL/path args register the project in the global config the
|
|
110
|
+
* daemon supervises rather than into a fresh cwd-local one.
|
|
111
|
+
*/
|
|
112
|
+
export declare function resolveOrCreateProject(arg: string | undefined, deps: ResolveDeps, opts?: ResolveOptions): Promise<Resolved>;
|
|
113
|
+
//# sourceMappingURL=resolve-project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-project.d.ts","sourceRoot":"","sources":["../../src/lib/resolve-project.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,OAAO,EAgBL,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAClB,KAAK,aAAa,EACnB,MAAM,gCAAgC,CAAC;AAQxC,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,aAAa,CAAC;AAEnE,MAAM,WAAW,QAAQ;IACvB,MAAM,EAAE,kBAAkB,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,EAAE,aAAa,CAAC;IACtB;;4EAEwE;IACxE,WAAW,EAAE,OAAO,CAAC;IACrB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,kBAAkB,EAAE,CAAC,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAClF;;;OAGG;IACH,gBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;IACtE;;;;OAIG;IACH,cAAc,EAAE,CACd,MAAM,EAAE,kBAAkB,EAC1B,UAAU,CAAC,EAAE,MAAM,KAChB,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,aAAa,CAAC;QAAC,MAAM,EAAE,kBAAkB,CAAA;KAAE,CAAC,CAAC;IACxF;;;OAGG;IACH,oBAAoB,EAAE,CACpB,MAAM,EAAE,kBAAkB,EAC1B,MAAM,EAAE,aAAa,KAClB,OAAO,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,aAAa,CAAC;QAAC,MAAM,EAAE,kBAAkB,CAAA;KAAE,CAAC,CAAC;IACxF;;;;OAIG;IACH,kBAAkB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACnE;;OAEG;IACH,SAAS,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACrF;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,cAAc;IAC7B,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAwaD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,IAAI,EAAE,WAAW,EACjB,IAAI,GAAE,cAAmB,GACxB,OAAO,CAAC,QAAQ,CAAC,CAInB"}
|
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified project resolution for `athene start`.
|
|
3
|
+
*
|
|
4
|
+
* Replaces the per-arg-shape dispatch that lived inline in start.ts (URL →
|
|
5
|
+
* handleUrlStart, path → addProjectToConfig, none → loadConfig/autoCreate +
|
|
6
|
+
* registerFlatConfig recovery, project-id → resolveProject). Each shape
|
|
7
|
+
* still has its own helper here, but they all return the same shape so
|
|
8
|
+
* the caller can treat them uniformly.
|
|
9
|
+
*
|
|
10
|
+
* The same resolver runs whether or not a daemon is already up. When a
|
|
11
|
+
* daemon is running, callers pass `targetGlobalRegistry: true` so URL/path
|
|
12
|
+
* args register the project in the global config (the daemon's source of
|
|
13
|
+
* truth) rather than into the cwd-local config a non-running fresh start
|
|
14
|
+
* would generate.
|
|
15
|
+
*/
|
|
16
|
+
import { existsSync, writeFileSync } from "node:fs";
|
|
17
|
+
import { resolve } from "node:path";
|
|
18
|
+
import { pathsEqual } from "./path-equality.js";
|
|
19
|
+
import { cwd } from "node:process";
|
|
20
|
+
import { ConfigNotFoundError, detectScmPlatform, findConfigFile, generateConfigFromUrl, configToYaml, isRepoUrl, loadConfig, parseRepoUrl, recordActivityEvent, registerProjectInGlobalConfig, resolveCloneTarget, isRepoAlreadyCloned, getGlobalConfigPath, sanitizeProjectId, writeLocalProjectConfig, } from "@made-by-moonlight/athene-core";
|
|
21
|
+
import chalk from "chalk";
|
|
22
|
+
import ora from "ora";
|
|
23
|
+
import { findFreePort } from "./web-dir.js";
|
|
24
|
+
import { DEFAULT_PORT } from "./constants.js";
|
|
25
|
+
import { ensureGit } from "./startup-preflight.js";
|
|
26
|
+
import { git } from "./shell.js";
|
|
27
|
+
/**
|
|
28
|
+
* Decide whether `arg` looks like a path (rather than a project id).
|
|
29
|
+
* Matches start.ts's `isLocalPath` — including Windows drive-letter and
|
|
30
|
+
* UNC patterns so e.g. `athene start C:\path\to\repo` is correctly classified.
|
|
31
|
+
*/
|
|
32
|
+
function isLocalPath(arg) {
|
|
33
|
+
if (arg.startsWith("/") || arg.startsWith("~") || arg.startsWith("./") || arg.startsWith("..")) {
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
if (/^[A-Za-z]:[\\/]/.test(arg))
|
|
37
|
+
return true;
|
|
38
|
+
if (arg.startsWith("\\\\") || arg.startsWith(".\\") || arg.startsWith("..\\"))
|
|
39
|
+
return true;
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Detect the actual default branch of a freshly cloned repo. Prefers
|
|
44
|
+
* `origin/HEAD` (the remote's default), falls back to the current local
|
|
45
|
+
* branch. Returns null for empty repos (no commits).
|
|
46
|
+
*/
|
|
47
|
+
async function detectClonedRepoDefaultBranch(repoPath) {
|
|
48
|
+
const symref = await git(["symbolic-ref", "refs/remotes/origin/HEAD"], repoPath);
|
|
49
|
+
if (symref) {
|
|
50
|
+
const match = symref.trim().match(/^refs\/remotes\/origin\/(.+)$/);
|
|
51
|
+
if (match)
|
|
52
|
+
return match[1];
|
|
53
|
+
}
|
|
54
|
+
const head = await git(["symbolic-ref", "--short", "HEAD"], repoPath);
|
|
55
|
+
if (head) {
|
|
56
|
+
const trimmed = head.trim();
|
|
57
|
+
if (trimmed.length > 0)
|
|
58
|
+
return trimmed;
|
|
59
|
+
}
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Clone (or reuse) a URL and register the project in the global config.
|
|
64
|
+
* The repo gets a flat local config (behavior only — scm/tracker plugin
|
|
65
|
+
* choices); identity (path, repo, defaultBranch, sessionPrefix) lives in
|
|
66
|
+
* the global registry so the daemon's project supervisor can see it.
|
|
67
|
+
*
|
|
68
|
+
* Mirrors the inline clone+register block that previously lived in start.ts
|
|
69
|
+
* for the "AO already running + URL arg" case.
|
|
70
|
+
*/
|
|
71
|
+
async function fromUrlIntoGlobal(arg, deps) {
|
|
72
|
+
const parsed = parseRepoUrl(arg);
|
|
73
|
+
const globalConfigPath = getGlobalConfigPath();
|
|
74
|
+
const globalConfig = existsSync(globalConfigPath) ? loadConfig(globalConfigPath) : loadConfig();
|
|
75
|
+
// Existing project with the same repo? Skip the clone entirely.
|
|
76
|
+
for (const [id, p] of Object.entries(globalConfig.projects)) {
|
|
77
|
+
if (p.repo === parsed.ownerRepo) {
|
|
78
|
+
return {
|
|
79
|
+
config: globalConfig,
|
|
80
|
+
projectId: id,
|
|
81
|
+
project: p,
|
|
82
|
+
source: "url",
|
|
83
|
+
justCreated: false,
|
|
84
|
+
parsed,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
console.log(chalk.bold.cyan(`\n Cloning ${parsed.ownerRepo} (${parsed.host})\n`));
|
|
89
|
+
await ensureGit("repository cloning");
|
|
90
|
+
const cwdDir = process.cwd();
|
|
91
|
+
const targetDir = resolveCloneTarget(parsed, cwdDir);
|
|
92
|
+
if (isRepoAlreadyCloned(targetDir, parsed.cloneUrl)) {
|
|
93
|
+
console.log(chalk.green(` Reusing existing clone at ${targetDir}`));
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
try {
|
|
97
|
+
await deps.cloneRepo(parsed, targetDir, cwdDir);
|
|
98
|
+
console.log(chalk.green(` Cloned to ${targetDir}`));
|
|
99
|
+
}
|
|
100
|
+
catch (err) {
|
|
101
|
+
recordActivityEvent({
|
|
102
|
+
source: "cli",
|
|
103
|
+
kind: "cli.project_resolve_failed",
|
|
104
|
+
level: "error",
|
|
105
|
+
summary: `failed to clone ${parsed.ownerRepo}`,
|
|
106
|
+
data: {
|
|
107
|
+
ownerRepo: parsed.ownerRepo,
|
|
108
|
+
targetDir,
|
|
109
|
+
source: "url-global",
|
|
110
|
+
errorMessage: err instanceof Error ? err.message : String(err),
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
throw new Error(`Failed to clone ${parsed.ownerRepo}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Empty repos can't host an orchestrator worktree — fail early with a
|
|
117
|
+
// clear message instead of a confusing "Unable to resolve base ref" later.
|
|
118
|
+
const detectedBranch = await detectClonedRepoDefaultBranch(targetDir);
|
|
119
|
+
if (!detectedBranch) {
|
|
120
|
+
throw new Error(`Repository "${parsed.ownerRepo}" appears to be empty (no commits or refs).\n` +
|
|
121
|
+
` AO needs at least one commit on the default branch to spawn an orchestrator.\n` +
|
|
122
|
+
` Push an initial commit, then re-run \`athene start ${arg}\`.`);
|
|
123
|
+
}
|
|
124
|
+
const platform = detectScmPlatform(parsed.host);
|
|
125
|
+
const requestedProjectId = sanitizeProjectId(parsed.repo);
|
|
126
|
+
const registeredId = registerProjectInGlobalConfig(requestedProjectId, parsed.repo, targetDir, {
|
|
127
|
+
repo: parsed.ownerRepo,
|
|
128
|
+
defaultBranch: detectedBranch,
|
|
129
|
+
}, globalConfigPath);
|
|
130
|
+
// Write a flat local config (behavior only, no `projects:` wrapper, no
|
|
131
|
+
// identity fields). Identity lives in the global registry; this file
|
|
132
|
+
// holds plugin choices for the project. Skip if the upstream commits its
|
|
133
|
+
// own agent-orchestrator.yaml — leave it for the user to reconcile.
|
|
134
|
+
const hasCommittedConfig = existsSync(resolve(targetDir, "agent-orchestrator.yaml")) ||
|
|
135
|
+
existsSync(resolve(targetDir, "agent-orchestrator.yml"));
|
|
136
|
+
if (!hasCommittedConfig) {
|
|
137
|
+
writeLocalProjectConfig(targetDir, {
|
|
138
|
+
scm: { plugin: platform !== "unknown" ? platform : "github" },
|
|
139
|
+
tracker: {
|
|
140
|
+
plugin: platform === "gitlab" ? "gitlab" : "github",
|
|
141
|
+
},
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
const refreshedConfig = loadConfig(globalConfigPath);
|
|
145
|
+
const project = refreshedConfig.projects[registeredId];
|
|
146
|
+
if (!project) {
|
|
147
|
+
throw new Error(`Failed to register "${registeredId}" in the global config — aborting.`);
|
|
148
|
+
}
|
|
149
|
+
return {
|
|
150
|
+
config: refreshedConfig,
|
|
151
|
+
projectId: registeredId,
|
|
152
|
+
project,
|
|
153
|
+
source: "url",
|
|
154
|
+
justCreated: true,
|
|
155
|
+
parsed,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
async function fromUrl(arg, deps, opts) {
|
|
159
|
+
if (opts.targetGlobalRegistry) {
|
|
160
|
+
return fromUrlIntoGlobal(arg, deps);
|
|
161
|
+
}
|
|
162
|
+
console.log(chalk.bold.cyan("\n Athene — Quick Start\n"));
|
|
163
|
+
const spinner = ora();
|
|
164
|
+
spinner.start("Parsing repository URL");
|
|
165
|
+
const parsed = parseRepoUrl(arg);
|
|
166
|
+
spinner.succeed(`Repository: ${chalk.cyan(parsed.ownerRepo)} (${parsed.host})`);
|
|
167
|
+
await ensureGit("repository cloning");
|
|
168
|
+
const cwdDir = process.cwd();
|
|
169
|
+
const targetDir = resolveCloneTarget(parsed, cwdDir);
|
|
170
|
+
const alreadyCloned = isRepoAlreadyCloned(targetDir, parsed.cloneUrl);
|
|
171
|
+
if (alreadyCloned) {
|
|
172
|
+
console.log(chalk.green(` Reusing existing clone at ${targetDir}`));
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
spinner.start(`Cloning ${parsed.ownerRepo}`);
|
|
176
|
+
try {
|
|
177
|
+
spinner.stop();
|
|
178
|
+
await deps.cloneRepo(parsed, targetDir, cwdDir);
|
|
179
|
+
spinner.succeed(`Cloned to ${targetDir}`);
|
|
180
|
+
}
|
|
181
|
+
catch (err) {
|
|
182
|
+
spinner.fail("Clone failed");
|
|
183
|
+
recordActivityEvent({
|
|
184
|
+
source: "cli",
|
|
185
|
+
kind: "cli.project_resolve_failed",
|
|
186
|
+
level: "error",
|
|
187
|
+
summary: `failed to clone ${parsed.ownerRepo}`,
|
|
188
|
+
data: {
|
|
189
|
+
ownerRepo: parsed.ownerRepo,
|
|
190
|
+
targetDir,
|
|
191
|
+
source: "url-local",
|
|
192
|
+
errorMessage: err instanceof Error ? err.message : String(err),
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
throw new Error(`Failed to clone ${parsed.ownerRepo}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
const configPath = resolve(targetDir, "agent-orchestrator.yaml");
|
|
199
|
+
const configPathAlt = resolve(targetDir, "agent-orchestrator.yml");
|
|
200
|
+
let config;
|
|
201
|
+
let justCreated;
|
|
202
|
+
if (existsSync(configPath)) {
|
|
203
|
+
console.log(chalk.green(` Using existing config: ${configPath}`));
|
|
204
|
+
config = loadConfig(configPath);
|
|
205
|
+
justCreated = false;
|
|
206
|
+
}
|
|
207
|
+
else if (existsSync(configPathAlt)) {
|
|
208
|
+
console.log(chalk.green(` Using existing config: ${configPathAlt}`));
|
|
209
|
+
config = loadConfig(configPathAlt);
|
|
210
|
+
justCreated = false;
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
spinner.start("Generating config");
|
|
214
|
+
const freePort = await findFreePort(DEFAULT_PORT);
|
|
215
|
+
const rawConfig = generateConfigFromUrl({
|
|
216
|
+
parsed,
|
|
217
|
+
repoPath: targetDir,
|
|
218
|
+
port: freePort ?? DEFAULT_PORT,
|
|
219
|
+
});
|
|
220
|
+
const yamlContent = configToYaml(rawConfig);
|
|
221
|
+
writeFileSync(configPath, yamlContent);
|
|
222
|
+
spinner.succeed(`Config generated: ${configPath}`);
|
|
223
|
+
config = loadConfig(configPath);
|
|
224
|
+
justCreated = true;
|
|
225
|
+
}
|
|
226
|
+
const resolved = await deps.resolveProjectByRepo(config, parsed);
|
|
227
|
+
return {
|
|
228
|
+
config: resolved.config,
|
|
229
|
+
projectId: resolved.projectId,
|
|
230
|
+
project: resolved.project,
|
|
231
|
+
source: "url",
|
|
232
|
+
justCreated,
|
|
233
|
+
parsed,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
async function fromPath(arg, deps, opts) {
|
|
237
|
+
const resolvedPath = resolve(arg.replace(/^~/, process.env["HOME"] || ""));
|
|
238
|
+
// When a daemon is already running, register against the global config
|
|
239
|
+
// (the daemon's source of truth) instead of whatever cwd-local config
|
|
240
|
+
// findConfigFile() walks up to. addProjectToConfig is canonical-global-
|
|
241
|
+
// aware, so handing it a config loaded from the global path routes the
|
|
242
|
+
// write through registerProjectInGlobalConfig.
|
|
243
|
+
if (opts.targetGlobalRegistry) {
|
|
244
|
+
const globalPath = getGlobalConfigPath();
|
|
245
|
+
const globalConfig = existsSync(globalPath) ? loadConfig(globalPath) : loadConfig();
|
|
246
|
+
// pathsEqual canonicalizes via realpathSync so symlinked paths (e.g.
|
|
247
|
+
// macOS /tmp -> /private/tmp) match an entry stored under the
|
|
248
|
+
// resolved target, and lowercases on Windows so drive-letter / 8.3
|
|
249
|
+
// case mismatches don't slip through. Without this, `athene start
|
|
250
|
+
// /tmp/foo` against a daemon whose global config has /private/tmp/foo
|
|
251
|
+
// would fail to dedupe and double-register the project.
|
|
252
|
+
const existingEntry = Object.entries(globalConfig.projects).find(([, p]) => pathsEqual(p.path, resolvedPath));
|
|
253
|
+
if (existingEntry) {
|
|
254
|
+
return {
|
|
255
|
+
config: globalConfig,
|
|
256
|
+
projectId: existingEntry[0],
|
|
257
|
+
project: existingEntry[1],
|
|
258
|
+
source: "path",
|
|
259
|
+
justCreated: false,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
const addedId = await deps.addProjectToConfig(globalConfig, resolvedPath);
|
|
263
|
+
const reloaded = loadConfig(globalConfig.configPath);
|
|
264
|
+
const project = reloaded.projects[addedId];
|
|
265
|
+
if (!project) {
|
|
266
|
+
throw new Error(`Failed to register "${addedId}" in the global config — aborting.`);
|
|
267
|
+
}
|
|
268
|
+
return {
|
|
269
|
+
config: reloaded,
|
|
270
|
+
projectId: addedId,
|
|
271
|
+
project,
|
|
272
|
+
source: "path",
|
|
273
|
+
justCreated: true,
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
let configPath;
|
|
277
|
+
try {
|
|
278
|
+
configPath = findConfigFile() ?? undefined;
|
|
279
|
+
}
|
|
280
|
+
catch {
|
|
281
|
+
// No config — fall through to autoCreate.
|
|
282
|
+
}
|
|
283
|
+
if (!configPath) {
|
|
284
|
+
// No config anywhere — auto-create at the target path (or cwd if they match).
|
|
285
|
+
const targetDir = resolve(cwd()) === resolvedPath ? cwd() : resolvedPath;
|
|
286
|
+
const config = await deps.autoCreateConfig(targetDir);
|
|
287
|
+
const resolved = await deps.resolveProject(config);
|
|
288
|
+
return {
|
|
289
|
+
config: resolved.config,
|
|
290
|
+
projectId: resolved.projectId,
|
|
291
|
+
project: resolved.project,
|
|
292
|
+
source: "path",
|
|
293
|
+
justCreated: true,
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
// Config exists — check if the path is already registered.
|
|
297
|
+
const config = loadConfig(configPath);
|
|
298
|
+
const existingEntry = Object.entries(config.projects).find(([, p]) => pathsEqual(p.path, resolvedPath));
|
|
299
|
+
if (existingEntry) {
|
|
300
|
+
return {
|
|
301
|
+
config,
|
|
302
|
+
projectId: existingEntry[0],
|
|
303
|
+
project: existingEntry[1],
|
|
304
|
+
source: "path",
|
|
305
|
+
justCreated: false,
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
// Path is new — register it.
|
|
309
|
+
const addedId = await deps.addProjectToConfig(config, resolvedPath);
|
|
310
|
+
const reloaded = loadConfig(config.configPath);
|
|
311
|
+
return {
|
|
312
|
+
config: reloaded,
|
|
313
|
+
projectId: addedId,
|
|
314
|
+
project: reloaded.projects[addedId],
|
|
315
|
+
source: "path",
|
|
316
|
+
justCreated: true,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
async function fromCwdOrId(arg, deps, opts) {
|
|
320
|
+
// Daemon-running + project id: the global registry is the source of
|
|
321
|
+
// truth for project identity, so look there directly. Skipping the cwd-
|
|
322
|
+
// local loadConfig() also avoids first-run autoCreate prompts when the
|
|
323
|
+
// user just wants to attach to a known project.
|
|
324
|
+
if (opts.targetGlobalRegistry && arg) {
|
|
325
|
+
const globalPath = getGlobalConfigPath();
|
|
326
|
+
const config = existsSync(globalPath) ? loadConfig(globalPath) : loadConfig();
|
|
327
|
+
const project = config.projects[arg];
|
|
328
|
+
if (!project) {
|
|
329
|
+
throw new Error(`Project "${arg}" is not registered in the global config (${config.configPath}).\n` +
|
|
330
|
+
` Run \`athene project add\` or \`athene start <path|url>\` first.`);
|
|
331
|
+
}
|
|
332
|
+
return {
|
|
333
|
+
config,
|
|
334
|
+
projectId: arg,
|
|
335
|
+
project,
|
|
336
|
+
source: "existing-id",
|
|
337
|
+
justCreated: false,
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
let config;
|
|
341
|
+
let recovered = false;
|
|
342
|
+
try {
|
|
343
|
+
config = loadConfig();
|
|
344
|
+
}
|
|
345
|
+
catch (err) {
|
|
346
|
+
if (err instanceof ConfigNotFoundError) {
|
|
347
|
+
// First run — auto-create config in cwd.
|
|
348
|
+
config = await deps.autoCreateConfig(cwd());
|
|
349
|
+
recovered = true;
|
|
350
|
+
recordActivityEvent({
|
|
351
|
+
source: "cli",
|
|
352
|
+
kind: "cli.config_recovered",
|
|
353
|
+
level: "info",
|
|
354
|
+
summary: `auto-created config in cwd (first-run)`,
|
|
355
|
+
data: { recovery: "auto_create", cwd: cwd() },
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
// A config file exists but failed to load — likely a flat local
|
|
360
|
+
// config whose project isn't in the global registry yet. Recover
|
|
361
|
+
// by registering it, then retry the load.
|
|
362
|
+
const foundConfig = findConfigFile() ?? undefined;
|
|
363
|
+
if (!foundConfig)
|
|
364
|
+
throw err;
|
|
365
|
+
const addedId = await deps.registerFlatConfig(foundConfig);
|
|
366
|
+
if (!addedId) {
|
|
367
|
+
recordActivityEvent({
|
|
368
|
+
source: "cli",
|
|
369
|
+
kind: "cli.config_recovery_failed",
|
|
370
|
+
level: "error",
|
|
371
|
+
summary: `registerFlatConfig returned null — recovery failed`,
|
|
372
|
+
data: {
|
|
373
|
+
configPath: foundConfig,
|
|
374
|
+
errorMessage: err instanceof Error ? err.message : String(err),
|
|
375
|
+
},
|
|
376
|
+
});
|
|
377
|
+
throw err;
|
|
378
|
+
}
|
|
379
|
+
config = loadConfig(foundConfig);
|
|
380
|
+
recovered = true;
|
|
381
|
+
recordActivityEvent({
|
|
382
|
+
projectId: addedId,
|
|
383
|
+
source: "cli",
|
|
384
|
+
kind: "cli.config_recovered",
|
|
385
|
+
level: "info",
|
|
386
|
+
summary: `registered flat config into global config and retried load`,
|
|
387
|
+
data: { recovery: "register_flat", configPath: foundConfig },
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
// If the user named a project that isn't in the local config, fall back
|
|
392
|
+
// to the global registry (which has all registered projects).
|
|
393
|
+
if (arg && !config.projects[arg]) {
|
|
394
|
+
const globalPath = getGlobalConfigPath();
|
|
395
|
+
if (existsSync(globalPath)) {
|
|
396
|
+
config = loadConfig(globalPath);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
const resolved = await deps.resolveProject(config, arg);
|
|
400
|
+
return {
|
|
401
|
+
config: resolved.config,
|
|
402
|
+
projectId: resolved.projectId,
|
|
403
|
+
project: resolved.project,
|
|
404
|
+
source: arg ? "existing-id" : "cwd",
|
|
405
|
+
justCreated: recovered,
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Resolve (and create if necessary) the project a given `athene start [arg]`
|
|
410
|
+
* invocation refers to.
|
|
411
|
+
*
|
|
412
|
+
* Dispatches by arg shape:
|
|
413
|
+
* - `arg` is a URL → clone (or reuse), load/generate config, match by repo
|
|
414
|
+
* - `arg` is a local path → load existing or addProject or autoCreate
|
|
415
|
+
* - `arg` is a project id → load config, fall back to global if needed
|
|
416
|
+
* - `arg` is undefined → load cwd config, autoCreate on first run, register
|
|
417
|
+
* flat configs that exist but aren't globally known
|
|
418
|
+
*
|
|
419
|
+
* The same `Resolved` shape comes back regardless of source; callers use
|
|
420
|
+
* `source` and `justCreated` for hints (e.g. dashboard cache invalidation).
|
|
421
|
+
*
|
|
422
|
+
* Pass `opts.targetGlobalRegistry: true` when an `ao` daemon is already
|
|
423
|
+
* running so URL/path args register the project in the global config the
|
|
424
|
+
* daemon supervises rather than into a fresh cwd-local one.
|
|
425
|
+
*/
|
|
426
|
+
export async function resolveOrCreateProject(arg, deps, opts = {}) {
|
|
427
|
+
if (arg && isRepoUrl(arg))
|
|
428
|
+
return fromUrl(arg, deps, opts);
|
|
429
|
+
if (arg && isLocalPath(arg))
|
|
430
|
+
return fromPath(arg, deps, opts);
|
|
431
|
+
return fromCwdOrId(arg, deps, opts);
|
|
432
|
+
}
|
|
433
|
+
//# sourceMappingURL=resolve-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-project.js","sourceRoot":"","sources":["../../src/lib/resolve-project.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,YAAY,EACZ,SAAS,EACT,UAAU,EACV,YAAY,EACZ,mBAAmB,EACnB,6BAA6B,EAC7B,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,uBAAuB,GAIxB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAiFjC;;;;GAIG;AACH,SAAS,WAAW,CAAC,GAAW;IAC9B,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/F,OAAO,IAAI,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AK;QACnC,WAAW,EAAE,SAAS;KACvB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC1C,GAAuB,EACvB,IAAiB,EACjB,OAAuB,EAAE;IAEzB,IAAI,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC;QAAE,OAAO,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC3D,IAAI,GAAG,IAAI,WAAW,CAAC,GAAG,CAAC;QAAE,OAAO,QAAQ,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IAC9D,OAAO,WAAW,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/lib/routes.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5F"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { dashboardUrl } from "./dashboard-url.js";
|
|
2
|
+
export function projectSessionUrl(port, projectId, sessionId) {
|
|
3
|
+
return `${dashboardUrl(port)}/projects/${encodeURIComponent(projectId)}/sessions/${encodeURIComponent(sessionId)}`;
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=routes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/lib/routes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,UAAU,iBAAiB,CAAC,IAAY,EAAE,SAAiB,EAAE,SAAiB;IAClF,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,aAAa,kBAAkB,CAAC,SAAS,CAAC,aAAa,kBAAkB,CAAC,SAAS,CAAC,EAAE,CAAC;AACrH,CAAC"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export interface RunningState {
|
|
2
|
+
pid: number;
|
|
3
|
+
configPath: string;
|
|
4
|
+
port: number;
|
|
5
|
+
startedAt: string;
|
|
6
|
+
projects: string[];
|
|
7
|
+
}
|
|
8
|
+
export interface LastStopState {
|
|
9
|
+
stoppedAt: string;
|
|
10
|
+
projectId: string;
|
|
11
|
+
sessionIds: string[];
|
|
12
|
+
/** Sessions from other projects that were also active at stop time. */
|
|
13
|
+
otherProjects?: Array<{
|
|
14
|
+
projectId: string;
|
|
15
|
+
sessionIds: string[];
|
|
16
|
+
}>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Register the current AO instance as running.
|
|
20
|
+
* Uses a lockfile to prevent concurrent registration.
|
|
21
|
+
*/
|
|
22
|
+
export declare function register(entry: RunningState): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Unregister the running AO instance.
|
|
25
|
+
*/
|
|
26
|
+
export declare function unregister(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Remove a single project from the running state's project list.
|
|
29
|
+
* Used by `athene stop <project>` so that `athene start <project>` can restart
|
|
30
|
+
* the orchestrator without hitting the "already running" gate.
|
|
31
|
+
* No-op if the state is missing or the project isn't listed.
|
|
32
|
+
*/
|
|
33
|
+
export declare function removeProjectFromRunning(projectId: string): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Add a project to the running state's project list (idempotent).
|
|
36
|
+
* Used when a project's orchestrator is spawned against an already-running
|
|
37
|
+
* daemon — for example after `athene start <project>` attaches to an existing
|
|
38
|
+
* parent process whose `projects` list didn't yet include the project.
|
|
39
|
+
* Without this, subsequent `athene stop` (no args) would leave the new
|
|
40
|
+
* orchestrator orphaned because it isn't in `running.projects`.
|
|
41
|
+
* No-op if the state is missing or the project is already listed.
|
|
42
|
+
*/
|
|
43
|
+
export declare function addProjectToRunning(projectId: string): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Get the currently running AO instance, if any.
|
|
46
|
+
* Auto-prunes stale entries (dead PIDs).
|
|
47
|
+
*/
|
|
48
|
+
export declare function getRunning(): Promise<RunningState | null>;
|
|
49
|
+
/**
|
|
50
|
+
* Check if AO is already running.
|
|
51
|
+
* Returns the running state if alive, null otherwise.
|
|
52
|
+
*/
|
|
53
|
+
export declare function isAlreadyRunning(): Promise<RunningState | null>;
|
|
54
|
+
/**
|
|
55
|
+
* Serialize `athene start` so concurrent startups cannot both observe an empty
|
|
56
|
+
* running.json and create competing orchestrator/dashboard processes.
|
|
57
|
+
*/
|
|
58
|
+
export declare function acquireStartupLock(timeoutMs?: number): Promise<() => void>;
|
|
59
|
+
/**
|
|
60
|
+
* Wait for a process to exit, polling isProcessAlive.
|
|
61
|
+
* Returns true if the process exited, false if timeout reached.
|
|
62
|
+
*/
|
|
63
|
+
export declare function waitForExit(pid: number, timeoutMs?: number): Promise<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* Record which sessions were active when `athene stop` ran.
|
|
66
|
+
*/
|
|
67
|
+
export declare function writeLastStop(state: LastStopState): Promise<void>;
|
|
68
|
+
/**
|
|
69
|
+
* Read the last-stop state, if any.
|
|
70
|
+
*/
|
|
71
|
+
export declare function readLastStop(): Promise<LastStopState | null>;
|
|
72
|
+
/**
|
|
73
|
+
* Remove the last-stop state file (after restore or skip).
|
|
74
|
+
*/
|
|
75
|
+
export declare function clearLastStop(): Promise<void>;
|
|
76
|
+
//# sourceMappingURL=running-state.d.ts.map
|