@deepagents/orchestrator 6.1.0 → 7.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 (62) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/lib/arxiv/arxiv.js +153 -0
  4. package/dist/lib/arxiv/arxiv.js.map +7 -0
  5. package/dist/lib/citation.js +120 -0
  6. package/dist/lib/citation.js.map +7 -0
  7. package/dist/lib/deepplan/demo.js +518 -0
  8. package/dist/lib/deepplan/demo.js.map +7 -0
  9. package/dist/lib/deepplan/executors/generic-executor.js +196 -0
  10. package/dist/lib/deepplan/executors/generic-executor.js.map +7 -0
  11. package/dist/lib/deepplan/executors/hackernews-executor.js +210 -0
  12. package/dist/lib/deepplan/executors/hackernews-executor.js.map +7 -0
  13. package/dist/lib/deepplan/executors/product-manager-executor.js +226 -0
  14. package/dist/lib/deepplan/executors/product-manager-executor.js.map +7 -0
  15. package/dist/lib/deepplan/executors/repo-search-executor.js +76 -0
  16. package/dist/lib/deepplan/executors/repo-search-executor.js.map +7 -0
  17. package/dist/lib/deepplan/executors/research-executor.js +196 -0
  18. package/dist/lib/deepplan/executors/research-executor.js.map +7 -0
  19. package/dist/lib/deepplan/next/plan.js +1 -0
  20. package/dist/lib/deepplan/next/plan.js.map +7 -0
  21. package/dist/lib/deepplan/plan-and-solve.js +826 -0
  22. package/dist/lib/deepplan/plan-and-solve.js.map +7 -0
  23. package/dist/lib/deepplan/planner-agent.js +416 -0
  24. package/dist/lib/deepplan/planner-agent.js.map +7 -0
  25. package/dist/lib/deepplan/replanner-agent.js +418 -0
  26. package/dist/lib/deepplan/replanner-agent.js.map +7 -0
  27. package/dist/lib/deepplan/synthesizer.js +75 -0
  28. package/dist/lib/deepplan/synthesizer.js.map +7 -0
  29. package/dist/lib/deepresearch.v0.js +297 -0
  30. package/dist/lib/deepresearch.v0.js.map +7 -0
  31. package/dist/lib/deepresearch.v1.js +260 -0
  32. package/dist/lib/deepresearch.v1.js.map +7 -0
  33. package/dist/lib/deepwiki/complete-wiki.js +319 -0
  34. package/dist/lib/deepwiki/complete-wiki.js.map +7 -0
  35. package/dist/lib/deepwiki/deepwiki.js +370 -0
  36. package/dist/lib/deepwiki/deepwiki.js.map +7 -0
  37. package/dist/lib/deepwiki/gitignore-agent.js +40 -0
  38. package/dist/lib/deepwiki/gitignore-agent.js.map +7 -0
  39. package/dist/lib/deepwiki/outline-agent.d.ts.map +1 -1
  40. package/dist/lib/deepwiki/outline-agent.js +186 -0
  41. package/dist/lib/deepwiki/outline-agent.js.map +7 -0
  42. package/dist/lib/deepwiki/wiki-writer.js +242 -0
  43. package/dist/lib/deepwiki/wiki-writer.js.map +7 -0
  44. package/dist/lib/deepwiki/writer.js +407 -0
  45. package/dist/lib/deepwiki/writer.js.map +7 -0
  46. package/dist/lib/evolving.js +204 -0
  47. package/dist/lib/evolving.js.map +7 -0
  48. package/dist/lib/graph.js +12 -0
  49. package/dist/lib/graph.js.map +7 -0
  50. package/dist/lib/openai-deepresearch/clarrify-agent.js +67 -0
  51. package/dist/lib/openai-deepresearch/clarrify-agent.js.map +7 -0
  52. package/dist/lib/openai-deepresearch/lead-research.js +168 -0
  53. package/dist/lib/openai-deepresearch/lead-research.js.map +7 -0
  54. package/dist/lib/openai-deepresearch/openai-deepresearch.js +179 -0
  55. package/dist/lib/openai-deepresearch/openai-deepresearch.js.map +7 -0
  56. package/dist/lib/openai-deepresearch/reasearcher.js +62 -0
  57. package/dist/lib/openai-deepresearch/reasearcher.js.map +7 -0
  58. package/dist/lib/openai-deepresearch/research-brief.js +59 -0
  59. package/dist/lib/openai-deepresearch/research-brief.js.map +7 -0
  60. package/dist/lib/repo-context.js +11 -0
  61. package/dist/lib/repo-context.js.map +7 -0
  62. package/package.json +8 -8
