@ryuenn3123/agentic-senior-core 4.3.15 → 5.1.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 (198) hide show
  1. package/.agents/plugins/marketplace.json +21 -0
  2. package/.agents/rules/agentic-senior-core.md +126 -0
  3. package/.claude-plugin/marketplace.json +17 -0
  4. package/.claude-plugin/plugin.json +17 -0
  5. package/.clinerules/agentic-senior-core.md +94 -0
  6. package/.codex-plugin/plugin.json +24 -0
  7. package/.cursor/rules/agentic-senior-core.mdc +99 -0
  8. package/.devin-plugin/plugin.json +13 -0
  9. package/.github/copilot-instructions.md +94 -0
  10. package/.github/plugin/marketplace.json +20 -0
  11. package/.github/plugin/plugin.json +16 -0
  12. package/.kiro/steering/agentic-senior-core.md +94 -0
  13. package/.openclaw/skills/asc/SKILL.md +23 -0
  14. package/.openclaw/skills/asc-audit/SKILL.md +28 -0
  15. package/.openclaw/skills/asc-review/SKILL.md +54 -0
  16. package/.opencode/plugins/agentic-senior-core.mjs +31 -0
  17. package/.windsurf/rules/agentic-senior-core.md +94 -0
  18. package/AGENTS.md +126 -179
  19. package/CONTRIBUTING.md +93 -63
  20. package/README.md +160 -111
  21. package/__init__.py +61 -0
  22. package/bin/agentic-senior-core.js +41 -43
  23. package/commands/asc-audit.md +1 -0
  24. package/commands/asc-audit.toml +2 -0
  25. package/commands/asc-help.md +9 -0
  26. package/commands/asc-help.toml +2 -0
  27. package/commands/asc-refactor.md +1 -0
  28. package/commands/asc-refactor.toml +2 -0
  29. package/commands/asc-review.md +1 -0
  30. package/commands/asc-review.toml +2 -0
  31. package/gemini-extension.json +10 -0
  32. package/hooks/copilot-hooks.json +21 -0
  33. package/hooks/hooks.json +31 -0
  34. package/hooks/session-start.js +36 -0
  35. package/hooks/subagent-start.js +38 -0
  36. package/lib/cli/commands/adapter.mjs +109 -0
  37. package/lib/cli/commands/clean.mjs +63 -0
  38. package/lib/cli/commands/status.mjs +94 -0
  39. package/package.json +43 -67
  40. package/plugin.yaml +16 -0
  41. package/scripts/uninstall.js +38 -0
  42. package/skills/asc/SKILL.md +16 -0
  43. package/skills/asc-audit/SKILL.md +28 -0
  44. package/skills/asc-refactor/SKILL.md +35 -0
  45. package/skills/asc-review/SKILL.md +54 -0
  46. package/.agent-context/policies/llm-judge-threshold.json +0 -29
  47. package/.agent-context/prompts/bootstrap-design.md +0 -63
  48. package/.agent-context/prompts/compact-natural-mode.md +0 -100
  49. package/.agent-context/prompts/init-project.md +0 -60
  50. package/.agent-context/prompts/refactor.md +0 -38
  51. package/.agent-context/prompts/review-code.md +0 -31
  52. package/.agent-context/review-checklists/architecture-review.md +0 -57
  53. package/.agent-context/review-checklists/pr-checklist.md +0 -136
  54. package/.agent-context/rules/api-docs.md +0 -24
  55. package/.agent-context/rules/api-versioning.md +0 -16
  56. package/.agent-context/rules/architecture.md +0 -33
  57. package/.agent-context/rules/background-jobs.md +0 -17
  58. package/.agent-context/rules/config-and-flags.md +0 -16
  59. package/.agent-context/rules/database-design.md +0 -18
  60. package/.agent-context/rules/docker-runtime.md +0 -17
  61. package/.agent-context/rules/error-handling.md +0 -16
  62. package/.agent-context/rules/event-driven.md +0 -16
  63. package/.agent-context/rules/frontend-architecture.md +0 -54
  64. package/.agent-context/rules/microservices.md +0 -16
  65. package/.agent-context/rules/migrations.md +0 -16
  66. package/.agent-context/rules/observability.md +0 -16
  67. package/.agent-context/rules/performance.md +0 -16
  68. package/.agent-context/rules/realtime.md +0 -16
  69. package/.agent-context/rules/resilience.md +0 -18
  70. package/.agent-context/rules/security.md +0 -18
  71. package/.agent-context/rules/testing.md +0 -16
  72. package/.agent-context/state/README.md +0 -25
  73. package/.agent-context/state/architecture-map.md +0 -40
  74. package/.agent-context/state/benchmark-comparison-schema.json +0 -181
  75. package/.agent-context/state/benchmark-reproducibility.json +0 -87
  76. package/.agent-context/state/benchmark-thresholds.json +0 -10
  77. package/.agent-context/state/benchmark-writer-judge-config.json +0 -58
  78. package/.agent-context/state/dependency-map.md +0 -41
  79. package/.agent-context/state/memory-adapter-contract.json +0 -52
  80. package/.agent-context/state/memory-schema-v1.json +0 -88
  81. package/GEMINI.md +0 -1
  82. package/benchmarks/README.md +0 -60
  83. package/benchmarks/compact-natural-mode/fixtures.mjs +0 -359
  84. package/benchmarks/compact-natural-mode/scorer.mjs +0 -331
  85. package/benchmarks/runtime-token-saver/fixtures.mjs +0 -836
  86. package/lib/cli/adaptive-context/catalog.mjs +0 -390
  87. package/lib/cli/adaptive-context/file-signals.mjs +0 -100
  88. package/lib/cli/adaptive-context/implications.mjs +0 -44
  89. package/lib/cli/adaptive-context.mjs +0 -365
  90. package/lib/cli/audits/typography-palette-anti-repeat/color-utils.mjs +0 -156
  91. package/lib/cli/audits/typography-palette-anti-repeat/file-scanner.mjs +0 -103
  92. package/lib/cli/audits/typography-palette-anti-repeat/typography-utils.mjs +0 -70
  93. package/lib/cli/audits/typography-palette-anti-repeat-audit.mjs +0 -239
  94. package/lib/cli/backup.mjs +0 -210
  95. package/lib/cli/commands/audit-design-anti-repeat.mjs +0 -39
  96. package/lib/cli/commands/context.mjs +0 -140
  97. package/lib/cli/commands/init/project-context.mjs +0 -60
  98. package/lib/cli/commands/init/runtime-environment.mjs +0 -59
  99. package/lib/cli/commands/init/setup-decisions.mjs +0 -83
  100. package/lib/cli/commands/init.mjs +0 -654
  101. package/lib/cli/commands/launch.mjs +0 -76
  102. package/lib/cli/commands/optimize.mjs +0 -284
  103. package/lib/cli/commands/rollback.mjs +0 -64
  104. package/lib/cli/commands/upgrade/token-optimization-state.mjs +0 -51
  105. package/lib/cli/commands/upgrade.mjs +0 -451
  106. package/lib/cli/compiler.mjs +0 -570
  107. package/lib/cli/constants.mjs +0 -136
  108. package/lib/cli/detector/constants.mjs +0 -135
  109. package/lib/cli/detector/design-evidence/collector.mjs +0 -256
  110. package/lib/cli/detector/design-evidence/constants.mjs +0 -39
  111. package/lib/cli/detector/design-evidence/file-traversal.mjs +0 -83
  112. package/lib/cli/detector/design-evidence/structured-attribute-evidence.mjs +0 -117
  113. package/lib/cli/detector/design-evidence/summary.mjs +0 -109
  114. package/lib/cli/detector/design-evidence/utility-helpers.mjs +0 -122
  115. package/lib/cli/detector/design-evidence.mjs +0 -25
  116. package/lib/cli/detector/stack-detection.mjs +0 -243
  117. package/lib/cli/detector/ui-signals.mjs +0 -150
  118. package/lib/cli/detector/workspace-scan.mjs +0 -177
  119. package/lib/cli/detector.mjs +0 -23
  120. package/lib/cli/init-detection-flow.mjs +0 -48
  121. package/lib/cli/init-options.mjs +0 -237
  122. package/lib/cli/init-selection.mjs +0 -29
  123. package/lib/cli/memory-continuity.mjs +0 -537
  124. package/lib/cli/preflight.mjs +0 -76
  125. package/lib/cli/project-scaffolder/constants.mjs +0 -69
  126. package/lib/cli/project-scaffolder/discovery.mjs +0 -272
  127. package/lib/cli/project-scaffolder/prompt-builders.mjs +0 -171
  128. package/lib/cli/project-scaffolder/storage.mjs +0 -144
  129. package/lib/cli/project-scaffolder/ui-scope-detection.mjs +0 -36
  130. package/lib/cli/project-scaffolder.mjs +0 -29
  131. package/lib/cli/rollback.mjs +0 -66
  132. package/lib/cli/token-optimization.mjs +0 -486
  133. package/lib/cli/utils/filesystem.mjs +0 -81
  134. package/lib/cli/utils/managed-surface.mjs +0 -280
  135. package/lib/cli/utils/prompting.mjs +0 -44
  136. package/lib/cli/utils.mjs +0 -479
  137. package/mcp.json +0 -134
  138. package/scripts/adaptive-context/fixtures.mjs +0 -183
  139. package/scripts/adaptive-context-benchmark.mjs +0 -9
  140. package/scripts/ascx-runtime-token-saver-benchmark.mjs +0 -9
  141. package/scripts/audit-cache-layer-contract.mjs +0 -263
  142. package/scripts/audit-caching-scope-hygiene.mjs +0 -268
  143. package/scripts/audit-file-size.mjs +0 -219
  144. package/scripts/audit-reflection-citations.mjs +0 -163
  145. package/scripts/audit-release-bundle.mjs +0 -170
  146. package/scripts/audit-rule-id-uniqueness.mjs +0 -313
  147. package/scripts/audit-typography-palette-anti-repeat.mjs +0 -120
  148. package/scripts/benchmark-evidence-bundle.mjs +0 -645
  149. package/scripts/benchmark-gate.mjs +0 -121
  150. package/scripts/benchmark-intelligence.mjs +0 -33
  151. package/scripts/benchmark-writer-judge-matrix.mjs +0 -379
  152. package/scripts/build-release-benchmark-bundle.mjs +0 -202
  153. package/scripts/bump-version.mjs +0 -103
  154. package/scripts/clean-local-artifacts.mjs +0 -78
  155. package/scripts/compact-natural-mode-benchmark.mjs +0 -9
  156. package/scripts/context-triggered-audit.mjs +0 -391
  157. package/scripts/detection-benchmark.mjs +0 -127
  158. package/scripts/docs-quality-drift-report.mjs +0 -358
  159. package/scripts/documentation-boundary-audit.mjs +0 -305
  160. package/scripts/explain-on-demand-audit.mjs +0 -427
  161. package/scripts/forbidden-content-check.mjs +0 -123
  162. package/scripts/frontend-usability-audit.mjs +0 -243
  163. package/scripts/generate-sbom.mjs +0 -61
  164. package/scripts/governance-weekly-report.mjs +0 -466
  165. package/scripts/llm-judge/checklist-loader.mjs +0 -45
  166. package/scripts/llm-judge/constants.mjs +0 -66
  167. package/scripts/llm-judge/diff-collection.mjs +0 -74
  168. package/scripts/llm-judge/prompting.mjs +0 -78
  169. package/scripts/llm-judge/providers.mjs +0 -111
  170. package/scripts/llm-judge/verdict.mjs +0 -134
  171. package/scripts/llm-judge.mjs +0 -200
  172. package/scripts/memory-continuity-benchmark.mjs +0 -322
  173. package/scripts/quality-trend-report.mjs +0 -289
  174. package/scripts/release-gate/audit-checks.mjs +0 -441
  175. package/scripts/release-gate/constants.mjs +0 -53
  176. package/scripts/release-gate/runtime.mjs +0 -63
  177. package/scripts/release-gate/static-checks.mjs +0 -182
  178. package/scripts/release-gate.mjs +0 -42
  179. package/scripts/rules-guardian-audit.mjs +0 -580
  180. package/scripts/single-source-lazy-loading-audit.mjs +0 -449
  181. package/scripts/sync-thin-adapters.mjs +0 -72
  182. package/scripts/token-optimization-benchmark.mjs +0 -252
  183. package/scripts/ui-design-judge/constants.mjs +0 -13
  184. package/scripts/ui-design-judge/design-execution-summary.mjs +0 -81
  185. package/scripts/ui-design-judge/git-input.mjs +0 -134
  186. package/scripts/ui-design-judge/prompting.mjs +0 -52
  187. package/scripts/ui-design-judge/providers.mjs +0 -102
  188. package/scripts/ui-design-judge/reporting.mjs +0 -183
  189. package/scripts/ui-design-judge/rubric-calibration.mjs +0 -214
  190. package/scripts/ui-design-judge/rubric-goldset.json +0 -188
  191. package/scripts/ui-design-judge.mjs +0 -319
  192. package/scripts/ui-rubric-calibration.mjs +0 -35
  193. package/scripts/validate/config.mjs +0 -519
  194. package/scripts/validate/coverage-checks.mjs +0 -446
  195. package/scripts/validate/file-structure.mjs +0 -162
  196. package/scripts/validate/markdown-content.mjs +0 -109
  197. package/scripts/validate/project-metadata.mjs +0 -166
  198. package/scripts/validate.mjs +0 -338
