agent-watch 1.0.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 +39 -0
- package/LICENSE +21 -0
- package/README.md +95 -0
- package/dist/cli-nMe9-VkJ.d.ts +1 -0
- package/dist/cli.cjs +770 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +771 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/run.d.ts +5 -0
- package/dist/commands/run.d.ts.map +1 -0
- package/dist/config.d.ts +31 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/constants.d.ts +21 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/detect-BMnM34-m.cjs +177 -0
- package/dist/detect-BMnM34-m.cjs.map +1 -0
- package/dist/detect-BWGm1KGQ.js +122 -0
- package/dist/detect-BWGm1KGQ.js.map +1 -0
- package/dist/detect-B_DDBj5N.cjs +182 -0
- package/dist/detect-B_DDBj5N.cjs.map +1 -0
- package/dist/detect-CPW1RRIq.js +117 -0
- package/dist/detect-CPW1RRIq.js.map +1 -0
- package/dist/detect-Dii2e4wf.cjs +174 -0
- package/dist/detect-Dii2e4wf.cjs.map +1 -0
- package/dist/detect-Pkaqn3YG.js +120 -0
- package/dist/detect-Pkaqn3YG.js.map +1 -0
- package/dist/detect.d.ts +16 -0
- package/dist/detect.d.ts.map +1 -0
- package/dist/hooks.d.ts +13 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/index-CXIlEXUx.d.ts +51 -0
- package/dist/index.cjs +13 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/logger-BNjXChov.js +164 -0
- package/dist/logger-BNjXChov.js.map +1 -0
- package/dist/logger-CdAUnlsG.cjs +271 -0
- package/dist/logger-CdAUnlsG.cjs.map +1 -0
- package/dist/logger-hSIaaw_k.js +166 -0
- package/dist/logger-hSIaaw_k.js.map +1 -0
- package/dist/logger-oq2Z7oYf.cjs +269 -0
- package/dist/logger-oq2Z7oYf.cjs.map +1 -0
- package/dist/sessions-90kmJrQI.js +360 -0
- package/dist/sessions-90kmJrQI.js.map +1 -0
- package/dist/sessions-Bmk48zTI.js +311 -0
- package/dist/sessions-Bmk48zTI.js.map +1 -0
- package/dist/sessions-BpNk9YjU.cjs +431 -0
- package/dist/sessions-BpNk9YjU.cjs.map +1 -0
- package/dist/sessions-CkCQikpl.cjs +444 -0
- package/dist/sessions-CkCQikpl.cjs.map +1 -0
- package/dist/sessions-Cy-_zIh6.js +315 -0
- package/dist/sessions-Cy-_zIh6.js.map +1 -0
- package/dist/sessions-DZgPENb6.cjs +434 -0
- package/dist/sessions-DZgPENb6.cjs.map +1 -0
- package/dist/sessions-_HBb3nIW.cjs +495 -0
- package/dist/sessions-_HBb3nIW.cjs.map +1 -0
- package/dist/sessions-tBeR9gKG.js +308 -0
- package/dist/sessions-tBeR9gKG.js.map +1 -0
- package/dist/utils/copilot.d.ts +27 -0
- package/dist/utils/copilot.d.ts.map +1 -0
- package/dist/utils/git.d.ts +35 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/gitignore.d.ts +5 -0
- package/dist/utils/gitignore.d.ts.map +1 -0
- package/dist/utils/logger.d.ts +14 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/sessions.d.ts +48 -0
- package/dist/utils/sessions.d.ts.map +1 -0
- package/package.json +79 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
const require_cli = require('./cli.cjs');
|
|
2
|
+
let node_fs = require("node:fs");
|
|
3
|
+
let node_path = require("node:path");
|
|
4
|
+
|
|
5
|
+
//#region src/constants.ts
|
|
6
|
+
const KNOWN_AGENT_FILES = [
|
|
7
|
+
{
|
|
8
|
+
path: "CLAUDE.md",
|
|
9
|
+
label: "CLAUDE.md (Claude Code)",
|
|
10
|
+
agent: "Claude Code"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
path: ".github/copilot-instructions.md",
|
|
14
|
+
label: ".github/copilot-instructions.md (GitHub Copilot)",
|
|
15
|
+
agent: "GitHub Copilot"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
path: "copilot-instructions.md",
|
|
19
|
+
label: "copilot-instructions.md (GitHub Copilot)",
|
|
20
|
+
agent: "GitHub Copilot"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
path: "AGENTS.md",
|
|
24
|
+
label: "AGENTS.md (Generic)",
|
|
25
|
+
agent: "Generic"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
path: "agents.md",
|
|
29
|
+
label: "agents.md (Generic)",
|
|
30
|
+
agent: "Generic"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
path: ".cursorrules",
|
|
34
|
+
label: ".cursorrules (Cursor)",
|
|
35
|
+
agent: "Cursor"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
path: ".cursor/rules",
|
|
39
|
+
label: ".cursor/rules (Cursor)",
|
|
40
|
+
agent: "Cursor"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
path: ".windsurfrules",
|
|
44
|
+
label: ".windsurfrules (Windsurf)",
|
|
45
|
+
agent: "Windsurf"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
path: ".clinerules",
|
|
49
|
+
label: ".clinerules (Cline)",
|
|
50
|
+
agent: "Cline"
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
const CONFIG_FILE_NAME = ".agent-watch.json";
|
|
54
|
+
const SUPPORTED_HOOKS = ["commit", "push"];
|
|
55
|
+
const SUPPORTED_AI_AGENTS = [{
|
|
56
|
+
value: "github-copilot-cli",
|
|
57
|
+
name: "GitHub Copilot CLI"
|
|
58
|
+
}];
|
|
59
|
+
const FILE_SELECTION_PAGE_SIZE = 10;
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
//#region src/config.ts
|
|
63
|
+
/**
|
|
64
|
+
* Load the agent-watch configuration from the project root.
|
|
65
|
+
* Returns null if no config file exists or is invalid.
|
|
66
|
+
*/
|
|
67
|
+
function loadConfig(projectRoot) {
|
|
68
|
+
const configPath = (0, node_path.join)(projectRoot, CONFIG_FILE_NAME);
|
|
69
|
+
if (!(0, node_fs.existsSync)(configPath)) return null;
|
|
70
|
+
try {
|
|
71
|
+
const raw = (0, node_fs.readFileSync)(configPath, "utf-8");
|
|
72
|
+
return JSON.parse(raw);
|
|
73
|
+
} catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Save the agent-watch configuration to the project root.
|
|
79
|
+
*/
|
|
80
|
+
function saveConfig(projectRoot, config) {
|
|
81
|
+
(0, node_fs.writeFileSync)((0, node_path.join)(projectRoot, CONFIG_FILE_NAME), `${JSON.stringify(config, null, 2)}\n`, "utf-8");
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Create a default configuration with optional overrides.
|
|
85
|
+
*/
|
|
86
|
+
function createDefaultConfig(overrides = {}) {
|
|
87
|
+
return {
|
|
88
|
+
version: 1,
|
|
89
|
+
agentFiles: [],
|
|
90
|
+
watchFileChanges: true,
|
|
91
|
+
includeChatSession: true,
|
|
92
|
+
hookTrigger: "commit",
|
|
93
|
+
agents: [],
|
|
94
|
+
...overrides
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/detect.ts
|
|
100
|
+
/**
|
|
101
|
+
* Scan the project root for known agent configuration files.
|
|
102
|
+
* Returns information about each known file pattern including whether it exists.
|
|
103
|
+
*/
|
|
104
|
+
function detectAgentFiles(projectRoot) {
|
|
105
|
+
return KNOWN_AGENT_FILES.map((pattern) => {
|
|
106
|
+
const absolutePath = (0, node_path.join)(projectRoot, pattern.path);
|
|
107
|
+
return {
|
|
108
|
+
pattern,
|
|
109
|
+
exists: (0, node_fs.existsSync)(absolutePath),
|
|
110
|
+
absolutePath
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Get only the agent files that exist in the project.
|
|
116
|
+
*/
|
|
117
|
+
function getExistingAgentFiles(projectRoot) {
|
|
118
|
+
return detectAgentFiles(projectRoot).filter((f) => f.exists);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
//#endregion
|
|
122
|
+
Object.defineProperty(exports, 'CONFIG_FILE_NAME', {
|
|
123
|
+
enumerable: true,
|
|
124
|
+
get: function () {
|
|
125
|
+
return CONFIG_FILE_NAME;
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
Object.defineProperty(exports, 'FILE_SELECTION_PAGE_SIZE', {
|
|
129
|
+
enumerable: true,
|
|
130
|
+
get: function () {
|
|
131
|
+
return FILE_SELECTION_PAGE_SIZE;
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
Object.defineProperty(exports, 'KNOWN_AGENT_FILES', {
|
|
135
|
+
enumerable: true,
|
|
136
|
+
get: function () {
|
|
137
|
+
return KNOWN_AGENT_FILES;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(exports, 'SUPPORTED_AI_AGENTS', {
|
|
141
|
+
enumerable: true,
|
|
142
|
+
get: function () {
|
|
143
|
+
return SUPPORTED_AI_AGENTS;
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
Object.defineProperty(exports, 'SUPPORTED_HOOKS', {
|
|
147
|
+
enumerable: true,
|
|
148
|
+
get: function () {
|
|
149
|
+
return SUPPORTED_HOOKS;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
Object.defineProperty(exports, 'createDefaultConfig', {
|
|
153
|
+
enumerable: true,
|
|
154
|
+
get: function () {
|
|
155
|
+
return createDefaultConfig;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
Object.defineProperty(exports, 'detectAgentFiles', {
|
|
159
|
+
enumerable: true,
|
|
160
|
+
get: function () {
|
|
161
|
+
return detectAgentFiles;
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
Object.defineProperty(exports, 'getExistingAgentFiles', {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
get: function () {
|
|
167
|
+
return getExistingAgentFiles;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
Object.defineProperty(exports, 'loadConfig', {
|
|
171
|
+
enumerable: true,
|
|
172
|
+
get: function () {
|
|
173
|
+
return loadConfig;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
Object.defineProperty(exports, 'saveConfig', {
|
|
177
|
+
enumerable: true,
|
|
178
|
+
get: function () {
|
|
179
|
+
return saveConfig;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
//# sourceMappingURL=detect-B_DDBj5N.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-B_DDBj5N.cjs","names":[],"sources":["../src/constants.ts","../src/config.ts","../src/detect.ts"],"sourcesContent":["export interface AgentFilePattern {\n\t/** Relative path from project root */\n\tpath: string\n\t/** Human-readable label for display */\n\tlabel: string\n\t/** Which AI agent/tool uses this file */\n\tagent: string\n}\n\nexport const KNOWN_AGENT_FILES: AgentFilePattern[] = [\n\t{ path: \"CLAUDE.md\", label: \"CLAUDE.md (Claude Code)\", agent: \"Claude Code\" },\n\t{\n\t\tpath: \".github/copilot-instructions.md\",\n\t\tlabel: \".github/copilot-instructions.md (GitHub Copilot)\",\n\t\tagent: \"GitHub Copilot\",\n\t},\n\t{ path: \"copilot-instructions.md\", label: \"copilot-instructions.md (GitHub Copilot)\", agent: \"GitHub Copilot\" },\n\t{ path: \"AGENTS.md\", label: \"AGENTS.md (Generic)\", agent: \"Generic\" },\n\t{ path: \"agents.md\", label: \"agents.md (Generic)\", agent: \"Generic\" },\n\t{ path: \".cursorrules\", label: \".cursorrules (Cursor)\", agent: \"Cursor\" },\n\t{ path: \".cursor/rules\", label: \".cursor/rules (Cursor)\", agent: \"Cursor\" },\n\t{ path: \".windsurfrules\", label: \".windsurfrules (Windsurf)\", agent: \"Windsurf\" },\n\t{ path: \".clinerules\", label: \".clinerules (Cline)\", agent: \"Cline\" },\n]\n\nexport const CONFIG_FILE_NAME = \".agent-watch.json\"\n\nexport const SUPPORTED_HOOKS = [\"commit\", \"push\"] as const\nexport type GitHookTrigger = (typeof SUPPORTED_HOOKS)[number]\n\nexport const SUPPORTED_AI_AGENTS = [{ value: \"github-copilot-cli\", name: \"GitHub Copilot CLI\" }] as const\n\n// UI Configuration\nexport const FILE_SELECTION_PAGE_SIZE = 10 // Static scroll limit for file selection\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\"\nimport { join } from \"node:path\"\nimport { CONFIG_FILE_NAME, type GitHookTrigger } from \"./constants.js\"\n\nexport interface AgentWatchConfig {\n\t/** Version of the config schema */\n\tversion: 1\n\t/** Relative paths to the agent files being managed */\n\tagentFiles: string[]\n\t/** Whether to use git commit messages and chat sessions for context (legacy) */\n\tuseGitContext?: boolean\n\t/** Whether to watch for file changes */\n\twatchFileChanges: boolean\n\t/** Whether to include chat session context */\n\tincludeChatSession: boolean\n\t/** Which git hook triggers the update */\n\thookTrigger: GitHookTrigger\n\t/** Which AI agent integrations to configure */\n\tagents: string[]\n}\n\n/**\n * Load the agent-watch configuration from the project root.\n * Returns null if no config file exists or is invalid.\n */\nexport function loadConfig(projectRoot: string): AgentWatchConfig | null {\n\tconst configPath = join(projectRoot, CONFIG_FILE_NAME)\n\tif (!existsSync(configPath)) {\n\t\treturn null\n\t}\n\ttry {\n\t\tconst raw = readFileSync(configPath, \"utf-8\")\n\t\treturn JSON.parse(raw) as AgentWatchConfig\n\t} catch {\n\t\treturn null\n\t}\n}\n\n/**\n * Save the agent-watch configuration to the project root.\n */\nexport function saveConfig(projectRoot: string, config: AgentWatchConfig): void {\n\tconst configPath = join(projectRoot, CONFIG_FILE_NAME)\n\twriteFileSync(configPath, `${JSON.stringify(config, null, 2)}\\n`, \"utf-8\")\n}\n\n/**\n * Create a default configuration with optional overrides.\n */\nexport function createDefaultConfig(overrides: Partial<AgentWatchConfig> = {}): AgentWatchConfig {\n\treturn {\n\t\tversion: 1,\n\t\tagentFiles: [],\n\t\twatchFileChanges: true,\n\t\tincludeChatSession: true,\n\t\thookTrigger: \"commit\",\n\t\tagents: [],\n\t\t...overrides,\n\t}\n}\n","import { existsSync } from \"node:fs\"\nimport { join } from \"node:path\"\nimport { type AgentFilePattern, KNOWN_AGENT_FILES } from \"./constants.js\"\n\nexport interface AgentFileInfo {\n\tpattern: AgentFilePattern\n\texists: boolean\n\tabsolutePath: string\n}\n\n/**\n * Scan the project root for known agent configuration files.\n * Returns information about each known file pattern including whether it exists.\n */\nexport function detectAgentFiles(projectRoot: string): AgentFileInfo[] {\n\treturn KNOWN_AGENT_FILES.map((pattern) => {\n\t\tconst absolutePath = join(projectRoot, pattern.path)\n\t\treturn {\n\t\t\tpattern,\n\t\t\texists: existsSync(absolutePath),\n\t\t\tabsolutePath,\n\t\t}\n\t})\n}\n\n/**\n * Get only the agent files that exist in the project.\n */\nexport function getExistingAgentFiles(projectRoot: string): AgentFileInfo[] {\n\treturn detectAgentFiles(projectRoot).filter((f) => f.exists)\n}\n"],"mappings":";;;;;AASA,MAAa,oBAAwC;CACpD;EAAE,MAAM;EAAa,OAAO;EAA2B,OAAO;EAAe;CAC7E;EACC,MAAM;EACN,OAAO;EACP,OAAO;EACP;CACD;EAAE,MAAM;EAA2B,OAAO;EAA4C,OAAO;EAAkB;CAC/G;EAAE,MAAM;EAAa,OAAO;EAAuB,OAAO;EAAW;CACrE;EAAE,MAAM;EAAa,OAAO;EAAuB,OAAO;EAAW;CACrE;EAAE,MAAM;EAAgB,OAAO;EAAyB,OAAO;EAAU;CACzE;EAAE,MAAM;EAAiB,OAAO;EAA0B,OAAO;EAAU;CAC3E;EAAE,MAAM;EAAkB,OAAO;EAA6B,OAAO;EAAY;CACjF;EAAE,MAAM;EAAe,OAAO;EAAuB,OAAO;EAAS;CACrE;AAED,MAAa,mBAAmB;AAEhC,MAAa,kBAAkB,CAAC,UAAU,OAAO;AAGjD,MAAa,sBAAsB,CAAC;CAAE,OAAO;CAAsB,MAAM;CAAsB,CAAC;AAGhG,MAAa,2BAA2B;;;;;;;;ACRxC,SAAgB,WAAW,aAA8C;CACxE,MAAM,iCAAkB,aAAa,iBAAiB;AACtD,KAAI,yBAAY,WAAW,CAC1B,QAAO;AAER,KAAI;EACH,MAAM,gCAAmB,YAAY,QAAQ;AAC7C,SAAO,KAAK,MAAM,IAAI;SACf;AACP,SAAO;;;;;;AAOT,SAAgB,WAAW,aAAqB,QAAgC;AAE/E,gDADwB,aAAa,iBAAiB,EAC5B,GAAG,KAAK,UAAU,QAAQ,MAAM,EAAE,CAAC,KAAK,QAAQ;;;;;AAM3E,SAAgB,oBAAoB,YAAuC,EAAE,EAAoB;AAChG,QAAO;EACN,SAAS;EACT,YAAY,EAAE;EACd,kBAAkB;EAClB,oBAAoB;EACpB,aAAa;EACb,QAAQ,EAAE;EACV,GAAG;EACH;;;;;;;;;AC5CF,SAAgB,iBAAiB,aAAsC;AACtE,QAAO,kBAAkB,KAAK,YAAY;EACzC,MAAM,mCAAoB,aAAa,QAAQ,KAAK;AACpD,SAAO;GACN;GACA,gCAAmB,aAAa;GAChC;GACA;GACA;;;;;AAMH,SAAgB,sBAAsB,aAAsC;AAC3E,QAAO,iBAAiB,YAAY,CAAC,QAAQ,MAAM,EAAE,OAAO"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
|
|
4
|
+
//#region src/constants.ts
|
|
5
|
+
const KNOWN_AGENT_FILES = [
|
|
6
|
+
{
|
|
7
|
+
path: "CLAUDE.md",
|
|
8
|
+
label: "CLAUDE.md (Claude Code)",
|
|
9
|
+
agent: "Claude Code"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
path: ".github/copilot-instructions.md",
|
|
13
|
+
label: ".github/copilot-instructions.md (GitHub Copilot)",
|
|
14
|
+
agent: "GitHub Copilot"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
path: "copilot-instructions.md",
|
|
18
|
+
label: "copilot-instructions.md (GitHub Copilot)",
|
|
19
|
+
agent: "GitHub Copilot"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
path: "AGENTS.md",
|
|
23
|
+
label: "AGENTS.md (Generic)",
|
|
24
|
+
agent: "Generic"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
path: ".cursorrules",
|
|
28
|
+
label: ".cursorrules (Cursor)",
|
|
29
|
+
agent: "Cursor"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
path: ".cursor/rules",
|
|
33
|
+
label: ".cursor/rules (Cursor)",
|
|
34
|
+
agent: "Cursor"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
path: ".windsurfrules",
|
|
38
|
+
label: ".windsurfrules (Windsurf)",
|
|
39
|
+
agent: "Windsurf"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
path: ".clinerules",
|
|
43
|
+
label: ".clinerules (Cline)",
|
|
44
|
+
agent: "Cline"
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
const CONFIG_FILE_NAME = ".agent-watch.json";
|
|
48
|
+
const SUPPORTED_HOOKS = ["commit", "push"];
|
|
49
|
+
const SUPPORTED_AI_AGENTS = [{
|
|
50
|
+
value: "github-copilot-cli",
|
|
51
|
+
name: "GitHub Copilot CLI"
|
|
52
|
+
}];
|
|
53
|
+
const FILE_SELECTION_PAGE_SIZE = 10;
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/config.ts
|
|
57
|
+
/**
|
|
58
|
+
* Load the agent-watch configuration from the project root.
|
|
59
|
+
* Returns null if no config file exists or is invalid.
|
|
60
|
+
*/
|
|
61
|
+
function loadConfig(projectRoot) {
|
|
62
|
+
const configPath = join(projectRoot, CONFIG_FILE_NAME);
|
|
63
|
+
if (!existsSync(configPath)) return null;
|
|
64
|
+
try {
|
|
65
|
+
const raw = readFileSync(configPath, "utf-8");
|
|
66
|
+
return JSON.parse(raw);
|
|
67
|
+
} catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Save the agent-watch configuration to the project root.
|
|
73
|
+
*/
|
|
74
|
+
function saveConfig(projectRoot, config) {
|
|
75
|
+
writeFileSync(join(projectRoot, CONFIG_FILE_NAME), `${JSON.stringify(config, null, 2)}\n`, "utf-8");
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Create a default configuration with optional overrides.
|
|
79
|
+
*/
|
|
80
|
+
function createDefaultConfig(overrides = {}) {
|
|
81
|
+
return {
|
|
82
|
+
version: 1,
|
|
83
|
+
agentFiles: [],
|
|
84
|
+
watchFileChanges: true,
|
|
85
|
+
includeChatSession: true,
|
|
86
|
+
hookTrigger: "commit",
|
|
87
|
+
agents: [],
|
|
88
|
+
...overrides
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/detect.ts
|
|
94
|
+
/**
|
|
95
|
+
* Scan the project root for known agent configuration files.
|
|
96
|
+
* Returns information about each known file pattern including whether it exists.
|
|
97
|
+
*/
|
|
98
|
+
function detectAgentFiles(projectRoot) {
|
|
99
|
+
return KNOWN_AGENT_FILES.map((pattern) => {
|
|
100
|
+
const absolutePath = join(projectRoot, pattern.path);
|
|
101
|
+
return {
|
|
102
|
+
pattern,
|
|
103
|
+
exists: existsSync(absolutePath),
|
|
104
|
+
absolutePath
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Get only the agent files that exist in the project.
|
|
110
|
+
*/
|
|
111
|
+
function getExistingAgentFiles(projectRoot) {
|
|
112
|
+
return detectAgentFiles(projectRoot).filter((f) => f.exists);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
//#endregion
|
|
116
|
+
export { saveConfig as a, KNOWN_AGENT_FILES as c, loadConfig as i, SUPPORTED_AI_AGENTS as l, getExistingAgentFiles as n, CONFIG_FILE_NAME as o, createDefaultConfig as r, FILE_SELECTION_PAGE_SIZE as s, detectAgentFiles as t, SUPPORTED_HOOKS as u };
|
|
117
|
+
//# sourceMappingURL=detect-CPW1RRIq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-CPW1RRIq.js","names":[],"sources":["../src/constants.ts","../src/config.ts","../src/detect.ts"],"sourcesContent":["export interface AgentFilePattern {\n\t/** Relative path from project root */\n\tpath: string\n\t/** Human-readable label for display */\n\tlabel: string\n\t/** Which AI agent/tool uses this file */\n\tagent: string\n}\n\nexport const KNOWN_AGENT_FILES: AgentFilePattern[] = [\n\t{ path: \"CLAUDE.md\", label: \"CLAUDE.md (Claude Code)\", agent: \"Claude Code\" },\n\t{\n\t\tpath: \".github/copilot-instructions.md\",\n\t\tlabel: \".github/copilot-instructions.md (GitHub Copilot)\",\n\t\tagent: \"GitHub Copilot\",\n\t},\n\t{ path: \"copilot-instructions.md\", label: \"copilot-instructions.md (GitHub Copilot)\", agent: \"GitHub Copilot\" },\n\t{ path: \"AGENTS.md\", label: \"AGENTS.md (Generic)\", agent: \"Generic\" },\n\t{ path: \".cursorrules\", label: \".cursorrules (Cursor)\", agent: \"Cursor\" },\n\t{ path: \".cursor/rules\", label: \".cursor/rules (Cursor)\", agent: \"Cursor\" },\n\t{ path: \".windsurfrules\", label: \".windsurfrules (Windsurf)\", agent: \"Windsurf\" },\n\t{ path: \".clinerules\", label: \".clinerules (Cline)\", agent: \"Cline\" },\n]\n\nexport const CONFIG_FILE_NAME = \".agent-watch.json\"\n\nexport const SUPPORTED_HOOKS = [\"commit\", \"push\"] as const\nexport type GitHookTrigger = (typeof SUPPORTED_HOOKS)[number]\n\nexport const SUPPORTED_AI_AGENTS = [{ value: \"github-copilot-cli\", name: \"GitHub Copilot CLI\" }] as const\n\n// UI Configuration\nexport const FILE_SELECTION_PAGE_SIZE = 10 // Static scroll limit for file selection\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\"\nimport { join } from \"node:path\"\nimport { CONFIG_FILE_NAME, type GitHookTrigger } from \"./constants.js\"\n\nexport interface AgentWatchConfig {\n\t/** Version of the config schema */\n\tversion: 1\n\t/** Relative paths to the agent files being managed */\n\tagentFiles: string[]\n\t/** Whether to use git commit messages and chat sessions for context (legacy) */\n\tuseGitContext?: boolean\n\t/** Whether to watch for file changes */\n\twatchFileChanges: boolean\n\t/** Whether to include chat session context */\n\tincludeChatSession: boolean\n\t/** Which git hook triggers the update */\n\thookTrigger: GitHookTrigger\n\t/** Which AI agent integrations to configure */\n\tagents: string[]\n}\n\n/**\n * Load the agent-watch configuration from the project root.\n * Returns null if no config file exists or is invalid.\n */\nexport function loadConfig(projectRoot: string): AgentWatchConfig | null {\n\tconst configPath = join(projectRoot, CONFIG_FILE_NAME)\n\tif (!existsSync(configPath)) {\n\t\treturn null\n\t}\n\ttry {\n\t\tconst raw = readFileSync(configPath, \"utf-8\")\n\t\treturn JSON.parse(raw) as AgentWatchConfig\n\t} catch {\n\t\treturn null\n\t}\n}\n\n/**\n * Save the agent-watch configuration to the project root.\n */\nexport function saveConfig(projectRoot: string, config: AgentWatchConfig): void {\n\tconst configPath = join(projectRoot, CONFIG_FILE_NAME)\n\twriteFileSync(configPath, `${JSON.stringify(config, null, 2)}\\n`, \"utf-8\")\n}\n\n/**\n * Create a default configuration with optional overrides.\n */\nexport function createDefaultConfig(overrides: Partial<AgentWatchConfig> = {}): AgentWatchConfig {\n\treturn {\n\t\tversion: 1,\n\t\tagentFiles: [],\n\t\twatchFileChanges: true,\n\t\tincludeChatSession: true,\n\t\thookTrigger: \"commit\",\n\t\tagents: [],\n\t\t...overrides,\n\t}\n}\n","import { existsSync } from \"node:fs\"\nimport { join } from \"node:path\"\nimport { type AgentFilePattern, KNOWN_AGENT_FILES } from \"./constants.js\"\n\nexport interface AgentFileInfo {\n\tpattern: AgentFilePattern\n\texists: boolean\n\tabsolutePath: string\n}\n\n/**\n * Scan the project root for known agent configuration files.\n * Returns information about each known file pattern including whether it exists.\n */\nexport function detectAgentFiles(projectRoot: string): AgentFileInfo[] {\n\treturn KNOWN_AGENT_FILES.map((pattern) => {\n\t\tconst absolutePath = join(projectRoot, pattern.path)\n\t\treturn {\n\t\t\tpattern,\n\t\t\texists: existsSync(absolutePath),\n\t\t\tabsolutePath,\n\t\t}\n\t})\n}\n\n/**\n * Get only the agent files that exist in the project.\n */\nexport function getExistingAgentFiles(projectRoot: string): AgentFileInfo[] {\n\treturn detectAgentFiles(projectRoot).filter((f) => f.exists)\n}\n"],"mappings":";;;;AASA,MAAa,oBAAwC;CACpD;EAAE,MAAM;EAAa,OAAO;EAA2B,OAAO;EAAe;CAC7E;EACC,MAAM;EACN,OAAO;EACP,OAAO;EACP;CACD;EAAE,MAAM;EAA2B,OAAO;EAA4C,OAAO;EAAkB;CAC/G;EAAE,MAAM;EAAa,OAAO;EAAuB,OAAO;EAAW;CACrE;EAAE,MAAM;EAAgB,OAAO;EAAyB,OAAO;EAAU;CACzE;EAAE,MAAM;EAAiB,OAAO;EAA0B,OAAO;EAAU;CAC3E;EAAE,MAAM;EAAkB,OAAO;EAA6B,OAAO;EAAY;CACjF;EAAE,MAAM;EAAe,OAAO;EAAuB,OAAO;EAAS;CACrE;AAED,MAAa,mBAAmB;AAEhC,MAAa,kBAAkB,CAAC,UAAU,OAAO;AAGjD,MAAa,sBAAsB,CAAC;CAAE,OAAO;CAAsB,MAAM;CAAsB,CAAC;AAGhG,MAAa,2BAA2B;;;;;;;;ACPxC,SAAgB,WAAW,aAA8C;CACxE,MAAM,aAAa,KAAK,aAAa,iBAAiB;AACtD,KAAI,CAAC,WAAW,WAAW,CAC1B,QAAO;AAER,KAAI;EACH,MAAM,MAAM,aAAa,YAAY,QAAQ;AAC7C,SAAO,KAAK,MAAM,IAAI;SACf;AACP,SAAO;;;;;;AAOT,SAAgB,WAAW,aAAqB,QAAgC;AAE/E,eADmB,KAAK,aAAa,iBAAiB,EAC5B,GAAG,KAAK,UAAU,QAAQ,MAAM,EAAE,CAAC,KAAK,QAAQ;;;;;AAM3E,SAAgB,oBAAoB,YAAuC,EAAE,EAAoB;AAChG,QAAO;EACN,SAAS;EACT,YAAY,EAAE;EACd,kBAAkB;EAClB,oBAAoB;EACpB,aAAa;EACb,QAAQ,EAAE;EACV,GAAG;EACH;;;;;;;;;AC5CF,SAAgB,iBAAiB,aAAsC;AACtE,QAAO,kBAAkB,KAAK,YAAY;EACzC,MAAM,eAAe,KAAK,aAAa,QAAQ,KAAK;AACpD,SAAO;GACN;GACA,QAAQ,WAAW,aAAa;GAChC;GACA;GACA;;;;;AAMH,SAAgB,sBAAsB,aAAsC;AAC3E,QAAO,iBAAiB,YAAY,CAAC,QAAQ,MAAM,EAAE,OAAO"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
const require_cli = require('./cli.cjs');
|
|
2
|
+
let node_fs = require("node:fs");
|
|
3
|
+
let node_path = require("node:path");
|
|
4
|
+
|
|
5
|
+
//#region src/constants.ts
|
|
6
|
+
const KNOWN_AGENT_FILES = [
|
|
7
|
+
{
|
|
8
|
+
path: "CLAUDE.md",
|
|
9
|
+
label: "CLAUDE.md (Claude Code)",
|
|
10
|
+
agent: "Claude Code"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
path: ".github/copilot-instructions.md",
|
|
14
|
+
label: ".github/copilot-instructions.md (GitHub Copilot)",
|
|
15
|
+
agent: "GitHub Copilot"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
path: "copilot-instructions.md",
|
|
19
|
+
label: "copilot-instructions.md (GitHub Copilot)",
|
|
20
|
+
agent: "GitHub Copilot"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
path: "AGENTS.md",
|
|
24
|
+
label: "AGENTS.md (Generic)",
|
|
25
|
+
agent: "Generic"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
path: "agents.md",
|
|
29
|
+
label: "agents.md (Generic)",
|
|
30
|
+
agent: "Generic"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
path: ".cursorrules",
|
|
34
|
+
label: ".cursorrules (Cursor)",
|
|
35
|
+
agent: "Cursor"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
path: ".cursor/rules",
|
|
39
|
+
label: ".cursor/rules (Cursor)",
|
|
40
|
+
agent: "Cursor"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
path: ".windsurfrules",
|
|
44
|
+
label: ".windsurfrules (Windsurf)",
|
|
45
|
+
agent: "Windsurf"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
path: ".clinerules",
|
|
49
|
+
label: ".clinerules (Cline)",
|
|
50
|
+
agent: "Cline"
|
|
51
|
+
}
|
|
52
|
+
];
|
|
53
|
+
const CONFIG_FILE_NAME = ".agent-watch.json";
|
|
54
|
+
const SUPPORTED_HOOKS = ["commit", "push"];
|
|
55
|
+
const SUPPORTED_AI_AGENTS = [{
|
|
56
|
+
value: "github-copilot-cli",
|
|
57
|
+
name: "GitHub Copilot CLI"
|
|
58
|
+
}];
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/config.ts
|
|
62
|
+
/**
|
|
63
|
+
* Load the agent-watch configuration from the project root.
|
|
64
|
+
* Returns null if no config file exists or is invalid.
|
|
65
|
+
*/
|
|
66
|
+
function loadConfig(projectRoot) {
|
|
67
|
+
const configPath = (0, node_path.join)(projectRoot, CONFIG_FILE_NAME);
|
|
68
|
+
if (!(0, node_fs.existsSync)(configPath)) return null;
|
|
69
|
+
try {
|
|
70
|
+
const raw = (0, node_fs.readFileSync)(configPath, "utf-8");
|
|
71
|
+
return JSON.parse(raw);
|
|
72
|
+
} catch {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Save the agent-watch configuration to the project root.
|
|
78
|
+
*/
|
|
79
|
+
function saveConfig(projectRoot, config) {
|
|
80
|
+
(0, node_fs.writeFileSync)((0, node_path.join)(projectRoot, CONFIG_FILE_NAME), `${JSON.stringify(config, null, 2)}\n`, "utf-8");
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Create a default configuration with optional overrides.
|
|
84
|
+
*/
|
|
85
|
+
function createDefaultConfig(overrides = {}) {
|
|
86
|
+
return {
|
|
87
|
+
version: 1,
|
|
88
|
+
agentFiles: [],
|
|
89
|
+
useGitContext: true,
|
|
90
|
+
hookTrigger: "commit",
|
|
91
|
+
agents: [],
|
|
92
|
+
...overrides
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/detect.ts
|
|
98
|
+
/**
|
|
99
|
+
* Scan the project root for known agent configuration files.
|
|
100
|
+
* Returns information about each known file pattern including whether it exists.
|
|
101
|
+
*/
|
|
102
|
+
function detectAgentFiles(projectRoot) {
|
|
103
|
+
return KNOWN_AGENT_FILES.map((pattern) => {
|
|
104
|
+
const absolutePath = (0, node_path.join)(projectRoot, pattern.path);
|
|
105
|
+
return {
|
|
106
|
+
pattern,
|
|
107
|
+
exists: (0, node_fs.existsSync)(absolutePath),
|
|
108
|
+
absolutePath
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Get only the agent files that exist in the project.
|
|
114
|
+
*/
|
|
115
|
+
function getExistingAgentFiles(projectRoot) {
|
|
116
|
+
return detectAgentFiles(projectRoot).filter((f) => f.exists);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
//#endregion
|
|
120
|
+
Object.defineProperty(exports, 'CONFIG_FILE_NAME', {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () {
|
|
123
|
+
return CONFIG_FILE_NAME;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
Object.defineProperty(exports, 'KNOWN_AGENT_FILES', {
|
|
127
|
+
enumerable: true,
|
|
128
|
+
get: function () {
|
|
129
|
+
return KNOWN_AGENT_FILES;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
Object.defineProperty(exports, 'SUPPORTED_AI_AGENTS', {
|
|
133
|
+
enumerable: true,
|
|
134
|
+
get: function () {
|
|
135
|
+
return SUPPORTED_AI_AGENTS;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
Object.defineProperty(exports, 'SUPPORTED_HOOKS', {
|
|
139
|
+
enumerable: true,
|
|
140
|
+
get: function () {
|
|
141
|
+
return SUPPORTED_HOOKS;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
Object.defineProperty(exports, 'createDefaultConfig', {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
get: function () {
|
|
147
|
+
return createDefaultConfig;
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
Object.defineProperty(exports, 'detectAgentFiles', {
|
|
151
|
+
enumerable: true,
|
|
152
|
+
get: function () {
|
|
153
|
+
return detectAgentFiles;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
Object.defineProperty(exports, 'getExistingAgentFiles', {
|
|
157
|
+
enumerable: true,
|
|
158
|
+
get: function () {
|
|
159
|
+
return getExistingAgentFiles;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
Object.defineProperty(exports, 'loadConfig', {
|
|
163
|
+
enumerable: true,
|
|
164
|
+
get: function () {
|
|
165
|
+
return loadConfig;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
Object.defineProperty(exports, 'saveConfig', {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
get: function () {
|
|
171
|
+
return saveConfig;
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
//# sourceMappingURL=detect-Dii2e4wf.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-Dii2e4wf.cjs","names":[],"sources":["../src/constants.ts","../src/config.ts","../src/detect.ts"],"sourcesContent":["export interface AgentFilePattern {\n\t/** Relative path from project root */\n\tpath: string\n\t/** Human-readable label for display */\n\tlabel: string\n\t/** Which AI agent/tool uses this file */\n\tagent: string\n}\n\nexport const KNOWN_AGENT_FILES: AgentFilePattern[] = [\n\t{ path: \"CLAUDE.md\", label: \"CLAUDE.md (Claude Code)\", agent: \"Claude Code\" },\n\t{\n\t\tpath: \".github/copilot-instructions.md\",\n\t\tlabel: \".github/copilot-instructions.md (GitHub Copilot)\",\n\t\tagent: \"GitHub Copilot\",\n\t},\n\t{ path: \"copilot-instructions.md\", label: \"copilot-instructions.md (GitHub Copilot)\", agent: \"GitHub Copilot\" },\n\t{ path: \"AGENTS.md\", label: \"AGENTS.md (Generic)\", agent: \"Generic\" },\n\t{ path: \"agents.md\", label: \"agents.md (Generic)\", agent: \"Generic\" },\n\t{ path: \".cursorrules\", label: \".cursorrules (Cursor)\", agent: \"Cursor\" },\n\t{ path: \".cursor/rules\", label: \".cursor/rules (Cursor)\", agent: \"Cursor\" },\n\t{ path: \".windsurfrules\", label: \".windsurfrules (Windsurf)\", agent: \"Windsurf\" },\n\t{ path: \".clinerules\", label: \".clinerules (Cline)\", agent: \"Cline\" },\n]\n\nexport const CONFIG_FILE_NAME = \".agent-watch.json\"\n\nexport const SUPPORTED_HOOKS = [\"commit\", \"push\"] as const\nexport type GitHookTrigger = (typeof SUPPORTED_HOOKS)[number]\n\nexport const SUPPORTED_AI_AGENTS = [{ value: \"github-copilot-cli\", name: \"GitHub Copilot CLI\" }] as const\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\"\nimport { join } from \"node:path\"\nimport { CONFIG_FILE_NAME, type GitHookTrigger } from \"./constants.js\"\n\nexport interface AgentWatchConfig {\n\t/** Version of the config schema */\n\tversion: 1\n\t/** Relative paths to the agent files being managed */\n\tagentFiles: string[]\n\t/** Whether to use git commit messages and chat sessions for context */\n\tuseGitContext: boolean\n\t/** Which git hook triggers the update */\n\thookTrigger: GitHookTrigger\n\t/** Which AI agent integrations to configure */\n\tagents: string[]\n}\n\n/**\n * Load the agent-watch configuration from the project root.\n * Returns null if no config file exists or is invalid.\n */\nexport function loadConfig(projectRoot: string): AgentWatchConfig | null {\n\tconst configPath = join(projectRoot, CONFIG_FILE_NAME)\n\tif (!existsSync(configPath)) {\n\t\treturn null\n\t}\n\ttry {\n\t\tconst raw = readFileSync(configPath, \"utf-8\")\n\t\treturn JSON.parse(raw) as AgentWatchConfig\n\t} catch {\n\t\treturn null\n\t}\n}\n\n/**\n * Save the agent-watch configuration to the project root.\n */\nexport function saveConfig(projectRoot: string, config: AgentWatchConfig): void {\n\tconst configPath = join(projectRoot, CONFIG_FILE_NAME)\n\twriteFileSync(configPath, `${JSON.stringify(config, null, 2)}\\n`, \"utf-8\")\n}\n\n/**\n * Create a default configuration with optional overrides.\n */\nexport function createDefaultConfig(overrides: Partial<AgentWatchConfig> = {}): AgentWatchConfig {\n\treturn {\n\t\tversion: 1,\n\t\tagentFiles: [],\n\t\tuseGitContext: true,\n\t\thookTrigger: \"commit\",\n\t\tagents: [],\n\t\t...overrides,\n\t}\n}\n","import { existsSync } from \"node:fs\"\nimport { join } from \"node:path\"\nimport { type AgentFilePattern, KNOWN_AGENT_FILES } from \"./constants.js\"\n\nexport interface AgentFileInfo {\n\tpattern: AgentFilePattern\n\texists: boolean\n\tabsolutePath: string\n}\n\n/**\n * Scan the project root for known agent configuration files.\n * Returns information about each known file pattern including whether it exists.\n */\nexport function detectAgentFiles(projectRoot: string): AgentFileInfo[] {\n\treturn KNOWN_AGENT_FILES.map((pattern) => {\n\t\tconst absolutePath = join(projectRoot, pattern.path)\n\t\treturn {\n\t\t\tpattern,\n\t\t\texists: existsSync(absolutePath),\n\t\t\tabsolutePath,\n\t\t}\n\t})\n}\n\n/**\n * Get only the agent files that exist in the project.\n */\nexport function getExistingAgentFiles(projectRoot: string): AgentFileInfo[] {\n\treturn detectAgentFiles(projectRoot).filter((f) => f.exists)\n}\n"],"mappings":";;;;;AASA,MAAa,oBAAwC;CACpD;EAAE,MAAM;EAAa,OAAO;EAA2B,OAAO;EAAe;CAC7E;EACC,MAAM;EACN,OAAO;EACP,OAAO;EACP;CACD;EAAE,MAAM;EAA2B,OAAO;EAA4C,OAAO;EAAkB;CAC/G;EAAE,MAAM;EAAa,OAAO;EAAuB,OAAO;EAAW;CACrE;EAAE,MAAM;EAAa,OAAO;EAAuB,OAAO;EAAW;CACrE;EAAE,MAAM;EAAgB,OAAO;EAAyB,OAAO;EAAU;CACzE;EAAE,MAAM;EAAiB,OAAO;EAA0B,OAAO;EAAU;CAC3E;EAAE,MAAM;EAAkB,OAAO;EAA6B,OAAO;EAAY;CACjF;EAAE,MAAM;EAAe,OAAO;EAAuB,OAAO;EAAS;CACrE;AAED,MAAa,mBAAmB;AAEhC,MAAa,kBAAkB,CAAC,UAAU,OAAO;AAGjD,MAAa,sBAAsB,CAAC;CAAE,OAAO;CAAsB,MAAM;CAAsB,CAAC;;;;;;;;ACThG,SAAgB,WAAW,aAA8C;CACxE,MAAM,iCAAkB,aAAa,iBAAiB;AACtD,KAAI,yBAAY,WAAW,CAC1B,QAAO;AAER,KAAI;EACH,MAAM,gCAAmB,YAAY,QAAQ;AAC7C,SAAO,KAAK,MAAM,IAAI;SACf;AACP,SAAO;;;;;;AAOT,SAAgB,WAAW,aAAqB,QAAgC;AAE/E,gDADwB,aAAa,iBAAiB,EAC5B,GAAG,KAAK,UAAU,QAAQ,MAAM,EAAE,CAAC,KAAK,QAAQ;;;;;AAM3E,SAAgB,oBAAoB,YAAuC,EAAE,EAAoB;AAChG,QAAO;EACN,SAAS;EACT,YAAY,EAAE;EACd,eAAe;EACf,aAAa;EACb,QAAQ,EAAE;EACV,GAAG;EACH;;;;;;;;;ACvCF,SAAgB,iBAAiB,aAAsC;AACtE,QAAO,kBAAkB,KAAK,YAAY;EACzC,MAAM,mCAAoB,aAAa,QAAQ,KAAK;AACpD,SAAO;GACN;GACA,gCAAmB,aAAa;GAChC;GACA;GACA;;;;;AAMH,SAAgB,sBAAsB,aAAsC;AAC3E,QAAO,iBAAiB,YAAY,CAAC,QAAQ,MAAM,EAAE,OAAO"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
|
|
4
|
+
//#region src/constants.ts
|
|
5
|
+
const KNOWN_AGENT_FILES = [
|
|
6
|
+
{
|
|
7
|
+
path: "CLAUDE.md",
|
|
8
|
+
label: "CLAUDE.md (Claude Code)",
|
|
9
|
+
agent: "Claude Code"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
path: ".github/copilot-instructions.md",
|
|
13
|
+
label: ".github/copilot-instructions.md (GitHub Copilot)",
|
|
14
|
+
agent: "GitHub Copilot"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
path: "copilot-instructions.md",
|
|
18
|
+
label: "copilot-instructions.md (GitHub Copilot)",
|
|
19
|
+
agent: "GitHub Copilot"
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
path: "AGENTS.md",
|
|
23
|
+
label: "AGENTS.md (Generic)",
|
|
24
|
+
agent: "Generic"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
path: "agents.md",
|
|
28
|
+
label: "agents.md (Generic)",
|
|
29
|
+
agent: "Generic"
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
path: ".cursorrules",
|
|
33
|
+
label: ".cursorrules (Cursor)",
|
|
34
|
+
agent: "Cursor"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
path: ".cursor/rules",
|
|
38
|
+
label: ".cursor/rules (Cursor)",
|
|
39
|
+
agent: "Cursor"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
path: ".windsurfrules",
|
|
43
|
+
label: ".windsurfrules (Windsurf)",
|
|
44
|
+
agent: "Windsurf"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
path: ".clinerules",
|
|
48
|
+
label: ".clinerules (Cline)",
|
|
49
|
+
agent: "Cline"
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
const CONFIG_FILE_NAME = ".agent-watch.json";
|
|
53
|
+
const SUPPORTED_HOOKS = ["commit", "push"];
|
|
54
|
+
const SUPPORTED_AI_AGENTS = [{
|
|
55
|
+
value: "github-copilot-cli",
|
|
56
|
+
name: "GitHub Copilot CLI"
|
|
57
|
+
}];
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
//#region src/config.ts
|
|
61
|
+
/**
|
|
62
|
+
* Load the agent-watch configuration from the project root.
|
|
63
|
+
* Returns null if no config file exists or is invalid.
|
|
64
|
+
*/
|
|
65
|
+
function loadConfig(projectRoot) {
|
|
66
|
+
const configPath = join(projectRoot, CONFIG_FILE_NAME);
|
|
67
|
+
if (!existsSync(configPath)) return null;
|
|
68
|
+
try {
|
|
69
|
+
const raw = readFileSync(configPath, "utf-8");
|
|
70
|
+
return JSON.parse(raw);
|
|
71
|
+
} catch {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Save the agent-watch configuration to the project root.
|
|
77
|
+
*/
|
|
78
|
+
function saveConfig(projectRoot, config) {
|
|
79
|
+
writeFileSync(join(projectRoot, CONFIG_FILE_NAME), `${JSON.stringify(config, null, 2)}\n`, "utf-8");
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Create a default configuration with optional overrides.
|
|
83
|
+
*/
|
|
84
|
+
function createDefaultConfig(overrides = {}) {
|
|
85
|
+
return {
|
|
86
|
+
version: 1,
|
|
87
|
+
agentFiles: [],
|
|
88
|
+
useGitContext: true,
|
|
89
|
+
hookTrigger: "commit",
|
|
90
|
+
agents: [],
|
|
91
|
+
...overrides
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/detect.ts
|
|
97
|
+
/**
|
|
98
|
+
* Scan the project root for known agent configuration files.
|
|
99
|
+
* Returns information about each known file pattern including whether it exists.
|
|
100
|
+
*/
|
|
101
|
+
function detectAgentFiles(projectRoot) {
|
|
102
|
+
return KNOWN_AGENT_FILES.map((pattern) => {
|
|
103
|
+
const absolutePath = join(projectRoot, pattern.path);
|
|
104
|
+
return {
|
|
105
|
+
pattern,
|
|
106
|
+
exists: existsSync(absolutePath),
|
|
107
|
+
absolutePath
|
|
108
|
+
};
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Get only the agent files that exist in the project.
|
|
113
|
+
*/
|
|
114
|
+
function getExistingAgentFiles(projectRoot) {
|
|
115
|
+
return detectAgentFiles(projectRoot).filter((f) => f.exists);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
export { saveConfig as a, SUPPORTED_AI_AGENTS as c, loadConfig as i, SUPPORTED_HOOKS as l, getExistingAgentFiles as n, CONFIG_FILE_NAME as o, createDefaultConfig as r, KNOWN_AGENT_FILES as s, detectAgentFiles as t };
|
|
120
|
+
//# sourceMappingURL=detect-Pkaqn3YG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-Pkaqn3YG.js","names":[],"sources":["../src/constants.ts","../src/config.ts","../src/detect.ts"],"sourcesContent":["export interface AgentFilePattern {\n\t/** Relative path from project root */\n\tpath: string\n\t/** Human-readable label for display */\n\tlabel: string\n\t/** Which AI agent/tool uses this file */\n\tagent: string\n}\n\nexport const KNOWN_AGENT_FILES: AgentFilePattern[] = [\n\t{ path: \"CLAUDE.md\", label: \"CLAUDE.md (Claude Code)\", agent: \"Claude Code\" },\n\t{\n\t\tpath: \".github/copilot-instructions.md\",\n\t\tlabel: \".github/copilot-instructions.md (GitHub Copilot)\",\n\t\tagent: \"GitHub Copilot\",\n\t},\n\t{ path: \"copilot-instructions.md\", label: \"copilot-instructions.md (GitHub Copilot)\", agent: \"GitHub Copilot\" },\n\t{ path: \"AGENTS.md\", label: \"AGENTS.md (Generic)\", agent: \"Generic\" },\n\t{ path: \"agents.md\", label: \"agents.md (Generic)\", agent: \"Generic\" },\n\t{ path: \".cursorrules\", label: \".cursorrules (Cursor)\", agent: \"Cursor\" },\n\t{ path: \".cursor/rules\", label: \".cursor/rules (Cursor)\", agent: \"Cursor\" },\n\t{ path: \".windsurfrules\", label: \".windsurfrules (Windsurf)\", agent: \"Windsurf\" },\n\t{ path: \".clinerules\", label: \".clinerules (Cline)\", agent: \"Cline\" },\n]\n\nexport const CONFIG_FILE_NAME = \".agent-watch.json\"\n\nexport const SUPPORTED_HOOKS = [\"commit\", \"push\"] as const\nexport type GitHookTrigger = (typeof SUPPORTED_HOOKS)[number]\n\nexport const SUPPORTED_AI_AGENTS = [{ value: \"github-copilot-cli\", name: \"GitHub Copilot CLI\" }] as const\n","import { existsSync, readFileSync, writeFileSync } from \"node:fs\"\nimport { join } from \"node:path\"\nimport { CONFIG_FILE_NAME, type GitHookTrigger } from \"./constants.js\"\n\nexport interface AgentWatchConfig {\n\t/** Version of the config schema */\n\tversion: 1\n\t/** Relative paths to the agent files being managed */\n\tagentFiles: string[]\n\t/** Whether to use git commit messages and chat sessions for context */\n\tuseGitContext: boolean\n\t/** Which git hook triggers the update */\n\thookTrigger: GitHookTrigger\n\t/** Which AI agent integrations to configure */\n\tagents: string[]\n}\n\n/**\n * Load the agent-watch configuration from the project root.\n * Returns null if no config file exists or is invalid.\n */\nexport function loadConfig(projectRoot: string): AgentWatchConfig | null {\n\tconst configPath = join(projectRoot, CONFIG_FILE_NAME)\n\tif (!existsSync(configPath)) {\n\t\treturn null\n\t}\n\ttry {\n\t\tconst raw = readFileSync(configPath, \"utf-8\")\n\t\treturn JSON.parse(raw) as AgentWatchConfig\n\t} catch {\n\t\treturn null\n\t}\n}\n\n/**\n * Save the agent-watch configuration to the project root.\n */\nexport function saveConfig(projectRoot: string, config: AgentWatchConfig): void {\n\tconst configPath = join(projectRoot, CONFIG_FILE_NAME)\n\twriteFileSync(configPath, `${JSON.stringify(config, null, 2)}\\n`, \"utf-8\")\n}\n\n/**\n * Create a default configuration with optional overrides.\n */\nexport function createDefaultConfig(overrides: Partial<AgentWatchConfig> = {}): AgentWatchConfig {\n\treturn {\n\t\tversion: 1,\n\t\tagentFiles: [],\n\t\tuseGitContext: true,\n\t\thookTrigger: \"commit\",\n\t\tagents: [],\n\t\t...overrides,\n\t}\n}\n","import { existsSync } from \"node:fs\"\nimport { join } from \"node:path\"\nimport { type AgentFilePattern, KNOWN_AGENT_FILES } from \"./constants.js\"\n\nexport interface AgentFileInfo {\n\tpattern: AgentFilePattern\n\texists: boolean\n\tabsolutePath: string\n}\n\n/**\n * Scan the project root for known agent configuration files.\n * Returns information about each known file pattern including whether it exists.\n */\nexport function detectAgentFiles(projectRoot: string): AgentFileInfo[] {\n\treturn KNOWN_AGENT_FILES.map((pattern) => {\n\t\tconst absolutePath = join(projectRoot, pattern.path)\n\t\treturn {\n\t\t\tpattern,\n\t\t\texists: existsSync(absolutePath),\n\t\t\tabsolutePath,\n\t\t}\n\t})\n}\n\n/**\n * Get only the agent files that exist in the project.\n */\nexport function getExistingAgentFiles(projectRoot: string): AgentFileInfo[] {\n\treturn detectAgentFiles(projectRoot).filter((f) => f.exists)\n}\n"],"mappings":";;;;AASA,MAAa,oBAAwC;CACpD;EAAE,MAAM;EAAa,OAAO;EAA2B,OAAO;EAAe;CAC7E;EACC,MAAM;EACN,OAAO;EACP,OAAO;EACP;CACD;EAAE,MAAM;EAA2B,OAAO;EAA4C,OAAO;EAAkB;CAC/G;EAAE,MAAM;EAAa,OAAO;EAAuB,OAAO;EAAW;CACrE;EAAE,MAAM;EAAa,OAAO;EAAuB,OAAO;EAAW;CACrE;EAAE,MAAM;EAAgB,OAAO;EAAyB,OAAO;EAAU;CACzE;EAAE,MAAM;EAAiB,OAAO;EAA0B,OAAO;EAAU;CAC3E;EAAE,MAAM;EAAkB,OAAO;EAA6B,OAAO;EAAY;CACjF;EAAE,MAAM;EAAe,OAAO;EAAuB,OAAO;EAAS;CACrE;AAED,MAAa,mBAAmB;AAEhC,MAAa,kBAAkB,CAAC,UAAU,OAAO;AAGjD,MAAa,sBAAsB,CAAC;CAAE,OAAO;CAAsB,MAAM;CAAsB,CAAC;;;;;;;;ACThG,SAAgB,WAAW,aAA8C;CACxE,MAAM,aAAa,KAAK,aAAa,iBAAiB;AACtD,KAAI,CAAC,WAAW,WAAW,CAC1B,QAAO;AAER,KAAI;EACH,MAAM,MAAM,aAAa,YAAY,QAAQ;AAC7C,SAAO,KAAK,MAAM,IAAI;SACf;AACP,SAAO;;;;;;AAOT,SAAgB,WAAW,aAAqB,QAAgC;AAE/E,eADmB,KAAK,aAAa,iBAAiB,EAC5B,GAAG,KAAK,UAAU,QAAQ,MAAM,EAAE,CAAC,KAAK,QAAQ;;;;;AAM3E,SAAgB,oBAAoB,YAAuC,EAAE,EAAoB;AAChG,QAAO;EACN,SAAS;EACT,YAAY,EAAE;EACd,eAAe;EACf,aAAa;EACb,QAAQ,EAAE;EACV,GAAG;EACH;;;;;;;;;ACvCF,SAAgB,iBAAiB,aAAsC;AACtE,QAAO,kBAAkB,KAAK,YAAY;EACzC,MAAM,eAAe,KAAK,aAAa,QAAQ,KAAK;AACpD,SAAO;GACN;GACA,QAAQ,WAAW,aAAa;GAChC;GACA;GACA;;;;;AAMH,SAAgB,sBAAsB,aAAsC;AAC3E,QAAO,iBAAiB,YAAY,CAAC,QAAQ,MAAM,EAAE,OAAO"}
|
package/dist/detect.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type AgentFilePattern } from "./constants.js";
|
|
2
|
+
export interface AgentFileInfo {
|
|
3
|
+
pattern: AgentFilePattern;
|
|
4
|
+
exists: boolean;
|
|
5
|
+
absolutePath: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Scan the project root for known agent configuration files.
|
|
9
|
+
* Returns information about each known file pattern including whether it exists.
|
|
10
|
+
*/
|
|
11
|
+
export declare function detectAgentFiles(projectRoot: string): AgentFileInfo[];
|
|
12
|
+
/**
|
|
13
|
+
* Get only the agent files that exist in the project.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getExistingAgentFiles(projectRoot: string): AgentFileInfo[];
|
|
16
|
+
//# sourceMappingURL=detect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect.d.ts","sourceRoot":"","sources":["../src/detect.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gBAAgB,EAAqB,MAAM,gBAAgB,CAAA;AAEzE,MAAM,WAAW,aAAa;IAC7B,OAAO,EAAE,gBAAgB,CAAA;IACzB,MAAM,EAAE,OAAO,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;CACpB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,EAAE,CASrE;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,EAAE,CAE1E"}
|
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GitHookTrigger } from "./constants.js";
|
|
2
|
+
export interface HookInstallResult {
|
|
3
|
+
success: boolean;
|
|
4
|
+
message: string;
|
|
5
|
+
method: "direct" | "lefthook" | "husky" | "manual";
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Install the agent-watch hook into the git hooks directory.
|
|
9
|
+
* If a hook file already exists, appends our section.
|
|
10
|
+
* If lefthook or husky is detected, provides instructions instead.
|
|
11
|
+
*/
|
|
12
|
+
export declare function installGitHook(projectRoot: string, gitRoot: string, trigger: GitHookTrigger): HookInstallResult;
|
|
13
|
+
//# sourceMappingURL=hooks.d.ts.map
|