@ryuenn3123/agentic-senior-core 4.1.0 → 4.2.1

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 (50) hide show
  1. package/.agent-context/prompts/compact-natural-mode.md +100 -0
  2. package/.agent-context/prompts/init-project.md +1 -0
  3. package/.agent-context/prompts/refactor.md +1 -0
  4. package/.agent-context/review-checklists/pr-checklist.md +1 -0
  5. package/.agent-context/rules/architecture.md +10 -0
  6. package/.agent-context/rules/naming-conv.md +6 -3
  7. package/.agent-context/state/README.md +2 -1
  8. package/AGENTS.md +6 -8
  9. package/README.md +95 -117
  10. package/benchmarks/README.md +60 -0
  11. package/benchmarks/compact-natural-mode/fixtures.mjs +359 -0
  12. package/benchmarks/compact-natural-mode/scorer.mjs +331 -0
  13. package/benchmarks/runtime-token-saver/fixtures.mjs +714 -0
  14. package/bin/agentic-senior-core.js +6 -0
  15. package/bin/ascx.js +23 -0
  16. package/lib/cli/adaptive-context/catalog.mjs +428 -0
  17. package/lib/cli/adaptive-context/file-signals.mjs +100 -0
  18. package/lib/cli/adaptive-context/implications.mjs +44 -0
  19. package/lib/cli/adaptive-context.mjs +365 -0
  20. package/lib/cli/ascx/adapters/git-diff.mjs +223 -0
  21. package/lib/cli/ascx/adapters/git-status.mjs +145 -0
  22. package/lib/cli/ascx/adapters/npm-run-build.mjs +99 -0
  23. package/lib/cli/ascx/adapters/npm-test.mjs +120 -0
  24. package/lib/cli/ascx/adapters/rg.mjs +39 -0
  25. package/lib/cli/ascx/fixture-evaluator.mjs +180 -0
  26. package/lib/cli/ascx/formatter.mjs +47 -0
  27. package/lib/cli/ascx/lexer.mjs +129 -0
  28. package/lib/cli/ascx/runtime.mjs +192 -0
  29. package/lib/cli/ascx/tee-writer.mjs +63 -0
  30. package/lib/cli/ascx/token-estimate.mjs +15 -0
  31. package/lib/cli/backup.mjs +37 -4
  32. package/lib/cli/commands/context.mjs +140 -0
  33. package/lib/cli/commands/init.mjs +14 -2
  34. package/lib/cli/commands/optimize.mjs +143 -2
  35. package/lib/cli/commands/upgrade/design-intent-seed.mjs +46 -0
  36. package/lib/cli/commands/upgrade/token-optimization-state.mjs +51 -0
  37. package/lib/cli/commands/upgrade.mjs +34 -45
  38. package/lib/cli/compiler.mjs +9 -0
  39. package/lib/cli/project-scaffolder/prompt-builders.mjs +1 -0
  40. package/lib/cli/token-optimization.mjs +161 -6
  41. package/lib/cli/utils.mjs +15 -1
  42. package/package.json +10 -3
  43. package/scripts/adaptive-context/fixtures.mjs +188 -0
  44. package/scripts/adaptive-context-benchmark.mjs +9 -0
  45. package/scripts/ascx-runtime-token-saver-benchmark.mjs +9 -0
  46. package/scripts/build-release-benchmark-bundle.mjs +1 -3
  47. package/scripts/clean-local-artifacts.mjs +2 -0
  48. package/scripts/compact-natural-mode-benchmark.mjs +9 -0
  49. package/scripts/validate/config.mjs +6 -0
  50. package/scripts/validate.mjs +2 -0
