agentmap 0.2.0 → 0.4.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/cli.js +42 -4
- package/dist/cli.js.map +1 -1
- package/dist/extract/definitions.d.ts.map +1 -1
- package/dist/extract/definitions.js +80 -15
- package/dist/extract/definitions.js.map +1 -1
- package/dist/extract/definitions.test.d.ts +2 -0
- package/dist/extract/definitions.test.d.ts.map +1 -0
- package/dist/extract/definitions.test.js +1414 -0
- package/dist/extract/definitions.test.js.map +1 -0
- package/dist/extract/git-status.d.ts +51 -0
- package/dist/extract/git-status.d.ts.map +1 -0
- package/dist/extract/git-status.js +288 -0
- package/dist/extract/git-status.js.map +1 -0
- package/dist/extract/git-status.test.d.ts +2 -0
- package/dist/extract/git-status.test.d.ts.map +1 -0
- package/dist/extract/git-status.test.js +456 -0
- package/dist/extract/git-status.test.js.map +1 -0
- package/dist/extract/marker.d.ts +9 -2
- package/dist/extract/marker.d.ts.map +1 -1
- package/dist/extract/marker.js +211 -103
- package/dist/extract/marker.js.map +1 -1
- package/dist/extract/marker.test.d.ts +2 -0
- package/dist/extract/marker.test.d.ts.map +1 -0
- package/dist/extract/marker.test.js +374 -0
- package/dist/extract/marker.test.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/map/builder.d.ts.map +1 -1
- package/dist/map/builder.js +41 -4
- package/dist/map/builder.js.map +1 -1
- package/dist/map/yaml.d.ts.map +1 -1
- package/dist/map/yaml.js +7 -3
- package/dist/map/yaml.js.map +1 -1
- package/dist/parser/index.d.ts.map +1 -1
- package/dist/parser/index.js +0 -1
- package/dist/parser/index.js.map +1 -1
- package/dist/parser/languages.d.ts.map +1 -1
- package/dist/parser/languages.js +0 -1
- package/dist/parser/languages.js.map +1 -1
- package/dist/scanner.d.ts +1 -1
- package/dist/scanner.d.ts.map +1 -1
- package/dist/scanner.js +34 -7
- package/dist/scanner.js.map +1 -1
- package/dist/types.d.ts +43 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -1
- package/dist/types.js.map +1 -1
- package/package.json +6 -9
- package/README +0 -158
- package/dist/opencode/plugin.d.ts +0 -3
- package/dist/opencode/plugin.d.ts.map +0 -1
- package/dist/opencode/plugin.js +0 -18
- package/dist/opencode/plugin.js.map +0 -1
package/dist/scanner.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Scan directory for files with @agentmap marker.
|
|
1
|
+
// Scan directory for files with header comments/docstrings.
|
|
3
2
|
import { execSync } from 'child_process';
|
|
4
3
|
import fg from 'fast-glob';
|
|
5
4
|
import picomatch from 'picomatch';
|
|
@@ -7,6 +6,7 @@ import { readFile } from 'fs/promises';
|
|
|
7
6
|
import { join, normalize } from 'path';
|
|
8
7
|
import { extractMarker } from './extract/marker.js';
|
|
9
8
|
import { extractDefinitions } from './extract/definitions.js';
|
|
9
|
+
import { getAllDiffData, applyDiffToDefinitions } from './extract/git-status.js';
|
|
10
10
|
import { parseCode, detectLanguage, LANGUAGE_EXTENSIONS } from './parser/index.js';
|
|
11
11
|
/**
|
|
12
12
|
* Supported file extensions (from LANGUAGE_EXTENSIONS)
|
|
@@ -74,11 +74,13 @@ async function getGlobFiles(dir) {
|
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
|
-
* Scan directory and process files with
|
|
77
|
+
* Scan directory and process files with header comments
|
|
78
78
|
*/
|
|
79
79
|
export async function scanDirectory(options = {}) {
|
|
80
80
|
const dir = options.dir ?? process.cwd();
|
|
81
|
-
|
|
81
|
+
// Filter out null/undefined/empty patterns (cac can pass [null] when option not used)
|
|
82
|
+
const ignorePatterns = (options.ignore ?? []).filter((p) => !!p);
|
|
83
|
+
const includeDiff = options.diff ?? false;
|
|
82
84
|
// Get file list - prefer git, fallback to glob
|
|
83
85
|
let files;
|
|
84
86
|
if (isGitRepo(dir)) {
|
|
@@ -94,12 +96,31 @@ export async function scanDirectory(options = {}) {
|
|
|
94
96
|
const isIgnored = picomatch(ignorePatterns);
|
|
95
97
|
files = files.filter(f => !isIgnored(f));
|
|
96
98
|
}
|
|
99
|
+
// Get git diff data if needed (isolated from main processing)
|
|
100
|
+
let fileStats = null;
|
|
101
|
+
let fileDiffs = null;
|
|
102
|
+
if (includeDiff && isGitRepo(dir)) {
|
|
103
|
+
try {
|
|
104
|
+
const diffData = getAllDiffData(dir);
|
|
105
|
+
fileStats = diffData.fileStats;
|
|
106
|
+
fileDiffs = diffData.fileDiffs;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
// Diff failed - continue without diff info
|
|
110
|
+
fileStats = null;
|
|
111
|
+
fileDiffs = null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
97
114
|
// Process each file
|
|
98
115
|
const results = [];
|
|
99
116
|
for (const relativePath of files) {
|
|
100
117
|
const fullPath = join(dir, relativePath);
|
|
118
|
+
// Normalize path for lookup (handle Windows backslashes)
|
|
119
|
+
const normalizedPath = relativePath.replace(/\\/g, '/');
|
|
101
120
|
try {
|
|
102
|
-
const
|
|
121
|
+
const fileDiff = fileDiffs?.get(normalizedPath);
|
|
122
|
+
const stats = fileStats?.get(normalizedPath);
|
|
123
|
+
const result = await processFile(fullPath, relativePath, fileDiff, stats);
|
|
103
124
|
if (result) {
|
|
104
125
|
results.push(result);
|
|
105
126
|
}
|
|
@@ -114,7 +135,7 @@ export async function scanDirectory(options = {}) {
|
|
|
114
135
|
/**
|
|
115
136
|
* Process a single file - check for marker and extract definitions
|
|
116
137
|
*/
|
|
117
|
-
async function processFile(fullPath, relativePath) {
|
|
138
|
+
async function processFile(fullPath, relativePath, fileDiff, fileStats) {
|
|
118
139
|
// Check for marker first (only reads first 30KB)
|
|
119
140
|
const marker = await extractMarker(fullPath);
|
|
120
141
|
if (!marker.found) {
|
|
@@ -129,11 +150,17 @@ async function processFile(fullPath, relativePath) {
|
|
|
129
150
|
const code = await readFile(fullPath, 'utf8');
|
|
130
151
|
// Parse and extract definitions
|
|
131
152
|
const tree = await parseCode(code, language);
|
|
132
|
-
|
|
153
|
+
let definitions = extractDefinitions(tree.rootNode, language);
|
|
154
|
+
// Apply diff info if available (for definition-level stats)
|
|
155
|
+
if (fileDiff) {
|
|
156
|
+
definitions = applyDiffToDefinitions(definitions, fileDiff);
|
|
157
|
+
}
|
|
133
158
|
return {
|
|
134
159
|
relativePath,
|
|
135
160
|
description: marker.description,
|
|
136
161
|
definitions,
|
|
162
|
+
// Use pre-calculated file stats from --numstat (more reliable)
|
|
163
|
+
diff: fileStats,
|
|
137
164
|
};
|
|
138
165
|
}
|
|
139
166
|
//# sourceMappingURL=scanner.js.map
|
package/dist/scanner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanner.js","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"scanner.js","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAE5D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,MAAM,WAAW,CAAA;AAC1B,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAChF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAGlF;;GAEG;AACH,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IA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C"}
|
package/dist/types.d.ts
CHANGED
|
@@ -9,11 +9,19 @@ export type Language = 'typescript' | 'javascript' | 'python' | 'rust' | 'go';
|
|
|
9
9
|
export interface DefEntry {
|
|
10
10
|
[symbolName: string]: string;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Git diff stats for a file (total lines added/deleted)
|
|
14
|
+
*/
|
|
15
|
+
export interface FileDiffStats {
|
|
16
|
+
added: number;
|
|
17
|
+
deleted: number;
|
|
18
|
+
}
|
|
12
19
|
/**
|
|
13
20
|
* A file entry in the map
|
|
14
21
|
*/
|
|
15
22
|
export interface FileEntry {
|
|
16
23
|
description?: string;
|
|
24
|
+
diff?: string;
|
|
17
25
|
defs?: DefEntry;
|
|
18
26
|
}
|
|
19
27
|
/**
|
|
@@ -33,14 +41,28 @@ export interface MarkerResult {
|
|
|
33
41
|
* Types of definitions we extract
|
|
34
42
|
*/
|
|
35
43
|
export type DefinitionType = 'function' | 'class' | 'type' | 'interface' | 'const' | 'enum';
|
|
44
|
+
/**
|
|
45
|
+
* Git status for a definition
|
|
46
|
+
*/
|
|
47
|
+
export type DefinitionStatus = 'added' | 'updated';
|
|
48
|
+
/**
|
|
49
|
+
* Git diff stats for a definition
|
|
50
|
+
*/
|
|
51
|
+
export interface DefinitionDiff {
|
|
52
|
+
status: DefinitionStatus;
|
|
53
|
+
added: number;
|
|
54
|
+
deleted: number;
|
|
55
|
+
}
|
|
36
56
|
/**
|
|
37
57
|
* A definition extracted from source code
|
|
38
58
|
*/
|
|
39
59
|
export interface Definition {
|
|
40
60
|
name: string;
|
|
41
61
|
line: number;
|
|
62
|
+
endLine: number;
|
|
42
63
|
type: DefinitionType;
|
|
43
64
|
exported: boolean;
|
|
65
|
+
diff?: DefinitionDiff;
|
|
44
66
|
}
|
|
45
67
|
/**
|
|
46
68
|
* Result of processing a single file
|
|
@@ -49,6 +71,7 @@ export interface FileResult {
|
|
|
49
71
|
relativePath: string;
|
|
50
72
|
description?: string;
|
|
51
73
|
definitions: Definition[];
|
|
74
|
+
diff?: FileDiffStats;
|
|
52
75
|
}
|
|
53
76
|
/**
|
|
54
77
|
* Options for generating the map
|
|
@@ -58,6 +81,26 @@ export interface GenerateOptions {
|
|
|
58
81
|
dir?: string;
|
|
59
82
|
/** Glob patterns to ignore */
|
|
60
83
|
ignore?: string[];
|
|
84
|
+
/** Include git diff status for definitions */
|
|
85
|
+
diff?: boolean;
|
|
86
|
+
/** Git ref to diff against (default: HEAD for unstaged, --cached for staged) */
|
|
87
|
+
diffBase?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* A hunk from git diff output
|
|
91
|
+
*/
|
|
92
|
+
export interface DiffHunk {
|
|
93
|
+
oldStart: number;
|
|
94
|
+
oldCount: number;
|
|
95
|
+
newStart: number;
|
|
96
|
+
newCount: number;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Parsed diff for a single file
|
|
100
|
+
*/
|
|
101
|
+
export interface FileDiff {
|
|
102
|
+
path: string;
|
|
103
|
+
hunks: DiffHunk[];
|
|
61
104
|
}
|
|
62
105
|
/**
|
|
63
106
|
* Re-export parser types
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAA;AAEzC;;GAEG;AACH,MAAM,MAAM,QAAQ,GAChB,YAAY,GACZ,YAAY,GACZ,QAAQ,GACR,MAAM,GACN,IAAI,CAAA;AAER;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAA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,8CAA8C;IAC9C,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,gFAAgF;IAChF,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,QAAQ,EAAE,CAAA;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAA;AAC1C,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAA"}
|
package/dist/types.js
CHANGED
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,8CAA8C"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentmap",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Generate a YAML map of your codebase for AI agent context",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/remorses/agentmap.git"
|
|
8
|
+
"url": "git+https://github.com/remorses/agentmap.git",
|
|
9
|
+
"directory": "cli"
|
|
9
10
|
},
|
|
10
11
|
"homepage": "https://github.com/remorses/agentmap#readme",
|
|
11
12
|
"bugs": {
|
|
@@ -20,10 +21,6 @@
|
|
|
20
21
|
".": {
|
|
21
22
|
"types": "./dist/index.d.ts",
|
|
22
23
|
"default": "./dist/index.js"
|
|
23
|
-
},
|
|
24
|
-
"./opencode": {
|
|
25
|
-
"types": "./dist/opencode/plugin.d.ts",
|
|
26
|
-
"default": "./dist/opencode/plugin.js"
|
|
27
24
|
}
|
|
28
25
|
},
|
|
29
26
|
"files": [
|
|
@@ -32,8 +29,8 @@
|
|
|
32
29
|
"scripts": {
|
|
33
30
|
"build": "tsc",
|
|
34
31
|
"dev": "tsc --watch",
|
|
35
|
-
"cli": "
|
|
36
|
-
"
|
|
32
|
+
"cli": "bun src/cli.ts",
|
|
33
|
+
"test": "bun test"
|
|
37
34
|
},
|
|
38
35
|
"dependencies": {
|
|
39
36
|
"cac": "^6.7.14",
|
|
@@ -48,7 +45,7 @@
|
|
|
48
45
|
"web-tree-sitter": "^0.24.4"
|
|
49
46
|
},
|
|
50
47
|
"devDependencies": {
|
|
51
|
-
"@
|
|
48
|
+
"@types/bun": "^1.3.5",
|
|
52
49
|
"@types/js-yaml": "^4.0.9",
|
|
53
50
|
"@types/node": "^22.10.2",
|
|
54
51
|
"@types/picomatch": "^3.0.1",
|
package/README
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
# agentmap
|
|
2
|
-
|
|
3
|
-
A compact, YAML-based inventory of your codebase, intended to be prepended to a coding agent's context at session start.
|
|
4
|
-
|
|
5
|
-
## Purpose
|
|
6
|
-
|
|
7
|
-
- Give the agent a fast, structured overview of files and responsibilities
|
|
8
|
-
- Provide jump targets via top-level `defs` (functions/classes with line numbers)
|
|
9
|
-
|
|
10
|
-
## Installation
|
|
11
|
-
|
|
12
|
-
```bash
|
|
13
|
-
npm install agentmap
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
## CLI Usage
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
# Map current directory
|
|
20
|
-
npx agentmap
|
|
21
|
-
|
|
22
|
-
# Map specific directory
|
|
23
|
-
npx agentmap ./src
|
|
24
|
-
|
|
25
|
-
# Write to file
|
|
26
|
-
npx agentmap -o map.yaml
|
|
27
|
-
|
|
28
|
-
# Ignore patterns
|
|
29
|
-
npx agentmap --ignore "dist/**" --ignore "**/test/**"
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
### Options
|
|
33
|
-
|
|
34
|
-
```
|
|
35
|
-
-o, --output <file> Write output to file (default: stdout)
|
|
36
|
-
-i, --ignore <pattern> Ignore pattern (can be repeated)
|
|
37
|
-
-h, --help Show help
|
|
38
|
-
-v, --version Show version
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## Library Usage
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
import { generateMap, generateMapYaml } from 'agentmap'
|
|
45
|
-
|
|
46
|
-
// Get as object
|
|
47
|
-
const map = await generateMap({ dir: './src' })
|
|
48
|
-
|
|
49
|
-
// Get as YAML string
|
|
50
|
-
const yaml = await generateMapYaml({ dir: './src' })
|
|
51
|
-
|
|
52
|
-
// With ignore patterns
|
|
53
|
-
const yaml = await generateMapYaml({
|
|
54
|
-
dir: './src',
|
|
55
|
-
ignore: ['**/test/**', '**/*.spec.ts']
|
|
56
|
-
})
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## Marking Files
|
|
60
|
-
|
|
61
|
-
Only files with the `@agentmap` marker comment are included. Add it to the top of files you want in the map:
|
|
62
|
-
|
|
63
|
-
```typescript
|
|
64
|
-
// @agentmap
|
|
65
|
-
// CLI entrypoint.
|
|
66
|
-
// Parses args, wires deps, calls into lib/.
|
|
67
|
-
|
|
68
|
-
export function main() { ... }
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
```python
|
|
72
|
-
# @agentmap
|
|
73
|
-
# Parsing + normalization utilities.
|
|
74
|
-
|
|
75
|
-
def parse_input(): ...
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
Block comments also work:
|
|
79
|
-
|
|
80
|
-
```typescript
|
|
81
|
-
/**
|
|
82
|
-
* @agentmap
|
|
83
|
-
* Core data structures.
|
|
84
|
-
*/
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## Output Format
|
|
88
|
-
|
|
89
|
-
```yaml
|
|
90
|
-
my-project:
|
|
91
|
-
src:
|
|
92
|
-
main.py:
|
|
93
|
-
desc: |
|
|
94
|
-
CLI entrypoint.
|
|
95
|
-
Parses args, wires deps, calls into lib/.
|
|
96
|
-
defs:
|
|
97
|
-
main: 12
|
|
98
|
-
parse_args: 34
|
|
99
|
-
App: 58
|
|
100
|
-
lib:
|
|
101
|
-
parse.py:
|
|
102
|
-
desc: |
|
|
103
|
-
Parsing + normalization utilities.
|
|
104
|
-
defs:
|
|
105
|
-
parse_input: 10
|
|
106
|
-
ASTNode: 41
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### Format Rules
|
|
110
|
-
|
|
111
|
-
- Directories are YAML mappings
|
|
112
|
-
- Files have optional `desc` (description) and `defs` (definitions)
|
|
113
|
-
- `desc` uses YAML literal block scalar (`|`) for multi-line text
|
|
114
|
-
- `defs` maps symbol names to 1-based line numbers
|
|
115
|
-
- Only top-level `function` and `class` definitions are included
|
|
116
|
-
|
|
117
|
-
## Supported Languages
|
|
118
|
-
|
|
119
|
-
| Language | Extensions |
|
|
120
|
-
|------------|---------------------------|
|
|
121
|
-
| TypeScript | .ts .tsx .mts .cts |
|
|
122
|
-
| JavaScript | .js .jsx .mjs .cjs |
|
|
123
|
-
| Python | .py .pyi |
|
|
124
|
-
| Rust | .rs |
|
|
125
|
-
| Go | .go |
|
|
126
|
-
|
|
127
|
-
## OpenCode Plugin
|
|
128
|
-
|
|
129
|
-
agentmap includes a plugin for [OpenCode](https://opencode.ai) that automatically injects the codebase map into the system prompt at session start.
|
|
130
|
-
|
|
131
|
-
Add the plugin to your `opencode.json`:
|
|
132
|
-
|
|
133
|
-
```json
|
|
134
|
-
{
|
|
135
|
-
"plugin": ["agentmap/opencode"]
|
|
136
|
-
}
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
The plugin will scan your project for files with `@agentmap` markers and inject the map into the system prompt wrapped in `<agentmap>` tags:
|
|
140
|
-
|
|
141
|
-
```xml
|
|
142
|
-
<agentmap>
|
|
143
|
-
These are some of the files in the repo with their descriptions and definition locations:
|
|
144
|
-
|
|
145
|
-
my-project:
|
|
146
|
-
src:
|
|
147
|
-
main.ts:
|
|
148
|
-
desc: CLI entrypoint.
|
|
149
|
-
defs:
|
|
150
|
-
main: 12
|
|
151
|
-
</agentmap>
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
This gives the AI agent immediate context about your codebase structure without needing to explore files first.
|
|
155
|
-
|
|
156
|
-
## License
|
|
157
|
-
|
|
158
|
-
MIT
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/opencode/plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAGjD,eAAO,MAAM,cAAc,EAAE,MAa5B,CAAA"}
|
package/dist/opencode/plugin.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// @agentmap
|
|
2
|
-
// OpenCode plugin that injects codebase map into system prompt.
|
|
3
|
-
import { generateMapYaml } from '../index.js';
|
|
4
|
-
export const AgentMapPlugin = async ({ directory }) => {
|
|
5
|
-
return {
|
|
6
|
-
'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:
|
|
12
|
-
|
|
13
|
-
${yaml}
|
|
14
|
-
</agentmap>`);
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
//# sourceMappingURL=plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/opencode/plugin.ts"],"names":[],"mappings":"AAAA,YAAY;AACZ,gEAAgE;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C,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"}
|