@gaunt-sloth/core 2.0.0-alpha.2 → 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.
Files changed (53) hide show
  1. package/.gsloth.code.md +10 -0
  2. package/README.md +3 -4
  3. package/dist/config/defaults.d.ts +84 -0
  4. package/dist/config/defaults.js +97 -0
  5. package/dist/config/defaults.js.map +1 -0
  6. package/dist/config/loader.d.ts +88 -0
  7. package/dist/config/loader.js +604 -0
  8. package/dist/config/loader.js.map +1 -0
  9. package/dist/config/schema.d.ts +471 -0
  10. package/dist/config/schema.js +301 -0
  11. package/dist/config/schema.js.map +1 -0
  12. package/dist/config/shell-policy.d.ts +212 -0
  13. package/dist/config/shell-policy.js +142 -0
  14. package/dist/config/shell-policy.js.map +1 -0
  15. package/dist/config/types.d.ts +453 -0
  16. package/dist/config/types.js +12 -0
  17. package/dist/config/types.js.map +1 -0
  18. package/dist/config.d.ts +18 -647
  19. package/dist/config.js +15 -516
  20. package/dist/config.js.map +1 -1
  21. package/dist/constants.d.ts +6 -0
  22. package/dist/constants.js +6 -0
  23. package/dist/constants.js.map +1 -1
  24. package/dist/core/GthAbstractAgent.d.ts +24 -1
  25. package/dist/core/GthAbstractAgent.js +86 -4
  26. package/dist/core/GthAbstractAgent.js.map +1 -1
  27. package/dist/core/GthAgentRunner.d.ts +127 -1
  28. package/dist/core/GthAgentRunner.js +298 -4
  29. package/dist/core/GthAgentRunner.js.map +1 -1
  30. package/dist/core/shell/allowlist.d.ts +75 -0
  31. package/dist/core/shell/allowlist.js +187 -0
  32. package/dist/core/shell/allowlist.js.map +1 -0
  33. package/dist/core/shell/arity.d.ts +75 -0
  34. package/dist/core/shell/arity.js +313 -0
  35. package/dist/core/shell/arity.js.map +1 -0
  36. package/dist/core/shell/judge.d.ts +161 -0
  37. package/dist/core/shell/judge.js +261 -0
  38. package/dist/core/shell/judge.js.map +1 -0
  39. package/dist/core/shell/normalize.d.ts +27 -0
  40. package/dist/core/shell/normalize.js +53 -0
  41. package/dist/core/shell/normalize.js.map +1 -0
  42. package/dist/core/types.d.ts +75 -0
  43. package/dist/core/types.js.map +1 -1
  44. package/dist/providers/openrouter.js +2 -2
  45. package/dist/providers/openrouter.js.map +1 -1
  46. package/dist/utils/fileUtils.d.ts +4 -1
  47. package/dist/utils/fileUtils.js +19 -10
  48. package/dist/utils/fileUtils.js.map +1 -1
  49. package/dist/utils/systemUtils.d.ts +31 -0
  50. package/dist/utils/systemUtils.js +38 -0
  51. package/dist/utils/systemUtils.js.map +1 -1
  52. package/package.json +12 -8
  53. package/schema/gsloth-config.schema.json +1548 -0
package/.gsloth.code.md CHANGED
@@ -16,6 +16,16 @@ You have access to the entire project directory and can:
16
16
  - Create new files and directories as needed
17
17
  - Execute commands to run tests, build the project or run static analysis (lint)
18
18
 
19
+ ## File paths
20
+
21
+ - Paths are real absolute filesystem paths — there is no virtual root. The current
22
+ working directory is provided to you separately; do NOT assume it is `/`.
23
+ - The filesystem tools (`ls`/`glob`/`read_file`/`write_file`/`edit_file`/`grep`) and
24
+ `run_shell_command` share the same real paths. A path that works in the shell works
25
+ in the filesystem tools and vice versa.
26
+ - Relative paths resolve against the working directory. Check the current directory
27
+ before filesystem operations and prefer absolute paths when unsure.
28
+
19
29
  Focus on writing clean, maintainable code that follows the project's established patterns and conventions. Always test your changes when possible and explain what you're doing and why.
20
30
 
21
31
  ## Running tests
