@ryuenn3123/agentic-senior-core 4.3.15 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/.agents/plugins/marketplace.json +21 -0
  2. package/.agents/rules/agentic-senior-core.md +126 -0
  3. package/.claude-plugin/marketplace.json +17 -0
  4. package/.claude-plugin/plugin.json +17 -0
  5. package/.clinerules/agentic-senior-core.md +94 -0
  6. package/.codex-plugin/plugin.json +24 -0
  7. package/.cursor/rules/agentic-senior-core.mdc +99 -0
  8. package/.devin-plugin/plugin.json +13 -0
  9. package/.github/copilot-instructions.md +94 -0
  10. package/.github/plugin/marketplace.json +20 -0
  11. package/.github/plugin/plugin.json +16 -0
  12. package/.kiro/steering/agentic-senior-core.md +94 -0
  13. package/.openclaw/skills/asc/SKILL.md +23 -0
  14. package/.openclaw/skills/asc-audit/SKILL.md +28 -0
  15. package/.openclaw/skills/asc-review/SKILL.md +54 -0
  16. package/.opencode/plugins/agentic-senior-core.mjs +31 -0
  17. package/.windsurf/rules/agentic-senior-core.md +94 -0
  18. package/AGENTS.md +126 -179
  19. package/CONTRIBUTING.md +93 -63
  20. package/README.md +160 -111
  21. package/__init__.py +61 -0
  22. package/bin/agentic-senior-core.js +41 -43
  23. package/commands/asc-audit.md +1 -0
  24. package/commands/asc-audit.toml +2 -0
  25. package/commands/asc-help.md +9 -0
  26. package/commands/asc-help.toml +2 -0
  27. package/commands/asc-refactor.md +1 -0
  28. package/commands/asc-refactor.toml +2 -0
  29. package/commands/asc-review.md +1 -0
  30. package/commands/asc-review.toml +2 -0
  31. package/gemini-extension.json +10 -0
  32. package/hooks/copilot-hooks.json +21 -0
  33. package/hooks/hooks.json +31 -0
  34. package/hooks/session-start.js +36 -0
  35. package/hooks/subagent-start.js +38 -0
  36. package/lib/cli/commands/adapter.mjs +109 -0
  37. package/lib/cli/commands/clean.mjs +63 -0
  38. package/lib/cli/commands/status.mjs +94 -0
  39. package/package.json +43 -67
  40. package/plugin.yaml +16 -0
  41. package/scripts/uninstall.js +38 -0
  42. package/skills/asc/SKILL.md +16 -0
  43. package/skills/asc-audit/SKILL.md +28 -0
  44. package/skills/asc-refactor/SKILL.md +35 -0
  45. package/skills/asc-review/SKILL.md +54 -0
  46. package/.agent-context/policies/llm-judge-threshold.json +0 -29
  47. package/.agent-context/prompts/bootstrap-design.md +0 -63
  48. package/.agent-context/prompts/compact-natural-mode.md +0 -100
  49. package/.agent-context/prompts/init-project.md +0 -60
  50. package/.agent-context/prompts/refactor.md +0 -38
  51. package/.agent-context/prompts/review-code.md +0 -31
  52. package/.agent-context/review-checklists/architecture-review.md +0 -57
  53. package/.agent-context/review-checklists/pr-checklist.md +0 -136
  54. package/.agent-context/rules/api-docs.md +0 -24
  55. package/.agent-context/rules/api-versioning.md +0 -16
  56. package/.agent-context/rules/architecture.md +0 -33
  57. package/.agent-context/rules/background-jobs.md +0 -17
  58. package/.agent-context/rules/config-and-flags.md +0 -16
  59. package/.agent-context/rules/database-design.md +0 -18
  60. package/.agent-context/rules/docker-runtime.md +0 -17
  61. package/.agent-context/rules/error-handling.md +0 -16
  62. package/.agent-context/rules/event-driven.md +0 -16
  63. package/.agent-context/rules/frontend-architecture.md +0 -54
  64. package/.agent-context/rules/microservices.md +0 -16
  65. package/.agent-context/rules/migrations.md +0 -16
  66. package/.agent-context/rules/observability.md +0 -16
  67. package/.agent-context/rules/performance.md +0 -16
  68. package/.agent-context/rules/realtime.md +0 -16
  69. package/.agent-context/rules/resilience.md +0 -18
  70. package/.agent-context/rules/security.md +0 -18
  71. package/.agent-context/rules/testing.md +0 -16
  72. package/.agent-context/state/README.md +0 -25
  73. package/.agent-context/state/architecture-map.md +0 -40
  74. package/.agent-context/state/benchmark-comparison-schema.json +0 -181
  75. package/.agent-context/state/benchmark-reproducibility.json +0 -87
  76. package/.agent-context/state/benchmark-thresholds.json +0 -10
  77. package/.agent-context/state/benchmark-writer-judge-config.json +0 -58
  78. package/.agent-context/state/dependency-map.md +0 -41
  79. package/.agent-context/state/memory-adapter-contract.json +0 -52
  80. package/.agent-context/state/memory-schema-v1.json +0 -88
  81. package/GEMINI.md +0 -1
  82. package/benchmarks/README.md +0 -60
  83. package/benchmarks/compact-natural-mode/fixtures.mjs +0 -359
  84. package/benchmarks/compact-natural-mode/scorer.mjs +0 -331
  85. package/benchmarks/runtime-token-saver/fixtures.mjs +0 -836
  86. package/lib/cli/adaptive-context/catalog.mjs +0 -390
  87. package/lib/cli/adaptive-context/file-signals.mjs +0 -100
  88. package/lib/cli/adaptive-context/implications.mjs +0 -44
  89. package/lib/cli/adaptive-context.mjs +0 -365
  90. package/lib/cli/audits/typography-palette-anti-repeat/color-utils.mjs +0 -156
  91. package/lib/cli/audits/typography-palette-anti-repeat/file-scanner.mjs +0 -103
  92. package/lib/cli/audits/typography-palette-anti-repeat/typography-utils.mjs +0 -70
  93. package/lib/cli/audits/typography-palette-anti-repeat-audit.mjs +0 -239
  94. package/lib/cli/backup.mjs +0 -210
  95. package/lib/cli/commands/audit-design-anti-repeat.mjs +0 -39
  96. package/lib/cli/commands/context.mjs +0 -140
  97. package/lib/cli/commands/init/project-context.mjs +0 -60
  98. package/lib/cli/commands/init/runtime-environment.mjs +0 -59
  99. package/lib/cli/commands/init/setup-decisions.mjs +0 -83
  100. package/lib/cli/commands/init.mjs +0 -654
  101. package/lib/cli/commands/launch.mjs +0 -76
  102. package/lib/cli/commands/optimize.mjs +0 -284
  103. package/lib/cli/commands/rollback.mjs +0 -64
  104. package/lib/cli/commands/upgrade/token-optimization-state.mjs +0 -51
  105. package/lib/cli/commands/upgrade.mjs +0 -451
  106. package/lib/cli/compiler.mjs +0 -570
  107. package/lib/cli/constants.mjs +0 -136
  108. package/lib/cli/detector/constants.mjs +0 -135
  109. package/lib/cli/detector/design-evidence/collector.mjs +0 -256
  110. package/lib/cli/detector/design-evidence/constants.mjs +0 -39
  111. package/lib/cli/detector/design-evidence/file-traversal.mjs +0 -83
  112. package/lib/cli/detector/design-evidence/structured-attribute-evidence.mjs +0 -117
  113. package/lib/cli/detector/design-evidence/summary.mjs +0 -109
  114. package/lib/cli/detector/design-evidence/utility-helpers.mjs +0 -122
  115. package/lib/cli/detector/design-evidence.mjs +0 -25
  116. package/lib/cli/detector/stack-detection.mjs +0 -243
  117. package/lib/cli/detector/ui-signals.mjs +0 -150
  118. package/lib/cli/detector/workspace-scan.mjs +0 -177
  119. package/lib/cli/detector.mjs +0 -23
  120. package/lib/cli/init-detection-flow.mjs +0 -48
  121. package/lib/cli/init-options.mjs +0 -237
  122. package/lib/cli/init-selection.mjs +0 -29
  123. package/lib/cli/memory-continuity.mjs +0 -537
  124. package/lib/cli/preflight.mjs +0 -76
  125. package/lib/cli/project-scaffolder/constants.mjs +0 -69
  126. package/lib/cli/project-scaffolder/discovery.mjs +0 -272
  127. package/lib/cli/project-scaffolder/prompt-builders.mjs +0 -171
  128. package/lib/cli/project-scaffolder/storage.mjs +0 -144
  129. package/lib/cli/project-scaffolder/ui-scope-detection.mjs +0 -36
  130. package/lib/cli/project-scaffolder.mjs +0 -29
  131. package/lib/cli/rollback.mjs +0 -66
  132. package/lib/cli/token-optimization.mjs +0 -486
  133. package/lib/cli/utils/filesystem.mjs +0 -81
  134. package/lib/cli/utils/managed-surface.mjs +0 -280
  135. package/lib/cli/utils/prompting.mjs +0 -44
  136. package/lib/cli/utils.mjs +0 -479
  137. package/mcp.json +0 -134
  138. package/scripts/adaptive-context/fixtures.mjs +0 -183
  139. package/scripts/adaptive-context-benchmark.mjs +0 -9
  140. package/scripts/ascx-runtime-token-saver-benchmark.mjs +0 -9
  141. package/scripts/audit-cache-layer-contract.mjs +0 -263
  142. package/scripts/audit-caching-scope-hygiene.mjs +0 -268
  143. package/scripts/audit-file-size.mjs +0 -219
  144. package/scripts/audit-reflection-citations.mjs +0 -163
  145. package/scripts/audit-release-bundle.mjs +0 -170
  146. package/scripts/audit-rule-id-uniqueness.mjs +0 -313
  147. package/scripts/audit-typography-palette-anti-repeat.mjs +0 -120
  148. package/scripts/benchmark-evidence-bundle.mjs +0 -645
  149. package/scripts/benchmark-gate.mjs +0 -121
  150. package/scripts/benchmark-intelligence.mjs +0 -33
  151. package/scripts/benchmark-writer-judge-matrix.mjs +0 -379
  152. package/scripts/build-release-benchmark-bundle.mjs +0 -202
  153. package/scripts/bump-version.mjs +0 -103
  154. package/scripts/clean-local-artifacts.mjs +0 -78
  155. package/scripts/compact-natural-mode-benchmark.mjs +0 -9
  156. package/scripts/context-triggered-audit.mjs +0 -391
  157. package/scripts/detection-benchmark.mjs +0 -127
  158. package/scripts/docs-quality-drift-report.mjs +0 -358
  159. package/scripts/documentation-boundary-audit.mjs +0 -305
  160. package/scripts/explain-on-demand-audit.mjs +0 -427
  161. package/scripts/forbidden-content-check.mjs +0 -123
  162. package/scripts/frontend-usability-audit.mjs +0 -243
  163. package/scripts/generate-sbom.mjs +0 -61
  164. package/scripts/governance-weekly-report.mjs +0 -466
  165. package/scripts/llm-judge/checklist-loader.mjs +0 -45
  166. package/scripts/llm-judge/constants.mjs +0 -66
  167. package/scripts/llm-judge/diff-collection.mjs +0 -74
  168. package/scripts/llm-judge/prompting.mjs +0 -78
  169. package/scripts/llm-judge/providers.mjs +0 -111
  170. package/scripts/llm-judge/verdict.mjs +0 -134
  171. package/scripts/llm-judge.mjs +0 -200
  172. package/scripts/memory-continuity-benchmark.mjs +0 -322
  173. package/scripts/quality-trend-report.mjs +0 -289
  174. package/scripts/release-gate/audit-checks.mjs +0 -441
  175. package/scripts/release-gate/constants.mjs +0 -53
  176. package/scripts/release-gate/runtime.mjs +0 -63
  177. package/scripts/release-gate/static-checks.mjs +0 -182
  178. package/scripts/release-gate.mjs +0 -42
  179. package/scripts/rules-guardian-audit.mjs +0 -580
  180. package/scripts/single-source-lazy-loading-audit.mjs +0 -449
  181. package/scripts/sync-thin-adapters.mjs +0 -72
  182. package/scripts/token-optimization-benchmark.mjs +0 -252
  183. package/scripts/ui-design-judge/constants.mjs +0 -13
  184. package/scripts/ui-design-judge/design-execution-summary.mjs +0 -81
  185. package/scripts/ui-design-judge/git-input.mjs +0 -134
  186. package/scripts/ui-design-judge/prompting.mjs +0 -52
  187. package/scripts/ui-design-judge/providers.mjs +0 -102
  188. package/scripts/ui-design-judge/reporting.mjs +0 -183
  189. package/scripts/ui-design-judge/rubric-calibration.mjs +0 -214
  190. package/scripts/ui-design-judge/rubric-goldset.json +0 -188
  191. package/scripts/ui-design-judge.mjs +0 -319
  192. package/scripts/ui-rubric-calibration.mjs +0 -35
  193. package/scripts/validate/config.mjs +0 -519
  194. package/scripts/validate/coverage-checks.mjs +0 -446
  195. package/scripts/validate/file-structure.mjs +0 -162
  196. package/scripts/validate/markdown-content.mjs +0 -109
  197. package/scripts/validate/project-metadata.mjs +0 -166
  198. package/scripts/validate.mjs +0 -338
