@ryuenn3123/agentic-senior-core 4.4.0 → 5.2.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/.agents/plugins/agentic-senior-core/plugin.json +3 -0
- package/.agents/plugins/agentic-senior-core/rules/agentic-senior-core.md +131 -0
- package/.agents/plugins/agentic-senior-core/skills/asc/SKILL.md +16 -0
- package/.agents/plugins/agentic-senior-core/skills/asc-audit/SKILL.md +28 -0
- package/.agents/plugins/agentic-senior-core/skills/asc-refactor/SKILL.md +35 -0
- package/.agents/plugins/agentic-senior-core/skills/asc-review/SKILL.md +54 -0
- package/.agents/rules/agentic-senior-core.md +131 -0
- package/.claude-plugin/marketplace.json +17 -0
- package/.claude-plugin/plugin.json +17 -0
- package/.clinerules/agentic-senior-core.md +94 -0
- package/.codex-plugin/plugin.json +24 -0
- package/.cursor/rules/agentic-senior-core.mdc +99 -0
- package/.devin-plugin/plugin.json +13 -0
- package/.github/copilot-instructions.md +94 -0
- package/.github/plugin/marketplace.json +20 -0
- package/.github/plugin/plugin.json +16 -0
- package/.kiro/steering/agentic-senior-core.md +94 -0
- package/.openclaw/skills/asc/SKILL.md +23 -0
- package/.openclaw/skills/asc-audit/SKILL.md +28 -0
- package/.openclaw/skills/asc-review/SKILL.md +54 -0
- package/.opencode/plugins/agentic-senior-core.mjs +31 -0
- package/.windsurf/rules/agentic-senior-core.md +94 -0
- package/AGENTS.md +126 -127
- package/CONTRIBUTING.md +93 -63
- package/README.md +190 -110
- package/__init__.py +61 -0
- package/bin/agentic-senior-core.js +42 -41
- package/commands/asc-audit.md +1 -0
- package/commands/asc-audit.toml +2 -0
- package/commands/asc-help.md +9 -0
- package/commands/asc-help.toml +2 -0
- package/commands/asc-refactor.md +1 -0
- package/commands/asc-refactor.toml +2 -0
- package/commands/asc-review.md +1 -0
- package/commands/asc-review.toml +2 -0
- package/gemini-extension.json +10 -0
- package/hooks/copilot-hooks.json +21 -0
- package/hooks/hooks.json +31 -0
- package/hooks/session-start.js +36 -0
- package/hooks/subagent-start.js +38 -0
- package/lib/cli/commands/adapter.mjs +109 -0
- package/lib/cli/commands/clean.mjs +63 -0
- package/lib/cli/commands/status.mjs +94 -0
- package/package.json +43 -60
- package/plugin.yaml +16 -0
- package/scripts/uninstall.js +38 -0
- package/skills/asc/SKILL.md +16 -0
- package/skills/asc-audit/SKILL.md +28 -0
- package/skills/asc-refactor/SKILL.md +35 -0
- package/skills/asc-review/SKILL.md +54 -0
- package/.agent-context/policies/llm-judge-threshold.json +0 -29
- package/.agent-context/prompts/bootstrap-design.md +0 -63
- package/.agent-context/prompts/compact-natural-mode.md +0 -100
- package/.agent-context/prompts/init-project.md +0 -60
- package/.agent-context/prompts/refactor.md +0 -38
- package/.agent-context/prompts/review-code.md +0 -31
- package/.agent-context/review-checklists/architecture-review.md +0 -57
- package/.agent-context/review-checklists/pr-checklist.md +0 -134
- package/.agent-context/rules/api-docs.md +0 -24
- package/.agent-context/rules/api-versioning.md +0 -16
- package/.agent-context/rules/architecture.md +0 -38
- package/.agent-context/rules/background-jobs.md +0 -17
- package/.agent-context/rules/config-and-flags.md +0 -16
- package/.agent-context/rules/database-design.md +0 -18
- package/.agent-context/rules/docker-runtime.md +0 -17
- package/.agent-context/rules/error-handling.md +0 -16
- package/.agent-context/rules/event-driven.md +0 -16
- package/.agent-context/rules/frontend-architecture.md +0 -54
- package/.agent-context/rules/microservices.md +0 -16
- package/.agent-context/rules/migrations.md +0 -16
- package/.agent-context/rules/observability.md +0 -16
- package/.agent-context/rules/performance.md +0 -16
- package/.agent-context/rules/realtime.md +0 -16
- package/.agent-context/rules/resilience.md +0 -18
- package/.agent-context/rules/security.md +0 -18
- package/.agent-context/rules/testing.md +0 -16
- package/.agent-context/state/README.md +0 -25
- package/.agent-context/state/architecture-map.md +0 -40
- package/.agent-context/state/benchmark-comparison-schema.json +0 -181
- package/.agent-context/state/benchmark-reproducibility.json +0 -87
- package/.agent-context/state/benchmark-thresholds.json +0 -10
- package/.agent-context/state/benchmark-writer-judge-config.json +0 -58
- package/.agent-context/state/dependency-map.md +0 -41
- package/.agent-context/state/memory-adapter-contract.json +0 -52
- package/.agent-context/state/memory-schema-v1.json +0 -88
- package/GEMINI.md +0 -1
- package/benchmarks/README.md +0 -60
- package/benchmarks/compact-natural-mode/fixtures.mjs +0 -359
- package/benchmarks/compact-natural-mode/scorer.mjs +0 -331
- package/benchmarks/runtime-token-saver/fixtures.mjs +0 -836
- package/lib/cli/adaptive-context/catalog.mjs +0 -394
- package/lib/cli/adaptive-context/file-signals.mjs +0 -100
- package/lib/cli/adaptive-context/implications.mjs +0 -44
- package/lib/cli/adaptive-context.mjs +0 -151
- package/lib/cli/audits/typography-palette-anti-repeat/color-utils.mjs +0 -156
- package/lib/cli/audits/typography-palette-anti-repeat/file-scanner.mjs +0 -103
- package/lib/cli/audits/typography-palette-anti-repeat/typography-utils.mjs +0 -70
- package/lib/cli/backup.mjs +0 -210
- package/lib/cli/commands/context.mjs +0 -140
- package/lib/cli/commands/init/project-context.mjs +0 -60
- package/lib/cli/commands/init/runtime-environment.mjs +0 -59
- package/lib/cli/commands/init/setup-decisions.mjs +0 -83
- package/lib/cli/commands/init.mjs +0 -654
- package/lib/cli/commands/launch.mjs +0 -76
- package/lib/cli/commands/optimize.mjs +0 -284
- package/lib/cli/commands/rollback.mjs +0 -64
- package/lib/cli/commands/upgrade/token-optimization-state.mjs +0 -51
- package/lib/cli/commands/upgrade.mjs +0 -451
- package/lib/cli/compiler.mjs +0 -187
- package/lib/cli/constants.mjs +0 -136
- package/lib/cli/detector/constants.mjs +0 -135
- package/lib/cli/detector/design-evidence/collector.mjs +0 -256
- package/lib/cli/detector/design-evidence/constants.mjs +0 -39
- package/lib/cli/detector/design-evidence/file-traversal.mjs +0 -83
- package/lib/cli/detector/design-evidence/structured-attribute-evidence.mjs +0 -117
- package/lib/cli/detector/design-evidence/summary.mjs +0 -109
- package/lib/cli/detector/design-evidence/utility-helpers.mjs +0 -122
- package/lib/cli/detector/design-evidence.mjs +0 -25
- package/lib/cli/detector/stack-detection.mjs +0 -243
- package/lib/cli/detector/ui-signals.mjs +0 -150
- package/lib/cli/detector/workspace-scan.mjs +0 -177
- package/lib/cli/detector.mjs +0 -23
- package/lib/cli/init-detection-flow.mjs +0 -48
- package/lib/cli/init-options.mjs +0 -237
- package/lib/cli/init-selection.mjs +0 -29
- package/lib/cli/memory-continuity.mjs +0 -537
- package/lib/cli/preflight.mjs +0 -76
- package/lib/cli/project-scaffolder/constants.mjs +0 -69
- package/lib/cli/project-scaffolder/discovery.mjs +0 -272
- package/lib/cli/project-scaffolder/prompt-builders.mjs +0 -171
- package/lib/cli/project-scaffolder/storage.mjs +0 -144
- package/lib/cli/project-scaffolder/ui-scope-detection.mjs +0 -36
- package/lib/cli/project-scaffolder.mjs +0 -29
- package/lib/cli/rollback.mjs +0 -66
- package/lib/cli/token-optimization.mjs +0 -401
- package/lib/cli/utils/filesystem.mjs +0 -81
- package/lib/cli/utils/managed-surface.mjs +0 -280
- package/lib/cli/utils/prompting.mjs +0 -44
- package/lib/cli/utils.mjs +0 -479
- package/mcp.json +0 -134
- package/scripts/adaptive-context/fixtures.mjs +0 -183
- package/scripts/adaptive-context-benchmark.mjs +0 -9
- package/scripts/ascx-runtime-token-saver-benchmark.mjs +0 -9
- package/scripts/benchmark-evidence-bundle.mjs +0 -645
- package/scripts/benchmark-gate.mjs +0 -121
- package/scripts/benchmark-intelligence.mjs +0 -33
- package/scripts/benchmark-writer-judge-matrix.mjs +0 -379
- package/scripts/build-release-benchmark-bundle.mjs +0 -202
- package/scripts/bump-version.mjs +0 -103
- package/scripts/clean-local-artifacts.mjs +0 -78
- package/scripts/compact-natural-mode-benchmark.mjs +0 -9
- package/scripts/context-triggered-audit.mjs +0 -391
- package/scripts/detection-benchmark.mjs +0 -127
- package/scripts/docs-quality-drift-report.mjs +0 -358
- package/scripts/documentation-boundary-audit.mjs +0 -305
- package/scripts/explain-on-demand-audit.mjs +0 -427
- package/scripts/forbidden-content-check.mjs +0 -123
- package/scripts/frontend-usability-audit.mjs +0 -243
- package/scripts/generate-sbom.mjs +0 -61
- package/scripts/governance-weekly-report.mjs +0 -466
- package/scripts/llm-judge/checklist-loader.mjs +0 -45
- package/scripts/llm-judge/constants.mjs +0 -66
- package/scripts/llm-judge/diff-collection.mjs +0 -74
- package/scripts/llm-judge/prompting.mjs +0 -78
- package/scripts/llm-judge/providers.mjs +0 -111
- package/scripts/llm-judge/verdict.mjs +0 -134
- package/scripts/llm-judge.mjs +0 -200
- package/scripts/memory-continuity-benchmark.mjs +0 -322
- package/scripts/quality-trend-report.mjs +0 -289
- package/scripts/release-gate/audit-checks.mjs +0 -441
- package/scripts/release-gate/constants.mjs +0 -53
- package/scripts/release-gate/runtime.mjs +0 -63
- package/scripts/release-gate/static-checks.mjs +0 -182
- package/scripts/release-gate.mjs +0 -42
- package/scripts/rules-guardian-audit.mjs +0 -580
- package/scripts/single-source-lazy-loading-audit.mjs +0 -449
- package/scripts/sync-thin-adapters.mjs +0 -72
- package/scripts/token-optimization-benchmark.mjs +0 -252
- package/scripts/ui-design-judge/constants.mjs +0 -13
- package/scripts/ui-design-judge/design-execution-summary.mjs +0 -81
- package/scripts/ui-design-judge/git-input.mjs +0 -134
- package/scripts/ui-design-judge/prompting.mjs +0 -52
- package/scripts/ui-design-judge/providers.mjs +0 -102
- package/scripts/ui-design-judge/reporting.mjs +0 -183
- package/scripts/ui-design-judge/rubric-calibration.mjs +0 -214
- package/scripts/ui-design-judge/rubric-goldset.json +0 -188
- package/scripts/ui-design-judge.mjs +0 -319
- package/scripts/ui-rubric-calibration.mjs +0 -35
- package/scripts/validate/audits/cache-layer-contract.mjs +0 -230
- package/scripts/validate/audits/caching-scope-hygiene.mjs +0 -235
- package/scripts/validate/audits/file-size.mjs +0 -158
- package/scripts/validate/audits/reflection-citations.mjs +0 -130
- package/scripts/validate/audits/release-bundle.mjs +0 -135
- package/scripts/validate/audits/rule-id-uniqueness.mjs +0 -278
- package/scripts/validate/config.mjs +0 -501
- package/scripts/validate/coverage-checks.mjs +0 -446
- package/scripts/validate/file-structure.mjs +0 -158
- package/scripts/validate/markdown-content.mjs +0 -109
- package/scripts/validate/project-metadata.mjs +0 -166
- package/scripts/validate/utils.mjs +0 -52
- package/scripts/validate.mjs +0 -267
|
@@ -1,451 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Upgrade Command — Governance upgrade assistant.
|
|
3
|
-
* Depends on: constants, utils, detector, compiler
|
|
4
|
-
*/
|
|
5
|
-
import { createInterface } from 'node:readline/promises';
|
|
6
|
-
import { stdin, stdout } from 'node:process';
|
|
7
|
-
import fs from 'node:fs/promises';
|
|
8
|
-
import path from 'node:path';
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
CLI_VERSION,
|
|
12
|
-
AGENT_CONTEXT_DIR,
|
|
13
|
-
PROFILE_PRESETS,
|
|
14
|
-
AGENT_DECISION_STACK_FILE_NAME,
|
|
15
|
-
AGENT_DECISION_BLUEPRINT_FILE_NAME,
|
|
16
|
-
} from '../constants.mjs';
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
ensureDirectory,
|
|
20
|
-
askYesNo,
|
|
21
|
-
toTitleCase,
|
|
22
|
-
collectFileNames,
|
|
23
|
-
formatDuration,
|
|
24
|
-
pathExists,
|
|
25
|
-
analyzeManagedGovernanceSurface,
|
|
26
|
-
copyGovernanceAssetsToTarget,
|
|
27
|
-
} from '../utils.mjs';
|
|
28
|
-
|
|
29
|
-
import {
|
|
30
|
-
detectProjectContext,
|
|
31
|
-
buildDetectionSummary,
|
|
32
|
-
formatDetectionCandidates,
|
|
33
|
-
detectUiScopeSignals,
|
|
34
|
-
} from '../detector.mjs';
|
|
35
|
-
import {
|
|
36
|
-
writeSelectedPolicy,
|
|
37
|
-
writeOnboardingReport,
|
|
38
|
-
loadOnboardingReportIfExists,
|
|
39
|
-
} from '../compiler.mjs';
|
|
40
|
-
|
|
41
|
-
import { runPreflightChecks } from '../preflight.mjs';
|
|
42
|
-
import {
|
|
43
|
-
createBackup,
|
|
44
|
-
ensureBackupGitignoreEntry,
|
|
45
|
-
ensureRuntimeArtifactGitignoreEntries,
|
|
46
|
-
} from '../backup.mjs';
|
|
47
|
-
import { performRollback } from '../rollback.mjs';
|
|
48
|
-
import { detectProjectDocTemplateStaleness } from '../project-scaffolder.mjs';
|
|
49
|
-
import { ensureActiveMemorySnapshot } from '../memory-continuity.mjs';
|
|
50
|
-
import { buildExistingProjectMajorConstraints } from '../init-detection-flow.mjs';
|
|
51
|
-
import {
|
|
52
|
-
applyUpgradeTokenOptimizationPlan,
|
|
53
|
-
resolveUpgradeTokenOptimizationPlan,
|
|
54
|
-
} from './upgrade/token-optimization-state.mjs';
|
|
55
|
-
|
|
56
|
-
export function parseUpgradeArguments(commandArguments) {
|
|
57
|
-
const parsedUpgradeOptions = {
|
|
58
|
-
targetDirectory: '.',
|
|
59
|
-
dryRun: false,
|
|
60
|
-
skipConfirmation: false,
|
|
61
|
-
includeMcpTemplate: false,
|
|
62
|
-
pruneManagedSurface: true,
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
for (let argumentIndex = 0; argumentIndex < commandArguments.length; argumentIndex++) {
|
|
66
|
-
const currentArgument = commandArguments[argumentIndex];
|
|
67
|
-
|
|
68
|
-
if (!currentArgument.startsWith('--')) {
|
|
69
|
-
parsedUpgradeOptions.targetDirectory = currentArgument;
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (currentArgument === '--dry-run') {
|
|
74
|
-
parsedUpgradeOptions.dryRun = true;
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (currentArgument === '--yes') {
|
|
79
|
-
parsedUpgradeOptions.skipConfirmation = true;
|
|
80
|
-
continue;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (currentArgument === '--mcp-template') {
|
|
84
|
-
parsedUpgradeOptions.includeMcpTemplate = true;
|
|
85
|
-
continue;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (currentArgument === '--no-mcp-template') {
|
|
89
|
-
parsedUpgradeOptions.includeMcpTemplate = false;
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (currentArgument === '--prune') {
|
|
94
|
-
parsedUpgradeOptions.pruneManagedSurface = true;
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (currentArgument === '--no-prune') {
|
|
99
|
-
parsedUpgradeOptions.pruneManagedSurface = false;
|
|
100
|
-
continue;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
throw new Error(`Unknown option: ${currentArgument}`);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return parsedUpgradeOptions;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export async function runUpgradeCommand(targetDirectoryArgument, upgradeOptions = {}) {
|
|
110
|
-
const resolvedTargetDirectoryPath = path.resolve(targetDirectoryArgument || '.');
|
|
111
|
-
|
|
112
|
-
if (resolvedTargetDirectoryPath.toLowerCase() === 'c:\\windows' || resolvedTargetDirectoryPath.toLowerCase() === 'c:\\windows\\system32') {
|
|
113
|
-
console.error('\n[FATAL] Target directory resolved to a Windows system folder (C:\\Windows).');
|
|
114
|
-
console.error('If you are running Windows npm from inside WSL, this is caused by cmd.exe lacking UNC path support.');
|
|
115
|
-
console.error('Please install and use a native Linux Node.js/npm directly inside WSL to setup your project.');
|
|
116
|
-
process.exit(1);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
const setupStartedAt = Date.now();
|
|
120
|
-
await ensureDirectory(resolvedTargetDirectoryPath);
|
|
121
|
-
|
|
122
|
-
const preflightResult = await runPreflightChecks(resolvedTargetDirectoryPath, 'upgrade');
|
|
123
|
-
if (!preflightResult.passed) {
|
|
124
|
-
console.error('\n[FATAL] Preflight checks failed. Upgrading here would cause errors or data loss:');
|
|
125
|
-
console.error(JSON.stringify(preflightResult, null, 2));
|
|
126
|
-
throw new Error('Preflight checks failed.');
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const userInterface = createInterface({ input: stdin, output: stdout });
|
|
130
|
-
|
|
131
|
-
try {
|
|
132
|
-
console.log(`\nAgentic-Senior-Core CLI v${CLI_VERSION}`);
|
|
133
|
-
console.log('Running managed guidance upgrade for an existing repository.');
|
|
134
|
-
|
|
135
|
-
const managedSurfacePlan = await analyzeManagedGovernanceSurface(resolvedTargetDirectoryPath, {
|
|
136
|
-
includeMcpTemplate: upgradeOptions.includeMcpTemplate === true,
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
const stackFileNames = await collectFileNames(path.join(AGENT_CONTEXT_DIR, 'stacks'));
|
|
140
|
-
const blueprintFileNames = await collectFileNames(path.join(AGENT_CONTEXT_DIR, 'blueprints'));
|
|
141
|
-
const existingOnboardingReport = await loadOnboardingReportIfExists(resolvedTargetDirectoryPath);
|
|
142
|
-
const tokenOptimizationPlan = await resolveUpgradeTokenOptimizationPlan(
|
|
143
|
-
resolvedTargetDirectoryPath,
|
|
144
|
-
existingOnboardingReport
|
|
145
|
-
);
|
|
146
|
-
const projectDetection = await detectProjectContext(resolvedTargetDirectoryPath);
|
|
147
|
-
const selectedProfileName = PROFILE_PRESETS[existingOnboardingReport?.selectedProfile]
|
|
148
|
-
? existingOnboardingReport.selectedProfile
|
|
149
|
-
: 'balanced';
|
|
150
|
-
|
|
151
|
-
const hasExplicitRuntimeConstraint = existingOnboardingReport?.runtimeDecision?.mode === 'explicit-constraint';
|
|
152
|
-
const hasExplicitArchitectureConstraint = existingOnboardingReport?.architectureDecision?.mode === 'explicit-constraint';
|
|
153
|
-
|
|
154
|
-
const selectedStackFileName = hasExplicitRuntimeConstraint && stackFileNames.includes(existingOnboardingReport?.selectedStack)
|
|
155
|
-
? existingOnboardingReport.selectedStack
|
|
156
|
-
: AGENT_DECISION_STACK_FILE_NAME;
|
|
157
|
-
|
|
158
|
-
const selectedAdditionalStackFileNames = hasExplicitRuntimeConstraint && Array.isArray(existingOnboardingReport?.selectedAdditionalStacks)
|
|
159
|
-
? Array.from(new Set(existingOnboardingReport.selectedAdditionalStacks.filter(
|
|
160
|
-
(stackFileName) => stackFileNames.includes(stackFileName) && stackFileName !== selectedStackFileName
|
|
161
|
-
)))
|
|
162
|
-
: [];
|
|
163
|
-
|
|
164
|
-
const selectedBlueprintFileName = hasExplicitArchitectureConstraint && blueprintFileNames.includes(existingOnboardingReport?.selectedBlueprint)
|
|
165
|
-
? existingOnboardingReport.selectedBlueprint
|
|
166
|
-
: AGENT_DECISION_BLUEPRINT_FILE_NAME;
|
|
167
|
-
|
|
168
|
-
const selectedAdditionalBlueprintFileNames = hasExplicitArchitectureConstraint && Array.isArray(existingOnboardingReport?.selectedAdditionalBlueprints)
|
|
169
|
-
? Array.from(new Set(existingOnboardingReport.selectedAdditionalBlueprints.filter(
|
|
170
|
-
(blueprintFileName) => blueprintFileNames.includes(blueprintFileName) && blueprintFileName !== selectedBlueprintFileName
|
|
171
|
-
)))
|
|
172
|
-
: [];
|
|
173
|
-
|
|
174
|
-
const includeCiGuardrails = typeof existingOnboardingReport?.ciGuardrailsEnabled === 'boolean'
|
|
175
|
-
? existingOnboardingReport.ciGuardrailsEnabled
|
|
176
|
-
: true;
|
|
177
|
-
const uiScopeSignals = await detectUiScopeSignals({
|
|
178
|
-
targetDirectoryPath: resolvedTargetDirectoryPath,
|
|
179
|
-
selectedStackFileName,
|
|
180
|
-
selectedBlueprintFileName,
|
|
181
|
-
projectScopeKey: existingOnboardingReport?.projectScope?.key || null,
|
|
182
|
-
projectScopeSourceLabel: 'onboarding project scope',
|
|
183
|
-
});
|
|
184
|
-
const packageManifest = uiScopeSignals.packageManifest;
|
|
185
|
-
const designContractPaths = ['docs/DESIGN.md'];
|
|
186
|
-
const missingDesignContractPaths = [];
|
|
187
|
-
|
|
188
|
-
for (const designContractPath of designContractPaths) {
|
|
189
|
-
const absoluteDesignContractPath = path.join(resolvedTargetDirectoryPath, ...designContractPath.split('/'));
|
|
190
|
-
if (!(await pathExists(absoluteDesignContractPath))) {
|
|
191
|
-
missingDesignContractPaths.push(designContractPath);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const detectionMajorConstraints = buildExistingProjectMajorConstraints({ mode: 'upgrade' });
|
|
196
|
-
const detectionTransparency = {
|
|
197
|
-
declaredAt: new Date().toISOString(),
|
|
198
|
-
declarationType: 'existing-project',
|
|
199
|
-
declarationShown: true,
|
|
200
|
-
detectionSummary: buildDetectionSummary(projectDetection),
|
|
201
|
-
activeRulesSummary: {
|
|
202
|
-
canonicalSource: 'AGENTS.md',
|
|
203
|
-
compiledRulebook: null,
|
|
204
|
-
legacyThinAdapters: [],
|
|
205
|
-
generatedBridgeAdapters: ['CLAUDE.md', 'GEMINI.md'],
|
|
206
|
-
stackLoadingMode: 'lazy',
|
|
207
|
-
domainRuleLoadingMode: 'lazy',
|
|
208
|
-
selectedProfile: selectedProfileName,
|
|
209
|
-
selectedProfileDisplayName: toTitleCase(selectedProfileName),
|
|
210
|
-
blockingSeverities: PROFILE_PRESETS[selectedProfileName]?.blockingSeverities || [],
|
|
211
|
-
ciGuardrailsEnabled: includeCiGuardrails,
|
|
212
|
-
},
|
|
213
|
-
majorConstraints: detectionMajorConstraints,
|
|
214
|
-
quickConfirmation: {
|
|
215
|
-
offered: false,
|
|
216
|
-
response: 'upgrade-auto',
|
|
217
|
-
source: 'upgrade-assistant',
|
|
218
|
-
},
|
|
219
|
-
decision: {
|
|
220
|
-
mode: 'upgrade-auto',
|
|
221
|
-
selectedStackFileName,
|
|
222
|
-
selectedBlueprintFileName,
|
|
223
|
-
},
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
console.log('\nExisting project detection transparency:');
|
|
227
|
-
if (projectDetection.detectedStackFileName) {
|
|
228
|
-
const confidenceScoreLabel = Number(projectDetection.confidenceScore || 0).toFixed(2);
|
|
229
|
-
console.log(
|
|
230
|
-
`- Detected stack: ${toTitleCase(projectDetection.detectedStackFileName)} (${projectDetection.confidenceLabel}, score ${confidenceScoreLabel})`
|
|
231
|
-
);
|
|
232
|
-
} else {
|
|
233
|
-
console.log('- Detected stack: unresolved (insufficient markers).');
|
|
234
|
-
}
|
|
235
|
-
console.log('- Active rules baseline: canonical AGENTS.md + .agent-context/ lazy rule library');
|
|
236
|
-
console.log(
|
|
237
|
-
`- Active review thresholds: ${(
|
|
238
|
-
PROFILE_PRESETS[selectedProfileName]?.blockingSeverities || []
|
|
239
|
-
).join(', ') || 'none'})`
|
|
240
|
-
);
|
|
241
|
-
console.log('- Top candidates:');
|
|
242
|
-
console.log(formatDetectionCandidates(projectDetection.rankedCandidates));
|
|
243
|
-
console.log('- Major constraints:');
|
|
244
|
-
for (const majorConstraint of detectionMajorConstraints) {
|
|
245
|
-
console.log(` - ${majorConstraint}`);
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
const projectDocStalenessReport = await detectProjectDocTemplateStaleness(resolvedTargetDirectoryPath);
|
|
249
|
-
|
|
250
|
-
console.log('\nUpgrade preview:');
|
|
251
|
-
console.log(`- Target directory: ${resolvedTargetDirectoryPath}`);
|
|
252
|
-
console.log(`- Runtime decision: ${selectedStackFileName === AGENT_DECISION_STACK_FILE_NAME ? 'agent recommendation required from repo evidence' : toTitleCase(selectedStackFileName)}`);
|
|
253
|
-
if (selectedAdditionalStackFileNames.length > 0) {
|
|
254
|
-
console.log(`- Additional stacks: ${selectedAdditionalStackFileNames.map((stackFileName) => toTitleCase(stackFileName)).join(', ')}`);
|
|
255
|
-
}
|
|
256
|
-
console.log(`- Architecture decision: ${selectedBlueprintFileName === AGENT_DECISION_BLUEPRINT_FILE_NAME ? 'agent recommendation required from repo evidence' : toTitleCase(selectedBlueprintFileName)}`);
|
|
257
|
-
if (selectedAdditionalBlueprintFileNames.length > 0) {
|
|
258
|
-
console.log(`- Additional blueprints: ${selectedAdditionalBlueprintFileNames.map((blueprintFileName) => toTitleCase(blueprintFileName)).join(', ')}`);
|
|
259
|
-
}
|
|
260
|
-
console.log(`- CI/CD quality checks (guardrails): ${includeCiGuardrails ? 'enabled' : 'disabled'}`);
|
|
261
|
-
console.log('- Instruction surface: AGENTS.md canonical with CLAUDE.md and GEMINI.md import bridges');
|
|
262
|
-
console.log('- Default activation cues: Adaptive Context bootstrap, ASCX wrappers, Compact Natural replies');
|
|
263
|
-
console.log(`- Token optimization policy: ${tokenOptimizationPlan.previewLabel}`);
|
|
264
|
-
console.log('- Default response mode: Compact Natural Mode enabled');
|
|
265
|
-
console.log(`- Managed surface stale files: ${managedSurfacePlan.staleFiles.length}`);
|
|
266
|
-
console.log(`- Managed surface stale directories: ${managedSurfacePlan.staleDirectories.length}`);
|
|
267
|
-
console.log(`- Managed surface sync mode: 1:1 (prune enabled)`);
|
|
268
|
-
console.log(`- Managed surface prune mode: ${upgradeOptions.pruneManagedSurface === true ? 'enabled (default)' : 'disabled (--no-prune)'}`);
|
|
269
|
-
console.log(`- MCP config write mode: ${upgradeOptions.includeMcpTemplate === true ? 'enabled (--mcp-template)' : 'disabled (default)'}`);
|
|
270
|
-
if (projectDocStalenessReport.hasProjectDocs) {
|
|
271
|
-
console.log(`- Project docs detected: ${projectDocStalenessReport.checkedFileNames.length}`);
|
|
272
|
-
console.log(`- Project docs expected template version: ${projectDocStalenessReport.expectedTemplateVersion}`);
|
|
273
|
-
console.log(`- Project docs stale files: ${projectDocStalenessReport.staleFiles.length}`);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
if (managedSurfacePlan.staleFiles.length > 0 || managedSurfacePlan.staleDirectories.length > 0) {
|
|
277
|
-
console.log('\nManaged surface stale paths preview (up to 5):');
|
|
278
|
-
const previewPaths = [
|
|
279
|
-
...managedSurfacePlan.staleFiles,
|
|
280
|
-
...managedSurfacePlan.staleDirectories,
|
|
281
|
-
].slice(0, 5);
|
|
282
|
-
for (const previewPath of previewPaths) {
|
|
283
|
-
console.log(`- ${previewPath}`);
|
|
284
|
-
}
|
|
285
|
-
if (managedSurfacePlan.staleFiles.length + managedSurfacePlan.staleDirectories.length > previewPaths.length) {
|
|
286
|
-
console.log('- ...');
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
if (projectDocStalenessReport.staleFiles.length > 0) {
|
|
291
|
-
console.log('\n[WARN] Some project docs were generated from older template versions:');
|
|
292
|
-
for (const staleDoc of projectDocStalenessReport.staleFiles) {
|
|
293
|
-
const detectedVersionLabel = staleDoc.detectedTemplateVersion || 'missing';
|
|
294
|
-
console.log(`- docs/${staleDoc.fileName} (detected: ${detectedVersionLabel}, expected: ${projectDocStalenessReport.expectedTemplateVersion})`);
|
|
295
|
-
}
|
|
296
|
-
console.log('Required action: regenerate docs with init --scaffold-docs or update the files manually to match the latest template version.');
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if (uiScopeSignals.isUiScopeLikely && missingDesignContractPaths.length > 0) {
|
|
300
|
-
console.log('\n[WARN] UI/frontend scope was detected, but the dynamic design contract is incomplete:');
|
|
301
|
-
for (const missingDesignContractPath of missingDesignContractPaths) {
|
|
302
|
-
console.log(`- Missing ${missingDesignContractPath}`);
|
|
303
|
-
}
|
|
304
|
-
if (uiScopeSignals.signalReasons.length > 0) {
|
|
305
|
-
console.log(`- Detection signals: ${uiScopeSignals.signalReasons.join('; ')}`);
|
|
306
|
-
}
|
|
307
|
-
if (Array.isArray(uiScopeSignals.workspaceUiEntries) && uiScopeSignals.workspaceUiEntries.length > 0) {
|
|
308
|
-
console.log(`- Nested UI workspaces: ${uiScopeSignals.workspaceUiEntries.map((workspaceUiEntry) => workspaceUiEntry.relativePath).join(', ')}`);
|
|
309
|
-
}
|
|
310
|
-
console.log('Required action: create or refresh docs/DESIGN.md before allowing UI implementation work.');
|
|
311
|
-
console.log('Upgrade synchronizes governance assets, but it does not author project-specific docs/DESIGN.md automatically.');
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
if (upgradeOptions.dryRun) {
|
|
315
|
-
console.log('\nDry run enabled. No files were modified.');
|
|
316
|
-
return;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
const shouldApplyUpgrade = upgradeOptions.skipConfirmation
|
|
320
|
-
? true
|
|
321
|
-
: await askYesNo('Apply upgrade and synchronize managed files?', userInterface, true);
|
|
322
|
-
|
|
323
|
-
if (!shouldApplyUpgrade) {
|
|
324
|
-
console.log('Upgrade cancelled by user.');
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
await createBackup(resolvedTargetDirectoryPath);
|
|
329
|
-
const backupGitignoreResult = await ensureBackupGitignoreEntry(resolvedTargetDirectoryPath);
|
|
330
|
-
if (backupGitignoreResult.status !== 'unchanged') {
|
|
331
|
-
console.log(`Local backup artifacts ignored in .gitignore (${backupGitignoreResult.entry}).`);
|
|
332
|
-
}
|
|
333
|
-
const runtimeArtifactGitignoreResult = await ensureRuntimeArtifactGitignoreEntries(resolvedTargetDirectoryPath);
|
|
334
|
-
if (runtimeArtifactGitignoreResult.status !== 'unchanged') {
|
|
335
|
-
console.log(
|
|
336
|
-
`Local runtime artifacts ignored in .gitignore (${runtimeArtifactGitignoreResult.addedEntries.join(', ')}).`
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
try {
|
|
341
|
-
const governanceSyncResult = await copyGovernanceAssetsToTarget(resolvedTargetDirectoryPath, {
|
|
342
|
-
includeMcpTemplate: upgradeOptions.includeMcpTemplate === true,
|
|
343
|
-
pruneManagedSurface: upgradeOptions.pruneManagedSurface === true,
|
|
344
|
-
managedSurfacePlan,
|
|
345
|
-
});
|
|
346
|
-
const supplementalCreatedFileNames = [];
|
|
347
|
-
const shouldEnsureActiveMemorySnapshot = existingOnboardingReport?.memoryContinuity?.enabled !== false;
|
|
348
|
-
const tokenOptimizationApplyResult = await applyUpgradeTokenOptimizationPlan(
|
|
349
|
-
resolvedTargetDirectoryPath,
|
|
350
|
-
tokenOptimizationPlan
|
|
351
|
-
);
|
|
352
|
-
if (tokenOptimizationApplyResult.createdFileName) {
|
|
353
|
-
supplementalCreatedFileNames.push(tokenOptimizationApplyResult.createdFileName);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
const obsoleteDesignIntentPath = path.join(resolvedTargetDirectoryPath, 'docs', 'design-intent.json');
|
|
357
|
-
if (await pathExists(obsoleteDesignIntentPath)) {
|
|
358
|
-
try {
|
|
359
|
-
await fs.unlink(obsoleteDesignIntentPath);
|
|
360
|
-
supplementalCreatedFileNames.push('docs/design-intent.json (DELETED - Obsolete Compliance Theater)');
|
|
361
|
-
console.log('\n[CLEANUP] Removed obsolete docs/design-intent.json. The 2026 Context Ops Paradigm uses plain-text DESIGN.md only.');
|
|
362
|
-
} catch (err) {
|
|
363
|
-
// ignore error
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
if (shouldEnsureActiveMemorySnapshot) {
|
|
368
|
-
const activeMemoryResult = await ensureActiveMemorySnapshot(resolvedTargetDirectoryPath, {
|
|
369
|
-
projectName: packageManifest?.name || path.basename(resolvedTargetDirectoryPath),
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
if (activeMemoryResult.created) {
|
|
373
|
-
supplementalCreatedFileNames.push('.agent-context/state/active-memory.json');
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
await writeSelectedPolicy(resolvedTargetDirectoryPath, selectedProfileName);
|
|
378
|
-
|
|
379
|
-
const setupDurationMs = Date.now() - setupStartedAt;
|
|
380
|
-
await writeOnboardingReport({
|
|
381
|
-
targetDirectoryPath: resolvedTargetDirectoryPath,
|
|
382
|
-
selectedProfileName,
|
|
383
|
-
projectScope: existingOnboardingReport?.projectScope || null,
|
|
384
|
-
selectedStackFileName,
|
|
385
|
-
selectedAdditionalStackFileNames,
|
|
386
|
-
selectedBlueprintFileName,
|
|
387
|
-
selectedAdditionalBlueprintFileNames,
|
|
388
|
-
includeCiGuardrails,
|
|
389
|
-
setupDurationMs,
|
|
390
|
-
projectDetection,
|
|
391
|
-
runtimeEnvironment: existingOnboardingReport?.runtimeEnvironment || null,
|
|
392
|
-
operationMode: 'upgrade',
|
|
393
|
-
tokenOptimization: tokenOptimizationApplyResult.reportState,
|
|
394
|
-
detectionTransparency,
|
|
395
|
-
uiScopeSignals,
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
console.log('\nUpgrade complete.');
|
|
399
|
-
console.log(`- Governance surface sync: 1:1 (${governanceSyncResult.updatedFiles.length} updated, ${governanceSyncResult.createdFiles.length} new, ${governanceSyncResult.deletedManagedFiles.length} deleted, ${governanceSyncResult.unchangedFiles.length} unchanged)`);
|
|
400
|
-
const preservedInstructionEntrypoints = Array.from(new Set([
|
|
401
|
-
...(governanceSyncResult.preservedFiles || []),
|
|
402
|
-
])).sort();
|
|
403
|
-
if (preservedInstructionEntrypoints.length > 0) {
|
|
404
|
-
console.log(`- User-owned instruction entrypoints preserved: ${preservedInstructionEntrypoints.length}`);
|
|
405
|
-
}
|
|
406
|
-
if (governanceSyncResult.deletedManagedDirectories.length > 0) {
|
|
407
|
-
console.log(`- Managed stale directories removed: ${governanceSyncResult.deletedManagedDirectories.length}`);
|
|
408
|
-
}
|
|
409
|
-
console.log(`- Setup time: ${formatDuration(setupDurationMs)}`);
|
|
410
|
-
|
|
411
|
-
const hasDetailedGovernanceChanges = governanceSyncResult.updatedFiles.length > 0
|
|
412
|
-
|| governanceSyncResult.createdFiles.length > 0
|
|
413
|
-
|| governanceSyncResult.deletedManagedFiles.length > 0
|
|
414
|
-
|| preservedInstructionEntrypoints.length > 0;
|
|
415
|
-
|
|
416
|
-
if (hasDetailedGovernanceChanges) {
|
|
417
|
-
console.log('\nDetailed changes:');
|
|
418
|
-
governanceSyncResult.createdFiles.forEach((fileName) => console.log(` [NEW] ${fileName}`));
|
|
419
|
-
governanceSyncResult.updatedFiles.forEach((fileName) => console.log(` [UPDATED] ${fileName}`));
|
|
420
|
-
governanceSyncResult.deletedManagedFiles.forEach((fileName) => console.log(` [DELETED] ${fileName}`));
|
|
421
|
-
preservedInstructionEntrypoints.forEach((fileName) => console.log(` [PRESERVE] ${fileName}`));
|
|
422
|
-
}
|
|
423
|
-
if (supplementalCreatedFileNames.length > 0) {
|
|
424
|
-
if (!hasDetailedGovernanceChanges) {
|
|
425
|
-
console.log('\nDetailed changes:');
|
|
426
|
-
}
|
|
427
|
-
supplementalCreatedFileNames.forEach((fileName) => console.log(` [NEW] ${fileName} (seed)`));
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
console.log('\nRefreshed files: AGENTS.md, CLAUDE.md, GEMINI.md, .agent-context/, and .agent-context/state/onboarding-report.json');
|
|
431
|
-
console.log('Default activation cues remain Adaptive Context bootstrap, ASCX command wrappers, and Compact Natural final replies.');
|
|
432
|
-
console.log('Default response mode remains Compact Natural Mode through .agent-context/prompts/compact-natural-mode.md.');
|
|
433
|
-
|
|
434
|
-
} catch (error) {
|
|
435
|
-
console.error('\n[FATAL] An error occurred during upgrade. Attempting automatic rollback...');
|
|
436
|
-
try {
|
|
437
|
-
const rollbackReport = await performRollback(resolvedTargetDirectoryPath);
|
|
438
|
-
if (rollbackReport.success) {
|
|
439
|
-
console.error('[OK] Automatic rollback successful. The directory has been restored.');
|
|
440
|
-
} else {
|
|
441
|
-
console.error('[WARN] Automatic rollback completed with errors. You may need to manually clean up.');
|
|
442
|
-
}
|
|
443
|
-
} catch (rbError) {
|
|
444
|
-
console.error(`[FATAL] Automatic rollback failed: ${rbError.message}`);
|
|
445
|
-
}
|
|
446
|
-
throw error;
|
|
447
|
-
}
|
|
448
|
-
} finally {
|
|
449
|
-
userInterface.close();
|
|
450
|
-
}
|
|
451
|
-
}
|
package/lib/cli/compiler.mjs
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
// @file-size-exception: Multiple compilation passes (rule + state + adapter); planned for split in Phase 1 compiler refactor.
|
|
2
|
-
/**
|
|
3
|
-
* Context Compiler — Rulebook compilation and state persistence.
|
|
4
|
-
* Depends on: constants.mjs, utils.mjs
|
|
5
|
-
*/
|
|
6
|
-
import fs from 'node:fs/promises';
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
CLI_VERSION,
|
|
11
|
-
POLICY_FILE_NAME,
|
|
12
|
-
AGENT_DECISION_STACK_FILE_NAME,
|
|
13
|
-
AGENT_DECISION_BLUEPRINT_FILE_NAME,
|
|
14
|
-
} from './constants.mjs';
|
|
15
|
-
|
|
16
|
-
import {
|
|
17
|
-
pathExists,
|
|
18
|
-
collectFileNames,
|
|
19
|
-
} from './utils.mjs';
|
|
20
|
-
|
|
21
|
-
import {
|
|
22
|
-
readTokenOptimizationState,
|
|
23
|
-
buildTokenOptimizationGuidanceBlock,
|
|
24
|
-
} from './token-optimization.mjs';
|
|
25
|
-
import {
|
|
26
|
-
readMemoryContinuityState,
|
|
27
|
-
buildMemoryContinuityGuidanceBlock,
|
|
28
|
-
} from './memory-continuity.mjs';
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* ## LAYER 2 POLICY: LAZY RULE LOADING
|
|
32
|
-
* Load global domain rules only when task scope touches that domain.
|
|
33
|
-
* Avoid eager loading unrelated runtime or domain guidance to prevent instruction conflicts.
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
function toSingleLine(value, fallbackValue) {
|
|
37
|
-
const normalizedValue = String(value || '').replace(/\s+/g, ' ').trim();
|
|
38
|
-
return normalizedValue || fallbackValue;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function buildAnchorCommitmentHeader(designIntent) {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function buildContainerizationStrategySnapshot(dockerStrategy) {
|
|
46
|
-
const selectedDockerStrategy = String(dockerStrategy || '').trim();
|
|
47
|
-
const normalizedDockerStrategy = selectedDockerStrategy.toLowerCase();
|
|
48
|
-
const dockerSelected = Boolean(selectedDockerStrategy) && !normalizedDockerStrategy.startsWith('no docker');
|
|
49
|
-
const developmentRequired = dockerSelected
|
|
50
|
-
&& (normalizedDockerStrategy.includes('development') || normalizedDockerStrategy.includes('both'));
|
|
51
|
-
const productionRequired = dockerSelected
|
|
52
|
-
&& (normalizedDockerStrategy.includes('production') || normalizedDockerStrategy.includes('both'));
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
selected: selectedDockerStrategy || null,
|
|
56
|
-
developmentRequired,
|
|
57
|
-
productionRequired,
|
|
58
|
-
materializationRequired: dockerSelected,
|
|
59
|
-
requiredRuleFile: dockerSelected ? '.agent-context/rules/docker-runtime.md' : null,
|
|
60
|
-
commandExecutionPolicy: dockerSelected
|
|
61
|
-
? 'author-files-first-run-docker-commands-only-when-requested-or-approved'
|
|
62
|
-
: null,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export async function writeSelectedPolicy(targetDirectoryPath, selectedProfileName) {
|
|
67
|
-
const policyFilePath = path.join(targetDirectoryPath, '.agent-context', 'policies', POLICY_FILE_NAME);
|
|
68
|
-
const parsedPolicy = JSON.parse(await fs.readFile(policyFilePath, 'utf8'));
|
|
69
|
-
parsedPolicy.selectedProfile = selectedProfileName;
|
|
70
|
-
await fs.writeFile(policyFilePath, JSON.stringify(parsedPolicy, null, 2) + '\n', 'utf8');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export async function writeOnboardingReport({
|
|
74
|
-
targetDirectoryPath,
|
|
75
|
-
selectedProfileName,
|
|
76
|
-
selectedPreset,
|
|
77
|
-
projectScope = null,
|
|
78
|
-
projectTopology = null,
|
|
79
|
-
selectedStackFileName,
|
|
80
|
-
selectedAdditionalStackFileNames = [],
|
|
81
|
-
selectedBlueprintFileName,
|
|
82
|
-
selectedAdditionalBlueprintFileNames = [],
|
|
83
|
-
includeCiGuardrails,
|
|
84
|
-
localOnly = false,
|
|
85
|
-
setupDurationMs,
|
|
86
|
-
projectDetection,
|
|
87
|
-
runtimeEnvironment = null,
|
|
88
|
-
dockerStrategy = null,
|
|
89
|
-
operationMode = 'init',
|
|
90
|
-
tokenOptimization = undefined,
|
|
91
|
-
memoryContinuity = undefined,
|
|
92
|
-
detectionTransparency = null,
|
|
93
|
-
uiScopeSignals = null,
|
|
94
|
-
}) {
|
|
95
|
-
const hasExplicitRuntimeDecision = selectedStackFileName && selectedStackFileName !== AGENT_DECISION_STACK_FILE_NAME;
|
|
96
|
-
const hasExplicitArchitectureDecision = selectedBlueprintFileName && selectedBlueprintFileName !== AGENT_DECISION_BLUEPRINT_FILE_NAME;
|
|
97
|
-
const onboardingReportPath = path.join(targetDirectoryPath, '.agent-context', 'state', 'onboarding-report.json');
|
|
98
|
-
const resolvedTokenOptimization = typeof tokenOptimization === 'undefined'
|
|
99
|
-
? await readTokenOptimizationState(targetDirectoryPath)
|
|
100
|
-
: tokenOptimization;
|
|
101
|
-
const resolvedMemoryContinuity = typeof memoryContinuity === 'undefined'
|
|
102
|
-
? await readMemoryContinuityState(targetDirectoryPath)
|
|
103
|
-
: memoryContinuity;
|
|
104
|
-
const onboardingReport = {
|
|
105
|
-
cliVersion: CLI_VERSION,
|
|
106
|
-
generatedAt: new Date().toISOString(),
|
|
107
|
-
operationMode,
|
|
108
|
-
selectedProfile: selectedProfileName,
|
|
109
|
-
selectedPreset,
|
|
110
|
-
projectScope,
|
|
111
|
-
projectTopology,
|
|
112
|
-
runtimeDecision: {
|
|
113
|
-
mode: hasExplicitRuntimeDecision ? 'explicit-constraint' : 'agent-decision-required',
|
|
114
|
-
explicitStack: hasExplicitRuntimeDecision ? selectedStackFileName : null,
|
|
115
|
-
detectedStackEvidence: projectDetection.detectedStackFileName || null,
|
|
116
|
-
detectedAdditionalStackEvidence: projectDetection.secondaryStackFileNames || [],
|
|
117
|
-
},
|
|
118
|
-
architectureDecision: {
|
|
119
|
-
mode: hasExplicitArchitectureDecision ? 'explicit-constraint' : 'agent-decision-required',
|
|
120
|
-
explicitBlueprint: hasExplicitArchitectureDecision ? selectedBlueprintFileName : null,
|
|
121
|
-
detectedBlueprintEvidence: projectDetection.detectedBlueprintFileName || null,
|
|
122
|
-
},
|
|
123
|
-
selectedStack: hasExplicitRuntimeDecision ? selectedStackFileName : null,
|
|
124
|
-
selectedAdditionalStacks: hasExplicitRuntimeDecision ? selectedAdditionalStackFileNames : [],
|
|
125
|
-
selectedBlueprint: hasExplicitArchitectureDecision ? selectedBlueprintFileName : null,
|
|
126
|
-
selectedAdditionalBlueprints: hasExplicitArchitectureDecision ? selectedAdditionalBlueprintFileNames : [],
|
|
127
|
-
ruleLoadingPolicy: {
|
|
128
|
-
canonicalSource: 'AGENTS.md',
|
|
129
|
-
stackLoadingMode: 'lazy',
|
|
130
|
-
domainRuleLoadingMode: 'lazy',
|
|
131
|
-
loadedOnDemand: true,
|
|
132
|
-
primaryStack: hasExplicitRuntimeDecision ? selectedStackFileName : null,
|
|
133
|
-
additionalStacks: hasExplicitRuntimeDecision ? selectedAdditionalStackFileNames : [],
|
|
134
|
-
agentDecisionRequired: !hasExplicitRuntimeDecision,
|
|
135
|
-
},
|
|
136
|
-
ciGuardrailsEnabled: includeCiGuardrails,
|
|
137
|
-
localOnly,
|
|
138
|
-
setupDurationMs,
|
|
139
|
-
runtimeEnvironment,
|
|
140
|
-
containerizationStrategy: buildContainerizationStrategySnapshot(dockerStrategy),
|
|
141
|
-
tokenOptimization: resolvedTokenOptimization,
|
|
142
|
-
memoryContinuity: resolvedMemoryContinuity,
|
|
143
|
-
responseCompression: {
|
|
144
|
-
enabled: true,
|
|
145
|
-
mode: 'compact-natural-mode',
|
|
146
|
-
defaultOn: true,
|
|
147
|
-
promptFile: '.agent-context/prompts/compact-natural-mode.md',
|
|
148
|
-
appliesTo: 'agent-final-responses',
|
|
149
|
-
commandOutputBoundary: 'ASCX handles command-output compression separately',
|
|
150
|
-
},
|
|
151
|
-
autoDetection: {
|
|
152
|
-
detectedStack: projectDetection.detectedStackFileName,
|
|
153
|
-
detectedAdditionalStacks: projectDetection.secondaryStackFileNames || [],
|
|
154
|
-
detectedBlueprint: projectDetection.detectedBlueprintFileName,
|
|
155
|
-
detectedAdditionalBlueprints: [],
|
|
156
|
-
confidenceLabel: projectDetection.confidenceLabel,
|
|
157
|
-
confidenceScore: projectDetection.confidenceScore,
|
|
158
|
-
confidenceGap: projectDetection.confidenceGap,
|
|
159
|
-
detectionReasoning: projectDetection.detectionReasoning,
|
|
160
|
-
rankedCandidates: projectDetection.rankedCandidates,
|
|
161
|
-
evidence: projectDetection.evidence,
|
|
162
|
-
detectionTransparency: detectionTransparency || null,
|
|
163
|
-
uiScope: uiScopeSignals
|
|
164
|
-
? {
|
|
165
|
-
isUiScopeLikely: uiScopeSignals.isUiScopeLikely === true,
|
|
166
|
-
signalReasons: uiScopeSignals.signalReasons || [],
|
|
167
|
-
workspaceUiEntries: uiScopeSignals.workspaceUiEntries || [],
|
|
168
|
-
frontendEvidenceMetrics: uiScopeSignals.frontendEvidenceMetrics || null,
|
|
169
|
-
designEvidenceSummary: uiScopeSignals.designEvidenceSummary || null,
|
|
170
|
-
}
|
|
171
|
-
: null,
|
|
172
|
-
},
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
await fs.writeFile(onboardingReportPath, JSON.stringify(onboardingReport, null, 2) + '\n', 'utf8');
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export async function loadOnboardingReportIfExists(targetDirectoryPath) {
|
|
179
|
-
const onboardingReportPath = path.join(targetDirectoryPath, '.agent-context', 'state', 'onboarding-report.json');
|
|
180
|
-
if (!(await pathExists(onboardingReportPath))) {
|
|
181
|
-
return null;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const onboardingReportContent = await fs.readFile(onboardingReportPath, 'utf8');
|
|
185
|
-
return JSON.parse(onboardingReportContent);
|
|
186
|
-
}
|
|
187
|
-
|