agent-termo 1.0.1 → 1.0.2
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 +27 -2
- package/dist/agents/index.d.ts +5 -0
- package/dist/agents/index.d.ts.map +1 -0
- package/dist/agents/index.js +86 -0
- package/dist/agents/index.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +97 -168
- package/dist/cli.js.map +4 -4
- package/dist/diff/index.d.ts +9 -0
- package/dist/diff/index.d.ts.map +1 -0
- package/dist/diff/index.js +213 -0
- package/dist/diff/index.js.map +1 -0
- package/dist/llm/client.d.ts +39 -0
- package/dist/llm/client.d.ts.map +1 -0
- package/dist/llm/client.js +188 -0
- package/dist/llm/client.js.map +1 -0
- package/dist/llm/models.d.ts +19 -0
- package/dist/llm/models.d.ts.map +1 -0
- package/dist/llm/models.js +45 -0
- package/dist/llm/models.js.map +1 -0
- package/dist/llm/tools.d.ts +3 -0
- package/dist/llm/tools.d.ts.map +1 -0
- package/dist/llm/tools.js +204 -0
- package/dist/llm/tools.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +91 -140
- package/dist/main.js.map +4 -4
- package/dist/memory/index.d.ts +10 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +117 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/tools/index.d.ts +5 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +334 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/types/index.d.ts +119 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/ui/index.d.ts +47 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +321 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/screen.d.ts +59 -0
- package/dist/ui/screen.d.ts.map +1 -0
- package/dist/ui/screen.js +629 -0
- package/dist/ui/screen.js.map +1 -0
- package/dist/utils/ansi.d.ts +62 -0
- package/dist/utils/ansi.d.ts.map +1 -0
- package/dist/utils/ansi.js +116 -0
- package/dist/utils/ansi.js.map +1 -0
- package/dist/utils/config.d.ts +9 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +120 -0
- package/dist/utils/config.js.map +1 -0
- package/package.json +1 -1
- package/src/cli.ts +1 -1
- package/src/llm/client.ts +24 -0
- package/src/llm/models.ts +55 -0
- package/src/main.ts +201 -75
- package/src/ui/index.ts +256 -389
- package/src/ui/screen.ts +698 -0
- package/src/utils/config.ts +37 -20
package/src/utils/config.ts
CHANGED
|
@@ -52,37 +52,25 @@ export function getAgentTermoDir(): string {
|
|
|
52
52
|
return resolve(process.env.HOME || process.env.USERPROFILE || '.', '.agent-termo');
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
function
|
|
56
|
-
if (process.env.NIM_API_KEY) return;
|
|
57
|
-
|
|
55
|
+
function readStoredConfig(): Record<string, unknown> {
|
|
58
56
|
try {
|
|
59
|
-
const
|
|
57
|
+
const existing: unknown = JSON.parse(
|
|
60
58
|
readFileSync(resolve(getAgentTermoDir(), 'config.json'), 'utf-8'),
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
process.env.NIM_API_KEY = stored.nimApiKey;
|
|
59
|
+
);
|
|
60
|
+
if (existing && typeof existing === 'object' && !Array.isArray(existing)) {
|
|
61
|
+
return existing as Record<string, unknown>;
|
|
65
62
|
}
|
|
66
63
|
} catch {
|
|
67
64
|
// No saved user configuration yet.
|
|
68
65
|
}
|
|
66
|
+
return {};
|
|
69
67
|
}
|
|
70
68
|
|
|
71
|
-
|
|
69
|
+
function updateStoredConfig(patch: Record<string, unknown>): void {
|
|
72
70
|
const configDir = getAgentTermoDir();
|
|
73
71
|
const configPath = resolve(configDir, 'config.json');
|
|
74
|
-
|
|
72
|
+
const storedConfig = { ...readStoredConfig(), ...patch };
|
|
75
73
|
|
|
76
|
-
try {
|
|
77
|
-
const existing: unknown = JSON.parse(readFileSync(configPath, 'utf-8'));
|
|
78
|
-
if (existing && typeof existing === 'object' && !Array.isArray(existing)) {
|
|
79
|
-
storedConfig = existing as Record<string, unknown>;
|
|
80
|
-
}
|
|
81
|
-
} catch {
|
|
82
|
-
// Create a new configuration file when one does not exist.
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
storedConfig.nimApiKey = apiKey;
|
|
86
74
|
mkdirSync(configDir, { recursive: true, mode: 0o700 });
|
|
87
75
|
writeFileSync(configPath, `${JSON.stringify(storedConfig, null, 2)}\n`, {
|
|
88
76
|
encoding: 'utf-8',
|
|
@@ -93,7 +81,36 @@ export function saveNimApiKey(apiKey: string): void {
|
|
|
93
81
|
if (process.platform !== 'win32') chmodSync(configPath, 0o600);
|
|
94
82
|
}
|
|
95
83
|
|
|
84
|
+
function loadStoredNimApiKey(): void {
|
|
85
|
+
if (process.env.NIM_API_KEY) return;
|
|
86
|
+
|
|
87
|
+
const { nimApiKey } = readStoredConfig();
|
|
88
|
+
if (typeof nimApiKey === 'string' && nimApiKey.trim()) {
|
|
89
|
+
process.env.NIM_API_KEY = nimApiKey;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* A model picked with /model is saved and wins over NIM_MODEL from .env, so
|
|
95
|
+
* the choice survives restarts. The --model CLI flag still overrides it.
|
|
96
|
+
*/
|
|
97
|
+
function loadStoredNimModel(): void {
|
|
98
|
+
const { nimModel } = readStoredConfig();
|
|
99
|
+
if (typeof nimModel === 'string' && nimModel.trim()) {
|
|
100
|
+
process.env.NIM_MODEL = nimModel;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function saveNimApiKey(apiKey: string): void {
|
|
105
|
+
updateStoredConfig({ nimApiKey: apiKey });
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export function saveNimModel(model: string): void {
|
|
109
|
+
updateStoredConfig({ nimModel: model });
|
|
110
|
+
}
|
|
111
|
+
|
|
96
112
|
loadStoredNimApiKey();
|
|
113
|
+
loadStoredNimModel();
|
|
97
114
|
|
|
98
115
|
export function getConfig(projectRoot: string): AppConfig {
|
|
99
116
|
loadEnvFile(resolve(projectRoot, '.env'));
|