@@ -0,0 +1,186 @@
1
+ // packages/orchestrator/src/lib/deepwiki/outline-agent.ts
2
+ import { groq } from "@ai-sdk/groq";
3
+ import { generateId, toUIMessageStream, tool } from "ai";
4
+ import z from "zod";
5
+ import {
6
+ agent,
7
+ execute,
8
+ generate,
9
+ instructions,
10
+ user
11
+ } from "@deepagents/agent";
12
+ import { read_file_tool, scratchpad_tool } from "@deepagents/toolbox";
13
+ var BaseOutlineItem = z.object({
14
+ title: z.string().trim().min(1, "Title is required")
15
+ });
16
+ var OutlineItemSchema = z.lazy(
17
+ () => BaseOutlineItem.extend({
18
+ sections: z.array(OutlineItemSchema).optional()
19
+ })
20
+ );
21
+ var OutlineSchema = z.array(OutlineItemSchema);
22
+ var outlineAgent = agent({
23
+ name: "Outline Agent",
24
+ model: groq("moonshotai/kimi-k2-instruct-0905"),
25
+ // model: lmstudio('qwen/qwen3-8b'),
26
+ // model: lmstudio('openai/gpt-oss-20b'),
27
+ // temperature: 0.1,
28
+ prompt: (context) => instructions({
29
+ purpose: [
30
+ "You are wiki architect, meticulously analyzing a repository's structure and content to automatically generate a comprehensive, intelligent, and perfectly structured outline, laying the bedrock for exceptional documentation.",
31
+ "\n",
32
+ "<RepositoryTree>",
33
+ context?.tree || "",
34
+ "</RepositoryTree>"
35
+ ],
36
+ routine: []
37
+ // routine: [
38
+ // 'Your primary tool for memory is your `scratchpad`. After every action, you MUST summarize your findings and add them to the scratchpad using the `update_scratchpad` tool.',
39
+ // 'Systematically investigate key files and directories use `search_files`. For each finding add it as a new note to your scratchpad.',
40
+ // 'When you read a file like `README.md` or `package.json`, do not keep the whole content in your head. Instead, summarize the important parts (like headings, dependencies, or scripts) and add that summary to your scratchpad.',
41
+ // 'Continue this process of exploring, summarizing, and adding to your scratchpad until you are confident you have a full picture of the repository.',
42
+ // 'Once you believe you have gathered enough information, your second-to-last step is to review your entire scratchpad to synthesize a plan for the final outline.',
43
+ // 'Finally, based *only* on the information you have gathered in your scratchpad, generate the complete, detailed outline and store it using the `store_outline` tool. You must only call `store_outline` ONCE at the very end.',
44
+ // ],
45
+ }),
46
+ tools: {
47
+ read_file: read_file_tool,
48
+ // read_dir: read_dir_tool,
49
+ // search_files: search_files_tool,
50
+ // file_exists: file_exists_tool,
51
+ update_scratchpad: scratchpad_tool,
52
+ store_outline: tool({
53
+ description: `Use this tool to store the generated outline.
54
+ The outline should be a detailed hierarchical structure representing the sections and subsections of the repository documentation. In thory you can nest sections as deep as you want, but try to keep it to 4 levels deep maximum.
55
+
56
+ ## Example outline
57
+ [
58
+ {
59
+ "title": "xxxx",
60
+ "sections": [
61
+ {
62
+ "title": "yyyy",
63
+ sections: [
64
+ {
65
+ "title": "vvvv",
66
+ "sections": [...],
67
+ }
68
+ ]
69
+ },
70
+ {
71
+ "title": "gggg",
72
+ "sections": [...],
73
+ }
74
+ ]
75
+ },
76
+ ]
77
+ `,
78
+ inputSchema: z.object({
79
+ outline: OutlineSchema
80
+ })
81
+ // execute: ({ outline }, options) => {
82
+ // const context = toState<OutlineAgentContext>(options);
83
+ // // Store the outline in a file or database
84
+ // console.log('Generated Outline:\n', outline);
85
+ // context.outline = outline;
86
+ // return 'Outline stored successfully.';
87
+ // },
88
+ })
89
+ }
90
+ });
91
+ var outlineCondensedAgent = agent({
92
+ name: "Outline Condensed Agent",
93
+ model: groq("moonshotai/kimi-k2-instruct-0905"),
94
+ prompt: instructions({
95
+ purpose: [
96
+ "To intelligently condense and optimize an existing outline by merging redundant sections, removing overly granular subdivisions, and creating a more streamlined, maintainable documentation structure.",
97
+ "Your goal is to reduce complexity while preserving all essential information and maintaining logical hierarchy."
98
+ ],
99
+ routine: [
100
+ "Examine the current outline structure stored in the context. Use your scratchpad to track your analysis.",
101
+ "Identify sections that are too granular (e.g., sections with only 1-2 subsections that could be merged with their parent).",
102
+ "Look for redundant or overlapping sections that cover similar topics and can be consolidated.",
103
+ "Note sections with excessive nesting depth (more than 3-4 levels) that could be flattened.",
104
+ 'Identify sections with very similar titles that could be merged (e.g., "API Overview" and "API Introduction").',
105
+ "For each potential consolidation, add a note to your scratchpad explaining the rationale.",
106
+ "Create a condensed version of the outline that:",
107
+ " - Merges related subsections into broader topics",
108
+ " - Reduces nesting depth where appropriate",
109
+ " - Eliminates redundancy while keeping all unique content areas",
110
+ " - Maintains a maximum depth of 3 levels unless absolutely necessary",
111
+ " - Ensures each section has substantial content to document",
112
+ "Return the condensed outline as structured output."
113
+ ]
114
+ }),
115
+ output: OutlineSchema
116
+ });
117
+ async function generateOutline(state) {
118
+ const messages = [
119
+ user(
120
+ "Walk through the repository and generate a detailed outline. Make sure to avoid looking into framework generated files and folders. when outline is complete, call the store_outline tool."
121
+ )
122
+ ];
123
+ const max_iterations = 3;
124
+ let current_iteration = 0;
125
+ while (current_iteration < max_iterations) {
126
+ console.log(`
127
+ === Outline Iteration ${current_iteration + 1} ===
128
+ `);
129
+ const result = await execute(outlineAgent, messages, state);
130
+ await Array.fromAsync(
131
+ toUIMessageStream({
132
+ stream: result.stream,
133
+ tools: outlineAgent.toToolset(),
134
+ generateMessageId: generateId,
135
+ originalMessages: messages,
136
+ onEnd: async ({ responseMessage }) => {
137
+ messages.push(responseMessage);
138
+ }
139
+ })
140
+ );
141
+ await result.consumeStream();
142
+ const calls = await result.toolCalls;
143
+ const outlineCall = calls.find(
144
+ (t) => t.toolName === "store_outline"
145
+ );
146
+ if (outlineCall) {
147
+ console.log("\n=== Outline Generation Complete ===\n");
148
+ state.outline = outlineCall.input.outline;
149
+ break;
150
+ }
151
+ current_iteration++;
152
+ }
153
+ if (!state.outline.length) {
154
+ throw new Error("Outline generation failed.");
155
+ }
156
+ return generate(
157
+ outlineCondensedAgent,
158
+ `Condense and optimize the following outline:
159
+
160
+ ${buildToc(state.outline)}`,
161
+ state
162
+ ).then(({ output }) => output);
163
+ }
164
+ function slugify(text) {
165
+ return text.toLowerCase().replace(/[^a-z0-9\s-]/g, "").trim().replace(/\s+/g, "-").replace(/-+/g, "-");
166
+ }
167
+ function buildToc(items, baseDepth = 1, prefix = []) {
168
+ const lines = [];
169
+ for (const it of items) {
170
+ const path = [...prefix, it.title];
171
+ const indent = " ".repeat(Math.max(0, path.length - 1));
172
+ const anchor = slugify(it.title);
173
+ lines.push(`${indent}- [${it.title}](#${anchor})`);
174
+ if (it.sections?.length) {
175
+ lines.push(...buildToc(it.sections, baseDepth + 1, path));
176
+ }
177
+ }
178
+ return lines;
179
+ }
180
+ export {
181
+ buildToc,
182
+ generateOutline,
183
+ outlineAgent,
184
+ outlineCondensedAgent
185
+ };
186
+ //# sourceMappingURL=outline-agent.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/deepwiki/outline-agent.ts"],
4
+ "sourcesContent": ["import { groq } from '@ai-sdk/groq';\nimport { type UIMessage, generateId, toUIMessageStream, tool } from 'ai';\nimport z from 'zod';\n\nimport {\n agent,\n execute,\n generate,\n instructions,\n user,\n} from '@deepagents/agent';\nimport { read_file_tool, scratchpad_tool } from '@deepagents/toolbox';\n\nconst BaseOutlineItem = z.object({\n title: z.string().trim().min(1, 'Title is required'),\n});\ntype OutlineItem = z.output<typeof BaseOutlineItem> & {\n sections?: z.output<typeof OutlineItemSchema>[];\n};\nconst OutlineItemSchema: z.ZodType<OutlineItem> = z.lazy(() =>\n BaseOutlineItem.extend({\n sections: z.array(OutlineItemSchema).optional(),\n }),\n);\nconst OutlineSchema = z.array(OutlineItemSchema);\nexport type Outline = z.output<typeof OutlineSchema>;\nexport type OutlineAgentContext = {\n repo_path: string;\n outline: z.output<typeof OutlineSchema>;\n scratchpad: string;\n tree: string;\n};\n\nexport const outlineAgent = agent<unknown, OutlineAgentContext>({\n name: 'Outline Agent',\n model: groq('moonshotai/kimi-k2-instruct-0905'),\n // model: lmstudio('qwen/qwen3-8b'),\n // model: lmstudio('openai/gpt-oss-20b'),\n\n // temperature: 0.1,\n prompt: (context) =>\n instructions({\n purpose: [\n \"You are wiki architect, meticulously analyzing a repository's structure and content to automatically generate a comprehensive, intelligent, and perfectly structured outline, laying the bedrock for exceptional documentation.\",\n '\\n',\n '<RepositoryTree>',\n context?.tree || '',\n '</RepositoryTree>',\n ],\n routine: [],\n // routine: [\n // 'Your primary tool for memory is your `scratchpad`. After every action, you MUST summarize your findings and add them to the scratchpad using the `update_scratchpad` tool.',\n // 'Systematically investigate key files and directories use `search_files`. For each finding add it as a new note to your scratchpad.',\n // 'When you read a file like `README.md` or `package.json`, do not keep the whole content in your head. Instead, summarize the important parts (like headings, dependencies, or scripts) and add that summary to your scratchpad.',\n // 'Continue this process of exploring, summarizing, and adding to your scratchpad until you are confident you have a full picture of the repository.',\n // 'Once you believe you have gathered enough information, your second-to-last step is to review your entire scratchpad to synthesize a plan for the final outline.',\n // 'Finally, based *only* on the information you have gathered in your scratchpad, generate the complete, detailed outline and store it using the `store_outline` tool. You must only call `store_outline` ONCE at the very end.',\n // ],\n }),\n tools: {\n read_file: read_file_tool,\n // read_dir: read_dir_tool,\n // search_files: search_files_tool,\n // file_exists: file_exists_tool,\n update_scratchpad: scratchpad_tool,\n store_outline: tool({\n description: `Use this tool to store the generated outline.\n\t\tThe outline should be a detailed hierarchical structure representing the sections and subsections of the repository documentation. In thory you can nest sections as deep as you want, but try to keep it to 4 levels deep maximum.\n\n\t\t## Example outline\n\t\t[\n\t\t\t{\n\t\t\t\t\"title\": \"xxxx\",\n\t\t\t\t\"sections\": [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"title\": \"yyyy\",\n\t\t\t\t\t\tsections: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\"title\": \"vvvv\",\n\t\t\t\t\t\t\t\t\"sections\": [...],\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t]\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"title\": \"gggg\",\n\t\t\t\t\t\t\"sections\": [...],\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t]\n\t\t\t`,\n inputSchema: z.object({\n outline: OutlineSchema,\n }),\n // execute: ({ outline }, options) => {\n // const context = toState<OutlineAgentContext>(options);\n // // Store the outline in a file or database\n // console.log('Generated Outline:\\n', outline);\n // context.outline = outline;\n // return 'Outline stored successfully.';\n // },\n }),\n },\n});\n\nexport const outlineCondensedAgent = agent<unknown, OutlineAgentContext>({\n name: 'Outline Condensed Agent',\n model: groq('moonshotai/kimi-k2-instruct-0905'),\n prompt: instructions({\n purpose: [\n 'To intelligently condense and optimize an existing outline by merging redundant sections, removing overly granular subdivisions, and creating a more streamlined, maintainable documentation structure.',\n 'Your goal is to reduce complexity while preserving all essential information and maintaining logical hierarchy.',\n ],\n routine: [\n 'Examine the current outline structure stored in the context. Use your scratchpad to track your analysis.',\n 'Identify sections that are too granular (e.g., sections with only 1-2 subsections that could be merged with their parent).',\n 'Look for redundant or overlapping sections that cover similar topics and can be consolidated.',\n 'Note sections with excessive nesting depth (more than 3-4 levels) that could be flattened.',\n 'Identify sections with very similar titles that could be merged (e.g., \"API Overview\" and \"API Introduction\").',\n 'For each potential consolidation, add a note to your scratchpad explaining the rationale.',\n 'Create a condensed version of the outline that:',\n ' - Merges related subsections into broader topics',\n ' - Reduces nesting depth where appropriate',\n ' - Eliminates redundancy while keeping all unique content areas',\n ' - Maintains a maximum depth of 3 levels unless absolutely necessary',\n ' - Ensures each section has substantial content to document',\n 'Return the condensed outline as structured output.',\n ],\n }),\n output: OutlineSchema,\n});\n\nexport async function generateOutline(state: OutlineAgentContext) {\n const messages: UIMessage[] = [\n user(\n 'Walk through the repository and generate a detailed outline. Make sure to avoid looking into framework generated files and folders. when outline is complete, call the store_outline tool.',\n ),\n ];\n const max_iterations = 3;\n let current_iteration = 0;\n while (current_iteration < max_iterations) {\n console.log(`\\n=== Outline Iteration ${current_iteration + 1} ===\\n`);\n const result = await execute(outlineAgent, messages, state);\n await Array.fromAsync(\n toUIMessageStream({\n stream: result.stream,\n tools: outlineAgent.toToolset(),\n generateMessageId: generateId,\n originalMessages: messages,\n onEnd: async ({ responseMessage }: { responseMessage: UIMessage }) => {\n messages.push(responseMessage);\n },\n }),\n );\n await result.consumeStream();\n const calls = await result.toolCalls;\n const outlineCall = calls.find(\n (t: { toolName: string }) => t.toolName === 'store_outline',\n );\n if (outlineCall) {\n console.log('\\n=== Outline Generation Complete ===\\n');\n state.outline = outlineCall.input.outline;\n break;\n }\n current_iteration++;\n }\n if (!state.outline.length) {\n throw new Error('Outline generation failed.');\n }\n return generate(\n outlineCondensedAgent,\n `Condense and optimize the following outline:\\n\\n${buildToc(state.outline)}`,\n state,\n ).then(({ output }) => output);\n}\n\nfunction slugify(text: string) {\n return text\n .toLowerCase()\n .replace(/[^a-z0-9\\s-]/g, '')\n .trim()\n .replace(/\\s+/g, '-')\n .replace(/-+/g, '-');\n}\n\nexport function buildToc(\n items: OutlineItem[],\n baseDepth = 1,\n prefix: string[] = [],\n) {\n const lines: string[] = [];\n for (const it of items) {\n const path = [...prefix, it.title];\n const indent = ' '.repeat(Math.max(0, path.length - 1));\n const anchor = slugify(it.title);\n lines.push(`${indent}- [${it.title}](#${anchor})`);\n if (it.sections?.length) {\n lines.push(...buildToc(it.sections, baseDepth + 1, path));\n }\n }\n return lines;\n}\n"],
5
+ "mappings": ";AAAA,SAAS,YAAY;AACrB,SAAyB,YAAY,mBAAmB,YAAY;AACpE,OAAO,OAAO;AAEd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB,uBAAuB;AAEhD,IAAM,kBAAkB,EAAE,OAAO;AAAA,EAC/B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,GAAG,mBAAmB;AACrD,CAAC;AAID,IAAM,oBAA4C,EAAE;AAAA,EAAK,MACvD,gBAAgB,OAAO;AAAA,IACrB,UAAU,EAAE,MAAM,iBAAiB,EAAE,SAAS;AAAA,EAChD,CAAC;AACH;AACA,IAAM,gBAAgB,EAAE,MAAM,iBAAiB;AASxC,IAAM,eAAe,MAAoC;AAAA,EAC9D,MAAM;AAAA,EACN,OAAO,KAAK,kCAAkC;AAAA;AAAA;AAAA;AAAA,EAK9C,QAAQ,CAAC,YACP,aA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YAAM,KAAK,GAAG,SAAS,GAAG,UAAU,YAAY,GAAG,IAAI,CAAC;AAAA,IAC1D;AAAA,EACF;AACA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,242 @@
1
+ // packages/orchestrator/src/lib/deepwiki/wiki-writer.ts
2
+ import {
3
+ defaultSettingsMiddleware,
4
+ wrapLanguageModel
5
+ } from "ai";
6
+ import { writeFile } from "node:fs/promises";
7
+ import {
8
+ agent as agent2,
9
+ execute as execute2,
10
+ instructions as instructions2,
11
+ lmstudio,
12
+ user as user2
13
+ } from "@deepagents/agent";
14
+ import { scratchpad_tool as scratchpad_tool2, search_content_tool } from "@deepagents/toolbox";
15
+
16
+ // packages/orchestrator/src/lib/deepwiki/outline-agent.ts
17
+ import { groq } from "@ai-sdk/groq";
18
+ import { generateId, toUIMessageStream, tool } from "ai";
19
+ import z from "zod";
20
+ import {
21
+ agent,
22
+ execute,
23
+ generate,
24
+ instructions,
25
+ user
26
+ } from "@deepagents/agent";
27
+ import { read_file_tool, scratchpad_tool } from "@deepagents/toolbox";
28
+ var BaseOutlineItem = z.object({
29
+ title: z.string().trim().min(1, "Title is required")
30
+ });
31
+ var OutlineItemSchema = z.lazy(
32
+ () => BaseOutlineItem.extend({
33
+ sections: z.array(OutlineItemSchema).optional()
34
+ })
35
+ );
36
+ var OutlineSchema = z.array(OutlineItemSchema);
37
+ var outlineAgent = agent({
38
+ name: "Outline Agent",
39
+ model: groq("moonshotai/kimi-k2-instruct-0905"),
40
+ // model: lmstudio('qwen/qwen3-8b'),
41
+ // model: lmstudio('openai/gpt-oss-20b'),
42
+ // temperature: 0.1,
43
+ prompt: (context) => instructions({
44
+ purpose: [
45
+ "You are wiki architect, meticulously analyzing a repository's structure and content to automatically generate a comprehensive, intelligent, and perfectly structured outline, laying the bedrock for exceptional documentation.",
46
+ "\n",
47
+ "<RepositoryTree>",
48
+ context?.tree || "",
49
+ "</RepositoryTree>"
50
+ ],
51
+ routine: []
52
+ // routine: [
53
+ // 'Your primary tool for memory is your `scratchpad`. After every action, you MUST summarize your findings and add them to the scratchpad using the `update_scratchpad` tool.',
54
+ // 'Systematically investigate key files and directories use `search_files`. For each finding add it as a new note to your scratchpad.',
55
+ // 'When you read a file like `README.md` or `package.json`, do not keep the whole content in your head. Instead, summarize the important parts (like headings, dependencies, or scripts) and add that summary to your scratchpad.',
56
+ // 'Continue this process of exploring, summarizing, and adding to your scratchpad until you are confident you have a full picture of the repository.',
57
+ // 'Once you believe you have gathered enough information, your second-to-last step is to review your entire scratchpad to synthesize a plan for the final outline.',
58
+ // 'Finally, based *only* on the information you have gathered in your scratchpad, generate the complete, detailed outline and store it using the `store_outline` tool. You must only call `store_outline` ONCE at the very end.',
59
+ // ],
60
+ }),
61
+ tools: {
62
+ read_file: read_file_tool,
63
+ // read_dir: read_dir_tool,
64
+ // search_files: search_files_tool,
65
+ // file_exists: file_exists_tool,
66
+ update_scratchpad: scratchpad_tool,
67
+ store_outline: tool({
68
+ description: `Use this tool to store the generated outline.
69
+ The outline should be a detailed hierarchical structure representing the sections and subsections of the repository documentation. In thory you can nest sections as deep as you want, but try to keep it to 4 levels deep maximum.
70
+
71
+ ## Example outline
72
+ [
73
+ {
74
+ "title": "xxxx",
75
+ "sections": [
76
+ {
77
+ "title": "yyyy",
78
+ sections: [
79
+ {
80
+ "title": "vvvv",
81
+ "sections": [...],
82
+ }
83
+ ]
84
+ },
85
+ {
86
+ "title": "gggg",
87
+ "sections": [...],
88
+ }
89
+ ]
90
+ },
91
+ ]
92
+ `,
93
+ inputSchema: z.object({
94
+ outline: OutlineSchema
95
+ })
96
+ // execute: ({ outline }, options) => {
97
+ // const context = toState<OutlineAgentContext>(options);
98
+ // // Store the outline in a file or database
99
+ // console.log('Generated Outline:\n', outline);
100
+ // context.outline = outline;
101
+ // return 'Outline stored successfully.';
102
+ // },
103
+ })
104
+ }
105
+ });
106
+ var outlineCondensedAgent = agent({
107
+ name: "Outline Condensed Agent",
108
+ model: groq("moonshotai/kimi-k2-instruct-0905"),
109
+ prompt: instructions({
110
+ purpose: [
111
+ "To intelligently condense and optimize an existing outline by merging redundant sections, removing overly granular subdivisions, and creating a more streamlined, maintainable documentation structure.",
112
+ "Your goal is to reduce complexity while preserving all essential information and maintaining logical hierarchy."
113
+ ],
114
+ routine: [
115
+ "Examine the current outline structure stored in the context. Use your scratchpad to track your analysis.",
116
+ "Identify sections that are too granular (e.g., sections with only 1-2 subsections that could be merged with their parent).",
117
+ "Look for redundant or overlapping sections that cover similar topics and can be consolidated.",
118
+ "Note sections with excessive nesting depth (more than 3-4 levels) that could be flattened.",
119
+ 'Identify sections with very similar titles that could be merged (e.g., "API Overview" and "API Introduction").',
120
+ "For each potential consolidation, add a note to your scratchpad explaining the rationale.",
121
+ "Create a condensed version of the outline that:",
122
+ " - Merges related subsections into broader topics",
123
+ " - Reduces nesting depth where appropriate",
124
+ " - Eliminates redundancy while keeping all unique content areas",
125
+ " - Maintains a maximum depth of 3 levels unless absolutely necessary",
126
+ " - Ensures each section has substantial content to document",
127
+ "Return the condensed outline as structured output."
128
+ ]
129
+ }),
130
+ output: OutlineSchema
131
+ });
132
+ function slugify(text) {
133
+ return text.toLowerCase().replace(/[^a-z0-9\s-]/g, "").trim().replace(/\s+/g, "-").replace(/-+/g, "-");
134
+ }
135
+ function buildToc(items, baseDepth = 1, prefix = []) {
136
+ const lines = [];
137
+ for (const it of items) {
138
+ const path = [...prefix, it.title];
139
+ const indent = " ".repeat(Math.max(0, path.length - 1));
140
+ const anchor = slugify(it.title);
141
+ lines.push(`${indent}- [${it.title}](#${anchor})`);
142
+ if (it.sections?.length) {
143
+ lines.push(...buildToc(it.sections, baseDepth + 1, path));
144
+ }
145
+ }
146
+ return lines;
147
+ }
148
+
149
+ // packages/orchestrator/src/lib/deepwiki/wiki-writer.ts
150
+ var sectionWriter = agent2({
151
+ name: "wiki-section-writer",
152
+ model: wrapLanguageModel({
153
+ // model: lmstudio('openai/gpt-oss-20b'),
154
+ model: lmstudio("qwen/qwen3-4b-2507"),
155
+ middleware: defaultSettingsMiddleware({
156
+ settings: { temperature: 0 }
157
+ })
158
+ }),
159
+ prompt: instructions2({
160
+ purpose: [
161
+ "You write comprehensive, accurate, and actionable documentation sections for a repository wiki.",
162
+ "You can inspect files and directory structure using provided tools to ground your writing in the actual codebase."
163
+ ],
164
+ routine: [
165
+ "Use the scratchpad to note findings from reading files or directories; keep it concise and relevant.",
166
+ "Clarify scope: write ONLY for the current section path you are working on; do not expand into subsections (those are handled separately).",
167
+ "When pasting code, include only short, illustrative snippets\u2014do not dump large files.",
168
+ "Avoid references to unknown frameworks or generated folders; ground claims in actual repo contents when possible.",
169
+ "Make use of the `search_content` tool to find relevant information in the codebase. this tool can search the entire repository for keywords or topics. use it to find code examples, explanations, or relevant files.",
170
+ "Return ONLY the final markdown for this section."
171
+ ]
172
+ }),
173
+ tools: {
174
+ // read_file: read_file_tool,
175
+ // read_dir: read_dir_tool,
176
+ // search_files: search_files_tool,
177
+ search_content: search_content_tool,
178
+ update_scratchpad: scratchpad_tool2
179
+ }
180
+ });
181
+ function headingFor(level, title) {
182
+ const capped = Math.min(Math.max(level, 1), 6);
183
+ return `${"#".repeat(capped)} ${title}`;
184
+ }
185
+ async function renderSection(outline, path, ctx) {
186
+ const messages = [
187
+ user2(
188
+ [
189
+ `You are part of an AI team writing a project wiki based on a structured outline.`,
190
+ `You are writing the section: ${path.join(" > ")}`,
191
+ "Provide the final markdown for this section (no JSON, no commentary)."
192
+ ].join("\n")
193
+ )
194
+ ];
195
+ return (await execute2(sectionWriter, messages, {
196
+ repo_path: ctx.repo_path,
197
+ section_path: path,
198
+ scratchpad: "## Scratchpad\n\n"
199
+ })).text;
200
+ }
201
+ async function renderOutline(items, ctx, depth = 1, path = []) {
202
+ let out = "";
203
+ for (const item of items) {
204
+ const currentPath = [...path, item.title];
205
+ out += `
206
+
207
+ ${headingFor(depth, item.title)}
208
+
209
+ `;
210
+ const content = await renderSection(item, currentPath, ctx);
211
+ await writeFile(`./${currentPath.join("-")}.md`, content, "utf-8");
212
+ if (content) {
213
+ out += `${content}
214
+ `;
215
+ }
216
+ if (item.sections?.length) {
217
+ out += await renderOutline(item.sections, ctx, depth + 1, currentPath);
218
+ }
219
+ }
220
+ return out;
221
+ }
222
+ async function generateWiki(outline, options) {
223
+ const header = [
224
+ "# Project Wiki",
225
+ "",
226
+ "## Table of Contents",
227
+ ...buildToc(outline)
228
+ ].join("\n");
229
+ const body = await renderOutline(
230
+ outline,
231
+ { repo_path: options.repo_path },
232
+ 1
233
+ );
234
+ return `${header}
235
+
236
+ ${body}
237
+ `;
238
+ }
239
+ export {
240
+ generateWiki
241
+ };
242
+ //# sourceMappingURL=wiki-writer.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/lib/deepwiki/wiki-writer.ts", "../../../src/lib/deepwiki/outline-agent.ts"],
4
+ "sourcesContent": ["import {\n type UIMessage,\n defaultSettingsMiddleware,\n wrapLanguageModel,\n} from 'ai';\nimport { writeFile } from 'node:fs/promises';\n\nimport {\n agent,\n execute,\n instructions,\n lmstudio,\n user,\n} from '@deepagents/agent';\nimport { scratchpad_tool, search_content_tool } from '@deepagents/toolbox';\n\nimport { buildToc } from './outline-agent.ts';\n\ntype OutlineItem = { title: string; sections?: OutlineItem[] };\n\ntype SectionAgentContext = {\n repo_path: string;\n section_path: string[];\n scratchpad: string;\n};\n\nconst sectionWriter = agent<SectionAgentContext>({\n name: 'wiki-section-writer',\n model: wrapLanguageModel({\n // model: lmstudio('openai/gpt-oss-20b'),\n model: lmstudio('qwen/qwen3-4b-2507'),\n middleware: defaultSettingsMiddleware({\n settings: { temperature: 0 },\n }),\n }),\n prompt: instructions({\n purpose: [\n 'You write comprehensive, accurate, and actionable documentation sections for a repository wiki.',\n 'You can inspect files and directory structure using provided tools to ground your writing in the actual codebase.',\n ],\n routine: [\n 'Use the scratchpad to note findings from reading files or directories; keep it concise and relevant.',\n 'Clarify scope: write ONLY for the current section path you are working on; do not expand into subsections (those are handled separately).',\n 'When pasting code, include only short, illustrative snippets\u2014do not dump large files.',\n 'Avoid references to unknown frameworks or generated folders; ground claims in actual repo contents when possible.',\n 'Make use of the `search_content` tool to find relevant information in the codebase. this tool can search the entire repository for keywords or topics. use it to find code examples, explanations, or relevant files.',\n 'Return ONLY the final markdown for this section.',\n ],\n }),\n tools: {\n // read_file: read_file_tool,\n // read_dir: read_dir_tool,\n // search_files: search_files_tool,\n search_content: search_content_tool,\n update_scratchpad: scratchpad_tool,\n },\n});\n\nfunction headingFor(level: number, title: string) {\n const capped = Math.min(Math.max(level, 1), 6);\n return `${'#'.repeat(capped)} ${title}`;\n}\n\nasync function renderSection(\n outline: OutlineItem,\n path: string[],\n ctx: { repo_path: string },\n) {\n const messages: UIMessage[] = [\n user(\n [\n `You are part of an AI team writing a project wiki based on a structured outline.`,\n `You are writing the section: ${path.join(' > ')}`,\n 'Provide the final markdown for this section (no JSON, no commentary).',\n ].join('\\n'),\n ),\n ];\n\n return (\n await execute(sectionWriter, messages, {\n repo_path: ctx.repo_path,\n section_path: path,\n scratchpad: '## Scratchpad\\n\\n',\n })\n ).text;\n}\n\nasync function renderOutline(\n items: OutlineItem[],\n ctx: { repo_path: string },\n depth = 1,\n path: string[] = [],\n): Promise<string> {\n let out = '';\n for (const item of items) {\n const currentPath = [...path, item.title];\n out += `\\n\\n${headingFor(depth, item.title)}\\n\\n`;\n const content = await renderSection(item, currentPath, ctx);\n await writeFile(`./${currentPath.join('-')}.md`, content, 'utf-8');\n if (content) {\n out += `${content}\\n`;\n }\n if (item.sections?.length) {\n out += await renderOutline(item.sections, ctx, depth + 1, currentPath);\n }\n }\n return out;\n}\n\nexport async function generateWiki(\n outline: OutlineItem[],\n options: { repo_path: string },\n) {\n const header = [\n '# Project Wiki',\n '',\n '## Table of Contents',\n ...buildToc(outline),\n ].join('\\n');\n\n const body = await renderOutline(\n outline,\n { repo_path: options.repo_path },\n 1,\n );\n return `${header}\\n\\n${body}\\n`;\n}\n", "import { groq } from '@ai-sdk/groq';\nimport { type UIMessage, generateId, toUIMessageStream, tool } from 'ai';\nimport z from 'zod';\n\nimport {\n agent,\n execute,\n generate,\n instructions,\n user,\n} from '@deepagents/agent';\nimport { read_file_tool, scratchpad_tool } from '@deepagents/toolbox';\n\nconst BaseOutlineItem = z.object({\n title: z.string().trim().min(1, 'Title is required'),\n});\ntype OutlineItem = z.output<typeof BaseOutlineItem> & {\n sections?: z.output<typeof OutlineItemSchema>[];\n};\nconst OutlineItemSchema: z.ZodType<OutlineItem> = z.lazy(() =>\n BaseOutlineItem.extend({\n sections: z.array(OutlineItemSchema).optional(),\n }),\n);\nconst OutlineSchema = z.array(OutlineItemSchema);\nexport type Outline = z.output<typeof OutlineSchema>;\nexport type OutlineAgentContext = {\n repo_path: string;\n outline: z.output<typeof OutlineSchema>;\n scratchpad: string;\n tree: string;\n};\n\nexport const outlineAgent = agent<unknown, OutlineAgentContext>({\n name: 'Outline Agent',\n model: groq('moonshotai/kimi-k2-instruct-0905'),\n // model: lmstudio('qwen/qwen3-8b'),\n // model: lmstudio('openai/gpt-oss-20b'),\n\n // temperature: 0.1,\n prompt: (context) =>\n instructions({\n purpose: [\n \"You are wiki architect, meticulously analyzing a repository's structure and content to automatically generate a comprehensive, intelligent, and perfectly structured outline, laying the bedrock for exceptional documentation.\",\n '\\n',\n '<RepositoryTree>',\n context?.tree || '',\n '</RepositoryTree>',\n ],\n routine: [],\n // routine: [\n // 'Your primary tool for memory is your `scratchpad`. After every action, you MUST summarize your findings and add them to the scratchpad using the `update_scratchpad` tool.',\n // 'Systematically investigate key files and directories use `search_files`. For each finding add it as a new note to your scratchpad.',\n // 'When you read a file like `README.md` or `package.json`, do not keep the whole content in your head. Instead, summarize the important parts (like headings, dependencies, or scripts) and add that summary to your scratchpad.',\n // 'Continue this process of exploring, summarizing, and adding to your scratchpad until you are confident you have a full picture of the repository.',\n // 'Once you believe you have gathered enough information, your second-to-last step is to review your entire scratchpad to synthesize a plan for the final outline.',\n // 'Finally, based *only* on the information you have gathered in your scratchpad, generate the complete, detailed outline and store it using the `store_outline` tool. You must only call `store_outline` ONCE at the very end.',\n // ],\n }),\n tools: {\n read_file: read_file_tool,\n // read_dir: read_dir_tool,\n // search_files: search_files_tool,\n // file_exists: file_exists_tool,\n update_scratchpad: scratchpad_tool,\n store_outline: tool({\n description: `Use this tool to store the generated outline.\n\t\tThe outline should be a detailed hierarchical structure representing the sections and subsections of the repository documentation. In thory you can nest sections as deep as you want, but try to keep it to 4 levels deep maximum.\n\n\t\t## Example outline\n\t\t[\n\t\t\t{\n\t\t\t\t\"title\": \"xxxx\",\n\t\t\t\t\"sections\": [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"title\": \"yyyy\",\n\t\t\t\t\t\tsections: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\"title\": \"vvvv\",\n\t\t\t\t\t\t\t\t\"sections\": [...],\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t]\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\t\"title\": \"gggg\",\n\t\t\t\t\t\t\"sections\": [...],\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t]\n\t\t\t`,\n inputSchema: z.object({\n outline: OutlineSchema,\n }),\n // execute: ({ outline }, options) => {\n // const context = toState<OutlineAgentContext>(options);\n // // Store the outline in a file or database\n // console.log('Generated Outline:\\n', outline);\n // context.outline = outline;\n // return 'Outline stored successfully.';\n // },\n }),\n },\n});\n\nexport const outlineCondensedAgent = agent<unknown, OutlineAgentContext>({\n name: 'Outline Condensed Agent',\n model: groq('moonshotai/kimi-k2-instruct-0905'),\n prompt: instructions({\n purpose: [\n 'To intelligently condense and optimize an existing outline by merging redundant sections, removing overly granular subdivisions, and creating a more streamlined, maintainable documentation structure.',\n 'Your goal is to reduce complexity while preserving all essential information and maintaining logical hierarchy.',\n ],\n routine: [\n 'Examine the current outline structure stored in the context. Use your scratchpad to track your analysis.',\n 'Identify sections that are too granular (e.g., sections with only 1-2 subsections that could be merged with their parent).',\n 'Look for redundant or overlapping sections that cover similar topics and can be consolidated.',\n 'Note sections with excessive nesting depth (more than 3-4 levels) that could be flattened.',\n 'Identify sections with very similar titles that could be merged (e.g., \"API Overview\" and \"API Introduction\").',\n 'For each potential consolidation, add a note to your scratchpad explaining the rationale.',\n 'Create a condensed version of the outline that:',\n ' - Merges related subsections into broader topics',\n ' - Reduces nesting depth where appropriate',\n ' - Eliminates redundancy while keeping all unique content areas',\n ' - Maintains a maximum depth of 3 levels unless absolutely necessary',\n ' - Ensures each section has substantial content to document',\n 'Return the condensed outline as structured output.',\n ],\n }),\n output: OutlineSchema,\n});\n\nexport async function generateOutline(state: OutlineAgentContext) {\n const messages: UIMessage[] = [\n user(\n 'Walk through the repository and generate a detailed outline. Make sure to avoid looking into framework generated files and folders. when outline is complete, call the store_outline tool.',\n ),\n ];\n const max_iterations = 3;\n let current_iteration = 0;\n while (current_iteration < max_iterations) {\n console.log(`\\n=== Outline Iteration ${current_iteration + 1} ===\\n`);\n const result = await execute(outlineAgent, messages, state);\n await Array.fromAsync(\n toUIMessageStream({\n stream: result.stream,\n tools: outlineAgent.toToolset(),\n generateMessageId: generateId,\n originalMessages: messages,\n onEnd: async ({ responseMessage }: { responseMessage: UIMessage }) => {\n messages.push(responseMessage);\n },\n }),\n );\n await result.consumeStream();\n const calls = await result.toolCalls;\n const outlineCall = calls.find(\n (t: { toolName: string }) => t.toolName === 'store_outline',\n );\n if (outlineCall) {\n console.log('\\n=== Outline Generation Complete ===\\n');\n state.outline = outlineCall.input.outline;\n break;\n }\n current_iteration++;\n }\n if (!state.outline.length) {\n throw new Error('Outline generation failed.');\n }\n return generate(\n outlineCondensedAgent,\n `Condense and optimize the following outline:\\n\\n${buildToc(state.outline)}`,\n state,\n ).then(({ output }) => output);\n}\n\nfunction slugify(text: string) {\n return text\n .toLowerCase()\n .replace(/[^a-z0-9\\s-]/g, '')\n .trim()\n .replace(/\\s+/g, '-')\n .replace(/-+/g, '-');\n}\n\nexport function buildToc(\n items: OutlineItem[],\n baseDepth = 1,\n prefix: string[] = [],\n) {\n const lines: string[] = [];\n for (const it of items) {\n const path = [...prefix, it.title];\n const indent = ' '.repeat(Math.max(0, path.length - 1));\n const anchor = slugify(it.title);\n lines.push(`${indent}- [${it.title}](#${anchor})`);\n if (it.sections?.length) {\n lines.push(...buildToc(it.sections, baseDepth + 1, path));\n }\n }\n return lines;\n}\n"],
5
+ "mappings": ";AAAA;AAAA,EAEE;AAAA,EACA;AAAA,OACK;AACP,SAAS,iBAAiB;AAE1B;AAAA,EACE,SAAAA;AAAA,EACA,WAAAC;AAAA,EACA,gBAAAC;AAAA,EACA;AAAA,EACA,QAAAC;AAAA,OACK;AACP,SAAS,mBAAAC,kBAAiB,2BAA2B;;;ACdrD,SAAS,YAAY;AACrB,SAAyB,YAAY,mBAAmB,YAAY;AACpE,OAAO,OAAO;AAEd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,gBAAgB,uBAAuB;AAEhD,IAAM,kBAAkB,EAAE,OAAO;AAAA,EAC/B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,GAAG,mBAAmB;AACrD,CAAC;AAID,IAAM,oBAA4C,EAAE;AAAA,EAAK,MACvD,gBAAgB,OAAO;AAAA,IACrB,UAAU,EAAE,MAAM,iBAAiB,EAAE,SAAS;AAAA,EAChD,CAAC;AACH;AACA,IAAM,gBAAgB,EAAE,MAAM,iBAAiB;AASxC,IAAM,eAAe,MAAoC;AAAA,EAC9D,MAAM;AAAA,EACN,OAAO,KAAK,kCAAkC;AAAA;AAAA;AAAA;AAAA,EAK9C,QAAQ,CAAC,YACP,aAAa;AAAA,IACX,SAAS;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA,SAAS,QAAQ;AAAA,MACjB;AAAA,IACF;AAAA,IACA,SAAS,CAAC;AAAA;AAAA;AAAA;AAA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,MAAI,MAAM;AACV,aAAW,QAAQ,OAAO;AACxB,UAAM,cAAc,CAAC,GAAG,MAAM,KAAK,KAAK;AACxC,WAAO;AAAA;AAAA,EAAO,WAAW,OAAO,KAAK,KAAK,CAAC;AAAA;AAAA;AAC3C,UAAM,UAAU,MAAM,cAAc,MAAM,aAAa,GAAG;AAC1D,UAAM,UAAU,KAAK,YAAY,KAAK,GAAG,CAAC,OAAO,SAAS,OAAO;AACjE,QAAI,SAAS;AACX,aAAO,GAAG,OAAO;AAAA;AAAA,IACnB;AACA,QAAI,KAAK,UAAU,QAAQ;AACzB,aAAO,MAAM,cAAc,KAAK,UAAU,KAAK,QAAQ,GAAG,WAAW;AAAA,IACvE;AAAA,EACF;AACA,SAAO;AACT;AAEA,eAAsB,aACpB,SACA,SACA;AACA,QAAM,SAAS;AAAA,IACb;AAAA,IACA;AAAA,IACA;AAAA,IACA,GAAG,SAAS,OAAO;AAAA,EACrB,EAAE,KAAK,IAAI;AAEX,QAAM,OAAO,MAAM;AAAA,IACjB;AAAA,IACA,EAAE,WAAW,QAAQ,UAAU;AAAA,IAC/B;AAAA,EACF;AACA,SAAO,GAAG,MAAM;AAAA;AAAA,EAAO,IAAI;AAAA;AAC7B;",
6
+ "names": ["agent", "execute", "instructions", "user", "scratchpad_tool", "agent", "instructions", "scratchpad_tool", "user", "execute"]
7
+ }