godspeed-agent 0.1.0 → 0.1.3
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/package.json +9 -1
- package/src/commands/models.ts +69 -8
- package/src/lib/config.ts +7 -1
- package/src/providers/ollamaModels.ts +17 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "godspeed-agent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -13,6 +13,14 @@
|
|
|
13
13
|
"LICENSE",
|
|
14
14
|
"package.json"
|
|
15
15
|
],
|
|
16
|
+
"homepage": "https://github.com/bhupeshv29/tui-starter#readme",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/bhupeshv29/tui-starter.git"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/bhupeshv29/tui-starter/issues"
|
|
23
|
+
},
|
|
16
24
|
"scripts": {
|
|
17
25
|
"dev": "bun run src/cli.ts"
|
|
18
26
|
},
|
package/src/commands/models.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Command } from "commander";
|
|
|
2
2
|
import chalk from "chalk";
|
|
3
3
|
import { loadConfig, saveConfig } from "../lib/config.js";
|
|
4
4
|
import { SUPPORTED_PROVIDERS } from "../lib/providers.js";
|
|
5
|
+
import { getOllamaModels } from "../providers/ollamaModels.js";
|
|
5
6
|
|
|
6
7
|
export const modelsCommand = new Command("models");
|
|
7
8
|
|
|
@@ -17,16 +18,14 @@ modelsCommand
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
const provider = SUPPORTED_PROVIDERS.find(
|
|
20
|
-
p => p.name === config.activeProvider
|
|
21
|
+
(p) => p.name === config.activeProvider,
|
|
21
22
|
);
|
|
22
23
|
|
|
23
24
|
if (!provider) return;
|
|
24
25
|
|
|
25
26
|
for (const model of provider.models) {
|
|
26
27
|
const active =
|
|
27
|
-
config.activeModel === model
|
|
28
|
-
? chalk.green(" (active)")
|
|
29
|
-
: "";
|
|
28
|
+
config.activeModel === model ? chalk.green(" (active)") : "";
|
|
30
29
|
|
|
31
30
|
console.log(`- ${model}${active}`);
|
|
32
31
|
}
|
|
@@ -43,7 +42,69 @@ modelsCommand
|
|
|
43
42
|
|
|
44
43
|
saveConfig(config);
|
|
45
44
|
|
|
46
|
-
console.log(
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
console.log(chalk.green(`Active model set to ${model}`));
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
modelsCommand
|
|
49
|
+
.command("sync")
|
|
50
|
+
.option("--save", "Save discovered models")
|
|
51
|
+
.description("Sync/list models from active provider")
|
|
52
|
+
.action(async (options) => {
|
|
53
|
+
const config = loadConfig();
|
|
54
|
+
|
|
55
|
+
if (!config.activeProvider) {
|
|
56
|
+
console.log(chalk.red("No active provider selected"));
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (config.activeProvider !== "ollama") {
|
|
61
|
+
console.log(
|
|
62
|
+
chalk.yellow(
|
|
63
|
+
`models sync is currently only supported for ollama. Active provider: ${config.activeProvider}`,
|
|
64
|
+
),
|
|
65
|
+
);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
const models = await getOllamaModels();
|
|
71
|
+
|
|
72
|
+
if (models.length === 0) {
|
|
73
|
+
console.log(chalk.yellow("No Ollama models found."));
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
console.log(chalk.green("Installed Ollama models:"));
|
|
78
|
+
|
|
79
|
+
for (const model of models) {
|
|
80
|
+
const sizeInGB = (model.size / 1024 / 1024 / 1024).toFixed(2);
|
|
81
|
+
|
|
82
|
+
console.log(`- ${model.name} (${sizeInGB} GB)`);
|
|
83
|
+
}
|
|
84
|
+
if (options.save) {
|
|
85
|
+
config.providers.ollama ??= {};
|
|
86
|
+
|
|
87
|
+
config.providers.ollama.models = models.map((model) => model.name);
|
|
88
|
+
|
|
89
|
+
saveConfig(config);
|
|
90
|
+
|
|
91
|
+
console.log(chalk.green(`Saved ${models.length} models to config.`));
|
|
92
|
+
}
|
|
93
|
+
} catch (err) {
|
|
94
|
+
console.log(chalk.red(err instanceof Error ? err.message : String(err)));
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
modelsCommand
|
|
99
|
+
.command("use")
|
|
100
|
+
.argument("<model>")
|
|
101
|
+
.description("Set active model")
|
|
102
|
+
.action((model) => {
|
|
103
|
+
const config = loadConfig();
|
|
104
|
+
|
|
105
|
+
config.activeModel = model;
|
|
106
|
+
|
|
107
|
+
saveConfig(config);
|
|
108
|
+
|
|
109
|
+
console.log(chalk.green(`Active model set to ${model}`));
|
|
110
|
+
});
|
package/src/lib/config.ts
CHANGED
|
@@ -10,7 +10,13 @@ export type ProviderConfig = {
|
|
|
10
10
|
export type AppConfig = {
|
|
11
11
|
activeProvider?: string;
|
|
12
12
|
activeModel?: string;
|
|
13
|
-
providers: Record<
|
|
13
|
+
providers: Record<
|
|
14
|
+
string,
|
|
15
|
+
{
|
|
16
|
+
apiKey?: string;
|
|
17
|
+
models?: string[];
|
|
18
|
+
}
|
|
19
|
+
>;
|
|
14
20
|
};
|
|
15
21
|
|
|
16
22
|
const CONFIG_DIR = path.join(os.homedir(), ".tuistarter");
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export async function getOllamaModels() {
|
|
2
|
+
const res = await fetch("http://localhost:11434/api/tags");
|
|
3
|
+
|
|
4
|
+
if (!res.ok) {
|
|
5
|
+
throw new Error("Could not connect to Ollama");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const data: any = await res.json();
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
data.models?.map((model: any) => ({
|
|
12
|
+
name: model.name,
|
|
13
|
+
size: model.size,
|
|
14
|
+
modifiedAt: model.modified_at,
|
|
15
|
+
})) ?? []
|
|
16
|
+
);
|
|
17
|
+
}
|