@@ -0,0 +1,100 @@
1
+ # Compact Natural Mode
2
+
3
+ Status: active default response contract.
4
+
5
+ Use this prompt for final user-facing replies after the task-specific rule, prompt, checklist, and validation work is complete.
6
+
7
+ ## Purpose
8
+
9
+ Write the smallest complete answer that still lets the next developer act correctly.
10
+
11
+ Compact means high signal. It does not mean broken grammar, dialect, clipped fragments, or hiding evidence.
12
+
13
+ ## Always Remove
14
+
15
+ - greetings, affirmations, and repeated restatements
16
+ - narration about what you are about to do
17
+ - generic closing offers
18
+ - padding paragraphs that add no new technical content
19
+ - repeated summaries of the same decision
20
+
21
+ ## Always Preserve
22
+
23
+ - exact commands
24
+ - exact file paths and line numbers
25
+ - exact error messages, assertions, exit codes, and stack-trace highlights
26
+ - validation status, including tests not run
27
+ - assumptions, scope qualifiers, blockers, risks, and next actions
28
+ - destructive-operation warnings
29
+ - breaking changes and migration notes
30
+
31
+ ## Task Shapes
32
+
33
+ Use natural prose inside these shapes. Omit fields that do not apply, except safety fields.
34
+
35
+ Debug/root cause:
36
+
37
+ ```text
38
+ Root Cause: <one sentence>
39
+ Evidence: <exact error, command output, or file:line>
40
+ Fix: <exact command or code direction>
41
+ Next: <verification step>
42
+ ```
43
+
44
+ Test failure:
45
+
46
+ ```text
47
+ Failed: <test name>
48
+ Expected/Got: <value> / <value>
49
+ At: <file:line>
50
+ Evidence: <exact assertion or root error>
51
+ Fix direction: <one sentence>
52
+ ```
53
+
54
+ Code review finding:
55
+
56
+ ```text
57
+ [critical|warn|nit] <file>:<line> - <concern>. <requested change>
58
+ ```
59
+
60
+ Implementation/refactor summary:
61
+
62
+ ```text
63
+ Changed: <what changed>
64
+ Reason: <why>
65
+ Behavior: <changed, unchanged, or not verified>
66
+ Validation: <what ran or was not run>
67
+ Risk: <only if relevant>
68
+ ```
69
+
70
+ Destructive command:
71
+
72
+ ```text
73
+ WARNING: <what this destroys and whether it is reversible>
74
+ Command: <exact command>
75
+ Precondition: <what must be true before running>
76
+ ```
77
+
78
+ Security finding:
79
+
80
+ ```text
81
+ Severity: <critical|high|medium|low>
82
+ Class: <vulnerability class>
83
+ Location: <file:line>
84
+ Impact: <who or what is affected>
85
+ Evidence: <exact code, behavior, or command output>
86
+ Remediation: <specific fix direction>
87
+ Validation: <how to prove it is fixed>
88
+ ```
89
+
90
+ Planning/architecture may be longer. Keep decision, rationale, alternatives, tradeoffs, assumptions, and open questions visible.
91
+
92
+ ## Second-Pass Check
93
+
94
+ Before finalizing:
95
+
96
+ 1. Remove any sentence that adds no new technical content.
97
+ 2. Confirm mandatory evidence atoms remain exact.
98
+ 3. Confirm assumptions and validation gaps are visible.
99
+ 4. Confirm the answer has a decision or next action when the user asked for one.
100
+ 5. Confirm the tone is natural professional writing.
@@ -46,6 +46,7 @@ If the user specifies a framework, runtime, or architecture constraint, the agen
46
46
  - Set up configuration, validation, error handling, observability, health checks, and persistence only when they fit the approved runtime and project scope.
47
47
  - Every file must follow [naming conventions](../rules/naming-conv.md).
48
48
  - Every module must follow [architecture.md](../rules/architecture.md).
49
+ - New code must pass the natural implementation pass in [architecture.md](../rules/architecture.md): start with the simplest correct flow, add complexity only when the requirement or repo evidence needs it, and do not add files or layers for small tasks.
49
50
  - Every dependency must be justified per [efficiency-vs-hype.md](../rules/efficiency-vs-hype.md).
50
51
  - Use official framework setup commands or canonical starter flows when they produce newer, better-supported dependency defaults than manual package assembly.
51
52
  - Do not assemble a framework project from scratch by habit when official setup commands create the supported structure. Manual assembly is allowed only for tiny prototypes, educational demos, unusual repo constraints, or a documented architecture reason.
@@ -20,6 +20,7 @@ Before editing:
20
20
  Refactor rules:
21
21
  - Improve clarity, boundaries, naming, validation, error handling, tests, and docs.
22
22
  - Prioritize maintainability over compressed one-liners.
23
+ - Apply the natural implementation pass from architecture.md: keep the main flow traceable, use early returns where they reduce nesting, and avoid helper chains that only make the code look abstract.
23
24
  - Do not choose a stack, framework, library, or topology from offline assumptions.
24
25
  - Keep module boundaries explicit and project-specific.
25
26
  - Split large files when the split makes the flow easier to understand.
@@ -27,6 +27,7 @@ Run this before declaring a task done. Apply only the sections relevant to the c
27
27
  - [ ] No premature abstraction (base classes/util layers created only after repeated stable patterns)
28
28
  - [ ] Readability over brevity for maintainability
29
29
  - [ ] Complexity budget was applied: equivalent behavior uses fewer moving parts without losing validation, error handling, fallbacks, accessibility, tests, or security boundaries.
30
+ - [ ] Natural implementation pass was applied: the main flow is traceable, names are domain-specific, helpers carry real meaning, and compact code did not hide safeguards.
30
31
  - [ ] Controllers, route handlers, and transport adapters do not contain business policy, raw queries, or cross-resource orchestration.
31
32
  - [ ] Services or use cases own business flow, transaction boundaries, and mutation safety.
32
33
  - [ ] Repositories or adapters own persistence/external IO details without hiding business decisions.
@@ -143,3 +143,13 @@ keywords:
143
143
  1. Import through a module's public API instead of reaching into internal files.
144
144
  2. Keep contracts explicit at boundaries between modules.
145
145
  3. If a new developer cannot find the full flow of a feature in one clear area, the structure is too diffuse.
