@ryuenn3123/agentic-senior-core 4.0.3 → 4.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 (63) 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/api-docs.md +14 -0
  6. package/.agent-context/rules/api-versioning.md +93 -0
  7. package/.agent-context/rules/architecture.md +10 -0
  8. package/.agent-context/rules/background-jobs.md +93 -0
  9. package/.agent-context/rules/config-and-flags.md +79 -0
  10. package/.agent-context/rules/database-design.md +32 -0
  11. package/.agent-context/rules/frontend-architecture.md +35 -0
  12. package/.agent-context/rules/migrations.md +84 -0
  13. package/.agent-context/rules/naming-conv.md +6 -3
  14. package/.agent-context/rules/observability.md +69 -0
  15. package/.agent-context/rules/resilience.md +78 -0
  16. package/.agent-context/rules/security.md +28 -0
  17. package/AGENTS.md +13 -15
  18. package/README.md +102 -91
  19. package/benchmarks/README.md +40 -0
  20. package/benchmarks/compact-natural-mode/fixtures.mjs +359 -0
  21. package/benchmarks/compact-natural-mode/scorer.mjs +331 -0
  22. package/benchmarks/runtime-token-saver/fixtures.mjs +613 -0
  23. package/bin/agentic-senior-core.js +6 -0
  24. package/bin/ascx.js +23 -0
  25. package/lib/cli/adaptive-context/catalog.mjs +428 -0
  26. package/lib/cli/adaptive-context/file-signals.mjs +100 -0
  27. package/lib/cli/adaptive-context/implications.mjs +44 -0
  28. package/lib/cli/adaptive-context.mjs +365 -0
  29. package/lib/cli/ascx/adapters/git-diff.mjs +223 -0
  30. package/lib/cli/ascx/adapters/git-status.mjs +145 -0
  31. package/lib/cli/ascx/adapters/npm-test.mjs +120 -0
  32. package/lib/cli/ascx/fixture-evaluator.mjs +180 -0
  33. package/lib/cli/ascx/formatter.mjs +46 -0
  34. package/lib/cli/ascx/lexer.mjs +113 -0
  35. package/lib/cli/ascx/runtime.mjs +188 -0
  36. package/lib/cli/ascx/tee-writer.mjs +38 -0
  37. package/lib/cli/ascx/token-estimate.mjs +15 -0
  38. package/lib/cli/commands/context.mjs +140 -0
  39. package/lib/cli/commands/init.mjs +2 -1
  40. package/lib/cli/commands/optimize.mjs +143 -2
  41. package/lib/cli/commands/upgrade.mjs +2 -0
  42. package/lib/cli/compiler.mjs +9 -0
  43. package/lib/cli/token-optimization.mjs +161 -6
  44. package/lib/cli/utils.mjs +15 -1
  45. package/package.json +11 -5
  46. package/scripts/adaptive-context/fixtures.mjs +188 -0
  47. package/scripts/adaptive-context-benchmark.mjs +9 -0
  48. package/scripts/ascx-runtime-token-saver-benchmark.mjs +9 -0
  49. package/scripts/audit-cache-layer-contract.mjs +5 -0
  50. package/scripts/audit-caching-scope-hygiene.mjs +5 -0
  51. package/scripts/clean-local-artifacts.mjs +0 -1
  52. package/scripts/compact-natural-mode-benchmark.mjs +9 -0
  53. package/scripts/frontend-usability-audit.mjs +5 -8
  54. package/scripts/release-gate/static-checks.mjs +7 -7
  55. package/scripts/validate/config.mjs +1 -2
  56. package/scripts/validate/coverage-checks.mjs +1 -42
  57. package/scripts/validate.mjs +11 -7
  58. package/scripts/migrate-rule-format/id-prefix-table.mjs +0 -37
  59. package/scripts/migrate-rule-format/parse-legacy.mjs +0 -180
  60. package/scripts/migrate-rule-format/render-new.mjs +0 -169
  61. package/scripts/migrate-rule-format/roundtrip-validate.mjs +0 -89
  62. package/scripts/migrate-rule-format.mjs +0 -192
  63. package/scripts/v3-purge-audit.mjs +0 -236
package/README.md CHANGED
@@ -2,68 +2,94 @@
2
2
 
3
3
  # Agentic-Senior-Core
4
4
 
5
- ### Force your AI Agent to code like a Staff Engineer, not a Junior.
5
+ ### Change your AI Agent to code like a Staff Engineer, not a Junior.
6
6
 
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.0.0. Last published version before this release: 3.0.50.
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
- ## What's New in v4
26
-
27
- 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:
17
+ ## Install
28
18
 
29
- - 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.
30
- - A three-layer prompt caching contract (D4 in `docs/architecture/decisions-foundation.md`) is now enforced by `npm run audit:cache-layer-contract`.
31
- - A provider-free anti-halu benchmark is included (`benchmarks/anti-halu/`); pass rate and citation validity are reproducible locally.
32
- - 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.
19
+ ```bash
20
+ npx @ryuenn3123/agentic-senior-core init
21
+ ```
33
22
 
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.
34
24
 
