oh-my-claude-sisyphus 1.10.0 → 1.10.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.
Files changed (80) hide show
  1. package/dist/agents/definitions.js +1 -1
  2. package/dist/agents/model-lists.d.ts +26 -0
  3. package/dist/agents/model-lists.d.ts.map +1 -0
  4. package/dist/agents/model-lists.js +62 -0
  5. package/dist/agents/model-lists.js.map +1 -0
  6. package/dist/agents/orchestrator-sisyphus.js +1 -1
  7. package/dist/auth/index.d.ts +10 -0
  8. package/dist/auth/index.d.ts.map +1 -0
  9. package/dist/auth/index.js +13 -0
  10. package/dist/auth/index.js.map +1 -0
  11. package/dist/auth/manager.d.ts +54 -0
  12. package/dist/auth/manager.d.ts.map +1 -0
  13. package/dist/auth/manager.js +248 -0
  14. package/dist/auth/manager.js.map +1 -0
  15. package/dist/auth/oauth-google.d.ts +47 -0
  16. package/dist/auth/oauth-google.d.ts.map +1 -0
  17. package/dist/auth/oauth-google.js +280 -0
  18. package/dist/auth/oauth-google.js.map +1 -0
  19. package/dist/auth/oauth-openai.d.ts +46 -0
  20. package/dist/auth/oauth-openai.d.ts.map +1 -0
  21. package/dist/auth/oauth-openai.js +264 -0
  22. package/dist/auth/oauth-openai.js.map +1 -0
  23. package/dist/auth/pkce.d.ts +14 -0
  24. package/dist/auth/pkce.d.ts.map +1 -0
  25. package/dist/auth/pkce.js +35 -0
  26. package/dist/auth/pkce.js.map +1 -0
  27. package/dist/auth/storage.d.ts +52 -0
  28. package/dist/auth/storage.d.ts.map +1 -0
  29. package/dist/auth/storage.js +230 -0
  30. package/dist/auth/storage.js.map +1 -0
  31. package/dist/auth/types.d.ts +76 -0
  32. package/dist/auth/types.d.ts.map +1 -0
  33. package/dist/auth/types.js +5 -0
  34. package/dist/auth/types.js.map +1 -0
  35. package/dist/cli/index.js +0 -0
  36. package/dist/features/auto-update.d.ts +20 -0
  37. package/dist/features/auto-update.d.ts.map +1 -1
  38. package/dist/features/auto-update.js +35 -0
  39. package/dist/features/auto-update.js.map +1 -1
  40. package/dist/features/builtin-skills/skills.js +2 -2
  41. package/dist/hooks/bridge.d.ts.map +1 -1
  42. package/dist/hooks/bridge.js +26 -1
  43. package/dist/hooks/bridge.js.map +1 -1
  44. package/dist/hooks/persistent-mode/index.d.ts.map +1 -1
  45. package/dist/hooks/persistent-mode/index.js +126 -4
  46. package/dist/hooks/persistent-mode/index.js.map +1 -1
  47. package/dist/hooks/preemptive-compaction/index.js +2 -2
  48. package/dist/hooks/preemptive-compaction/index.js.map +1 -1
  49. package/dist/hooks/thinking-block-validator/index.d.ts +3 -34
  50. package/dist/hooks/thinking-block-validator/index.d.ts.map +1 -1
  51. package/dist/hooks/thinking-block-validator/index.js +21 -70
  52. package/dist/hooks/thinking-block-validator/index.js.map +1 -1
  53. package/dist/installer/hooks.d.ts +2 -2
  54. package/dist/installer/hooks.d.ts.map +1 -1
  55. package/dist/installer/hooks.js +85 -2
  56. package/dist/installer/hooks.js.map +1 -1
  57. package/dist/installer/index.js +3 -3
  58. package/dist/providers/index.d.ts +8 -0
  59. package/dist/providers/index.d.ts.map +1 -0
  60. package/dist/providers/index.js +10 -0
  61. package/dist/providers/index.js.map +1 -0
  62. package/dist/providers/registry.d.ts +29 -0
  63. package/dist/providers/registry.d.ts.map +1 -0
  64. package/dist/providers/registry.js +162 -0
  65. package/dist/providers/registry.js.map +1 -0
  66. package/dist/providers/router.d.ts +40 -0
  67. package/dist/providers/router.d.ts.map +1 -0
  68. package/dist/providers/router.js +88 -0
  69. package/dist/providers/router.js.map +1 -0
  70. package/dist/providers/types.d.ts +92 -0
  71. package/dist/providers/types.d.ts.map +1 -0
  72. package/dist/providers/types.js +27 -0
  73. package/dist/providers/types.js.map +1 -0
  74. package/dist/tools/ast-tools.d.ts +3 -3
  75. package/dist/tools/ast-tools.d.ts.map +1 -1
  76. package/dist/tools/ast-tools.js +205 -104
  77. package/dist/tools/ast-tools.js.map +1 -1
  78. package/package.json +1 -1
  79. package/scripts/install.sh +70 -3
  80. package/scripts/uninstall.sh +116 -3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.js","sourceRoot":"","sources":["../../src/providers/router.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGxE;;GAEG;AACH,MAAM,OAAO,WAAW;IACF;IAApB,YAAoB,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;IAAG,CAAC;IAEhD;;;;;;OAMG;IACH,KAAK,CAAC,YAAY,CAAC,SAAoB;QACrC,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;QAED,MAAM,cAAc,GAAmB,EAAE,CAAC;QAE1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC1C,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;YAC7B,MAAM,QAAQ,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;YAEjD,4CAA4C;YAC5C,IAAI,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACtC,SAAS;YACX,CAAC;YACD,cAAc,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAE9B,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;YAEzE,IAAI,eAAe,EAAE,CAAC;gBACpB,OAAO;oBACL,QAAQ;oBACR,OAAO;oBACP,SAAS,EAAE,kBAAkB,CAAC,OAAO,CAAC;oBACtC,UAAU,EAAE,CAAC,GAAG,CAAC;oBACjB,cAAc,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,kBAAkB,SAAS,CAAC,CAAC,CAAC,4CAA4C,CAAC,CAAC,CAAC,SAAS;iBAC/G,CAAC;YACJ,CAAC;QACH,CAAC;QAED,kDAAkD;QAClD,MAAM,IAAI,KAAK,CACb,sDAAsD,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;YAC9E,0CAA0C,CAC3C,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,UAAU,CAAC,SAAoB;QACnC,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,KAAK,MAAM,OAAO,IAAI,SAAS,EAAE,CAAC;YAChC,MAAM,QAAQ,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAC;YACjD,IAAI,MAAM,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACrD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,eAAe,CAAC,SAAoB;QACxC,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;QAC5C,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAAwB;IACxD,OAAO,IAAI,WAAW,CAAC,WAAW,CAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Provider and model type definitions for multi-provider support
