@interf/compiler 0.2.5 → 0.3.1
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 +192 -187
- package/dist/bin.js +3 -3
- package/dist/bin.js.map +1 -1
- package/dist/commands/compile.d.ts +1 -0
- package/dist/commands/compile.d.ts.map +1 -1
- package/dist/commands/compile.js +45 -138
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/create-workflow-wizard.d.ts +4 -25
- package/dist/commands/create-workflow-wizard.d.ts.map +1 -1
- package/dist/commands/create-workflow-wizard.js +46 -222
- package/dist/commands/create-workflow-wizard.js.map +1 -1
- package/dist/commands/create.d.ts +2 -11
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +78 -477
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/default.d.ts.map +1 -1
- package/dist/commands/default.js +27 -43
- package/dist/commands/default.js.map +1 -1
- package/dist/commands/doctor.js +2 -2
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/executor-flow.d.ts +9 -0
- package/dist/commands/executor-flow.d.ts.map +1 -0
- package/dist/commands/executor-flow.js +55 -0
- package/dist/commands/executor-flow.js.map +1 -0
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +320 -321
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +12 -22
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/reset.d.ts.map +1 -1
- package/dist/commands/reset.js +27 -124
- package/dist/commands/reset.js.map +1 -1
- package/dist/commands/source-config-wizard.d.ts +10 -11
- package/dist/commands/source-config-wizard.d.ts.map +1 -1
- package/dist/commands/source-config-wizard.js +100 -97
- package/dist/commands/source-config-wizard.js.map +1 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +60 -56
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/test-flow.d.ts +21 -0
- package/dist/commands/test-flow.d.ts.map +1 -0
- package/dist/commands/test-flow.js +106 -0
- package/dist/commands/test-flow.js.map +1 -0
- package/dist/commands/test.d.ts +4 -0
- package/dist/commands/test.d.ts.map +1 -0
- package/dist/commands/test.js +131 -0
- package/dist/commands/test.js.map +1 -0
- package/dist/commands/verify.d.ts.map +1 -1
- package/dist/commands/verify.js +63 -98
- package/dist/commands/verify.js.map +1 -1
- package/dist/commands/workspace-flow.d.ts +21 -0
- package/dist/commands/workspace-flow.d.ts.map +1 -0
- package/dist/commands/workspace-flow.js +90 -0
- package/dist/commands/workspace-flow.js.map +1 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -7
- package/dist/index.js.map +1 -1
- package/dist/lib/agent-constants.js +1 -1
- package/dist/lib/agent-constants.js.map +1 -1
- package/dist/lib/agent-detection.js +4 -4
- package/dist/lib/agent-detection.js.map +1 -1
- package/dist/lib/agent-skills.js +6 -6
- package/dist/lib/agent-skills.js.map +1 -1
- package/dist/lib/benchmark-execution.d.ts.map +1 -1
- package/dist/lib/benchmark-execution.js +32 -19
- package/dist/lib/benchmark-execution.js.map +1 -1
- package/dist/lib/benchmark-sandbox.d.ts +10 -0
- package/dist/lib/benchmark-sandbox.d.ts.map +1 -0
- package/dist/lib/benchmark-sandbox.js +75 -0
- package/dist/lib/benchmark-sandbox.js.map +1 -0
- package/dist/lib/benchmark-targets.d.ts +4 -4
- package/dist/lib/benchmark-targets.d.ts.map +1 -1
- package/dist/lib/benchmark-targets.js +20 -54
- package/dist/lib/benchmark-targets.js.map +1 -1
- package/dist/lib/benchmark-types.d.ts +2 -3
- package/dist/lib/benchmark-types.d.ts.map +1 -1
- package/dist/lib/benchmark.d.ts +1 -1
- package/dist/lib/benchmark.d.ts.map +1 -1
- package/dist/lib/benchmark.js +1 -1
- package/dist/lib/benchmark.js.map +1 -1
- package/dist/lib/config.d.ts +1 -2
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +2 -4
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/discovery.d.ts +1 -1
- package/dist/lib/discovery.d.ts.map +1 -1
- package/dist/lib/discovery.js +7 -2
- package/dist/lib/discovery.js.map +1 -1
- package/dist/lib/eval-packs.d.ts +6 -52
- package/dist/lib/eval-packs.d.ts.map +1 -1
- package/dist/lib/eval-packs.js +11 -39
- package/dist/lib/eval-packs.js.map +1 -1
- package/dist/lib/interf-bootstrap.d.ts +3 -5
- package/dist/lib/interf-bootstrap.d.ts.map +1 -1
- package/dist/lib/interf-bootstrap.js +10 -57
- package/dist/lib/interf-bootstrap.js.map +1 -1
- package/dist/lib/interf-detect.d.ts +13 -11
- package/dist/lib/interf-detect.d.ts.map +1 -1
- package/dist/lib/interf-detect.js +59 -45
- package/dist/lib/interf-detect.js.map +1 -1
- package/dist/lib/interf-scaffold.d.ts +2 -5
- package/dist/lib/interf-scaffold.d.ts.map +1 -1
- package/dist/lib/interf-scaffold.js +99 -235
- package/dist/lib/interf-scaffold.js.map +1 -1
- package/dist/lib/interf-workflow-package.d.ts +1 -2
- package/dist/lib/interf-workflow-package.d.ts.map +1 -1
- package/dist/lib/interf-workflow-package.js +99 -90
- package/dist/lib/interf-workflow-package.js.map +1 -1
- package/dist/lib/interf.d.ts +4 -5
- package/dist/lib/interf.d.ts.map +1 -1
- package/dist/lib/interf.js +3 -6
- package/dist/lib/interf.js.map +1 -1
- package/dist/lib/local-workflows.d.ts +9 -8
- package/dist/lib/local-workflows.d.ts.map +1 -1
- package/dist/lib/local-workflows.js +56 -92
- package/dist/lib/local-workflows.js.map +1 -1
- package/dist/lib/obsidian.d.ts +1 -3
- package/dist/lib/obsidian.d.ts.map +1 -1
- package/dist/lib/obsidian.js +10 -81
- package/dist/lib/obsidian.js.map +1 -1
- package/dist/lib/registry.d.ts +6 -17
- package/dist/lib/registry.d.ts.map +1 -1
- package/dist/lib/registry.js +36 -50
- package/dist/lib/registry.js.map +1 -1
- package/dist/lib/runtime-contracts.d.ts +4 -3
- package/dist/lib/runtime-contracts.d.ts.map +1 -1
- package/dist/lib/runtime-contracts.js +125 -9
- package/dist/lib/runtime-contracts.js.map +1 -1
- package/dist/lib/runtime-reconcile.d.ts +3 -5
- package/dist/lib/runtime-reconcile.d.ts.map +1 -1
- package/dist/lib/runtime-reconcile.js +70 -167
- package/dist/lib/runtime-reconcile.js.map +1 -1
- package/dist/lib/runtime-runs.d.ts.map +1 -1
- package/dist/lib/runtime-runs.js +61 -57
- package/dist/lib/runtime-runs.js.map +1 -1
- package/dist/lib/runtime-types.d.ts +16 -6
- package/dist/lib/runtime-types.d.ts.map +1 -1
- package/dist/lib/runtime.d.ts +2 -2
- package/dist/lib/runtime.d.ts.map +1 -1
- package/dist/lib/runtime.js +1 -1
- package/dist/lib/runtime.js.map +1 -1
- package/dist/lib/schema.d.ts +69 -311
- package/dist/lib/schema.d.ts.map +1 -1
- package/dist/lib/schema.js +49 -210
- package/dist/lib/schema.js.map +1 -1
- package/dist/lib/source-config.d.ts +8 -7
- package/dist/lib/source-config.d.ts.map +1 -1
- package/dist/lib/source-config.js +59 -63
- package/dist/lib/source-config.js.map +1 -1
- package/dist/lib/state-artifacts.d.ts +5 -11
- package/dist/lib/state-artifacts.d.ts.map +1 -1
- package/dist/lib/state-artifacts.js +8 -18
- package/dist/lib/state-artifacts.js.map +1 -1
- package/dist/lib/state-health.d.ts +4 -8
- package/dist/lib/state-health.d.ts.map +1 -1
- package/dist/lib/state-health.js +52 -233
- package/dist/lib/state-health.js.map +1 -1
- package/dist/lib/state-io.d.ts +7 -12
- package/dist/lib/state-io.d.ts.map +1 -1
- package/dist/lib/state-io.js +32 -93
- package/dist/lib/state-io.js.map +1 -1
- package/dist/lib/state-view.d.ts +4 -6
- package/dist/lib/state-view.d.ts.map +1 -1
- package/dist/lib/state-view.js +62 -101
- package/dist/lib/state-view.js.map +1 -1
- package/dist/lib/state.d.ts +5 -5
- package/dist/lib/state.d.ts.map +1 -1
- package/dist/lib/state.js +4 -4
- package/dist/lib/state.js.map +1 -1
- package/dist/lib/summarize-plan.d.ts +2 -2
- package/dist/lib/summarize-plan.d.ts.map +1 -1
- package/dist/lib/summarize-plan.js +13 -13
- package/dist/lib/summarize-plan.js.map +1 -1
- package/dist/lib/{validate-kb.d.ts → validate-workspace.d.ts} +49 -8
- package/dist/lib/validate-workspace.d.ts.map +1 -0
- package/dist/lib/validate-workspace.js +398 -0
- package/dist/lib/validate-workspace.js.map +1 -0
- package/dist/lib/validate.d.ts +5 -7
- package/dist/lib/validate.d.ts.map +1 -1
- package/dist/lib/validate.js +22 -20
- package/dist/lib/validate.js.map +1 -1
- package/dist/lib/workflow-definitions.d.ts +14 -50
- package/dist/lib/workflow-definitions.d.ts.map +1 -1
- package/dist/lib/workflow-definitions.js +100 -353
- package/dist/lib/workflow-definitions.js.map +1 -1
- package/dist/lib/workflow-helpers.d.ts +3 -4
- package/dist/lib/workflow-helpers.d.ts.map +1 -1
- package/dist/lib/workflow-helpers.js +17 -49
- package/dist/lib/workflow-helpers.js.map +1 -1
- package/dist/lib/workflow-stage-runner.d.ts +1 -2
- package/dist/lib/workflow-stage-runner.d.ts.map +1 -1
- package/dist/lib/workflow-stage-runner.js +4 -6
- package/dist/lib/workflow-stage-runner.js.map +1 -1
- package/dist/lib/workflow-starter-docs.d.ts +3 -5
- package/dist/lib/workflow-starter-docs.d.ts.map +1 -1
- package/dist/lib/workflow-starter-docs.js +2 -17
- package/dist/lib/workflow-starter-docs.js.map +1 -1
- package/dist/lib/workflows.d.ts +9 -14
- package/dist/lib/workflows.d.ts.map +1 -1
- package/dist/lib/workflows.js +15 -30
- package/dist/lib/workflows.js.map +1 -1
- package/dist/lib/workspace-compile.d.ts +51 -0
- package/dist/lib/workspace-compile.d.ts.map +1 -0
- package/dist/lib/workspace-compile.js +397 -0
- package/dist/lib/workspace-compile.js.map +1 -0
- package/package.json +9 -9
- package/skills/benchmark/SKILL.md +20 -27
- package/skills/workflow/create/SKILL.md +10 -14
- package/skills/workspace/shape/SKILL.md +15 -0
- package/skills/workspace/structure/SKILL.md +15 -0
- package/skills/workspace/summarize/SKILL.md +15 -0
- package/templates/workspace/README.md +23 -0
- package/templates/workspace/interfignore +2 -0
- package/dist/commands/benchmark.d.ts +0 -3
- package/dist/commands/benchmark.d.ts.map +0 -1
- package/dist/commands/benchmark.js +0 -374
- package/dist/commands/benchmark.js.map +0 -1
- package/dist/lib/bundled-templates.d.ts +0 -5
- package/dist/lib/bundled-templates.d.ts.map +0 -1
- package/dist/lib/bundled-templates.js +0 -23
- package/dist/lib/bundled-templates.js.map +0 -1
- package/dist/lib/interf-compile-plan.d.ts +0 -12
- package/dist/lib/interf-compile-plan.d.ts.map +0 -1
- package/dist/lib/interf-compile-plan.js +0 -143
- package/dist/lib/interf-compile-plan.js.map +0 -1
- package/dist/lib/validate-interface.d.ts +0 -79
- package/dist/lib/validate-interface.d.ts.map +0 -1
- package/dist/lib/validate-interface.js +0 -535
- package/dist/lib/validate-interface.js.map +0 -1
- package/dist/lib/validate-kb.d.ts.map +0 -1
- package/dist/lib/validate-kb.js +0 -252
- package/dist/lib/validate-kb.js.map +0 -1
- package/dist/lib/workflows-interface-contracts.d.ts +0 -24
- package/dist/lib/workflows-interface-contracts.d.ts.map +0 -1
- package/dist/lib/workflows-interface-contracts.js +0 -304
- package/dist/lib/workflows-interface-contracts.js.map +0 -1
- package/dist/lib/workflows-interface.d.ts +0 -72
- package/dist/lib/workflows-interface.d.ts.map +0 -1
- package/dist/lib/workflows-interface.js +0 -377
- package/dist/lib/workflows-interface.js.map +0 -1
- package/dist/lib/workflows-kb.d.ts +0 -50
- package/dist/lib/workflows-kb.d.ts.map +0 -1
- package/dist/lib/workflows-kb.js +0 -306
- package/dist/lib/workflows-kb.js.map +0 -1
- package/skills/interface/analyze/SKILL.md +0 -191
- package/skills/interface/compile/SKILL.md +0 -152
- package/skills/interface/compile/references/output-format.md +0 -48
- package/skills/interface/create/SKILL.md +0 -87
- package/skills/interface/create/references/compile-plan-format.md +0 -109
- package/skills/interface/create/references/workflows.md +0 -35
- package/skills/interface/query/SKILL.md +0 -48
- package/skills/interface/retrieve/SKILL.md +0 -133
- package/skills/knowledge-base/compile/SKILL.md +0 -196
- package/skills/knowledge-base/compile/references/output-format.md +0 -48
- package/skills/knowledge-base/compile/references/stage-claims.md +0 -60
- package/skills/knowledge-base/compile/references/stage-entities.md +0 -46
- package/skills/knowledge-base/query/SKILL.md +0 -45
- package/skills/knowledge-base/summarize/SKILL.md +0 -152
- package/templates/interface/README.md +0 -159
- package/templates/interface/interfaces.md +0 -102
- package/templates/knowledge-base/README.md +0 -137
- package/templates/knowledge-base/interfignore +0 -19
- package/templates/knowledge-base/registry.md +0 -118
- package/templates/workflow-package/README.md +0 -16
- package/templates/workflow-package/create/SKILL.md +0 -8
- package/templates/workflow-package/interface-query/SKILL.md +0 -29
- package/templates/workflow-package/interface-stage/SKILL.md +0 -13
- package/templates/workflow-package/knowledge-base-query/SKILL.md +0 -36
- package/templates/workflow-package/knowledge-base-stage/SKILL.md +0 -13
- package/templates/workflow-starters/interface/interf/README.md +0 -13
- package/templates/workflow-starters/interface/interf/create/SKILL.md +0 -15
- package/templates/workflow-starters/knowledge-base/interf/README.md +0 -13
- package/templates/workflow-starters/knowledge-base/karpathy/README.md +0 -13
package/dist/lib/workflows-kb.js
DELETED
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import { join } from "node:path";
|
|
2
|
-
import { countFilesRecursive } from "./filesystem.js";
|
|
3
|
-
import { readInterfConfig, refreshWorkspaceBootstrapGuidance, resolveKnowledgeBaseSourcePath, } from "./interf.js";
|
|
4
|
-
import { buildSummarizePlan, writeSummarizePlan } from "./summarize-plan.js";
|
|
5
|
-
import { reconcileKnowledgeBaseCompileRun, reconcileKnowledgeBaseSummarizeRun, } from "./runtime-reconcile.js";
|
|
6
|
-
import { loadState, refreshKnowledgeBaseArtifacts, } from "./state.js";
|
|
7
|
-
import { buildKnowledgeBaseSummarizeContract, validateStageContractAcceptance, } from "./runtime.js";
|
|
8
|
-
import { readJsonFileUnchecked } from "./parse.js";
|
|
9
|
-
import { formatKnowledgeBaseWorkflowStageStep, getKnowledgeBaseWorkflow, getWorkflowStagePolicyNotes, resolveKnowledgeBaseWorkflowFromConfig, } from "./workflow-definitions.js";
|
|
10
|
-
import { validateKnowledgeBaseSummarize, validateKnowledgeBaseCompile, } from "./validate.js";
|
|
11
|
-
import { reportLine, reportBlankLine, reportValidationFailure, buildLocalSkillContractExtension, buildStageInstructions, bundledSkillForContractType, resolveStageAcceptance, workflowCompileStageDirectory, } from "./workflow-helpers.js";
|
|
12
|
-
import { executeValidatedStage, executeValidatedSummarizeStage, findStageByContractType, } from "./workflow-stage-runner.js";
|
|
13
|
-
// ---------------------------------------------------------------------------
|
|
14
|
-
// KB-specific helpers
|
|
15
|
-
// ---------------------------------------------------------------------------
|
|
16
|
-
export function resolveKnowledgeBaseContext(knowledgeBasePath) {
|
|
17
|
-
const config = readInterfConfig(knowledgeBasePath);
|
|
18
|
-
const workflowId = resolveKnowledgeBaseWorkflowFromConfig(config);
|
|
19
|
-
return {
|
|
20
|
-
knowledgeBaseName: config?.name ?? "knowledge-base",
|
|
21
|
-
sourcePath: resolveKnowledgeBaseSourcePath(knowledgeBasePath, config),
|
|
22
|
-
workflowId,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
export function knowledgeBaseExecutionStages(workflowId, knowledgeBasePath) {
|
|
26
|
-
return getKnowledgeBaseWorkflow(workflowId, { workspacePath: knowledgeBasePath }).stages;
|
|
27
|
-
}
|
|
28
|
-
function readKnowledgeBaseInventoryTotal(knowledgeBasePath) {
|
|
29
|
-
const inventory = readJsonFileUnchecked(join(knowledgeBasePath, ".interf", "inventory.json"), "knowledge-base inventory");
|
|
30
|
-
if (!inventory)
|
|
31
|
-
return 0;
|
|
32
|
-
if (typeof inventory.total === "number")
|
|
33
|
-
return inventory.total;
|
|
34
|
-
if (typeof inventory.summary_total === "number")
|
|
35
|
-
return inventory.summary_total;
|
|
36
|
-
if (Array.isArray(inventory.entries))
|
|
37
|
-
return inventory.entries.length;
|
|
38
|
-
if (Array.isArray(inventory.summaries))
|
|
39
|
-
return inventory.summaries.length;
|
|
40
|
-
if (Array.isArray(inventory.files))
|
|
41
|
-
return inventory.files.length;
|
|
42
|
-
return 0;
|
|
43
|
-
}
|
|
44
|
-
function isKnowledgeBaseSummarizeStageComplete(knowledgeBasePath, expectedSummaryTotal) {
|
|
45
|
-
const validation = validateKnowledgeBaseSummarize(knowledgeBasePath);
|
|
46
|
-
const acceptance = validateStageContractAcceptance(knowledgeBasePath);
|
|
47
|
-
const state = loadState(knowledgeBasePath);
|
|
48
|
-
const inventoryTotal = readKnowledgeBaseInventoryTotal(knowledgeBasePath);
|
|
49
|
-
return Boolean(validation.ok &&
|
|
50
|
-
acceptance.ok &&
|
|
51
|
-
state?.inventory_complete === true &&
|
|
52
|
-
typeof state.last_summarize === "string" &&
|
|
53
|
-
state.last_summarize.length > 0 &&
|
|
54
|
-
(state.summarized ?? 0) >= expectedSummaryTotal &&
|
|
55
|
-
inventoryTotal >= expectedSummaryTotal);
|
|
56
|
-
}
|
|
57
|
-
// ---------------------------------------------------------------------------
|
|
58
|
-
// KB compile contract builder
|
|
59
|
-
// ---------------------------------------------------------------------------
|
|
60
|
-
export function buildKnowledgeBaseCompileContract(knowledgeBasePath, workflowId, summaryCount, instructions, stageId = "compile", stageSkillDir = "compile") {
|
|
61
|
-
const sourcePath = resolveKnowledgeBaseSourcePath(knowledgeBasePath);
|
|
62
|
-
const acceptance = resolveStageAcceptance("knowledge-base", workflowId, stageId, sourcePath, knowledgeBasePath);
|
|
63
|
-
const localSkills = buildLocalSkillContractExtension(knowledgeBasePath, [workflowCompileStageDirectory(stageSkillDir)], "Use them to refine knowledge-base compile behavior, entity/claim extraction, and retrieval structure.");
|
|
64
|
-
return {
|
|
65
|
-
instructions,
|
|
66
|
-
counts: {
|
|
67
|
-
summary_total: summaryCount,
|
|
68
|
-
local_skill_docs: localSkills.count,
|
|
69
|
-
},
|
|
70
|
-
...(acceptance ? { acceptance } : {}),
|
|
71
|
-
artifacts: {
|
|
72
|
-
reads: [
|
|
73
|
-
"interf.json",
|
|
74
|
-
"summaries/",
|
|
75
|
-
...localSkills.reads,
|
|
76
|
-
],
|
|
77
|
-
writes: [
|
|
78
|
-
".interf/inventory.json",
|
|
79
|
-
"knowledge/entities/",
|
|
80
|
-
"knowledge/claims/",
|
|
81
|
-
"knowledge/indexes/",
|
|
82
|
-
"home.md",
|
|
83
|
-
],
|
|
84
|
-
verifies: [
|
|
85
|
-
"interf verify compile --json",
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
policies: {
|
|
89
|
-
execution_mode: "deterministic",
|
|
90
|
-
status_prefixes: ["STATUS:", "DONE:", "BLOCKED:", "ERROR:"],
|
|
91
|
-
notes: [
|
|
92
|
-
"Build or refresh `.interf/inventory.json` first, then use it as the progress ledger for the rest of the run.",
|
|
93
|
-
"Prefer the current inventory runtime shape: `.interf/inventory.json` should use `entries` plus `total`, and each entry should carry `source`, `summary`, `frontmatter_scanned: true`, and the abstract/overview-read proof needed for compile verification.",
|
|
94
|
-
"This stage is the knowledge-base compile pass. Treat synthesis outputs as evidence objects, not final truth.",
|
|
95
|
-
"Use a multi-pass approach: inventory -> local evidence reading -> canonicalization -> retrieval optimization.",
|
|
96
|
-
"Build retrieval-oriented outputs: canonical entities, cross-file claims, timelines, themes, and navigation indexes that make interface retrieval easier later.",
|
|
97
|
-
"Write structured knowledge outputs under `knowledge/entities/`, `knowledge/claims/`, and `knowledge/indexes/`.",
|
|
98
|
-
"Do not collapse the knowledge-base knowledge layer into flat files like `knowledge/entities.md` or `knowledge/claims.md`.",
|
|
99
|
-
"Do not start compile by deleting prior outputs with `rm`, wildcard cleanup, `;`, or `&&` chains. Rewrite the required files directly and remove stale artifacts only with narrow, explicit path writes when truly needed.",
|
|
100
|
-
...(summaryCount <= 3
|
|
101
|
-
? [
|
|
102
|
-
`This run has ${summaryCount} summary file${summaryCount === 1 ? "" : "s"}. Treat it as a tiny compile: read every summary overview, write the smallest truthful substrate immediately, then stop.`,
|
|
103
|
-
"For a tiny compile, do not spend time designing a broad ontology or rereading the same evidence loop. A compact landing layer plus a small grounded retrieval surface is enough.",
|
|
104
|
-
"For a tiny compile, finish as soon as `home.md`, the stable core indexes, and at least one grounded entity or claim note exist together with a valid inventory.",
|
|
105
|
-
]
|
|
106
|
-
: []),
|
|
107
|
-
...getWorkflowStagePolicyNotes("knowledge-base", workflowId, stageId, sourcePath, knowledgeBasePath),
|
|
108
|
-
...localSkills.notes,
|
|
109
|
-
],
|
|
110
|
-
evidence_weighting: {
|
|
111
|
-
required_fields: ["source_kind", "evidence_tier", "truth_mode", "state"],
|
|
112
|
-
preserve_tiers: true,
|
|
113
|
-
},
|
|
114
|
-
working_set: {
|
|
115
|
-
target_context_fraction: 0.4,
|
|
116
|
-
strategy: "Batch summary reads into bounded working sets, then canonicalize and optimize retrieval in multiple passes.",
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
// ---------------------------------------------------------------------------
|
|
122
|
-
// KB orchestration functions
|
|
123
|
-
// ---------------------------------------------------------------------------
|
|
124
|
-
export async function runKnowledgeBaseSummarize(options) {
|
|
125
|
-
const context = resolveKnowledgeBaseContext(options.knowledgeBasePath);
|
|
126
|
-
const sourcePath = options.sourcePath ?? context.sourcePath;
|
|
127
|
-
const workflowId = context.workflowId;
|
|
128
|
-
const stageDefinition = options.stageDefinition ?? findStageByContractType(knowledgeBaseExecutionStages(workflowId, options.knowledgeBasePath), "kb-file-evidence");
|
|
129
|
-
const stageStatusLabel = stageDefinition.label.toLowerCase();
|
|
130
|
-
const plan = buildSummarizePlan(sourcePath, options.knowledgeBasePath, options.fullPass ? "all" : "pending");
|
|
131
|
-
const expectedSummaryTotal = plan.summaryCount + plan.targetCount;
|
|
132
|
-
const planPath = writeSummarizePlan(options.knowledgeBasePath, plan);
|
|
133
|
-
const localSkills = buildLocalSkillContractExtension(options.knowledgeBasePath, [workflowCompileStageDirectory(stageDefinition.skillDir)], "Use them to refine summary structure, evidence grouping, and summarization heuristics.");
|
|
134
|
-
const instructions = buildStageInstructions(bundledSkillForContractType(stageDefinition.contractType), localSkills);
|
|
135
|
-
if (options.reportSummary !== false) {
|
|
136
|
-
reportLine(options.reporter, `${plan.sourceCount} source files, ${plan.summaryCount} summarized, ${plan.targetCount} to summarize`);
|
|
137
|
-
}
|
|
138
|
-
if (plan.targetCount === 0) {
|
|
139
|
-
refreshKnowledgeBaseArtifacts(options.knowledgeBasePath, { ensureViewSpec: true });
|
|
140
|
-
const validation = validateKnowledgeBaseSummarize(options.knowledgeBasePath);
|
|
141
|
-
if (options.reportStep !== false) {
|
|
142
|
-
reportLine(options.reporter, `${formatKnowledgeBaseWorkflowStageStep(workflowId, stageDefinition.id, { sourcePath })} skipped (no work required)`);
|
|
143
|
-
}
|
|
144
|
-
if (!validation.ok) {
|
|
145
|
-
reportValidationFailure(options.reporter, validation.summary);
|
|
146
|
-
}
|
|
147
|
-
return {
|
|
148
|
-
ok: validation.ok,
|
|
149
|
-
code: validation.ok ? 0 : 1,
|
|
150
|
-
skipped: true,
|
|
151
|
-
plan,
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
if (options.reportStep !== false) {
|
|
155
|
-
reportLine(options.reporter, `${formatKnowledgeBaseWorkflowStageStep(workflowId, stageDefinition.id, { sourcePath })} (${plan.targetCount} files)`);
|
|
156
|
-
}
|
|
157
|
-
const stageResult = await executeValidatedSummarizeStage({
|
|
158
|
-
executor: options.executor,
|
|
159
|
-
workspacePath: options.knowledgeBasePath,
|
|
160
|
-
targetType: "knowledge-base",
|
|
161
|
-
targetName: context.knowledgeBaseName,
|
|
162
|
-
workflow: workflowId,
|
|
163
|
-
workflowSourcePath: sourcePath,
|
|
164
|
-
stageDefinition,
|
|
165
|
-
instructions,
|
|
166
|
-
summary: `Preparing ${stageDefinition.label.toLowerCase()} for ${plan.targetCount} source files.`,
|
|
167
|
-
contract: buildKnowledgeBaseSummarizeContract({
|
|
168
|
-
knowledgeBaseName: context.knowledgeBaseName,
|
|
169
|
-
targetCount: plan.targetCount,
|
|
170
|
-
expectedSummaryTotal,
|
|
171
|
-
sourcePath,
|
|
172
|
-
planPath,
|
|
173
|
-
workflowNotes: getWorkflowStagePolicyNotes("knowledge-base", workflowId, stageDefinition.id, sourcePath, options.knowledgeBasePath),
|
|
174
|
-
localSkillDocs: localSkills.reads,
|
|
175
|
-
instructions,
|
|
176
|
-
acceptance: resolveStageAcceptance("knowledge-base", workflowId, stageDefinition.id, sourcePath, options.knowledgeBasePath),
|
|
177
|
-
}),
|
|
178
|
-
statusLines: [
|
|
179
|
-
`Emit exactly one startup line: STATUS: loaded ${stageStatusLabel} plan ${plan.targetCount} files.`,
|
|
180
|
-
"The CLI owns live file-count progress. Do not emit per-file progress.",
|
|
181
|
-
"If `.interf/inventory.json` already exists, overwrite it completely instead of patching prior contents.",
|
|
182
|
-
"Emit STATUS: batch committed after a completed batch has been merged into summaries/ and inventory.",
|
|
183
|
-
`Emit DONE: ${stageStatusLabel} complete ${plan.targetCount}/${plan.targetCount} when finished.`,
|
|
184
|
-
],
|
|
185
|
-
reporter: options.reporter,
|
|
186
|
-
completionCheck: () => isKnowledgeBaseSummarizeStageComplete(options.knowledgeBasePath, expectedSummaryTotal),
|
|
187
|
-
reconcile: () => reconcileKnowledgeBaseSummarizeRun(options.knowledgeBasePath, expectedSummaryTotal),
|
|
188
|
-
refreshArtifacts: () => refreshKnowledgeBaseArtifacts(options.knowledgeBasePath, { ensureViewSpec: true }),
|
|
189
|
-
validate: () => validateKnowledgeBaseSummarize(options.knowledgeBasePath),
|
|
190
|
-
startingSummaryCount: plan.summaryCount,
|
|
191
|
-
targetCount: plan.targetCount,
|
|
192
|
-
});
|
|
193
|
-
if (!stageResult.ok) {
|
|
194
|
-
return {
|
|
195
|
-
ok: false,
|
|
196
|
-
code: stageResult.code,
|
|
197
|
-
skipped: false,
|
|
198
|
-
plan,
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
return {
|
|
202
|
-
ok: true,
|
|
203
|
-
code: 0,
|
|
204
|
-
skipped: false,
|
|
205
|
-
plan,
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
export async function runKnowledgeBaseCompile(options) {
|
|
209
|
-
const knowledgeBaseConfig = readInterfConfig(options.knowledgeBasePath);
|
|
210
|
-
const knowledgeBaseName = knowledgeBaseConfig?.name ?? "knowledge-base";
|
|
211
|
-
const workflowId = resolveKnowledgeBaseWorkflowFromConfig(knowledgeBaseConfig);
|
|
212
|
-
const sourcePath = options.sourcePath ?? resolveKnowledgeBaseSourcePath(options.knowledgeBasePath, knowledgeBaseConfig);
|
|
213
|
-
const stageDefinition = options.stageDefinition ?? findStageByContractType(knowledgeBaseExecutionStages(workflowId, options.knowledgeBasePath), "kb-knowledge-layer");
|
|
214
|
-
const stageStatusLabel = stageDefinition.label.toLowerCase();
|
|
215
|
-
const summaryCount = countFilesRecursive(join(options.knowledgeBasePath, "summaries"));
|
|
216
|
-
if (options.reportStep !== false) {
|
|
217
|
-
reportBlankLine(options.reporter);
|
|
218
|
-
reportLine(options.reporter, `${formatKnowledgeBaseWorkflowStageStep(workflowId, stageDefinition.id, { sourcePath })} (building graph)`);
|
|
219
|
-
}
|
|
220
|
-
const instructions = buildStageInstructions(bundledSkillForContractType(stageDefinition.contractType), buildLocalSkillContractExtension(options.knowledgeBasePath, [workflowCompileStageDirectory(stageDefinition.skillDir)], "Use them to refine knowledge-base compile behavior, entity/claim extraction, and retrieval structure."));
|
|
221
|
-
return executeValidatedStage({
|
|
222
|
-
executor: options.executor,
|
|
223
|
-
workspacePath: options.knowledgeBasePath,
|
|
224
|
-
targetType: "knowledge-base",
|
|
225
|
-
targetName: knowledgeBaseName,
|
|
226
|
-
workflow: workflowId,
|
|
227
|
-
workflowSourcePath: sourcePath,
|
|
228
|
-
stageDefinition,
|
|
229
|
-
instructions,
|
|
230
|
-
summary: `Preparing ${stageDefinition.label.toLowerCase()} for ${summaryCount} summary files.`,
|
|
231
|
-
contract: buildKnowledgeBaseCompileContract(options.knowledgeBasePath, workflowId, summaryCount, instructions, stageDefinition.id, stageDefinition.skillDir),
|
|
232
|
-
statusLines: [
|
|
233
|
-
`Emit exactly one startup line: STATUS: loaded ${stageStatusLabel} plan ${summaryCount} summary files.`,
|
|
234
|
-
`Emit STATUS: inventoried summaries ${summaryCount}/${summaryCount} after the inventory pass completes.`,
|
|
235
|
-
`Emit STATUS: read summary files X/${summaryCount} after each deep-read batch or every 25 files, whichever comes first.`,
|
|
236
|
-
`Emit STATUS: wrote ${stageStatusLabel} outputs after knowledge/ and home.md are updated.`,
|
|
237
|
-
`Emit DONE: ${stageStatusLabel} complete ${summaryCount}/${summaryCount} when the required outputs are on disk.`,
|
|
238
|
-
],
|
|
239
|
-
reporter: options.reporter,
|
|
240
|
-
completionCheck: () => validateKnowledgeBaseCompile(options.knowledgeBasePath).ok &&
|
|
241
|
-
validateStageContractAcceptance(options.knowledgeBasePath).ok,
|
|
242
|
-
reconcile: () => reconcileKnowledgeBaseCompileRun(options.knowledgeBasePath),
|
|
243
|
-
refreshArtifacts: () => refreshKnowledgeBaseArtifacts(options.knowledgeBasePath, { ensureViewSpec: true }),
|
|
244
|
-
validate: () => validateKnowledgeBaseCompile(options.knowledgeBasePath),
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
export async function compileKnowledgeBase(options) {
|
|
248
|
-
refreshWorkspaceBootstrapGuidance(options.knowledgeBasePath);
|
|
249
|
-
const { sourcePath, workflowId } = resolveKnowledgeBaseContext(options.knowledgeBasePath);
|
|
250
|
-
const stages = knowledgeBaseExecutionStages(workflowId, options.knowledgeBasePath);
|
|
251
|
-
let summarize = {
|
|
252
|
-
ok: true,
|
|
253
|
-
code: 0,
|
|
254
|
-
skipped: true,
|
|
255
|
-
plan: buildSummarizePlan(sourcePath, options.knowledgeBasePath),
|
|
256
|
-
};
|
|
257
|
-
let compile = null;
|
|
258
|
-
let evidencePassCount = 0;
|
|
259
|
-
for (const stageDefinition of stages) {
|
|
260
|
-
if (stageDefinition.contractType === "kb-file-evidence") {
|
|
261
|
-
summarize = await runKnowledgeBaseSummarize({
|
|
262
|
-
executor: options.executor,
|
|
263
|
-
knowledgeBasePath: options.knowledgeBasePath,
|
|
264
|
-
sourcePath,
|
|
265
|
-
reporter: options.reporter,
|
|
266
|
-
reportSummary: evidencePassCount === 0,
|
|
267
|
-
reportStep: true,
|
|
268
|
-
stageDefinition,
|
|
269
|
-
fullPass: evidencePassCount > 0,
|
|
270
|
-
});
|
|
271
|
-
evidencePassCount += 1;
|
|
272
|
-
if (!summarize.ok) {
|
|
273
|
-
return {
|
|
274
|
-
ok: false,
|
|
275
|
-
summarize,
|
|
276
|
-
compile: null,
|
|
277
|
-
failedStage: stageDefinition.id,
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
continue;
|
|
281
|
-
}
|
|
282
|
-
compile = await runKnowledgeBaseCompile({
|
|
283
|
-
executor: options.executor,
|
|
284
|
-
knowledgeBasePath: options.knowledgeBasePath,
|
|
285
|
-
sourcePath,
|
|
286
|
-
reporter: options.reporter,
|
|
287
|
-
reportStep: true,
|
|
288
|
-
stageDefinition,
|
|
289
|
-
});
|
|
290
|
-
if (!compile.ok) {
|
|
291
|
-
return {
|
|
292
|
-
ok: false,
|
|
293
|
-
summarize,
|
|
294
|
-
compile,
|
|
295
|
-
failedStage: stageDefinition.id,
|
|
296
|
-
};
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
return {
|
|
300
|
-
ok: compile?.ok ?? summarize.ok,
|
|
301
|
-
summarize,
|
|
302
|
-
compile,
|
|
303
|
-
failedStage: null,
|
|
304
|
-
};
|
|
305
|
-
}
|
|
306
|
-
//# sourceMappingURL=workflows-kb.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"workflows-kb.js","sourceRoot":"","sources":["../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AAC,OAAO,CAAC,EAAE,EAAE,CAAC;YAChB,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,SAAS;gBACT,OAAO;gBACP,WAAW,EAAE,eAAe,CAAC,EAAE;aAChC,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO;QACL,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,SAAS,CAAC,EAAE;QAC/B,SAAS;QACT,OAAO;QACP,WAAW,EAAE,IAAI;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
{
|
|
3
|
-
"name": "interface/analyze",
|
|
4
|
-
"description": "Interface analysis contract. Deep analysis of relevant summaries from the knowledge base. Reads delta files from state, batches them, and extracts entities and claims for this interface's ontology. Use when asked to analyze, extract, or run an analysis stage inside interface compile."
|
|
5
|
-
}
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# Interface Compile — Analyze
|
|
9
|
-
|
|
10
|
-
Read `interf.json`, `compile-plan.md`, and `.interf/relevant.json` for the current target set from the preceding retrieval stage.
|
|
11
|
-
|
|
12
|
-
Local runtime reference:
|
|
13
|
-
- active stage contract: `.interf/stage-contract.json`
|
|
14
|
-
- active run ledger: `.interf/run.json`
|
|
15
|
-
- local config: `interf.json`
|
|
16
|
-
- local plan: `compile-plan.md`
|
|
17
|
-
- local instruction docs: the files listed by `.interf/stage-contract.json`
|
|
18
|
-
|
|
19
|
-
When this skill is embedded into a generated interface, do not try to open SDK repo docs or source files outside the current workspace. The local contract and local docs are the source of truth for this run.
|
|
20
|
-
|
|
21
|
-
This skill does the deep analysis — reading summaries and extracting what matters for this interface. It may refine the interface runtime after the requested target set is classified, but bounded audits should close the named task before widening scope.
|
|
22
|
-
If `../../.interf/source-access.json` exists, use it as the quick check for whether raw paths are actually reachable from this session before assuming raw fallback will work.
|
|
23
|
-
If local docs are listed by the stage contract, read them before analyzing. They may `extend` or `override` the bundled workflow instructions for this stage, but they do not bypass coverage proof or the stage contract.
|
|
24
|
-
|
|
25
|
-
Harness role:
|
|
26
|
-
- This skill is an internal harness step normally invoked by `interf compile` from inside an interface.
|
|
27
|
-
- For standard operation, prefer the CLI or another higher-level tool over calling this skill directly.
|
|
28
|
-
|
|
29
|
-
## Runtime contract
|
|
30
|
-
|
|
31
|
-
When invoked by the CLI, honor any explicit execution instructions in the prompt. In particular:
|
|
32
|
-
- if `.interf/stage-contract.json` exists, treat it as the authoritative stage contract for this run
|
|
33
|
-
- if the prompt gives an expected analysis set size, use it for progress reporting
|
|
34
|
-
- use `.interf/relevant.json` as the source of truth for `relevant_files` and `delta_files`
|
|
35
|
-
- require `.interf/coverage.json` and `coverage_complete: true` as proof that retrieve reached retrieval closure
|
|
36
|
-
- only emit user-facing lines that start with `STATUS:`, `DONE:`, `BLOCKED:`, or `ERROR:`
|
|
37
|
-
- the CLI reconciles `.interf/state.json` and refreshes `.interf/health.json` after validation; do not treat those files as stage-owned write targets for analyze
|
|
38
|
-
- before any long-running raw inspection, PDF/chart extraction, OCR, or shell-based helper step, emit a `STATUS:` line naming the current subtask
|
|
39
|
-
- do not stay silent for more than about one minute while extraction work is still in progress
|
|
40
|
-
- when you switch page groups, markets, chart families, or extraction methods, emit another `STATUS:` line first
|
|
41
|
-
- do not keep reopening the same large raw PDF once the relevant pages are known; switch to a narrower page-bounded extraction step instead
|
|
42
|
-
- avoid long inline Bash heredocs for extraction helpers; prefer one page-bounded command per step, or write a short scratch script file and run it explicitly
|
|
43
|
-
|
|
44
|
-
## Prerequisites
|
|
45
|
-
|
|
46
|
-
`.interf/relevant.json` and `.interf/coverage.json` must exist. If not: "Run the retrieval stage first." Stop.
|
|
47
|
-
|
|
48
|
-
Before analyzing, prefer running:
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
interf verify retrieve --json
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
If it fails, stop and fix the retrieval proof instead of continuing.
|
|
55
|
-
|
|
56
|
-
## Steps
|
|
57
|
-
|
|
58
|
-
```
|
|
59
|
-
Analyze:
|
|
60
|
-
- [ ] 1. Read retrieve proof and plan
|
|
61
|
-
- [ ] 2. Load summaries in bounded working sets
|
|
62
|
-
- [ ] 3. Extract entities, claims, and relationships
|
|
63
|
-
- [ ] 4. Refine runtime where evidence demands it
|
|
64
|
-
- [ ] 5. Merge results
|
|
65
|
-
- [ ] 6. Write analysis handoff
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### 1. Read retrieve proof and plan
|
|
69
|
-
|
|
70
|
-
- `.interf/relevant.json` → `delta_files[]` (or all `relevant_files[]` when delta is conservative)
|
|
71
|
-
- `.interf/coverage.json` → proof of scanned summary set, abstract review, and expansion passes
|
|
72
|
-
- `compile-plan.md` → this stage's section: what to extract (entity types, claim types, relationships)
|
|
73
|
-
- `../../.interf/source-access.json` → sample raw paths and suggested access checks when raw fallback is needed
|
|
74
|
-
- local instruction docs listed by the stage contract
|
|
75
|
-
- treat the plan as the starting ontology
|
|
76
|
-
- if the plan names a bounded audit target set, treat that set as the hard default scope until every requested value is classified as exact, approximate, or unresolved
|
|
77
|
-
- if the plan includes a target ledger, use it as the primary checklist and record one result per target
|
|
78
|
-
- if the plan depends on exact figures from PDFs, charts, or tables, raw inspection is part of analysis for those items, not an optional afterthought
|
|
79
|
-
- for exact-value PDF work, reading raw pages with `Read` confirms location and context, but it does not by itself satisfy the extraction requirement
|
|
80
|
-
- choose the local extraction path from whatever the current environment actually supports; do not assume a specific binary or hardcode shell recipes into the answer
|
|
81
|
-
- before locking in a machine-readable path, verify that the local method is actually available in this environment; if it is missing or blocked, count that as one failed path and switch to another available local method
|
|
82
|
-
|
|
83
|
-
### 2. Load summaries in bounded working sets
|
|
84
|
-
|
|
85
|
-
Read full abstract + overview for each delta file.
|
|
86
|
-
Summaries are the default evidence surface, but if the plan requires exact chart/table values and the summaries do not preserve them, inspect the raw source for those specific items and record how the values were derived.
|
|
87
|
-
Do not treat `the summary was coarse` as proof that the source lacks the number.
|
|
88
|
-
When exact chart values matter, the analysis is not complete until you either recover the value more precisely or record why the local environment blocked a machine-readable attempt.
|
|
89
|
-
Keep raw probing focused. Do not dump large SVG, PDF, or OCR bodies into the run log. Extract the needed values, calibration anchors, and method notes only.
|
|
90
|
-
If the plan names a bounded target set, keep the extraction bounded to that set. Do not widen to every market, page, or entity in the report unless one extra comparator or calibration anchor is required to answer the task correctly.
|
|
91
|
-
For bounded audits, do not widen the ontology, taxonomy, or target set until the requested values are classified or a concrete blocker has been recorded.
|
|
92
|
-
Treat metric plus period as part of the target identity. A nearby exact figure with the wrong period, wrong unit, or wrong chart family does not satisfy the target and must remain separate supporting context.
|
|
93
|
-
As soon as each target row is classified as exact, approximate, or unresolved, stop extraction and move directly to the required file writes. Do not spend extra turns polishing, re-reading, or chasing more precision after the ledger is complete.
|
|
94
|
-
|
|
95
|
-
### Exact-value escalation for PDFs and charts
|
|
96
|
-
|
|
97
|
-
If the task asks for exact chart or table values:
|
|
98
|
-
- opening the PDF with `Read` is only the first step; it does not count as the machine-readable extraction attempt
|
|
99
|
-
- a concrete local extraction path is the default path rather than an optional enhancement
|
|
100
|
-
- before each new page group, market batch, or extraction method, emit a short `STATUS:` line so the run ledger shows where extraction is currently focused
|
|
101
|
-
- use `Read` on the raw PDF to confirm location, context, or a narrow page group only; once the page map is known, do not keep reopening the full PDF
|
|
102
|
-
- after the page map is known, switch to a page-bounded local extraction helper or scratch file workflow for that page group instead of rereading the whole PDF
|
|
103
|
-
- keep helper commands single-purpose and short. Avoid long inline Bash heredocs; if you need multiple steps, write a short scratch script file first or run separate bounded commands
|
|
104
|
-
- use this ladder in order and do not stop after a single failed extractor:
|
|
105
|
-
1. confirm the relevant pages, chart titles, axes, units, time cuts, and left-to-right target order from the raw PDF
|
|
106
|
-
1a. before locking in values, build a page-level chart map for each target chart: page, chart title, visible axis range/ticks, legend or component series, and whether the chart is stacked
|
|
107
|
-
2. attempt text or table extraction with a local machine-readable method that you have already verified is available in this environment
|
|
108
|
-
3. if the text layer still misses the values, switch to another machine-readable path that fits the source structure and is already available in the environment
|
|
109
|
-
4. if the chart still has no explicit labels, attempt another recoverable extraction path before giving up on exactness
|
|
110
|
-
4a. try at most two machine-readable extraction paths per target or tightly related page group; if both fail, record the blocker and mark the value unresolved instead of escalating indefinitely
|
|
111
|
-
5. when the report contains known anchor values elsewhere (for example Key Stats or Q1/YTD tables), use them to validate calibration before finalizing historical chart values
|
|
112
|
-
6. if the anchor check is materially off, recalibrate or change method instead of locking in a coarse approximation
|
|
113
|
-
7. only then fall back to a visual estimate
|
|
114
|
-
- if the chart is stacked, recover the total stacked height or area unless the request explicitly names one component series; do not treat one colored segment as the requested total
|
|
115
|
-
- if multiple charts share a page, keep a separate chart map and scale for each chart family; never reuse one chart's scale for another chart on the same page
|
|
116
|
-
- when you use shell commands for scratch extraction, keep them single-purpose and non-destructive. Do not start with `rm`, wildcard cleanup, or chained helpers like `;` and `&&`. Prefer fresh temp filenames or directories instead.
|
|
117
|
-
- if a local extraction path is unavailable, blocked, or missing a dependency, record that explicitly, do not retry the same missing path, and either switch once to another available local path or record the blocker
|
|
118
|
-
- do not call a value approximate or unavailable until you have exhausted the extraction ladder or documented a concrete blocker on the local extraction path
|
|
119
|
-
- if you only have an approximation, keep that precision gap visible in the analysis instead of presenting it as final truth
|
|
120
|
-
- if the task only needs a rounded bin, one-decimal chart read, or other answer-grade approximation, and the rendered chart plus visible axis labels already support that answer, stop there instead of drilling deeper into SVG or PDF internals for pseudo-precision
|
|
121
|
-
- if you record an approximate chart value, also record the scale band that supports it, such as `between 0.5 and 0.6, closer to 0.5`, plus any nearby labeled anchors used to choose the rounded value or `bin_choice`
|
|
122
|
-
- if a chart-derived value sits between adjacent one-decimal bins, set `bin_choice` to the closer supported bin and explain that choice in `scale_band` or the notes; do not default to rounding an uncertain midpoint up
|
|
123
|
-
- for approximate chart reads, make `value_display` the answer-grade value a later weak model should quote; keep any finer-grained midpoint guess in `scale_band` or `notes` instead of promoting it into the main display value
|
|
124
|
-
- if the visible chart scale is coarser than the requested display precision, prefer the nearest clearly supported bin or anchor rather than interpolating a prettier in-between tenth that the chart does not really justify
|
|
125
|
-
- if you cannot state which chart title, scale, and total-vs-component interpretation produced the number, keep the target unresolved instead of emitting a confident approximate answer
|
|
126
|
-
- if you widen beyond the named target set, record why in the extraction ledger and stop once that reason is satisfied
|
|
127
|
-
- once every requested value is classified as exact, approximate, or unresolved, stop exploring. Write `.interf/analysis.json`, emit the required status line, and finish the stage.
|
|
128
|
-
- when using scratch extraction files, keep the command output minimal. Write bulk SVG/OCR/PDF output to temp files and inspect only the relevant slices for the target chart rather than streaming whole blobs into the run log.
|
|
129
|
-
|
|
130
|
-
Batching strategy:
|
|
131
|
-
- Prefer a working set budget of roughly 35-45% of the model context window per batch
|
|
132
|
-
- For 100+ files: spawn subagents per batch
|
|
133
|
-
|
|
134
|
-
### 3. Extract entities, claims, and relationships
|
|
135
|
-
|
|
136
|
-
Each batch (or subagent) extracts:
|
|
137
|
-
- Entities relevant to this interface's ontology goals
|
|
138
|
-
- Claims (patterns, decisions, risks, metrics)
|
|
139
|
-
- Relationships between entities
|
|
140
|
-
- Modality notes when it matters: whether a key numeric claim came from prose, tables, or chart/figure extraction
|
|
141
|
-
- Time-cut notes when it matters: whether a value is annual, quarterly, trailing-twelve-month, or another window
|
|
142
|
-
- Precision notes when it matters: exact, approximate, or unresolved
|
|
143
|
-
- For bounded audits, only extract the entities and claims needed for the named targets plus any narrowly justified comparators or calibration anchors
|
|
144
|
-
- For bounded target ledgers, emit one result per requested item with metric, entity, period, source kind, derivation, value, and precision
|
|
145
|
-
|
|
146
|
-
Subagent instruction:
|
|
147
|
-
```
|
|
148
|
-
Analyze these summaries for the {interface-name} interface.
|
|
149
|
-
Ontology goals: {from compile-plan.md}
|
|
150
|
-
Return: entities, claims, relationships as structured list.
|
|
151
|
-
Include summary title as evidence reference.
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### 4. Refine runtime where evidence demands it
|
|
155
|
-
|
|
156
|
-
If repeated evidence shows the interface needs better local structure, propose or record:
|
|
157
|
-
- new ontology branches
|
|
158
|
-
- refined taxonomy labels
|
|
159
|
-
- emergent thread clusters
|
|
160
|
-
- stronger relationship groupings
|
|
161
|
-
|
|
162
|
-
Do not rewrite the runtime gratuitously. Refine only when it helps the interface become a better local context layer for future agents.
|
|
163
|
-
For bounded audit or exact-value tasks, do not widen the runtime before the requested values are classified and the main brief can be written.
|
|
164
|
-
|
|
165
|
-
### 5. Merge results
|
|
166
|
-
|
|
167
|
-
Combine all batch/subagent outputs:
|
|
168
|
-
- Deduplicate entities (same person/company from different batches)
|
|
169
|
-
- Merge evidence for existing entities/claims
|
|
170
|
-
- merge runtime refinements
|
|
171
|
-
- Flag conflicts for manual review
|
|
172
|
-
|
|
173
|
-
### 6. Write analysis handoff
|
|
174
|
-
|
|
175
|
-
Store the merged extraction results in `.interf/analysis.json` (temporary, consumed by the next output stage). Include runtime refinements when present.
|
|
176
|
-
When exact-value PDF or chart work happened, include a raw extraction ledger in `.interf/analysis.json` with enough detail for the compile stage to judge confidence: source path, pages inspected, methods attempted, result, whether a scratch helper was used, and whether each reported value is exact, approximate, or unresolved.
|
|
177
|
-
For chart-derived approximate values, include enough structure in `.interf/analysis.json` for a later reviewer to reconstruct the judgment without reopening the raw file: chart title, whether the chart was stacked, scale band or nearest labeled anchors, and the reason the chosen `bin_choice` is closer than the neighboring bins.
|
|
178
|
-
For bounded target audits, the final write sequence is strict: write `.interf/analysis.json`, emit `STATUS: wrote analyze outputs`, emit `DONE: analyze complete`, and stop.
|
|
179
|
-
|
|
180
|
-
The CLI reconciles `.interf/state.json` and refreshes `.interf/health.json` after validation.
|
|
181
|
-
|
|
182
|
-
Report with status-style lines:
|
|
183
|
-
```
|
|
184
|
-
STATUS: loaded analyze plan N files.
|
|
185
|
-
STATUS: inspecting <current subtask>
|
|
186
|
-
STATUS: analyzed N/N
|
|
187
|
-
STATUS: wrote analysis
|
|
188
|
-
DONE: analyze complete
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
When the analysis artifact is written, emit the required `DONE:` line and stop. The CLI reconciles `.interf/state.json` and refreshes `.interf/health.json` after validation. Do not keep exploring after the analyze contract is satisfied.
|