@oh-my-tool/cli 0.2.0

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 (49) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +13 -0
  3. package/assets/skills/oh-my-tool/SKILL.md +77 -0
  4. package/bin/ohmytool.cjs +15 -0
  5. package/bin/ohmytool.ts +5 -0
  6. package/package.json +34 -0
  7. package/src/cli/commands/describe.ts +24 -0
  8. package/src/cli/commands/extension.ts +24 -0
  9. package/src/cli/commands/index.ts +7 -0
  10. package/src/cli/commands/integrate.ts +64 -0
  11. package/src/cli/commands/run.ts +39 -0
  12. package/src/cli/commands/search.ts +16 -0
  13. package/src/cli/commands/secret.ts +72 -0
  14. package/src/cli/context.ts +44 -0
  15. package/src/cli/index.ts +296 -0
  16. package/src/cli/parseArgs.ts +44 -0
  17. package/src/config/config.ts +63 -0
  18. package/src/core/executor.ts +99 -0
  19. package/src/core/registry.ts +33 -0
  20. package/src/core/result.ts +14 -0
  21. package/src/core/schema.ts +2 -0
  22. package/src/extension/discovery.ts +62 -0
  23. package/src/extension/install.ts +24 -0
  24. package/src/extension/loader.ts +32 -0
  25. package/src/extension/manifest.ts +115 -0
  26. package/src/integration/adapters.ts +98 -0
  27. package/src/integration/index.ts +4 -0
  28. package/src/integration/manager.ts +375 -0
  29. package/src/integration/skill.ts +84 -0
  30. package/src/integration/types.ts +55 -0
  31. package/src/migration.ts +44 -0
  32. package/src/paths.ts +41 -0
  33. package/src/policy/policy.ts +139 -0
  34. package/src/runtime/errors.ts +8 -0
  35. package/src/runtime/executor.ts +66 -0
  36. package/src/runtime/provider-registry.ts +23 -0
  37. package/src/runtime/provider.ts +29 -0
  38. package/src/runtime/providers/native/discovery.ts +2 -0
  39. package/src/runtime/providers/native/install.ts +2 -0
  40. package/src/runtime/providers/native/loader.ts +1 -0
  41. package/src/runtime/providers/native/manifest.ts +6 -0
  42. package/src/runtime/providers/native/provider.ts +57 -0
  43. package/src/runtime/result.ts +12 -0
  44. package/src/runtime/runtime.ts +71 -0
  45. package/src/runtime/schema.ts +49 -0
  46. package/src/runtime/tool-registry.ts +54 -0
  47. package/src/search/search.ts +78 -0
  48. package/src/secrets/secrets.ts +45 -0
  49. package/src/version.ts +1 -0
@@ -0,0 +1,78 @@
1
+ import type { ExtensionManifest } from "@oh-my-tool/sdk";
2
+
3
+ export interface SearchHit {
4
+ name: string;
5
+ description: string;
6
+ extension: string;
7
+ risk: string;
8
+ score: number;
9
+ }
10
+
11
+ interface Searchable {
12
+ name: string;
13
+ description: string;
14
+ keywords: string[];
15
+ risk: string;
16
+ extension: string;
17
+ extName: string;
18
+ }
19
+
20
+ const NAME_WEIGHT = 3;
21
+ const KEYWORD_WEIGHT = 2;
22
+ const DESC_WEIGHT = 1;
23
+
24
+ function toSearchable(ext: ExtensionManifest) {
25
+ const out: Searchable[] = [];
26
+ for (const tool of ext.tools) {
27
+ out.push({
28
+ name: tool.name.toLowerCase(),
29
+ description: tool.description.toLowerCase(),
30
+ keywords: (tool.keywords ?? []).map((k) => k.toLowerCase()),
31
+ risk: tool.risk ?? "read",
32
+ extension: ext.id,
33
+ extName: ext.name.toLowerCase(),
34
+ });
35
+ }
36
+ return out;
37
+ }
38
+
39
+ function bestWeight(s: Searchable, token: string): number {
40
+ if (s.name.includes(token)) return NAME_WEIGHT;
41
+ if (s.extName.includes(token)) return NAME_WEIGHT;
42
+ if (s.keywords.some((k) => k.includes(token) || token.includes(k))) {
43
+ return KEYWORD_WEIGHT;
44
+ }
45
+ if (s.description.includes(token)) return DESC_WEIGHT;
46
+ return 0;
47
+ }
48
+
49
+ export function searchTools(query: string, manifests: ExtensionManifest[]): SearchHit[] {
50
+ const tokens = query
51
+ .toLowerCase()
52
+ .split(/\s+/)
53
+ .filter((t) => t.length > 0);
54
+
55
+ if (tokens.length === 0) return [];
56
+
57
+ const hits: SearchHit[] = [];
58
+ for (const ext of manifests) {
59
+ for (const s of toSearchable(ext)) {
60
+ let score = 0;
61
+ for (const token of tokens) {
62
+ score += bestWeight(s, token);
63
+ }
64
+ if (score > 0) {
65
+ hits.push({
66
+ name: s.name,
67
+ description: s.description,
68
+ extension: s.extension,
69
+ risk: s.risk,
70
+ score,
71
+ });
72
+ }
73
+ }
74
+ }
75
+
76
+ hits.sort((a, b) => b.score - a.score);
77
+ return hits;
78
+ }
@@ -0,0 +1,45 @@
1
+ import type { SecretStore } from "@oh-my-tool/sdk";
2
+
3
+ export const SECRET_SERVICE = "oh-my-tool";
4
+
5
+ export function memoryStore(init: Record<string, string> = {}): SecretStore {
6
+ const data = new Map(Object.entries(init));
7
+ return {
8
+ async get(name) {
9
+ return data.get(name);
10
+ },
11
+ async set(name, value) {
12
+ data.set(name, value);
13
+ },
14
+ async delete(name) {
15
+ data.delete(name);
16
+ },
17
+ };
18
+ }
19
+
20
+ export const bunStore: SecretStore = {
21
+ async get(name) {
22
+ const v = await Bun.secrets.get({ service: SECRET_SERVICE, name });
23
+ return v ?? undefined;
24
+ },
25
+ async set(name, value) {
26
+ await Bun.secrets.set({ service: SECRET_SERVICE, name, value });
27
+ },
28
+ async delete(name) {
29
+ await Bun.secrets.delete({ service: SECRET_SERVICE, name });
30
+ },
31
+ };
32
+
33
+ export class SecretsManager {
34
+ constructor(private store: SecretStore = bunStore) {}
35
+
36
+ get(name: string): Promise<string | undefined> {
37
+ return this.store.get(name);
38
+ }
39
+ set(name: string, value: string): Promise<void> {
40
+ return this.store.set(name, value);
41
+ }
42
+ delete(name: string): Promise<void> {
43
+ return this.store.delete(name);
44
+ }
45
+ }
package/src/version.ts ADDED
@@ -0,0 +1 @@
1
+ export const VERSION = "0.2.0";