avorelo 0.1.0 → 0.3.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/LICENSE +23 -16
- package/README.md +90 -51
- package/bin/avorelo.mjs +7 -0
- package/dist/avorelo.mjs +19741 -0
- package/package.json +135 -120
- package/bin/avorelo +0 -9
- package/scripts/README.md +0 -40
- package/scripts/cco-dashboard.js +0 -252
- package/scripts/cco-status.js +0 -430
- package/scripts/lib/activation/account-state.js +0 -37
- package/scripts/lib/activation/activation-runner.js +0 -546
- package/scripts/lib/activation/activation-self-healing.js +0 -480
- package/scripts/lib/activation/activation-state.js +0 -83
- package/scripts/lib/activation/activation-summary.js +0 -191
- package/scripts/lib/activation/adapters/claude-code.js +0 -77
- package/scripts/lib/activation/adapters/codex-cli.js +0 -52
- package/scripts/lib/activation/adapters/cursor.js +0 -37
- package/scripts/lib/activation/adapters/github-agent.js +0 -39
- package/scripts/lib/activation/adapters/terminal.js +0 -42
- package/scripts/lib/activation/adapters/vscode.js +0 -39
- package/scripts/lib/activation/adapters/windsurf.js +0 -37
- package/scripts/lib/activation/ai-surface-detector.js +0 -151
- package/scripts/lib/activation/connect-account.js +0 -145
- package/scripts/lib/activation/detect-environment.js +0 -75
- package/scripts/lib/activation/detect-hosts.js +0 -62
- package/scripts/lib/activation/format-activation-output.js +0 -109
- package/scripts/lib/activation/next-action.js +0 -43
- package/scripts/lib/activation/repair-engine.js +0 -219
- package/scripts/lib/activation-distribution-readiness.js +0 -507
- package/scripts/lib/adapter-conformance.js +0 -176
- package/scripts/lib/adapter-readiness.js +0 -417
- package/scripts/lib/adapter-safety-boundaries.js +0 -335
- package/scripts/lib/adapter-technical-readiness-gate.js +0 -205
- package/scripts/lib/agent-access-governance.js +0 -455
- package/scripts/lib/agent-enforcement.js +0 -765
- package/scripts/lib/agent-policy-profile.js +0 -210
- package/scripts/lib/agent-security/action-evaluator.js +0 -507
- package/scripts/lib/agent-security/adapter-registry.js +0 -98
- package/scripts/lib/agent-security/auto-policy.js +0 -139
- package/scripts/lib/agent-security/bounded-scan.js +0 -93
- package/scripts/lib/agent-security/enforcement-adapter.js +0 -174
- package/scripts/lib/agent-security/enforcement-engine.js +0 -1129
- package/scripts/lib/agent-security/file-write-adapter.js +0 -183
- package/scripts/lib/agent-security/file-write-rules.js +0 -178
- package/scripts/lib/agent-security/index.js +0 -3342
- package/scripts/lib/agent-security/instruction-risk.js +0 -181
- package/scripts/lib/agent-security/mcp-action-adapter.js +0 -185
- package/scripts/lib/agent-security/mcp-action-rules.js +0 -184
- package/scripts/lib/agent-security/package-action-adapter.js +0 -175
- package/scripts/lib/agent-security/package-action-rules.js +0 -233
- package/scripts/lib/agent-security/performance.js +0 -148
- package/scripts/lib/agent-security/permission-minimizer.js +0 -403
- package/scripts/lib/agent-security/scan-cache.js +0 -74
- package/scripts/lib/agent-security/source-trust.js +0 -146
- package/scripts/lib/ai-install-prompt.js +0 -288
- package/scripts/lib/ai-workspace-hygiene.js +0 -1499
- package/scripts/lib/alpha-activation.js +0 -520
- package/scripts/lib/alpha-feedback.js +0 -263
- package/scripts/lib/alpha-readiness-gate.js +0 -332
- package/scripts/lib/anti-gaming.js +0 -169
- package/scripts/lib/artifact-health.js +0 -431
- package/scripts/lib/attribution.js +0 -180
- package/scripts/lib/audit.js +0 -289
- package/scripts/lib/avorelo-skill-registry.js +0 -810
- package/scripts/lib/batch-jobs.js +0 -71
- package/scripts/lib/brain-pack.js +0 -578
- package/scripts/lib/brand-boundary.js +0 -424
- package/scripts/lib/brand.js +0 -74
- package/scripts/lib/browser-capability.js +0 -1048
- package/scripts/lib/browser-proof-preflight.js +0 -321
- package/scripts/lib/cache-readiness.js +0 -187
- package/scripts/lib/canonical-reentry.js +0 -162
- package/scripts/lib/capability-packs.js +0 -314
- package/scripts/lib/capability-recommender.js +0 -512
- package/scripts/lib/capability-registry.js +0 -1059
- package/scripts/lib/carry-forward-surfacing.js +0 -194
- package/scripts/lib/ccusage-adapter.js +0 -188
- package/scripts/lib/company-loop.js +0 -1149
- package/scripts/lib/config.js +0 -637
- package/scripts/lib/context-acquisition-plan.js +0 -287
- package/scripts/lib/context-budget-guard.js +0 -170
- package/scripts/lib/context-budget-scanner.js +0 -257
- package/scripts/lib/context-optimizer.js +0 -715
- package/scripts/lib/context-reduction-plan.js +0 -178
- package/scripts/lib/context-safety.js +0 -88
- package/scripts/lib/context-savings-engine.js +0 -158
- package/scripts/lib/cost-evidence.js +0 -254
- package/scripts/lib/cross-host-install-plan.js +0 -308
- package/scripts/lib/cross-host-install-readiness.js +0 -237
- package/scripts/lib/cross-host-value-flow.js +0 -268
- package/scripts/lib/dashboard.js +0 -900
- package/scripts/lib/design-partner-feedback.js +0 -346
- package/scripts/lib/entitlements.js +0 -100
- package/scripts/lib/execution-packet.js +0 -559
- package/scripts/lib/experimentation-events.js +0 -547
- package/scripts/lib/external-capability-compliance.js +0 -107
- package/scripts/lib/external-user-simulation.js +0 -166
- package/scripts/lib/failure-recovery-readiness.js +0 -81
- package/scripts/lib/failure-recovery.js +0 -419
- package/scripts/lib/feedback-intelligence.js +0 -537
- package/scripts/lib/feedback-signals.js +0 -205
- package/scripts/lib/file-integrity.js +0 -68
- package/scripts/lib/fsx.js +0 -127
- package/scripts/lib/full-readiness-gate.js +0 -451
- package/scripts/lib/guidance-builder.js +0 -174
- package/scripts/lib/hook-apply.js +0 -1019
- package/scripts/lib/hook-baseline.js +0 -310
- package/scripts/lib/hook-config-preview.js +0 -275
- package/scripts/lib/hook-contracts.js +0 -290
- package/scripts/lib/hook-safety-boundary-readiness.js +0 -80
- package/scripts/lib/host-capability-matrix.js +0 -351
- package/scripts/lib/host-support-context.js +0 -254
- package/scripts/lib/http-hook-action.js +0 -538
- package/scripts/lib/install-ai-readiness.js +0 -84
- package/scripts/lib/install-intake-risk.js +0 -1037
- package/scripts/lib/install-journey-intelligence.js +0 -329
- package/scripts/lib/intervention-guidance.js +0 -57
- package/scripts/lib/known-limitations.js +0 -115
- package/scripts/lib/l8-path-truth.js +0 -146
- package/scripts/lib/launch-hardening-gate.js +0 -436
- package/scripts/lib/launch-readiness.js +0 -628
- package/scripts/lib/learning-memory.js +0 -686
- package/scripts/lib/lifecycle-hooks.js +0 -802
- package/scripts/lib/local-package-smoke.js +0 -423
- package/scripts/lib/local-pricing.js +0 -299
- package/scripts/lib/mcp-enforcement.js +0 -311
- package/scripts/lib/mcp-least-privilege-policy.js +0 -303
- package/scripts/lib/mcp-tool-inventory.js +0 -388
- package/scripts/lib/mcp-tool-risk.js +0 -0
- package/scripts/lib/memory.js +0 -335
- package/scripts/lib/metrics.js +0 -699
- package/scripts/lib/micro-proof.js +0 -133
- package/scripts/lib/next-run-context.js +0 -436
- package/scripts/lib/operating-value.js +0 -1648
- package/scripts/lib/optimization-v3.js +0 -122
- package/scripts/lib/orchestration/adapters/_shared.js +0 -49
- package/scripts/lib/orchestration/adapters/aider.js +0 -18
- package/scripts/lib/orchestration/adapters/claude-code.js +0 -35
- package/scripts/lib/orchestration/adapters/codex.js +0 -35
- package/scripts/lib/orchestration/adapters/gemini-cli.js +0 -18
- package/scripts/lib/orchestration/adapters/git.js +0 -25
- package/scripts/lib/orchestration/adapters/index.js +0 -31
- package/scripts/lib/orchestration/adapters/lm-studio.js +0 -18
- package/scripts/lib/orchestration/adapters/ollama.js +0 -18
- package/scripts/lib/orchestration/adapters/opencode.js +0 -18
- package/scripts/lib/orchestration/adapters/openrouter.js +0 -18
- package/scripts/lib/orchestration/adapters/test-runner.js +0 -25
- package/scripts/lib/orchestration/cli.js +0 -438
- package/scripts/lib/orchestration/execution-manager.js +0 -279
- package/scripts/lib/orchestration/handoff.js +0 -314
- package/scripts/lib/orchestration/index.js +0 -456
- package/scripts/lib/orchestration/inventory.js +0 -47
- package/scripts/lib/orchestration/model-discovery.js +0 -498
- package/scripts/lib/orchestration/model-profiler.js +0 -170
- package/scripts/lib/orchestration/model-profiles.js +0 -252
- package/scripts/lib/orchestration/model-refresh-policy.js +0 -72
- package/scripts/lib/orchestration/proof-writer.js +0 -349
- package/scripts/lib/orchestration/provider-discovery/aider.js +0 -49
- package/scripts/lib/orchestration/provider-discovery/claude-code.js +0 -56
- package/scripts/lib/orchestration/provider-discovery/codex.js +0 -49
- package/scripts/lib/orchestration/provider-discovery/common.js +0 -186
- package/scripts/lib/orchestration/provider-discovery/gemini.js +0 -106
- package/scripts/lib/orchestration/provider-discovery/lm-studio.js +0 -118
- package/scripts/lib/orchestration/provider-discovery/models-dev.js +0 -12
- package/scripts/lib/orchestration/provider-discovery/ollama.js +0 -100
- package/scripts/lib/orchestration/provider-discovery/opencode.js +0 -47
- package/scripts/lib/orchestration/provider-discovery/openrouter.js +0 -44
- package/scripts/lib/orchestration/risk-classifier.js +0 -130
- package/scripts/lib/orchestration/routing-policy.js +0 -486
- package/scripts/lib/orchestration/settings.js +0 -112
- package/scripts/lib/orchestration/state.js +0 -165
- package/scripts/lib/orchestration/verification-manager.js +0 -138
- package/scripts/lib/output-profiles.js +0 -146
- package/scripts/lib/package-content-audit.js +0 -368
- package/scripts/lib/package-runtime.js +0 -278
- package/scripts/lib/plan-surface.js +0 -53
- package/scripts/lib/plans.js +0 -2318
- package/scripts/lib/policy-provider.js +0 -27
- package/scripts/lib/prelaunch-activation-readiness.js +0 -409
- package/scripts/lib/prelaunch-evidence-store.js +0 -816
- package/scripts/lib/prelaunch-intelligence.js +0 -869
- package/scripts/lib/pricing-experiment.js +0 -118
- package/scripts/lib/pro-moment-events.js +0 -77
- package/scripts/lib/pro-moment-state.js +0 -227
- package/scripts/lib/pro-moments.js +0 -1216
- package/scripts/lib/product-learning-events.js +0 -629
- package/scripts/lib/project-profile.js +0 -555
- package/scripts/lib/prompt-compiler.js +0 -280
- package/scripts/lib/prompt-lint.js +0 -32
- package/scripts/lib/prompt-suggestions.js +0 -52
- package/scripts/lib/proof-canonical.js +0 -398
- package/scripts/lib/proof-drilldown.js +0 -383
- package/scripts/lib/proof-events.js +0 -342
- package/scripts/lib/proof-history.js +0 -243
- package/scripts/lib/proof-metrics.js +0 -296
- package/scripts/lib/proof-outcome-evidence.js +0 -134
- package/scripts/lib/proof-receipt.js +0 -335
- package/scripts/lib/proof-record.js +0 -461
- package/scripts/lib/public-activation-distribution-gate.js +0 -258
- package/scripts/lib/public-cli.js +0 -3891
- package/scripts/lib/public-distribution-truth.js +0 -211
- package/scripts/lib/public-install-claim-checker.js +0 -294
- package/scripts/lib/publish-provenance-readiness.js +0 -283
- package/scripts/lib/readiness-delta.js +0 -218
- package/scripts/lib/readiness-evidence-closure.js +0 -196
- package/scripts/lib/reentry-memory-capture.js +0 -241
- package/scripts/lib/reentry-memory-retrieval.js +0 -302
- package/scripts/lib/reentry-memory-status.js +0 -146
- package/scripts/lib/reentry-memory-store.js +0 -178
- package/scripts/lib/reentry-state.js +0 -66
- package/scripts/lib/release-candidate-bundle.js +0 -166
- package/scripts/lib/remediation.js +0 -81
- package/scripts/lib/repo-map.js +0 -391
- package/scripts/lib/run-improvements-lifecycle.js +0 -330
- package/scripts/lib/run-improvements.js +0 -789
- package/scripts/lib/runtime-decision-policy.js +0 -387
- package/scripts/lib/safe-path-engine.js +0 -705
- package/scripts/lib/safe-run-controller.js +0 -887
- package/scripts/lib/score.js +0 -262
- package/scripts/lib/seamless-enforcement.js +0 -329
- package/scripts/lib/seamless-outcome.js +0 -689
- package/scripts/lib/seamless-reality-gate.js +0 -5043
- package/scripts/lib/security-risk-classifier.js +0 -511
- package/scripts/lib/security-scan.js +0 -384
- package/scripts/lib/session-context-optimizer.js +0 -1211
- package/scripts/lib/session-timing.js +0 -315
- package/scripts/lib/skill-hygiene.js +0 -805
- package/scripts/lib/skill-packs.js +0 -161
- package/scripts/lib/skills-operating-layer.js +0 -580
- package/scripts/lib/smart-work-routing.js +0 -768
- package/scripts/lib/source-catalog.js +0 -700
- package/scripts/lib/status-value-summary.js +0 -32
- package/scripts/lib/support-bundle.js +0 -578
- package/scripts/lib/task-continuation.js +0 -440
- package/scripts/lib/test-helpers.js +0 -15
- package/scripts/lib/tier.js +0 -38
- package/scripts/lib/token-context-quality-gate.js +0 -370
- package/scripts/lib/token-cost-capture.js +0 -187
- package/scripts/lib/token-cost-intelligence.js +0 -358
- package/scripts/lib/token-efficiency-evidence.js +0 -213
- package/scripts/lib/token-evidence.js +0 -699
- package/scripts/lib/tokenish.js +0 -17
- package/scripts/lib/tool-output-sandbox.js +0 -304
- package/scripts/lib/trust-audit.js +0 -136
- package/scripts/lib/unified-events.js +0 -396
- package/scripts/lib/upgrade-interruption-recovery.js +0 -407
- package/scripts/lib/usage-ledger.js +0 -201
- package/scripts/lib/value-ledger.js +0 -130
- package/scripts/lib/value-proof-calibration.js +0 -531
- package/scripts/lib/visual-qa.js +0 -231
- package/scripts/lib/voice-alpha.js +0 -29
- package/scripts/lib/work-aware-orchestration.js +0 -976
- package/scripts/lib/work-control-receipts.js +0 -577
- package/scripts/lib/work-ledger.js +0 -1123
- package/scripts/lib/work-panel-preview.js +0 -352
- package/scripts/lib/workflow-discipline.js +0 -280
- package/scripts/lib/workflow-signals.js +0 -419
- package/scripts/lib/workspace-map.js +0 -281
- package/scripts/lib/workspace-registry.js +0 -1367
- package/scripts/lib/workspace-resolver.js +0 -480
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// ── Browser Proof Preflight ───────────────────────────────────────────────────
|
|
4
|
-
// Contract: avorelo.browserProofPreflight.v1
|
|
5
|
-
// Answers: "Can avorelo prove value WITHOUT a browser? Is local-first proof path
|
|
6
|
-
// viable? Is browser an optional enhancement (not a requirement)?"
|
|
7
|
-
// PREFLIGHT ONLY — does NOT launch a browser, does NOT start a server,
|
|
8
|
-
// does NOT make network requests.
|
|
9
|
-
|
|
10
|
-
const fs = require("fs");
|
|
11
|
-
const path = require("path");
|
|
12
|
-
const { nowIso } = require("./fsx");
|
|
13
|
-
const { appendProductLearningEvent } = require("./product-learning-events");
|
|
14
|
-
|
|
15
|
-
const CONTRACT = "avorelo.browserProofPreflight.v1";
|
|
16
|
-
const SCHEMA_VERSION = 1;
|
|
17
|
-
const ARTIFACT_DIR_REL = ".claude/cco/orchestration/adapter-readiness";
|
|
18
|
-
const ARTIFACT_REL = ARTIFACT_DIR_REL + "/latest-browser-proof-preflight.json";
|
|
19
|
-
|
|
20
|
-
function safeReadJson(absPath) {
|
|
21
|
-
try {
|
|
22
|
-
if (!fs.existsSync(absPath)) return null;
|
|
23
|
-
return JSON.parse(fs.readFileSync(absPath, "utf8").replace(/^/, ""));
|
|
24
|
-
} catch { return null; }
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function pass(id, label, evidence, detail) {
|
|
28
|
-
return { id, label, status: "pass", evidence: evidence || null, detail: detail || null, safeNextAction: null };
|
|
29
|
-
}
|
|
30
|
-
function warn(id, label, safeNextAction, evidence, detail) {
|
|
31
|
-
return { id, label, status: "warn", evidence: evidence || null, detail: detail || null, safeNextAction: safeNextAction || "Review and resolve." };
|
|
32
|
-
}
|
|
33
|
-
function blocked(id, label, safeNextAction, evidence, detail) {
|
|
34
|
-
return { id, label, status: "blocked", evidence: evidence || null, detail: detail || null, safeNextAction: safeNextAction || "Fix blocker before proceeding." };
|
|
35
|
-
}
|
|
36
|
-
function info(id, label, evidence, detail) {
|
|
37
|
-
return { id, label, status: "info", evidence: evidence || null, detail: detail || null, safeNextAction: null };
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// ── Preflight Checks ──────────────────────────────────────────────────────────
|
|
41
|
-
|
|
42
|
-
function checkLocalFirstProofPathExists(cwd) {
|
|
43
|
-
// Verify that CLI proof path exists (no browser required)
|
|
44
|
-
const binPath = path.join(cwd, "bin", "avorelo");
|
|
45
|
-
if (!fs.existsSync(binPath)) {
|
|
46
|
-
return blocked("local_first_proof_path", "bin/avorelo entry point missing",
|
|
47
|
-
"Create bin/avorelo. Local-first proof path is the primary path.",
|
|
48
|
-
null, "bin/avorelo not found.");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Check for proof-receipt command availability via public-cli
|
|
52
|
-
const cliPath = path.join(cwd, "scripts/lib/public-cli.js");
|
|
53
|
-
if (!fs.existsSync(cliPath)) {
|
|
54
|
-
return blocked("local_first_proof_path", "public-cli.js missing",
|
|
55
|
-
"scripts/lib/public-cli.js not found. Restore CLI before browser preflight.",
|
|
56
|
-
null);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const cliText = fs.readFileSync(cliPath, "utf8");
|
|
60
|
-
if (cliText.includes("proof-receipt") || cliText.includes("proof-outcome")) {
|
|
61
|
-
return pass("local_first_proof_path", "Local-first proof path available via CLI",
|
|
62
|
-
{ binExists: true, cliHasProofCommand: true });
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return warn("local_first_proof_path", "CLI proof command not found in public-cli.js",
|
|
66
|
-
"Add proof-receipt or proof-outcome command to public-cli.js.",
|
|
67
|
-
{ cliChecked: true });
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function checkProofDoesNotRequireBrowser(cwd) {
|
|
71
|
-
// Check that existing proof artifacts were generated without browser
|
|
72
|
-
const proofPath = path.join(cwd, ".claude/cco/orchestration/proof-outcome/latest-proof-outcome.json");
|
|
73
|
-
const proof = safeReadJson(proofPath);
|
|
74
|
-
if (!proof) {
|
|
75
|
-
return info("proof_no_browser_required", "No proof artifact to inspect",
|
|
76
|
-
null, "Proof artifact not yet generated — browser requirement not determinable.");
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (proof.requiresBrowser === true) {
|
|
80
|
-
return blocked("proof_no_browser_required", "Proof artifact marks browser as required",
|
|
81
|
-
"Update proof generation to work without browser. Browser is an optional enhancement.",
|
|
82
|
-
{ requiresBrowser: true });
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return pass("proof_no_browser_required", "Proof artifact does not require browser",
|
|
86
|
-
{ requiresBrowser: proof.requiresBrowser || false });
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function checkBrowserIsOptionalEnhancement(cwd) {
|
|
90
|
-
// Verify documentation states browser is optional
|
|
91
|
-
const docsToCheck = [
|
|
92
|
-
{ relPath: "docs/ACTIVATION.md", pattern: /local|cli|terminal|without.*browser/i },
|
|
93
|
-
{ relPath: "docs/INSTALL.md", pattern: /local|cli|terminal/i },
|
|
94
|
-
{ relPath: "README.md", pattern: /local.first|cli|terminal/i },
|
|
95
|
-
];
|
|
96
|
-
|
|
97
|
-
let anyDocHasLocalFirst = false;
|
|
98
|
-
const found = [];
|
|
99
|
-
|
|
100
|
-
for (const { relPath, pattern } of docsToCheck) {
|
|
101
|
-
const absPath = path.join(cwd, relPath);
|
|
102
|
-
if (!fs.existsSync(absPath)) continue;
|
|
103
|
-
try {
|
|
104
|
-
const text = fs.readFileSync(absPath, "utf8").slice(0, 5000);
|
|
105
|
-
if (pattern.test(text)) {
|
|
106
|
-
anyDocHasLocalFirst = true;
|
|
107
|
-
found.push(relPath);
|
|
108
|
-
}
|
|
109
|
-
} catch { /* ignore */ }
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (!anyDocHasLocalFirst) {
|
|
113
|
-
return warn("browser_optional_enhancement", "No doc confirms local-first/CLI path without browser",
|
|
114
|
-
"Add explicit local-first activation path in docs/ACTIVATION.md or README.md.",
|
|
115
|
-
{ docsChecked: docsToCheck.map(function(d) { return d.relPath; }) });
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return pass("browser_optional_enhancement", "Docs confirm local-first/CLI path exists",
|
|
119
|
-
{ docsWithLocalFirst: found });
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function checkNoBrowserRuntimeDependency(cwd) {
|
|
123
|
-
const pkgPath = path.join(cwd, "package.json");
|
|
124
|
-
const pkg = safeReadJson(pkgPath);
|
|
125
|
-
if (!pkg) {
|
|
126
|
-
return warn("no_browser_runtime_dependency", "No package.json found",
|
|
127
|
-
"Run from a directory with package.json.",
|
|
128
|
-
null);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const allDeps = Object.assign({},
|
|
132
|
-
pkg.dependencies || {},
|
|
133
|
-
pkg.devDependencies || {}
|
|
134
|
-
);
|
|
135
|
-
|
|
136
|
-
// Check for browser-specific runtime dependencies that would block local-first
|
|
137
|
-
const browserRuntimeDeps = Object.keys(allDeps).filter(function(dep) {
|
|
138
|
-
// playwright/puppeteer as prod dependency (not devDependency) would be a concern
|
|
139
|
-
return /^playwright$|^puppeteer$/.test(dep) && (pkg.dependencies || {})[dep];
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
if (browserRuntimeDeps.length > 0) {
|
|
143
|
-
return warn("no_browser_runtime_dependency",
|
|
144
|
-
"Browser runtime dependencies in prod dependencies: " + browserRuntimeDeps.join(", "),
|
|
145
|
-
"Move playwright/puppeteer to devDependencies. Browser should not be required at runtime.",
|
|
146
|
-
{ deps: browserRuntimeDeps });
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return pass("no_browser_runtime_dependency", "No browser runtime dependencies in prod deps",
|
|
150
|
-
{ checked: Object.keys(allDeps).length });
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
function checkBrowserProofDocsOrPlanned(cwd) {
|
|
154
|
-
// Check if browser proof is at least documented as a future enhancement
|
|
155
|
-
const browserProofDocs = [
|
|
156
|
-
"docs/browser-proof.md",
|
|
157
|
-
"docs/product/browser-proof.md",
|
|
158
|
-
"docs/Browser-Capability-Governance.md",
|
|
159
|
-
];
|
|
160
|
-
|
|
161
|
-
for (const relPath of browserProofDocs) {
|
|
162
|
-
if (fs.existsSync(path.join(cwd, relPath))) {
|
|
163
|
-
return pass("browser_proof_docs_or_planned", "Browser proof documented",
|
|
164
|
-
{ path: relPath });
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// Check if mentioned in roadmap
|
|
169
|
-
const roadmapPath = path.join(cwd, "docs/Roadmap.md");
|
|
170
|
-
if (fs.existsSync(roadmapPath)) {
|
|
171
|
-
try {
|
|
172
|
-
const text = fs.readFileSync(roadmapPath, "utf8").slice(0, 10000);
|
|
173
|
-
if (/browser.*proof|browser.*capability|browser.*enhancement/i.test(text)) {
|
|
174
|
-
return pass("browser_proof_docs_or_planned", "Browser proof mentioned in Roadmap.md",
|
|
175
|
-
{ path: "docs/Roadmap.md" });
|
|
176
|
-
}
|
|
177
|
-
} catch { /* ignore */ }
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
return info("browser_proof_docs_or_planned", "Browser proof not yet documented as planned feature",
|
|
181
|
-
null, "Optional — document when browser proof is on the roadmap.");
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// ── Build Browser Proof Preflight ─────────────────────────────────────────────
|
|
185
|
-
|
|
186
|
-
function buildBrowserProofPreflight(cwd, options) {
|
|
187
|
-
const checks = [
|
|
188
|
-
checkLocalFirstProofPathExists(cwd),
|
|
189
|
-
checkProofDoesNotRequireBrowser(cwd),
|
|
190
|
-
checkBrowserIsOptionalEnhancement(cwd),
|
|
191
|
-
checkNoBrowserRuntimeDependency(cwd),
|
|
192
|
-
checkBrowserProofDocsOrPlanned(cwd),
|
|
193
|
-
];
|
|
194
|
-
|
|
195
|
-
const blockers = checks.filter(function(c) { return c.status === "blocked"; });
|
|
196
|
-
const warnings = checks.filter(function(c) { return c.status === "warn"; });
|
|
197
|
-
|
|
198
|
-
var status;
|
|
199
|
-
if (blockers.length > 0) {
|
|
200
|
-
status = "blocked";
|
|
201
|
-
} else if (warnings.length > 0) {
|
|
202
|
-
status = "warn";
|
|
203
|
-
} else {
|
|
204
|
-
status = "pass";
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const safeNextAction = blockers.length > 0
|
|
208
|
-
? "Fix preflight blockers. Ensure local-first proof path works without browser."
|
|
209
|
-
: warnings.length > 0
|
|
210
|
-
? "Review preflight warnings. Document local-first activation path and browser-optional stance."
|
|
211
|
-
: "Browser proof preflight passed. Local-first proof path verified. Browser is optional enhancement.";
|
|
212
|
-
|
|
213
|
-
return {
|
|
214
|
-
contract: CONTRACT,
|
|
215
|
-
schemaVersion: SCHEMA_VERSION,
|
|
216
|
-
generatedAt: nowIso(),
|
|
217
|
-
status,
|
|
218
|
-
checks,
|
|
219
|
-
localFirstPathVerified: !blockers.some(function(b) { return b.id === "local_first_proof_path"; }),
|
|
220
|
-
browserRequired: false, // Preflight asserts browser is never required for core value
|
|
221
|
-
browserOptionalEnhancement: true,
|
|
222
|
-
blockerCount: blockers.length,
|
|
223
|
-
warningCount: warnings.length,
|
|
224
|
-
safeNextAction,
|
|
225
|
-
noPublicLaunchClaim: true,
|
|
226
|
-
noBrowserLaunch: true, // This module never launches a browser
|
|
227
|
-
redacted: true,
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// ── Write ─────────────────────────────────────────────────────────────────────
|
|
232
|
-
|
|
233
|
-
function writeBrowserProofPreflight(cwd, preflight) {
|
|
234
|
-
const dir = path.join(cwd, ARTIFACT_DIR_REL);
|
|
235
|
-
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
|
236
|
-
fs.writeFileSync(path.join(cwd, ARTIFACT_REL), JSON.stringify(preflight, null, 2));
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// ── Surface ───────────────────────────────────────────────────────────────────
|
|
240
|
-
|
|
241
|
-
function buildBrowserProofPreflightSurface(cwd, options) {
|
|
242
|
-
const preflight = buildBrowserProofPreflight(cwd, options);
|
|
243
|
-
writeBrowserProofPreflight(cwd, preflight);
|
|
244
|
-
try {
|
|
245
|
-
appendProductLearningEvent(cwd, {
|
|
246
|
-
event: "browser_proof_preflight_run",
|
|
247
|
-
contract: CONTRACT,
|
|
248
|
-
status: preflight.status,
|
|
249
|
-
localFirstPathVerified: preflight.localFirstPathVerified,
|
|
250
|
-
browserRequired: false,
|
|
251
|
-
});
|
|
252
|
-
} catch { /* non-fatal */ }
|
|
253
|
-
return {
|
|
254
|
-
status: preflight.status,
|
|
255
|
-
localFirstPathVerified: preflight.localFirstPathVerified,
|
|
256
|
-
browserRequired: false,
|
|
257
|
-
browserOptionalEnhancement: true,
|
|
258
|
-
blockerCount: preflight.blockerCount,
|
|
259
|
-
warningCount: preflight.warningCount,
|
|
260
|
-
noPublicLaunchClaim: true,
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// ── Format ────────────────────────────────────────────────────────────────────
|
|
265
|
-
|
|
266
|
-
function formatBrowserProofPreflightText(preflight) {
|
|
267
|
-
var lines = [
|
|
268
|
-
"Browser Proof Preflight [" + (preflight.status || "?").toUpperCase() + "] (preflight only — no browser launched)",
|
|
269
|
-
" Local-first path verified: " + (preflight.localFirstPathVerified ? "yes" : "no"),
|
|
270
|
-
" Browser required: " + (preflight.browserRequired ? "yes" : "no"),
|
|
271
|
-
" Browser optional enhancement: " + (preflight.browserOptionalEnhancement ? "yes" : "no"),
|
|
272
|
-
" Blockers: " + (preflight.blockerCount || 0),
|
|
273
|
-
" Warnings: " + (preflight.warningCount || 0),
|
|
274
|
-
" Next: " + (preflight.safeNextAction || "Review browser proof preflight."),
|
|
275
|
-
];
|
|
276
|
-
return lines.join("\n");
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
// ── Detect Browser Proof Capabilities ────────────────────────────────────────
|
|
280
|
-
|
|
281
|
-
function detectBrowserProofCapabilities(cwd, options) {
|
|
282
|
-
options = options || {};
|
|
283
|
-
const preflight = buildBrowserProofPreflight(cwd, options);
|
|
284
|
-
return {
|
|
285
|
-
localFirstPathVerified: preflight.localFirstPathVerified,
|
|
286
|
-
browserRequired: preflight.browserRequired,
|
|
287
|
-
browserOptionalEnhancement: preflight.browserOptionalEnhancement,
|
|
288
|
-
status: preflight.status,
|
|
289
|
-
noBrowserLaunch: preflight.noBrowserLaunch,
|
|
290
|
-
blockerCount: preflight.blockerCount,
|
|
291
|
-
warningCount: preflight.warningCount,
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
// ── Classify Browser Proof Need ───────────────────────────────────────────────
|
|
296
|
-
// Returns: "not_required" | "optional_enhancement" | "required_unavailable"
|
|
297
|
-
|
|
298
|
-
function classifyBrowserProofNeed(cwd, options) {
|
|
299
|
-
options = options || {};
|
|
300
|
-
const caps = detectBrowserProofCapabilities(cwd, options);
|
|
301
|
-
if (caps.browserRequired === true) return "required_unavailable";
|
|
302
|
-
if (caps.localFirstPathVerified) return "not_required";
|
|
303
|
-
return "optional_enhancement";
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
module.exports = {
|
|
307
|
-
CONTRACT,
|
|
308
|
-
SCHEMA_VERSION,
|
|
309
|
-
ARTIFACT_REL,
|
|
310
|
-
buildBrowserProofPreflight,
|
|
311
|
-
writeBrowserProofPreflight,
|
|
312
|
-
buildBrowserProofPreflightSurface,
|
|
313
|
-
formatBrowserProofPreflightText,
|
|
314
|
-
checkLocalFirstProofPathExists,
|
|
315
|
-
checkProofDoesNotRequireBrowser,
|
|
316
|
-
checkBrowserIsOptionalEnhancement,
|
|
317
|
-
checkNoBrowserRuntimeDependency,
|
|
318
|
-
checkBrowserProofDocsOrPlanned,
|
|
319
|
-
detectBrowserProofCapabilities,
|
|
320
|
-
classifyBrowserProofNeed,
|
|
321
|
-
};
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
// ── Cache Readiness Checker ───────────────────────────────────────────────────
|
|
4
|
-
//
|
|
5
|
-
// Checks whether prompt layout is stable and cache-friendly.
|
|
6
|
-
// Does NOT claim active caching from any provider.
|
|
7
|
-
// Does NOT act as a caching gateway.
|
|
8
|
-
//
|
|
9
|
-
// Contract: avorelo.cacheReadiness.v1
|
|
10
|
-
//
|
|
11
|
-
// Non-goals: OpenAI/Anthropic/LiteLLM cache integration, provider-specific claims,
|
|
12
|
-
// cache warming, cache invalidation management.
|
|
13
|
-
|
|
14
|
-
const fs = require("node:fs");
|
|
15
|
-
const path = require("node:path");
|
|
16
|
-
const { nowIso } = require("./fsx");
|
|
17
|
-
const { appendProductLearningEvent } = require("./product-learning-events");
|
|
18
|
-
|
|
19
|
-
const CONTRACT = "avorelo.cacheReadiness.v1";
|
|
20
|
-
const SCHEMA_VERSION = 1;
|
|
21
|
-
|
|
22
|
-
const CACHE_DIR_REL = ".claude/cco/orchestration/cache-readiness";
|
|
23
|
-
const LATEST_READINESS_REL = `${CACHE_DIR_REL}/latest-readiness.json`;
|
|
24
|
-
|
|
25
|
-
// ── Prompt layout checks ──────────────────────────────────────────────────────
|
|
26
|
-
|
|
27
|
-
function checkPromptLayoutStability(input, options = {}) {
|
|
28
|
-
const checks = [];
|
|
29
|
-
const {
|
|
30
|
-
hasStaticInstructionsBefore = null,
|
|
31
|
-
hasDynamicTaskAfter = null,
|
|
32
|
-
toolDefinitionsGrouped = null,
|
|
33
|
-
dynamicToolOutputInPrefix = null,
|
|
34
|
-
fileSpecificContentLate = null,
|
|
35
|
-
orderingStableAcrossRuns = null,
|
|
36
|
-
providerConfirmed = false,
|
|
37
|
-
} = input || {};
|
|
38
|
-
|
|
39
|
-
// Static instructions before dynamic task
|
|
40
|
-
if (hasStaticInstructionsBefore === true) {
|
|
41
|
-
checks.push({ id: "static_before_dynamic", status: "pass", detail: "Static instructions precede dynamic task content." });
|
|
42
|
-
} else if (hasStaticInstructionsBefore === false) {
|
|
43
|
-
checks.push({ id: "static_before_dynamic", status: "warn", detail: "Dynamic content may appear before static instructions, reducing cache stability." });
|
|
44
|
-
} else {
|
|
45
|
-
checks.push({ id: "static_before_dynamic", status: "unknown", detail: "Cannot determine ordering from available signals." });
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Dynamic tool output not in cache prefix
|
|
49
|
-
if (dynamicToolOutputInPrefix === true) {
|
|
50
|
-
checks.push({ id: "dynamic_output_not_in_prefix", status: "warn", detail: "Dynamic tool output appears in cache prefix position. Move to suffix for cache stability." });
|
|
51
|
-
} else if (dynamicToolOutputInPrefix === false) {
|
|
52
|
-
checks.push({ id: "dynamic_output_not_in_prefix", status: "pass", detail: "Dynamic tool output is not in cache prefix position." });
|
|
53
|
-
} else {
|
|
54
|
-
checks.push({ id: "dynamic_output_not_in_prefix", status: "unknown", detail: "Tool output position not confirmed." });
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// File-specific content late
|
|
58
|
-
if (fileSpecificContentLate === true) {
|
|
59
|
-
checks.push({ id: "file_specific_content_late", status: "pass", detail: "File-specific content appears late in prompt (after stable prefix)." });
|
|
60
|
-
} else if (fileSpecificContentLate === false) {
|
|
61
|
-
checks.push({ id: "file_specific_content_late", status: "warn", detail: "File-specific content appears early; may invalidate cache prefix on every file change." });
|
|
62
|
-
} else {
|
|
63
|
-
checks.push({ id: "file_specific_content_late", status: "unknown", detail: "File content position not confirmed." });
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Tool definitions grouped
|
|
67
|
-
if (toolDefinitionsGrouped === true) {
|
|
68
|
-
checks.push({ id: "tool_definitions_grouped", status: "pass", detail: "Tool definitions are grouped and stable." });
|
|
69
|
-
} else if (toolDefinitionsGrouped === false) {
|
|
70
|
-
checks.push({ id: "tool_definitions_grouped", status: "warn", detail: "Tool definitions appear scattered or dynamic. Group them for cache stability." });
|
|
71
|
-
} else {
|
|
72
|
-
checks.push({ id: "tool_definitions_grouped", status: "unknown", detail: "Tool definition grouping not confirmed." });
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Stable ordering across runs
|
|
76
|
-
if (orderingStableAcrossRuns === true) {
|
|
77
|
-
checks.push({ id: "ordering_stable", status: "pass", detail: "Prompt ordering is stable across runs." });
|
|
78
|
-
} else if (orderingStableAcrossRuns === false) {
|
|
79
|
-
checks.push({ id: "ordering_stable", status: "warn", detail: "Prompt ordering varies across runs. Randomized or unstable ordering prevents caching." });
|
|
80
|
-
} else {
|
|
81
|
-
checks.push({ id: "ordering_stable", status: "unknown", detail: "Ordering stability not confirmed." });
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Provider not confirmed — no active cache claim
|
|
85
|
-
if (!providerConfirmed) {
|
|
86
|
-
checks.push({ id: "provider_confirmed", status: "unknown", detail: "Provider not confirmed. No active cache claim can be made." });
|
|
87
|
-
} else {
|
|
88
|
-
checks.push({ id: "provider_confirmed", status: "pass", detail: `Provider confirmed: ${providerConfirmed}.` });
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return checks;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function buildCacheReadiness(cwd, input = {}, options = {}) {
|
|
95
|
-
const checks = checkPromptLayoutStability(input, options);
|
|
96
|
-
|
|
97
|
-
const passed = checks.filter((c) => c.status === "pass").length;
|
|
98
|
-
const warned = checks.filter((c) => c.status === "warn").length;
|
|
99
|
-
const unknown = checks.filter((c) => c.status === "unknown").length;
|
|
100
|
-
const failed = checks.filter((c) => c.status === "fail").length;
|
|
101
|
-
|
|
102
|
-
let readinessLevel;
|
|
103
|
-
if (failed > 0) readinessLevel = "not_ready";
|
|
104
|
-
else if (warned > 0) readinessLevel = "partial";
|
|
105
|
-
else if (unknown === checks.length) readinessLevel = "unknown";
|
|
106
|
-
else if (passed > 0 && warned === 0) readinessLevel = "ready";
|
|
107
|
-
else readinessLevel = "partial";
|
|
108
|
-
|
|
109
|
-
const caveats = ["Cache readiness is a layout signal only. No provider-specific cache claim is made."];
|
|
110
|
-
if (unknown > 0) {
|
|
111
|
-
caveats.push(`${unknown} check(s) could not be evaluated from available signals.`);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return {
|
|
115
|
-
contract: CONTRACT,
|
|
116
|
-
schemaVersion: SCHEMA_VERSION,
|
|
117
|
-
createdAt: nowIso(),
|
|
118
|
-
readinessLevel,
|
|
119
|
-
checksPass: passed,
|
|
120
|
-
checksWarn: warned,
|
|
121
|
-
checksUnknown: unknown,
|
|
122
|
-
checksFail: failed,
|
|
123
|
-
checks,
|
|
124
|
-
caveats,
|
|
125
|
-
noProviderCacheClaim: true,
|
|
126
|
-
redacted: true,
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
function writeCacheReadiness(cwd, readiness) {
|
|
131
|
-
const dir = path.join(cwd, CACHE_DIR_REL);
|
|
132
|
-
fs.mkdirSync(dir, { recursive: true });
|
|
133
|
-
const abs = path.join(cwd, LATEST_READINESS_REL);
|
|
134
|
-
fs.writeFileSync(abs, JSON.stringify(readiness, null, 2), "utf8");
|
|
135
|
-
try {
|
|
136
|
-
appendProductLearningEvent(cwd, "cache_readiness_checked", {
|
|
137
|
-
readinessLevel: readiness.readinessLevel,
|
|
138
|
-
checksPass: readiness.checksPass,
|
|
139
|
-
checksWarn: readiness.checksWarn,
|
|
140
|
-
noProviderCacheClaim: readiness.noProviderCacheClaim,
|
|
141
|
-
});
|
|
142
|
-
} catch {}
|
|
143
|
-
return abs;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function buildCacheReadinessSurface(cwd, options = {}) {
|
|
147
|
-
const abs = path.join(cwd, LATEST_READINESS_REL);
|
|
148
|
-
if (!fs.existsSync(abs)) {
|
|
149
|
-
return { status: "not_available", artifactPath: LATEST_READINESS_REL };
|
|
150
|
-
}
|
|
151
|
-
try {
|
|
152
|
-
const r = JSON.parse(fs.readFileSync(abs, "utf8"));
|
|
153
|
-
return {
|
|
154
|
-
status: "available",
|
|
155
|
-
readinessLevel: r.readinessLevel,
|
|
156
|
-
checksPass: r.checksPass,
|
|
157
|
-
checksWarn: r.checksWarn,
|
|
158
|
-
noProviderCacheClaim: r.noProviderCacheClaim,
|
|
159
|
-
artifactPath: LATEST_READINESS_REL,
|
|
160
|
-
};
|
|
161
|
-
} catch {
|
|
162
|
-
return { status: "error", artifactPath: LATEST_READINESS_REL };
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
function formatCacheReadinessText(readiness, options = {}) {
|
|
167
|
-
const lines = [`Cache Readiness: ${readiness.readinessLevel}`];
|
|
168
|
-
lines.push(` Pass: ${readiness.checksPass} | Warn: ${readiness.checksWarn} | Unknown: ${readiness.checksUnknown}`);
|
|
169
|
-
lines.push(` noProviderCacheClaim: ${readiness.noProviderCacheClaim}`);
|
|
170
|
-
for (const c of readiness.checks) {
|
|
171
|
-
if (c.status !== "pass") lines.push(` [${c.status}] ${c.id}: ${c.detail}`);
|
|
172
|
-
}
|
|
173
|
-
if (readiness.caveats.length) lines.push(` Caveat: ${readiness.caveats[0]}`);
|
|
174
|
-
return lines.join("\n");
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
module.exports = {
|
|
178
|
-
CONTRACT,
|
|
179
|
-
SCHEMA_VERSION,
|
|
180
|
-
CACHE_DIR_REL,
|
|
181
|
-
LATEST_READINESS_REL,
|
|
182
|
-
checkPromptLayoutStability,
|
|
183
|
-
buildCacheReadiness,
|
|
184
|
-
writeCacheReadiness,
|
|
185
|
-
buildCacheReadinessSurface,
|
|
186
|
-
formatCacheReadinessText,
|
|
187
|
-
};
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
|
|
6
|
-
const { buildBoundedStateContext, formatNextBoundedAction } = require("./proof-canonical");
|
|
7
|
-
const { loadCarryForward } = require("./carry-forward-surfacing");
|
|
8
|
-
const { parseContinueNote } = require("./guidance-builder");
|
|
9
|
-
const { loadReentryState } = require("./reentry-state");
|
|
10
|
-
|
|
11
|
-
const CONTINUE_NOTE_REL = ".claude/cco/reports/continue-from-here.md";
|
|
12
|
-
const REENTRY_STATE_REL = ".claude/cco/state/reentry-state.json";
|
|
13
|
-
const CARRY_FORWARD_REL = ".claude/cco/state/reentry-carry-forward.json";
|
|
14
|
-
|
|
15
|
-
function loadCanonicalReentry(cwd) {
|
|
16
|
-
const context = buildBoundedStateContext(cwd);
|
|
17
|
-
if (!context) {
|
|
18
|
-
return {
|
|
19
|
-
is_canonical_truth_available: false,
|
|
20
|
-
artifact_refs: [],
|
|
21
|
-
state_source: null,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
is_canonical_truth_available: true,
|
|
27
|
-
artifact_refs: Array.isArray(context.artifact_refs) ? context.artifact_refs : [],
|
|
28
|
-
state_source: context.state_source || context.artifact_path || null,
|
|
29
|
-
where_am_i_now: context.where_am_i_now || null,
|
|
30
|
-
what_can_i_honestly_claim: context.what_can_i_honestly_claim || context.claim_boundary || null,
|
|
31
|
-
reentry_status: context.reentry_status || null,
|
|
32
|
-
latest_trustworthy_run_id: context.latest_trustworthy_run_id || null,
|
|
33
|
-
latest_trustworthy_workset_id: context.latest_trustworthy_workset_id || null,
|
|
34
|
-
next_bounded_action: context.next_bounded_action || null,
|
|
35
|
-
next_bounded_action_text: formatNextBoundedAction(context.next_bounded_action),
|
|
36
|
-
rollback_available:
|
|
37
|
-
typeof context.rollback_available === "boolean" ? context.rollback_available : null,
|
|
38
|
-
rollback_trigger: context.rollback_trigger || null,
|
|
39
|
-
readiness_state: context.readiness_status || null,
|
|
40
|
-
reason_summary: context.reentry_reason_summary || null,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function hasCanonicalReentryTruth(value) {
|
|
45
|
-
return Boolean(value && value.is_canonical_truth_available);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function readContinueNote(cwd) {
|
|
49
|
-
const absPath = path.join(cwd, CONTINUE_NOTE_REL);
|
|
50
|
-
try {
|
|
51
|
-
return parseContinueNote(fs.readFileSync(absPath, "utf8"));
|
|
52
|
-
} catch {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function uniqueRefs(values) {
|
|
58
|
-
return [...new Set((values || []).filter(Boolean).map((value) => String(value).trim()).filter(Boolean))];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function buildFallbackCurrentState(cwd) {
|
|
62
|
-
const continueNote = readContinueNote(cwd);
|
|
63
|
-
const reentryState = loadReentryState(cwd);
|
|
64
|
-
const carryForward = loadCarryForward(cwd);
|
|
65
|
-
const carryForwardNext =
|
|
66
|
-
formatNextBoundedAction(carryForward?.nextBoundedAction)
|
|
67
|
-
|| formatNextBoundedAction(carryForward?.next_bounded_action);
|
|
68
|
-
const nextAction =
|
|
69
|
-
continueNote?.nextAction
|
|
70
|
-
|| reentryState?.nextAction
|
|
71
|
-
|| carryForwardNext
|
|
72
|
-
|| null;
|
|
73
|
-
const artifactRefs = uniqueRefs([
|
|
74
|
-
continueNote ? CONTINUE_NOTE_REL : null,
|
|
75
|
-
reentryState ? REENTRY_STATE_REL : null,
|
|
76
|
-
carryForward ? CARRY_FORWARD_REL : null,
|
|
77
|
-
continueNote?.artifactPath || null,
|
|
78
|
-
reentryState?.primaryArtifactPath || null,
|
|
79
|
-
]);
|
|
80
|
-
|
|
81
|
-
if (!continueNote && !reentryState && !carryForward) {
|
|
82
|
-
return {
|
|
83
|
-
truthSource: "none",
|
|
84
|
-
isCanonicalTruthAvailable: false,
|
|
85
|
-
whereAmINow: null,
|
|
86
|
-
whatCanIHonestlyClaim: null,
|
|
87
|
-
nextBoundedAction: null,
|
|
88
|
-
reentryStatus: null,
|
|
89
|
-
latestTrustworthyRunId: null,
|
|
90
|
-
rollbackAvailable: null,
|
|
91
|
-
readinessState: null,
|
|
92
|
-
stateSource: null,
|
|
93
|
-
artifactRefs: [],
|
|
94
|
-
limitations: [
|
|
95
|
-
"No canonical or wrapper continuity cues are available yet.",
|
|
96
|
-
],
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
truthSource: "fallback",
|
|
102
|
-
isCanonicalTruthAvailable: false,
|
|
103
|
-
whereAmINow: null,
|
|
104
|
-
whatCanIHonestlyClaim: null,
|
|
105
|
-
nextBoundedAction: nextAction,
|
|
106
|
-
reentryStatus: carryForward ? "resume_available" : null,
|
|
107
|
-
latestTrustworthyRunId: null,
|
|
108
|
-
rollbackAvailable: null,
|
|
109
|
-
readinessState: null,
|
|
110
|
-
stateSource:
|
|
111
|
-
continueNote ? CONTINUE_NOTE_REL
|
|
112
|
-
: reentryState ? REENTRY_STATE_REL
|
|
113
|
-
: carryForward ? CARRY_FORWARD_REL
|
|
114
|
-
: null,
|
|
115
|
-
artifactRefs,
|
|
116
|
-
limitations: [
|
|
117
|
-
"Canonical L8 current-state artifacts are not available; showing wrapper-derived continuity cues.",
|
|
118
|
-
],
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function buildCurrentStateSurface(cwd) {
|
|
123
|
-
const canonicalReentry = loadCanonicalReentry(cwd);
|
|
124
|
-
if (hasCanonicalReentryTruth(canonicalReentry)) {
|
|
125
|
-
const limitations = [];
|
|
126
|
-
if (!canonicalReentry.where_am_i_now) {
|
|
127
|
-
limitations.push("Canonical L8 artifacts do not currently describe where the session stands.");
|
|
128
|
-
}
|
|
129
|
-
if (!canonicalReentry.what_can_i_honestly_claim) {
|
|
130
|
-
limitations.push("Canonical L8 artifacts do not currently define an honest claim boundary.");
|
|
131
|
-
}
|
|
132
|
-
if (!canonicalReentry.next_bounded_action_text) {
|
|
133
|
-
limitations.push("Canonical L8 artifacts do not currently define the next bounded action.");
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return {
|
|
137
|
-
truthSource: "canonical_l8",
|
|
138
|
-
isCanonicalTruthAvailable: true,
|
|
139
|
-
whereAmINow: canonicalReentry.where_am_i_now || null,
|
|
140
|
-
whatCanIHonestlyClaim: canonicalReentry.what_can_i_honestly_claim || null,
|
|
141
|
-
nextBoundedAction: canonicalReentry.next_bounded_action_text || null,
|
|
142
|
-
reentryStatus: canonicalReentry.reentry_status || null,
|
|
143
|
-
latestTrustworthyRunId: canonicalReentry.latest_trustworthy_run_id || null,
|
|
144
|
-
rollbackAvailable:
|
|
145
|
-
typeof canonicalReentry.rollback_available === "boolean"
|
|
146
|
-
? canonicalReentry.rollback_available
|
|
147
|
-
: null,
|
|
148
|
-
readinessState: canonicalReentry.readiness_state || null,
|
|
149
|
-
stateSource: canonicalReentry.state_source || null,
|
|
150
|
-
artifactRefs: uniqueRefs(canonicalReentry.artifact_refs || []),
|
|
151
|
-
limitations,
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return buildFallbackCurrentState(cwd);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
module.exports = {
|
|
159
|
-
buildCurrentStateSurface,
|
|
160
|
-
hasCanonicalReentryTruth,
|
|
161
|
-
loadCanonicalReentry,
|
|
162
|
-
};
|