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,555 +0,0 @@
|
|
|
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
|
-
};
|