apt-mcp-agent-setup 2.0.1 → 3.0.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 (55) hide show
  1. package/bin/cli.js +1 -1
  2. package/bundle/NOTICES.md +0 -0
  3. package/bundle/core.enc +0 -0
  4. package/bundle/mcp-rules.enc +0 -0
  5. package/bundle/skills-aso.enc +0 -0
  6. package/bundle/skills-ba.enc +0 -0
  7. package/bundle/skills-base.enc +0 -0
  8. package/bundle/skills-be.enc +0 -0
  9. package/bundle/skills-design.enc +0 -0
  10. package/bundle/skills-fe.enc +0 -0
  11. package/bundle/skills-mobile.enc +0 -0
  12. package/bundle/skills-pm.enc +0 -0
  13. package/integrity-manifest.json +63 -17
  14. package/package.json +1 -1
  15. package/src/core/catalog.js +1 -0
  16. package/src/core/context-metrics.js +1 -0
  17. package/src/core/doctor.js +1 -0
  18. package/src/core/execution.js +1 -0
  19. package/src/core/hook-bridge.js +1 -0
  20. package/src/core/host-adapters.js +1 -0
  21. package/src/core/memory-store.js +1 -0
  22. package/src/core/model-routing.js +1 -0
  23. package/src/core/owned-lock.js +1 -0
  24. package/src/core/session.js +1 -0
  25. package/src/core/skill-names.js +1 -0
  26. package/src/installer/context-legacy-hashes.json +42 -0
  27. package/src/installer/global-setup.js +1 -1
  28. package/src/installer/host-hooks.js +1 -0
  29. package/src/installer/managed-config.js +1 -0
  30. package/src/installer/platform-config.js +1 -1
  31. package/src/installer/prerequisites.js +1 -1
  32. package/src/installer/project-setup.js +1 -1
  33. package/src/installer/runtime-launcher.js +1 -0
  34. package/src/installer/runtime-lock.js +1 -0
  35. package/src/installer/runtime-store.js +1 -0
  36. package/src/installer/setup-wizard.js +1 -1
  37. package/src/license/crypto.js +1 -1
  38. package/src/license/fingerprint.js +1 -1
  39. package/src/license/terms.js +1 -1
  40. package/src/license/verify.js +1 -1
  41. package/src/presets/index.js +1 -1
  42. package/src/proxy/backends.js +1 -1
  43. package/src/proxy/core-tools.js +1 -0
  44. package/src/proxy/pipeline.js +1 -1
  45. package/src/proxy/router.config.js +1 -1
  46. package/src/proxy/router.js +1 -1
  47. package/src/proxy/server.js +1 -1
  48. package/src/templates/AGENTS.md +13 -181
  49. package/src/templates/CLAUDE.md +7 -248
  50. package/src/templates/GEMINI.md +12 -293
  51. package/src/templates/apt-runtime.md +16 -0
  52. package/src/templates/copilot-instructions.md +7 -208
  53. package/src/templates/cursorrules.mdc +8 -222
  54. package/src/templates/mcp-tools.md +176 -175
  55. package/src/templates/windsurfrules.md +7 -208
