@jetrabbits/agentic 0.3.2 → 0.3.3
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.
- package/CHANGELOG.md +6 -0
- package/agentic +2 -2
- package/docs/agentic-stabilization/README.md +6 -5
- package/docs/agentic-usage.md +1 -1
- package/docs/opencode_setup.md +1 -1
- package/docs/review-pipeline/examples/instruction-review.example.md +95 -0
- package/docs/review-pipeline/examples/memory-curation.example.md +56 -0
- package/docs/review-pipeline/examples/summary.example.md +18 -0
- package/extensions/opencode/agents/developer.md +1 -1
- package/extensions/opencode/agents/devops-engineer.md +1 -1
- package/extensions/opencode/agents/instruction_reviewer.md +1 -1
- package/extensions/opencode/agents/memory_curator.md +1 -1
- package/extensions/opencode/agents/team-lead.md +1 -1
- package/extensions/opencode/opencode.json +16 -36
- package/package.json +1 -1
- package/extensions/opencode/plugins/agent-model-mapper.ts +0 -117
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v0.3.3
|
|
4
|
+
|
|
5
|
+
- Updated MemPalace project initialization to pipe explicit confirmation (`echo "Y" | mempalace init ...`) for non-interactive setup robustness.
|
|
6
|
+
- Removed `agent-model-mapper` from OpenCode plugin registration.
|
|
7
|
+
- Deleted obsolete OpenCode plugin source `extensions/opencode/plugins/agent-model-mapper.ts`.
|
|
8
|
+
|
|
3
9
|
## v0.3.2
|
|
4
10
|
|
|
5
11
|
- Added optional post-task specialist agents `instruction_reviewer` and `memory_curator` outside the mandatory SDLC role matrix.
|
package/agentic
CHANGED
|
@@ -1946,7 +1946,7 @@ print_mempalace_project_setup_instructions() {
|
|
|
1946
1946
|
out "2) Install MemPalace:"
|
|
1947
1947
|
out " pip install mempalace"
|
|
1948
1948
|
out "3) Initialize the project memory taxonomy without LLM calls:"
|
|
1949
|
-
out " mempalace init \"$PROJECT_DIR\" --yes --no-llm"
|
|
1949
|
+
out " echo \"N\" | mempalace init \"$PROJECT_DIR\" --yes --no-llm"
|
|
1950
1950
|
out "4) Mine project knowledge into its isolated wing:"
|
|
1951
1951
|
out " mempalace mine \"$PROJECT_DIR\" --wing \"$project_wing\""
|
|
1952
1952
|
if [[ -d "$PROJECT_DIR/docs" ]]; then
|
|
@@ -2242,7 +2242,7 @@ initialize_mempalace_project() {
|
|
|
2242
2242
|
return 1
|
|
2243
2243
|
fi
|
|
2244
2244
|
|
|
2245
|
-
if ! run_mempalace_command "MemPalace init" mempalace init "$PROJECT_DIR" --yes --no-llm; then
|
|
2245
|
+
if ! run_mempalace_command "MemPalace init" bash -lc "echo \"N\" | mempalace init \"$PROJECT_DIR\" --yes --no-llm"; then
|
|
2246
2246
|
print_mempalace_project_setup_instructions
|
|
2247
2247
|
return 1
|
|
2248
2248
|
fi
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
- Post-install doctor checks run independently for `codex`, `opencode`, `claude`, and `gemini`.
|
|
6
6
|
- `AGENTIC_DOCTOR_TIMEOUT_SECONDS` defaults to `10`; a timeout is reported as a doctor failure and install continues.
|
|
7
7
|
- Codex doctor runs non-interactively with `--ephemeral`, `--sandbox workspace-write`, and the same lightweight smoke prompt as other supported doctor targets.
|
|
8
|
-
- OpenCode uses `agent-model-mapper` instead of the removed `model-checker` artifacts.
|
|
8
|
+
- OpenCode uses an install-time `agent-model-mapper` flow instead of the removed `model-checker` artifacts.
|
|
9
9
|
- `agent-model-mapper` writes `.opencode/opencode.json` during interactive install only after confirmation.
|
|
10
|
-
- `agent-model-mapper` uses `fzf` for install-time model dropdowns when available
|
|
11
|
-
-
|
|
10
|
+
- `agent-model-mapper` uses `fzf` for install-time model dropdowns when available.
|
|
11
|
+
- No runtime OpenCode plugin is shipped for `agent-model-mapper`, so OpenCode startup never opens `fzf`, asks questions, or writes project files.
|
|
12
12
|
- Context7 offers an interactive key mode: configure without a key or enter `CONTEXT7_API_KEY` for the selected target configs.
|
|
13
13
|
- OpenCode MemPalace setup writes `mempalace-mcp` config and initializes/mines project memory into a project-specific wing without LLM calls.
|
|
14
14
|
- Telegram notification credentials are read from project `.agentic.json` when the plugin is enabled.
|
|
@@ -24,8 +24,9 @@
|
|
|
24
24
|
- Hung agent doctor commands time out and do not stop remaining selected agents from running.
|
|
25
25
|
- Doctor output includes timeout duration, exit status, and per-agent elapsed time.
|
|
26
26
|
- `extensions/opencode/plugins/model-checker.ts` and `model-checker.json` are absent.
|
|
27
|
-
- `extensions/opencode/
|
|
28
|
-
-
|
|
27
|
+
- `extensions/opencode/plugins/agent-model-mapper.ts` is absent.
|
|
28
|
+
- `extensions/opencode/opencode.json` does not list `agent-model-mapper`.
|
|
29
|
+
- Install-time model mapper execution still writes confirmed role model mappings.
|
|
29
30
|
- Telegram plugin tests prove environment-only credentials and no secret output.
|
|
30
31
|
- Real blackbox tests print created files, managed guidance sources, and MCP config evidence, then save instruction evidence to a temp file without printing Telegram secrets.
|
|
31
32
|
|
package/docs/agentic-usage.md
CHANGED
|
@@ -169,7 +169,7 @@ When `opencode` is selected, interactive installs ask whether to enable Telegram
|
|
|
169
169
|
~/.config/agentic/opencode-plugins.json
|
|
170
170
|
```
|
|
171
171
|
|
|
172
|
-
Non-interactive installs create a disabled config when no config exists. Interactive installs ask for Telegram `botToken` and `chatId` when `telegram-notification` is selected. Those credentials are written to the target project `.agentic.json` under `settings.opencode_plugins.telegram`, not to `~/.config/agentic/opencode-plugins.json`. Treat `.agentic.json` as plaintext secret-bearing project config when Telegram is enabled and do not commit it to public repositories. When enabled, `agent-model-mapper` runs during interactive `agentic install`/`agentic tui`, uses `fzf` as a dropdown picker when available, and writes `.opencode/opencode.json` only after a Confirm action. OpenCode startup
|
|
172
|
+
Non-interactive installs create a disabled config when no config exists. Interactive installs ask for Telegram `botToken` and `chatId` when `telegram-notification` is selected. Those credentials are written to the target project `.agentic.json` under `settings.opencode_plugins.telegram`, not to `~/.config/agentic/opencode-plugins.json`. Treat `.agentic.json` as plaintext secret-bearing project config when Telegram is enabled and do not commit it to public repositories. When enabled, `agent-model-mapper` runs during interactive `agentic install`/`agentic tui`, uses `fzf` as a dropdown picker when available, and writes `.opencode/opencode.json` only after a Confirm action. OpenCode startup does not load a mapper runtime plugin or prompt for model mapping.
|
|
173
173
|
|
|
174
174
|
## Context7
|
|
175
175
|
|
package/docs/opencode_setup.md
CHANGED
|
@@ -46,7 +46,7 @@ The runtime plugin reads credentials from the project `.agentic.json`; it does n
|
|
|
46
46
|
|
|
47
47
|
Non-interactive `agentic install` defaults optional plugins to disabled when no config exists.
|
|
48
48
|
|
|
49
|
-
`agent-model-mapper` reads roles from target `.opencode/agents/*.md` and discovers model names from `~/.config/opencode/opencode.json`, then adds models from active providers in `~/.local/share/opencode/auth.json` using non-deprecated entries in `~/.cache/opencode/models.json`. When enabled, interactive `agentic install`/`agentic tui` prompts for a main and fallback model per role, using `fzf` as a dropdown picker when available, and writes `.opencode/opencode.json` only after a Confirm action. OpenCode startup never opens `fzf` or waits for model input
|
|
49
|
+
`agent-model-mapper` reads roles from target `.opencode/agents/*.md` and discovers model names from `~/.config/opencode/opencode.json`, then adds models from active providers in `~/.local/share/opencode/auth.json` using non-deprecated entries in `~/.cache/opencode/models.json`. When enabled, interactive `agentic install`/`agentic tui` prompts for a main and fallback model per role, using `fzf` as a dropdown picker when available, and writes `.opencode/opencode.json` only after a Confirm action. OpenCode startup never opens `fzf` or waits for model input because no mapper runtime plugin is shipped or registered.
|
|
50
50
|
|
|
51
51
|
For OpenCode targets, `agentic` writes generated operating guidance to `.opencode/AGENTS.md`. If OpenCode is installed
|
|
52
52
|
alongside another agent target, root `AGENTS.md` is generated as well for the non-OpenCode target.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Instruction Effectiveness Review
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
The instruction set helped the task stay inside the existing extension layout and prevented the new roles from being
|
|
6
|
+
added to the mandatory SDLC matrix. Tool discipline was mostly strong because repository facts were discovered before
|
|
7
|
+
editing. The main gap was that review pipeline behavior had to be inferred from docs rather than a dedicated guidance
|
|
8
|
+
section. No code quality findings are included because they are outside this role's scope.
|
|
9
|
+
|
|
10
|
+
## Scores
|
|
11
|
+
|
|
12
|
+
| Category | Score 0-10 | Notes |
|
|
13
|
+
|---|---:|---|
|
|
14
|
+
| Clarity | 8 | Role boundaries were clear after reading README and SDLC rules. |
|
|
15
|
+
| Usefulness | 8 | Existing extension patterns made implementation straightforward. |
|
|
16
|
+
| Tool discipline | 8 | File inspection was targeted and avoided repeated broad loops. |
|
|
17
|
+
| Memory discipline | 7 | Memory rules existed, but post-task curation was not documented. |
|
|
18
|
+
| Ambiguity resistance | 7 | The repo lacked a review pipeline section, causing one product decision. |
|
|
19
|
+
| Token efficiency | 7 | Some duplicate role text is necessary for installed agents. |
|
|
20
|
+
| Overall | 8 | Minor instruction additions are enough. |
|
|
21
|
+
|
|
22
|
+
## Effective instructions
|
|
23
|
+
|
|
24
|
+
| Instruction | Impact | Evidence |
|
|
25
|
+
|---|---|---|
|
|
26
|
+
| Keep SDLC roles one-to-one | Prevented specialist roles from replacing core SDLC owners. | `sdlc-role-responsibilities.md` keeps the mandatory matrix unchanged. |
|
|
27
|
+
| Discover project guidance before implementation | Found the extension-based agent layout. | Existing files live under `extensions/*/agents`. |
|
|
28
|
+
|
|
29
|
+
## Harmful instructions
|
|
30
|
+
|
|
31
|
+
| Instruction | Problem | Evidence |
|
|
32
|
+
|---|---|---|
|
|
33
|
+
| None | No instruction directly caused task failure. | The task completed with scoped docs and tests. |
|
|
34
|
+
|
|
35
|
+
## Missing instructions
|
|
36
|
+
|
|
37
|
+
| Missing instruction | Why needed | Suggested text |
|
|
38
|
+
|---|---|---|
|
|
39
|
+
| Post-task review pipeline guidance | Future agents need to know when specialists run and where reports go. | Add a review pipeline section that lists optional roles and `.reviews/<task-id>/` output paths. |
|
|
40
|
+
|
|
41
|
+
## Redundant instructions
|
|
42
|
+
|
|
43
|
+
| Instruction | Reason |
|
|
44
|
+
|---|---|
|
|
45
|
+
| Repeated role boundaries across extension files | Required because each installed agent file must be self-contained. |
|
|
46
|
+
|
|
47
|
+
## Tool usage findings
|
|
48
|
+
|
|
49
|
+
| Tool | Calls | Useful | Waste | Notes |
|
|
50
|
+
|---|---:|---:|---:|---|
|
|
51
|
+
| `rg` | 4 | 4 | 0 | Located role and installer references quickly. |
|
|
52
|
+
| `sed` | 5 | 5 | 0 | Confirmed local file formats before edits. |
|
|
53
|
+
| `apply_patch` | 3 | 3 | 0 | Added and updated tracked files. |
|
|
54
|
+
|
|
55
|
+
## Suggested edits
|
|
56
|
+
|
|
57
|
+
### Remove
|
|
58
|
+
|
|
59
|
+
```md
|
|
60
|
+
None.
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Replace
|
|
64
|
+
|
|
65
|
+
```md
|
|
66
|
+
The same 7-agent team works across supported IDEs.
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
with:
|
|
70
|
+
|
|
71
|
+
```md
|
|
72
|
+
The same 7-agent SDLC team works across supported IDEs, with optional post-task review specialists.
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Add
|
|
76
|
+
|
|
77
|
+
```md
|
|
78
|
+
Use `instruction_reviewer` and `memory_curator` after non-trivial tasks when instruction quality or memory hygiene needs review.
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Estimated waste
|
|
82
|
+
|
|
83
|
+
| Metric | Estimate |
|
|
84
|
+
|---|---:|
|
|
85
|
+
| Extra tokens | 500 |
|
|
86
|
+
| Extra tool calls | 1 |
|
|
87
|
+
| Extra retries | 0 |
|
|
88
|
+
| Extra runtime | 2 minutes |
|
|
89
|
+
|
|
90
|
+
## Final recommendation
|
|
91
|
+
|
|
92
|
+
Minor edits
|
|
93
|
+
|
|
94
|
+
The instruction set is generally effective. Add explicit review pipeline guidance so future runs do not have to infer
|
|
95
|
+
how specialist agents should be used.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Memory Curation Report
|
|
2
|
+
|
|
3
|
+
## Summary
|
|
4
|
+
|
|
5
|
+
The task introduced a durable convention: post-task review specialists are optional and remain outside the mandatory
|
|
6
|
+
SDLC role matrix. That convention is likely to help future agent-system changes. Temporary test output, command logs,
|
|
7
|
+
and generated report examples should not be stored as memory. No automatic memory write is recommended without user or
|
|
8
|
+
orchestrator approval.
|
|
9
|
+
|
|
10
|
+
## Store
|
|
11
|
+
|
|
12
|
+
| Priority | Fact | Reason | Suggested memory text |
|
|
13
|
+
|---|---|---|---|
|
|
14
|
+
| High | `instruction_reviewer` and `memory_curator` are optional post-task specialists, not SDLC owners. | Prevents future role-boundary drift. | Agentic treats `instruction_reviewer` and `memory_curator` as optional post-task review specialists outside the mandatory SDLC role matrix. |
|
|
15
|
+
| Medium | Review artifacts use `.reviews/<task-id>/` or timestamp fallback. | Helps future tasks place reports consistently. | Post-task review reports should be written under `.reviews/<task-id>/`, or `.reviews/YYYY-MM-DD-HHMMSS/` when no task id exists. |
|
|
16
|
+
|
|
17
|
+
## Update
|
|
18
|
+
|
|
19
|
+
| Existing memory | Replace with | Reason |
|
|
20
|
+
|---|---|---|
|
|
21
|
+
| None | None | No stale memory was identified. |
|
|
22
|
+
|
|
23
|
+
## Merge
|
|
24
|
+
|
|
25
|
+
| Memory A | Memory B | Merged memory | Reason |
|
|
26
|
+
|---|---|---|---|
|
|
27
|
+
| None | None | None | No duplicate memory was identified. |
|
|
28
|
+
|
|
29
|
+
## Ignore
|
|
30
|
+
|
|
31
|
+
| Fact | Reason |
|
|
32
|
+
|---|---|
|
|
33
|
+
| Exact shell output from test runs | Temporary logs are low-value memory. |
|
|
34
|
+
| Generated example report wording | Generated code/docs examples should remain in files, not memory. |
|
|
35
|
+
| One-time task status | Current task state is transient. |
|
|
36
|
+
|
|
37
|
+
## Delete candidates
|
|
38
|
+
|
|
39
|
+
| Memory | Reason |
|
|
40
|
+
|---|---|
|
|
41
|
+
| None | No delete candidate was found. |
|
|
42
|
+
|
|
43
|
+
## Contradictions
|
|
44
|
+
|
|
45
|
+
| Memory | New information | Resolution |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| None | None | No contradiction found. |
|
|
48
|
+
|
|
49
|
+
## Final recommendation
|
|
50
|
+
|
|
51
|
+
Store count: 2
|
|
52
|
+
Update count: 0
|
|
53
|
+
Merge count: 0
|
|
54
|
+
Delete candidate count: 0
|
|
55
|
+
Memory quality score: 8/10
|
|
56
|
+
Store only the two durable conventions. Ignore logs, generated examples, and current task progress.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Review Summary
|
|
2
|
+
|
|
3
|
+
## Instruction review
|
|
4
|
+
|
|
5
|
+
Overall score: 8/10
|
|
6
|
+
Recommendation: Minor edits
|
|
7
|
+
|
|
8
|
+
## Memory curation
|
|
9
|
+
|
|
10
|
+
Store: 2
|
|
11
|
+
Update: 0
|
|
12
|
+
Delete candidates: 0
|
|
13
|
+
|
|
14
|
+
## Action items
|
|
15
|
+
|
|
16
|
+
- [ ] Document optional post-task specialists in README.
|
|
17
|
+
- [ ] Keep specialist roles outside the mandatory SDLC matrix.
|
|
18
|
+
- [ ] Store only durable review-pipeline conventions, not logs or generated examples.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
description: Instruction Reviewer for post-task reports on instruction effectiveness, tool discipline, memory discipline, and context efficiency
|
|
3
|
-
mode:
|
|
3
|
+
mode: all
|
|
4
4
|
vibe: Reviews the instructions that shaped the work, not the code that was produced.
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://opencode.ai/config.json",
|
|
3
3
|
"plugin": [
|
|
4
|
-
"agent-model-mapper",
|
|
5
4
|
"sound-notification",
|
|
6
5
|
"telegram-notification"
|
|
7
6
|
],
|
|
@@ -9,10 +8,8 @@
|
|
|
9
8
|
"product-owner": {
|
|
10
9
|
"description": "Main coordinator for feature development workflow",
|
|
11
10
|
"mode": "primary",
|
|
12
|
-
"model": "
|
|
11
|
+
"model": "",
|
|
13
12
|
"fallback": [
|
|
14
|
-
"openai/gpt-5.4",
|
|
15
|
-
"opencode/minimax-m2.5-free"
|
|
16
13
|
],
|
|
17
14
|
"permission": {
|
|
18
15
|
"task": {
|
|
@@ -29,88 +26,71 @@
|
|
|
29
26
|
"pm": {
|
|
30
27
|
"description": "Project Manager - coordinates workflow",
|
|
31
28
|
"mode": "subagent",
|
|
32
|
-
"model": "
|
|
29
|
+
"model": "",
|
|
33
30
|
"fallback": [
|
|
34
|
-
"openai/gpt-5.4",
|
|
35
|
-
"opencode/minimax-m2.5-free"
|
|
36
31
|
],
|
|
37
32
|
"permission": {
|
|
38
33
|
"task": {
|
|
39
34
|
"team-lead": "allow",
|
|
40
35
|
"designer": "allow",
|
|
41
36
|
"developer": "allow",
|
|
42
|
-
"qa": "allow"
|
|
43
|
-
"instruction_reviewer": "allow",
|
|
44
|
-
"memory_curator": "allow"
|
|
37
|
+
"qa": "allow"
|
|
45
38
|
}
|
|
46
39
|
}
|
|
47
40
|
},
|
|
48
41
|
"team-lead": {
|
|
49
42
|
"description": "Team Lead - planning and code review",
|
|
50
|
-
"mode": "
|
|
51
|
-
"model": "
|
|
43
|
+
"mode": "all",
|
|
44
|
+
"model": "",
|
|
52
45
|
"fallback": [
|
|
53
|
-
"openai/gpt-5.3-codex"
|
|
54
46
|
],
|
|
55
47
|
"permission": {
|
|
56
48
|
"task": {
|
|
57
49
|
"developer": "allow",
|
|
58
|
-
"qa": "allow"
|
|
59
|
-
"instruction_reviewer": "allow",
|
|
60
|
-
"memory_curator": "allow"
|
|
50
|
+
"qa": "allow"
|
|
61
51
|
}
|
|
62
52
|
}
|
|
63
53
|
},
|
|
64
54
|
"developer": {
|
|
65
55
|
"description": "Developer - implements code",
|
|
66
|
-
"mode": "
|
|
67
|
-
"model": "
|
|
56
|
+
"mode": "all",
|
|
57
|
+
"model": "",
|
|
68
58
|
"fallback": [
|
|
69
|
-
"openai/gpt-5.3-codex"
|
|
70
59
|
]
|
|
71
60
|
},
|
|
72
61
|
"devops-engineer": {
|
|
73
62
|
"description": "DevOps Engineer - infrastructure, CI/CD, and platform reliability",
|
|
74
|
-
"mode": "
|
|
75
|
-
"model": "
|
|
63
|
+
"mode": "all",
|
|
64
|
+
"model": "",
|
|
76
65
|
"fallback": [
|
|
77
|
-
"openai/gpt-5.3-codex"
|
|
78
66
|
]
|
|
79
67
|
},
|
|
80
68
|
"instruction_reviewer": {
|
|
81
69
|
"description": "Instruction Reviewer - post-task review of instruction effectiveness and tool discipline",
|
|
82
|
-
"mode": "
|
|
83
|
-
"model": "
|
|
70
|
+
"mode": "all",
|
|
71
|
+
"model": "",
|
|
84
72
|
"fallback": [
|
|
85
|
-
"openai/gpt-5.4",
|
|
86
|
-
"opencode/minimax-m2.5-free"
|
|
87
73
|
]
|
|
88
74
|
},
|
|
89
75
|
"memory_curator": {
|
|
90
76
|
"description": "Memory Curator - post-task memory hygiene recommendations without automatic writes",
|
|
91
|
-
"mode": "
|
|
92
|
-
"model": "
|
|
77
|
+
"mode": "all",
|
|
78
|
+
"model": "",
|
|
93
79
|
"fallback": [
|
|
94
|
-
"openai/gpt-5.4",
|
|
95
|
-
"opencode/minimax-m2.5-free"
|
|
96
80
|
]
|
|
97
81
|
},
|
|
98
82
|
"qa": {
|
|
99
83
|
"description": "QA Engineer - runs tests",
|
|
100
84
|
"mode": "subagent",
|
|
101
|
-
"model": "
|
|
85
|
+
"model": "",
|
|
102
86
|
"fallback": [
|
|
103
|
-
"opencode/minimax-m2.5-free",
|
|
104
|
-
"openai/gpt-5.4"
|
|
105
87
|
]
|
|
106
88
|
},
|
|
107
89
|
"designer": {
|
|
108
90
|
"description": "Designer - UI/UX validation",
|
|
109
91
|
"mode": "subagent",
|
|
110
|
-
"model": "
|
|
92
|
+
"model": "",
|
|
111
93
|
"fallback": [
|
|
112
|
-
"opencode/minimax-m2.5-free",
|
|
113
|
-
"openai/gpt-5.4"
|
|
114
94
|
]
|
|
115
95
|
}
|
|
116
96
|
}
|
package/package.json
CHANGED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from "@opencode-ai/plugin"
|
|
2
|
-
import { existsSync, readFileSync } from "node:fs"
|
|
3
|
-
import { readdir, readFile } from "node:fs/promises"
|
|
4
|
-
import { basename, join } from "node:path"
|
|
5
|
-
|
|
6
|
-
type AgenticPluginConfig = {
|
|
7
|
-
agentModelMapper?: {
|
|
8
|
-
enabled?: boolean
|
|
9
|
-
}
|
|
10
|
-
settings?: any
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
type Role = {
|
|
14
|
-
name: string
|
|
15
|
-
description: string
|
|
16
|
-
mode: string
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function readAgenticConfig(): AgenticPluginConfig {
|
|
20
|
-
const configHome = process.env.XDG_CONFIG_HOME || join(process.env.HOME || "", ".config")
|
|
21
|
-
const configPath = join(configHome, "agentic", "opencode-plugins.json")
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
return JSON.parse(readFileSync(configPath, "utf-8")) as AgenticPluginConfig
|
|
25
|
-
} catch {
|
|
26
|
-
return {}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function readProjectAgenticConfig(directory: string): AgenticPluginConfig {
|
|
31
|
-
try {
|
|
32
|
-
return JSON.parse(readFileSync(join(directory, ".agentic.json"), "utf-8")) as AgenticPluginConfig
|
|
33
|
-
} catch {
|
|
34
|
-
return {}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function parseFrontmatter(text: string): Record<string, string> {
|
|
39
|
-
if (!text.startsWith("---\n")) return {}
|
|
40
|
-
const end = text.indexOf("\n---", 4)
|
|
41
|
-
if (end === -1) return {}
|
|
42
|
-
|
|
43
|
-
const result: Record<string, string> = {}
|
|
44
|
-
for (const line of text.slice(4, end).split("\n")) {
|
|
45
|
-
const index = line.indexOf(":")
|
|
46
|
-
if (index === -1) continue
|
|
47
|
-
result[line.slice(0, index).trim()] = line.slice(index + 1).trim().replace(/^['"]|['"]$/g, "")
|
|
48
|
-
}
|
|
49
|
-
return result
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async function readRoles(directory: string): Promise<Role[]> {
|
|
53
|
-
const agentsDir = join(directory, ".opencode", "agents")
|
|
54
|
-
let entries: string[]
|
|
55
|
-
try {
|
|
56
|
-
entries = await readdir(agentsDir)
|
|
57
|
-
} catch {
|
|
58
|
-
return []
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const roles: Role[] = []
|
|
62
|
-
for (const entry of entries.sort()) {
|
|
63
|
-
if (!entry.endsWith(".md")) continue
|
|
64
|
-
const path = join(agentsDir, entry)
|
|
65
|
-
const text = await readFile(path, "utf-8")
|
|
66
|
-
const frontmatter = parseFrontmatter(text)
|
|
67
|
-
roles.push({
|
|
68
|
-
name: basename(entry, ".md"),
|
|
69
|
-
description: frontmatter.description || "OpenCode agent",
|
|
70
|
-
mode: frontmatter.mode || "subagent",
|
|
71
|
-
})
|
|
72
|
-
}
|
|
73
|
-
return roles
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function readJsonIfExists(path: string): unknown {
|
|
77
|
-
if (!existsSync(path)) return undefined
|
|
78
|
-
try {
|
|
79
|
-
return JSON.parse(readFileSync(path, "utf-8"))
|
|
80
|
-
} catch {
|
|
81
|
-
return undefined
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function hasCompleteAgentModelMapping(directory: string, roles: Role[]): boolean {
|
|
86
|
-
const state = readJsonIfExists(join(directory, ".opencode", "agent-model-mapper.state.json")) as Record<string, any> | undefined
|
|
87
|
-
if (!state?.configured) return false
|
|
88
|
-
|
|
89
|
-
const config = readJsonIfExists(join(directory, ".opencode", "opencode.json")) as Record<string, any> | undefined
|
|
90
|
-
const agents = config?.agent
|
|
91
|
-
if (!agents || typeof agents !== "object") return false
|
|
92
|
-
return roles.every((role) => {
|
|
93
|
-
const agent = agents[role.name]
|
|
94
|
-
return agent && typeof agent === "object" && typeof agent.model === "string" && agent.model.trim().length > 0
|
|
95
|
-
})
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
export const AgentModelMapperPlugin: Plugin = async ({ directory }) => {
|
|
99
|
-
const projectConfig = readProjectAgenticConfig(directory)
|
|
100
|
-
const globalConfig = readAgenticConfig()
|
|
101
|
-
const enabled = projectConfig.settings?.opencode_plugins?.agentModelMapper?.enabled ?? globalConfig.agentModelMapper?.enabled
|
|
102
|
-
if (!enabled) return {}
|
|
103
|
-
|
|
104
|
-
const roles = await readRoles(directory)
|
|
105
|
-
if (!roles.length) {
|
|
106
|
-
console.log("agent-model-mapper: skipped because .opencode/agents/*.md was not found")
|
|
107
|
-
return {}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (hasCompleteAgentModelMapping(directory, roles)) {
|
|
111
|
-
console.log("agent-model-mapper: skipped because all Agentic roles already have model mappings")
|
|
112
|
-
return {}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
console.log("agent-model-mapper: install-time model mapping is required; run agentic install or agentic tui")
|
|
116
|
-
return {}
|
|
117
|
-
}
|