@ryuenn3123/agentic-senior-core 4.4.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (201) hide show
  1. package/.agents/plugins/agentic-senior-core/plugin.json +3 -0
  2. package/.agents/plugins/agentic-senior-core/rules/agentic-senior-core.md +131 -0
  3. package/.agents/plugins/agentic-senior-core/skills/asc/SKILL.md +16 -0
  4. package/.agents/plugins/agentic-senior-core/skills/asc-audit/SKILL.md +28 -0
  5. package/.agents/plugins/agentic-senior-core/skills/asc-refactor/SKILL.md +35 -0
  6. package/.agents/plugins/agentic-senior-core/skills/asc-review/SKILL.md +54 -0
  7. package/.agents/rules/agentic-senior-core.md +131 -0
  8. package/.claude-plugin/marketplace.json +17 -0
  9. package/.claude-plugin/plugin.json +17 -0
  10. package/.clinerules/agentic-senior-core.md +94 -0
  11. package/.codex-plugin/plugin.json +24 -0
  12. package/.cursor/rules/agentic-senior-core.mdc +99 -0
  13. package/.devin-plugin/plugin.json +13 -0
  14. package/.github/copilot-instructions.md +94 -0
  15. package/.github/plugin/marketplace.json +20 -0
  16. package/.github/plugin/plugin.json +16 -0
  17. package/.kiro/steering/agentic-senior-core.md +94 -0
  18. package/.openclaw/skills/asc/SKILL.md +23 -0
  19. package/.openclaw/skills/asc-audit/SKILL.md +28 -0
  20. package/.openclaw/skills/asc-review/SKILL.md +54 -0
  21. package/.opencode/plugins/agentic-senior-core.mjs +31 -0
  22. package/.windsurf/rules/agentic-senior-core.md +94 -0
  23. package/AGENTS.md +126 -127
  24. package/CONTRIBUTING.md +93 -63
  25. package/README.md +190 -110
  26. package/__init__.py +61 -0
  27. package/bin/agentic-senior-core.js +42 -41
  28. package/commands/asc-audit.md +1 -0
  29. package/commands/asc-audit.toml +2 -0
  30. package/commands/asc-help.md +9 -0
  31. package/commands/asc-help.toml +2 -0
  32. package/commands/asc-refactor.md +1 -0
  33. package/commands/asc-refactor.toml +2 -0
  34. package/commands/asc-review.md +1 -0
  35. package/commands/asc-review.toml +2 -0
  36. package/gemini-extension.json +10 -0
  37. package/hooks/copilot-hooks.json +21 -0
  38. package/hooks/hooks.json +31 -0
  39. package/hooks/session-start.js +36 -0
  40. package/hooks/subagent-start.js +38 -0
  41. package/lib/cli/commands/adapter.mjs +109 -0
  42. package/lib/cli/commands/clean.mjs +63 -0
  43. package/lib/cli/commands/status.mjs +94 -0
  44. package/package.json +43 -60
  45. package/plugin.yaml +16 -0
  46. package/scripts/uninstall.js +38 -0
  47. package/skills/asc/SKILL.md +16 -0
  48. package/skills/asc-audit/SKILL.md +28 -0
  49. package/skills/asc-refactor/SKILL.md +35 -0
  50. package/skills/asc-review/SKILL.md +54 -0
  51. package/.agent-context/policies/llm-judge-threshold.json +0 -29
  52. package/.agent-context/prompts/bootstrap-design.md +0 -63
  53. package/.agent-context/prompts/compact-natural-mode.md +0 -100
  54. package/.agent-context/prompts/init-project.md +0 -60
  55. package/.agent-context/prompts/refactor.md +0 -38
  56. package/.agent-context/prompts/review-code.md +0 -31
  57. package/.agent-context/review-checklists/architecture-review.md +0 -57
  58. package/.agent-context/review-checklists/pr-checklist.md +0 -134
  59. package/.agent-context/rules/api-docs.md +0 -24
  60. package/.agent-context/rules/api-versioning.md +0 -16
  61. package/.agent-context/rules/architecture.md +0 -38
  62. package/.agent-context/rules/background-jobs.md +0 -17
  63. package/.agent-context/rules/config-and-flags.md +0 -16
  64. package/.agent-context/rules/database-design.md +0 -18
  65. package/.agent-context/rules/docker-runtime.md +0 -17
  66. package/.agent-context/rules/error-handling.md +0 -16
  67. package/.agent-context/rules/event-driven.md +0 -16
  68. package/.agent-context/rules/frontend-architecture.md +0 -54
  69. package/.agent-context/rules/microservices.md +0 -16
  70. package/.agent-context/rules/migrations.md +0 -16
  71. package/.agent-context/rules/observability.md +0 -16
  72. package/.agent-context/rules/performance.md +0 -16
  73. package/.agent-context/rules/realtime.md +0 -16
  74. package/.agent-context/rules/resilience.md +0 -18
  75. package/.agent-context/rules/security.md +0 -18
  76. package/.agent-context/rules/testing.md +0 -16
  77. package/.agent-context/state/README.md +0 -25
  78. package/.agent-context/state/architecture-map.md +0 -40
  79. package/.agent-context/state/benchmark-comparison-schema.json +0 -181
  80. package/.agent-context/state/benchmark-reproducibility.json +0 -87
  81. package/.agent-context/state/benchmark-thresholds.json +0 -10
  82. package/.agent-context/state/benchmark-writer-judge-config.json +0 -58
  83. package/.agent-context/state/dependency-map.md +0 -41
  84. package/.agent-context/state/memory-adapter-contract.json +0 -52
  85. package/.agent-context/state/memory-schema-v1.json +0 -88
  86. package/GEMINI.md +0 -1
  87. package/benchmarks/README.md +0 -60
  88. package/benchmarks/compact-natural-mode/fixtures.mjs +0 -359
  89. package/benchmarks/compact-natural-mode/scorer.mjs +0 -331
  90. package/benchmarks/runtime-token-saver/fixtures.mjs +0 -836
  91. package/lib/cli/adaptive-context/catalog.mjs +0 -394
  92. package/lib/cli/adaptive-context/file-signals.mjs +0 -100
  93. package/lib/cli/adaptive-context/implications.mjs +0 -44
  94. package/lib/cli/adaptive-context.mjs +0 -151
  95. package/lib/cli/audits/typography-palette-anti-repeat/color-utils.mjs +0 -156
  96. package/lib/cli/audits/typography-palette-anti-repeat/file-scanner.mjs +0 -103
  97. package/lib/cli/audits/typography-palette-anti-repeat/typography-utils.mjs +0 -70
  98. package/lib/cli/backup.mjs +0 -210
  99. package/lib/cli/commands/context.mjs +0 -140
  100. package/lib/cli/commands/init/project-context.mjs +0 -60
  101. package/lib/cli/commands/init/runtime-environment.mjs +0 -59
  102. package/lib/cli/commands/init/setup-decisions.mjs +0 -83
  103. package/lib/cli/commands/init.mjs +0 -654
  104. package/lib/cli/commands/launch.mjs +0 -76
  105. package/lib/cli/commands/optimize.mjs +0 -284
  106. package/lib/cli/commands/rollback.mjs +0 -64
  107. package/lib/cli/commands/upgrade/token-optimization-state.mjs +0 -51
  108. package/lib/cli/commands/upgrade.mjs +0 -451
  109. package/lib/cli/compiler.mjs +0 -187
  110. package/lib/cli/constants.mjs +0 -136
  111. package/lib/cli/detector/constants.mjs +0 -135
  112. package/lib/cli/detector/design-evidence/collector.mjs +0 -256
  113. package/lib/cli/detector/design-evidence/constants.mjs +0 -39
  114. package/lib/cli/detector/design-evidence/file-traversal.mjs +0 -83
  115. package/lib/cli/detector/design-evidence/structured-attribute-evidence.mjs +0 -117
  116. package/lib/cli/detector/design-evidence/summary.mjs +0 -109
  117. package/lib/cli/detector/design-evidence/utility-helpers.mjs +0 -122
  118. package/lib/cli/detector/design-evidence.mjs +0 -25
  119. package/lib/cli/detector/stack-detection.mjs +0 -243
  120. package/lib/cli/detector/ui-signals.mjs +0 -150
  121. package/lib/cli/detector/workspace-scan.mjs +0 -177
  122. package/lib/cli/detector.mjs +0 -23
  123. package/lib/cli/init-detection-flow.mjs +0 -48
  124. package/lib/cli/init-options.mjs +0 -237
  125. package/lib/cli/init-selection.mjs +0 -29
  126. package/lib/cli/memory-continuity.mjs +0 -537
  127. package/lib/cli/preflight.mjs +0 -76
  128. package/lib/cli/project-scaffolder/constants.mjs +0 -69
  129. package/lib/cli/project-scaffolder/discovery.mjs +0 -272
  130. package/lib/cli/project-scaffolder/prompt-builders.mjs +0 -171
  131. package/lib/cli/project-scaffolder/storage.mjs +0 -144
  132. package/lib/cli/project-scaffolder/ui-scope-detection.mjs +0 -36
  133. package/lib/cli/project-scaffolder.mjs +0 -29
  134. package/lib/cli/rollback.mjs +0 -66
  135. package/lib/cli/token-optimization.mjs +0 -401
  136. package/lib/cli/utils/filesystem.mjs +0 -81
  137. package/lib/cli/utils/managed-surface.mjs +0 -280
  138. package/lib/cli/utils/prompting.mjs +0 -44
  139. package/lib/cli/utils.mjs +0 -479
  140. package/mcp.json +0 -134
  141. package/scripts/adaptive-context/fixtures.mjs +0 -183
  142. package/scripts/adaptive-context-benchmark.mjs +0 -9
  143. package/scripts/ascx-runtime-token-saver-benchmark.mjs +0 -9
  144. package/scripts/benchmark-evidence-bundle.mjs +0 -645
  145. package/scripts/benchmark-gate.mjs +0 -121
  146. package/scripts/benchmark-intelligence.mjs +0 -33
  147. package/scripts/benchmark-writer-judge-matrix.mjs +0 -379
  148. package/scripts/build-release-benchmark-bundle.mjs +0 -202
  149. package/scripts/bump-version.mjs +0 -103
  150. package/scripts/clean-local-artifacts.mjs +0 -78
  151. package/scripts/compact-natural-mode-benchmark.mjs +0 -9
  152. package/scripts/context-triggered-audit.mjs +0 -391
  153. package/scripts/detection-benchmark.mjs +0 -127
  154. package/scripts/docs-quality-drift-report.mjs +0 -358
  155. package/scripts/documentation-boundary-audit.mjs +0 -305
  156. package/scripts/explain-on-demand-audit.mjs +0 -427
  157. package/scripts/forbidden-content-check.mjs +0 -123
  158. package/scripts/frontend-usability-audit.mjs +0 -243
  159. package/scripts/generate-sbom.mjs +0 -61
  160. package/scripts/governance-weekly-report.mjs +0 -466
  161. package/scripts/llm-judge/checklist-loader.mjs +0 -45
  162. package/scripts/llm-judge/constants.mjs +0 -66
  163. package/scripts/llm-judge/diff-collection.mjs +0 -74
  164. package/scripts/llm-judge/prompting.mjs +0 -78
  165. package/scripts/llm-judge/providers.mjs +0 -111
  166. package/scripts/llm-judge/verdict.mjs +0 -134
  167. package/scripts/llm-judge.mjs +0 -200
  168. package/scripts/memory-continuity-benchmark.mjs +0 -322
  169. package/scripts/quality-trend-report.mjs +0 -289
  170. package/scripts/release-gate/audit-checks.mjs +0 -441
  171. package/scripts/release-gate/constants.mjs +0 -53
  172. package/scripts/release-gate/runtime.mjs +0 -63
  173. package/scripts/release-gate/static-checks.mjs +0 -182
  174. package/scripts/release-gate.mjs +0 -42
  175. package/scripts/rules-guardian-audit.mjs +0 -580
  176. package/scripts/single-source-lazy-loading-audit.mjs +0 -449
  177. package/scripts/sync-thin-adapters.mjs +0 -72
  178. package/scripts/token-optimization-benchmark.mjs +0 -252
  179. package/scripts/ui-design-judge/constants.mjs +0 -13
  180. package/scripts/ui-design-judge/design-execution-summary.mjs +0 -81
  181. package/scripts/ui-design-judge/git-input.mjs +0 -134
  182. package/scripts/ui-design-judge/prompting.mjs +0 -52
  183. package/scripts/ui-design-judge/providers.mjs +0 -102
  184. package/scripts/ui-design-judge/reporting.mjs +0 -183
  185. package/scripts/ui-design-judge/rubric-calibration.mjs +0 -214
  186. package/scripts/ui-design-judge/rubric-goldset.json +0 -188
  187. package/scripts/ui-design-judge.mjs +0 -319
  188. package/scripts/ui-rubric-calibration.mjs +0 -35
  189. package/scripts/validate/audits/cache-layer-contract.mjs +0 -230
  190. package/scripts/validate/audits/caching-scope-hygiene.mjs +0 -235
  191. package/scripts/validate/audits/file-size.mjs +0 -158
  192. package/scripts/validate/audits/reflection-citations.mjs +0 -130
  193. package/scripts/validate/audits/release-bundle.mjs +0 -135
  194. package/scripts/validate/audits/rule-id-uniqueness.mjs +0 -278
  195. package/scripts/validate/config.mjs +0 -501
  196. package/scripts/validate/coverage-checks.mjs +0 -446
  197. package/scripts/validate/file-structure.mjs +0 -158
  198. package/scripts/validate/markdown-content.mjs +0 -109
  199. package/scripts/validate/project-metadata.mjs +0 -166
  200. package/scripts/validate/utils.mjs +0 -52
  201. package/scripts/validate.mjs +0 -267
