@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.
- package/.agents/plugins/agentic-senior-core/plugin.json +3 -0
- package/.agents/plugins/agentic-senior-core/rules/agentic-senior-core.md +131 -0
- package/.agents/plugins/agentic-senior-core/skills/asc/SKILL.md +16 -0
- package/.agents/plugins/agentic-senior-core/skills/asc-audit/SKILL.md +28 -0
- package/.agents/plugins/agentic-senior-core/skills/asc-refactor/SKILL.md +35 -0
- package/.agents/plugins/agentic-senior-core/skills/asc-review/SKILL.md +54 -0
- package/.agents/rules/agentic-senior-core.md +131 -0
- package/.claude-plugin/marketplace.json +17 -0
- package/.claude-plugin/plugin.json +17 -0
- package/.clinerules/agentic-senior-core.md +94 -0
- package/.codex-plugin/plugin.json +24 -0
- package/.cursor/rules/agentic-senior-core.mdc +99 -0
- package/.devin-plugin/plugin.json +13 -0
- package/.github/copilot-instructions.md +94 -0
- package/.github/plugin/marketplace.json +20 -0
- package/.github/plugin/plugin.json +16 -0
- package/.kiro/steering/agentic-senior-core.md +94 -0
- package/.openclaw/skills/asc/SKILL.md +23 -0
- package/.openclaw/skills/asc-audit/SKILL.md +28 -0
- package/.openclaw/skills/asc-review/SKILL.md +54 -0
- package/.opencode/plugins/agentic-senior-core.mjs +31 -0
- package/.windsurf/rules/agentic-senior-core.md +94 -0
- package/AGENTS.md +126 -127
- package/CONTRIBUTING.md +93 -63
- package/README.md +190 -110
- package/__init__.py +61 -0
- package/bin/agentic-senior-core.js +42 -41
- package/commands/asc-audit.md +1 -0
- package/commands/asc-audit.toml +2 -0
- package/commands/asc-help.md +9 -0
- package/commands/asc-help.toml +2 -0
- package/commands/asc-refactor.md +1 -0
- package/commands/asc-refactor.toml +2 -0
- package/commands/asc-review.md +1 -0
- package/commands/asc-review.toml +2 -0
- package/gemini-extension.json +10 -0
- package/hooks/copilot-hooks.json +21 -0
- package/hooks/hooks.json +31 -0
- package/hooks/session-start.js +36 -0
- package/hooks/subagent-start.js +38 -0
- package/lib/cli/commands/adapter.mjs +109 -0
- package/lib/cli/commands/clean.mjs +63 -0
- package/lib/cli/commands/status.mjs +94 -0
- package/package.json +43 -60
- package/plugin.yaml +16 -0
- package/scripts/uninstall.js +38 -0
- package/skills/asc/SKILL.md +16 -0
- package/skills/asc-audit/SKILL.md +28 -0
- package/skills/asc-refactor/SKILL.md +35 -0
- package/skills/asc-review/SKILL.md +54 -0
- package/.agent-context/policies/llm-judge-threshold.json +0 -29
- package/.agent-context/prompts/bootstrap-design.md +0 -63
- package/.agent-context/prompts/compact-natural-mode.md +0 -100
- package/.agent-context/prompts/init-project.md +0 -60
- package/.agent-context/prompts/refactor.md +0 -38
- package/.agent-context/prompts/review-code.md +0 -31
- package/.agent-context/review-checklists/architecture-review.md +0 -57
- package/.agent-context/review-checklists/pr-checklist.md +0 -134
- package/.agent-context/rules/api-docs.md +0 -24
- package/.agent-context/rules/api-versioning.md +0 -16
- package/.agent-context/rules/architecture.md +0 -38
- package/.agent-context/rules/background-jobs.md +0 -17
- package/.agent-context/rules/config-and-flags.md +0 -16
- package/.agent-context/rules/database-design.md +0 -18
- package/.agent-context/rules/docker-runtime.md +0 -17
- package/.agent-context/rules/error-handling.md +0 -16
- package/.agent-context/rules/event-driven.md +0 -16
- package/.agent-context/rules/frontend-architecture.md +0 -54
- package/.agent-context/rules/microservices.md +0 -16
- package/.agent-context/rules/migrations.md +0 -16
- package/.agent-context/rules/observability.md +0 -16
- package/.agent-context/rules/performance.md +0 -16
- package/.agent-context/rules/realtime.md +0 -16
- package/.agent-context/rules/resilience.md +0 -18
- package/.agent-context/rules/security.md +0 -18
- package/.agent-context/rules/testing.md +0 -16
- package/.agent-context/state/README.md +0 -25
- package/.agent-context/state/architecture-map.md +0 -40
- package/.agent-context/state/benchmark-comparison-schema.json +0 -181
- package/.agent-context/state/benchmark-reproducibility.json +0 -87
- package/.agent-context/state/benchmark-thresholds.json +0 -10
- package/.agent-context/state/benchmark-writer-judge-config.json +0 -58
- package/.agent-context/state/dependency-map.md +0 -41
- package/.agent-context/state/memory-adapter-contract.json +0 -52
- package/.agent-context/state/memory-schema-v1.json +0 -88
- package/GEMINI.md +0 -1
- package/benchmarks/README.md +0 -60
- package/benchmarks/compact-natural-mode/fixtures.mjs +0 -359
- package/benchmarks/compact-natural-mode/scorer.mjs +0 -331
- package/benchmarks/runtime-token-saver/fixtures.mjs +0 -836
- package/lib/cli/adaptive-context/catalog.mjs +0 -394
- package/lib/cli/adaptive-context/file-signals.mjs +0 -100
- package/lib/cli/adaptive-context/implications.mjs +0 -44
- package/lib/cli/adaptive-context.mjs +0 -151
- package/lib/cli/audits/typography-palette-anti-repeat/color-utils.mjs +0 -156
- package/lib/cli/audits/typography-palette-anti-repeat/file-scanner.mjs +0 -103
- package/lib/cli/audits/typography-palette-anti-repeat/typography-utils.mjs +0 -70
- package/lib/cli/backup.mjs +0 -210
- package/lib/cli/commands/context.mjs +0 -140
- package/lib/cli/commands/init/project-context.mjs +0 -60
- package/lib/cli/commands/init/runtime-environment.mjs +0 -59
- package/lib/cli/commands/init/setup-decisions.mjs +0 -83
- package/lib/cli/commands/init.mjs +0 -654
- package/lib/cli/commands/launch.mjs +0 -76
- package/lib/cli/commands/optimize.mjs +0 -284
- package/lib/cli/commands/rollback.mjs +0 -64
- package/lib/cli/commands/upgrade/token-optimization-state.mjs +0 -51
- package/lib/cli/commands/upgrade.mjs +0 -451
- package/lib/cli/compiler.mjs +0 -187
- package/lib/cli/constants.mjs +0 -136
- package/lib/cli/detector/constants.mjs +0 -135
- package/lib/cli/detector/design-evidence/collector.mjs +0 -256
- package/lib/cli/detector/design-evidence/constants.mjs +0 -39
- package/lib/cli/detector/design-evidence/file-traversal.mjs +0 -83
- package/lib/cli/detector/design-evidence/structured-attribute-evidence.mjs +0 -117
- package/lib/cli/detector/design-evidence/summary.mjs +0 -109
- package/lib/cli/detector/design-evidence/utility-helpers.mjs +0 -122
- package/lib/cli/detector/design-evidence.mjs +0 -25
- package/lib/cli/detector/stack-detection.mjs +0 -243
- package/lib/cli/detector/ui-signals.mjs +0 -150
- package/lib/cli/detector/workspace-scan.mjs +0 -177
- package/lib/cli/detector.mjs +0 -23
- package/lib/cli/init-detection-flow.mjs +0 -48
- package/lib/cli/init-options.mjs +0 -237
- package/lib/cli/init-selection.mjs +0 -29
- package/lib/cli/memory-continuity.mjs +0 -537
- package/lib/cli/preflight.mjs +0 -76
- package/lib/cli/project-scaffolder/constants.mjs +0 -69
- package/lib/cli/project-scaffolder/discovery.mjs +0 -272
- package/lib/cli/project-scaffolder/prompt-builders.mjs +0 -171
- package/lib/cli/project-scaffolder/storage.mjs +0 -144
- package/lib/cli/project-scaffolder/ui-scope-detection.mjs +0 -36
- package/lib/cli/project-scaffolder.mjs +0 -29
- package/lib/cli/rollback.mjs +0 -66
- package/lib/cli/token-optimization.mjs +0 -401
- package/lib/cli/utils/filesystem.mjs +0 -81
- package/lib/cli/utils/managed-surface.mjs +0 -280
- package/lib/cli/utils/prompting.mjs +0 -44
- package/lib/cli/utils.mjs +0 -479
- package/mcp.json +0 -134
- package/scripts/adaptive-context/fixtures.mjs +0 -183
- package/scripts/adaptive-context-benchmark.mjs +0 -9
- package/scripts/ascx-runtime-token-saver-benchmark.mjs +0 -9
- package/scripts/benchmark-evidence-bundle.mjs +0 -645
- package/scripts/benchmark-gate.mjs +0 -121
- package/scripts/benchmark-intelligence.mjs +0 -33
- package/scripts/benchmark-writer-judge-matrix.mjs +0 -379
- package/scripts/build-release-benchmark-bundle.mjs +0 -202
- package/scripts/bump-version.mjs +0 -103
- package/scripts/clean-local-artifacts.mjs +0 -78
- package/scripts/compact-natural-mode-benchmark.mjs +0 -9
- package/scripts/context-triggered-audit.mjs +0 -391
- package/scripts/detection-benchmark.mjs +0 -127
- package/scripts/docs-quality-drift-report.mjs +0 -358
- package/scripts/documentation-boundary-audit.mjs +0 -305
- package/scripts/explain-on-demand-audit.mjs +0 -427
- package/scripts/forbidden-content-check.mjs +0 -123
- package/scripts/frontend-usability-audit.mjs +0 -243
- package/scripts/generate-sbom.mjs +0 -61
- package/scripts/governance-weekly-report.mjs +0 -466
- package/scripts/llm-judge/checklist-loader.mjs +0 -45
- package/scripts/llm-judge/constants.mjs +0 -66
- package/scripts/llm-judge/diff-collection.mjs +0 -74
- package/scripts/llm-judge/prompting.mjs +0 -78
- package/scripts/llm-judge/providers.mjs +0 -111
- package/scripts/llm-judge/verdict.mjs +0 -134
- package/scripts/llm-judge.mjs +0 -200
- package/scripts/memory-continuity-benchmark.mjs +0 -322
- package/scripts/quality-trend-report.mjs +0 -289
- package/scripts/release-gate/audit-checks.mjs +0 -441
- package/scripts/release-gate/constants.mjs +0 -53
- package/scripts/release-gate/runtime.mjs +0 -63
- package/scripts/release-gate/static-checks.mjs +0 -182
- package/scripts/release-gate.mjs +0 -42
- package/scripts/rules-guardian-audit.mjs +0 -580
- package/scripts/single-source-lazy-loading-audit.mjs +0 -449
- package/scripts/sync-thin-adapters.mjs +0 -72
- package/scripts/token-optimization-benchmark.mjs +0 -252
- package/scripts/ui-design-judge/constants.mjs +0 -13
- package/scripts/ui-design-judge/design-execution-summary.mjs +0 -81
- package/scripts/ui-design-judge/git-input.mjs +0 -134
- package/scripts/ui-design-judge/prompting.mjs +0 -52
- package/scripts/ui-design-judge/providers.mjs +0 -102
- package/scripts/ui-design-judge/reporting.mjs +0 -183
- package/scripts/ui-design-judge/rubric-calibration.mjs +0 -214
- package/scripts/ui-design-judge/rubric-goldset.json +0 -188
- package/scripts/ui-design-judge.mjs +0 -319
- package/scripts/ui-rubric-calibration.mjs +0 -35
- package/scripts/validate/audits/cache-layer-contract.mjs +0 -230
- package/scripts/validate/audits/caching-scope-hygiene.mjs +0 -235
- package/scripts/validate/audits/file-size.mjs +0 -158
- package/scripts/validate/audits/reflection-citations.mjs +0 -130
- package/scripts/validate/audits/release-bundle.mjs +0 -135
- package/scripts/validate/audits/rule-id-uniqueness.mjs +0 -278
- package/scripts/validate/config.mjs +0 -501
- package/scripts/validate/coverage-checks.mjs +0 -446
- package/scripts/validate/file-structure.mjs +0 -158
- package/scripts/validate/markdown-content.mjs +0 -109
- package/scripts/validate/project-metadata.mjs +0 -166
- package/scripts/validate/utils.mjs +0 -52
- 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
|
-
}
|
package/lib/cli/backup.mjs
DELETED
|
@@ -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
|
-
}
|