@@ -1,175 +1,176 @@
1
- # MCP Tools — Decision Tree & Conventions
2
-
3
- ## Developer pipeline 2.0
4
-
5
- - Start: `pipeline_start(pipeline, task, workspace)` with a canonical lowercase task ID.
6
- - Resume: `pipeline_use(task, runId)` binds the MCP session and project-scoped backends to the run workspace.
7
- - Progress: `pipeline_checkpoint(task, runId, step, status="completed", summary)` only accepts the next step.
8
- - Inspect: `pipeline_status()` lists current runs; task and runId inspect one run without rebinding.
9
- - Cancel: `pipeline_reset(task, runId, confirm=true)` preserves state and ledger history.
10
- - Finish: `pipeline_prepare_merge(task, runId)` never merges, pushes, publishes, or deletes a branch.
11
-
12
- Git projects share pipeline state through the Git common directory. Non-Git projects use `.agents/pipelines` and can run in place. Git bootstrap for a managed worktree always requires a read-only preview and direct user confirmation.
13
-
14
- Pipeline enforcement covers proxied MCP tools only. Native host shell and file tools must follow the returned `workspacePath` explicitly.
15
-
16
- ## 🔍 Tool Selection — When to Use What
17
-
18
- ### Code Search & Navigation
19
-
20
- | Situation | Use Tool | NOT | Why |
21
- |---|---|---|---|
22
- | Explore file structure & dependencies | `explore_code` | `list_dir` | **PRIMARY TOOL — call FIRST for any code question or before edit** |
23
- | Find symbol definition, function, class | `code_search` | `grep_search` | Semantic search, understands code structure |
24
- | Find all callers of a function | `find_callers` | `grep_search` | Follows call graph, not just text match |
25
- | Find all functions called by a function | `find_callees` | — | Call graph traversal |
26
- | List files matching a pattern | `list_code_files` | `list_dir` | Faster, code-aware filtering |
27
- | Search in config files (YAML, JSON, .env) | `grep_search` | `code_search` | Non-code files, literal string match |
28
- | Search in markdown, docs, comments | `grep_search` | `code_search` | Plain text, not code symbols |
29
- | Search for exact string literal in code | `grep_search` | `code_search` | Literal match (error messages, magic strings) |
30
-
31
- **Rule: explore_code FIRST. grep_search ONLY non-code. No grep loops.**
32
-
33
- ### Impact Analysis
34
-
35
- | Situation | Use Tool | Why |
36
- |---|---|---|
37
- | "What breaks if I change this function?" | `impact_analysis` | Blast radius — shows all affected files/functions |
38
- | Before refactoring a shared module | `impact_analysis` | Prevent unintended side effects |
39
- | Code review — assessing risk of a PR | `impact_analysis` | Quantify change scope |
40
- | Simple "where is this used?" | `find_callers` | Lighter weight than full impact analysis |
41
-
42
- ### Persistent Knowledge
43
-
44
- | Situation | Use Tool | Why |
45
- |---|---|---|
46
- | Save a decision made this session | `remember` | Cross-session persistence |
47
- | Save a bug fix (root cause + solution) | `remember` | Future reference when similar bug appears |
48
- | Recall what was decided about X | `recall` | Search by keyword |
49
- | Load full knowledge graph | `read_knowledge` | Session start, get full context |
50
- | Connect two related concepts | `link_knowledge` | Build relationship graph |
51
- | Remove outdated information | `forget` | Keep knowledge graph clean |
52
-
53
- ---
54
-
55
- ## 🧠 Memory Auto-Save Protocol (MANDATORY)
56
-
57
- Agent MUST auto-call `remember` in these situations — do NOT wait for user to ask:
58
-
59
- | Trigger | What to Save |
60
- |---|---|
61
- | After completing pipeline step `grill-me` | Design decisions + constraints discussed |
62
- | After completing pipeline step `diagnose` | Root cause + reproduction steps |
63
- | After completing pipeline step `tdd` | Implementation decisions + test patterns |
64
- | After completing pipeline step `improve-architecture` | Architecture improvements + quality findings |
65
- | User states a preference or convention | What they prefer + context |
66
- | Non-trivial bug resolved | Root cause, solution, affected files |
67
-
68
- **Pipeline checkpoint responses include `memory_action` field — follow it immediately.**
69
-
70
- ### Google Drive & Online Documents
71
-
72
- | Situation | Use Tool | Why |
73
- |---|---|---|
74
- | Search files on project Drive | `gdrive-search` | Find specs, testcases, sheets |
75
- | List files inside folder | `gdrive-list-folder` | Browse project folder structure |
76
- | Upload specs/testcase (xlsx/docx) | `gdrive-upload-file` | Set `convertToGoogleFormat: true` to auto-convert to Sheets/Docs |
77
- | Update specific row/cell in Sheets | `gdrive-update-sheet-cell` | Modify cells for real-time QC collaboration |
78
- | Share sheet/doc with bank stakeholder | `gdrive-share-file` | Invite collaborators (editor/viewer) |
79
-
80
- ---
81
-
82
- ## 🔄 Index Management — When to Rebuild
83
-
84
- ### code_search index (auto-managed)
85
-
86
- | Event | Action | Notes |
87
- |---|---|---|
88
- | Files changed on disk | **Auto-update** (file watcher) | No manual action needed |
89
- | Large refactor (50+ files) | Agent runs `code_search` after changes | Index catches up automatically |
90
- | New project setup | **Auto-index** on first query | May be slow first time |
91
-
92
- **Rule: NEVER ask the user to rebuild the code search index. It auto-manages.**
93
-
94
- ### impact_analysis index (MANUAL update required)
95
-
96
- | Event | Action Required |
97
- |---|---|
98
- | Before ANY impact analysis query | Agent MUST run index update first |
99
- | After committing changes (git) | Agent MUST run index update before next query |
100
- | User manages git manually (SourceTree, etc.) | Agent auto-runs update, NEVER asks user |
101
-
102
- **Rule: ALWAYS update impact_analysis index before querying. Do it silently — never ask the user.**
103
-
104
- Before calling `impact_analysis`:
105
- 1. Run index update (silent, no user prompt)
106
- 2. Wait for completion
107
- 3. Then execute the impact query
108
-
109
- ---
110
-
111
- ## 🪜 Code Writing — Laziness Ladder
112
-
113
- Before writing ANY code, stop at the **first rung** that holds:
114
-
115
- | Rung | Check | Tool to Use | If Yes → |
116
- |---|---|---|---|
117
- | 1. YAGNI | Does this need to exist? | Think first | Skip it, explain why in one line |
118
- | 2. Reuse | Already in codebase? | `explore_code` | Reuse existing helper/util/pattern |
119
- | 3. Stdlib | Standard library does it? | Language docs | Use stdlib |
120
- | 4. Platform | Native platform feature? | — | Use it (CSS > JS, `<input type="date">` > picker lib, DB constraint > app code) |
121
- | 5. Installed dep | Already-installed dependency? | `explore_code` on package.json/pubspec | Use existing dep. No new deps for what a few lines do |
122
- | 6. One-liner | Can it be one line? | — | One line |
123
- | 7. Minimum | Only when above fail | — | Write minimum code that works |
124
-
125
- **Rule: The ladder runs AFTER understanding the problem. Read the code it touches (`explore_code`), trace the real flow, THEN climb.**
126
-
127
- **Bug fix rule: Root cause, not symptom.** Grep every caller (`find_callers`), fix the shared function once — not each caller path.
128
-
129
- ---
130
-
131
- ## 🧠 Memory Conventions — When to Save & Read
132
-
133
- ### When to SAVE (`remember`)
134
-
135
- | Trigger | Entity Type | What to Save |
136
- |---|---|---|
137
- | Resolved a non-trivial bug | `bug-fix` | Root cause, solution, affected files, how to detect similar |
138
- | Made an architecture/design decision | `decision` | What was decided, alternatives considered, rationale |
139
- | Completed a feature milestone | `feature` | What was built, key files, design choices |
140
- | Discovered a workflow/convention | `convention` | The pattern, why it exists, when to apply it |
141
- | User stated a preference | `preference` | What they prefer, context |
142
- | Completed project setup | `setup` | What was configured, tool versions, settings |
143
-
144
- **Save format:**
145
- ```
146
- Entity: [descriptive-name]
147
- Type: [bug-fix | decision | feature | convention | preference | setup]
148
- Content: [structured description]
149
- Tags: [relevant, searchable, keywords]
150
- ```
151
-
152
- ### When to READ (`recall` / `read_knowledge`)
153
-
154
- | Trigger | Action | Tool |
155
- |---|---|---|
156
- | **Session start** | Load full knowledge graph | `read_knowledge` |
157
- | Before investigating known-problematic areas | Search for related bug-fixes | `recall` with keywords |
158
- | Before making design decisions | Search for prior decisions on same topic | `recall` with topic |
159
- | Before touching a module with history | Search for conventions/gotchas | `recall` with module name |
160
- | User asks "what did we decide about X?" | Search explicitly | `recall` with X |
161
-
162
- ### Memory Architecture (2-tier)
163
-
164
- | Source | Purpose | Mutability | Location |
165
- |---|---|---|---|
166
- | `.agents/memory/MEMORY.md` | Static conventions, user preferences, coding standards | Manual edit only | Project repo |
167
- | `.memory/memory.jsonl` | Dynamic project knowledge graph | Agent read/write via MCP tools | Project root (gitignored) |
168
-
169
- **Rule: NEVER save to `.agents/memory/MEMORY.md` via MCP tools. That file is manually curated. MCP `remember`/`recall` always targets `.memory/memory.jsonl`.**
170
-
171
- ### Memory Isolation
172
-
173
- - Each project has its own `.memory/memory.jsonl` (configured via `.mcp.json`)
174
- - Global fallback: `~/.anhdh/memory/global.json` (neutral, for cross-project knowledge)
175
- - `.mcp.json` per project overrides global config → no data leakage between projects
1
+ # MCP Tools — Decision Tree & Conventions
2
+
3
+ ## Runtime and pipelines
4
+
5
+ - Bootstrap: `session_bootstrap(sessionId, contextEpoch, host, capabilities)` identifies this context and reports resumable work.
6
+ - Route: `route_request(sessionId, requestId, prompt, target, stack, explicitSkills)` returns the workflow and companion skills. Load them using `skill_load` only when needed.
7
+ - Start: `pipeline_start(pipeline, task, workspace, acceptanceCriteria, scope, sessionId)` creates a versioned run. Use `pipeline_use(task, runId)` to resume the same run.
8
+ - Execute: `pipeline_next(task, runId, sessionId, role, requestId)` reserves an attempt. Native host agents perform the work; the coordinator controls transitions.
9
+ - Verify: `pipeline_verify` records authorized argv execution under the run workspace. `pipeline_checkpoint` references evidence IDs for completion and supports report, pause, resume, release and criteria actions.
10
+ - Inspect: `pipeline_status` is read-only and does not bind sessions. `pipeline_reset` cancels without deleting history. `pipeline_prepare_merge` only prepares a report.
11
+ - Read-only questions, review and existing test execution do not require a mutation pipeline. Scope-limited changes use the short pipeline; increased risk adds required checks.
12
+ - MCP gates cover proxied calls. Native tool gates and continuation require observed host hooks. Plan Mode and user interruption take precedence.
13
+ - Codegraph failures permit file-search fallback. The proxy refreshes the review graph before impact analysis; it must report failure rather than use stale results.
14
+ - `mcp_agent_health` reports process, initialization and functional readiness separately. `npx apt-mcp-agent-setup doctor` performs read-only configuration inspection.
15
+
16
+
17
+ ## 🔍 Tool Selection — When to Use What
18
+
19
+ ### Code Search & Navigation
20
+
21
+ | Situation | Use Tool | NOT | Why |
22
+ |---|---|---|---|
23
+ | Explore file structure & dependencies | `explore_code` | `list_dir` | **PRIMARY TOOL — call FIRST for any code question or before edit** |
24
+ | Find symbol definition, function, class | `code_search` | `grep_search` | Semantic search, understands code structure |
25
+ | Find all callers of a function | `find_callers` | `grep_search` | Follows call graph, not just text match |
26
+ | Find all functions called by a function | `find_callees` | — | Call graph traversal |
27
+ | List files matching a pattern | `list_code_files` | `list_dir` | Faster, code-aware filtering |
28
+ | Search in config files (YAML, JSON, .env) | `grep_search` | `code_search` | Non-code files, literal string match |
29
+ | Search in markdown, docs, comments | `grep_search` | `code_search` | Plain text, not code symbols |
30
+ | Search for exact string literal in code | `grep_search` | `code_search` | Literal match (error messages, magic strings) |
31
+
32
+ **Rule: explore_code FIRST. grep_search ONLY non-code. No grep loops.**
33
+
34
+ ### Impact Analysis
35
+
36
+ | Situation | Use Tool | Why |
37
+ |---|---|---|
38
+ | "What breaks if I change this function?" | `impact_analysis` | Blast radius — shows all affected files/functions |
39
+ | Before refactoring a shared module | `impact_analysis` | Prevent unintended side effects |
40
+ | Code review — assessing risk of a PR | `impact_analysis` | Quantify change scope |
41
+ | Simple "where is this used?" | `find_callers` | Lighter weight than full impact analysis |
42
+
43
+ ### Persistent Knowledge
44
+
45
+ | Situation | Use Tool | Why |
46
+ |---|---|---|
47
+ | Save a decision made this session | `remember` | Cross-session persistence |
48
+ | Save a bug fix (root cause + solution) | `remember` | Future reference when similar bug appears |
49
+ | Recall what was decided about X | `recall` | Search by keyword |
50
+ | Load relevant task knowledge | `recall` | Explicit whole-graph inspection; prefer relevant recall during bootstrap |
51
+ | Connect two related concepts | `link_knowledge` | Build relationship graph |
52
+ | Remove outdated information | `forget` | Keep knowledge graph clean |
53
+
54
+ ---
55
+
56
+ ## 🧠 Memory Auto-Save Protocol (MANDATORY)
57
+
58
+ Agent MUST auto-call `remember` in these situations — do NOT wait for user to ask:
59
+
60
+ | Trigger | What to Save |
61
+ |---|---|
62
+ | After completing pipeline step `grill-me` | Design decisions + constraints discussed |
63
+ | After completing pipeline step `diagnose` | Root cause + reproduction steps |
64
+ | After completing pipeline step `tdd` | Implementation decisions + test patterns |
65
+ | After completing pipeline step `improve-architecture` | Architecture improvements + quality findings |
66
+ | User states a preference or convention | What they prefer + context |
67
+ | Non-trivial bug resolved | Root cause, solution, affected files |
68
+
69
+ **Pipeline checkpoint responses include `memory_action` field — follow it immediately.**
70
+
71
+ ### Google Drive & Online Documents
72
+
73
+ | Situation | Use Tool | Why |
74
+ |---|---|---|
75
+ | Search files on project Drive | `gdrive-search` | Find specs, testcases, sheets |
76
+ | List files inside folder | `gdrive-list-folder` | Browse project folder structure |
77
+ | Upload specs/testcase (xlsx/docx) | `gdrive-upload-file` | Set `convertToGoogleFormat: true` to auto-convert to Sheets/Docs |
78
+ | Update specific row/cell in Sheets | `gdrive-update-sheet-cell` | Modify cells for real-time QC collaboration |
79
+ | Share sheet/doc with bank stakeholder | `gdrive-share-file` | Invite collaborators (editor/viewer) |
80
+
81
+ ---
82
+
83
+ ## 🔄 Index Management — When to Rebuild
84
+
85
+ ### code_search index (auto-managed)
86
+
87
+ | Event | Action | Notes |
88
+ |---|---|---|
89
+ | Files changed on disk | **Auto-update** (file watcher) | No manual action needed |
90
+ | Large refactor (50+ files) | Agent runs `code_search` after changes | Index catches up automatically |
91
+ | New project setup | **Auto-index** on first query | May be slow first time |
92
+
93
+ **Rule: NEVER ask the user to rebuild the code search index. It auto-manages.**
94
+
95
+ ### impact_analysis index (MANUAL update required)
96
+
97
+ | Event | Action Required |
98
+ |---|---|
99
+ | Before ANY impact analysis query | Agent MUST run index update first |
100
+ | After committing changes (git) | Agent MUST run index update before next query |
101
+ | User manages git manually (SourceTree, etc.) | Agent auto-runs update, NEVER asks user |
102
+
103
+ **Rule: ALWAYS update impact_analysis index before querying. Do it silently — never ask the user.**
104
+
105
+ Before calling `impact_analysis`:
106
+ 1. Run index update (silent, no user prompt)
107
+ 2. Wait for completion
108
+ 3. Then execute the impact query
109
+
110
+ ---
111
+
112
+ ## 🪜 Code Writing — Laziness Ladder
113
+
114
+ Before writing ANY code, stop at the **first rung** that holds:
115
+
116
+ | Rung | Check | Tool to Use | If Yes → |
117
+ |---|---|---|---|
118
+ | 1. YAGNI | Does this need to exist? | Think first | Skip it, explain why in one line |
119
+ | 2. Reuse | Already in codebase? | `explore_code` | Reuse existing helper/util/pattern |
120
+ | 3. Stdlib | Standard library does it? | Language docs | Use stdlib |
121
+ | 4. Platform | Native platform feature? | — | Use it (CSS > JS, `<input type="date">` > picker lib, DB constraint > app code) |
122
+ | 5. Installed dep | Already-installed dependency? | `explore_code` on package.json/pubspec | Use existing dep. No new deps for what a few lines do |
123
+ | 6. One-liner | Can it be one line? | — | One line |
124
+ | 7. Minimum | Only when above fail | — | Write minimum code that works |
125
+
126
+ **Rule: The ladder runs AFTER understanding the problem. Read the code it touches (`explore_code`), trace the real flow, THEN climb.**
127
+
128
+ **Bug fix rule: Root cause, not symptom.** Grep every caller (`find_callers`), fix the shared function once — not each caller path.
129
+
130
+ ---
131
+
132
+ ## 🧠 Memory Conventions — When to Save & Read
133
+
134
+ ### When to SAVE (`remember`)
135
+
136
+ | Trigger | Entity Type | What to Save |
137
+ |---|---|---|
138
+ | Resolved a non-trivial bug | `bug-fix` | Root cause, solution, affected files, how to detect similar |
139
+ | Made an architecture/design decision | `decision` | What was decided, alternatives considered, rationale |
140
+ | Completed a feature milestone | `feature` | What was built, key files, design choices |
141
+ | Discovered a workflow/convention | `convention` | The pattern, why it exists, when to apply it |
142
+ | User stated a preference | `preference` | What they prefer, context |
143
+ | Completed project setup | `setup` | What was configured, tool versions, settings |
144
+
145
+ **Save format:**
146
+ ```
147
+ Entity: [descriptive-name]
148
+ Type: [bug-fix | decision | feature | convention | preference | setup]
149
+ Content: [structured description]
150
+ Tags: [relevant, searchable, keywords]
151
+ ```
152
+
153
+ ### When to READ (`recall` / `read_knowledge`)
154
+
155
+ | Trigger | Action | Tool |
156
+ |---|---|---|
157
+ | **Session start** | Load relevant task knowledge | `recall` |
158
+ | Before investigating known-problematic areas | Search for related bug-fixes | `recall` with keywords |
159
+ | Before making design decisions | Search for prior decisions on same topic | `recall` with topic |
160
+ | Before touching a module with history | Search for conventions/gotchas | `recall` with module name |
161
+ | User asks "what did we decide about X?" | Search explicitly | `recall` with X |
162
+
163
+ ### Memory Architecture (2-tier)
164
+
165
+ | Source | Purpose | Mutability | Location |
166
+ |---|---|---|---|
167
+ | `.agents/memory/MEMORY.md` | Static conventions, user preferences, coding standards | Manual edit only | Project repo |
168
+ | `.memory/memory.jsonl` | Dynamic project knowledge graph | Agent read/write via MCP tools | Project root (gitignored) |
169
+
170
+ **Rule: NEVER save to `.agents/memory/MEMORY.md` via MCP tools. That file is manually curated. MCP `remember`/`recall` always targets `.memory/memory.jsonl`.**
171
+
172
+ ### Memory Isolation
173
+
174
+ - Each project has its own `.memory/memory.jsonl` (configured via `.mcp.json`)
175
+ - Global fallback: `~/.anhdh/memory/global.json` (neutral, for cross-project knowledge)
176
+ - `.mcp.json` per project overrides global config → no data leakage between projects
@@ -1,214 +1,13 @@
1
- # AG Kit — Agent Rules
1
+ # APT workspace contract
2
2
 