146
+
147
+ ## ARCH-013: Natural Implementation Pass
148
+
149
+ 1. Treat "human-readable" code as code that a maintainer can trace, test, and change safely. Do not optimize for looking hand-written at the expense of behavior.
150
+ 2. Write new code and refactors as a clear sequence of intent: validate the input, name the domain state, perform the operation, then return or report the outcome.
151
+ 3. Prefer early returns for invalid, empty, or unauthorized paths when they reduce nesting and make the happy path easier to follow.
152
+ 4. Keep functions focused on one responsibility, but do not create tiny helper chains unless the helper names a real domain condition, removes repeated logic, or makes the main flow easier to read.
153
+ 5. Avoid dense one-liners, nested ternaries, speculative classes, factories, interfaces, design patterns, and extra layers when direct code preserves the same guarantees.
154
+ 6. Match the local project style before introducing a new pattern. Do not make code generic enough to fit any product.
155
+ 7. Run a final naturalness pass before completion: domain names are specific, booleans expose state or permission, comments explain why only, edge cases are explicit, and simplification did not remove validation, error handling, fallbacks, accessibility, tests, security boundaries, or observability.
@@ -27,6 +27,9 @@ Use the target language and framework conventions. Do not invent a naming style
27
27
  3. Reject names that require reading the implementation to understand the value.
28
28
  4. Keep file and directory naming styles consistent inside the same feature unless a framework reason requires mixed styles.
29
29
  5. Reject booleans, units, and side-effect functions whose names hide what they represent or change.
30
- 6. Inline comments must explain why, not what.
31
- 7. Put a one-line rationale near non-obvious choices that deserve explanation, such as retry strategy, index column order, denormalized field, intentional swallow with named recovery, or magic constant tied to an external system.
32
- 8. Treat comments that paraphrase the code as noise.
30
+ 6. Name collections as collections when the language convention supports it.
31
+ 7. Name side-effect functions with an action plus the domain outcome they change.
32
+ 8. Avoid broad function names that describe activity without domain intent.
33
+ 9. Inline comments must explain why, not what.
34
+ 10. Put a one-line rationale near non-obvious choices that deserve explanation, such as retry strategy, index column order, denormalized field, intentional swallow with named recovery, or magic constant tied to an external system.
35
+ 11. Treat comments that paraphrase the code as noise.
@@ -17,8 +17,9 @@ Tracked operational artifact:
17
17
 
18
18
  Local-only/generated artifacts:
19
19
  - `active-memory.json`
20
- - `v3-purge-audit.json`
21
20
  - `llm-judge-report.json`
21
+ - `token-saver/`
22
+ - `token-optimization-report.json`
22
23
  - benchmark, trend, weekly governance, and quality report outputs
23
24
 
24
25
  Do not treat generated reports or archived research as current project truth. Rerun the matching `npm run benchmark:*`, `npm run report:*`, or `npm run audit:*` command when fresh evidence is needed.
package/AGENTS.md CHANGED
@@ -18,17 +18,17 @@ Write instructions as imperative gates:
18
18
  - Add validation when a rule can drift.
19
19
 
20
20
  ## Bootstrap Receipt
21
- For non-trivial coding, review, planning, or governance work, emit a concise Bootstrap Receipt before implementation output or file edits:
21
+ For non-trivial coding, review, planning, or governance work, run `agentic-senior-core context` first if available, or `npx @ryuenn3123/agentic-senior-core context` when only the package is available, then emit a concise Bootstrap Receipt before implementation output or file edits:
22
22
  - `loaded_files`: files actually read
23
23
  - `selected_rules`: files selected for this scope and why
24
24
  - `skipped_rules`: out-of-scope categories left unloaded
25
25
  - `unreachable_files`: required files that could not be read
26
26
  - `validation_plan`: expected checks before completion
27
27
 
28
- Keep it short. Do not load every rule just to fill it out.
28
+ Keep it short. Do not load every rule just to fill it out. Skip this receipt and do not run the context command for trivial tasks (e.g., simple version bumps, minor typo fixes, or simple commits).
29
29
 
30
- ## Command Economy
31
- Avoid repeated command output. Do not rerun broad inspections unless edits changed the result. Prefer targeted reads, targeted searches, concise diffs, and final validation gates.
30
+ ## Default Activation And Command Economy
31
+ At session start, enforce default-on surfaces: run `agentic-senior-core context` for non-trivial work, prefer `ascx git status` / `ascx git diff` / `ascx npm test` when available, and apply `compact-natural-mode.md` for final replies. Avoid repeated command output; use raw commands for pipes, redirects, or unsupported commands.
32
32
 
33
33
  ## Layer Index
34
34
  ### Layer 1: Rules (21 Files) [SCOPE-RESOLVED]
@@ -67,9 +67,8 @@ Execution Contracts are dynamic execution contracts from prompts, review checkli
67
67
 
68
68
  ### Layer 5: Prompts
69
69
 
70
- Location: `.agent-context/prompts/`.
71
-
72
- Load the matching prompt only:
70
+ Location: `.agent-context/prompts/`. Load the matching prompt only, plus `compact-natural-mode.md` as the default final-response contract:
71
+ - `compact-natural-mode.md` -> final response shape, evidence preservation, and compact natural prose
73
72
  - `init-project.md` -> create, build, new project, scaffold
74
73
  - `refactor.md` -> refactor, improve, clean up, fix
75
74
  - `review-code.md` -> review, audit, check, analyze
@@ -159,7 +158,6 @@ Action: one-line bounded next step
159
158
  Use valid rule IDs only; do not quote full rule prose, expose hidden chain-of-thought, or require the block for trivial replies.
160
159
 
161
160
  ## Definition of Done
