@dmrlzz/davecode 0.5.0 → 0.5.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/dist/{ChatApp-CJBICQGA.js → ChatApp-Z6PQIZ5J.js} +7 -6
- package/dist/{ChatApp-CJBICQGA.js.map → ChatApp-Z6PQIZ5J.js.map} +1 -1
- package/dist/{account-QWDPJWAA.js → account-RTPS2V6O.js} +4 -3
- package/dist/{accounts-IQMR72FC.js → accounts-IYQ4ZRL7.js} +6 -5
- package/dist/{budget-XANOUVWO.js → budget-N2ZB66FF.js} +5 -4
- package/dist/{budget-XANOUVWO.js.map → budget-N2ZB66FF.js.map} +1 -1
- package/dist/{chat-KDDRNC5V.js → chat-6TX6JX45.js} +9 -8
- package/dist/{chat-KDDRNC5V.js.map → chat-6TX6JX45.js.map} +1 -1
- package/dist/chunk-732GIHRQ.js +23 -0
- package/dist/chunk-732GIHRQ.js.map +1 -0
- package/dist/{chunk-AZKACMME.js → chunk-BJTXMET2.js} +2 -2
- package/dist/{chunk-FYPMA55O.js → chunk-KUY3QHGS.js} +239 -106
- package/dist/chunk-KUY3QHGS.js.map +1 -0
- package/dist/{chunk-JLATEHS7.js → chunk-LEU46DGH.js} +2 -2
- package/dist/{chunk-HSBJDV3O.js → chunk-QKY3OKVG.js} +309 -23
- package/dist/chunk-QKY3OKVG.js.map +1 -0
- package/dist/{chunk-WQ7MEWDF.js → chunk-UEV5K3DH.js} +10 -4
- package/dist/chunk-UEV5K3DH.js.map +1 -0
- package/dist/{chunk-44AFJL2X.js → chunk-UNK3EQD6.js} +6 -5
- package/dist/chunk-UNK3EQD6.js.map +1 -0
- package/dist/{chunk-W7GPBEBZ.js → chunk-WAARDGCZ.js} +5 -21
- package/dist/chunk-WAARDGCZ.js.map +1 -0
- package/dist/{chunk-PGAJIGUF.js → chunk-YNAMNQLW.js} +3 -3
- package/dist/{config-YTUPIYZT.js → config-YQKY2AA4.js} +4 -3
- package/dist/{config-YTUPIYZT.js.map → config-YQKY2AA4.js.map} +1 -1
- package/dist/dashboard/assets/Accounts-DXiGsutB.js +1 -0
- package/dist/dashboard/assets/{Badge-Z4RBdO9j.js → Badge-DUGKlx3Z.js} +1 -1
- package/dist/dashboard/assets/{Callout-w8BTYh4k.js → Callout-1E8Wsl9W.js} +1 -1
- package/dist/dashboard/assets/{Goals-Bw02to72.js → Goals-kL4VAxw3.js} +1 -1
- package/dist/dashboard/assets/{Library-DK7mlpRb.js → Library-DZxBVUo_.js} +1 -1
- package/dist/dashboard/assets/Markdown-CGgIydUh.js +71 -0
- package/dist/dashboard/assets/{Panes-_KTf8pbZ.js → Panes-C-TJekjs.js} +1 -1
- package/dist/dashboard/assets/{RoutesPage-QV0oPRW9.js → RoutesPage-DWYm9tW8.js} +1 -1
- package/dist/dashboard/assets/{Runner-CkHBLQl0.js → Runner-CmHBjECR.js} +1 -1
- package/dist/dashboard/assets/{Settings-BLz2gTBR.js → Settings-BANphxva.js} +1 -1
- package/dist/dashboard/assets/{Tasks-BiUQSTpt.js → Tasks-cSx1PKyQ.js} +1 -1
- package/dist/dashboard/assets/{Traffic-BVfBuC70.js → Traffic-DEAuM6jq.js} +1 -1
- package/dist/dashboard/assets/{Workspace-CJTgiiU5.js → Workspace-BQFjc1jH.js} +1 -1
- package/dist/dashboard/assets/index-B8kld9xo.js +104 -0
- package/dist/dashboard/assets/{task-errors-Daqwi0ue.js → task-errors-r-WYZ_S3.js} +1 -1
- package/dist/dashboard/index.html +2 -2
- package/dist/{dist-37VQSHHA.js → dist-PIC255RX.js} +20 -2
- package/dist/{doctor-PYUQRRCB.js → doctor-PQC7JQPP.js} +4 -3
- package/dist/{doctor-PYUQRRCB.js.map → doctor-PQC7JQPP.js.map} +1 -1
- package/dist/{goal-SXZUDUCL.js → goal-STLEU7C7.js} +4 -3
- package/dist/{goal-SXZUDUCL.js.map → goal-STLEU7C7.js.map} +1 -1
- package/dist/index.js +31 -31
- package/dist/{init-Z2AFQEEP.js → init-NHU5LJSS.js} +4 -3
- package/dist/{init-Z2AFQEEP.js.map → init-NHU5LJSS.js.map} +1 -1
- package/dist/{run-AOS7L3RT.js → run-7HWSHMRJ.js} +4 -3
- package/dist/{run-AOS7L3RT.js.map → run-7HWSHMRJ.js.map} +1 -1
- package/dist/runtime.js +3 -2
- package/dist/{start-CEPXKZUE.js → start-WVAEAQWL.js} +4 -3
- package/dist/{start-CEPXKZUE.js.map → start-WVAEAQWL.js.map} +1 -1
- package/dist/{status-WNJ3GGKU.js → status-ZRHPFLFT.js} +5 -4
- package/dist/{tasks-TFUTUMWB.js → tasks-JVWXUNXN.js} +5 -4
- package/dist/{tasks-TFUTUMWB.js.map → tasks-JVWXUNXN.js.map} +1 -1
- package/package.json +6 -6
- package/dist/chunk-44AFJL2X.js.map +0 -1
- package/dist/chunk-FYPMA55O.js.map +0 -1
- package/dist/chunk-HSBJDV3O.js.map +0 -1
- package/dist/chunk-W7GPBEBZ.js.map +0 -1
- package/dist/chunk-WQ7MEWDF.js.map +0 -1
- package/dist/dashboard/assets/Accounts-cq8RLMoI.js +0 -1
- package/dist/dashboard/assets/Markdown-DCZ4Awcc.js +0 -69
- package/dist/dashboard/assets/index-BDBa5cb0.js +0 -104
- /package/dist/{account-QWDPJWAA.js.map → account-RTPS2V6O.js.map} +0 -0
- /package/dist/{accounts-IQMR72FC.js.map → accounts-IYQ4ZRL7.js.map} +0 -0
- /package/dist/{chunk-AZKACMME.js.map → chunk-BJTXMET2.js.map} +0 -0
- /package/dist/{chunk-JLATEHS7.js.map → chunk-LEU46DGH.js.map} +0 -0
- /package/dist/{chunk-PGAJIGUF.js.map → chunk-YNAMNQLW.js.map} +0 -0
- /package/dist/{dist-37VQSHHA.js.map → dist-PIC255RX.js.map} +0 -0
- /package/dist/{status-WNJ3GGKU.js.map → status-ZRHPFLFT.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -36,12 +36,12 @@ Docs: https://github.com/DMRLZZ/DaveCode#readme`
|
|
|
36
36
|
run(async (ctx) => {
|
|
37
37
|
const globals = program.opts();
|
|
38
38
|
if (globals.version) {
|
|
39
|
-
const { VERSION } = await import("./dist-
|
|
39
|
+
const { VERSION } = await import("./dist-PIC255RX.js");
|
|
40
40
|
ctx.out(`davecode ${VERSION}`);
|
|
41
41
|
return EXIT.ok;
|
|
42
42
|
}
|
|
43
43
|
if (ctx.interactive) {
|
|
44
|
-
const { chatCommand } = await import("./chat-
|
|
44
|
+
const { chatCommand } = await import("./chat-6TX6JX45.js");
|
|
45
45
|
return chatCommand(ctx, {});
|
|
46
46
|
}
|
|
47
47
|
program.outputHelp();
|
|
@@ -74,43 +74,43 @@ function collect(value, previous = []) {
|
|
|
74
74
|
function registerCommands(program, run) {
|
|
75
75
|
program.command("app").description("start your local workspace in a Chrome or Edge app window").addOption(new Option("-p, --port <port>", "port to listen on").argParser(parsePort)).option("--project <dir>", "repository to open").action(
|
|
76
76
|
run(async (ctx, opts) => {
|
|
77
|
-
const { startCommand } = await import("./start-
|
|
77
|
+
const { startCommand } = await import("./start-WVAEAQWL.js");
|
|
78
78
|
return startCommand(ctx, { ...opts, host: "127.0.0.1", app: true });
|
|
79
79
|
})
|
|
80
80
|
);
|
|
81
81
|
program.command("start").description("start the gateway (OpenAI-compatible /v1, dashboard API and web dashboard)").addOption(new Option("-p, --port <port>", "port to listen on").argParser(parsePort)).option("--host <host>", "interface to bind (default 127.0.0.1)").option("--no-dashboard", "do not serve the web dashboard").option("--project <dir>", "repository whose project brain to serve (default: detected)").option("--verbose", "print gateway request logs").option("-q, --quiet", "do not print the live activity log").action(
|
|
82
82
|
run(async (ctx, opts) => {
|
|
83
|
-
const { startCommand } = await import("./start-
|
|
83
|
+
const { startCommand } = await import("./start-WVAEAQWL.js");
|
|
84
84
|
return startCommand(ctx, opts);
|
|
85
85
|
})
|
|
86
86
|
);
|
|
87
87
|
program.command("status").description("gateway health, accounts and 1m/5h/24h quota usage").action(
|
|
88
88
|
run(async (ctx) => {
|
|
89
|
-
const { statusCommand } = await import("./status-
|
|
89
|
+
const { statusCommand } = await import("./status-ZRHPFLFT.js");
|
|
90
90
|
return statusCommand(ctx);
|
|
91
91
|
})
|
|
92
92
|
);
|
|
93
93
|
program.command("chat").description("chat TUI (also what bare `davecode` opens in a terminal)").option("-m, --model <id>", "model or route, e.g. davecode/auto or anthropic/claude-sonnet-5-5").option("--project <dir>", "repository whose brain an in-process gateway serves").action(
|
|
94
94
|
run(async (ctx, opts) => {
|
|
95
|
-
const { chatCommand } = await import("./chat-
|
|
95
|
+
const { chatCommand } = await import("./chat-6TX6JX45.js");
|
|
96
96
|
return chatCommand(ctx, opts);
|
|
97
97
|
})
|
|
98
98
|
);
|
|
99
99
|
program.command("login").description("sign in to your DaveCode account in the browser").action(
|
|
100
100
|
run(async (ctx) => {
|
|
101
|
-
const { loginCommand } = await import("./account-
|
|
101
|
+
const { loginCommand } = await import("./account-RTPS2V6O.js");
|
|
102
102
|
return loginCommand(ctx);
|
|
103
103
|
})
|
|
104
104
|
);
|
|
105
105
|
program.command("logout").description("sign out of your DaveCode account").action(
|
|
106
106
|
run(async (ctx) => {
|
|
107
|
-
const { logoutCommand } = await import("./account-
|
|
107
|
+
const { logoutCommand } = await import("./account-RTPS2V6O.js");
|
|
108
108
|
return logoutCommand(ctx);
|
|
109
109
|
})
|
|
110
110
|
);
|
|
111
111
|
program.command("account").description("show the signed-in DaveCode account").action(
|
|
112
112
|
run(async (ctx) => {
|
|
113
|
-
const { accountCommand } = await import("./account-
|
|
113
|
+
const { accountCommand } = await import("./account-RTPS2V6O.js");
|
|
114
114
|
return accountCommand(ctx);
|
|
115
115
|
})
|
|
116
116
|
);
|
|
@@ -118,13 +118,13 @@ function registerCommands(program, run) {
|
|
|
118
118
|
registerProject(program, run);
|
|
119
119
|
program.command("budget").description("plans, renewals and remaining quota per account (what agents are told)").option("--context", "print only the summary injected into agent prompts").option("--local", "read the local database even if a gateway is running").action(
|
|
120
120
|
run(async (ctx, opts) => {
|
|
121
|
-
const { budgetCommand } = await import("./budget-
|
|
121
|
+
const { budgetCommand } = await import("./budget-N2ZB66FF.js");
|
|
122
122
|
return budgetCommand(ctx, opts);
|
|
123
123
|
})
|
|
124
124
|
);
|
|
125
125
|
program.command("doctor").description("check the environment and print fixes").action(
|
|
126
126
|
run(async (ctx) => {
|
|
127
|
-
const { doctorCommand } = await import("./doctor-
|
|
127
|
+
const { doctorCommand } = await import("./doctor-PQC7JQPP.js");
|
|
128
128
|
return doctorCommand(ctx);
|
|
129
129
|
})
|
|
130
130
|
);
|
|
@@ -138,7 +138,7 @@ Exit codes with --once: 0 success or nothing to do, 1 failed or error, 130 stopp
|
|
|
138
138
|
Ctrl+C stops safely: partial work stays on the task branch and the task goes back to PENDING.`
|
|
139
139
|
).action(
|
|
140
140
|
run(async (ctx, opts) => {
|
|
141
|
-
const { runCommand } = await import("./run-
|
|
141
|
+
const { runCommand } = await import("./run-7HWSHMRJ.js");
|
|
142
142
|
return runCommand(ctx, opts);
|
|
143
143
|
})
|
|
144
144
|
);
|
|
@@ -166,26 +166,26 @@ Examples:
|
|
|
166
166
|
davecode goal "Add a /health endpoint with tests" --max-rounds 2`
|
|
167
167
|
).action(
|
|
168
168
|
run(async (ctx, words, opts) => {
|
|
169
|
-
const { goalCommand } = await import("./goal-
|
|
169
|
+
const { goalCommand } = await import("./goal-STLEU7C7.js");
|
|
170
170
|
return goalCommand(ctx, words, opts);
|
|
171
171
|
})
|
|
172
172
|
);
|
|
173
173
|
const goals = program.command("goals").description("goals of this repository");
|
|
174
174
|
goals.command("list", { isDefault: true }).alias("ls").description("goals, newest first").option("--project <dir>", "repository (default: detected)").action(
|
|
175
175
|
run(async (ctx, opts) => {
|
|
176
|
-
const { goalsList } = await import("./goal-
|
|
176
|
+
const { goalsList } = await import("./goal-STLEU7C7.js");
|
|
177
177
|
return goalsList(ctx, opts);
|
|
178
178
|
})
|
|
179
179
|
);
|
|
180
180
|
goals.command("show <id>").description("tasks, artifacts and summary of a goal").option("--project <dir>", "repository (default: detected)").action(
|
|
181
181
|
run(async (ctx, id, opts) => {
|
|
182
|
-
const { goalsShow } = await import("./goal-
|
|
182
|
+
const { goalsShow } = await import("./goal-STLEU7C7.js");
|
|
183
183
|
return goalsShow(ctx, id, opts);
|
|
184
184
|
})
|
|
185
185
|
);
|
|
186
186
|
goals.command("cancel <id>").description("cancel a running goal").option("--project <dir>", "repository (default: detected)").action(
|
|
187
187
|
run(async (ctx, id, opts) => {
|
|
188
|
-
const { goalsCancel } = await import("./goal-
|
|
188
|
+
const { goalsCancel } = await import("./goal-STLEU7C7.js");
|
|
189
189
|
return goalsCancel(ctx, id, opts);
|
|
190
190
|
})
|
|
191
191
|
);
|
|
@@ -193,20 +193,20 @@ Examples:
|
|
|
193
193
|
function registerProject(program, run) {
|
|
194
194
|
program.command("init").description("scaffold the project brain (.davecode/) in this repository").option("--name <name>", "project name used in STATE.md and ARCHITECTURE.md").option("--config", "write a starter .davecode/config.json without asking").option("--no-config", "do not write .davecode/config.json").action(
|
|
195
195
|
run(async (ctx, opts) => {
|
|
196
|
-
const { initCommand } = await import("./init-
|
|
196
|
+
const { initCommand } = await import("./init-NHU5LJSS.js");
|
|
197
197
|
return initCommand(ctx, opts);
|
|
198
198
|
})
|
|
199
199
|
);
|
|
200
200
|
const tasks = program.command("tasks").description("show and edit the task graph");
|
|
201
201
|
tasks.command("list", { isDefault: true }).alias("ls").description("task tree with status and blocked reasons").action(
|
|
202
202
|
run(async (ctx) => {
|
|
203
|
-
const { tasksList } = await import("./tasks-
|
|
203
|
+
const { tasksList } = await import("./tasks-JVWXUNXN.js");
|
|
204
204
|
return tasksList(ctx);
|
|
205
205
|
})
|
|
206
206
|
);
|
|
207
207
|
tasks.command("next").description("the task the runner would pick next").action(
|
|
208
208
|
run(async (ctx) => {
|
|
209
|
-
const { tasksNext } = await import("./tasks-
|
|
209
|
+
const { tasksNext } = await import("./tasks-JVWXUNXN.js");
|
|
210
210
|
return tasksNext(ctx);
|
|
211
211
|
})
|
|
212
212
|
);
|
|
@@ -217,33 +217,33 @@ function registerProject(program, run) {
|
|
|
217
217
|
).action(
|
|
218
218
|
run(
|
|
219
219
|
async (ctx, id, title, opts) => {
|
|
220
|
-
const { tasksAdd } = await import("./tasks-
|
|
220
|
+
const { tasksAdd } = await import("./tasks-JVWXUNXN.js");
|
|
221
221
|
return tasksAdd(ctx, id, title, opts);
|
|
222
222
|
}
|
|
223
223
|
)
|
|
224
224
|
);
|
|
225
225
|
tasks.command("status <id> <status>").description("move a task to PENDING | IN_PROGRESS | SUCCESS | FAILED").option("--notes <text>", "note stored on the task").action(
|
|
226
226
|
run(async (ctx, id, status, opts) => {
|
|
227
|
-
const { tasksStatus } = await import("./tasks-
|
|
227
|
+
const { tasksStatus } = await import("./tasks-JVWXUNXN.js");
|
|
228
228
|
return tasksStatus(ctx, id, status, opts);
|
|
229
229
|
})
|
|
230
230
|
);
|
|
231
231
|
const config = program.command("config").description("show the resolved configuration");
|
|
232
232
|
config.command("show", { isDefault: true }).description("resolved config as JSON (secrets redacted)").action(
|
|
233
233
|
run(async (ctx) => {
|
|
234
|
-
const { configShow } = await import("./config-
|
|
234
|
+
const { configShow } = await import("./config-YQKY2AA4.js");
|
|
235
235
|
return configShow(ctx);
|
|
236
236
|
})
|
|
237
237
|
);
|
|
238
238
|
config.command("path").description("where config, state and brains live").action(
|
|
239
239
|
run(async (ctx) => {
|
|
240
|
-
const { configPath } = await import("./config-
|
|
240
|
+
const { configPath } = await import("./config-YQKY2AA4.js");
|
|
241
241
|
return configPath(ctx);
|
|
242
242
|
})
|
|
243
243
|
);
|
|
244
244
|
config.command("get <key>").description("one value by dotted key, e.g. server.port").action(
|
|
245
245
|
run(async (ctx, key) => {
|
|
246
|
-
const { configGet } = await import("./config-
|
|
246
|
+
const { configGet } = await import("./config-YQKY2AA4.js");
|
|
247
247
|
return configGet(ctx, key);
|
|
248
248
|
})
|
|
249
249
|
);
|
|
@@ -267,7 +267,7 @@ Examples:
|
|
|
267
267
|
davecode accounts add --provider claude-cli --label "Claude Pro" --yes`
|
|
268
268
|
).action(
|
|
269
269
|
run(async (ctx, opts) => {
|
|
270
|
-
const { accountsAdd } = await import("./accounts-
|
|
270
|
+
const { accountsAdd } = await import("./accounts-IYQ4ZRL7.js");
|
|
271
271
|
return accountsAdd(ctx, opts);
|
|
272
272
|
})
|
|
273
273
|
);
|
|
@@ -276,7 +276,7 @@ function registerAccounts(program, run) {
|
|
|
276
276
|
const accounts = program.command("accounts").description("manage provider accounts");
|
|
277
277
|
accounts.command("list", { isDefault: true }).alias("ls").description("list accounts").option("--local", "read the local database even if a gateway is running").action(
|
|
278
278
|
run(async (ctx, opts) => {
|
|
279
|
-
const { accountsList } = await import("./accounts-
|
|
279
|
+
const { accountsList } = await import("./accounts-IYQ4ZRL7.js");
|
|
280
280
|
return accountsList(ctx, opts);
|
|
281
281
|
})
|
|
282
282
|
);
|
|
@@ -286,7 +286,7 @@ function registerAccounts(program, run) {
|
|
|
286
286
|
);
|
|
287
287
|
accounts.command("remove <id>").alias("rm").description("remove an account, its secret and its sandbox").option("-y, --yes", "do not ask for confirmation").option("--local", "write to the local database even if a gateway is running").action(
|
|
288
288
|
run(async (ctx, id, opts) => {
|
|
289
|
-
const { accountsRemove } = await import("./accounts-
|
|
289
|
+
const { accountsRemove } = await import("./accounts-IYQ4ZRL7.js");
|
|
290
290
|
return accountsRemove(ctx, id, opts);
|
|
291
291
|
})
|
|
292
292
|
);
|
|
@@ -296,7 +296,7 @@ function registerAccounts(program, run) {
|
|
|
296
296
|
]) {
|
|
297
297
|
accounts.command(`${name} <id>`).description(`${name} an account${enabled ? " (also clears error and cooldown state)" : ""}`).option("--local", "write to the local database even if a gateway is running").action(
|
|
298
298
|
run(async (ctx, id, opts) => {
|
|
299
|
-
const { accountsSetEnabled } = await import("./accounts-
|
|
299
|
+
const { accountsSetEnabled } = await import("./accounts-IYQ4ZRL7.js");
|
|
300
300
|
return accountsSetEnabled(ctx, id, enabled, opts);
|
|
301
301
|
})
|
|
302
302
|
);
|
|
@@ -308,7 +308,7 @@ Entered by hand: DaveCode never reads billing pages. Example:
|
|
|
308
308
|
davecode accounts plan acc_123 --plan "Claude Pro" --price 20 --renews 2026-11-01`
|
|
309
309
|
).action(
|
|
310
310
|
run(async (ctx, id, opts) => {
|
|
311
|
-
const { accountsPlan } = await import("./accounts-
|
|
311
|
+
const { accountsPlan } = await import("./accounts-IYQ4ZRL7.js");
|
|
312
312
|
return accountsPlan(ctx, id, opts);
|
|
313
313
|
})
|
|
314
314
|
);
|
|
@@ -324,7 +324,7 @@ Extra arguments after -- replace the default ones (e.g. -- login --device-auth f
|
|
|
324
324
|
).action(
|
|
325
325
|
run(
|
|
326
326
|
async (ctx, id, args, opts) => {
|
|
327
|
-
const { accountsLogin } = await import("./accounts-
|
|
327
|
+
const { accountsLogin } = await import("./accounts-IYQ4ZRL7.js");
|
|
328
328
|
return accountsLogin(ctx, id, args, opts);
|
|
329
329
|
}
|
|
330
330
|
)
|
|
@@ -338,7 +338,7 @@ connected, start the vendor's own sign-in. Example:
|
|
|
338
338
|
davecode accounts connect acc_123 --check`
|
|
339
339
|
).action(
|
|
340
340
|
run(async (ctx, id, opts) => {
|
|
341
|
-
const { accountsConnect } = await import("./accounts-
|
|
341
|
+
const { accountsConnect } = await import("./accounts-IYQ4ZRL7.js");
|
|
342
342
|
return accountsConnect(ctx, id, opts);
|
|
343
343
|
})
|
|
344
344
|
);
|
|
@@ -6,16 +6,17 @@ import {
|
|
|
6
6
|
} from "./chunk-QA3O6RA2.js";
|
|
7
7
|
import {
|
|
8
8
|
detectProjectRoot
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-KUY3QHGS.js";
|
|
10
10
|
import {
|
|
11
11
|
CliError,
|
|
12
12
|
EXIT
|
|
13
13
|
} from "./chunk-7XVXEO7U.js";
|
|
14
|
+
import "./chunk-732GIHRQ.js";
|
|
14
15
|
import {
|
|
15
16
|
ProjectBrain,
|
|
16
17
|
configSchema,
|
|
17
18
|
projectPaths
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-QKY3OKVG.js";
|
|
19
20
|
import "./chunk-MC7RIPL7.js";
|
|
20
21
|
|
|
21
22
|
// src/commands/init.ts
|
|
@@ -191,4 +192,4 @@ export {
|
|
|
191
192
|
ensureLockIgnored,
|
|
192
193
|
initCommand
|
|
193
194
|
};
|
|
194
|
-
//# sourceMappingURL=init-
|
|
195
|
+
//# sourceMappingURL=init-NHU5LJSS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/init.ts","../src/lib/validate-detect.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { basename, join, relative } from 'node:path';\nimport { configSchema, ProjectBrain, projectPaths } from '@davecode/core';\nimport { type CliContext, printJson } from '../context';\nimport { CliError, EXIT } from '../errors';\nimport { PromptCancelledError, type Prompter } from '../lib/prompter';\nimport {\n detectPackageManager,\n detectValidateCommands,\n readPackageJson,\n starterConfig,\n} from '../lib/validate-detect';\nimport { detectProjectRoot } from '../runtime';\n\nexport interface InitOptions {\n name?: string;\n /** `--config` writes the starter config without asking; `--no-config` skips it. */\n config?: boolean;\n}\n\nexport interface InitDeps {\n prompter?: Prompter;\n}\n\nconst LOCK_IGNORE = '.davecode/.lock';\n\n/** Make sure `.davecode/.lock` is git-ignored. Returns true when `.gitignore` changed. */\nexport function ensureLockIgnored(root: string): boolean {\n const path = join(root, '.gitignore');\n const current = existsSync(path) ? readFileSync(path, 'utf8') : '';\n const lines = current.split(/\\r?\\n/).map((l) => l.trim());\n if (lines.includes(LOCK_IGNORE) || lines.includes('.davecode/') || lines.includes('.davecode')) {\n return false;\n }\n const prefix = current === '' || current.endsWith('\\n') ? current : `${current}\\n`;\n writeFileSync(\n path,\n `${prefix}${current === '' ? '' : '\\n'}# DaveCode runtime lock\\n${LOCK_IGNORE}\\n`,\n );\n return true;\n}\n\nexport async function initCommand(\n ctx: CliContext,\n opts: InitOptions,\n deps: InitDeps = {},\n): Promise<number> {\n const root = (await detectProjectRoot(ctx.cwd, ctx.home)) ?? ctx.cwd;\n const paths = projectPaths(root);\n const pkg = readPackageJson(root);\n const name = opts.name?.trim() || pkg?.name || basename(root);\n\n const before = {\n state: existsSync(paths.state),\n architecture: existsSync(paths.architecture),\n taskGraph: existsSync(paths.taskGraph),\n };\n await ProjectBrain.init(root, { name });\n const created = Object.entries(before)\n .filter(([, existed]) => !existed)\n .map(([file]) => file);\n\n // Starter config with validation commands detected from package.json.\n const pm = detectPackageManager(root, pkg);\n const validate = detectValidateCommands(pkg, pm);\n let configWritten = false;\n let configSkipped: string | undefined;\n if (existsSync(paths.config)) {\n configSkipped = 'exists';\n } else if (opts.config === false) {\n configSkipped = 'declined';\n } else {\n let write = opts.config === true;\n if (!write && ctx.interactive) {\n const prompter =\n deps.prompter ??\n (await import('../tui/prompts')).createInkPrompter({\n stdout: ctx.io.stdout,\n stdin: ctx.io.stdin,\n theme: ctx.theme,\n });\n const summary = Object.entries(validate)\n .map(([k, v]) => `${k}: ${v}`)\n .join(', ');\n try {\n write = await prompter.confirm(\n summary\n ? `Write .davecode/config.json with runner.validate (${summary})?`\n : 'Write a starter .davecode/config.json (no lint/typecheck/test scripts found)?',\n true,\n );\n } catch (err) {\n if (!(err instanceof PromptCancelledError)) throw err;\n }\n }\n if (write) {\n const content = starterConfig(validate);\n const check = configSchema.safeParse(content);\n if (!check.success) throw new CliError('Generated config is invalid (please report a bug)');\n writeFileSync(paths.config, `${JSON.stringify(content, null, 2)}\\n`);\n configWritten = true;\n } else {\n configSkipped = ctx.interactive ? 'declined' : 'non-interactive';\n }\n }\n\n const ignoreUpdated = existsSync(join(root, '.git')) ? ensureLockIgnored(root) : false;\n\n if (ctx.json) {\n printJson(ctx, {\n root,\n name,\n created,\n config: configWritten ? paths.config : null,\n validate,\n gitignoreUpdated: ignoreUpdated,\n });\n return EXIT.ok;\n }\n\n const { theme } = ctx;\n const rel = (p: string) => relative(ctx.cwd, p) || '.';\n ctx.out(\n `${theme.ok(theme.glyph.ok)} Project brain ready for ${theme.bold(name)} ${theme.dim(rel(paths.dir))}`,\n );\n const files: Array<[string, string, boolean]> = [\n ['STATE.md', paths.state, before.state],\n ['ARCHITECTURE.md', paths.architecture, before.architecture],\n ['TASK_GRAPH.json', paths.taskGraph, before.taskGraph],\n ];\n for (const [label, , existed] of files) {\n ctx.out(` ${existed ? theme.dim('kept ') : theme.accent('created')} ${label}`);\n }\n if (configWritten) {\n ctx.out(` ${theme.accent('created')} config.json`);\n for (const [kind, command] of Object.entries(validate)) {\n ctx.out(theme.dim(` runner.validate.${kind} = ${command}`));\n }\n } else if (configSkipped === 'exists') {\n ctx.out(` ${theme.dim('kept ')} config.json`);\n } else if (configSkipped === 'non-interactive') {\n ctx.out(theme.dim(' config.json not written (pass --config to create a starter config)'));\n }\n if (ignoreUpdated)\n ctx.out(` ${theme.accent('updated')} .gitignore ${theme.dim(`(${LOCK_IGNORE})`)}`);\n\n ctx.out();\n ctx.out(theme.dim('Next:'));\n ctx.out(` ${theme.accent('davecode tasks add setup \"Describe the first task\"')}`);\n ctx.out(` ${theme.accent('davecode start')}`);\n return EXIT.ok;\n}\n","import { existsSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\nexport type PackageManager = 'pnpm' | 'yarn' | 'bun' | 'npm';\n\nexport interface PackageJson {\n name?: string;\n packageManager?: string;\n scripts?: Record<string, string>;\n}\n\nexport function readPackageJson(root: string): PackageJson | undefined {\n try {\n const value: unknown = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));\n return value && typeof value === 'object' ? (value as PackageJson) : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** From `packageManager` in package.json, then lockfiles; npm otherwise. */\nexport function detectPackageManager(root: string, pkg?: PackageJson): PackageManager {\n const declared = pkg?.packageManager?.split('@')[0];\n if (declared === 'pnpm' || declared === 'yarn' || declared === 'bun' || declared === 'npm') {\n return declared;\n }\n if (existsSync(join(root, 'pnpm-lock.yaml'))) return 'pnpm';\n if (existsSync(join(root, 'yarn.lock'))) return 'yarn';\n if (existsSync(join(root, 'bun.lock')) || existsSync(join(root, 'bun.lockb'))) return 'bun';\n return 'npm';\n}\n\nconst CANDIDATES = {\n lint: ['lint', 'lint:check', 'check:lint'],\n typecheck: ['typecheck', 'type-check', 'check-types', 'check:types', 'types', 'tsc'],\n test: ['test', 'test:unit', 'test:ci'],\n} as const;\n\n/** npm's placeholder `test` script, which always fails. */\nconst NPM_PLACEHOLDER = /no test specified/i;\n\nexport function runScript(pm: PackageManager, script: string): string {\n if (script === 'test') return `${pm} test`;\n switch (pm) {\n case 'npm':\n return `npm run ${script}`;\n case 'bun':\n return `bun run ${script}`;\n default:\n return `${pm} ${script}`;\n }\n}\n\nexport interface ValidateCommands {\n lint?: string;\n typecheck?: string;\n test?: string;\n}\n\n/** `runner.validate` commands for the lint/typecheck/test scripts a package.json defines. */\nexport function detectValidateCommands(\n pkg: PackageJson | undefined,\n pm: PackageManager,\n): ValidateCommands {\n const scripts = pkg?.scripts ?? {};\n const found: ValidateCommands = {};\n for (const [kind, names] of Object.entries(CANDIDATES) as Array<\n [keyof ValidateCommands, readonly string[]]\n >) {\n const script = names.find((name) => {\n const body = scripts[name];\n return typeof body === 'string' && body.trim() !== '' && !NPM_PLACEHOLDER.test(body);\n });\n if (script) found[kind] = runScript(pm, script);\n }\n return found;\n}\n\n/** Starter `.davecode/config.json` content. */\nexport function starterConfig(validate: ValidateCommands): Record<string, unknown> {\n return { runner: { validate, judge: { kind: 'none' } } };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,cAAAA,aAAY,gBAAAC,eAAc,qBAAqB;AACxD,SAAS,UAAU,QAAAC,OAAM,gBAAgB;;;ACDzC,SAAS,YAAY,oBAAoB;AACzC,SAAS,YAAY;AAUd,SAAS,gBAAgB,MAAuC;AACrE,MAAI;AACF,UAAM,QAAiB,KAAK,MAAM,aAAa,KAAK,MAAM,cAAc,GAAG,MAAM,CAAC;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CAAC,eAAe,MAAM,IAAI,IAAI,WAAW,GAAG,CAAC,EAAE;AAEpF,MAAI,IAAI;AACR,MAAI,IAAI,MAAM,IAAI,OAAO,CAAC;AAC1B,MAAI,IAAI,KAAK,MAAM,OAAO,oDAAoD,CAAC,EAAE;AACjF,MAAI,IAAI,KAAK,MAAM,OAAO,gBAAgB,CAAC,EAAE;AAC7C,SAAO,KAAK;AACd;","names":["existsSync","readFileSync","join","join","existsSync","readFileSync"]}
|
|
1
|
+
{"version":3,"sources":["../src/commands/init.ts","../src/lib/validate-detect.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from 'node:fs';\nimport { basename, join, relative } from 'node:path';\nimport { configSchema, ProjectBrain, projectPaths } from '@davecode/core';\nimport { type CliContext, printJson } from '../context';\nimport { CliError, EXIT } from '../errors';\nimport { PromptCancelledError, type Prompter } from '../lib/prompter';\nimport {\n detectPackageManager,\n detectValidateCommands,\n readPackageJson,\n starterConfig,\n} from '../lib/validate-detect';\nimport { detectProjectRoot } from '../runtime';\n\nexport interface InitOptions {\n name?: string;\n /** `--config` writes the starter config without asking; `--no-config` skips it. */\n config?: boolean;\n}\n\nexport interface InitDeps {\n prompter?: Prompter;\n}\n\nconst LOCK_IGNORE = '.davecode/.lock';\n\n/** Make sure `.davecode/.lock` is git-ignored. Returns true when `.gitignore` changed. */\nexport function ensureLockIgnored(root: string): boolean {\n const path = join(root, '.gitignore');\n const current = existsSync(path) ? readFileSync(path, 'utf8') : '';\n const lines = current.split(/\\r?\\n/).map((l) => l.trim());\n if (lines.includes(LOCK_IGNORE) || lines.includes('.davecode/') || lines.includes('.davecode')) {\n return false;\n }\n const prefix = current === '' || current.endsWith('\\n') ? current : `${current}\\n`;\n writeFileSync(\n path,\n `${prefix}${current === '' ? '' : '\\n'}# DaveCode runtime lock\\n${LOCK_IGNORE}\\n`,\n );\n return true;\n}\n\nexport async function initCommand(\n ctx: CliContext,\n opts: InitOptions,\n deps: InitDeps = {},\n): Promise<number> {\n const root = (await detectProjectRoot(ctx.cwd, ctx.home)) ?? ctx.cwd;\n const paths = projectPaths(root);\n const pkg = readPackageJson(root);\n const name = opts.name?.trim() || pkg?.name || basename(root);\n\n const before = {\n state: existsSync(paths.state),\n architecture: existsSync(paths.architecture),\n taskGraph: existsSync(paths.taskGraph),\n };\n await ProjectBrain.init(root, { name });\n const created = Object.entries(before)\n .filter(([, existed]) => !existed)\n .map(([file]) => file);\n\n // Starter config with validation commands detected from package.json.\n const pm = detectPackageManager(root, pkg);\n const validate = detectValidateCommands(pkg, pm);\n let configWritten = false;\n let configSkipped: string | undefined;\n if (existsSync(paths.config)) {\n configSkipped = 'exists';\n } else if (opts.config === false) {\n configSkipped = 'declined';\n } else {\n let write = opts.config === true;\n if (!write && ctx.interactive) {\n const prompter =\n deps.prompter ??\n (await import('../tui/prompts')).createInkPrompter({\n stdout: ctx.io.stdout,\n stdin: ctx.io.stdin,\n theme: ctx.theme,\n });\n const summary = Object.entries(validate)\n .map(([k, v]) => `${k}: ${v}`)\n .join(', ');\n try {\n write = await prompter.confirm(\n summary\n ? `Write .davecode/config.json with runner.validate (${summary})?`\n : 'Write a starter .davecode/config.json (no lint/typecheck/test scripts found)?',\n true,\n );\n } catch (err) {\n if (!(err instanceof PromptCancelledError)) throw err;\n }\n }\n if (write) {\n const content = starterConfig(validate);\n const check = configSchema.safeParse(content);\n if (!check.success) throw new CliError('Generated config is invalid (please report a bug)');\n writeFileSync(paths.config, `${JSON.stringify(content, null, 2)}\\n`);\n configWritten = true;\n } else {\n configSkipped = ctx.interactive ? 'declined' : 'non-interactive';\n }\n }\n\n const ignoreUpdated = existsSync(join(root, '.git')) ? ensureLockIgnored(root) : false;\n\n if (ctx.json) {\n printJson(ctx, {\n root,\n name,\n created,\n config: configWritten ? paths.config : null,\n validate,\n gitignoreUpdated: ignoreUpdated,\n });\n return EXIT.ok;\n }\n\n const { theme } = ctx;\n const rel = (p: string) => relative(ctx.cwd, p) || '.';\n ctx.out(\n `${theme.ok(theme.glyph.ok)} Project brain ready for ${theme.bold(name)} ${theme.dim(rel(paths.dir))}`,\n );\n const files: Array<[string, string, boolean]> = [\n ['STATE.md', paths.state, before.state],\n ['ARCHITECTURE.md', paths.architecture, before.architecture],\n ['TASK_GRAPH.json', paths.taskGraph, before.taskGraph],\n ];\n for (const [label, , existed] of files) {\n ctx.out(` ${existed ? theme.dim('kept ') : theme.accent('created')} ${label}`);\n }\n if (configWritten) {\n ctx.out(` ${theme.accent('created')} config.json`);\n for (const [kind, command] of Object.entries(validate)) {\n ctx.out(theme.dim(` runner.validate.${kind} = ${command}`));\n }\n } else if (configSkipped === 'exists') {\n ctx.out(` ${theme.dim('kept ')} config.json`);\n } else if (configSkipped === 'non-interactive') {\n ctx.out(theme.dim(' config.json not written (pass --config to create a starter config)'));\n }\n if (ignoreUpdated)\n ctx.out(` ${theme.accent('updated')} .gitignore ${theme.dim(`(${LOCK_IGNORE})`)}`);\n\n ctx.out();\n ctx.out(theme.dim('Next:'));\n ctx.out(` ${theme.accent('davecode tasks add setup \"Describe the first task\"')}`);\n ctx.out(` ${theme.accent('davecode start')}`);\n return EXIT.ok;\n}\n","import { existsSync, readFileSync } from 'node:fs';\nimport { join } from 'node:path';\n\nexport type PackageManager = 'pnpm' | 'yarn' | 'bun' | 'npm';\n\nexport interface PackageJson {\n name?: string;\n packageManager?: string;\n scripts?: Record<string, string>;\n}\n\nexport function readPackageJson(root: string): PackageJson | undefined {\n try {\n const value: unknown = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));\n return value && typeof value === 'object' ? (value as PackageJson) : undefined;\n } catch {\n return undefined;\n }\n}\n\n/** From `packageManager` in package.json, then lockfiles; npm otherwise. */\nexport function detectPackageManager(root: string, pkg?: PackageJson): PackageManager {\n const declared = pkg?.packageManager?.split('@')[0];\n if (declared === 'pnpm' || declared === 'yarn' || declared === 'bun' || declared === 'npm') {\n return declared;\n }\n if (existsSync(join(root, 'pnpm-lock.yaml'))) return 'pnpm';\n if (existsSync(join(root, 'yarn.lock'))) return 'yarn';\n if (existsSync(join(root, 'bun.lock')) || existsSync(join(root, 'bun.lockb'))) return 'bun';\n return 'npm';\n}\n\nconst CANDIDATES = {\n lint: ['lint', 'lint:check', 'check:lint'],\n typecheck: ['typecheck', 'type-check', 'check-types', 'check:types', 'types', 'tsc'],\n test: ['test', 'test:unit', 'test:ci'],\n} as const;\n\n/** npm's placeholder `test` script, which always fails. */\nconst NPM_PLACEHOLDER = /no test specified/i;\n\nexport function runScript(pm: PackageManager, script: string): string {\n if (script === 'test') return `${pm} test`;\n switch (pm) {\n case 'npm':\n return `npm run ${script}`;\n case 'bun':\n return `bun run ${script}`;\n default:\n return `${pm} ${script}`;\n }\n}\n\nexport interface ValidateCommands {\n lint?: string;\n typecheck?: string;\n test?: string;\n}\n\n/** `runner.validate` commands for the lint/typecheck/test scripts a package.json defines. */\nexport function detectValidateCommands(\n pkg: PackageJson | undefined,\n pm: PackageManager,\n): ValidateCommands {\n const scripts = pkg?.scripts ?? {};\n const found: ValidateCommands = {};\n for (const [kind, names] of Object.entries(CANDIDATES) as Array<\n [keyof ValidateCommands, readonly string[]]\n >) {\n const script = names.find((name) => {\n const body = scripts[name];\n return typeof body === 'string' && body.trim() !== '' && !NPM_PLACEHOLDER.test(body);\n });\n if (script) found[kind] = runScript(pm, script);\n }\n return found;\n}\n\n/** Starter `.davecode/config.json` content. */\nexport function starterConfig(validate: ValidateCommands): Record<string, unknown> {\n return { runner: { validate, judge: { kind: 'none' } } };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,cAAAA,aAAY,gBAAAC,eAAc,qBAAqB;AACxD,SAAS,UAAU,QAAAC,OAAM,gBAAgB;;;ACDzC,SAAS,YAAY,oBAAoB;AACzC,SAAS,YAAY;AAUd,SAAS,gBAAgB,MAAuC;AACrE,MAAI;AACF,UAAM,QAAiB,KAAK,MAAM,aAAa,KAAK,MAAM,cAAc,GAAG,MAAM,CAAC;AAClF,WAAO,SAAS,OAAO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,IAAI,WAAW,GAAG,CAAC,EAAE;AAEpF,MAAI,IAAI;AACR,MAAI,IAAI,MAAM,IAAI,OAAO,CAAC;AAC1B,MAAI,IAAI,KAAK,MAAM,OAAO,oDAAoD,CAAC,EAAE;AACjF,MAAI,IAAI,KAAK,MAAM,OAAO,gBAAgB,CAAC,EAAE;AAC7C,SAAO,KAAK;AACd;","names":["existsSync","readFileSync","join","join","existsSync","readFileSync"]}
|
|
@@ -18,17 +18,18 @@ import {
|
|
|
18
18
|
detectProjectRoot,
|
|
19
19
|
findGateway,
|
|
20
20
|
wireProject
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-KUY3QHGS.js";
|
|
22
22
|
import {
|
|
23
23
|
CliError,
|
|
24
24
|
EXIT
|
|
25
25
|
} from "./chunk-7XVXEO7U.js";
|
|
26
|
+
import "./chunk-732GIHRQ.js";
|
|
26
27
|
import {
|
|
27
28
|
ProjectBrain,
|
|
28
29
|
RunnerError,
|
|
29
30
|
createEngine,
|
|
30
31
|
loadConfig
|
|
31
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-QKY3OKVG.js";
|
|
32
33
|
import "./chunk-MC7RIPL7.js";
|
|
33
34
|
|
|
34
35
|
// src/commands/run.ts
|
|
@@ -373,4 +374,4 @@ export {
|
|
|
373
374
|
explainRunnerError,
|
|
374
375
|
runCommand
|
|
375
376
|
};
|
|
376
|
-
//# sourceMappingURL=run-
|
|
377
|
+
//# sourceMappingURL=run-7HWSHMRJ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/commands/run.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { basename, resolve } from 'node:path';\nimport {\n type AutonomousRunner,\n createEngine,\n type DaveConfig,\n type DaveEvent,\n type Engine,\n loadConfig,\n ProjectBrain,\n RunnerError,\n type RunnerErrorCode,\n type RunnerStatus,\n type RunOnceResult,\n type TaskGraph,\n type TaskNode,\n} from '@davecode/core';\nimport { findGateway, type GatewayClient, GatewayError } from '../client';\nimport { type CliContext, printJson } from '../context';\nimport { CliError, EXIT } from '../errors';\nimport { detectProjectRoot, wireProject } from '../runtime';\nimport { logText } from '../tui/RunnerView';\nimport { initialRunnerState, isTerminal } from '../tui/runner-state';\nimport { formatDuration } from '../ui/format';\n\nexport interface RunOptions {\n once?: boolean;\n task?: string;\n project?: string;\n}\n\n/** Test seams: an injected runner/engine instead of building them from the project. */\nexport interface RunDeps {\n wire?: (\n engine: Engine,\n root: string,\n ) => {\n runner: Pick<\n AutonomousRunner,\n 'runOnce' | 'start' | 'stop' | 'pause' | 'resume' | 'status' | 'running'\n >;\n };\n engine?: Engine;\n /** Resolves when the user asks to stop (default: SIGINT/SIGTERM). */\n interrupt?: () => Promise<void>;\n /** Skip the running-gateway probe. */\n noGateway?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Friendly errors\n// ---------------------------------------------------------------------------\n\nconst HINTS: Record<RunnerErrorCode, (config: DaveConfig) => { message?: string; hint: string }> = {\n not_a_repo: () => ({\n message: 'This project is not inside a git repository',\n hint: 'The runner works on task branches: run `git init` and make a first commit.',\n }),\n no_brain: () => ({\n message: 'No project brain here',\n hint: 'Run `davecode init`, then add tasks with `davecode tasks add`.',\n }),\n no_base_branch: (config) => ({\n message: `The base branch \"${config.runner.baseBranch}\" does not exist`,\n hint: 'Create it, or set runner.baseBranch in .davecode/config.json.',\n }),\n dirty_worktree: () => ({\n hint: 'Commit or stash your changes, then run again (the runner never works on top of uncommitted edits).',\n }),\n invalid_graph: () => ({\n hint: 'Fix .davecode/TASK_GRAPH.json; `davecode tasks` shows the problem.',\n }),\n task_not_found: () => ({\n hint: 'See `davecode tasks` for the task ids.',\n }),\n task_not_runnable: () => ({\n hint: 'Only PENDING tasks can run: reopen it with `davecode tasks status <id> PENDING`.',\n }),\n task_blocked: () => ({\n hint: 'Run its dependencies first (`davecode tasks` shows what each task waits on).',\n }),\n busy: () => ({\n hint: 'Stop the runner or the running goal (dashboard, `davecode goals cancel <id>` or the other `davecode run`) first.',\n }),\n};\n\nconst CODE_PATTERNS: Array<[RunnerErrorCode, RegExp]> = [\n ['not_a_repo', /not inside a git repository/i],\n ['no_brain', /no project brain/i],\n ['no_base_branch', /base branch .* does not exist/i],\n ['dirty_worktree', /uncommitted changes/i],\n ['busy', /already running|working tree is busy/i],\n ['invalid_graph', /task graph/i],\n];\n\n/** Turn a `RunnerError` (or the gateway's 409 for one) into a CLI error with a fix. */\nexport function explainRunnerError(err: unknown, config: DaveConfig): unknown {\n const message = err instanceof Error ? err.message : String(err);\n let code: RunnerErrorCode | undefined;\n if (err instanceof RunnerError) code = err.code;\n else if (err instanceof GatewayError && err.status === 409) {\n // The gateway forwards RunnerError codes; fall back to message matching for older gateways.\n code =\n err.code in HINTS\n ? (err.code as RunnerErrorCode)\n : CODE_PATTERNS.find(([, re]) => re.test(message))?.[0];\n }\n if (!code) return err;\n const friendly = HINTS[code](config);\n return new CliError(friendly.message ?? message, { hint: friendly.hint });\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\ninterface Waiter {\n promise: Promise<void>;\n dispose(): void;\n}\n\n/** Resolves on SIGINT/SIGTERM; `dispose()` removes the listeners again. */\nfunction signalWaiter(): Waiter {\n let dispose = () => {};\n const promise = new Promise<void>((resolveSignal) => {\n const done = () => {\n dispose();\n resolveSignal();\n };\n dispose = () => {\n process.off('SIGINT', done);\n process.off('SIGTERM', done);\n };\n process.on('SIGINT', done);\n process.on('SIGTERM', done);\n });\n return { promise, dispose };\n}\n\nfunction interruptFor(deps: RunDeps): Waiter {\n return deps.interrupt ? { promise: deps.interrupt(), dispose: () => {} } : signalWaiter();\n}\n\nexport function describeResult(ctx: CliContext, result: RunOnceResult): string[] {\n const { theme } = ctx;\n const task = result.task ? `${theme.bold(result.task.id)} ${result.task.title}` : '';\n const lines: string[] = [];\n switch (result.outcome) {\n case 'success':\n lines.push(`${theme.ok(theme.glyph.ok)} ${task} ${theme.ok('succeeded')}`);\n if (result.delivery?.mode === 'pr' && result.delivery.url) {\n lines.push(` pull request ${theme.accent(result.delivery.url)}`);\n } else if (result.delivery) lines.push(theme.dim(' merged into the base branch'));\n break;\n case 'failed':\n lines.push(`${theme.error(theme.glyph.fail)} ${task} ${theme.error('failed')}`);\n if (result.branch) lines.push(theme.dim(` work kept on ${result.branch}`));\n break;\n case 'idle':\n lines.push(theme.dim('Nothing to do: no task is ready (see `davecode tasks`).'));\n break;\n case 'stopped':\n lines.push(theme.warn(`${theme.glyph.warn} Stopped; the task is back to PENDING.`));\n if (result.branch) lines.push(theme.dim(` partial work kept on ${result.branch}`));\n break;\n default:\n lines.push(\n `${theme.error(theme.glyph.fail)} Runner error: ${result.error ?? 'unknown error'}`,\n );\n }\n if (result.outcome === 'success' || result.outcome === 'failed') {\n lines.push(theme.dim(` repair cycles ${result.repairCycles}`));\n if (result.validation && !result.validation.ok) {\n const failing = result.validation.steps.filter((s) => !s.ok).map((s) => s.name);\n if (failing.length > 0) lines.push(theme.dim(` failing checks: ${failing.join(', ')}`));\n }\n if (result.verdict) {\n lines.push(\n theme.dim(\n ` judge ${result.verdict.pass ? 'passed' : 'rejected'}${result.verdict.confidence !== undefined ? ` (confidence ${result.verdict.confidence.toFixed(2)})` : ''}`,\n ),\n );\n }\n if (result.summary) lines.push('', result.summary.trim());\n }\n return lines;\n}\n\nexport function exitCodeFor(result: RunOnceResult): number {\n if (result.outcome === 'success' || result.outcome === 'idle') return EXIT.ok;\n if (result.outcome === 'stopped') return 130;\n return EXIT.failure;\n}\n\nfunction printEvent(ctx: CliContext, event: DaveEvent, toStderr: boolean): void {\n const write = toStderr ? ctx.err : ctx.out;\n const theme = toStderr ? ctx.errTheme : ctx.theme;\n if (event.type === 'runner.log' && event.level !== 'debug') {\n write(\n logText(theme, { ts: event.ts, level: event.level, message: event.message }, ctx.columns),\n );\n } else if (event.type === 'runner.status') {\n const s = event.status;\n write(\n theme.dim(\n `${new Date(event.ts).toTimeString().slice(0, 8)} ${theme.glyph.arrow} ${s.state}${s.taskId ? ` · ${s.taskId}` : ''}${s.repairCycle ? ` · repair ${s.repairCycle}` : ''}`,\n ),\n );\n }\n}\n\n// ---------------------------------------------------------------------------\n// Command\n// ---------------------------------------------------------------------------\n\nexport async function runCommand(\n ctx: CliContext,\n opts: RunOptions,\n deps: RunDeps = {},\n): Promise<number> {\n const root = opts.project\n ? resolve(ctx.cwd, opts.project)\n : await detectProjectRoot(ctx.cwd, ctx.home);\n if (!root || !existsSync(root)) {\n throw new CliError('Not inside a project', {\n hint: 'Run `davecode run` inside a git repository with a project brain (`davecode init`).',\n });\n }\n const config =\n deps.engine?.config ?? loadConfig({ home: ctx.home, env: ctx.env, projectRoot: root });\n\n // A gateway (davecode start) may already own a runner for this repository.\n const gateway = deps.noGateway ? undefined : await findGateway(config).catch(() => undefined);\n if (gateway) {\n const status = await gateway.client\n .get<{ status: RunnerStatus }>('/api/runner')\n .then((r) => r.status)\n .catch(() => undefined);\n if (status && !['idle', 'stopped', 'error'].includes(status.state)) {\n throw new CliError(`The gateway's runner is already ${status.state}`, {\n hint: `Watch it in the dashboard at ${gateway.client.baseUrl}/ or stop it there first.`,\n });\n }\n if (!opts.once) return driveGateway(ctx, gateway.client, config, root, opts.task);\n }\n\n const engine = deps.engine ?? createEngine({ home: ctx.home, env: ctx.env, projectRoot: root });\n try {\n const { runner } = (deps.wire ?? ((e, r) => wireProject(e, r, { env: ctx.env })))(engine, root);\n const graph = await new ProjectBrain(root)\n .readGraph()\n .catch(() => ({ version: 1 as const, tasks: [] }));\n return opts.once\n ? await runOnce(ctx, engine, runner, config, deps, opts.task)\n : await runContinuous(\n ctx,\n engine,\n runner,\n config,\n basename(root),\n graph.tasks,\n deps,\n opts.task,\n );\n } finally {\n if (!deps.engine) engine.close();\n }\n}\n\ntype RunnerLike = ReturnType<NonNullable<RunDeps['wire']>>['runner'];\n\nasync function runOnce(\n ctx: CliContext,\n engine: Engine,\n runner: RunnerLike,\n config: DaveConfig,\n deps: RunDeps,\n taskId?: string,\n): Promise<number> {\n const unsubscribe = engine.events.subscribe((event) => printEvent(ctx, event, ctx.json));\n let interrupted = false;\n const interrupt = interruptFor(deps);\n void interrupt.promise.then(() => {\n interrupted = true;\n if (!ctx.json) ctx.err(ctx.errTheme.dim('Stopping safely…'));\n void runner.stop();\n });\n const started = Date.now();\n let result: RunOnceResult;\n try {\n result = await runner.runOnce(taskId === undefined ? {} : { taskId });\n } catch (err) {\n throw explainRunnerError(err, config);\n } finally {\n unsubscribe();\n interrupt.dispose();\n }\n if (ctx.json) {\n printJson(ctx, { ...result, interrupted });\n } else {\n ctx.out();\n for (const line of describeResult(ctx, result)) ctx.out(line);\n ctx.out(ctx.theme.dim(` took ${formatDuration((Date.now() - started) / 1000)}`));\n }\n return exitCodeFor(result);\n}\n\nasync function runContinuous(\n ctx: CliContext,\n engine: Engine,\n runner: RunnerLike,\n config: DaveConfig,\n projectName: string,\n tasks: TaskNode[],\n deps: RunDeps,\n taskId?: string,\n): Promise<number> {\n // Buffer events emitted before the view mounts so the first log lines are not lost.\n const early: DaveEvent[] = [];\n const unsubscribeEarly = engine.events.subscribe((e) => early.push(e));\n try {\n await runner.start(taskId === undefined ? {} : { taskId });\n } catch (err) {\n unsubscribeEarly();\n throw explainRunnerError(err, config);\n }\n\n if (!ctx.interactive) {\n unsubscribeEarly();\n for (const event of early) printEvent(ctx, event, false);\n const unsubscribe = engine.events.subscribe((event) => printEvent(ctx, event, false));\n const finished = new Promise<void>((resolveDone) => {\n const timer = setInterval(() => {\n if (!runner.running) {\n clearInterval(timer);\n resolveDone();\n }\n }, 250);\n });\n const interrupt = interruptFor(deps);\n await Promise.race([interrupt.promise, finished]);\n interrupt.dispose();\n if (runner.running) {\n ctx.out(ctx.theme.dim('Stopping safely…'));\n await runner.stop();\n }\n unsubscribe();\n } else {\n const [{ render }, { createElement }, { RunnerApp }] = await Promise.all([\n import('ink'),\n import('react'),\n import('../tui/RunnerView'),\n ]);\n let initial = initialRunnerState(runner.status(), tasks);\n const { runnerReducer } = await import('../tui/runner-state');\n for (const event of early) initial = runnerReducer(initial, event);\n unsubscribeEarly();\n const instance = render(\n createElement(RunnerApp, {\n theme: ctx.theme,\n initial,\n subscribe: (onEvent: (e: DaveEvent) => void) => engine.events.subscribe(onEvent),\n maxRepairCycles: config.runner.maxRepairCycles,\n projectName,\n stop: () => runner.stop(),\n pause: () => runner.pause(),\n resume: () => runner.resume(),\n }),\n { stdout: ctx.io.stdout as NodeJS.WriteStream, exitOnCtrlC: false },\n );\n await instance.waitUntilExit();\n if (runner.running) await runner.stop();\n }\n const final = runner.status();\n if (final.state === 'error') {\n ctx.err(ctx.errTheme.error(`Runner error: ${final.lastError ?? 'unknown error'}`));\n return EXIT.failure;\n }\n return EXIT.ok;\n}\n\n/** Continuous mode against the runner of a running gateway, fed by `/api/events`. */\nasync function driveGateway(\n ctx: CliContext,\n client: GatewayClient,\n config: DaveConfig,\n root: string,\n taskId?: string,\n): Promise<number> {\n try {\n await client.post('/api/runner/start', taskId === undefined ? undefined : { taskId });\n } catch (err) {\n if (err instanceof GatewayError && err.status === 501) {\n throw new CliError('The running gateway has no project brain to work on', {\n hint: 'Restart `davecode start` inside this repository, or stop it so `davecode run` can work in-process.',\n });\n }\n throw explainRunnerError(err, config);\n }\n const stop = async () => {\n await client.post('/api/runner/stop', undefined, { timeoutMs: 10 * 60_000 });\n };\n const controller = new AbortController();\n const listeners = new Set<(e: DaveEvent) => void>();\n let latest: RunnerStatus = { state: 'selecting' };\n const pump = (async () => {\n try {\n for await (const event of client.events(controller.signal)) {\n if (event.type === 'runner.status') latest = event.status;\n for (const listener of listeners) listener(event);\n }\n } catch {\n // aborted or disconnected\n }\n })();\n\n try {\n if (!ctx.interactive) {\n const print = (e: DaveEvent) => printEvent(ctx, e, false);\n listeners.add(print);\n await signalWaiter().promise;\n ctx.out(ctx.theme.dim('Stopping safely…'));\n await stop();\n } else {\n const [{ render }, { createElement }, { RunnerApp }, { tasks }] = await Promise.all([\n import('ink'),\n import('react'),\n import('../tui/RunnerView'),\n client\n .get<{ graph: TaskGraph }>('/api/tasks')\n .then((r) => ({ tasks: r.graph.tasks }))\n .catch(() => ({ tasks: [] as TaskNode[] })),\n ]);\n const status = await client\n .get<{ status: RunnerStatus }>('/api/runner')\n .then((r) => r.status)\n .catch(() => latest);\n const instance = render(\n createElement(RunnerApp, {\n theme: ctx.theme,\n initial: initialRunnerState(status, tasks),\n subscribe: (onEvent: (e: DaveEvent) => void) => {\n listeners.add(onEvent);\n return () => listeners.delete(onEvent);\n },\n maxRepairCycles: config.runner.maxRepairCycles,\n projectName: basename(root),\n stop,\n pause: async () => {\n await client.post('/api/runner/pause');\n },\n resume: async () => {\n await client.post('/api/runner/start');\n },\n }),\n { stdout: ctx.io.stdout as NodeJS.WriteStream, exitOnCtrlC: false },\n );\n await instance.waitUntilExit();\n if (!isTerminal(latest.state)) await stop().catch(() => undefined);\n }\n } finally {\n controller.abort();\n await pump;\n }\n return latest.state === 'error' ? EXIT.failure : EXIT.ok;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,UAAU,eAAe;AAoDlC,IAAM,QAA6F;AAAA,EACjG,YAAY,OAAO;AAAA,IACjB,SAAS;AAAA,IACT,MAAM;AAAA,EACR;AAAA,EACA,UAAU,OAAO;AAAA,IACf,SAAS;AAAA,IACT,MAAM;AAAA,EACR;AAAA,EACA,gBAAgB,CAAC,YAAY;AAAA,IAC3B,SAAS,oBAAoB,OAAO,OAAO,UAAU;AAAA,IACrD,MAAM;AAAA,EACR;AAAA,EACA,gBAAgB,OAAO;AAAA,IACrB,MAAM;AAAA,EACR;AAAA,EACA,eAAe,OAAO;AAAA,IACpB,MAAM;AAAA,EACR;AAAA,EACA,gBAAgB,OAAO;AAAA,IACrB,MAAM;AAAA,EACR;AAAA,EACA,mBAAmB,OAAO;AAAA,IACxB,MAAM;AAAA,EACR;AAAA,EACA,cAAc,OAAO;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AACrB,mBAAO,MAAM,UAAU,OAAO,OAAO;AAAA,UACvC;AAAA,UACA,iBAAiB,OAAO,OAAO;AAAA,UAC/B,aAAa,SAAS,IAAI;AAAA,UAC1B;AAAA,UACA,OAAO,YAAY;AACjB,kBAAM,OAAO,KAAK,mBAAmB;AAAA,UACvC;AAAA,UACA,QAAQ,YAAY;AAClB,kBAAM,OAAO,KAAK,mBAAmB;AAAA,UACvC;AAAA,QACF,CAAC;AAAA,QACD,EAAE,QAAQ,IAAI,GAAG,QAA8B,aAAa,MAAM;AAAA,MACpE;AACA,YAAM,SAAS,cAAc;AAC7B,UAAI,CAAC,WAAW,OAAO,KAAK,EAAG,OAAM,KAAK,EAAE,MAAM,MAAM,MAAS;AAAA,IACnE;AAAA,EACF,UAAE;AACA,eAAW,MAAM;AACjB,UAAM;AAAA,EACR;AACA,SAAO,OAAO,UAAU,UAAU,KAAK,UAAU,KAAK;AACxD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/commands/run.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { basename, resolve } from 'node:path';\nimport {\n type AutonomousRunner,\n createEngine,\n type DaveConfig,\n type DaveEvent,\n type Engine,\n loadConfig,\n ProjectBrain,\n RunnerError,\n type RunnerErrorCode,\n type RunnerStatus,\n type RunOnceResult,\n type TaskGraph,\n type TaskNode,\n} from '@davecode/core';\nimport { findGateway, type GatewayClient, GatewayError } from '../client';\nimport { type CliContext, printJson } from '../context';\nimport { CliError, EXIT } from '../errors';\nimport { detectProjectRoot, wireProject } from '../runtime';\nimport { logText } from '../tui/RunnerView';\nimport { initialRunnerState, isTerminal } from '../tui/runner-state';\nimport { formatDuration } from '../ui/format';\n\nexport interface RunOptions {\n once?: boolean;\n task?: string;\n project?: string;\n}\n\n/** Test seams: an injected runner/engine instead of building them from the project. */\nexport interface RunDeps {\n wire?: (\n engine: Engine,\n root: string,\n ) => {\n runner: Pick<\n AutonomousRunner,\n 'runOnce' | 'start' | 'stop' | 'pause' | 'resume' | 'status' | 'running'\n >;\n };\n engine?: Engine;\n /** Resolves when the user asks to stop (default: SIGINT/SIGTERM). */\n interrupt?: () => Promise<void>;\n /** Skip the running-gateway probe. */\n noGateway?: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Friendly errors\n// ---------------------------------------------------------------------------\n\nconst HINTS: Record<RunnerErrorCode, (config: DaveConfig) => { message?: string; hint: string }> = {\n not_a_repo: () => ({\n message: 'This project is not inside a git repository',\n hint: 'The runner works on task branches: run `git init` and make a first commit.',\n }),\n no_brain: () => ({\n message: 'No project brain here',\n hint: 'Run `davecode init`, then add tasks with `davecode tasks add`.',\n }),\n no_base_branch: (config) => ({\n message: `The base branch \"${config.runner.baseBranch}\" does not exist`,\n hint: 'Create it, or set runner.baseBranch in .davecode/config.json.',\n }),\n dirty_worktree: () => ({\n hint: 'Commit or stash your changes, then run again (the runner never works on top of uncommitted edits).',\n }),\n invalid_graph: () => ({\n hint: 'Fix .davecode/TASK_GRAPH.json; `davecode tasks` shows the problem.',\n }),\n task_not_found: () => ({\n hint: 'See `davecode tasks` for the task ids.',\n }),\n task_not_runnable: () => ({\n hint: 'Only PENDING tasks can run: reopen it with `davecode tasks status <id> PENDING`.',\n }),\n task_blocked: () => ({\n hint: 'Run its dependencies first (`davecode tasks` shows what each task waits on).',\n }),\n busy: () => ({\n hint: 'Stop the runner or the running goal (dashboard, `davecode goals cancel <id>` or the other `davecode run`) first.',\n }),\n};\n\nconst CODE_PATTERNS: Array<[RunnerErrorCode, RegExp]> = [\n ['not_a_repo', /not inside a git repository/i],\n ['no_brain', /no project brain/i],\n ['no_base_branch', /base branch .* does not exist/i],\n ['dirty_worktree', /uncommitted changes/i],\n ['busy', /already running|working tree is busy/i],\n ['invalid_graph', /task graph/i],\n];\n\n/** Turn a `RunnerError` (or the gateway's 409 for one) into a CLI error with a fix. */\nexport function explainRunnerError(err: unknown, config: DaveConfig): unknown {\n const message = err instanceof Error ? err.message : String(err);\n let code: RunnerErrorCode | undefined;\n if (err instanceof RunnerError) code = err.code;\n else if (err instanceof GatewayError && err.status === 409) {\n // The gateway forwards RunnerError codes; fall back to message matching for older gateways.\n code =\n err.code in HINTS\n ? (err.code as RunnerErrorCode)\n : CODE_PATTERNS.find(([, re]) => re.test(message))?.[0];\n }\n if (!code) return err;\n const friendly = HINTS[code](config);\n return new CliError(friendly.message ?? message, { hint: friendly.hint });\n}\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\ninterface Waiter {\n promise: Promise<void>;\n dispose(): void;\n}\n\n/** Resolves on SIGINT/SIGTERM; `dispose()` removes the listeners again. */\nfunction signalWaiter(): Waiter {\n let dispose = () => {};\n const promise = new Promise<void>((resolveSignal) => {\n const done = () => {\n dispose();\n resolveSignal();\n };\n dispose = () => {\n process.off('SIGINT', done);\n process.off('SIGTERM', done);\n };\n process.on('SIGINT', done);\n process.on('SIGTERM', done);\n });\n return { promise, dispose };\n}\n\nfunction interruptFor(deps: RunDeps): Waiter {\n return deps.interrupt ? { promise: deps.interrupt(), dispose: () => {} } : signalWaiter();\n}\n\nexport function describeResult(ctx: CliContext, result: RunOnceResult): string[] {\n const { theme } = ctx;\n const task = result.task ? `${theme.bold(result.task.id)} ${result.task.title}` : '';\n const lines: string[] = [];\n switch (result.outcome) {\n case 'success':\n lines.push(`${theme.ok(theme.glyph.ok)} ${task} ${theme.ok('succeeded')}`);\n if (result.delivery?.mode === 'pr' && result.delivery.url) {\n lines.push(` pull request ${theme.accent(result.delivery.url)}`);\n } else if (result.delivery) lines.push(theme.dim(' merged into the base branch'));\n break;\n case 'failed':\n lines.push(`${theme.error(theme.glyph.fail)} ${task} ${theme.error('failed')}`);\n if (result.branch) lines.push(theme.dim(` work kept on ${result.branch}`));\n break;\n case 'idle':\n lines.push(theme.dim('Nothing to do: no task is ready (see `davecode tasks`).'));\n break;\n case 'stopped':\n lines.push(theme.warn(`${theme.glyph.warn} Stopped; the task is back to PENDING.`));\n if (result.branch) lines.push(theme.dim(` partial work kept on ${result.branch}`));\n break;\n default:\n lines.push(\n `${theme.error(theme.glyph.fail)} Runner error: ${result.error ?? 'unknown error'}`,\n );\n }\n if (result.outcome === 'success' || result.outcome === 'failed') {\n lines.push(theme.dim(` repair cycles ${result.repairCycles}`));\n if (result.validation && !result.validation.ok) {\n const failing = result.validation.steps.filter((s) => !s.ok).map((s) => s.name);\n if (failing.length > 0) lines.push(theme.dim(` failing checks: ${failing.join(', ')}`));\n }\n if (result.verdict) {\n lines.push(\n theme.dim(\n ` judge ${result.verdict.pass ? 'passed' : 'rejected'}${result.verdict.confidence !== undefined ? ` (confidence ${result.verdict.confidence.toFixed(2)})` : ''}`,\n ),\n );\n }\n if (result.summary) lines.push('', result.summary.trim());\n }\n return lines;\n}\n\nexport function exitCodeFor(result: RunOnceResult): number {\n if (result.outcome === 'success' || result.outcome === 'idle') return EXIT.ok;\n if (result.outcome === 'stopped') return 130;\n return EXIT.failure;\n}\n\nfunction printEvent(ctx: CliContext, event: DaveEvent, toStderr: boolean): void {\n const write = toStderr ? ctx.err : ctx.out;\n const theme = toStderr ? ctx.errTheme : ctx.theme;\n if (event.type === 'runner.log' && event.level !== 'debug') {\n write(\n logText(theme, { ts: event.ts, level: event.level, message: event.message }, ctx.columns),\n );\n } else if (event.type === 'runner.status') {\n const s = event.status;\n write(\n theme.dim(\n `${new Date(event.ts).toTimeString().slice(0, 8)} ${theme.glyph.arrow} ${s.state}${s.taskId ? ` · ${s.taskId}` : ''}${s.repairCycle ? ` · repair ${s.repairCycle}` : ''}`,\n ),\n );\n }\n}\n\n// ---------------------------------------------------------------------------\n// Command\n// ---------------------------------------------------------------------------\n\nexport async function runCommand(\n ctx: CliContext,\n opts: RunOptions,\n deps: RunDeps = {},\n): Promise<number> {\n const root = opts.project\n ? resolve(ctx.cwd, opts.project)\n : await detectProjectRoot(ctx.cwd, ctx.home);\n if (!root || !existsSync(root)) {\n throw new CliError('Not inside a project', {\n hint: 'Run `davecode run` inside a git repository with a project brain (`davecode init`).',\n });\n }\n const config =\n deps.engine?.config ?? loadConfig({ home: ctx.home, env: ctx.env, projectRoot: root });\n\n // A gateway (davecode start) may already own a runner for this repository.\n const gateway = deps.noGateway ? undefined : await findGateway(config).catch(() => undefined);\n if (gateway) {\n const status = await gateway.client\n .get<{ status: RunnerStatus }>('/api/runner')\n .then((r) => r.status)\n .catch(() => undefined);\n if (status && !['idle', 'stopped', 'error'].includes(status.state)) {\n throw new CliError(`The gateway's runner is already ${status.state}`, {\n hint: `Watch it in the dashboard at ${gateway.client.baseUrl}/ or stop it there first.`,\n });\n }\n if (!opts.once) return driveGateway(ctx, gateway.client, config, root, opts.task);\n }\n\n const engine = deps.engine ?? createEngine({ home: ctx.home, env: ctx.env, projectRoot: root });\n try {\n const { runner } = (deps.wire ?? ((e, r) => wireProject(e, r, { env: ctx.env })))(engine, root);\n const graph = await new ProjectBrain(root)\n .readGraph()\n .catch(() => ({ version: 1 as const, tasks: [] }));\n return opts.once\n ? await runOnce(ctx, engine, runner, config, deps, opts.task)\n : await runContinuous(\n ctx,\n engine,\n runner,\n config,\n basename(root),\n graph.tasks,\n deps,\n opts.task,\n );\n } finally {\n if (!deps.engine) engine.close();\n }\n}\n\ntype RunnerLike = ReturnType<NonNullable<RunDeps['wire']>>['runner'];\n\nasync function runOnce(\n ctx: CliContext,\n engine: Engine,\n runner: RunnerLike,\n config: DaveConfig,\n deps: RunDeps,\n taskId?: string,\n): Promise<number> {\n const unsubscribe = engine.events.subscribe((event) => printEvent(ctx, event, ctx.json));\n let interrupted = false;\n const interrupt = interruptFor(deps);\n void interrupt.promise.then(() => {\n interrupted = true;\n if (!ctx.json) ctx.err(ctx.errTheme.dim('Stopping safely…'));\n void runner.stop();\n });\n const started = Date.now();\n let result: RunOnceResult;\n try {\n result = await runner.runOnce(taskId === undefined ? {} : { taskId });\n } catch (err) {\n throw explainRunnerError(err, config);\n } finally {\n unsubscribe();\n interrupt.dispose();\n }\n if (ctx.json) {\n printJson(ctx, { ...result, interrupted });\n } else {\n ctx.out();\n for (const line of describeResult(ctx, result)) ctx.out(line);\n ctx.out(ctx.theme.dim(` took ${formatDuration((Date.now() - started) / 1000)}`));\n }\n return exitCodeFor(result);\n}\n\nasync function runContinuous(\n ctx: CliContext,\n engine: Engine,\n runner: RunnerLike,\n config: DaveConfig,\n projectName: string,\n tasks: TaskNode[],\n deps: RunDeps,\n taskId?: string,\n): Promise<number> {\n // Buffer events emitted before the view mounts so the first log lines are not lost.\n const early: DaveEvent[] = [];\n const unsubscribeEarly = engine.events.subscribe((e) => early.push(e));\n try {\n await runner.start(taskId === undefined ? {} : { taskId });\n } catch (err) {\n unsubscribeEarly();\n throw explainRunnerError(err, config);\n }\n\n if (!ctx.interactive) {\n unsubscribeEarly();\n for (const event of early) printEvent(ctx, event, false);\n const unsubscribe = engine.events.subscribe((event) => printEvent(ctx, event, false));\n const finished = new Promise<void>((resolveDone) => {\n const timer = setInterval(() => {\n if (!runner.running) {\n clearInterval(timer);\n resolveDone();\n }\n }, 250);\n });\n const interrupt = interruptFor(deps);\n await Promise.race([interrupt.promise, finished]);\n interrupt.dispose();\n if (runner.running) {\n ctx.out(ctx.theme.dim('Stopping safely…'));\n await runner.stop();\n }\n unsubscribe();\n } else {\n const [{ render }, { createElement }, { RunnerApp }] = await Promise.all([\n import('ink'),\n import('react'),\n import('../tui/RunnerView'),\n ]);\n let initial = initialRunnerState(runner.status(), tasks);\n const { runnerReducer } = await import('../tui/runner-state');\n for (const event of early) initial = runnerReducer(initial, event);\n unsubscribeEarly();\n const instance = render(\n createElement(RunnerApp, {\n theme: ctx.theme,\n initial,\n subscribe: (onEvent: (e: DaveEvent) => void) => engine.events.subscribe(onEvent),\n maxRepairCycles: config.runner.maxRepairCycles,\n projectName,\n stop: () => runner.stop(),\n pause: () => runner.pause(),\n resume: () => runner.resume(),\n }),\n { stdout: ctx.io.stdout as NodeJS.WriteStream, exitOnCtrlC: false },\n );\n await instance.waitUntilExit();\n if (runner.running) await runner.stop();\n }\n const final = runner.status();\n if (final.state === 'error') {\n ctx.err(ctx.errTheme.error(`Runner error: ${final.lastError ?? 'unknown error'}`));\n return EXIT.failure;\n }\n return EXIT.ok;\n}\n\n/** Continuous mode against the runner of a running gateway, fed by `/api/events`. */\nasync function driveGateway(\n ctx: CliContext,\n client: GatewayClient,\n config: DaveConfig,\n root: string,\n taskId?: string,\n): Promise<number> {\n try {\n await client.post('/api/runner/start', taskId === undefined ? undefined : { taskId });\n } catch (err) {\n if (err instanceof GatewayError && err.status === 501) {\n throw new CliError('The running gateway has no project brain to work on', {\n hint: 'Restart `davecode start` inside this repository, or stop it so `davecode run` can work in-process.',\n });\n }\n throw explainRunnerError(err, config);\n }\n const stop = async () => {\n await client.post('/api/runner/stop', undefined, { timeoutMs: 10 * 60_000 });\n };\n const controller = new AbortController();\n const listeners = new Set<(e: DaveEvent) => void>();\n let latest: RunnerStatus = { state: 'selecting' };\n const pump = (async () => {\n try {\n for await (const event of client.events(controller.signal)) {\n if (event.type === 'runner.status') latest = event.status;\n for (const listener of listeners) listener(event);\n }\n } catch {\n // aborted or disconnected\n }\n })();\n\n try {\n if (!ctx.interactive) {\n const print = (e: DaveEvent) => printEvent(ctx, e, false);\n listeners.add(print);\n await signalWaiter().promise;\n ctx.out(ctx.theme.dim('Stopping safely…'));\n await stop();\n } else {\n const [{ render }, { createElement }, { RunnerApp }, { tasks }] = await Promise.all([\n import('ink'),\n import('react'),\n import('../tui/RunnerView'),\n client\n .get<{ graph: TaskGraph }>('/api/tasks')\n .then((r) => ({ tasks: r.graph.tasks }))\n .catch(() => ({ tasks: [] as TaskNode[] })),\n ]);\n const status = await client\n .get<{ status: RunnerStatus }>('/api/runner')\n .then((r) => r.status)\n .catch(() => latest);\n const instance = render(\n createElement(RunnerApp, {\n theme: ctx.theme,\n initial: initialRunnerState(status, tasks),\n subscribe: (onEvent: (e: DaveEvent) => void) => {\n listeners.add(onEvent);\n return () => listeners.delete(onEvent);\n },\n maxRepairCycles: config.runner.maxRepairCycles,\n projectName: basename(root),\n stop,\n pause: async () => {\n await client.post('/api/runner/pause');\n },\n resume: async () => {\n await client.post('/api/runner/start');\n },\n }),\n { stdout: ctx.io.stdout as NodeJS.WriteStream, exitOnCtrlC: false },\n );\n await instance.waitUntilExit();\n if (!isTerminal(latest.state)) await stop().catch(() => undefined);\n }\n } finally {\n controller.abort();\n await pump;\n }\n return latest.state === 'error' ? EXIT.failure : EXIT.ok;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,kBAAkB;AAC3B,SAAS,UAAU,eAAe;AAoDlC,IAAM,QAA6F;AAAA,EACjG,YAAY,OAAO;AAAA,IACjB,SAAS;AAAA,IACT,MAAM;AAAA,EACR;AAAA,EACA,UAAU,OAAO;AAAA,IACf,SAAS;AAAA,IACT,MAAM;AAAA,EACR;AAAA,EACA,gBAAgB,CAAC,YAAY;AAAA,IAC3B,SAAS,oBAAoB,OAAO,OAAO,UAAU;AAAA,IACrD,MAAM;AAAA,EACR;AAAA,EACA,gBAAgB,OAAO;AAAA,IACrB,MAAM;AAAA,EACR;AAAA,EACA,eAAe,OAAO;AAAA,IACpB,MAAM;AAAA,EACR;AAAA,EACA,gBAAgB,OAAO;AAAA,IACrB,MAAM;AAAA,EACR;AAAA,EACA,mBAAmB,OAAO;AAAA,IACxB,MAAM;AAAA,EACR;AAAA,EACA,cAAc,OAAO;AAAA,IACnB,MAAM;AAAA,EACR;AAAA,EACA,MAAM,OAAO;AAAA,IACX,MAAM;AAAA,EACR;AACF;AAEA,IAAM,gBAAkD;AAAA,EACtD,CAAC,cAAc,8BAA8B;AAAA,EAC7C,CAAC,YAAY,mBAAmB;AAAA,EAChC,CAAC,kBAAkB,gCAAgC;AAAA,EACnD,CAAC,kBAAkB,sBAAsB;AAAA,EACzC,CAAC,QAAQ,uCAAuC;AAAA,EAChD,CAAC,iBAAiB,aAAa;AACjC;AAGO,SAAS,mBAAmB,KAAc,QAA6B;AAC5E,QAAM,UAAU,eAA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;AAC7B,UAAI,CAAC,WAAW,OAAO,KAAK,EAAG,OAAM,KAAK,EAAE,MAAM,MAAM,MAAS;AAAA,IACnE;AAAA,EACF,UAAE;AACA,eAAW,MAAM;AACjB,UAAM;AAAA,EACR;AACA,SAAO,OAAO,UAAU,UAAU,KAAK,UAAU,KAAK;AACxD;","names":[]}
|
package/dist/runtime.js
CHANGED
|
@@ -5,8 +5,9 @@ import {
|
|
|
5
5
|
resolveProjectRoot,
|
|
6
6
|
startRuntime,
|
|
7
7
|
wireProject
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
8
|
+
} from "./chunk-KUY3QHGS.js";
|
|
9
|
+
import "./chunk-732GIHRQ.js";
|
|
10
|
+
import "./chunk-QKY3OKVG.js";
|
|
10
11
|
export {
|
|
11
12
|
detectProjectRoot,
|
|
12
13
|
launchLoginTerminal,
|
|
@@ -10,16 +10,17 @@ import {
|
|
|
10
10
|
findGateway,
|
|
11
11
|
startRuntime,
|
|
12
12
|
which
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-KUY3QHGS.js";
|
|
14
14
|
import {
|
|
15
15
|
CliError,
|
|
16
16
|
EXIT
|
|
17
17
|
} from "./chunk-7XVXEO7U.js";
|
|
18
|
+
import "./chunk-732GIHRQ.js";
|
|
18
19
|
import {
|
|
19
20
|
VERSION,
|
|
20
21
|
loadConfig,
|
|
21
22
|
summarize
|
|
22
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-QKY3OKVG.js";
|
|
23
24
|
import "./chunk-MC7RIPL7.js";
|
|
24
25
|
|
|
25
26
|
// src/commands/start.ts
|
|
@@ -282,4 +283,4 @@ async function startCommand(ctx, opts, deps = {}) {
|
|
|
282
283
|
export {
|
|
283
284
|
startCommand
|
|
284
285
|
};
|
|
285
|
-
//# sourceMappingURL=start-
|
|
286
|
+
//# sourceMappingURL=start-WVAEAQWL.js.map
|