@@ -1,427 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * explain-on-demand-audit.mjs
5
- *
6
- * Enforces invisible state management defaults and explicit diagnostic
7
- * visibility rules for state internals.
8
- */
9
-
10
- import { existsSync, readFileSync } from 'node:fs';
11
- import { execFileSync } from 'node:child_process';
12
- import { dirname, resolve } from 'node:path';
13
- import { fileURLToPath } from 'node:url';
14
-
15
- const __filename = fileURLToPath(import.meta.url);
16
- const __dirname = dirname(__filename);
17
- const REPOSITORY_ROOT = resolve(__dirname, '..');
18
-
19
- const ONBOARDING_REPORT_PATH = '.agent-context/state/onboarding-report.json';
20
- const ARCHITECTURE_RULE_PATH = '.agent-context/rules/architecture.md';
21
- const PR_CHECKLIST_PATH = '.agent-context/review-checklists/pr-checklist.md';
22
- const REVIEW_PROMPT_PATH = '.agent-context/prompts/review-code.md';
23
-
24
- const DEFAULT_MODE = 'default';
25
- const SUPPORTED_MODES = new Set([DEFAULT_MODE, 'diagnostic']);
26
- const DEFAULT_WORKFLOW = 'standard';
27
-
28
- const REQUIRED_ARCHITECTURE_RULE_SNIPPETS = [
29
- '## ARCH-006: Invisible State Management with Explain-on-Demand',
30
- 'Default responses must avoid unnecessary state-file internals.',
31
- 'State internals are exposed only on explicit user request.',
32
- 'Diagnostic mode explains relevant state decisions when needed.',
33
- ];
34
-
35
- const REQUIRED_PR_CHECKLIST_SNIPPETS = [
36
- 'Default responses avoid unnecessary state-file internals',
37
- 'State internals are exposed only on explicit request',
38
- 'Diagnostic mode can explain relevant state decisions when needed',
39
- ];
40
-
41
- const REQUIRED_REVIEW_PROMPT_SNIPPETS = [
42
- 'Review the code with a production-risk mindset.',
43
- ];
44
-
45
- const INTERNAL_STATE_SIGNAL_PATTERNS = [
46
- /\.agent-context\/state\//i,
47
- /\bautoDetection\b/i,
48
- /\brankedCandidates\b/i,
49
- /\bconfidenceGap\b/i,
50
- /\bschemaVersion\b/i,
51
- ];
52
-
53
- function pushResult(results, isPassed, checkName, details) {
54
- results.push({
55
- checkName,
56
- passed: isPassed,
57
- details,
58
- });
59
- }
60
-
61
- function normalizeFilePath(filePath) {
62
- return filePath.replace(/\\/g, '/').replace(/^\.\//, '');
63
- }
64
-
65
- function parseGitFileList(rawOutput) {
66
- if (typeof rawOutput !== 'string' || rawOutput.trim().length === 0) {
67
- return [];
68
- }
69
-
70
- return rawOutput
71
- .split(/\r?\n/)
72
- .map((filePath) => filePath.trim())
73
- .filter((filePath) => filePath.length > 0)
74
- .map(normalizeFilePath);
75
- }
76
-
77
- function runGitFileQuery(commandArguments) {
78
- try {
79
- const rawOutput = execFileSync('git', commandArguments, {
80
- cwd: REPOSITORY_ROOT,
81
- encoding: 'utf8',
82
- maxBuffer: 1024 * 1024,
83
- stdio: ['ignore', 'pipe', 'ignore'],
84
- });
85
-
86
- return parseGitFileList(rawOutput);
87
- } catch {
88
- return [];
89
- }
90
- }
91
-
92
- function uniqueSorted(filePaths) {
93
- return Array.from(new Set(filePaths)).sort((leftPath, rightPath) => leftPath.localeCompare(rightPath));
94
- }
95
-
96
- function collectChangedFiles() {
97
- const workingTreeFiles = runGitFileQuery(['diff', '--name-only']);
98
- const stagedFiles = runGitFileQuery(['diff', '--name-only', '--cached']);
99
- const workingScopeFiles = uniqueSorted([...workingTreeFiles, ...stagedFiles]);
100
-
101
- if (workingScopeFiles.length > 0) {
102
- return {
103
- source: 'working-tree-and-index',
104
- files: workingScopeFiles,
105
- };
106
- }
107
-
108
- const latestCommitRangeFiles = runGitFileQuery(['diff', '--name-only', 'HEAD~1..HEAD']);
109
- if (latestCommitRangeFiles.length > 0) {
110
- return {
111
- source: 'latest-commit-range',
112
- files: uniqueSorted(latestCommitRangeFiles),
113
- };
114
- }
115
-
116
- const headCommitFiles = runGitFileQuery(['show', '--pretty=format:', '--name-only', 'HEAD']);
117
- if (headCommitFiles.length > 0) {
118
- return {
119
- source: 'head-commit',
120
- files: uniqueSorted(headCommitFiles),
121
- };
122
- }
123
-
124
- return {
125
- source: 'none',
126
- files: [],
127
- };
128
- }
129
-
130
- function readText(relativeFilePath) {
131
- const absolutePath = resolve(REPOSITORY_ROOT, relativeFilePath);
132
- if (!existsSync(absolutePath)) {
133
- return '';
134
- }
135
-
136
- return readFileSync(absolutePath, 'utf8');
137
- }
138
-
139
- function parseOnboardingReport(onboardingReportContent) {
140
- if (typeof onboardingReportContent !== 'string' || onboardingReportContent.trim().length === 0) {
141
- return null;
142
- }
143
-
144
- try {
145
- return JSON.parse(onboardingReportContent);
146
- } catch {
147
- return null;
148
- }
149
- }
150
-
151
- function parseCliArguments(argumentList) {
152
- let mode = DEFAULT_MODE;
153
- let workflow = DEFAULT_WORKFLOW;
154
- let explicitStateRequest = false;
155
-
156
- for (let argumentIndex = 0; argumentIndex < argumentList.length; argumentIndex += 1) {
157
- const argumentValue = argumentList[argumentIndex];
158
-
159
- if (argumentValue === '--state-debug') {
160
- explicitStateRequest = true;
161
- continue;
162
- }
163
-
164
- if (argumentValue === '--mode') {
165
- const nextArgumentValue = argumentList[argumentIndex + 1];
166
- if (nextArgumentValue && !nextArgumentValue.startsWith('--')) {
167
- mode = nextArgumentValue;
168
- argumentIndex += 1;
169
- }
170
- continue;
171
- }
172
-
173
- if (argumentValue.startsWith('--mode=')) {
174
- mode = argumentValue.slice('--mode='.length);
175
- continue;
176
- }
177
-
178
- if (argumentValue === '--workflow') {
179
- const nextArgumentValue = argumentList[argumentIndex + 1];
180
- if (nextArgumentValue && !nextArgumentValue.startsWith('--')) {
181
- workflow = nextArgumentValue;
182
- argumentIndex += 1;
183
- }
184
- continue;
185
- }
186
-
187
- if (argumentValue.startsWith('--workflow=')) {
188
- workflow = argumentValue.slice('--workflow='.length);
189
- }
190
- }
191
-
192
- const normalizedMode = String(mode || '').trim().toLowerCase();
193
-
194
- return {
195
- mode: SUPPORTED_MODES.has(normalizedMode) ? normalizedMode : DEFAULT_MODE,
196
- workflow: String(workflow || '').trim().toLowerCase() || DEFAULT_WORKFLOW,
197
- explicitStateRequest,
198
- };
199
- }
200
-
201
- function assertSnippetCoverage(sourceLabel, sourcePath, requiredSnippets, failures, results) {
202
- const sourceContent = readText(sourcePath);
203
-
204
- if (!sourceContent) {
205
- failures.push(`Missing ${sourceLabel} source: ${sourcePath}`);
206
- pushResult(results, false, `${sourceLabel}-source-exists`, `Missing ${sourcePath}`);
207
- return;
208
- }
209
-
210
- pushResult(results, true, `${sourceLabel}-source-exists`, `${sourcePath} is present`);
211
-
212
- const missingSnippets = requiredSnippets.filter((requiredSnippet) => !sourceContent.includes(requiredSnippet));
213
-
214
- if (missingSnippets.length > 0) {
215
- failures.push(`Missing ${sourceLabel} snippets: ${missingSnippets.join(', ')}`);
216
- pushResult(
217
- results,
218
- false,
219
- `${sourceLabel}-source-coverage`,
220
- `Missing snippets in ${sourcePath}: ${missingSnippets.join(', ')}`
221
- );
222
- return;
223
- }
224
-
225
- pushResult(results, true, `${sourceLabel}-source-coverage`, `${sourceLabel} snippets are complete`);
226
- }
227
-
228
- function buildDefaultResponseSummary(onboardingReport) {
229
- const runtimeDecision = String(onboardingReport?.runtimeDecision?.mode || onboardingReport?.selectedStack || 'unknown-runtime-decision').trim() || 'unknown-runtime-decision';
230
- const architectureDecision = String(onboardingReport?.architectureDecision?.mode || onboardingReport?.selectedBlueprint || 'unknown-architecture-decision').trim() || 'unknown-architecture-decision';
231
- const selectedProfile = String(onboardingReport?.selectedProfile || 'unknown-profile').trim() || 'unknown-profile';
232
-
233
- return `Active setup summary: runtimeDecision=${runtimeDecision}, architectureDecision=${architectureDecision}, profile=${selectedProfile}.`;
234
- }
235
-
236
- function detectInternalSignals(textValue) {
237
- const normalizedText = String(textValue || '');
238
- return INTERNAL_STATE_SIGNAL_PATTERNS.some((signalPattern) => signalPattern.test(normalizedText));
239
- }
240
-
241
- function buildDiagnosticDecisionSummaries(onboardingReport) {
242
- const explanations = [];
243
-
244
- const runtimeDecision = String(onboardingReport?.runtimeDecision?.mode || onboardingReport?.selectedStack || '').trim();
245
- if (runtimeDecision) {
246
- explanations.push(`Runtime decision: ${runtimeDecision}.`);
247
- }
248
-
249
- const architectureDecision = String(onboardingReport?.architectureDecision?.mode || onboardingReport?.selectedBlueprint || '').trim();
250
- if (architectureDecision) {
251
- explanations.push(`Architecture decision: ${architectureDecision}.`);
252
- }
253
-
254
- const selectedProfile = String(onboardingReport?.selectedProfile || '').trim();
255
- if (selectedProfile) {
256
- explanations.push(`Profile decision: selectedProfile=${selectedProfile}.`);
257
- }
258
-
259
- const detectionReasoning = String(onboardingReport?.autoDetection?.detectionReasoning || '').trim();
260
- if (detectionReasoning) {
261
- explanations.push(`Detection reasoning: ${detectionReasoning}`);
262
- }
263
-
264
- if (typeof onboardingReport?.ciGuardrailsEnabled === 'boolean') {
265
- explanations.push(`CI guardrails decision: ciGuardrailsEnabled=${String(onboardingReport.ciGuardrailsEnabled)}.`);
266
- }
267
-
268
- return explanations;
269
- }
270
-
271
- function runAudit() {
272
- const parsedArguments = parseCliArguments(process.argv.slice(2));
273
- const changedScope = collectChangedFiles();
274
- const changedFiles = changedScope.files;
275
- const results = [];
276
- const failures = [];
277
- const warnings = [];
278
-
279
- pushResult(results, true, 'context-workflow', `workflow=${parsedArguments.workflow}`);
280
- pushResult(results, true, 'explain-mode', `mode=${parsedArguments.mode}`);
281
- pushResult(
282
- results,
283
- true,
284
- 'state-debug-explicit-request',
285
- parsedArguments.explicitStateRequest
286
- ? 'Explicit state diagnostic request received'
287
- : 'No explicit state diagnostic request provided'
288
- );
289
-
290
- assertSnippetCoverage(
291
- 'explain-on-demand-architecture-rule',
292
- ARCHITECTURE_RULE_PATH,
293
- REQUIRED_ARCHITECTURE_RULE_SNIPPETS,
294
- failures,
295
- results
296
- );
297
-
298
- assertSnippetCoverage(
299
- 'explain-on-demand-pr-checklist',
300
- PR_CHECKLIST_PATH,
301
- REQUIRED_PR_CHECKLIST_SNIPPETS,
302
- failures,
303
- results
304
- );
305
-
306
- assertSnippetCoverage(
307
- 'explain-on-demand-review-prompt',
308
- REVIEW_PROMPT_PATH,
309
- REQUIRED_REVIEW_PROMPT_SNIPPETS,
310
- failures,
311
- results
312
- );
313
-
314
- const onboardingReportContent = readText(ONBOARDING_REPORT_PATH);
315
- const onboardingReport = parseOnboardingReport(onboardingReportContent);
316
-
317
- if (!onboardingReportContent) {
318
- failures.push(`Missing state source: ${ONBOARDING_REPORT_PATH}`);
319
- pushResult(results, false, 'state-source', `Missing ${ONBOARDING_REPORT_PATH}`);
320
- } else if (!onboardingReport) {
321
- failures.push(`Invalid state source JSON: ${ONBOARDING_REPORT_PATH}`);
322
- pushResult(results, false, 'state-source', `Cannot parse ${ONBOARDING_REPORT_PATH}`);
323
- } else {
324
- pushResult(results, true, 'state-source', `${ONBOARDING_REPORT_PATH} is present and valid`);
325
- }
326
-
327
- const defaultResponseSummary = buildDefaultResponseSummary(onboardingReport);
328
- const defaultModeExposesStateInternals = detectInternalSignals(defaultResponseSummary);
329
-
330
- if (defaultModeExposesStateInternals) {
331
- failures.push('Default response exposes state internals');
332
- pushResult(
333
- results,
334
- false,
335
- 'default-response-invisible-state',
336
- 'Default response leaks internal state details'
337
- );
338
- } else {
339
- pushResult(
340
- results,
341
- true,
342
- 'default-response-invisible-state',
343
- 'Default response avoids unnecessary state-file internals'
344
- );
345
- }
346
-
347
- const diagnosticDecisionSummaries = buildDiagnosticDecisionSummaries(onboardingReport);
348
- const canExplainStateDecisions = diagnosticDecisionSummaries.length > 0;
349
-
350
- if (parsedArguments.mode === 'diagnostic' && !parsedArguments.explicitStateRequest) {
351
- failures.push('Diagnostic mode requested without explicit state request');
352
- pushResult(
353
- results,
354
- false,
355
- 'diagnostic-explicit-request-gate',
356
- 'Diagnostic mode requires explicit request. Re-run with --state-debug when user asks for state-level details.'
357
- );
358
- } else {
359
- pushResult(
360
- results,
361
- true,
362
- 'diagnostic-explicit-request-gate',
363
- parsedArguments.mode === 'diagnostic'
364
- ? 'Diagnostic mode is explicitly requested and permitted'
365
- : 'Diagnostic mode not requested; default hidden-state behavior applies'
366
- );
367
- }
368
-
369
- if (!canExplainStateDecisions) {
370
- failures.push('Diagnostic mode cannot explain relevant state decisions');
371
- pushResult(
372
- results,
373
- false,
374
- 'diagnostic-explain-state-decisions',
375
- 'No state decision explanations available'
376
- );
377
- } else {
378
- pushResult(
379
- results,
380
- true,
381
- 'diagnostic-explain-state-decisions',
382
- `Diagnostic mode can explain ${diagnosticDecisionSummaries.length} state decision points`
383
- );
384
- }
385
-
386
- if (parsedArguments.mode === 'default' && parsedArguments.explicitStateRequest) {
387
- warnings.push('Explicit state request was provided in default mode; internal state details remain hidden unless diagnostic mode is selected.');
388
- }
389
-
390
- const reportPayload = {
391
- generatedAt: new Date().toISOString(),
392
- auditName: 'explain-on-demand-audit',
393
- workflow: parsedArguments.workflow,
394
- mode: parsedArguments.mode,
395
- source: changedScope.source,
396
- changedFileCount: changedFiles.length,
397
- changedFiles,
398
- responsePolicy: {
399
- defaultModeExposesStateInternals,
400
- diagnosticRequiresExplicitRequest: true,
401
- explicitStateRequestReceived: parsedArguments.explicitStateRequest,
402
- },
403
- defaultResponse: {
404
- summary: defaultResponseSummary,
405
- containsStateInternals: defaultModeExposesStateInternals,
406
- },
407
- diagnosticMode: {
408
- requested: parsedArguments.mode === 'diagnostic',
409
- allowed: parsedArguments.mode !== 'diagnostic' || parsedArguments.explicitStateRequest,
410
- canExplainStateDecisions,
411
- stateDecisionExplanations: parsedArguments.mode === 'diagnostic' && parsedArguments.explicitStateRequest
412
- ? diagnosticDecisionSummaries
413
- : [],
414
- availableDecisionCount: diagnosticDecisionSummaries.length,
415
- },
416
- passed: failures.length === 0,
417
- failureCount: failures.length,
418
- failures,
419
- warnings,
420
- results,
421
- };
422
-
423
- console.log(JSON.stringify(reportPayload, null, 2));
424
- process.exit(reportPayload.passed ? 0 : 1);
425
- }
426
-
427
- runAudit();
@@ -1,123 +0,0 @@
1
- import { readFileSync, readdirSync } from 'node:fs';
2
- import { join, relative } from 'node:path';
3
-
4
- const ROOT_DIR = process.cwd();
5
-
6
- // Directories to aggressively scan before NPM publish
7
- const SCAN_DIRECTORIES = [
8
- 'lib',
9
- 'bin',
10
- 'scripts',
11
- '.agent-context'
12
- ];
13
-
14
- const FORBIDDEN_PATTERNS = [
15
- {
16
- name: 'Hardcoded API Key',
17
- regex: /api_?key\s*[:=]\s*['"][a-zA-Z0-9_\-]{16,}['"]/i,
18
- requiredAction: 'API Keys must be provided via environment variables (process.env) or config files, never hardcoded.'
19
- },
20
- {
21
- name: 'Hardcoded Password',
22
- regex: /password\s*[:=]\s*['"][^'"]+['"]/i,
23
- requiredAction: 'Passwords must be injected via secret managers or environment variables.'
24
- },
25
- {
26
- name: 'Absolute Local Desktop Path',
27
- regex: /file:\/\/\/?([c-zC-Z]:|\/Users\/|\/home\/)/,
28
- requiredAction: 'Do not commit local absolute file paths. Use relative paths or process.cwd().'
29
- },
30
- {
31
- name: 'Stray Breakpoint (debugger)',
32
- regex: /\bdebugger\s*;?/,
33
- requiredAction: 'Remove debug breakpoints before publishing to production.'
34
- }
35
- ];
36
-
37
- function scanFile(filePath) {
38
- const content = readFileSync(filePath, 'utf8');
39
- const lines = content.split('\n');
40
- const violations = [];
41
-
42
- for (let i = 0; i < lines.length; i++) {
43
- const line = lines[i];
44
-
45
- for (const pattern of FORBIDDEN_PATTERNS) {
46
- if (pattern.regex.test(line)) {
47
- violations.push({
48
- line: i + 1,
49
- content: line.trim().substring(0, 80), // truncate long lines
50
- rule: pattern.name,
51
- requiredAction: pattern.requiredAction
52
- });
53
- }
54
- }
55
- }
56
-
57
- return violations;
58
- }
59
-
60
- function walkDirectory(dir, filePaths = []) {
61
- try {
62
- const entries = readdirSync(dir, { withFileTypes: true });
63
-
64
- for (const entry of entries) {
65
- const fullPath = join(dir, entry.name);
66
-
67
- if (entry.isDirectory()) {
68
- walkDirectory(fullPath, filePaths);
69
- } else if (entry.isFile()) {
70
- // Only scan source/docs, exclude markdown as it contains example anti-patterns
71
- if (/\.(js|mjs|cjs|ts|json|yml|yaml)$/i.test(entry.name) && entry.name !== 'forbidden-content-check.mjs') {
72
- filePaths.push(fullPath);
73
- }
74
- }
75
- }
76
- } catch (err) {
77
- if (err.code !== 'ENOENT') {
78
- console.error(`Error reading ${dir}: ${err.message}`);
79
- }
80
- }
81
- return filePaths;
82
- }
83
-
84
- async function runCheck() {
85
- console.log('Scanning for forbidden content (Publish Gate)...\n');
86
-
87
- let totalViolations = 0;
88
- const filesScanned = [];
89
-
90
- for (const dirName of SCAN_DIRECTORIES) {
91
- const targetDir = join(ROOT_DIR, dirName);
92
- const files = walkDirectory(targetDir);
93
-
94
- for (const file of files) {
95
- filesScanned.push(file);
96
- const violations = scanFile(file);
97
-
98
- if (violations.length > 0) {
99
- const relPath = relative(ROOT_DIR, file);
100
- console.error(`\nFORBIDDEN CONTENT DETECTED IN: ${relPath}`);
101
-
102
- for (const v of violations) {
103
- console.error(` Line ${v.line}: [${v.rule}]`);
104
- console.error(` > ${v.content}`);
105
- console.error(` Action required: ${v.requiredAction}`);
106
- totalViolations++;
107
- }
108
- }
109
- }
110
- }
111
-
112
- console.log(`\nScanned ${filesScanned.length} files across ${SCAN_DIRECTORIES.length} source directories.`);
113
-
114
- if (totalViolations > 0) {
115
- console.error(`\nPUBLISH ABORTED: Found ${totalViolations} forbidden content violation(s).`);
116
- process.exit(1);
117
- } else {
118
- console.log('Clean. No forbidden content detected.');
119
- process.exit(0);
120
- }
121
- }
122
-
123
- runCheck();