@interf/compiler 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/LICENSE.md +1 -0
  2. package/README.md +10 -7
  3. package/TRADEMARKS.md +4 -4
  4. package/builtin-methods/interf-default/README.md +6 -7
  5. package/builtin-methods/interf-default/method.json +7 -68
  6. package/builtin-methods/interf-default/method.schema.json +52 -50
  7. package/dist/cli/commands/prep.js +58 -2
  8. package/dist/cli/commands/verify.d.ts +2 -0
  9. package/dist/cli/commands/verify.js +17 -8
  10. package/dist/cli/commands/wizard.js +122 -14
  11. package/dist/compiler-ui/404.html +1 -1
  12. package/dist/compiler-ui/__next.__PAGE__.txt +2 -2
  13. package/dist/compiler-ui/__next._full.txt +3 -3
  14. package/dist/compiler-ui/__next._head.txt +1 -1
  15. package/dist/compiler-ui/__next._index.txt +2 -2
  16. package/dist/compiler-ui/__next._tree.txt +2 -2
  17. package/dist/compiler-ui/_next/static/chunks/{13awzu4tooflw.css → 0_c_tvh-cukjz.css} +1 -1
  18. package/dist/compiler-ui/_next/static/chunks/{0jipmpez3_ehh.js → 0f_geuwdesg_c.js} +42 -17
  19. package/dist/compiler-ui/_not-found/__next._full.txt +2 -2
  20. package/dist/compiler-ui/_not-found/__next._head.txt +1 -1
  21. package/dist/compiler-ui/_not-found/__next._index.txt +2 -2
  22. package/dist/compiler-ui/_not-found/__next._not-found.__PAGE__.txt +1 -1
  23. package/dist/compiler-ui/_not-found/__next._not-found.txt +1 -1
  24. package/dist/compiler-ui/_not-found/__next._tree.txt +2 -2
  25. package/dist/compiler-ui/_not-found.html +1 -1
  26. package/dist/compiler-ui/_not-found.txt +2 -2
  27. package/dist/compiler-ui/index.html +1 -1
  28. package/dist/compiler-ui/index.txt +3 -3
  29. package/dist/packages/contracts/index.d.ts +2 -2
  30. package/dist/packages/contracts/index.js +1 -1
  31. package/dist/packages/contracts/lib/schema.d.ts +271 -72
  32. package/dist/packages/contracts/lib/schema.js +243 -83
  33. package/dist/packages/engine/action-definitions.js +1 -1
  34. package/dist/packages/engine/agents/lib/shells.d.ts +12 -4
  35. package/dist/packages/engine/agents/lib/shells.js +127 -120
  36. package/dist/packages/engine/cloud-seams.d.ts +115 -0
  37. package/dist/packages/engine/cloud-seams.js +84 -0
  38. package/dist/packages/engine/compile/artifact-counts.d.ts +1 -1
  39. package/dist/packages/engine/compile/artifact-counts.js +3 -3
  40. package/dist/packages/engine/compile/artifact-status.d.ts +41 -0
  41. package/dist/packages/engine/compile/artifact-status.js +166 -0
  42. package/dist/packages/engine/compile/billing-events.d.ts +89 -0
  43. package/dist/packages/engine/compile/billing-events.js +74 -0
  44. package/dist/packages/engine/compile/check-evaluator.d.ts +66 -0
  45. package/dist/packages/engine/compile/check-evaluator.js +298 -0
  46. package/dist/packages/engine/compile/compiled-schema.d.ts +7 -17
  47. package/dist/packages/engine/compile/compiled-schema.js +55 -70
  48. package/dist/packages/engine/compile/compiled-stage-plan.d.ts +1 -0
  49. package/dist/packages/engine/compile/compiled-stage-plan.js +32 -15
  50. package/dist/packages/engine/compile/compiled-stage-runner.js +1 -1
  51. package/dist/packages/engine/compile/index.d.ts +0 -1
  52. package/dist/packages/engine/compile/index.js +0 -1
  53. package/dist/packages/engine/compile/lib/schema.d.ts +111 -92
  54. package/dist/packages/engine/compile/lib/schema.js +35 -39
  55. package/dist/packages/engine/compile/method-primitives.d.ts +2 -2
  56. package/dist/packages/engine/compile/method-primitives.js +1 -1
  57. package/dist/packages/engine/compile/reset.js +4 -4
  58. package/dist/packages/engine/compile/runtime-contracts.js +2 -1
  59. package/dist/packages/engine/compile/runtime-prompt.js +3 -2
  60. package/dist/packages/engine/compile/runtime-reconcile.js +35 -35
  61. package/dist/packages/engine/compile/runtime-runs.js +0 -1
  62. package/dist/packages/engine/compile/runtime-types.d.ts +7 -8
  63. package/dist/packages/engine/compile/runtime.d.ts +1 -2
  64. package/dist/packages/engine/compile/runtime.js +0 -1
  65. package/dist/packages/engine/compile/state-health.js +6 -6
  66. package/dist/packages/engine/compile/state-view.js +7 -6
  67. package/dist/packages/engine/compile/validate-compiled.js +61 -30
  68. package/dist/packages/engine/compile/validate.js +26 -24
  69. package/dist/packages/engine/execution/lib/schema.d.ts +79 -33
  70. package/dist/packages/engine/execution/lib/schema.js +13 -5
  71. package/dist/packages/engine/index.d.ts +2 -2
  72. package/dist/packages/engine/index.js +1 -1
  73. package/dist/packages/engine/lib/schema.d.ts +551 -242
  74. package/dist/packages/engine/lib/schema.js +53 -17
  75. package/dist/packages/engine/native-run-handlers.js +15 -7
  76. package/dist/packages/engine/preparation-store.d.ts +6 -0
  77. package/dist/packages/engine/preparation-store.js +8 -0
  78. package/dist/packages/engine/routes.d.ts +6 -0
  79. package/dist/packages/engine/routes.js +6 -0
  80. package/dist/packages/engine/run-observability.js +1 -2
  81. package/dist/packages/engine/runtime-event-applier.js +7 -0
  82. package/dist/packages/engine/runtime-proposal-helpers.js +1 -1
  83. package/dist/packages/engine/runtime-resource-builders.d.ts +6 -6
  84. package/dist/packages/engine/runtime-resource-builders.js +5 -4
  85. package/dist/packages/engine/runtime.d.ts +67 -7
  86. package/dist/packages/engine/runtime.js +159 -29
  87. package/dist/packages/engine/server.d.ts +25 -0
  88. package/dist/packages/engine/server.js +62 -3
  89. package/dist/packages/engine/verify/index.d.ts +10 -10
  90. package/dist/packages/engine/verify/index.js +8 -8
  91. package/dist/packages/engine/verify/readiness-check-run.d.ts +27 -4
  92. package/dist/packages/engine/verify/readiness-check-run.js +92 -24
  93. package/dist/packages/engine/verify/{test-execution.d.ts → verify-execution.d.ts} +2 -2
  94. package/dist/packages/engine/verify/{test-execution.js → verify-execution.js} +2 -2
  95. package/dist/packages/engine/verify/{test-paths.d.ts → verify-paths.d.ts} +1 -1
  96. package/dist/packages/engine/verify/{test-sandbox.d.ts → verify-sandbox.d.ts} +1 -1
  97. package/dist/packages/engine/verify/{test-specs.d.ts → verify-specs.d.ts} +1 -1
  98. package/dist/packages/engine/verify/{test-specs.js → verify-specs.js} +1 -1
  99. package/dist/packages/engine/verify/{test-targets.d.ts → verify-targets.d.ts} +1 -1
  100. package/dist/packages/engine/verify/{test.d.ts → verify.d.ts} +4 -4
  101. package/dist/packages/engine/verify/{test.js → verify.js} +3 -3
  102. package/dist/packages/engine/wire-schemas.d.ts +545 -0
  103. package/dist/packages/engine/wire-schemas.js +59 -0
  104. package/dist/packages/methods/authoring/method-authoring.d.ts +2 -0
  105. package/dist/packages/methods/authoring/method-authoring.js +99 -18
  106. package/dist/packages/methods/authoring/method-edit-session.js +5 -5
  107. package/dist/packages/methods/authoring/method-improvement.js +1 -1
  108. package/dist/packages/methods/package/builtin-compiled-method.d.ts +12 -12
  109. package/dist/packages/methods/package/builtin-compiled-method.js +25 -22
  110. package/dist/packages/methods/package/context-interface.d.ts +39 -26
  111. package/dist/packages/methods/package/context-interface.js +48 -39
  112. package/dist/packages/methods/package/interf-method-package.js +28 -47
  113. package/dist/packages/methods/package/local-methods.d.ts +3 -4
  114. package/dist/packages/methods/package/local-methods.js +34 -62
  115. package/dist/packages/methods/package/method-definitions.d.ts +4 -6
  116. package/dist/packages/methods/package/method-definitions.js +0 -4
  117. package/dist/packages/methods/package/method-helpers.d.ts +0 -2
  118. package/dist/packages/methods/package/method-helpers.js +0 -4
  119. package/dist/packages/project/interf-scaffold.js +12 -12
  120. package/dist/packages/project/source-config.js +2 -1
  121. package/package.json +6 -16
  122. package/dist/packages/engine/compile/runtime-acceptance.d.ts +0 -9
  123. package/dist/packages/engine/compile/runtime-acceptance.js +0 -265
  124. /package/dist/compiler-ui/_next/static/{a3UiUF0DiMEbfWy_0gihg → 6qyE1u9m_oBUkvAhhoCmO}/_buildManifest.js +0 -0
  125. /package/dist/compiler-ui/_next/static/{a3UiUF0DiMEbfWy_0gihg → 6qyE1u9m_oBUkvAhhoCmO}/_clientMiddlewareManifest.js +0 -0
  126. /package/dist/compiler-ui/_next/static/{a3UiUF0DiMEbfWy_0gihg → 6qyE1u9m_oBUkvAhhoCmO}/_ssgManifest.js +0 -0
  127. /package/dist/packages/engine/verify/{test-paths.js → verify-paths.js} +0 -0
  128. /package/dist/packages/engine/verify/{test-profile-presets.d.ts → verify-profile-presets.d.ts} +0 -0
  129. /package/dist/packages/engine/verify/{test-profile-presets.js → verify-profile-presets.js} +0 -0
  130. /package/dist/packages/engine/verify/{test-sandbox.js → verify-sandbox.js} +0 -0
  131. /package/dist/packages/engine/verify/{test-targets.js → verify-targets.js} +0 -0
  132. /package/dist/packages/engine/verify/{test-types.d.ts → verify-types.d.ts} +0 -0
  133. /package/dist/packages/engine/verify/{test-types.js → verify-types.js} +0 -0
