@wildo-ai/dev-companion 1.1.14 → 1.1.15

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 (138) hide show
  1. package/dist/esm/.tsbuildinfo +1 -1
  2. package/dist/esm/claude-cli/models/coding-agent-dispatch.models.d.ts +68 -1
  3. package/dist/esm/claude-cli/models/coding-agent-dispatch.models.d.ts.map +1 -1
  4. package/dist/esm/claude-cli/models/coding-agent-dispatch.models.js +77 -5
  5. package/dist/esm/claude-cli/models/coding-agent-dispatch.models.js.map +1 -1
  6. package/dist/esm/claude-cli/models/concurrent-coding-runs.models.d.ts +46 -1
  7. package/dist/esm/claude-cli/models/concurrent-coding-runs.models.d.ts.map +1 -1
  8. package/dist/esm/claude-cli/models/concurrent-coding-runs.models.js +39 -2
  9. package/dist/esm/claude-cli/models/concurrent-coding-runs.models.js.map +1 -1
  10. package/dist/esm/claude-cli/models/shared-tree-reconciliation.models.d.ts +6 -0
  11. package/dist/esm/claude-cli/models/shared-tree-reconciliation.models.d.ts.map +1 -1
  12. package/dist/esm/claude-cli/models/shared-tree-reconciliation.models.js.map +1 -1
  13. package/dist/esm/claude-cli/models/verification-tool-availability.models.d.ts +19 -5
  14. package/dist/esm/claude-cli/models/verification-tool-availability.models.d.ts.map +1 -1
  15. package/dist/esm/claude-cli/models/verification-tool-availability.models.js +17 -5
  16. package/dist/esm/claude-cli/models/verification-tool-availability.models.js.map +1 -1
  17. package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.d.ts +16 -1
  18. package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.d.ts.map +1 -1
  19. package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.js +44 -4
  20. package/dist/esm/claude-cli/services/accepted-change-commit.companion.service.js.map +1 -1
  21. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.d.ts +79 -6
  22. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.d.ts.map +1 -1
  23. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js +291 -40
  24. package/dist/esm/claude-cli/services/coding-agent-dispatch.companion.service.js.map +1 -1
  25. package/dist/esm/claude-cli/services/research-evidence-store.companion.d.ts +14 -0
  26. package/dist/esm/claude-cli/services/research-evidence-store.companion.d.ts.map +1 -1
  27. package/dist/esm/claude-cli/services/research-evidence-store.companion.js +35 -0
  28. package/dist/esm/claude-cli/services/research-evidence-store.companion.js.map +1 -1
  29. package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.d.ts +36 -0
  30. package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.d.ts.map +1 -0
  31. package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.js +134 -0
  32. package/dist/esm/claude-cli/services/unrecorded-provider-directories.companion.js.map +1 -0
  33. package/dist/esm/core/introspection/services/translation-placement.companion.service.d.ts +3 -2
  34. package/dist/esm/core/introspection/services/translation-placement.companion.service.d.ts.map +1 -1
  35. package/dist/esm/core/introspection/services/translation-placement.companion.service.js.map +1 -1
  36. package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.d.ts.map +1 -1
  37. package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.js +24 -14
  38. package/dist/esm/core/introspection/subprocess/companion-introspection-behavior-handlers.js.map +1 -1
  39. package/dist/esm/core/introspection/workspace-element-index.companion.d.ts +42 -0
  40. package/dist/esm/core/introspection/workspace-element-index.companion.d.ts.map +1 -1
  41. package/dist/esm/core/introspection/workspace-element-index.companion.js +42 -0
  42. package/dist/esm/core/introspection/workspace-element-index.companion.js.map +1 -1
  43. package/dist/esm/core/runtime/dev-compile-quiet.companion.d.ts +53 -0
  44. package/dist/esm/core/runtime/dev-compile-quiet.companion.d.ts.map +1 -1
  45. package/dist/esm/core/runtime/dev-compile-quiet.companion.js +119 -2
  46. package/dist/esm/core/runtime/dev-compile-quiet.companion.js.map +1 -1
  47. package/dist/esm/core/runtime/services/start-companion-application.service.d.ts.map +1 -1
  48. package/dist/esm/core/runtime/services/start-companion-application.service.js +13 -1
  49. package/dist/esm/core/runtime/services/start-companion-application.service.js.map +1 -1
  50. package/dist/esm/core/runtime/utils/companion-platform-config.companion.d.ts +2 -2
  51. package/dist/esm/core/runtime/utils/companion-platform-config.companion.d.ts.map +1 -1
  52. package/dist/esm/core/runtime/utils/companion-platform-config.companion.js +6 -6
  53. package/dist/esm/core/runtime/utils/companion-platform-config.companion.js.map +1 -1
  54. package/dist/esm/email/services/email-template.companion.service.d.ts +5 -0
  55. package/dist/esm/email/services/email-template.companion.service.d.ts.map +1 -1
  56. package/dist/esm/email/services/email-template.companion.service.js +44 -11
  57. package/dist/esm/email/services/email-template.companion.service.js.map +1 -1
  58. package/dist/esm/email/utils/email-template-fs-discovery.utils.d.ts +26 -2
  59. package/dist/esm/email/utils/email-template-fs-discovery.utils.d.ts.map +1 -1
  60. package/dist/esm/email/utils/email-template-fs-discovery.utils.js +41 -2
  61. package/dist/esm/email/utils/email-template-fs-discovery.utils.js.map +1 -1
  62. package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.d.ts +19 -0
  63. package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.d.ts.map +1 -0
  64. package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.js +171 -0
  65. package/dist/esm/email/utils/email-template-scanner-calls.companion.utils.js.map +1 -0
  66. package/dist/esm/email/utils/module-email-root.companion.utils.d.ts +75 -0
  67. package/dist/esm/email/utils/module-email-root.companion.utils.d.ts.map +1 -0
  68. package/dist/esm/email/utils/module-email-root.companion.utils.js +162 -0
  69. package/dist/esm/email/utils/module-email-root.companion.utils.js.map +1 -0
  70. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.d.ts +1 -0
  71. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.d.ts.map +1 -1
  72. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.js +1 -0
  73. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.en.js.map +1 -1
  74. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.d.ts +1 -0
  75. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.d.ts.map +1 -1
  76. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.js +1 -0
  77. package/dist/esm/i18n/components/LOW_LEVEL_AI_AGENT_CONFIG.fr.js.map +1 -1
  78. package/dist/esm/i18n/resources/workbenchAspects.en.d.ts.map +1 -1
  79. package/dist/esm/i18n/resources/workbenchAspects.en.js +4 -0
  80. package/dist/esm/i18n/resources/workbenchAspects.en.js.map +1 -1
  81. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts +35 -0
  82. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.d.ts.map +1 -1
  83. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js +12 -0
  84. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.en.js.map +1 -1
  85. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.d.ts +536 -531
  86. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.d.ts.map +1 -1
  87. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.js +536 -531
  88. package/dist/esm/i18n/resources/workbenchSpecificationArtifacts.fr.js.map +1 -1
  89. package/dist/esm/i18n/system_enums/workbench-build.en.d.ts +2 -2
  90. package/dist/esm/i18n/system_enums/workbench-build.en.js +2 -2
  91. package/dist/esm/i18n/system_enums/workbench-build.en.js.map +1 -1
  92. package/dist/esm/i18n-labelling/services/email-template-labelling-units.companion.service.d.ts.map +1 -1
  93. package/dist/esm/i18n-labelling/services/email-template-labelling-units.companion.service.js +7 -3
  94. package/dist/esm/i18n-labelling/services/email-template-labelling-units.companion.service.js.map +1 -1
  95. package/dist/esm/meta-workflows/models/creation-journey-timeline.models.d.ts +9 -0
  96. package/dist/esm/meta-workflows/models/creation-journey-timeline.models.d.ts.map +1 -1
  97. package/dist/esm/meta-workflows/models/creation-journey-timeline.models.js +18 -2
  98. package/dist/esm/meta-workflows/models/creation-journey-timeline.models.js.map +1 -1
  99. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts +33 -6
  100. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.d.ts.map +1 -1
  101. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js +97 -19
  102. package/dist/esm/meta-workflows/services/application-build-dispatch.companion.service.js.map +1 -1
  103. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.d.ts +21 -8
  104. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.d.ts.map +1 -1
  105. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.js +65 -12
  106. package/dist/esm/meta-workflows/services/application-build-follow-up-derivation.companion.js.map +1 -1
  107. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.d.ts +1 -1
  108. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.d.ts.map +1 -1
  109. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.js +48 -26
  110. package/dist/esm/meta-workflows/services/application-build-task-coding-policy.companion.service.js.map +1 -1
  111. package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.d.ts +12 -0
  112. package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.d.ts.map +1 -1
  113. package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.js +30 -1
  114. package/dist/esm/meta-workflows/services/build-task-brief-application-facts.companion.js.map +1 -1
  115. package/dist/esm/meta-workflows/services/creation-run-report.companion.service.d.ts.map +1 -1
  116. package/dist/esm/meta-workflows/services/creation-run-report.companion.service.js +12 -1
  117. package/dist/esm/meta-workflows/services/creation-run-report.companion.service.js.map +1 -1
  118. package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts +7 -0
  119. package/dist/esm/meta-workflows/services/playbook-run.companion.service.d.ts.map +1 -1
  120. package/dist/esm/meta-workflows/services/playbook-run.companion.service.js +81 -4
  121. package/dist/esm/meta-workflows/services/playbook-run.companion.service.js.map +1 -1
  122. package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.d.ts +55 -1
  123. package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.d.ts.map +1 -1
  124. package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.js +157 -10
  125. package/dist/esm/meta-workflows/services/provider-registry-brief.companion.utils.js.map +1 -1
  126. package/dist/esm/module-layout/module-layout-convention.companion.d.ts +158 -0
  127. package/dist/esm/module-layout/module-layout-convention.companion.d.ts.map +1 -0
  128. package/dist/esm/module-layout/module-layout-convention.companion.js +272 -0
  129. package/dist/esm/module-layout/module-layout-convention.companion.js.map +1 -0
  130. package/dist/esm/module-layout/module-layout-inspection.companion.d.ts +42 -0
  131. package/dist/esm/module-layout/module-layout-inspection.companion.d.ts.map +1 -0
  132. package/dist/esm/module-layout/module-layout-inspection.companion.js +290 -0
  133. package/dist/esm/module-layout/module-layout-inspection.companion.js.map +1 -0
  134. package/dist/esm/module-layout/module-source-files.companion.d.ts +3 -0
  135. package/dist/esm/module-layout/module-source-files.companion.d.ts.map +1 -0
  136. package/dist/esm/module-layout/module-source-files.companion.js +45 -0
  137. package/dist/esm/module-layout/module-source-files.companion.js.map +1 -0
  138. package/package.json +17 -17
