@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.
Files changed (201) hide show
  1. package/.agents/plugins/agentic-senior-core/plugin.json +3 -0
  2. package/.agents/plugins/agentic-senior-core/rules/agentic-senior-core.md +131 -0
  3. package/.agents/plugins/agentic-senior-core/skills/asc/SKILL.md +16 -0
  4. package/.agents/plugins/agentic-senior-core/skills/asc-audit/SKILL.md +28 -0
  5. package/.agents/plugins/agentic-senior-core/skills/asc-refactor/SKILL.md +35 -0
  6. package/.agents/plugins/agentic-senior-core/skills/asc-review/SKILL.md +54 -0
  7. package/.agents/rules/agentic-senior-core.md +131 -0
  8. package/.claude-plugin/marketplace.json +17 -0
  9. package/.claude-plugin/plugin.json +17 -0
  10. package/.clinerules/agentic-senior-core.md +94 -0
  11. package/.codex-plugin/plugin.json +24 -0
  12. package/.cursor/rules/agentic-senior-core.mdc +99 -0
  13. package/.devin-plugin/plugin.json +13 -0
  14. package/.github/copilot-instructions.md +94 -0
  15. package/.github/plugin/marketplace.json +20 -0
  16. package/.github/plugin/plugin.json +16 -0
  17. package/.kiro/steering/agentic-senior-core.md +94 -0
  18. package/.openclaw/skills/asc/SKILL.md +23 -0
  19. package/.openclaw/skills/asc-audit/SKILL.md +28 -0
  20. package/.openclaw/skills/asc-review/SKILL.md +54 -0
  21. package/.opencode/plugins/agentic-senior-core.mjs +31 -0
  22. package/.windsurf/rules/agentic-senior-core.md +94 -0
  23. package/AGENTS.md +126 -127
  24. package/CONTRIBUTING.md +93 -63
  25. package/README.md +190 -110
  26. package/__init__.py +61 -0
  27. package/bin/agentic-senior-core.js +42 -41
  28. package/commands/asc-audit.md +1 -0
  29. package/commands/asc-audit.toml +2 -0
  30. package/commands/asc-help.md +9 -0
  31. package/commands/asc-help.toml +2 -0
  32. package/commands/asc-refactor.md +1 -0
  33. package/commands/asc-refactor.toml +2 -0
  34. package/commands/asc-review.md +1 -0
  35. package/commands/asc-review.toml +2 -0
  36. package/gemini-extension.json +10 -0
  37. package/hooks/copilot-hooks.json +21 -0
  38. package/hooks/hooks.json +31 -0
  39. package/hooks/session-start.js +36 -0
  40. package/hooks/subagent-start.js +38 -0
  41. package/lib/cli/commands/adapter.mjs +109 -0
  42. package/lib/cli/commands/clean.mjs +63 -0
  43. package/lib/cli/commands/status.mjs +94 -0
  44. package/package.json +43 -60
  45. package/plugin.yaml +16 -0
  46. package/scripts/uninstall.js +38 -0
  47. package/skills/asc/SKILL.md +16 -0
  48. package/skills/asc-audit/SKILL.md +28 -0
  49. package/skills/asc-refactor/SKILL.md +35 -0
  50. package/skills/asc-review/SKILL.md +54 -0
  51. package/.agent-context/policies/llm-judge-threshold.json +0 -29
  52. package/.agent-context/prompts/bootstrap-design.md +0 -63
  53. package/.agent-context/prompts/compact-natural-mode.md +0 -100
  54. package/.agent-context/prompts/init-project.md +0 -60
  55. package/.agent-context/prompts/refactor.md +0 -38
  56. package/.agent-context/prompts/review-code.md +0 -31
  57. package/.agent-context/review-checklists/architecture-review.md +0 -57
  58. package/.agent-context/review-checklists/pr-checklist.md +0 -134
  59. package/.agent-context/rules/api-docs.md +0 -24
  60. package/.agent-context/rules/api-versioning.md +0 -16
  61. package/.agent-context/rules/architecture.md +0 -38
  62. package/.agent-context/rules/background-jobs.md +0 -17
  63. package/.agent-context/rules/config-and-flags.md +0 -16
  64. package/.agent-context/rules/database-design.md +0 -18
  65. package/.agent-context/rules/docker-runtime.md +0 -17
  66. package/.agent-context/rules/error-handling.md +0 -16
  67. package/.agent-context/rules/event-driven.md +0 -16
  68. package/.agent-context/rules/frontend-architecture.md +0 -54
  69. package/.agent-context/rules/microservices.md +0 -16
  70. package/.agent-context/rules/migrations.md +0 -16
  71. package/.agent-context/rules/observability.md +0 -16
  72. package/.agent-context/rules/performance.md +0 -16
  73. package/.agent-context/rules/realtime.md +0 -16
  74. package/.agent-context/rules/resilience.md +0 -18
  75. package/.agent-context/rules/security.md +0 -18
  76. package/.agent-context/rules/testing.md +0 -16
  77. package/.agent-context/state/README.md +0 -25
  78. package/.agent-context/state/architecture-map.md +0 -40
  79. package/.agent-context/state/benchmark-comparison-schema.json +0 -181
  80. package/.agent-context/state/benchmark-reproducibility.json +0 -87
  81. package/.agent-context/state/benchmark-thresholds.json +0 -10
  82. package/.agent-context/state/benchmark-writer-judge-config.json +0 -58
  83. package/.agent-context/state/dependency-map.md +0 -41
  84. package/.agent-context/state/memory-adapter-contract.json +0 -52
  85. package/.agent-context/state/memory-schema-v1.json +0 -88
  86. package/GEMINI.md +0 -1
  87. package/benchmarks/README.md +0 -60
  88. package/benchmarks/compact-natural-mode/fixtures.mjs +0 -359
  89. package/benchmarks/compact-natural-mode/scorer.mjs +0 -331
  90. package/benchmarks/runtime-token-saver/fixtures.mjs +0 -836
  91. package/lib/cli/adaptive-context/catalog.mjs +0 -394
  92. package/lib/cli/adaptive-context/file-signals.mjs +0 -100
  93. package/lib/cli/adaptive-context/implications.mjs +0 -44
  94. package/lib/cli/adaptive-context.mjs +0 -151
  95. package/lib/cli/audits/typography-palette-anti-repeat/color-utils.mjs +0 -156
  96. package/lib/cli/audits/typography-palette-anti-repeat/file-scanner.mjs +0 -103
  97. package/lib/cli/audits/typography-palette-anti-repeat/typography-utils.mjs +0 -70
  98. package/lib/cli/backup.mjs +0 -210
  99. package/lib/cli/commands/context.mjs +0 -140
  100. package/lib/cli/commands/init/project-context.mjs +0 -60
  101. package/lib/cli/commands/init/runtime-environment.mjs +0 -59
  102. package/lib/cli/commands/init/setup-decisions.mjs +0 -83
  103. package/lib/cli/commands/init.mjs +0 -654
  104. package/lib/cli/commands/launch.mjs +0 -76
  105. package/lib/cli/commands/optimize.mjs +0 -284
  106. package/lib/cli/commands/rollback.mjs +0 -64
  107. package/lib/cli/commands/upgrade/token-optimization-state.mjs +0 -51
  108. package/lib/cli/commands/upgrade.mjs +0 -451
  109. package/lib/cli/compiler.mjs +0 -187
  110. package/lib/cli/constants.mjs +0 -136
  111. package/lib/cli/detector/constants.mjs +0 -135
  112. package/lib/cli/detector/design-evidence/collector.mjs +0 -256
  113. package/lib/cli/detector/design-evidence/constants.mjs +0 -39
  114. package/lib/cli/detector/design-evidence/file-traversal.mjs +0 -83
  115. package/lib/cli/detector/design-evidence/structured-attribute-evidence.mjs +0 -117
  116. package/lib/cli/detector/design-evidence/summary.mjs +0 -109
  117. package/lib/cli/detector/design-evidence/utility-helpers.mjs +0 -122
  118. package/lib/cli/detector/design-evidence.mjs +0 -25
  119. package/lib/cli/detector/stack-detection.mjs +0 -243
  120. package/lib/cli/detector/ui-signals.mjs +0 -150
  121. package/lib/cli/detector/workspace-scan.mjs +0 -177
  122. package/lib/cli/detector.mjs +0 -23
  123. package/lib/cli/init-detection-flow.mjs +0 -48
  124. package/lib/cli/init-options.mjs +0 -237
  125. package/lib/cli/init-selection.mjs +0 -29
  126. package/lib/cli/memory-continuity.mjs +0 -537
  127. package/lib/cli/preflight.mjs +0 -76
  128. package/lib/cli/project-scaffolder/constants.mjs +0 -69
  129. package/lib/cli/project-scaffolder/discovery.mjs +0 -272
  130. package/lib/cli/project-scaffolder/prompt-builders.mjs +0 -171
  131. package/lib/cli/project-scaffolder/storage.mjs +0 -144
  132. package/lib/cli/project-scaffolder/ui-scope-detection.mjs +0 -36
  133. package/lib/cli/project-scaffolder.mjs +0 -29
  134. package/lib/cli/rollback.mjs +0 -66
  135. package/lib/cli/token-optimization.mjs +0 -401
  136. package/lib/cli/utils/filesystem.mjs +0 -81
  137. package/lib/cli/utils/managed-surface.mjs +0 -280
  138. package/lib/cli/utils/prompting.mjs +0 -44
  139. package/lib/cli/utils.mjs +0 -479
  140. package/mcp.json +0 -134
  141. package/scripts/adaptive-context/fixtures.mjs +0 -183
  142. package/scripts/adaptive-context-benchmark.mjs +0 -9
  143. package/scripts/ascx-runtime-token-saver-benchmark.mjs +0 -9
  144. package/scripts/benchmark-evidence-bundle.mjs +0 -645
  145. package/scripts/benchmark-gate.mjs +0 -121
  146. package/scripts/benchmark-intelligence.mjs +0 -33
  147. package/scripts/benchmark-writer-judge-matrix.mjs +0 -379
  148. package/scripts/build-release-benchmark-bundle.mjs +0 -202
  149. package/scripts/bump-version.mjs +0 -103
  150. package/scripts/clean-local-artifacts.mjs +0 -78
  151. package/scripts/compact-natural-mode-benchmark.mjs +0 -9
  152. package/scripts/context-triggered-audit.mjs +0 -391
  153. package/scripts/detection-benchmark.mjs +0 -127
  154. package/scripts/docs-quality-drift-report.mjs +0 -358
  155. package/scripts/documentation-boundary-audit.mjs +0 -305
  156. package/scripts/explain-on-demand-audit.mjs +0 -427
  157. package/scripts/forbidden-content-check.mjs +0 -123
  158. package/scripts/frontend-usability-audit.mjs +0 -243
  159. package/scripts/generate-sbom.mjs +0 -61
  160. package/scripts/governance-weekly-report.mjs +0 -466
  161. package/scripts/llm-judge/checklist-loader.mjs +0 -45
  162. package/scripts/llm-judge/constants.mjs +0 -66
  163. package/scripts/llm-judge/diff-collection.mjs +0 -74
  164. package/scripts/llm-judge/prompting.mjs +0 -78
  165. package/scripts/llm-judge/providers.mjs +0 -111
  166. package/scripts/llm-judge/verdict.mjs +0 -134
  167. package/scripts/llm-judge.mjs +0 -200
  168. package/scripts/memory-continuity-benchmark.mjs +0 -322
  169. package/scripts/quality-trend-report.mjs +0 -289
  170. package/scripts/release-gate/audit-checks.mjs +0 -441
  171. package/scripts/release-gate/constants.mjs +0 -53
  172. package/scripts/release-gate/runtime.mjs +0 -63
  173. package/scripts/release-gate/static-checks.mjs +0 -182
  174. package/scripts/release-gate.mjs +0 -42
  175. package/scripts/rules-guardian-audit.mjs +0 -580
  176. package/scripts/single-source-lazy-loading-audit.mjs +0 -449
  177. package/scripts/sync-thin-adapters.mjs +0 -72
  178. package/scripts/token-optimization-benchmark.mjs +0 -252
  179. package/scripts/ui-design-judge/constants.mjs +0 -13
  180. package/scripts/ui-design-judge/design-execution-summary.mjs +0 -81
  181. package/scripts/ui-design-judge/git-input.mjs +0 -134
  182. package/scripts/ui-design-judge/prompting.mjs +0 -52
  183. package/scripts/ui-design-judge/providers.mjs +0 -102
  184. package/scripts/ui-design-judge/reporting.mjs +0 -183
  185. package/scripts/ui-design-judge/rubric-calibration.mjs +0 -214
  186. package/scripts/ui-design-judge/rubric-goldset.json +0 -188
  187. package/scripts/ui-design-judge.mjs +0 -319
  188. package/scripts/ui-rubric-calibration.mjs +0 -35
  189. package/scripts/validate/audits/cache-layer-contract.mjs +0 -230
  190. package/scripts/validate/audits/caching-scope-hygiene.mjs +0 -235
  191. package/scripts/validate/audits/file-size.mjs +0 -158
  192. package/scripts/validate/audits/reflection-citations.mjs +0 -130
  193. package/scripts/validate/audits/release-bundle.mjs +0 -135
  194. package/scripts/validate/audits/rule-id-uniqueness.mjs +0 -278
  195. package/scripts/validate/config.mjs +0 -501
  196. package/scripts/validate/coverage-checks.mjs +0 -446
  197. package/scripts/validate/file-structure.mjs +0 -158
  198. package/scripts/validate/markdown-content.mjs +0 -109
  199. package/scripts/validate/project-metadata.mjs +0 -166
  200. package/scripts/validate/utils.mjs +0 -52
  201. package/scripts/validate.mjs +0 -267
