@backendkit-labs/agent-coding 0.14.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 (193) hide show
  1. package/dist/agents/AgentLoader.d.ts +33 -0
  2. package/dist/agents/AgentLoader.d.ts.map +1 -0
  3. package/dist/agents/AgentLoader.js +167 -0
  4. package/dist/agents/AgentLoader.js.map +1 -0
  5. package/dist/agents/profiles.d.ts +3 -0
  6. package/dist/agents/profiles.d.ts.map +1 -0
  7. package/dist/agents/profiles.js +121 -0
  8. package/dist/agents/profiles.js.map +1 -0
  9. package/dist/agents/prompts/architecture.d.ts +2 -0
  10. package/dist/agents/prompts/architecture.d.ts.map +1 -0
  11. package/dist/agents/prompts/architecture.js +151 -0
  12. package/dist/agents/prompts/architecture.js.map +1 -0
  13. package/dist/agents/prompts/backend.d.ts +2 -0
  14. package/dist/agents/prompts/backend.d.ts.map +1 -0
  15. package/dist/agents/prompts/backend.js +96 -0
  16. package/dist/agents/prompts/backend.js.map +1 -0
  17. package/dist/agents/prompts/coder.d.ts +2 -0
  18. package/dist/agents/prompts/coder.d.ts.map +1 -0
  19. package/dist/agents/prompts/coder.js +50 -0
  20. package/dist/agents/prompts/coder.js.map +1 -0
  21. package/dist/agents/prompts/data.d.ts +2 -0
  22. package/dist/agents/prompts/data.d.ts.map +1 -0
  23. package/dist/agents/prompts/data.js +123 -0
  24. package/dist/agents/prompts/data.js.map +1 -0
  25. package/dist/agents/prompts/frontend.d.ts +2 -0
  26. package/dist/agents/prompts/frontend.d.ts.map +1 -0
  27. package/dist/agents/prompts/frontend.js +91 -0
  28. package/dist/agents/prompts/frontend.js.map +1 -0
  29. package/dist/agents/prompts/general.d.ts +2 -0
  30. package/dist/agents/prompts/general.d.ts.map +1 -0
  31. package/dist/agents/prompts/general.js +93 -0
  32. package/dist/agents/prompts/general.js.map +1 -0
  33. package/dist/agents/prompts/infrastructure.d.ts +2 -0
  34. package/dist/agents/prompts/infrastructure.d.ts.map +1 -0
  35. package/dist/agents/prompts/infrastructure.js +145 -0
  36. package/dist/agents/prompts/infrastructure.js.map +1 -0
  37. package/dist/agents/prompts/project-manager.d.ts +2 -0
  38. package/dist/agents/prompts/project-manager.d.ts.map +1 -0
  39. package/dist/agents/prompts/project-manager.js +66 -0
  40. package/dist/agents/prompts/project-manager.js.map +1 -0
  41. package/dist/agents/prompts/qa.d.ts +2 -0
  42. package/dist/agents/prompts/qa.d.ts.map +1 -0
  43. package/dist/agents/prompts/qa.js +166 -0
  44. package/dist/agents/prompts/qa.js.map +1 -0
  45. package/dist/agents/prompts/security.d.ts +2 -0
  46. package/dist/agents/prompts/security.d.ts.map +1 -0
  47. package/dist/agents/prompts/security.js +129 -0
  48. package/dist/agents/prompts/security.js.map +1 -0
  49. package/dist/config/ConfigLoader.d.ts +27 -0
  50. package/dist/config/ConfigLoader.d.ts.map +1 -0
  51. package/dist/config/ConfigLoader.js +167 -0
  52. package/dist/config/ConfigLoader.js.map +1 -0
  53. package/dist/index.d.ts +160 -0
  54. package/dist/index.d.ts.map +1 -0
  55. package/dist/index.js +340 -0
  56. package/dist/index.js.map +1 -0
  57. package/dist/orchestration/capability-matrix.d.ts +10 -0
  58. package/dist/orchestration/capability-matrix.d.ts.map +1 -0
  59. package/dist/orchestration/capability-matrix.js +48 -0
  60. package/dist/orchestration/capability-matrix.js.map +1 -0
  61. package/dist/providers/AnthropicProvider.d.ts +20 -0
  62. package/dist/providers/AnthropicProvider.d.ts.map +1 -0
  63. package/dist/providers/AnthropicProvider.js +185 -0
  64. package/dist/providers/AnthropicProvider.js.map +1 -0
  65. package/dist/providers/DeepSeekProvider.d.ts +11 -0
  66. package/dist/providers/DeepSeekProvider.d.ts.map +1 -0
  67. package/dist/providers/DeepSeekProvider.js +18 -0
  68. package/dist/providers/DeepSeekProvider.js.map +1 -0
  69. package/dist/providers/OpenAICompatibleProvider.d.ts +22 -0
  70. package/dist/providers/OpenAICompatibleProvider.d.ts.map +1 -0
  71. package/dist/providers/OpenAICompatibleProvider.js +124 -0
  72. package/dist/providers/OpenAICompatibleProvider.js.map +1 -0
  73. package/dist/skills/builtins/global.d.ts +7 -0
  74. package/dist/skills/builtins/global.d.ts.map +1 -0
  75. package/dist/skills/builtins/global.js +208 -0
  76. package/dist/skills/builtins/global.js.map +1 -0
  77. package/dist/skills/builtins/go-pack.d.ts +7 -0
  78. package/dist/skills/builtins/go-pack.d.ts.map +1 -0
  79. package/dist/skills/builtins/go-pack.js +263 -0
  80. package/dist/skills/builtins/go-pack.js.map +1 -0
  81. package/dist/skills/builtins/java-pack.d.ts +7 -0
  82. package/dist/skills/builtins/java-pack.d.ts.map +1 -0
  83. package/dist/skills/builtins/java-pack.js +272 -0
  84. package/dist/skills/builtins/java-pack.js.map +1 -0
  85. package/dist/skills/builtins/kotlin-pack.d.ts +9 -0
  86. package/dist/skills/builtins/kotlin-pack.d.ts.map +1 -0
  87. package/dist/skills/builtins/kotlin-pack.js +292 -0
  88. package/dist/skills/builtins/kotlin-pack.js.map +1 -0
  89. package/dist/skills/builtins/node-pack.d.ts +7 -0
  90. package/dist/skills/builtins/node-pack.d.ts.map +1 -0
  91. package/dist/skills/builtins/node-pack.js +750 -0
  92. package/dist/skills/builtins/node-pack.js.map +1 -0
  93. package/dist/skills/builtins/python-pack.d.ts +7 -0
  94. package/dist/skills/builtins/python-pack.d.ts.map +1 -0
  95. package/dist/skills/builtins/python-pack.js +303 -0
  96. package/dist/skills/builtins/python-pack.js.map +1 -0
  97. package/dist/skills/index.d.ts +7 -0
  98. package/dist/skills/index.d.ts.map +1 -0
  99. package/dist/skills/index.js +16 -0
  100. package/dist/skills/index.js.map +1 -0
  101. package/dist/store/LearningRouter.d.ts +17 -0
  102. package/dist/store/LearningRouter.d.ts.map +1 -0
  103. package/dist/store/LearningRouter.js +165 -0
  104. package/dist/store/LearningRouter.js.map +1 -0
  105. package/dist/store/PersistentMemory.d.ts +10 -0
  106. package/dist/store/PersistentMemory.d.ts.map +1 -0
  107. package/dist/store/PersistentMemory.js +29 -0
  108. package/dist/store/PersistentMemory.js.map +1 -0
  109. package/dist/store/ProjectStore.d.ts +29 -0
  110. package/dist/store/ProjectStore.d.ts.map +1 -0
  111. package/dist/store/ProjectStore.js +191 -0
  112. package/dist/store/ProjectStore.js.map +1 -0
  113. package/dist/store/__tests__/PersistentMemory.test.d.ts +2 -0
  114. package/dist/store/__tests__/PersistentMemory.test.d.ts.map +1 -0
  115. package/dist/store/__tests__/PersistentMemory.test.js +46 -0
  116. package/dist/store/__tests__/PersistentMemory.test.js.map +1 -0
  117. package/dist/tools/__tests__/file-tools.test.d.ts +2 -0
  118. package/dist/tools/__tests__/file-tools.test.d.ts.map +1 -0
  119. package/dist/tools/__tests__/file-tools.test.js +144 -0
  120. package/dist/tools/__tests__/file-tools.test.js.map +1 -0
  121. package/dist/tools/__tests__/path-sandbox.test.d.ts +2 -0
  122. package/dist/tools/__tests__/path-sandbox.test.d.ts.map +1 -0
  123. package/dist/tools/__tests__/path-sandbox.test.js +45 -0
  124. package/dist/tools/__tests__/path-sandbox.test.js.map +1 -0
  125. package/dist/tools/__tests__/run-command.test.d.ts +2 -0
  126. package/dist/tools/__tests__/run-command.test.d.ts.map +1 -0
  127. package/dist/tools/__tests__/run-command.test.js +61 -0
  128. package/dist/tools/__tests__/run-command.test.js.map +1 -0
  129. package/dist/tools/append-log.d.ts +2 -0
  130. package/dist/tools/append-log.d.ts.map +1 -0
  131. package/dist/tools/append-log.js +3 -0
  132. package/dist/tools/append-log.js.map +1 -0
  133. package/dist/tools/edit-file.d.ts +2 -0
  134. package/dist/tools/edit-file.d.ts.map +1 -0
  135. package/dist/tools/edit-file.js +45 -0
  136. package/dist/tools/edit-file.js.map +1 -0
  137. package/dist/tools/list-directory.d.ts +2 -0
  138. package/dist/tools/list-directory.d.ts.map +1 -0
  139. package/dist/tools/list-directory.js +47 -0
  140. package/dist/tools/list-directory.js.map +1 -0
  141. package/dist/tools/path-sandbox.d.ts +31 -0
  142. package/dist/tools/path-sandbox.d.ts.map +1 -0
  143. package/dist/tools/path-sandbox.js +99 -0
  144. package/dist/tools/path-sandbox.js.map +1 -0
  145. package/dist/tools/read-file.d.ts +2 -0
  146. package/dist/tools/read-file.d.ts.map +1 -0
  147. package/dist/tools/read-file.js +28 -0
  148. package/dist/tools/read-file.js.map +1 -0
  149. package/dist/tools/run-command.d.ts +2 -0
  150. package/dist/tools/run-command.d.ts.map +1 -0
  151. package/dist/tools/run-command.js +192 -0
  152. package/dist/tools/run-command.js.map +1 -0
  153. package/dist/tools/save-audit.d.ts +4 -0
  154. package/dist/tools/save-audit.d.ts.map +1 -0
  155. package/dist/tools/save-audit.js +42 -0
  156. package/dist/tools/save-audit.js.map +1 -0
  157. package/dist/tools/save-context.d.ts +2 -0
  158. package/dist/tools/save-context.d.ts.map +1 -0
  159. package/dist/tools/save-context.js +18 -0
  160. package/dist/tools/save-context.js.map +1 -0
  161. package/dist/tools/save-learning.d.ts +2 -0
  162. package/dist/tools/save-learning.d.ts.map +1 -0
  163. package/dist/tools/save-learning.js +41 -0
  164. package/dist/tools/save-learning.js.map +1 -0
  165. package/dist/tools/save-user-preference.d.ts +3 -0
  166. package/dist/tools/save-user-preference.d.ts.map +1 -0
  167. package/dist/tools/save-user-preference.js +22 -0
  168. package/dist/tools/save-user-preference.js.map +1 -0
  169. package/dist/tools/search-files.d.ts +2 -0
  170. package/dist/tools/search-files.d.ts.map +1 -0
  171. package/dist/tools/search-files.js +170 -0
  172. package/dist/tools/search-files.js.map +1 -0
  173. package/dist/tools/secret-scanner.d.ts +15 -0
  174. package/dist/tools/secret-scanner.d.ts.map +1 -0
  175. package/dist/tools/secret-scanner.js +44 -0
  176. package/dist/tools/secret-scanner.js.map +1 -0
  177. package/dist/tools/update-session.d.ts +3 -0
  178. package/dist/tools/update-session.d.ts.map +1 -0
  179. package/dist/tools/update-session.js +49 -0
  180. package/dist/tools/update-session.js.map +1 -0
  181. package/dist/tools/write-file.d.ts +2 -0
  182. package/dist/tools/write-file.d.ts.map +1 -0
  183. package/dist/tools/write-file.js +32 -0
  184. package/dist/tools/write-file.js.map +1 -0
  185. package/dist/workflows/InitWorkflow.d.ts +6 -0
  186. package/dist/workflows/InitWorkflow.d.ts.map +1 -0
  187. package/dist/workflows/InitWorkflow.js +448 -0
  188. package/dist/workflows/InitWorkflow.js.map +1 -0
  189. package/dist/workflows/__tests__/InitWorkflow.test.d.ts +2 -0
  190. package/dist/workflows/__tests__/InitWorkflow.test.d.ts.map +1 -0
  191. package/dist/workflows/__tests__/InitWorkflow.test.js +43 -0
  192. package/dist/workflows/__tests__/InitWorkflow.test.js.map +1 -0
  193. package/package.json +34 -0
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.saveLearningTool = void 0;
4
+ const agent_core_1 = require("@backendkit-labs/agent-core");
5
+ const LearningRouter_1 = require("../store/LearningRouter");
6
+ exports.saveLearningTool = (0, agent_core_1.defineTool)({
7
+ name: 'save_learning',
8
+ description: [
9
+ 'Save a learning from this session. The system classifies it automatically and routes it to the right destination:',
10
+ '- tool_quirk → agent-notes/{agent}.md (specific behavior of a tool or library)',
11
+ '- skill → skills/{name}.yaml (reusable step-by-step process)',
12
+ '- project → contexto-proyecto.md (architectural decision or project fact)',
13
+ '- user → USER.md (user preference or working style)',
14
+ '- session → discarded (ephemeral, not worth persisting)',
15
+ 'Duplicates are detected and skipped automatically.',
16
+ ].join('\n'),
17
+ input: agent_core_1.z.object({
18
+ content: agent_core_1.z.string().min(1).describe('The learning to save (concrete and specific)'),
19
+ }),
20
+ execute: async ({ content }, ctx) => {
21
+ if (!ctx.store)
22
+ return 'Error: no persistent store configured';
23
+ if (!ctx.llmCall) {
24
+ // Fallback: no LLM available, append to legacy learnings.md
25
+ ctx.store.appendLearning(content);
26
+ return 'Learning saved (no router available).';
27
+ }
28
+ const store = ctx.store;
29
+ const result = await (0, LearningRouter_1.routeLearning)(content, {
30
+ projectDir: store.projectDir,
31
+ homeDir: store.homeDir,
32
+ llm: ctx.llmCall,
33
+ emit: ctx.emitCompacting,
34
+ });
35
+ if (result.skipped) {
36
+ return `Learning skipped (${result.type === 'session' ? 'ephemeral' : 'duplicate'}) → ${result.target}`;
37
+ }
38
+ return `Learning saved [${result.type}] → ${result.target}`;
39
+ },
40
+ });
41
+ //# sourceMappingURL=save-learning.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"save-learning.js","sourceRoot":"","sources":["../../src/tools/save-learning.ts"],"names":[],"mappings":";;;AAAA,4DAA4D;AAC5D,4DAAwD;AAE3C,QAAA,gBAAgB,GAAG,IAAA,uBAAU,EAAC;IACvC,IAAI,EAAE,eAAe;IACrB,WAAW,EAAE;QACT,mHAAmH;QACnH,kFAAkF;QAClF,0EAA0E;QAC1E,mFAAmF;QACnF,6EAA6E;QAC7E,4EAA4E;QAC5E,oDAAoD;KACvD,CAAC,IAAI,CAAC,IAAI,CAAC;IACZ,KAAK,EAAE,cAAC,CAAC,MAAM,CAAC;QACZ,OAAO,EAAE,cAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,8CAA8C,CAAC;KACtF,CAAC;IACF,OAAO,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE;QAChC,IAAI,CAAC,GAAG,CAAC,KAAK;YAAE,OAAO,uCAAuC,CAAC;QAC/D,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;YACf,4DAA4D;YAC5D,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;YAClC,OAAO,uCAAuC,CAAC;QACnD,CAAC;QAED,MAAM,KAAK,GAAG,GAAG,CAAC,KAAqD,CAAC;QAExE,MAAM,MAAM,GAAG,MAAM,IAAA,8BAAa,EAAC,OAAO,EAAE;YACxC,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,OAAO,EAAK,KAAK,CAAC,OAAO;YACzB,GAAG,EAAS,GAAG,CAAC,OAAO;YACvB,IAAI,EAAQ,GAAG,CAAC,cAAc;SACjC,CAAC,CAAC;QAEH,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;YACjB,OAAO,qBAAqB,MAAM,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC;QAC5G,CAAC;QACD,OAAO,mBAAmB,MAAM,CAAC,IAAI,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC;IAChE,CAAC;CACJ,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ToolDefinition } from '@backendkit-labs/agent-core';
2
+ export declare const saveUserPreferenceTool: ToolDefinition;
3
+ //# sourceMappingURL=save-user-preference.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"save-user-preference.d.ts","sourceRoot":"","sources":["../../src/tools/save-user-preference.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAoB,MAAM,6BAA6B,CAAC;AAEpF,eAAO,MAAM,sBAAsB,EAAE,cAgBpC,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.saveUserPreferenceTool = void 0;
4
+ exports.saveUserPreferenceTool = {
5
+ name: 'save_user_preference',
6
+ description: 'Save a global user preference that applies across all projects — communication style, general habits, things to always or never do.',
7
+ parameters: {
8
+ type: 'object',
9
+ properties: {
10
+ content: { type: 'string', description: 'The preference to save (e.g. "user prefers concise responses, no emojis")' },
11
+ },
12
+ required: ['content'],
13
+ },
14
+ async execute(args, ctx) {
15
+ const { content } = args;
16
+ if (!ctx.store)
17
+ return 'Error: no persistent store configured';
18
+ ctx.store.appendUserPreference(content);
19
+ return `User preference saved.`;
20
+ },
21
+ };
22
+ //# sourceMappingURL=save-user-preference.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"save-user-preference.js","sourceRoot":"","sources":["../../src/tools/save-user-preference.ts"],"names":[],"mappings":";;;AAEa,QAAA,sBAAsB,GAAmB;IAClD,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,qIAAqI;IAClJ,UAAU,EAAE;QACR,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACR,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,2EAA2E,EAAE;SACxH;QACD,QAAQ,EAAE,CAAC,SAAS,CAAC;KACxB;IACD,KAAK,CAAC,OAAO,CAAC,IAAa,EAAE,GAAqB;QAC9C,MAAM,EAAE,OAAO,EAAE,GAAG,IAA2B,CAAC;QAChD,IAAI,CAAC,GAAG,CAAC,KAAK;YAAE,OAAO,uCAAuC,CAAC;QAC/D,GAAG,CAAC,KAAK,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;QACxC,OAAO,wBAAwB,CAAC;IACpC,CAAC;CACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const searchFilesTool: import("@backendkit-labs/agent-core").ToolDefinition;
2
+ //# sourceMappingURL=search-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-files.d.ts","sourceRoot":"","sources":["../../src/tools/search-files.ts"],"names":[],"mappings":"AAyEA,eAAO,MAAM,eAAe,sDAoD1B,CAAC"}
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.searchFilesTool = void 0;
37
+ const fs = __importStar(require("fs"));
38
+ const path = __importStar(require("path"));
39
+ const agent_core_1 = require("@backendkit-labs/agent-core");
40
+ const path_sandbox_1 = require("./path-sandbox");
41
+ const MAX_RESULTS = 200;
42
+ const MAX_FILE_SIZE = 2 * 1024 * 1024; // 2 MB — skip binary/large files
43
+ const SKIP_DIRS = new Set(['node_modules', 'dist', '.git', '.next', 'build', 'coverage', '__pycache__', '.venv']);
44
+ /** Compile a glob pattern to a RegExp that matches file basenames or relative paths. */
45
+ function globToRegex(glob) {
46
+ // B2: use \x00 as sentinel for ** to avoid collision with literal spaces in paths
47
+ const escaped = glob
48
+ .replace(/[.+^${}()|[\]\\]/g, '\\$&')
49
+ .replace(/\*\*/g, '\x00')
50
+ .replace(/\*/g, '[^/\\\\]*')
51
+ .replace(/\?/g, '[^/\\\\]')
52
+ .replace(/\x00/g, '.*');
53
+ return new RegExp(escaped + '$', 'i');
54
+ }
55
+ function matchesGlob(filePath, glob) {
56
+ if (!glob || glob === '*')
57
+ return true;
58
+ const re = globToRegex(glob);
59
+ return re.test(filePath) || re.test(path.basename(filePath));
60
+ }
61
+ function walkAndSearch(dir, baseDir, pattern, glob, results) {
62
+ if (results.length >= MAX_RESULTS)
63
+ return;
64
+ let entries;
65
+ try {
66
+ entries = fs.readdirSync(dir, { withFileTypes: true });
67
+ }
68
+ catch {
69
+ return;
70
+ }
71
+ for (const entry of entries) {
72
+ if (results.length >= MAX_RESULTS)
73
+ break;
74
+ if (entry.name.startsWith('.') && entry.name !== '.env')
75
+ continue;
76
+ const fullPath = path.join(dir, entry.name);
77
+ const relPath = path.relative(baseDir, fullPath);
78
+ if (entry.isDirectory()) {
79
+ if (SKIP_DIRS.has(entry.name))
80
+ continue;
81
+ walkAndSearch(fullPath, baseDir, pattern, glob, results);
82
+ }
83
+ else if (entry.isFile()) {
84
+ if (!matchesGlob(relPath, glob))
85
+ continue;
86
+ let stat;
87
+ try {
88
+ stat = fs.statSync(fullPath);
89
+ }
90
+ catch {
91
+ continue;
92
+ }
93
+ if (stat.size > MAX_FILE_SIZE)
94
+ continue;
95
+ let content;
96
+ try {
97
+ content = fs.readFileSync(fullPath, 'utf-8');
98
+ }
99
+ catch {
100
+ continue;
101
+ } // binary file
102
+ const lines = content.split('\n');
103
+ for (let i = 0; i < lines.length; i++) {
104
+ if (results.length >= MAX_RESULTS)
105
+ break;
106
+ if (pattern.test(lines[i])) {
107
+ results.push(`${relPath}:${i + 1}:${lines[i]}`);
108
+ }
109
+ }
110
+ }
111
+ }
112
+ }
113
+ exports.searchFilesTool = (0, agent_core_1.defineTool)({
114
+ name: 'search_files',
115
+ description: 'Search for text patterns across files. ' +
116
+ 'Returns matching lines with relative file paths and line numbers. ' +
117
+ 'Cross-platform — works on Windows, Mac, and Linux without external tools.',
118
+ input: agent_core_1.z.object({
119
+ pattern: agent_core_1.z.string().describe('Regex or literal text to search for'),
120
+ path: agent_core_1.z.string().optional().describe('Directory or file to search in (default: working dir)'),
121
+ glob: agent_core_1.z.string().optional().describe('File glob filter (e.g. "*.ts", "**/*.json", "*.{ts,tsx}")'),
122
+ case_insensitive: agent_core_1.z.boolean().default(false).describe('Case-insensitive search'),
123
+ }),
124
+ execute: async ({ pattern, path: searchPath, glob, case_insensitive }, ctx) => {
125
+ const cwd = ctx.workingDir ?? process.cwd();
126
+ const targetPath = searchPath ? (0, path_sandbox_1.resolveAndCheck)(cwd, searchPath) : cwd;
127
+ let regex;
128
+ try {
129
+ regex = new RegExp(pattern, case_insensitive ? 'i' : '');
130
+ }
131
+ catch {
132
+ return `Error: Invalid regex pattern: ${pattern}`;
133
+ }
134
+ // B3: wrap statSync so a missing path returns a clean error
135
+ let stat;
136
+ try {
137
+ stat = fs.statSync(targetPath);
138
+ }
139
+ catch {
140
+ return `Error: Path not found: ${searchPath ?? cwd}`;
141
+ }
142
+ const results = [];
143
+ if (stat.isFile()) {
144
+ // Single file search
145
+ let content;
146
+ try {
147
+ content = fs.readFileSync(targetPath, 'utf-8');
148
+ }
149
+ catch {
150
+ return `Error: Cannot read file: ${searchPath}`;
151
+ }
152
+ const relPath = path.relative(cwd, targetPath);
153
+ content.split('\n').forEach((line, i) => {
154
+ if (results.length < MAX_RESULTS && regex.test(line)) {
155
+ results.push(`${relPath}:${i + 1}:${line}`);
156
+ }
157
+ });
158
+ }
159
+ else {
160
+ walkAndSearch(targetPath, cwd, regex, glob, results);
161
+ }
162
+ if (results.length === 0)
163
+ return '(no matches found)';
164
+ const output = results.join('\n');
165
+ return results.length >= MAX_RESULTS
166
+ ? output + `\n[truncated at ${MAX_RESULTS} results]`
167
+ : output;
168
+ },
169
+ });
170
+ //# sourceMappingURL=search-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-files.js","sourceRoot":"","sources":["../../src/tools/search-files.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,4DAA4D;AAC5D,iDAAiD;AAEjD,MAAM,WAAW,GAAI,GAAG,CAAC;AACzB,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,iCAAiC;AAExE,MAAM,SAAS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;QAED,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,oBAAoB,CAAC;QAEtD,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClC,OAAO,OAAO,CAAC,MAAM,IAAI,WAAW;YAChC,CAAC,CAAC,MAAM,GAAG,mBAAmB,WAAW,WAAW;YACpD,CAAC,CAAC,MAAM,CAAC;IACjB,CAAC;CACJ,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Non-blocking secret detection for agent write paths.
3
+ *
4
+ * Logs a console.warn when content appears to contain credentials.
5
+ * Does NOT block the write — legitimate code examples may match patterns.
6
+ * The warning is surfaced to the developer/operator, not exposed to the LLM.
7
+ */
8
+ /**
9
+ * Scan content for potential secrets. Returns matched pattern names (empty if clean).
10
+ * The caller decides what to do with the findings (typically log a warning).
11
+ */
12
+ export declare function scanForSecrets(content: string): string[];
13
+ /** Log a non-blocking warning when secrets are detected. Always logs to stderr. */
14
+ export declare function warnIfSecrets(filePath: string, content: string): string | undefined;
15
+ //# sourceMappingURL=secret-scanner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secret-scanner.d.ts","sourceRoot":"","sources":["../../src/tools/secret-scanner.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAYH;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAMxD;AAED,mFAAmF;AACnF,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CASnF"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /**
3
+ * Non-blocking secret detection for agent write paths.
4
+ *
5
+ * Logs a console.warn when content appears to contain credentials.
6
+ * Does NOT block the write — legitimate code examples may match patterns.
7
+ * The warning is surfaced to the developer/operator, not exposed to the LLM.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.scanForSecrets = scanForSecrets;
11
+ exports.warnIfSecrets = warnIfSecrets;
12
+ const SECRET_PATTERNS = [
13
+ { name: 'Anthropic API key', pattern: /sk-ant-[a-zA-Z0-9_-]{20,}/ },
14
+ { name: 'OpenAI API key', pattern: /sk-(?!ant-)[a-zA-Z0-9]{32,}/ },
15
+ { name: 'AWS Access Key ID', pattern: /AKIA[A-Z0-9]{16}/ },
16
+ { name: 'GitHub token (PAT)', pattern: /ghp_[a-zA-Z0-9]{36}/ },
17
+ { name: 'GitLab token', pattern: /glpat-[a-zA-Z0-9_-]{20}/ },
18
+ { name: 'Private key block', pattern: /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/ },
19
+ { name: 'Generic secret value', pattern: /(?:password|secret|apiKey|api_key|auth_token)\s*[:=]\s*["']?[a-zA-Z0-9+\/=_-]{24,}["']?/i },
20
+ ];
21
+ /**
22
+ * Scan content for potential secrets. Returns matched pattern names (empty if clean).
23
+ * The caller decides what to do with the findings (typically log a warning).
24
+ */
25
+ function scanForSecrets(content) {
26
+ const found = [];
27
+ for (const { name, pattern } of SECRET_PATTERNS) {
28
+ if (pattern.test(content))
29
+ found.push(name);
30
+ }
31
+ return found;
32
+ }
33
+ /** Log a non-blocking warning when secrets are detected. Always logs to stderr. */
34
+ function warnIfSecrets(filePath, content) {
35
+ const matches = scanForSecrets(content);
36
+ if (matches.length === 0)
37
+ return undefined;
38
+ const msg = `[SecretScanner] ⚠ Potential secret(s) detected in "${filePath}": ` +
39
+ `${matches.join(', ')}. ` +
40
+ `Verify this is intentional and never commit secrets to version control.`;
41
+ console.warn(msg);
42
+ return msg;
43
+ }
44
+ //# sourceMappingURL=secret-scanner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"secret-scanner.js","sourceRoot":"","sources":["../../src/tools/secret-scanner.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAgBH,wCAMC;AAGD,sCASC;AAhCD,MAAM,eAAe,GAA6C;IAC9D,EA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3
+ //# sourceMappingURL=update-session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-session.d.ts","sourceRoot":"","sources":["../../src/tools/update-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAoB,MAAM,6BAA6B,CAAC;AAEpF,eAAO,MAAM,iBAAiB,EAAE,cAiD/B,CAAC"}
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateSessionTool = void 0;
4
+ exports.updateSessionTool = {
5
+ name: 'update_session',
6
+ description: [
7
+ 'Update memory/session.md with the current work state.',
8
+ 'Call this after completing a task, a wave of agent calls, or making key decisions.',
9
+ 'Decisions and learnings ACCUMULATE over time — do not repeat existing ones.',
10
+ 'Issues and next_steps REPLACE the current list — provide the full updated list.',
11
+ ].join(' '),
12
+ parameters: {
13
+ type: 'object',
14
+ properties: {
15
+ feature: {
16
+ type: 'string',
17
+ description: 'What is being worked on right now and its progress. Example: "auth-login — implementing JWT refresh token rotation (70%)"',
18
+ },
19
+ decisions: {
20
+ type: 'array',
21
+ items: { type: 'string' },
22
+ description: 'Key technical decisions made in this turn (each appended as a bullet). Example: ["Use Redis for session storage — lower latency than DB", "Rotate refresh tokens on each use"]',
23
+ },
24
+ issues: {
25
+ type: 'array',
26
+ items: { type: 'string' },
27
+ description: 'Current blockers or open items — replaces the full list. Empty array clears all issues.',
28
+ },
29
+ next_steps: {
30
+ type: 'array',
31
+ items: { type: 'string' },
32
+ description: 'What needs to happen next — replaces the full list.',
33
+ },
34
+ learnings: {
35
+ type: 'array',
36
+ items: { type: 'string' },
37
+ description: 'Non-obvious things discovered about the codebase (each appended as a bullet). Example: ["UserService caches tokens in memory — invalidation requires service restart"]',
38
+ },
39
+ },
40
+ },
41
+ async execute(args, ctx) {
42
+ const updates = args;
43
+ if (!ctx.store)
44
+ return 'Error: no persistent store configured';
45
+ ctx.store.updateSession(updates);
46
+ return 'Session updated.';
47
+ },
48
+ };
49
+ //# sourceMappingURL=update-session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-session.js","sourceRoot":"","sources":["../../src/tools/update-session.ts"],"names":[],"mappings":";;;AAEa,QAAA,iBAAiB,GAAmB;IAC7C,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE;QACT,uDAAuD;QACvD,oFAAoF;QACpF,6EAA6E;QAC7E,iFAAiF;KACpF,CAAC,IAAI,CAAC,GAAG,CAAC;IACX,UAAU,EAAE;QACR,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACR,OAAO,EAAE;gBACL,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,2HAA2H;aAC3I;YACD,SAAS,EAAE;gBACP,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EAAE,gLAAgL;aAChM;YACD,MAAM,EAAE;gBACJ,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EAAE,yFAAyF;aACzG;YACD,UAAU,EAAE;gBACR,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EAAE,qDAAqD;aACrE;YACD,SAAS,EAAE;gBACP,IAAI,EAAE,OAAO;gBACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,WAAW,EAAE,wKAAwK;aACxL;SACJ;KACJ;IACD,KAAK,CAAC,OAAO,CAAC,IAAa,EAAE,GAAqB;QAC9C,MAAM,OAAO,GAAG,IAMf,CAAC;QACF,IAAI,CAAC,GAAG,CAAC,KAAK;YAAE,OAAO,uCAAuC,CAAC;QAC/D,GAAG,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACjC,OAAO,kBAAkB,CAAC;IAC9B,CAAC;CACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const writeFileTool: import("@backendkit-labs/agent-core").ToolDefinition;
2
+ //# sourceMappingURL=write-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-file.d.ts","sourceRoot":"","sources":["../../src/tools/write-file.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,aAAa,sDAoBxB,CAAC"}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.writeFileTool = void 0;
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ const agent_core_1 = require("@backendkit-labs/agent-core");
7
+ const path_sandbox_1 = require("./path-sandbox");
8
+ const secret_scanner_1 = require("./secret-scanner");
9
+ exports.writeFileTool = (0, agent_core_1.defineTool)({
10
+ name: 'write_file',
11
+ description: 'Write or overwrite a file inside the working directory. Creates parent directories if needed.',
12
+ input: agent_core_1.z.object({
13
+ file_path: agent_core_1.z.string().describe('Relative or absolute path to the file'),
14
+ content: agent_core_1.z.string().describe('Content to write'),
15
+ }),
16
+ execute: async ({ file_path, content }, ctx) => {
17
+ try {
18
+ const abs = (0, path_sandbox_1.resolveAndCheck)(ctx.workingDir, file_path);
19
+ const fwWarn = (0, path_sandbox_1.checkFrameworkProtection)(abs, ctx.workingDir);
20
+ if (fwWarn)
21
+ return `Error: ${fwWarn}`;
22
+ const warning = (0, secret_scanner_1.warnIfSecrets)(abs, content);
23
+ (0, fs_1.mkdirSync)((0, path_1.dirname)(abs), { recursive: true });
24
+ (0, agent_core_1.atomicWriteSync)(abs, content);
25
+ return warning ? `Written: ${abs}\n⚠ ${warning}` : `Written: ${abs}`;
26
+ }
27
+ catch (err) {
28
+ return `Error: ${err.message}`;
29
+ }
30
+ },
31
+ });
32
+ //# sourceMappingURL=write-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"write-file.js","sourceRoot":"","sources":["../../src/tools/write-file.ts"],"names":[],"mappings":";;;AAAA,2BAA+B;AAC/B,+BAA+B;AAC/B,4DAA6E;AAC7E,iDAA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+ static buildPrompt(cwd: string, mode?: InitMode): string;
5
+ }
6
+ //# sourceMappingURL=InitWorkflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InitWorkflow.d.ts","sourceRoot":"","sources":["../../src/workflows/InitWorkflow.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,UAAU,GAAG,QAAQ,CAAC;AAarD,qBAAa,YAAY;IACrB,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ;IASxC,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,QAAQ,GAAG,MAAM;CAQ3D"}