@@ -86,6 +86,20 @@ export interface FinalEvidenceRecordInput {
86
86
  * investigation. Returns the absolute path written, so the caller can report it.
87
87
  */
88
88
  export declare function writeFinalEvidenceRecord(input: FinalEvidenceRecordInput): string;
89
+ /** One completed research turn, as its final evidence record states it (#3896). */
90
+ export interface ResearchTurnRecord {
91
+ /** The playbook that asked; the record's own evidence scope (its directory) when the record names none. */
92
+ readonly playbookRef: string;
93
+ readonly startedAt: string;
94
+ readonly elapsedMs: number;
95
+ }
96
+ /**
97
+ * Every completed research turn of the application, read from the final evidence records under
98
+ * {@link RESEARCH_EVIDENCE_RELATIVE_ROOT} (`<scope>/<yyyy-mm-dd>-round-<n>.md`, written by {@link writeFinalEvidenceRecord}).
99
+ * The creation timeline reads them because a research turn writes no playbook-run row (#3896). A record without
100
+ * `startedAt` or `elapsedMs` is skipped; a missing root answers none. Throws only on an unreadable directory.
101
+ */
102
+ export declare function readResearchTurnRecords(saasRoot: string): readonly ResearchTurnRecord[];
89
103
  /**
90
104
  * Stamp the markdown files a research turn wrote as THIRD_PARTY content (#2846 review M1, N7).
91
105
  *
@@ -1 +1 @@
1
- {"version":3,"file":"research-evidence-store.companion.d.ts","sourceRoot":"","sources":["../../../../src/claude-cli/services/research-evidence-store.companion.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,uGAAuG;AACvG,eAAO,MAAM,+BAA+B,qCAAqC,CAAC;AAElF;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAExF;AAED,iGAAiG;AACjG,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO1D;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,+BAA+B,CAAC,6BAA6B,EAAE,MAAM,EAAE,mCAAmC,CAAC,EAAE,MAAM,GAAG,MAAM,CAiB3I;AAED,sGAAsG;AACtG,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,6BAA6B,EAAE,MAAM,CAAC;IAC/C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,yFAAyF;IACzF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,wBAAwB,GAAG,MAAM,CAsChF;AAKD;;;;;;;;;;;GAWG;AACH,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,MAAM,EAAE,6BAA6B,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,EAAE,CAUtJ;AAYD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAS7D;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,6BAA6B,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAYrH;AAED,oHAAoH;AACpH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACjC,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,CAAC,CAQ3E"}
1
+ {"version":3,"file":"research-evidence-store.companion.d.ts","sourceRoot":"","sources":["../../../../src/claude-cli/services/research-evidence-store.companion.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,uGAAuG;AACvG,eAAO,MAAM,+BAA+B,qCAAqC,CAAC;AAElF;;;;GAIG;AACH,wBAAgB,gCAAgC,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAExF;AAED,iGAAiG;AACjG,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO1D;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,+BAA+B,CAAC,6BAA6B,EAAE,MAAM,EAAE,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B,CAClC,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,GACjC,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,CAAC,CAQ3E"}
@@ -142,6 +142,41 @@ export function writeFinalEvidenceRecord(input) {
142
142
  writeFileSync(filePath, body, 'utf8');
143
143
  return filePath;
144
144
  }
145
+ /**
146
+ * Every completed research turn of the application, read from the final evidence records under
147
+ * {@link RESEARCH_EVIDENCE_RELATIVE_ROOT} (`<scope>/<yyyy-mm-dd>-round-<n>.md`, written by {@link writeFinalEvidenceRecord}).
148
+ * The creation timeline reads them because a research turn writes no playbook-run row (#3896). A record without
149
+ * `startedAt` or `elapsedMs` is skipped; a missing root answers none. Throws only on an unreadable directory.
150
+ */
151
+ export function readResearchTurnRecords(saasRoot) {
152
+ const root = join(saasRoot, RESEARCH_EVIDENCE_RELATIVE_ROOT);
153
+ if (!existsSync(root))
154
+ return [];
155
+ const turns = [];
156
+ const visit = (directory, scope) => {
157
+ for (const entry of readdirSync(directory, { withFileTypes: true })) {
158
+ const fullPath = join(directory, entry.name);
159
+ if (entry.isDirectory()) {
160
+ visit(fullPath, scope === undefined ? entry.name : `${scope}/${entry.name}`);
161
+ continue;
162
+ }
163
+ if (!/^\d{4}-\d{2}-\d{2}-round-\d+\.md$/u.test(entry.name))
164
+ continue;
165
+ const frontmatter = /^---\n([\s\S]*?)\n---/u.exec(readFileSync(fullPath, 'utf8'))?.[1];
166
+ if (frontmatter === undefined)
167
+ continue;
168
+ const field = (name) => new RegExp(`^${name}: (.+)$`, 'mu').exec(frontmatter)?.[1]?.trim();
169
+ const startedAt = field('startedAt');
170
+ const elapsedMs = Number(field('elapsedMs'));
171
+ const playbookRef = field('playbookRef') ?? scope;
172
+ if (startedAt === undefined || Number.isNaN(Date.parse(startedAt)) || !Number.isFinite(elapsedMs) || playbookRef === undefined)
173
+ continue;
174
+ turns.push({ playbookRef, startedAt, elapsedMs });
175
+ }
176
+ };
177
+ visit(root, undefined);
178
+ return turns;
179
+ }
145
180
  /** The frontmatter line that says a research evidence file is the web's (#2846). */
146
181
  const CONTENT_TRUST_LINE = `contentTrust: ${MetaWorkflow_ContextSourceTrust.THIRD_PARTY}`;
147
182
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"research-evidence-store.companion.js","sourceRoot":"","sources":["../../../../src/claude-cli/services/research-evidence-store.companion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAEvF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,uGAAuG;AACvG,MAAM,CAAC,MAAM,+BAA+B,GAAG,kCAAkC,CAAC;AAElF;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAAC,QAAgB,EAAE,KAAa;IAC9E,OAAO,IAAI,CAAC,QAAQ,EAAE,+BAA+B,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;AACtF,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,MAAM,IAAI,GAAG,KAAK;SACf,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;SACvB,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChB,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;AAC1C,CAAC;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AM,UAAU,oBAAoB,CAClC,MAAmC,EACnC,KAAkC;IAElC,OAAO,CAAC,GAAG,KAAK,CAAC;SACd,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC;SAC/E,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;SACpD,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,EAAE;QAC9B,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC;IACjG,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { mkdirSync, writeFileSync, existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { join, relative, sep } from 'node:path';\n\nimport { MetaWorkflow_ContextSourceTrust } from '@wildo-ai/saas-models/meta-workflows';\n\n/**\n * The research evidence store — where a research agent's findings become FILES.\n *\n * ## Why this exists (2026-09-04)\n *\n * Research evidence used to live in exactly one place: the run's in-memory step results, feeding\n * the next child's brief and dying with the run. Three consecutive compliance runs proved what that\n * costs — a 56-minute, 14-children evidence body lost to a quota cut, then two relaunches lost to\n * an expired login — and the run-level checkpoint only protects the SCHEDULING state, not the\n * knowledge. The store is the knowledge half: evidence lands on disk as it is gathered, survives\n * any death, and is READ BACK by later runs so they extend prior research instead of re-buying it.\n *\n * ## Where, and why it is COMMITTABLE\n *\n * `<application>/specifications/research-evidence/<scope>/` — inside the application repository,\n * outside `specifications/src/`, so it enters no TypeScript program and no family classification.\n * Committable on purpose: source-attributed research is knowledge the posture artifacts cite, and\n * \"delete it and re-run\" costs hours and a quota window — git is where things that must survive a\n * re-clone live (`one-source-of-truth.md`). Since #2419 a turn's evidence is RECORDED in the write register under the\n * root run of its tree, so `wildo creation accept <runId>` commits it; the record is accept-on-request-only, so the\n * posture's automatic commit never carries it: in the framework's dogfood applications this store sits inside\n * framework git, and unreviewed research has already tripped the assurance boundary gate there once.\n *\n * ## Who writes\n *\n * TWO writers, layered:\n * 1. The research AGENT, incrementally, during its turn — its WRITE predicate admits exactly its own\n * scope's directory, and its READ predicate the whole store (both built by the same\n * `buildApplicationCodingTaskLocationPredicate` the coding lane trusts), so a mid-turn death still\n * leaves everything already consolidated, and no task writes another scope's evidence (#1609).\n * 2. The COMPANION, once per completed task — `writeFinalEvidenceRecord` persists the returned\n * brief with its provenance frontmatter, so a completed turn is on disk even if the agent wrote\n * nothing itself.\n */\n\n/** Application-relative root of the store. Also the ONLY path prefix the research predicate admits. */\nexport const RESEARCH_EVIDENCE_RELATIVE_ROOT = 'specifications/research-evidence';\n\n/**\n * A scope names the investigation a set of evidence files belongs to — normally the composite\n * playbook ref (`top_down.compliance-analysis`), so every child of one choreography, across every\n * run of it, consolidates into one directory.\n */\nexport function resolveResearchEvidenceDirectory(saasRoot: string, scope: string): string {\n return join(saasRoot, RESEARCH_EVIDENCE_RELATIVE_ROOT, slugifyEvidenceScope(scope));\n}\n\n/** Directory-safe scope: lowercase, dots and separators to hyphens, nothing traversal-shaped. */\nexport function slugifyEvidenceScope(scope: string): string {\n const slug = scope\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 80);\n return slug.length > 0 ? slug : 'adhoc';\n}\n\n/**\n * The prompt block that turns \"you may write here\" into \"you consolidate here\".\n *\n * Appended to every research objective by the dispatch, never authored per playbook: the store is a\n * property of the LANE, and a convention restated per method drifts. The instruction is explicit\n * that the directory is the ONLY writable location — the predicate enforces it, but an agent told\n * the boundary spends its turn researching instead of discovering refusals.\n *\n * ## Why it also carries a SOURCE-NEUTRALITY clause (2026-09-04)\n *\n * A compliance researcher enumerating \"which regimes apply\" reaches for proprietary security\n * certification and attestation standards unprompted, alongside the public law that is the actual\n * subject. Public law is fine — statutes and regulations are quotable. The proprietary standards are\n * not: their control catalogues and identifiers are licensed material, and `CLAUDE.md` confines every\n * external framework name, identifier and mapping to a rights-classified boundary that this store is\n * not. `pnpm check:assurance-control-boundary` refuses them repository-wide against a baseline drained\n * to zero, so a dogfood application's committed store is a surface where they land in FRAMEWORK git.\n *\n * That is not hypothetical: Wonder CRM's first accepted evidence population carried six such names —\n * every one of them merely listing the standard as \"voluntary, not a legal obligation, never\n * researched\" — and reddened the gate on the shared branch. The finding survives its neutral phrasing\n * intact, which is why the instruction asks for the CATEGORY rather than forbidding the conclusion:\n * an agent told only \"do not name X\" tends to drop the finding along with the name.\n */\nexport function composeEvidenceStoreInstruction(evidenceDirectoryAbsolutePath: string, sharedEvidenceDirectoryAbsolutePath?: string): string {\n return [\n '# Evidence store (persist as you go)',\n `The directory \\`${evidenceDirectoryAbsolutePath}\\` is your evidence store — the ONLY location you may write to (every other path is refused).`,\n 'FIRST read what it already contains: earlier rounds consolidated their findings there. Extend that record; do not re-research or restate what a prior file already establishes with sources.',\n /*\n * An INSTANCE's research (#1609) keeps its own store, so one segment's or one feature's findings never\n * mix into another's, and READS the default instance's, where facts true of the whole application\n * (the market, the law) were gathered. Read-only: what this instance finds belongs to this instance.\n */\n ...(sharedEvidenceDirectoryAbsolutePath\n ? [`ALSO read \\`${sharedEvidenceDirectoryAbsolutePath}\\`: the evidence the application as a whole gathered for the same investigation. Rely on what it establishes and do not re-research it, but never write there; what you find for THIS purpose goes in your own store.`]\n : []),\n 'AS YOU RESEARCH, persist your findings into markdown files in that directory — one file per coherent topic, named `<topic-slug>.md`, updated in place as your understanding sharpens. Each finding carries its source URL beside it. Write incrementally: evidence on disk survives an interrupted turn; evidence only in your final message does not.',\n 'SOURCE NEUTRALITY: name public law freely (statutes, regulations, regulator guidance — quote and cite them). Do NOT name a proprietary security certification or attestation standard, or any of its control identifiers, in a file or in your final message: their catalogues are licensed material this store is not a rights-classified boundary for. Refer to that whole class as \"voluntary security-certification and attestation frameworks\" and state your finding about it in full — the conclusion is wanted, the proprietary name is not.',\n 'Your final message still reports the answer in full — the store is the durable record, not a substitute for answering.',\n ].join('\\n');\n}\n\n/** What the companion persists about one COMPLETED research task, beside whatever the agent wrote. */\nexport interface FinalEvidenceRecordInput {\n readonly evidenceDirectoryAbsolutePath: string;\n readonly objective: string;\n readonly evidence: string;\n readonly stopReason: string;\n readonly startedAtIso: string;\n readonly elapsedMs: number;\n /** The playbook that asked, when one did — an operator's ad-hoc `/research` has none. */\n readonly playbookRef?: string;\n}\n\n/**\n * Persist the final returned brief as a dated, provenance-stamped markdown record.\n *\n * Filename is `<yyyy-mm-dd>-round-<n>.md` where `n` disambiguates within a day — deliberately NOT\n * derived from the objective, whose first words are near-identical across rounds of one\n * investigation. Returns the absolute path written, so the caller can report it.\n */\nexport function writeFinalEvidenceRecord(input: FinalEvidenceRecordInput): string {\n mkdirSync(input.evidenceDirectoryAbsolutePath, { recursive: true });\n const day = input.startedAtIso.slice(0, 10);\n const existing = readdirSync(input.evidenceDirectoryAbsolutePath).filter((name) => name.startsWith(`${day}-round-`));\n let round = existing.length + 1;\n let filePath = join(input.evidenceDirectoryAbsolutePath, `${day}-round-${round}.md`);\n while (existsSync(filePath)) {\n round += 1;\n filePath = join(input.evidenceDirectoryAbsolutePath, `${day}-round-${round}.md`);\n }\n const frontmatter = [\n '---',\n `startedAt: ${input.startedAtIso}`,\n `elapsedMs: ${input.elapsedMs}`,\n `stopReason: ${input.stopReason}`,\n ...(input.playbookRef ? [`playbookRef: ${input.playbookRef}`] : []),\n /*\n * WHO WROTE IT (#2846): the evidence is the web's, condensed by a research agent, and a reader of the committed file\n * (an operator, a judge, a later research round) is told so in the record itself. The value is the brief's trust\n * vocabulary, so the file and a coding brief name the class identically.\n */\n `contentTrust: ${MetaWorkflow_ContextSourceTrust.THIRD_PARTY}`,\n '---',\n ].join('\\n');\n const body = [\n frontmatter,\n '',\n '## Objective',\n '',\n input.objective,\n '',\n '## Evidence',\n '',\n input.evidence,\n '',\n ].join('\\n');\n writeFileSync(filePath, body, 'utf8');\n return filePath;\n}\n\n/** The frontmatter line that says a research evidence file is the web's (#2846). */\nconst CONTENT_TRUST_LINE = `contentTrust: ${MetaWorkflow_ContextSourceTrust.THIRD_PARTY}`;\n\n/**\n * Stamp the markdown files a research turn wrote as THIRD_PARTY content (#2846 review M1, N7).\n *\n * The agent writes its own `<topic-slug>.md` files and is asked to cite sources; nothing made it say whose text the file\n * is, and an instruction is not a control. So the companion stamps them itself: a file with frontmatter gets (or has\n * corrected) its `contentTrust` line, a file without one gets a frontmatter block. A `contentTrust` line the file already\n * carries with another value is overwritten: text a research agent wrote cannot declare itself trusted.\n *\n * Only the files THIS turn created or changed are touched, read from the turn's own evidence diff (`before` is the\n * snapshot taken before the turn): a file an earlier round wrote, or a person edited since, is not this turn's to rewrite.\n * Idempotent. Returns the app-relative paths it changed.\n */\nexport function stampResearchEvidenceProvenance(saasRoot: string, evidenceDirectoryAbsolutePath: string, before: ReadonlyMap<string, string>): string[] {\n const stamped: string[] = [];\n for (const change of diffResearchEvidence(before, snapshotResearchEvidence(saasRoot, evidenceDirectoryAbsolutePath))) {\n if (!change.path.endsWith('.md')) continue;\n const next = withContentTrustStamp(change.writtenContent);\n if (next === change.writtenContent) continue;\n writeFileSync(join(saasRoot, ...change.path.split('/')), next, 'utf8');\n stamped.push(change.path);\n }\n return stamped;\n}\n\n/**\n * Whether the lines between two `---` markers are a FRONTMATTER block (YAML `key: value` entries, their indented\n * continuations and blank lines), and not two horizontal rules around ordinary markdown: a `# heading` or a sentence\n * between them is prose. A file that\n * opens on a `---` rule keeps it: the stamp then adds a frontmatter block above it rather than rewriting prose.\n */\nfunction isFrontmatterBlock(lines: readonly string[]): boolean {\n return lines.every((line) => line.trim().length === 0 || /^[A-Za-z0-9_-]+\\s*:/u.test(line) || /^\\s+\\S/u.test(line));\n}\n\n/**\n * The file's text with exactly one THIRD_PARTY `contentTrust` line in its frontmatter. Pure. Keeps the file's own line\n * endings: a CRLF file stays CRLF.\n */\nexport function withContentTrustStamp(content: string): string {\n const eol = /\\r\\n/u.test(content.slice(0, content.indexOf('\\n') + 1)) ? '\\r\\n' : '\\n';\n const frontmatter = /^---\\r?\\n(?:([\\s\\S]*?)\\r?\\n)?---(\\r?\\n|$)/u.exec(content);\n const lines = frontmatter === null || frontmatter[1] === undefined ? [] : frontmatter[1].split(/\\r?\\n/u);\n if (frontmatter === null || !isFrontmatterBlock(lines)) return `---${eol}${CONTENT_TRUST_LINE}${eol}---${eol}${eol}${content}`;\n const kept = lines.filter((line) => !/^\\s*contentTrust\\s*:/u.test(line));\n if (kept.length === lines.length - 1 && lines.includes(CONTENT_TRUST_LINE)) return content;\n const body = content.slice(frontmatter[0].length);\n return `---${eol}${[...kept, CONTENT_TRUST_LINE].join(eol)}${eol}---${frontmatter[2]}${body}`;\n}\n\n/**\n * Every file under an evidence directory, app-root-relative (POSIX), with its bytes. Empty when the directory does not\n * exist yet. Taken before and after a research turn so the turn's evidence can be recorded as a change (#2419).\n */\nexport function snapshotResearchEvidence(saasRoot: string, evidenceDirectoryAbsolutePath: string): Map<string, string> {\n const snapshot = new Map<string, string>();\n const walk = (directory: string): void => {\n if (!existsSync(directory)) return;\n for (const entry of readdirSync(directory, { withFileTypes: true })) {\n const absolutePath = join(directory, entry.name);\n if (entry.isDirectory()) walk(absolutePath);\n else if (entry.isFile()) snapshot.set(relative(saasRoot, absolutePath).split(sep).join('/'), readFileSync(absolutePath, 'utf8'));\n }\n };\n walk(evidenceDirectoryAbsolutePath);\n return snapshot;\n}\n\n/** The files a turn created or changed between two snapshots, with their pre-images. Deletions are not evidence. */\nexport function diffResearchEvidence(\n before: ReadonlyMap<string, string>,\n after: ReadonlyMap<string, string>,\n): Array<{ path: string; previousContent?: string; writtenContent: string }> {\n return [...after]\n .filter(([path, content]) => content.length > 0 && before.get(path) !== content)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([path, writtenContent]) => {\n const previousContent = before.get(path);\n return { path, ...(previousContent !== undefined ? { previousContent } : {}), writtenContent };\n });\n}\n"]}
1
+ {"version":3,"file":"research-evidence-store.companion.js","sourceRoot":"","sources":["../../../../src/claude-cli/services/research-evidence-store.companion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAEvF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,uGAAuG;AACvG,MAAM,CAAC,MAAM,+BAA+B,GAAG,kCAAkC,CAAC;AAElF;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAAC,QAAgB,EAAE,KAAa;IAC9E,OAAO,IAAI,CAAC,QAAQ,EAAE,+BAA+B,EAAE,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC;AACtF,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,MAAM,IAAI,GAAG,KAAK;SACf,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;SACvB,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAChB,OAAO,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;AAC1C,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,+BAA+B,C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C;YACjD,IAAI,KAAK,CAAC,WAAW,EAAE;gBAAE,IAAI,CAAC,YAAY,CAAC,CAAC;iBACvC,IAAI,KAAK,CAAC,MAAM,EAAE;gBAAE,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,YAAY,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC,CAAC;QACnI,CAAC;IACH,CAAC,CAAC;IACF,IAAI,CAAC,6BAA6B,CAAC,CAAC;IACpC,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,oHAAoH;AACpH,MAAM,UAAU,oBAAoB,CAClC,MAAmC,EACnC,KAAkC;IAElC,OAAO,CAAC,GAAG,KAAK,CAAC;SACd,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC;SAC/E,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;SACpD,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,cAAc,CAAC,EAAE,EAAE;QAC9B,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzC,OAAO,EAAE,IAAI,EAAE,GAAG,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,cAAc,EAAE,CAAC;IACjG,CAAC,CAAC,CAAC;AACP,CAAC","sourcesContent":["import { mkdirSync, writeFileSync, existsSync, readdirSync, readFileSync } from 'node:fs';\nimport { join, relative, sep } from 'node:path';\n\nimport { MetaWorkflow_ContextSourceTrust } from '@wildo-ai/saas-models/meta-workflows';\n\n/**\n * The research evidence store — where a research agent's findings become FILES.\n *\n * ## Why this exists (2026-09-04)\n *\n * Research evidence used to live in exactly one place: the run's in-memory step results, feeding\n * the next child's brief and dying with the run. Three consecutive compliance runs proved what that\n * costs — a 56-minute, 14-children evidence body lost to a quota cut, then two relaunches lost to\n * an expired login — and the run-level checkpoint only protects the SCHEDULING state, not the\n * knowledge. The store is the knowledge half: evidence lands on disk as it is gathered, survives\n * any death, and is READ BACK by later runs so they extend prior research instead of re-buying it.\n *\n * ## Where, and why it is COMMITTABLE\n *\n * `<application>/specifications/research-evidence/<scope>/` — inside the application repository,\n * outside `specifications/src/`, so it enters no TypeScript program and no family classification.\n * Committable on purpose: source-attributed research is knowledge the posture artifacts cite, and\n * \"delete it and re-run\" costs hours and a quota window — git is where things that must survive a\n * re-clone live (`one-source-of-truth.md`). Since #2419 a turn's evidence is RECORDED in the write register under the\n * root run of its tree, so `wildo creation accept <runId>` commits it; the record is accept-on-request-only, so the\n * posture's automatic commit never carries it: in the framework's dogfood applications this store sits inside\n * framework git, and unreviewed research has already tripped the assurance boundary gate there once.\n *\n * ## Who writes\n *\n * TWO writers, layered:\n * 1. The research AGENT, incrementally, during its turn — its WRITE predicate admits exactly its own\n * scope's directory, and its READ predicate the whole store (both built by the same\n * `buildApplicationCodingTaskLocationPredicate` the coding lane trusts), so a mid-turn death still\n * leaves everything already consolidated, and no task writes another scope's evidence (#1609).\n * 2. The COMPANION, once per completed task — `writeFinalEvidenceRecord` persists the returned\n * brief with its provenance frontmatter, so a completed turn is on disk even if the agent wrote\n * nothing itself.\n */\n\n/** Application-relative root of the store. Also the ONLY path prefix the research predicate admits. */\nexport const RESEARCH_EVIDENCE_RELATIVE_ROOT = 'specifications/research-evidence';\n\n/**\n * A scope names the investigation a set of evidence files belongs to — normally the composite\n * playbook ref (`top_down.compliance-analysis`), so every child of one choreography, across every\n * run of it, consolidates into one directory.\n */\nexport function resolveResearchEvidenceDirectory(saasRoot: string, scope: string): string {\n return join(saasRoot, RESEARCH_EVIDENCE_RELATIVE_ROOT, slugifyEvidenceScope(scope));\n}\n\n/** Directory-safe scope: lowercase, dots and separators to hyphens, nothing traversal-shaped. */\nexport function slugifyEvidenceScope(scope: string): string {\n const slug = scope\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, 80);\n return slug.length > 0 ? slug : 'adhoc';\n}\n\n/**\n * The prompt block that turns \"you may write here\" into \"you consolidate here\".\n *\n * Appended to every research objective by the dispatch, never authored per playbook: the store is a\n * property of the LANE, and a convention restated per method drifts. The instruction is explicit\n * that the directory is the ONLY writable location — the predicate enforces it, but an agent told\n * the boundary spends its turn researching instead of discovering refusals.\n *\n * ## Why it also carries a SOURCE-NEUTRALITY clause (2026-09-04)\n *\n * A compliance researcher enumerating \"which regimes apply\" reaches for proprietary security\n * certification and attestation standards unprompted, alongside the public law that is the actual\n * subject. Public law is fine — statutes and regulations are quotable. The proprietary standards are\n * not: their control catalogues and identifiers are licensed material, and `CLAUDE.md` confines every\n * external framework name, identifier and mapping to a rights-classified boundary that this store is\n * not. `pnpm check:assurance-control-boundary` refuses them repository-wide against a baseline drained\n * to zero, so a dogfood application's committed store is a surface where they land in FRAMEWORK git.\n *\n * That is not hypothetical: Wonder CRM's first accepted evidence population carried six such names —\n * every one of them merely listing the standard as \"voluntary, not a legal obligation, never\n * researched\" — and reddened the gate on the shared branch. The finding survives its neutral phrasing\n * intact, which is why the instruction asks for the CATEGORY rather than forbidding the conclusion:\n * an agent told only \"do not name X\" tends to drop the finding along with the name.\n */\nexport function composeEvidenceStoreInstruction(evidenceDirectoryAbsolutePath: string, sharedEvidenceDirectoryAbsolutePath?: string): string {\n return [\n '# Evidence store (persist as you go)',\n `The directory \\`${evidenceDirectoryAbsolutePath}\\` is your evidence store — the ONLY location you may write to (every other path is refused).`,\n 'FIRST read what it already contains: earlier rounds consolidated their findings there. Extend that record; do not re-research or restate what a prior file already establishes with sources.',\n /*\n * An INSTANCE's research (#1609) keeps its own store, so one segment's or one feature's findings never\n * mix into another's, and READS the default instance's, where facts true of the whole application\n * (the market, the law) were gathered. Read-only: what this instance finds belongs to this instance.\n */\n ...(sharedEvidenceDirectoryAbsolutePath\n ? [`ALSO read \\`${sharedEvidenceDirectoryAbsolutePath}\\`: the evidence the application as a whole gathered for the same investigation. Rely on what it establishes and do not re-research it, but never write there; what you find for THIS purpose goes in your own store.`]\n : []),\n 'AS YOU RESEARCH, persist your findings into markdown files in that directory — one file per coherent topic, named `<topic-slug>.md`, updated in place as your understanding sharpens. Each finding carries its source URL beside it. Write incrementally: evidence on disk survives an interrupted turn; evidence only in your final message does not.',\n 'SOURCE NEUTRALITY: name public law freely (statutes, regulations, regulator guidance — quote and cite them). Do NOT name a proprietary security certification or attestation standard, or any of its control identifiers, in a file or in your final message: their catalogues are licensed material this store is not a rights-classified boundary for. Refer to that whole class as \"voluntary security-certification and attestation frameworks\" and state your finding about it in full — the conclusion is wanted, the proprietary name is not.',\n 'Your final message still reports the answer in full — the store is the durable record, not a substitute for answering.',\n ].join('\\n');\n}\n\n/** What the companion persists about one COMPLETED research task, beside whatever the agent wrote. */\nexport interface FinalEvidenceRecordInput {\n readonly evidenceDirectoryAbsolutePath: string;\n readonly objective: string;\n readonly evidence: string;\n readonly stopReason: string;\n readonly startedAtIso: string;\n readonly elapsedMs: number;\n /** The playbook that asked, when one did — an operator's ad-hoc `/research` has none. */\n readonly playbookRef?: string;\n}\n\n/**\n * Persist the final returned brief as a dated, provenance-stamped markdown record.\n *\n * Filename is `<yyyy-mm-dd>-round-<n>.md` where `n` disambiguates within a day — deliberately NOT\n * derived from the objective, whose first words are near-identical across rounds of one\n * investigation. Returns the absolute path written, so the caller can report it.\n */\nexport function writeFinalEvidenceRecord(input: FinalEvidenceRecordInput): string {\n mkdirSync(input.evidenceDirectoryAbsolutePath, { recursive: true });\n const day = input.startedAtIso.slice(0, 10);\n const existing = readdirSync(input.evidenceDirectoryAbsolutePath).filter((name) => name.startsWith(`${day}-round-`));\n let round = existing.length + 1;\n let filePath = join(input.evidenceDirectoryAbsolutePath, `${day}-round-${round}.md`);\n while (existsSync(filePath)) {\n round += 1;\n filePath = join(input.evidenceDirectoryAbsolutePath, `${day}-round-${round}.md`);\n }\n const frontmatter = [\n '---',\n `startedAt: ${input.startedAtIso}`,\n `elapsedMs: ${input.elapsedMs}`,\n `stopReason: ${input.stopReason}`,\n ...(input.playbookRef ? [`playbookRef: ${input.playbookRef}`] : []),\n /*\n * WHO WROTE IT (#2846): the evidence is the web's, condensed by a research agent, and a reader of the committed file\n * (an operator, a judge, a later research round) is told so in the record itself. The value is the brief's trust\n * vocabulary, so the file and a coding brief name the class identically.\n */\n `contentTrust: ${MetaWorkflow_ContextSourceTrust.THIRD_PARTY}`,\n '---',\n ].join('\\n');\n const body = [\n frontmatter,\n '',\n '## Objective',\n '',\n input.objective,\n '',\n '## Evidence',\n '',\n input.evidence,\n '',\n ].join('\\n');\n writeFileSync(filePath, body, 'utf8');\n return filePath;\n}\n\n/** One completed research turn, as its final evidence record states it (#3896). */\nexport interface ResearchTurnRecord {\n /** The playbook that asked; the record's own evidence scope (its directory) when the record names none. */\n readonly playbookRef: string;\n readonly startedAt: string;\n readonly elapsedMs: number;\n}\n\n/**\n * Every completed research turn of the application, read from the final evidence records under\n * {@link RESEARCH_EVIDENCE_RELATIVE_ROOT} (`<scope>/<yyyy-mm-dd>-round-<n>.md`, written by {@link writeFinalEvidenceRecord}).\n * The creation timeline reads them because a research turn writes no playbook-run row (#3896). A record without\n * `startedAt` or `elapsedMs` is skipped; a missing root answers none. Throws only on an unreadable directory.\n */\nexport function readResearchTurnRecords(saasRoot: string): readonly ResearchTurnRecord[] {\n const root = join(saasRoot, RESEARCH_EVIDENCE_RELATIVE_ROOT);\n if (!existsSync(root)) return [];\n const turns: ResearchTurnRecord[] = [];\n const visit = (directory: string, scope: string | undefined): void => {\n for (const entry of readdirSync(directory, { withFileTypes: true })) {\n const fullPath = join(directory, entry.name);\n if (entry.isDirectory()) {\n visit(fullPath, scope === undefined ? entry.name : `${scope}/${entry.name}`);\n continue;\n }\n if (!/^\\d{4}-\\d{2}-\\d{2}-round-\\d+\\.md$/u.test(entry.name)) continue;\n const frontmatter = /^---\\n([\\s\\S]*?)\\n---/u.exec(readFileSync(fullPath, 'utf8'))?.[1];\n if (frontmatter === undefined) continue;\n const field = (name: string) => new RegExp(`^${name}: (.+)$`, 'mu').exec(frontmatter)?.[1]?.trim();\n const startedAt = field('startedAt');\n const elapsedMs = Number(field('elapsedMs'));\n const playbookRef = field('playbookRef') ?? scope;\n if (startedAt === undefined || Number.isNaN(Date.parse(startedAt)) || !Number.isFinite(elapsedMs) || playbookRef === undefined) continue;\n turns.push({ playbookRef, startedAt, elapsedMs });\n }\n };\n visit(root, undefined);\n return turns;\n}\n\n/** The frontmatter line that says a research evidence file is the web's (#2846). */\nconst CONTENT_TRUST_LINE = `contentTrust: ${MetaWorkflow_ContextSourceTrust.THIRD_PARTY}`;\n\n/**\n * Stamp the markdown files a research turn wrote as THIRD_PARTY content (#2846 review M1, N7).\n *\n * The agent writes its own `<topic-slug>.md` files and is asked to cite sources; nothing made it say whose text the file\n * is, and an instruction is not a control. So the companion stamps them itself: a file with frontmatter gets (or has\n * corrected) its `contentTrust` line, a file without one gets a frontmatter block. A `contentTrust` line the file already\n * carries with another value is overwritten: text a research agent wrote cannot declare itself trusted.\n *\n * Only the files THIS turn created or changed are touched, read from the turn's own evidence diff (`before` is the\n * snapshot taken before the turn): a file an earlier round wrote, or a person edited since, is not this turn's to rewrite.\n * Idempotent. Returns the app-relative paths it changed.\n */\nexport function stampResearchEvidenceProvenance(saasRoot: string, evidenceDirectoryAbsolutePath: string, before: ReadonlyMap<string, string>): string[] {\n const stamped: string[] = [];\n for (const change of diffResearchEvidence(before, snapshotResearchEvidence(saasRoot, evidenceDirectoryAbsolutePath))) {\n if (!change.path.endsWith('.md')) continue;\n const next = withContentTrustStamp(change.writtenContent);\n if (next === change.writtenContent) continue;\n writeFileSync(join(saasRoot, ...change.path.split('/')), next, 'utf8');\n stamped.push(change.path);\n }\n return stamped;\n}\n\n/**\n * Whether the lines between two `---` markers are a FRONTMATTER block (YAML `key: value` entries, their indented\n * continuations and blank lines), and not two horizontal rules around ordinary markdown: a `# heading` or a sentence\n * between them is prose. A file that\n * opens on a `---` rule keeps it: the stamp then adds a frontmatter block above it rather than rewriting prose.\n */\nfunction isFrontmatterBlock(lines: readonly string[]): boolean {\n return lines.every((line) => line.trim().length === 0 || /^[A-Za-z0-9_-]+\\s*:/u.test(line) || /^\\s+\\S/u.test(line));\n}\n\n/**\n * The file's text with exactly one THIRD_PARTY `contentTrust` line in its frontmatter. Pure. Keeps the file's own line\n * endings: a CRLF file stays CRLF.\n */\nexport function withContentTrustStamp(content: string): string {\n const eol = /\\r\\n/u.test(content.slice(0, content.indexOf('\\n') + 1)) ? '\\r\\n' : '\\n';\n const frontmatter = /^---\\r?\\n(?:([\\s\\S]*?)\\r?\\n)?---(\\r?\\n|$)/u.exec(content);\n const lines = frontmatter === null || frontmatter[1] === undefined ? [] : frontmatter[1].split(/\\r?\\n/u);\n if (frontmatter === null || !isFrontmatterBlock(lines)) return `---${eol}${CONTENT_TRUST_LINE}${eol}---${eol}${eol}${content}`;\n const kept = lines.filter((line) => !/^\\s*contentTrust\\s*:/u.test(line));\n if (kept.length === lines.length - 1 && lines.includes(CONTENT_TRUST_LINE)) return content;\n const body = content.slice(frontmatter[0].length);\n return `---${eol}${[...kept, CONTENT_TRUST_LINE].join(eol)}${eol}---${frontmatter[2]}${body}`;\n}\n\n/**\n * Every file under an evidence directory, app-root-relative (POSIX), with its bytes. Empty when the directory does not\n * exist yet. Taken before and after a research turn so the turn's evidence can be recorded as a change (#2419).\n */\nexport function snapshotResearchEvidence(saasRoot: string, evidenceDirectoryAbsolutePath: string): Map<string, string> {\n const snapshot = new Map<string, string>();\n const walk = (directory: string): void => {\n if (!existsSync(directory)) return;\n for (const entry of readdirSync(directory, { withFileTypes: true })) {\n const absolutePath = join(directory, entry.name);\n if (entry.isDirectory()) walk(absolutePath);\n else if (entry.isFile()) snapshot.set(relative(saasRoot, absolutePath).split(sep).join('/'), readFileSync(absolutePath, 'utf8'));\n }\n };\n walk(evidenceDirectoryAbsolutePath);\n return snapshot;\n}\n\n/** The files a turn created or changed between two snapshots, with their pre-images. Deletions are not evidence. */\nexport function diffResearchEvidence(\n before: ReadonlyMap<string, string>,\n after: ReadonlyMap<string, string>,\n): Array<{ path: string; previousContent?: string; writtenContent: string }> {\n return [...after]\n .filter(([path, content]) => content.length > 0 && before.get(path) !== content)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([path, writtenContent]) => {\n const previousContent = before.get(path);\n return { path, ...(previousContent !== undefined ? { previousContent } : {}), writtenContent };\n });\n}\n"]}
@@ -0,0 +1,36 @@
1
+ import type { CompanionContext } from '../../core/context/companion-context';
2
+ import { type GitChangeSetCapture, type GitChangeSetFileEntry } from '../models/coding-agent-dispatch.models';
3
+ /** Where an application keeps its provider packages: installed modules and authored ones alike (`providers/<ref>/`). */
4
+ export declare const APPLICATION_PROVIDER_PACKAGES_DIRECTORY = "providers";
5
+ /** One provider directory the run created that neither the lock nor the integration plan accounts for. */
6
+ export interface UnrecordedProviderDirectory {
7
+ readonly providerRef: string;
8
+ /** Application-relative, with its trailing slash: `providers/<ref>/`. */
9
+ readonly directory: string;
10
+ /** What the run wrote there, application-relative. */
11
+ readonly paths: readonly string[];
12
+ readonly advisory: string;
13
+ }
14
+ /**
15
+ * The provider directories the run CREATED, by ref, with the paths it wrote there. Pure over the change set; see the
16
+ * module's JSDoc for what counts as new.
17
+ */
18
+ export declare function findProviderDirectoriesCreatedByRun(files: readonly GitChangeSetFileEntry[]): ReadonlyMap<string, readonly string[]>;
19
+ /** The refs the lock records as installed module directories: the module ids and the files each entry lists. */
20
+ export declare function installedProviderRefsFromLockModules(installed: Readonly<Record<string, {
21
+ readonly moduleId: string;
22
+ readonly files: readonly string[];
23
+ }>>): ReadonlySet<string>;
24
+ /** The created directories neither recorded as installed nor named by a recorded unprovided need. Pure. */
25
+ export declare function selectUnrecordedProviderDirectories(input: {
26
+ readonly created: ReadonlyMap<string, readonly string[]>;
27
+ readonly installedRefs: ReadonlySet<string>;
28
+ readonly unprovidedNeedRefs: ReadonlySet<string>;
29
+ }): UnrecordedProviderDirectory[];
30
+ /**
31
+ * The advisory for a settled run's change set: reads the baseline commit and the lock and, only when the run created a
32
+ * provider directory neither accounts for, the integration plan. `undefined` when any of them could not be read, since an
33
+ * advisory that may be false is not one; an ABSENT plan reads as no recorded need, which is the case this exists for.
34
+ */
35
+ export declare function readUnrecordedProviderDirectories(companionContext: CompanionContext, changeSet: Pick<GitChangeSetCapture, 'files' | 'baselineHeadSha'>): Promise<readonly UnrecordedProviderDirectory[] | undefined>;
36
+ //# sourceMappingURL=unrecorded-provider-directories.companion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unrecorded-provider-directories.companion.d.ts","sourceRoot":"","sources":["../../../../src/claude-cli/services/unrecorded-provider-directories.companion.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,OAAO,EAAwD,KAAK,mBAAmB,EAAE,KAAK,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAIpK,wHAAwH;AACxH,eAAO,MAAM,uCAAuC,cAAc,CAAC;AAEnE,0GAA0G;AAC1G,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,yEAAyE;IACzE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,sDAAsD;IACtD,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAUD;;;GAGG;AACH,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,SAAS,qBAAqB,EAAE,GAAG,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAenI;AAED,gHAAgH;AAChH,wBAAgB,oCAAoC,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,CAY/K;AAED,2GAA2G;AAC3G,wBAAgB,mCAAmC,CAAC,KAAK,EAAE;IACzD,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IACzD,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5C,QAAQ,CAAC,kBAAkB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAClD,GAAG,2BAA2B,EAAE,CAYhC;AAQD;;;;GAIG;AACH,wBAAsB,iCAAiC,CACrD,gBAAgB,EAAE,gBAAgB,EAClC,SAAS,EAAE,IAAI,CAAC,mBAAmB,EAAE,OAAO,GAAG,iBAAiB,CAAC,GAChE,OAAO,CAAC,SAAS,2BAA2B,EAAE,GAAG,SAAS,CAAC,CAyB7D"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * A provider a coding run AUTHORED that nothing decided to author (#3995 item 2): an ADVISORY on the run's result, never a
3
+ * refusal.
4
+ *
5
+ * App creation uses the providers the framework already has, and authors a new one only for a need the integration plan
6
+ * records with its reason (#3992, Paul 2026-11-16). The worker contract tells the agent so, and the build decomposition
7
+ * emits an authoring task only for such a need. Neither stops an agent from writing `providers/<ref>/` anyway, and nothing
8
+ * looked afterwards. This is the look: a NEW `providers/<ref>/` directory the run wrote, that the lock does not record as
9
+ * an installed module (`.wildo-saas/wildo-saas.lock.json` → `sections.modules.installed`, what `wildo registry add`
10
+ * writes) and that no `unprovidedNeeds` entry of the integration plan names.
11
+ *
12
+ * Why an advisory: a coding run produces a WORKING result and acceptance is the commit
13
+ * (`application-creation-directive.md`). The directory may be the start of a legitimate need nobody recorded yet, and the
14
+ * remedy (record the need, install the registry module instead, or remove the package) is a person's or a judge's. So it
15
+ * rides on the run's recorded scope assessment, which the run's reviewer and the `dispatch-outcome-sound` judge read.
16
+ *
17
+ * What counts as NEW: a directory the run added files to (`added` / `untracked`, clean at the baseline, written by this
18
+ * run rather than another writer), in which it changed no file that existed (`modified`, `deleted`, `renamed` mean the
19
+ * directory was already there), and which held no committed file at the run's baseline commit (`git ls-tree`), so an
20
+ * earlier-authored package the run only adds a file to is not new either. So an edit to an installed or earlier-authored
21
+ * provider is never flagged here: what an earlier run authored was reported on that run.
22
+ */
23
+ import { execFile } from 'node:child_process';
24
+ import { promisify } from 'node:util';
25
+ import { DEFAULT_REGISTRY_SECTION_SCHEMAS, readWildoSaasLock } from '@wildo-ai/platform-config-lib';
26
+ import { APPLICATION_SPECIFICATION_SEMANTIC_SCHEMA_BINDINGS } from '@wildo-ai/application-creation-runtime';
27
+ import { ApplicationSpecificationFamily, IntegrationPlanSchema } from '@wildo-ai/saas-specifications/application-creation';
28
+ import { loadSpecificationFamilyData } from '../../core/context/specification-family-data.companion.js';
29
+ import { ChangeSetFileChangeKind, isAttributedToAnotherWriter } from '../models/coding-agent-dispatch.models.js';
30
+ const execFileAsync = promisify(execFile);
31
+ /** Where an application keeps its provider packages: installed modules and authored ones alike (`providers/<ref>/`). */
32
+ export const APPLICATION_PROVIDER_PACKAGES_DIRECTORY = 'providers';
33
+ const NEW_FILE_KINDS = new Set([ChangeSetFileChangeKind.ADDED, ChangeSetFileChangeKind.UNTRACKED]);
34
+ /** The provider ref a path sits under (`providers/<ref>/…`), or `undefined` for any other path. */
35
+ function providerRefOf(path) {
36
+ const segments = path.replace(/\\/gu, '/').replace(/^\.\//u, '').split('/');
37
+ return segments.length >= 3 && segments[0] === APPLICATION_PROVIDER_PACKAGES_DIRECTORY && segments[1] !== '' ? segments[1] : undefined;
38
+ }
39
+ /**
40
+ * The provider directories the run CREATED, by ref, with the paths it wrote there. Pure over the change set; see the
41
+ * module's JSDoc for what counts as new.
42
+ */
43
+ export function findProviderDirectoriesCreatedByRun(files) {
44
+ const created = new Map();
45
+ const preExisting = new Set();
46
+ for (const entry of files) {
47
+ if (isAttributedToAnotherWriter(entry.attribution))
48
+ continue;
49
+ const ref = providerRefOf(entry.path);
50
+ if (ref === undefined)
51
+ continue;
52
+ if (NEW_FILE_KINDS.has(entry.changeKind) && !entry.dirtyAtBaseline) {
53
+ created.set(ref, [...(created.get(ref) ?? []), entry.path]);
54
+ }
55
+ else {
56
+ preExisting.add(ref);
57
+ }
58
+ }
59
+ for (const ref of preExisting)
60
+ created.delete(ref);
61
+ return created;
62
+ }
63
+ /** The refs the lock records as installed module directories: the module ids and the files each entry lists. */
64
+ export function installedProviderRefsFromLockModules(installed) {
65
+ const refs = new Set();
66
+ for (const entry of Object.values(installed)) {
67
+ // The module id is the directory (`providers/asana`), and every file the install wrote sits under it.
68
+ const [root, moduleRef] = entry.moduleId.split('/');
69
+ if (root === APPLICATION_PROVIDER_PACKAGES_DIRECTORY && moduleRef !== undefined && moduleRef !== '')
70
+ refs.add(moduleRef);
71
+ for (const path of entry.files) {
72
+ const ref = providerRefOf(path);
73
+ if (ref !== undefined)
74
+ refs.add(ref);
75
+ }
76
+ }
77
+ return refs;
78
+ }
79
+ /** The created directories neither recorded as installed nor named by a recorded unprovided need. Pure. */
80
+ export function selectUnrecordedProviderDirectories(input) {
81
+ return [...input.created.entries()]
82
+ .filter(([ref]) => !input.installedRefs.has(ref) && !input.unprovidedNeedRefs.has(ref))
83
+ .sort(([left], [right]) => left.localeCompare(right))
84
+ .map(([ref, paths]) => ({
85
+ providerRef: ref,
86
+ directory: `${APPLICATION_PROVIDER_PACKAGES_DIRECTORY}/${ref}/`,
87
+ paths: [...paths].sort(),
88
+ advisory: `The run created ${APPLICATION_PROVIDER_PACKAGES_DIRECTORY}/${ref}/, a provider package no installed module accounts for `
89
+ + `and no unprovidedNeeds entry of the integration plan names. A provider is authored only for a need nothing the framework `
90
+ + `has fills, recorded with why (#3992): record that need, install the registry module that fills it instead, or remove the package.`,
91
+ }));
92
+ }
93
+ /** Whether `providers/<ref>/` held a committed file at `commit`, read with `git ls-tree` from the application root. */
94
+ async function providerDirectoryCommittedAt(applicationRoot, commit, providerRef) {
95
+ const { stdout } = await execFileAsync('git', ['-C', applicationRoot, 'ls-tree', '--name-only', commit, '--', `${APPLICATION_PROVIDER_PACKAGES_DIRECTORY}/${providerRef}/`]);
96
+ return stdout.trim() !== '';
97
+ }
98
+ /**
99
+ * The advisory for a settled run's change set: reads the baseline commit and the lock and, only when the run created a
100
+ * provider directory neither accounts for, the integration plan. `undefined` when any of them could not be read, since an
101
+ * advisory that may be false is not one; an ABSENT plan reads as no recorded need, which is the case this exists for.
102
+ */
103
+ export async function readUnrecordedProviderDirectories(companionContext, changeSet) {
104
+ const createdByRun = findProviderDirectoriesCreatedByRun(changeSet.files);
105
+ if (createdByRun.size === 0)
106
+ return [];
107
+ // A directory with a committed file at the baseline existed before the run, whatever the run added to it.
108
+ const created = new Map();
109
+ for (const [ref, paths] of createdByRun) {
110
+ if (!(await providerDirectoryCommittedAt(companionContext.saasRoot, changeSet.baselineHeadSha, ref)))
111
+ created.set(ref, paths);
112
+ }
113
+ if (created.size === 0)
114
+ return [];
115
+ const envelope = await readWildoSaasLock({ saasRoot: companionContext.saasRoot, sectionSchemas: DEFAULT_REGISTRY_SECTION_SCHEMAS, createIfMissing: true });
116
+ const modules = envelope.sections.modules;
117
+ const installedRefs = installedProviderRefsFromLockModules(modules?.installed ?? {});
118
+ if ([...created.keys()].every((ref) => installedRefs.has(ref)))
119
+ return [];
120
+ const binding = APPLICATION_SPECIFICATION_SEMANTIC_SCHEMA_BINDINGS.find((entry) => entry.family === ApplicationSpecificationFamily.INTEGRATION_PLAN);
121
+ let unprovidedNeedRefs = new Set();
122
+ if (binding?.companionExportsField !== undefined && companionContext.resolvedSpecifications != null) {
123
+ const exports = await loadSpecificationFamilyData(companionContext);
124
+ const plan = exports[binding.companionExportsField];
125
+ if (plan !== undefined) {
126
+ const parsed = IntegrationPlanSchema.safeParse(plan);
127
+ if (!parsed.success)
128
+ return undefined;
129
+ unprovidedNeedRefs = new Set(parsed.data.unprovidedNeeds.map((need) => need.providerRef));
130
+ }
131
+ }
132
+ return selectUnrecordedProviderDirectories({ created, installedRefs, unprovidedNeedRefs });
133
+ }
134
+ //# sourceMappingURL=unrecorded-provider-directories.companion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unrecorded-provider-directories.companion.js","sourceRoot":"","sources":["../../../../src/claude-cli/services/unrecorded-provider-directories.companion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,gCAAgC,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACpG,OAAO,EAAE,kDAAkD,EAAE,MAAM,wCAAwC,CAAC;AAC5G,OAAO,EAAE,8BAA8B,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAG3H,OAAO,EAAE,2BAA2B,EAAE,MAAM,wDAAwD,CAAC;AACrG,OAAO,EAAE,uBAAuB,EAAE,2BAA2B,EAAwD,MAAM,wCAAwC,CAAC;AAEpK,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,wHAAwH;AACxH,MAAM,CAAC,MAAM,uCAAuC,GAAG,WAAW,CAAC;AAYnE,MAAM,cAAc,GAAyC,IAAI,GAAG,CAAC,CAAC,uBAAuB,CAAC,KAAK,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAC,CAAC;AAEzI,mGAAmG;AACnG,SAAS,aAAa,CAAC,IAAY;IACjC,MAAM,QAAQ,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","sourcesContent":["/**\n * A provider a coding run AUTHORED that nothing decided to author (#3995 item 2): an ADVISORY on the run's result, never a\n * refusal.\n *\n * App creation uses the providers the framework already has, and authors a new one only for a need the integration plan\n * records with its reason (#3992, Paul 2026-11-16). The worker contract tells the agent so, and the build decomposition\n * emits an authoring task only for such a need. Neither stops an agent from writing `providers/<ref>/` anyway, and nothing\n * looked afterwards. This is the look: a NEW `providers/<ref>/` directory the run wrote, that the lock does not record as\n * an installed module (`.wildo-saas/wildo-saas.lock.json` → `sections.modules.installed`, what `wildo registry add`\n * writes) and that no `unprovidedNeeds` entry of the integration plan names.\n *\n * Why an advisory: a coding run produces a WORKING result and acceptance is the commit\n * (`application-creation-directive.md`). The directory may be the start of a legitimate need nobody recorded yet, and the\n * remedy (record the need, install the registry module instead, or remove the package) is a person's or a judge's. So it\n * rides on the run's recorded scope assessment, which the run's reviewer and the `dispatch-outcome-sound` judge read.\n *\n * What counts as NEW: a directory the run added files to (`added` / `untracked`, clean at the baseline, written by this\n * run rather than another writer), in which it changed no file that existed (`modified`, `deleted`, `renamed` mean the\n * directory was already there), and which held no committed file at the run's baseline commit (`git ls-tree`), so an\n * earlier-authored package the run only adds a file to is not new either. So an edit to an installed or earlier-authored\n * provider is never flagged here: what an earlier run authored was reported on that run.\n */\nimport { execFile } from 'node:child_process';\nimport { promisify } from 'node:util';\n\nimport { DEFAULT_REGISTRY_SECTION_SCHEMAS, readWildoSaasLock } from '@wildo-ai/platform-config-lib';\nimport { APPLICATION_SPECIFICATION_SEMANTIC_SCHEMA_BINDINGS } from '@wildo-ai/application-creation-runtime';\nimport { ApplicationSpecificationFamily, IntegrationPlanSchema } from '@wildo-ai/saas-specifications/application-creation';\n\nimport type { CompanionContext } from '../../core/context/companion-context';\nimport { loadSpecificationFamilyData } from '../../core/context/specification-family-data.companion';\nimport { ChangeSetFileChangeKind, isAttributedToAnotherWriter, type GitChangeSetCapture, type GitChangeSetFileEntry } from '../models/coding-agent-dispatch.models';\n\nconst execFileAsync = promisify(execFile);\n\n/** Where an application keeps its provider packages: installed modules and authored ones alike (`providers/<ref>/`). */\nexport const APPLICATION_PROVIDER_PACKAGES_DIRECTORY = 'providers';\n\n/** One provider directory the run created that neither the lock nor the integration plan accounts for. */\nexport interface UnrecordedProviderDirectory {\n readonly providerRef: string;\n /** Application-relative, with its trailing slash: `providers/<ref>/`. */\n readonly directory: string;\n /** What the run wrote there, application-relative. */\n readonly paths: readonly string[];\n readonly advisory: string;\n}\n\nconst NEW_FILE_KINDS: ReadonlySet<ChangeSetFileChangeKind> = new Set([ChangeSetFileChangeKind.ADDED, ChangeSetFileChangeKind.UNTRACKED]);\n\n/** The provider ref a path sits under (`providers/<ref>/…`), or `undefined` for any other path. */\nfunction providerRefOf(path: string): string | undefined {\n const segments = path.replace(/\\\\/gu, '/').replace(/^\\.\\//u, '').split('/');\n return segments.length >= 3 && segments[0] === APPLICATION_PROVIDER_PACKAGES_DIRECTORY && segments[1] !== '' ? segments[1] : undefined;\n}\n\n/**\n * The provider directories the run CREATED, by ref, with the paths it wrote there. Pure over the change set; see the\n * module's JSDoc for what counts as new.\n */\nexport function findProviderDirectoriesCreatedByRun(files: readonly GitChangeSetFileEntry[]): ReadonlyMap<string, readonly string[]> {\n const created = new Map<string, string[]>();\n const preExisting = new Set<string>();\n for (const entry of files) {\n if (isAttributedToAnotherWriter(entry.attribution)) continue;\n const ref = providerRefOf(entry.path);\n if (ref === undefined) continue;\n if (NEW_FILE_KINDS.has(entry.changeKind) && !entry.dirtyAtBaseline) {\n created.set(ref, [...(created.get(ref) ?? []), entry.path]);\n } else {\n preExisting.add(ref);\n }\n }\n for (const ref of preExisting) created.delete(ref);\n return created;\n}\n\n/** The refs the lock records as installed module directories: the module ids and the files each entry lists. */\nexport function installedProviderRefsFromLockModules(installed: Readonly<Record<string, { readonly moduleId: string; readonly files: readonly string[] }>>): ReadonlySet<string> {\n const refs = new Set<string>();\n for (const entry of Object.values(installed)) {\n // The module id is the directory (`providers/asana`), and every file the install wrote sits under it.\n const [root, moduleRef] = entry.moduleId.split('/');\n if (root === APPLICATION_PROVIDER_PACKAGES_DIRECTORY && moduleRef !== undefined && moduleRef !== '') refs.add(moduleRef);\n for (const path of entry.files) {\n const ref = providerRefOf(path);\n if (ref !== undefined) refs.add(ref);\n }\n }\n return refs;\n}\n\n/** The created directories neither recorded as installed nor named by a recorded unprovided need. Pure. */\nexport function selectUnrecordedProviderDirectories(input: {\n readonly created: ReadonlyMap<string, readonly string[]>;\n readonly installedRefs: ReadonlySet<string>;\n readonly unprovidedNeedRefs: ReadonlySet<string>;\n}): UnrecordedProviderDirectory[] {\n return [...input.created.entries()]\n .filter(([ref]) => !input.installedRefs.has(ref) && !input.unprovidedNeedRefs.has(ref))\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([ref, paths]) => ({\n providerRef: ref,\n directory: `${APPLICATION_PROVIDER_PACKAGES_DIRECTORY}/${ref}/`,\n paths: [...paths].sort(),\n advisory: `The run created ${APPLICATION_PROVIDER_PACKAGES_DIRECTORY}/${ref}/, a provider package no installed module accounts for `\n + `and no unprovidedNeeds entry of the integration plan names. A provider is authored only for a need nothing the framework `\n + `has fills, recorded with why (#3992): record that need, install the registry module that fills it instead, or remove the package.`,\n }));\n}\n\n/** Whether `providers/<ref>/` held a committed file at `commit`, read with `git ls-tree` from the application root. */\nasync function providerDirectoryCommittedAt(applicationRoot: string, commit: string, providerRef: string): Promise<boolean> {\n const { stdout } = await execFileAsync('git', ['-C', applicationRoot, 'ls-tree', '--name-only', commit, '--', `${APPLICATION_PROVIDER_PACKAGES_DIRECTORY}/${providerRef}/`]);\n return stdout.trim() !== '';\n}\n\n/**\n * The advisory for a settled run's change set: reads the baseline commit and the lock and, only when the run created a\n * provider directory neither accounts for, the integration plan. `undefined` when any of them could not be read, since an\n * advisory that may be false is not one; an ABSENT plan reads as no recorded need, which is the case this exists for.\n */\nexport async function readUnrecordedProviderDirectories(\n companionContext: CompanionContext,\n changeSet: Pick<GitChangeSetCapture, 'files' | 'baselineHeadSha'>,\n): Promise<readonly UnrecordedProviderDirectory[] | undefined> {\n const createdByRun = findProviderDirectoriesCreatedByRun(changeSet.files);\n if (createdByRun.size === 0) return [];\n // A directory with a committed file at the baseline existed before the run, whatever the run added to it.\n const created = new Map<string, readonly string[]>();\n for (const [ref, paths] of createdByRun) {\n if (!(await providerDirectoryCommittedAt(companionContext.saasRoot, changeSet.baselineHeadSha, ref))) created.set(ref, paths);\n }\n if (created.size === 0) return [];\n const envelope = await readWildoSaasLock({ saasRoot: companionContext.saasRoot, sectionSchemas: DEFAULT_REGISTRY_SECTION_SCHEMAS, createIfMissing: true });\n const modules = envelope.sections.modules as { installed?: Record<string, { moduleId: string; files: string[] }> } | undefined;\n const installedRefs = installedProviderRefsFromLockModules(modules?.installed ?? {});\n if ([...created.keys()].every((ref) => installedRefs.has(ref))) return [];\n const binding = APPLICATION_SPECIFICATION_SEMANTIC_SCHEMA_BINDINGS.find((entry) => entry.family === ApplicationSpecificationFamily.INTEGRATION_PLAN);\n let unprovidedNeedRefs: ReadonlySet<string> = new Set();\n if (binding?.companionExportsField !== undefined && companionContext.resolvedSpecifications != null) {\n const exports = await loadSpecificationFamilyData(companionContext) as unknown as Record<string, unknown>;\n const plan = exports[binding.companionExportsField];\n if (plan !== undefined) {\n const parsed = IntegrationPlanSchema.safeParse(plan);\n if (!parsed.success) return undefined;\n unprovidedNeedRefs = new Set(parsed.data.unprovidedNeeds.map((need) => need.providerRef));\n }\n }\n return selectUnrecordedProviderDirectories({ created, installedRefs, unprovidedNeedRefs });\n}\n"]}
@@ -1,7 +1,8 @@
1
1
  import type { LoggerService } from '@wildo-ai/saas-backend-lib';
2
- import type { CompanionArtifactPlacementDescriptor, CompanionEmailTemplateOwnershipDescriptor, CompanionResourceOwnershipDescriptor } from '@wildo-ai/saas-models/companion';
2
+ import type { CompanionArtifactPlacementDescriptor, CompanionResourceOwnershipDescriptor } from '@wildo-ai/saas-models/companion';
3
3
  import type { CompanionContext } from '../../context/companion-context';
4
4
  import { CompanionIntrospectionService } from './companion-introspection.companion.service';
5
+ import type { EmailTemplateOwnershipPlacement } from '../../../email/utils/email-template-fs-discovery.utils';
5
6
  interface SharedTranslationPlacementInfo {
6
7
  carrierServiceKey: string;
7
8
  moduleIds: string[];
@@ -15,7 +16,7 @@ interface FrontendTranslationPlacementInfo {
15
16
  }
16
17
  interface BackendEmailPlacementInfo {
17
18
  serviceKey: string;
18
- emailTemplateOwnership: CompanionEmailTemplateOwnershipDescriptor[];
19
+ emailTemplateOwnership: EmailTemplateOwnershipPlacement[];
19
20
  }
20
21
  export interface TranslationPlacementSnapshot {
21
22
  declaredModuleIds: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"translation-placement.companion.service.d.ts","sourceRoot":"","sources":["../../../../../src/core/introspection/services/translation-placement.companion.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,KAAK,EACV,oCAAoC,EACpC,yCAAyC,EACzC,oCAAoC,EACrC,MAAM,iCAAiC,CAAC;AAGzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAG5F,UAAU,8BAA8B;IACtC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,qBAAqB,EAAE,MAAM,EAAE,CAAC;IAChC,kBAAkB,EAAE,oCAAoC,EAAE,CAAC;IAC3D,iBAAiB,EAAE,oCAAoC,EAAE,CAAC;CAC3D;AAED,UAAU,gCAAgC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,kBAAkB,EAAE,oCAAoC,EAAE,CAAC;CAC5D;AAED,UAAU,yBAAyB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,sBAAsB,EAAE,yCAAyC,EAAE,CAAC;CACrE;AAED,MAAM,WAAW,4BAA4B;IAC3C,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAC5B,MAAM,EAAE,8BAA8B,GAAG,IAAI,CAAC;IAC9C,QAAQ,EAAE,gCAAgC,EAAE,CAAC;IAC7C,YAAY,EAAE,yBAAyB,EAAE,CAAC;IAC1C,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,mCAAmC;IAClD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,qBACa,oCAAoC;IAIV,OAAO,CAAC,QAAQ,CAAC,MAAM;IACR,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IAEnF,OAAO,CAAC,QAAQ,CAAC,6BAA6B;IANhD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA+D;gBAGlC,MAAM,EAAE,aAAa,EACN,gBAAgB,EAAE,gBAAgB,EAEpF,6BAA6B,EAAE,6BAA6B;IAMlE,oBAAoB,CAC/B,OAAO,GAAE,mCAAwC,GAChD,OAAO,CAAC,4BAA4B,CAAC;IAgDxC,OAAO,CAAC,2BAA2B;YAgBrB,mBAAmB;YAwBnB,qBAAqB;YAkBrB,yBAAyB;YAkBzB,mBAAmB;CA0BlC"}
1
+ {"version":3,"file":"translation-placement.companion.service.d.ts","sourceRoot":"","sources":["../../../../../src/core/introspection/services/translation-placement.companion.service.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,KAAK,EACV,oCAAoC,EACpC,oCAAoC,EACrC,MAAM,iCAAiC,CAAC;AAGzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAG5F,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,wDAAwD,CAAC;AAE9G,UAAU,8BAA8B;IACtC,iBAAiB,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,"file":"translation-placement.companion.service.js","sourceRoot":"","sources":["../../../../../src/core/introspection/services/translation-placement.companion.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAG,mBAAmB,EAAC,MAAM,4BAA4B,CAAC;AAOrF,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAE5E,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAoCrF,IAAM,oCAAoC,GAA1C,MAAM,oCAAoC;IAIO;IACe;IAElD;IANF,QAAQ,CAA+D;IAExF,YACsD,MAAqB,EACN,gBAAkC,EAEpF,6BAA4D;QAHzB,WAAM,GAAN,MAAM,CAAe;QACN,qBAAgB,GAAhB,gBAAgB,CAAkB;QAEpF,kCAA6B,GAA7B,6BAA6B,CAA+B;QAE7E,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,sCAAsC,CAAC,CAAC;QAChF,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,sCAAsC,EAAE,IAAI,CAAC,CAAC;IAChF,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAC/B,UAA+C,EAAE;QAEjD,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,IAAI,CAAC;QACpD,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,IAAI,CAAC;QACxD,MAAM,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,IAAI,IAAI,CAAC;QAChE,MAAM,cAAc,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QAC3E,MAAM,kBAAkB,GAAG,cAAc;aACtC,MAAM,CAAC,CAAC,CAAC,EA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ACf,MAAM,OAAO,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;YAC3C,QAAQ,CAAC,IAAI,CAAC,GAAG,UAAU,IAAI,QAAQ,YAAY,OAAO,EAAE,CAAC,CAAC;YAC9D,IAAI,CAAC,QAAQ,CAAC,mCAAmC,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;YACtF,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF,CAAA;AArKY,oCAAoC;IADhD,UAAU,EAAE;IAKR,WAAA,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAA;IACjC,WAAA,MAAM,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,CAAA;IAChD,WAAA,MAAM,CAAC,uBAAuB,CAAC,oBAAoB,CAAC,CAAA;uDACL,6BAA6B;GAPpE,oCAAoC,CAqKhD","sourcesContent":["import { inject, injectable } from 'inversify';\nimport { AppFrontendType } from '@wildo-ai/platform-config-lib';\nimport type { LoggerService } from '@wildo-ai/saas-backend-lib';\nimport { SAAS_SERVICE_TYPES , describeCaughtError} from '@wildo-ai/saas-backend-lib';\nimport type {\n CompanionArtifactPlacementDescriptor,\n CompanionEmailTemplateOwnershipDescriptor,\n CompanionResourceOwnershipDescriptor,\n} from '@wildo-ai/saas-models/companion';\nimport { CompanionArtifactClass } from '@wildo-ai/saas-models/companion';\nimport { COMPANION_SERVICE_TYPES } from '../../inject/models/service-types';\nimport type { CompanionContext } from '../../context/companion-context';\nimport { CompanionIntrospectionService } from './companion-introspection.companion.service';\nimport type { CompanionIntrospectionBehaviorId } from '../models/companion-introspection.models';\n\ninterface SharedTranslationPlacementInfo {\n carrierServiceKey: string;\n moduleIds: string[];\n contributionModuleIds: string[];\n artifactPlacements: CompanionArtifactPlacementDescriptor[];\n resourceOwnership: CompanionResourceOwnershipDescriptor[];\n}\n\ninterface FrontendTranslationPlacementInfo {\n serviceKey: string;\n artifactPlacements: CompanionArtifactPlacementDescriptor[];\n}\n\ninterface BackendEmailPlacementInfo {\n serviceKey: string;\n emailTemplateOwnership: CompanionEmailTemplateOwnershipDescriptor[];\n}\n\nexport interface TranslationPlacementSnapshot {\n declaredModuleIds: string[];\n shared: SharedTranslationPlacementInfo | null;\n frontend: FrontendTranslationPlacementInfo[];\n backendEmail: BackendEmailPlacementInfo[];\n warnings: string[];\n}\n\nexport interface TranslationPlacementSnapshotOptions {\n includeShared?: boolean;\n includeFrontend?: boolean;\n includeBackendEmail?: boolean;\n}\n\n@injectable()\nexport class TranslationPlacementCompanionService {\n private readonly logDebug: (message: string, context?: Record<string, unknown>) => void;\n\n constructor(\n @inject(SAAS_SERVICE_TYPES.Logger) private readonly logger: LoggerService,\n @inject(COMPANION_SERVICE_TYPES.CompanionContext) private readonly companionContext: CompanionContext,\n @inject(COMPANION_SERVICE_TYPES.IntrospectionService)\n private readonly companionIntrospectionService: CompanionIntrospectionService,\n ) {\n this.logDebug = this.logger.debugByType('TranslationPlacementCompanionService');\n this.logger.setDebugTypeLogging('TranslationPlacementCompanionService', true);\n }\n\n public async getPlacementSnapshot(\n options: TranslationPlacementSnapshotOptions = {},\n ): Promise<TranslationPlacementSnapshot> {\n const warnings: string[] = [];\n const includeShared = options.includeShared ?? true;\n const includeFrontend = options.includeFrontend ?? true;\n const includeBackendEmail = options.includeBackendEmail ?? true;\n const serviceEntries = Object.entries(this.companionContext.servicesByKey);\n const backendServiceKeys = serviceEntries\n .filter(([, service]) => !service.frontendType)\n .map(([serviceKey]) => serviceKey);\n const frontendServiceKeys = serviceEntries\n .filter(([, service]) => service.frontendType === AppFrontendType.SAAS_APP)\n .map(([serviceKey]) => serviceKey);\n\n const sharedCarrierServiceKey = includeShared\n ? this.pickSharedCarrierServiceKey(\n backendServiceKeys,\n frontendServiceKeys,\n )\n : null;\n const shared = sharedCarrierServiceKey\n ? await this.loadSharedPlacement(sharedCarrierServiceKey, warnings)\n : null;\n\n const frontend = includeFrontend\n ? (\n await Promise.all(\n frontendServiceKeys.map((serviceKey) => this.loadFrontendPlacement(serviceKey, warnings)),\n )\n ).filter((entry): entry is FrontendTranslationPlacementInfo => entry !== null)\n : [];\n\n const backendEmail = includeBackendEmail\n ? (\n await Promise.all(\n backendServiceKeys.map((serviceKey) => this.loadBackendEmailPlacement(serviceKey, warnings)),\n )\n ).filter((entry): entry is BackendEmailPlacementInfo => entry !== null)\n : [];\n\n return {\n declaredModuleIds: this.companionContext.moduleIds,\n shared,\n frontend,\n backendEmail,\n warnings,\n };\n }\n\n private pickSharedCarrierServiceKey(\n backendServiceKeys: string[],\n frontendServiceKeys: string[],\n ): string | null {\n const candidates = [...backendServiceKeys, ...frontendServiceKeys];\n if (candidates.length === 0) {\n return null;\n }\n\n return [...candidates].sort((left, right) => {\n const leftCount = this.companionContext.moduleIdsByService[left]?.length ?? 0;\n const rightCount = this.companionContext.moduleIdsByService[right]?.length ?? 0;\n return rightCount - leftCount;\n })[0] ?? null;\n }\n\n private async loadSharedPlacement(\n serviceKey: string,\n warnings: string[],\n ): Promise<SharedTranslationPlacementInfo | null> {\n const data = await this.requestBehaviorData<{\n moduleIds?: string[];\n contributionModuleIds?: string[];\n artifactPlacements?: CompanionArtifactPlacementDescriptor[];\n resourceOwnership?: CompanionResourceOwnershipDescriptor[];\n }>(serviceKey, 'translation-needed-info', warnings);\n\n if (!data) {\n return null;\n }\n\n return {\n carrierServiceKey: serviceKey,\n moduleIds: data.moduleIds ?? [],\n contributionModuleIds: data.contributionModuleIds ?? [],\n artifactPlacements: data.artifactPlacements ?? [],\n resourceOwnership: data.resourceOwnership ?? [],\n };\n }\n\n private async loadFrontendPlacement(\n serviceKey: string,\n warnings: string[],\n ): Promise<FrontendTranslationPlacementInfo | null> {\n const data = await this.requestBehaviorData<{\n artifactPlacements?: CompanionArtifactPlacementDescriptor[];\n }>(serviceKey, 'frontend-artifact-placement-info', warnings);\n\n if (!data) {\n return null;\n }\n\n return {\n serviceKey,\n artifactPlacements: data.artifactPlacements ?? [],\n };\n }\n\n private async loadBackendEmailPlacement(\n serviceKey: string,\n warnings: string[],\n ): Promise<BackendEmailPlacementInfo | null> {\n const data = await this.requestBehaviorData<{\n emailTemplateOwnership?: CompanionEmailTemplateOwnershipDescriptor[];\n }>(serviceKey, 'email-template-placement-info', warnings);\n\n if (!data) {\n return null;\n }\n\n return {\n serviceKey,\n emailTemplateOwnership: data.emailTemplateOwnership ?? [],\n };\n }\n\n private async requestBehaviorData<T>(\n serviceKey: string,\n behavior: CompanionIntrospectionBehaviorId,\n warnings: string[],\n ): Promise<T | null> {\n try {\n const result = await this.companionIntrospectionService.requestInfo({\n serviceKey,\n behavior,\n });\n\n if (!result.success && 'error' in result) {\n warnings.push(\n `${serviceKey}:${behavior} failed: ${result.error.message}`,\n );\n return null;\n }\n\n return (result.data ?? null) as T | null;\n } catch (error) {\n const message = describeCaughtError(error);\n warnings.push(`${serviceKey}:${behavior} failed: ${message}`);\n this.logDebug('Placement behavior request failed', { serviceKey, behavior, message });\n return null;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"translation-placement.companion.service.js","sourceRoot":"","sources":["../../../../../src/core/introspection/services/translation-placement.companion.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAE,kBAAkB,EAAG,mBAAmB,EAAC,MAAM,4BAA4B,CAAC;AAMrF,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAE5E,OAAO,EAAE,6BAA6B,EAAE,MAAM,6CAA6C,CAAC;AAsCrF,IAAM,oCAAoC,GAA1C,MAAM,oCAAoC;IAIO;IACe;IAElD;IANF,QAAQ,CAA+D;IAExF,YACsD,MAAqB,EACN,gBAAkC,EAEpF,6BAA4D;QAHzB,WAAM,GAAN,MAAM,CAAe;QACN,qBAAgB,GAAhB,gBAAgB,CAAkB;QAEpF,kCAA6B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ai/platform-config-lib';\nimport type { LoggerService } from '@wildo-ai/saas-backend-lib';\nimport { SAAS_SERVICE_TYPES , describeCaughtError} from '@wildo-ai/saas-backend-lib';\nimport type {\n CompanionArtifactPlacementDescriptor,\n CompanionResourceOwnershipDescriptor,\n} from '@wildo-ai/saas-models/companion';\nimport { CompanionArtifactClass } from '@wildo-ai/saas-models/companion';\nimport { COMPANION_SERVICE_TYPES } from '../../inject/models/service-types';\nimport type { CompanionContext } from '../../context/companion-context';\nimport { CompanionIntrospectionService } from './companion-introspection.companion.service';\nimport type { CompanionIntrospectionBehaviorId } from '../models/companion-introspection.models';\n// The owner as the placement introspection reports it, a business module's email layout included (#3904).\nimport type { EmailTemplateOwnershipPlacement } from '../../../email/utils/email-template-fs-discovery.utils';\n\ninterface SharedTranslationPlacementInfo {\n carrierServiceKey: string;\n moduleIds: string[];\n contributionModuleIds: string[];\n artifactPlacements: CompanionArtifactPlacementDescriptor[];\n resourceOwnership: CompanionResourceOwnershipDescriptor[];\n}\n\ninterface FrontendTranslationPlacementInfo {\n serviceKey: string;\n artifactPlacements: CompanionArtifactPlacementDescriptor[];\n}\n\ninterface BackendEmailPlacementInfo {\n serviceKey: string;\n emailTemplateOwnership: EmailTemplateOwnershipPlacement[];\n}\n\nexport interface TranslationPlacementSnapshot {\n declaredModuleIds: string[];\n shared: SharedTranslationPlacementInfo | null;\n frontend: FrontendTranslationPlacementInfo[];\n backendEmail: BackendEmailPlacementInfo[];\n warnings: string[];\n}\n\nexport interface TranslationPlacementSnapshotOptions {\n includeShared?: boolean;\n includeFrontend?: boolean;\n includeBackendEmail?: boolean;\n}\n\n@injectable()\nexport class TranslationPlacementCompanionService {\n private readonly logDebug: (message: string, context?: Record<string, unknown>) => void;\n\n constructor(\n @inject(SAAS_SERVICE_TYPES.Logger) private readonly logger: LoggerService,\n @inject(COMPANION_SERVICE_TYPES.CompanionContext) private readonly companionContext: CompanionContext,\n @inject(COMPANION_SERVICE_TYPES.IntrospectionService)\n private readonly companionIntrospectionService: CompanionIntrospectionService,\n ) {\n this.logDebug = this.logger.debugByType('TranslationPlacementCompanionService');\n this.logger.setDebugTypeLogging('TranslationPlacementCompanionService', true);\n }\n\n public async getPlacementSnapshot(\n options: TranslationPlacementSnapshotOptions = {},\n ): Promise<TranslationPlacementSnapshot> {\n const warnings: string[] = [];\n const includeShared = options.includeShared ?? true;\n const includeFrontend = options.includeFrontend ?? true;\n const includeBackendEmail = options.includeBackendEmail ?? true;\n const serviceEntries = Object.entries(this.companionContext.servicesByKey);\n const backendServiceKeys = serviceEntries\n .filter(([, service]) => !service.frontendType)\n .map(([serviceKey]) => serviceKey);\n const frontendServiceKeys = serviceEntries\n .filter(([, service]) => service.frontendType === AppFrontendType.SAAS_APP)\n .map(([serviceKey]) => serviceKey);\n\n const sharedCarrierServiceKey = includeShared\n ? this.pickSharedCarrierServiceKey(\n backendServiceKeys,\n frontendServiceKeys,\n )\n : null;\n const shared = sharedCarrierServiceKey\n ? await this.loadSharedPlacement(sharedCarrierServiceKey, warnings)\n : null;\n\n const frontend = includeFrontend\n ? (\n await Promise.all(\n frontendServiceKeys.map((serviceKey) => this.loadFrontendPlacement(serviceKey, warnings)),\n )\n ).filter((entry): entry is FrontendTranslationPlacementInfo => entry !== null)\n : [];\n\n const backendEmail = includeBackendEmail\n ? (\n await Promise.all(\n backendServiceKeys.map((serviceKey) => this.loadBackendEmailPlacement(serviceKey, warnings)),\n )\n ).filter((entry): entry is BackendEmailPlacementInfo => entry !== null)\n : [];\n\n return {\n declaredModuleIds: this.companionContext.moduleIds,\n shared,\n frontend,\n backendEmail,\n warnings,\n };\n }\n\n private pickSharedCarrierServiceKey(\n backendServiceKeys: string[],\n frontendServiceKeys: string[],\n ): string | null {\n const candidates = [...backendServiceKeys, ...frontendServiceKeys];\n if (candidates.length === 0) {\n return null;\n }\n\n return [...candidates].sort((left, right) => {\n const leftCount = this.companionContext.moduleIdsByService[left]?.length ?? 0;\n const rightCount = this.companionContext.moduleIdsByService[right]?.length ?? 0;\n return rightCount - leftCount;\n })[0] ?? null;\n }\n\n private async loadSharedPlacement(\n serviceKey: string,\n warnings: string[],\n ): Promise<SharedTranslationPlacementInfo | null> {\n const data = await this.requestBehaviorData<{\n moduleIds?: string[];\n contributionModuleIds?: string[];\n artifactPlacements?: CompanionArtifactPlacementDescriptor[];\n resourceOwnership?: CompanionResourceOwnershipDescriptor[];\n }>(serviceKey, 'translation-needed-info', warnings);\n\n if (!data) {\n return null;\n }\n\n return {\n carrierServiceKey: serviceKey,\n moduleIds: data.moduleIds ?? [],\n contributionModuleIds: data.contributionModuleIds ?? [],\n artifactPlacements: data.artifactPlacements ?? [],\n resourceOwnership: data.resourceOwnership ?? [],\n };\n }\n\n private async loadFrontendPlacement(\n serviceKey: string,\n warnings: string[],\n ): Promise<FrontendTranslationPlacementInfo | null> {\n const data = await this.requestBehaviorData<{\n artifactPlacements?: CompanionArtifactPlacementDescriptor[];\n }>(serviceKey, 'frontend-artifact-placement-info', warnings);\n\n if (!data) {\n return null;\n }\n\n return {\n serviceKey,\n artifactPlacements: data.artifactPlacements ?? [],\n };\n }\n\n private async loadBackendEmailPlacement(\n serviceKey: string,\n warnings: string[],\n ): Promise<BackendEmailPlacementInfo | null> {\n const data = await this.requestBehaviorData<{\n emailTemplateOwnership?: EmailTemplateOwnershipPlacement[];\n }>(serviceKey, 'email-template-placement-info', warnings);\n\n if (!data) {\n return null;\n }\n\n return {\n serviceKey,\n emailTemplateOwnership: data.emailTemplateOwnership ?? [],\n };\n }\n\n private async requestBehaviorData<T>(\n serviceKey: string,\n behavior: CompanionIntrospectionBehaviorId,\n warnings: string[],\n ): Promise<T | null> {\n try {\n const result = await this.companionIntrospectionService.requestInfo({\n serviceKey,\n behavior,\n });\n\n if (!result.success && 'error' in result) {\n warnings.push(\n `${serviceKey}:${behavior} failed: ${result.error.message}`,\n );\n return null;\n }\n\n return (result.data ?? null) as T | null;\n } catch (error) {\n const message = describeCaughtError(error);\n warnings.push(`${serviceKey}:${behavior} failed: ${message}`);\n this.logDebug('Placement behavior request failed', { serviceKey, behavior, message });\n return null;\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"companion-introspection-behavior-handlers.d.ts","sourceRoot":"","sources":["../../../../../src/core/introspection/subprocess/companion-introspection-behavior-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAYjG,OAAO,EAGL,gBAAgB,EAMjB,MAAM,uBAAuB,CAAC;AA+E/B,OAAO,EAEL,KAAK,gCAAgC,EACrC,KAAK,kCAAkC,EACvC,KAAK,gDAAgD,EACtD,MAAM,0CAA0C,CAAC;AAGlD,MAAM,WAAW,4CAA4C;IAC3D,OAAO,EAAE,kCAAkC,CAAC;IAC5C,QAAQ,EAAE,gDAAgD,CAAC;IAC3D,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,MAAM,MAAM,qCAAqC,GAAG,CAClD,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,4CAA4C,KAClD,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAmDhC,wBAAgB,6BAA6B,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAMzE;AAED,eAAO,MAAM,iDAAiD,EAAE,OAAO,CACrE,MAAM,CAAC,gCAAgC,EAAE,qCAAqC,CAAC,CAozChF,CAAC;AAwWF;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG;IAC3D,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,KAAK,CAAC;IAChD,yBAAyB,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACzD,CAqCA"}
1
+ {"version":3,"file":"companion-introspection-behavior-handlers.d.ts","sourceRoot":"","sources":["../../../../../src/core/introspection/subprocess/companion-introspection-behavior-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAcjG,OAAO,EAGL,gBAAgB,EAMjB,MAAM,uBAAuB,CAAC;AA+E/B,OAAO,EAEL,KAAK,gCAAgC,EACrC,KAAK,kCAAkC,EACvC,KAAK,gDAAgD,EACtD,MAAM,0CAA0C,CAAC;AAGlD,MAAM,WAAW,4CAA4C;IAC3D,OAAO,EAAE,kCAAkC,CAAC;IAC5C,QAAQ,EAAE,gDAAgD,CAAC;IAC3D,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,MAAM,MAAM,qCAAqC,GAAG,CAClD,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,4CAA4C,KAClD,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAmDhC,wBAAgB,6BAA6B,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAMzE;AAED,eAAO,MAAM,iDAAiD,EAAE,OAAO,CACrE,MAAM,CAAC,gCAAgC,EAAE,qCAAqC,CAAC,CA6zChF,CAAC;AAwWF;;;;;;;GAOG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG;IAC3D,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,GAAG,KAAK,CAAC;IAChD,yBAAyB,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAC;CACzD,CAqCA"}
@@ -2,6 +2,7 @@ import { resolveCompanionContext } from '../../context/companion-context.js';
2
2
  import { answerSpecificationsCompanionData, loadCompleteResourceSpecifications, loadSpecificationsCompanionEvaluation, projectBackendCompanionData, } from '../../context/companion-package-loaders.companion.js';
3
3
  import { projectLabellingResourceSpecifications } from '../../../i18n-labelling/utils/labelling-resource-specification-facts.utils.js';
4
4
  import { basename, relative } from 'node:path';
5
+ import { moduleEmailTemplatePlacement } from '../../../email/utils/module-email-root.companion.utils.js';
5
6
  import { pathToFileURL } from 'node:url';
6
7
  import { generateDesignTokensCssFromSourceConfig } from '@wildo-ai/presets-components-models';
7
8
  import { buildSharedSaaSModulesRegistry, coreResourceShared_FieldIdentifierPriority, CoreResourceType, projectAgentAiUseDeclarations, Resources_SharedUtils, resourceInheritanceVariantSchemas, } from '@wildo-ai/saas-models';
@@ -683,20 +684,29 @@ export const COMPANION_INTROSPECTION_BUILTIN_BEHAVIOR_HANDLERS = {
683
684
  emailTemplateOwnership: backendModules
684
685
  .filter((ownedModule) => Object.keys(ownedModule.emailTemplateDefinitions ?? {}).length > 0
685
686
  || Object.keys(ownedModule.emailComponentLabels ?? {}).length > 0)
686
- .map((ownedModule) => ({
687
- ownerId: ownedModule.moduleId,
688
- artifactClass: ownedModule.kind === 'engine'
689
- ? CompanionArtifactClass.ENGINE
690
- : CompanionArtifactClass.DOMAIN_MODULE,
691
- rootsByRole: {
692
- backend: ownedModule.kind === 'engine'
693
- ? 'backend-api/src/engine/email'
694
- : `backend-api/src/modules/${ownedModule.moduleId}/emails`,
695
- },
696
- templateRefs: Object.keys(ownedModule.emailTemplateDefinitions ?? {}),
697
- // The shared components' words (#2884), planned by the translate lane as one unit per owner.
698
- declaresComponentLabels: Object.keys(ownedModule.emailComponentLabels ?? {}).length > 0,
699
- })),
687
+ .map((ownedModule) => {
688
+ /*
689
+ * A business module's root is where ITS definitions file scans (#3904), `emails/` when nothing scans yet, and
690
+ * its layout says which folder registers which refs, or why that cannot be read: the generation step writes
691
+ * nothing for an undetermined module rather than writing where nothing registers (review F2, F5).
692
+ */
693
+ const modulePlacement = ownedModule.kind === 'engine'
694
+ ? undefined
695
+ : moduleEmailTemplatePlacement({ applicationRoot: context.request.homes.appDeclarationRoot, backendPackageRoot: context.request.packageRoot, moduleId: ownedModule.moduleId });
696
+ return {
697
+ ownerId: ownedModule.moduleId,
698
+ artifactClass: ownedModule.kind === 'engine'
699
+ ? CompanionArtifactClass.ENGINE
700
+ : CompanionArtifactClass.DOMAIN_MODULE,
701
+ rootsByRole: {
702
+ backend: modulePlacement === undefined ? 'backend-api/src/engine/email' : modulePlacement.backend,
703
+ },
704
+ ...(modulePlacement === undefined ? {} : { backendEmailLayout: modulePlacement.layout }),
705
+ templateRefs: Object.keys(ownedModule.emailTemplateDefinitions ?? {}),
706
+ // The shared components' words (#2884), planned by the translate lane as one unit per owner.
707
+ declaresComponentLabels: Object.keys(ownedModule.emailComponentLabels ?? {}).length > 0,
708
+ };
709
+ }),
700
710
  };
701
711
  },
702
712
  'translation-needed-info': async (_input, context) => {