@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,448 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InitWorkflow = void 0;
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ const CODE_MARKERS = [
7
+ 'package.json', 'pyproject.toml', 'go.mod', 'Cargo.toml',
8
+ 'pom.xml', 'composer.json', 'Gemfile', 'mix.exs',
9
+ ];
10
+ const SRC_DIRS = ['src', 'lib', 'app', 'pkg', 'cmd', 'api'];
11
+ function hasSourceCode(cwd) {
12
+ if (CODE_MARKERS.some(f => (0, fs_1.existsSync)((0, path_1.join)(cwd, f))))
13
+ return true;
14
+ return SRC_DIRS.some(d => (0, fs_1.existsSync)((0, path_1.join)(cwd, d)));
15
+ }
16
+ class InitWorkflow {
17
+ static detectMode(cwd) {
18
+ const hasPrompt = (0, fs_1.existsSync)((0, path_1.join)(cwd, 'prompt.md'));
19
+ const hasCode = hasSourceCode(cwd);
20
+ if (hasPrompt && !hasCode)
21
+ return 'new';
22
+ if (!hasPrompt && hasCode)
23
+ return 'existing';
24
+ if (hasPrompt && hasCode)
25
+ return 'hybrid';
26
+ return 'new'; // no prompt.md and no code → treat as new project
27
+ }
28
+ static buildPrompt(cwd, mode) {
29
+ const resolved = mode ?? this.detectMode(cwd);
30
+ switch (resolved) {
31
+ case 'new': return NEW_PROJECT_PROMPT;
32
+ case 'existing': return EXISTING_PROJECT_PROMPT;
33
+ case 'hybrid': return HYBRID_PROJECT_PROMPT;
34
+ }
35
+ }
36
+ }
37
+ exports.InitWorkflow = InitWorkflow;
38
+ // ── Shared rules injected into every prompt ───────────────────────────────────
39
+ const FILE_RULES = `
40
+ CRITICAL — FILE OPERATION RULES (MANDATORY):
41
+ - To CREATE a new file: use the write_file tool
42
+ - To APPEND or MODIFY an existing file: use the edit_file tool
43
+ - To READ a file: use the read_file tool
44
+ - NEVER use run_command for any file operation (no cat, echo, tail, sed, awk, etc.)
45
+ - Write large documents in multiple small edit_file calls — NOT one huge write_file
46
+ `.trim();
47
+ // ── Output file set (same across all modes) ───────────────────────────────────
48
+ //
49
+ // design.md — current architecture (concise, stable)
50
+ // specification.md — API contracts and data models
51
+ // security.md — security findings and requirements (grows with audits)
52
+ // roadmap.md — phases, priorities, current status (living document)
53
+ // AGENT.md — operational instructions injected into every agent session
54
+ // ── Prompts ───────────────────────────────────────────────────────────────────
55
+ const NEW_PROJECT_PROMPT = `
56
+ INIT WORKFLOW — NEW PROJECT
57
+
58
+ You are executing the project initialization workflow.
59
+ Follow these phases STRICTLY and IN ORDER. Do NOT skip any phase.
60
+
61
+ ${FILE_RULES}
62
+
63
+ ---
64
+ PHASE 1 — Generate design and specification
65
+ Emit BOTH ask_agent calls in the same response so they run IN PARALLEL:
66
+
67
+ ask_agent "architecture":
68
+ 1. Use read_file to read prompt.md at the project root.
69
+ 2. Use write_file to CREATE design.md with skeleton headers only (no content yet):
70
+ # Design — [Project Name]
71
+ ## Overview
72
+ ## Components
73
+ ## Data Models
74
+ ## API Design
75
+ ## Tech Stack
76
+ ## Infrastructure
77
+ ## Key Decisions
78
+ 3. Use edit_file to fill each section ONE AT A TIME.
79
+
80
+ ask_agent "backend" (simultaneously):
81
+ 1. Use read_file to read prompt.md.
82
+ 2. Use write_file to CREATE specification.md with skeleton headers only:
83
+ # Specification — [Project Name]
84
+ ## Functional Requirements
85
+ ## API Endpoints
86
+ ## Data Models
87
+ ## Business Logic
88
+ ## Integrations
89
+ ## Non-functional Requirements
90
+ 3. Use edit_file to fill each section ONE AT A TIME.
91
+
92
+ ---
93
+ PHASE 2 — Security and QA audit (after Phase 1 — WAIT for both files)
94
+ Emit BOTH ask_agent calls in the same response IN PARALLEL:
95
+
96
+ ask_agent "security":
97
+ 1. Use read_file to read design.md.
98
+ 2. Use read_file to read specification.md.
99
+ 3. Use write_file to CREATE security.md with skeleton headers only:
100
+ # Security — [Project Name]
101
+ ## Threat Model
102
+ ## Authentication & Authorization
103
+ ## Data Protection
104
+ ## Input Validation
105
+ ## OWASP Checklist
106
+ ## Security Requirements
107
+ 4. Use edit_file to fill each section ONE AT A TIME.
108
+ IMPORTANT: CREATE security.md as a NEW file — do NOT append to design.md.
109
+
110
+ ask_agent "qa-engineer" (simultaneously):
111
+ 1. Use read_file to read specification.md.
112
+ 2. Use edit_file to APPEND a "## QA Review" section to specification.md with:
113
+ test strategy, test cases per requirement, edge cases, acceptance criteria.
114
+
115
+ ---
116
+ PHASE 3 — Roadmap (after Phase 2 results arrive)
117
+ Single call:
118
+
119
+ ask_agent "architecture":
120
+ 1. Use read_file to read design.md, specification.md, security.md.
121
+ 2. Use write_file to CREATE roadmap.md with skeleton headers only:
122
+ # Roadmap — [Project Name]
123
+ ## Current Status
124
+ ## Phase 1 — [Name]
125
+ ## Phase 2 — [Name]
126
+ ## Phase 3 — [Name]
127
+ ## Deferred / Out of Scope
128
+ 3. Use edit_file to fill each section ONE AT A TIME.
129
+ Each phase must include: objective, responsible agent, tasks checklist, definition of done.
130
+ IMPORTANT: CREATE roadmap.md as a NEW file — do NOT append to design.md.
131
+
132
+ ---
133
+ PHASE 4 — AGENT.md (after Phase 3)
134
+ You do this yourself (no delegation):
135
+ Use write_file to CREATE AGENT.md with this exact structure:
136
+
137
+ # AGENT.md — [Project Name]
138
+
139
+ ## Commands
140
+ - Build: [detected from package.json / Makefile / etc, or "TODO"]
141
+ - Test: [detected or "TODO"]
142
+ - Dev: [detected or "TODO"]
143
+ - Lint: [detected or "TODO"]
144
+
145
+ ## Stack
146
+ [One-line summary: language, framework, database, infra]
147
+
148
+ ## Architecture
149
+ [2-3 sentences describing the main layers and their responsibilities]
150
+
151
+ ## Conventions
152
+ - [Key conventions found or inferred from prompt.md]
153
+ - [Naming patterns, folder structure rules]
154
+
155
+ ## Do NOT touch
156
+ - [Files or folders that should not be modified]
157
+
158
+ ## Current phase
159
+ [Phase 1 from roadmap.md — copy the objective here]
160
+
161
+ ## Key documents
162
+ - design.md — architecture and key decisions
163
+ - specification.md — API contracts and data models
164
+ - security.md — security requirements and findings
165
+ - roadmap.md — phases and current status
166
+
167
+ ---
168
+ PHASE 5 — Persist (use these tools directly, no delegation):
169
+ 1. Call save_context with this exact format:
170
+ ## Project: [name]
171
+ Stack: [one line]
172
+ Mode: new project
173
+
174
+ ## Documents
175
+ - design.md — architecture ([N] sections)
176
+ - specification.md — [N] endpoints documented
177
+ - security.md — [N] security requirements
178
+ - roadmap.md — [N] phases, currently Phase 1
179
+ - AGENT.md — operational instructions
180
+
181
+ ## Current phase
182
+ [copy Phase 1 objective from roadmap.md]
183
+
184
+ `.trim();
185
+ const EXISTING_PROJECT_PROMPT = `
186
+ INIT WORKFLOW — EXISTING PROJECT
187
+
188
+ You are executing the initialization workflow for an EXISTING codebase.
189
+ Follow these phases STRICTLY and IN ORDER.
190
+
191
+ ${FILE_RULES}
192
+
193
+ ---
194
+ PHASE 1 — Explore (do this yourself before delegating)
195
+ Use list_directory (max_depth: 3) and read_file for key files:
196
+ package.json / pyproject.toml / go.mod / README.md / main entry point.
197
+ Build a mental model of the project structure, stack, and entry points.
198
+
199
+ ---
200
+ PHASE 2 — Document architecture and spec
201
+ Emit BOTH ask_agent calls in the same response IN PARALLEL:
202
+
203
+ ask_agent "architecture":
204
+ 1. Explore the codebase (list_directory + read_file for key files).
205
+ 2. Use write_file to CREATE design.md with skeleton headers only:
206
+ # Design — [Project Name]
207
+ ## Overview
208
+ ## Components
209
+ ## Data Models
210
+ ## API Design
211
+ ## Tech Stack
212
+ ## Infrastructure
213
+ ## Key Decisions
214
+ 3. Use edit_file to fill each section ONE AT A TIME.
215
+ Document what EXISTS — reverse-engineered from the codebase.
216
+
217
+ ask_agent "backend" (simultaneously):
218
+ 1. Explore the codebase (list_directory + read_file).
219
+ 2. Use write_file to CREATE specification.md with skeleton headers only:
220
+ # Specification — [Project Name]
221
+ ## Endpoints
222
+ ## Data Models
223
+ ## Business Logic
224
+ ## Integrations
225
+ ## Non-functional Requirements
226
+ 3. Use edit_file to fill each section ONE AT A TIME.
227
+ Mark undocumented gaps as "Undocumented".
228
+
229
+ ---
230
+ PHASE 3 — Security and QA audit (after Phase 2 — WAIT for both files)
231
+ Emit BOTH ask_agent calls in the same response IN PARALLEL:
232
+
233
+ ask_agent "security":
234
+ 1. Use read_file to read design.md and specification.md.
235
+ 2. Use write_file to CREATE security.md with skeleton headers only:
236
+ # Security — [Project Name]
237
+ ## Findings (prioritized P0–P3)
238
+ ## Authentication & Authorization Review
239
+ ## Data Protection Gaps
240
+ ## Quick Wins
241
+ ## Security Requirements
242
+ 3. Use edit_file to fill each section ONE AT A TIME.
243
+ IMPORTANT: CREATE security.md as a NEW file — do NOT append to design.md.
244
+
245
+ ask_agent "qa-engineer" (simultaneously):
246
+ 1. Use read_file to read specification.md.
247
+ 2. Use edit_file to APPEND a "## QA Findings" section to specification.md with:
248
+ test coverage gaps, missing scenarios, quality concerns, recommendations.
249
+
250
+ ---
251
+ PHASE 4 — Roadmap (after Phase 3 results arrive)
252
+ Single call:
253
+
254
+ ask_agent "architecture":
255
+ 1. Use read_file to read design.md, specification.md, security.md.
256
+ 2. Use write_file to CREATE roadmap.md with skeleton headers only:
257
+ # Roadmap — [Project Name]
258
+ ## Current Status
259
+ ## Phase 1 — [Name] (recommended first priority)
260
+ ## Phase 2 — [Name]
261
+ ## Phase 3 — [Name]
262
+ ## Deferred / Out of Scope
263
+ 3. Use edit_file to fill each section ONE AT A TIME.
264
+ Prioritize security P0/P1 findings. Each phase: objective, agent, tasks, definition of done.
265
+ IMPORTANT: CREATE roadmap.md as a NEW file — do NOT append to design.md.
266
+
267
+ ---
268
+ PHASE 5 — AGENT.md (after Phase 4)
269
+ You do this yourself (no delegation):
270
+ Use write_file to CREATE AGENT.md with this exact structure:
271
+
272
+ # AGENT.md — [Project Name]
273
+
274
+ ## Commands
275
+ - Build: [detected from package.json / Makefile / etc]
276
+ - Test: [detected]
277
+ - Dev: [detected]
278
+ - Lint: [detected]
279
+
280
+ ## Stack
281
+ [One-line summary: language, framework, database, infra]
282
+
283
+ ## Architecture
284
+ [2-3 sentences describing the main layers and their responsibilities]
285
+
286
+ ## Conventions
287
+ - [Key conventions observed in the codebase]
288
+ - [Naming patterns, folder structure, coding style]
289
+
290
+ ## Do NOT touch
291
+ - [Files or folders observed as sensitive/legacy/generated]
292
+
293
+ ## Current phase
294
+ [Phase 1 from roadmap.md — copy the objective here]
295
+
296
+ ## Key documents
297
+ - design.md — architecture (reverse-engineered)
298
+ - specification.md — API contracts and data models
299
+ - security.md — security findings and requirements
300
+ - roadmap.md — phases and current status
301
+
302
+ ---
303
+ PHASE 6 — Persist (use these tools directly, no delegation):
304
+ 1. Call save_context with this exact format:
305
+ ## Project: [name]
306
+ Stack: [one line]
307
+ Mode: existing project
308
+
309
+ ## Documents
310
+ - design.md — architecture ([N] sections)
311
+ - specification.md — [N] endpoints documented
312
+ - security.md — [N] findings (list P0 count)
313
+ - roadmap.md — [N] phases, currently Phase 1
314
+ - AGENT.md — operational instructions
315
+
316
+ ## Current phase
317
+ [copy Phase 1 objective from roadmap.md]
318
+
319
+ `.trim();
320
+ const HYBRID_PROJECT_PROMPT = `
321
+ INIT WORKFLOW — HYBRID (existing project + new direction)
322
+
323
+ prompt.md describes the DESIRED direction. The codebase is the CURRENT state.
324
+ Follow these phases STRICTLY and IN ORDER.
325
+
326
+ ${FILE_RULES}
327
+
328
+ ---
329
+ PHASE 1 — Explore (do this yourself)
330
+ Use read_file to read prompt.md (desired direction).
331
+ Use list_directory (max_depth: 3) and read_file for key files (current state).
332
+
333
+ ---
334
+ PHASE 2 — Gap analysis: design and spec
335
+ Emit BOTH ask_agent calls in the same response IN PARALLEL:
336
+
337
+ ask_agent "architecture":
338
+ 1. Use read_file to read prompt.md and explore the codebase.
339
+ 2. Use write_file to CREATE design.md with skeleton headers only:
340
+ # Design — [Project Name]
341
+ ## Current Architecture
342
+ ## Target Architecture
343
+ ## Migration Path
344
+ ## Tech Stack Decisions
345
+ ## Key Decisions
346
+ 3. Use edit_file to fill each section ONE AT A TIME.
347
+
348
+ ask_agent "backend" (simultaneously):
349
+ 1. Use read_file to read prompt.md and explore the codebase.
350
+ 2. Use write_file to CREATE specification.md with skeleton headers only:
351
+ # Specification — [Project Name]
352
+ ## Current State
353
+ ## New Requirements
354
+ ## Build vs Modify vs Remove
355
+ ## API Changes
356
+ ## Data Model Changes
357
+ 3. Use edit_file to fill each section ONE AT A TIME.
358
+
359
+ ---
360
+ PHASE 3 — Security and QA audit (after Phase 2 — WAIT for both files)
361
+ Emit BOTH ask_agent calls in the same response IN PARALLEL:
362
+
363
+ ask_agent "security":
364
+ 1. Use read_file to read design.md and specification.md.
365
+ 2. Use write_file to CREATE security.md with skeleton headers only:
366
+ # Security — [Project Name]
367
+ ## Migration Security Impact
368
+ ## New Attack Surface
369
+ ## Existing Findings
370
+ ## Security Requirements for New Features
371
+ 3. Use edit_file to fill each section ONE AT A TIME.
372
+ IMPORTANT: CREATE security.md as a NEW file — do NOT append to design.md.
373
+
374
+ ask_agent "qa-engineer" (simultaneously):
375
+ 1. Use read_file to read specification.md.
376
+ 2. Use edit_file to APPEND a "## QA Plan" section to specification.md with:
377
+ test strategy for new features, regression risks, acceptance criteria.
378
+
379
+ ---
380
+ PHASE 4 — Roadmap (after Phase 3 results arrive)
381
+ Single call:
382
+
383
+ ask_agent "architecture":
384
+ 1. Use read_file to read design.md, specification.md, security.md.
385
+ 2. Use write_file to CREATE roadmap.md with skeleton headers only:
386
+ # Roadmap — [Project Name]
387
+ ## Current Status
388
+ ## Immediate Next Steps
389
+ ## Phase 1 — [Name]
390
+ ## Phase 2 — [Name]
391
+ ## Phase 3 — [Name]
392
+ ## Deferred / Out of Scope
393
+ 3. Use edit_file to fill each section ONE AT A TIME.
394
+ IMPORTANT: CREATE roadmap.md as a NEW file — do NOT append to design.md.
395
+
396
+ ---
397
+ PHASE 5 — AGENT.md (after Phase 4)
398
+ You do this yourself (no delegation):
399
+ Use write_file to CREATE AGENT.md with this exact structure:
400
+
401
+ # AGENT.md — [Project Name]
402
+
403
+ ## Commands
404
+ - Build: [detected]
405
+ - Test: [detected]
406
+ - Dev: [detected]
407
+ - Lint: [detected]
408
+
409
+ ## Stack
410
+ [One-line summary: current stack + target changes]
411
+
412
+ ## Architecture
413
+ [2-3 sentences: current state and migration direction]
414
+
415
+ ## Conventions
416
+ - [Key conventions observed in the codebase]
417
+
418
+ ## Do NOT touch
419
+ - [Files or folders that are sensitive/legacy/generated]
420
+
421
+ ## Current phase
422
+ [Immediate Next Steps from roadmap.md]
423
+
424
+ ## Key documents
425
+ - design.md — current + target architecture and migration path
426
+ - specification.md — current spec + new requirements
427
+ - security.md — security impact of migration
428
+ - roadmap.md — phases and migration priorities
429
+
430
+ ---
431
+ PHASE 6 — Persist (use these tools directly, no delegation):
432
+ 1. Call save_context with this exact format:
433
+ ## Project: [name]
434
+ Stack: [current] → [target]
435
+ Mode: hybrid (migration)
436
+
437
+ ## Documents
438
+ - design.md — current + target architecture
439
+ - specification.md — [N] endpoints, [N] new requirements
440
+ - security.md — security impact documented
441
+ - roadmap.md — [N] phases, immediate next steps defined
442
+ - AGENT.md — operational instructions
443
+
444
+ ## Current phase
445
+ [copy Immediate Next Steps from roadmap.md]
446
+
447
+ `.trim();
448
+ //# sourceMappingURL=InitWorkflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InitWorkflow.js","sourceRoot":"","sources":["../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itWorkflow.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fs_1 = require("fs");
4
+ const path_1 = require("path");
5
+ const os_1 = require("os");
6
+ const crypto_1 = require("crypto");
7
+ const InitWorkflow_1 = require("../InitWorkflow");
8
+ function makeTmpDir() {
9
+ const dir = (0, path_1.join)((0, os_1.tmpdir)(), `bk-test-${(0, crypto_1.randomUUID)()}`);
10
+ (0, fs_1.mkdirSync)(dir, { recursive: true });
11
+ return dir;
12
+ }
13
+ describe('InitWorkflow.detectMode', () => {
14
+ let dir;
15
+ beforeEach(() => { dir = makeTmpDir(); });
16
+ afterEach(() => { (0, fs_1.rmSync)(dir, { recursive: true, force: true }); });
17
+ it("returns 'new' when prompt.md exists and no source code", () => {
18
+ (0, fs_1.writeFileSync)((0, path_1.join)(dir, 'prompt.md'), 'Build a fintech app', 'utf-8');
19
+ expect(InitWorkflow_1.InitWorkflow.detectMode(dir)).toBe('new');
20
+ });
21
+ it("returns 'existing' when source code exists and no prompt.md", () => {
22
+ (0, fs_1.writeFileSync)((0, path_1.join)(dir, 'package.json'), '{}', 'utf-8');
23
+ expect(InitWorkflow_1.InitWorkflow.detectMode(dir)).toBe('existing');
24
+ });
25
+ it("returns 'hybrid' when both prompt.md and source code exist", () => {
26
+ (0, fs_1.writeFileSync)((0, path_1.join)(dir, 'prompt.md'), 'Add auth', 'utf-8');
27
+ (0, fs_1.writeFileSync)((0, path_1.join)(dir, 'package.json'), '{}', 'utf-8');
28
+ expect(InitWorkflow_1.InitWorkflow.detectMode(dir)).toBe('hybrid');
29
+ });
30
+ it("returns 'new' (not 'hybrid') when neither prompt.md nor code exist", () => {
31
+ // Empty directory — should default to 'new', not 'hybrid'
32
+ expect(InitWorkflow_1.InitWorkflow.detectMode(dir)).toBe('new');
33
+ });
34
+ it("detects existing via src/ directory", () => {
35
+ (0, fs_1.mkdirSync)((0, path_1.join)(dir, 'src'), { recursive: true });
36
+ expect(InitWorkflow_1.InitWorkflow.detectMode(dir)).toBe('existing');
37
+ });
38
+ it("detects existing via go.mod", () => {
39
+ (0, fs_1.writeFileSync)((0, path_1.join)(dir, 'go.mod'), 'module example.com/app\n\ngo 1.21', 'utf-8');
40
+ expect(InitWorkflow_1.InitWorkflow.detectMode(dir)).toBe('existing');
41
+ });
42
+ });
43
+ //# sourceMappingURL=InitWorkflow.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InitWorkflow.test.js","sourceRoot":"","sources":["../../../src/workflows/__tests__/InitWorkflow.test.ts"],"names":[],"mappings":";;AAAA,2BAAsD;AACtD,+BAA4B;AAC5B,2BAA4B;AAC5B,mCAAoC;AACpC,kDAA+C;AAE/C,SAAS,UAAU;IACf,MAAM,GAAG,GAAG,IAAA,WAAI,EAAC,IAAA,WAAM,GAAE,EAAE,WAAW,IAAA,mBAAU,GAAE,EAAE,CAAC,CAAC;IACtD,IAAA,cAAS,EAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACpC,OAAO,GAAG,CAAC;AACf,CAAC;AAED,QAAQ,CAAC,yBAAyB,EAAE,GAAG,EAAE;IACrC,IAAI,GAAW,CAAC;IAChB,UAAU,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,SAAS,CAAC,GAAG,EAAE,GAAG,IAAA,WAAM,EAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEpE,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;QAC9D,IAAA,kBAAa,EAAC,IAAA,WAAI,EAAC,GAAG,EAAE,WAAW,CAAC,EAAE,qBAAqB,EAAE,OAAO,CAAC,CAAC;QACtE,MAAM,CAAC,2BAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,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AC,IAAA,WAAI,EAAC,GAAG,EAAE,QAAQ,CAAC,EAAE,mCAAmC,EAAE,OAAO,CAAC,CAAC;QACjF,MAAM,CAAC,2BAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "@backendkit-labs/agent-coding",
3
+ "version": "0.14.0",
4
+ "description": "Coding agent profiles and tools for @backendkit-labs/agent-core",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": ["dist/", "README.md"],
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/BackendKit-labs/backendkit-agent-framework.git",
11
+ "directory": "packages/coding"
12
+ },
13
+ "publishConfig": { "access": "public" },
14
+ "engines": { "node": ">=20.0.0" },
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "dev": "tsc --watch",
18
+ "typecheck": "tsc --noEmit",
19
+ "test": "jest",
20
+ "prepublishOnly": "npm run build"
21
+ },
22
+ "dependencies": {
23
+ "@anthropic-ai/sdk": "^0.98.0",
24
+ "@backendkit-labs/agent-core": "*",
25
+ "openai": "^4.0.0"
26
+ },
27
+ "devDependencies": {
28
+ "@types/jest": "^29.0.0",
29
+ "@types/node": "^20.0.0",
30
+ "jest": "^29.0.0",
31
+ "ts-jest": "^29.0.0",
32
+ "typescript": "^5.4.0"
33
+ }
34
+ }