@ryuenn3123/agentic-senior-core 4.4.0 → 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 (196) 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 -127
  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 +42 -41
  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 -60
  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 -134
  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 -38
  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 -394
  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 -151
  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/backup.mjs +0 -210
  94. package/lib/cli/commands/context.mjs +0 -140
  95. package/lib/cli/commands/init/project-context.mjs +0 -60
  96. package/lib/cli/commands/init/runtime-environment.mjs +0 -59
  97. package/lib/cli/commands/init/setup-decisions.mjs +0 -83
  98. package/lib/cli/commands/init.mjs +0 -654
  99. package/lib/cli/commands/launch.mjs +0 -76
  100. package/lib/cli/commands/optimize.mjs +0 -284
  101. package/lib/cli/commands/rollback.mjs +0 -64
  102. package/lib/cli/commands/upgrade/token-optimization-state.mjs +0 -51
  103. package/lib/cli/commands/upgrade.mjs +0 -451
  104. package/lib/cli/compiler.mjs +0 -187
  105. package/lib/cli/constants.mjs +0 -136
  106. package/lib/cli/detector/constants.mjs +0 -135
  107. package/lib/cli/detector/design-evidence/collector.mjs +0 -256
  108. package/lib/cli/detector/design-evidence/constants.mjs +0 -39
  109. package/lib/cli/detector/design-evidence/file-traversal.mjs +0 -83
  110. package/lib/cli/detector/design-evidence/structured-attribute-evidence.mjs +0 -117
  111. package/lib/cli/detector/design-evidence/summary.mjs +0 -109
  112. package/lib/cli/detector/design-evidence/utility-helpers.mjs +0 -122
  113. package/lib/cli/detector/design-evidence.mjs +0 -25
  114. package/lib/cli/detector/stack-detection.mjs +0 -243
  115. package/lib/cli/detector/ui-signals.mjs +0 -150
  116. package/lib/cli/detector/workspace-scan.mjs +0 -177
  117. package/lib/cli/detector.mjs +0 -23
  118. package/lib/cli/init-detection-flow.mjs +0 -48
  119. package/lib/cli/init-options.mjs +0 -237
  120. package/lib/cli/init-selection.mjs +0 -29
  121. package/lib/cli/memory-continuity.mjs +0 -537
  122. package/lib/cli/preflight.mjs +0 -76
  123. package/lib/cli/project-scaffolder/constants.mjs +0 -69
  124. package/lib/cli/project-scaffolder/discovery.mjs +0 -272
  125. package/lib/cli/project-scaffolder/prompt-builders.mjs +0 -171
  126. package/lib/cli/project-scaffolder/storage.mjs +0 -144
  127. package/lib/cli/project-scaffolder/ui-scope-detection.mjs +0 -36
  128. package/lib/cli/project-scaffolder.mjs +0 -29
  129. package/lib/cli/rollback.mjs +0 -66
  130. package/lib/cli/token-optimization.mjs +0 -401
  131. package/lib/cli/utils/filesystem.mjs +0 -81
  132. package/lib/cli/utils/managed-surface.mjs +0 -280
  133. package/lib/cli/utils/prompting.mjs +0 -44
  134. package/lib/cli/utils.mjs +0 -479
  135. package/mcp.json +0 -134
  136. package/scripts/adaptive-context/fixtures.mjs +0 -183
  137. package/scripts/adaptive-context-benchmark.mjs +0 -9
  138. package/scripts/ascx-runtime-token-saver-benchmark.mjs +0 -9
  139. package/scripts/benchmark-evidence-bundle.mjs +0 -645
  140. package/scripts/benchmark-gate.mjs +0 -121
  141. package/scripts/benchmark-intelligence.mjs +0 -33
  142. package/scripts/benchmark-writer-judge-matrix.mjs +0 -379
  143. package/scripts/build-release-benchmark-bundle.mjs +0 -202
  144. package/scripts/bump-version.mjs +0 -103
  145. package/scripts/clean-local-artifacts.mjs +0 -78
  146. package/scripts/compact-natural-mode-benchmark.mjs +0 -9
  147. package/scripts/context-triggered-audit.mjs +0 -391
  148. package/scripts/detection-benchmark.mjs +0 -127
  149. package/scripts/docs-quality-drift-report.mjs +0 -358
  150. package/scripts/documentation-boundary-audit.mjs +0 -305
  151. package/scripts/explain-on-demand-audit.mjs +0 -427
  152. package/scripts/forbidden-content-check.mjs +0 -123
  153. package/scripts/frontend-usability-audit.mjs +0 -243
  154. package/scripts/generate-sbom.mjs +0 -61
  155. package/scripts/governance-weekly-report.mjs +0 -466
  156. package/scripts/llm-judge/checklist-loader.mjs +0 -45
  157. package/scripts/llm-judge/constants.mjs +0 -66
  158. package/scripts/llm-judge/diff-collection.mjs +0 -74
  159. package/scripts/llm-judge/prompting.mjs +0 -78
  160. package/scripts/llm-judge/providers.mjs +0 -111
  161. package/scripts/llm-judge/verdict.mjs +0 -134
  162. package/scripts/llm-judge.mjs +0 -200
  163. package/scripts/memory-continuity-benchmark.mjs +0 -322
  164. package/scripts/quality-trend-report.mjs +0 -289
  165. package/scripts/release-gate/audit-checks.mjs +0 -441
  166. package/scripts/release-gate/constants.mjs +0 -53
  167. package/scripts/release-gate/runtime.mjs +0 -63
  168. package/scripts/release-gate/static-checks.mjs +0 -182
  169. package/scripts/release-gate.mjs +0 -42
  170. package/scripts/rules-guardian-audit.mjs +0 -580
  171. package/scripts/single-source-lazy-loading-audit.mjs +0 -449
  172. package/scripts/sync-thin-adapters.mjs +0 -72
  173. package/scripts/token-optimization-benchmark.mjs +0 -252
  174. package/scripts/ui-design-judge/constants.mjs +0 -13
  175. package/scripts/ui-design-judge/design-execution-summary.mjs +0 -81
  176. package/scripts/ui-design-judge/git-input.mjs +0 -134
  177. package/scripts/ui-design-judge/prompting.mjs +0 -52
  178. package/scripts/ui-design-judge/providers.mjs +0 -102
  179. package/scripts/ui-design-judge/reporting.mjs +0 -183
  180. package/scripts/ui-design-judge/rubric-calibration.mjs +0 -214
  181. package/scripts/ui-design-judge/rubric-goldset.json +0 -188
  182. package/scripts/ui-design-judge.mjs +0 -319
  183. package/scripts/ui-rubric-calibration.mjs +0 -35
  184. package/scripts/validate/audits/cache-layer-contract.mjs +0 -230
  185. package/scripts/validate/audits/caching-scope-hygiene.mjs +0 -235
  186. package/scripts/validate/audits/file-size.mjs +0 -158
  187. package/scripts/validate/audits/reflection-citations.mjs +0 -130
  188. package/scripts/validate/audits/release-bundle.mjs +0 -135
  189. package/scripts/validate/audits/rule-id-uniqueness.mjs +0 -278
  190. package/scripts/validate/config.mjs +0 -501
  191. package/scripts/validate/coverage-checks.mjs +0 -446
  192. package/scripts/validate/file-structure.mjs +0 -158
  193. package/scripts/validate/markdown-content.mjs +0 -109
  194. package/scripts/validate/project-metadata.mjs +0 -166
  195. package/scripts/validate/utils.mjs +0 -52
  196. package/scripts/validate.mjs +0 -267