162
-
163
161
  Never claim done without:
164
162
  1. Relevant rules applied.
165
163
  2. PR and architecture checklists considered.
package/README.md CHANGED
@@ -7,93 +7,89 @@
7
7
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
8
8
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md)
9
9
 
10
- **Production-grade Rules Engine (Governance Engine) for AI coding agents.**
10
+ **Production-grade Rules Engine for AI coding agents.**
11
11
  Works with Cursor, Windsurf, GitHub Copilot, Claude Code, Gemini, and other LLM-powered IDE workflows.
12
12
 
13
- Current package version: 4.1.0. Last published version before this release: 4.0.3.
14
-
15
- Highlights:
16
- - Uses `AGENTS.md` as the canonical instruction entrypoint.
17
- - Keeps Claude Code and Gemini bridges as native `@AGENTS.md` imports.
18
- - Loads detailed rules lazily from `.agent-context/` by task scope.
19
- - Keeps MCP workspace files opt-in through `--mcp-template`.
20
-
21
13
  </div>
22
14
 
23
15
  ---
24
16
 
25
- ## Why this exists
17
+ ## Install
26
18
 
27
- A coding agent that has read every framework tutorial on the internet still ships junior-grade work because nothing in its training tells it which trade-off matters in your codebase. This pack is a small set of plain-language rules an agent loads only when the work scope calls for them: data, endpoints, observability, resilience, migrations, jobs, configuration, versioning, security, design, and a few more. The rules are written as invariants and as bad habits to reject, not as opinions about which framework is fashionable. An agent that reads them treats your repo with the discipline of a senior engineer the first time, instead of after three rounds of review. You install it with one command, you can revert it with a backup, and it does not depend on any particular IDE or LLM provider.
28
-
29
- ### Long-Term Stability
30
-
31
- The rules in this pack are written as invariants, outcomes, and freshness criteria, not as named patterns, library prescriptions, or magic-number thresholds. A migration rule says "DDL expected to hold a lock longer than the service's acceptable request-latency threshold must use an online migration mechanism", not "use pgroll for tables larger than ten million rows". A resilience rule says "fail fast when a dependency is unhealthy and shed load before shared resources are exhausted", not "implement a circuit breaker using library X". The intent is that each rule continues to tell a future maintainer the right thing to do across at least three years of framework and tooling churn. Where a rule cites a specific tool name or numeric threshold, the citation block at the bottom of the rule carries a freshness anchor and (in the next release) a `last_validated` date so the next maintainer knows when the technology references were last cross-checked against current practice.
32
-
33
- ---
19
+ ```bash
20
+ npx @ryuenn3123/agentic-senior-core init
21
+ ```
34
22
 
35
- ## What's New in v4.1
23
+ Initializes `AGENTS.md`, native import bridges, checklists, policies, state files, and the lazy `.agent-context/` rule library. Token optimization and Compact Natural Mode are enabled by default.
36
24
 
37
- This release adds six backend rule files that bring the backend pack to parity with the existing frontend rule. They are technology-neutral by construction and follow the same v4 numbered-Markdown format as the prior fifteen rules.
25
+ Options:
26
+ - Add `--mcp-template` to generate VS Code MCP workspace config.
27
+ - Default init keeps MCP files opt-in.
28
+ - Add `--no-token-optimize` only when you do not want ASCX command guidance enabled.
29
+ - Local backup snapshots are written under `.agentic-backup/` and excluded from version control.
38
30
 
39
- - `observability.md` (`OBS-*`) — observability as structured per-request events; metrics, logs, and traces as derived views; SLO-backed alerting; cardinality, signal-substitution, and audit-stream rules.
40
- - `resilience.md` (`RES-*`) — explicit timeouts and deadline propagation, idempotency-required retries, dependency isolation, fail-fast as outcome (not named pattern), explicit graceful degradation, observable backpressure.
41
- - `migrations.md` (`MIG-*`) — expand-contract / parallel-change for live data, deploy-ordering invariant, lock-posture rule keyed to the service's own latency budget, idempotent resumable backfills, mandatory risk fields per migration ticket.
42
- - `background-jobs.md` (`JOB-*`) — job-shape selection (scheduled vs queued vs stream vs one-shot), per-job ownership and runbook, job-level idempotency, lease/checkpoint/graceful-shutdown for long jobs, poison-message and dead-letter discipline, UTC schedules, jittered fan-out, explicit backpressure.
43
- - `config-and-flags.md` (`CFG-*`) — configuration sources and startup validation, secret handling, four-way feature-flag taxonomy (release / kill switch / experiment / entitlement) with per-flag owner and expiry, safe defaults on flag-service outage, no-branch-on-environment rule.
44
- - `api-versioning.md` (`VER-*`) — single versioning strategy per surface, breaking-vs-non-breaking definitions, deprecation discipline (in-band signal via RFC 9745 / RFC 8594 where adopted, plus migration guide and telemetry), explicit support windows, additive evolution as default, CI-blocking compatibility checks.
31
+ ## Upgrade
45
32
 
46
- Plus targeted refinements to four existing rules:
33
+ ```bash
34
+ npx @ryuenn3123/agentic-senior-core upgrade --dry-run
35
+ npx @ryuenn3123/agentic-senior-core upgrade --yes
36
+ ```
47
37
 
