durable-chat 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/LICENSES/mcp-sdk-MIT.txt +21 -0
- package/LICENSES/pi-MIT.txt +21 -0
- package/LICENSES/typebox-MIT.txt +23 -0
- package/LICENSES/yaml-ISC.txt +13 -0
- package/README.md +794 -2
- package/THIRD_PARTY_NOTICES.md +46 -0
- package/dist/agent-instructions.js +176 -0
- package/dist/auth.js +91 -0
- package/dist/chat.js +121 -0
- package/dist/cli.js +519 -0
- package/dist/codemode.js +23 -0
- package/dist/commands.js +227 -0
- package/dist/config-commands.js +142 -0
- package/dist/config.js +567 -0
- package/dist/context-usage.js +48 -0
- package/dist/existing-session.js +52 -0
- package/dist/faux.js +89 -0
- package/dist/forks.js +33 -0
- package/dist/format.js +144 -0
- package/dist/handoff.js +56 -0
- package/dist/harness.js +446 -0
- package/dist/images.js +64 -0
- package/dist/jobs.js +274 -0
- package/dist/mcp.js +231 -0
- package/dist/models.js +64 -0
- package/dist/reboot.js +70 -0
- package/dist/reminders.js +120 -0
- package/dist/rollback.js +72 -0
- package/dist/state.js +64 -0
- package/dist/tags.js +44 -0
- package/dist/tasks.js +466 -0
- package/dist/tool.js +205 -0
- package/dist/tui/app.js +1750 -0
- package/dist/tui/browser.js +19 -0
- package/dist/tui/composer.js +47 -0
- package/dist/tui/dialog.js +39 -0
- package/dist/tui/format.js +223 -0
- package/dist/tui/main.js +83 -0
- package/dist/tui/selection.js +161 -0
- package/dist/tui/state.js +98 -0
- package/dist/tui/transcript.js +151 -0
- package/dist/watch.js +134 -0
- package/dist/workspaces.js +106 -0
- package/package.json +57 -4
package/dist/commands.js
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { withAbortSignal } from "@earendil-works/chord/context";
|
|
2
|
+
import { formatJobDetail, formatJobList } from "./format.js";
|
|
3
|
+
import { announceJobStart, compactConversation, createJobInCommit, findJobConversation, formatLog, jobConversationId, jobCreateOptionsOf, jobRecord, normalizeBrief, readLog, scanJobs, sendToJob, } from "./jobs.js";
|
|
4
|
+
import { followJobs } from "./watch.js";
|
|
5
|
+
import { compactionLimit, contextPercent, estimateContextTokens, formatTokenCount } from "./context-usage.js";
|
|
6
|
+
function line(text = "") {
|
|
7
|
+
process.stdout.write(`${text}\n`);
|
|
8
|
+
}
|
|
9
|
+
function printMcpWarning(runtime) {
|
|
10
|
+
if (runtime.mcpAttempted && !runtime.mcpConnected) {
|
|
11
|
+
line("! Substrate MCP is not connected; job agents run without it (see `info`).");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export async function listJobs(runtime) {
|
|
15
|
+
const records = await scanJobs(runtime.harness, runtime.context);
|
|
16
|
+
printMcpWarning(runtime);
|
|
17
|
+
line(formatJobList(records, Date.now()));
|
|
18
|
+
}
|
|
19
|
+
export async function showJob(runtime, rawId) {
|
|
20
|
+
const id = parseId(rawId);
|
|
21
|
+
const record = await jobRecord(runtime.harness, id, runtime.context);
|
|
22
|
+
if (record === undefined) {
|
|
23
|
+
line(`No job #${id}.`);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
line(formatJobDetail(record, Date.now()));
|
|
27
|
+
const conversation = await findJobConversation(runtime.harness, id, runtime.context);
|
|
28
|
+
const conversationId = conversation === undefined ? undefined : Number(conversation.id);
|
|
29
|
+
if (conversation !== undefined) {
|
|
30
|
+
const view = await conversation.context(runtime.context);
|
|
31
|
+
const tokens = estimateContextTokens(view);
|
|
32
|
+
const window = runtime.config.contextWindow;
|
|
33
|
+
line("");
|
|
34
|
+
line(`Context: ~${formatTokenCount(tokens)} / ${formatTokenCount(window)} (${contextPercent(tokens, window).toFixed(0)}%; compact at ~${formatTokenCount(compactionLimit(window))})`);
|
|
35
|
+
}
|
|
36
|
+
if (conversationId !== undefined) {
|
|
37
|
+
line("");
|
|
38
|
+
line(`Conversation #${conversationId}. Recent transcript:`);
|
|
39
|
+
line(formatLog(await readLog(runtime.harness, conversationId, runtime.context, 12)));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export async function showLog(runtime, rawId) {
|
|
43
|
+
const id = parseId(rawId);
|
|
44
|
+
const conversationId = await jobConversationId(runtime.harness, id, runtime.context);
|
|
45
|
+
if (conversationId === undefined) {
|
|
46
|
+
line(`Job #${id} has no conversation yet.`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
line(formatLog(await readLog(runtime.harness, conversationId, runtime.context, 40)));
|
|
50
|
+
}
|
|
51
|
+
export async function startJob(runtime, rawBrief, options = {}) {
|
|
52
|
+
const brief = normalizeBrief(rawBrief);
|
|
53
|
+
if (options.resume === true)
|
|
54
|
+
runtime.harness.resume();
|
|
55
|
+
const started = await runtime.root.commit((tx) => createJobInCommit(tx, brief, runtime.model, runtime.jobExtensions, runtime.cwd, {
|
|
56
|
+
...jobCreateOptionsOf(runtime.config),
|
|
57
|
+
notifyMain: true,
|
|
58
|
+
}), runtime.context);
|
|
59
|
+
line(`Started job #${started.taskId} in conversation #${started.conversationId}.`);
|
|
60
|
+
try {
|
|
61
|
+
await announceJobStart(runtime.root, started, brief, runtime.context);
|
|
62
|
+
line("Main conversation notified.");
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
line(`! could not notify main: ${error instanceof Error ? error.message : String(error)}`);
|
|
66
|
+
}
|
|
67
|
+
if (options.detach !== true) {
|
|
68
|
+
const controller = new AbortController();
|
|
69
|
+
const onSigint = () => controller.abort();
|
|
70
|
+
process.once("SIGINT", onSigint);
|
|
71
|
+
try {
|
|
72
|
+
await followJobs(runtime, { ids: [Number(started.taskId)], signal: controller.signal });
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
process.removeListener("SIGINT", onSigint);
|
|
76
|
+
}
|
|
77
|
+
const record = await jobRecord(runtime.harness, Number(started.taskId), runtime.context);
|
|
78
|
+
if (record !== undefined)
|
|
79
|
+
line(formatJobDetail(record, Date.now()));
|
|
80
|
+
}
|
|
81
|
+
return Number(started.taskId);
|
|
82
|
+
}
|
|
83
|
+
export async function sendJob(runtime, rawId, message, options = {}) {
|
|
84
|
+
const id = parseId(rawId);
|
|
85
|
+
line(`${options.steer === true ? "Steering" : "Sending to"} job #${id}…`);
|
|
86
|
+
const result = await sendToJob(runtime.harness, id, message, runtime.context, options);
|
|
87
|
+
if (result.status === "answered") {
|
|
88
|
+
line(result.answer ?? "(answered without text)");
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
line(`Job #${id} did not answer: ${result.reason}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
export async function cancelJob(runtime, rawId) {
|
|
95
|
+
const id = parseId(rawId);
|
|
96
|
+
const mark = await runtime.harness.abortTask(id, runtime.context);
|
|
97
|
+
if (mark === "terminal") {
|
|
98
|
+
line(`Job #${id} is already terminal.`);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
line(`Abort requested for job #${id}.`);
|
|
102
|
+
try {
|
|
103
|
+
const settled = await runtime.harness.waitForTask(id, withAbortSignal(AbortSignal.timeout(20_000), runtime.context));
|
|
104
|
+
line(`Job #${id} settled: ${settled.state.outcome.status}`);
|
|
105
|
+
}
|
|
106
|
+
catch {
|
|
107
|
+
line(`Job #${id} is still releasing; its abort mark is durable. Check \`task show ${id}\` later.`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
export async function compactMain(runtime, instructions) {
|
|
111
|
+
line("Compacting the main conversation…");
|
|
112
|
+
const result = await compactConversation(runtime.harness, runtime.root, instructions, runtime.context);
|
|
113
|
+
if (result.noop) {
|
|
114
|
+
line(`Compaction task #${result.taskId} produced no summary (nothing to compact or declined).`);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
line(`Compaction complete (task #${result.taskId}${result.entryId === undefined ? ", summary placed" : `, summary entry #${result.entryId}`}).`);
|
|
118
|
+
}
|
|
119
|
+
export async function resetMain(runtime, handoff) {
|
|
120
|
+
const clean = handoff === undefined || handoff.trim().length === 0 ? undefined : handoff;
|
|
121
|
+
await runtime.root.reset(clean, runtime.context);
|
|
122
|
+
line(clean === undefined
|
|
123
|
+
? "Reset admitted: the next context starts empty. Raw history is retained."
|
|
124
|
+
: "Reset admitted: the next context starts from the handoff. Raw history is retained.");
|
|
125
|
+
}
|
|
126
|
+
export async function compactJob(runtime, rawId, instructions) {
|
|
127
|
+
const id = parseId(rawId);
|
|
128
|
+
const conversation = await findJobConversation(runtime.harness, id, runtime.context);
|
|
129
|
+
if (conversation === undefined) {
|
|
130
|
+
line(`Job #${id} has no conversation.`);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
line(`Compacting job #${id} (conversation #${conversation.id})…`);
|
|
134
|
+
const result = await compactConversation(runtime.harness, conversation, instructions, runtime.context);
|
|
135
|
+
if (result.noop) {
|
|
136
|
+
line(`Compaction task #${result.taskId} produced no summary.`);
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
line(`Compaction complete (task #${result.taskId}${result.entryId === undefined ? ", summary placed" : `, summary entry #${result.entryId}`}).`);
|
|
140
|
+
}
|
|
141
|
+
export async function resetJob(runtime, rawId, handoff) {
|
|
142
|
+
const id = parseId(rawId);
|
|
143
|
+
const conversation = await findJobConversation(runtime.harness, id, runtime.context);
|
|
144
|
+
if (conversation === undefined) {
|
|
145
|
+
line(`Job #${id} has no conversation.`);
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const clean = handoff === undefined || handoff.trim().length === 0 ? undefined : handoff;
|
|
149
|
+
await conversation.reset(clean, runtime.context);
|
|
150
|
+
line(`Reset admitted for job #${id}${clean === undefined ? "" : " with a handoff"}. Raw history is retained.`);
|
|
151
|
+
}
|
|
152
|
+
export async function followAll(runtime, follow) {
|
|
153
|
+
const controller = new AbortController();
|
|
154
|
+
const onSigint = () => controller.abort();
|
|
155
|
+
process.once("SIGINT", onSigint);
|
|
156
|
+
try {
|
|
157
|
+
await followJobs(runtime, { follow, signal: controller.signal });
|
|
158
|
+
}
|
|
159
|
+
finally {
|
|
160
|
+
process.removeListener("SIGINT", onSigint);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
export async function printInfo(runtime) {
|
|
164
|
+
const view = await runtime.root.context(runtime.context);
|
|
165
|
+
const tokens = estimateContextTokens(view);
|
|
166
|
+
const window = runtime.config.contextWindow;
|
|
167
|
+
line(`Config: ${runtime.config.configPath}${runtime.config.configFound ? "" : " (not found; built-ins)"}`);
|
|
168
|
+
if (runtime.config.configPaths.length > 1)
|
|
169
|
+
line(`Layers: ${runtime.config.configPaths.join(" → ")} (low → high)`);
|
|
170
|
+
line(`Store: ${runtime.storePath}`);
|
|
171
|
+
if (runtime.previousStateArchive !== undefined)
|
|
172
|
+
line(`Archive: ${runtime.previousStateArchive}`);
|
|
173
|
+
if (runtime.restoredFrom !== undefined)
|
|
174
|
+
line(`Restored: ${runtime.restoredFrom}`);
|
|
175
|
+
line(`Model: ${runtime.modelLabel}`);
|
|
176
|
+
line(`Limits: context ${runtime.config.contextWindow}, output ${runtime.config.maxTokens}, timeout ${runtime.config.streamTimeoutMs}ms, thinking ${runtime.config.thinkingLevel}`);
|
|
177
|
+
line(`Context: ~${formatTokenCount(tokens)} / ${formatTokenCount(window)} (${contextPercent(tokens, window).toFixed(0)}%; compact at ~${formatTokenCount(compactionLimit(window))})`);
|
|
178
|
+
line(`Jobs: ${runtime.config.autoContinue ? "auto-continue main on completion" : "passive completion notices"}`);
|
|
179
|
+
line(`Workspace: ${runtime.cwd}`);
|
|
180
|
+
line(`Main tools: ${[...(runtime.tasksExtension.tools?.map((tool) => tool.name) ?? []), ...(runtime.codemodeExtension === undefined ? [] : ["codemode"])].join(", ")}`);
|
|
181
|
+
// `pi.codemode.*` tools are script globals (the `models` catalog), not tools the model is offered.
|
|
182
|
+
const jobTools = runtime.jobExtensions
|
|
183
|
+
.flatMap((extension) => extension.tools?.map((tool) => tool.name) ?? [])
|
|
184
|
+
.filter((name) => !name.startsWith("pi.codemode."));
|
|
185
|
+
line(`Job tools: ${jobTools.length === 0 ? "(none)" : jobTools.join(", ")}`);
|
|
186
|
+
line(`MCP: ${runtime.mcpAttempted ? (runtime.mcpConnected ? "substrate connected" : "substrate unavailable") : "not checked by this command"}`);
|
|
187
|
+
for (const note of runtime.mcpNotes)
|
|
188
|
+
line(` · ${note}`);
|
|
189
|
+
for (const warning of runtime.config.warnings)
|
|
190
|
+
line(` ! ${warning}`);
|
|
191
|
+
}
|
|
192
|
+
export function printHelp(command = "main") {
|
|
193
|
+
if (command === "jobs") {
|
|
194
|
+
line("task add <brief> [--detach] start a background agent job");
|
|
195
|
+
line("task show <id> job status, answer, recent transcript");
|
|
196
|
+
line("task log <id> recent job transcript");
|
|
197
|
+
line("task send <id> <message> [--steer] continue the job conversation, or steer its run");
|
|
198
|
+
line("task cancel <id> abort a running job");
|
|
199
|
+
line("task compact <id> [focus] compact the job conversation");
|
|
200
|
+
line("task reset <id> [handoff] reset the job context");
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
line("durable-chat full-screen TUI dashboard");
|
|
204
|
+
line("durable-chat --plain line-oriented chat (same runtime)");
|
|
205
|
+
line("durable-chat ask <text> one-shot message to the main agent (--wait joins jobs)");
|
|
206
|
+
line("durable-chat tui force the TUI even if chat was implied");
|
|
207
|
+
line("durable-chat task add <brief> start a background job (--detach returns at once)");
|
|
208
|
+
line("durable-chat tasks list jobs");
|
|
209
|
+
line("durable-chat task <id> show a job");
|
|
210
|
+
line("durable-chat task log <id> recent job transcript");
|
|
211
|
+
line("durable-chat task send <id> <m> [--steer] continue or steer a job");
|
|
212
|
+
line("durable-chat task cancel <id> abort a job");
|
|
213
|
+
line("durable-chat watch [--follow] live job board until jobs settle");
|
|
214
|
+
line("durable-chat compact [focus] compact the main conversation");
|
|
215
|
+
line("durable-chat reset [handoff] reset the main context");
|
|
216
|
+
line("durable-chat info store, model, limits, tools, MCP status");
|
|
217
|
+
line("durable-chat state fork fork the selected state into this folder (--store selects a source)");
|
|
218
|
+
line("durable-chat config ... path/show/keys/init/edit/get/set/unset");
|
|
219
|
+
line("");
|
|
220
|
+
line("In chat: /tasks /task <id> /log <id> /new <brief> /send <id> <msg> /steer <id> <msg>");
|
|
221
|
+
line(" /cancel <id> /compact [focus] /reset [handoff] /model [id] /provider [name] /thinking [level] /wait /info /reboot /rollback [path] /quit");
|
|
222
|
+
}
|
|
223
|
+
export function parseId(raw) {
|
|
224
|
+
if (raw === undefined || !/^[0-9]+$/.test(raw))
|
|
225
|
+
throw new Error("Provide a numeric job id.");
|
|
226
|
+
return Number(raw);
|
|
227
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { configEditPath, configKeys, localConfigPath, describeConfig, effectiveValue, initConfigFile, resolveConfig, setConfigValue, unsetConfigValue, } from "./config.js";
|
|
4
|
+
function out(text) {
|
|
5
|
+
process.stdout.write(`${text}\n`);
|
|
6
|
+
}
|
|
7
|
+
function overridesFor(configPath) {
|
|
8
|
+
return configPath === undefined ? {} : { configPath };
|
|
9
|
+
}
|
|
10
|
+
function requireArg(value, usage) {
|
|
11
|
+
if (value === undefined || value.trim() === "")
|
|
12
|
+
throw new Error(`Usage: durable-chat ${usage}`);
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
const ENV_FOR_KEY = {
|
|
16
|
+
store: "DURABLE_STORE",
|
|
17
|
+
provider: "DURABLE_PROVIDER",
|
|
18
|
+
model: "DURABLE_MODEL_ID",
|
|
19
|
+
baseUrl: "DURABLE_BASE_URL",
|
|
20
|
+
contextWindow: "DURABLE_CONTEXT_WINDOW",
|
|
21
|
+
maxTokens: "DURABLE_MAX_TOKENS",
|
|
22
|
+
streamTimeoutMs: "DURABLE_STREAM_TIMEOUT_MS",
|
|
23
|
+
retries: "DURABLE_RETRIES",
|
|
24
|
+
thinkingLevel: "DURABLE_THINKING_LEVEL",
|
|
25
|
+
maxTurns: "DURABLE_MAX_TURNS",
|
|
26
|
+
jobMaxTurns: "DURABLE_JOB_MAX_TURNS",
|
|
27
|
+
autoContinue: "DURABLE_AUTO_CONTINUE",
|
|
28
|
+
"mcp.enabled": "DURABLE_MCP_ENABLED",
|
|
29
|
+
"mcp.servers": "DURABLE_MCP_SERVERS",
|
|
30
|
+
"mcp.tools": "DURABLE_MCP_TOOLS",
|
|
31
|
+
"mcp.config": "DURABLE_MCP_CONFIG",
|
|
32
|
+
};
|
|
33
|
+
function warnIfShadowed(key) {
|
|
34
|
+
const name = ENV_FOR_KEY[key];
|
|
35
|
+
if (name !== undefined && process.env[name] !== undefined && process.env[name] !== "") {
|
|
36
|
+
out(`note: ${name} is set and overrides this key for now.`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function warnIfUnresolved(configPath) {
|
|
40
|
+
try {
|
|
41
|
+
resolveConfig(overridesFor(configPath));
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
out(`note: the config does not resolve yet: ${error instanceof Error ? error.message : String(error)}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* `config` subcommands. `set` and `unset` edit the YAML document in place, so
|
|
49
|
+
* comments and key order survive; every write is type-checked before it lands.
|
|
50
|
+
*/
|
|
51
|
+
export function runConfigCommand(args, options = {}) {
|
|
52
|
+
const [sub, ...rest] = args;
|
|
53
|
+
const explicit = options.configPath !== undefined || (process.env.DURABLE_CHAT_CONFIG?.trim() ?? "") !== "";
|
|
54
|
+
if (options.local === true && explicit)
|
|
55
|
+
throw new Error("--local cannot be combined with --config or DURABLE_CHAT_CONFIG.");
|
|
56
|
+
const configPath = options.local === true ? localConfigPath() : configEditPath(options.configPath);
|
|
57
|
+
const local = !explicit && configPath === localConfigPath();
|
|
58
|
+
const overrides = overridesFor(options.configPath);
|
|
59
|
+
switch (sub ?? "show") {
|
|
60
|
+
case "path":
|
|
61
|
+
out(configPath);
|
|
62
|
+
return;
|
|
63
|
+
case "show":
|
|
64
|
+
for (const line of describeConfig(resolveConfig(overrides)))
|
|
65
|
+
out(line);
|
|
66
|
+
return;
|
|
67
|
+
case "keys":
|
|
68
|
+
for (const key of configKeys())
|
|
69
|
+
out(key);
|
|
70
|
+
return;
|
|
71
|
+
case "init": {
|
|
72
|
+
const written = initConfigFile(configPath, { force: options.force === true, local });
|
|
73
|
+
out(`Created ${written}`);
|
|
74
|
+
out("Change one key with `durable-chat config set <key> <value>`, or open it with `durable-chat config edit`.");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
case "edit": {
|
|
78
|
+
if (!existsSync(configPath)) {
|
|
79
|
+
initConfigFile(configPath, { local });
|
|
80
|
+
out(`Created ${configPath}`);
|
|
81
|
+
}
|
|
82
|
+
const editor = process.env.VISUAL ?? process.env.EDITOR;
|
|
83
|
+
if (editor === undefined || editor.trim() === "") {
|
|
84
|
+
out(`No $VISUAL or $EDITOR set. Edit ${configPath} directly.`);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const [command, ...editorArgs] = editor.trim().split(/\s+/);
|
|
88
|
+
const result = spawnSync(command, [...editorArgs, configPath], { stdio: "inherit" });
|
|
89
|
+
if (result.error !== undefined)
|
|
90
|
+
throw new Error(`Could not run ${editor}: ${result.error.message}`);
|
|
91
|
+
if (result.status !== 0) {
|
|
92
|
+
process.exitCode = result.status ?? 1;
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
resolveConfig(overrides);
|
|
97
|
+
out("config valid");
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
process.stderr.write(`config error: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
101
|
+
process.exitCode = 1;
|
|
102
|
+
}
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
case "get": {
|
|
106
|
+
const key = requireArg(rest[0], "config get <key>");
|
|
107
|
+
out(effectiveValue(resolveConfig(overrides), key));
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
case "set": {
|
|
111
|
+
const key = requireArg(rest[0], "config set <key> <value>");
|
|
112
|
+
const value = requireArg(rest.slice(1).join(" "), "config set <key> <value>");
|
|
113
|
+
const written = setConfigValue(configPath, key, value);
|
|
114
|
+
out(`${written.key} = ${JSON.stringify(written.value)} (${configPath})`);
|
|
115
|
+
warnIfShadowed(key);
|
|
116
|
+
warnIfUnresolved(options.configPath);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
case "unset": {
|
|
120
|
+
const key = requireArg(rest[0], "config unset <key>");
|
|
121
|
+
const removed = unsetConfigValue(configPath, key);
|
|
122
|
+
out(removed ? `Removed ${key} from ${configPath}` : `${key} was not set in ${configPath}`);
|
|
123
|
+
warnIfUnresolved(options.configPath);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
default:
|
|
127
|
+
throw new Error(`Unknown config command "${sub}". Try path, show, keys, init, edit, get, set, or unset.`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
export function printConfigHelp() {
|
|
131
|
+
out("");
|
|
132
|
+
out("Config commands:");
|
|
133
|
+
out("durable-chat config path show the active edit target (local if present, otherwise global)");
|
|
134
|
+
out("durable-chat config show print the effective values");
|
|
135
|
+
out("durable-chat config keys list editable keys");
|
|
136
|
+
out("durable-chat config init [--local] [--force] create a config (--local creates folder overrides)");
|
|
137
|
+
out("Add --local to config commands to target .durable-chat/config.yaml; --config selects a standalone file.");
|
|
138
|
+
out("durable-chat config edit open the file in $VISUAL/$EDITOR");
|
|
139
|
+
out("durable-chat config get <key> print one effective value");
|
|
140
|
+
out("durable-chat config set <key> <v> edit one key in place");
|
|
141
|
+
out("durable-chat config unset <key> remove one key");
|
|
142
|
+
}
|