@ryuenn3123/agentic-senior-core 3.0.46 → 3.0.48
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/prompts/init-project.md +9 -7
- package/.agent-context/prompts/refactor.md +1 -1
- package/.agent-context/prompts/review-code.md +1 -1
- package/.agent-context/review-checklists/pr-checklist.md +3 -0
- package/.agent-context/rules/api-docs.md +4 -0
- package/.agent-context/rules/architecture.md +16 -2
- package/.agent-context/state/architecture-map.md +3 -3
- package/.agent-context/state/dependency-map.md +2 -2
- package/AGENTS.md +170 -35
- package/CLAUDE.md +1 -44
- package/CONTRIBUTING.md +2 -3
- package/GEMINI.md +1 -44
- package/README.md +28 -22
- package/lib/cli/backup.mjs +37 -0
- package/lib/cli/commands/init.mjs +15 -29
- package/lib/cli/commands/optimize.mjs +2 -48
- package/lib/cli/commands/upgrade.mjs +14 -52
- package/lib/cli/compiler.mjs +25 -95
- package/lib/cli/constants.mjs +1 -9
- package/lib/cli/detector.mjs +0 -1
- package/lib/cli/init-options.mjs +1 -1
- package/lib/cli/project-scaffolder/constants.mjs +1 -0
- package/lib/cli/project-scaffolder/discovery.mjs +2 -0
- package/lib/cli/project-scaffolder/prompt-builders.mjs +9 -5
- package/lib/cli/utils/filesystem.mjs +2 -0
- package/lib/cli/utils/managed-surface.mjs +45 -2
- package/lib/cli/utils.mjs +19 -4
- package/package.json +1 -10
- package/scripts/bump-version.mjs +1 -16
- package/scripts/docs-quality-drift-report.mjs +0 -6
- package/scripts/frontend-usability-audit.mjs +2 -2
- package/scripts/governance-weekly-report.mjs +2 -2
- package/scripts/single-source-lazy-loading-audit.mjs +13 -126
- package/scripts/sync-thin-adapters.mjs +13 -121
- package/scripts/validate/config.mjs +20 -27
- package/scripts/validate/coverage-checks.mjs +9 -76
- package/scripts/validate.mjs +12 -97
- package/.agent-override.md +0 -36
- package/.agents/workflows/init-project.md +0 -12
- package/.agents/workflows/refactor.md +0 -12
- package/.agents/workflows/review-code.md +0 -11
- package/.cursor/mcp.json +0 -10
- package/.cursor/rules/agentic-senior-core.mdc +0 -49
- package/.cursorrules +0 -26
- package/.gemini/instructions.md +0 -44
- package/.github/copilot-instructions.md +0 -44
- package/.github/instructions/agentic-senior-core.instructions.md +0 -48
- package/.github/workflows/benchmark-detection.yml +0 -45
- package/.github/workflows/benchmark-intelligence.yml +0 -50
- package/.github/workflows/docs-quality-drift-report.yml +0 -37
- package/.github/workflows/frontend-usability-gate.yml +0 -36
- package/.github/workflows/governance-weekly-report.yml +0 -43
- package/.github/workflows/publish.yml +0 -32
- package/.github/workflows/release-gate.yml +0 -32
- package/.github/workflows/sbom-compliance.yml +0 -32
- package/.instructions.md +0 -186
- package/.windsurf/rules/agentic-senior-core.md +0 -44
- package/.windsurfrules +0 -26
package/README.md
CHANGED
|
@@ -10,12 +10,13 @@
|
|
|
10
10
|
**Production-grade Rules Engine (Governance Engine) for AI coding agents.**
|
|
11
11
|
Works with Cursor, Windsurf, GitHub Copilot, Claude Code, Gemini, and other LLM-powered IDE workflows.
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Current package version: 3.0.48.
|
|
14
14
|
|
|
15
|
-
Highlights
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
15
|
+
Highlights:
|
|
16
|
+
- Uses `AGENTS.md` as the canonical instruction entrypoint.
|
|
17
|
+
- Keeps Claude Code and Gemini bridges as native `@AGENTS.md` imports.
|
|
18
|
+
- Loads detailed rules lazily from `.agent-context/` by task scope.
|
|
19
|
+
- Keeps MCP workspace files opt-in through `--mcp-template`.
|
|
19
20
|
|
|
20
21
|
</div>
|
|
21
22
|
|
|
@@ -29,11 +30,14 @@ Highlights in 3.0.40:
|
|
|
29
30
|
npx @ryuenn3123/agentic-senior-core init
|
|
30
31
|
```
|
|
31
32
|
|
|
32
|
-
One command to initialize
|
|
33
|
+
One command to initialize `AGENTS.md`, native import bridges, checklists, policies, state files, and the lazy `.agent-context/` rule library for your project.
|
|
33
34
|
|
|
34
|
-
> **See [docs/deep-dive.md](docs/deep-dive.md) and [docs/roadmap.md](docs/roadmap.md) for
|
|
35
|
+
> **See [docs/doc-index.md](docs/doc-index.md), [docs/deep-dive.md](docs/deep-dive.md), and [docs/roadmap.md](docs/roadmap.md) for deeper CLI, architecture, integration, and roadmap context.**
|
|
35
36
|
|
|
36
|
-
-
|
|
37
|
+
- Default init copies the compact instruction surface and writes onboarding, selected policy, token optimization, and memory continuity state.
|
|
38
|
+
- MCP workspace files are disabled by default. Add `--mcp-template` when you want starter IDE MCP configuration files.
|
|
39
|
+
- When project docs are scaffolded, `docs/doc-index.md` is used as the compact map for deeper docs so agents can read the right files without scanning every Markdown file.
|
|
40
|
+
- Local backup snapshots are written under `.agentic-backup/`; init and upgrade ensure that folder is ignored by the target repository.
|
|
37
41
|
- Package scope is `@ryuenn3123`; the GitHub repository owner is `fatidaprilian`.
|
|
38
42
|
|
|
39
43
|
---
|
|
@@ -74,8 +78,8 @@ If you see `Property $schema is not allowed`, keep `.vscode/mcp.json` without `$
|
|
|
74
78
|
|
|
75
79
|
| Command | Purpose |
|
|
76
80
|
|---------|---------|
|
|
77
|
-
| `agentic-senior-core init` | Initialize the project guidance pack
|
|
78
|
-
| `agentic-senior-core upgrade --dry-run` | Preview
|
|
81
|
+
| `agentic-senior-core init` | Initialize the compact project guidance pack and native agent entrypoints |
|
|
82
|
+
| `agentic-senior-core upgrade --dry-run` | Preview managed-surface upgrades |
|
|
79
83
|
| `agentic-senior-core optimize --show` | Show token optimization state |
|
|
80
84
|
| `npm run audit:v3-purge` | Run deep purge readiness audit (no deletion) |
|
|
81
85
|
| `npm run clean:local` | Remove ignored local reports, backups, benchmarks, and active-memory state |
|
|
@@ -92,24 +96,24 @@ npx @ryuenn3123/agentic-senior-core upgrade --yes
|
|
|
92
96
|
|
|
93
97
|
Use `--dry-run` first to preview changes safely, then apply with `--yes`.
|
|
94
98
|
|
|
95
|
-
Upgrade now performs managed-surface synchronization by default: obsolete
|
|
99
|
+
Upgrade now performs managed-surface synchronization by default: obsolete Agentic-managed instruction files are pruned so the pack stays aligned with the latest release.
|
|
96
100
|
Use `--no-prune` if you want to keep legacy managed files.
|
|
97
101
|
|
|
102
|
+
When upgrade creates `.agentic-backup/`, it also keeps the target root `.gitignore` aligned with that local-only backup folder. The backup is for rollback safety, not a source of truth and not a file to commit.
|
|
103
|
+
|
|
98
104
|
## Instruction Entrypoints
|
|
99
105
|
|
|
100
|
-
The canonical source is
|
|
106
|
+
The canonical installed source is `AGENTS.md`.
|
|
101
107
|
|
|
102
|
-
|
|
108
|
+
Default init and upgrade now keep the project root compact:
|
|
103
109
|
- `AGENTS.md`
|
|
104
110
|
- `CLAUDE.md`
|
|
105
111
|
- `GEMINI.md`
|
|
106
|
-
- `.
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
- `.github/instructions/agentic-senior-core.instructions.md`
|
|
110
|
-
- `.gemini/instructions.md`
|
|
112
|
+
- `.agent-context/`
|
|
113
|
+
|
|
114
|
+
`CLAUDE.md` and `GEMINI.md` are native import bridges that load `AGENTS.md`. Detailed rules, prompts, checklists, policies, and state stay under `.agent-context/` and load by task scope.
|
|
111
115
|
|
|
112
|
-
|
|
116
|
+
Deprecated legacy files such as `.instructions.md`, `.agent-instructions.md`, `.cursorrules`, `.windsurfrules`, `.agent-override.md`, tool-specific rule directories, and copied Copilot/Gemini instruction folders are no longer generated by default. Upgrade prunes Agentic-managed copies while preserving user-owned files without Agentic markers.
|
|
113
117
|
|
|
114
118
|
---
|
|
115
119
|
|
|
@@ -155,9 +159,11 @@ This repository publishes to npm automatically through GitHub Actions on every p
|
|
|
155
159
|
|
|
156
160
|
Release checklist:
|
|
157
161
|
|
|
158
|
-
1.
|
|
159
|
-
2.
|
|
160
|
-
3.
|
|
162
|
+
1. Run `node scripts/bump-version.mjs <version>`.
|
|
163
|
+
2. Fill the matching release notes in `CHANGELOG.md`.
|
|
164
|
+
3. Run `npm run check:adapters`, `npm run validate`, `npm test`, `npm run gate:release`, and `git diff --check`.
|
|
165
|
+
4. Commit with a Conventional Commit message.
|
|
166
|
+
5. Push to `origin/main`.
|
|
161
167
|
|
|
162
168
|
Important notes:
|
|
163
169
|
|
package/lib/cli/backup.mjs
CHANGED
|
@@ -4,6 +4,9 @@ import crypto from 'node:crypto';
|
|
|
4
4
|
import { pathExists, ensureDirectory } from './utils.mjs';
|
|
5
5
|
import { entryPointFiles, BACKUP_DIR_NAME } from './constants.mjs';
|
|
6
6
|
|
|
7
|
+
const BACKUP_GITIGNORE_ENTRY = `${BACKUP_DIR_NAME}/`;
|
|
8
|
+
const BACKUP_GITIGNORE_COMMENT = '# agentic-senior-core: local backup artifacts';
|
|
9
|
+
|
|
7
10
|
/**
|
|
8
11
|
* Calculates a SHA-256 hash of a file's contents.
|
|
9
12
|
*/
|
|
@@ -54,6 +57,7 @@ export async function createBackup(targetDirectoryPath) {
|
|
|
54
57
|
await ensureDirectory(objectsDir);
|
|
55
58
|
|
|
56
59
|
const pathsToTrack = [
|
|
60
|
+
path.join(targetDirectoryPath, '.gitignore'),
|
|
57
61
|
...entryPointFiles.map((entryPointFileName) => path.join(targetDirectoryPath, entryPointFileName)),
|
|
58
62
|
path.join(targetDirectoryPath, '.agent-context'),
|
|
59
63
|
];
|
|
@@ -122,3 +126,36 @@ export async function createBackup(targetDirectoryPath) {
|
|
|
122
126
|
durationMs: Date.now() - startTime
|
|
123
127
|
};
|
|
124
128
|
}
|
|
129
|
+
|
|
130
|
+
export async function ensureBackupGitignoreEntry(targetDirectoryPath) {
|
|
131
|
+
const gitignorePath = path.join(targetDirectoryPath, '.gitignore');
|
|
132
|
+
const existingContent = await pathExists(gitignorePath)
|
|
133
|
+
? await fs.readFile(gitignorePath, 'utf8')
|
|
134
|
+
: '';
|
|
135
|
+
const existingLines = existingContent.split(/\r?\n/).map((line) => line.trim());
|
|
136
|
+
|
|
137
|
+
if (existingLines.includes(BACKUP_GITIGNORE_ENTRY) || existingLines.includes(BACKUP_DIR_NAME)) {
|
|
138
|
+
return {
|
|
139
|
+
status: 'unchanged',
|
|
140
|
+
gitignorePath,
|
|
141
|
+
entry: BACKUP_GITIGNORE_ENTRY,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
let nextContent = existingContent;
|
|
146
|
+
if (nextContent.length > 0 && !nextContent.endsWith('\n')) {
|
|
147
|
+
nextContent += '\n';
|
|
148
|
+
}
|
|
149
|
+
if (nextContent.length > 0 && !nextContent.endsWith('\n\n')) {
|
|
150
|
+
nextContent += '\n';
|
|
151
|
+
}
|
|
152
|
+
nextContent += `${BACKUP_GITIGNORE_COMMENT}\n${BACKUP_GITIGNORE_ENTRY}\n`;
|
|
153
|
+
|
|
154
|
+
await fs.writeFile(gitignorePath, nextContent, 'utf8');
|
|
155
|
+
|
|
156
|
+
return {
|
|
157
|
+
status: existingContent ? 'updated' : 'created',
|
|
158
|
+
gitignorePath,
|
|
159
|
+
entry: BACKUP_GITIGNORE_ENTRY,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
formatDetectionCandidates,
|
|
35
35
|
detectUiScopeSignals,
|
|
36
36
|
} from '../detector.mjs';
|
|
37
|
-
import {
|
|
37
|
+
import { writeSelectedPolicy, writeOnboardingReport } from '../compiler.mjs';
|
|
38
38
|
import {
|
|
39
39
|
normalizeAdditionalStackSelection,
|
|
40
40
|
normalizeAdditionalBlueprintSelection,
|
|
@@ -44,7 +44,7 @@ import {
|
|
|
44
44
|
resolveDetectedSetupDecision,
|
|
45
45
|
} from '../init-detection-flow.mjs';
|
|
46
46
|
import { runPreflightChecks } from '../preflight.mjs';
|
|
47
|
-
import { createBackup } from '../backup.mjs';
|
|
47
|
+
import { createBackup, ensureBackupGitignoreEntry } from '../backup.mjs';
|
|
48
48
|
import {
|
|
49
49
|
runProjectDiscovery,
|
|
50
50
|
generateProjectDocumentation,
|
|
@@ -153,7 +153,7 @@ export async function runInitCommand(targetDirectoryArgument, initOptions = {})
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
console.log(`\nAgentic-Senior-Core CLI v${CLI_VERSION}`);
|
|
156
|
-
console.log('I will copy the project guidance pack into your target folder and
|
|
156
|
+
console.log('I will copy the project guidance pack into your target folder with AGENTS.md and native import bridges for your AI tools.');
|
|
157
157
|
|
|
158
158
|
if (selectedPreset) {
|
|
159
159
|
console.log(`Using preset: ${initOptions.preset} (${selectedPreset.description}).`);
|
|
@@ -198,19 +198,10 @@ export async function runInitCommand(targetDirectoryArgument, initOptions = {})
|
|
|
198
198
|
? buildDetectionSummary(projectDetection)
|
|
199
199
|
: 'No existing project markers were detected.',
|
|
200
200
|
activeRulesSummary: {
|
|
201
|
-
canonicalSource: '.
|
|
202
|
-
compiledRulebook:
|
|
203
|
-
legacyThinAdapters: [
|
|
204
|
-
generatedBridgeAdapters: [
|
|
205
|
-
'AGENTS.md',
|
|
206
|
-
'CLAUDE.md',
|
|
207
|
-
'GEMINI.md',
|
|
208
|
-
'.cursor/rules/agentic-senior-core.mdc',
|
|
209
|
-
'.windsurf/rules/agentic-senior-core.md',
|
|
210
|
-
'.github/copilot-instructions.md',
|
|
211
|
-
'.github/instructions/agentic-senior-core.instructions.md',
|
|
212
|
-
'.gemini/instructions.md',
|
|
213
|
-
],
|
|
201
|
+
canonicalSource: 'AGENTS.md',
|
|
202
|
+
compiledRulebook: null,
|
|
203
|
+
legacyThinAdapters: [],
|
|
204
|
+
generatedBridgeAdapters: ['CLAUDE.md', 'GEMINI.md'],
|
|
214
205
|
stackLoadingMode: 'lazy',
|
|
215
206
|
domainRuleLoadingMode: 'lazy',
|
|
216
207
|
selectedProfile: selectedPolicyProfileName,
|
|
@@ -249,7 +240,7 @@ export async function runInitCommand(targetDirectoryArgument, initOptions = {})
|
|
|
249
240
|
console.log('- Detected stack: unresolved (insufficient markers).');
|
|
250
241
|
}
|
|
251
242
|
|
|
252
|
-
console.log('- Active rules baseline: canonical .
|
|
243
|
+
console.log('- Active rules baseline: canonical AGENTS.md + .agent-context/ lazy rule library');
|
|
253
244
|
console.log(
|
|
254
245
|
`- Active review thresholds: ${formatBlockingSeverities(selectedPolicyProfile.blockingSeverities)}`
|
|
255
246
|
);
|
|
@@ -376,6 +367,10 @@ export async function runInitCommand(targetDirectoryArgument, initOptions = {})
|
|
|
376
367
|
detectionTransparency.decision.selectedProjectScopeLabel = selectedProjectScopeLabel;
|
|
377
368
|
|
|
378
369
|
await createBackup(resolvedTargetDirectoryPath);
|
|
370
|
+
const backupGitignoreResult = await ensureBackupGitignoreEntry(resolvedTargetDirectoryPath);
|
|
371
|
+
if (backupGitignoreResult.status !== 'unchanged') {
|
|
372
|
+
console.log(`Local backup artifacts ignored in .gitignore (${backupGitignoreResult.entry}).`);
|
|
373
|
+
}
|
|
379
374
|
|
|
380
375
|
await copyGovernanceAssetsToTarget(resolvedTargetDirectoryPath, {
|
|
381
376
|
includeMcpTemplate: shouldIncludeMcpTemplate,
|
|
@@ -489,15 +484,6 @@ export async function runInitCommand(targetDirectoryArgument, initOptions = {})
|
|
|
489
484
|
console.log('\nExisting UI/frontend scope detected. Seeded docs/design-intent.json so the machine-readable design contract exists before UI implementation work continues.');
|
|
490
485
|
}
|
|
491
486
|
|
|
492
|
-
await compileDynamicContext({
|
|
493
|
-
targetDirectoryPath: resolvedTargetDirectoryPath,
|
|
494
|
-
selectedStackFileName: selectedResolvedStackFileName,
|
|
495
|
-
selectedAdditionalStackFileNames,
|
|
496
|
-
selectedBlueprintFileName: selectedResolvedBlueprintFileName,
|
|
497
|
-
selectedAdditionalBlueprintFileNames,
|
|
498
|
-
includeCiGuardrails,
|
|
499
|
-
});
|
|
500
|
-
|
|
501
487
|
await writeSelectedPolicy(resolvedTargetDirectoryPath, selectedPolicyProfileName);
|
|
502
488
|
|
|
503
489
|
const setupDurationMs = Date.now() - setupStartedAt;
|
|
@@ -566,7 +552,7 @@ export async function runInitCommand(targetDirectoryArgument, initOptions = {})
|
|
|
566
552
|
console.log(`- CI/CD quality checks (guardrails): ${includeCiGuardrails ? 'enabled' : 'disabled'}`);
|
|
567
553
|
console.log(`- Review thresholds: ${formatBlockingSeverities(selectedPolicyProfile.blockingSeverities)}`);
|
|
568
554
|
console.log(`- Setup time: ${formatDuration(setupDurationMs)}`);
|
|
569
|
-
console.log('- Generated files: .
|
|
555
|
+
console.log('- Generated files: AGENTS.md, CLAUDE.md, GEMINI.md, .agent-context/, and .agent-context/state/onboarding-report.json');
|
|
570
556
|
if (scaffoldingResult?.bootstrapMode === 'ai-synthesis') {
|
|
571
557
|
console.log(`- Bootstrap prompts: ${(scaffoldingResult.generatedPromptFileNames || []).length} files generated in .agent-context/prompts/`);
|
|
572
558
|
if ((scaffoldingResult.materializedFileNames || []).length > 0) {
|
|
@@ -582,7 +568,7 @@ export async function runInitCommand(targetDirectoryArgument, initOptions = {})
|
|
|
582
568
|
console.log(`- Design seed docs: ${supplementalMaterializedDocFileNames.length} files generated in docs/`);
|
|
583
569
|
}
|
|
584
570
|
console.log(`- Repository workflows copied: no (workflows remain source-repo assets)`);
|
|
585
|
-
console.log(`- MCP configuration: ${shouldIncludeMcpTemplate ? 'auto-configured for your IDEs (VS Code, Cursor, Zed, Gemini)' : 'disabled (--
|
|
571
|
+
console.log(`- MCP configuration: ${shouldIncludeMcpTemplate ? 'auto-configured for your IDEs (VS Code, Cursor, Zed, Gemini)' : 'disabled (use --mcp-template to enable)'}`);
|
|
586
572
|
if (isMemoryContinuityEnabled) {
|
|
587
573
|
console.log('- Memory continuity policy: enabled (index + selective hydration; host support required)');
|
|
588
574
|
} else {
|
|
@@ -630,7 +616,7 @@ export async function runInitCommand(targetDirectoryArgument, initOptions = {})
|
|
|
630
616
|
console.log('- If docs/DESIGN.md is missing, execute .agent-context/prompts/bootstrap-design.md now and refine docs/design-intent.json into a complete design contract before building UI components.');
|
|
631
617
|
console.log('- Keep docs/design-intent.json and docs/DESIGN.md synchronized whenever the UI direction changes.');
|
|
632
618
|
}
|
|
633
|
-
console.log('Your AI tools will now receive
|
|
619
|
+
console.log('Your AI tools will now receive AGENTS.md, native import bridges, and the lazy-loaded .agent-context rule library. Your review threshold is stored in .agent-context/policies/llm-judge-threshold.json.');
|
|
634
620
|
console.log('MCP server registration is manual inside your IDE settings, even when mcp.json exists.');
|
|
635
621
|
} catch (error) {
|
|
636
622
|
console.error('\n[FATAL] An error occurred during initialization. Attempting automatic rollback...');
|
|
@@ -2,11 +2,7 @@ import fs from 'node:fs/promises';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
|
|
4
4
|
import { ensureDirectory, formatDuration } from '../utils.mjs';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
AGENT_DECISION_STACK_FILE_NAME,
|
|
8
|
-
AGENT_DECISION_BLUEPRINT_FILE_NAME,
|
|
9
|
-
} from '../constants.mjs';
|
|
5
|
+
import { loadOnboardingReportIfExists } from '../compiler.mjs';
|
|
10
6
|
import {
|
|
11
7
|
TOKEN_OPTIMIZATION_REPORT_FILE_NAME,
|
|
12
8
|
normalizeAgentName,
|
|
@@ -18,17 +14,6 @@ import {
|
|
|
18
14
|
writeTokenOptimizationState,
|
|
19
15
|
} from '../token-optimization.mjs';
|
|
20
16
|
|
|
21
|
-
function normalizeMarkdownFileName(rawFileName, fallbackFileName) {
|
|
22
|
-
if (typeof rawFileName !== 'string' || rawFileName.trim().length === 0) {
|
|
23
|
-
return fallbackFileName;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const normalizedFileName = rawFileName.trim();
|
|
27
|
-
return normalizedFileName.endsWith('.md')
|
|
28
|
-
? normalizedFileName
|
|
29
|
-
: `${normalizedFileName}.md`;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
17
|
export function parseOptimizeArguments(commandArguments) {
|
|
33
18
|
const parsedOptimizeOptions = {
|
|
34
19
|
targetDirectory: '.',
|
|
@@ -119,37 +104,6 @@ export async function runOptimizeCommand(targetDirectoryArgument, optimizeOption
|
|
|
119
104
|
|
|
120
105
|
await writeTokenOptimizationState(resolvedTargetDirectoryPath, tokenOptimizationState);
|
|
121
106
|
|
|
122
|
-
const hasExplicitRuntimeConstraint = onboardingReport?.runtimeDecision?.mode === 'explicit-constraint';
|
|
123
|
-
const hasExplicitArchitectureConstraint = onboardingReport?.architectureDecision?.mode === 'explicit-constraint';
|
|
124
|
-
const selectedStackFileName = hasExplicitRuntimeConstraint
|
|
125
|
-
? normalizeMarkdownFileName(onboardingReport.selectedStack, AGENT_DECISION_STACK_FILE_NAME)
|
|
126
|
-
: AGENT_DECISION_STACK_FILE_NAME;
|
|
127
|
-
const selectedAdditionalStackFileNames = hasExplicitRuntimeConstraint && Array.isArray(onboardingReport.selectedAdditionalStacks)
|
|
128
|
-
? onboardingReport.selectedAdditionalStacks
|
|
129
|
-
.map((stackFileName) => normalizeMarkdownFileName(stackFileName, ''))
|
|
130
|
-
.filter((stackFileName) => stackFileName && stackFileName !== selectedStackFileName)
|
|
131
|
-
: [];
|
|
132
|
-
const selectedBlueprintFileName = hasExplicitArchitectureConstraint
|
|
133
|
-
? normalizeMarkdownFileName(onboardingReport.selectedBlueprint, AGENT_DECISION_BLUEPRINT_FILE_NAME)
|
|
134
|
-
: AGENT_DECISION_BLUEPRINT_FILE_NAME;
|
|
135
|
-
const selectedAdditionalBlueprintFileNames = hasExplicitArchitectureConstraint && Array.isArray(onboardingReport.selectedAdditionalBlueprints)
|
|
136
|
-
? onboardingReport.selectedAdditionalBlueprints
|
|
137
|
-
.map((blueprintFileName) => normalizeMarkdownFileName(blueprintFileName, ''))
|
|
138
|
-
.filter((blueprintFileName) => blueprintFileName && blueprintFileName !== selectedBlueprintFileName)
|
|
139
|
-
: [];
|
|
140
|
-
const includeCiGuardrails = typeof onboardingReport.ciGuardrailsEnabled === 'boolean'
|
|
141
|
-
? onboardingReport.ciGuardrailsEnabled
|
|
142
|
-
: true;
|
|
143
|
-
|
|
144
|
-
await compileDynamicContext({
|
|
145
|
-
targetDirectoryPath: resolvedTargetDirectoryPath,
|
|
146
|
-
selectedStackFileName,
|
|
147
|
-
selectedAdditionalStackFileNames,
|
|
148
|
-
selectedBlueprintFileName,
|
|
149
|
-
selectedAdditionalBlueprintFileNames,
|
|
150
|
-
includeCiGuardrails,
|
|
151
|
-
});
|
|
152
|
-
|
|
153
107
|
const optimizationDurationMs = Date.now() - optimizationStartedAt;
|
|
154
108
|
const tokenOptimizationReport = {
|
|
155
109
|
generatedAt: new Date().toISOString(),
|
|
@@ -174,7 +128,7 @@ export async function runOptimizeCommand(targetDirectoryArgument, optimizeOption
|
|
|
174
128
|
console.log(`- Agent profile: ${tokenOptimizationState.selectedAgent}`);
|
|
175
129
|
console.log(`- Preferred shell proxy: ${tokenOptimizationState.preferredShellProxy}`);
|
|
176
130
|
console.log(`- Setup time: ${formatDuration(optimizationDurationMs)}`);
|
|
177
|
-
console.log('- Updated files: .agent-
|
|
131
|
+
console.log('- Updated files: .agent-context/state/token-optimization.json and .agent-context/state/token-optimization-report.json');
|
|
178
132
|
|
|
179
133
|
if (tokenOptimizationState.enabled) {
|
|
180
134
|
if (rtkDetection.isAvailable) {
|
|
@@ -33,15 +33,13 @@ import {
|
|
|
33
33
|
detectUiScopeSignals,
|
|
34
34
|
} from '../detector.mjs';
|
|
35
35
|
import {
|
|
36
|
-
buildCompiledRulesContent,
|
|
37
|
-
compileDynamicContext,
|
|
38
36
|
writeSelectedPolicy,
|
|
39
37
|
writeOnboardingReport,
|
|
40
38
|
loadOnboardingReportIfExists,
|
|
41
39
|
} from '../compiler.mjs';
|
|
42
40
|
|
|
43
41
|
import { runPreflightChecks } from '../preflight.mjs';
|
|
44
|
-
import { createBackup } from '../backup.mjs';
|
|
42
|
+
import { createBackup, ensureBackupGitignoreEntry } from '../backup.mjs';
|
|
45
43
|
import { performRollback } from '../rollback.mjs';
|
|
46
44
|
import {
|
|
47
45
|
detectProjectDocTemplateStaleness,
|
|
@@ -55,7 +53,7 @@ export function parseUpgradeArguments(commandArguments) {
|
|
|
55
53
|
targetDirectory: '.',
|
|
56
54
|
dryRun: false,
|
|
57
55
|
skipConfirmation: false,
|
|
58
|
-
includeMcpTemplate:
|
|
56
|
+
includeMcpTemplate: false,
|
|
59
57
|
pruneManagedSurface: true,
|
|
60
58
|
};
|
|
61
59
|
|
|
@@ -243,19 +241,10 @@ export async function runUpgradeCommand(targetDirectoryArgument, upgradeOptions
|
|
|
243
241
|
declarationShown: true,
|
|
244
242
|
detectionSummary: buildDetectionSummary(projectDetection),
|
|
245
243
|
activeRulesSummary: {
|
|
246
|
-
canonicalSource: '.
|
|
247
|
-
compiledRulebook:
|
|
248
|
-
legacyThinAdapters: [
|
|
249
|
-
generatedBridgeAdapters: [
|
|
250
|
-
'AGENTS.md',
|
|
251
|
-
'CLAUDE.md',
|
|
252
|
-
'GEMINI.md',
|
|
253
|
-
'.cursor/rules/agentic-senior-core.mdc',
|
|
254
|
-
'.windsurf/rules/agentic-senior-core.md',
|
|
255
|
-
'.github/copilot-instructions.md',
|
|
256
|
-
'.github/instructions/agentic-senior-core.instructions.md',
|
|
257
|
-
'.gemini/instructions.md',
|
|
258
|
-
],
|
|
244
|
+
canonicalSource: 'AGENTS.md',
|
|
245
|
+
compiledRulebook: null,
|
|
246
|
+
legacyThinAdapters: [],
|
|
247
|
+
generatedBridgeAdapters: ['CLAUDE.md', 'GEMINI.md'],
|
|
259
248
|
stackLoadingMode: 'lazy',
|
|
260
249
|
domainRuleLoadingMode: 'lazy',
|
|
261
250
|
selectedProfile: selectedProfileName,
|
|
@@ -285,7 +274,7 @@ export async function runUpgradeCommand(targetDirectoryArgument, upgradeOptions
|
|
|
285
274
|
} else {
|
|
286
275
|
console.log('- Detected stack: unresolved (insufficient markers).');
|
|
287
276
|
}
|
|
288
|
-
console.log('- Active rules baseline: canonical .
|
|
277
|
+
console.log('- Active rules baseline: canonical AGENTS.md + .agent-context/ lazy rule library');
|
|
289
278
|
console.log(
|
|
290
279
|
`- Active review thresholds: ${(
|
|
291
280
|
PROFILE_PRESETS[selectedProfileName]?.blockingSeverities || []
|
|
@@ -300,24 +289,6 @@ export async function runUpgradeCommand(targetDirectoryArgument, upgradeOptions
|
|
|
300
289
|
|
|
301
290
|
const projectDocStalenessReport = await detectProjectDocTemplateStaleness(resolvedTargetDirectoryPath);
|
|
302
291
|
|
|
303
|
-
const currentRulesPath = path.join(resolvedTargetDirectoryPath, '.agent-instructions.md');
|
|
304
|
-
const currentRulesContent = await pathExists(currentRulesPath)
|
|
305
|
-
? await fs.readFile(currentRulesPath, 'utf8')
|
|
306
|
-
: '';
|
|
307
|
-
|
|
308
|
-
const plannedRulesContent = await buildCompiledRulesContent({
|
|
309
|
-
targetDirectoryPath: resolvedTargetDirectoryPath,
|
|
310
|
-
selectedStackFileName,
|
|
311
|
-
selectedAdditionalStackFileNames,
|
|
312
|
-
selectedBlueprintFileName,
|
|
313
|
-
selectedAdditionalBlueprintFileNames,
|
|
314
|
-
includeCiGuardrails,
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
const isRulesContentChanged = currentRulesContent !== plannedRulesContent;
|
|
318
|
-
const currentRuleLineCount = currentRulesContent ? currentRulesContent.split(/\r?\n/).length : 0;
|
|
319
|
-
const plannedRuleLineCount = plannedRulesContent.split(/\r?\n/).length;
|
|
320
|
-
|
|
321
292
|
console.log('\nUpgrade preview:');
|
|
322
293
|
console.log(`- Target directory: ${resolvedTargetDirectoryPath}`);
|
|
323
294
|
console.log(`- Runtime decision: ${selectedStackFileName === AGENT_DECISION_STACK_FILE_NAME ? 'agent recommendation required from repo evidence' : toTitleCase(selectedStackFileName)}`);
|
|
@@ -329,14 +300,12 @@ export async function runUpgradeCommand(targetDirectoryArgument, upgradeOptions
|
|
|
329
300
|
console.log(`- Additional blueprints: ${selectedAdditionalBlueprintFileNames.map((blueprintFileName) => toTitleCase(blueprintFileName)).join(', ')}`);
|
|
330
301
|
}
|
|
331
302
|
console.log(`- CI/CD quality checks (guardrails): ${includeCiGuardrails ? 'enabled' : 'disabled'}`);
|
|
332
|
-
console.log(
|
|
333
|
-
console.log(`- Planned rules lines: ${plannedRuleLineCount}`);
|
|
334
|
-
console.log(`- Rules changed: ${isRulesContentChanged ? 'yes' : 'no'}`);
|
|
303
|
+
console.log('- Instruction surface: AGENTS.md canonical with CLAUDE.md and GEMINI.md import bridges');
|
|
335
304
|
console.log(`- Managed surface stale files: ${managedSurfacePlan.staleFiles.length}`);
|
|
336
305
|
console.log(`- Managed surface stale directories: ${managedSurfacePlan.staleDirectories.length}`);
|
|
337
306
|
console.log(`- Managed surface sync mode: 1:1 (prune enabled)`);
|
|
338
307
|
console.log(`- Managed surface prune mode: ${upgradeOptions.pruneManagedSurface === true ? 'enabled (default)' : 'disabled (--no-prune)'}`);
|
|
339
|
-
console.log(`- MCP config write mode: ${upgradeOptions.includeMcpTemplate === true ? 'enabled (
|
|
308
|
+
console.log(`- MCP config write mode: ${upgradeOptions.includeMcpTemplate === true ? 'enabled (--mcp-template)' : 'disabled (default)'}`);
|
|
340
309
|
if (projectDocStalenessReport.hasProjectDocs) {
|
|
341
310
|
console.log(`- Project docs detected: ${projectDocStalenessReport.checkedFileNames.length}`);
|
|
342
311
|
console.log(`- Project docs expected template version: ${projectDocStalenessReport.expectedTemplateVersion}`);
|
|
@@ -399,6 +368,10 @@ export async function runUpgradeCommand(targetDirectoryArgument, upgradeOptions
|
|
|
399
368
|
}
|
|
400
369
|
|
|
401
370
|
await createBackup(resolvedTargetDirectoryPath);
|
|
371
|
+
const backupGitignoreResult = await ensureBackupGitignoreEntry(resolvedTargetDirectoryPath);
|
|
372
|
+
if (backupGitignoreResult.status !== 'unchanged') {
|
|
373
|
+
console.log(`Local backup artifacts ignored in .gitignore (${backupGitignoreResult.entry}).`);
|
|
374
|
+
}
|
|
402
375
|
|
|
403
376
|
try {
|
|
404
377
|
const governanceSyncResult = await copyGovernanceAssetsToTarget(resolvedTargetDirectoryPath, {
|
|
@@ -427,15 +400,6 @@ export async function runUpgradeCommand(targetDirectoryArgument, upgradeOptions
|
|
|
427
400
|
}
|
|
428
401
|
}
|
|
429
402
|
|
|
430
|
-
const compileResult = await compileDynamicContext({
|
|
431
|
-
targetDirectoryPath: resolvedTargetDirectoryPath,
|
|
432
|
-
selectedStackFileName,
|
|
433
|
-
selectedAdditionalStackFileNames,
|
|
434
|
-
selectedBlueprintFileName,
|
|
435
|
-
selectedAdditionalBlueprintFileNames,
|
|
436
|
-
includeCiGuardrails,
|
|
437
|
-
preserveUserOwnedEntrypoints: true,
|
|
438
|
-
});
|
|
439
403
|
await writeSelectedPolicy(resolvedTargetDirectoryPath, selectedProfileName);
|
|
440
404
|
|
|
441
405
|
const setupDurationMs = Date.now() - setupStartedAt;
|
|
@@ -458,10 +422,8 @@ export async function runUpgradeCommand(targetDirectoryArgument, upgradeOptions
|
|
|
458
422
|
|
|
459
423
|
console.log('\nUpgrade complete.');
|
|
460
424
|
console.log(`- Governance surface sync: 1:1 (${governanceSyncResult.updatedFiles.length} updated, ${governanceSyncResult.createdFiles.length} new, ${governanceSyncResult.deletedManagedFiles.length} deleted, ${governanceSyncResult.unchangedFiles.length} unchanged)`);
|
|
461
|
-
console.log(`- Rules rewritten: ${isRulesContentChanged ? 'yes' : 'no (metadata refreshed)'}`);
|
|
462
425
|
const preservedInstructionEntrypoints = Array.from(new Set([
|
|
463
426
|
...(governanceSyncResult.preservedFiles || []),
|
|
464
|
-
...(compileResult.preservedEntrypoints || []),
|
|
465
427
|
])).sort();
|
|
466
428
|
if (preservedInstructionEntrypoints.length > 0) {
|
|
467
429
|
console.log(`- User-owned instruction entrypoints preserved: ${preservedInstructionEntrypoints.length}`);
|
|
@@ -490,7 +452,7 @@ export async function runUpgradeCommand(targetDirectoryArgument, upgradeOptions
|
|
|
490
452
|
supplementalCreatedFileNames.forEach((fileName) => console.log(` [NEW] ${fileName} (seed)`));
|
|
491
453
|
}
|
|
492
454
|
|
|
493
|
-
console.log('\nRefreshed files: .
|
|
455
|
+
console.log('\nRefreshed files: AGENTS.md, CLAUDE.md, GEMINI.md, .agent-context/, and .agent-context/state/onboarding-report.json');
|
|
494
456
|
} catch (error) {
|
|
495
457
|
console.error('\n[FATAL] An error occurred during upgrade. Attempting automatic rollback...');
|
|
496
458
|
try {
|