3
+ */
4
+ /**
5
+ * Supported AI providers
6
+ */
7
+ export type ProviderType = 'anthropic' | 'openai' | 'google' | 'openrouter';
8
+ /**
9
+ * Model ID format: "provider/model-id"
10
+ * Examples: "openai/gpt-4o", "anthropic/claude-opus-4-5", "google/gemini-2.0-flash"
11
+ */
12
+ export type ModelId = string;
13
+ /**
14
+ * Authentication type for a provider
15
+ */
16
+ export type AuthType = 'api_key' | 'oauth';
17
+ /**
18
+ * Provider configuration and status
19
+ */
20
+ export interface ProviderConfig {
21
+ type: ProviderType;
22
+ authenticated: boolean;
23
+ authType: AuthType;
24
+ }
25
+ /**
26
+ * Result of model resolution
27
+ */
28
+ export interface ResolvedModel {
29
+ /** The provider that will be used */
30
+ provider: ProviderType;
31
+ /** The full model ID (e.g., "openai/gpt-4o") */
32
+ modelId: ModelId;
33
+ /** The model name without provider prefix (e.g., "gpt-4o") */
34
+ modelName: string;
35
+ /** Whether this is a fallback from the preferred model */
36
+ isFallback: boolean;
37
+ /** Reason for fallback, if applicable */
38
+ fallbackReason?: string;
39
+ }
40
+ /**
41
+ * Model information in the registry
42
+ */
43
+ export interface ModelInfo {
44
+ /** Full model ID (e.g., "openai/gpt-4o") */
45
+ id: ModelId;
46
+ /** Provider for this model */
47
+ provider: ProviderType;
48
+ /** Human-readable display name */
49
+ displayName: string;
50
+ /** Context window size in tokens */
51
+ contextWindow: number;
52
+ /** Whether the model supports vision/images */
53
+ supportsVision: boolean;
54
+ /** Whether the model supports tool/function calling */
55
+ supportsTools: boolean;
56
+ /** Whether the model supports streaming */
57
+ supportsStreaming: boolean;
58
+ }
59
+ /**
60
+ * OAuth tokens structure
61
+ */
62
+ export interface OAuthTokens {
63
+ accessToken: string;
64
+ refreshToken?: string;
65
+ idToken?: string;
66
+ expiresAt?: number;
67
+ tokenType?: string;
68
+ }
69
+ /**
70
+ * OAuth configuration for a provider
71
+ */
72
+ export interface OAuthConfig {
73
+ clientId: string;
74
+ clientSecret?: string;
75
+ authUrl: string;
76
+ tokenUrl: string;
77
+ redirectUri: string;
78
+ scopes: string[];
79
+ }
80
+ /**
81
+ * Extract provider from a model ID
82
+ */
83
+ export declare function getProviderFromModelId(modelId: ModelId): ProviderType;
84
+ /**
85
+ * Extract model name from a model ID
86
+ */
87
+ export declare function getModelNameFromId(modelId: ModelId): string;
88
+ /**
89
+ * Create a model ID from provider and model name
90
+ */
91
+ export declare function createModelId(provider: ProviderType, modelName: string): ModelId;
92
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/providers/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,QAAQ,GAAG,QAAQ,GAAG,YAAY,CAAC;AAE5E;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAE7B;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,OAAO,CAAC;AAE3C;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,YAAY,CAAC;IACnB,aAAa,EAAE,OAAO,CAAC;IACvB,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,qCAAqC;IACrC,QAAQ,EAAE,YAAY,CAAC;IACvB,gDAAgD;IAChD,OAAO,EAAE,OAAO,CAAC;IACjB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,UAAU,EAAE,OAAO,CAAC;IACpB,yCAAyC;IACzC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,4CAA4C;IAC5C,EAAE,EAAE,OAAO,CAAC;IACZ,8BAA8B;IAC9B,QAAQ,EAAE,YAAY,CAAC;IACvB,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,cAAc,EAAE,OAAO,CAAC;IACxB,uDAAuD;IACvD,aAAa,EAAE,OAAO,CAAC;IACvB,2CAA2C;IAC3C,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,YAAY,CAMrE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAG3D;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAEhF"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Provider and model type definitions for multi-provider support
3
+ */
4
+ /**
5
+ * Extract provider from a model ID
6
+ */
7
+ export function getProviderFromModelId(modelId) {
8
+ const [provider] = modelId.split('/');
9
+ if (!['anthropic', 'openai', 'google', 'openrouter'].includes(provider)) {
10
+ throw new Error(`Unknown provider in model ID: ${modelId}`);
11
+ }
12
+ return provider;
13
+ }
14
+ /**
15
+ * Extract model name from a model ID
16
+ */
17
+ export function getModelNameFromId(modelId) {
18
+ const parts = modelId.split('/');
19
+ return parts.slice(1).join('/');
20
+ }
21
+ /**
22
+ * Create a model ID from provider and model name
23
+ */
24
+ export function createModelId(provider, modelName) {
25
+ return `${provider}/${modelName}`;
26
+ }
27
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/providers/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAsFH;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACrD,MAAM,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,IAAI,CAAC,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CAAC,iCAAiC,OAAO,EAAE,CAAC,CAAC;IAC9D,CAAC;IACD,OAAO,QAAwB,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAgB;IACjD,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,QAAsB,EAAE,SAAiB;IACrE,OAAO,GAAG,QAAQ,IAAI,SAAS,EAAE,CAAC;AACpC,CAAC"}
@@ -6,14 +6,14 @@
6
6
  * - Code replacement while preserving structure