3
- > This file defines how the AI (Windsurf Cascade) behaves in this workspace.
3
+ At session start and after context recovery, call `session_bootstrap` for this workspace and read `docs/agents/apt-runtime.md` once per context. Read project conventions in `.agents/memory/MEMORY.md`; retrieve only relevant dynamic memory. Report unavailable backends once and use available fallbacks.
4
4
 
5
- ## Agent skills
5
+ For new or changed intent, call `route_request` with the target, stack and explicit skills. Use `skill_load` for selected skills and current-step references. Do not load the full trigger catalog or repeat rules on every tool call.
6
6
 
7
- ### Support & issues
7
+ Before code changes, bind `pipeline_status` and `pipeline_start` or `pipeline_use` to an explicit task, runId and workspace. Reserve with `pipeline_next`; verify and checkpoint current code before completion. Read-only questions, review and existing tests need no code-change pipeline. Clarify only unresolved decisions.
8
8
 
9
- For bug reports, feature requests, or licensing questions, contact: `info.alphatechs.ai@gmail.com`
9
+ Use at most four actors including the coordinator and one writer per workspace. Respect host permissions, Plan Mode and user stops. Never claim independent review or native enforcement without observed capability. Keep attempts and evidence across resume; do not reset exhausted budgets.
10
10
 
