avorelo 0.1.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 +21 -0
- package/README.md +56 -0
- package/bin/avorelo +9 -0
- package/package.json +135 -0
- package/scripts/README.md +40 -0
- package/scripts/cco-dashboard.js +252 -0
- package/scripts/cco-status.js +430 -0
- package/scripts/lib/activation/account-state.js +37 -0
- package/scripts/lib/activation/activation-runner.js +546 -0
- package/scripts/lib/activation/activation-self-healing.js +480 -0
- package/scripts/lib/activation/activation-state.js +83 -0
- package/scripts/lib/activation/activation-summary.js +191 -0
- package/scripts/lib/activation/adapters/claude-code.js +77 -0
- package/scripts/lib/activation/adapters/codex-cli.js +52 -0
- package/scripts/lib/activation/adapters/cursor.js +37 -0
- package/scripts/lib/activation/adapters/github-agent.js +39 -0
- package/scripts/lib/activation/adapters/terminal.js +42 -0
- package/scripts/lib/activation/adapters/vscode.js +39 -0
- package/scripts/lib/activation/adapters/windsurf.js +37 -0
- package/scripts/lib/activation/ai-surface-detector.js +151 -0
- package/scripts/lib/activation/connect-account.js +145 -0
- package/scripts/lib/activation/detect-environment.js +75 -0
- package/scripts/lib/activation/detect-hosts.js +62 -0
- package/scripts/lib/activation/format-activation-output.js +109 -0
- package/scripts/lib/activation/next-action.js +43 -0
- package/scripts/lib/activation/repair-engine.js +219 -0
- package/scripts/lib/activation-distribution-readiness.js +507 -0
- package/scripts/lib/adapter-conformance.js +176 -0
- package/scripts/lib/adapter-readiness.js +417 -0
- package/scripts/lib/adapter-safety-boundaries.js +335 -0
- package/scripts/lib/adapter-technical-readiness-gate.js +205 -0
- package/scripts/lib/agent-access-governance.js +455 -0
- package/scripts/lib/agent-enforcement.js +765 -0
- package/scripts/lib/agent-policy-profile.js +210 -0
- package/scripts/lib/agent-security/action-evaluator.js +507 -0
- package/scripts/lib/agent-security/adapter-registry.js +98 -0
- package/scripts/lib/agent-security/auto-policy.js +139 -0
- package/scripts/lib/agent-security/bounded-scan.js +93 -0
- package/scripts/lib/agent-security/enforcement-adapter.js +174 -0
- package/scripts/lib/agent-security/enforcement-engine.js +1129 -0
- package/scripts/lib/agent-security/file-write-adapter.js +183 -0
- package/scripts/lib/agent-security/file-write-rules.js +178 -0
- package/scripts/lib/agent-security/index.js +3342 -0
- package/scripts/lib/agent-security/instruction-risk.js +181 -0
- package/scripts/lib/agent-security/mcp-action-adapter.js +185 -0
- package/scripts/lib/agent-security/mcp-action-rules.js +184 -0
- package/scripts/lib/agent-security/package-action-adapter.js +175 -0
- package/scripts/lib/agent-security/package-action-rules.js +233 -0
- package/scripts/lib/agent-security/performance.js +148 -0
- package/scripts/lib/agent-security/permission-minimizer.js +403 -0
- package/scripts/lib/agent-security/scan-cache.js +74 -0
- package/scripts/lib/agent-security/source-trust.js +146 -0
- package/scripts/lib/ai-install-prompt.js +288 -0
- package/scripts/lib/ai-workspace-hygiene.js +1499 -0
- package/scripts/lib/alpha-activation.js +520 -0
- package/scripts/lib/alpha-feedback.js +263 -0
- package/scripts/lib/alpha-readiness-gate.js +332 -0
- package/scripts/lib/anti-gaming.js +169 -0
- package/scripts/lib/artifact-health.js +431 -0
- package/scripts/lib/attribution.js +180 -0
- package/scripts/lib/audit.js +289 -0
- package/scripts/lib/avorelo-skill-registry.js +810 -0
- package/scripts/lib/batch-jobs.js +71 -0
- package/scripts/lib/brain-pack.js +578 -0
- package/scripts/lib/brand-boundary.js +424 -0
- package/scripts/lib/brand.js +74 -0
- package/scripts/lib/browser-capability.js +1048 -0
- package/scripts/lib/browser-proof-preflight.js +321 -0
- package/scripts/lib/cache-readiness.js +187 -0
- package/scripts/lib/canonical-reentry.js +162 -0
- package/scripts/lib/capability-packs.js +314 -0
- package/scripts/lib/capability-recommender.js +512 -0
- package/scripts/lib/capability-registry.js +1059 -0
- package/scripts/lib/carry-forward-surfacing.js +194 -0
- package/scripts/lib/ccusage-adapter.js +188 -0
- package/scripts/lib/company-loop.js +1149 -0
- package/scripts/lib/config.js +637 -0
- package/scripts/lib/context-acquisition-plan.js +287 -0
- package/scripts/lib/context-budget-guard.js +170 -0
- package/scripts/lib/context-budget-scanner.js +257 -0
- package/scripts/lib/context-optimizer.js +715 -0
- package/scripts/lib/context-reduction-plan.js +178 -0
- package/scripts/lib/context-safety.js +88 -0
- package/scripts/lib/context-savings-engine.js +158 -0
- package/scripts/lib/cost-evidence.js +254 -0
- package/scripts/lib/cross-host-install-plan.js +308 -0
- package/scripts/lib/cross-host-install-readiness.js +237 -0
- package/scripts/lib/cross-host-value-flow.js +268 -0
- package/scripts/lib/dashboard.js +900 -0
- package/scripts/lib/design-partner-feedback.js +346 -0
- package/scripts/lib/entitlements.js +100 -0
- package/scripts/lib/execution-packet.js +559 -0
- package/scripts/lib/experimentation-events.js +547 -0
- package/scripts/lib/external-capability-compliance.js +107 -0
- package/scripts/lib/external-user-simulation.js +166 -0
- package/scripts/lib/failure-recovery-readiness.js +81 -0
- package/scripts/lib/failure-recovery.js +419 -0
- package/scripts/lib/feedback-intelligence.js +537 -0
- package/scripts/lib/feedback-signals.js +205 -0
- package/scripts/lib/file-integrity.js +68 -0
- package/scripts/lib/fsx.js +127 -0
- package/scripts/lib/full-readiness-gate.js +451 -0
- package/scripts/lib/guidance-builder.js +174 -0
- package/scripts/lib/hook-apply.js +1019 -0
- package/scripts/lib/hook-baseline.js +310 -0
- package/scripts/lib/hook-config-preview.js +275 -0
- package/scripts/lib/hook-contracts.js +290 -0
- package/scripts/lib/hook-safety-boundary-readiness.js +80 -0
- package/scripts/lib/host-capability-matrix.js +351 -0
- package/scripts/lib/host-support-context.js +254 -0
- package/scripts/lib/http-hook-action.js +538 -0
- package/scripts/lib/install-ai-readiness.js +84 -0
- package/scripts/lib/install-intake-risk.js +1037 -0
- package/scripts/lib/install-journey-intelligence.js +329 -0
- package/scripts/lib/intervention-guidance.js +57 -0
- package/scripts/lib/known-limitations.js +115 -0
- package/scripts/lib/l8-path-truth.js +146 -0
- package/scripts/lib/launch-hardening-gate.js +436 -0
- package/scripts/lib/launch-readiness.js +628 -0
- package/scripts/lib/learning-memory.js +686 -0
- package/scripts/lib/lifecycle-hooks.js +802 -0
- package/scripts/lib/local-package-smoke.js +423 -0
- package/scripts/lib/local-pricing.js +299 -0
- package/scripts/lib/mcp-enforcement.js +311 -0
- package/scripts/lib/mcp-least-privilege-policy.js +303 -0
- package/scripts/lib/mcp-tool-inventory.js +388 -0
- package/scripts/lib/mcp-tool-risk.js +0 -0
- package/scripts/lib/memory.js +335 -0
- package/scripts/lib/metrics.js +699 -0
- package/scripts/lib/micro-proof.js +133 -0
- package/scripts/lib/next-run-context.js +436 -0
- package/scripts/lib/operating-value.js +1648 -0
- package/scripts/lib/optimization-v3.js +122 -0
- package/scripts/lib/orchestration/adapters/_shared.js +49 -0
- package/scripts/lib/orchestration/adapters/aider.js +18 -0
- package/scripts/lib/orchestration/adapters/claude-code.js +35 -0
- package/scripts/lib/orchestration/adapters/codex.js +35 -0
- package/scripts/lib/orchestration/adapters/gemini-cli.js +18 -0
- package/scripts/lib/orchestration/adapters/git.js +25 -0
- package/scripts/lib/orchestration/adapters/index.js +31 -0
- package/scripts/lib/orchestration/adapters/lm-studio.js +18 -0
- package/scripts/lib/orchestration/adapters/ollama.js +18 -0
- package/scripts/lib/orchestration/adapters/opencode.js +18 -0
- package/scripts/lib/orchestration/adapters/openrouter.js +18 -0
- package/scripts/lib/orchestration/adapters/test-runner.js +25 -0
- package/scripts/lib/orchestration/cli.js +438 -0
- package/scripts/lib/orchestration/execution-manager.js +279 -0
- package/scripts/lib/orchestration/handoff.js +314 -0
- package/scripts/lib/orchestration/index.js +456 -0
- package/scripts/lib/orchestration/inventory.js +47 -0
- package/scripts/lib/orchestration/model-discovery.js +498 -0
- package/scripts/lib/orchestration/model-profiler.js +170 -0
- package/scripts/lib/orchestration/model-profiles.js +252 -0
- package/scripts/lib/orchestration/model-refresh-policy.js +72 -0
- package/scripts/lib/orchestration/proof-writer.js +349 -0
- package/scripts/lib/orchestration/provider-discovery/aider.js +49 -0
- package/scripts/lib/orchestration/provider-discovery/claude-code.js +56 -0
- package/scripts/lib/orchestration/provider-discovery/codex.js +49 -0
- package/scripts/lib/orchestration/provider-discovery/common.js +186 -0
- package/scripts/lib/orchestration/provider-discovery/gemini.js +106 -0
- package/scripts/lib/orchestration/provider-discovery/lm-studio.js +118 -0
- package/scripts/lib/orchestration/provider-discovery/models-dev.js +12 -0
- package/scripts/lib/orchestration/provider-discovery/ollama.js +100 -0
- package/scripts/lib/orchestration/provider-discovery/opencode.js +47 -0
- package/scripts/lib/orchestration/provider-discovery/openrouter.js +44 -0
- package/scripts/lib/orchestration/risk-classifier.js +130 -0
- package/scripts/lib/orchestration/routing-policy.js +486 -0
- package/scripts/lib/orchestration/settings.js +112 -0
- package/scripts/lib/orchestration/state.js +165 -0
- package/scripts/lib/orchestration/verification-manager.js +138 -0
- package/scripts/lib/output-profiles.js +146 -0
- package/scripts/lib/package-content-audit.js +368 -0
- package/scripts/lib/package-runtime.js +278 -0
- package/scripts/lib/plan-surface.js +53 -0
- package/scripts/lib/plans.js +2318 -0
- package/scripts/lib/policy-provider.js +27 -0
- package/scripts/lib/prelaunch-activation-readiness.js +409 -0
- package/scripts/lib/prelaunch-evidence-store.js +816 -0
- package/scripts/lib/prelaunch-intelligence.js +869 -0
- package/scripts/lib/pricing-experiment.js +118 -0
- package/scripts/lib/pro-moment-events.js +77 -0
- package/scripts/lib/pro-moment-state.js +227 -0
- package/scripts/lib/pro-moments.js +1216 -0
- package/scripts/lib/product-learning-events.js +629 -0
- package/scripts/lib/project-profile.js +555 -0
- package/scripts/lib/prompt-compiler.js +280 -0
- package/scripts/lib/prompt-lint.js +32 -0
- package/scripts/lib/prompt-suggestions.js +52 -0
- package/scripts/lib/proof-canonical.js +398 -0
- package/scripts/lib/proof-drilldown.js +383 -0
- package/scripts/lib/proof-events.js +342 -0
- package/scripts/lib/proof-history.js +243 -0
- package/scripts/lib/proof-metrics.js +296 -0
- package/scripts/lib/proof-outcome-evidence.js +134 -0
- package/scripts/lib/proof-receipt.js +335 -0
- package/scripts/lib/proof-record.js +461 -0
- package/scripts/lib/public-activation-distribution-gate.js +258 -0
- package/scripts/lib/public-cli.js +3891 -0
- package/scripts/lib/public-distribution-truth.js +211 -0
- package/scripts/lib/public-install-claim-checker.js +294 -0
- package/scripts/lib/publish-provenance-readiness.js +283 -0
- package/scripts/lib/readiness-delta.js +218 -0
- package/scripts/lib/readiness-evidence-closure.js +196 -0
- package/scripts/lib/reentry-memory-capture.js +241 -0
- package/scripts/lib/reentry-memory-retrieval.js +302 -0
- package/scripts/lib/reentry-memory-status.js +146 -0
- package/scripts/lib/reentry-memory-store.js +178 -0
- package/scripts/lib/reentry-state.js +66 -0
- package/scripts/lib/release-candidate-bundle.js +166 -0
- package/scripts/lib/remediation.js +81 -0
- package/scripts/lib/repo-map.js +391 -0
- package/scripts/lib/run-improvements-lifecycle.js +330 -0
- package/scripts/lib/run-improvements.js +789 -0
- package/scripts/lib/runtime-decision-policy.js +387 -0
- package/scripts/lib/safe-path-engine.js +705 -0
- package/scripts/lib/safe-run-controller.js +887 -0
- package/scripts/lib/score.js +262 -0
- package/scripts/lib/seamless-enforcement.js +329 -0
- package/scripts/lib/seamless-outcome.js +689 -0
- package/scripts/lib/seamless-reality-gate.js +5043 -0
- package/scripts/lib/security-risk-classifier.js +511 -0
- package/scripts/lib/security-scan.js +384 -0
- package/scripts/lib/session-context-optimizer.js +1211 -0
- package/scripts/lib/session-timing.js +315 -0
- package/scripts/lib/skill-hygiene.js +805 -0
- package/scripts/lib/skill-packs.js +161 -0
- package/scripts/lib/skills-operating-layer.js +580 -0
- package/scripts/lib/smart-work-routing.js +768 -0
- package/scripts/lib/source-catalog.js +700 -0
- package/scripts/lib/status-value-summary.js +32 -0
- package/scripts/lib/support-bundle.js +578 -0
- package/scripts/lib/task-continuation.js +440 -0
- package/scripts/lib/test-helpers.js +15 -0
- package/scripts/lib/tier.js +38 -0
- package/scripts/lib/token-context-quality-gate.js +370 -0
- package/scripts/lib/token-cost-capture.js +187 -0
- package/scripts/lib/token-cost-intelligence.js +358 -0
- package/scripts/lib/token-efficiency-evidence.js +213 -0
- package/scripts/lib/token-evidence.js +699 -0
- package/scripts/lib/tokenish.js +17 -0
- package/scripts/lib/tool-output-sandbox.js +304 -0
- package/scripts/lib/trust-audit.js +136 -0
- package/scripts/lib/unified-events.js +396 -0
- package/scripts/lib/upgrade-interruption-recovery.js +407 -0
- package/scripts/lib/usage-ledger.js +201 -0
- package/scripts/lib/value-ledger.js +130 -0
- package/scripts/lib/value-proof-calibration.js +531 -0
- package/scripts/lib/visual-qa.js +231 -0
- package/scripts/lib/voice-alpha.js +29 -0
- package/scripts/lib/work-aware-orchestration.js +976 -0
- package/scripts/lib/work-control-receipts.js +577 -0
- package/scripts/lib/work-ledger.js +1123 -0
- package/scripts/lib/work-panel-preview.js +352 -0
- package/scripts/lib/workflow-discipline.js +280 -0
- package/scripts/lib/workflow-signals.js +419 -0
- package/scripts/lib/workspace-map.js +281 -0
- package/scripts/lib/workspace-registry.js +1367 -0
- package/scripts/lib/workspace-resolver.js +480 -0
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
// ── Project Profile ───────────────────────────────────────────────────────────
|
|
4
|
+
//
|
|
5
|
+
// Contract: avorelo.projectProfile.v1
|
|
6
|
+
//
|
|
7
|
+
// Deterministic project profile detection: infers framework, package manager,
|
|
8
|
+
// build/test/dev scripts, deploy provider, and risk boundaries from local files.
|
|
9
|
+
//
|
|
10
|
+
// No network calls. No package installs. No script execution. No secret reading.
|
|
11
|
+
|
|
12
|
+
const fs = require("fs");
|
|
13
|
+
const path = require("path");
|
|
14
|
+
const { ensureCcoDirs, safeWriteJson } = require("./fsx");
|
|
15
|
+
const { appendProductLearningEvent } = require("./product-learning-events");
|
|
16
|
+
|
|
17
|
+
const CONTRACT = "avorelo.projectProfile.v1";
|
|
18
|
+
const SCHEMA_VERSION = 1;
|
|
19
|
+
|
|
20
|
+
const LATEST_PROFILE_REL = ".claude/cco/orchestration/project-profile/latest-profile.json";
|
|
21
|
+
|
|
22
|
+
// ── Risk boundary constants ───────────────────────────────────────────────────
|
|
23
|
+
|
|
24
|
+
const DEFAULT_BLOCKED_FILES = Object.freeze([
|
|
25
|
+
".env",
|
|
26
|
+
".env.local",
|
|
27
|
+
".env.production",
|
|
28
|
+
".env.development",
|
|
29
|
+
".env.staging",
|
|
30
|
+
".env.test",
|
|
31
|
+
".env.server",
|
|
32
|
+
".env.client",
|
|
33
|
+
"*.pem",
|
|
34
|
+
"*.key",
|
|
35
|
+
"*.p12",
|
|
36
|
+
"*.pfx",
|
|
37
|
+
".npmrc",
|
|
38
|
+
".yarnrc",
|
|
39
|
+
"secrets.json",
|
|
40
|
+
"credentials.json",
|
|
41
|
+
"service-account.json",
|
|
42
|
+
]);
|
|
43
|
+
|
|
44
|
+
const DEFAULT_SENSITIVE_DIRS = Object.freeze([
|
|
45
|
+
"auth",
|
|
46
|
+
"authentication",
|
|
47
|
+
"billing",
|
|
48
|
+
"payments",
|
|
49
|
+
"payment",
|
|
50
|
+
"secrets",
|
|
51
|
+
"secret",
|
|
52
|
+
"infra",
|
|
53
|
+
"infrastructure",
|
|
54
|
+
"api/auth",
|
|
55
|
+
"api/billing",
|
|
56
|
+
"api/payments",
|
|
57
|
+
"api/admin",
|
|
58
|
+
"server/auth",
|
|
59
|
+
"server/billing",
|
|
60
|
+
"src/auth",
|
|
61
|
+
"src/billing",
|
|
62
|
+
"src/payments",
|
|
63
|
+
]);
|
|
64
|
+
|
|
65
|
+
const DEFAULT_BLOCKED_ACTIONS = Object.freeze([
|
|
66
|
+
"deploy",
|
|
67
|
+
"publish",
|
|
68
|
+
"push_to_production",
|
|
69
|
+
"run_migrations_production",
|
|
70
|
+
"delete_database",
|
|
71
|
+
"drop_table",
|
|
72
|
+
"truncate_table",
|
|
73
|
+
"send_email_production",
|
|
74
|
+
"charge_customer",
|
|
75
|
+
"run_env_script",
|
|
76
|
+
]);
|
|
77
|
+
|
|
78
|
+
const DEFAULT_ALLOWED_ACTIONS = Object.freeze([
|
|
79
|
+
"file_read",
|
|
80
|
+
"file_write_with_diff",
|
|
81
|
+
"run_tests",
|
|
82
|
+
"run_lint",
|
|
83
|
+
"run_build",
|
|
84
|
+
"run_type_check",
|
|
85
|
+
"git_status",
|
|
86
|
+
"git_diff",
|
|
87
|
+
"git_log",
|
|
88
|
+
]);
|
|
89
|
+
|
|
90
|
+
// ── Helpers ───────────────────────────────────────────────────────────────────
|
|
91
|
+
|
|
92
|
+
function safeReadJson(absPath) {
|
|
93
|
+
try {
|
|
94
|
+
if (!fs.existsSync(absPath)) return null;
|
|
95
|
+
const raw = fs.readFileSync(absPath, "utf8").replace(/^/, "");
|
|
96
|
+
return JSON.parse(raw);
|
|
97
|
+
} catch {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function fileExists(cwd, ...parts) {
|
|
103
|
+
return fs.existsSync(path.join(cwd, ...parts));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function readText(cwd, ...parts) {
|
|
107
|
+
try {
|
|
108
|
+
const absPath = path.join(cwd, ...parts);
|
|
109
|
+
if (!fs.existsSync(absPath)) return null;
|
|
110
|
+
return fs.readFileSync(absPath, "utf8");
|
|
111
|
+
} catch {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function nowIso() {
|
|
117
|
+
return new Date().toISOString();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// ── Package manager detection ─────────────────────────────────────────────────
|
|
121
|
+
|
|
122
|
+
function detectPackageManager(cwd, pkg) {
|
|
123
|
+
// Check packageManager field in package.json first
|
|
124
|
+
if (pkg && pkg.packageManager) {
|
|
125
|
+
const pm = pkg.packageManager;
|
|
126
|
+
if (pm.startsWith("pnpm")) return "pnpm";
|
|
127
|
+
if (pm.startsWith("yarn")) return "yarn";
|
|
128
|
+
if (pm.startsWith("bun")) return "bun";
|
|
129
|
+
if (pm.startsWith("npm")) return "npm";
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Check lockfiles
|
|
133
|
+
if (fileExists(cwd, "pnpm-lock.yaml")) return "pnpm";
|
|
134
|
+
if (fileExists(cwd, "yarn.lock")) return "yarn";
|
|
135
|
+
if (fileExists(cwd, "bun.lockb") || fileExists(cwd, "bun.lock")) return "bun";
|
|
136
|
+
if (fileExists(cwd, "package-lock.json")) return "npm";
|
|
137
|
+
|
|
138
|
+
// Has package.json but no lockfile
|
|
139
|
+
if (pkg) return "npm";
|
|
140
|
+
|
|
141
|
+
return "unknown";
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ── Framework detection ───────────────────────────────────────────────────────
|
|
145
|
+
|
|
146
|
+
function detectFramework(cwd, pkg) {
|
|
147
|
+
if (!pkg) return "unknown";
|
|
148
|
+
|
|
149
|
+
const deps = {
|
|
150
|
+
...((pkg.dependencies) || {}),
|
|
151
|
+
...((pkg.devDependencies) || {}),
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const scripts = pkg.scripts || {};
|
|
155
|
+
const hasScript = (name) => Boolean(scripts[name]);
|
|
156
|
+
const hasDep = (name) => Boolean(deps[name]);
|
|
157
|
+
|
|
158
|
+
// Wasp
|
|
159
|
+
if (fileExists(cwd, "main.wasp") || fileExists(cwd, ".wasproot")) return "wasp";
|
|
160
|
+
|
|
161
|
+
// Next.js
|
|
162
|
+
if (hasDep("next")) return "nextjs";
|
|
163
|
+
|
|
164
|
+
// Remix
|
|
165
|
+
if (hasDep("@remix-run/react") || hasDep("@remix-run/node")) return "remix";
|
|
166
|
+
|
|
167
|
+
// Vite + React
|
|
168
|
+
if (hasDep("vite") && hasDep("react")) return "vite_react";
|
|
169
|
+
|
|
170
|
+
// Vite generic
|
|
171
|
+
if (hasDep("vite")) return "vite";
|
|
172
|
+
|
|
173
|
+
// React (CRA or other)
|
|
174
|
+
if (hasDep("react") && hasDep("react-dom")) return "react";
|
|
175
|
+
|
|
176
|
+
// Vue
|
|
177
|
+
if (hasDep("vue") || hasDep("@vue/core")) return "vue";
|
|
178
|
+
|
|
179
|
+
// Express
|
|
180
|
+
if (hasDep("express")) return "express_node";
|
|
181
|
+
|
|
182
|
+
// Node (generic)
|
|
183
|
+
if (hasScript("start") || hasScript("dev")) return "node";
|
|
184
|
+
|
|
185
|
+
// Static HTML (no package.json framework)
|
|
186
|
+
if (fileExists(cwd, "index.html") && !pkg) return "static_html";
|
|
187
|
+
|
|
188
|
+
return "node";
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// ── Workspace type detection ──────────────────────────────────────────────────
|
|
192
|
+
|
|
193
|
+
function detectWorkspaceType(cwd, pkg) {
|
|
194
|
+
if (!pkg) return "unknown";
|
|
195
|
+
|
|
196
|
+
// pnpm workspaces
|
|
197
|
+
if (fileExists(cwd, "pnpm-workspace.yaml")) return "monorepo";
|
|
198
|
+
|
|
199
|
+
// yarn/npm workspaces
|
|
200
|
+
if (pkg.workspaces) return "monorepo";
|
|
201
|
+
|
|
202
|
+
// Multiple apps directories
|
|
203
|
+
const appsDir = fileExists(cwd, "apps");
|
|
204
|
+
const packagesDir = fileExists(cwd, "packages");
|
|
205
|
+
if (appsDir && packagesDir) return "monorepo";
|
|
206
|
+
|
|
207
|
+
return "single";
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// ── App detection ─────────────────────────────────────────────────────────────
|
|
211
|
+
|
|
212
|
+
function detectApps(cwd) {
|
|
213
|
+
const apps = [];
|
|
214
|
+
const appsDir = path.join(cwd, "apps");
|
|
215
|
+
if (fs.existsSync(appsDir)) {
|
|
216
|
+
try {
|
|
217
|
+
const entries = fs.readdirSync(appsDir, { withFileTypes: true });
|
|
218
|
+
for (const entry of entries) {
|
|
219
|
+
if (entry.isDirectory()) {
|
|
220
|
+
const appPkg = safeReadJson(path.join(appsDir, entry.name, "package.json"));
|
|
221
|
+
apps.push({
|
|
222
|
+
name: entry.name,
|
|
223
|
+
path: `apps/${entry.name}`,
|
|
224
|
+
framework: detectFramework(path.join(appsDir, entry.name), appPkg),
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
} catch {}
|
|
229
|
+
}
|
|
230
|
+
return apps;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// ── Script detection ──────────────────────────────────────────────────────────
|
|
234
|
+
|
|
235
|
+
function detectCommands(pkg) {
|
|
236
|
+
if (!pkg || !pkg.scripts) {
|
|
237
|
+
return {
|
|
238
|
+
build: null,
|
|
239
|
+
test: null,
|
|
240
|
+
lint: null,
|
|
241
|
+
dev: null,
|
|
242
|
+
preview: null,
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const scripts = pkg.scripts;
|
|
247
|
+
return {
|
|
248
|
+
build: scripts.build || scripts["build:prod"] || null,
|
|
249
|
+
test: scripts.test || scripts["test:unit"] || scripts["test:ci"] || null,
|
|
250
|
+
lint: scripts.lint || scripts["lint:check"] || null,
|
|
251
|
+
dev: scripts.dev || scripts.start || scripts.serve || null,
|
|
252
|
+
preview: scripts.preview || scripts["preview:prod"] || null,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// ── Dev server detection ──────────────────────────────────────────────────────
|
|
257
|
+
|
|
258
|
+
function detectDevServer(cwd, pkg, framework) {
|
|
259
|
+
const portGuesses = {
|
|
260
|
+
nextjs: 3000,
|
|
261
|
+
vite_react: 5173,
|
|
262
|
+
vite: 5173,
|
|
263
|
+
react: 3000,
|
|
264
|
+
wasp: 3000,
|
|
265
|
+
remix: 3000,
|
|
266
|
+
vue: 5173,
|
|
267
|
+
express_node: 3000,
|
|
268
|
+
node: 3000,
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
const scripts = (pkg && pkg.scripts) || {};
|
|
272
|
+
const hasDevScript = Boolean(scripts.dev || scripts.start);
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
detected: hasDevScript || ["nextjs", "vite_react", "vite", "react", "wasp"].includes(framework),
|
|
276
|
+
defaultPort: portGuesses[framework] || 3000,
|
|
277
|
+
previewCommand: scripts.preview || scripts.dev || null,
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// ── Deploy detection ──────────────────────────────────────────────────────────
|
|
282
|
+
|
|
283
|
+
function detectDeploy(cwd) {
|
|
284
|
+
const configFiles = [];
|
|
285
|
+
let provider = "unknown";
|
|
286
|
+
|
|
287
|
+
if (fileExists(cwd, "netlify.toml")) {
|
|
288
|
+
configFiles.push("netlify.toml");
|
|
289
|
+
provider = "netlify";
|
|
290
|
+
}
|
|
291
|
+
if (fileExists(cwd, "vercel.json") || fileExists(cwd, ".vercel")) {
|
|
292
|
+
configFiles.push("vercel.json");
|
|
293
|
+
provider = provider === "netlify" ? "netlify+vercel" : "vercel";
|
|
294
|
+
}
|
|
295
|
+
if (fileExists(cwd, "railway.toml") || fileExists(cwd, "railway.json")) {
|
|
296
|
+
configFiles.push("railway.toml");
|
|
297
|
+
provider = provider === "unknown" ? "railway" : provider + "+railway";
|
|
298
|
+
}
|
|
299
|
+
if (fileExists(cwd, "fly.toml")) {
|
|
300
|
+
configFiles.push("fly.toml");
|
|
301
|
+
provider = provider === "unknown" ? "fly" : provider + "+fly";
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return {
|
|
305
|
+
provider,
|
|
306
|
+
configFiles,
|
|
307
|
+
requiresApproval: configFiles.length > 0,
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// ── Proof defaults ────────────────────────────────────────────────────────────
|
|
312
|
+
|
|
313
|
+
function detectProofDefaults(commands, deploy) {
|
|
314
|
+
const proofSteps = [];
|
|
315
|
+
|
|
316
|
+
if (commands.build) proofSteps.push({ step: "build", command: commands.build, available: true });
|
|
317
|
+
if (commands.test) proofSteps.push({ step: "test", command: commands.test, available: true });
|
|
318
|
+
if (commands.lint) proofSteps.push({ step: "lint", command: commands.lint, available: true });
|
|
319
|
+
|
|
320
|
+
if (proofSteps.length === 0) {
|
|
321
|
+
proofSteps.push({ step: "manual_review", command: null, available: false, note: "not_available" });
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return {
|
|
325
|
+
requiredSteps: proofSteps.filter((s) => s.available).map((s) => s.step),
|
|
326
|
+
steps: proofSteps,
|
|
327
|
+
screenshotAvailable: false,
|
|
328
|
+
deployGateRequired: deploy.requiresApproval,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// ── Agent config surfaces ─────────────────────────────────────────────────────
|
|
333
|
+
|
|
334
|
+
function detectAgentConfigSurfaces(cwd) {
|
|
335
|
+
const surfaces = [];
|
|
336
|
+
if (fileExists(cwd, ".claude", "settings.json")) surfaces.push(".claude/settings.json");
|
|
337
|
+
if (fileExists(cwd, ".claude", "settings.local.json")) surfaces.push(".claude/settings.local.json");
|
|
338
|
+
if (fileExists(cwd, "CLAUDE.md")) surfaces.push("CLAUDE.md");
|
|
339
|
+
if (fileExists(cwd, "AGENTS.md")) surfaces.push("AGENTS.md");
|
|
340
|
+
if (fileExists(cwd, ".cursorrules")) surfaces.push(".cursorrules");
|
|
341
|
+
if (fileExists(cwd, ".codex")) surfaces.push(".codex");
|
|
342
|
+
return surfaces;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// ── Source signals ────────────────────────────────────────────────────────────
|
|
346
|
+
|
|
347
|
+
function buildSourceSignals(cwd, pkg) {
|
|
348
|
+
const signals = [];
|
|
349
|
+
|
|
350
|
+
if (pkg) signals.push("package.json");
|
|
351
|
+
if (fileExists(cwd, "main.wasp")) signals.push("main.wasp");
|
|
352
|
+
if (fileExists(cwd, "netlify.toml")) signals.push("netlify.toml");
|
|
353
|
+
if (fileExists(cwd, "vercel.json")) signals.push("vercel.json");
|
|
354
|
+
if (fileExists(cwd, "tsconfig.json")) signals.push("tsconfig.json");
|
|
355
|
+
if (fileExists(cwd, "vite.config.ts") || fileExists(cwd, "vite.config.js")) signals.push("vite.config");
|
|
356
|
+
if (fileExists(cwd, "next.config.js") || fileExists(cwd, "next.config.mjs")) signals.push("next.config");
|
|
357
|
+
if (fileExists(cwd, "schema.prisma")) signals.push("schema.prisma");
|
|
358
|
+
|
|
359
|
+
return signals;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// ── Risk boundaries ───────────────────────────────────────────────────────────
|
|
363
|
+
|
|
364
|
+
function buildRiskBoundaries(cwd, pkg, deploy) {
|
|
365
|
+
const blockedFiles = [...DEFAULT_BLOCKED_FILES];
|
|
366
|
+
const sensitiveDirs = [...DEFAULT_SENSITIVE_DIRS];
|
|
367
|
+
|
|
368
|
+
// Add deploy config files to blocked (require explicit approval)
|
|
369
|
+
if (deploy.configFiles.length > 0) {
|
|
370
|
+
blockedFiles.push(...deploy.configFiles);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// package-lock.json is risky to auto-modify
|
|
374
|
+
if (fileExists(cwd, "package-lock.json")) {
|
|
375
|
+
if (!blockedFiles.includes("package-lock.json")) {
|
|
376
|
+
blockedFiles.push("package-lock.json");
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// schema.prisma is risky (production DB schema)
|
|
381
|
+
if (fileExists(cwd, "schema.prisma")) {
|
|
382
|
+
blockedFiles.push("schema.prisma");
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return {
|
|
386
|
+
blockedFiles: [...new Set(blockedFiles)],
|
|
387
|
+
sensitiveDirs: [...new Set(sensitiveDirs)],
|
|
388
|
+
blockedActions: [...DEFAULT_BLOCKED_ACTIONS],
|
|
389
|
+
allowedDefaultActions: [...DEFAULT_ALLOWED_ACTIONS],
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// ── Profile status determination ──────────────────────────────────────────────
|
|
394
|
+
|
|
395
|
+
function determineStatus(pkg, framework, packageManager) {
|
|
396
|
+
if (!pkg) return "unknown";
|
|
397
|
+
if (framework === "unknown" || packageManager === "unknown") return "partial";
|
|
398
|
+
return "ready";
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// ── Build functions ───────────────────────────────────────────────────────────
|
|
402
|
+
|
|
403
|
+
function detectProjectProfile(cwd, options = {}) {
|
|
404
|
+
const pkgPath = path.join(cwd, "package.json");
|
|
405
|
+
const pkg = safeReadJson(pkgPath);
|
|
406
|
+
|
|
407
|
+
const packageManager = detectPackageManager(cwd, pkg);
|
|
408
|
+
const framework = detectFramework(cwd, pkg);
|
|
409
|
+
const workspaceType = detectWorkspaceType(cwd, pkg);
|
|
410
|
+
const apps = detectApps(cwd);
|
|
411
|
+
const commands = detectCommands(pkg);
|
|
412
|
+
const devServer = detectDevServer(cwd, pkg, framework);
|
|
413
|
+
const deploy = detectDeploy(cwd);
|
|
414
|
+
const riskBoundaries = buildRiskBoundaries(cwd, pkg, deploy);
|
|
415
|
+
const proofDefaults = detectProofDefaults(commands, deploy);
|
|
416
|
+
const agentConfigSurfaces = detectAgentConfigSurfaces(cwd);
|
|
417
|
+
const sourceSignals = buildSourceSignals(cwd, pkg);
|
|
418
|
+
const status = determineStatus(pkg, framework, packageManager);
|
|
419
|
+
|
|
420
|
+
const caveats = [];
|
|
421
|
+
if (!pkg) caveats.push("No package.json found. Profile is partial.");
|
|
422
|
+
if (deploy.requiresApproval) caveats.push("Deploy config found. Deploy actions require explicit approval.");
|
|
423
|
+
caveats.push("Risk boundaries are defaults. Review for project-specific exceptions.");
|
|
424
|
+
caveats.push("No script execution was performed during profile detection.");
|
|
425
|
+
|
|
426
|
+
return {
|
|
427
|
+
contract: CONTRACT,
|
|
428
|
+
schemaVersion: SCHEMA_VERSION,
|
|
429
|
+
status,
|
|
430
|
+
framework,
|
|
431
|
+
packageManager,
|
|
432
|
+
workspaceType,
|
|
433
|
+
apps,
|
|
434
|
+
commands,
|
|
435
|
+
devServer,
|
|
436
|
+
deploy,
|
|
437
|
+
riskBoundaries,
|
|
438
|
+
proofDefaults,
|
|
439
|
+
agentConfigSurfaces,
|
|
440
|
+
sourceSignals,
|
|
441
|
+
caveats,
|
|
442
|
+
redacted: true,
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function buildProjectProfile(cwd, options = {}) {
|
|
447
|
+
return detectProjectProfile(cwd, options);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function writeProjectProfile(cwd, profile) {
|
|
451
|
+
ensureCcoDirs(cwd);
|
|
452
|
+
const dir = path.join(cwd, ".claude", "cco", "orchestration", "project-profile");
|
|
453
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
454
|
+
const absPath = path.join(cwd, LATEST_PROFILE_REL);
|
|
455
|
+
fs.writeFileSync(absPath, JSON.stringify(profile, null, 2), "utf8");
|
|
456
|
+
|
|
457
|
+
try {
|
|
458
|
+
appendProductLearningEvent(cwd, {
|
|
459
|
+
eventName: "project_profile_detected",
|
|
460
|
+
category: "project_profile",
|
|
461
|
+
surface: "local",
|
|
462
|
+
status: "observed",
|
|
463
|
+
payload: {
|
|
464
|
+
profileStatus: profile.status,
|
|
465
|
+
framework: profile.framework,
|
|
466
|
+
packageManager: profile.packageManager,
|
|
467
|
+
workspaceType: profile.workspaceType,
|
|
468
|
+
deployProvider: profile.deploy?.provider || "unknown",
|
|
469
|
+
deployRequiresApproval: profile.deploy?.requiresApproval || false,
|
|
470
|
+
proofStepCount: (profile.proofDefaults?.steps || []).filter((s) => s.available).length,
|
|
471
|
+
sourceSignalCount: (profile.sourceSignals || []).length,
|
|
472
|
+
agentConfigSurfaceCount: (profile.agentConfigSurfaces || []).length,
|
|
473
|
+
},
|
|
474
|
+
});
|
|
475
|
+
} catch {
|
|
476
|
+
// non-blocking
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
return { profilePath: LATEST_PROFILE_REL };
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
function buildProjectProfileSurface(cwd, options = {}) {
|
|
483
|
+
const absPath = path.join(cwd, LATEST_PROFILE_REL);
|
|
484
|
+
const profile = safeReadJson(absPath);
|
|
485
|
+
if (!profile) {
|
|
486
|
+
return {
|
|
487
|
+
status: "not_run",
|
|
488
|
+
latestProfilePath: null,
|
|
489
|
+
framework: null,
|
|
490
|
+
packageManager: null,
|
|
491
|
+
buildAvailable: false,
|
|
492
|
+
testAvailable: false,
|
|
493
|
+
nextAction: "Run `avorelo project-profile` to detect project profile.",
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
return {
|
|
497
|
+
status: profile.status,
|
|
498
|
+
latestProfilePath: LATEST_PROFILE_REL,
|
|
499
|
+
framework: profile.framework,
|
|
500
|
+
packageManager: profile.packageManager,
|
|
501
|
+
buildAvailable: Boolean(profile.commands?.build),
|
|
502
|
+
testAvailable: Boolean(profile.commands?.test),
|
|
503
|
+
deployProvider: profile.deploy?.provider || "unknown",
|
|
504
|
+
deployRequiresApproval: profile.deploy?.requiresApproval || false,
|
|
505
|
+
nextAction: null,
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
function formatProjectProfileText(profile, options = {}) {
|
|
510
|
+
const lines = [
|
|
511
|
+
"Avorelo Project Profile",
|
|
512
|
+
"",
|
|
513
|
+
`Status: ${profile.status}`,
|
|
514
|
+
`Framework: ${profile.framework}`,
|
|
515
|
+
`Package Mgr: ${profile.packageManager}`,
|
|
516
|
+
`Workspace: ${profile.workspaceType}`,
|
|
517
|
+
profile.apps?.length > 0 ? `Apps: ${profile.apps.map((a) => a.name).join(", ")}` : null,
|
|
518
|
+
"",
|
|
519
|
+
"Commands:",
|
|
520
|
+
profile.commands?.build ? ` build: ${profile.commands.build}` : " build: not detected",
|
|
521
|
+
profile.commands?.test ? ` test: ${profile.commands.test}` : " test: not detected",
|
|
522
|
+
profile.commands?.lint ? ` lint: ${profile.commands.lint}` : " lint: not detected",
|
|
523
|
+
profile.commands?.dev ? ` dev: ${profile.commands.dev}` : " dev: not detected",
|
|
524
|
+
"",
|
|
525
|
+
"Deploy:",
|
|
526
|
+
` Provider: ${profile.deploy?.provider || "none"}`,
|
|
527
|
+
` Requires approval: ${profile.deploy?.requiresApproval ? "yes" : "no"}`,
|
|
528
|
+
profile.deploy?.configFiles?.length > 0 ? ` Config: ${profile.deploy.configFiles.join(", ")}` : null,
|
|
529
|
+
"",
|
|
530
|
+
"Risk Boundaries:",
|
|
531
|
+
` Blocked files: ${(profile.riskBoundaries?.blockedFiles || []).length} patterns`,
|
|
532
|
+
` Sensitive dirs: ${(profile.riskBoundaries?.sensitiveDirs || []).length} dirs`,
|
|
533
|
+
` Blocked actions: ${(profile.riskBoundaries?.blockedActions || []).length}`,
|
|
534
|
+
"",
|
|
535
|
+
"Proof defaults:",
|
|
536
|
+
(profile.proofDefaults?.requiredSteps || []).length > 0
|
|
537
|
+
? ` Steps: ${profile.proofDefaults.requiredSteps.join(", ")}`
|
|
538
|
+
: " Steps: none detected",
|
|
539
|
+
"",
|
|
540
|
+
`Profile: ${LATEST_PROFILE_REL}`,
|
|
541
|
+
].filter((l) => l !== null);
|
|
542
|
+
|
|
543
|
+
return lines.join("\n") + "\n";
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
module.exports = {
|
|
547
|
+
CONTRACT,
|
|
548
|
+
SCHEMA_VERSION,
|
|
549
|
+
LATEST_PROFILE_REL,
|
|
550
|
+
detectProjectProfile,
|
|
551
|
+
buildProjectProfile,
|
|
552
|
+
writeProjectProfile,
|
|
553
|
+
buildProjectProfileSurface,
|
|
554
|
+
formatProjectProfileText,
|
|
555
|
+
};
|