7
7
  * - Support for 25+ programming languages
8
8
  */
9
- import { z } from 'zod';
9
+ import { z } from "zod";
10
10
  export interface AstToolDefinition<T extends z.ZodRawShape> {
11
11
  name: string;
12
12
  description: string;
13
13
  schema: T;
14
14
  handler: (args: z.infer<z.ZodObject<T>>) => Promise<{
15
15
  content: Array<{
16
- type: 'text';
16
+ type: "text";
17
17
  text: string;
18
18
  }>;
19
19
  }>;
@@ -23,7 +23,7 @@ export interface AstToolDefinition<T extends z.ZodRawShape> {
23
23
  * Maps to ast-grep language identifiers
24
24
  */
25
25
  export declare const SUPPORTED_LANGUAGES: [string, ...string[]];
26
- export type SupportedLanguage = typeof SUPPORTED_LANGUAGES[number];
26
+ export type SupportedLanguage = (typeof SUPPORTED_LANGUAGES)[number];
27
27
  /**
28
28
  * AST Grep Search Tool - Find code patterns using AST matching
29
29
  */
@@ -1 +1 @@
1
- {"version":3,"file":"ast-tools.d.ts","sourceRoot":"","sources":["../../src/tools/ast-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAcxB,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,CAAC,CAAC,WAAW;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC;IACV,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC;QAAE,OAAO,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE,CAAC,CAAC;CACzG;AAED;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAIrD,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAC;AA8GnE;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,iBAAiB,CAAC;IAChD,OAAO,EAAE,CAAC,CAAC,SAAS,CAAC;IACrB,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC;IAC3C,IAAI,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACjC,OAAO,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACpC,UAAU,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;CACxC,CAiGA,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,k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AC,UAAU,CAAC,CAAC;CACrC,CA4LA,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ;aAnVV,CAAC,CAAC,SAAS;cACV,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;UACpC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;aACvB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;gBACvB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;;aAyI7B,CAAC,CAAC,SAAS;iBACP,CAAC,CAAC,SAAS;cACd,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;UACpC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC;YACxB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,UAAU,CAAC;KAkM0B,CAAC"}
@@ -6,59 +6,103 @@
6
6
  * - Code replacement while preserving structure
7
7
  * - Support for 25+ programming languages
8
8
  */
9
- import { z } from 'zod';
10
- import { readFileSync, readdirSync, statSync, writeFileSync } from 'fs';
11
- import { join, extname, resolve } from 'path';
9
+ import { z } from "zod";
10
+ import { readFileSync, readdirSync, statSync, writeFileSync } from "fs";
11
+ import { join, extname, resolve } from "path";
12
12
  // Dynamic import for @ast-grep/napi (ESM module)
13
13
  let sgModule = null;
14
14
  async function getSgModule() {
15
15
  if (!sgModule) {
16
- sgModule = await import('@ast-grep/napi');
16
+ sgModule = await import("@ast-grep/napi");
17
17
  }
18
18
  return sgModule;
19
19
  }
20
+ /**
21
+ * Convert lowercase language string to ast-grep Lang enum value
22
+ * This provides type-safe language conversion without using 'as any'
23
+ */
24
+ function toLangEnum(sg, language) {
25
+ const langMap = {
26
+ javascript: sg.Lang.JavaScript,
27
+ typescript: sg.Lang.TypeScript,
28
+ tsx: sg.Lang.Tsx,
29
+ python: sg.Lang.Python,
30
+ ruby: sg.Lang.Ruby,
31
+ go: sg.Lang.Go,
32
+ rust: sg.Lang.Rust,
33
+ java: sg.Lang.Java,
34
+ kotlin: sg.Lang.Kotlin,
35
+ swift: sg.Lang.Swift,
36
+ c: sg.Lang.C,
37
+ cpp: sg.Lang.Cpp,
38
+ csharp: sg.Lang.CSharp,
39
+ html: sg.Lang.Html,
40
+ css: sg.Lang.Css,
41
+ json: sg.Lang.Json,
42
+ yaml: sg.Lang.Yaml,
43
+ };
44
+ const lang = langMap[language];
45
+ if (!lang) {
46
+ throw new Error(`Unsupported language: ${language}`);
47
+ }
48
+ return lang;
49
+ }
20
50
  /**
21
51
  * Supported languages for AST analysis
22
52
  * Maps to ast-grep language identifiers
23
53
  */
24
54
  export const SUPPORTED_LANGUAGES = [
25
- 'javascript', 'typescript', 'tsx', 'python', 'ruby', 'go', 'rust',
26
- 'java', 'kotlin', 'swift', 'c', 'cpp', 'csharp',
27
- 'html', 'css', 'json', 'yaml'
55
+ "javascript",
56
+ "typescript",
57
+ "tsx",
58
+ "python",
59
+ "ruby",
60
+ "go",
61
+ "rust",
62
+ "java",
63
+ "kotlin",
64
+ "swift",
65
+ "c",
66
+ "cpp",
67
+ "csharp",
68
+ "html",
69
+ "css",
70
+ "json",
71
+ "yaml",
28
72
  ];
29
73
  /**
30
74
  * Map file extensions to ast-grep language identifiers
31
75
  */
32
76
  const EXT_TO_LANG = {
33
- '.js': 'javascript',
34
- '.mjs': 'javascript',
35
- '.cjs': 'javascript',
36
- '.jsx': 'javascript',
37
- '.ts': 'typescript',
38
- '.mts': 'typescript',
39
- '.cts': 'typescript',
40
- '.tsx': 'tsx',
41
- '.py': 'python',
42
- '.rb': 'ruby',
43
- '.go': 'go',
44
- '.rs': 'rust',
45
- '.java': 'java',
46
- '.kt': 'kotlin',
47
- '.kts': 'kotlin',
48
- '.swift': 'swift',
49
- '.c': 'c',
50
- '.h': 'c',
51
- '.cpp': 'cpp',
52
- '.cc': 'cpp',
53
- '.cxx': 'cpp',
54
- '.hpp': 'cpp',
55
- '.cs': 'csharp',
56
- '.html': 'html',
57
- '.htm': 'html',
58
- '.css': 'css',
59
- '.json': 'json',
60
- '.yaml': 'yaml',
61
- '.yml': 'yaml'
77
+ ".js": "javascript",
78
+ ".mjs": "javascript",
79
+ ".cjs": "javascript",
80
+ ".jsx": "javascript",
81
+ ".ts": "typescript",
82
+ ".mts": "typescript",
83
+ ".cts": "typescript",
84
+ ".tsx": "tsx",
85
+ ".py": "python",
86
+ ".rb": "ruby",
87
+ ".go": "go",
88
+ ".rs": "rust",
89
+ ".java": "java",
90
+ ".kt": "kotlin",
91
+ ".kts": "kotlin",
92
+ ".swift": "swift",
93
+ ".c": "c",
94
+ ".h": "c",
95
+ ".cpp": "cpp",
96
+ ".cc": "cpp",
97
+ ".cxx": "cpp",
98
+ ".hpp": "cpp",
99
+ ".cs": "csharp",
100
+ ".html": "html",
101
+ ".htm": "html",
102
+ ".css": "css",
103
+ ".json": "json",
104
+ ".yaml": "yaml",
105
+ ".yml": "yaml",
62
106
  };
63
107
  /**
64
108
  * Get files matching the language in a directory
@@ -79,7 +123,15 @@ function getFilesForLanguage(dirPath, language, maxFiles = 1000) {
79
123
  const fullPath = join(dir, entry.name);
80
124
  // Skip common non-source directories
81
125
  if (entry.isDirectory()) {
82
- if (!['node_modules', '.git', 'dist', 'build', '__pycache__', '.venv', 'venv'].includes(entry.name)) {
126
+ if (![
127
+ "node_modules",
128
+ ".git",
129
+ "dist",
130
+ "build",
131
+ "__pycache__",
132
+ ".venv",
133
+ "venv",
134
+ ].includes(entry.name)) {
83
135
  walk(fullPath);
84
136
  }
85
137
  }
@@ -107,23 +159,23 @@ function getFilesForLanguage(dirPath, language, maxFiles = 1000) {
107
159
  * Format a match result for display
108
160
  */
109
161
  function formatMatch(filePath, matchText, startLine, endLine, context, fileContent) {
110
- const lines = fileContent.split('\n');
162
+ const lines = fileContent.split("\n");
111
163
  const contextStart = Math.max(0, startLine - context - 1);
112
164
  const contextEnd = Math.min(lines.length, endLine + context);
113
165
  const contextLines = lines.slice(contextStart, contextEnd);
114
166
  const numberedLines = contextLines.map((line, i) => {
115
167
  const lineNum = contextStart + i + 1;
116
168
  const isMatch = lineNum >= startLine && lineNum <= endLine;
117
- const prefix = isMatch ? '>' : ' ';
169
+ const prefix = isMatch ? ">" : " ";
118
170
  return `${prefix} ${lineNum.toString().padStart(4)}: ${line}`;
119
171
  });
120
- return `${filePath}:${startLine}\n${numberedLines.join('\n')}`;
172
+ return `${filePath}:${startLine}\n${numberedLines.join("\n")}`;
121
173
  }
122
174
  /**
123
175
  * AST Grep Search Tool - Find code patterns using AST matching
124
176
  */
125
177
  export const astGrepSearchTool = {
126
- name: 'ast_grep_search',
178
+ name: "ast_grep_search",
127
179
  description: `Search for code patterns using AST matching. More precise than text search.
128
180
 
129
181
  Use meta-variables in patterns:
@@ -139,23 +191,42 @@ Examples:
139
191
 
140
192
  Note: Patterns must be valid AST nodes for the language.`,
141
193
  schema: {
142
- pattern: z.string().describe('AST pattern with meta-variables ($VAR, $$$VARS)'),
143
- language: z.enum(SUPPORTED_LANGUAGES).describe('Programming language'),
144
- path: z.string().optional().describe('Directory or file to search (default: current directory)'),
145
- context: z.number().int().min(0).max(10).optional().describe('Lines of context around matches (default: 2)'),
146
- maxResults: z.number().int().min(1).max(100).optional().describe('Maximum results to return (default: 20)')
194
+ pattern: z
195
+ .string()
196
+ .describe("AST pattern with meta-variables ($VAR, $$$VARS)"),
197
+ language: z.enum(SUPPORTED_LANGUAGES).describe("Programming language"),
198
+ path: z
199
+ .string()
200
+ .optional()
201
+ .describe("Directory or file to search (default: current directory)"),
202
+ context: z
203
+ .number()
204
+ .int()
205
+ .min(0)
206
+ .max(10)
207
+ .optional()
208
+ .describe("Lines of context around matches (default: 2)"),
209
+ maxResults: z
210
+ .number()
211
+ .int()
212
+ .min(1)
213
+ .max(100)
214
+ .optional()
215
+ .describe("Maximum results to return (default: 20)"),
147
216
  },
148
217
  handler: async (args) => {
149
- const { pattern, language, path = '.', context = 2, maxResults = 20 } = args;
218
+ const { pattern, language, path = ".", context = 2, maxResults = 20, } = args;
150
219
  try {
151
220
  const sg = await getSgModule();
152
221
  const files = getFilesForLanguage(path, language);
153
222
  if (files.length === 0) {
154
223
  return {
155
- content: [{
156
- type: 'text',
157
- text: `No ${language} files found in ${path}`
158
- }]
224
+ content: [
225
+ {
226
+ type: "text",
227
+ text: `No ${language} files found in ${path}`,
228
+ },
229
+ ],
159
230
  };
160
231
  }
161
232
  const results = [];
@@ -164,8 +235,8 @@ Note: Patterns must be valid AST nodes for the language.`,
164
235
  if (totalMatches >= maxResults)
165
236
  break;
166
237
  try {
167
- const content = readFileSync(filePath, 'utf-8');
168
- const root = sg.parse(language, content).root();
238
+ const content = readFileSync(filePath, "utf-8");
239
+ const root = sg.parse(toLangEnum(sg, language), content).root();
169
240
  const matches = root.findAll(pattern);
170
241
  for (const match of matches) {
171
242
  if (totalMatches >= maxResults)
@@ -183,35 +254,41 @@ Note: Patterns must be valid AST nodes for the language.`,
183
254
  }
184
255
  if (results.length === 0) {
185
256
  return {
186
- content: [{
187
- type: 'text',
188
- text: `No matches found for pattern: ${pattern}\n\nSearched ${files.length} ${language} file(s) in ${path}\n\nTip: Ensure the pattern is a valid AST node. For example:\n- Use "function $NAME" not just "$NAME"\n- Use "console.log($X)" not "console.log"`
189
- }]
257
+ content: [
258
+ {
259
+ type: "text",
260
+ text: `No matches found for pattern: ${pattern}\n\nSearched ${files.length} ${language} file(s) in ${path}\n\nTip: Ensure the pattern is a valid AST node. For example:\n- Use "function $NAME" not just "$NAME"\n- Use "console.log($X)" not "console.log"`,
261
+ },
262
+ ],
190
263
  };
191
264
  }
192
265
  const header = `Found ${totalMatches} match(es) in ${files.length} file(s)\nPattern: ${pattern}\n\n`;
193
266
  return {
194
- content: [{
195
- type: 'text',
196
- text: header + results.join('\n\n---\n\n')
197
- }]
267
+ content: [
268
+ {
269
+ type: "text",
270
+ text: header + results.join("\n\n---\n\n"),
271
+ },
272
+ ],
198
273
  };
199
274
  }
200
275
  catch (error) {
201
276
  return {
202
- content: [{
203
- type: 'text',
204
- text: `Error in AST search: ${error instanceof Error ? error.message : String(error)}\n\nCommon issues:\n- Pattern must be a complete AST node\n- Language must match file type\n- Check that @ast-grep/napi is installed`
205
- }]
277
+ content: [
278
+ {
279
+ type: "text",
280
+ text: `Error in AST search: ${error instanceof Error ? error.message : String(error)}\n\nCommon issues:\n- Pattern must be a complete AST node\n- Language must match file type\n- Check that @ast-grep/napi is installed`,
281
+ },
282
+ ],
206
283
  };
207
284
  }
208
- }
285
+ },
209
286
  };
210
287
  /**
211
288
  * AST Grep Replace Tool - Replace code patterns using AST matching
212
289
  */
213
290
  export const astGrepReplaceTool = {
214
- name: 'ast_grep_replace',
291
+ name: "ast_grep_replace",
215
292
  description: `Replace code patterns using AST matching. Preserves matched content via meta-variables.
216
293
 
217
294
  Use meta-variables in both pattern and replacement:
@@ -225,31 +302,41 @@ Examples:
225
302
 
226
303
  IMPORTANT: dryRun=true (default) only previews changes. Set dryRun=false to apply.`,
227
304
  schema: {
228
- pattern: z.string().describe('Pattern to match'),
229
- replacement: z.string().describe('Replacement pattern (use same meta-variables)'),
230
- language: z.enum(SUPPORTED_LANGUAGES).describe('Programming language'),
231
- path: z.string().optional().describe('Directory or file to search (default: current directory)'),
232
- dryRun: z.boolean().optional().describe('Preview only, don\'t apply changes (default: true)')
305
+ pattern: z.string().describe("Pattern to match"),
306
+ replacement: z
307
+ .string()
308
+ .describe("Replacement pattern (use same meta-variables)"),
309
+ language: z.enum(SUPPORTED_LANGUAGES).describe("Programming language"),
310
+ path: z
311
+ .string()
312
+ .optional()
313
+ .describe("Directory or file to search (default: current directory)"),
314
+ dryRun: z
315
+ .boolean()
316
+ .optional()
317
+ .describe("Preview only, don't apply changes (default: true)"),
233
318
  },
234
319
  handler: async (args) => {
235
- const { pattern, replacement, language, path = '.', dryRun = true } = args;
320
+ const { pattern, replacement, language, path = ".", dryRun = true } = args;
236
321
  try {
237
322
  const sg = await getSgModule();
238
323
  const files = getFilesForLanguage(path, language);
239
324
  if (files.length === 0) {
240
325
  return {
241
- content: [{
242
- type: 'text',
243
- text: `No ${language} files found in ${path}`
244
- }]
326
+ content: [
327
+ {
328
+ type: "text",
329
+ text: `No ${language} files found in ${path}`,
330
+ },
331
+ ],
245
332
  };
246
333
  }
247
334
  const changes = [];
248
335
  let totalReplacements = 0;
249
336
  for (const filePath of files) {
250
337
  try {
251
- const content = readFileSync(filePath, 'utf-8');
252
- const root = sg.parse(language, content).root();
338
+ const content = readFileSync(filePath, "utf-8");
339
+ const root = sg.parse(toLangEnum(sg, language), content).root();
253
340
  const matches = root.findAll(pattern);
254
341
  if (matches.length === 0)
255
342
  continue;
@@ -270,7 +357,7 @@ IMPORTANT: dryRun=true (default) only previews changes. Set dryRun=false to appl
270
357
  // Replace meta-variables in the replacement string
271
358
  const metaVars = replacement.match(/\$\$?\$?[A-Z_][A-Z0-9_]*/g) || [];
272
359
  for (const metaVar of metaVars) {
273
- const varName = metaVar.replace(/^\$+/, '');
360
+ const varName = metaVar.replace(/^\$+/, "");
274
361
  const captured = match.getMatch(varName);
275
362
  if (captured) {
276
363
  finalReplacement = finalReplacement.replace(metaVar, captured.text());
@@ -285,7 +372,7 @@ IMPORTANT: dryRun=true (default) only previews changes. Set dryRun=false to appl
285
372
  end: endOffset,
286
373
  replacement: finalReplacement,
287
374
  line: range.start.line + 1,
288
- before: matchedText
375
+ before: matchedText,
289
376
  });
290
377
  }
291
378
  // Sort edits in reverse order to apply from end to start
@@ -293,17 +380,20 @@ IMPORTANT: dryRun=true (default) only previews changes. Set dryRun=false to appl
293
380
  let newContent = content;
294
381
  for (const edit of edits) {
295
382
  const before = newContent.slice(edit.start, edit.end);
296
- newContent = newContent.slice(0, edit.start) + edit.replacement + newContent.slice(edit.end);
383
+ newContent =
384
+ newContent.slice(0, edit.start) +
385
+ edit.replacement +
386
+ newContent.slice(edit.end);
297
387
  changes.push({
298
388
  file: filePath,
299
389
  before,
300
390
  after: edit.replacement,
301
- line: edit.line
391
+ line: edit.line,
302
392
  });
303
393
  totalReplacements++;
304
394
  }
305
395
  if (!dryRun && edits.length > 0) {
306
- writeFileSync(filePath, newContent, 'utf-8');
396
+ writeFileSync(filePath, newContent, "utf-8");
307
397
  }
308
398
  }
309
399
  catch {
@@ -312,38 +402,49 @@ IMPORTANT: dryRun=true (default) only previews changes. Set dryRun=false to appl
312
402
  }
313
403
  if (changes.length === 0) {
314
404
  return {
315
- content: [{
316
- type: 'text',
317
- text: `No matches found for pattern: ${pattern}\n\nSearched ${files.length} ${language} file(s) in ${path}`
318
- }]
405
+ content: [
406
+ {
407
+ type: "text",
408
+ text: `No matches found for pattern: ${pattern}\n\nSearched ${files.length} ${language} file(s) in ${path}`,
409
+ },
410
+ ],
319
411
  };
320
412
  }
321
- const mode = dryRun ? 'DRY RUN (no changes applied)' : 'CHANGES APPLIED';
413
+ const mode = dryRun ? "DRY RUN (no changes applied)" : "CHANGES APPLIED";
322
414
  const header = `${mode}\n\nFound ${totalReplacements} replacement(s) in ${files.length} file(s)\nPattern: ${pattern}\nReplacement: ${replacement}\n\n`;
323
- const changeList = changes.slice(0, 50).map(c => `${c.file}:${c.line}\n - ${c.before}\n + ${c.after}`).join('\n\n');
324
- const footer = changes.length > 50 ? `\n\n... and ${changes.length - 50} more changes` : '';
415
+ const changeList = changes
416
+ .slice(0, 50)
417
+ .map((c) => `${c.file}:${c.line}\n - ${c.before}\n + ${c.after}`)
418
+ .join("\n\n");
419
+ const footer = changes.length > 50
420
+ ? `\n\n... and ${changes.length - 50} more changes`
421
+ : "";
325
422
  return {
326
- content: [{
327
- type: 'text',
328
- text: header + changeList + footer + (dryRun ? '\n\nTo apply changes, run with dryRun: false' : '')
329
- }]
423
+ content: [
424
+ {
425
+ type: "text",
426
+ text: header +
427
+ changeList +
428
+ footer +
429
+ (dryRun ? "\n\nTo apply changes, run with dryRun: false" : ""),
430
+ },
431
+ ],
330
432
  };
331
433
  }
332
434
  catch (error) {
333
435
  return {
334
- content: [{
335
- type: 'text',
336
- text: `Error in AST replace: ${error instanceof Error ? error.message : String(error)}`
337
- }]
436
+ content: [
437
+ {
438
+ type: "text",
439
+ text: `Error in AST replace: ${error instanceof Error ? error.message : String(error)}`,
440
+ },
441
+ ],
338
442
  };
339
443
  }
340
- }
444
+ },
341
445
  };
342
446
  /**
343
447
  * Get all AST tool definitions
344
448
  */
345
- export const astTools = [
346
- astGrepSearchTool,
347
- astGrepReplaceTool
348
- ];
449
+ export const astTools = [astGrepSearchTool, astGrepReplaceTool];
349
450
  //# sourceMappingURL=ast-tools.js.map