topchester-ai 0.43.0 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -117,16 +117,12 @@ Do not commit API keys. Put keys in environment variables, a user config file, o
117
117
 
118
118
  Topchester reads config in this order, with later entries overriding earlier ones:
119
119
 
120
- 1. `~/.config/topchester/config.yaml`
120
+ 1. `topchester.jsonc`
121
121
  2. `~/.config/topchester/config.jsonc`
122
- 3. `topchester.yaml`
123
- 4. `topchester.jsonc`
124
- 5. `.topchester/config.local.yaml`
125
- 6. `.topchester/config.local.jsonc`
126
- 7. `TOPCHESTER_CONFIG`
127
- 8. `--config <path>`
122
+ 3. `TOPCHESTER_CONFIG`
123
+ 4. `--config <path>`
128
124
 
129
- Prefer `topchester.jsonc` for new project config. YAML paths are kept for compatibility.
125
+ On first startup, Topchester creates `~/.config/topchester/config.jsonc` with a commented minimal example. Uncomment it to set your personal default model, or keep shared project policy in `topchester.jsonc`.
130
126
 
131
127
  ## How The Knowledge Base Works
132
128
 
@@ -166,11 +162,12 @@ The package name is `topchester-ai`; the installed command is `topchester`.
166
162
  ## Read More
167
163
 
168
164
  - [Onboarding](onboarding.md)
169
- - [CLI Commands](docs/cli.md)
170
- - [TUI Guide](docs/tui.md)
171
- - [Skills](docs/skills.md)
172
- - [Configuration](docs/config.md)
173
- - [Model Configuration](docs/MODEL_CONFIG.md)
174
- - [Knowledge System](docs/KNOWLEDGE.md)
175
- - [Architecture](docs/ARCHITECTURE.md)
176
- - [Sessions](docs/SESSIONS.md)
165
+ - [Docs](docs/README.md)
166
+ - [Quickstart](docs/getting-started/quickstart.md)
167
+ - [CLI Commands](docs/reference/cli.md)
168
+ - [TUI](docs/features/tui.md)
169
+ - [Skills](docs/features/skills.md)
170
+ - [Configuration](docs/configuration/config-files.md)
171
+ - [Models and providers](docs/configuration/models-and-providers.md)
172
+ - [Knowledge base](docs/features/knowledge-base.md)
173
+ - [Sessions](docs/features/sessions.md)
package/dist/bin.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { t as runTopchesterCli } from "./cli-CVWQPq7z.mjs";
2
+ import { t as runTopchesterCli } from "./cli-Cz5puJBe.mjs";
3
3
  //#region src/bin.ts
4
4
  await runTopchesterCli();
5
5
  //#endregion
@@ -7,9 +7,9 @@ import { generateText, stepCountIs, streamText, tool } from "ai";
7
7
  import { ZodError, z } from "zod";
8
8
  import { access, mkdir, open, readFile, readdir, realpath, rename, rm, stat, truncate, writeFile } from "node:fs/promises";
9
9
  import { execFile, spawn } from "node:child_process";
10
- import { constants, existsSync, mkdirSync, readFileSync, statSync } from "node:fs";
10
+ import { constants, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
11
11
  import { createHash, randomUUID } from "node:crypto";
12
- import { parse as parse$1, parseDocument } from "yaml";
12
+ import { parseDocument } from "yaml";
13
13
  import { fileURLToPath } from "node:url";
14
14
  import { homedir } from "node:os";
15
15
  import pino from "pino";
@@ -5668,12 +5668,18 @@ function ensureGlobalTopchesterConfigDir() {
5668
5668
  });
5669
5669
  return dir;
5670
5670
  }
