@gaunt-sloth/core 2.0.0-alpha.1 → 2.0.0-alpha.11
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/.gsloth.code.md +10 -0
- package/LICENSE +7 -0
- package/README.md +3 -4
- package/dist/config/defaults.d.ts +85 -0
- package/dist/config/defaults.js +101 -0
- package/dist/config/defaults.js.map +1 -0
- package/dist/config/jsonc.d.ts +12 -0
- package/dist/config/jsonc.js +41 -0
- package/dist/config/jsonc.js.map +1 -0
- package/dist/config/loader.d.ts +109 -0
- package/dist/config/loader.js +663 -0
- package/dist/config/loader.js.map +1 -0
- package/dist/config/schema.d.ts +509 -0
- package/dist/config/schema.js +349 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/config/shell-policy.d.ts +212 -0
- package/dist/config/shell-policy.js +142 -0
- package/dist/config/shell-policy.js.map +1 -0
- package/dist/config/types.d.ts +490 -0
- package/dist/config/types.js +13 -0
- package/dist/config/types.js.map +1 -0
- package/dist/config.d.ts +18 -647
- package/dist/config.js +15 -516
- package/dist/config.js.map +1 -1
- package/dist/constants.d.ts +32 -0
- package/dist/constants.js +32 -0
- package/dist/constants.js.map +1 -1
- package/dist/core/GthAbstractAgent.d.ts +57 -1
- package/dist/core/GthAbstractAgent.js +171 -4
- package/dist/core/GthAbstractAgent.js.map +1 -1
- package/dist/core/GthAgentRunner.d.ts +158 -1
- package/dist/core/GthAgentRunner.js +367 -4
- package/dist/core/GthAgentRunner.js.map +1 -1
- package/dist/core/GthLangChainAgent.js +118 -5
- package/dist/core/GthLangChainAgent.js.map +1 -1
- package/dist/core/debugCapture.d.ts +59 -0
- package/dist/core/debugCapture.js +101 -0
- package/dist/core/debugCapture.js.map +1 -0
- package/dist/core/gthLeanAgentFactory.d.ts +9 -0
- package/dist/core/gthLeanAgentFactory.js +10 -0
- package/dist/core/gthLeanAgentFactory.js.map +1 -0
- package/dist/core/runStats.d.ts +41 -0
- package/dist/core/runStats.js +73 -0
- package/dist/core/runStats.js.map +1 -0
- package/dist/core/shell/ShellCommandFailedError.d.ts +54 -0
- package/dist/core/shell/ShellCommandFailedError.js +68 -0
- package/dist/core/shell/ShellCommandFailedError.js.map +1 -0
- package/dist/core/shell/allowlist.d.ts +75 -0
- package/dist/core/shell/allowlist.js +187 -0
- package/dist/core/shell/allowlist.js.map +1 -0
- package/dist/core/shell/arity.d.ts +75 -0
- package/dist/core/shell/arity.js +313 -0
- package/dist/core/shell/arity.js.map +1 -0
- package/dist/core/shell/judge.d.ts +161 -0
- package/dist/core/shell/judge.js +261 -0
- package/dist/core/shell/judge.js.map +1 -0
- package/dist/core/shell/normalize.d.ts +27 -0
- package/dist/core/shell/normalize.js +53 -0
- package/dist/core/shell/normalize.js.map +1 -0
- package/dist/core/types.d.ts +124 -0
- package/dist/core/types.js.map +1 -1
- package/dist/history/historyFormat.d.ts +28 -0
- package/dist/history/historyFormat.js +127 -0
- package/dist/history/historyFormat.js.map +1 -0
- package/dist/history/historyStore.d.ts +198 -0
- package/dist/history/historyStore.js +469 -0
- package/dist/history/historyStore.js.map +1 -0
- package/dist/history/recordSession.d.ts +37 -0
- package/dist/history/recordSession.js +56 -0
- package/dist/history/recordSession.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/providers/anthropic.d.ts +1 -1
- package/dist/providers/anthropic.js +5 -10
- package/dist/providers/anthropic.js.map +1 -1
- package/dist/providers/deepseek.d.ts +1 -1
- package/dist/providers/deepseek.js +5 -10
- package/dist/providers/deepseek.js.map +1 -1
- package/dist/providers/google-genai.d.ts +1 -1
- package/dist/providers/google-genai.js +5 -10
- package/dist/providers/google-genai.js.map +1 -1
- package/dist/providers/groq.d.ts +1 -1
- package/dist/providers/groq.js +5 -10
- package/dist/providers/groq.js.map +1 -1
- package/dist/providers/huggingface.d.ts +25 -0
- package/dist/providers/huggingface.js +69 -0
- package/dist/providers/huggingface.js.map +1 -0
- package/dist/providers/modelCatalog.d.ts +109 -0
- package/dist/providers/modelCatalog.js +245 -0
- package/dist/providers/modelCatalog.js.map +1 -0
- package/dist/providers/modelDiscovery.d.ts +54 -1
- package/dist/providers/modelDiscovery.js +119 -8
- package/dist/providers/modelDiscovery.js.map +1 -1
- package/dist/providers/ollama.d.ts +1 -1
- package/dist/providers/ollama.js +5 -15
- package/dist/providers/ollama.js.map +1 -1
- package/dist/providers/openai.d.ts +1 -1
- package/dist/providers/openai.js +5 -10
- package/dist/providers/openai.js.map +1 -1
- package/dist/providers/openrouter.d.ts +1 -1
- package/dist/providers/openrouter.js +7 -12
- package/dist/providers/openrouter.js.map +1 -1
- package/dist/providers/vertexai.d.ts +1 -1
- package/dist/providers/vertexai.js +5 -10
- package/dist/providers/vertexai.js.map +1 -1
- package/dist/providers/xai.d.ts +1 -1
- package/dist/providers/xai.js +5 -10
- package/dist/providers/xai.js.map +1 -1
- package/dist/runtime/singleShot.d.ts +5 -2
- package/dist/runtime/singleShot.js +36 -3
- package/dist/runtime/singleShot.js.map +1 -1
- package/dist/utils/consoleUtils.d.ts +13 -0
- package/dist/utils/consoleUtils.js +31 -0
- package/dist/utils/consoleUtils.js.map +1 -1
- package/dist/utils/fileUtils.d.ts +24 -2
- package/dist/utils/fileUtils.js +54 -12
- package/dist/utils/fileUtils.js.map +1 -1
- package/dist/utils/systemPromptNotes.d.ts +89 -0
- package/dist/utils/systemPromptNotes.js +184 -0
- package/dist/utils/systemPromptNotes.js.map +1 -0
- package/dist/utils/systemUtils.d.ts +31 -0
- package/dist/utils/systemUtils.js +38 -0
- package/dist/utils/systemUtils.js.map +1 -1
- package/package.json +16 -11
- package/schema/gsloth-config.schema.json +1579 -0
|
@@ -4,6 +4,8 @@ import { GthAgentRunner } from '#src/core/GthAgentRunner.js';
|
|
|
4
4
|
import { MemorySaver } from '@langchain/langgraph';
|
|
5
5
|
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
6
6
|
import { ProgressIndicator } from '#src/utils/ProgressIndicator.js';
|
|
7
|
+
import { recordSessionSafe } from '#src/history/recordSession.js';
|
|
8
|
+
import { getProjectDir } from '#src/utils/systemUtils.js';
|
|
7
9
|
/**
|
|
8
10
|
* Ask a question and get an answer from the LLM.
|
|
9
11
|
*
|
|
@@ -17,10 +19,13 @@ import { ProgressIndicator } from '#src/utils/ProgressIndicator.js';
|
|
|
17
19
|
* @param config - The resolved config
|
|
18
20
|
* @param resolvers - Optional agent resolvers (tools/middleware)
|
|
19
21
|
* @param command - The originating command (defaults to `ask`); selects the agent mode prompt
|
|
22
|
+
* @param agentFactory - Optional backend factory (B5). When omitted the runner uses its built-in
|
|
23
|
+
* lean {@link GthLangChainAgent} default (unchanged behavior for existing callers). The app
|
|
24
|
+
* layer passes `resolveAgentFactory(config, 'lean')` so an explicit `agent.backend` is honored.
|
|
20
25
|
* @returns `true` when the run completed without error, `false` when it failed (so callers
|
|
21
26
|
* such as `exec` can set a non-zero exit code).
|
|
22
27
|
*/
|
|
23
|
-
export async function runSingleShot(source, preamble, content, config, resolvers, command = 'ask') {
|
|
28
|
+
export async function runSingleShot(source, preamble, content, config, resolvers, command = 'ask', agentFactory) {
|
|
24
29
|
const progressIndicator = config.streamOutput ? undefined : new ProgressIndicator('Thinking.');
|
|
25
30
|
const messages = [new SystemMessage(preamble), new HumanMessage(content)];
|
|
26
31
|
// Resolve output path and initialize session logging if enabled
|
|
@@ -29,11 +34,13 @@ export async function runSingleShot(source, preamble, content, config, resolvers
|
|
|
29
34
|
initSessionLogging(filePath, config.streamSessionInferenceLog);
|
|
30
35
|
}
|
|
31
36
|
// Run via Agent Runner (consistent with interactive session)
|
|
32
|
-
const runner = new GthAgentRunner(defaultStatusCallback, resolvers);
|
|
37
|
+
const runner = new GthAgentRunner(defaultStatusCallback, resolvers, agentFactory);
|
|
33
38
|
let succeeded = true;
|
|
39
|
+
let responseText = '';
|
|
40
|
+
const startedAt = Date.now();
|
|
34
41
|
try {
|
|
35
42
|
await runner.init(command, config, new MemorySaver());
|
|
36
|
-
await runner.processMessages(messages);
|
|
43
|
+
responseText = await runner.processMessages(messages);
|
|
37
44
|
}
|
|
38
45
|
catch (err) {
|
|
39
46
|
succeeded = false;
|
|
@@ -42,6 +49,32 @@ export async function runSingleShot(source, preamble, content, config, resolvers
|
|
|
42
49
|
finally {
|
|
43
50
|
await runner.cleanup();
|
|
44
51
|
}
|
|
52
|
+
// GS2-16: live token usage + invoked tool names for this run (fail-soft; empty when the
|
|
53
|
+
// provider reported no usage / the runner has no stats). Read post-cleanup — the runner
|
|
54
|
+
// snapshots stats at cleanup() so this still reflects the finished run.
|
|
55
|
+
let runStats = { tools: [] };
|
|
56
|
+
try {
|
|
57
|
+
const s = runner.getRunStats?.();
|
|
58
|
+
if (s)
|
|
59
|
+
runStats = s;
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
/* fail-soft: analytics must never affect this run */
|
|
63
|
+
}
|
|
64
|
+
// GS2-7 (B20): opt-in, fail-soft session history. A no-op unless `history.enabled`; never throws
|
|
65
|
+
// (recordSessionSafe is fully guarded) so a DB problem can't abort or alter this run.
|
|
66
|
+
// GS2-16 threads token/tool analytics; costUsd is intentionally left unset (no reliable price).
|
|
67
|
+
recordSessionSafe(config, {
|
|
68
|
+
command,
|
|
69
|
+
project: getProjectDir(),
|
|
70
|
+
model: config.modelDisplayName,
|
|
71
|
+
prompt: content,
|
|
72
|
+
response: responseText,
|
|
73
|
+
tokensInput: runStats.tokensInput,
|
|
74
|
+
tokensOutput: runStats.tokensOutput,
|
|
75
|
+
tools: runStats.tools.length > 0 ? runStats.tools : undefined,
|
|
76
|
+
durationMs: Date.now() - startedAt,
|
|
77
|
+
});
|
|
45
78
|
progressIndicator?.stop();
|
|
46
79
|
if (config.writeOutputToFile === false) {
|
|
47
80
|
display('\n'); // something going on in some terminals, they swallow last line of output
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"singleShot.js","sourceRoot":"","sources":["../../src/runtime/singleShot.ts"],"names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flushSessionLog: () => void;
|
|
19
19
|
export declare const stopSessionLogging: () => void;
|
|
20
20
|
export declare function displayError(message: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Open a warning-capture window: from now until {@link endWarningCapture}, each
|
|
23
|
+
* `displayWarning` message is buffered (IN ADDITION to being printed/logged as usual). Used by
|
|
24
|
+
* the TUI session module to grab the transient load-time config advisories and thread them into
|
|
25
|
+
* the persistent notice surface. Idempotent-ish: a second call starts a fresh buffer.
|
|
26
|
+
*/
|
|
27
|
+
export declare const beginWarningCapture: () => void;
|
|
28
|
+
/**
|
|
29
|
+
* Close the warning-capture window opened by {@link beginWarningCapture} and return everything
|
|
30
|
+
* collected (empty array if none / never opened). Always call this — a `try/finally` around the
|
|
31
|
+
* captured work — so a throw can't leak the capture state into later warnings.
|
|
32
|
+
*/
|
|
33
|
+
export declare const endWarningCapture: () => string[];
|
|
21
34
|
export declare function displayWarning(message: string): void;
|
|
22
35
|
export declare function displaySuccess(message: string): void;
|
|
23
36
|
export declare function displayInfo(message: string): void;
|
|
@@ -87,9 +87,40 @@ export function displayError(message) {
|
|
|
87
87
|
writeToSessionLog(message + '\n');
|
|
88
88
|
su.log(coloredMessage);
|
|
89
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Optional capture buffer for warning advisories (TUI-C19). When a capture window is open
|
|
92
|
+
* (see {@link beginWarningCapture}), every {@link displayWarning} message is also collected
|
|
93
|
+
* here so a surface that takes over the screen — the Ink TUI — can re-surface warnings that
|
|
94
|
+
* would otherwise print once and scroll out of sight. `null` when no window is open, so the
|
|
95
|
+
* plain-CLI path and the session log are entirely untouched.
|
|
96
|
+
*/
|
|
97
|
+
let warningCapture = null;
|
|
98
|
+
/**
|
|
99
|
+
* Open a warning-capture window: from now until {@link endWarningCapture}, each
|
|
100
|
+
* `displayWarning` message is buffered (IN ADDITION to being printed/logged as usual). Used by
|
|
101
|
+
* the TUI session module to grab the transient load-time config advisories and thread them into
|
|
102
|
+
* the persistent notice surface. Idempotent-ish: a second call starts a fresh buffer.
|
|
103
|
+
*/
|
|
104
|
+
export const beginWarningCapture = () => {
|
|
105
|
+
warningCapture = [];
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Close the warning-capture window opened by {@link beginWarningCapture} and return everything
|
|
109
|
+
* collected (empty array if none / never opened). Always call this — a `try/finally` around the
|
|
110
|
+
* captured work — so a throw can't leak the capture state into later warnings.
|
|
111
|
+
*/
|
|
112
|
+
export const endWarningCapture = () => {
|
|
113
|
+
const captured = warningCapture ?? [];
|
|
114
|
+
warningCapture = null;
|
|
115
|
+
return captured;
|
|
116
|
+
};
|
|
90
117
|
export function displayWarning(message) {
|
|
91
118
|
if (!shouldDisplayLevel(StatusLevel.WARNING))
|
|
92
119
|
return;
|
|
120
|
+
// Collect into the active capture window (if any) so the TUI can re-surface it later. Done
|
|
121
|
+
// after the level guard so a user who quieted warnings sees them neither printed nor captured.
|
|
122
|
+
if (warningCapture)
|
|
123
|
+
warningCapture.push(message);
|
|
93
124
|
const coloredMessage = colorText(message, 'yellow');
|
|
94
125
|
writeToSessionLog(message + '\n');
|
|
95
126
|
su.warn(coloredMessage);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consoleUtils.js","sourceRoot":"","sources":["../../src/utils/consoleUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAwB,MAAM,oBAAoB,CAAC;AACvE,OAAO,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AACpG,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAapD,MAAM,YAAY,GAAiB;IACjC,cAAc,EAAE,SAAS;IACzB,oBAAoB,EAAE,KAAK;CAC5B,CAAC;AAEF,MAAM,iBAAiB,GAAsB;IAC3C,YAAY,EAAE,WAAW,CAAC,IAAI,EAAE,mCAAmC;CACpE,CA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1E,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;IAC3C,CAAC;IAED,mBAAmB;IACnB,IAAI,KAAK,KAAK,MAAM,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,GAAG,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;QAC1E,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;IAC1C,CAAC;IAED,qDAAqD;IACrD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;AAC5C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,MAAM,MAAM,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IAC3C,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,SAAS;YACZ,OAAO,MAAM,CAAC,KAAK,CAAC;QACtB,KAAK,QAAQ;YACX,OAAO,MAAM,CAAC,KAAK,CAAC;QACtB;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -60,11 +60,33 @@ export declare function readMultipleFilesFromProjectDir(fileNames: string | stri
|
|
|
60
60
|
* package dir.
|
|
61
61
|
*/
|
|
62
62
|
export declare function readFileFromInstallDir(filePath: string, packageDir?: string): string;
|
|
63
|
-
|
|
63
|
+
/**
|
|
64
|
+
* No-clobber write: writes `content` only when `filePath` does not already exist.
|
|
65
|
+
* @returns `true` when the file was written, `false` when it was skipped because it
|
|
66
|
+
* already existed. Callers use the return value to avoid claiming success on a skip.
|
|
67
|
+
*/
|
|
68
|
+
export declare function writeFileIfNotExistsWithMessages(filePath: string, content: string): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Unconditional write: writes (or overwrites) `content` at `filePath`, creating parent
|
|
71
|
+
* directories as needed. Use this only for the config-overwrite path (an explicit user /
|
|
72
|
+
* `--force` decision); the no-clobber {@link writeFileIfNotExistsWithMessages} still guards
|
|
73
|
+
* user-editable preamble files (guidelines / review).
|
|
74
|
+
*/
|
|
75
|
+
export declare function writeFileWithMessages(filePath: string, content: string): void;
|
|
76
|
+
/**
|
|
77
|
+
* Config-file write that honours an overwrite flag.
|
|
78
|
+
* - `force === true` → always (over)writes.
|
|
79
|
+
* - `force === false` → no-clobber (skips + warns when the file already exists).
|
|
80
|
+
* @returns `true` when a write happened, `false` when it was skipped.
|
|
81
|
+
*/
|
|
82
|
+
export declare function writeConfigFileWithMessages(filePath: string, content: string, force?: boolean): boolean;
|
|
64
83
|
export declare function appendToFile(filePath: string, content: string): void;
|
|
65
84
|
export declare function readFileSyncWithMessages(filePath: string, errorMessageIn?: string, noFileMessage?: string): string;
|
|
66
85
|
/**
|
|
67
|
-
* Dynamically imports a module from a file path from the outside of the installation dir
|
|
86
|
+
* Dynamically imports a module from a file path from the outside of the installation dir.
|
|
87
|
+
* `.ts` modules are loaded through jiti (Node's native dynamic `import()` cannot load
|
|
88
|
+
* TypeScript), so `.gsloth.config.ts` honours the same async `configure()` contract as
|
|
89
|
+
* `.js`/`.mjs`. All other extensions use native dynamic import.
|
|
68
90
|
* @returns A promise that resolves to the imported module
|
|
69
91
|
*/
|
|
70
92
|
export declare function importExternalFile(filePath: string): Promise<Record<string, any>>;
|
package/dist/utils/fileUtils.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { dirname, resolve } from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import {
|
|
4
|
+
import { getProjectDir } from '#src/utils/systemUtils.js';
|
|
5
5
|
import { GSLOTH_DIR, GSLOTH_SETTINGS_DIR } from '#src/constants.js';
|
|
6
6
|
import { displayError, displayInfo, displaySuccess, displayWarning, } from '#src/utils/consoleUtils.js';
|
|
7
7
|
import { wrapContent } from '#src/utils/llmUtils.js';
|
|
8
8
|
import url from 'node:url';
|
|
9
|
+
import { createJiti } from 'jiti';
|
|
9
10
|
/**
|
|
10
11
|
* Checks if .gsloth directory exists in the project root
|
|
11
12
|
* @returns Boolean indicating whether .gsloth directory exists
|
|
12
13
|
*/
|
|
13
14
|
export function gslothDirExists() {
|
|
14
|
-
const currentDir =
|
|
15
|
+
const currentDir = getProjectDir();
|
|
15
16
|
const gslothDirPath = resolve(currentDir, GSLOTH_DIR);
|
|
16
17
|
return existsSync(gslothDirPath);
|
|
17
18
|
}
|
|
@@ -21,7 +22,7 @@ export function gslothDirExists() {
|
|
|
21
22
|
* @returns The resolved path where the file should be written
|
|
22
23
|
*/
|
|
23
24
|
export function getGslothFilePath(filename) {
|
|
24
|
-
const currentDir =
|
|
25
|
+
const currentDir = getProjectDir();
|
|
25
26
|
if (gslothDirExists()) {
|
|
26
27
|
const gslothDirPath = resolve(currentDir, GSLOTH_DIR);
|
|
27
28
|
return resolve(gslothDirPath, filename);
|
|
@@ -40,7 +41,7 @@ export function getGslothFilePath(filename) {
|
|
|
40
41
|
* @returns The resolved path where the configuration file should be written
|
|
41
42
|
*/
|
|
42
43
|
export function getGslothConfigWritePath(filename) {
|
|
43
|
-
const currentDir =
|
|
44
|
+
const currentDir = getProjectDir();
|
|
44
45
|
if (gslothDirExists()) {
|
|
45
46
|
const gslothDirPath = resolve(currentDir, GSLOTH_DIR);
|
|
46
47
|
const gslothSettingsPath = resolve(gslothDirPath, GSLOTH_SETTINGS_DIR);
|
|
@@ -59,10 +60,10 @@ export function getGslothConfigWritePath(filename) {
|
|
|
59
60
|
* @returns The resolved path where the configuration file should be found
|
|
60
61
|
*/
|
|
61
62
|
export function getGslothConfigReadPath(filename, identityProfileRaw) {
|
|
62
|
-
const
|
|
63
|
+
const baseDir = getProjectDir();
|
|
63
64
|
const identityProfile = identityProfileRaw?.trim();
|
|
64
65
|
if (gslothDirExists()) {
|
|
65
|
-
const gslothDirPath = resolve(
|
|
66
|
+
const gslothDirPath = resolve(baseDir, GSLOTH_DIR);
|
|
66
67
|
const gslothSettingsPath = resolve(gslothDirPath, GSLOTH_SETTINGS_DIR);
|
|
67
68
|
const configPath = identityProfile
|
|
68
69
|
? resolve(gslothSettingsPath, identityProfile, filename)
|
|
@@ -71,7 +72,7 @@ export function getGslothConfigReadPath(filename, identityProfileRaw) {
|
|
|
71
72
|
return configPath;
|
|
72
73
|
}
|
|
73
74
|
}
|
|
74
|
-
return resolve(
|
|
75
|
+
return resolve(baseDir, filename);
|
|
75
76
|
}
|
|
76
77
|
/**
|
|
77
78
|
* Resolve an explicit output path string to an absolute file path.
|
|
@@ -80,7 +81,7 @@ export function getGslothConfigReadPath(filename, identityProfileRaw) {
|
|
|
80
81
|
* - If it's a bare filename, place it under .gsloth/ when present, otherwise project root.
|
|
81
82
|
*/
|
|
82
83
|
export function resolveOutputPath(writeOutputToFile) {
|
|
83
|
-
const currentDir =
|
|
84
|
+
const currentDir = getProjectDir();
|
|
84
85
|
const provided = String(writeOutputToFile).trim();
|
|
85
86
|
// Detect if provided path contains path separators (cross-platform)
|
|
86
87
|
const hasSeparator = provided.includes('/') || provided.includes('\\');
|
|
@@ -125,7 +126,7 @@ export function generateStandardFileName(command) {
|
|
|
125
126
|
return `gth_${dateTimeStr}_${commandStr}.md`;
|
|
126
127
|
}
|
|
127
128
|
export function readFileFromProjectDir(fileName) {
|
|
128
|
-
const currentDir =
|
|
129
|
+
const currentDir = getProjectDir();
|
|
129
130
|
const filePath = resolve(currentDir, fileName);
|
|
130
131
|
displayInfo(`Reading file ${filePath}...`);
|
|
131
132
|
return readFileSyncWithMessages(filePath);
|
|
@@ -162,6 +163,11 @@ export function readFileFromInstallDir(filePath, packageDir = corePackageDir) {
|
|
|
162
163
|
throw readFromInstallDirError;
|
|
163
164
|
}
|
|
164
165
|
}
|
|
166
|
+
/**
|
|
167
|
+
* No-clobber write: writes `content` only when `filePath` does not already exist.
|
|
168
|
+
* @returns `true` when the file was written, `false` when it was skipped because it
|
|
169
|
+
* already existed. Callers use the return value to avoid claiming success on a skip.
|
|
170
|
+
*/
|
|
165
171
|
export function writeFileIfNotExistsWithMessages(filePath, content) {
|
|
166
172
|
displayInfo(`checking ${filePath} existence`);
|
|
167
173
|
if (!existsSync(filePath)) {
|
|
@@ -172,10 +178,38 @@ export function writeFileIfNotExistsWithMessages(filePath, content) {
|
|
|
172
178
|
}
|
|
173
179
|
writeFileSync(filePath, content);
|
|
174
180
|
displaySuccess(`Created ${filePath}`);
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
183
|
+
displayWarning(`${filePath} already exists`);
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Unconditional write: writes (or overwrites) `content` at `filePath`, creating parent
|
|
188
|
+
* directories as needed. Use this only for the config-overwrite path (an explicit user /
|
|
189
|
+
* `--force` decision); the no-clobber {@link writeFileIfNotExistsWithMessages} still guards
|
|
190
|
+
* user-editable preamble files (guidelines / review).
|
|
191
|
+
*/
|
|
192
|
+
export function writeFileWithMessages(filePath, content) {
|
|
193
|
+
const parentDir = dirname(filePath);
|
|
194
|
+
if (!existsSync(parentDir)) {
|
|
195
|
+
mkdirSync(parentDir, { recursive: true });
|
|
175
196
|
}
|
|
176
|
-
|
|
177
|
-
|
|
197
|
+
const existed = existsSync(filePath);
|
|
198
|
+
writeFileSync(filePath, content);
|
|
199
|
+
displaySuccess(existed ? `Overwrote ${filePath}` : `Created ${filePath}`);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Config-file write that honours an overwrite flag.
|
|
203
|
+
* - `force === true` → always (over)writes.
|
|
204
|
+
* - `force === false` → no-clobber (skips + warns when the file already exists).
|
|
205
|
+
* @returns `true` when a write happened, `false` when it was skipped.
|
|
206
|
+
*/
|
|
207
|
+
export function writeConfigFileWithMessages(filePath, content, force = false) {
|
|
208
|
+
if (force) {
|
|
209
|
+
writeFileWithMessages(filePath, content);
|
|
210
|
+
return true;
|
|
178
211
|
}
|
|
212
|
+
return writeFileIfNotExistsWithMessages(filePath, content);
|
|
179
213
|
}
|
|
180
214
|
export function appendToFile(filePath, content) {
|
|
181
215
|
try {
|
|
@@ -206,11 +240,19 @@ export function readFileSyncWithMessages(filePath, errorMessageIn, noFileMessage
|
|
|
206
240
|
}
|
|
207
241
|
}
|
|
208
242
|
/**
|
|
209
|
-
* Dynamically imports a module from a file path from the outside of the installation dir
|
|
243
|
+
* Dynamically imports a module from a file path from the outside of the installation dir.
|
|
244
|
+
* `.ts` modules are loaded through jiti (Node's native dynamic `import()` cannot load
|
|
245
|
+
* TypeScript), so `.gsloth.config.ts` honours the same async `configure()` contract as
|
|
246
|
+
* `.js`/`.mjs`. All other extensions use native dynamic import.
|
|
210
247
|
* @returns A promise that resolves to the imported module
|
|
211
248
|
*/
|
|
212
249
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
213
250
|
export function importExternalFile(filePath) {
|
|
251
|
+
if (filePath.endsWith('.ts')) {
|
|
252
|
+
const jiti = createJiti(import.meta.url);
|
|
253
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
254
|
+
return jiti.import(filePath);
|
|
255
|
+
}
|
|
214
256
|
const configFileUrl = url.pathToFileURL(filePath).toString();
|
|
215
257
|
return import(configFileUrl);
|
|
216
258
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileUtils.js","sourceRoot":"","sources":["../../src/utils/fileUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7F,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"fileUtils.js","sourceRoot":"","sources":["../../src/utils/fileUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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,IAAI,EAAE,CAAC;QAC/B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QACtC,OAAO,iBAAiB,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,6EAA6E;IAC7E,MAAM,QAAQ,GAAG,wBAAwB,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC;IAChE,OAAO,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared code-mode system-prompt augmentations (GS2-27).
|
|
3
|
+
*
|
|
4
|
+
* These notes describe capabilities that are IDENTICAL across both agent backends — the lean
|
|
5
|
+
* {@link import('#src/core/GthLangChainAgent.js').GthLangChainAgent} (`createAgent`, in core) and
|
|
6
|
+
* the deep `GthDeepAgent` (`createDeepAgent`, in `@gaunt-sloth/agent`): both expose the opt-in
|
|
7
|
+
* `run_shell_command` tool and both operate on the real filesystem cwd. They were originally
|
|
8
|
+
* composed ONLY inside `GthDeepAgent.init()` (EXT-13/EXT-26), so the now-default lean backend never
|
|
9
|
+
* received them — accidental deep-only drift of the same class GS2-21 fixed for the main prompt.
|
|
10
|
+
*
|
|
11
|
+
* They live here in core so BOTH backends compose from ONE source. `GthDeepAgent` re-exports them
|
|
12
|
+
* for back-compat with existing importers. The deepagents virtual-fs-namespace notes
|
|
13
|
+
* (`appendVirtualCwdNote` / `PATH_NAMESPACE_GUIDANCE` / the correction middleware) are NOT here:
|
|
14
|
+
* they are genuinely deep-only (a deepagents artifact — lean never runs virtualMode) and stay in
|
|
15
|
+
* `GthDeepAgent`.
|
|
16
|
+
*/
|
|
17
|
+
import type { McpServerInstruction } from '#src/core/types.js';
|
|
18
|
+
/**
|
|
19
|
+
* EXT-26: the platform-agnostic tail shared by both {@link appendOsShellNote} branches.
|
|
20
|
+
*
|
|
21
|
+
* The recurring failure mode on non-POSIX hosts is not just wrong command NAMES but shell
|
|
22
|
+
* REDIRECTION quoting: a grouped/multi-line `echo` redirect on cmd.exe reported success yet wrote
|
|
23
|
+
* a 0-byte file. So on every platform we steer file creation/mutation to the built-in
|
|
24
|
+
* `write_file`/`edit_file` tools (which never touch the shell's quoting) and keep each shell
|
|
25
|
+
* command a single line. Kept short — this is prompt text an LLM reads, not documentation.
|
|
26
|
+
*/
|
|
27
|
+
export declare const OS_SHELL_GUIDANCE: string;
|
|
28
|
+
/**
|
|
29
|
+
* EXT-26: append an OS + shell-dialect note to the composed code-mode system prompt.
|
|
30
|
+
*
|
|
31
|
+
* The model was never told its host OS or which shell `run_shell_command` uses, so on
|
|
32
|
+
* non-POSIX hosts it defaulted to POSIX idioms that fail (ran `ls` where cmd.exe has `dir`, a
|
|
33
|
+
* multi-line echo-redirect that wrote 0 bytes, a PowerShell here-string, `python -c` multi-line).
|
|
34
|
+
* This is ORTHOGONAL to the EXT-13/16/22 path-namespace notes: those say WHERE the model is (path
|
|
35
|
+
* form); this says WHAT shell it speaks (dialect). Backend-agnostic — the lean backend also exposes
|
|
36
|
+
* `run_shell_command`, so GS2-27 composes it in the shared path.
|
|
37
|
+
*
|
|
38
|
+
* The shell is derived from the SAME rule Node's `spawn(command, { shell: true })` uses — exactly
|
|
39
|
+
* how `run_shell_command` spawns (GthDevToolkit spawn) — so on `win32` it is cmd.exe (via
|
|
40
|
+
* `%ComSpec%`) and on POSIX it is `/bin/sh` (POSIX sh, NOT guaranteed bash). Computed from
|
|
41
|
+
* `process.platform` at call time so the text is correct per host. Returns the note alone when
|
|
42
|
+
* there is no base prompt. A single injection is authoritative (nothing in the base prompt
|
|
43
|
+
* contradicts shell dialect), so unlike EXT-22 no correction middleware is needed.
|
|
44
|
+
*/
|
|
45
|
+
export declare function appendOsShellNote(systemPrompt: string | undefined): string;
|
|
46
|
+
/**
|
|
47
|
+
* EXT-13 (part b): append a real-cwd / path-model note to the composed code-mode system prompt.
|
|
48
|
+
*
|
|
49
|
+
* Code mode runs in REAL-path mode, so the filesystem tools and `run_shell_command` share one
|
|
50
|
+
* real-absolute-path namespace rooted at `cwd`. The shared `.gsloth.code.md` prompt already tells
|
|
51
|
+
* the model "the current working directory is provided to you separately"; this note is what
|
|
52
|
+
* provides it — without it the model assumes `/` is cwd and hands `/`-rooted paths to the real-fs
|
|
53
|
+
* shell. The cwd is injected dynamically (never baked into the .md). Backend-agnostic — the lean
|
|
54
|
+
* backend also runs real-fs code sessions and previously received NO cwd value, so GS2-27 composes
|
|
55
|
+
* it in the shared path. Returns the note alone when there is no base prompt.
|
|
56
|
+
*/
|
|
57
|
+
export declare function appendCwdNote(systemPrompt: string | undefined, cwd: string): string;
|
|
58
|
+
/**
|
|
59
|
+
* EXT-32: hard per-server cap on injected MCP instruction length.
|
|
60
|
+
*
|
|
61
|
+
* A connected MCP server could advertise a very long `instructions` string that would then ride
|
|
62
|
+
* along in EVERY turn's system prompt and bloat context. This is a simple defensive constant (no
|
|
63
|
+
* config-schema plumbing — that stays out of this node): text beyond the cap is dropped and a
|
|
64
|
+
* truncation marker is appended so the model knows it was clipped. Generous enough that realistic
|
|
65
|
+
* server instructions pass through untouched.
|
|
66
|
+
*/
|
|
67
|
+
export declare const MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER = 4000;
|
|
68
|
+
/** EXT-32: truncation marker appended when a server's instructions exceed the per-server cap. */
|
|
69
|
+
export declare const MCP_INSTRUCTIONS_TRUNCATION_MARKER = "\u2026 [truncated]";
|
|
70
|
+
/**
|
|
71
|
+
* EXT-32: append connected MCP servers' discovery `instructions` to the composed system prompt.
|
|
72
|
+
*
|
|
73
|
+
* Each connected MCP server may return an `instructions` string in its `initialize` handshake that
|
|
74
|
+
* describes how to use its tools. We surface those to the model — but the text is **server-supplied
|
|
75
|
+
* and therefore a prompt-injection surface**, so it is:
|
|
76
|
+
* - fenced in an explicit `[BEGIN/END MCP SERVER-PROVIDED CONTEXT]` block (never blended into
|
|
77
|
+
* first-party prompt text),
|
|
78
|
+
* - labelled per server (`--- Server: "name" ---`) so the model can attribute each block, and
|
|
79
|
+
* - bracketed by a leading framing line AND a trailing first-party reassertion, so the LAST thing
|
|
80
|
+
* the model reads is gsloth's own authority, not the server text — server instructions may not
|
|
81
|
+
* override the system instructions, safety rules, or the user's directives.
|
|
82
|
+
*
|
|
83
|
+
* Backend-agnostic: composed through the shared path so BOTH the lean `GthLangChainAgent` and the
|
|
84
|
+
* deep `GthDeepAgent` inject it. Empty/absent contributes NOTHING: when no server supplied
|
|
85
|
+
* (non-whitespace) instructions the base prompt is returned unchanged — no empty header, no dangling
|
|
86
|
+
* label. Each server's text is trimmed and capped at {@link MCP_INSTRUCTIONS_MAX_CHARS_PER_SERVER}.
|
|
87
|
+
* Returns the block alone when there is no base prompt.
|
|
88
|
+
*/
|
|
89
|
+
export declare function appendMcpServerInstructionsNote(systemPrompt: string | undefined, instructions: McpServerInstruction[] | undefined): string | undefined;
|