@voicethere/cli 0.1.0 → 0.2.0
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 +76 -50
- package/dist/cli.js +23 -30
- package/dist/cli.js.map +1 -1
- package/dist/commands/build/list.d.ts +3 -2
- package/dist/commands/build/list.d.ts.map +1 -1
- package/dist/commands/build/list.js +9 -7
- package/dist/commands/build/list.js.map +1 -1
- package/dist/commands/build/promote.d.ts +1 -2
- package/dist/commands/build/promote.d.ts.map +1 -1
- package/dist/commands/build/promote.js +45 -7
- package/dist/commands/build/promote.js.map +1 -1
- package/dist/commands/build/upload.d.ts +0 -1
- package/dist/commands/build/upload.d.ts.map +1 -1
- package/dist/commands/build/upload.js +11 -5
- package/dist/commands/build/upload.js.map +1 -1
- package/dist/commands/build/validate.d.ts +2 -0
- package/dist/commands/build/validate.d.ts.map +1 -1
- package/dist/commands/build/validate.js +8 -14
- package/dist/commands/build/validate.js.map +1 -1
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +5 -2
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/projects/create.d.ts.map +1 -1
- package/dist/commands/projects/create.js +4 -2
- package/dist/commands/projects/create.js.map +1 -1
- package/dist/commands/projects/show.js +1 -1
- package/dist/commands/projects/show.js.map +1 -1
- package/dist/commands/projects/use.d.ts +2 -1
- package/dist/commands/projects/use.d.ts.map +1 -1
- package/dist/commands/projects/use.js +65 -10
- package/dist/commands/projects/use.js.map +1 -1
- package/dist/lib/command-log.d.ts +6 -0
- package/dist/lib/command-log.d.ts.map +1 -0
- package/dist/lib/command-log.js +29 -0
- package/dist/lib/command-log.js.map +1 -0
- package/dist/lib/project-config.d.ts +26 -4
- package/dist/lib/project-config.d.ts.map +1 -1
- package/dist/lib/project-config.js +49 -17
- package/dist/lib/project-config.js.map +1 -1
- package/dist/lib/prompt.d.ts +7 -0
- package/dist/lib/prompt.d.ts.map +1 -0
- package/dist/lib/prompt.js +30 -0
- package/dist/lib/prompt.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,6 +18,29 @@ Or run without a global install:
|
|
|
18
18
|
npx @voicethere/cli <command>
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
+
## Debugging
|
|
22
|
+
|
|
23
|
+
Commands print resolved paths on **stderr** at startup:
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
[voicethere] project: 550e8400-… (project config (/path/.voicethere/config.json))
|
|
27
|
+
[voicethere] bundle: /path/to/dist/agent.js (project config (/path/.voicethere/config.json))
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Use this when a command fails to confirm which project and bundle file were picked up.
|
|
31
|
+
|
|
32
|
+
## Project selection
|
|
33
|
+
|
|
34
|
+
The CLI remembers the **active project** in **`.voicethere/config.json`** (safe to commit — no API keys).
|
|
35
|
+
|
|
36
|
+
| Situation | What happens |
|
|
37
|
+
| --------- | -------------- |
|
|
38
|
+
| Config file present | `build upload`, `build list`, `build promote` use its `project_id` automatically |
|
|
39
|
+
| No config, interactive terminal | `projects use` shows a numbered project picker |
|
|
40
|
+
| No config, CI / script | Run `voicethere projects use <projectId>` once (or commit config from `projects create`) |
|
|
41
|
+
|
|
42
|
+
You do **not** need to run `projects use` on every command when the config file is already in the repo.
|
|
43
|
+
|
|
21
44
|
## Typical workflow
|
|
22
45
|
|
|
23
46
|
### 1. One-time login (per machine)
|
|
@@ -32,7 +55,7 @@ voicethere login --api-key "$VOICETHERE_API_KEY" --api-base http://localhost:300
|
|
|
32
55
|
|
|
33
56
|
Default API base: `https://app.voicethere.dev/api/v1`
|
|
34
57
|
|
|
35
|
-
### 2. New agent repo — create project and
|
|
58
|
+
### 2. New agent repo — create project and commit config
|
|
36
59
|
|
|
37
60
|
From your agent project root (where you build `dist/agent.js`):
|
|
38
61
|
|
|
@@ -40,37 +63,34 @@ From your agent project root (where you build `dist/agent.js`):
|
|
|
40
63
|
npm install @voicethere/agent
|
|
41
64
|
npx @voicethere/agent build
|
|
42
65
|
|
|
43
|
-
# Creates the cloud project and
|
|
44
|
-
voicethere projects create
|
|
66
|
+
# Creates the cloud project and uses it (.voicethere/config.json)
|
|
67
|
+
voicethere projects create "My Voice Agent"
|
|
45
68
|
|
|
46
69
|
git add .voicethere/config.json
|
|
47
|
-
git commit -m "chore:
|
|
70
|
+
git commit -m "chore: use VoiceThere project"
|
|
48
71
|
```
|
|
49
72
|
|
|
50
|
-
`.voicethere/config.json` holds the **project id** and default **bundle** path. Commit it so teammates and CI use the same project without passing `--project` every time.
|
|
51
|
-
|
|
52
73
|
### 3. Upload a build (store artifact)
|
|
53
74
|
|
|
54
75
|
Upload **stores** a new immutable build in history — it does **not** go live yet.
|
|
55
76
|
|
|
56
77
|
```bash
|
|
57
|
-
voicethere build validate # optional
|
|
78
|
+
voicethere build validate # optional; uses config bundle or dist/agent.js
|
|
58
79
|
voicethere build upload -m "Add Spanish greeting and fix barge-in"
|
|
59
80
|
```
|
|
60
81
|
|
|
61
82
|
`-m` / `--message` is like a git commit message: a short label so you can tell builds apart in `build list` and the dashboard.
|
|
62
83
|
|
|
63
|
-
`build upload` reads `project_id` and `bundle` from `.voicethere/config.json` when flags are omitted.
|
|
64
|
-
|
|
65
84
|
### 4. Promote a build (set active in control plane)
|
|
66
85
|
|
|
67
86
|
**Promote** sets the **active** build in the VoiceThere control plane. It does **not** roll out to cloud runners yet — use **`voicethere deploy`** when that command ships.
|
|
68
87
|
|
|
69
|
-
Pass the build UUID from **`build
|
|
88
|
+
Pass the build UUID from **`build upload`** or **`build list`**, or omit it in an interactive terminal to pick from a list:
|
|
70
89
|
|
|
71
90
|
```bash
|
|
72
91
|
voicethere build list
|
|
73
92
|
voicethere build promote <build-uuid>
|
|
93
|
+
# interactive: voicethere build promote
|
|
74
94
|
```
|
|
75
95
|
|
|
76
96
|
Typical release loop:
|
|
@@ -94,19 +114,19 @@ voicethere build list
|
|
|
94
114
|
voicethere build promote <build-uuid>
|
|
95
115
|
```
|
|
96
116
|
|
|
97
|
-
No `projects
|
|
117
|
+
No `projects use` needed — the active project travels with the repo.
|
|
98
118
|
|
|
99
|
-
### 6.
|
|
100
|
-
|
|
101
|
-
If the project already exists in the dashboard:
|
|
119
|
+
### 6. Use a different cloud project
|
|
102
120
|
|
|
103
121
|
```bash
|
|
104
122
|
voicethere projects list
|
|
105
|
-
voicethere projects use
|
|
106
|
-
git add .voicethere/config.json && git commit -m "chore:
|
|
123
|
+
voicethere projects use <uuid> --slug my-agent --bundle dist/agent.js
|
|
124
|
+
git add .voicethere/config.json && git commit -m "chore: use VoiceThere project"
|
|
107
125
|
```
|
|
108
126
|
|
|
109
|
-
|
|
127
|
+
Re-run `voicethere projects use` with no args to confirm the current project (reads existing config).
|
|
128
|
+
|
|
129
|
+
Inspect the selection anytime:
|
|
110
130
|
|
|
111
131
|
```bash
|
|
112
132
|
voicethere projects show
|
|
@@ -114,18 +134,33 @@ voicethere projects show
|
|
|
114
134
|
|
|
115
135
|
### 7. CI / automation
|
|
116
136
|
|
|
117
|
-
|
|
118
|
-
- **Project:** rely on committed `.voicethere/config.json` — no `--project` in the pipeline.
|
|
119
|
-
- **Override config path:** `VOICETHERE_PROJECT_CONFIG=/path/to/config.json`
|
|
137
|
+
**With committed `.voicethere/config.json`** (typical agent repo):
|
|
120
138
|
|
|
121
139
|
```bash
|
|
122
140
|
voicethere login --api-key "$VOICETHERE_API_KEY"
|
|
123
141
|
npx @voicethere/agent build
|
|
124
142
|
voicethere build upload -m "$GITHUB_SHA — $GITHUB_REF_NAME" --skip-validate
|
|
125
|
-
voicethere build promote <build-uuid>
|
|
143
|
+
voicethere build promote <build-uuid-from-upload>
|
|
126
144
|
```
|
|
127
145
|
|
|
128
|
-
|
|
146
|
+
No `projects use` step — the config file is the active project.
|
|
147
|
+
|
|
148
|
+
**Without a config file** (one-off job cwd):
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
voicethere login --api-key "$VOICETHERE_API_KEY"
|
|
152
|
+
voicethere projects use <project-uuid>
|
|
153
|
+
npx @voicethere/agent build
|
|
154
|
+
voicethere build upload --skip-validate
|
|
155
|
+
voicethere build promote <build-uuid-from-upload>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
Other CI notes:
|
|
159
|
+
|
|
160
|
+
- **Credentials:** `VOICETHERE_CREDENTIALS_PATH` for isolated test runs
|
|
161
|
+
- **Config override:** `VOICETHERE_PROJECT_CONFIG=/path/to/config.json`
|
|
162
|
+
|
|
163
|
+
Split upload and promote across jobs if you want a human approval gate between them.
|
|
129
164
|
|
|
130
165
|
### 8. `deploy` (coming soon)
|
|
131
166
|
|
|
@@ -133,41 +168,32 @@ Split upload and promote in separate jobs if you want a human approval gate betw
|
|
|
133
168
|
|
|
134
169
|
## Repo config (version control)
|
|
135
170
|
|
|
136
|
-
Per-agent-repo
|
|
137
|
-
|
|
138
|
-
| Field | Purpose |
|
|
139
|
-
| ---------------------- | ---------------------------------------------------------- |
|
|
140
|
-
| `project_id` | Platform project UUID — used as default for `build upload` |
|
|
141
|
-
| `project_slug`, `name` | Human-readable metadata (optional) |
|
|
142
|
-
| `bundle` | Default bundle path (default `dist/agent.js`) |
|
|
171
|
+
Per-agent-repo file: **`.voicethere/config.json`**
|
|
143
172
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
export VOICETHERE_PROJECT_CONFIG=/path/to/config.json
|
|
150
|
-
```
|
|
173
|
+
| Field | Purpose |
|
|
174
|
+
| ---------------------- | ---------------------------------------------------- |
|
|
175
|
+
| `project_id` | Active platform project UUID |
|
|
176
|
+
| `project_slug`, `name` | Human-readable metadata (optional) |
|
|
177
|
+
| `bundle` | Default bundle path (default `dist/agent.js`) |
|
|
151
178
|
|
|
152
|
-
**Secrets stay global:** `~/.config/voicethere/credentials.json` (from `voicethere login`).
|
|
153
|
-
Optional gitignored overrides: `.voicethere/local.json` (reserved for future use).
|
|
179
|
+
**Secrets stay global:** `~/.config/voicethere/credentials.json` (from `voicethere login`).
|
|
154
180
|
|
|
155
181
|
Example: [`.voicethere/config.json.example`](./.voicethere/config.json.example)
|
|
156
182
|
|
|
157
183
|
## Commands
|
|
158
184
|
|
|
159
|
-
| Command
|
|
160
|
-
|
|
|
161
|
-
| `login --api-key <key> [--api-base <url>]`
|
|
162
|
-
| `projects list`
|
|
163
|
-
| `projects create
|
|
164
|
-
| `projects use
|
|
165
|
-
| `projects show`
|
|
166
|
-
| `build list
|
|
167
|
-
| `build validate [
|
|
168
|
-
| `build upload [-m <msg>]
|
|
169
|
-
| `build promote
|
|
170
|
-
| `deploy`
|
|
185
|
+
| Command | Description |
|
|
186
|
+
| ---------------------------------------------- | -------------------------------------------------------- |
|
|
187
|
+
| `login --api-key <key> [--api-base <url>]` | Save credentials |
|
|
188
|
+
| `projects list` | List org projects |
|
|
189
|
+
| `projects create <name> [--slug <slug>]` | Create project; uses it (writes config) |
|
|
190
|
+
| `projects use [projectId]` | Use project (picker or existing config when omitted) |
|
|
191
|
+
| `projects show` | Print `.voicethere/config.json` |
|
|
192
|
+
| `build list` | Builds for the active project |
|
|
193
|
+
| `build validate [file]` | Sandbox verify (default bundle from config) |
|
|
194
|
+
| `build upload [file] [-m <msg>]` | Upload to active project |
|
|
195
|
+
| `build promote [buildId]` | Promote on active project (picker when omitted in TTY) |
|
|
196
|
+
| `deploy` | **Coming soon** — promote + cloud rollout + wait |
|
|
171
197
|
|
|
172
198
|
## Development
|
|
173
199
|
|
package/dist/cli.js
CHANGED
|
@@ -16,7 +16,7 @@ async function main() {
|
|
|
16
16
|
program
|
|
17
17
|
.name("voicethere")
|
|
18
18
|
.description("VoiceThere cloud CLI")
|
|
19
|
-
.version("0.
|
|
19
|
+
.version("0.2.0");
|
|
20
20
|
program
|
|
21
21
|
.command("login")
|
|
22
22
|
.description("Store API key and API base URL")
|
|
@@ -40,13 +40,13 @@ async function main() {
|
|
|
40
40
|
projects
|
|
41
41
|
.command("create")
|
|
42
42
|
.description("Create a new project")
|
|
43
|
-
.
|
|
43
|
+
.argument("<name>", "Project display name")
|
|
44
44
|
.option("--slug <slug>", "URL-safe slug (derived from name when omitted)")
|
|
45
45
|
.option("--no-link", "Do not write .voicethere/config.json in the current repo")
|
|
46
46
|
.option("--bundle <path>", "Default bundle path stored in .voicethere/config.json", "dist/agent.js")
|
|
47
|
-
.action(async (options) => {
|
|
47
|
+
.action(async (name, options) => {
|
|
48
48
|
await runProjectsCreate({
|
|
49
|
-
name
|
|
49
|
+
name,
|
|
50
50
|
slug: options.slug,
|
|
51
51
|
link: !options.noLink,
|
|
52
52
|
bundle: options.bundle,
|
|
@@ -54,14 +54,14 @@ async function main() {
|
|
|
54
54
|
});
|
|
55
55
|
projects
|
|
56
56
|
.command("use")
|
|
57
|
-
.description("
|
|
58
|
-
.
|
|
59
|
-
.option("--slug <slug>", "
|
|
60
|
-
.option("--name <name>", "
|
|
57
|
+
.description("Use a project for this repo (.voicethere/config.json)")
|
|
58
|
+
.argument("[projectId]", "Project UUID (interactive picker when omitted in a TTY)")
|
|
59
|
+
.option("--slug <slug>", "Override project slug in local config")
|
|
60
|
+
.option("--name <name>", "Override display name in local config")
|
|
61
61
|
.option("--bundle <path>", "Default bundle path", "dist/agent.js")
|
|
62
|
-
.action(async (options) => {
|
|
62
|
+
.action(async (projectId, options) => {
|
|
63
63
|
await runProjectsUse({
|
|
64
|
-
|
|
64
|
+
projectId,
|
|
65
65
|
slug: options.slug,
|
|
66
66
|
name: options.name,
|
|
67
67
|
bundle: options.bundle,
|
|
@@ -69,7 +69,7 @@ async function main() {
|
|
|
69
69
|
});
|
|
70
70
|
projects
|
|
71
71
|
.command("show")
|
|
72
|
-
.description("Show
|
|
72
|
+
.description("Show the active project (.voicethere/config.json)")
|
|
73
73
|
.action(async () => {
|
|
74
74
|
await runProjectsShow();
|
|
75
75
|
});
|
|
@@ -77,28 +77,25 @@ async function main() {
|
|
|
77
77
|
build
|
|
78
78
|
.command("validate")
|
|
79
79
|
.description("Run @voicethere/agent sandbox verify on a bundle")
|
|
80
|
-
.
|
|
81
|
-
.action(async (
|
|
82
|
-
await runBuildValidate({ file
|
|
80
|
+
.argument("[file]", "Bundle path (default: config bundle or dist/agent.js)")
|
|
81
|
+
.action(async (file) => {
|
|
82
|
+
await runBuildValidate({ file });
|
|
83
83
|
});
|
|
84
84
|
build
|
|
85
85
|
.command("list")
|
|
86
|
-
.description("List uploaded builds (newest first)")
|
|
87
|
-
.
|
|
88
|
-
|
|
89
|
-
await runBuildList({ project: options.project });
|
|
86
|
+
.description("List uploaded builds for the active project (newest first)")
|
|
87
|
+
.action(async () => {
|
|
88
|
+
await runBuildList();
|
|
90
89
|
});
|
|
91
90
|
build
|
|
92
91
|
.command("upload")
|
|
93
92
|
.description("Validate (unless skipped) and upload a bundle")
|
|
94
|
-
.
|
|
95
|
-
.option("--file <path>", "Bundle path (default: config bundle or dist/agent.js)")
|
|
93
|
+
.argument("[file]", "Bundle path (default: config bundle or dist/agent.js)")
|
|
96
94
|
.option("-m, --message <text>", "Build label (like a git commit message)")
|
|
97
95
|
.option("--skip-validate", "Upload without local sandbox verify")
|
|
98
|
-
.action(async (options) => {
|
|
96
|
+
.action(async (file, options) => {
|
|
99
97
|
await runBuildUpload({
|
|
100
|
-
|
|
101
|
-
file: options.file,
|
|
98
|
+
file,
|
|
102
99
|
message: options.message,
|
|
103
100
|
skipValidate: options.skipValidate,
|
|
104
101
|
});
|
|
@@ -106,13 +103,9 @@ async function main() {
|
|
|
106
103
|
build
|
|
107
104
|
.command("promote")
|
|
108
105
|
.description("Set active build in the control plane (platform promote API; no cluster rollout)")
|
|
109
|
-
.argument("
|
|
110
|
-
.
|
|
111
|
-
|
|
112
|
-
await runBuildPromote({
|
|
113
|
-
project: options.project,
|
|
114
|
-
buildId,
|
|
115
|
-
});
|
|
106
|
+
.argument("[buildId]", "Build UUID (interactive picker when omitted in a TTY)")
|
|
107
|
+
.action(async (buildId) => {
|
|
108
|
+
await runBuildPromote({ buildId });
|
|
116
109
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ListOptions {
|
|
2
|
-
|
|
2
|
+
/** Reserved for tests. */
|
|
3
|
+
startDir?: string;
|
|
3
4
|
}
|
|
4
|
-
export declare function runBuildList(options
|
|
5
|
+
export declare function runBuildList(options?: BuildListOptions): Promise<void>;
|
|
5
6
|
//# sourceMappingURL=list.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/build/list.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/commands/build/list.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,gBAAgB;IAC/B,0BAA0B;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAaD,wBAAsB,YAAY,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2BhF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createApi } from "../../lib/api.js";
|
|
2
|
+
import { logResolvedProject } from "../../lib/command-log.js";
|
|
2
3
|
import { requireCredentials } from "../../lib/config.js";
|
|
3
|
-
import {
|
|
4
|
+
import { resolveProjectId } from "../../lib/project-config.js";
|
|
4
5
|
function formatUploadedAt(iso) {
|
|
5
6
|
const date = new Date(iso);
|
|
6
7
|
if (Number.isNaN(date.getTime())) {
|
|
@@ -11,13 +12,14 @@ function formatUploadedAt(iso) {
|
|
|
11
12
|
.replace("T", " ")
|
|
12
13
|
.replace(/\.\d{3}Z$/, " UTC");
|
|
13
14
|
}
|
|
14
|
-
export async function runBuildList(options) {
|
|
15
|
-
const
|
|
15
|
+
export async function runBuildList(options = {}) {
|
|
16
|
+
const project = await resolveProjectId({ startDir: options.startDir });
|
|
17
|
+
logResolvedProject(project);
|
|
16
18
|
const credentials = await requireCredentials();
|
|
17
19
|
const api = createApi(credentials.api_key, credentials.api_base);
|
|
18
|
-
const [
|
|
19
|
-
api.getProject(projectId),
|
|
20
|
-
api.listBuilds(projectId),
|
|
20
|
+
const [platformProject, builds] = await Promise.all([
|
|
21
|
+
api.getProject(project.projectId),
|
|
22
|
+
api.listBuilds(project.projectId),
|
|
21
23
|
]);
|
|
22
24
|
if (builds.length === 0) {
|
|
23
25
|
console.log("No builds uploaded yet.");
|
|
@@ -25,7 +27,7 @@ export async function runBuildList(options) {
|
|
|
25
27
|
}
|
|
26
28
|
console.log("build_id\tuploaded_at\tstatus\tactive\tmessage");
|
|
27
29
|
for (const build of builds) {
|
|
28
|
-
const active =
|
|
30
|
+
const active = platformProject.active_build_id === build.id ? "yes" : "";
|
|
29
31
|
const message = build.message?.replace(/\s+/g, " ").trim() ?? "";
|
|
30
32
|
console.log(`${build.id}\t${formatUploadedAt(build.created_at)}\t${build.validation_status}\t${active}\t${message}`);
|
|
31
33
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/build/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/commands/build/list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAO/D,SAAS,gBAAgB,CAAC,GAAW;IACnC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QACjC,OAAO,GA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gB,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,KAAK,CAAC,iBAAiB,KAAK,MAAM,KAAK,OAAO,EAAE,CACxG,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promote.d.ts","sourceRoot":"","sources":["../../../src/commands/build/promote.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"promote.d.ts","sourceRoot":"","sources":["../../../src/commands/build/promote.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAyDD;;;GAGG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,mBAAmB,GAC3B,OAAO,CAAC,IAAI,CAAC,CAiBf"}
|
|
@@ -1,19 +1,57 @@
|
|
|
1
1
|
import { createApi } from "../../lib/api.js";
|
|
2
|
+
import { logBuildPromoteContext } from "../../lib/command-log.js";
|
|
2
3
|
import { requireCredentials } from "../../lib/config.js";
|
|
3
|
-
import {
|
|
4
|
+
import { isInteractive, promptChoice } from "../../lib/prompt.js";
|
|
5
|
+
import { resolveProjectId } from "../../lib/project-config.js";
|
|
6
|
+
function formatUploadedAt(iso) {
|
|
7
|
+
const date = new Date(iso);
|
|
8
|
+
if (Number.isNaN(date.getTime())) {
|
|
9
|
+
return iso;
|
|
10
|
+
}
|
|
11
|
+
return date
|
|
12
|
+
.toISOString()
|
|
13
|
+
.replace("T", " ")
|
|
14
|
+
.replace(/\.\d{3}Z$/, " UTC");
|
|
15
|
+
}
|
|
16
|
+
function formatBuildChoice(build, activeBuildId) {
|
|
17
|
+
const active = activeBuildId === build.id ? " [active]" : "";
|
|
18
|
+
const message = build.message?.replace(/\s+/g, " ").trim();
|
|
19
|
+
const label = message ? `${message} — ` : "";
|
|
20
|
+
return `${label}${build.id} — ${formatUploadedAt(build.created_at)}${active}`;
|
|
21
|
+
}
|
|
22
|
+
async function resolveBuildId(projectId, buildIdArg) {
|
|
23
|
+
const trimmed = buildIdArg?.trim();
|
|
24
|
+
if (trimmed) {
|
|
25
|
+
return trimmed;
|
|
26
|
+
}
|
|
27
|
+
const credentials = await requireCredentials();
|
|
28
|
+
const api = createApi(credentials.api_key, credentials.api_base);
|
|
29
|
+
const [project, builds] = await Promise.all([
|
|
30
|
+
api.getProject(projectId),
|
|
31
|
+
api.listBuilds(projectId),
|
|
32
|
+
]);
|
|
33
|
+
if (builds.length === 0) {
|
|
34
|
+
throw new Error("No builds uploaded yet. Run: voicethere build upload");
|
|
35
|
+
}
|
|
36
|
+
if (!isInteractive()) {
|
|
37
|
+
throw new Error("Build id required in non-interactive mode. Run: voicethere build promote <buildId>");
|
|
38
|
+
}
|
|
39
|
+
return promptChoice("Select a build to promote", builds.map((build) => ({
|
|
40
|
+
label: formatBuildChoice(build, project.active_build_id),
|
|
41
|
+
value: build.id,
|
|
42
|
+
})));
|
|
43
|
+
}
|
|
4
44
|
/**
|
|
5
45
|
* Promote sets the active build in the control plane (platform `POST …/promote`).
|
|
6
46
|
* Does not roll out to cloud runners — use `voicethere deploy` when available.
|
|
7
47
|
*/
|
|
8
48
|
export async function runBuildPromote(options) {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
const projectId = await requireProjectId({ projectFlag: options.project });
|
|
49
|
+
const project = await resolveProjectId();
|
|
50
|
+
const buildId = await resolveBuildId(project.projectId, options.buildId);
|
|
51
|
+
logBuildPromoteContext(buildId, project);
|
|
14
52
|
const credentials = await requireCredentials();
|
|
15
53
|
const api = createApi(credentials.api_key, credentials.api_base);
|
|
16
|
-
const result = await api.promote(projectId, buildId);
|
|
54
|
+
const result = await api.promote(project.projectId, buildId);
|
|
17
55
|
console.log(`Promoted build ${result.active_build_id} for project ${result.project_id}`);
|
|
18
56
|
console.log(`Active artifact: ${result.active_storage_path}`);
|
|
19
57
|
console.log("Control plane updated — cloud runner rollout is not available yet (future: voicethere deploy --wait).");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"promote.js","sourceRoot":"","sources":["../../../src/commands/build/promote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"promote.js","sourceRoot":"","sources":["../../../src/commands/build/promote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAc,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAM/D,SAAS,gBAAgB,CAAC,GAAW;IACnC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC;QACjC,OAAO,GAAG,CAAC;IACb,CAAC;IACD,OAAO,IAAI;SACR,WAAW,EAAE;SACb,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;SACjB,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;AAClC,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAY,EAAE,aAA4B;IACnE,MAAM,MAAM,GAAG,aAAa,KAAK,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7D,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAC3D,MAAM,KAAK,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7C,OAAO,GAAG,KAAK,GAAG,KAAK,CAAC,EAAE,MAAM,gBAAgB,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AC;IACzE,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAEzC,MAAM,WAAW,GAAG,MAAM,kBAAkB,EAAE,CAAC;IAC/C,MAAM,GAAG,GAAG,SAAS,CAAC,WAAW,CAAC,OAAO,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;IAEjE,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAE7D,OAAO,CAAC,GAAG,CACT,kBAAkB,MAAM,CAAC,eAAe,gBAAgB,MAAM,CAAC,UAAU,EAAE,CAC5E,CAAC;IACF,OAAO,CAAC,GAAG,CAAC,oBAAoB,MAAM,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAC9D,OAAO,CAAC,GAAG,CACT,uGAAuG,CACxG,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../src/commands/build/upload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../src/commands/build/upload.ts"],"names":[],"mappings":"AAWA,OAAO,EAAoB,KAAK,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE5E,MAAM,WAAW,kBAAmB,SAAQ,oBAAoB;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC,CA4Bf"}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
import { createApi } from "../../lib/api.js";
|
|
2
|
+
import { logResolvedBundle, logResolvedProject, } from "../../lib/command-log.js";
|
|
2
3
|
import { requireCredentials } from "../../lib/config.js";
|
|
3
|
-
import {
|
|
4
|
+
import { assertBundleExists, resolveBundlePathDetailed, resolveProjectId, } from "../../lib/project-config.js";
|
|
4
5
|
import { runBuildValidate } from "./validate.js";
|
|
5
6
|
export async function runBuildUpload(options) {
|
|
6
|
-
const
|
|
7
|
-
const
|
|
7
|
+
const project = await resolveProjectId();
|
|
8
|
+
const bundle = await resolveBundlePathDetailed(options.file);
|
|
9
|
+
logResolvedProject(project);
|
|
10
|
+
logResolvedBundle(bundle);
|
|
8
11
|
if (!options.skipValidate) {
|
|
9
|
-
await runBuildValidate({ file:
|
|
12
|
+
await runBuildValidate({ file: options.file, logContext: false });
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
await assertBundleExists(bundle.absolutePath);
|
|
10
16
|
}
|
|
11
17
|
const credentials = await requireCredentials();
|
|
12
18
|
const api = createApi(credentials.api_key, credentials.api_base);
|
|
13
|
-
const build = await api.uploadBuild(projectId,
|
|
19
|
+
const build = await api.uploadBuild(project.projectId, bundle.absolutePath, options.message);
|
|
14
20
|
console.log(`Uploaded build ${build.id}`);
|
|
15
21
|
if (build.message) {
|
|
16
22
|
console.log(`Message: ${build.message}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.js","sourceRoot":"","sources":["../../../src/commands/build/upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,
|
|
1
|
+
{"version":3,"file":"upload.js","sourceRoot":"","sources":["../../../src/commands/build/upload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EACL,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EACL,kBAAkB,EAClB,yBAAyB,EACzB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAA6B,MAAM,eAAe,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C;AACxD,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare const DEFAULT_BUNDLE_PATH = "dist/agent.js";
|
|
2
2
|
export interface BuildValidateOptions {
|
|
3
3
|
file?: string;
|
|
4
|
+
/** When false, skip startup path logging (caller already logged). Default true. */
|
|
5
|
+
logContext?: boolean;
|
|
4
6
|
}
|
|
5
7
|
export declare function runBuildValidate(options: BuildValidateOptions): Promise<void>;
|
|
6
8
|
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/commands/build/validate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/commands/build/validate.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,mBAAmB,kBAAkB,CAAC;AAEnD,MAAM,WAAW,oBAAoB;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mFAAmF;IACnF,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAQf"}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import { access } from "node:fs/promises";
|
|
2
1
|
import { spawn } from "node:child_process";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { logResolvedBundle } from "../../lib/command-log.js";
|
|
3
|
+
import { assertBundleExists, resolveBundlePathDetailed, } from "../../lib/project-config.js";
|
|
5
4
|
export const DEFAULT_BUNDLE_PATH = "dist/agent.js";
|
|
6
5
|
export async function runBuildValidate(options) {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
console.log(`Bundle validated: ${bundlePath}`);
|
|
11
|
-
}
|
|
12
|
-
async function assertBundleExists(bundlePath) {
|
|
13
|
-
try {
|
|
14
|
-
await access(bundlePath, constants.R_OK);
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
throw new Error(`Bundle not found or not readable: ${bundlePath} — run: npx @voicethere/agent build`);
|
|
6
|
+
const bundle = await resolveBundlePathDetailed(options.file);
|
|
7
|
+
if (options.logContext !== false) {
|
|
8
|
+
logResolvedBundle(bundle);
|
|
18
9
|
}
|
|
10
|
+
await assertBundleExists(bundle.absolutePath);
|
|
11
|
+
await spawnAgentVerify(bundle.absolutePath);
|
|
12
|
+
console.log(`Bundle validated: ${bundle.absolutePath}`);
|
|
19
13
|
}
|
|
20
14
|
async function spawnAgentVerify(bundlePath) {
|
|
21
15
|
return new Promise((resolve, reject) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/commands/build/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/commands/build/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EACL,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,6BAA6B,CAAC;AAErC,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAQnD,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAA6B;IAE7B,MAAM,MAAM,GAAG,MAAM,yBAAyB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,IAAI,OAAO,CAAC,UAAU,KAAK,KAAK,EAAE,CAAC;QACjC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IACD,MAAM,kBAAkB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC9C,MAAM,gBAAgB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC5C,OAAO,CAAC,GAAG,CAAC,qBAAqB,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;AAC1D,CAAC;AAED,KAAK,UAAU,gBAAgB,CAAC,UAAkB;IAChD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,KAAK,GAAG,KAAK,CACjB,KAAK,EACL,CAAC,mBAAmB,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,CAAC,EACrE;YACE,KAAK,EAAE,SAAS;YAChB,KAAK,EAAE,OAAO,CAAC,QAAQ,KAAK,OAAO;SACpC,CACF,CAAC;QAEF,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YAC1B,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YACzB,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,OAAO,EAAE,CAAC;gBACV,OAAO;YACT,CAAC;YACD,MAAM,CACJ,IAAI,KAAK,CAAC,sCAAsC,IAAI,IAAI,SAAS,EAAE,CAAC,CACrE,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAsB,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBnE"}
|
package/dist/commands/login.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { logCommandInfo } from "../lib/command-log.js";
|
|
2
|
+
import { DEFAULT_API_BASE, getCredentialsPath, writeCredentials, } from "../lib/config.js";
|
|
2
3
|
export async function runLogin(options) {
|
|
3
4
|
const apiKey = options.apiKey.trim();
|
|
4
5
|
if (!apiKey) {
|
|
5
6
|
throw new Error("--api-key is required");
|
|
6
7
|
}
|
|
7
8
|
const apiBase = (options.apiBase?.trim() || DEFAULT_API_BASE).replace(/\/$/, "");
|
|
9
|
+
const credentialsPath = getCredentialsPath();
|
|
10
|
+
logCommandInfo(`credentials: ${credentialsPath}`);
|
|
8
11
|
await writeCredentials({
|
|
9
12
|
api_key: apiKey,
|
|
10
13
|
api_base: apiBase,
|
|
11
14
|
});
|
|
12
|
-
console.log(`Saved credentials to
|
|
15
|
+
console.log(`Saved credentials to ${credentialsPath} (api_base=${apiBase})`);
|
|
13
16
|
}
|
|
14
17
|
//# sourceMappingURL=login.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAO1B,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,OAAqB;IAClD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IACrC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,gBAAgB,CAAC,CAAC,OAAO,CACnE,KAAK,EACL,EAAE,CACH,CAAC;IAEF,MAAM,eAAe,GAAG,kBAAkB,EAAE,CAAC;IAC7C,cAAc,CAAC,gBAAgB,eAAe,EAAE,CAAC,CAAC;IAElD,MAAM,gBAAgB,CAAC;QACrB,OAAO,EAAE,MAAM;QACf,QAAQ,EAAE,OAAO;KAClB,CAAC,CAAC;IAEH,OAAO,CAAC,GAAG,CAAC,wBAAwB,eAAe,cAAc,OAAO,GAAG,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/projects/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/commands/projects/create.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAOhD;AAED,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,IAAI,CAAC,CAiCf"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createApi } from "../../lib/api.js";
|
|
2
2
|
import { requireCredentials } from "../../lib/config.js";
|
|
3
|
+
import { logCommandInfo } from "../../lib/command-log.js";
|
|
3
4
|
import { writeProjectConfig } from "../../lib/project-config.js";
|
|
4
5
|
export function slugifyName(name) {
|
|
5
6
|
return name
|
|
@@ -12,7 +13,7 @@ export function slugifyName(name) {
|
|
|
12
13
|
export async function runProjectsCreate(options) {
|
|
13
14
|
const name = options.name.trim();
|
|
14
15
|
if (!name) {
|
|
15
|
-
throw new Error("
|
|
16
|
+
throw new Error("project name is required");
|
|
16
17
|
}
|
|
17
18
|
const slug = (options.slug?.trim() || slugifyName(name)).replace(/^-+|-+$/g, "");
|
|
18
19
|
if (!slug) {
|
|
@@ -29,7 +30,8 @@ export async function runProjectsCreate(options) {
|
|
|
29
30
|
name: project.name,
|
|
30
31
|
bundle: options.bundle?.trim() || undefined,
|
|
31
32
|
});
|
|
32
|
-
|
|
33
|
+
logCommandInfo(`project config: ${configPath}`);
|
|
34
|
+
console.error(`Using project ${project.name} (${project.id}) — commit ${configPath}`);
|
|
33
35
|
}
|
|
34
36
|
console.log(JSON.stringify(project, null, 2));
|
|
35
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/projects/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAUjE,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,IAAI;SACR,IAAI,EAAE;SACN,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;SACvB,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAClB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,OAA8B;IAE9B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACjC,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/commands/projects/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,O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OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,SAAS;SAC5C,CAAC,CAAC;QACH,cAAc,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAC;QAChD,OAAO,CAAC,KAAK,CACX,iBAAiB,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,EAAE,cAAc,UAAU,EAAE,CACvE,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -3,7 +3,7 @@ export async function runProjectsShow() {
|
|
|
3
3
|
const path = await findProjectConfigPath();
|
|
4
4
|
if (!path) {
|
|
5
5
|
console.log("No .voicethere/config.json found in this directory or parents.");
|
|
6
|
-
console.log("Run: voicethere projects use
|
|
6
|
+
console.log("Run: voicethere projects use <projectId>");
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
9
|
const linked = await readProjectConfig();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"show.js","sourceRoot":"","sources":["../../../src/commands/projects/show.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEvF,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,MAAM,IAAI,GAAG,MAAM,qBAAqB,EAAE,CAAC;IAC3C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,CAAC,GAAG,CAAC,gEAAgE,CAAC,CAAC;QAC9E,OAAO,CAAC,GAAG,CAAC
|
|
1
|
+
{"version":3,"file":"show.js","sourceRoot":"","sources":["../../../src/commands/projects/show.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEvF,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,MAAM,IAAI,GAAG,MAAM,qBAAqB,EAAE,CAAC;IAC3C,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,CAAC,GAAG,CAAC,gEAAgE,CAAC,CAAC;QAC9E,OAAO,CAAC,GAAG,CAAC,0CAA0C,CAAC,CAAC;QACxD,OAAO;IACT,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,iBAAiB,EAAE,CAAC;IACzC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,OAAO,CAAC,GAAG,CACT,IAAI,CAAC,SAAS,CACZ;QACE,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,GAAG,MAAM,CAAC,MAAM;KACjB,EACD,IAAI,EACJ,CAAC,CACF,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export interface ProjectsUseOptions {
|
|
2
|
-
|
|
2
|
+
projectId?: string;
|
|
3
3
|
slug?: string;
|
|
4
4
|
name?: string;
|
|
5
5
|
bundle?: string;
|
|
6
|
+
startDir?: string;
|
|
6
7
|
}
|
|
7
8
|
export declare function runProjectsUse(options: ProjectsUseOptions): Promise<void>;
|
|
8
9
|
//# sourceMappingURL=use.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../../../src/commands/projects/use.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../../../src/commands/projects/use.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,kBAAkB;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAwDD,wBAAsB,cAAc,CAClC,OAAO,EAAE,kBAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAuCf"}
|
|
@@ -1,15 +1,70 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { createApi } from "../../lib/api.js";
|
|
2
|
+
import { logCommandInfo } from "../../lib/command-log.js";
|
|
3
|
+
import { requireCredentials } from "../../lib/config.js";
|
|
4
|
+
import { isInteractive, promptChoice } from "../../lib/prompt.js";
|
|
5
|
+
import { readProjectConfig, writeProjectConfig, } from "../../lib/project-config.js";
|
|
6
|
+
function formatProjectChoice(project) {
|
|
7
|
+
const active = project.active_build_id
|
|
8
|
+
? `active=${project.active_build_id.slice(0, 8)}…`
|
|
9
|
+
: "no active build";
|
|
10
|
+
return `${project.name} (${project.slug}) — ${project.id} — ${active}`;
|
|
11
|
+
}
|
|
12
|
+
async function resolveProjectToUse(api, options) {
|
|
13
|
+
const trimmed = options.projectId?.trim();
|
|
14
|
+
if (trimmed) {
|
|
15
|
+
return { project: await api.getProject(trimmed), fromExistingConfig: false };
|
|
16
|
+
}
|
|
17
|
+
const linked = await readProjectConfig(options.startDir);
|
|
18
|
+
if (linked?.config.project_id) {
|
|
19
|
+
logCommandInfo(`using project from ${linked.path}`);
|
|
20
|
+
return {
|
|
21
|
+
project: await api.getProject(linked.config.project_id),
|
|
22
|
+
fromExistingConfig: true,
|
|
23
|
+
configPath: linked.path,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (!isInteractive()) {
|
|
27
|
+
throw new Error("No .voicethere/config.json found. Run: voicethere projects use <projectId>");
|
|
28
|
+
}
|
|
29
|
+
const projects = await api.listProjects();
|
|
30
|
+
if (projects.length === 0) {
|
|
31
|
+
throw new Error("No projects found. Create one with: voicethere projects create \"My Agent\"");
|
|
6
32
|
}
|
|
33
|
+
const selectedId = await promptChoice("Choose a project", projects.map((project) => ({
|
|
34
|
+
label: formatProjectChoice(project),
|
|
35
|
+
value: project.id,
|
|
36
|
+
})));
|
|
37
|
+
const selected = projects.find((project) => project.id === selectedId);
|
|
38
|
+
if (!selected) {
|
|
39
|
+
throw new Error("Selected project not found.");
|
|
40
|
+
}
|
|
41
|
+
return { project: selected, fromExistingConfig: false };
|
|
42
|
+
}
|
|
43
|
+
export async function runProjectsUse(options) {
|
|
44
|
+
const credentials = await requireCredentials();
|
|
45
|
+
const api = createApi(credentials.api_key, credentials.api_base);
|
|
46
|
+
const linked = await readProjectConfig(options.startDir);
|
|
47
|
+
const { project, fromExistingConfig, configPath } = await resolveProjectToUse(api, options);
|
|
48
|
+
const bundle = options.bundle?.trim() || linked?.config.bundle?.trim() || undefined;
|
|
49
|
+
logCommandInfo(`project: ${project.id} (${project.name})`);
|
|
7
50
|
const path = await writeProjectConfig({
|
|
8
|
-
project_id:
|
|
9
|
-
project_slug: options.slug?.trim() ||
|
|
10
|
-
name: options.name?.trim() ||
|
|
11
|
-
bundle
|
|
51
|
+
project_id: project.id,
|
|
52
|
+
project_slug: options.slug?.trim() || project.slug,
|
|
53
|
+
name: options.name?.trim() || project.name,
|
|
54
|
+
bundle,
|
|
55
|
+
}, {
|
|
56
|
+
startDir: options.startDir,
|
|
57
|
+
path: fromExistingConfig ? configPath : undefined,
|
|
12
58
|
});
|
|
13
|
-
|
|
59
|
+
if (bundle) {
|
|
60
|
+
logCommandInfo(`default bundle: ${bundle}`);
|
|
61
|
+
}
|
|
62
|
+
logCommandInfo(`project config: ${path}`);
|
|
63
|
+
if (fromExistingConfig) {
|
|
64
|
+
console.log(`Using project ${project.name} (${project.id}) from ${path}`);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
console.log(`Using project ${project.name} (${project.id})`);
|
|
68
|
+
console.log(`Saved ${path}`);
|
|
14
69
|
}
|
|
15
70
|
//# sourceMappingURL=use.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use.js","sourceRoot":"","sources":["../../../src/commands/projects/use.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA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olvedProjectId } from "./project-config.js";
|
|
2
|
+
export declare function logCommandInfo(message: string): void;
|
|
3
|
+
export declare function logResolvedBundle(bundle: ResolvedBundlePath): void;
|
|
4
|
+
export declare function logResolvedProject(project: ResolvedProjectId): void;
|
|
5
|
+
export declare function logBuildPromoteContext(buildId: string, project: ResolvedProjectId): void;
|
|
6
|
+
//# sourceMappingURL=command-log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-log.d.ts","sourceRoot":"","sources":["../../src/lib/command-log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAEjF,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEpD;AAmBD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAIlE;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAInE;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,iBAAiB,GACzB,IAAI,CAGN"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export function logCommandInfo(message) {
|
|
2
|
+
console.error(`[voicethere] ${message}`);
|
|
3
|
+
}
|
|
4
|
+
function describeBundleSource(bundle) {
|
|
5
|
+
switch (bundle.source) {
|
|
6
|
+
case "argument":
|
|
7
|
+
return "CLI argument";
|
|
8
|
+
case "config":
|
|
9
|
+
return bundle.configPath
|
|
10
|
+
? `project config (${bundle.configPath})`
|
|
11
|
+
: "project config";
|
|
12
|
+
case "default":
|
|
13
|
+
return "default (dist/agent.js)";
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function describeProjectSource(project) {
|
|
17
|
+
return `project config (${project.configPath})`;
|
|
18
|
+
}
|
|
19
|
+
export function logResolvedBundle(bundle) {
|
|
20
|
+
logCommandInfo(`bundle: ${bundle.absolutePath} (${describeBundleSource(bundle)})`);
|
|
21
|
+
}
|
|
22
|
+
export function logResolvedProject(project) {
|
|
23
|
+
logCommandInfo(`project: ${project.projectId} (${describeProjectSource(project)})`);
|
|
24
|
+
}
|
|
25
|
+
export function logBuildPromoteContext(buildId, project) {
|
|
26
|
+
logCommandInfo(`build: ${buildId}`);
|
|
27
|
+
logResolvedProject(project);
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=command-log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-log.js","sourceRoot":"","sources":["../../src/lib/command-log.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,cAAc,CAAC,OAAe;IAC5C,OAAO,CAAC,KAAK,CAAC,gBAAgB,OAAO,EAAE,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,oBAAoB,CAAC,MAA0B;IACtD,QAAQ,MAAM,CAAC,MAAM,EAAE,CAAC;QACtB,KAAK,UAAU;YACb,OAAO,cAAc,CAAC;QACxB,KAAK,QAAQ;YACX,OAAO,MAAM,CAAC,UAAU;gBACtB,CAAC,CAAC,mBAAmB,MAAM,CAAC,UAAU,GAAG;gBACzC,CAAC,CAAC,gBAAgB,CAAC;QACvB,KAAK,SAAS;YACZ,OAAO,yBAAyB,CAAC;IACrC,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAAC,OAA0B;IACvD,OAAO,mBAAmB,OAAO,CAAC,UAAU,GAAG,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAA0B;IAC1D,cAAc,CACZ,WAAW,MAAM,CAAC,YAAY,KAAK,oBAAoB,CAAC,MAAM,CAAC,GAAG,CACnE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAA0B;IAC3D,cAAc,CACZ,YAAY,OAAO,CAAC,SAAS,KAAK,qBAAqB,CAAC,OAAO,CAAC,GAAG,CACpE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,sBAAsB,CACpC,OAAe,EACf,OAA0B;IAE1B,cAAc,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC;IACpC,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const PROJECT_CONFIG_DIR = ".voicethere";
|
|
2
2
|
export declare const PROJECT_CONFIG_FILENAME = "config.json";
|
|
3
|
+
export declare const DEFAULT_BUNDLE = "dist/agent.js";
|
|
3
4
|
export interface ProjectConfig {
|
|
4
5
|
/** Platform project UUID — safe to commit; links this repo to a cloud project. */
|
|
5
6
|
project_id: string;
|
|
@@ -15,7 +16,23 @@ export interface ProjectConfigFile {
|
|
|
15
16
|
name?: string;
|
|
16
17
|
bundle?: string;
|
|
17
18
|
}
|
|
19
|
+
export type BundlePathSource = "argument" | "config" | "default";
|
|
20
|
+
export interface ResolvedBundlePath {
|
|
21
|
+
relativePath: string;
|
|
22
|
+
absolutePath: string;
|
|
23
|
+
source: BundlePathSource;
|
|
24
|
+
configPath?: string;
|
|
25
|
+
}
|
|
26
|
+
export type ProjectIdSource = "config";
|
|
27
|
+
export interface ResolvedProjectId {
|
|
28
|
+
projectId: string;
|
|
29
|
+
source: ProjectIdSource;
|
|
30
|
+
configPath: string;
|
|
31
|
+
}
|
|
32
|
+
export declare const NO_PROJECT_SELECTED_MESSAGE = "No project selected. Commit .voicethere/config.json in this repo or run: voicethere projects use <projectId>";
|
|
18
33
|
export declare function getProjectConfigOverridePath(): string | null;
|
|
34
|
+
/** Repo root: parent of `.voicethere/` containing config.json. */
|
|
35
|
+
export declare function repoRootFromConfigPath(configPath: string): string;
|
|
19
36
|
/** Walk upward from startDir to find `.voicethere/config.json`. */
|
|
20
37
|
export declare function findProjectConfigPath(startDir?: string): Promise<string | null>;
|
|
21
38
|
export declare function parseProjectConfig(raw: string): ProjectConfig;
|
|
@@ -23,14 +40,19 @@ export declare function readProjectConfig(startDir?: string): Promise<{
|
|
|
23
40
|
config: ProjectConfig;
|
|
24
41
|
path: string;
|
|
25
42
|
} | null>;
|
|
26
|
-
export declare function
|
|
27
|
-
|
|
43
|
+
export declare function resolveProjectId(options?: {
|
|
44
|
+
startDir?: string;
|
|
45
|
+
}): Promise<ResolvedProjectId>;
|
|
46
|
+
export declare function requireProjectId(options?: {
|
|
28
47
|
startDir?: string;
|
|
29
48
|
}): Promise<string>;
|
|
30
49
|
export declare function writeProjectConfig(config: ProjectConfig, options?: {
|
|
31
50
|
startDir?: string;
|
|
32
51
|
path?: string;
|
|
33
52
|
}): Promise<string>;
|
|
34
|
-
/** Bundle path: CLI
|
|
35
|
-
export declare function
|
|
53
|
+
/** Bundle path: CLI arg → `.voicethere/config.json` bundle → default `dist/agent.js`. */
|
|
54
|
+
export declare function resolveBundlePathDetailed(fileArg?: string, startDir?: string): Promise<ResolvedBundlePath>;
|
|
55
|
+
/** @deprecated Prefer resolveBundlePathDetailed for logging and absolute paths. */
|
|
56
|
+
export declare function resolveBundlePath(fileArg?: string, startDir?: string): Promise<string>;
|
|
57
|
+
export declare function assertBundleExists(absolutePath: string): Promise<void>;
|
|
36
58
|
//# sourceMappingURL=project-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-config.d.ts","sourceRoot":"","sources":["../../src/lib/project-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"project-config.d.ts","sourceRoot":"","sources":["../../src/lib/project-config.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,gBAAgB,CAAC;AAChD,eAAO,MAAM,uBAAuB,gBAAgB,CAAC;AACrD,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B,kFAAkF;IAClF,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,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AED,wBAAsB,gBAAgB,CAAC,OAAO,CAAC,EAAE;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC,MAAM,CAAC,CAGlB;AAED,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,aAAa,EACrB,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAO,GACjD,OAAO,CAAC,MAAM,CAAC,CAuBjB;AAED,yFAAyF;AACzF,wBAAsB,yBAAyB,CAC7C,OAAO,CAAC,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,kBAAkB,CAAC,CAsB7B;AAED,mFAAmF;AACnF,wBAAsB,iBAAiB,CACrC,OAAO,CAAC,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAGjB;AAED,wBAAsB,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ5E"}
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { access, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { constants } from "node:fs";
|
|
2
3
|
import { dirname, join, resolve } from "node:path";
|
|
3
4
|
export const PROJECT_CONFIG_DIR = ".voicethere";
|
|
4
5
|
export const PROJECT_CONFIG_FILENAME = "config.json";
|
|
6
|
+
export const DEFAULT_BUNDLE = "dist/agent.js";
|
|
7
|
+
export const NO_PROJECT_SELECTED_MESSAGE = "No project selected. Commit .voicethere/config.json in this repo or run: voicethere projects use <projectId>";
|
|
5
8
|
export function getProjectConfigOverridePath() {
|
|
6
9
|
const override = process.env.VOICETHERE_PROJECT_CONFIG?.trim();
|
|
7
10
|
return override || null;
|
|
8
11
|
}
|
|
12
|
+
/** Repo root: parent of `.voicethere/` containing config.json. */
|
|
13
|
+
export function repoRootFromConfigPath(configPath) {
|
|
14
|
+
return dirname(dirname(configPath));
|
|
15
|
+
}
|
|
9
16
|
/** Walk upward from startDir to find `.voicethere/config.json`. */
|
|
10
17
|
export async function findProjectConfigPath(startDir = process.cwd()) {
|
|
11
18
|
const override = getProjectConfigOverridePath();
|
|
@@ -66,16 +73,20 @@ export async function readProjectConfig(startDir) {
|
|
|
66
73
|
const raw = await readFile(path, "utf8");
|
|
67
74
|
return { config: parseProjectConfig(raw), path };
|
|
68
75
|
}
|
|
69
|
-
export async function
|
|
70
|
-
const
|
|
71
|
-
if (fromFlag) {
|
|
72
|
-
return fromFlag;
|
|
73
|
-
}
|
|
74
|
-
const linked = await readProjectConfig(options.startDir);
|
|
76
|
+
export async function resolveProjectId(options) {
|
|
77
|
+
const linked = await readProjectConfig(options?.startDir);
|
|
75
78
|
if (linked?.config.project_id) {
|
|
76
|
-
return
|
|
79
|
+
return {
|
|
80
|
+
projectId: linked.config.project_id,
|
|
81
|
+
source: "config",
|
|
82
|
+
configPath: linked.path,
|
|
83
|
+
};
|
|
77
84
|
}
|
|
78
|
-
throw new Error(
|
|
85
|
+
throw new Error(NO_PROJECT_SELECTED_MESSAGE);
|
|
86
|
+
}
|
|
87
|
+
export async function requireProjectId(options) {
|
|
88
|
+
const resolved = await resolveProjectId(options);
|
|
89
|
+
return resolved.projectId;
|
|
79
90
|
}
|
|
80
91
|
export async function writeProjectConfig(config, options = {}) {
|
|
81
92
|
const dir = resolve(options.startDir ?? process.cwd());
|
|
@@ -97,17 +108,38 @@ export async function writeProjectConfig(config, options = {}) {
|
|
|
97
108
|
await writeFile(path, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
|
|
98
109
|
return path;
|
|
99
110
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
105
|
-
return
|
|
111
|
+
/** Bundle path: CLI arg → `.voicethere/config.json` bundle → default `dist/agent.js`. */
|
|
112
|
+
export async function resolveBundlePathDetailed(fileArg, startDir) {
|
|
113
|
+
const cwd = resolve(startDir ?? process.cwd());
|
|
114
|
+
const fromArg = fileArg?.trim();
|
|
115
|
+
if (fromArg) {
|
|
116
|
+
return {
|
|
117
|
+
relativePath: fromArg,
|
|
118
|
+
absolutePath: resolve(cwd, fromArg),
|
|
119
|
+
source: "argument",
|
|
120
|
+
};
|
|
106
121
|
}
|
|
107
122
|
const linked = await readProjectConfig(startDir);
|
|
108
|
-
|
|
109
|
-
|
|
123
|
+
const relativePath = linked?.config.bundle?.trim() || DEFAULT_BUNDLE;
|
|
124
|
+
const baseDir = linked ? repoRootFromConfigPath(linked.path) : cwd;
|
|
125
|
+
return {
|
|
126
|
+
relativePath,
|
|
127
|
+
absolutePath: resolve(baseDir, relativePath),
|
|
128
|
+
source: linked?.config.bundle ? "config" : "default",
|
|
129
|
+
configPath: linked?.path,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/** @deprecated Prefer resolveBundlePathDetailed for logging and absolute paths. */
|
|
133
|
+
export async function resolveBundlePath(fileArg, startDir) {
|
|
134
|
+
const resolved = await resolveBundlePathDetailed(fileArg, startDir);
|
|
135
|
+
return resolved.absolutePath;
|
|
136
|
+
}
|
|
137
|
+
export async function assertBundleExists(absolutePath) {
|
|
138
|
+
try {
|
|
139
|
+
await access(absolutePath, constants.R_OK);
|
|
140
|
+
}
|
|
141
|
+
catch {
|
|
142
|
+
throw new Error(`Bundle not found or not readable: ${absolutePath} — run: npx @voicethere/agent build`);
|
|
110
143
|
}
|
|
111
|
-
return DEFAULT_BUNDLE;
|
|
112
144
|
}
|
|
113
145
|
//# sourceMappingURL=project-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-config.js","sourceRoot":"","sources":["../../src/lib/project-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE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,30 @@
|
|
|
1
|
+
import * as readline from "node:readline/promises";
|
|
2
|
+
export function isInteractive() {
|
|
3
|
+
return Boolean(process.stdin.isTTY && process.stdout.isTTY);
|
|
4
|
+
}
|
|
5
|
+
export async function promptChoice(prompt, choices) {
|
|
6
|
+
if (choices.length === 0) {
|
|
7
|
+
throw new Error("No choices available.");
|
|
8
|
+
}
|
|
9
|
+
for (const [index, choice] of choices.entries()) {
|
|
10
|
+
console.error(` ${index + 1}. ${choice.label}`);
|
|
11
|
+
}
|
|
12
|
+
const rl = readline.createInterface({
|
|
13
|
+
input: process.stdin,
|
|
14
|
+
output: process.stderr,
|
|
15
|
+
});
|
|
16
|
+
try {
|
|
17
|
+
while (true) {
|
|
18
|
+
const answer = await rl.question(`${prompt} [1-${choices.length}]: `);
|
|
19
|
+
const index = Number.parseInt(answer.trim(), 10);
|
|
20
|
+
if (index >= 1 && index <= choices.length) {
|
|
21
|
+
return choices[index - 1].value;
|
|
22
|
+
}
|
|
23
|
+
console.error("Invalid choice — enter a number from the list.");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
rl.close();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../../src/lib/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AAOnD,MAAM,UAAU,aAAa;IAC3B,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAc,EACd,OAAuB;IAEvB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;IAC3C,C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