5671
+ function ensureGlobalTopchesterConfigFile() {
5672
+ const configPath = getGlobalTopchesterConfigPath();
5673
+ if (!existsSync(configPath)) {
5674
+ ensureGlobalTopchesterConfigDir();
5675
+ writeFileSync(configPath, getCommentedStarterConfig(), { mode: 384 });
5676
+ }
5677
+ return configPath;
5678
+ }
5671
5679
  function loadTopchesterConfig(options) {
5672
5680
  const globalConfigDir = getGlobalTopchesterConfigDir();
5673
5681
  const paths = [
5674
- join(options.workspaceRoot, "topchester.yaml"),
5675
5682
  join(options.workspaceRoot, "topchester.jsonc"),
5676
- join(globalConfigDir, "config.yaml"),
5677
5683
  join(globalConfigDir, "config.jsonc"),
5678
5684
  process.env.TOPCHESTER_CONFIG,
5679
5685
  options.configPath
@@ -5821,11 +5827,100 @@ function ensureStringArrayProperty(parent, key) {
5821
5827
  }
5822
5828
  function readConfigFile(path) {
5823
5829
  try {
5824
- return parse$1(readFileSync(path, "utf8"));
5830
+ return parseJsonc(readFileSync(path, "utf8"));
5825
5831
  } catch (error) {
5826
5832
  throw new Error(`Invalid Topchester config at ${path}: ${formatErrorMessage$1(error)}`);
5827
5833
  }
5828
5834
  }
5835
+ function parseJsonc(source) {
5836
+ const stripped = stripJsoncSyntax(source);
5837
+ return stripped.trim() ? JSON.parse(stripped) : {};
5838
+ }
5839
+ function getCommentedStarterConfig() {
5840
+ return [
5841
+ "// Uncomment and edit this minimal config to choose a default model.",
5842
+ "// {",
5843
+ "// \"models\": {",
5844
+ "// \"default\": \"openrouter/google/gemini-3.1-flash-lite\",",
5845
+ "// },",
5846
+ "// }",
5847
+ ""
5848
+ ].join("\n");
5849
+ }
5850
+ function stripJsoncSyntax(source) {
5851
+ let output = "";
5852
+ let inString = false;
5853
+ let escaped = false;
5854
+ for (let index = 0; index < source.length; index += 1) {
5855
+ const char = source[index];
5856
+ const next = source[index + 1];
5857
+ if (inString) {
5858
+ output += char;
5859
+ if (escaped) escaped = false;
5860
+ else if (char === "\\") escaped = true;
5861
+ else if (char === "\"") inString = false;
5862
+ continue;
5863
+ }
5864
+ if (char === "\"") {
5865
+ inString = true;
5866
+ output += char;
5867
+ continue;
5868
+ }
5869
+ if (char === "/" && next === "/") {
5870
+ output += " ";
5871
+ index += 2;
5872
+ while (index < source.length && source[index] !== "\n" && source[index] !== "\r") {
5873
+ output += " ";
5874
+ index += 1;
5875
+ }
5876
+ index -= 1;
5877
+ continue;
5878
+ }
5879
+ if (char === "/" && next === "*") {
5880
+ output += " ";
5881
+ index += 2;
5882
+ while (index < source.length && !(source[index] === "*" && source[index + 1] === "/")) {
5883
+ output += source[index] === "\n" || source[index] === "\r" ? source[index] : " ";
5884
+ index += 1;
5885
+ }
5886
+ if (index < source.length) {
5887
+ output += " ";
5888
+ index += 1;
5889
+ }
5890
+ continue;
5891
+ }
5892
+ if (char === "," && isTrailingJsonComma(source, index + 1)) {
5893
+ output += " ";
5894
+ continue;
5895
+ }
5896
+ output += char;
5897
+ }
5898
+ return output;
5899
+ }
5900
+ function isTrailingJsonComma(source, startIndex) {
5901
+ let index = startIndex;
5902
+ while (index < source.length) {
5903
+ const char = source[index];
5904
+ const next = source[index + 1];
5905
+ if (/\s/u.test(char)) {
5906
+ index += 1;
5907
+ continue;
5908
+ }
5909
+ if (char === "/" && next === "/") {
5910
+ index += 2;
5911
+ while (index < source.length && source[index] !== "\n" && source[index] !== "\r") index += 1;
5912
+ continue;
5913
+ }
5914
+ if (char === "/" && next === "*") {
5915
+ index += 2;
5916
+ while (index < source.length && !(source[index] === "*" && source[index + 1] === "/")) index += 1;
5917
+ index += 2;
5918
+ continue;
5919
+ }
5920
+ return char === "}" || char === "]";
5921
+ }
5922
+ return false;
5923
+ }
5829
5924
  function parseConfigFile(path, value) {
5830
5925
  const raw = rawTopchesterConfigSchema.safeParse(value ?? {});
5831
5926
  if (!raw.success) throw new Error(`Invalid Topchester config at ${path}: ${raw.error.issues.map(formatZodIssue).join("; ")}`);
@@ -6041,7 +6136,7 @@ function normalizeLogLevel(level) {
6041
6136
  //#endregion
6042
6137
  //#region src/app/context.ts
6043
6138
  function createAppContext(options) {
6044
- ensureGlobalTopchesterConfigDir();
6139
+ ensureGlobalTopchesterConfigFile();
6045
6140
  const config = loadTopchesterConfig(options);
6046
6141
  const modelGateway = createModelGatewayFromConfig(config);
6047
6142
  const loggerInfo = createTopchesterLogger(options.workspaceRoot);
@@ -12050,6 +12145,11 @@ var TopchesterAgentRuntime = class TopchesterAgentRuntime {
12050
12145
  else {
12051
12146
  const approval = await this.resolveBashApproval(executableToolCall, toolCall.id, options, session, abortSignal);
12052
12147
  for (const event of approval.events) yield event;
12148
+ if (approval.cancelled && approval.stopped) {
12149
+ if (!approval.events.some((event) => event.type === "message" && event.text === approval.reason)) yield agentEvent.systemMessage(approval.reason);
12150
+ yield agentEvent.status("ready");
12151
+ return;
12152
+ }
12053
12153
  if (approval.cancelled) toolResult = createToolErrorResult(executableToolCall.tool, approval.reason);
12054
12154
  else {
12055
12155
  const toolEventQueue = createRuntimeEventQueue();
@@ -12293,9 +12393,15 @@ var TopchesterAgentRuntime = class TopchesterAgentRuntime {
12293
12393
  abortSignal
12294
12394
  });
12295
12395
  const events = this.hookResultToEvents(actionRequiredHook);
12296
- if (actionRequiredHook.blocked || actionRequiredHook.stopped) return {
12396
+ if (actionRequiredHook.stopped) return {
12397
+ cancelled: true,
12398
+ stopped: true,
12399
+ reason: actionRequiredHook.stopped.message,
12400
+ events
12401
+ };
12402
+ if (actionRequiredHook.blocked) return {
12297
12403
  cancelled: true,
12298
- reason: (actionRequiredHook.blocked ?? actionRequiredHook.stopped).message,
12404
+ reason: actionRequiredHook.blocked.message,
12299
12405
  events
12300
12406
  };
12301
12407
  const approval = await options.requestBashApproval({
@@ -14163,4 +14269,4 @@ function formatDryRunSyncStatus(status) {
14163
14269
  //#endregion
14164
14270
  export { runTopchesterCli as t };
14165
14271
 
14166
- //# sourceMappingURL=cli-CVWQPq7z.mjs.map
14272
+ //# sourceMappingURL=cli-Cz5puJBe.mjs.map