35
- ## 60-Second Start
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.
36
30
 
31
+ ## Upgrade
37
32
 
38
33
  ```bash
39
- npx @ryuenn3123/agentic-senior-core init
34
+ npx @ryuenn3123/agentic-senior-core upgrade --dry-run
35
+ npx @ryuenn3123/agentic-senior-core upgrade --yes
40
36
  ```
41
37
 
42
- One command to initialize `AGENTS.md`, native import bridges, checklists, policies, state files, and the lazy `.agent-context/` rule library for your project.
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.
39
+
40
+ ---
41
+
42
+ ## Core Commands
43
+
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 |
43
57
 
44
- > **See [docs/doc-index.md](docs/doc-index.md), [docs/deep-dive.md](docs/deep-dive.md), and [docs/roadmap.md](docs/roadmap.md) for deeper CLI, architecture, integration, and roadmap context.**
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.
45
59
 
46
- - Default init copies the compact instruction surface and writes onboarding, selected policy, token optimization, and memory continuity state.
47
- - MCP workspace files are disabled by default. Add `--mcp-template` when you want starter IDE MCP configuration files.
48
- - 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.
49
- - Local backup snapshots are written under `.agentic-backup/`; init and upgrade ensure that folder is ignored by the target repository.
50
- - Package scope is `@ryuenn3123`; the GitHub repository owner is `fatidaprilian`.
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`.
51
61
 
52
62
  ---
53
63
 
54
- ## Design Direction
64
+ ## What It Does
65
+
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.
55
67
 
56
- 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.
68
+ ### How It Works
57
69
 
58
- The intended behavior is agent-led, not offline-template-led:
70
+ 1. Agent reads `AGENTS.md` at the start of each session.
71
+ 2. `AGENTS.md` instructs the agent to run the Adaptive Context resolver, which selects only the rules, prompts, and docs relevant to the current task.
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.
59
75
 
60
- - Existing projects: read the real repository, docs, UI surface, and current user brief before changing design.
61
- - Fresh projects: ask the LLM agent to recommend the stack and design approach from current evidence instead of silently choosing a hardcoded framework.
62
- - No visual reference provided: synthesize one modern conceptual anchor first, then derive typography, spacing, morphology, motion, and responsive behavior from that anchor.
63
- - 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.
64
- - 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.
76
+ ### Instruction Entrypoints
65
77
 
66
- 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.
78
+ The canonical installed source is `AGENTS.md`.
79
+
80
+ Default init and upgrade keep the project root compact:
81
+ - `AGENTS.md`
82
+ - `CLAUDE.md`
83
+ - `GEMINI.md`
84
+ - `.agent-context/`
85
+
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
+
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
+
90
+ ### Long-Term Stability
91
+
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.
67
93
 
68
94
  ---
69
95
 
@@ -85,60 +111,40 @@ If you see `Property $schema is not allowed`, keep `.vscode/mcp.json` without `$
85
111
 
86
112
  ---
87
113
 
88
- ## Core Commands
89
-
90
- | Command | Purpose |
91
- |---------|---------|
92
- | `agentic-senior-core init` | Initialize the compact project guidance pack and native agent entrypoints |
93
- | `agentic-senior-core upgrade --dry-run` | Preview managed-surface upgrades |
94
- | `agentic-senior-core optimize --show` | Show token optimization state |
95
- | `npm run audit:v3-purge` | Run deep purge readiness audit (no deletion) |
96
- | `npm run clean:local` | Remove ignored local reports, backups, benchmarks, and active-memory state |
97
- | `agentic-senior-core mcp` | Start local MCP stdio runtime |
114
+ ## Design Direction
98
115
 
99
- ---
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.
100
117
 
101
- ## Upgrade Existing Governance Pack
118
+ See [docs/doc-index.md](docs/doc-index.md) for the full doc routing map.
102
119
 
103
- ```bash
104
- npx @ryuenn3123/agentic-senior-core upgrade --dry-run
105
- npx @ryuenn3123/agentic-senior-core upgrade --yes
106
- ```
120
+ ---
107
121
 
108
- Use `--dry-run` first to preview changes safely, then apply with `--yes`.
122
+ ## What's New
109
123
 
110
- Upgrade now performs managed-surface synchronization by default: obsolete Agentic-managed instruction files are pruned so the pack stays aligned with the latest release.
111
- Use `--no-prune` if you want to keep legacy managed files.
124
+ ### v4.2
112
125
 
113
- 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.
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.
114
127
 
115
- ## Instruction Entrypoints
128
+ ### v4.1
116
129
 
117
- The canonical installed source is `AGENTS.md`.
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.
118
131
 
119
- Default init and upgrade now keep the project root compact:
120
- - `AGENTS.md`
121
- - `CLAUDE.md`
122
- - `GEMINI.md`
123
- - `.agent-context/`
132
+ ### v4.0
124
133
 
