@ryuenn3123/agentic-senior-core 2.0.5 → 2.0.8
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/.agent-context/blueprints/mobile-app.md +91 -21
- package/.agent-context/profiles/platform.md +13 -13
- package/.agent-context/profiles/regulated.md +13 -13
- package/.agent-context/profiles/startup.md +13 -13
- package/.agent-context/prompts/review-code.md +3 -3
- package/.agent-context/review-checklists/frontend-skill-parity.md +28 -28
- package/.agent-context/review-checklists/frontend-usability.md +33 -33
- package/.agent-context/review-checklists/pr-checklist.md +11 -6
- package/.agent-context/review-checklists/release-operations.md +29 -29
- package/.agent-context/rules/api-docs.md +34 -0
- package/.agent-context/skills/README.md +62 -62
- package/.agent-context/skills/backend/README.md +67 -67
- package/.agent-context/skills/backend/architecture.md +360 -360
- package/.agent-context/skills/backend/compatibility-manifest.json +8 -8
- package/.agent-context/skills/backend/data-access.md +230 -230
- package/.agent-context/skills/backend/errors.md +137 -137
- package/.agent-context/skills/backend/validation.md +116 -116
- package/.agent-context/skills/backend.md +28 -28
- package/.agent-context/skills/cli/README.md +55 -49
- package/.agent-context/skills/cli/compatibility-manifest.json +8 -8
- package/.agent-context/skills/cli/init.md +37 -37
- package/.agent-context/skills/cli/output.md +35 -35
- package/.agent-context/skills/cli/safety-telemetry.md +39 -0
- package/.agent-context/skills/cli/upgrade.md +37 -37
- package/.agent-context/skills/cli.md +31 -28
- package/.agent-context/skills/distribution/.evidence/compatibility-manifest.json +9 -0
- package/.agent-context/skills/distribution/.evidence/sbom-excerpt.json +6 -0
- package/.agent-context/skills/distribution/.evidence/test-report.json +8 -0
- package/.agent-context/skills/distribution/CHANGELOG.md +7 -0
- package/.agent-context/skills/distribution/README.md +27 -19
- package/.agent-context/skills/distribution/compatibility-manifest.json +8 -8
- package/.agent-context/skills/distribution/compatibility.md +31 -31
- package/.agent-context/skills/distribution/package.json +5 -0
- package/.agent-context/skills/distribution/provenance-attestation.md +47 -0
- package/.agent-context/skills/distribution/publish.md +36 -36
- package/.agent-context/skills/distribution/rollback.md +31 -31
- package/.agent-context/skills/distribution/tests/.gitkeep +1 -0
- package/.agent-context/skills/distribution.md +31 -28
- package/.agent-context/skills/frontend/.evidence/compatibility-manifest.json +9 -0
- package/.agent-context/skills/frontend/.evidence/sbom-excerpt.json +6 -0
- package/.agent-context/skills/frontend/.evidence/test-report.json +8 -0
- package/.agent-context/skills/frontend/CHANGELOG.md +7 -0
- package/.agent-context/skills/frontend/README.md +49 -36
- package/.agent-context/skills/frontend/accessibility.md +107 -107
- package/.agent-context/skills/frontend/compatibility-manifest.json +8 -8
- package/.agent-context/skills/frontend/conversion-clarity.md +51 -0
- package/.agent-context/skills/frontend/motion.md +66 -66
- package/.agent-context/skills/frontend/package.json +5 -0
- package/.agent-context/skills/frontend/performance.md +62 -62
- package/.agent-context/skills/frontend/responsive-delivery.md +41 -0
- package/.agent-context/skills/frontend/tests/.gitkeep +1 -0
- package/.agent-context/skills/frontend/ui-architecture.md +128 -128
- package/.agent-context/skills/frontend.md +35 -29
- package/.agent-context/skills/fullstack/.evidence/compatibility-manifest.json +9 -0
- package/.agent-context/skills/fullstack/.evidence/sbom-excerpt.json +6 -0
- package/.agent-context/skills/fullstack/.evidence/test-report.json +8 -0
- package/.agent-context/skills/fullstack/CHANGELOG.md +7 -0
- package/.agent-context/skills/fullstack/README.md +27 -19
- package/.agent-context/skills/fullstack/compatibility-manifest.json +8 -8
- package/.agent-context/skills/fullstack/contracts.md +52 -52
- package/.agent-context/skills/fullstack/end-to-end.md +41 -41
- package/.agent-context/skills/fullstack/feature-slicing.md +64 -64
- package/.agent-context/skills/fullstack/package.json +5 -0
- package/.agent-context/skills/fullstack/release-coordination.md +51 -0
- package/.agent-context/skills/fullstack/tests/.gitkeep +1 -0
- package/.agent-context/skills/fullstack.md +29 -26
- package/.agent-context/skills/index.json +107 -107
- package/.agent-context/skills/review-quality/.evidence/compatibility-manifest.json +9 -0
- package/.agent-context/skills/review-quality/.evidence/sbom-excerpt.json +6 -0
- package/.agent-context/skills/review-quality/.evidence/test-report.json +8 -0
- package/.agent-context/skills/review-quality/CHANGELOG.md +7 -0
- package/.agent-context/skills/review-quality/README.md +27 -19
- package/.agent-context/skills/review-quality/benchmark.md +29 -29
- package/.agent-context/skills/review-quality/compatibility-manifest.json +8 -8
- package/.agent-context/skills/review-quality/package.json +5 -0
- package/.agent-context/skills/review-quality/planning.md +37 -37
- package/.agent-context/skills/review-quality/release-decision.md +49 -0
- package/.agent-context/skills/review-quality/security.md +33 -33
- package/.agent-context/skills/review-quality/tests/.gitkeep +1 -0
- package/.agent-context/skills/review-quality.md +33 -27
- package/.agent-context/stacks/flutter.md +16 -16
- package/.agent-context/stacks/react-native.md +16 -16
- package/.agent-context/state/architecture-map.md +25 -25
- package/.agent-context/state/benchmark-analysis.json +431 -431
- package/.agent-context/state/benchmark-thresholds.json +10 -10
- package/.agent-context/state/benchmark-watchlist.json +19 -19
- package/.agent-context/state/dependency-map.md +32 -32
- package/.agent-context/state/quality-trend-report.json +16 -6
- package/.agent-context/state/skill-platform.json +38 -38
- package/.agent-context/state/weekly-governance-report.json +126 -0
- package/.agent-override.md +36 -36
- package/.cursorrules +1 -1
- package/.gemini/instructions.md +20 -20
- package/.github/ISSUE_TEMPLATE/v1.7-frontend-work-item.yml +54 -54
- package/.github/copilot-instructions.md +21 -21
- package/.github/workflows/benchmark-detection.yml +38 -38
- package/.github/workflows/benchmark-intelligence.yml +50 -50
- package/.github/workflows/frontend-usability-gate.yml +36 -36
- package/.github/workflows/governance-weekly-report.yml +43 -0
- package/.github/workflows/release-gate.yml +32 -32
- package/.github/workflows/sbom-compliance.yml +32 -32
- package/.windsurfrules +1 -1
- package/AGENTS.md +27 -27
- package/README.md +389 -368
- package/lib/cli/commands/init.mjs +13 -1
- package/lib/cli/commands/optimize.mjs +171 -171
- package/lib/cli/commands/upgrade.mjs +9 -1
- package/lib/cli/compatibility.mjs +124 -124
- package/lib/cli/constants.mjs +37 -2
- package/lib/cli/token-optimization.mjs +275 -275
- package/lib/cli/utils.mjs +24 -3
- package/mcp.json +92 -92
- package/package.json +2 -1
- package/scripts/benchmark-gate.mjs +121 -121
- package/scripts/benchmark-intelligence.mjs +140 -140
- package/scripts/detection-benchmark.mjs +138 -138
- package/scripts/frontend-usability-audit.mjs +87 -87
- package/scripts/generate-sbom.mjs +61 -61
- package/scripts/governance-weekly-report.mjs +293 -0
- package/scripts/init-project.ps1 +104 -104
- package/scripts/llm-judge.mjs +664 -664
- package/scripts/quality-trend-report.mjs +288 -288
- package/scripts/release-gate.mjs +261 -259
- package/scripts/skill-tier-policy.mjs +75 -75
- package/scripts/token-optimization-benchmark.mjs +252 -252
- package/scripts/validate.mjs +942 -865
|
@@ -57,6 +57,7 @@ export function parseInitArguments(commandArguments) {
|
|
|
57
57
|
newbie: false,
|
|
58
58
|
tokenOptimize: true,
|
|
59
59
|
tokenAgent: 'copilot',
|
|
60
|
+
includeMcpTemplate: false,
|
|
60
61
|
};
|
|
61
62
|
|
|
62
63
|
for (let argumentIndex = 0; argumentIndex < commandArguments.length; argumentIndex++) {
|
|
@@ -160,6 +161,11 @@ export function parseInitArguments(commandArguments) {
|
|
|
160
161
|
continue;
|
|
161
162
|
}
|
|
162
163
|
|
|
164
|
+
if (currentArgument === '--mcp-template') {
|
|
165
|
+
parsedInitOptions.includeMcpTemplate = true;
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
|
|
163
169
|
throw new Error(`Unknown option: ${currentArgument}`);
|
|
164
170
|
}
|
|
165
171
|
|
|
@@ -177,6 +183,7 @@ export async function runInitCommand(targetDirectoryArgument, initOptions = {})
|
|
|
177
183
|
const isTokenOptimizationEnabled = typeof initOptions.tokenOptimize === 'boolean'
|
|
178
184
|
? initOptions.tokenOptimize
|
|
179
185
|
: true;
|
|
186
|
+
const shouldIncludeMcpTemplate = initOptions.includeMcpTemplate === true;
|
|
180
187
|
const selectedTokenAgentName = normalizeAgentName(initOptions.tokenAgent || 'copilot');
|
|
181
188
|
|
|
182
189
|
if (resolvedTargetDirectoryPath.toLowerCase() === 'c:\\windows' || resolvedTargetDirectoryPath.toLowerCase() === 'c:\\windows\\system32') {
|
|
@@ -348,7 +355,9 @@ export async function runInitCommand(targetDirectoryArgument, initOptions = {})
|
|
|
348
355
|
? selectedProfile.defaultCi
|
|
349
356
|
: await askYesNo('Enable CI/CD guardrails and the LLM Judge policy?', userInterface, selectedProfile.defaultCi);
|
|
350
357
|
|
|
351
|
-
await copyGovernanceAssetsToTarget(resolvedTargetDirectoryPath
|
|
358
|
+
await copyGovernanceAssetsToTarget(resolvedTargetDirectoryPath, {
|
|
359
|
+
includeMcpTemplate: shouldIncludeMcpTemplate,
|
|
360
|
+
});
|
|
352
361
|
|
|
353
362
|
if (isTokenOptimizationEnabled) {
|
|
354
363
|
const detectedExternalProxy = detectRtkBinary();
|
|
@@ -419,6 +428,8 @@ export async function runInitCommand(targetDirectoryArgument, initOptions = {})
|
|
|
419
428
|
console.log(`- Blocking severities: ${formatBlockingSeverities(selectedProfile.blockingSeverities)}`);
|
|
420
429
|
console.log(`- Setup time: ${formatDuration(setupDurationMs)}`);
|
|
421
430
|
console.log('- Generated files: .cursorrules, .windsurfrules, and .agent-context/state/onboarding-report.json');
|
|
431
|
+
console.log(`- Repository workflows copied: no (workflows remain source-repo assets)`);
|
|
432
|
+
console.log(`- MCP template file: ${shouldIncludeMcpTemplate ? 'copied (mcp.json)' : 'not copied by default (use --mcp-template)'}`);
|
|
422
433
|
if (isTokenOptimizationEnabled) {
|
|
423
434
|
console.log(`- Token optimization policy: enabled for ${selectedTokenAgentName}`);
|
|
424
435
|
} else {
|
|
@@ -427,6 +438,7 @@ export async function runInitCommand(targetDirectoryArgument, initOptions = {})
|
|
|
427
438
|
console.log('\nPlain-language summary:');
|
|
428
439
|
console.log(`I prepared a ${selectedProfile.displayName.toLowerCase()} governance pack for a ${toTitleCase(selectedResolvedStackFileName)} project using the ${toTitleCase(selectedResolvedBlueprintFileName)} blueprint.`);
|
|
429
440
|
console.log('Your AI tools will now receive one compiled rulebook plus the original source rules, and your review threshold is stored in .agent-context/policies/llm-judge-threshold.json.');
|
|
441
|
+
console.log('MCP server registration is manual inside your IDE settings, even when mcp.json exists.');
|
|
430
442
|
} catch (error) {
|
|
431
443
|
console.error('\n[FATAL] An error occurred during initialization. Attempting automatic rollback...');
|
|
432
444
|
try {
|
|
@@ -1,171 +1,171 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
|
|
4
|
-
import { ensureDirectory, formatDuration } from '../utils.mjs';
|
|
5
|
-
import { compileDynamicContext, loadOnboardingReportIfExists } from '../compiler.mjs';
|
|
6
|
-
import {
|
|
7
|
-
TOKEN_OPTIMIZATION_REPORT_FILE_NAME,
|
|
8
|
-
normalizeAgentName,
|
|
9
|
-
detectRtkBinary,
|
|
10
|
-
buildRtkInstallHint,
|
|
11
|
-
buildRtkHookCommand,
|
|
12
|
-
createTokenOptimizationState,
|
|
13
|
-
readTokenOptimizationState,
|
|
14
|
-
writeTokenOptimizationState,
|
|
15
|
-
} from '../token-optimization.mjs';
|
|
16
|
-
|
|
17
|
-
function normalizeMarkdownFileName(rawFileName, fallbackFileName) {
|
|
18
|
-
if (typeof rawFileName !== 'string' || rawFileName.trim().length === 0) {
|
|
19
|
-
return fallbackFileName;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const normalizedFileName = rawFileName.trim();
|
|
23
|
-
return normalizedFileName.endsWith('.md')
|
|
24
|
-
? normalizedFileName
|
|
25
|
-
: `${normalizedFileName}.md`;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function parseOptimizeArguments(commandArguments) {
|
|
29
|
-
const parsedOptimizeOptions = {
|
|
30
|
-
targetDirectory: '.',
|
|
31
|
-
agent: 'copilot',
|
|
32
|
-
enabled: true,
|
|
33
|
-
show: false,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
for (let argumentIndex = 0; argumentIndex < commandArguments.length; argumentIndex++) {
|
|
37
|
-
const currentArgument = commandArguments[argumentIndex];
|
|
38
|
-
|
|
39
|
-
if (!currentArgument.startsWith('--')) {
|
|
40
|
-
parsedOptimizeOptions.targetDirectory = currentArgument;
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (currentArgument === '--agent') {
|
|
45
|
-
parsedOptimizeOptions.agent = commandArguments[argumentIndex + 1] || 'copilot';
|
|
46
|
-
argumentIndex += 1;
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (currentArgument.startsWith('--agent=')) {
|
|
51
|
-
parsedOptimizeOptions.agent = currentArgument.split('=')[1] || 'copilot';
|
|
52
|
-
continue;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (currentArgument === '--enable') {
|
|
56
|
-
parsedOptimizeOptions.enabled = true;
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (currentArgument === '--disable') {
|
|
61
|
-
parsedOptimizeOptions.enabled = false;
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (currentArgument === '--show') {
|
|
66
|
-
parsedOptimizeOptions.show = true;
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
throw new Error(`Unknown option: ${currentArgument}`);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
parsedOptimizeOptions.agent = normalizeAgentName(parsedOptimizeOptions.agent);
|
|
74
|
-
return parsedOptimizeOptions;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export async function runOptimizeCommand(targetDirectoryArgument, optimizeOptions = {}) {
|
|
78
|
-
const optimizationStartedAt = Date.now();
|
|
79
|
-
const resolvedTargetDirectoryPath = path.resolve(targetDirectoryArgument || '.');
|
|
80
|
-
|
|
81
|
-
await ensureDirectory(resolvedTargetDirectoryPath);
|
|
82
|
-
|
|
83
|
-
const selectedAgentName = normalizeAgentName(optimizeOptions.agent || 'copilot');
|
|
84
|
-
const rtkDetection = detectRtkBinary();
|
|
85
|
-
|
|
86
|
-
if (optimizeOptions.show) {
|
|
87
|
-
const existingOptimizationState = await readTokenOptimizationState(resolvedTargetDirectoryPath);
|
|
88
|
-
console.log(
|
|
89
|
-
JSON.stringify(
|
|
90
|
-
{
|
|
91
|
-
targetDirectory: resolvedTargetDirectoryPath,
|
|
92
|
-
selectedAgent: selectedAgentName,
|
|
93
|
-
externalProxy: rtkDetection,
|
|
94
|
-
tokenOptimizationState: existingOptimizationState,
|
|
95
|
-
},
|
|
96
|
-
null,
|
|
97
|
-
2
|
|
98
|
-
)
|
|
99
|
-
);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const onboardingReport = await loadOnboardingReportIfExists(resolvedTargetDirectoryPath);
|
|
104
|
-
if (!onboardingReport) {
|
|
105
|
-
throw new Error(
|
|
106
|
-
'Token optimization requires an initialized repository. Run "agentic-senior-core init" first.'
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const tokenOptimizationState = createTokenOptimizationState({
|
|
111
|
-
isEnabled: optimizeOptions.enabled,
|
|
112
|
-
selectedAgentName,
|
|
113
|
-
rtkDetection,
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
await writeTokenOptimizationState(resolvedTargetDirectoryPath, tokenOptimizationState);
|
|
117
|
-
|
|
118
|
-
const selectedProfileName = typeof onboardingReport.selectedProfile === 'string'
|
|
119
|
-
? onboardingReport.selectedProfile
|
|
120
|
-
: 'balanced';
|
|
121
|
-
const selectedStackFileName = normalizeMarkdownFileName(onboardingReport.selectedStack, 'typescript.md');
|
|
122
|
-
const selectedBlueprintFileName = normalizeMarkdownFileName(onboardingReport.selectedBlueprint, 'api-nextjs.md');
|
|
123
|
-
const includeCiGuardrails = typeof onboardingReport.ciGuardrailsEnabled === 'boolean'
|
|
124
|
-
? onboardingReport.ciGuardrailsEnabled
|
|
125
|
-
: true;
|
|
126
|
-
|
|
127
|
-
await compileDynamicContext({
|
|
128
|
-
targetDirectoryPath: resolvedTargetDirectoryPath,
|
|
129
|
-
selectedProfileName,
|
|
130
|
-
selectedStackFileName,
|
|
131
|
-
selectedBlueprintFileName,
|
|
132
|
-
includeCiGuardrails,
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
const optimizationDurationMs = Date.now() - optimizationStartedAt;
|
|
136
|
-
const tokenOptimizationReport = {
|
|
137
|
-
generatedAt: new Date().toISOString(),
|
|
138
|
-
targetDirectory: resolvedTargetDirectoryPath,
|
|
139
|
-
enabled: tokenOptimizationState.enabled,
|
|
140
|
-
selectedAgent: tokenOptimizationState.selectedAgent,
|
|
141
|
-
preferredShellProxy: tokenOptimizationState.preferredShellProxy,
|
|
142
|
-
externalProxy: tokenOptimizationState.externalProxy,
|
|
143
|
-
setupDurationMs: optimizationDurationMs,
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
const reportFilePath = path.join(
|
|
147
|
-
resolvedTargetDirectoryPath,
|
|
148
|
-
'.agent-context',
|
|
149
|
-
'state',
|
|
150
|
-
TOKEN_OPTIMIZATION_REPORT_FILE_NAME
|
|
151
|
-
);
|
|
152
|
-
await fs.writeFile(reportFilePath, JSON.stringify(tokenOptimizationReport, null, 2) + '\n', 'utf8');
|
|
153
|
-
|
|
154
|
-
console.log(`\nToken optimization ${tokenOptimizationState.enabled ? 'enabled' : 'disabled'}.`);
|
|
155
|
-
console.log(`- Target directory: ${resolvedTargetDirectoryPath}`);
|
|
156
|
-
console.log(`- Agent profile: ${tokenOptimizationState.selectedAgent}`);
|
|
157
|
-
console.log(`- Preferred shell proxy: ${tokenOptimizationState.preferredShellProxy}`);
|
|
158
|
-
console.log(`- Setup time: ${formatDuration(optimizationDurationMs)}`);
|
|
159
|
-
console.log('- Updated files: .cursorrules, .windsurfrules, .agent-context/state/token-optimization.json');
|
|
160
|
-
|
|
161
|
-
if (tokenOptimizationState.enabled) {
|
|
162
|
-
if (rtkDetection.isAvailable) {
|
|
163
|
-
console.log(`- External proxy detected: ${rtkDetection.version ? `v${rtkDetection.version}` : 'yes'}`);
|
|
164
|
-
console.log('- Recommended hook command:');
|
|
165
|
-
console.log(` ${buildRtkHookCommand(tokenOptimizationState.selectedAgent)}`);
|
|
166
|
-
} else {
|
|
167
|
-
console.log('- External proxy not detected. Native fallback mode has been activated.');
|
|
168
|
-
console.log(`- Install hint: ${buildRtkInstallHint()}`);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
4
|
+
import { ensureDirectory, formatDuration } from '../utils.mjs';
|
|
5
|
+
import { compileDynamicContext, loadOnboardingReportIfExists } from '../compiler.mjs';
|
|
6
|
+
import {
|
|
7
|
+
TOKEN_OPTIMIZATION_REPORT_FILE_NAME,
|
|
8
|
+
normalizeAgentName,
|
|
9
|
+
detectRtkBinary,
|
|
10
|
+
buildRtkInstallHint,
|
|
11
|
+
buildRtkHookCommand,
|
|
12
|
+
createTokenOptimizationState,
|
|
13
|
+
readTokenOptimizationState,
|
|
14
|
+
writeTokenOptimizationState,
|
|
15
|
+
} from '../token-optimization.mjs';
|
|
16
|
+
|
|
17
|
+
function normalizeMarkdownFileName(rawFileName, fallbackFileName) {
|
|
18
|
+
if (typeof rawFileName !== 'string' || rawFileName.trim().length === 0) {
|
|
19
|
+
return fallbackFileName;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const normalizedFileName = rawFileName.trim();
|
|
23
|
+
return normalizedFileName.endsWith('.md')
|
|
24
|
+
? normalizedFileName
|
|
25
|
+
: `${normalizedFileName}.md`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function parseOptimizeArguments(commandArguments) {
|
|
29
|
+
const parsedOptimizeOptions = {
|
|
30
|
+
targetDirectory: '.',
|
|
31
|
+
agent: 'copilot',
|
|
32
|
+
enabled: true,
|
|
33
|
+
show: false,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
for (let argumentIndex = 0; argumentIndex < commandArguments.length; argumentIndex++) {
|
|
37
|
+
const currentArgument = commandArguments[argumentIndex];
|
|
38
|
+
|
|
39
|
+
if (!currentArgument.startsWith('--')) {
|
|
40
|
+
parsedOptimizeOptions.targetDirectory = currentArgument;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (currentArgument === '--agent') {
|
|
45
|
+
parsedOptimizeOptions.agent = commandArguments[argumentIndex + 1] || 'copilot';
|
|
46
|
+
argumentIndex += 1;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (currentArgument.startsWith('--agent=')) {
|
|
51
|
+
parsedOptimizeOptions.agent = currentArgument.split('=')[1] || 'copilot';
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (currentArgument === '--enable') {
|
|
56
|
+
parsedOptimizeOptions.enabled = true;
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (currentArgument === '--disable') {
|
|
61
|
+
parsedOptimizeOptions.enabled = false;
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (currentArgument === '--show') {
|
|
66
|
+
parsedOptimizeOptions.show = true;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
throw new Error(`Unknown option: ${currentArgument}`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
parsedOptimizeOptions.agent = normalizeAgentName(parsedOptimizeOptions.agent);
|
|
74
|
+
return parsedOptimizeOptions;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export async function runOptimizeCommand(targetDirectoryArgument, optimizeOptions = {}) {
|
|
78
|
+
const optimizationStartedAt = Date.now();
|
|
79
|
+
const resolvedTargetDirectoryPath = path.resolve(targetDirectoryArgument || '.');
|
|
80
|
+
|
|
81
|
+
await ensureDirectory(resolvedTargetDirectoryPath);
|
|
82
|
+
|
|
83
|
+
const selectedAgentName = normalizeAgentName(optimizeOptions.agent || 'copilot');
|
|
84
|
+
const rtkDetection = detectRtkBinary();
|
|
85
|
+
|
|
86
|
+
if (optimizeOptions.show) {
|
|
87
|
+
const existingOptimizationState = await readTokenOptimizationState(resolvedTargetDirectoryPath);
|
|
88
|
+
console.log(
|
|
89
|
+
JSON.stringify(
|
|
90
|
+
{
|
|
91
|
+
targetDirectory: resolvedTargetDirectoryPath,
|
|
92
|
+
selectedAgent: selectedAgentName,
|
|
93
|
+
externalProxy: rtkDetection,
|
|
94
|
+
tokenOptimizationState: existingOptimizationState,
|
|
95
|
+
},
|
|
96
|
+
null,
|
|
97
|
+
2
|
|
98
|
+
)
|
|
99
|
+
);
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const onboardingReport = await loadOnboardingReportIfExists(resolvedTargetDirectoryPath);
|
|
104
|
+
if (!onboardingReport) {
|
|
105
|
+
throw new Error(
|
|
106
|
+
'Token optimization requires an initialized repository. Run "agentic-senior-core init" first.'
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const tokenOptimizationState = createTokenOptimizationState({
|
|
111
|
+
isEnabled: optimizeOptions.enabled,
|
|
112
|
+
selectedAgentName,
|
|
113
|
+
rtkDetection,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
await writeTokenOptimizationState(resolvedTargetDirectoryPath, tokenOptimizationState);
|
|
117
|
+
|
|
118
|
+
const selectedProfileName = typeof onboardingReport.selectedProfile === 'string'
|
|
119
|
+
? onboardingReport.selectedProfile
|
|
120
|
+
: 'balanced';
|
|
121
|
+
const selectedStackFileName = normalizeMarkdownFileName(onboardingReport.selectedStack, 'typescript.md');
|
|
122
|
+
const selectedBlueprintFileName = normalizeMarkdownFileName(onboardingReport.selectedBlueprint, 'api-nextjs.md');
|
|
123
|
+
const includeCiGuardrails = typeof onboardingReport.ciGuardrailsEnabled === 'boolean'
|
|
124
|
+
? onboardingReport.ciGuardrailsEnabled
|
|
125
|
+
: true;
|
|
126
|
+
|
|
127
|
+
await compileDynamicContext({
|
|
128
|
+
targetDirectoryPath: resolvedTargetDirectoryPath,
|
|
129
|
+
selectedProfileName,
|
|
130
|
+
selectedStackFileName,
|
|
131
|
+
selectedBlueprintFileName,
|
|
132
|
+
includeCiGuardrails,
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
const optimizationDurationMs = Date.now() - optimizationStartedAt;
|
|
136
|
+
const tokenOptimizationReport = {
|
|
137
|
+
generatedAt: new Date().toISOString(),
|
|
138
|
+
targetDirectory: resolvedTargetDirectoryPath,
|
|
139
|
+
enabled: tokenOptimizationState.enabled,
|
|
140
|
+
selectedAgent: tokenOptimizationState.selectedAgent,
|
|
141
|
+
preferredShellProxy: tokenOptimizationState.preferredShellProxy,
|
|
142
|
+
externalProxy: tokenOptimizationState.externalProxy,
|
|
143
|
+
setupDurationMs: optimizationDurationMs,
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const reportFilePath = path.join(
|
|
147
|
+
resolvedTargetDirectoryPath,
|
|
148
|
+
'.agent-context',
|
|
149
|
+
'state',
|
|
150
|
+
TOKEN_OPTIMIZATION_REPORT_FILE_NAME
|
|
151
|
+
);
|
|
152
|
+
await fs.writeFile(reportFilePath, JSON.stringify(tokenOptimizationReport, null, 2) + '\n', 'utf8');
|
|
153
|
+
|
|
154
|
+
console.log(`\nToken optimization ${tokenOptimizationState.enabled ? 'enabled' : 'disabled'}.`);
|
|
155
|
+
console.log(`- Target directory: ${resolvedTargetDirectoryPath}`);
|
|
156
|
+
console.log(`- Agent profile: ${tokenOptimizationState.selectedAgent}`);
|
|
157
|
+
console.log(`- Preferred shell proxy: ${tokenOptimizationState.preferredShellProxy}`);
|
|
158
|
+
console.log(`- Setup time: ${formatDuration(optimizationDurationMs)}`);
|
|
159
|
+
console.log('- Updated files: .cursorrules, .windsurfrules, .agent-context/state/token-optimization.json');
|
|
160
|
+
|
|
161
|
+
if (tokenOptimizationState.enabled) {
|
|
162
|
+
if (rtkDetection.isAvailable) {
|
|
163
|
+
console.log(`- External proxy detected: ${rtkDetection.version ? `v${rtkDetection.version}` : 'yes'}`);
|
|
164
|
+
console.log('- Recommended hook command:');
|
|
165
|
+
console.log(` ${buildRtkHookCommand(tokenOptimizationState.selectedAgent)}`);
|
|
166
|
+
} else {
|
|
167
|
+
console.log('- External proxy not detected. Native fallback mode has been activated.');
|
|
168
|
+
console.log(`- Install hint: ${buildRtkInstallHint()}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -43,6 +43,7 @@ export function parseUpgradeArguments(commandArguments) {
|
|
|
43
43
|
targetDirectory: '.',
|
|
44
44
|
dryRun: false,
|
|
45
45
|
skipConfirmation: false,
|
|
46
|
+
includeMcpTemplate: false,
|
|
46
47
|
};
|
|
47
48
|
|
|
48
49
|
for (let argumentIndex = 0; argumentIndex < commandArguments.length; argumentIndex++) {
|
|
@@ -63,6 +64,11 @@ export function parseUpgradeArguments(commandArguments) {
|
|
|
63
64
|
continue;
|
|
64
65
|
}
|
|
65
66
|
|
|
67
|
+
if (currentArgument === '--mcp-template') {
|
|
68
|
+
parsedUpgradeOptions.includeMcpTemplate = true;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
|
|
66
72
|
throw new Error(`Unknown option: ${currentArgument}`);
|
|
67
73
|
}
|
|
68
74
|
|
|
@@ -95,7 +101,9 @@ export async function runUpgradeCommand(targetDirectoryArgument, upgradeOptions
|
|
|
95
101
|
console.log(`\nAgentic-Senior-Core CLI v${CLI_VERSION}`);
|
|
96
102
|
console.log('Running upgrade assistant for an existing repository.');
|
|
97
103
|
|
|
98
|
-
await copyGovernanceAssetsToTarget(resolvedTargetDirectoryPath
|
|
104
|
+
await copyGovernanceAssetsToTarget(resolvedTargetDirectoryPath, {
|
|
105
|
+
includeMcpTemplate: upgradeOptions.includeMcpTemplate === true,
|
|
106
|
+
});
|
|
99
107
|
|
|
100
108
|
const stackFileNames = await collectFileNames(path.join(AGENT_CONTEXT_DIR, 'stacks'));
|
|
101
109
|
const blueprintFileNames = await collectFileNames(path.join(AGENT_CONTEXT_DIR, 'blueprints'));
|