@gaunt-sloth/core 2.0.0-alpha.3 → 2.0.0-alpha.4

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.
@@ -0,0 +1,84 @@
1
+ import { StatusLevel } from '#src/core/types.js';
2
+ /**
3
+ * Default config
4
+ */
5
+ export declare const DEFAULT_CONFIG: {
6
+ readonly contentSource: "file";
7
+ readonly requirementSource: "file";
8
+ /**
9
+ * Path to project-specific guidelines.
10
+ * The default is `.gsloth.guidelines.md`; this config may be used to point Gaunt Sloth to a different file,
11
+ * for example, to AGENTS.md
12
+ */
13
+ readonly projectGuidelines: ".gsloth.guidelines.md";
14
+ /**
15
+ * Whether to include the current date in the project review instructions or not.
16
+ */
17
+ readonly includeCurrentDateAfterGuidelines: false;
18
+ readonly projectReviewInstructions: ".gsloth.review.md";
19
+ readonly filesystem: "none";
20
+ readonly debugLog: false;
21
+ readonly consoleLevel: StatusLevel.INFO;
22
+ /**
23
+ * Default source for both requirements and content is GitHub.
24
+ * It needs GitHub CLI (gh).
25
+ *
26
+ * `github` content source uses `gh pr diff NN` internally. {@link src/sources/ghPrDiffSource.ts!}
27
+ *
28
+ *
29
+ * `github` requirement source uses `gh issue view NN` internally
30
+ */
31
+ readonly commands: {
32
+ readonly pr: {
33
+ readonly contentSource: "github";
34
+ readonly requirementSource: "github";
35
+ readonly rating: {
36
+ readonly enabled: true;
37
+ readonly passThreshold: 6;
38
+ readonly minRating: 0;
39
+ readonly maxRating: 10;
40
+ readonly errorOnReviewFail: true;
41
+ };
42
+ };
43
+ readonly review: {
44
+ readonly rating: {
45
+ readonly enabled: true;
46
+ readonly passThreshold: 6;
47
+ readonly minRating: 0;
48
+ readonly maxRating: 10;
49
+ readonly errorOnReviewFail: true;
50
+ };
51
+ };
52
+ readonly ask: {
53
+ readonly filesystem: "read";
54
+ };
55
+ readonly chat: {
56
+ readonly filesystem: "read";
57
+ };
58
+ readonly code: {
59
+ readonly filesystem: "all";
60
+ };
61
+ readonly exec: {
62
+ readonly filesystem: "all";
63
+ };
64
+ readonly api: {
65
+ readonly filesystem: "read";
66
+ readonly port: 3000;
67
+ readonly cors: {
68
+ readonly allowOrigin: "http://localhost:3000";
69
+ readonly allowMethods: "POST, GET, OPTIONS";
70
+ readonly allowHeaders: "Content-Type, Accept";
71
+ };
72
+ };
73
+ };
74
+ readonly streamOutput: true;
75
+ readonly writeOutputToFile: true;
76
+ readonly writeBinaryOutputsToFile: true;
77
+ readonly useColour: true;
78
+ readonly streamSessionInferenceLog: true;
79
+ readonly canInterruptInferenceWithEsc: true;
80
+ readonly aiignore: {
81
+ readonly enabled: true;
82
+ readonly patterns: undefined;
83
+ };
84
+ };
@@ -0,0 +1,97 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * Default Gaunt Sloth configuration ({@link DEFAULT_CONFIG}). Extracted verbatim from
4
+ * the former `config.ts` god-file; values are unchanged.
5
+ */
6
+ import { PROJECT_GUIDELINES, PROJECT_REVIEW_INSTRUCTIONS } from '#src/constants.js';
7
+ import { StatusLevel } from '#src/core/types.js';
8
+ /**
9
+ * Default config
10
+ */
11
+ export const DEFAULT_CONFIG = {
12
+ contentSource: 'file',
13
+ requirementSource: 'file',
14
+ /**
15
+ * Path to project-specific guidelines.
16
+ * The default is `.gsloth.guidelines.md`; this config may be used to point Gaunt Sloth to a different file,
17
+ * for example, to AGENTS.md
18
+ */
19
+ projectGuidelines: PROJECT_GUIDELINES,
20
+ /**
21
+ * Whether to include the current date in the project review instructions or not.
22
+ */
23
+ includeCurrentDateAfterGuidelines: false,
24
+ projectReviewInstructions: PROJECT_REVIEW_INSTRUCTIONS,
25
+ filesystem: 'none',
26
+ debugLog: false,
27
+ consoleLevel: StatusLevel.INFO, // Default to INFO level, not debug
28
+ /**
29
+ * Default source for both requirements and content is GitHub.
30
+ * It needs GitHub CLI (gh).
31
+ *
32
+ * `github` content source uses `gh pr diff NN` internally. {@link src/sources/ghPrDiffSource.ts!}
33
+ *
34
+ *
35
+ * `github` requirement source uses `gh issue view NN` internally
36
+ */
37
+ commands: {
38
+ pr: {
39
+ contentSource: 'github',
40
+ requirementSource: 'github',
41
+ rating: {
42
+ enabled: true,
43
+ passThreshold: 6,
44
+ minRating: 0,
45
+ maxRating: 10,
46
+ errorOnReviewFail: true,
47
+ },
48
+ },
49
+ review: {
50
+ rating: {
51
+ enabled: true,
52
+ passThreshold: 6,
53
+ minRating: 0,
54
+ maxRating: 10,
55
+ errorOnReviewFail: true,
56
+ },
57
+ },
58
+ ask: {
59
+ filesystem: 'read',
60
+ },
61
+ chat: {
62
+ filesystem: 'read',
63
+ },
64
+ code: {
65
+ filesystem: 'all',
66
+ },
67
+ exec: {
68
+ filesystem: 'all',
69
+ },
70
+ api: {
71
+ filesystem: 'read',
72
+ port: 3000,
73
+ cors: {
74
+ allowOrigin: 'http://localhost:3000',
75
+ allowMethods: 'POST, GET, OPTIONS',
76
+ allowHeaders: 'Content-Type, Accept',
77
+ },
78
+ },
79
+ },
80
+ streamOutput: true,
81
+ writeOutputToFile: true,
82
+ writeBinaryOutputsToFile: true,
83
+ useColour: true,
84
+ streamSessionInferenceLog: true,
85
+ canInterruptInferenceWithEsc: true,
86
+ aiignore: {
87
+ enabled: true,
88
+ patterns: undefined,
89
+ },
90
+ };
91
+ /**
92
+ * Needed DEFAULT_CONFIG to be plain const to be picked up by typedoc,
93
+ * this cast here is just for typecheck.
94
+ */
95
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
96
+ DEFAULT_CONFIG;
97
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/config/defaults.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG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;QACR,OAAO,EAAE,IAAI;QACb,QAAQ,EAAE,SAAS;KACpB;CACO,CAAC;AAEX;;;GAGG;AACH,oEAAoE;AACpE,cAA2B,CAAC"}
@@ -0,0 +1,88 @@
1
+ import type { CommandLineConfigOverrides, ConsoleLevelInput, GthConfig, RawGthConfig } from '#src/config/types.js';
2
+ /**
3
+ * Find THE project config by walking up from cwd toward a stop boundary, returning the FIRST
4
+ * match (first-match-win: nearest dir, then format precedence within that dir — NOT a merged
5
+ * stack). Detection ({@link hasProjectConfig}/{@link hasAnyConfig}) and loading ({@link initConfig})
6
+ * both go through this, so they can never disagree.
7
+ *
8
+ * Stop boundary — the dir is SEARCHED, then ascent stops at: a dir containing `.git` (the git
9
+ * root), the user's home dir, or the filesystem root — whichever comes first. So a config IN the
10
+ * git root (or home) is found; a config ABOVE it is not.
11
+ *
12
+ * A `customConfigPath` override wins outright (no walking).
13
+ *
14
+ * @returns the matched `{ dir, path }`, or `undefined` when no project config exists within the
15
+ * boundary.
16
+ */
17
+ export declare function findProjectConfigPath(commandLineConfigOverrides: CommandLineConfigOverrides): {
18
+ dir: string;
19
+ path: string;
20
+ } | undefined;
21
+ /**
22
+ * Loads the global gsloth config (if present) from the global `~/.gsloth` folder.
23
+ *
24
+ * Precedence support: the returned raw config is intended to act as the BASE that the
25
+ * project config (and CLI overrides) merge on top of, so any value here is the lowest
26
+ * user-controlled layer (still above {@link DEFAULT_CONFIG}).
27
+ *
28
+ * Lookup order within the global folder, first match wins:
29
+ * `.gsloth.config.json` -> `.gsloth.config.js` -> `.gsloth.config.mjs`
30
+ *
31
+ * Absence of every variant is a no-op: returns `undefined` so behaviour is unchanged.
32
+ *
33
+ * NOTE: secrets (API keys) may live in this file; this function must never log its
34
+ * contents. Only non-sensitive diagnostics (the resolved path / parse failure) are emitted.
35
+ *
36
+ * @returns The raw global config object, or `undefined` when no global config exists.
37
+ */
38
+ export declare function loadGlobalRawConfig(): Promise<Partial<RawGthConfig> | undefined>;
39
+ /**
40
+ * ORDERING INVARIANT (GS2-11): detection ({@link hasProjectConfig}/{@link hasAnyConfig}) MUST run
41
+ * before {@link initConfig} in a given process. Both resolve cwd-level candidates via
42
+ * `getGslothConfigReadPath`, which reads `getProjectDir()`; {@link initConfig} clears `projectDir`
43
+ * at the start of its run, so detection stays cwd-correct as long as it precedes initConfig (it
44
+ * does: startSession calls hasAnyConfig before any initConfig, and the ACP/agent path calls
45
+ * initConfig directly without detection). Calling detection AFTER an initConfig with a changed cwd
46
+ * in a long-lived process would read a stale projectDir (currently unreachable). If that call
47
+ * order is ever introduced, decouple discovery's cwd-branch from `getProjectDir()`.
48
+ */
49
+ /**
50
+ * Returns true when a project-level config file (json/js/mjs) exists for the given
51
+ * overrides. Honours `customConfigPath` and the active identity profile so the check
52
+ * matches exactly what {@link initConfig} would attempt to load.
53
+ *
54
+ * This is the project half of CFG-10's "is any config present?" detection; the global
55
+ * half is {@link loadGlobalRawConfig} (used by {@link hasAnyConfig}).
56
+ */
57
+ export declare function hasProjectConfig(commandLineConfigOverrides: CommandLineConfigOverrides): boolean;
58
+ /**
59
+ * CFG-10 — true when ANY usable configuration is present, either a project config file
60
+ * (json/js/mjs) or a standalone global config (`~/.gsloth/.gsloth.config.*`). When this
61
+ * returns false the caller should run the first-run dialog instead of erroring.
62
+ *
63
+ * Reuses CFG-8's project + global detection so the two paths can never disagree.
64
+ */
65
+ export declare function hasAnyConfig(commandLineConfigOverrides: CommandLineConfigOverrides): Promise<boolean>;
66
+ /**
67
+ * Initialize configuration by loading from available config files
68
+ * @returns The loaded GthConfig
69
+ */
70
+ export declare function initConfig(commandLineConfigOverrides: CommandLineConfigOverrides): Promise<GthConfig>;
71
+ /**
72
+ * Process JSON LLM config by creating the appropriate LLM instance
73
+ * @param jsonConfig - The parsed JSON config
74
+ * @param commandLineConfigOverrides - command line config overrides
75
+ * @returns Promise<GthConfig>
76
+ */
77
+ export declare function tryJsonConfig(jsonConfig: RawGthConfig, commandLineConfigOverrides: CommandLineConfigOverrides): Promise<GthConfig>;
78
+ /**
79
+ * Resolve a fully-merged {@link GthConfig} from a partial config + CLI overrides WITHOUT
80
+ * any global side effects (a pure transform). It deep-merges defaults, applies CLI overrides,
81
+ * resolves the numeric `consoleLevel` (warning + defaulting to INFO on an invalid value), and
82
+ * computes `canInterruptInferenceWithEsc`. The process-global setters (`setUseColour` /
83
+ * `setConsoleLevel`) are applied separately by {@link mergeConfig}, so this function can be
84
+ * reasoned about and reused without touching global state.
85
+ */
86
+ export declare function resolveConfig(partialConfig: Omit<Partial<GthConfig>, 'consoleLevel'> & {
87
+ consoleLevel?: ConsoleLevelInput;
88
+ }, commandLineConfigOverrides: CommandLineConfigOverrides): GthConfig;