package/lib/cli/utils.mjs DELETED
@@ -1,479 +0,0 @@
1
- /**
2
- * CLI Utilities — Shared helper functions.
3
- * Depends on: constants.mjs
4
- */
5
- import fs from 'node:fs/promises';
6
- import path from 'node:path';
7
- import os from 'node:os';
8
-
9
- import {
10
- REPOSITORY_ROOT,
11
- ALLOWED_SEVERITY_LEVELS,
12
- PROFILE_PRESETS,
13
- INIT_PRESETS,
14
- entryPointFiles,
15
- directoryCopies,
16
- } from './constants.mjs';
17
- import {
18
- pathExists,
19
- ensureDirectory,
20
- syncFile,
21
- } from './utils/filesystem.mjs';
22
- import {
23
- collectRelativeTreeEntries,
24
- analyzeManagedGovernanceSurface,
25
- legacyManagedInstructionDirectories,
26
- } from './utils/managed-surface.mjs';
27
- export {
28
- pathExists,
29
- ensureDirectory,
30
- copyDirectory,
31
- isAgenticManagedContent,
32
- syncFile,
33
- } from './utils/filesystem.mjs';
34
- export {
35
- analyzeManagedGovernanceSurface,
36
- legacyManagedInstructionDirectories,
37
- } from './utils/managed-surface.mjs';
38
- export {
39
- askChoice,
40
- askYesNo,
41
- } from './utils/prompting.mjs';
42
-
43
- export function printUsage() {
44
- const presetNames = Object.keys(INIT_PRESETS).join(', ');
45
-
46
- console.log('Agentic-Senior-Core CLI');
47
- console.log('');
48
- console.log('Local runtime:');
49
- console.log(' npm exec --yes @ryuenn3123/agentic-senior-core init');
50
- console.log(' npx @ryuenn3123/agentic-senior-core init');
51
- console.log(' npm install -g @ryuenn3123/agentic-senior-core && agentic-senior-core init');
52
- console.log(' bunx @ryuenn3123/agentic-senior-core init # optional Bun path');
53
- console.log('');
54
- console.log('Usage:');
55
- console.log(' agentic-senior-core launch');
56
- console.log(' agentic-senior-core init [target-directory] [--preset <name>] [--stack <name>] [--blueprint <name>] [--project-description <text>] [--ci <true|false>] [--token-optimize] [--no-token-optimize] [--token-agent <name>] [--memory-continuity] [--no-memory-continuity] [--scaffold-docs] [--no-scaffold-docs] [--docs-lang <en|id>] [--project-config <path>] [--runtime-env <auto|linux-wsl|linux|windows|macos>]');
57
- console.log(' agentic-senior-core upgrade [target-directory] [--dry-run] [--yes] [--mcp-template] [--no-mcp-template] [--prune] [--no-prune]');
58
- console.log(' agentic-senior-core optimize [install|off|status|doctor] [target-directory] [--agent <copilot|claude|cursor|windsurf|gemini|codex|cline>] [--enable|--disable] [--show]');
59
- console.log(' asc optimize status [target-directory]');
60
- console.log(' asc optimize doctor [target-directory]');
61
- console.log(' agentic-senior-core context "<request>" [--json] [--request-id <id>] [--file <path>] [--files <paths>]');
62
- console.log(' ascx git status');
63
- console.log(' ascx git diff');
64
- console.log(' ascx npm test');
65
- console.log(' agentic-senior-core mcp');
66
- console.log(' agentic-senior-core rollback [target-directory]');
67
- console.log(' agentic-senior-core audit:design-anti-repeat [target-directory] [--json] [--palette-advisory] [--threshold <number>]');
68
- console.log(' agentic-senior-core --version');
69
- console.log('');
70
- console.log('Options:');
71
- console.log(' --help Show help');
72
- console.log(' --version Show CLI version');
73
- console.log(` --preset Use a scope hint preset; it does not choose stack/framework (${presetNames})`);
74
- console.log(' --stack Explicit runtime constraint from the user');
75
- console.log(' --blueprint Explicit architecture constraint from the user');
76
- console.log(' --project-description Project intent text used to build an offline architecture brief before agent-led live research');
77
- console.log(' --ci Override CI/CD quality checks (guardrails) (true|false)');
78
- console.log(' --token-optimize Explicitly enable token optimization policy during init (default behavior)');
79
- console.log(' --token-agent Set token optimization agent target (copilot, claude, cursor, windsurf, gemini, codex, cline)');
80
- console.log(' --no-token-optimize Disable token optimization policy during init');
81
- console.log(' --memory-continuity Explicitly enable cross-session memory continuity policy during init (default behavior)');
82
- console.log(' --no-memory-continuity Disable memory continuity policy during init');
83
- console.log(' --mcp-template Explicitly enable cross-IDE MCP auto-configuration (opt-in)');
84
- console.log(' --no-mcp-template Keep MCP configuration disabled (default behavior)');
85
- console.log(' --scaffold-docs Force project documentation scaffolding (architecture, database, API, flow)');
86
- console.log(' --no-scaffold-docs Skip project documentation scaffolding');
87
- console.log(' --docs-lang Optional override for bootstrap docs synthesis language (default: en)');
88
- console.log(' --project-config Path to a project config file for non-interactive doc scaffolding');
89
- console.log(' --runtime-env Override runtime environment hint (auto, linux-wsl, linux, windows, macos)');
90
- console.log(' --dry-run Preview upgrade without writing files');
91
- console.log(' --yes Skip confirmation prompts for upgrade');
92
- console.log(' --prune Keep managed governance files synchronized 1:1 (default in upgrade)');
93
- console.log(' --no-prune Do not remove stale managed governance files during upgrade');
94
- console.log(' --agent Target agent integration for token optimization mode');
95
- console.log(' --enable Enable token optimization policy state');
96
- console.log(' --disable Disable token optimization policy state');
97
- console.log(' --show Print current token optimization state as JSON');
98
- console.log(' status Show ASCX runtime token saver readiness');
99
- console.log(' doctor Diagnose ASCX runtime token saver readiness and tee write safety');
100
- console.log(' --json Print context manifest as JSON');
101
- console.log(' --stdin Read context request text from stdin');
102
- console.log(' --request-id Set the context manifest request id');
103
- console.log(' --file Add a context file path signal for adaptive rule selection');
104
- console.log(' --files Add comma-separated context file path signals');
105
- console.log(' ascx Execute a supported command with evidence-preserving output compression');
106
- }
107
-
108
- /**
109
- * Intelligent MCP configuration synchronization.
110
- * Merges the agentic-senior-core server into existing config or creates new.
111
- */
112
- async function syncMcpConfig(mcpJsonPath, templateConfig) {
113
- const topKey = Object.keys(templateConfig)[0]; // e.g. "mcpServers" or "servers"
114
- const serverName = 'agentic-senior-core';
115
- const templateServer = templateConfig[topKey][serverName];
116
-
117
- if (!(await pathExists(mcpJsonPath))) {
118
- await ensureDirectory(path.dirname(mcpJsonPath));
119
- await fs.writeFile(mcpJsonPath, JSON.stringify(templateConfig, null, 2) + '\n', 'utf8');
120
- return { status: 'created' };
121
- }
122
-
123
- try {
124
- const existingContent = await fs.readFile(mcpJsonPath, 'utf8');
125
- const config = JSON.parse(existingContent);
126
-
127
- if (!config[topKey]) config[topKey] = {};
128
-
129
- const existingServer = config[topKey][serverName];
130
-
131
- if (JSON.stringify(existingServer) === JSON.stringify(templateServer)) {
132
- return { status: 'unchanged' };
133
- }
134
-
135
- config[topKey][serverName] = templateServer;
136
- await fs.writeFile(mcpJsonPath, JSON.stringify(config, null, 2) + '\n', 'utf8');
137
- return { status: 'updated' };
138
- } catch {
139
- // If JSON is broken, overwrite it as a last resort to recovery
140
- await fs.writeFile(mcpJsonPath, JSON.stringify(templateConfig, null, 2) + '\n', 'utf8');
141
- return { status: 'updated' };
142
- }
143
- }
144
-
145
- async function pruneEmptyLegacyInstructionDirectories(resolvedTargetDirectoryPath) {
146
- for (const relativeDirectoryPath of legacyManagedInstructionDirectories) {
147
- const directoryPath = path.join(resolvedTargetDirectoryPath, ...relativeDirectoryPath.split('/'));
148
- try {
149
- await fs.rmdir(directoryPath);
150
- } catch {
151
- // Keep non-empty or missing directories. They may contain user-owned files.
152
- }
153
- }
154
- }
155
-
156
- export async function copyGovernanceAssetsToTarget(
157
- resolvedTargetDirectoryPath,
158
- options = {}
159
- ) {
160
- const shouldIncludeMcpTemplate = options.includeMcpTemplate === true;
161
- const shouldPruneManagedSurface = options.pruneManagedSurface === true;
162
- const managedSurfacePlan = shouldPruneManagedSurface
163
- ? options.managedSurfacePlan || await analyzeManagedGovernanceSurface(resolvedTargetDirectoryPath, {
164
- includeMcpTemplate: shouldIncludeMcpTemplate,
165
- })
166
- : null;
167
- const deletedManagedFiles = [];
168
- const deletedManagedDirectories = [];
169
- const createdFiles = [];
170
- const updatedFiles = [];
171
- const unchangedFiles = [];
172
- const preservedFiles = [];
173
-
174
- for (const sourceDirectoryName of directoryCopies) {
175
- const sourceDirectoryPath = path.join(REPOSITORY_ROOT, sourceDirectoryName);
176
- if (!(await pathExists(sourceDirectoryPath))) {
177
- continue;
178
- }
179
-
180
- const sourceTree = await collectRelativeTreeEntries(sourceDirectoryPath, sourceDirectoryName);
181
- for (const relativeFilePath of sourceTree.files) {
182
- const sourcePath = path.join(REPOSITORY_ROOT, ...relativeFilePath.split('/'));
183
- const targetPath = path.join(resolvedTargetDirectoryPath, ...relativeFilePath.split('/'));
184
- const syncResult = await syncFile(sourcePath, targetPath, {
185
- preserveUserOwned: sourceDirectoryName === '.gemini',
186
- });
187
-
188
- if (syncResult.status === 'created') createdFiles.push(relativeFilePath);
189
- else if (syncResult.status === 'updated') updatedFiles.push(relativeFilePath);
190
- else if (syncResult.status === 'unchanged') unchangedFiles.push(relativeFilePath);
191
- else if (syncResult.status === 'preserved') preservedFiles.push(relativeFilePath);
192
- }
193
- }
194
-
195
- for (const entryPointFileName of entryPointFiles) {
196
- const sourceFilePath = path.join(REPOSITORY_ROOT, entryPointFileName);
197
- const targetFilePath = path.join(resolvedTargetDirectoryPath, entryPointFileName);
198
-
199
- if (!(await pathExists(sourceFilePath))) {
200
- continue;
201
- }
202
-
203
- if (path.resolve(sourceFilePath) === path.resolve(targetFilePath)) {
204
- continue;
205
- }
206
-
207
- const syncResult = await syncFile(sourceFilePath, targetFilePath, {
208
- preserveUserOwned: true,
209
- });
210
- if (syncResult.status === 'created') createdFiles.push(entryPointFileName);
211
- else if (syncResult.status === 'updated') updatedFiles.push(entryPointFileName);
212
- else if (syncResult.status === 'unchanged') unchangedFiles.push(entryPointFileName);
213
- else if (syncResult.status === 'preserved') preservedFiles.push(entryPointFileName);
214
- }
215
-
216
- if (shouldPruneManagedSurface && managedSurfacePlan) {
217
- for (const staleFileRelativePath of managedSurfacePlan.staleFiles) {
218
- const staleFilePath = path.join(resolvedTargetDirectoryPath, ...staleFileRelativePath.split('/'));
219
- if (!(await pathExists(staleFilePath))) {
220
- continue;
221
- }
222
-
223
- await fs.unlink(staleFilePath);
224
- deletedManagedFiles.push(staleFileRelativePath);
225
- }
226
-
227
- for (const staleDirectoryRelativePath of managedSurfacePlan.staleDirectories) {
228
- const staleDirectoryPath = path.join(resolvedTargetDirectoryPath, ...staleDirectoryRelativePath.split('/'));
229
- if (!(await pathExists(staleDirectoryPath))) {
230
- continue;
231
- }
232
-
233
- await fs.rm(staleDirectoryPath, { recursive: true, force: true });
234
- deletedManagedDirectories.push(staleDirectoryRelativePath);
235
- }
236
-
237
- await pruneEmptyLegacyInstructionDirectories(resolvedTargetDirectoryPath);
238
- }
239
-
240
- if (shouldIncludeMcpTemplate) {
241
- const projectName = path.basename(resolvedTargetDirectoryPath);
242
- const mcpArgs = ['./scripts/mcp-server.mjs'];
243
-
244
- const sourceMcpServerPath = path.join(REPOSITORY_ROOT, 'scripts', 'mcp-server.mjs');
245
- const targetMcpServerPath = path.join(resolvedTargetDirectoryPath, 'scripts', 'mcp-server.mjs');
246
- const mcpServerSync = await syncFile(sourceMcpServerPath, targetMcpServerPath);
247
- if (mcpServerSync.status === 'created') createdFiles.push('scripts/mcp-server.mjs');
248
- else if (mcpServerSync.status === 'updated') updatedFiles.push('scripts/mcp-server.mjs');
249
-
250
- const sourceMcpHelpersDirectoryPath = path.join(REPOSITORY_ROOT, 'scripts', 'mcp-server');
251
- if (await pathExists(sourceMcpHelpersDirectoryPath)) {
252
- const mcpHelperTreeEntries = await collectRelativeTreeEntries(
253
- sourceMcpHelpersDirectoryPath,
254
- 'scripts/mcp-server'
255
- );
256
-
257
- for (const relativeHelperFilePath of mcpHelperTreeEntries.files) {
258
- const sourceHelperFilePath = path.join(REPOSITORY_ROOT, ...relativeHelperFilePath.split('/'));
259
- const targetHelperFilePath = path.join(resolvedTargetDirectoryPath, ...relativeHelperFilePath.split('/'));
260
- const helperSyncResult = await syncFile(sourceHelperFilePath, targetHelperFilePath);
261
-
262
- if (helperSyncResult.status === 'created') createdFiles.push(relativeHelperFilePath);
263
- else if (helperSyncResult.status === 'updated') updatedFiles.push(relativeHelperFilePath);
264
- else if (helperSyncResult.status === 'unchanged') unchangedFiles.push(relativeHelperFilePath);
265
- }
266
- }
267
-
268
- // 1. VS Code (Workspace Local Settings)
269
- const vscodeMcpJsonPath = path.join(resolvedTargetDirectoryPath, '.vscode', 'mcp.json');
270
- const vscodeWorkspaceMcpConfig = {
271
- servers: {
272
- 'agentic-senior-core': {
273
- type: 'stdio',
274
- command: 'node',
275
- cwd: '${workspaceFolder}',
276
- args: mcpArgs,
277
- },
278
- },
279
- };
280
- const vscodeSync = await syncMcpConfig(vscodeMcpJsonPath, vscodeWorkspaceMcpConfig);
281
- if (vscodeSync.status === 'created') createdFiles.push('.vscode/mcp.json');
282
- else if (vscodeSync.status === 'updated') updatedFiles.push('.vscode/mcp.json');
283
-
284
- // 2. Cursor (Workspace Local Settings)
285
- const cursorMcpJsonPath = path.join(resolvedTargetDirectoryPath, '.cursor', 'mcp.json');
286
- const cursorWorkspaceMcpConfig = {
287
- mcpServers: {
288
- 'agentic-senior-core': {
289
- command: 'node',
290
- args: mcpArgs,
291
- cwd: '${workspaceFolder}',
292
- },
293
- },
294
- };
295
- const cursorSync = await syncMcpConfig(cursorMcpJsonPath, cursorWorkspaceMcpConfig);
296
- if (cursorSync.status === 'created') createdFiles.push('.cursor/mcp.json');
297
- else if (cursorSync.status === 'updated') updatedFiles.push('.cursor/mcp.json');
298
-
299
- // 3. Zed IDE (Workspace Local Settings)
300
- const zedSettingsPath = path.join(resolvedTargetDirectoryPath, '.zed', 'settings.json');
301
- const zedMcpConfig = {
302
- context_servers: {
303
- 'agentic-senior-core': {
304
- command: 'node',
305
- env: {},
306
- args: mcpArgs,
307
- },
308
- },
309
- };
310
-
311
- if (!(await pathExists(zedSettingsPath))) {
312
- await ensureDirectory(path.dirname(zedSettingsPath));
313
- await fs.writeFile(zedSettingsPath, JSON.stringify(zedMcpConfig, null, 2) + '\n', 'utf8');
314
- createdFiles.push('.zed/settings.json');
315
- } else {
316
- try {
317
- const existingZedContent = await fs.readFile(zedSettingsPath, 'utf8');
318
- const parsedZedSettings = JSON.parse(existingZedContent);
319
- if (!parsedZedSettings.context_servers) parsedZedSettings.context_servers = {};
320
-
321
- const templateServer = zedMcpConfig.context_servers['agentic-senior-core'];
322
- if (JSON.stringify(parsedZedSettings.context_servers['agentic-senior-core']) !== JSON.stringify(templateServer)) {
323
- parsedZedSettings.context_servers['agentic-senior-core'] = templateServer;
324
- await fs.writeFile(zedSettingsPath, JSON.stringify(parsedZedSettings, null, 2) + '\n', 'utf8');
325
- updatedFiles.push('.zed/settings.json');
326
- }
327
- } catch { /* Ignore malformed Zed JSON */ }
328
- }
329
-
330
- // 4. Antigravity / Gemini (Global Settings)
331
- const isTmpDir = resolvedTargetDirectoryPath.startsWith(os.tmpdir());
332
- if (!isTmpDir) {
333
- try {
334
- const globalGeminiDir = path.join(os.homedir(), '.gemini', 'antigravity');
335
- const globalGeminiMcpPath = path.join(globalGeminiDir, 'mcp_config.json');
336
- const targetMcpServerScript = path.join(resolvedTargetDirectoryPath, 'scripts', 'mcp-server.mjs');
337
-
338
- // Only inject if the MCP server script will actually exist at the target.
339
- // When the script is missing, Antigravity blocks all chat instead of degrading gracefully.
340
- const targetHasMcpServer = await pathExists(targetMcpServerScript);
341
-
342
- if (targetHasMcpServer && await pathExists(globalGeminiDir)) {
343
- let geminiConfig = { mcpServers: {} };
344
- if (await pathExists(globalGeminiMcpPath)) {
345
- const content = await fs.readFile(globalGeminiMcpPath, 'utf8');
346
- if (content.trim()) {
347
- try { geminiConfig = JSON.parse(content); } catch {}
348
- }
349
- }
350
- if (!geminiConfig.mcpServers) geminiConfig.mcpServers = {};
351
-
352
- // Prune stale agentic-senior-core entries whose workspace no longer exists
353
- let configChanged = false;
354
- for (const serverName of Object.keys(geminiConfig.mcpServers)) {
355
- if (!serverName.startsWith('agentic-senior-core-')) continue;
356
- const serverEntry = geminiConfig.mcpServers[serverName];
357
- if (!serverEntry?.cwd) continue;
358
- const staleMcpScript = path.join(serverEntry.cwd, 'scripts', 'mcp-server.mjs');
359
- if (!(await pathExists(staleMcpScript))) {
360
- delete geminiConfig.mcpServers[serverName];
361
- configChanged = true;
362
- }
363
- }
364
-
365
- const safeProjectName = projectName.replace(/[^a-zA-Z0-9_-]/g, '-');
366
- const uniqueServerName = `agentic-senior-core-${safeProjectName}`;
367
- const templateServer = {
368
- command: 'node',
369
- args: mcpArgs,
370
- cwd: resolvedTargetDirectoryPath,
371
- };
372
-
373
- if (JSON.stringify(geminiConfig.mcpServers[uniqueServerName]) !== JSON.stringify(templateServer)) {
374
- geminiConfig.mcpServers[uniqueServerName] = templateServer;
375
- configChanged = true;
376
- }
377
-
378
- if (configChanged) {
379
- await fs.writeFile(globalGeminiMcpPath, JSON.stringify(geminiConfig, null, 2) + '\n', 'utf8');
380
- }
381
- }
382
- } catch { /* Ignore global injection errors */ }
383
- }
384
- }
385
-
386
- return {
387
- deletedManagedFiles,
388
- deletedManagedDirectories,
389
- createdFiles,
390
- updatedFiles,
391
- unchangedFiles,
392
- preservedFiles,
393
- managedSurfacePlan,
394
- };
395
- }
396
-
397
- export function toTitleCase(fileName) {
398
- return fileName
399
- .replace(/\.md$/i, '')
400
- .split(/[-_]/g)
401
- .map((wordPart) => wordPart.charAt(0).toUpperCase() + wordPart.slice(1))
402
- .join(' ');
403
- }
404
-
405
- export function normalizeChoiceInput(rawInput) {
406
- return rawInput.trim().toLowerCase().replace(/\s+/g, '-');
407
- }
408
-
409
- export function matchFileNameFromInput(rawInput, fileNames) {
410
- const normalizedInput = normalizeChoiceInput(rawInput);
411
-
412
- return fileNames.find((fileName) => {
413
- const normalizedFileName = normalizeChoiceInput(fileName.replace(/\.md$/i, ''));
414
- const normalizedTitle = normalizeChoiceInput(toTitleCase(fileName));
415
- return normalizedInput === normalizedFileName || normalizedInput === normalizedTitle;
416
- });
417
- }
418
-
419
- export function matchProfileNameFromInput(rawInput) {
420
- const normalizedInput = normalizeChoiceInput(rawInput);
421
- return Object.keys(PROFILE_PRESETS).find((profileName) => profileName === normalizedInput) || null;
422
- }
423
-
424
- export function parseBooleanSetting(rawBooleanValue, contextLabel) {
425
- const normalizedValue = normalizeChoiceInput(rawBooleanValue);
426
-
427
- if (normalizedValue === 'true') {
428
- return true;
429
- }
430
-
431
- if (normalizedValue === 'false') {
432
- return false;
433
- }
434
-
435
- throw new Error(`Invalid boolean value for ${contextLabel}: ${rawBooleanValue}`);
436
- }
437
-
438
- export function parseBlockingSeverities(rawSeverityValues, fileName) {
439
- const parsedSeverities = rawSeverityValues
440
- .split(',')
441
- .map((severityValue) => normalizeChoiceInput(severityValue))
442
- .filter(Boolean);
443
-
444
- if (parsedSeverities.length === 0) {
445
- throw new Error(`Profile pack ${fileName} must define at least one blocking severity.`);
446
- }
447
-
448
- const invalidSeverity = parsedSeverities.find((severityValue) => !ALLOWED_SEVERITY_LEVELS.has(severityValue));
449
- if (invalidSeverity) {
450
- throw new Error(`Profile pack ${fileName} uses unsupported severity: ${invalidSeverity}`);
451
- }
452
-
453
- return parsedSeverities;
454
- }
455
-
456
- export async function collectFileNames(folderPath) {
457
- try {
458
- const fileNames = await fs.readdir(folderPath, { withFileTypes: true });
459
- return fileNames
460
- .filter((entry) => entry.isFile() && entry.name.endsWith('.md'))
461
- .map((entry) => entry.name)
462
- .sort((leftName, rightName) => leftName.localeCompare(rightName));
463
- } catch (error) {
464
- if (error?.code === 'ENOENT') {
465
- return [];
466
- }
467
-
468
- throw error;
469
- }
470
- }
471
-
472
- export function formatBlockingSeverities(blockingSeverities) {
473
- return blockingSeverities.join(', ');
474
- }
475
-
476
- export function formatDuration(durationMs) {
477
- const durationInSeconds = (durationMs / 1000).toFixed(1);
478
- return `${durationInSeconds}s`;
479
- }
package/mcp.json DELETED
@@ -1,134 +0,0 @@
1
- {
2
- "version": "1.1",
3
- "name": "agentic-senior-core",
4
- "description": "MCP configuration for governance-aware diagnostics and scoped rule loading. Five knowledge layers ship as concrete file-backed surfaces today; four additional layers are declared as planned dynamic surfaces. See docs/architecture-vision.md for the roadmap.",
5
- "knowledgeLayers": {
6
- "enabled": true,
7
- "description": "Knowledge layer registry. 5 layers are file-backed and active today (rules, prompts, state, policies, project-context). 4 layers are reserved as planned dynamic surfaces (stack-strategies, architecture-playbooks, execution-contracts, governance-modes) and resolve to no-op until implemented in a later phase.",
8
- "implementedLayerCount": 5,
9
- "plannedLayerCount": 4,
10
- "totalDeclaredLayers": 9,
11
- "roadmapReference": "docs/architecture-vision.md",
12
- "layers": {
13
- "rules": {
14
- "path": ".agent-context/rules",
15
- "count": 15,
16
- "autoLoad": true,
17
- "status": "implemented"
18
- },
19
- "stack-strategies": {
20
- "path": "dynamic",
21
- "autoLoad": true,
22
- "type": "virtual",
23
- "status": "planned",
24
- "plannedPhase": "phase-2-or-later",
25
- "rationale": "Reserved for runtime-decision-signal cache derived from detected project stack."
26
- },
27
- "architecture-playbooks": {
28
- "path": "dynamic",
29
- "autoLoad": true,
30
- "type": "virtual",
31
- "status": "planned",
32
- "plannedPhase": "phase-2-or-later",
33
- "rationale": "Reserved for structural-planning playbooks derived from repo evidence."
34
- },
35
- "execution-contracts": {
36
- "path": "dynamic",
37
- "autoLoad": true,
38
- "sources": [
39
- "prompts",
40
- "review-checklists",
41
- "policies"
42
- ],
43
- "type": "virtual",
44
- "status": "planned",
45
- "plannedPhase": "phase-3-anti-halu",
46
- "rationale": "Reserved for active-contract resolution. Today the agent reads prompts, review-checklists, and policies directly from their file-backed layers; the dedicated execution-contract resolver is planned for the validation MCP tools in Phase 3."
47
- },
48
- "prompts": {
49
- "path": ".agent-context/prompts",
50
- "count": 4,
51
- "autoLoad": true,
52
- "status": "implemented",
53
- "templates": [
54
- "init-project",
55
- "bootstrap-design",
56
- "refactor",
57
- "review-code"
58
- ]
59
- },
60
- "governance-modes": {
61
- "path": "dynamic",
62
- "autoLoad": true,
63
- "governance": [
64
- "platform",
65
- "regulated",
66
- "startup"
67
- ],
68
- "type": "virtual",
69
- "status": "planned",
70
- "plannedPhase": "phase-2-or-later",
71
- "rationale": "Reserved for governance-mode selection metadata. Profile selection lives in policy files today and the mode-resolver is planned."
72
- },
73
- "state": {
74
- "path": ".agent-context/state",
75
- "count": 22,
76
- "autoLoad": true,
77
- "status": "implemented"
78
- },
79
- "policies": {
80
- "path": ".agent-context/policies",
81
- "count": 1,
82
- "autoLoad": true,
83
- "status": "implemented"
84
- },
85
- "project-context": {
86
- "path": "docs",
87
- "count": 0,
88
- "autoLoad": false,
89
- "status": "implemented",
90
- "sources": [
91
- "project-brief",
92
- "architecture-decision-record",
93
- "flow-overview",
94
- "api-contract",
95
- "database-schema",
96
- "DESIGN",
97
- "design-intent"
98
- ]
99
- }
100
- }
101
- },
102
- "workflows": {
103
- "self-heal-on-failure": {
104
- "trigger": [
105
- "ci.failure",
106
- "lint.failure"
107
- ],
108
- "steps": [
109
- "collect_logs",
110
- "map_violation_to_rule",
111
- "propose_patch",
112
- "run_checklist_review"
113
- ]
114
- },
115
- "full-knowledge-injection": {
116
- "trigger": [
117
- "workspace.initialize",
118
- "agent.start"
119
- ],
120
- "steps": [
121
- "resolve_scope_first",
122
- "inject_relevant_rules",
123
- "inject_runtime_decision_signals",
124
- "inject_structural_planning_signals",
125
- "inject_execution_contracts",
126
- "inject_prompts",
127
- "inject_governance_modes",
128
- "inject_state",
129
- "inject_policies",
130
- "inject_project_context_when_relevant"
131
- ]
132
- }
133
- }
134
- }