opencode-gitloops 0.2.1 → 0.2.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/README.md +1 -1
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -56
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/schema/config.schema.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Gitloops auto-creates a config file on first load at:
|
|
|
14
14
|
|
|
15
15
|
```json
|
|
16
16
|
{
|
|
17
|
-
"$schema": "https://raw.githubusercontent.com/
|
|
17
|
+
"$schema": "https://raw.githubusercontent.com/maharshi365/opencode-gitloops/master/schema/config.schema.json",
|
|
18
18
|
"max_repos": 10,
|
|
19
19
|
"cache_loc": "~/.cache/gitloops/repos",
|
|
20
20
|
"eviction_strategy": "lru"
|
package/dist/config.js
CHANGED
|
@@ -2,7 +2,7 @@ import * as fs from "fs/promises";
|
|
|
2
2
|
import * as path from "path";
|
|
3
3
|
import * as os from "os";
|
|
4
4
|
import { logger } from "./logger";
|
|
5
|
-
const SCHEMA_URL = "https://raw.githubusercontent.com/
|
|
5
|
+
const SCHEMA_URL = "https://raw.githubusercontent.com/maharshi365/opencode-gitloops/master/schema/config.schema.json";
|
|
6
6
|
const CONFIG_PATH = path.join(os.homedir(), ".config", "opencode", "plugin", "gitloops.json");
|
|
7
7
|
const DEFAULT_CACHE_LOC = path.join(os.homedir(), ".cache", "gitloops", "repos");
|
|
8
8
|
const DEFAULTS = {
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAC5B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AACxB,OAAO,EAAE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B,EAAE,MAAM,CAAC,iBAAiB;KAC5C,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,GAAG,IAAI,CAAA;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB;IACpC,IAAI,CAAC;QACH,MAAM,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAA;QAC5B,OAAO,KAAK,CAAA,CAAC,iBAAiB;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,iCAAiC;IACnC,CAAC;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IAC3C,MAAM,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;IAE9C,MAAM,cAAc,GAAG;QACrB,OAAO,EAAE,UAAU;QACnB,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,SAAS,EAAE,yBAAyB;QACpC,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB;KAC9C,CAAA;IAED,MAAM,EAAE,CAAC,SAAS,CAChB,WAAW,EACX,IAAI,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAC9C,MAAM,CACP,CAAA;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,WAAW,CAAA;AACpB,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AA0BjD,eAAO,MAAM,cAAc,EAAE,MAyF5B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,34 +1,9 @@
|
|
|
1
1
|
import { gitloops_clone, gitloops_refresh, gitloops_list } from "./tools";
|
|
2
2
|
import { ensureRepo } from "./repo-manager";
|
|
3
|
-
import { ensureConfigFile, getConfig
|
|
3
|
+
import { ensureConfigFile, getConfig } from "./config";
|
|
4
4
|
import { initLogger, logger } from "./logger";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import * as os from "os";
|
|
8
|
-
function buildAgentMD(cacheLoc) {
|
|
9
|
-
return `---
|
|
10
|
-
description: Explore GitHub repositories locally. Clone any public repo and answer questions about its code, structure, and patterns.
|
|
11
|
-
mode: all
|
|
12
|
-
color: "#ed5f00"
|
|
13
|
-
temperature: 0.1
|
|
14
|
-
tools:
|
|
15
|
-
read: true
|
|
16
|
-
grep: true
|
|
17
|
-
glob: true
|
|
18
|
-
list: true
|
|
19
|
-
webfetch: false
|
|
20
|
-
bash: false
|
|
21
|
-
edit: false
|
|
22
|
-
write: false
|
|
23
|
-
gitloops_clone: true
|
|
24
|
-
gitloops_refresh: true
|
|
25
|
-
gitloops_list: true
|
|
26
|
-
permission:
|
|
27
|
-
edit: deny
|
|
28
|
-
bash: deny
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
You are Gitloops, a read-only agent for exploring public GitHub repositories locally.
|
|
5
|
+
function buildAgentPrompt(cacheLoc) {
|
|
6
|
+
return `You are Gitloops, a read-only agent for exploring public GitHub repositories locally.
|
|
32
7
|
|
|
33
8
|
When a user asks about a repository:
|
|
34
9
|
1. Parse the repo slug from their message (e.g. "facebook/react" or a full GitHub URL)
|
|
@@ -43,43 +18,61 @@ Important rules:
|
|
|
43
18
|
- All file paths passed to read/grep/glob/list must be absolute paths under the repo's localPath.
|
|
44
19
|
- When switching between repos in the same session, always call \`gitloops_clone\` again for the new repo.
|
|
45
20
|
|
|
46
|
-
Repos are cached at: ${cacheLoc}/<owner>/<repo
|
|
47
|
-
`;
|
|
21
|
+
Repos are cached at: ${cacheLoc}/<owner>/<repo>/`;
|
|
48
22
|
}
|
|
49
23
|
export const GitLoopsPlugin = async ({ client }) => {
|
|
50
24
|
// Initialize the logger so all modules can use it
|
|
51
25
|
initLogger(client);
|
|
52
26
|
await logger.info("Gitloops plugin initialized");
|
|
27
|
+
// Pre-load config so it's ready for the config hook
|
|
28
|
+
let pluginConfig = null;
|
|
29
|
+
try {
|
|
30
|
+
await ensureConfigFile();
|
|
31
|
+
pluginConfig = await getConfig();
|
|
32
|
+
await logger.info("Gitloops config loaded", {
|
|
33
|
+
cache_loc: pluginConfig.cache_loc,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
await logger.warn(`Failed to load config: ${err.message || err}`);
|
|
38
|
+
}
|
|
53
39
|
return {
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
// Register the gitloops agent via the config hook.
|
|
41
|
+
// This is called by OpenCode at startup to let plugins inject agents,
|
|
42
|
+
// tools, and other config before the UI renders.
|
|
43
|
+
config: async (config) => {
|
|
57
44
|
try {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
45
|
+
const cfg = pluginConfig ?? await getConfig();
|
|
46
|
+
const agentDefs = (config.agent ?? {});
|
|
47
|
+
agentDefs.gitloops = {
|
|
48
|
+
description: "Explore GitHub repositories locally. Clone any public repo and answer questions about its code, structure, and patterns.",
|
|
49
|
+
mode: "all",
|
|
50
|
+
color: "#ed5f00",
|
|
51
|
+
temperature: 0.1,
|
|
52
|
+
tools: {
|
|
53
|
+
read: true,
|
|
54
|
+
grep: true,
|
|
55
|
+
glob: true,
|
|
56
|
+
list: true,
|
|
57
|
+
webfetch: false,
|
|
58
|
+
bash: false,
|
|
59
|
+
edit: false,
|
|
60
|
+
write: false,
|
|
61
|
+
gitloops_clone: true,
|
|
62
|
+
gitloops_refresh: true,
|
|
63
|
+
gitloops_list: true,
|
|
64
|
+
},
|
|
65
|
+
permission: {
|
|
66
|
+
edit: "deny",
|
|
67
|
+
bash: "deny",
|
|
68
|
+
},
|
|
69
|
+
prompt: buildAgentPrompt(cfg.cache_loc),
|
|
70
|
+
};
|
|
71
|
+
config.agent = agentDefs;
|
|
72
|
+
await logger.info("Gitloops agent registered via config hook");
|
|
80
73
|
}
|
|
81
74
|
catch (err) {
|
|
82
|
-
await logger.
|
|
75
|
+
await logger.error(`Failed to register agent via config hook: ${err.message || err}`);
|
|
83
76
|
}
|
|
84
77
|
},
|
|
85
78
|
// Auto-fetch: when a gitloops session is created, pre-warm clone if a slug
|
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":"AAEA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAE7C,SAAS,gBAAgB,CAAC,QAAgB;IACxC,OAAO;;;;;;;;;;;;;;;uBAec,QAAQ,kBAAkB,CAAA;AACjD,CAAC;AAED,MAAM,CAAC,MAAM,cAAc,GAAW,KAAK,EAAE,E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
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "GitHub repo explorer agent and plugin for OpenCode. Clone and explore any public GitHub repo locally.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"repository": {
|
|
40
40
|
"type": "git",
|
|
41
|
-
"url": "https://github.com/
|
|
41
|
+
"url": "https://github.com/maharshi365/opencode-gitloops"
|
|
42
42
|
},
|
|
43
|
-
"author": "",
|
|
43
|
+
"author": "maharshi365",
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": ">=18"
|
|
46
46
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"$id": "https://raw.githubusercontent.com/
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/maharshi365/opencode-gitloops/master/schema/config.schema.json",
|
|
4
4
|
"title": "Gitloops Configuration",
|
|
5
5
|
"description": "Configuration for the opencode-gitloops plugin.",
|
|
6
6
|
"type": "object",
|