48
- - `frontend-architecture.md` — FE-012 Data state surface, FE-017 Interactivity priority, FE-018 Internationalization as layout, FE-019 Theme as context.
49
- - `security.md` — SEC-003 authn vs authz, SEC-004 memory-hard credential storage, SEC-005 cryptographically verifiable service-to-service identity.
50
- - `database-design.md` — DATA-003 money and time (no floating-point money, UTC for real-world moments), DATA-004 concurrency and write conflicts.
51
- - `api-docs.md` — API-005 cross-reference to the new versioning rule, API-012 idempotency as a runtime invariant (not just a documentation field).
38
+ Preview changes with `--dry-run`, then apply with `--yes`. Upgrade prunes obsolete managed files by default; use `--no-prune` to keep them. User-owned files without Agentic markers are never overwritten.
52
39
 
53
- Plus repository hygiene: archive consolidation into `docs/archive/HISTORY.md`, removal of the v3-purge and migrate-rule-format tooling (now under `docs/archive/migrations/`), and inlining of the terminology mapping into this README.
40
+ ---
54
41
 
55
- ## What's New in v4 (prior)
42
+ ## Core Commands
56
43
 
57
- The internal `.agent-context/rules/` pack is now numbered Markdown with YAML frontmatter and stable section IDs (e.g. `FE-004`, `ARCH-009`, `API-006`). This is a breaking change for downstream consumers that parse rule headings; the migration guide lives in `CHANGELOG.md` under `4.0.0`. Repository-wide impact:
44
+ | Command | Purpose |
45
+ |---------|---------|
46
+ | `agentic-senior-core init` | Initialize the compact project guidance pack and native agent entrypoints |
47
+ | `agentic-senior-core upgrade --dry-run` | Preview managed-surface upgrades |
48
+ | `agentic-senior-core context "<request>" --json --file src/app/page.tsx` | Resolve request labels, rules, prompts, docs, file signals, budget status, and fallback status |
49
+ | `ascx git status` | Run `git status` through the local evidence-preserving output wrapper |
50
+ | `ascx git diff` | Run `git diff` through the local evidence-preserving diff summary wrapper |
51
+ | `ascx npm test` | Run `npm test` through the local evidence-preserving output wrapper |
52
+ | `asc optimize status` | Check ASCX runtime token saver readiness |
53
+ | `asc optimize doctor` | Diagnose ASCX availability, tee write safety, and compression conflicts |
54
+ | `agentic-senior-core optimize --show` | Show token optimization state |
55
+ | `agentic-senior-core mcp` | Start local MCP stdio runtime |
56
+ | `npm run clean:local` | Remove ignored local reports, backups, benchmarks, and active-memory state |
58
57
 
59
- - Rules are now citable by ID, which the new bounded reflection block in `AGENTS.md` and the validation MCP tools (`lookup_rule`, `validate_against_rules`, `audit_compliance`) rely on.
60
- - A three-layer prompt caching contract (D4 in `docs/architecture/decisions-foundation.md`) is now enforced by `npm run audit:cache-layer-contract`.
61
- - A provider-free anti-halu benchmark is included (`benchmarks/anti-halu/`); pass rate and citation validity are reproducible locally.
62
- - Caching numbers are scoped per integration. The 89.31% Anthropic warm-cache effective reduction reported in `benchmarks/results/cache-phase-2-2026-05-16.json` applies to direct provider API and Claude Code SDK programmatic mode only. IDE wrapper integrations (Cursor, Windsurf, Codex CLI, Kiro) receive prefix stability without a measurable per-pack saving. See `docs/integration-playbook.md` for the per-tool matrix and `docs/benchmark-reference.md` for the required reporting JSON shape.
58
+ `ascx` currently compresses only `git status`, `git diff`, and `npm test`. Other commands, pipes, redirects, and unsupported shell shapes pass through without compression. Compressed output includes a structured footer with command, exit code, filter name, estimated token reduction, and a raw tee path when safety requires it.
63
59
 
60
+ `asc` is a short alias for the main `agentic-senior-core` CLI. The doctor does not probe localhost services in this phase; `9router` status remains `not-checked`.
64
61
 
65
- ## 60-Second Start
62
+ ---
66
63
 
64
+ ## What It Does
67
65
 
68
- ```bash
69
- npx @ryuenn3123/agentic-senior-core init
70
- ```
66
+ A coding agent that has read every framework tutorial still ships junior-grade work because nothing in its training tells it which trade-off matters in your codebase. This pack is a small set of plain-language rules an agent loads only when the work scope calls for them. The rules are written as invariants and bad habits to reject, not as opinions about which framework is fashionable. You install it with one command, revert with a backup, and it does not depend on any IDE or LLM provider.
71
67
 
72
- One command to initialize `AGENTS.md`, native import bridges, checklists, policies, state files, and the lazy `.agent-context/` rule library for your project.
68
+ ### How It Works
73
69
 
