@interf/compiler 0.33.0 → 0.50.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.
- package/README.md +122 -226
- package/dist/cli/commands/agents.js +1 -32
- package/dist/cli/commands/benchmark.d.ts +2 -3
- package/dist/cli/commands/benchmark.js +1 -31
- package/dist/cli/commands/build-plan.js +26 -50
- package/dist/cli/commands/build.d.ts +2 -3
- package/dist/cli/commands/build.js +1 -31
- package/dist/cli/commands/graphs.js +177 -32
- package/dist/cli/commands/mcp.d.ts +1 -0
- package/dist/cli/commands/mcp.js +223 -126
- package/dist/cli/commands/project.js +10 -36
- package/dist/cli/commands/reset.d.ts +2 -3
- package/dist/cli/commands/reset.js +1 -22
- package/dist/cli/commands/runs.js +86 -33
- package/dist/cli/commands/status.js +3 -24
- package/dist/cli/commands/traces.js +1 -29
- package/dist/cli/commands/wizard.js +17 -29
- package/dist/cli/lib/http-client.d.ts +39 -0
- package/dist/cli/lib/http-client.js +73 -0
- package/dist/packages/build-plans/authoring/brief.d.ts +25 -4
- package/dist/packages/build-plans/authoring/build-plan-authoring.d.ts +42 -1
- package/dist/packages/build-plans/authoring/build-plan-authoring.js +470 -63
- package/dist/packages/build-plans/authoring/build-plan-edit-session.d.ts +9 -0
- package/dist/packages/build-plans/authoring/build-plan-edit-session.js +27 -10
- package/dist/packages/build-plans/authoring/build-plan-improvement.js +62 -8
- package/dist/packages/build-plans/authoring/lib/build-plan-edit-utils.d.ts +1 -0
- package/dist/packages/build-plans/package/build-plan-definitions.d.ts +0 -1
- package/dist/packages/build-plans/package/build-plan-definitions.js +5 -3
- package/dist/packages/build-plans/package/build-plan-stage-runner.d.ts +1 -0
- package/dist/packages/build-plans/package/build-plan-stage-runner.js +2 -1
- package/dist/packages/build-plans/package/builtin-build-plan.d.ts +2 -2
- package/dist/packages/build-plans/package/builtin-build-plan.js +3 -3
- package/dist/packages/build-plans/package/context-interface.d.ts +3 -0
- package/dist/packages/build-plans/package/context-interface.js +5 -5
- package/dist/packages/build-plans/package/interf-build-plan-package.js +22 -22
- package/dist/packages/build-plans/package/local-build-plans.d.ts +10 -5
- package/dist/packages/build-plans/package/local-build-plans.js +57 -32
- package/dist/packages/contracts/index.d.ts +4 -3
- package/dist/packages/contracts/index.js +2 -1
- package/dist/packages/contracts/lib/context-graph-layer.d.ts +161 -0
- package/dist/packages/contracts/lib/context-graph-layer.js +216 -0
- package/dist/packages/contracts/lib/project-paths.d.ts +7 -0
- package/dist/packages/contracts/lib/project-paths.js +9 -0
- package/dist/packages/contracts/lib/project-schema.d.ts +264 -1
- package/dist/packages/contracts/lib/project-schema.js +38 -13
- package/dist/packages/contracts/lib/schema.d.ts +556 -23
- package/dist/packages/contracts/lib/schema.js +279 -18
- package/dist/packages/contracts/utils/filesystem.d.ts +1 -0
- package/dist/packages/contracts/utils/filesystem.js +29 -1
- package/dist/packages/projects/lib/schema.d.ts +6 -8
- package/dist/packages/projects/lib/schema.js +3 -1
- package/dist/packages/projects/source-config.d.ts +0 -5
- package/dist/packages/projects/source-config.js +9 -22
- package/dist/packages/runtime/actions/fields.d.ts +4 -0
- package/dist/packages/runtime/actions/form-builders.js +79 -31
- package/dist/packages/runtime/actions/form-validators.js +9 -3
- package/dist/packages/runtime/actions/helpers.js +3 -3
- package/dist/packages/runtime/actions/registry.d.ts +1 -1
- package/dist/packages/runtime/actions/registry.js +1 -1
- package/dist/packages/runtime/actions/requests.d.ts +1 -1
- package/dist/packages/runtime/actions/requests.js +12 -6
- package/dist/packages/runtime/actions/schemas.d.ts +7 -0
- package/dist/packages/runtime/actions/schemas.js +1 -0
- package/dist/packages/runtime/agent-handoff.js +8 -7
- package/dist/packages/runtime/agents/lib/execution-profile.d.ts +14 -0
- package/dist/packages/runtime/agents/lib/execution-profile.js +23 -0
- package/dist/packages/runtime/agents/lib/execution.js +14 -8
- package/dist/packages/runtime/agents/lib/executors.d.ts +1 -0
- package/dist/packages/runtime/agents/lib/executors.js +11 -2
- package/dist/packages/runtime/agents/lib/logs.d.ts +10 -0
- package/dist/packages/runtime/agents/lib/logs.js +32 -8
- package/dist/packages/runtime/agents/lib/preflight.js +4 -1
- package/dist/packages/runtime/agents/lib/render.d.ts +18 -0
- package/dist/packages/runtime/agents/lib/render.js +44 -18
- package/dist/packages/runtime/agents/lib/shell-templates.js +105 -63
- package/dist/packages/runtime/agents/lib/shells.d.ts +29 -0
- package/dist/packages/runtime/agents/lib/shells.js +158 -32
- package/dist/packages/runtime/agents/lib/source-context-scan.d.ts +10 -0
- package/dist/packages/runtime/agents/lib/source-context-scan.js +388 -0
- package/dist/packages/runtime/agents/lib/status.js +1 -14
- package/dist/packages/runtime/agents/lib/string-utils.d.ts +16 -0
- package/dist/packages/runtime/agents/lib/string-utils.js +36 -0
- package/dist/packages/runtime/agents/lib/types.d.ts +1 -0
- package/dist/packages/runtime/agents/providers/codex.js +2 -0
- package/dist/packages/runtime/agents/role-executors.js +2 -1
- package/dist/packages/runtime/auth/session-store.js +11 -3
- package/dist/packages/runtime/benchmark-question-draft.d.ts +3 -0
- package/dist/packages/runtime/benchmark-question-draft.js +57 -28
- package/dist/packages/runtime/build/artifact-status.d.ts +1 -1
- package/dist/packages/runtime/build/artifact-status.js +1 -1
- package/dist/packages/runtime/build/build-evidence.d.ts +2 -1
- package/dist/packages/runtime/build/build-evidence.js +11 -5
- package/dist/packages/runtime/build/build-pipeline.js +89 -5
- package/dist/packages/runtime/build/build-stage-plan.js +3 -1
- package/dist/packages/runtime/build/build-stage-runner.js +169 -32
- package/dist/packages/runtime/build/build-target.d.ts +3 -0
- package/dist/packages/runtime/build/build-target.js +25 -1
- package/dist/packages/runtime/build/check-evaluator.d.ts +1 -1
- package/dist/packages/runtime/build/check-evaluator.js +655 -4
- package/dist/packages/runtime/build/context-graph-paths.d.ts +13 -0
- package/dist/packages/runtime/build/context-graph-paths.js +27 -0
- package/dist/packages/runtime/build/index.d.ts +2 -2
- package/dist/packages/runtime/build/index.js +2 -2
- package/dist/packages/runtime/build/inspect-map.d.ts +10 -0
- package/dist/packages/runtime/build/inspect-map.js +270 -0
- package/dist/packages/runtime/build/lib/schema.d.ts +246 -53
- package/dist/packages/runtime/build/lib/schema.js +173 -15
- package/dist/packages/runtime/build/native-entrypoint.d.ts +2 -0
- package/dist/packages/runtime/build/native-entrypoint.js +286 -0
- package/dist/packages/runtime/build/runtime-contracts.js +9 -3
- package/dist/packages/runtime/build/runtime-log-paths.d.ts +3 -0
- package/dist/packages/runtime/build/runtime-log-paths.js +16 -0
- package/dist/packages/runtime/build/runtime-prompt.js +6 -4
- package/dist/packages/runtime/build/runtime-runs.js +63 -10
- package/dist/packages/runtime/build/runtime-types.d.ts +4 -1
- package/dist/packages/runtime/build/runtime.d.ts +3 -1
- package/dist/packages/runtime/build/runtime.js +3 -1
- package/dist/packages/runtime/build/source-files.js +11 -2
- package/dist/packages/runtime/build/source-inventory.d.ts +1 -0
- package/dist/packages/runtime/build/source-inventory.js +246 -7
- package/dist/packages/runtime/build/source-manifest.d.ts +11 -0
- package/dist/packages/runtime/build/source-manifest.js +30 -2
- package/dist/packages/runtime/build/stage-evidence.js +80 -11
- package/dist/packages/runtime/build/stage-manifest.d.ts +45 -0
- package/dist/packages/runtime/build/stage-manifest.js +1125 -0
- package/dist/packages/runtime/build/stage-reuse.js +12 -0
- package/dist/packages/runtime/build/stage-session.d.ts +81 -0
- package/dist/packages/runtime/build/stage-session.js +308 -0
- package/dist/packages/runtime/build/state-io.js +10 -11
- package/dist/packages/runtime/build/state-view.js +1 -1
- package/dist/packages/runtime/build/state.d.ts +1 -1
- package/dist/packages/runtime/build/state.js +1 -1
- package/dist/packages/runtime/build/summary-coverage-index.d.ts +21 -0
- package/dist/packages/runtime/build/summary-coverage-index.js +189 -0
- package/dist/packages/runtime/build/traces.js +3 -3
- package/dist/packages/runtime/build/validate-context-graph.d.ts +1 -1
- package/dist/packages/runtime/build/validate-context-graph.js +5 -5
- package/dist/packages/runtime/build/validate.d.ts +1 -1
- package/dist/packages/runtime/build/validate.js +1 -1
- package/dist/packages/runtime/client.d.ts +3 -3
- package/dist/packages/runtime/client.js +8 -13
- package/dist/packages/runtime/context-checks.js +13 -0
- package/dist/packages/runtime/context-graph-scaffold.js +2 -1
- package/dist/packages/runtime/context-graph-semantic-graph.d.ts +9 -0
- package/dist/packages/runtime/context-graph-semantic-graph.js +416 -0
- package/dist/packages/runtime/execution/lib/schema.d.ts +34 -31
- package/dist/packages/runtime/index.d.ts +2 -2
- package/dist/packages/runtime/index.js +1 -1
- package/dist/packages/runtime/native-run-handlers.d.ts +38 -0
- package/dist/packages/runtime/native-run-handlers.js +52 -33
- package/dist/packages/runtime/plan-artifact-contract.js +1 -1
- package/dist/packages/runtime/project-source-state.d.ts +4 -4
- package/dist/packages/runtime/project-source-state.js +5 -2
- package/dist/packages/runtime/project-store.d.ts +5 -0
- package/dist/packages/runtime/project-store.js +30 -3
- package/dist/packages/runtime/requested-artifacts.js +1 -1
- package/dist/packages/runtime/run-observability.js +9 -4
- package/dist/packages/runtime/runtime-action-proposals.js +3 -3
- package/dist/packages/runtime/runtime-build-plans.js +47 -3
- package/dist/packages/runtime/runtime-build-runs.js +9 -16
- package/dist/packages/runtime/runtime-caches.d.ts +26 -0
- package/dist/packages/runtime/runtime-caches.js +47 -0
- package/dist/packages/runtime/runtime-jobs.js +6 -6
- package/dist/packages/runtime/runtime-project-mutations.js +1 -0
- package/dist/packages/runtime/runtime-project-reads.d.ts +4 -1
- package/dist/packages/runtime/runtime-project-reads.js +229 -36
- package/dist/packages/runtime/runtime-proposal-helpers.js +6 -6
- package/dist/packages/runtime/runtime-resource-builders.d.ts +4 -2
- package/dist/packages/runtime/runtime-resource-builders.js +16 -14
- package/dist/packages/runtime/runtime-status.d.ts +14 -0
- package/dist/packages/runtime/runtime-status.js +15 -0
- package/dist/packages/runtime/runtime-verify-runs.js +6 -5
- package/dist/packages/runtime/runtime.d.ts +439 -22
- package/dist/packages/runtime/runtime.js +16 -2
- package/dist/packages/runtime/schemas/actions.d.ts +24 -0
- package/dist/packages/runtime/schemas/agents.d.ts +28 -0
- package/dist/packages/runtime/schemas/agents.js +33 -0
- package/dist/packages/runtime/schemas/build-plans.d.ts +181 -8
- package/dist/packages/runtime/schemas/build-plans.js +36 -2
- package/dist/packages/runtime/schemas/context-graphs.d.ts +1522 -0
- package/dist/packages/runtime/schemas/context-graphs.js +110 -0
- package/dist/packages/runtime/schemas/files.d.ts +7 -347
- package/dist/packages/runtime/schemas/files.js +1 -24
- package/dist/packages/runtime/schemas/index.d.ts +1 -0
- package/dist/packages/runtime/schemas/index.js +1 -0
- package/dist/packages/runtime/schemas/jobs.js +4 -0
- package/dist/packages/runtime/schemas/projects.d.ts +48 -21
- package/dist/packages/runtime/schemas/projects.js +34 -10
- package/dist/packages/runtime/schemas/runs.d.ts +1009 -240
- package/dist/packages/runtime/schemas/runs.js +17 -0
- package/dist/packages/runtime/service/openapi.js +1 -0
- package/dist/packages/runtime/service/operations.d.ts +1666 -145
- package/dist/packages/runtime/service/operations.js +147 -17
- package/dist/packages/runtime/service/routes.d.ts +11 -3
- package/dist/packages/runtime/service/routes.js +11 -3
- package/dist/packages/runtime/service/server-app-boot.js +2 -2
- package/dist/packages/runtime/service/server-helpers.d.ts +11 -0
- package/dist/packages/runtime/service/server-helpers.js +19 -0
- package/dist/packages/runtime/service/server-routes-action-proposals.js +4 -2
- package/dist/packages/runtime/service/server-routes-agents.js +19 -85
- package/dist/packages/runtime/service/server-routes-build-plans.js +14 -11
- package/dist/packages/runtime/service/server-routes-project-context.js +102 -7
- package/dist/packages/runtime/service/server-routes-project-jobs.js +19 -12
- package/dist/packages/runtime/service/server-routes-project-runs.js +5 -2
- package/dist/packages/runtime/service/server-routes-projects.js +6 -2
- package/dist/packages/runtime/service/server-routes-runs.js +11 -4
- package/dist/packages/runtime/verify/lib/schema.js +12 -0
- package/dist/packages/runtime/verify/test-file-guard.d.ts +2 -0
- package/dist/packages/runtime/verify/test-file-guard.js +29 -0
- package/dist/packages/runtime/verify/verify-execution.d.ts +7 -0
- package/dist/packages/runtime/verify/verify-execution.js +109 -35
- package/dist/packages/runtime/verify/verify-paths.d.ts +1 -0
- package/dist/packages/runtime/verify/verify-paths.js +4 -0
- package/dist/packages/runtime/verify/verify-specs.js +49 -39
- package/dist/packages/runtime/wire-schemas.d.ts +1 -1
- package/dist/packages/runtime/wire-schemas.js +1 -1
- package/package.json +2 -8
- package/public-repo/CONTRIBUTING.md +10 -3
- package/public-repo/README.md +122 -226
- package/public-repo/build-plans/interf-default/README.md +15 -12
- package/public-repo/build-plans/interf-default/build/stages/entrypoint/SKILL.md +74 -0
- package/public-repo/build-plans/interf-default/build/stages/knowledge/SKILL.md +95 -0
- package/public-repo/build-plans/interf-default/build/stages/summarize/SKILL.md +38 -5
- package/public-repo/build-plans/interf-default/build-plan.json +27 -23
- package/public-repo/build-plans/interf-default/build-plan.schema.json +24 -20
- package/public-repo/build-plans/interf-default/use/query/SKILL.md +8 -7
- package/public-repo/openapi/local-service.openapi.json +11637 -4213
- package/public-repo/skills/interf/SKILL.md +174 -134
- package/dist/packages/runtime/build/runtime-paths.d.ts +0 -8
- package/dist/packages/runtime/build/runtime-paths.js +0 -26
- package/dist/packages/runtime/build/state-paths.d.ts +0 -7
- package/dist/packages/runtime/build/state-paths.js +0 -22
- package/public-repo/build-plans/interf-default/build/stages/shape/SKILL.md +0 -34
- package/public-repo/build-plans/interf-default/build/stages/structure/SKILL.md +0 -28
|
@@ -1,13 +1,30 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { BUILD_PLAN_ARTIFACT_KINDS, } from "../build-plan-primitives.js";
|
|
3
|
-
import { ArtifactIdSchema, ArtifactSchema, CheckSchema, RuntimeContractTypeSchema, RuntimeExecutorInfoSchema, RuntimeStageSchema, RuntimeTargetTypeSchema, StageEvidenceCountSchema, StageEvidenceEdgeSchema, StageEvidenceItemSchema, SourceBuildMaxAttemptsSchema, SourceBuildMaxLoopsSchema, InterfIdPattern, BuildPlanIdSchema, isInterfRelativePath, } from "../../../contracts/lib/schema.js";
|
|
3
|
+
import { ArtifactIdSchema, ArtifactSchema, CheckSchema, ProjectIntentSchema, ProjectIdSchema, RuntimeContractTypeSchema, RuntimeExecutorInfoSchema, RuntimeStageSchema, RuntimeTargetTypeSchema, StageEvidenceCountSchema, StageEvidenceEdgeSchema, StageEvidenceItemSchema, SourceBuildMaxAttemptsSchema, SourceBuildMaxLoopsSchema, InterfIdPattern, BuildPlanIdSchema, isInterfRelativePath, } from "../../../contracts/lib/schema.js";
|
|
4
4
|
// `ArtifactSchema` is used internally below in `BuildPlanContextRawSchema`'s
|
|
5
5
|
// `artifacts[]` field. The other Artifact* schemas/types are NOT
|
|
6
6
|
// re-exported through this module — callers import them directly from
|
|
7
7
|
// `contracts/lib/schema.js`. Re-exports with zero consumers were pruned
|
|
8
8
|
// to keep this barrel narrow.
|
|
9
|
-
export { GateStatusSchema, ReadinessGateSchema, ReadinessSchema, ReadinessStatusSchema, VerifyTargetResultSchema, RuntimeContractTypeSchema, RuntimeExecutorInfoSchema, RuntimeStageSchema, RuntimeTargetTypeSchema, SourceFilesSchema, SourceFileSchema, SourceKindSchema, SourceManifestAuditSchema, SourceManifestEvidenceSchema, SourceManifestFileKindSchema, SourceManifestFileSchema, SourceManifestScannerSchema, SourceManifestSchema, SourceInspectableUnitSchema, SourceSchema, SourceStateSchema, StageInputSchema, StageInputsSchema, StageEvidenceCountSchema, StageEvidenceEdgeSchema, StageEvidenceItemSchema, SourceBuildMaxAttemptsSchema, SourceBuildMaxLoopsSchema, TestCaseExpectSchema, TestTargetTypeSchema, InterfIdPattern, BuildPlanIdSchema, } from "../../../contracts/lib/schema.js";
|
|
9
|
+
export { GateStatusSchema, ProjectIntentSchema, ReadinessGateSchema, ReadinessSchema, ReadinessStatusSchema, VerifyTargetResultSchema, RuntimeContractTypeSchema, RuntimeExecutorInfoSchema, RuntimeStageSchema, RuntimeTargetTypeSchema, SourceFilesSchema, SourceFileSchema, SourceKindSchema, SourceManifestAuditSchema, SourceManifestEvidenceSchema, SourceManifestFileKindSchema, SourceManifestFileSchema, SourceManifestScannerSchema, SourceManifestSchema, SourceInspectableUnitSchema, SourceSchema, SourceStateSchema, StageInputSchema, StageInputsSchema, StageEvidenceCountSchema, StageEvidenceEdgeSchema, StageEvidenceItemSchema, GraphManifestSchema, GraphManifestStageSummarySchema, GraphOutputCountsSchema, GraphReadinessRollupSchema, MetricCountSchema, MissingInputSchema, ResourceRefSchema, ResourceRoleSchema, ReviewedInputDecisionSchema, ReviewedInputSchema, StageManifestSchema, SourceBuildMaxAttemptsSchema, SourceBuildMaxLoopsSchema, TestCaseExpectSchema, TestTargetTypeSchema, InterfIdPattern, BuildPlanIdSchema, } from "../../../contracts/lib/schema.js";
|
|
10
|
+
import { BuildPlanContextCheckDraftSchema, } from "../../../build-plans/authoring/brief.js";
|
|
10
11
|
const JsonRecordSchema = z.record(z.string(), z.unknown());
|
|
12
|
+
// Lifecycle status of a built Context Graph as reported by `health.json`.
|
|
13
|
+
// Defined once here and reused inside `ContextGraphHealthSchema.status` so the
|
|
14
|
+
// `RuntimeStatus` type can never drift from the schema that validates the file.
|
|
15
|
+
export const RuntimeStatusSchema = z.enum(["idle", "running", "built", "stale", "failed"]);
|
|
16
|
+
// Which stage `health.json` reports: a terminal pseudo-stage
|
|
17
|
+
// (`idle`/`built`/`failed`) or a concrete Build Plan stage id. This is the
|
|
18
|
+
// SAME union used at `ContextGraphHealthSchema.stage`; the type is inferred
|
|
19
|
+
// from it so the inline alias no longer widens to a bare `string`.
|
|
20
|
+
export const BuildStageSchema = z.union([
|
|
21
|
+
z.enum(["idle", "built", "failed"]),
|
|
22
|
+
RuntimeStageSchema,
|
|
23
|
+
]);
|
|
24
|
+
// Status of one agent-run execution (a stage session and the run-scoped
|
|
25
|
+
// ledger that records it). Single source for both `StageExecutionSessionSchema`
|
|
26
|
+
// and `ExecutionStageLedgerSchema` so the two records can never disagree.
|
|
27
|
+
export const ExecutionStatusSchema = z.enum(["running", "succeeded", "failed"]);
|
|
11
28
|
export const BuildPlanArtifactIdSchema = z.string().regex(InterfIdPattern);
|
|
12
29
|
export const BuildPlanArtifactKindSchema = z.enum(BUILD_PLAN_ARTIFACT_KINDS);
|
|
13
30
|
export const BuildPlanArtifactRoleSchema = z.literal("output");
|
|
@@ -34,13 +51,34 @@ export const ContextGraphStateSchema = z.object({
|
|
|
34
51
|
warning_count: z.number().optional(),
|
|
35
52
|
error_count: z.number().optional(),
|
|
36
53
|
}).strict();
|
|
37
|
-
|
|
54
|
+
// A view-spec section, discriminated on `type` so each variant declares its
|
|
55
|
+
// own path contract instead of one object where both `path?` and `paths?` are
|
|
56
|
+
// always optional. The producer is `buildDefaultContextGraphViewSpec`
|
|
57
|
+
// (state-view.ts): `status`/`cards` carry a single source `path`; `documents`
|
|
58
|
+
// carries a `paths` list. `flow`/`table` have no producer yet, so their path
|
|
59
|
+
// contract is genuinely unknown — both fields stay optional for those two
|
|
60
|
+
// rather than guessing a shape no caller has committed to.
|
|
61
|
+
const ViewSectionBaseFields = {
|
|
38
62
|
id: z.string(),
|
|
39
|
-
type: z.enum(["status", "cards", "flow", "documents", "table"]),
|
|
40
63
|
title: z.string(),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
})
|
|
64
|
+
};
|
|
65
|
+
export const ViewSectionSchema = z.discriminatedUnion("type", [
|
|
66
|
+
z.object({ ...ViewSectionBaseFields, type: z.literal("status"), path: z.string() }),
|
|
67
|
+
z.object({ ...ViewSectionBaseFields, type: z.literal("cards"), path: z.string() }),
|
|
68
|
+
z.object({ ...ViewSectionBaseFields, type: z.literal("documents"), paths: z.array(z.string()) }),
|
|
69
|
+
z.object({
|
|
70
|
+
...ViewSectionBaseFields,
|
|
71
|
+
type: z.literal("flow"),
|
|
72
|
+
path: z.string().optional(),
|
|
73
|
+
paths: z.array(z.string()).optional(),
|
|
74
|
+
}),
|
|
75
|
+
z.object({
|
|
76
|
+
...ViewSectionBaseFields,
|
|
77
|
+
type: z.literal("table"),
|
|
78
|
+
path: z.string().optional(),
|
|
79
|
+
paths: z.array(z.string()).optional(),
|
|
80
|
+
}),
|
|
81
|
+
]);
|
|
44
82
|
export const ViewCardSchema = z.object({
|
|
45
83
|
id: z.string(),
|
|
46
84
|
label: z.string(),
|
|
@@ -53,11 +91,8 @@ export const ContextGraphHealthSchema = z.object({
|
|
|
53
91
|
version: z.number().int().min(1),
|
|
54
92
|
generated_at: z.string(),
|
|
55
93
|
target_name: z.string(),
|
|
56
|
-
status:
|
|
57
|
-
stage:
|
|
58
|
-
z.enum(["idle", "built", "failed"]),
|
|
59
|
-
RuntimeStageSchema,
|
|
60
|
-
]),
|
|
94
|
+
status: RuntimeStatusSchema,
|
|
95
|
+
stage: BuildStageSchema,
|
|
61
96
|
summary: z.string(),
|
|
62
97
|
metrics: z.record(z.string(), z.number()),
|
|
63
98
|
checks: z.record(z.string(), z.boolean()),
|
|
@@ -129,6 +164,117 @@ export const ExecutionShellPathsSchema = z.object({
|
|
|
129
164
|
reads: z.array(ExecutionShellArtifactMountSchema),
|
|
130
165
|
writes: z.array(ExecutionShellArtifactMountSchema),
|
|
131
166
|
});
|
|
167
|
+
export const StageExecutionSessionValidationAttemptSchema = z.object({
|
|
168
|
+
attempt: z.number().int().min(1),
|
|
169
|
+
recorded_at: z.string().min(1),
|
|
170
|
+
status: z.enum(["succeeded", "failed"]),
|
|
171
|
+
summary: z.string().min(1),
|
|
172
|
+
}).strict();
|
|
173
|
+
/**
|
|
174
|
+
* Which kind of agent job a `StageExecutionSession` preserves. Every
|
|
175
|
+
* `executor.execute()` job that writes a graph-scoped session leaves the SAME
|
|
176
|
+
* inspectable session shape; `job_type` is the discriminator a reader keys off
|
|
177
|
+
* instead of inferring the job from coincidental fields. The default is `stage`
|
|
178
|
+
* so every existing writer/caller (a Build-Plan stage attempt inside a Context
|
|
179
|
+
* Graph) is unchanged. The stage-only fields (`stage_id`, `stage_label`,
|
|
180
|
+
* `contract_type`) stay populated for `stage`/`source-inventory` jobs.
|
|
181
|
+
*
|
|
182
|
+
* Only `stage` and `source-inventory` are ever produced by a session writer:
|
|
183
|
+
* `writeStageExecutionSessionStarted` defaults to `stage`, and source-inventory
|
|
184
|
+
* passes `jobType: "source-inventory"`. Graph-less jobs (Build Plan draft/
|
|
185
|
+
* improvement, benchmark-question drafting) record `LocalJobRun` instead — see
|
|
186
|
+
* `LocalJobTypeSchema` in `schemas/jobs.ts` — so their kinds never appear here.
|
|
187
|
+
*
|
|
188
|
+
* job_type -> preserved shell_type map (`PreservedShellTypeSchema` below):
|
|
189
|
+
* stage -> "stage-execution"
|
|
190
|
+
* source-inventory -> "stage-execution"
|
|
191
|
+
* The other `PreservedShellTypeSchema` members are driven by their own job
|
|
192
|
+
* substrate, NOT by an `AgentJobType`:
|
|
193
|
+
* build-plan-authoring <- LocalJobRun "build-plan-draft"
|
|
194
|
+
* build-plan-improvement <- LocalJobRun "build-plan-improvement"
|
|
195
|
+
* benchmark-question-draft <- LocalJobRun "benchmark-question-draft"
|
|
196
|
+
* test-judge <- the verify/judge path (verify-execution.ts),
|
|
197
|
+
* which is not an AgentJobType at all.
|
|
198
|
+
*/
|
|
199
|
+
export const AgentJobTypeSchema = z.enum([
|
|
200
|
+
"stage",
|
|
201
|
+
"source-inventory",
|
|
202
|
+
]);
|
|
203
|
+
export const StageExecutionSessionSchema = z.object({
|
|
204
|
+
kind: z.literal("interf-stage-execution-session"),
|
|
205
|
+
version: z.literal(1),
|
|
206
|
+
// `.default("stage")` lets every session written before this discriminator
|
|
207
|
+
// existed parse as a stage job, and keeps all current stage/source-inventory
|
|
208
|
+
// writers byte-identical without passing job_type explicitly.
|
|
209
|
+
job_type: AgentJobTypeSchema.default("stage"),
|
|
210
|
+
generated_at: z.string().min(1),
|
|
211
|
+
updated_at: z.string().min(1),
|
|
212
|
+
project: ProjectIdSchema,
|
|
213
|
+
project_intent: ProjectIntentSchema.nullable(),
|
|
214
|
+
context_graph_path: z.string().min(1),
|
|
215
|
+
build_plan: BuildPlanIdSchema,
|
|
216
|
+
build_run_id: z.string().min(1).nullable(),
|
|
217
|
+
// Stage identity: present for `stage`/`source-inventory` jobs (both produced
|
|
218
|
+
// here today). Kept nullable so a future non-stage `AgentJobType` could carry
|
|
219
|
+
// null without a schema migration.
|
|
220
|
+
stage_id: RuntimeStageSchema.nullable(),
|
|
221
|
+
stage_label: z.string().min(1).nullable(),
|
|
222
|
+
contract_type: RuntimeContractTypeSchema.nullable(),
|
|
223
|
+
stage_run_id: z.string().min(1),
|
|
224
|
+
attempt: z.number().int().min(1),
|
|
225
|
+
status: ExecutionStatusSchema,
|
|
226
|
+
executor: RuntimeExecutorInfoSchema,
|
|
227
|
+
shell: z.object({
|
|
228
|
+
root_path: z.string().min(1),
|
|
229
|
+
workspace_manifest_path: z.string().min(1).nullable(),
|
|
230
|
+
preserved_shell_manifest_path: z.string().min(1).nullable(),
|
|
231
|
+
replay_ready: z.boolean(),
|
|
232
|
+
// Why a non-replayable session is still truthful. Null while the shell is
|
|
233
|
+
// live; set when the shell was intentionally pruned (e.g. a successful
|
|
234
|
+
// attempt under `on-failure` retention) so "session exists" never implies a
|
|
235
|
+
// replay shell that is gone. When set, `replay_ready` is false and
|
|
236
|
+
// `preserved_shell_manifest_path` is null. `.default(null)` lets sessions
|
|
237
|
+
// written before this field existed parse without it.
|
|
238
|
+
retention_reason: z.string().min(1).nullable().default(null),
|
|
239
|
+
}).strict(),
|
|
240
|
+
logs: z.object({
|
|
241
|
+
prompt_path: z.string().min(1).nullable(),
|
|
242
|
+
event_stream_path: z.string().min(1).nullable(),
|
|
243
|
+
status_path: z.string().min(1).nullable(),
|
|
244
|
+
}).strict(),
|
|
245
|
+
runtime_files: z.object({
|
|
246
|
+
project_path: z.string().min(1).nullable(),
|
|
247
|
+
contract_path: z.string().min(1).nullable(),
|
|
248
|
+
paths_path: z.string().min(1).nullable(),
|
|
249
|
+
source_locator_path: z.string().min(1).nullable(),
|
|
250
|
+
source_manifest_path: z.string().min(1).nullable(),
|
|
251
|
+
source_state_path: z.string().min(1).nullable(),
|
|
252
|
+
stage_inputs_path: z.string().min(1).nullable(),
|
|
253
|
+
expected_inputs_path: z.string().min(1).nullable(),
|
|
254
|
+
reviewed_inputs_path: z.string().min(1).nullable(),
|
|
255
|
+
previous_attempts_path: z.string().min(1).nullable(),
|
|
256
|
+
retry_feedback_path: z.string().min(1).nullable(),
|
|
257
|
+
last_validation_failure_path: z.string().min(1).nullable(),
|
|
258
|
+
verifier_path: z.string().min(1).nullable(),
|
|
259
|
+
stage_evidence_path: z.string().min(1).nullable(),
|
|
260
|
+
// Best-effort transcript of the agent's reasoning/thinking spans, teed from
|
|
261
|
+
// the live event stream during the run (one JSON object per line). Null when
|
|
262
|
+
// the executor emitted no reasoning. This is the inspectable "full
|
|
263
|
+
// transcript" reference for a preserved attempt.
|
|
264
|
+
reasoning_path: z.string().min(1).nullable().default(null),
|
|
265
|
+
}).strict(),
|
|
266
|
+
artifacts: z.object({
|
|
267
|
+
reads: z.array(ExecutionShellArtifactMountSchema).default([]),
|
|
268
|
+
writes: z.array(ExecutionShellArtifactMountSchema).default([]),
|
|
269
|
+
}).strict(),
|
|
270
|
+
validation_attempts: z.array(StageExecutionSessionValidationAttemptSchema).default([]),
|
|
271
|
+
summary: z.string().min(1).nullable(),
|
|
272
|
+
error: z.string().min(1).nullable(),
|
|
273
|
+
}).strict();
|
|
274
|
+
export const RuntimeProjectContextSchema = z.object({
|
|
275
|
+
id: ProjectIdSchema,
|
|
276
|
+
intent: z.string().min(1).nullable(),
|
|
277
|
+
}).strict();
|
|
132
278
|
export const RuntimeStageInstructionsSchema = z.object({
|
|
133
279
|
stage_skill_dir: z.string().regex(InterfIdPattern),
|
|
134
280
|
effective_mode: z.enum(["builtin", "extend", "override"]),
|
|
@@ -143,6 +289,7 @@ export const RuntimeStageContractSchema = z.object({
|
|
|
143
289
|
run_id: z.string(),
|
|
144
290
|
target_type: RuntimeTargetTypeSchema,
|
|
145
291
|
target_name: z.string(),
|
|
292
|
+
project: RuntimeProjectContextSchema,
|
|
146
293
|
build_plan: z.object({
|
|
147
294
|
id: BuildPlanIdSchema,
|
|
148
295
|
stage_index: z.number().nullable(),
|
|
@@ -164,6 +311,7 @@ export const RuntimeStageContractSchema = z.object({
|
|
|
164
311
|
checks: z.array(CheckSchema),
|
|
165
312
|
}).strict()).default([]),
|
|
166
313
|
}),
|
|
314
|
+
context_checks: z.array(BuildPlanContextCheckDraftSchema).default([]),
|
|
167
315
|
policies: z.object({
|
|
168
316
|
execution_mode: z.literal("deterministic"),
|
|
169
317
|
status_prefixes: z.array(z.string()),
|
|
@@ -188,7 +336,7 @@ export const ExecutionStageLedgerSchema = z.object({
|
|
|
188
336
|
stage: RuntimeStageSchema,
|
|
189
337
|
stage_label: z.string(),
|
|
190
338
|
contract_type: RuntimeContractTypeSchema,
|
|
191
|
-
status:
|
|
339
|
+
status: ExecutionStatusSchema,
|
|
192
340
|
executor: RuntimeExecutorInfoSchema,
|
|
193
341
|
started_at: z.string(),
|
|
194
342
|
updated_at: z.string(),
|
|
@@ -235,8 +383,12 @@ export const ExecutionInventoryEntrySchema = z.object({
|
|
|
235
383
|
metadata: JsonRecordSchema.optional(),
|
|
236
384
|
}).strict();
|
|
237
385
|
export const ExecutionInventorySchema = z.object({
|
|
238
|
-
|
|
239
|
-
|
|
386
|
+
// Both discriminators are always written by the only producers
|
|
387
|
+
// (`emptyExecutionInventory`/`buildInventoryFromEntries` in
|
|
388
|
+
// runtime-inventory.ts), so they are required, not optional. A persisted
|
|
389
|
+
// inventory missing `kind`/`version` is malformed and must fail to parse.
|
|
390
|
+
kind: z.literal("context-graph-runtime-ledger"),
|
|
391
|
+
version: z.literal(1),
|
|
240
392
|
stage: RuntimeStageSchema.optional(),
|
|
241
393
|
entries: z.array(ExecutionInventoryEntrySchema),
|
|
242
394
|
total: z.number().int().nonnegative(),
|
|
@@ -284,6 +436,8 @@ export const PreservedShellTypeSchema = z.enum([
|
|
|
284
436
|
"stage-execution",
|
|
285
437
|
"build-plan-authoring",
|
|
286
438
|
"build-plan-improvement",
|
|
439
|
+
"benchmark-question-draft",
|
|
440
|
+
"test-judge",
|
|
287
441
|
]);
|
|
288
442
|
export const PreservedShellStateSchema = z.object({
|
|
289
443
|
kind: z.literal("interf-preserved-shell"),
|
|
@@ -319,6 +473,10 @@ export const BuildPlanImprovementLoopRecordSchema = z.object({
|
|
|
319
473
|
prompt_log_path: z.string(),
|
|
320
474
|
event_log_path: z.string(),
|
|
321
475
|
status_log_path: z.string(),
|
|
476
|
+
// The agent's reasoning transcript inside the preserved improvement shell
|
|
477
|
+
// (runtime/agent-reasoning.jsonl), so the record indexes the reasoning the
|
|
478
|
+
// same way a stage session exposes reasoning_path. Nullable for older records.
|
|
479
|
+
reasoning_path: z.string().nullable().default(null),
|
|
322
480
|
preserved_shell_manifest_path: z.string().nullable(),
|
|
323
481
|
validation: BuildPlanPackageValidationSchema.nullable(),
|
|
324
482
|
});
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync, } from "node:fs";
|
|
2
|
+
import { basename, extname, join, relative } from "node:path";
|
|
3
|
+
import { appendAgentEventLog, } from "../agents/lib/logs.js";
|
|
4
|
+
import { ExpectedInputsFileSchema, ResourceRefSchema, SourceManifestSchema, } from "../../contracts/lib/schema.js";
|
|
5
|
+
import { normalizeLayerPath } from "../../contracts/lib/context-graph-layer.js";
|
|
6
|
+
import { listFilesRecursive, } from "../../contracts/utils/filesystem.js";
|
|
7
|
+
import { parseJsonFrontmatter, renderJsonFrontmatter, } from "../../contracts/utils/parse.js";
|
|
8
|
+
function markdownTitle(path, content) {
|
|
9
|
+
const parsed = parseJsonFrontmatter(content);
|
|
10
|
+
const title = parsed && typeof parsed.frontmatter.title === "string"
|
|
11
|
+
? parsed.frontmatter.title.trim()
|
|
12
|
+
: "";
|
|
13
|
+
if (title)
|
|
14
|
+
return title;
|
|
15
|
+
const body = parsed?.body ?? content;
|
|
16
|
+
const heading = body.split(/\r?\n/).find((line) => /^#{1,3}\s+\S/.test(line));
|
|
17
|
+
if (heading)
|
|
18
|
+
return heading.replace(/^#{1,3}\s+/, "").trim();
|
|
19
|
+
return basename(path, extname(path));
|
|
20
|
+
}
|
|
21
|
+
function markdownSummary(content) {
|
|
22
|
+
const parsed = parseJsonFrontmatter(content);
|
|
23
|
+
if (parsed && typeof parsed.frontmatter.summary === "string" && parsed.frontmatter.summary.trim()) {
|
|
24
|
+
return parsed.frontmatter.summary.trim();
|
|
25
|
+
}
|
|
26
|
+
const body = parsed?.body ?? content;
|
|
27
|
+
const paragraph = body
|
|
28
|
+
.split(/\n\s*\n/)
|
|
29
|
+
.map((block) => block.replace(/\s+/g, " ").trim())
|
|
30
|
+
.find((block) => block.length > 0 && !block.startsWith("#"));
|
|
31
|
+
if (!paragraph)
|
|
32
|
+
return null;
|
|
33
|
+
return paragraph.length > 180 ? `${paragraph.slice(0, 177)}...` : paragraph;
|
|
34
|
+
}
|
|
35
|
+
function safeReadJson(path) {
|
|
36
|
+
try {
|
|
37
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function readExpectedInputs(shellRoot) {
|
|
44
|
+
const parsed = ExpectedInputsFileSchema.safeParse(safeReadJson(join(shellRoot, "runtime", "expected-inputs.json")));
|
|
45
|
+
return parsed.success ? parsed.data.expected : [];
|
|
46
|
+
}
|
|
47
|
+
function readSourceManifest(shellRoot) {
|
|
48
|
+
const raw = safeReadJson(join(shellRoot, "runtime", "source-manifest.json"));
|
|
49
|
+
const parsed = SourceManifestSchema.safeParse(raw);
|
|
50
|
+
return parsed.success ? parsed.data : null;
|
|
51
|
+
}
|
|
52
|
+
function readProjectIntent(shellRoot) {
|
|
53
|
+
const contract = safeReadJson(join(shellRoot, "runtime", "stage-contract.json"));
|
|
54
|
+
const intent = typeof contract?.project?.intent === "string" ? contract.project.intent.trim() : "";
|
|
55
|
+
return intent || "Build a task-specific Context Graph from the Project Source.";
|
|
56
|
+
}
|
|
57
|
+
function collectMarkdownResources(shellRoot, directory) {
|
|
58
|
+
const root = join(shellRoot, directory);
|
|
59
|
+
if (!existsSync(root))
|
|
60
|
+
return [];
|
|
61
|
+
return listFilesRecursive(root, (filePath) => filePath.endsWith(".md"))
|
|
62
|
+
.sort((left, right) => left.localeCompare(right))
|
|
63
|
+
.map((filePath) => {
|
|
64
|
+
const path = normalizeLayerPath(relative(shellRoot, filePath));
|
|
65
|
+
const content = readFileSync(filePath, "utf8");
|
|
66
|
+
const parsed = parseJsonFrontmatter(content);
|
|
67
|
+
const sourceRefs = sourceRefsFromFrontmatter(parsed?.frontmatter ?? {});
|
|
68
|
+
return ResourceRefSchema.parse({
|
|
69
|
+
id: `${directory}:${path.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "")}`,
|
|
70
|
+
role: directory === "knowledge" ? "knowledge" : "summary",
|
|
71
|
+
kind: directory === "knowledge" ? "knowledge.note" : "summary.note",
|
|
72
|
+
label: markdownTitle(path, content),
|
|
73
|
+
path,
|
|
74
|
+
source_refs: sourceRefs,
|
|
75
|
+
links: [],
|
|
76
|
+
metadata: {
|
|
77
|
+
...(markdownSummary(content) ? { summary: markdownSummary(content) } : {}),
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function sourceRefsFromFrontmatter(frontmatter) {
|
|
83
|
+
const values = [
|
|
84
|
+
frontmatter.source_refs,
|
|
85
|
+
frontmatter.source_ref,
|
|
86
|
+
frontmatter.source_path,
|
|
87
|
+
frontmatter.source,
|
|
88
|
+
];
|
|
89
|
+
const refs = values.flatMap((value) => {
|
|
90
|
+
if (typeof value === "string" && value.trim())
|
|
91
|
+
return [value.trim()];
|
|
92
|
+
if (Array.isArray(value)) {
|
|
93
|
+
return value
|
|
94
|
+
.filter((item) => typeof item === "string" && item.trim().length > 0)
|
|
95
|
+
.map((item) => item.trim());
|
|
96
|
+
}
|
|
97
|
+
return [];
|
|
98
|
+
});
|
|
99
|
+
return [...new Set(refs)];
|
|
100
|
+
}
|
|
101
|
+
function collectSourceRefs(expected, manifest, notes) {
|
|
102
|
+
const refs = new Set();
|
|
103
|
+
for (const resource of [...expected, ...notes]) {
|
|
104
|
+
for (const ref of resource.source_refs)
|
|
105
|
+
refs.add(ref);
|
|
106
|
+
}
|
|
107
|
+
for (const file of manifest?.files ?? [])
|
|
108
|
+
refs.add(file.path);
|
|
109
|
+
return [...refs].sort((left, right) => left.localeCompare(right));
|
|
110
|
+
}
|
|
111
|
+
function markdownLink(resource) {
|
|
112
|
+
const path = resource.path ?? "";
|
|
113
|
+
return path ? `[${resource.label}](${path})` : resource.label;
|
|
114
|
+
}
|
|
115
|
+
function renderResourceList(resources, limit) {
|
|
116
|
+
return resources.slice(0, limit).map((resource) => {
|
|
117
|
+
const summary = typeof resource.metadata?.summary === "string" ? resource.metadata.summary : null;
|
|
118
|
+
return `- ${markdownLink(resource)}${summary ? ` - ${summary}` : ""}`;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
function renderSourceRefList(sourceRefs, limit) {
|
|
122
|
+
return sourceRefs.slice(0, limit).map((ref) => `- \`${ref}\``);
|
|
123
|
+
}
|
|
124
|
+
function writeReviewedInputs(shellRoot, expected) {
|
|
125
|
+
const now = new Date().toISOString();
|
|
126
|
+
const reviewed = expected.map((resource) => ({
|
|
127
|
+
resource_id: resource.id,
|
|
128
|
+
decision: "used",
|
|
129
|
+
source_refs: resource.source_refs.length > 0 ? resource.source_refs : [resource.path ?? resource.id],
|
|
130
|
+
metadata: {
|
|
131
|
+
reviewer: "interf-native-entrypoint",
|
|
132
|
+
},
|
|
133
|
+
}));
|
|
134
|
+
writeFileSync(join(shellRoot, "runtime", "reviewed-inputs.json"), `${JSON.stringify({
|
|
135
|
+
kind: "interf-stage-reviewed-inputs",
|
|
136
|
+
version: 1,
|
|
137
|
+
generated_at: now,
|
|
138
|
+
stage_id: "entrypoint",
|
|
139
|
+
reviewed,
|
|
140
|
+
}, null, 2)}\n`);
|
|
141
|
+
}
|
|
142
|
+
function writeEntrypointOutputs(shellRoot) {
|
|
143
|
+
const intent = readProjectIntent(shellRoot);
|
|
144
|
+
const expected = readExpectedInputs(shellRoot);
|
|
145
|
+
const manifest = readSourceManifest(shellRoot);
|
|
146
|
+
const knowledge = collectMarkdownResources(shellRoot, "knowledge");
|
|
147
|
+
const summaries = collectMarkdownResources(shellRoot, "summaries");
|
|
148
|
+
const expectedByPath = new Map(expected.map((resource) => [resource.path, resource]));
|
|
149
|
+
const knowledgeForRouting = knowledge.length > 0
|
|
150
|
+
? knowledge
|
|
151
|
+
: expected.filter((resource) => resource.role === "knowledge");
|
|
152
|
+
const notesForRefs = [...knowledgeForRouting, ...summaries, ...expectedByPath.values()];
|
|
153
|
+
const sourceRefs = collectSourceRefs(expected, manifest, notesForRefs);
|
|
154
|
+
const generatedAt = new Date().toISOString();
|
|
155
|
+
const topKnowledge = knowledgeForRouting.slice(0, 12);
|
|
156
|
+
const topSummaries = summaries.slice(0, 12);
|
|
157
|
+
const links = [
|
|
158
|
+
"artifacts/agent-handoff.md",
|
|
159
|
+
...topKnowledge.map((resource) => resource.path).filter((path) => Boolean(path)),
|
|
160
|
+
...topSummaries.slice(0, 6).map((resource) => resource.path).filter((path) => Boolean(path)),
|
|
161
|
+
];
|
|
162
|
+
mkdirSync(join(shellRoot, "artifacts"), { recursive: true });
|
|
163
|
+
writeFileSync(join(shellRoot, "home.md"), [
|
|
164
|
+
renderJsonFrontmatter({
|
|
165
|
+
title: "Context Graph Home",
|
|
166
|
+
summary: "Primary agent entrypoint for the prepared Context Graph.",
|
|
167
|
+
task: intent,
|
|
168
|
+
source_refs: sourceRefs,
|
|
169
|
+
links,
|
|
170
|
+
generated_by: "interf-native-entrypoint",
|
|
171
|
+
}),
|
|
172
|
+
"",
|
|
173
|
+
"# Context Graph Home",
|
|
174
|
+
"",
|
|
175
|
+
`Project intent: ${intent}`,
|
|
176
|
+
"",
|
|
177
|
+
"Start with the task handoff, then follow the linked knowledge notes and summaries. Generated notes are routing and synthesis; original Source and source refs remain the authority for exact claims.",
|
|
178
|
+
"",
|
|
179
|
+
"## Start Here",
|
|
180
|
+
"",
|
|
181
|
+
"- [Agent handoff](artifacts/agent-handoff.md)",
|
|
182
|
+
...renderResourceList(topKnowledge, 10),
|
|
183
|
+
"",
|
|
184
|
+
"## Coverage Routes",
|
|
185
|
+
"",
|
|
186
|
+
...(topSummaries.length > 0
|
|
187
|
+
? renderResourceList(topSummaries, 10)
|
|
188
|
+
: ["- No summary notes were available to route."]),
|
|
189
|
+
"",
|
|
190
|
+
"## Source Refs",
|
|
191
|
+
"",
|
|
192
|
+
...(sourceRefs.length > 0
|
|
193
|
+
? renderSourceRefList(sourceRefs, 20)
|
|
194
|
+
: ["- No source refs were recorded."]),
|
|
195
|
+
"",
|
|
196
|
+
].join("\n"));
|
|
197
|
+
writeFileSync(join(shellRoot, "artifacts", "agent-handoff.md"), [
|
|
198
|
+
renderJsonFrontmatter({
|
|
199
|
+
title: "Agent Handoff",
|
|
200
|
+
summary: "Task-specific route through the prepared Context Graph.",
|
|
201
|
+
task: intent,
|
|
202
|
+
source_refs: sourceRefs,
|
|
203
|
+
handoff_type: "agent-context-handoff",
|
|
204
|
+
truth_mode: "source-backed routing",
|
|
205
|
+
verification_state: "Ready to use; follow original Source and source refs for exact claims.",
|
|
206
|
+
caveats: [
|
|
207
|
+
"Generated summaries and knowledge notes are prepared context, not replacement source material.",
|
|
208
|
+
"Use original Source and source refs when exact wording, table values, chart reads, dates, or provenance-sensitive claims matter.",
|
|
209
|
+
],
|
|
210
|
+
links,
|
|
211
|
+
generated_at: generatedAt,
|
|
212
|
+
generated_by: "interf-native-entrypoint",
|
|
213
|
+
}),
|
|
214
|
+
"",
|
|
215
|
+
"# Agent Handoff",
|
|
216
|
+
"",
|
|
217
|
+
`Task: ${intent}`,
|
|
218
|
+
"",
|
|
219
|
+
"Use this Context Graph as prepared context. For exact claims, follow the original Source and source refs from the notes below back to the source files.",
|
|
220
|
+
"",
|
|
221
|
+
"## Useful Knowledge",
|
|
222
|
+
"",
|
|
223
|
+
...(topKnowledge.length > 0
|
|
224
|
+
? renderResourceList(topKnowledge, 12)
|
|
225
|
+
: ["- No knowledge notes were available."]),
|
|
226
|
+
"",
|
|
227
|
+
"## Coverage And Source Routes",
|
|
228
|
+
"",
|
|
229
|
+
...(topSummaries.length > 0
|
|
230
|
+
? renderResourceList(topSummaries, 12)
|
|
231
|
+
: ["- No summary notes were available."]),
|
|
232
|
+
"",
|
|
233
|
+
"## Source Refs To Recheck",
|
|
234
|
+
"",
|
|
235
|
+
...(sourceRefs.length > 0
|
|
236
|
+
? renderSourceRefList(sourceRefs, 30)
|
|
237
|
+
: ["- No source refs were recorded."]),
|
|
238
|
+
"",
|
|
239
|
+
].join("\n"));
|
|
240
|
+
writeReviewedInputs(shellRoot, expected);
|
|
241
|
+
}
|
|
242
|
+
function appendStatus(options, line) {
|
|
243
|
+
appendAgentEventLog(options?.eventLogPath, {
|
|
244
|
+
type: "native-stage.status",
|
|
245
|
+
message: line,
|
|
246
|
+
});
|
|
247
|
+
options?.onStatus?.(line);
|
|
248
|
+
if (options?.statusLogPath) {
|
|
249
|
+
appendFileSync(options.statusLogPath, `${line}\n`);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function appendNativeEvent(options, event) {
|
|
253
|
+
appendAgentEventLog(options?.eventLogPath, {
|
|
254
|
+
type: "native-stage.event",
|
|
255
|
+
...event,
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
export function createNativeEntrypointExecutor() {
|
|
259
|
+
return {
|
|
260
|
+
kind: "managed",
|
|
261
|
+
name: "interf-native-entrypoint",
|
|
262
|
+
displayName: "Interf native entrypoint",
|
|
263
|
+
command: null,
|
|
264
|
+
execute(rootPath, _prompt, options) {
|
|
265
|
+
try {
|
|
266
|
+
appendNativeEvent(options, { phase: "started", root_path: rootPath });
|
|
267
|
+
appendStatus(options, "STATUS: loaded entrypoint stage.");
|
|
268
|
+
appendStatus(options, "STATUS: reading declared inputs.");
|
|
269
|
+
writeEntrypointOutputs(rootPath);
|
|
270
|
+
appendStatus(options, "STATUS: writing declared outputs.");
|
|
271
|
+
appendStatus(options, "DONE: entrypoint complete.");
|
|
272
|
+
appendNativeEvent(options, { phase: "succeeded", root_path: rootPath });
|
|
273
|
+
return Promise.resolve(0);
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
appendStatus(options, `ERROR: native entrypoint failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
277
|
+
appendNativeEvent(options, {
|
|
278
|
+
phase: "failed",
|
|
279
|
+
root_path: rootPath,
|
|
280
|
+
error: error instanceof Error ? error.message : String(error),
|
|
281
|
+
});
|
|
282
|
+
return Promise.resolve(1);
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
}
|
|
@@ -4,6 +4,7 @@ export function buildRuntimeStageContract(options) {
|
|
|
4
4
|
const buildPlanNotes = options.buildPlanNotes ?? [];
|
|
5
5
|
return {
|
|
6
6
|
instructions: options.instructions,
|
|
7
|
+
project: options.project,
|
|
7
8
|
counts: {
|
|
8
9
|
...(options.counts ?? {}),
|
|
9
10
|
local_skill_docs: localSkillDocs.length,
|
|
@@ -19,16 +20,21 @@ export function buildRuntimeStageContract(options) {
|
|
|
19
20
|
writes: options.stageWriteArtifacts,
|
|
20
21
|
write_contracts: options.stageWriteContracts ?? [],
|
|
21
22
|
},
|
|
23
|
+
context_checks: options.contextChecks ?? [],
|
|
22
24
|
policies: {
|
|
23
25
|
execution_mode: "deterministic",
|
|
24
26
|
status_prefixes: ["STATUS:", "DONE:", "BLOCKED:", "ERROR:"],
|
|
25
27
|
notes: [
|
|
26
28
|
`This is the "${options.stageLabel}" stage for the context graph "${options.contextGraphName}".`,
|
|
29
|
+
options.project.intent
|
|
30
|
+
? `Project intent: ${options.project.intent}`
|
|
31
|
+
: "Project intent is not set. Keep outputs source-grounded and explicitly note missing task focus where it limits usefulness.",
|
|
27
32
|
"The Build Plan is the authoritative plan layer for this run.",
|
|
28
|
-
`Use \`build-plan/${BUILD_PLAN_SCHEMA_FILE}\` as the deterministic requested
|
|
29
|
-
"
|
|
33
|
+
`Use \`build-plan/${BUILD_PLAN_SCHEMA_FILE}\` as the deterministic requested output contract for this context graph.`,
|
|
34
|
+
"Use `context_checks[]` only as legacy coverage-goal context; StageManifest and GraphManifest metrics are the readiness proof.",
|
|
35
|
+
"Honor the declared read and write outputs instead of inventing a parallel process.",
|
|
30
36
|
"Only create or update files that fall under the declared write targets for this stage.",
|
|
31
|
-
"Before emitting DONE, satisfy every check listed under `artifacts.write_contracts[]` for the write
|
|
37
|
+
"Before emitting DONE, satisfy every check listed under `artifacts.write_contracts[]` for the write outputs this stage owns.",
|
|
32
38
|
"Interf writes `.interf/runtime/` ledgers such as run, state, health, and view-spec files. Read them if needed, but do not create, edit, or replace them in this stage unless the contract explicitly marks a runtime artifact as stage-owned.",
|
|
33
39
|
"Keep scratch extraction commands single-purpose and non-destructive. Avoid wildcard cleanup and multi-command chains.",
|
|
34
40
|
...buildPlanNotes,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { contextGraphRuntimeLogsRoot } from "./context-graph-paths.js";
|
|
3
|
+
// Canonical per-run log-file builders for stage execution without a shell.
|
|
4
|
+
// They share the runtime logs root with the archived stage contract
|
|
5
|
+
// (contextGraphRuntimeArchivedStageContractPath) and use the same
|
|
6
|
+
// `<runId>.<suffix>` naming. Shell-backed runs use the parallel
|
|
7
|
+
// shell-workspace builders instead.
|
|
8
|
+
export function promptLogPath(dirPath, runId) {
|
|
9
|
+
return join(contextGraphRuntimeLogsRoot(dirPath), `${runId}.prompt.txt`);
|
|
10
|
+
}
|
|
11
|
+
export function eventLogPath(dirPath, runId) {
|
|
12
|
+
return join(contextGraphRuntimeLogsRoot(dirPath), `${runId}.events.ndjson`);
|
|
13
|
+
}
|
|
14
|
+
export function statusLogPath(dirPath, runId) {
|
|
15
|
+
return join(contextGraphRuntimeLogsRoot(dirPath), `${runId}.status.log`);
|
|
16
|
+
}
|
|
@@ -21,12 +21,14 @@ export function buildStagePrompt(instructions, contractPath, statusLines) {
|
|
|
21
21
|
"The user has already invoked this stage through the Interf CLI. Execute it now.",
|
|
22
22
|
"Do not ask what the user wants, offer help, list tools, or wait for another instruction.",
|
|
23
23
|
`Read \`${contractPath}\` first. It is the authoritative contract for this stage.`,
|
|
24
|
-
"
|
|
25
|
-
"
|
|
24
|
+
"Use `project.intent` in that contract as the task focus for task-aware summaries, knowledge, entrypoints, and task note work.",
|
|
25
|
+
"Use `runtime/expected-inputs.json` as the coverage contract and write `runtime/reviewed-inputs.json` before DONE.",
|
|
26
|
+
"If `runtime/paths.json` exists in this shell, read it next. It maps Build Plan output ids onto the shell-local `inputs/` and `outputs/` mounts for this stage.",
|
|
27
|
+
"For file output mounts, `runtime/paths.json` also gives the exact file path inside the `inputs/` or `outputs/` mount root.",
|
|
26
28
|
"Before DONE, run `node runtime/check-stage.mjs` from the shell root and fix outputs until it prints `VALID:`.",
|
|
27
29
|
"Honor the contract's counts, artifact paths, and policies instead of inventing another Build Plan.",
|
|
28
|
-
"The contract's `artifacts.write_contracts[]` lists the checks Interf will run against the
|
|
29
|
-
"Read only the files named by the contract's `artifacts.reads` list, `runtime/source-manifest.json`, `runtime/stage-inputs.json`, and any paths those files explicitly assign to this stage. `runtime/source-state.json` is compatibility-only and is not stage authority.",
|
|
30
|
+
"The contract's `artifacts.write_contracts[]` lists the checks Interf will run against the outputs this stage writes. Treat those checks as required output constraints.",
|
|
31
|
+
"Read only the files named by the contract's `artifacts.reads` list, `runtime/source-manifest.json`, `runtime/stage-inputs.json`, `runtime/expected-inputs.json`, and any paths those files explicitly assign to this stage. `runtime/source-state.json` is compatibility-only and is not stage authority.",
|
|
30
32
|
"Prefer direct file-reading and search tools over shell commands when you inspect inputs, docs, or generated outputs.",
|
|
31
33
|
"Do not use shell helpers like `cat`, `sed`, `ls`, or `find` for routine file inspection if a native read/search tool can do the same job.",
|
|
32
34
|
"If the contract lists `instructions.local_docs`, open every one of those files before you write artifacts or declare the stage complete.",
|