@agentmap/opencode 0.1.0 → 0.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.
@@ -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;AAGjD,eAAO,MAAM,cAAc,EAAE,MAa5B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAGjD,eAAO,MAAM,cAAc,EAAE,MAgC5B,CAAA"}
package/dist/index.js CHANGED
@@ -2,16 +2,34 @@
2
2
  // OpenCode plugin that injects codebase map into system prompt.
3
3
  import { generateMapYaml } from 'agentmap';
4
4
  export const AgentMapPlugin = async ({ directory }) => {
5
+ let cachedYaml;
6
+ let lastSessionID;
5
7
  return {
8
+ 'chat.message': async ({ sessionID }) => {
9
+ if (sessionID !== lastSessionID) {
10
+ lastSessionID = sessionID;
11
+ cachedYaml = undefined;
12
+ }
13
+ },
6
14
  'experimental.chat.system.transform': async (_input, output) => {
7
- const yaml = await generateMapYaml({ dir: directory });
8
- if (!yaml.trim())
9
- return;
10
- output.system.push(`<agentmap>
11
- These are some of the files in the repo with their descriptions and definition locations:
15
+ try {
16
+ // Skip if already has agentmap tag
17
+ if (output.system.some((s) => s.includes('<agentmap>')))
18
+ return;
19
+ cachedYaml ??= await generateMapYaml({ dir: directory });
20
+ if (!cachedYaml.trim())
21
+ return;
22
+ output.system.push(`
23
+
24
+ <agentmap>
25
+ Tree of the most important files in the repo, showing descriptions and definitions:
12
26
 
13
- ${yaml}
27
+ ${cachedYaml}
14
28
  </agentmap>`);
29
+ }
30
+ catch (err) {
31
+ console.error('[agentmap] Failed to generate map:', err);
32
+ }
15
33
  },
16
34
  };
17
35
  };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY;AACZ,gEAAgE;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1C,MAAM,CAAC,MAAM,cAAc,GAAW,KAAK,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;IAC5D,OAAO;QACL,oCAAoC,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YAC7D,MAAM,IAAI,GAAG,MAAM,eAAe,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAA;YACtD,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;gBAAE,OAAM;YAExB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;;;EAGvB,IAAI;YACM,CAAC,CAAA;QACT,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY;AACZ,gEAAgE;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1C,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,UAAU,KAAK,MAAM,eAAe,CAAC,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAA;gBACxD,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE;oBAAE,OAAM;gBAE9B,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;;;;;EAKzB,UAAU;YACA,CAAC,CAAA;YACP,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.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "OpenCode plugin that injects agentmap codebase map into system prompt",
5
5
  "type": "module",
6
6
  "repository": {