@@ -1,156 +0,0 @@
1
- // @ts-check
2
-
3
- /**
4
- * Color parsing and distance utilities for the typography/palette
5
- * anti-repeat audit. OKLCH math is contained here so the main audit module
6
- * stays focused on file scanning and ledger cross-check.
7
- */
8
-
9
- export const HEX_COLOR_PATTERN = /#([0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})\b/g;
10
- export const OKLCH_PATTERN = /oklch\(\s*([^)]+)\s*\)/gi;
11
-
12
- export function expandShortHexColor(rawHexColor) {
13
- if (rawHexColor.length !== 4) {
14
- return rawHexColor;
15
- }
16
- const expandedChars = [];
17
- for (let charIndex = 1; charIndex < rawHexColor.length; charIndex += 1) {
18
- expandedChars.push(rawHexColor[charIndex], rawHexColor[charIndex]);
19
- }
20
- return `#${expandedChars.join('')}`.toLowerCase();
21
- }
22
-
23
- export function normalizeHexColor(rawHexColor) {
24
- if (typeof rawHexColor !== 'string' || rawHexColor.length === 0) {
25
- return null;
26
- }
27
- const trimmedHex = rawHexColor.trim().toLowerCase();
28
- if (!trimmedHex.startsWith('#')) {
29
- return null;
30
- }
31
- if (trimmedHex.length === 4) {
32
- return expandShortHexColor(trimmedHex);
33
- }
34
- if (trimmedHex.length === 7 || trimmedHex.length === 9) {
35
- return trimmedHex.slice(0, 7);
36
- }
37
- return null;
38
- }
39
-
40
- function parseOklchNumber(rawNumber, percentScale) {
41
- const numberString = String(rawNumber || '').trim();
42
- if (numberString.endsWith('%')) {
43
- const percentValue = parseFloat(numberString.slice(0, -1));
44
- if (!Number.isFinite(percentValue)) {
45
- return Number.NaN;
46
- }
47
- return (percentValue / 100) * percentScale;
48
- }
49
- return parseFloat(numberString);
50
- }
51
-
52
- export function parseOklchTriple(oklchExpression) {
53
- const componentTokens = String(oklchExpression || '')
54
- .replace(/\//g, ' ')
55
- .split(/[\s,]+/)
56
- .filter((componentToken) => componentToken.length > 0);
57
- if (componentTokens.length < 3) {
58
- return null;
59
- }
60
- const lightness = parseOklchNumber(componentTokens[0], 1);
61
- const chroma = parseFloat(componentTokens[1]);
62
- const hueDegrees = parseOklchNumber(componentTokens[2], 360);
63
- if (!Number.isFinite(lightness) || !Number.isFinite(chroma) || !Number.isFinite(hueDegrees)) {
64
- return null;
65
- }
66
- return { lightness, chroma, hueDegrees };
67
- }
68
-
69
- /**
70
- * L*C*H-style perceptual distance proxy. OKLCH is perceptually uniform,
71
- * so a Cartesian-like delta over (L, C, C * Δhue_radians) tracks visible
72
- * difference well enough for an anti-repeat heuristic.
73
- */
74
- export function oklchPerceptualDistance(leftColor, rightColor) {
75
- const lightnessDelta = leftColor.lightness - rightColor.lightness;
76
- const chromaDelta = leftColor.chroma - rightColor.chroma;
77
- const hueDelta = ((leftColor.hueDegrees - rightColor.hueDegrees + 540) % 360) - 180;
78
- const hueArcRadians = (hueDelta * Math.PI) / 180;
79
- const hueChromaDelta = leftColor.chroma * hueArcRadians;
80
- return Math.sqrt(
81
- lightnessDelta * lightnessDelta
82
- + chromaDelta * chromaDelta
83
- + hueChromaDelta * hueChromaDelta,
84
- );
85
- }
86
-
87
- export function extractColorOccurrencesFromText(sourceText) {
88
- /** @type {{ kind: 'hex' | 'oklch', raw: string, normalized: string | null, oklch: { lightness: number, chroma: number, hueDegrees: number } | null, index: number }[]} */
89
- const colorOccurrences = [];
90
-
91
- HEX_COLOR_PATTERN.lastIndex = 0;
92
- let hexMatch;
93
- // eslint-disable-next-line no-cond-assign
94
- while ((hexMatch = HEX_COLOR_PATTERN.exec(sourceText)) !== null) {
95
- colorOccurrences.push({
96
- kind: 'hex',
97
- raw: hexMatch[0],
98
- normalized: normalizeHexColor(hexMatch[0]),
99
- oklch: null,
100
- index: hexMatch.index,
101
- });
102
- }
103
-
104
- OKLCH_PATTERN.lastIndex = 0;
105
- let oklchMatch;
106
- // eslint-disable-next-line no-cond-assign
107
- while ((oklchMatch = OKLCH_PATTERN.exec(sourceText)) !== null) {
108
- colorOccurrences.push({
109
- kind: 'oklch',
110
- raw: oklchMatch[0],
111
- normalized: oklchMatch[0].toLowerCase(),
112
- oklch: parseOklchTriple(oklchMatch[1]),
113
- index: oklchMatch.index,
114
- });
115
- }
116
-
117
- return colorOccurrences;
118
- }
119
-
120
- export function extractLedgerColors(antiRepeatLedger) {
121
- const previousPalettes = Array.isArray(antiRepeatLedger?.previousPalettes)
122
- ? antiRepeatLedger.previousPalettes
123
- : [];
124
-
125
- /** @type {{ kind: 'hex' | 'oklch', normalized: string | null, oklch: { lightness: number, chroma: number, hueDegrees: number } | null, sourceEntry: any }[]} */
126
- const ledgerColors = [];
127
- for (const ledgerEntry of previousPalettes) {
128
- const summaryString = String(ledgerEntry?.summary || '');
129
- if (!summaryString) {
130
- continue;
131
- }
132
- HEX_COLOR_PATTERN.lastIndex = 0;
133
- let hexMatch;
134
- // eslint-disable-next-line no-cond-assign
135
- while ((hexMatch = HEX_COLOR_PATTERN.exec(summaryString)) !== null) {
136
- ledgerColors.push({
137
- kind: 'hex',
138
- normalized: normalizeHexColor(hexMatch[0]),
139
- oklch: null,
140
- sourceEntry: ledgerEntry,
141
- });
142
- }
143
- OKLCH_PATTERN.lastIndex = 0;
144
- let oklchMatch;
145
- // eslint-disable-next-line no-cond-assign
146
- while ((oklchMatch = OKLCH_PATTERN.exec(summaryString)) !== null) {
147
- ledgerColors.push({
148
- kind: 'oklch',
149
- normalized: oklchMatch[0].toLowerCase(),
150
- oklch: parseOklchTriple(oklchMatch[1]),
151
- sourceEntry: ledgerEntry,
152
- });
153
- }
154
- }
155
- return ledgerColors;
156
- }
@@ -1,103 +0,0 @@
1
- // @ts-check
2
-
3
- /**
4
- * Filesystem scanning for the typography/palette anti-repeat audit. Walks
5
- * the repository tree, skips noisy directories (node_modules, build outputs,
6
- * etc.), and yields scannable CSS-like and token-config file paths.
7
- */
8
-
9
- import { readdirSync, statSync, existsSync } from 'node:fs';
10
- import { extname, join, relative, sep } from 'node:path';
11
-
12
- export const DEFAULT_CSS_FILE_EXTENSIONS = new Set(['.css', '.scss', '.sass', '.less']);
13
- export const TOKEN_CONFIG_FILE_NAMES = new Set([
14
- 'tailwind.config.js',
15
- 'tailwind.config.cjs',
16
- 'tailwind.config.mjs',
17
- 'tailwind.config.ts',
18
- 'theme.config.js',
19
- 'theme.config.ts',
20
- 'design-tokens.js',
21
- 'design-tokens.ts',
22
- ]);
23
- export const SCAN_SKIP_DIRECTORY_NAMES = new Set([
24
- 'node_modules',
25
- '.git',
26
- '.agentic-backup',
27
- '.benchmarks',
28
- 'dist',
29
- 'build',
30
- '.next',
31
- 'out',
32
- 'coverage',
33
- '.cache',
34
- ]);
35
-
36
- function isInsideSkippedDirectory(absolutePath, repositoryRootPath) {
37
- const relativePath = relative(repositoryRootPath, absolutePath);
38
- if (!relativePath || relativePath.startsWith('..')) {
39
- return true;
40
- }
41
- const pathSegments = relativePath.split(sep);
42
- return pathSegments.some((segmentName) => SCAN_SKIP_DIRECTORY_NAMES.has(segmentName));
43
- }
44
-
45
- function* walkDirectoryEntries(currentDirectoryPath, repositoryRootPath) {
46
- const directoryEntries = readdirSync(currentDirectoryPath, { withFileTypes: true });
47
- for (const directoryEntry of directoryEntries) {
48
- const childPath = join(currentDirectoryPath, directoryEntry.name);
49
- if (directoryEntry.isDirectory()) {
50
- if (SCAN_SKIP_DIRECTORY_NAMES.has(directoryEntry.name)) {
51
- continue;
52
- }
53
- if (isInsideSkippedDirectory(childPath, repositoryRootPath)) {
54
- continue;
55
- }
56
- yield* walkDirectoryEntries(childPath, repositoryRootPath);
57
- continue;
58
- }
59
- if (directoryEntry.isFile()) {
60
- yield childPath;
61
- }
62
- }
63
- }
64
-
65
- export function isScannableFile(absoluteFilePath) {
66
- const fileExtension = extname(absoluteFilePath).toLowerCase();
67
- if (DEFAULT_CSS_FILE_EXTENSIONS.has(fileExtension)) {
68
- return true;
69
- }
70
- const baseName = absoluteFilePath.split(/[\\/]/).pop();
71
- return TOKEN_CONFIG_FILE_NAMES.has(baseName);
72
- }
73
-
74
- export function collectScannableFilePaths(repositoryRootPath, scanRoots) {
75
- const collectedFilePaths = [];
76
- for (const scanRoot of scanRoots) {
77
- const absoluteScanRoot = join(repositoryRootPath, scanRoot);
78
- if (!existsSync(absoluteScanRoot)) {
79
- continue;
80
- }
81
- const scanRootStat = statSync(absoluteScanRoot);
82
- if (!scanRootStat.isDirectory()) {
83
- continue;
84
- }
85
- for (const candidateFilePath of walkDirectoryEntries(absoluteScanRoot, repositoryRootPath)) {
86
- if (!isScannableFile(candidateFilePath)) {
87
- continue;
88
- }
89
- collectedFilePaths.push(candidateFilePath);
90
- }
91
- }
92
- return collectedFilePaths.sort();
93
- }
94
-
95
- export function lineNumberFromIndex(sourceText, charIndex) {
96
- let lineNumber = 1;
97
- for (let scanIndex = 0; scanIndex < charIndex && scanIndex < sourceText.length; scanIndex += 1) {
98
- if (sourceText[scanIndex] === '\n') {
99
- lineNumber += 1;
100
- }
101
- }
102
- return lineNumber;
103
- }
@@ -1,70 +0,0 @@
1
- // @ts-check
2
-
3
- /**
4
- * Font-family parsing for the typography/palette anti-repeat audit. CSS
5
- * `font-family:` declarations and `@font-face` blocks are the inputs;
6
- * normalized lowercase family tokens are the outputs.
7
- */
8
-
9
- export const FONT_FAMILY_DECLARATION_PATTERN = /font-family\s*:\s*([^;}]+)[;}]/gi;
10
- export const FONT_FACE_FAMILY_PATTERN = /@font-face\s*\{[^}]*font-family\s*:\s*([^;]+);/gi;
11
-
12
- export function normalizeFontFamilyToken(rawFamilyToken) {
13
- return String(rawFamilyToken || '')
14
- .replace(/^["']|["']$/g, '')
15
- .trim()
16
- .toLowerCase();
17
- }
18
-
19
- export function splitFontFamilyDeclaration(declarationValue) {
20
- return String(declarationValue || '')
21
- .split(',')
22
- .map((familyEntry) => normalizeFontFamilyToken(familyEntry))
23
- .filter((familyEntry) => familyEntry.length > 0 && !familyEntry.startsWith('var('));
24
- }
25
-
26
- export function extractFontFamiliesFromText(sourceText) {
27
- /** @type {{ family: string, index: number }[]} */
28
- const familyOccurrences = [];
29
-
30
- for (const matchPattern of [FONT_FAMILY_DECLARATION_PATTERN, FONT_FACE_FAMILY_PATTERN]) {
31
- matchPattern.lastIndex = 0;
32
- let regexMatch;
33
- // eslint-disable-next-line no-cond-assign
34
- while ((regexMatch = matchPattern.exec(sourceText)) !== null) {
35
- const declarationValue = regexMatch[1];
36
- const declarationStartIndex = regexMatch.index;
37
- for (const familyEntry of splitFontFamilyDeclaration(declarationValue)) {
38
- familyOccurrences.push({ family: familyEntry, index: declarationStartIndex });
39
- }
40
- }
41
- }
42
-
43
- return familyOccurrences;
44
- }
45
-
46
- export function extractLedgerTypographyFamilies(antiRepeatLedger) {
47
- const previousTypographyChoices = Array.isArray(antiRepeatLedger?.previousTypographyChoices)
48
- ? antiRepeatLedger.previousTypographyChoices
49
- : [];
50
-
51
- const ledgerFamilies = new Map();
52
- for (const ledgerEntry of previousTypographyChoices) {
53
- const summaryString = String(ledgerEntry?.summary || '');
54
- if (!summaryString) {
55
- continue;
56
- }
57
- // Summaries are emitted as "role: value; role: value". Each value is a
58
- // font family that the previous design shipped.
59
- for (const summaryPart of summaryString.split(';')) {
60
- const colonSplitIndex = summaryPart.indexOf(':');
61
- const familyValue = colonSplitIndex >= 0 ? summaryPart.slice(colonSplitIndex + 1) : summaryPart;
62
- const normalizedFamilyValue = normalizeFontFamilyToken(familyValue);
63
- if (normalizedFamilyValue.length === 0) {
64
- continue;
65
- }
66
- ledgerFamilies.set(normalizedFamilyValue, ledgerEntry);
67
- }
68
- }
69
- return ledgerFamilies;
70
- }
@@ -1,210 +0,0 @@
1
- import fs from 'node:fs/promises';
2
- import path from 'node:path';
3
- import crypto from 'node:crypto';
4
- import { pathExists, ensureDirectory } from './utils.mjs';
5
- import { entryPointFiles, BACKUP_DIR_NAME } from './constants.mjs';
6
-
7
- const BACKUP_GITIGNORE_ENTRY = `${BACKUP_DIR_NAME}/`;
8
- const BACKUP_GITIGNORE_COMMENT = '# agentic-senior-core: local backup artifacts';
9
- const RUNTIME_ARTIFACT_GITIGNORE_ENTRIES = [
10
- '.agent-context/state/token-saver/',
11
- '.agent-context/state/token-optimization-report.json',
12
- ];
13
- const RUNTIME_ARTIFACT_GITIGNORE_COMMENT = '# agentic-senior-core: local runtime artifacts';
14
-
15
- const GOVERNANCE_GITIGNORE_ENTRIES = [
16
- '.agent-context/',
17
- 'AGENTS.md',
18
- 'CLAUDE.md',
19
- 'GEMINI.md',
20
- 'mcp.json',
21
- ];
22
- const GOVERNANCE_GITIGNORE_COMMENT = '# agentic-senior-core: local-only governance files';
23
-
24
- /**
25
- * Calculates a SHA-256 hash of a file's contents.
26
- */
27
- async function hashFile(filePath) {
28
- const fileBuffer = await fs.readFile(filePath);
29
- const hashSum = crypto.createHash('sha256');
30
- hashSum.update(fileBuffer);
31
- return hashSum.digest('hex');
32
- }
33
-
34
- /**
35
- * Helper to get all files in a directory recursively.
36
- */
37
- async function getFilesInDirectory(dirPath) {
38
- const files = [];
39
- try {
40
- const entries = await fs.readdir(dirPath, { withFileTypes: true });
41
- for (const entry of entries) {
42
- if (entry.name === '.git' || entry.name === 'node_modules' || entry.name === BACKUP_DIR_NAME) {
43
- continue;
44
- }
45
- const fullPath = path.join(dirPath, entry.name);
46
- if (entry.isDirectory()) {
47
- const nestedFiles = await getFilesInDirectory(fullPath);
48
- files.push(...nestedFiles);
49
- } else {
50
- files.push(fullPath);
51
- }
52
- }
53
- } catch (error) {
54
- if (error.code !== 'ENOENT') {
55
- throw error;
56
- }
57
- }
58
- return files;
59
- }
60
-
61
- /**
62
- * Creates a backup of specific paths in the target directory.
63
- * Currently backs up: managed entrypoint files and the entire .agent-context directory.
64
- * @param {string} targetDirectoryPath
65
- */
66
- export async function createBackup(targetDirectoryPath) {
67
- const startTime = Date.now();
68
- const backupRoot = path.join(targetDirectoryPath, BACKUP_DIR_NAME);
69
- const objectsDir = path.join(backupRoot, 'objects');
70
-
71
- await ensureDirectory(objectsDir);
72
-
73
- const pathsToTrack = [
74
- path.join(targetDirectoryPath, '.gitignore'),
75
- ...entryPointFiles.map((entryPointFileName) => path.join(targetDirectoryPath, entryPointFileName)),
76
- path.join(targetDirectoryPath, '.agent-context'),
77
- ];
78
-
79
- const resolvedFilesToTrack = [];
80
-
81
- for (const trackPath of pathsToTrack) {
82
- try {
83
- const stats = await fs.stat(trackPath);
84
- if (stats.isDirectory()) {
85
- const nested = await getFilesInDirectory(trackPath);
86
- resolvedFilesToTrack.push(...nested);
87
- } else if (stats.isFile()) {
88
- resolvedFilesToTrack.push(trackPath);
89
- }
90
- } catch (err) {
91
- if (err.code !== 'ENOENT') {
92
- throw err;
93
- }
94
- // If it doesn't exist, we track it as missing so that a rollback knows to delete it
95
- // if it gets created during the run. Wait, tracking everything that doesn't exist
96
- // is infinite. We should record the paths we intend to write to as "absent" state.
97
- resolvedFilesToTrack.push(trackPath);
98
- }
99
- }
100
-
101
- const manifest = {
102
- timestamp: new Date().toISOString(),
103
- files: {}
104
- };
105
-
106
- for (const filePath of resolvedFilesToTrack) {
107
- const relativePath = path.relative(targetDirectoryPath, filePath);
108
- // Ignore any backup operations within the backup directory itself
109
- if (relativePath.startsWith(BACKUP_DIR_NAME)) continue;
110
-
111
- if (await pathExists(filePath)) {
112
- // File exists: hash and backup
113
- const fileHash = await hashFile(filePath);
114
- const destObjectPath = path.join(objectsDir, fileHash);
115
-
116
- if (!(await pathExists(destObjectPath))) {
117
- await fs.copyFile(filePath, destObjectPath);
118
- }
119
-
120
- const stats = await fs.stat(filePath);
121
- manifest.files[relativePath] = {
122
- action: 'restore',
123
- hash: fileHash,
124
- mtimeMs: stats.mtimeMs
125
- };
126
- } else {
127
- // File did not exist before operation: must be deleted on rollback
128
- manifest.files[relativePath] = {
129
- action: 'delete'
130
- };
131
- }
132
- }
133
-
134
- const manifestPath = path.join(backupRoot, 'manifest.json');
135
- await fs.writeFile(manifestPath, JSON.stringify(manifest, null, 2));
136
-
137
- return {
138
- manifestPath,
139
- backupRoot,
140
- durationMs: Date.now() - startTime
141
- };
142
- }
143
-
144
- async function ensureGitignoreEntries(targetDirectoryPath, { comment, entries, aliasesByEntry = {} }) {
145
- const gitignorePath = path.join(targetDirectoryPath, '.gitignore');
146
- const existingContent = await pathExists(gitignorePath)
147
- ? await fs.readFile(gitignorePath, 'utf8')
148
- : '';
149
- const existingLines = existingContent.split(/\r?\n/).map((line) => line.trim());
150
- const missingEntries = entries.filter((entry) => {
151
- const equivalentEntries = [entry, ...(aliasesByEntry[entry] || [])];
152
- return !equivalentEntries.some((equivalentEntry) => existingLines.includes(equivalentEntry));
153
- });
154
-
155
- if (missingEntries.length === 0) {
156
- return {
157
- status: 'unchanged',
158
- gitignorePath,
159
- entries,
160
- addedEntries: [],
161
- };
162
- }
163
-
164
- let nextContent = existingContent;
165
- if (nextContent.length > 0 && !nextContent.endsWith('\n')) {
166
- nextContent += '\n';
167
- }
168
- if (nextContent.length > 0 && !nextContent.endsWith('\n\n')) {
169
- nextContent += '\n';
170
- }
171
- nextContent += `${comment}\n${missingEntries.join('\n')}\n`;
172
-
173
- await fs.writeFile(gitignorePath, nextContent, 'utf8');
174
-
175
- return {
176
- status: existingContent ? 'updated' : 'created',
177
- gitignorePath,
178
- entries,
179
- addedEntries: missingEntries,
180
- };
181
- }
182
-
183
- export async function ensureBackupGitignoreEntry(targetDirectoryPath) {
184
- const result = await ensureGitignoreEntries(targetDirectoryPath, {
185
- comment: BACKUP_GITIGNORE_COMMENT,
186
- entries: [BACKUP_GITIGNORE_ENTRY],
187
- aliasesByEntry: {
188
- [BACKUP_GITIGNORE_ENTRY]: [BACKUP_DIR_NAME],
189
- },
190
- });
191
-
192
- return {
193
- ...result,
194
- entry: BACKUP_GITIGNORE_ENTRY,
195
- };
196
- }
197
-
198
- export async function ensureRuntimeArtifactGitignoreEntries(targetDirectoryPath) {
199
- return ensureGitignoreEntries(targetDirectoryPath, {
200
- comment: RUNTIME_ARTIFACT_GITIGNORE_COMMENT,
201
- entries: RUNTIME_ARTIFACT_GITIGNORE_ENTRIES,
202
- });
203
- }
204
-
205
- export async function ensureLocalGovernanceGitignoreEntries(targetDirectoryPath) {
206
- return ensureGitignoreEntries(targetDirectoryPath, {
207
- comment: GOVERNANCE_GITIGNORE_COMMENT,
208
- entries: GOVERNANCE_GITIGNORE_ENTRIES,
209
- });
210
- }
@@ -1,140 +0,0 @@
1
- import { stdin } from 'node:process';
2
-
3
- import { buildSelectedContextManifest } from '../adaptive-context.mjs';
4
-
5
- export function parseContextArguments(commandArguments) {
6
- const parsedOptions = {
7
- requestId: 'adhoc-request',
8
- requestText: '',
9
- contextFiles: [],
10
- json: false,
11
- readStdin: false,
12
- };
13
- const requestParts = [];
14
-
15
- for (let argumentIndex = 0; argumentIndex < commandArguments.length; argumentIndex++) {
16
- const currentArgument = commandArguments[argumentIndex];
17
-
18
- if (currentArgument === '--json') {
19
- parsedOptions.json = true;
20
- continue;
21
- }
22
-
23
- if (currentArgument === '--stdin') {
24
- parsedOptions.readStdin = true;
25
- continue;
26
- }
27
-
28
- if (currentArgument === '--file') {
29
- const contextFilePath = commandArguments[argumentIndex + 1];
30
- if (!contextFilePath || contextFilePath.startsWith('--')) {
31
- throw new Error('Missing value for --file');
32
- }
33
-
34
- parsedOptions.contextFiles.push(contextFilePath);
35
- argumentIndex++;
36
- continue;
37
- }
38
-
39
- if (currentArgument === '--files') {
40
- const contextFileList = commandArguments[argumentIndex + 1];
41
- if (!contextFileList || contextFileList.startsWith('--')) {
42
- throw new Error('Missing value for --files');
43
- }
44
-
45
- parsedOptions.contextFiles.push(
46
- ...contextFileList
47
- .split(',')
48
- .map((contextFilePath) => contextFilePath.trim())
49
- .filter(Boolean)
50
- );
51
- argumentIndex++;
52
- continue;
53
- }
54
-
55
- if (currentArgument === '--request-id') {
56
- const requestId = commandArguments[argumentIndex + 1];
57
- if (!requestId || requestId.startsWith('--')) {
58
- throw new Error('Missing value for --request-id');
59
- }
60
-
61
- parsedOptions.requestId = requestId;
62
- argumentIndex++;
63
- continue;
64
- }
65
-
66
- if (currentArgument.startsWith('--')) {
67
- throw new Error(`Unknown option: ${currentArgument}`);
68
- }
69
-
70
- requestParts.push(currentArgument);
71
- }
72
-
73
- parsedOptions.requestText = requestParts.join(' ').trim();
74
- return parsedOptions;
75
- }
76
-
77
- function readRequestFromStdin() {
78
- return new Promise((resolve, reject) => {
79
- let requestText = '';
80
-
81
- stdin.setEncoding('utf8');
82
- stdin.on('data', (chunk) => {
83
- requestText += chunk;
84
- });
85
- stdin.on('error', reject);
86
- stdin.on('end', () => {
87
- resolve(requestText.trim());
88
- });
89
- });
90
- }
91
-
92
- function formatList(label, values) {
93
- if (values.length === 0) {
94
- return [`${label}: none`];
95
- }
96
-
97
- return [
98
- `${label}:`,
99
- ...values.map((value) => `- ${value}`),
100
- ];
101
- }
102
-
103
- function formatManifestText(manifest) {
104
- return [
105
- 'Adaptive Context',
106
- `requestId: ${manifest.requestId}`,
107
- `labels: ${manifest.labels.length > 0 ? manifest.labels.join(', ') : 'none'}`,
108
- `uncertainty: ${manifest.uncertainty}`,
109
- `budget: ${manifest.budget.status} (${manifest.budget.selectedRuleCount}/${manifest.budget.maxRecommendedRuleCount} recommended rules)`,
110
- `fallbackRequired: ${manifest.fallbackRequired}`,
111
- ...formatList('contextFiles', manifest.contextFiles),
112
- ...formatList('selectedRules', manifest.selectedRules),
113
- ...formatList('selectedPrompts', manifest.selectedPrompts),
114
- ...formatList('selectedDocs', manifest.selectedDocs),
115
- ].join('\n');
116
- }
117
-
118
- export async function runContextCommand(commandArguments) {
119
- const contextOptions = parseContextArguments(commandArguments);
120
- const requestText = contextOptions.readStdin
121
- ? await readRequestFromStdin()
122
- : contextOptions.requestText;
123
-
124
- if (!requestText) {
125
- throw new Error('Context request text is required. Pass text as arguments or use --stdin.');
126
- }
127
-
128
- const manifest = buildSelectedContextManifest({
129
- contextFiles: contextOptions.contextFiles,
130
- requestId: contextOptions.requestId,
131
- requestText,
132
- });
133
-
134
- if (contextOptions.json) {
135
- console.log(JSON.stringify(manifest, null, 2));
136
- return;
137
- }
138
-
139
- console.log(formatManifestText(manifest));
140
- }