@agentmap/opencode 0.3.0 → 0.5.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/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -109
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
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;AAKjD,eAAO,MAAM,cAAc,EAAE,MAmD5B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,101 +1,6 @@
|
|
|
1
|
-
// @agentmap
|
|
2
1
|
// OpenCode plugin that injects codebase map into system prompt.
|
|
3
|
-
import {
|
|
4
|
-
const MAX_DEFS_PER_FILE = 25;
|
|
2
|
+
import { generateMapYaml } from 'agentmap';
|
|
5
3
|
const MAX_LINES = 1000;
|
|
6
|
-
/**
|
|
7
|
-
* Check if a def value indicates exported or extern
|
|
8
|
-
*/
|
|
9
|
-
function isExportedDef(value) {
|
|
10
|
-
return value.includes('exported') || value.includes('extern');
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Truncate definitions in a file entry to MAX_DEFS_PER_FILE
|
|
14
|
-
* If file has exported symbols, shows only exports field instead
|
|
15
|
-
* Otherwise uses current truncation behavior
|
|
16
|
-
*/
|
|
17
|
-
function truncateDefs(entry) {
|
|
18
|
-
if (!entry.defs)
|
|
19
|
-
return entry;
|
|
20
|
-
const defNames = Object.keys(entry.defs);
|
|
21
|
-
if (defNames.length <= MAX_DEFS_PER_FILE)
|
|
22
|
-
return entry;
|
|
23
|
-
// Filter to only exported/extern definitions
|
|
24
|
-
const exportedNames = defNames.filter(name => isExportedDef(entry.defs[name]));
|
|
25
|
-
// If we have exports, use exports field instead of defs
|
|
26
|
-
if (exportedNames.length > 0) {
|
|
27
|
-
const exports = {};
|
|
28
|
-
const maxExports = Math.min(exportedNames.length, MAX_DEFS_PER_FILE);
|
|
29
|
-
for (let i = 0; i < maxExports; i++) {
|
|
30
|
-
const name = exportedNames[i];
|
|
31
|
-
exports[name] = entry.defs[name];
|
|
32
|
-
}
|
|
33
|
-
// Add marker if exports were also truncated
|
|
34
|
-
if (exportedNames.length > MAX_DEFS_PER_FILE) {
|
|
35
|
-
const remaining = exportedNames.length - MAX_DEFS_PER_FILE;
|
|
36
|
-
exports[`__more_${remaining}__`] = `${remaining} more exports`;
|
|
37
|
-
}
|
|
38
|
-
// Return with exports instead of defs
|
|
39
|
-
const { defs, ...rest } = entry;
|
|
40
|
-
return { ...rest, exports };
|
|
41
|
-
}
|
|
42
|
-
// No exports found - use current truncation behavior
|
|
43
|
-
const truncated = {};
|
|
44
|
-
for (let i = 0; i < MAX_DEFS_PER_FILE; i++) {
|
|
45
|
-
const name = defNames[i];
|
|
46
|
-
truncated[name] = entry.defs[name];
|
|
47
|
-
}
|
|
48
|
-
const remaining = defNames.length - MAX_DEFS_PER_FILE;
|
|
49
|
-
// Add marker that will be converted to comment
|
|
50
|
-
truncated[`__more_${remaining}__`] = `${remaining} more definitions`;
|
|
51
|
-
return { ...entry, defs: truncated };
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Check if a value is a FileEntry (has description or defs)
|
|
55
|
-
*/
|
|
56
|
-
function isFileEntry(value) {
|
|
57
|
-
if (!value || typeof value !== 'object')
|
|
58
|
-
return false;
|
|
59
|
-
const obj = value;
|
|
60
|
-
return 'description' in obj || 'defs' in obj;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Recursively truncate defs in all files in the map
|
|
64
|
-
*/
|
|
65
|
-
function truncateMap(node) {
|
|
66
|
-
const result = {};
|
|
67
|
-
for (const [key, value] of Object.entries(node)) {
|
|
68
|
-
if (isFileEntry(value)) {
|
|
69
|
-
result[key] = truncateDefs(value);
|
|
70
|
-
}
|
|
71
|
-
else if (value && typeof value === 'object') {
|
|
72
|
-
result[key] = truncateMap(value);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
result[key] = value;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return result;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Convert __more_N__ markers to YAML comments
|
|
82
|
-
*/
|
|
83
|
-
function markersToComments(yaml) {
|
|
84
|
-
// Match lines like: __more_25__: 25 more definitions/exports
|
|
85
|
-
// Replace with: # ... 25 more definitions/exports
|
|
86
|
-
return yaml.replace(/^(\s*)__more_(\d+)__: (\d+ more (?:definitions|exports))$/gm, '$1# ... $3');
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Truncate YAML to max lines, adding a comment if truncated
|
|
90
|
-
*/
|
|
91
|
-
function truncateLines(yaml) {
|
|
92
|
-
const lines = yaml.split('\n');
|
|
93
|
-
if (lines.length <= MAX_LINES)
|
|
94
|
-
return yaml;
|
|
95
|
-
const truncated = lines.slice(0, MAX_LINES);
|
|
96
|
-
truncated.push('# ... truncated');
|
|
97
|
-
return truncated.join('\n');
|
|
98
|
-
}
|
|
99
4
|
export const AgentMapPlugin = async ({ directory }) => {
|
|
100
5
|
let cachedYaml;
|
|
101
6
|
let lastSessionID;
|
|
@@ -112,20 +17,13 @@ export const AgentMapPlugin = async ({ directory }) => {
|
|
|
112
17
|
if (output.system.some((s) => s.includes('<agentmap>')))
|
|
113
18
|
return;
|
|
114
19
|
if (!cachedYaml) {
|
|
115
|
-
|
|
116
|
-
//
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
cachedYaml = '';
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
const truncatedMap = truncateMap(map);
|
|
124
|
-
let yaml = toYaml(truncatedMap);
|
|
125
|
-
yaml = markersToComments(yaml);
|
|
126
|
-
yaml = truncateLines(yaml);
|
|
127
|
-
cachedYaml = yaml;
|
|
20
|
+
let yaml = await generateMapYaml({ dir: directory, diff: true });
|
|
21
|
+
// Truncate to max lines
|
|
22
|
+
const lines = yaml.split('\n');
|
|
23
|
+
if (lines.length > MAX_LINES) {
|
|
24
|
+
yaml = lines.slice(0, MAX_LINES).join('\n') + '\n# ... truncated';
|
|
128
25
|
}
|
|
26
|
+
cachedYaml = yaml;
|
|
129
27
|
}
|
|
130
28
|
if (!cachedYaml.trim())
|
|
131
29
|
return;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,gEAAgE;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1C,MAAM,SAAS,GAAG,IAAI,CAAA;AAEtB,MAAM,CAAC,MAAM,cAAc,GAAW,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;IAC5D,IAAI,UAA8B,CAAA;IAClC,IAAI,aAAiC,CAAA;IAErC,OAAO;QACL,cAAc,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;YACtC,IAAI,SAAS,KAAK,aAAa,EAAE,CAAC;gBAChC,aAAa,GAAG,SAAS,CAAA;gBACzB,UAAU,GAAG,SAAS,CAAA;YACxB,CAAC;QACH,CAAC;QAED,oCAAoC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YAC7D,IAAI,CAAC;gBACH,mCAAmC;gBACnC,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;oBAAE,OAAM;gBAE/D,IAAI,CAAC,UAAU,EAAE,CAAC;oBAChB,IAAI,IAAI,GAAG,MAAM,eAAe,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;oBAEhE,wBAAwB;oBACxB,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;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,OAAO,CAAC,KAAK,CAAC,oCAAoC,EAAE,GAAG,CAAC,CAAA;YAC1D,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.5.0",
|
|
4
4
|
"description": "OpenCode plugin that injects agentmap codebase map into system prompt",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"prepublishOnly": "bun run build"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"agentmap": "0.
|
|
31
|
+
"agentmap": "0.7.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@opencode-ai/plugin": "^1.0.224",
|