74
- > **See [docs/doc-index.md](docs/doc-index.md), [docs/deep-dive.md](docs/deep-dive.md), and [docs/deep-analysis-and-roadmap-backlog.md](docs/deep-analysis-and-roadmap-backlog.md) for deeper CLI, architecture, integration, and roadmap context.**
70
+ 1. Agent reads `AGENTS.md` at the start of each session.
71
+ 2. `AGENTS.md` activates the default triad: Adaptive Context for scoped rule selection, ASCX wrappers for supported noisy commands, and Compact Natural Mode for final replies.
72
+ 3. For shell commands, the agent uses `ascx` wrappers that compress noisy output while preserving debugging evidence (exit codes, file paths, line numbers, root errors, truncation markers, and raw tee paths).
73
+ 4. For final replies, the agent applies `.agent-context/prompts/compact-natural-mode.md` so answers stay concise without losing commands, paths, errors, assumptions, validation status, risks, or next actions.
74
+ 5. Detailed rules live under `.agent-context/rules/` and load by scope: 21 rule files covering architecture, security, performance, testing, database, API, frontend, Docker, observability, resilience, migrations, background jobs, configuration, and versioning.
75
75
 
76
- - Default init copies the compact instruction surface and writes onboarding, selected policy, token optimization, and memory continuity state.
77
- - MCP workspace files are disabled by default. Add `--mcp-template` when you want starter IDE MCP configuration files.
78
- - When project docs are scaffolded, `docs/doc-index.md` is used as the compact map for deeper docs so agents can read the right files without scanning every Markdown file.
79
- - Local backup snapshots are written under `.agentic-backup/`; init and upgrade ensure that folder is ignored by the target repository.
80
- - Package scope is `@ryuenn3123`; the GitHub repository owner is `fatidaprilian`.
76
+ ### Instruction Entrypoints
81
77
 
82
- ---
78
+ The canonical installed source is `AGENTS.md`.
83
79
 
84
- ## Design Direction
80
+ Default init and upgrade keep the project root compact:
81
+ - `AGENTS.md`
82
+ - `CLAUDE.md`
83
+ - `GEMINI.md`
84
+ - `.agent-context/`
85
85
 
86
- For UI, UX, layout, screen, Tailwind, frontend, or redesign work, the pack routes agents through the design bootstrap and frontend architecture rules before code changes.
86
+ `CLAUDE.md` and `GEMINI.md` are native import bridges that load `AGENTS.md`. Detailed rules, prompts, checklists, policies, and state stay under `.agent-context/` and load by task scope.
87
87
 
88
- The intended behavior is agent-led, not offline-template-led:
88
+ Deprecated legacy files (`.instructions.md`, `.agent-instructions.md`, `.cursorrules`, `.windsurfrules`, tool-specific rule directories) are no longer generated. Upgrade prunes Agentic-managed copies while preserving user-owned files.
89
89
 
90
- - Existing projects: read the real repository, docs, UI surface, and current user brief before changing design.
91
- - Fresh projects: ask the LLM agent to recommend the stack and design approach from current evidence instead of silently choosing a hardcoded framework.
92
- - No visual reference provided: synthesize one modern conceptual anchor first, then derive typography, spacing, morphology, motion, and responsive behavior from that anchor.
93
- - Modern UI claims: research current-year libraries and patterns when relevant; 2026 work should use 2026 evidence, and future years should update automatically through agent research.
94
- - Anti-generic rule: avoid safe dashboard shells, admin panels, card grids, scale-only mobile layouts, and static no-motion interfaces unless the product context explicitly justifies them.
90
+ ### Long-Term Stability
95
91
 
96
- UI design work runs a research dossier prompt (`.agent-context/prompts/research-design.md`) before the bootstrap prompt. The dossier captures product reading, reference intake, category cliches, a morphological matrix, and five anchor candidates with a strengthened rename test. The contract carries a 90-day `researchVerifiedAt` freshness gate and an anti-repeat ledger seeded from prior anchor, palette, motion, and typography choices on existing projects, so additive UI work within the freshness window skips the research stage while redesigns and stale dossiers re-run it.
92
+ Rules are written as invariants, outcomes, and freshness criteria, not as named patterns, library prescriptions, or magic-number thresholds. Where a rule cites a specific tool or threshold, the citation block carries a freshness anchor so the next maintainer knows when the technology references were last validated.
97
93
 
98
94
  ---
99
95
 