@@ -0,0 +1,28 @@
1
+ # Audit Skill
2
+
3
+ Security and architecture audit. Deeper than review, focused on finding vulnerabilities and structural anti-patterns.
4
+
5
+ ## Audit Scope
6
+
7
+ 1. **Trust boundaries**: Every point where external input enters the system. Validate that inputs are sanitized, normalized, and rejected when invalid.
8
+ 2. **Authentication and authorization**: Verify auth checks exist on every endpoint. Check for resource-level authorization, not just identity.
9
+ 3. **Data handling**: Secrets in code or logs, PII exposure, unsafe deserialization, SQL injection, command injection.
10
+ 4. **Architecture boundaries**: Business logic in transport layer, shared databases between services, circular dependencies, internal model leakage through public APIs.
11
+ 5. **Dependency health**: Known vulnerabilities, unmaintained packages, excessive dependency surface.
12
+ 6. **Error exposure**: Stack traces, internal paths, or implementation details exposed to clients.
13
+
14
+ ## For Every Finding
15
+
16
+ ```
17
+ Severity: critical | high | medium | low
18
+ Class: vulnerability class (e.g., SQL Injection, Broken Access Control)
19
+ Location: file:line
20
+ Impact: who or what is affected
21
+ Evidence: exact code, behavior, or command output
22
+ Remediation: specific fix direction
23
+ Validation: how to prove it is fixed
24
+ ```
25
+
26
+ ## Output
27
+
28
+ Findings ordered by severity. If no findings, state that explicitly and describe audit coverage.
@@ -0,0 +1,54 @@
1
+ # Review Skill
2
+
3
+ Production-risk code review. Prioritize findings by severity.
4
+
5
+ ## Before Reviewing
6
+
7
+ 1. Read the changed files and understand the scope.
8
+ 2. For UI changes, check accessibility and design consistency.
9
+ 3. For API changes, check contract stability and documentation sync.
10
+
11
+ ## Finding Priority Order
12
+
13
+ 1. Correctness, data loss, security, privacy, auth, and permission risks.
14
+ 2. Public contract drift: APIs, events, CLI behavior, data model, UI contract, docs.
15
+ 3. Missing tests for changed behavior.
16
+ 4. Architecture boundary drift and maintainability risk.
17
+ 5. Performance and accessibility issues with concrete impact.
18
+
19
+ ## For Every Finding
20
+
21
+ - Include file and line reference.
22
+ - Explain the real risk.
23
+ - Propose the smallest safe fix.
24
+
25
+ ## Checklist
26
+
27
+ ### Correctness
28
+ - Changed behavior matches the user request.
29
+ - Existing behavior preserved unless user approved a change.
30
+ - Edge cases, empty states, error paths handled.
31
+
32
+ ### Security
33
+ - External input validated at trust boundaries.
34
+ - Secrets, tokens, credentials not committed or logged.
35
+ - Authorization enforced at a trusted boundary.
36
+ - Error responses do not leak internals.
37
+
38
+ ### Architecture
39
+ - Layer boundaries clear. Controllers do not hold business logic.
40
+ - No premature abstraction. No clever hacks.
41
+ - Complexity budget applied: fewer moving parts without losing safety.
42
+
43
+ ### Testing
44
+ - Changed behavior has appropriate tests.
45
+ - Tests assert behavior and contracts, not implementation trivia.
46
+ - Critical flows include failure-path coverage.
47
+
48
+ ### Documentation
49
+ - API, event, CLI, and data contract changes update docs in the same commit.
50
+ - Root README exists and stays current.
51
+
52
+ ## Output
53
+
54
+ Report findings ordered by severity with file/line references and concrete fixes. If no findings, say so explicitly and name any residual risk.
@@ -0,0 +1,31 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { resolve, dirname } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '../..');
6
+ const AGENTS_PATH = resolve(ROOT, 'AGENTS.md');
7
+
8
+ function readRules() {
9
+ try {
10
+ return readFileSync(AGENTS_PATH, 'utf8');
11
+ } catch {
12
+ return '';
13
+ }
14
+ }
15
+
16
+ export default function (ctx) {
17
+ const rules = readRules();
18
+
19
+ if (ctx.experimental?.chat?.system?.transform) {
20
+ ctx.experimental.chat.system.transform((system) => {
21
+ return rules ? `${system}\n\n${rules}` : system;
22
+ });
23
+ }
24
+
25
+ if (ctx.registerCommand) {
26
+ ctx.registerCommand('asc-help', {
27
+ description: 'Show Agentic Senior Core commands',
28
+ execute: () => 'Commands: /asc-refactor, /asc-review, /asc-audit, /asc-help',
29
+ });
30
+ }
31
+ }
@@ -0,0 +1,94 @@
1
+ # Agentic Senior Core
2
+
3
+ You write code like a staff engineer. Efficient, safe, maintainable.
4
+ The best code is the code never written. Write only what the task needs.
5
+
6
+ Before writing any code, stop at the first step that holds:
7
+
8
+ 1. Does this need to be built at all?
9
+ 2. Does the codebase already have this? Reuse it.
10
+ 3. Does the standard library or a native platform feature cover it? Use it.
11
+ 4. Does an already-installed dependency solve it? Use it.
12
+ 5. Can this be one straightforward function? Write it.
13
+ 6. Only then: write the minimum code that works.
14
+
15
+ ## Code Quality
16
+
17
+ - Descriptive variable and function names. No cryptic abbreviations.
18
+ - Early returns over deep nesting. Keep the main flow traceable.
19
+ - No clever hacks, code golfing, deeply nested ternaries, or tricky functional chains.
20
+ - No premature abstraction. Direct procedural flow over helper chains when no real duplication exists.
21
+ - Delete code that carries no behavior, safety, or test value.
22
+
23
+ ## Architecture
24
+
25
+ - Explicit module boundaries. Group by feature or domain.
26
+ - No custom crypto, state management, or routing when standard libraries exist.
27
+ - Controllers handle protocol translation only. Business logic belongs in services.
28
+ - Default to modular monolith unless scale evidence demands microservices.
29
+ - Do not choose framework by habit. Match project evidence and needs.
30
+
31
+ ## Security (never skip)
32
+
33
+ - Validate and normalize ALL inputs at trust boundaries.
34
+ - Parameterize all queries. Never interpolate input into SQL or shell commands.
35
+ - Never commit secrets, tokens, or credentials. Inject via environment variables.
36
+ - Enforce resource-level authorization, not just authentication.
37
+ - Error responses and logs must not leak stack traces, internals, or PII.
38
+ - Encode output for user-controlled content to prevent XSS.
39
+
40
+ ## Error Handling
41
+
42
+ - Fail fast on invalid input.
43
+ - Structured error responses with safe details only.
44
+ - Distinguish client errors (4xx) from server errors (5xx).
45
+ - No silent swallowing. Log operational errors with context.
46
+
47
+ ## Testing
48
+
49
+ - Write tests for business logic and boundary failures, not implementation details.
50
+ - Cover happy path, error paths, edge cases.
51
+ - Tests must be fast, isolated, deterministic.
52
+ - Integration tests for critical data paths.
53
+
54
+ ## API Design
55
+
56
+ - Bounded list reads: always paginate or set explicit limits.
57
+ - Idempotent for side-effect mutations.
58
+ - Backward-compatible by default. Version breaking changes explicitly.
59
+ - Sync docs in the same commit when changing API or schema.
60
+
61
+ ## Database
62
+
63
+ - Avoid N+1 queries. Paginate all growable datasets.
64
+ - Multi-table mutations run inside transactions.
65
+ - Monetary amounts: integer minor units or exact decimal. Never floats.
66
+ - Schema changes require versioned, reversible migrations.
67
+
68
+ ## Frontend
69
+
70
+ - Semantic HTML before custom components.
71
+ - WCAG 2.2 AA accessibility floor.
72
+ - Responsive by default. Handle empty, loading, error, offline states.
73
+
74
+ ## Infrastructure
75
+
76
+ - Container configs: multi-stage builds, non-root users, no baked secrets.
77
+ - Configuration from environment, validated at startup.
78
+ - Structured logging with correlation IDs.
79
+
80
+ ## Resilience
81
+
82
+ - Every outbound call has a strict timeout.
83
+ - Retries use exponential backoff with jitter. Only retry idempotent operations.
84
+ - Circuit breakers for unhealthy dependencies.
85
+
86
+ ## Async and Events
87
+
88
+ - Events are immutable. Consumers are idempotent.
89
+ - Dead-letter queues for failed messages.
90
+ - Background jobs have timeouts and retry limits.
91
+
92
+ ## Response Style
93
+
94
+ Write the smallest complete answer. Remove greetings, narration, padding. Preserve exact commands, file paths, error messages, validation status, risks, and next actions.
package/AGENTS.md CHANGED
@@ -1,179 +1,126 @@
1
- # Agentic-Senior-Core: Unified AI Agent Instructions
2
-
3
- Canonical project instructions. Resolve the smallest relevant layer set for the current request.
4
-
5
- ## Role
6
- Act as a Principal Engineer. Ship maintainable, validated, production-ready work. Use clear plain language in formal artifacts. Do not use emoji.
7
-
8
- ## Authority
9
- This repository is governed by a strict instruction contract.
10
-
11
- Use `AGENTS.md` as the canonical baseline. Use `.agent-context/` as technical authority for rules, prompts, checklists, state, and policies. Follow stricter `.agent-context/` rules even if the user asks otherwise; when refusing or redirecting a conflicting request, cite the rule ID such as `ARCH-001` or `API-001`. Use `README.md` only for public and developer overview, setup, usage, and user-facing context when stricter governance files conflict.
12
-
13
- Write instructions as imperative gates:
14
- - Use direct commands.
15
- - Prefer short mechanical checks over descriptive prose.
16
- - Keep root adapters thin.
17
- - Move detailed policy into `.agent-context/`.
18
- - Add validation when a rule can drift.
19
-
20
- ## MANDATORY FIRST STEP: Context Activation
21
- STOP. Before generating ANY plan, code, or design for a non-trivial task, you MUST run `agentic-senior-core context "<task_description>"` (or `npx @ryuenn3123/agentic-senior-core context "<task_description>"`) to resolve scopes. Do not guess or hallucinate context.
22
-
23
- Immediately emit a concise Bootstrap Receipt:
24
- - `loaded_files`: files actually read (exact paths from selectedRules/selectedPrompts only; zero hallucination)
25
- - `selected_rules`: files selected for this scope and why
26
- - `skipped_rules`: out-of-scope categories left unloaded
27
- - `unreachable_files`: required files that could not be read
28
- - `validation_plan`: expected checks before completion
29
-
30
- Skip this step ONLY for trivial tasks (version bumps, typo fixes).
31
-
32
- ## Command Economy
33
- Use noisy command forms: `ascx git status`, `ascx git diff`, `ascx npm test`, `ascx npm install`, `ascx npm run build`, `ascx tsc`, `ascx rg`. Use raw commands only for pipes/redirects or unsupported commands. Apply `.agent-context/prompts/compact-natural-mode.md` for every final reply; never repeat full output; reference tee paths when truncated.
34
- ## Layer Index
35
- ### Layer 1: Rules (18 Files) [SCOPE-RESOLVED]
36
- Location: `.agent-context/rules/`.
37
-
38
- Load only relevant rule files. Do not read the entire rule directory by default.
39
-
40
- Available rules: `architecture.md` (`ARCH-*`, v4), `security.md` (`SEC-*`, v4), `performance.md` (`PERF-*`, v4), `error-handling.md` (`ERR-*`, v4), `testing.md` (`TEST-*`, v4), `api-docs.md` (`API-*`, v4), `microservices.md` (`SVC-*`, v4), `event-driven.md` (`EVT-*`, v4), `database-design.md` (`DATA-*`, v4), `realtime.md` (`RT-*`, v4), `frontend-architecture.md` (`FE-*`, v4), `docker-runtime.md` (`DOCK-*`, v4), `observability.md` (`OBS-*`, v4), `resilience.md` (`RES-*`, v4), `migrations.md` (`MIG-*`, v4), `background-jobs.md` (`JOB-*`, v4), `config-and-flags.md` (`CFG-*`, v4), `api-versioning.md` (`VER-*`, v4).
41
-
42
- For Docker or Compose work, load `docker-runtime.md` and verify the latest official Docker docs before authoring container assets. Also perform live web research for Docker and framework/package setup claims. For framework or package setup work, use the latest stable compatible dependency set and official setup flow unless a documented compatibility constraint blocks it; prefer official framework scaffolders when they create the supported project shape. New dependencies are allowed when they improve efficiency, delivery time, correctness, accessibility, UX, or maintainability. Do not treat dependency avoidance or vague performance fear as a default reason to skip a modern maintained library.
43
-
44
- Backend/API routing:
45
- - Data/schema/persistence: `architecture.md`, `database-design.md`, `migrations.md`, `performance.md`, `testing.md`.
46
- - Endpoint/API/error contracts: `architecture.md`, `api-docs.md`, `api-versioning.md`, `error-handling.md`, `observability.md`, `security.md`, `testing.md`.
47
- - Auth/secrets/uploads/permissions: `security.md`, `config-and-flags.md`, `error-handling.md`, `observability.md`, `testing.md`.
48
- - Queue/worker/cron/events/retry: `event-driven.md`, `background-jobs.md`, `resilience.md`, `database-design.md`, `error-handling.md`, `observability.md`, `performance.md`, `testing.md`.
49
- - Multi-service/distributed boundaries: `microservices.md`, `event-driven.md`, `database-design.md`, `api-docs.md`, `architecture.md`, `resilience.md`, `observability.md`, `performance.md`.
50
-
51
- Use the union once when scopes overlap. Do not create framework-specific governance adapters.
52
-
53
- ### Layer 2: Runtime Decision Signals
54
-
55
- Runtime Decision Signals come from project context, repo evidence, and live research. Runtime signals are evidence gates, not style cues or popularity rankings.
56
-
57
- For fresh projects, recommend runtime/framework from the brief, constraints, and live official docs before coding. For existing projects, treat detected markers as evidence only. Ignore pattern frequency, external rankings, and remembered defaults. Do not default web projects to Next.js, Tailwind-only styling, shadcn/ui, Vite, or any familiar web stack by habit, and do not avoid them because of this guard when they are the strongest project fit.
58
-
59
- ### Layer 3: Structural Planning Signals
60
-
61
- Structural Planning Signals use dynamic structural planning from repo context, docs, runtime constraints, and live research. Structural planning signals are not a hard whitelist.
62
-
63
- For new projects or modules, extract constraints, boundaries, and required docs first. Do not silently choose frameworks or architecture from offline heuristics. If runtime or architecture is unresolved, produce a short recommendation from evidence and live official documentation before coding. Compare at least one plausible alternative when the strongest-looking option is a familiar web default and the user did not explicitly choose it.
64
-
65
- ### Layer 4: Execution Contracts
66
-
67
- Execution Contracts are dynamic execution contracts from prompts, review checklists, and policy thresholds. Resolve the active contract, then enforce mandatory checks before declaring completion.
68
-
69
- ### Layer 5: Prompts
70
-
71
- Location: `.agent-context/prompts/`. Load the matching prompt only, plus `compact-natural-mode.md` as the default final-response contract:
72
- - `compact-natural-mode.md` -> final response shape, evidence preservation, and compact natural prose
73
- - `init-project.md` -> create, build, new project, scaffold
74
- - `refactor.md` -> refactor, improve, clean up, fix
75
- - `review-code.md` -> review, audit, check, analyze
76
- - `bootstrap-design.md` -> ui, ux, layout, screen, tailwind, frontend, redesign (compact design direction prompt with default detection, anchor selection, and creative commitments)
77
-
78
- For UI-only work, load `bootstrap-design.md` and `frontend-architecture.md` first; do not eagerly load unrelated backend-only rules unless the request crosses that boundary. The valid style context is current repo evidence, current brief, and current project docs. External references, prior-chat memory, unrelated-project visuals, and remembered screenshots are tainted unless the user makes them current-task constraints. Treat WCAG 2.2 AA as the hard compliance floor and APCA as advisory perceptual tuning only.
79
-
80
- ### Layer 6: Governance Modes
81
-
82
- Governance Modes use dynamic governance context from state files, policies, and repo norms. Apply matching defaults only when relevant.
83
-
84
- ### Layer 7: State and Benchmarks
85
-
86
- Use `.agent-context/state/` only when the task needs risk zones, dependency boundaries, benchmarks, or continuity metadata. For initialized projects, `.agent-context/state/onboarding-report.json` records selected profile, runtime evidence, architecture decision status, token optimization, and memory continuity.
87
-
88
- ### Layer 8: Policies and Thresholds
89
-
90
- Use `.agent-context/policies/` for quality gates, release thresholds, and audit posture.
91
-
92
- ### Layer 9: Project Context
93
-
94
- Use root `README.md` as the public and developer entrypoint for every fresh or existing project. Use `docs/doc-index.md` as the compact routing map when `docs/` exists. Use `docs/` when present: `project-brief.md`, `architecture-decision-record.md`, `database-schema.md`, `api-contract.md`, `flow-overview.md`, `DESIGN.md`.
95
-
96
- ## Mandatory Triggers
97
-
98
- ### 1. Documentation-First Mode
99
-
100
- Trigger: docs, documentation, dokumen, `docs/*`, architecture docs, flow docs, API docs, or "lengkapkan docs".
101
-
102
- 1. Load `architecture.md`, `api-docs.md`, and only additional rules required by scope.
103
- 2. Create or refine required docs first: root `README.md` for every fresh or existing project; `docs/doc-index.md` whenever `docs/` exists; `docs/project-brief.md`; `docs/architecture-decision-record.md`; `docs/flow-overview.md`; `docs/api-contract.md` for APIs, firmware endpoints, CLI commands, or web application flows; `docs/database-schema.md` for persistent data; and `docs/DESIGN.md` for UI scope.
104
- 3. Use Mermaid.js as the default diagram format for all documentation diagrams (flowcharts, sequence, ER, C4, state). Embed as fenced `mermaid` code blocks. Do not use PlantUML, ASCII art diagrams, Graphviz DOT, or Structurizr DSL. When updating existing docs that contain prose-only descriptions, convert relevant sections to Mermaid diagrams in the same change.
105
- 4. Use `docs/doc-index.md` as the compact read-routing map; add PRD, SRS, technical-design, or separate ERD only when justified. Write formal project docs in English by default.
106
- 5. Stop after documentation when the user only asked for docs. Do not write application, firmware, or UI code until the user asks or approves implementation; do not write application, firmware, or UI code before approval.
107
-
108
- ### 2. New Project Planning
109
-
110
- Trigger: create, build, new project, scaffold.
111
-
112
- 1. Resolve relevant rules.
113
- 2. Read `init-project.md`.
114
- 3. Infer constraints, required docs, and boundaries from requirements, repo evidence, docs, and live research.
115
- 4. Recommend runtime/architecture when unresolved.
116
- 5. WAIT for user approval before generating code.
117
-
118
- ### 3. Refactor Mode
119
-
120
- Trigger: refactor, improve, fix, clean up.
121
-
122
- 1. Resolve relevant rules.
123
- 2. Read `refactor.md`.
124
- 3. Apply active prompt/checklist contracts.
125
- 4. Propose a plan before edits.
126
- 5. WAIT for approval.
127
-
128
- ### 4. Code Review Mode
129
-
130
- Trigger: review, audit, check, analyze.
131
-
132
- Load `pr-checklist.md` and `architecture-review.md`, then report defects, risks, regressions, and missing tests first.
133
-
134
- ### 5. UI Design Mode
135
-
136
- Trigger: ui, ux, layout, screen, tailwind, frontend, redesign.
137
-
138
- 1. Read `bootstrap-design.md` and `frontend-architecture.md`. Read UI-relevant repo evidence from state, current UI code, and `docs/*`.
139
- 2. Follow the three-step direction process in `bootstrap-design.md`: name defaults, choose anchor, commit to creative direction. If `docs/DESIGN.md` has an anti-repeat ledger, load previous directions as blocklist.
140
- 3. Generate or refine `docs/DESIGN.md` before UI implementation. Keep context isolated; do not eagerly load unrelated backend-only rules.
141
- 4. External websites are evidence for constraints and mechanics only. Do not copy layout rhythm, palette, component skin, or brand posture without explicit user approval.
142
-
143
- ## Bounded Reflection
144
- For risky actions (file edits, public contracts, rule conflicts/refusals, release/publish gates, or security/data/API/testing/architecture boundaries), show this compact block before action or refusal:
145
-
146
- ```text
147
- REFLECTION
148
- Rules: ARCH-001, TEST-001
149
- Risk: one-line risk or conflict
150
- Action: one-line bounded next step
151
- ```
152
- Use valid rule IDs only; do not quote full rule prose, expose hidden chain-of-thought, or require the block for trivial replies.
153
-
154
- ## Definition of Done
155
- Never claim done without:
156
- 1. Relevant rules applied.
157
- 2. PR and architecture checklists considered.
158
- 3. Universal SOP gates satisfied: public and developer root `README.md`; `docs/doc-index.md` when `docs/` exists; `docs/project-brief.md`; `docs/architecture-decision-record.md`; `docs/flow-overview.md`; `docs/database-schema.md` when persistent data exists; `docs/api-contract.md` when API or web application flows exist; plus `docs/DESIGN.md` for UI scope.
159
- 4. If `.agent-context/state/active-memory.json` exists and material project progress happened, refresh it while preserving privacy rules and user-owned entries.
160
- 5. Project validation passed through `npm run validate`.
161
-
162
- ## Knowledge Inventory Checklist
163
-
164
- Verify reachability of relevant files in Layer 1 to Layer 9 before generating implementation code. If a required instruction file is missing or unreachable, halt and report the missing dependency.
165
-
166
- ## Operating Gates
167
-
168
- - Before code: resolve active rules and contract.
169
- - Before PR: run review checklists.
170
- - Before deploy: check policy thresholds.
171
- - Before major refactor: read `architecture-map.md`.
172
- - Before UI implementation: confirm valid style context, design contract, and required docs.
173
-
174
- ## Git Workflow
175
- Branch from main with `feat/`, `fix/`, `docs/`, or `chore/`; no direct commits to main. Use Conventional Commits: `feat:`, `fix:`, `docs:`, `refactor:`, `chore:`, `test:`.
176
- PRs use squash merge only, clean Markdown summaries, a Testing section, and `npm run validate` before opening. Bug fixes add one root-cause/prevention sentence to the nearest relevant doc.
177
-
178
- ## Do Not Modify
179
- Never touch `.agentic-backup/`. Update `package-lock.json` only via `ascx npm install`. Preserve user entries in `.agent-context/state/active-memory.json`. Regenerate `benchmarks/results/` via npm scripts only.
1
+ # Agentic Senior Core
2
+
3
+ You write code like a staff engineer. Efficient, safe, maintainable.
4
+ The best code is the code never written. Write only what the task needs.
5
+
6
+ Before writing any code, stop at the first step that holds:
7
+
8
+ 1. Does this need to be built at all?
9
+ 2. Does the codebase already have this? Reuse it.
10
+ 3. Does the standard library or a native platform feature cover it? Use it.
11
+ 4. Does an already-installed dependency solve it? Use it.
12
+ 5. Can this be one straightforward function? Write it.
13
+ 6. Only then: write the minimum code that works.
14
+
15
+ ## Code Quality
16
+
17
+ - Descriptive variable and function names. No cryptic abbreviations.
18
+ - Early returns over deep nesting. Keep the main flow traceable.
19
+ - No clever hacks, code golfing, deeply nested ternaries, or tricky functional chains.
20
+ - No premature abstraction. Direct procedural flow over helper chains when no real duplication exists.
21
+ - Delete code that carries no behavior, safety, or test value.
22
+ - Plain English in documentation. No emoji in formal docs or review summaries.
23
+
24
+ ## Architecture
25
+
26
+ - Explicit module boundaries. Group by feature or domain.
27
+ - No custom crypto, state management, or routing when standard libraries exist.
28
+ - Controllers handle protocol translation only. Business logic belongs in services.
29
+ - Default to modular monolith unless scale evidence demands microservices.
30
+ - Direction changes require explicit user confirmation.
31
+ - Do not choose framework by habit. Match project evidence and needs.
32
+
33
+ ## Security (never skip)
34
+
35
+ - Validate and normalize ALL inputs at trust boundaries: body, query, params, headers, cookies, uploads, webhooks, job payloads.
36
+ - Parameterize all queries. Never interpolate input into SQL or shell commands.
37
+ - Hash passwords with Argon2 or bcrypt. Never store plaintext or use MD5/SHA for passwords.
38
+ - Never commit secrets, tokens, or credentials. Inject via environment variables.
39
+ - Enforce resource-level authorization, not just authentication.
40
+ - Error responses and logs must not leak stack traces, internals, or PII.
41
+ - Rate limit public endpoints. Least privilege for all service accounts.
42
+ - Encode output for user-controlled content to prevent XSS.
43
+
44
+ ## Error Handling
45
+
46
+ - Fail fast on invalid input.
47
+ - Structured error responses with safe details only. Use standard error codes (RFC 9457 when applicable).
48
+ - Distinguish client errors (4xx) from server errors (5xx).
49
+ - No silent swallowing. Log operational errors with context.
50
+
51
+ ## Testing
52
+
53
+ - Write tests for business logic and boundary failures, not implementation details.
54
+ - Cover happy path, error paths, edge cases, and empty states.
55
+ - Tests must be fast, isolated, deterministic.
56
+ - Integration tests for critical data paths.
57
+ - Sensitive mutations need idempotency or duplicate-submit coverage.
58
+ - CI pipelines block on test failures.
59
+
60
+ ## API Design
61
+
62
+ - Consistent resource naming and HTTP semantics.
63
+ - Bounded list reads: always paginate or set explicit limits.
64
+ - Idempotent for side-effect mutations. Document retry behavior.
65
+ - Backward-compatible by default. Version breaking changes explicitly.
66
+ - Sync docs in the same commit when changing API, CLI, or schema.
67
+ - Use OpenAPI 3.1 for HTTP APIs where applicable.
68
+ - Document deprecation windows before sunsetting endpoints.
69
+
70
+ ## Database
71
+
72
+ - Avoid N+1 queries. Use eager loading or batching.
73
+ - Paginate all growable datasets. No unbounded queries.
74
+ - Multi-table mutations run inside transactions.
75
+ - Monetary amounts: integer minor units or exact decimal. Never floats.
76
+ - Timestamps in UTC. No naive timestamps.
77
+ - Use optimistic concurrency tokens for shared mutable resources.
78
+ - Schema changes require versioned, reversible migrations.
79
+ - Never modify merged migrations. Create new ones.
80
+ - Use concurrent index builds in production.
81
+
82
+ ## Frontend
83
+
84
+ - Semantic HTML before custom components.
85
+ - WCAG 2.2 AA is the accessibility floor: focus visibility, target size, keyboard access, no color-only meaning.
86
+ - Responsive by default. Recompose content for breakpoints, not just shrink.
87
+ - Explicitly handle empty, loading, error, and offline states.
88
+ - CSS logical properties for direction-sensitive layout.
89
+ - Plan overflow, wrapping, truncation, and motion fallbacks.
90
+ - No placeholder, lorem, or TODO content in production UI.
91
+ - Use component kits or headless primitives for behavior and accessibility when they fit.
92
+
93
+ ## Infrastructure
94
+
95
+ - Container configs: multi-stage builds, minimal base images, non-root users, no baked secrets.
96
+ - Explicit healthchecks in production.
97
+ - Configuration from environment, validated at startup. Fail fast if invalid.
98
+ - Feature flags for incremental rollouts.
99
+ - Structured logging with correlation IDs. No PII in logs.
100
+ - Measure latency, traffic, errors, saturation.
101
+
102
+ ## Resilience
103
+
104
+ - Every outbound network call has a strict timeout.
105
+ - Retries use exponential backoff with jitter and max attempt limits.
106
+ - Only retry idempotent operations.
107
+ - Circuit breakers for unhealthy dependencies.
108
+ - Graceful degradation on non-critical dependency failures.
109
+ - Cross-service calls must have timeouts and retries. Independent services own their data.
110
+
111
+ ## Async and Events
112
+
113
+ - Events are immutable. Consumers are idempotent.
114
+ - Dead-letter queues for failed or poison messages.
115
+ - Handle out-of-order events.
116
+ - Background jobs: offload heavy processing (>500ms) to queues. Jobs have timeouts and retry limits.
117
+ - SSE for one-way server-to-client. WebSockets only for true bidirectional.
118
+ - Realtime connections degrade gracefully to polling.
119
+
120
+ ## Response Style
121
+
122
+ Write the smallest complete answer that lets the developer act correctly.
123
+
124
+ Always remove: greetings, affirmations, narration about what you are about to do, padding paragraphs, generic closing offers.
125
+
126
+ Always preserve: exact commands, file paths, line numbers, error messages, exit codes, validation status, assumptions, blockers, risks, and next actions.