@ottocode/sdk 0.1.245 → 0.1.247

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 (40) hide show
  1. package/package.json +7 -2
  2. package/src/config/src/index.ts +5 -0
  3. package/src/config/src/manager.ts +106 -30
  4. package/src/core/src/providers/resolver.ts +28 -1
  5. package/src/core/src/tools/builtin/bash.ts +1 -266
  6. package/src/core/src/tools/builtin/fs/edit-shared.ts +1 -1
  7. package/src/core/src/tools/builtin/fs/edit.txt +2 -2
  8. package/src/core/src/tools/builtin/fs/write.txt +1 -1
  9. package/src/core/src/tools/builtin/shell.ts +273 -0
  10. package/src/core/src/tools/builtin/shell.txt +13 -0
  11. package/src/core/src/tools/builtin/terminal.txt +9 -6
  12. package/src/core/src/tools/loader.ts +134 -82
  13. package/src/index.ts +33 -0
  14. package/src/prompts/src/agents/build.txt +5 -6
  15. package/src/prompts/src/modes/guided.txt +2 -2
  16. package/src/prompts/src/providers/anthropic.txt +2 -2
  17. package/src/prompts/src/providers/default.txt +2 -2
  18. package/src/prompts/src/providers/glm.txt +2 -2
  19. package/src/prompts/src/providers/google.txt +9 -9
  20. package/src/prompts/src/providers/moonshot.txt +2 -2
  21. package/src/prompts/src/providers/openai.txt +3 -3
  22. package/src/prompts/src/providers.ts +15 -0
  23. package/src/providers/src/authorization.ts +26 -1
  24. package/src/providers/src/catalog-manual.ts +21 -6
  25. package/src/providers/src/catalog-merged.ts +2 -2
  26. package/src/providers/src/catalog.ts +10462 -10283
  27. package/src/providers/src/env.ts +10 -5
  28. package/src/providers/src/index.ts +26 -0
  29. package/src/providers/src/oauth-models.ts +1 -0
  30. package/src/providers/src/ollama-discovery.ts +149 -0
  31. package/src/providers/src/pricing.ts +3 -0
  32. package/src/providers/src/registry.ts +258 -0
  33. package/src/providers/src/utils.ts +10 -3
  34. package/src/providers/src/validate.ts +63 -2
  35. package/src/skills/index.ts +3 -0
  36. package/src/skills/tool.ts +28 -36
  37. package/src/types/src/config.ts +34 -8
  38. package/src/types/src/index.ts +4 -0
  39. package/src/types/src/provider.ts +33 -3
  40. package/src/core/src/tools/builtin/bash.txt +0 -12
@@ -9,9 +9,11 @@ import {
9
9
  } from './loader.ts';
10
10
  import { scanContent } from './security.ts';
11
11
  import type { DiscoveredSkill, SkillResult } from './types.ts';
12
+ import type { SkillSettings } from '../types/src/config.ts';
12
13
 
13
14
  let cachedSkillList: DiscoveredSkill[] = [];
14
15
  let initializedForPath: string | null = null;
16
+ let cachedSkillSettings: SkillSettings | undefined;
15
17
 