@@ -115,64 +111,40 @@ If you see `Property $schema is not allowed`, keep `.vscode/mcp.json` without `$
115
111
 
116
112
  ---
117
113
 
118
- ## Core Commands
114
+ ## Design Direction
119
115
 
120
- | Command | Purpose |
121
- |---------|---------|
122
- | `agentic-senior-core init` | Initialize the compact project guidance pack and native agent entrypoints |
123
- | `agentic-senior-core upgrade --dry-run` | Preview managed-surface upgrades |
124
- | `agentic-senior-core optimize --show` | Show token optimization state |
125
- | `npm run clean:local` | Remove ignored local reports, backups, benchmarks, and active-memory state |
126
- | `agentic-senior-core mcp` | Start local MCP stdio runtime |
116
+ For UI, UX, layout, screen, Tailwind, frontend, or redesign work, the pack routes agents through a research dossier prompt and design bootstrap before code changes. The flow synthesizes a conceptual anchor, derives typography, spacing, morphology, motion, and responsive behavior, and carries a 90-day freshness gate with an anti-repeat ledger to avoid recycling the same visual direction. Existing projects read the real repository and docs first; fresh projects ask the agent to recommend the stack from current evidence instead of hardcoding a framework.
117
+
118
+ See [docs/doc-index.md](docs/doc-index.md) for the full doc routing map.
127
119
 
128
120
  ---
129
121
 
130
- ## Upgrade Existing Governance Pack
122
+ ## What's New
131
123
 
132
- ```bash
133
- npx @ryuenn3123/agentic-senior-core upgrade --dry-run
134
- npx @ryuenn3123/agentic-senior-core upgrade --yes
135
- ```
124
+ ### v4.2
136
125
 
137
- Use `--dry-run` first to preview changes safely, then apply with `--yes`.
126
+ Adds `ascx` command wrapper to optimize token usage via high-signal adapters for `git status`, `git diff`, and `npm test` alongside the `Compact Natural Mode` response compression contract to reduce token overhead while retaining high-fidelity reasoning.
138
127
 
139
- Upgrade now performs managed-surface synchronization by default: obsolete Agentic-managed instruction files are pruned so the pack stays aligned with the latest release.
140
- Use `--no-prune` if you want to keep legacy managed files.
128
+ ### v4.1
141
129
 
142
- When upgrade creates `.agentic-backup/`, it also keeps the target root `.gitignore` aligned with that local-only backup folder. The backup is for rollback safety, not a source of truth and not a file to commit.
130
+ Adds six backend rule files (`OBS-*`, `RES-*`, `MIG-*`, `JOB-*`, `CFG-*`, `VER-*`) and targeted refinements to `frontend-architecture.md`, `security.md`, `database-design.md`, and `api-docs.md`. See [CHANGELOG.md](CHANGELOG.md) for the full list.
143
131
 
144
- ## Instruction Entrypoints
132
+ ### v4.0
145
133
 
146
- The canonical installed source is `AGENTS.md`.
134
+ Numbered Markdown rules with stable section IDs, bounded reflection, provider-free anti-halu benchmark, three-layer prompt caching contract, and per-integration caching scope enforcement. Caching numbers are scoped per integration; IDE wrapper integrations receive prefix stability without a measurable per-pack saving. See [docs/benchmark-reference.md](docs/benchmark-reference.md) for the reporting format and [CHANGELOG.md](CHANGELOG.md) for details.
147
135
 
148
- Default init and upgrade now keep the project root compact:
149
- - `AGENTS.md`
150
- - `CLAUDE.md`
151
- - `GEMINI.md`
152
- - `.agent-context/`
153
-
154
- `CLAUDE.md` and `GEMINI.md` are native import bridges that load `AGENTS.md`. Detailed rules, prompts, checklists, policies, and state stay under `.agent-context/` and load by task scope.
155
-
156
- Deprecated legacy files such as `.instructions.md`, `.agent-instructions.md`, `.cursorrules`, `.windsurfrules`, `.agent-override.md`, tool-specific rule directories, and copied Copilot/Gemini instruction folders are no longer generated by default. Upgrade prunes Agentic-managed copies while preserving user-owned files without Agentic markers.
136
+ Current package version: 4.2.0. Last published version: 4.0.3.
157
137
 
158
138
  ---
159
139
 
160
- ## Terminology Mapping (Final)
161
-
162
- | Canonical Term | Developer-Facing Alias | Usage Rule |
163
- |----------------|------------------------|------------|
164
- | Federated Governance | Federated Rules Operations | Use canonical term in formal policy artifacts. |
165
- | Governance Engine | Rules Engine | Use alias in onboarding and day-to-day developer docs. |
166
- | Guardrails | Quality Checks | Use alias in implementation guidance and quickstart docs. |
167
-
168
- Rule: on first mention in developer-facing docs, include canonical term in parentheses.
169
-
170
- Examples:
171
- - `Federated Rules Operations (Federated Governance)`
172
- - `Rules Engine (Governance Engine)`
173
- - `quality checks (guardrails)`
140
+ ## Validation
174
141
 
175
- Compliance boundary: formal policy and audit artifacts must keep canonical terminology for operational traceability.
142
+ ```bash
143
+ npm run validate
144
+ npm test
145
+ npm run gate:release
146
+ npm run benchmark:ascx
147
+ ```
176
148
 
177
149
  ---
178
150
 
@@ -180,26 +152,16 @@ Compliance boundary: formal policy and audit artifacts must keep canonical termi
180
152
 
181
153
  - FAQ: docs/faq.md
182
154
  - Deep dive internals: docs/deep-dive.md
183
- - Project history (phase outcomes, archived playbooks, retired roadmap): docs/archive/HISTORY.md
155
+ - Deep analysis and roadmap: docs/deep-analysis-and-roadmap-backlog.md
184
156
  - Integration playbook: docs/integration-playbook.md
185
157
  - Benchmark and stack reference: docs/benchmark-reference.md
186
- - Active roadmap and backlog: docs/deep-analysis-and-roadmap-backlog.md
187
-
188
- ---
189
-
190
- ## Validation
191
-
192
- ```bash
193
- npm run validate
194
- npm test
195
- npm run gate:release
196
- ```
158
+ - Project history: docs/archive/HISTORY.md
197
159
 
198
160
  ---
199
161
 
200
162
  ## Release and npm Publish Flow
201
163
 
202
- This repository publishes to npm automatically through GitHub Actions on every push to `main`.
164
+ This repository publishes to npm through GitHub Actions on push to `main`.
203
165
 
204
166
  Release checklist:
205
167
 
@@ -209,10 +171,26 @@ Release checklist:
209
171
  4. Commit with a Conventional Commit message.
210
172
  5. Push to `origin/main`.
211
173
 
212
- Important notes:
174
+ Package scope: `@ryuenn3123`. GitHub owner: `fatidaprilian`.
175
+
176
+ ---
177
+
178
+ ## Terminology Mapping (Final)
179
+
180
+ | Canonical Term | Developer-Facing Alias | Usage Rule |
181
+ |----------------|------------------------|------------|
182
+ | Federated Governance | Federated Rules Operations | Use canonical term in formal policy artifacts. |
183
+ | Governance Engine | Rules Engine | Use alias in onboarding and day-to-day developer docs. |
184
+ | Guardrails | Quality Checks | Use alias in implementation guidance and quickstart docs. |
185
+
186
+ Rule: on first mention in developer-facing docs, include canonical term in parentheses.
213
187
 
214
- - If the npm version already exists, publish fails.
215
- - Publish requires valid `NPM_TOKEN` in repository secrets.
188
+ Examples:
189
+ - `Federated Rules Operations (Federated Governance)`
190
+ - `Rules Engine (Governance Engine)`
191
+ - `quality checks (guardrails)`
192
+
193
+ Compliance boundary: formal policy and audit artifacts must keep canonical terminology for operational traceability.
216
194
 
217
195
  ---
218
196
 
@@ -0,0 +1,60 @@
1
+ # Benchmarks
2
+
3
+ Reproducible measurement suites for this repository. Release-facing claims must point to tracked JSON evidence under `benchmarks/results/` or to deterministic benchmark commands that print machine-readable output.
4
+
5
+ ## Folder Structure
6
+
7
+ ```text
8
+ benchmarks/
9
+ |-- anti-halu/ Provider-free anti-hallucination fixtures and scorer
10
+ |-- compact-natural-mode/ Response compression fixtures and scorer
11
+ |-- runtime-token-saver/ ASCX command-output compression fixtures
12
+ |-- token-usage/ Provider token-counting and cache simulation benchmark
13
+ |-- results/ Tracked release evidence JSON
14
+ `-- README.md
15
+ ```
16
+
17
+ ## Active Benchmarks
18
+
19
+ | Suite | Folder | Status | Output |
20
+ | --- | --- | --- | --- |
21
+ | Token usage baseline | `token-usage/` | Historical release evidence | `results/baseline-{YYYY-MM-DD}.json` |
22
+ | Cache simulation | `token-usage/` | Historical release evidence | `results/cache-phase-2-{YYYY-MM-DD}.json` |
23
+ | Anti-halu benchmark | `anti-halu/` | Active deterministic gate | `results/anti-halu-phase-3-{YYYY-MM-DD}.json` |
24
+ | ASCX runtime token saver | `runtime-token-saver/` | Active deterministic gate | stdout via `npm run benchmark:ascx` |
25
+ | Compact Natural Mode | `compact-natural-mode/` | Active deterministic gate | stdout via `npm run benchmark:compact-natural` |
26
+ | Release benchmark bundle | `results/` | Active integrity gate | `results/release-bundle-{semver}.json` |
27
+
28
+ ## Running Benchmarks
29
+
30
+ Use the package scripts for active gates:
31
+
32
+ ```bash
33
+ npm run benchmark:adaptive-context
34
+ npm run benchmark:ascx
35
+ npm run benchmark:compact-natural
36
+ npm run benchmark:anti-halu
37
+ npm run build:release-bundle
38
+ npm run audit:release-bundle
39
+ ```
40
+
41
+ See `benchmarks/token-usage/README.md` for the provider token-counting benchmark details.
42
+
43
+ ## Reproducibility Requirements
44
+
45
+ 1. Use Node 22 or the runtime version documented by the current package metadata.
46
+ 2. Do not add runtime dependencies to the core package for benchmark-only work. Benchmark tooling belongs in `devDependencies`.
47
+ 3. Keep JSON output deterministic where possible. If timestamps or host facts vary, isolate them in metadata fields.
48
+ 4. Include schema version, timestamp, and tooling version when a result file is tracked so older evidence remains interpretable.
49
+
50
+ ## Result Files Convention
51
+
52
+ - Track release evidence under `benchmarks/results/*.json`.
53
+ - Use `{suite-name}-{YYYY-MM-DD}.json` or `{suite-name}-{semver}.json`.
54
+ - Do not store raw API responses, secrets, tokens, or user data.
55
+ - Historical phase outcomes are consolidated in `docs/archive/HISTORY.md`.
56
+ - Live benchmark reporting rules are in `docs/benchmark-reference.md`.
57
+
58
+ ## Why This Exists
59
+
60
+ Claims such as "40% token saving" or "rule adherence improved" need reproducible evidence. These suites are the comparator surface for README, changelog, release, and planning claims.