11
- ### Issue tracker
11
+ Preserve custom files. Write concise code and prose, run suitable checks, and review staged, unstaged and relevant new files. Publishing, merging and external messages require authorization. Strong caveman style is opt-in.
12
12
 
13
- Issues are tracked in GitLab Issues. See `docs/agents/issue-tracker.md`.
14
-
15
- ### Triage labels
16
-
17
- Default label vocabulary (needs-triage, needs-info, ready-for-agent, ready-for-human, wontfix). See `docs/agents/triage-labels.md`.
18
-
19
- ### Domain docs
20
-
21
- Single-context layout — one `CONTEXT.md` + `docs/adr/` at the repo root. See `docs/agents/domain.md`.
22
-
23
- ---
24
-
25
- ## ⛔ CRITICAL: apt-mcp-agent TOOL USAGE (P0 — READ FIRST)
26
-
27
- **You have `apt-mcp-agent` MCP tools available. You MUST use them:**
28
- - **Before ANY code search**: use `explore_code` or `code_search` — NOT grep_search for code symbols
29
- - **Before executable changes**: call `pipeline_status`, then `pipeline_start` or `pipeline_use`
30
- - **After each pipeline step**: call `pipeline_checkpoint` with required `task` and `runId`
31
- - **Session start**: call `read_knowledge` + `pipeline_status`
32
-
33
- Ignoring these tools and using only built-in IDE tools is a **P0 protocol violation**.
34
-
35
- ## Session Start Protocol (MANDATORY)
36
-
37
- At the start of every session:
38
- 1. Read `.agents/ARCHITECTURE.md` to understand Agents, Skills, and Scripts.
39
- 2. Read `.agents/memory/MEMORY.md` to load persistent project conventions, user preferences, and tech decisions.
40
- 3. Read `docs/agents/mcp-tools.md` to load MCP tool selection rules & memory conventions.
41
- 4. Call `read_knowledge` to load dynamic knowledge graph from memory.
42
- 5. **Read `.agents/skill-triggers.json` to load auto-routing rules for all skills/workflows/tools.**
43
-
44
- ### 🔄 Context Recovery (MANDATORY after any context truncation/compression)
45
- If your conversation context was truncated, compressed, or you are resuming after a checkpoint:
46
- 1. **Call `pipeline_status()` immediately** — it returns recovery instructions and tool reminders
47
- 2. Re-read the session start files above if not already in context
48
- 3. Classify the current user request before taking any code action
49
-
50
- ### ⚠️ MCP TOOL ACCESSIBILITY & FALLBACK WARNING (CRITICAL)
51
- If the specialized MCP tool `code_search` or other core MCP tools (e.g., `recall`, `remember`, `impact_analysis`) are not in your available tools list:
52
- - **DO NOT silently fall back to basic text search or skip debugging workflows.**
53
- - **STOP immediately, warn the user** that the `apt-mcp-agent` server did not start successfully or has been disabled in the IDE settings, and recommend they run `npx apt-mcp-agent-setup status` to check their setup.
54
- - Only proceed with fallback tools (e.g. `grep_search`) if the user explicitly approves it.
55
-
56
- ### 🛠️ ENFORCED DEVELOPER PIPELINES (MANDATORY — MCP TOOL GATE)
57
-
58
- Before writing any code or implementing features, you MUST follow one of the three enforced pipelines below.
59
- **Start or bind a run with `pipeline_start(pipeline, task, workspace)` or `pipeline_use(task, runId)`.**
60
- **After each step call `pipeline_checkpoint(task, runId, step, status="completed", summary)`.**
61
-
62
- Content-only documentation changes that do not affect executable behavior are exempt from PRD, issue, and TDD pipeline steps. Agent contracts such as `AGENTS.md`, `SKILL.md`, trigger maps, pipeline definitions, and runtime configuration are operational and are not exempt.
63
- Skipping steps or executing out-of-order is a **P0 protocol violation** — the tool will REJECT invalid transitions.
64
-
65
- #### 🚀 Feature Development Pipeline (5 steps — NO EXCEPTIONS, NO SKIP)
66
- ```
67
- /grill-me → /to-prd → /to-issues → /tdd → /improve-codebase-architecture
68
- ```
69
- 1. **`/grill-me`** → Stress-test the plan/design with relentless Socratic questions. Challenge edge cases, security, performance.
70
- 2. **`/to-prd`** → Synthesize the grill-me session and conversation context into a formal PRD document.
71
- 3. **`/to-issues`** → Break PRD into vertical-slice issues on the issue tracker. Create `{task-slug}.md` for tracking.
72
- 4. **`/tdd`** → Implement code test-first using RED-GREEN-REFACTOR cycle.
73
- 5. **`/improve-codebase-architecture`** → Review and deepen architecture. Generate HTML report + grill-me session on codebase quality.
74
-
75
- #### 🐛 Bug Fix Pipeline (5 steps — NO EXCEPTIONS, NO SKIP)
76
- ```
77
- /diagnose → /grill-me → /to-prd → /to-issues → /tdd
78
- ```
79
- 1. **`/diagnose`** → Build feedback loop: reproduce → minimize → hypothesize → fix.
80
- 2. **`/grill-me`** → Challenge the fix design. Stress-test the proposed solution.
81
- 3. **`/to-prd`** → Document the fix as a formal PRD with root cause analysis.
82
- 4. **`/to-issues`** → Create tracking issues for the fix and any follow-up work.
83
- 5. **`/tdd`** → Write regression tests first, then implement the fix.
84
-
85
- #### 🔧 Hotfix Pipeline (2 steps — for small, isolated changes ≤3 files)
86
- ```
87
- /verify-scope → /fix-and-test
88
- ```
89
- 1. **`/verify-scope`** → Confirm change is small (≤3 files, no new API, no dependency changes). Provide scope justification in summary.
90
- 2. **`/fix-and-test`** → Apply fix + write regression test if applicable.
91
-
92
- **When to use hotfix:** typos, config values, minor CSS, off-by-one errors, missing imports, small bug fixes with obvious root cause. If the change grows beyond scope, reset and escalate to `bugfix` or `feature` pipeline.
93
-
94
- **ENFORCEMENT PROTOCOL:**
95
- - After each step completion → call `pipeline_checkpoint(task, runId, step, "completed", summary)`
96
- - Before each step start → call `pipeline_status(task, runId)`
97
- - To cancel a run → call `pipeline_reset(task, runId, confirm=true)`; history is preserved
98
- - The MCP tool enforces ordering at runtime — out-of-order calls are **rejected with error**
99
-
100
-
101
- ---
102
-
103
- ## MCP Tool Selection
104
-
105
- | Situation | Use Tool | NOT | Why |
106
- |---|---|---|---|
107
- | Find symbol definition, function, class | `code_search` | `grep_search` | Semantic search, understands code structure |
108
- | Find all callers of a function | `find_callers` | `grep_search` | Follows call graph, not just text match |
109
- | Find all functions called by a function | `find_callees` | — | Call graph traversal |
110
- | Explore file structure & dependencies | `explore_code` | `list_dir` | Understands imports, exports, relationships |
111
- | Search in config/docs (YAML, JSON, .env, markdown) | `grep_search` | `code_search` | Non-code files, literal string match |
112
- | "What breaks if I change this?" | `impact_analysis` | — | Blast radius — always update index first |
113
- | Save a decision/bug-fix/convention | `remember` | — | Cross-session persistence |
114
- | Recall what was decided about X | `recall` | — | Search by keyword |
115
- | Load full knowledge graph | `read_knowledge` | — | Session start, get full context |
116
-
117
- **Rule: DEFAULT to `code_search` for code. Fall back to `grep_search` ONLY for non-code files or literal strings.**
118
-
119
- ---
120
-
121
- ## Auto-Trigger Skills (MANDATORY)
122
-
123
- ### Workflow Skills
124
-
125
- | Skill | Trigger Conditions | Agent Action |
126
- |---|---|---|
127
- | `spec-clarification` | Design decision, architecture choice, plan review | Load SKILL.md → Start alignment session |
128
- | `bug-diagnostics` | Bug report, error log, "fails", "crashes" | Load SKILL.md → Reproduce → minimise → hypothesise → fix |
129
- | `task-breakdown` | Plan/PRD completed, "break down", "create tickets" | Load SKILL.md → Convert plan to vertical-slice issues |
130
- | `prd-gen` | New feature/product description with enough context | Load SKILL.md → Extract PRD from conversation context |
131
- | `prototype` | "mockup", "explore options", unclear UI/logic | Load SKILL.md → Build throwaway prototype |
132
- | `tdd-loop` | Feature implementation, bug fix, "write tests" | Load SKILL.md → Apply RED-GREEN-REFACTOR loop |
133
-
134
- ### UI/UX Design Skills
135
-
136
- | Skill | Trigger Conditions | Agent Action |
137
- |---|---|---|
138
- | `ui-style-rules` | Any web UI task: page layout, component styling | Load SKILL.md → Apply anti-slop design rules |
139
- | `web-mockup-gen` | Web UI concept needed before coding | Load SKILL.md → Generate web design reference images |
140
- | `mobile-mockup-gen` | Mobile UI concept needed before coding | Load SKILL.md → Generate mobile screen mockups |
141
- | `mobile-rules` | Any mobile UI implementation: Flutter, touch interaction | Load SKILL.md → Apply platform conventions |
142
- | `stitch-design-flow` | "stitch", "tạo trên stitch", "/stitch-flow", design UI (khi stitch preset active) | Load SKILL.md → Collaborative 8-step Stitch design flow |
143
- | `figma-handoff` | Figma URL detected (`figma.com/...`), "figma", "/figma", "code theo Figma" (khi figma preset active) | Load SKILL.md → Extract design → generate code |
144
- | `design-to-code` | "code theo design", "pull code", "/design-to-code", design-to-code conversion | Load SKILL.md → Auto-detect input → route to correct design tool |
145
- | `flutter-fix-layout-issues` | "overflow", "unbounded height", `RenderFlex`, layout error | Load SKILL.md → Fix overflow/constraint issues |
146
- | `flutter-build-responsive-layout` | "responsive", "tablet", "media query", adaptive layout | Load SKILL.md → Build adaptive layout |
147
- | `flutter-setup-declarative-routing` | "routing", "deep link", "go_router", URL navigation | Load SKILL.md → Configure declarative routing |
148
- | `flutter-add-widget-test` | "widget test", "test component", "verify UI rendering" | Load SKILL.md → Write widget test |
149
- | `flutter-add-integration-test` | "integration test", "e2e", "Flutter Driver" | Load SKILL.md → Add integration test |
150
- | `flutter-implement-json-serialization` | "fromJson", "toJson", "model class", API mapping | Load SKILL.md → Create JSON serialization |
151
- | `flutter-setup-localization` | "localization", "i18n", "intl", ".arb" | Load SKILL.md → Setup l10n |
152
- | `flutter-apply-architecture-best-practices` | "architecture", "layer", project structure | Load SKILL.md → Apply layered architecture |
153
- | `flutter-add-widget-preview` | "preview", "widget catalog", "golden test" | Load SKILL.md → Add widget preview |
154
- | `flutter-use-http-package` | "http request", "REST API", "fetch data" | Load SKILL.md → Use http package |
155
-
156
- ### BA/QC Skills — auto-trigger for requirements and testing:
157
-
158
- | Skill | Trigger Conditions | Agent Action |
159
- |---|---|---|
160
- | `ba-urd-decomposer` | "URD", "phân rã URD", "feature list", .pdf (BA context) | Load SKILL.md → Parse URD → feature list |
161
- | `ba-clarification-session` | "làm rõ yêu cầu", "clarify", "hỏi PO" | Load SKILL.md → Generate Q&A questions |
162
- | `ba-specs-writer` | "viết specs", "đặc tả", "tạo specs", "PTTK" | Load SKILL.md → Generate Specs document |
163
- | `ba-feature-tracker` | "tiến độ BA", "feature tracker", "BA progress" | Load SKILL.md → Show BA dashboard |
164
- | `ba-requirements-generator` | "BRD", "user story", "sinh BRD", "tạo BRD" | Load SKILL.md → Generate BRD/User Story |
165
- | `pdf-specs-parser` | "parse PDF specs", "đọc PTTK", .pdf (specs context) | Load SKILL.md → Extract API/UI definitions |
166
- | `qc-template-parser` | "mẫu QC", "import QC template", .xlsx (QC context) | Load SKILL.md → Learn Excel template |
167
- | `qc-bidv-workflow` | "tạo testcase BIDV", "QC workflow" | Load SKILL.md → Run BIDV QC pipeline |
168
- | `testcase-generator` | "sinh test case", "generate TCs", "tạo testcase" | Load SKILL.md → Generate Excel testcase |
169
- | `mindmap-reader` | "mindmap", "xmind", .xmind/.mm file | Load SKILL.md → Parse mindmap → JSON |
170
- | `specs-to-mindmap` | "specs sang mindmap", "tạo outline từ specs" | Load SKILL.md → Specs → outline |
171
- | `requirement-coverage` | "bao phủ yêu cầu", "traceability", "coverage" | Load SKILL.md → Requirements vs test cases |
172
- | `webapp-testing` | "E2E test", "Playwright", "test trình duyệt" | Load SKILL.md → E2E/Playwright audit |
173
-
174
- ### ⚠️ DOMAIN SKILL LOADING (CRITICAL — DO NOT SKIP)
175
-
176
- Before writing ANY UI, design, or visual code:
177
- 1. **Web UI** → READ `.agents/skills/ui-style-rules/SKILL.md` — MANDATORY
178
- 2. **Mobile UI** → READ `.agents/skills/mobile-rules/SKILL.md` — MANDATORY
179
- 3. **Image/asset gen (web)** → READ `.agents/skills/web-mockup-gen/SKILL.md`
180
- 4. **Image/asset gen (mobile)** → READ `.agents/skills/mobile-mockup-gen/SKILL.md`
181
- 5. **Architecture decision** → READ `.agents/skills/stress-test-plan/SKILL.md`
182
-
183
- **Violation = SLOP output. Writing UI code without design skill = P0 violation.**
184
-
185
- ## Socratic Gate
186
-
187
- Every user request must pass through the Socratic Gate before ANY implementation:
188
-
189
- | Request Type | Strategy | Required Action |
190
- |---|---|---|
191
- | **New Feature / Build** | Deep Discovery | ASK minimum 3 strategic questions |
192
- | **Code Edit / Bug Fix** | Context Check | Confirm understanding + ask impact questions |
193
- | **Vague / Simple** | Clarification | Ask Purpose, Users, and Scope |
194
-
195
- > [!IMPORTANT]
196
- > **STRICT SOCRATIC & WORKFLOW ENFORCEMENT:**
197
- > - **DO NOT write any code logic, execute modifications, or create plans before completing the required Socratic Gate action.** Bypassing the Socratic Gate is a P0 protocol violation.
198
- > - **DO NOT bypass specialized workflow skills** (like `bug-diagnostics` for debugging, `spec-clarification` for specifications, `tdd-loop` for writing code/tests) even if the task or error log seems simple or clear. Bypassing skills is a P0 protocol violation.
199
-
200
- ---
201
-
202
- ## Universal Rules
203
-
204
- ### Clean Code (Global Mandatory)
205
- - **Code**: Concise, direct, no over-engineering. Self-documenting.
206
- - **Laziness Ladder**: Before writing code, stop at the first rung that holds: YAGNI → Reuse existing → Stdlib → Native platform → Installed dep → One-liner → Minimum viable. The ladder runs AFTER understanding the problem.
207
- - **Bug Fix**: Root cause, not symptom. Grep every caller, fix the shared function once.
208
- - **No Bloat**: No unrequested abstractions, no scaffolding "for later", deletion > addition, fewest files.
209
- - **Testing**: Mandatory. Pyramid (Unit > Int > E2E) + AAA Pattern.
210
- - **Performance**: Measure first. Adhere to current Core Web Vitals standards.
211
-
212
- ### Quick Reference
213
- - **Masters**: `orchestrator`, `project-planner`, `security-auditor`, `backend-specialist`, `frontend-specialist`, `mobile-developer`, `debugger`
214
- - **Key Skills**: `clean-code`, `brainstorming`, `ui-style-rules`, `mobile-rules`, `web-mockup-gen`, `mobile-mockup-gen`, `stitch-design-flow`, `bug-diagnostics`, `tdd-loop`, `spec-clarification`, `prd-gen`, `task-breakdown`, `prototype`, `stress-test-plan`, `skill-generator`, `git-safety-guardrails`, `git-hook-setup`, `test-type-migration`, `exercise-scaffold`, `interactive-teaching`, `writing-flow`, `raw-idea-collector`, `draft-shaper`, `project-config-wizard`, `skill-writing-guide`, `architecture-rules`, `solution-decision-map`, `task-implementation`, `git-conflict-resolver`, `workflow-navigator`, `terse-communication`, `session-handoff`
13
+ Tool interfaces: `docs/agents/mcp-tools.md`. Project/domain and issue conventions: `docs/agents/domain.md` and `docs/agents/issue-tracker.md`. Support: info.alphatechs.ai@gmail.com.