swallowkit 1.1.2 → 2.0.0-alpha.10

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 (262) hide show
  1. package/README.ja.md +61 -7
  2. package/README.md +61 -7
  3. package/dist/cli/commands/add-auth.d.ts.map +1 -1
  4. package/dist/cli/commands/add-auth.js +103 -27
  5. package/dist/cli/commands/add-auth.js.map +1 -1
  6. package/dist/cli/commands/configure-mcp.d.ts +12 -0
  7. package/dist/cli/commands/configure-mcp.d.ts.map +1 -0
  8. package/dist/cli/commands/configure-mcp.js +42 -0
  9. package/dist/cli/commands/configure-mcp.js.map +1 -0
  10. package/dist/cli/commands/dev.d.ts +5 -2
  11. package/dist/cli/commands/dev.d.ts.map +1 -1
  12. package/dist/cli/commands/dev.js +143 -67
  13. package/dist/cli/commands/dev.js.map +1 -1
  14. package/dist/cli/commands/init.d.ts +14 -7
  15. package/dist/cli/commands/init.d.ts.map +1 -1
  16. package/dist/cli/commands/init.js +149 -170
  17. package/dist/cli/commands/init.js.map +1 -1
  18. package/dist/cli/commands/migrations.d.ts.map +1 -1
  19. package/dist/cli/commands/migrations.js +25 -0
  20. package/dist/cli/commands/migrations.js.map +1 -1
  21. package/dist/cli/commands/provision.d.ts +5 -0
  22. package/dist/cli/commands/provision.d.ts.map +1 -1
  23. package/dist/cli/commands/provision.js +278 -55
  24. package/dist/cli/commands/provision.js.map +1 -1
  25. package/dist/cli/commands/scaffold.d.ts +5 -1
  26. package/dist/cli/commands/scaffold.d.ts.map +1 -1
  27. package/dist/cli/commands/scaffold.js +123 -18
  28. package/dist/cli/commands/scaffold.js.map +1 -1
  29. package/dist/cli/index.d.ts +2 -0
  30. package/dist/cli/index.d.ts.map +1 -1
  31. package/dist/cli/index.js +49 -8
  32. package/dist/cli/index.js.map +1 -1
  33. package/dist/core/config.d.ts +2 -1
  34. package/dist/core/config.d.ts.map +1 -1
  35. package/dist/core/config.js +19 -0
  36. package/dist/core/config.js.map +1 -1
  37. package/dist/core/operations/create-model.d.ts +2 -0
  38. package/dist/core/operations/create-model.d.ts.map +1 -1
  39. package/dist/core/operations/create-model.js +60 -8
  40. package/dist/core/operations/create-model.js.map +1 -1
  41. package/dist/core/operations/migration-generator.d.ts.map +1 -1
  42. package/dist/core/operations/migration-generator.js +12 -1
  43. package/dist/core/operations/migration-generator.js.map +1 -1
  44. package/dist/core/operations/model-migration.d.ts +22 -0
  45. package/dist/core/operations/model-migration.d.ts.map +1 -0
  46. package/dist/core/operations/model-migration.js +36 -0
  47. package/dist/core/operations/model-migration.js.map +1 -0
  48. package/dist/core/operations/provision-deployment.d.ts +52 -0
  49. package/dist/core/operations/provision-deployment.d.ts.map +1 -0
  50. package/dist/core/operations/provision-deployment.js +164 -0
  51. package/dist/core/operations/provision-deployment.js.map +1 -0
  52. package/dist/core/operations/provision-operations.d.ts +62 -6
  53. package/dist/core/operations/provision-operations.d.ts.map +1 -1
  54. package/dist/core/operations/provision-operations.js +653 -115
  55. package/dist/core/operations/provision-operations.js.map +1 -1
  56. package/dist/core/operations/scaffold-apply.d.ts +1 -0
  57. package/dist/core/operations/scaffold-apply.d.ts.map +1 -1
  58. package/dist/core/operations/scaffold-apply.js +1 -0
  59. package/dist/core/operations/scaffold-apply.js.map +1 -1
  60. package/dist/core/operations/scaffold-machine.d.ts +1 -0
  61. package/dist/core/operations/scaffold-machine.d.ts.map +1 -1
  62. package/dist/core/operations/scaffold-machine.js.map +1 -1
  63. package/dist/core/operations/scaffold-plan.d.ts +2 -0
  64. package/dist/core/operations/scaffold-plan.d.ts.map +1 -1
  65. package/dist/core/operations/scaffold-plan.js +3 -1
  66. package/dist/core/operations/scaffold-plan.js.map +1 -1
  67. package/dist/core/project/agent-instructions.d.ts +2 -1
  68. package/dist/core/project/agent-instructions.d.ts.map +1 -1
  69. package/dist/core/project/agent-instructions.js +15 -0
  70. package/dist/core/project/agent-instructions.js.map +1 -1
  71. package/dist/core/project/boundaries.d.ts +5 -2
  72. package/dist/core/project/boundaries.d.ts.map +1 -1
  73. package/dist/core/project/boundaries.js +51 -20
  74. package/dist/core/project/boundaries.js.map +1 -1
  75. package/dist/core/project/capabilities.d.ts +17 -0
  76. package/dist/core/project/capabilities.d.ts.map +1 -1
  77. package/dist/core/project/capabilities.js +45 -6
  78. package/dist/core/project/capabilities.js.map +1 -1
  79. package/dist/core/project/home-page.d.ts +4 -0
  80. package/dist/core/project/home-page.d.ts.map +1 -0
  81. package/dist/core/project/home-page.js +113 -0
  82. package/dist/core/project/home-page.js.map +1 -0
  83. package/dist/core/project/manifest.d.ts +3 -1
  84. package/dist/core/project/manifest.d.ts.map +1 -1
  85. package/dist/core/project/manifest.js +47 -25
  86. package/dist/core/project/manifest.js.map +1 -1
  87. package/dist/core/project/mcp-config.d.ts +26 -0
  88. package/dist/core/project/mcp-config.d.ts.map +1 -0
  89. package/dist/core/project/mcp-config.js +117 -0
  90. package/dist/core/project/mcp-config.js.map +1 -0
  91. package/dist/core/project/react-project.d.ts +26 -0
  92. package/dist/core/project/react-project.d.ts.map +1 -0
  93. package/dist/core/project/react-project.js +443 -0
  94. package/dist/core/project/react-project.js.map +1 -0
  95. package/dist/core/project/state.d.ts +7 -0
  96. package/dist/core/project/state.d.ts.map +1 -1
  97. package/dist/core/project/state.js +86 -0
  98. package/dist/core/project/state.js.map +1 -1
  99. package/dist/core/project/validation.d.ts.map +1 -1
  100. package/dist/core/project/validation.js +32 -10
  101. package/dist/core/project/validation.js.map +1 -1
  102. package/dist/core/project/workflows.d.ts.map +1 -1
  103. package/dist/core/project/workflows.js +53 -7
  104. package/dist/core/project/workflows.js.map +1 -1
  105. package/dist/core/scaffold/auth-generator.d.ts.map +1 -1
  106. package/dist/core/scaffold/auth-generator.js +26 -27
  107. package/dist/core/scaffold/auth-generator.js.map +1 -1
  108. package/dist/core/scaffold/model-parser.d.ts +23 -0
  109. package/dist/core/scaffold/model-parser.d.ts.map +1 -1
  110. package/dist/core/scaffold/model-parser.js +407 -137
  111. package/dist/core/scaffold/model-parser.js.map +1 -1
  112. package/dist/core/scaffold/native-schema-generator.d.ts +13 -0
  113. package/dist/core/scaffold/native-schema-generator.d.ts.map +1 -1
  114. package/dist/core/scaffold/native-schema-generator.js +294 -91
  115. package/dist/core/scaffold/native-schema-generator.js.map +1 -1
  116. package/dist/core/scaffold/openapi-generator.d.ts +5 -0
  117. package/dist/core/scaffold/openapi-generator.d.ts.map +1 -1
  118. package/dist/core/scaffold/openapi-generator.js +53 -3
  119. package/dist/core/scaffold/openapi-generator.js.map +1 -1
  120. package/dist/core/scaffold/react-bff-generator.d.ts +10 -0
  121. package/dist/core/scaffold/react-bff-generator.d.ts.map +1 -0
  122. package/dist/core/scaffold/react-bff-generator.js +252 -0
  123. package/dist/core/scaffold/react-bff-generator.js.map +1 -0
  124. package/dist/core/scaffold/react-ui-generator.d.ts +6 -0
  125. package/dist/core/scaffold/react-ui-generator.d.ts.map +1 -0
  126. package/dist/core/scaffold/react-ui-generator.js +41 -0
  127. package/dist/core/scaffold/react-ui-generator.js.map +1 -0
  128. package/dist/core/scaffold/ui-generator.d.ts +0 -3
  129. package/dist/core/scaffold/ui-generator.d.ts.map +1 -1
  130. package/dist/core/scaffold/ui-generator.js +68 -7
  131. package/dist/core/scaffold/ui-generator.js.map +1 -1
  132. package/dist/core/verify/index.d.ts +4 -3
  133. package/dist/core/verify/index.d.ts.map +1 -1
  134. package/dist/core/verify/index.js +122 -5
  135. package/dist/core/verify/index.js.map +1 -1
  136. package/dist/index.d.ts +3 -3
  137. package/dist/index.d.ts.map +1 -1
  138. package/dist/index.js +3 -2
  139. package/dist/index.js.map +1 -1
  140. package/dist/machine/contracts.d.ts +1 -0
  141. package/dist/machine/contracts.d.ts.map +1 -1
  142. package/dist/machine/errors.d.ts +3 -2
  143. package/dist/machine/errors.d.ts.map +1 -1
  144. package/dist/machine/errors.js +2 -1
  145. package/dist/machine/errors.js.map +1 -1
  146. package/dist/machine/index.d.ts.map +1 -1
  147. package/dist/machine/index.js +61 -30
  148. package/dist/machine/index.js.map +1 -1
  149. package/dist/mcp/index.d.ts +6 -4
  150. package/dist/mcp/index.d.ts.map +1 -1
  151. package/dist/mcp/index.js +210 -25
  152. package/dist/mcp/index.js.map +1 -1
  153. package/dist/mcp/version-selection.d.ts +55 -0
  154. package/dist/mcp/version-selection.d.ts.map +1 -0
  155. package/dist/mcp/version-selection.js +152 -0
  156. package/dist/mcp/version-selection.js.map +1 -0
  157. package/dist/types/index.d.ts +4 -0
  158. package/dist/types/index.d.ts.map +1 -1
  159. package/dist/utils/azure-cli.d.ts +56 -0
  160. package/dist/utils/azure-cli.d.ts.map +1 -0
  161. package/dist/utils/azure-cli.js +326 -0
  162. package/dist/utils/azure-cli.js.map +1 -0
  163. package/dist/utils/azure-diagnostics.d.ts +16 -0
  164. package/dist/utils/azure-diagnostics.d.ts.map +1 -0
  165. package/dist/utils/azure-diagnostics.js +68 -0
  166. package/dist/utils/azure-diagnostics.js.map +1 -0
  167. package/dist/utils/package-manager.d.ts +2 -2
  168. package/dist/utils/package-manager.d.ts.map +1 -1
  169. package/dist/utils/package-manager.js +6 -3
  170. package/dist/utils/package-manager.js.map +1 -1
  171. package/dist/utils/python-uv.d.ts +5 -7
  172. package/dist/utils/python-uv.d.ts.map +1 -1
  173. package/dist/utils/python-uv.js +50 -24
  174. package/dist/utils/python-uv.js.map +1 -1
  175. package/dist/utils/react-dev.d.ts +4 -0
  176. package/dist/utils/react-dev.d.ts.map +1 -0
  177. package/dist/utils/react-dev.js +35 -0
  178. package/dist/utils/react-dev.js.map +1 -0
  179. package/dist/utils/semver.d.ts +14 -0
  180. package/dist/utils/semver.d.ts.map +1 -0
  181. package/dist/utils/semver.js +61 -0
  182. package/dist/utils/semver.js.map +1 -0
  183. package/package.json +7 -4
  184. package/src/__tests__/__snapshots__/boundaries.test.ts.snap +154 -0
  185. package/src/__tests__/agent-instructions.test.ts +6 -1
  186. package/src/__tests__/agent-loop-phase34.test.ts +143 -8
  187. package/src/__tests__/auth.test.ts +9 -0
  188. package/src/__tests__/azure-cli.test.ts +202 -0
  189. package/src/__tests__/boundaries.test.ts +42 -0
  190. package/src/__tests__/csharp-schema.test.ts +261 -0
  191. package/src/__tests__/dev.test.ts +13 -6
  192. package/src/__tests__/fixtures/az wrapper.cmd +2 -0
  193. package/src/__tests__/fixtures/azure-cli.cjs +153 -0
  194. package/src/__tests__/fixtures/provision-runner.cjs +28 -0
  195. package/src/__tests__/generated-project-matrix.test.ts +789 -0
  196. package/src/__tests__/home-page.test.ts +50 -0
  197. package/src/__tests__/init.test.ts +145 -5
  198. package/src/__tests__/mcp-version.test.ts +262 -0
  199. package/src/__tests__/mcp.test.ts +120 -3
  200. package/src/__tests__/multi-auth.test.ts +115 -4
  201. package/src/__tests__/package-manager.test.ts +17 -2
  202. package/src/__tests__/plan-apply.test.ts +179 -0
  203. package/src/__tests__/provision-runtime.test.ts +722 -0
  204. package/src/__tests__/python-uv.test.ts +50 -14
  205. package/src/__tests__/python-venv.test.ts +48 -0
  206. package/src/__tests__/react-dev.test.ts +72 -0
  207. package/src/__tests__/react.test.ts +838 -0
  208. package/src/__tests__/release-metadata.test.ts +121 -0
  209. package/src/__tests__/schema-analysis.test.ts +329 -0
  210. package/src/cli/commands/add-auth.ts +103 -29
  211. package/src/cli/commands/configure-mcp.ts +54 -0
  212. package/src/cli/commands/dev.ts +145 -73
  213. package/src/cli/commands/init.ts +147 -172
  214. package/src/cli/commands/migrations.ts +22 -0
  215. package/src/cli/commands/provision.ts +294 -56
  216. package/src/cli/commands/scaffold.ts +145 -22
  217. package/src/cli/index.ts +46 -10
  218. package/src/core/config.ts +21 -1
  219. package/src/core/operations/create-model.ts +51 -13
  220. package/src/core/operations/migration-generator.ts +14 -1
  221. package/src/core/operations/model-migration.ts +52 -0
  222. package/src/core/operations/provision-deployment.ts +183 -0
  223. package/src/core/operations/provision-operations.ts +662 -154
  224. package/src/core/operations/scaffold-apply.ts +2 -0
  225. package/src/core/operations/scaffold-machine.ts +1 -0
  226. package/src/core/operations/scaffold-plan.ts +5 -1
  227. package/src/core/project/agent-instructions.ts +17 -1
  228. package/src/core/project/agent-templates/AGENTS.md +113 -15
  229. package/src/core/project/agent-templates/CLAUDE.md +14 -1
  230. package/src/core/project/agent-templates/bff-routes.instructions.md +5 -3
  231. package/src/core/project/agent-templates/copilot-instructions.md +15 -1
  232. package/src/core/project/agent-templates/shared-models.instructions.md +11 -3
  233. package/src/core/project/boundaries.ts +62 -20
  234. package/src/core/project/capabilities.ts +63 -6
  235. package/src/core/project/home-page.ts +114 -0
  236. package/src/core/project/manifest.ts +52 -27
  237. package/src/core/project/mcp-config.ts +84 -0
  238. package/src/core/project/react-project.ts +529 -0
  239. package/src/core/project/state.ts +70 -0
  240. package/src/core/project/validation.ts +32 -10
  241. package/src/core/project/workflows.ts +53 -7
  242. package/src/core/scaffold/auth-generator.ts +26 -27
  243. package/src/core/scaffold/model-parser.ts +413 -129
  244. package/src/core/scaffold/native-schema-generator.ts +319 -103
  245. package/src/core/scaffold/openapi-generator.ts +63 -5
  246. package/src/core/scaffold/react-bff-generator.ts +292 -0
  247. package/src/core/scaffold/react-ui-generator.ts +51 -0
  248. package/src/core/scaffold/ui-generator.ts +70 -8
  249. package/src/core/verify/index.ts +118 -6
  250. package/src/index.ts +3 -1
  251. package/src/machine/contracts.ts +1 -0
  252. package/src/machine/errors.ts +4 -2
  253. package/src/machine/index.ts +67 -36
  254. package/src/mcp/index.ts +221 -31
  255. package/src/mcp/version-selection.ts +163 -0
  256. package/src/types/index.ts +4 -0
  257. package/src/utils/azure-cli.ts +315 -0
  258. package/src/utils/azure-diagnostics.ts +75 -0
  259. package/src/utils/package-manager.ts +7 -4
  260. package/src/utils/python-uv.ts +53 -33
  261. package/src/utils/react-dev.ts +31 -0
  262. package/src/utils/semver.ts +59 -0