125
- `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.
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.
126
135
 
127
- 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.
128
137
 
129
138
  ---
130
139
 
131
- ## Terminology Mapping (Final)
132
-
133
- | Canonical Term | Developer-Facing Alias | Usage Rule |
134
- |----------------|------------------------|------------|
135
- | Federated Governance | Federated Rules Operations | Use canonical term in formal policy artifacts. |
136
- | Governance Engine | Rules Engine | Use alias in onboarding and day-to-day developer docs. |
137
- | Guardrails | Quality Checks | Use alias in implementation guidance and quickstart docs. |
138
-
139
- Rule: on first mention in developer-facing docs, include canonical term in parentheses.
140
+ ## Validation
140
141
 
141
- Full mapping reference: docs/terminology-mapping.md
142
+ ```bash
143
+ npm run validate
144
+ npm test
145
+ npm run gate:release
146
+ npm run benchmark:ascx
147
+ ```
142
148
 
143
149
  ---
144
150
 
@@ -146,27 +152,16 @@ Full mapping reference: docs/terminology-mapping.md
146
152
 
147
153
  - FAQ: docs/faq.md
148
154
  - Deep dive internals: docs/deep-dive.md
149
- - Archived V2 upgrade playbook: docs/archive/v2-upgrade-playbook.md
155
+ - Deep analysis and roadmap: docs/deep-analysis-and-roadmap-backlog.md
150
156
  - Integration playbook: docs/integration-playbook.md
151
157
  - Benchmark and stack reference: docs/benchmark-reference.md
152
- - Terminology mapping reference: docs/terminology-mapping.md
153
- - Product roadmap: docs/roadmap.md
154
-
155
- ---
156
-
157
- ## Validation
158
-
159
- ```bash
160
- npm run validate
161
- npm test
162
- npm run gate:release
163
- ```
158
+ - Project history: docs/archive/HISTORY.md
164
159
 
165
160
  ---
166
161
 
167
162
  ## Release and npm Publish Flow
168
163
 
169
- 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`.
170
165
 
171
166
  Release checklist:
172
167
 
@@ -176,10 +171,26 @@ Release checklist:
176
171
  4. Commit with a Conventional Commit message.
177
172
  5. Push to `origin/main`.
178
173
 
179
- 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.
187
+
188
+ Examples:
189
+ - `Federated Rules Operations (Federated Governance)`
190
+ - `Rules Engine (Governance Engine)`
191
+ - `quality checks (guardrails)`
180
192
 
181
- - If the npm version already exists, publish fails.
182
- - Publish requires valid `NPM_TOKEN` in repository secrets.
193
+ Compliance boundary: formal policy and audit artifacts must keep canonical terminology for operational traceability.
183
194
 
184
195
  ---
185
196
 
@@ -0,0 +1,40 @@
1
+ # Benchmarks
2
+
3
+ Reproducible measurement suites untuk repo ini. Setiap release publish hasil benchmark di `benchmarks/results/{name}-{date}.json` supaya klaim bisa diverifikasi.
4
+
5
+ ## Folder Structure
6
+
7
+ ```
8
+ benchmarks/
9
+ ├── token-usage/ Token measurement per provider untuk rules pack delivery
10
+ ├── results/ Output JSON yang dipublish per release (tracked di git)
11
+ └── README.md
12
+ ```
13
+
14
+ ## Active Benchmarks
15
+
16
+ | Suite | Folder | Status | Output |
17
+ |-------|--------|--------|--------|
18
+ | Token usage baseline | `token-usage/` | Phase 0 (in progress) | `results/baseline-{YYYY-MM-DD}.json` |
19
+
20
+ ## Running Benchmarks
21
+
22
+ Setiap suite punya README sendiri di sub-folder. Lihat `token-usage/README.md` untuk instruksi spesifik.
23
+
24
+ ## Reproducibility Requirements
25
+
26
+ 1. Node version: lihat `package.json#engines` (jika ada) atau gunakan Node 22 LTS minimum.
27
+ 2. Tidak boleh tambah dependency runtime ke core (`package.json#dependencies`). Benchmark hanya boleh pakai `devDependencies`.
28
+ 3. Output JSON harus deterministic — jika ada nilai yang berubah antar run (timestamp, host info), pisahkan ke field metadata terpisah.
29
+ 4. Setiap result file harus include schema version + timestamp + tooling version supaya hasil lama tetap interpretable.
30
+
31
+ ## Result Files Convention
32
+
33
+ - Tracked di git (`benchmarks/results/*.json` whitelisted di `.gitignore`).
34
+ - Naming: `{suite-name}-{YYYY-MM-DD}.json` atau `{suite-name}-{semver}.json`.
35
+ - Tidak boleh berisi raw API response yang bisa expose secrets atau data user.
36
+ - Latest baseline per suite is referenced from `docs/archive/phase-2-outcome.md` and the live decision authority in `docs/architecture/decisions-foundation.md`.
37
+
38
+ ## Why This Exists
39
+
40
+ Klaim seperti "hemat 40% token" atau "rule adherence +14pt" tanpa data reproducible = marketing. Suite di folder ini = comparator wajib untuk setiap claim di README atau release notes.