package/README.md CHANGED
@@ -11,7 +11,7 @@ Core utilities and types for Gaunt Sloth.
11
11
  - State and artifact storage: `artifactStore`
12
12
  - Shared constants and types
13
13
 
14
- AI vendor packages are not direct dependencies. Each vendor package is an optional peer dependency, resolved at runtime by whichever consumer (e.g. `gaunt-sloth-assistant`) pulls them in.
14
+ AI vendor packages are not direct dependencies. Each vendor package is an optional peer dependency, resolved at runtime by whichever consumer (e.g. `gaunt-sloth`) pulls them in.
15
15
 
16
16
  ## Dependencies
17
17
 
@@ -29,7 +29,6 @@ import { display } from '@gaunt-sloth/core/utils/consoleUtils.js';
29
29
  ## Related packages
30
30
 
31
31
  - [`@gaunt-sloth/core`](../core) — Core utilities, config, and agent infrastructure (this package)
32
- - [`@gaunt-sloth/tools`](../tools) — Built-in tools, filesystem toolkit, and middleware registry
33
- - [`@gaunt-sloth/api`](../api) — API server, AG-UI, MCP, and A2A integration
32
+ - [`@gaunt-sloth/agent`](../agent) — Agent runtime: built-in tools, filesystem toolkit, middleware registry, API server, AG-UI, MCP, and A2A integration
34
33
  - [`@gaunt-sloth/review`](../review) — Review and Q&A modules with standalone CLI
35
- - [`gaunt-sloth-assistant`](../assistant) — Main CLI application
34
+ - [`gaunt-sloth`](../app) — Main CLI application
@@ -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;IAC5B,aAAa,EAAE,MAAM;IACrB,iBAAiB,EAAE,MAAM;IACzB;;;;OAIG;IACH,iBAAiB,EAAE,kBAAkB;IACrC;;OAEG;IACH,iCAAiC,EAAE,KAAK;IACxC,yBAAyB,EAAE,2BAA2B;IACtD,UAAU,EAAE,MAAM;IAClB,QAAQ,EAAE,KAAK;IACf,YAAY,EAAE,WAAW,CAAC,IAAI,EAAE,mCAAmC;IACnE;;;;;;;;OAQG;IACH,QAAQ,EAAE;QACR,EAAE,EAAE;YACF,aAAa,EAAE,QAAQ;YACvB,iBAAiB,EAAE,QAAQ;YAC3B,MAAM,EAAE;gBACN,OAAO,EAAE,IAAI;gBACb,aAAa,EAAE,CAAC;gBAChB,SAAS,EAAE,CAAC;gBACZ,SAAS,EAAE,EAAE;gBACb,iBAAiB,EAAE,IAAI;aACxB;SACF;QACD,MAAM,EAAE;YACN,MAAM,EAAE;gBACN,OAAO,EAAE,IAAI;gBACb,aAAa,EAAE,CAAC;gBAChB,SAAS,EAAE,CAAC;gBACZ,SAAS,EAAE,EAAE;gBACb,iBAAiB,EAAE,IAAI;aACxB;SACF;QACD,GAAG,EAAE;YACH,UAAU,EAAE,MAAM;SACnB;QACD,IAAI,EAAE;YACJ,UAAU,EAAE,MAAM;SACnB;QACD,IAAI,EAAE;YACJ,UAAU,EAAE,KAAK;SAClB;QACD,IAAI,EAAE;YACJ,UAAU,EAAE,KAAK;SAClB;QACD,GAAG,EAAE;YACH,UAAU,EAAE,MAAM;YAClB,IAAI,EAAE,IAAI;YACV,IAAI,EAAE;gBACJ,WAAW,EAAE,uBAAuB;gBACpC,YAAY,EAAE,oBAAoB;gBAClC,YAAY,EAAE,sBAAsB;aACrC;SACF;KACF;IACD,YAAY,EAAE,IAAI;IAClB,iBAAiB,EAAE,IAAI;IACvB,wBAAwB,EAAE,IAAI;IAC9B,SAAS,EAAE,IAAI;IACf,yBAAyB,EAAE,IAAI;IAC/B,4BAA4B,EAAE,IAAI;IAClC,QAAQ,EAAE;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;