@@ -19,6 +19,7 @@ export interface ApplyScaffoldOptions {
19
19
  functionsDir?: string;
20
20
  apiDir?: string;
21
21
  apiOnly?: boolean;
22
+ skipInfra?: boolean;
22
23
  }
23
24
 
24
25
  export interface ApplyScaffoldResult extends MachineScaffoldOperationResult {
@@ -70,6 +71,7 @@ export async function applyScaffoldOperation(options: ApplyScaffoldOptions): Pro
70
71
  functionsDir: options.functionsDir ?? basePlan?.options.functionsDir,
71
72
  apiDir: options.apiDir ?? basePlan?.options.apiDir,
72
73
  apiOnly: options.apiOnly ?? basePlan?.options.apiOnly,
74
+ skipInfra: options.skipInfra ?? basePlan?.options.skipInfra,
73
75
  };
74
76
 
75
77
  // 常に最新状態で collect し、競合を検出する(plan 指定時も現況を再確認)
@@ -13,6 +13,7 @@ export interface MachineScaffoldOperationOptions {
13
13
  functionsDir?: string;
14
14
  apiDir?: string;
15
15
  apiOnly?: boolean;
16
+ skipInfra?: boolean;
16
17
  expectedSchemaAnalysis?: SchemaAnalysisSnapshot;
17
18
  }