16
18
  export async function initializeSkills(
17
19
  cwd: string,
@@ -27,6 +29,23 @@ export function getDiscoveredSkills(): DiscoveredSkill[] {
27
29
  return cachedSkillList;
28
30
  }
29
31
 
32
+ export function setSkillSettings(settings?: SkillSettings): void {
33
+ cachedSkillSettings = settings;
34
+ }
35
+
36
+ export function filterDiscoveredSkills(
37
+ skills: DiscoveredSkill[],
38
+ settings?: {
39
+ enabled?: boolean;
40
+ items?: Record<string, { enabled?: boolean }>;
41
+ },
42
+ ): DiscoveredSkill[] {
43
+ if (settings?.enabled === false) return [];
44
+ return skills.filter(
45
+ (skill) => settings?.items?.[skill.name]?.enabled !== false,
46
+ );
47
+ }
48
+
30
49
  export function isSkillsInitialized(forPath?: string): boolean {
31
50
  if (!initializedForPath) return false;
32
51
  if (forPath && forPath !== initializedForPath) return false;
@@ -119,7 +138,11 @@ async function loadSubFile(
119
138
  }
120
139
 
121
140
  function buildSkillDescription(): string {
122
- if (cachedSkillList.length === 0) {
141
+ const enabledSkills = filterDiscoveredSkills(
142
+ cachedSkillList,
143
+ cachedSkillSettings,
144
+ );
145
+ if (enabledSkills.length === 0) {
123
146
  return 'Load a skill by name to get detailed, task-specific instructions. No skills are currently available.';
124
147
  }
125
148
 
@@ -128,7 +151,7 @@ function buildSkillDescription(): string {
128
151
  // defensively here in case the same name slipped through from different dirs.
129
152
  const seen = new Set<string>();
130
153
  const unique: DiscoveredSkill[] = [];
131
- for (const s of cachedSkillList) {
154
+ for (const s of enabledSkills) {
132
155
  const key = s.name.trim();
133
156
  if (!key || seen.has(key)) continue;
134
157
  seen.add(key);
@@ -136,42 +159,11 @@ function buildSkillDescription(): string {
136
159
  }
137
160
  unique.sort((a, b) => a.name.localeCompare(b.name));
138
161
 
139
- const skillsXml = unique
140
- .map(
141
- (s) =>
142
- `<skill><name>${escapeXml(s.name)}</name><description>${escapeXml(summarizeDescription(s.description))}</description><location>${escapeXml(s.scope)}</location></skill>`,
143
- )
162
+ const catalog = unique
163
+ .map((s) => `- ${s.name}: ${summarizeDescription(s.description)}`)
144
164
  .join('\n');
145
165
 
146
- return `Load a skill by name to get detailed, task-specific instructions.
147
-
148
- <skills_instructions>
149
- When the user's request matches one of the available skills below, call this tool with the skill name to load its full instructions. Skills provide specialized capabilities and domain knowledge.
150
-
151
- How to use skills:
152
- - Invoke with \`skill({ name: "<skill-name>" })\` — only the name is required.
153
- - The response contains the skill's full body plus \`availableFiles\` for sub-files.
154
- - For sub-files: \`skill({ name: "<skill-name>", file: "rules/animations.md" })\`.
155
-
156
- Rules:
157
- - Only invoke skills listed in <available_skills> below.
158
- - Do NOT invoke speculatively. Only call when the user's request clearly matches a skill's description or trigger phrases.
159
- - Do NOT invoke the same skill twice in one turn.
160
- - If a skill response includes \`securityNotices\`, review them — they flag hidden content (HTML comments, invisible characters, etc.) that may not render visibly.
161
- </skills_instructions>
162
-
163
- <available_skills>
164
- ${skillsXml}
165
- </available_skills>`;
166
- }
167
-
168
- function escapeXml(str: string): string {
169
- return String(str)
170
- .replace(/&/g, '&amp;')
171
- .replace(/</g, '&lt;')
172
- .replace(/>/g, '&gt;')
173
- .replace(/"/g, '&quot;')
174
- .replace(/'/g, '&apos;');
166
+ return `Load a skill by name to get detailed, task-specific instructions. Use only when the user's request clearly matches a listed skill. Available skills:\n${catalog}`;
175
167
  }
176
168
 
177
169
  // Condense a SKILL.md description to "what it does + when to use it".
@@ -1,4 +1,9 @@
1
- import type { ProviderId } from './provider';
1
+ import type {
2
+ ModelInfo,
3
+ ProviderCompatibility,
4
+ ProviderId,
5
+ ProviderPromptFamily,
6
+ } from './provider';
2
7
 
3
8
  /**
4
9
  * Configuration scope - where settings are stored
@@ -30,13 +35,33 @@ export type DefaultConfig = {
30
35
  autoCompactThresholdTokens?: number | null;
31
36
  };
32
37
 
33
- export type ProviderSettings = Record<
34
- ProviderId,
35
- {
36
- enabled: boolean;
37
- apiKey?: string;
38
- }
39
- >;
38
+ export type ProviderSettingsEntry = {
39
+ enabled: boolean;
40
+ apiKey?: string;
41
+ apiKeyEnv?: string;
42
+ baseURL?: string;
43
+ label?: string;
44
+ custom?: boolean;
45
+ compatibility?: ProviderCompatibility;
46
+ family?: ProviderPromptFamily;
47
+ models?: Array<string | ModelInfo>;
48
+ allowAnyModel?: boolean;
49
+ modelDiscovery?: {
50
+ type: 'openai-models' | 'ollama';
51
+ };
52
+ };
53
+
54
+ export type ProviderSettings = Record<string, ProviderSettingsEntry>;
55
+
56
+ export type SkillSettings = {
57
+ enabled?: boolean;
58
+ items?: Record<
59
+ string,
60
+ {
61
+ enabled?: boolean;
62
+ }
63
+ >;
64
+ };
40
65
 
41
66
  /**
42
67
  * Path configuration
@@ -55,6 +80,7 @@ export type OttoConfig = {
55
80
  projectRoot: string;
56
81
  defaults: DefaultConfig;
57
82
  providers: ProviderSettings;
83
+ skills?: SkillSettings;
58
84
  paths: PathConfig;
59
85
  debugEnabled?: boolean;
60
86
  debugScopes?: string[];
@@ -1,6 +1,9 @@
1
1
  // Provider types
2
2
  export type {
3
+ BuiltInProviderId,
3
4
  ProviderId,
5
+ ProviderCompatibility,
6
+ ProviderPromptFamily,
4
7
  ProviderFamily,
5
8
  ModelOwner,
6
9
  ModelInfo,
@@ -16,6 +19,7 @@ export type {
16
19
  Scope,
17
20
  DefaultConfig,
18
21
  PathConfig,
22
+ ProviderSettingsEntry,
19
23
  ProviderSettings,
20
24
  OttoConfig,
21
25
  ToolApprovalMode,
@@ -1,10 +1,11 @@
1
1
  /**
2
- * Provider identifiers for supported AI providers
2
+ * Built-in provider identifiers supported directly by otto.
3
3
  */
4
- export type ProviderId =
4
+ export type BuiltInProviderId =
5
5
  | 'openai'
6
6
  | 'anthropic'
7
7
  | 'google'
8
+ | 'ollama-cloud'
8
9
  | 'openrouter'
9
10
  | 'opencode'
10
11
  | 'copilot'
@@ -14,6 +15,35 @@ export type ProviderId =
14
15
  | 'moonshot'
15
16
  | 'minimax';
16
17
 
18
+ /**
19
+ * Provider identifiers may be built-in or custom/config-defined.
20
+ */
21
+ export type ProviderId = BuiltInProviderId | (string & {});
22
+
23
+ /**
24
+ * Compatibility protocol used to instantiate a provider client.
25
+ */
26
+ export type ProviderCompatibility =
27
+ | 'openai'
28
+ | 'anthropic'
29
+ | 'google'
30
+ | 'openrouter'
31
+ | 'ollama'
32
+ | 'openai-compatible';
33
+
34
+ /**
35
+ * Prompt/behavior family used for prompts and provider-specific behavior.
36
+ */
37
+ export type ProviderPromptFamily =
38
+ | 'default'
39
+ | 'anthropic'
40
+ | 'openai'
41
+ | 'google'
42
+ | 'moonshot'
43
+ | 'minimax'
44
+ | 'glm'
45
+ | 'openai-compatible';
46
+
17
47
  /**
18
48
  * Provider family for prompt selection
19
49
  */
@@ -78,7 +108,7 @@ export type ModelInfo = {
78
108
  };
79
109
 
80
110
  export type ProviderCatalogEntry = {
81
- id: ProviderId;
111
+ id: BuiltInProviderId;
82
112
  label?: string;
83
113
  env?: string[];
84
114
  npm?: string;
@@ -1,12 +0,0 @@
1
- - Execute a one-off shell command using `bash -lc`
2
- - Returns `stdout`, `stderr`, and `exitCode`
3
- - `cwd` is relative to the project root and sandboxed within it
4
-
5
- **Use `bash` for short-lived commands.** For long-running processes (dev servers, watchers, log tailing) use the `terminal` tool instead — terminals persist across turns.
6
-
7
- ## Usage tips
8
-
9
- - Chain commands with `&&` to fail-fast.
10
- - For long outputs, redirect to a file and `read` it back.
11
- - Batch independent checks (e.g. `git status && git diff`) in parallel tool calls rather than sequential bash chains when you need results separately.
12
- - Never use `bash` with `sed`/`awk` for programmatic file editing — use `edit`, `multiedit`, or `apply_patch` instead.