zangief 0.1.1 → 1.0.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 (3) hide show
  1. package/dist/index.d.ts +211 -0
  2. package/dist/index.js +98 -68427
  3. package/package.json +16 -6
@@ -0,0 +1,211 @@
1
+ import * as llmist from 'llmist';
2
+ import { LLMist, AgentBuilder } from 'llmist';
3
+
4
+ /**
5
+ * SourcegraphExplorer agent factory.
6
+ */
7
+
8
+ /**
9
+ * Creates a pre-configured agent for exploring code via Sourcegraph.
10
+ *
11
+ * The agent comes with all Sourcegraph gadgets and an optimized system
12
+ * prompt that explains query syntax and best practices.
13
+ *
14
+ * @param client - LLMist client instance
15
+ * @returns Configured AgentBuilder ready for use
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * import { LLMist } from 'llmist';
20
+ * import { createSourcegraphExplorer } from 'sourcegraph-search-gadget';
21
+ *
22
+ * const client = new LLMist();
23
+ * const result = await createSourcegraphExplorer(client)
24
+ * .withModel('sonnet')
25
+ * .askAndCollect('Find how React implements useState');
26
+ * ```
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * // Streaming usage
31
+ * const agent = createSourcegraphExplorer(client)
32
+ * .withModel('sonnet')
33
+ * .ask('Explore the TypeScript compiler architecture');
34
+ *
35
+ * for await (const event of agent.run()) {
36
+ * if (event.type === 'text') {
37
+ * process.stdout.write(event.content);
38
+ * }
39
+ * }
40
+ * ```
41
+ */
42
+ declare function createSourcegraphExplorer(client: LLMist): AgentBuilder;
43
+
44
+ /**
45
+ * System prompt for the SourcegraphExplorer agent.
46
+ */
47
+ declare const SOURCEGRAPH_SYSTEM_PROMPT = "You are a code exploration assistant with access to Sourcegraph, a powerful code search engine that indexes millions of public repositories on GitHub.\n\n## Available Tools\n\nYou have 4 tools for exploring code:\n\n1. **SourcegraphSearch** - Search code across repositories\n - Use for finding code patterns, functions, implementations\n - Supports filters: repo:, lang:, file:, type:, case:\n\n2. **SourcegraphGetFile** - Read full file contents\n - Use after finding interesting files via search\n - Requires repo path and file path\n\n3. **SourcegraphListRepos** - List/search repositories\n - Use to discover repositories before searching\n - Filter by name patterns\n\n4. **SourcegraphCommitSearch** - Search commits and diffs\n - Use type:commit for commit messages\n - Use type:diff for code changes\n\n## Sourcegraph Query Syntax\n\n**Repository filters:**\n- `repo:github.com/org/repo` - Exact repo\n- `repo:^github.com/org/` - Regex (all repos in org)\n- `-repo:test` - Exclude repos matching pattern\n\n**Language and file filters:**\n- `lang:typescript` - Filter by language\n- `file:*.ts` - Filter by file pattern\n- `file:^src/` - Files in src directory\n\n**Search modifiers:**\n- `case:yes` - Case sensitive\n- `count:100` - Return up to 100 results\n- `type:symbol` - Search symbols only\n- `type:commit` - Search commit messages\n- `type:diff` - Search diffs\n\n**Boolean operators:**\n- `AND` or space - Both terms required\n- `OR` - Either term\n- `NOT` or `-` - Exclude term\n\n## Best Practices\n\n1. **Start broad, then narrow** - Begin with a general search, then add filters\n2. **Use language filters** - `lang:typescript` dramatically improves results\n3. **Specify repos when possible** - `repo:github.com/facebook/react` for targeted searches\n4. **Read files after finding them** - Use SourcegraphGetFile to see full context\n5. **Search commits for history** - Use type:commit to understand changes over time\n\n## Example Workflow\n\n1. List repos in an organization:\n `SourcegraphListRepos({ query: \"github.com/facebook/\" })`\n\n2. Search for specific code:\n `SourcegraphSearch({ query: \"useState lang:typescript repo:github.com/facebook/react\" })`\n\n3. Read interesting files:\n `SourcegraphGetFile({ repo: \"github.com/facebook/react\", path: \"packages/react/src/ReactHooks.js\" })`\n\n4. Check commit history:\n `SourcegraphCommitSearch({ query: \"type:commit useState repo:github.com/facebook/react\" })`\n";
48
+
49
+ /**
50
+ * SourcegraphSearch gadget - Search code across public GitHub repos.
51
+ */
52
+ declare const sourcegraphSearch: llmist.AbstractGadget;
53
+
54
+ /**
55
+ * SourcegraphGetFile gadget - Fetch file contents from a repository.
56
+ */
57
+ declare const sourcegraphGetFile: llmist.AbstractGadget;
58
+
59
+ /**
60
+ * SourcegraphListRepos gadget - List and search repositories.
61
+ */
62
+ declare const sourcegraphListRepos: llmist.AbstractGadget;
63
+
64
+ /**
65
+ * SourcegraphCommitSearch gadget - Search commits and diffs.
66
+ */
67
+ declare const sourcegraphCommitSearch: llmist.AbstractGadget;
68
+
69
+ /**
70
+ * Array of all Sourcegraph gadgets for easy registration.
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * import { sourcegraphGadgets } from 'sourcegraph-search-gadget';
75
+ *
76
+ * const agent = LLMist.createAgent()
77
+ * .withGadgets(...sourcegraphGadgets)
78
+ * .ask('Search for React hooks');
79
+ * ```
80
+ */
81
+ declare const sourcegraphGadgets: readonly [llmist.AbstractGadget, llmist.AbstractGadget, llmist.AbstractGadget, llmist.AbstractGadget];
82
+
83
+ /**
84
+ * TypeScript interfaces for Sourcegraph GraphQL API responses.
85
+ */
86
+ interface SearchResult {
87
+ search: {
88
+ results: {
89
+ matchCount: number;
90
+ limitHit: boolean;
91
+ cloning: Array<{
92
+ name: string;
93
+ }>;
94
+ missing: Array<{
95
+ name: string;
96
+ }>;
97
+ timedout: Array<{
98
+ name: string;
99
+ }>;
100
+ results: Array<FileMatch | CommitMatch | RepoMatch>;
101
+ };
102
+ };
103
+ }
104
+ interface FileMatch {
105
+ __typename: "FileMatch";
106
+ repository: {
107
+ name: string;
108
+ url: string;
109
+ };
110
+ file: {
111
+ path: string;
112
+ url: string;
113
+ };
114
+ lineMatches: Array<{
115
+ lineNumber: number;
116
+ preview: string;
117
+ offsetAndLengths: Array<[number, number]>;
118
+ }>;
119
+ chunkMatches?: Array<{
120
+ content: string;
121
+ contentStart: {
122
+ line: number;
123
+ };
124
+ ranges: Array<{
125
+ start: {
126
+ line: number;
127
+ };
128
+ end: {
129
+ line: number;
130
+ };
131
+ }>;
132
+ }>;
133
+ }
134
+ interface CommitMatch {
135
+ __typename: "CommitSearchResult";
136
+ commit: {
137
+ oid: string;
138
+ abbreviatedOID: string;
139
+ message: string;
140
+ subject: string;
141
+ body: string | null;
142
+ author: {
143
+ person: {
144
+ displayName: string;
145
+ email: string;
146
+ };
147
+ date: string;
148
+ };
149
+ url: string;
150
+ repository: {
151
+ name: string;
152
+ url: string;
153
+ };
154
+ };
155
+ matches?: Array<{
156
+ body: {
157
+ text: string;
158
+ };
159
+ }>;
160
+ }
161
+ interface RepoMatch {
162
+ __typename: "Repository";
163
+ name: string;
164
+ url: string;
165
+ description: string;
166
+ }
167
+ interface FileContentResult {
168
+ repository: {
169
+ commit: {
170
+ file: {
171
+ content: string;
172
+ byteSize: number;
173
+ richHTML?: string;
174
+ } | null;
175
+ } | null;
176
+ } | null;
177
+ }
178
+ interface RepositoryListResult {
179
+ repositories: {
180
+ nodes: Array<{
181
+ name: string;
182
+ description: string;
183
+ url: string;
184
+ externalURLs: Array<{
185
+ url: string;
186
+ serviceKind: string;
187
+ }>;
188
+ defaultBranch: {
189
+ name: string;
190
+ } | null;
191
+ }>;
192
+ totalCount: number;
193
+ pageInfo: {
194
+ hasNextPage: boolean;
195
+ endCursor: string | null;
196
+ };
197
+ };
198
+ }
199
+
200
+ declare class SourcegraphClientError extends Error {
201
+ readonly statusCode?: number | undefined;
202
+ readonly graphqlErrors?: Array<{
203
+ message: string;
204
+ }> | undefined;
205
+ constructor(message: string, statusCode?: number | undefined, graphqlErrors?: Array<{
206
+ message: string;
207
+ }> | undefined);
208
+ }
209
+ declare function sourcegraphQuery<T>(query: string, variables?: Record<string, unknown>, timeoutMs?: number): Promise<T>;
210
+
211
+ export { type CommitMatch, type FileContentResult, type FileMatch, type RepoMatch, type RepositoryListResult, SOURCEGRAPH_SYSTEM_PROMPT, type SearchResult, SourcegraphClientError, createSourcegraphExplorer, sourcegraphCommitSearch, sourcegraphGadgets, sourcegraphGetFile, sourcegraphListRepos, sourcegraphQuery, sourcegraphSearch };