18
19
 
@@ -29,6 +29,7 @@ export interface PlanScaffoldOptions {
29
29
  functionsDir?: string;
30
30
  apiDir?: string;
31
31
  apiOnly?: boolean;
32
+ skipInfra?: boolean;
32
33
  }
33
34
 
34
35
  export type ScaffoldPlanAction = "create" | "update" | "overwrite" | "append" | "delete" | "skip";
@@ -59,6 +60,7 @@ export interface ScaffoldPlanData {
59
60
  functionsDir?: string;
60
61
  apiDir?: string;
61
62
  apiOnly?: boolean;
63
+ skipInfra?: boolean;
62
64
  };
63
65
  createdAt: string;
64
66
  swallowkitVersion: string;
@@ -93,6 +95,7 @@ async function collectScaffoldOperations(options: PlanScaffoldOptions): Promise<
93
95
  functionsDir: options.functionsDir,
94
96
  apiDir: options.apiDir,
95
97
  apiOnly: options.apiOnly,
98
+ skipInfra: options.skipInfra,
96
99
  });
97
100
  });
98
101
  });
@@ -193,7 +196,7 @@ export async function planScaffoldOperation(options: PlanScaffoldOptions): Promi
193
196
  .update(
194
197
  JSON.stringify({
195
198
  model: options.model,
196
- options: { functionsDir: options.functionsDir, apiDir: options.apiDir, apiOnly: options.apiOnly },
199
+ options: { functionsDir: options.functionsDir, apiDir: options.apiDir, apiOnly: options.apiOnly, skipInfra: options.skipInfra },
197
200
  operations: operations.map((op) => ({ path: op.path, action: op.action })),
198
201
  fingerprints,
199
202
  schemaAnalysis,
@@ -210,6 +213,7 @@ export async function planScaffoldOperation(options: PlanScaffoldOptions): Promi
210
213
  ...(options.functionsDir ? { functionsDir: options.functionsDir } : {}),
211
214
  ...(options.apiDir ? { apiDir: options.apiDir } : {}),
212
215
  ...(options.apiOnly !== undefined ? { apiOnly: options.apiOnly } : {}),
216
+ ...(options.skipInfra ? { skipInfra: true } : {}),
213
217
  },
214
218
  createdAt: new Date().toISOString(),
215
219
  swallowkitVersion: getSwallowKitVersion(),
@@ -1,12 +1,13 @@
1
1
  import * as fs from "fs";
2
2
  import * as path from "path";
3
- import { BackendLanguage } from "../../types";
3
+ import { BackendLanguage, FrontendFramework } from "../../types";
4
4
  import { PackageManager, getCommands } from "../../utils/package-manager";
5
5
 
6
6
  export interface AgentInstructionContext {
7
7
  projectName: string;
8
8
  backendLanguage: BackendLanguage;
9
9
  packageManager: PackageManager;
10
+ frontend?: FrontendFramework;
10
11
  }
11
12
 
12
13
  export interface AgentInstructionDocuments {
@@ -70,16 +71,31 @@ function getBackendRules(backendLanguage: BackendLanguage): string {
70
71
  "- All backend business logic and data access live in `functions/`.",
71
72
  `- SwallowKit derives OpenAPI and native ${BACKEND_LANGUAGE_LABELS[backendLanguage]} schema assets from the Zod source of truth.`,
72
73
  "- Keep custom business logic in ai-authored locations identified by the current boundary contract.",
74
+ backendLanguage === "python"
75
+ ? "- Use uv with the user's interpreter/version settings. Local Python is not pinned to the Azure deployment runtime. Preserve functions/.venv and functions/.codegen-venv; do not clear them or weaken OS application-control policy to fix interpreter errors."
76
+ : "- Start the isolated Functions backend with dotnet run, not func start from the source directory, so the SDK loads extensions from the build output.",
73
77
  ].join("\n");
74
78
  }
75
79
 
76
80
  function interpolateTemplate(template: string, context: AgentInstructionContext): string {
77
81
  const runCmd = getCommands(context.packageManager).exec;
82
+ const react = context.frontend === "react";
78
83
  const replacements: Record<string, string> = {
79
84
  projectName: context.projectName,
80
85
  backendLanguageLabel: BACKEND_LANGUAGE_LABELS[context.backendLanguage],
81
86
  functionsStructureLine: getFunctionsStructureLine(context.backendLanguage),
82
87
  backendRules: getBackendRules(context.backendLanguage),
88
+ frontendLabel: react ? "React + Vite SPA" : "Next.js App Router",
89
+ bffLabel: react ? "SWA managed Functions" : "Next.js API routes",
90
+ bffPath: react ? "bff/src" : "app/api",
91
+ bffGlob: react ? "bff/**" : "app/api/**",
92
+ helperImport: react ? "../lib/call-function" : "@/lib/api/call-function",
93
+ frontendStructure: react
94
+ ? "├── src/ # React SPA (Vite + React Router)\n│ └── pages/ # generated/custom UI and route registrations\n├── bff/ # SWA managed HTTP-only Functions\n│ ├── src/ # BFF handlers and request-local helpers\n│ └── {function}/ # function.json registrations"
95
+ : "├── app/ # Next.js App Router\n│ ├── api/ # BFF routes\n│ └── {model}/ # generated/custom UI",
96
+ devGuidance: react
97
+ ? "Use http://localhost:4280 for the app. `swallowkit dev` runs Vite (3000), the managed BFF (7073), standalone Functions (7071), and SWA CLI (4280). SWA forwards /api only to the managed BFF, never directly to standalone Functions. `--no-functions` leaves the BFF running; `--no-swa` removes same-origin routing/auth emulation. BFF local settings belong in bff/local.settings.json. Build bundles BFF dependencies and copies staticwebapp.config.json into dist/. Deploy dist/ + bff/ together, and functions/ separately. Generated home, CRUD, and login pages share the Next.js presentation templates. Preserve their Tailwind styles and the light/dark defaults in src/style.css when editing them."
98
+ : "Use http://localhost:3000 for the app, or the SWA emulator port (4280) when testing SWA authentication. `swallowkit dev` runs Next.js and standalone Functions (7071). The BFF remains Next.js API routes.",
83
99
  pm: context.packageManager,
84
100
  runCmd,
85
101
  };
@@ -41,7 +41,14 @@ When a SwallowKit capability, project structure, or ownership boundary affects
41
41
  a design decision, inspect the current project and the currently available
42
42
  SwallowKit interfaces before deciding.
43
43
 
44
- Prefer the `swallowkit_*` MCP tools when available.
44
+ Prefer the `swallowkit_*` MCP tools when available, with one exception: every
45
+ MCP response reports the SwallowKit version that answered in
46
+ `metadata.swallowkitVersion` and `metadata.mcp`. If that version is older than
47
+ the project's installed SwallowKit (`{{runCmd}} swallowkit --version`), or
48
+ `metadata.warnings` contains `mcp-older-than-project`, its capabilities,
49
+ boundaries, and plan/apply contracts may be outdated for this project. Use
50
+ `{{runCmd}} swallowkit machine ...` instead and follow the response's
51
+ `nextActions` (for example `{{runCmd}} swallowkit configure-mcp`).
45
52
 
46
53
  If MCP is unavailable, use the machine interface:
47
54
 
@@ -217,6 +224,10 @@ required.
217
224
 
218
225
  Never invent or implicitly grant human approval.
219
226
 
227
+ Humans normally invoke `swallowkit provision` directly. Its invocation requests
228
+ execution without an additional confirmation. Agents must still use the
229
+ machine/MCP approval flow and must not switch to normal CLI to bypass it.
230
+
220
231
  ## Model Changes
221
232
 
222
233
  For an existing model change, the normal pattern is:
@@ -263,6 +274,18 @@ SwallowKit should generate framework-owned CRUD artifacts.
263
274
 
264
275
  Do not manually recreate boilerplate that SwallowKit owns.
265
276
 
277
+ When the task must not change Bicep or other infrastructure, still scaffold the
278
+ model: pass `--skip-infra` to `plan scaffold` / `apply scaffold` (MCP
279
+ `skipInfra: true`, or `swallowkit scaffold --skip-infra`). Nothing under
280
+ `infra/` changes, the plan reports `infra-skipped`, and `verify project` still
281
+ passes. Generate only the pending container migration later with
282
+ `{{runCmd}} swallowkit migrations add-model <model>`.
283
+
284
+ Treat plan `warnings` as decisions to make, not noise. In particular,
285
+ `user-scoped-data-without-auth` means the model looks per-user (for example a
286
+ `/userId` partition key) while authentication is not configured, so generated
287
+ CRUD would let any caller read and write every document.
288
+
266
289
  ## Authentication
267
290
 
268
291
  Authentication is a **plan/apply operation**, not a free-form config edit.
@@ -300,6 +323,20 @@ custom endpoints that derive the scoping key (e.g. `learnerId`) from the
300
323
  verified principal — never from the request body — and restrict the generated
301
324
  write endpoints to admin roles.
302
325
 
326
+ Configure authentication with `plan auth` / `apply auth` **before** declaring
327
+ `authPolicy`. Without authentication, an explicit policy
328
+ blocks plan/apply/scaffold with `auth-policy-without-auth` before file writes;
329
+ follow `nextActions`, then re-plan. Do not remove a required policy just to pass
330
+ generation.
331
+ An empty `authPolicy = {}` means no explicit policy; it does not enable authentication.
332
+
333
+ With named `auth.schemes`, define `auth.authorization.policies` selecting the
334
+ required schemes and roles, then use `authPolicy = { policy: 'adminOnly' }` (or
335
+ read/write policy names). Role-only declarations do not select a named scheme
336
+ and block with `auth-policy-requires-named-policy`. Conversely, single-provider
337
+ `auth.provider` supports role lists only; a named policy (including a named
338
+ `defaultPolicy`) blocks with `auth-named-policy-requires-named-scheme`.
339
+
303
340
  ## Verification Is a Completion Gate
304
341
 
305
342
  Before treating an agent-driven implementation as complete, run SwallowKit
@@ -311,8 +348,17 @@ verification:
311
348
 
312
349
  or the equivalent MCP operation.
313
350
 
314
- Verification covers SwallowKit structural correctness, drift, type correctness,
315
- and configured project checks.
351
+ Default checks are `structure`, `drift`, `typecheck`, `backend-build`, plus
352
+ configured project checks. `backend-build` checks standalone `functions/`:
353
+ C# uses `dotnet build`, TypeScript uses the project's `tsc --noEmit`, and Python
354
+ uses Python 3 `compileall` (syntax only, not imports or type checking), preferring
355
+ `functions/.venv` over PATH. Missing toolchains are `skip` with an explanation;
356
+ a skipped backend check is **not** evidence that the backend works. Restore the
357
+ toolchain and re-run it before claiming backend validation.
358
+
359
+ Root `build` scripts do not replace standalone backend verification. To include
360
+ frontend production builds, use `--checks "structure,drift,typecheck,backend-build,build"`.
361
+ Quote comma-separated values in PowerShell.
316
362
 
317
363
  When verification fails, use the structured failure explanation:
318
364
 
@@ -359,6 +405,24 @@ Use the `swallowkit-provision` Agent Skill or runbook and never bypass its
359
405
  approval gate. A broad request to deploy does not itself grant the explicit
360
406
  approval required by that workflow.
361
407
 
408
+ Provision applies Bicep once and tracks the original Azure deployment with a
409
+ bounded wait. A local timeout/error, output truncation, or Ctrl+C is not proof
410
+ that Azure failed. `in-progress` means Azure is Running/Accepted; `unknown`
411
+ means its result could not be read; `partial` means Azure succeeded but
412
+ tag/ledger completion is pending. Never re-submit Bicep, reconcile, adopt,
413
+ cancel, or delete just to repair waiting or migration bookkeeping.
414
+
415
+ Retain `.swallowkit/state/provision/` execution checkpoints. Use
416
+ `{{runCmd}} swallowkit machine inspect provision --plan <runId> --wait-seconds 300`
417
+ for read-only status/wait, and after explicit human approval use
418
+ `{{runCmd}} swallowkit machine apply provision --plan <runId> --approve`
419
+ to resume. `runId` equals the original `planId`; fingerprints, subscription,
420
+ deployment identity and migration checks remain in force. Only
421
+ `status: "complete"` / `outcome: "succeeded"` means Azure Succeeded plus verified
422
+ tags and local ledger. Do not print deployment output secrets or raw `az --debug`.
423
+ For older untracked baselines use `plan provision --resume-deployment <name>`
424
+ with original target/regions; it blocks unless ARM/parameter evidence matches.
425
+
362
426
  ## SwallowKit Agent Skills and Runbooks
363
427
 
364
428
  SwallowKit installs task-specific Agent Skills under:
@@ -393,9 +457,9 @@ This is a full-stack application deployed on Azure with a TypeScript
393
457
  frontend/BFF and an Azure Functions backend in {{backendLanguageLabel}}.
394
458
 
395
459
  ```text
396
- Frontend (React / Next.js App Router)
460
+ Frontend ({{frontendLabel}})
397
461
  ↓
398
- BFF (Next.js API Routes)
462
+ BFF ({{bffLabel}})
399
463
  ↓
400
464
  Azure Functions
401
465
  ↓
@@ -404,7 +468,7 @@ Azure Cosmos DB
404
468
 
405
469
  ### Core architecture rules
406
470
 
407
- 1. Next.js API routes are a BFF/proxy layer. Do not place application business
471
+ 1. {{bffLabel}} are a BFF/proxy layer. Do not place application business
408
472
  logic or direct database access there.
409
473
  2. Zod schemas under `shared/models/` are the application model source of truth.
410
474
  3. Do not duplicate model definitions across layers.
@@ -415,6 +479,11 @@ Azure Cosmos DB
415
479
  markers and boundaries.
416
480
  7. Production access to Azure resources must follow the generated security
417
481
  architecture; do not introduce hard-coded credentials or connection strings.
482
+ 8. Never link standalone Functions to SWA. The same-origin BFF calls the
483
+ independent backend with server-side BACKEND_FUNCTIONS_BASE_URL and
484
+ BACKEND_FUNCTIONS_KEY. Never expose these values in browser bundles or VITE_*.
485
+ Managed Functions use HTTP triggers only; database access, non-HTTP triggers,
486
+ managed identity, and private networking belong to the standalone backend.
418
487
 
419
488
  ### Backend-specific rules
420
489
 
@@ -427,16 +496,13 @@ values for these fields.
427
496
 
428
497
  ```text
429
498
  {{projectName}}/
430
- ├── app/ # Next.js App Router
431
- │ ├── api/ # BFF routes
432
- │ └── {model}/ # generated/custom UI
499
+ {{frontendStructure}}
433
500
  ├── functions/ # Azure Functions backend
434
501
  {{functionsStructureLine}}
435
502
  ├── shared/
436
503
  │ ├── models/ # Zod source-of-truth models
437
504
  │ └── index.ts
438
- ├── lib/
439
- │ └── api/
505
+ ├── lib/ # auth, navigation, and shared application utilities
440
506
  ├── components/
441
507
  ├── infra/ # Bicep infrastructure
442
508
  ├── .swallowkit/ # SwallowKit project metadata and runbooks
@@ -453,12 +519,24 @@ same generated structure.
453
519
  - Model schema files use `shared/models/{kebab-case}.ts`.
454
520
  - The Zod schema constant and inferred TypeScript type use the same PascalCase
455
521
  name: `export const Todo = z.object(...); export type Todo = z.infer<typeof Todo>`.
456
- - Re-export models from `shared/index.ts`.
522
+ - Re-export models from `shared/index.ts`. create-model and plan/apply scaffold
523
+ append missing exports, including manually authored models. Manual exports
524
+ are allowed; this file has no managed markers and existing content is preserved.
457
525
  - `id` is a required `z.string()`; only `createdAt` / `updatedAt` are optional
458
526
  backend-managed fields.
459
- - Models may declare `partitionKey`, `authPolicy`, `displayName`, and
460
- `connectorConfig` as exported constants. Exact formats:
527
+ - Models may declare `partitionKey`, `authPolicy`, `displayName`,
528
+ `references`, and `connectorConfig` as exported constants. Exact formats:
461
529
  `{{runCmd}} swallowkit machine inspect capabilities` (modelDeclarations).
530
+ - A string field named `<model>Id` is treated as a foreign key only when that
531
+ model exists in `shared/models`. Declare other references explicitly with
532
+ `export const references = { authorId: 'User' };` (map a field to `false`
533
+ to opt out).
534
+ - Native C#/Python schema types come from Zod, not field names: use
535
+ `z.iso.datetime()` / `z.iso.date()` for date values (`createdAt` stays a
536
+ string), `z.number().int()` for integers, and inline `z.object` for nested
537
+ classes. Length/range/regex/item constraints are enforced natively; formats
538
+ such as email remain Zod (BFF) validation. See `inspect capabilities`
539
+ (sharedModels.nativeSchemaMapping).
462
540
  - Cosmos DB containers use PascalCase plural names and default to `/id` as the
463
541
  partition key unless the model declares another key, e.g.
464
542
  `export const partitionKey = '/learnerId';` (the field must exist in the
@@ -470,13 +548,26 @@ same generated structure.
470
548
  {{pm}} install
471
549
  {{runCmd}} swallowkit dev
472
550
  {{pm}} run build
473
- {{pm}} run lint
551
+ {{pm}} run --if-present lint
474
552
  {{runCmd}} swallowkit machine verify project
475
553
  ```
476
554
 
477
555
  Always invoke SwallowKit using the package-runner convention generated for this
478
556
  project. Do not arbitrarily mix package-manager invocation styles.
479
557
 
558
+ {{devGuidance}}
559
+
560
+ Check for an already-running Cosmos DB Emulator before database tests. If it is
561
+ unavailable, report that prerequisite; do not start/restart it or change global
562
+ tools, TLS trust, or machine settings without explicit permission. Test against
563
+ an isolated database and ports, never reset user data, and stop only processes
564
+ you started. `dev --seed-env` replaces data, so inspect its target first.
565
+
566
+ Build and run `verify project`, then exercise UI, CRUD, error/validation paths,
567
+ and configured authentication through the same-origin BFF. A passing typecheck
568
+ or server readiness probe alone is not an end-to-end verification. Report
569
+ unverified cloud deployment or unavailable local prerequisites explicitly.
570
+
480
571
  ## Final Rules
481
572
 
482
573
  Do not:
@@ -502,3 +593,10 @@ Do:
502
593
  - verify before final semantic review
503
594
 
504
595
  Use `{{pm}}`, the package manager selected for this project. Do not introduce another package manager or lockfile. Use `{{runCmd}} swallowkit` for the project-local CLI. The MCP launcher intentionally resolves `latest` independently.
596
+ Exception for prerelease projects: when the project's SwallowKit is newer than
597
+ the published `latest` (for example `2.0.0-alpha.3` while `latest` is `1.1.2`),
598
+ `.mcp.json` may pin `SWALLOWKIT_MCP_VERSION` to the project version, and a
599
+ `latest` launcher that supports it hands the session to the project-installed
600
+ MCP. Run `{{runCmd}} swallowkit configure-mcp` to re-select the version (it
601
+ returns to `latest` once `latest` is at least the project version). Until MCP
602
+ reports the project version, prefer `{{runCmd}} swallowkit machine ...`.
@@ -14,7 +14,9 @@ Always-on rules:
14
14
  - Inspect the current project and SwallowKit capabilities before making
15
15
  SwallowKit-dependent assumptions or asking questions the repository can answer.
16
16
  - Prefer `swallowkit_*` MCP tools.
17
- - Fall back to `{{runCmd}} swallowkit machine ...` when MCP is unavailable.
17
+ - Fall back to `{{runCmd}} swallowkit machine ...` when MCP is unavailable, or
18
+ when an MCP response's `metadata.swallowkitVersion` is older than the project's
19
+ SwallowKit (`metadata.warnings` contains `mcp-older-than-project`).
18
20
  - Inspect responsibility boundaries before editing framework-related files.
19
21
  - Never hand-edit deterministic SwallowKit-managed artifacts.
20
22
  - Add auth schemes only via plan/apply auth; never hand-write `auth.schemes`
@@ -22,7 +24,18 @@ Always-on rules:
22
24
  after apply).
23
25
  - Use plan/apply for deterministic generation.
24
26
  - Respect all `requires-human` states and provisioning approval gates.
27
+ - Normal `swallowkit provision` is for humans. Agents must not use it to bypass
28
+ the machine/MCP approval flow.
29
+ - Provision timeouts/Ctrl+C do not prove Azure failed. Inspect the original
30
+ execution checkpoint with `machine inspect provision --plan <runId>`; resume
31
+ `machine apply provision --plan <runId> --approve` only after explicit human
32
+ approval. Preserve checkpoints; never re-submit Bicep/reconcile/cancel/delete
33
+ to repair waiting or tag/ledger failures. Do not print deployment output secrets.
25
34
  - Run SwallowKit verification before considering implementation complete.
35
+ - Default verification includes `backend-build` for standalone Functions.
36
+ Skipped toolchains are not validation; Python compilation checks syntax only.
37
+ - Configure auth via plan/apply auth before adding `authPolicy`; otherwise
38
+ scaffold blocks before file writes. Scaffold appends missing shared model exports.
26
39
 
27
40
  Task-specific SwallowKit Agent Skills are available under `.github/skills/`.
28
41
  Equivalent agent-agnostic runbooks are available under
@@ -1,5 +1,5 @@
1
1
  ---
2
- applyTo: "app/api/**"
2
+ applyTo: "{{bffGlob}}"
3
3
  ---
4
4
 
5
5
  # BFF API Routes — Rules
@@ -7,10 +7,12 @@ applyTo: "app/api/**"
7
7
  The root `AGENTS.md` is the canonical contract. Inspect the current
8
8
  responsibility boundary before editing files in this layer.
9
9
 
10
- - `app/api/` is a BFF/proxy layer. Never place business logic, database access,
10
+ - `{{bffPath}}/` is a BFF/proxy layer. Never place business logic, database access,
11
11
  or direct Cosmos DB calls here.
12
- - Use `callFunction()` from `@/lib/api/call-function` to forward requests to
12
+ - Use `callFunction()` from `{{helperImport}}` to forward requests to
13
13
  Azure Functions.
14
+ - Keep credentials request-local. Never put the backend URL/key in client
15
+ code or VITE_* variables. Do not link standalone Functions to SWA.
14
16
  - Input/output validation may use schemas imported from `@{{projectName}}/shared`.
15
17
  - Never directly edit a route reported as deterministic. Change its source of
16
18
  truth and use MCP-first plan/apply, with the machine interface as fallback.
@@ -13,7 +13,9 @@ Key rules:
13
13
  - Inspect current SwallowKit capabilities instead of assuming them.
14
14
  - Answer repository- and SwallowKit-inspectable questions before asking the human.
15
15
  - Prefer `swallowkit_*` MCP tools when available.
16
- - Otherwise use `{{runCmd}} swallowkit machine ...`.
16
+ - Otherwise use `{{runCmd}} swallowkit machine ...`. Also use it when an MCP
17
+ response's `metadata.swallowkitVersion` is older than the project's SwallowKit
18
+ or `metadata.warnings` contains `mcp-older-than-project`.
17
19
  - Inspect responsibility boundaries before editing framework-related files.
18
20
  - Never hand-edit deterministic SwallowKit-managed artifacts.
19
21
  - Add auth schemes only via plan/apply auth; never hand-write `auth.schemes`
@@ -21,7 +23,19 @@ Key rules:
21
23
  after apply).
22
24
  - Use plan/apply for deterministic generation.
23
25
  - Respect `requires-human` states and other human approval gates.
26
+ - Normal `swallowkit provision` is a human-facing deployment command. Agents must
27
+ use the machine/MCP approval flow, not normal CLI as an approval bypass.
28
+ - Provision timeouts/Ctrl+C do not prove Azure failed. Read `status`, `outcome`,
29
+ and `nextActions`; inspect the original run with `machine inspect provision
30
+ --plan <runId>`, then resume `machine apply provision --plan <runId> --approve`
31
+ only after explicit human approval. Preserve execution checkpoints; never
32
+ re-submit Bicep or use reconcile/cancel/delete to repair waiting or tag/ledger
33
+ failures. Do not print deployment output secrets.
24
34
  - Run SwallowKit verification before completion.
35
+ - Default verification includes `backend-build` for standalone Functions.
36
+ Skipped toolchains are not validation; Python compilation checks syntax only.
37
+ - Configure auth via plan/apply auth before adding `authPolicy`; otherwise
38
+ scaffold blocks before file writes. Scaffold appends missing shared model exports.
25
39
 
26
40
  Task-specific SwallowKit Agent Skills live under `.github/skills/`.
27
41
  Agent-agnostic equivalents live under `.swallowkit/workflows/`.
@@ -18,8 +18,9 @@ source-of-truth models, subject to the current result of
18
18
  - `createdAt` and `updatedAt` are **optional** string fields
19
19
  (`z.string().optional()`). The backend manages their values.
20
20
  - Export a `displayName` string for UI display.
21
- - Re-export every model from `shared/index.ts`, outside managed markers where
22
- applicable.
21
+ - create-model and plan/apply scaffold append missing model exports to
22
+ `shared/index.ts`, including manually authored models. Manual exports are
23
+ allowed; there are no managed markers and existing content is preserved.
23
24
  - For relationships, use nested schemas rather than duplicating model shapes.
24
25
 
25
26
  ## Optional model declarations (exact formats)
@@ -30,7 +31,7 @@ These are the only declarations SwallowKit parses from a model file:
30
31
  // Cosmos DB partition key (default '/id'). Must reference a schema field.
31
32
  export const partitionKey = '/learnerId';
32
33
 
33
- // Role-based access control on generated CRUD.
34
+ // Role-based access control on generated CRUD (requires plan/apply auth first).
34
35
  export const authPolicy = { roles: ['admin'] };
35
36
  // or: { read: ['user'], write: ['admin'] } or: { policy: 'adminOnly' }
36
37
 
@@ -48,6 +49,13 @@ export const connectorConfig = {
48
49
  The full machine-readable contract:
49
50
  `{{runCmd}} swallowkit machine inspect capabilities`
50
51
 
52
+ An explicit `authPolicy` without authentication blocks plan/apply/scaffold with
53
+ `auth-policy-without-auth` before writing files. Follow `nextActions` to configure
54
+ auth, then re-plan. Do not drop a required guard to bypass the prerequisite.
55
+ For named `auth.schemes`, use named authorization policies selecting schemes
56
+ and roles, referenced by `policy` or read/write names. Role-only declarations
57
+ block with `auth-policy-requires-named-policy` rather than emitting missing helpers.
58
+
51
59
  After changing a model, do not manually patch generated artifacts.
52
60
 
53
61
  ## After changing a model
@@ -10,7 +10,9 @@
10
10
  * - shared: マーカー区切りの共有領域。マーカー内は SwallowKit、外は自由。
11
11
  */
12
12
 
13
+ import { getBackendLanguage } from "../config";
13
14
  import { ArtifactOwnership } from "../operations/file-session";
15
+ import { BackendLanguage } from "../../types";
14
16
  import { inspectArtifacts } from "./artifacts";
15
17
 
16
18
  export type BoundaryZone = "deterministic" | "ai-authored" | "shared";
@@ -48,6 +50,8 @@ export interface BoundaryArtifact {
48
50
  export interface BoundariesContract {
49
51
  contractVersion: number;
50
52
  summary: string;
53
+ /** backend.language the convention rules were resolved for */
54
+ backendLanguage: BackendLanguage;
51
55
  ownershipPolicies: OwnershipPolicy[];
52
56
  /** 台帳に載っていないパスの既定規約 */
53
57
  conventionRules: BoundaryPathRule[];
@@ -82,7 +86,7 @@ export const OWNERSHIP_POLICIES: OwnershipPolicy[] = [
82
86
  zone: "shared",
83
87
  editPolicy: "edit-outside-markers",
84
88
  howToChange:
85
- "SwallowKit appends only inside marked sections (e.g. `# SwallowKit scaffold registrations`). Edit anywhere outside the markers freely; do not remove the markers.",
89
+ "SwallowKit appends at the file-specific extension point: marked sections (e.g. `# SwallowKit scaffold registrations`) or append-only files such as shared/index.ts. Follow the path rule; preserve existing generated entries and any markers.",
86
90
  },
87
91
  {
88
92
  ownership: "metadata",
@@ -92,7 +96,7 @@ export const OWNERSHIP_POLICIES: OwnershipPolicy[] = [
92
96
  },
93
97
  ];
94
98
 
95
- export const CONVENTION_RULES: BoundaryPathRule[] = [
99
+ const COMMON_LEADING_RULES: BoundaryPathRule[] = [
96
100
  {
97
101
  pattern: ".swallowkit/",
98
102
  zone: "deterministic",
@@ -107,32 +111,66 @@ export const CONVENTION_RULES: BoundaryPathRule[] = [
107
111
  "Zod model schemas — the single source of truth. AI/developers author these freely; deterministic generation derives everything else from them.",
108
112
  },
109
113
  {
110
- pattern: "infra/main.bicep",
111
- zone: "shared",
112
- editPolicy: "edit-outside-markers",
113
- description: "SwallowKit inserts container modules; other infrastructure edits are free.",
114
+ pattern: "infra/migrations/manifest.json",
115
+ zone: "deterministic",
116
+ editPolicy: "never-hand-edit",
117
+ description:
118
+ "Infrastructure migration ledger with baseline checksums. Updated by scaffold, `swallowkit migrations add-model`, and `swallowkit create-migration`.",
114
119
  },
115
120
  {
116
- pattern: "functions/function_app.py",
117
- zone: "shared",
118
- editPolicy: "edit-outside-markers",
119
- description: "SwallowKit appends blueprint registrations under its marker; other edits are free.",
121
+ pattern: "infra/migrations/",
122
+ zone: "ai-authored",
123
+ editPolicy: "free-edit",
124
+ description:
125
+ "Versioned Bicep migrations. Edit a migration only before it is provisioned; never change an applied migration — add a new one with `swallowkit create-migration <slug>`.",
120
126
  },
121
127
  {
122
- pattern: "shared/index.ts",
123
- zone: "shared",
124
- editPolicy: "edit-outside-markers",
125
- description: "SwallowKit appends model exports; other exports may be added freely.",
128
+ pattern: "infra/",
129
+ zone: "deterministic",
130
+ editPolicy: "never-hand-edit",
131
+ description:
132
+ "Baseline infrastructure (main.bicep and modules) whose checksums are recorded in infra/migrations/manifest.json. Hand edits block scaffold with baseline-drift; add resources through a new migration instead.",
126
133
  },
127
134
  {
128
- pattern: "*",
129
- zone: "ai-authored",
135
+ pattern: "shared/index.ts",
136
+ zone: "shared",
130
137
  editPolicy: "free-edit",
131
- description:
132
- "Any path not recorded in the artifact ledger is AI/developer-authored. Business logic, custom pages, custom Functions, and tests belong here.",
138
+ description: "create-model and scaffold append missing model exports while preserving existing content. No managed markers; manual exports are allowed. Keep exports needed by generated code.",
133
139
  },
134
140
  ];
135
141
 
142
+ /** Backend files that SwallowKit appends to; C# and TypeScript discover functions without a registration file. */
143
+ const BACKEND_EXTENSION_RULES: Record<BackendLanguage, BoundaryPathRule[]> = {
144
+ python: [
145
+ {
146
+ pattern: "functions/function_app.py",
147
+ zone: "shared",
148
+ editPolicy: "edit-outside-markers",
149
+ description: "SwallowKit appends blueprint registrations under its marker; other edits are free.",
150
+ },
151
+ {
152
+ pattern: "functions/requirements.txt",
153
+ zone: "shared",
154
+ editPolicy: "free-edit",
155
+ description: "SwallowKit appends connector driver requirements when connector models are scaffolded; keep those lines and edit other requirements freely.",
156
+ },
157
+ ],
158
+ csharp: [],
159
+ typescript: [],
160
+ };
161
+
162
+ const FALLBACK_RULE: BoundaryPathRule = {
163
+ pattern: "*",
164
+ zone: "ai-authored",
165
+ editPolicy: "free-edit",
166
+ description:
167
+ "Any path not recorded in the artifact ledger is AI/developer-authored. Business logic, custom pages, custom Functions, and tests belong here.",
168
+ };
169
+
170
+ export function buildConventionRules(backendLanguage: BackendLanguage): BoundaryPathRule[] {
171
+ return [...COMMON_LEADING_RULES, ...BACKEND_EXTENSION_RULES[backendLanguage], FALLBACK_RULE];
172
+ }
173
+
136
174
  const POLICY_BY_OWNERSHIP = new Map(OWNERSHIP_POLICIES.map((policy) => [policy.ownership, policy] as const));
137
175
 
138
176
  export const BOUNDARY_GUIDANCE: string[] = [
@@ -143,7 +181,10 @@ export const BOUNDARY_GUIDANCE: string[] = [
143
181
  "Run `swallowkit machine verify project` after applying changes; use `explain failure` to get repair evidence.",
144
182
  ];
145
183
 
146
- export function inspectBoundaries(projectRoot: string = process.cwd()): BoundariesContract {
184
+ export function inspectBoundaries(
185
+ projectRoot: string = process.cwd(),
186
+ backendLanguage: BackendLanguage = getBackendLanguage()
187
+ ): BoundariesContract {
147
188
  const inspected = inspectArtifacts(projectRoot);
148
189
 
149
190
  const artifacts: BoundaryArtifact[] = inspected.artifacts.map((artifact) => {
@@ -162,8 +203,9 @@ export function inspectBoundaries(projectRoot: string = process.cwd()): Boundari
162
203
  contractVersion: 1,
163
204
  summary:
164
205
  "SwallowKit separates deterministic generation (models → CRUD/BFF/UI/infra via plan/apply) from AI free-form authoring (models, business logic, custom code). This contract tells agents which files belong to which side.",
206
+ backendLanguage,
165
207
  ownershipPolicies: OWNERSHIP_POLICIES,
166
- conventionRules: CONVENTION_RULES,
208
+ conventionRules: buildConventionRules(backendLanguage),
167
209
  artifacts,
168
210
  guidance: BOUNDARY_GUIDANCE,
169
211
  };