@@ -1,76 +0,0 @@
1
- /**
2
- * Launch Command — Numbered interactive launcher.
3
- * Depends on: constants, utils, init command
4
- */
5
- import { createInterface } from 'node:readline/promises';
6
- import { stdin, stdout } from 'node:process';
7
-
8
- import { CLI_VERSION, INIT_PRESETS } from '../constants.mjs';
9
- import { askChoice, normalizeChoiceInput } from '../utils.mjs';
10
- import { runInitCommand } from './init.mjs';
11
- import { runOptimizeCommand } from './optimize.mjs';
12
-
13
- export async function runLaunchCommand() {
14
- const userInterface = createInterface({ input: stdin, output: stdout });
15
-
16
- try {
17
- console.log(`\nAgentic-Senior-Core CLI v${CLI_VERSION}`);
18
- console.log('Start with a numbered choice. You can still use commands later if you want direct control.');
19
-
20
- const launchChoice = await askChoice(
21
- 'How do you want to start?',
22
- [
23
- 'npm / npx path',
24
- 'Scope hint preset',
25
- 'Interactive init wizard',
26
- 'Enable token optimization',
27
- 'Exit',
28
- ],
29
- userInterface
30
- );
31
-
32
- if (launchChoice === 'npm / npx path') {
33
- console.log('\nChoose one of these package paths:');
34
- console.log('npm exec --yes @ryuenn3123/agentic-senior-core init');
35
- console.log('npx @ryuenn3123/agentic-senior-core init');
36
- console.log('npm install -g @ryuenn3123/agentic-senior-core && agentic-senior-core init');
37
- return;
38
- }
39
-
40
- if (launchChoice === 'Scope hint preset') {
41
- const presetNames = Object.keys(INIT_PRESETS);
42
- const selectedPresetName = await askChoice(
43
- 'Choose a scope hint preset:',
44
- presetNames.map((presetName) => `${presetName} - ${INIT_PRESETS[presetName].description}`),
45
- userInterface
46
- );
47
-
48
- await runInitCommand('.', { preset: normalizeChoiceInput(selectedPresetName.split(' - ')[0]) });
49
- return;
50
- }
51
-
52
- if (launchChoice === 'Interactive init wizard') {
53
- await runInitCommand('.', {});
54
- return;
55
- }
56
-
57
- if (launchChoice === 'Enable token optimization') {
58
- const selectedAgent = await askChoice(
59
- 'Choose your primary agent integration:',
60
- ['copilot', 'claude', 'cursor', 'windsurf', 'gemini', 'codex', 'cline'],
61
- userInterface
62
- );
63
-
64
- await runOptimizeCommand('.', {
65
- targetDirectory: '.',
66
- agent: selectedAgent,
67
- enabled: true,
68
- });
69
- return;
70
- }
71
-
72
- console.log('Exit selected.');
73
- } finally {
74
- userInterface.close();
75
- }
76
- }
@@ -1,284 +0,0 @@
1
- import fs from 'node:fs/promises';
2
- import path from 'node:path';
3
-
4
- import { ensureDirectory, formatDuration } from '../utils.mjs';
5
- import { loadOnboardingReportIfExists } from '../compiler.mjs';
6
- import {
7
- TOKEN_OPTIMIZATION_REPORT_FILE_NAME,
8
- normalizeAgentName,
9
- detectRtkBinary,
10
- detectAscxRuntime,
11
- checkAscxTeeReadiness,
12
- resolveRuntimeTokenSaverMode,
13
- buildRuntimeTokenSaverWarnings,
14
- buildRuntimeTokenSaverNextAction,
15
- buildRtkInstallHint,
16
- buildRtkHookCommand,
17
- createTokenOptimizationState,
18
- readTokenOptimizationState,
19
- writeTokenOptimizationState,
20
- } from '../token-optimization.mjs';
21
-
22
- export function parseOptimizeArguments(commandArguments) {
23
- const parsedOptimizeOptions = {
24
- targetDirectory: '.',
25
- agent: 'copilot',
26
- enabled: true,
27
- mode: 'configure',
28
- show: false,
29
- };
30
-
31
- function setOptimizeMode(nextMode) {
32
- if (parsedOptimizeOptions.mode !== 'configure' && parsedOptimizeOptions.mode !== nextMode) {
33
- throw new Error(`Conflicting optimize modes: ${parsedOptimizeOptions.mode} and ${nextMode}`);
34
- }
35
-
36
- parsedOptimizeOptions.mode = nextMode;
37
- }
38
-
39
- for (let argumentIndex = 0; argumentIndex < commandArguments.length; argumentIndex++) {
40
- const currentArgument = commandArguments[argumentIndex];
41
-
42
- if (currentArgument === 'install') {
43
- setOptimizeMode('install');
44
- parsedOptimizeOptions.enabled = true;
45
- continue;
46
- }
47
-
48
- if (currentArgument === 'off') {
49
- setOptimizeMode('off');
50
- parsedOptimizeOptions.enabled = false;
51
- continue;
52
- }
53
-
54
- if (currentArgument === 'status') {
55
- setOptimizeMode('status');
56
- continue;
57
- }
58
-
59
- if (currentArgument === 'doctor') {
60
- setOptimizeMode('doctor');
61
- continue;
62
- }
63
-
64
- if (!currentArgument.startsWith('--')) {
65
- parsedOptimizeOptions.targetDirectory = currentArgument;
66
- continue;
67
- }
68
-
69
- if (currentArgument === '--agent') {
70
- parsedOptimizeOptions.agent = commandArguments[argumentIndex + 1] || 'copilot';
71
- argumentIndex += 1;
72
- continue;
73
- }
74
-
75
- if (currentArgument.startsWith('--agent=')) {
76
- parsedOptimizeOptions.agent = currentArgument.split('=')[1] || 'copilot';
77
- continue;
78
- }
79
-
80
- if (currentArgument === '--enable') {
81
- parsedOptimizeOptions.enabled = true;
82
- if (parsedOptimizeOptions.mode === 'off') {
83
- setOptimizeMode('install');
84
- }
85
- continue;
86
- }
87
-
88
- if (currentArgument === '--disable') {
89
- parsedOptimizeOptions.enabled = false;
90
- if (parsedOptimizeOptions.mode === 'install') {
91
- setOptimizeMode('off');
92
- }
93
- continue;
94
- }
95
-
96
- if (currentArgument === '--show') {
97
- setOptimizeMode('show');
98
- parsedOptimizeOptions.show = true;
99
- continue;
100
- }
101
-
102
- if (currentArgument === '--status') {
103
- setOptimizeMode('status');
104
- continue;
105
- }
106
-
107
- if (currentArgument === '--doctor') {
108
- setOptimizeMode('doctor');
109
- continue;
110
- }
111
-
112
- throw new Error(`Unknown option: ${currentArgument}`);
113
- }
114
-
115
- parsedOptimizeOptions.agent = normalizeAgentName(parsedOptimizeOptions.agent);
116
- return parsedOptimizeOptions;
117
- }
118
-
119
- function formatStatusLine(label, value) {
120
- return `${label}: ${value}`;
121
- }
122
-
123
- async function buildRuntimeTokenSaverStatus(resolvedTargetDirectoryPath, options = {}) {
124
- const onboardingReport = await loadOnboardingReportIfExists(resolvedTargetDirectoryPath);
125
- const existingOptimizationState = await readTokenOptimizationState(resolvedTargetDirectoryPath);
126
- const ascxDetection = detectAscxRuntime();
127
- const rtkDetection = detectRtkBinary();
128
- const teeReadiness = await checkAscxTeeReadiness(resolvedTargetDirectoryPath, {
129
- writeProbe: options.writeProbe === true,
130
- });
131
- const mode = resolveRuntimeTokenSaverMode({
132
- tokenOptimizationState: existingOptimizationState,
133
- ascxDetection,
134
- rtkDetection,
135
- });
136
- const warnings = buildRuntimeTokenSaverWarnings({
137
- mode,
138
- onboardingReport,
139
- ascxDetection,
140
- teeReadiness,
141
- rtkDetection,
142
- });
143
-
144
- return {
145
- targetDirectory: resolvedTargetDirectoryPath,
146
- initialized: Boolean(onboardingReport),
147
- mode,
148
- ascx: ascxDetection,
149
- tee: teeReadiness,
150
- rtk: rtkDetection,
151
- nineRouter: {
152
- status: 'not-checked',
153
- reason: 'localhost probing is intentionally deferred',
154
- },
155
- warnings,
156
- nextAction: buildRuntimeTokenSaverNextAction({ mode, warnings }),
157
- tokenOptimizationState: existingOptimizationState,
158
- };
159
- }
160
-
161
- function printRuntimeTokenSaverStatus(statusReport, options = {}) {
162
- const title = options.title || 'Runtime token saver status';
163
- const ascxStatus = statusReport.ascx.isAvailable
164
- ? `found (${statusReport.ascx.source})`
165
- : 'missing';
166
- const rtkStatus = statusReport.rtk.isAvailable
167
- ? `detected${statusReport.rtk.version ? ` (${statusReport.rtk.version})` : ''}`
168
- : 'not-detected';
169
-
170
- console.log(title);
171
- console.log(formatStatusLine('target', statusReport.targetDirectory));
172
- console.log(formatStatusLine('initialized', statusReport.initialized ? 'yes' : 'no'));
173
- console.log(formatStatusLine('mode', statusReport.mode));
174
- console.log(formatStatusLine('ascx', ascxStatus));
175
- console.log(formatStatusLine('tee', `${statusReport.tee.status} (${statusReport.tee.path})`));
176
- console.log(formatStatusLine('rtk', rtkStatus));
177
- console.log(formatStatusLine('9router', statusReport.nineRouter.status));
178
-
179
- if (statusReport.warnings.length > 0) {
180
- console.log('warnings:');
181
- for (const warning of statusReport.warnings) {
182
- console.log(`- ${warning}`);
183
- }
184
- } else {
185
- console.log('warnings: none');
186
- }
187
-
188
- console.log(formatStatusLine('next_action', statusReport.nextAction));
189
- }
190
-
191
- export async function runOptimizeCommand(targetDirectoryArgument, optimizeOptions = {}) {
192
- const optimizationStartedAt = Date.now();
193
- const resolvedTargetDirectoryPath = path.resolve(targetDirectoryArgument || '.');
194
-
195
- await ensureDirectory(resolvedTargetDirectoryPath);
196
-
197
- const selectedAgentName = normalizeAgentName(optimizeOptions.agent || 'copilot');
198
- const rtkDetection = detectRtkBinary();
199
-
200
- if (optimizeOptions.mode === 'status') {
201
- const statusReport = await buildRuntimeTokenSaverStatus(resolvedTargetDirectoryPath);
202
- printRuntimeTokenSaverStatus(statusReport);
203
- return;
204
- }
205
-
206
- if (optimizeOptions.mode === 'doctor') {
207
- const statusReport = await buildRuntimeTokenSaverStatus(resolvedTargetDirectoryPath, {
208
- writeProbe: true,
209
- });
210
- printRuntimeTokenSaverStatus(statusReport, {
211
- title: 'ASCX runtime token saver doctor',
212
- });
213
- return;
214
- }
215
-
216
- if (optimizeOptions.show || optimizeOptions.mode === 'show') {
217
- const existingOptimizationState = await readTokenOptimizationState(resolvedTargetDirectoryPath);
218
- console.log(
219
- JSON.stringify(
220
- {
221
- targetDirectory: resolvedTargetDirectoryPath,
222
- selectedAgent: selectedAgentName,
223
- externalProxy: rtkDetection,
224
- tokenOptimizationState: existingOptimizationState,
225
- },
226
- null,
227
- 2
228
- )
229
- );
230
- return;
231
- }
232
-
233
- const onboardingReport = await loadOnboardingReportIfExists(resolvedTargetDirectoryPath);
234
- if (!onboardingReport) {
235
- throw new Error(
236
- 'Token optimization requires an initialized repository. Run "agentic-senior-core init" first.'
237
- );
238
- }
239
-
240
- const tokenOptimizationState = createTokenOptimizationState({
241
- isEnabled: optimizeOptions.mode === 'off' ? false : optimizeOptions.enabled,
242
- selectedAgentName,
243
- rtkDetection,
244
- });
245
-
246
- await writeTokenOptimizationState(resolvedTargetDirectoryPath, tokenOptimizationState);
247
-
248
- const optimizationDurationMs = Date.now() - optimizationStartedAt;
249
- const tokenOptimizationReport = {
250
- generatedAt: new Date().toISOString(),
251
- targetDirectory: resolvedTargetDirectoryPath,
252
- enabled: tokenOptimizationState.enabled,
253
- selectedAgent: tokenOptimizationState.selectedAgent,
254
- preferredShellProxy: tokenOptimizationState.preferredShellProxy,
255
- externalProxy: tokenOptimizationState.externalProxy,
256
- setupDurationMs: optimizationDurationMs,
257
- };
258
-
259
- const reportFilePath = path.join(
260
- resolvedTargetDirectoryPath,
261
- '.agent-context',
262
- 'state',
263
- TOKEN_OPTIMIZATION_REPORT_FILE_NAME
264
- );
265
- await fs.writeFile(reportFilePath, JSON.stringify(tokenOptimizationReport, null, 2) + '\n', 'utf8');
266
-
267
- console.log(`\nToken optimization ${tokenOptimizationState.enabled ? 'enabled' : 'disabled'}.`);
268
- console.log(`- Target directory: ${resolvedTargetDirectoryPath}`);
269
- console.log(`- Agent profile: ${tokenOptimizationState.selectedAgent}`);
270
- console.log(`- Preferred shell proxy: ${tokenOptimizationState.preferredShellProxy}`);
271
- console.log(`- Setup time: ${formatDuration(optimizationDurationMs)}`);
272
- console.log('- Updated files: .agent-context/state/token-optimization.json and .agent-context/state/token-optimization-report.json');
273
-
274
- if (tokenOptimizationState.enabled) {
275
- if (rtkDetection.isAvailable) {
276
- console.log(`- External proxy detected: ${rtkDetection.version ? `v${rtkDetection.version}` : 'yes'}`);
277
- console.log('- Recommended hook command:');
278
- console.log(` ${buildRtkHookCommand(tokenOptimizationState.selectedAgent)}`);
279
- } else {
280
- console.log('- External proxy not detected. Native fallback mode has been activated.');
281
- console.log(`- Install hint: ${buildRtkInstallHint()}`);
282
- }
283
- }
284
- }
@@ -1,64 +0,0 @@
1
- import path from 'node:path';
2
- import { performRollback } from '../rollback.mjs';
3
- import { ensureDirectory } from '../utils.mjs';
4
-
5
- /**
6
- * Command module for `rollback`
7
- */
8
- export async function runRollbackCommand(commandArguments) {
9
- // Parse simple argument <targetDir>
10
- const targetDirectoryArgument = commandArguments.length > 0 ? commandArguments[0] : null;
11
-
12
- if (!targetDirectoryArgument) {
13
- console.error('Usage: agentic-senior-core rollback <target-directory>');
14
- process.exit(1);
15
- }
16
-
17
- const resolvedTargetDirectoryPath = path.resolve(targetDirectoryArgument);
18
-
19
- if (resolvedTargetDirectoryPath.toLowerCase() === 'c:\\windows' || resolvedTargetDirectoryPath.toLowerCase() === 'c:\\windows\\system32') {
20
- console.error('\n[FATAL] Target directory resolved to a Windows system folder (C:\\Windows).');
21
- console.error('If you are running Windows npm from inside WSL, this is caused by cmd.exe lacking UNC path support.');
22
- console.error('Please install and use a native Linux Node.js/npm directly inside WSL to setup your project.');
23
- process.exit(1);
24
- }
25
-
26
- try {
27
- await ensureDirectory(resolvedTargetDirectoryPath);
28
- } catch {
29
- console.error(`[FATAL] Cannot access target directory: ${resolvedTargetDirectoryPath}`);
30
- process.exit(1);
31
- }
32
-
33
- console.log(`Starting manual rollback for directory: ${resolvedTargetDirectoryPath} ...\n`);
34
-
35
- try {
36
- const report = await performRollback(resolvedTargetDirectoryPath);
37
-
38
- if (report.success) {
39
- console.log('[OK] Rollback successful.\n');
40
- } else {
41
- console.error('[WARN] Rollback completed with errors.\n');
42
- }
43
-
44
- console.log('Restored files:');
45
- if (report.restoredFiles.length === 0) console.log(' (none)');
46
- report.restoredFiles.forEach(f => console.log(` + ${f}`));
47
-
48
- console.log('\nDeleted (new) files:');
49
- if (report.deletedFiles.length === 0) console.log(' (none)');
50
- report.deletedFiles.forEach(f => console.log(` - ${f}`));
51
-
52
- if (report.errors.length > 0) {
53
- console.error('\nErrors encountered:');
54
- report.errors.forEach(e => console.error(` ! ${e}`));
55
- }
56
-
57
- const exitCode = report.success ? 0 : 1;
58
- process.exit(exitCode);
59
- } catch (error) {
60
- console.error('\n[FATAL] Rollback operation failed:');
61
- console.error(error.message);
62
- process.exit(1);
63
- }
64
- }
@@ -1,51 +0,0 @@
1
- import {
2
- createTokenOptimizationState,
3
- detectRtkBinary,
4
- normalizeAgentName,
5
- readTokenOptimizationState,
6
- writeTokenOptimizationState,
7
- } from '../../token-optimization.mjs';
8
-
9
- export async function resolveUpgradeTokenOptimizationPlan(targetDirectoryPath, existingOnboardingReport) {
10
- const existingState = await readTokenOptimizationState(targetDirectoryPath);
11
- const optedOut = existingOnboardingReport?.tokenOptimization?.enabled === false;
12
- const selectedAgentName = normalizeAgentName(
13
- existingOnboardingReport?.tokenOptimization?.selectedAgent || 'copilot'
14
- );
15
-
16
- return {
17
- existingState,
18
- optedOut,
19
- selectedAgentName,
20
- shouldSeed: !existingState && !optedOut,
21
- previewLabel: optedOut
22
- ? 'disabled (preserved opt-out)'
23
- : existingState
24
- ? 'enabled'
25
- : 'enabled (will seed missing ASCX state)',
26
- reportState: existingState
27
- || (optedOut ? existingOnboardingReport?.tokenOptimization || { enabled: false } : null),
28
- };
29
- }
30
-
31
- export async function applyUpgradeTokenOptimizationPlan(targetDirectoryPath, plan) {
32
- if (!plan.shouldSeed) {
33
- return {
34
- createdFileName: null,
35
- reportState: plan.reportState,
36
- };
37
- }
38
-
39
- const tokenOptimizationState = createTokenOptimizationState({
40
- isEnabled: true,
41
- selectedAgentName: plan.selectedAgentName,
42
- rtkDetection: detectRtkBinary(),
43
- });
44
-
45
- await writeTokenOptimizationState(targetDirectoryPath, tokenOptimizationState);
46
-
47
- return {
48
- createdFileName: '.agent-context/state/token-optimization.json',
49
- reportState: tokenOptimizationState,
50
- };
51
- }