@@ -1,265 +0,0 @@
1
- import { existsSync, } from "node:fs";
2
- import { join } from "node:path";
3
- import { listFilesRecursive } from "../../contracts/utils/filesystem.js";
4
- import { readJsonFileWithSchema } from "../../contracts/utils/parse.js";
5
- import { METHOD_SCHEMA_FILE, compiledZoneAbsolutePath, findCompiledSchemaZone, readCompiledSchemaFile, } from "./compiled-schema.js";
6
- import { RuntimeStageContractSchema, } from "./lib/schema.js";
7
- import { ACCEPTANCE_RULE_KEYS } from "../../contracts/lib/schema.js";
8
- import { stageContractPath } from "./runtime-paths.js";
9
- import { methodPackagePathForCompiled } from "./compiled-paths.js";
10
- import { loadState } from "./state-io.js";
11
- import { countBrokenWikilinks, isOutputMarkdownFile, safeReadText, validateSynthFiles } from "./validate.js";
12
- import { countCompiledZoneArtifacts } from "./artifact-counts.js";
13
- function toFiniteNumber(value) {
14
- if (typeof value !== "number" || !Number.isFinite(value))
15
- return null;
16
- return value;
17
- }
18
- function hasAcceptanceRules(acceptance) {
19
- if (!acceptance)
20
- return false;
21
- // Drive off the canonical rule-key list so a new key added to
22
- // contracts/ is automatically considered here.
23
- for (const key of ACCEPTANCE_RULE_KEYS) {
24
- const value = acceptance[key];
25
- if (Array.isArray(value)) {
26
- if (value.length > 0)
27
- return true;
28
- }
29
- else if (value && typeof value === "object") {
30
- if (Object.keys(value).length > 0)
31
- return true;
32
- }
33
- }
34
- return false;
35
- }
36
- function readPathValue(record, keyPath) {
37
- if (!record)
38
- return undefined;
39
- return keyPath
40
- .split(".")
41
- .filter((segment) => segment.length > 0)
42
- .reduce((current, segment) => {
43
- if (!current || typeof current !== "object" || Array.isArray(current))
44
- return undefined;
45
- return current[segment];
46
- }, record);
47
- }
48
- function markdownFilesForZone(compiledPath, zonePath, kind) {
49
- const absolutePath = compiledZoneAbsolutePath(compiledPath, { path: zonePath });
50
- if (!existsSync(absolutePath))
51
- return [];
52
- if (kind === "file") {
53
- return isOutputMarkdownFile(absolutePath) ? [absolutePath] : [];
54
- }
55
- return listFilesRecursive(absolutePath, isOutputMarkdownFile);
56
- }
57
- function zoneRoots(compiledPath, acceptanceZones) {
58
- const schema = readCompiledSchemaFile(methodPackagePathForCompiled(compiledPath));
59
- if (!schema)
60
- return [];
61
- return acceptanceZones
62
- .map((zoneId) => findCompiledSchemaZone(schema, zoneId))
63
- .filter((zone) => zone !== null)
64
- .map((zone) => compiledZoneAbsolutePath(compiledPath, zone));
65
- }
66
- function readArtifactText(compiledPath, relativePath) {
67
- const artifactPath = join(compiledPath, relativePath);
68
- if (!existsSync(artifactPath))
69
- return null;
70
- return safeReadText(artifactPath);
71
- }
72
- function resolveStageCounts(contract, stageRecord) {
73
- const merged = { ...contract.counts };
74
- const fromStage = stageRecord?.counts;
75
- if (fromStage && typeof fromStage === "object" && !Array.isArray(fromStage)) {
76
- for (const [key, value] of Object.entries(fromStage)) {
77
- const numeric = toFiniteNumber(value);
78
- if (numeric !== null)
79
- merged[key] = numeric;
80
- }
81
- }
82
- return merged;
83
- }
84
- export function stageRecordFromState(state, stageId) {
85
- const stages = state?.stages;
86
- if (!stages || typeof stages !== "object")
87
- return null;
88
- const stage = stages[stageId];
89
- if (!stage || typeof stage !== "object" || Array.isArray(stage))
90
- return null;
91
- return stage;
92
- }
93
- export function validateResolvedStageAcceptance(dirPath, options) {
94
- const acceptance = options.acceptance;
95
- if (!hasAcceptanceRules(acceptance)) {
96
- return {
97
- ok: true,
98
- summary: "No additional stage acceptance criteria were declared.",
99
- failures: [],
100
- };
101
- }
102
- const schema = readCompiledSchemaFile(methodPackagePathForCompiled(dirPath));
103
- if (!schema) {
104
- return {
105
- ok: false,
106
- summary: `Stage acceptance failed for ${options.stageId}: missing Method schema.`,
107
- failures: [`Missing method/${METHOD_SCHEMA_FILE}.`],
108
- };
109
- }
110
- const failures = [];
111
- const state = loadState(dirPath);
112
- const stageRecord = stageRecordFromState(state, options.stageId);
113
- const counts = options.counts ?? {};
114
- for (const relativePath of acceptance?.artifacts_exist ?? []) {
115
- if (!existsSync(join(dirPath, relativePath))) {
116
- failures.push(`Missing required artifact: ${relativePath}.`);
117
- }
118
- }
119
- for (const keyPath of acceptance?.stage_truthy ?? []) {
120
- if (!readPathValue(stageRecord, keyPath)) {
121
- failures.push(`Expected truthy stage value at "${keyPath}".`);
122
- }
123
- }
124
- for (const [keyPath, countKey] of Object.entries(acceptance?.stage_equals_counts ?? {})) {
125
- const actual = readPathValue(stageRecord, keyPath);
126
- const expected = counts[countKey];
127
- if (typeof expected !== "number") {
128
- failures.push(`Acceptance references missing count "${countKey}" for "${keyPath}".`);
129
- continue;
130
- }
131
- if (actual !== expected) {
132
- failures.push(`Expected stage "${keyPath}" to equal count "${countKey}" (${expected}), got ${JSON.stringify(actual)}.`);
133
- }
134
- }
135
- for (const [keyPath, minimum] of Object.entries(acceptance?.stage_at_least ?? {})) {
136
- const actual = toFiniteNumber(readPathValue(stageRecord, keyPath));
137
- if (actual === null || actual < minimum) {
138
- failures.push(`Expected stage "${keyPath}" to be at least ${minimum}, got ${actual === null ? "non-numeric" : actual}.`);
139
- }
140
- }
141
- for (const [keyPath, countKey] of Object.entries(acceptance?.stage_at_least_counts ?? {})) {
142
- const actual = toFiniteNumber(readPathValue(stageRecord, keyPath));
143
- const expected = counts[countKey];
144
- if (typeof expected !== "number") {
145
- failures.push(`Acceptance references missing count "${countKey}" for "${keyPath}".`);
146
- continue;
147
- }
148
- if (actual === null || actual < expected) {
149
- failures.push(`Expected stage "${keyPath}" to be at least count "${countKey}" (${expected}), got ${actual === null ? "non-numeric" : actual}.`);
150
- }
151
- }
152
- for (const [zoneId, minimum] of Object.entries(acceptance?.zone_counts_at_least ?? {})) {
153
- const zone = findCompiledSchemaZone(schema, zoneId);
154
- if (!zone) {
155
- failures.push(`Acceptance references unknown zone "${zoneId}".`);
156
- continue;
157
- }
158
- const actual = countCompiledZoneArtifacts(dirPath, zone.path, zone.kind);
159
- if (actual < minimum) {
160
- failures.push(`Expected zone "${zoneId}" to contain at least ${minimum} artifact(s), got ${actual}.`);
161
- }
162
- }
163
- for (const [zoneId, countKey] of Object.entries(acceptance?.zone_counts_at_least_counts ?? {})) {
164
- const zone = findCompiledSchemaZone(schema, zoneId);
165
- if (!zone) {
166
- failures.push(`Acceptance references unknown zone "${zoneId}".`);
167
- continue;
168
- }
169
- const expected = counts[countKey];
170
- if (typeof expected !== "number") {
171
- failures.push(`Acceptance references missing count "${countKey}" for zone "${zoneId}".`);
172
- continue;
173
- }
174
- const actual = countCompiledZoneArtifacts(dirPath, zone.path, zone.kind);
175
- if (actual < expected) {
176
- failures.push(`Expected zone "${zoneId}" to contain at least count "${countKey}" (${expected}) artifact(s), got ${actual}.`);
177
- }
178
- }
179
- for (const zoneId of acceptance?.markdown_frontmatter_valid_zones ?? []) {
180
- const zone = findCompiledSchemaZone(schema, zoneId);
181
- if (!zone) {
182
- failures.push(`Acceptance references unknown zone "${zoneId}".`);
183
- continue;
184
- }
185
- const validation = validateSynthFiles(markdownFilesForZone(dirPath, zone.path, zone.kind));
186
- if (validation.invalid_frontmatter > 0) {
187
- failures.push(`Zone "${zoneId}" has ${validation.invalid_frontmatter} markdown file(s) with invalid or incomplete frontmatter.`);
188
- }
189
- }
190
- for (const [zoneId, requiredKeys] of Object.entries(acceptance?.frontmatter_required_keys_in_zones ?? {})) {
191
- const zone = findCompiledSchemaZone(schema, zoneId);
192
- if (!zone) {
193
- failures.push(`Acceptance references unknown zone "${zoneId}".`);
194
- continue;
195
- }
196
- const validation = validateSynthFiles(markdownFilesForZone(dirPath, zone.path, zone.kind), { requiredFrontmatterKeys: requiredKeys });
197
- if (validation.invalid_frontmatter > 0) {
198
- failures.push(`Zone "${zoneId}" has ${validation.invalid_frontmatter} markdown file(s) missing required frontmatter keys (${requiredKeys.join(", ")}).`);
199
- }
200
- }
201
- for (const zoneId of acceptance?.markdown_abstract_valid_zones ?? []) {
202
- const zone = findCompiledSchemaZone(schema, zoneId);
203
- if (!zone) {
204
- failures.push(`Acceptance references unknown zone "${zoneId}".`);
205
- continue;
206
- }
207
- const validation = validateSynthFiles(markdownFilesForZone(dirPath, zone.path, zone.kind));
208
- if (validation.short_abstracts > 0) {
209
- failures.push(`Zone "${zoneId}" has ${validation.short_abstracts} markdown file(s) with missing or weak abstracts.`);
210
- }
211
- }
212
- if ((acceptance?.wikilinks_valid_in_zones?.length ?? 0) > 0) {
213
- const roots = zoneRoots(dirPath, acceptance?.wikilinks_valid_in_zones ?? []);
214
- const brokenLinks = countBrokenWikilinks(dirPath, roots, roots);
215
- if (brokenLinks > 0) {
216
- failures.push(`Detected ${brokenLinks} broken wikilink(s) across the declared acceptance zones.`);
217
- }
218
- }
219
- for (const [relativePath, disallowedTexts] of Object.entries(acceptance?.artifacts_must_not_contain ?? {})) {
220
- const content = readArtifactText(dirPath, relativePath);
221
- if (content === null) {
222
- failures.push(`Missing artifact required for content check: ${relativePath}.`);
223
- continue;
224
- }
225
- for (const disallowed of disallowedTexts) {
226
- if (content.includes(disallowed)) {
227
- failures.push(`Artifact "${relativePath}" still contains forbidden text: ${JSON.stringify(disallowed)}.`);
228
- }
229
- }
230
- }
231
- if (failures.length === 0) {
232
- return {
233
- ok: true,
234
- summary: `Stage acceptance satisfied for ${options.stageId}.`,
235
- failures: [],
236
- };
237
- }
238
- return {
239
- ok: false,
240
- summary: `Stage acceptance failed for ${options.stageId}: ${failures.join(" ")}`,
241
- failures,
242
- };
243
- }
244
- export function validateStageContractAcceptance(dirPath, contract = null) {
245
- const resolvedContract = contract ?? (() => {
246
- const path = stageContractPath(dirPath);
247
- if (!existsSync(path))
248
- return null;
249
- return readJsonFileWithSchema(path, "stage contract", RuntimeStageContractSchema);
250
- })();
251
- if (!resolvedContract) {
252
- return {
253
- ok: true,
254
- summary: "No active stage contract found for acceptance validation.",
255
- failures: [],
256
- };
257
- }
258
- const state = loadState(dirPath);
259
- const stageRecord = stageRecordFromState(state, resolvedContract.stage);
260
- return validateResolvedStageAcceptance(dirPath, {
261
- stageId: resolvedContract.stage,
262
- acceptance: resolvedContract.acceptance,
263
- counts: resolveStageCounts(resolvedContract, stageRecord),
264
- });
265
- }