@agentmap/opencode 0.5.0 → 0.6.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.
- package/CHANGELOG.md +35 -0
- package/README.md +19 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -4
- package/dist/index.js.map +1 -1
- package/package.json +15 -3
- package/src/index.ts +78 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
1. **Error toast notifications** — plugin errors now surface as OpenCode TUI toast notifications instead of being silently swallowed or polluting the terminal UI.
|
|
6
|
+
|
|
7
|
+
2. **Updated to use agentmap 0.9.0** — benefits from recursive submodule trees, symlink filtering, duplicate file detection, and compressed output.
|
|
8
|
+
|
|
9
|
+
## 0.5.0
|
|
10
|
+
|
|
11
|
+
- Update to use agentmap 0.8.0 with submodule support
|
|
12
|
+
- Submodules now appear in the generated codebase map with branch and commit info
|
|
13
|
+
|
|
14
|
+
## 0.4.0
|
|
15
|
+
|
|
16
|
+
- Include git diff info in generated map by default
|
|
17
|
+
- Update to use agentmap 0.7.0
|
|
18
|
+
|
|
19
|
+
## 0.3.0
|
|
20
|
+
|
|
21
|
+
- Show only exported symbols when truncating files with many definitions
|
|
22
|
+
- Add `<agentmap-instructions>` section with guidance for maintaining file descriptions
|
|
23
|
+
- Safety checks now handled by agentmap library (non-git repos, home directory)
|
|
24
|
+
- Update to use agentmap 0.6.0
|
|
25
|
+
|
|
26
|
+
## 0.2.0
|
|
27
|
+
|
|
28
|
+
- Update to use agentmap 0.3.0 with new diff features
|
|
29
|
+
- Improved system prompt description
|
|
30
|
+
|
|
31
|
+
## 0.1.0
|
|
32
|
+
|
|
33
|
+
- Initial release
|
|
34
|
+
- OpenCode plugin that injects codebase map into system prompt
|
|
35
|
+
- Uses `experimental.chat.system.transform` hook to inject map wrapped in `<agentmap>` tags
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# @agentmap/opencode
|
|
2
|
+
|
|
3
|
+
OpenCode plugin that injects an `agentmap` codebase map into the system prompt at session time.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bun add @agentmap/opencode
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## OpenCode config
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"plugin": ["@agentmap/opencode"]
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Restart OpenCode after updating the plugin list.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAOjD,eAAO,MAAM,cAAc,EAAE,MAmE5B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
// OpenCode plugin that injects codebase map into system prompt.
|
|
2
|
-
import {
|
|
2
|
+
import { formatLogMessage } from 'agentmap/src/logger';
|
|
3
|
+
import { generateMapYaml } from 'agentmap/src/index';
|
|
3
4
|
const MAX_LINES = 1000;
|
|
4
|
-
export const AgentMapPlugin = async ({ directory }) => {
|
|
5
|
+
export const AgentMapPlugin = async ({ directory, client }) => {
|
|
5
6
|
let cachedYaml;
|
|
6
7
|
let lastSessionID;
|
|
8
|
+
const logger = {
|
|
9
|
+
debug: () => { },
|
|
10
|
+
info: () => { },
|
|
11
|
+
warn: () => { },
|
|
12
|
+
error: (...args) => {
|
|
13
|
+
const message = formatLogMessage(args);
|
|
14
|
+
void client.tui.showToast({
|
|
15
|
+
body: {
|
|
16
|
+
title: 'agentmap',
|
|
17
|
+
message,
|
|
18
|
+
variant: 'error',
|
|
19
|
+
},
|
|
20
|
+
}).catch(() => { });
|
|
21
|
+
},
|
|
22
|
+
};
|
|
7
23
|
return {
|
|
8
24
|
'chat.message': async ({ sessionID }) => {
|
|
9
25
|
if (sessionID !== lastSessionID) {
|
|
@@ -17,7 +33,7 @@ export const AgentMapPlugin = async ({ directory }) => {
|
|
|
17
33
|
if (output.system.some((s) => s.includes('<agentmap>')))
|
|
18
34
|
return;
|
|
19
35
|
if (!cachedYaml) {
|
|
20
|
-
let yaml = await generateMapYaml({ dir: directory, diff: true });
|
|
36
|
+
let yaml = await generateMapYaml({ dir: directory, diff: true, logger });
|
|
21
37
|
// Truncate to max lines
|
|
22
38
|
const lines = yaml.split('\n');
|
|
23
39
|
if (lines.length > MAX_LINES) {
|
|
@@ -44,7 +60,7 @@ These descriptions appear in the agentmap XML at the start of every agent sessio
|
|
|
44
60
|
</agentmap-instructions>`);
|
|
45
61
|
}
|
|
46
62
|
catch (err) {
|
|
47
|
-
|
|
63
|
+
logger.error('[agentmap] Failed to generate map:', err);
|
|
48
64
|
}
|
|
49
65
|
},
|
|
50
66
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,gEAAgE;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,gEAAgE;AAGhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAEpD,MAAM,SAAS,GAAG,IAAI,CAAA;AAEtB,MAAM,CAAC,MAAM,cAAc,GAAW,KAAK,EAAE,EAAE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AA;oBAC9B,IAAI,KAAK,CAAC,MAAM,GAAG,SAAS,EAAE,CAAC;wBAC7B,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,mBAAmB,CAAA;oBACnE,CAAC;oBAED,UAAU,GAAG,IAAI,CAAA;gBACnB,CAAC;gBAED,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE;oBAAE,OAAM;gBAE9B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;;;;;EAKzB,UAAU;;;;;;;;;yBASa,CAAC,CAAA;YACpB,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,CAAC,KAAK,CAAC,oCAAoC,EAAE,GAAG,CAAC,CAAA;YACzD,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentmap/opencode",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "OpenCode plugin that injects agentmap codebase map into system prompt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -15,20 +15,32 @@
|
|
|
15
15
|
"main": "./dist/index.js",
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
17
17
|
"exports": {
|
|
18
|
+
"./package.json": "./package.json",
|
|
18
19
|
".": {
|
|
19
20
|
"types": "./dist/index.d.ts",
|
|
20
21
|
"default": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./src": {
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"default": "./src/index.ts"
|
|
26
|
+
},
|
|
27
|
+
"./src/*": {
|
|
28
|
+
"types": "./dist/*.d.ts",
|
|
29
|
+
"default": "./src/*.ts"
|
|
21
30
|
}
|
|
22
31
|
},
|
|
23
32
|
"files": [
|
|
24
|
-
"
|
|
33
|
+
"src",
|
|
34
|
+
"dist",
|
|
35
|
+
"README.md",
|
|
36
|
+
"CHANGELOG.md"
|
|
25
37
|
],
|
|
26
38
|
"scripts": {
|
|
27
39
|
"build": "tsc",
|
|
28
40
|
"prepublishOnly": "bun run build"
|
|
29
41
|
},
|
|
30
42
|
"dependencies": {
|
|
31
|
-
"agentmap": "0.
|
|
43
|
+
"agentmap": "^0.8.0"
|
|
32
44
|
},
|
|
33
45
|
"devDependencies": {
|
|
34
46
|
"@opencode-ai/plugin": "^1.0.224",
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
|
|
2
|
+
// OpenCode plugin that injects codebase map into system prompt.
|
|
3
|
+
|
|
4
|
+
import type { Plugin } from '@opencode-ai/plugin'
|
|
5
|
+
import { formatLogMessage } from 'agentmap/src/logger'
|
|
6
|
+
import type { Logger } from 'agentmap/src/logger'
|
|
7
|
+
import { generateMapYaml } from 'agentmap/src/index'
|
|
8
|
+
|
|
9
|
+
const MAX_LINES = 1000
|
|
10
|
+
|
|
11
|
+
export const AgentMapPlugin: Plugin = async ({ directory, client }) => {
|
|
12
|
+
let cachedYaml: string | undefined
|
|
13
|
+
let lastSessionID: string | undefined
|
|
14
|
+
|
|
15
|
+
const logger: Logger = {
|
|
16
|
+
debug: () => {},
|
|
17
|
+
info: () => {},
|
|
18
|
+
warn: () => {},
|
|
19
|
+
error: (...args) => {
|
|
20
|
+
const message = formatLogMessage(args)
|
|
21
|
+
void client.tui.showToast({
|
|
22
|
+
body: {
|
|
23
|
+
title: 'agentmap',
|
|
24
|
+
message,
|
|
25
|
+
variant: 'error',
|
|
26
|
+
},
|
|
27
|
+
}).catch(() => {})
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
'chat.message': async ({ sessionID }) => {
|
|
33
|
+
if (sessionID !== lastSessionID) {
|
|
34
|
+
lastSessionID = sessionID
|
|
35
|
+
cachedYaml = undefined
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
'experimental.chat.system.transform': async (_input, output) => {
|
|
40
|
+
try {
|
|
41
|
+
// Skip if already has agentmap tag
|
|
42
|
+
if (output.system.some((s) => s.includes('<agentmap>'))) return
|
|
43
|
+
|
|
44
|
+
if (!cachedYaml) {
|
|
45
|
+
let yaml = await generateMapYaml({ dir: directory, diff: true, logger })
|
|
46
|
+
|
|
47
|
+
// Truncate to max lines
|
|
48
|
+
const lines = yaml.split('\n')
|
|
49
|
+
if (lines.length > MAX_LINES) {
|
|
50
|
+
yaml = lines.slice(0, MAX_LINES).join('\n') + '\n# ... truncated'
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
cachedYaml = yaml
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!cachedYaml.trim()) return
|
|
57
|
+
|
|
58
|
+
output.system.push(`
|
|
59
|
+
|
|
60
|
+
<agentmap>
|
|
61
|
+
Tree of the most important files in the repo, showing descriptions and definitions:
|
|
62
|
+
|
|
63
|
+
${cachedYaml}
|
|
64
|
+
</agentmap>
|
|
65
|
+
|
|
66
|
+
<agentmap-instructions>
|
|
67
|
+
When creating new files, add a brief description comment at the top explaining the file's purpose. This makes the file discoverable in the agentmap.
|
|
68
|
+
|
|
69
|
+
When making significant changes to a file's purpose or responsibilities, update its header comment to reflect the changes.
|
|
70
|
+
|
|
71
|
+
These descriptions appear in the agentmap XML at the start of every agent session.
|
|
72
|
+
</agentmap-instructions>`)
|
|
73
|
+
} catch (err) {
|
|
74
|
+
logger.error('[agentmap] Failed to generate map:', err)
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
}
|