create-expert 0.0.39 → 0.0.41
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/bin/cli.ts +85 -0
- package/dist/bin/cli.js +62 -116364
- package/dist/bin/cli.js.map +1 -1
- package/dist/package.json +40 -0
- package/dist/perstack.toml +224 -116
- package/package.json +19 -17
- package/LICENSE +0 -202
- package/dist/chunk-D_gEzPfs.js +0 -47
- package/dist/devtools-DaNYFZHF.js +0 -3589
- package/dist/devtools-DaNYFZHF.js.map +0 -1
- package/dist/dist-BSxt_hUE.js +0 -1254
- package/dist/dist-BSxt_hUE.js.map +0 -1
- package/dist/from-D01OR38y.js +0 -3886
- package/dist/from-D01OR38y.js.map +0 -1
- package/dist/multipart-parser-DR1odBAg.js +0 -298
- package/dist/multipart-parser-DR1odBAg.js.map +0 -1
- package/dist/resolve-expert-CTnETi9d.js +0 -1651
- package/dist/resolve-expert-CTnETi9d.js.map +0 -1
- package/dist/src-AFNJ8T_q.js +0 -1192
- package/dist/src-AFNJ8T_q.js.map +0 -1
- package/dist/src-C0pz_C3h.js +0 -7653
- package/dist/src-C0pz_C3h.js.map +0 -1
- package/dist/token-DYCUdnJD.js +0 -51
- package/dist/token-DYCUdnJD.js.map +0 -1
- package/dist/token-error-CfavTss_.js +0 -43
- package/dist/token-error-CfavTss_.js.map +0 -1
- package/dist/token-util-CV5msMnB.js +0 -6
- package/dist/token-util-C_HjEdAu.js +0 -357
- package/dist/token-util-C_HjEdAu.js.map +0 -1
package/bin/cli.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
|
|
3
|
+
import { readFileSync } from "node:fs"
|
|
4
|
+
import { PerstackError } from "@perstack/core"
|
|
5
|
+
import { findLockfile, loadLockfile, parsePerstackConfig } from "@perstack/perstack-toml"
|
|
6
|
+
import { runHandler, startHandler } from "@perstack/tui"
|
|
7
|
+
import { PROVIDER_ENV_MAP } from "@perstack/tui/provider-config"
|
|
8
|
+
import { Command } from "commander"
|
|
9
|
+
import packageJson from "../package.json" with { type: "json" }
|
|
10
|
+
|
|
11
|
+
const tomlPath = new URL("../perstack.toml", import.meta.url)
|
|
12
|
+
|
|
13
|
+
new Command()
|
|
14
|
+
.name(packageJson.name)
|
|
15
|
+
.description(packageJson.description)
|
|
16
|
+
.version(packageJson.version)
|
|
17
|
+
.argument("[query]", "Description of the expert to create or modify")
|
|
18
|
+
.option("--headless", "Run in headless mode with JSON output (no TUI)")
|
|
19
|
+
.option(
|
|
20
|
+
"--filter <types>",
|
|
21
|
+
"Filter events by type (comma-separated, e.g., completeRun,stopRunByError)",
|
|
22
|
+
)
|
|
23
|
+
.option("--provider <provider>", "Provider to use")
|
|
24
|
+
.option("--model <model>", "Model to use")
|
|
25
|
+
.option(
|
|
26
|
+
"--reasoning-budget <budget>",
|
|
27
|
+
"Reasoning budget for native LLM reasoning (minimal, low, medium, high, or token count)",
|
|
28
|
+
)
|
|
29
|
+
.option("--max-retries <maxRetries>", "Maximum number of generation retries, default is 5")
|
|
30
|
+
.option(
|
|
31
|
+
"--timeout <timeout>",
|
|
32
|
+
"Timeout for each generation in milliseconds, default is 300000 (5 minutes)",
|
|
33
|
+
)
|
|
34
|
+
.option("--job-id <jobId>", "Job ID for identifying the job")
|
|
35
|
+
.option(
|
|
36
|
+
"--env-path <path>",
|
|
37
|
+
"Path to the environment file (can be specified multiple times), default is .env and .env.local",
|
|
38
|
+
(value: string, previous: string[]) => previous.concat(value),
|
|
39
|
+
[] as string[],
|
|
40
|
+
)
|
|
41
|
+
.option("--verbose", "Enable verbose logging")
|
|
42
|
+
.option("--continue", "Continue the most recent job with new query")
|
|
43
|
+
.option("--continue-job <jobId>", "Continue the specified job with new query")
|
|
44
|
+
.option(
|
|
45
|
+
"--resume-from <checkpointId>",
|
|
46
|
+
"Resume from a specific checkpoint (requires --continue or --continue-job)",
|
|
47
|
+
)
|
|
48
|
+
.option("-i, --interactive-tool-call-result", "Query is interactive tool call result")
|
|
49
|
+
.action(async (query: string | undefined, options: Record<string, unknown>) => {
|
|
50
|
+
const config = parsePerstackConfig(readFileSync(tomlPath, "utf-8"))
|
|
51
|
+
const lockfilePath = findLockfile()
|
|
52
|
+
const lockfile = lockfilePath ? (loadLockfile(lockfilePath) ?? undefined) : undefined
|
|
53
|
+
const additionalEnv = (env: Record<string, string>) => {
|
|
54
|
+
const provider = config.provider?.providerName ?? "anthropic"
|
|
55
|
+
const envKey = PROVIDER_ENV_MAP[provider]
|
|
56
|
+
const value = envKey ? env[envKey] : undefined
|
|
57
|
+
return value ? { PROVIDER_API_KEY: value } : ({} as Record<string, string>)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (options.headless) {
|
|
61
|
+
if (!query) {
|
|
62
|
+
console.error("Error: query argument is required in headless mode")
|
|
63
|
+
process.exit(1)
|
|
64
|
+
}
|
|
65
|
+
await runHandler("create-expert", query, options, {
|
|
66
|
+
perstackConfig: config,
|
|
67
|
+
lockfile,
|
|
68
|
+
additionalEnv,
|
|
69
|
+
})
|
|
70
|
+
} else {
|
|
71
|
+
await startHandler("create-expert", query, options, {
|
|
72
|
+
perstackConfig: config,
|
|
73
|
+
lockfile,
|
|
74
|
+
additionalEnv,
|
|
75
|
+
})
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
.parseAsync()
|
|
79
|
+
.catch((error) => {
|
|
80
|
+
if (error instanceof PerstackError) {
|
|
81
|
+
console.error(error.message)
|
|
82
|
+
process.exit(1)
|
|
83
|
+
}
|
|
84
|
+
throw error
|
|
85
|
+
})
|