x7-code-line 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/src/install.js CHANGED
@@ -1,268 +1,276 @@
1
- "use strict";
2
-
1
+ "use strict";
2
+
3
3
  const fs = require("node:fs");
4
4
  const path = require("node:path");
5
- const { CACHE_DIR_NAME, ensureCacheFiles, readProjects, writeProjects } = require("./cache");
6
-
7
- const PACKAGE_ROOT = path.resolve(__dirname, "..");
8
-
9
- function install(options = {}) {
10
- const pathBaseDir = path.resolve(options.pathBaseDir || process.env.INIT_CWD || process.cwd());
11
- const config = readConfig(options.configPath || process.env.X7_CODE_LINE_CONFIG);
12
- const targetDirs = normalizeTargetDirs(options.targetDirs, config, {
13
- relativePaths: Boolean(options.relativePaths || process.env.X7_CODE_LINE_RELATIVE_PATHS === "1"),
14
- pathBaseDir
15
- });
16
- const cacheBaseDir = path.resolve(options.cacheBaseDir || pathBaseDir);
17
- const validatedTargets = validateTargets(targetDirs, config);
18
-
19
- installCurrentProjectFiles(cacheBaseDir);
20
- for (const target of validatedTargets) {
21
- installGitHooksInto(target, cacheBaseDir);
22
- }
23
- writeProjects(cacheBaseDir, validatedTargets.map((target) => target.targetDir));
24
-
25
- return validatedTargets.map((target) => target.targetDir);
26
- }
27
-
28
- function installFromPostinstall() {
29
- const envDirs = splitList(process.env.X7_CODE_LINE_DIRS);
30
-
31
- return install({
32
- configPath: process.env.X7_CODE_LINE_CONFIG,
33
- targetDirs: envDirs,
34
- relativePaths: process.env.X7_CODE_LINE_RELATIVE_PATHS === "1"
35
- });
36
- }
37
-
38
- function addDirs(options = {}) {
39
- const explicitDirs = Array.isArray(options.targetDirs) ? options.targetDirs.map((dir) => String(dir || "").trim()).filter(Boolean) : [];
40
- if (explicitDirs.length === 0) {
41
- throw new Error("addDir requires at least one --dir value");
42
- }
43
-
44
- const pathBaseDir = path.resolve(options.pathBaseDir || process.env.INIT_CWD || process.cwd());
45
- const config = readConfig(options.configPath || process.env.X7_CODE_LINE_CONFIG);
46
- const targetDirs = normalizeTargetDirs(explicitDirs, config, {
47
- relativePaths: Boolean(options.relativePaths || process.env.X7_CODE_LINE_RELATIVE_PATHS === "1"),
48
- pathBaseDir
49
- });
50
- const cacheBaseDir = path.resolve(options.cacheBaseDir || pathBaseDir);
51
- assertInstalledBase(cacheBaseDir);
52
-
53
- const validatedTargets = validateTargets(targetDirs, config);
54
- for (const target of validatedTargets) {
55
- installGitHooksInto(target, cacheBaseDir);
56
- }
57
-
58
- const mergedProjects = [...new Set([...readProjects(cacheBaseDir), ...validatedTargets.map((target) => target.targetDir)])];
59
- writeProjects(cacheBaseDir, mergedProjects);
60
-
61
- return validatedTargets.map((target) => target.targetDir);
62
- }
63
-
5
+ const { CACHE_DIR_NAME, ensureCacheFiles, readProjects, writeBasePointer, writeProjects } = require("./cache");
6
+
7
+ const PACKAGE_ROOT = path.resolve(__dirname, "..");
8
+
9
+ function install(options = {}) {
10
+ const pathBaseDir = path.resolve(options.pathBaseDir || process.env.INIT_CWD || process.cwd());
11
+ const config = readConfig(options.configPath || process.env.X7_CODE_LINE_CONFIG);
12
+ const targetDirs = normalizeTargetDirs(options.targetDirs, config, {
13
+ relativePaths: Boolean(options.relativePaths || process.env.X7_CODE_LINE_RELATIVE_PATHS === "1"),
14
+ pathBaseDir
15
+ });
16
+ const cacheBaseDir = path.resolve(options.cacheBaseDir || pathBaseDir);
17
+ const validatedTargets = validateTargets(targetDirs, config);
18
+
19
+ installCurrentProjectFiles(cacheBaseDir);
20
+ for (const target of validatedTargets) {
21
+ installGitHooksInto(target, cacheBaseDir);
22
+ }
23
+ writeProjects(cacheBaseDir, validatedTargets.map((target) => target.targetDir));
24
+
25
+ return validatedTargets.map((target) => target.targetDir);
26
+ }
27
+
28
+ function installFromPostinstall() {
29
+ const envDirs = splitList(process.env.X7_CODE_LINE_DIRS);
30
+ const configPath = process.env.X7_CODE_LINE_CONFIG;
31
+ const config = readConfig(configPath);
32
+ const configuredDirs = Array.isArray(config.dirs) ? config.dirs.map((dir) => String(dir || "").trim()).filter(Boolean) : [];
33
+
34
+ if (envDirs.length === 0 && configuredDirs.length === 0) {
35
+ return [];
36
+ }
37
+
38
+ return install({
39
+ configPath,
40
+ targetDirs: envDirs,
41
+ relativePaths: process.env.X7_CODE_LINE_RELATIVE_PATHS === "1"
42
+ });
43
+ }
44
+
45
+ function addDirs(options = {}) {
46
+ const explicitDirs = Array.isArray(options.targetDirs) ? options.targetDirs.map((dir) => String(dir || "").trim()).filter(Boolean) : [];
47
+ if (explicitDirs.length === 0) {
48
+ throw new Error("addDir requires at least one --dir value");
49
+ }
50
+
51
+ const pathBaseDir = path.resolve(options.pathBaseDir || process.env.INIT_CWD || process.cwd());
52
+ const config = readConfig(options.configPath || process.env.X7_CODE_LINE_CONFIG);
53
+ const targetDirs = normalizeTargetDirs(explicitDirs, config, {
54
+ relativePaths: Boolean(options.relativePaths || process.env.X7_CODE_LINE_RELATIVE_PATHS === "1"),
55
+ pathBaseDir
56
+ });
57
+ const cacheBaseDir = path.resolve(options.cacheBaseDir || pathBaseDir);
58
+ assertInstalledBase(cacheBaseDir);
59
+
60
+ const validatedTargets = validateTargets(targetDirs, config);
61
+ for (const target of validatedTargets) {
62
+ installGitHooksInto(target, cacheBaseDir);
63
+ }
64
+
65
+ const mergedProjects = [...new Set([...readProjects(cacheBaseDir), ...validatedTargets.map((target) => target.targetDir)])];
66
+ writeProjects(cacheBaseDir, mergedProjects);
67
+
68
+ return validatedTargets.map((target) => target.targetDir);
69
+ }
70
+
64
71
  function installCurrentProjectFiles(cacheBaseDir) {
65
- const resolvedTarget = path.resolve(cacheBaseDir);
66
- ensureDirectory(resolvedTarget);
67
-
68
- const cacheDir = path.join(resolvedTarget, CACHE_DIR_NAME);
69
- ensureCacheFiles(resolvedTarget);
70
- writeJson(path.join(cacheDir, "install.json"), {
71
- packageName: "x7-code-line",
72
- installedAt: new Date().toISOString(),
73
- moduleRoot: PACKAGE_ROOT
74
- });
75
-
76
- copyFile(
77
- path.join(PACKAGE_ROOT, "templates", ".cursor", "hooks.json"),
78
- path.join(resolvedTarget, ".cursor", "hooks.json")
79
- );
72
+ const resolvedTarget = path.resolve(cacheBaseDir);
73
+ ensureDirectory(resolvedTarget);
74
+
75
+ const cacheDir = path.join(resolvedTarget, CACHE_DIR_NAME);
76
+ ensureCacheFiles(resolvedTarget);
77
+ writeJson(path.join(cacheDir, "install.json"), {
78
+ packageName: "x7-code-line",
79
+ installedAt: new Date().toISOString(),
80
+ moduleRoot: PACKAGE_ROOT
81
+ });
82
+
83
+ copyFile(
84
+ path.join(PACKAGE_ROOT, "templates", ".cursor", "hooks.json"),
85
+ path.join(resolvedTarget, ".cursor", "hooks.json")
86
+ );
80
87
  copyFile(
81
88
  path.join(PACKAGE_ROOT, "templates", ".codex", "hooks.json"),
82
89
  path.join(resolvedTarget, ".codex", "hooks.json")
83
90
  );
91
+ writeBasePointer(resolvedTarget);
84
92
  }
85
-
86
- function installGitHooksInto(target, cacheBaseDir = process.cwd()) {
87
- for (const gitDir of target.gitDirs) {
88
- installGitHooks(gitDir, cacheBaseDir);
89
- }
90
- }
91
-
92
- function installGitHooks(gitDir, cacheBaseDir) {
93
- const hooksDir = path.join(gitDir, "hooks");
94
- ensureDirectory(hooksDir);
95
-
96
- writeExecutable(path.join(hooksDir, "pre-commit"), makeGitHook("git-pre-commit", cacheBaseDir));
97
- writeExecutable(path.join(hooksDir, "commit-msg"), makeGitHook("git-commit-msg \"$1\"", cacheBaseDir));
98
- }
99
-
100
- function resolveGitTargets(targetDir, config = {}) {
101
- const configured = Array.isArray(config.gitDirs) ? config.gitDirs : [];
102
- const gitDirs = configured.map((gitDir) => path.resolve(targetDir, gitDir));
103
- const defaultGitDir = path.join(targetDir, ".git");
104
-
105
- if (fs.existsSync(defaultGitDir)) {
106
- gitDirs.unshift(defaultGitDir);
107
- }
108
-
109
- return [...new Set(gitDirs)].filter((gitDir) => {
110
- try {
111
- return fs.statSync(gitDir).isDirectory();
112
- } catch {
113
- return false;
114
- }
115
- });
116
- }
117
-
118
- function validateTargets(targetDirs, config = {}) {
119
- return targetDirs.map((targetDir) => validateTarget(targetDir, config));
120
- }
121
-
122
- function validateTarget(targetDir, config = {}) {
123
- const resolvedTarget = path.resolve(targetDir);
124
- assertReachableDirectory(resolvedTarget);
125
- const gitDirs = resolveGitTargets(resolvedTarget, config);
126
-
127
- if (gitDirs.length === 0) {
128
- throw new Error(`Target directory must contain a reachable .git directory: ${resolvedTarget}`);
129
- }
130
-
131
- const configured = Array.isArray(config.gitDirs) ? config.gitDirs : [];
132
- if (configured.length > 0) {
133
- const missing = configured
134
- .map((gitDir) => path.resolve(resolvedTarget, gitDir))
135
- .filter((gitDir) => !gitDirs.includes(gitDir));
136
- if (missing.length > 0) {
137
- throw new Error(`Configured gitDirs are not reachable in target directory: ${missing.join(", ")}`);
138
- }
139
- }
140
-
141
- return { targetDir: resolvedTarget, gitDirs };
142
- }
143
-
144
- function assertReachableDirectory(directory) {
145
- let stat;
146
- try {
147
- stat = fs.statSync(directory);
148
- } catch {
149
- throw new Error(`Target directory does not exist or is not reachable: ${directory}`);
150
- }
151
-
152
- if (!stat.isDirectory()) {
153
- throw new Error(`Target path is not a directory: ${directory}`);
154
- }
155
-
156
- try {
157
- fs.accessSync(directory, fs.constants.R_OK);
158
- } catch {
159
- throw new Error(`Target directory is not readable: ${directory}`);
160
- }
161
- }
162
-
163
- function assertInstalledBase(cacheBaseDir) {
164
- const installFile = path.join(cacheBaseDir, CACHE_DIR_NAME, "install.json");
165
- try {
166
- const stat = fs.statSync(installFile);
167
- if (!stat.isFile()) {
168
- throw new Error("");
169
- }
170
- } catch {
171
- throw new Error(`Current directory is not an installed x7-code-line base: ${cacheBaseDir}`);
172
- }
173
- }
174
-
175
- function readConfig(configPath) {
176
- if (!configPath) {
177
- return {};
178
- }
179
-
180
- const resolvedConfigPath = path.resolve(configPath);
181
- const raw = fs.readFileSync(resolvedConfigPath, "utf8");
182
- const config = JSON.parse(raw);
183
-
184
- if (!config || typeof config !== "object" || Array.isArray(config)) {
185
- throw new Error(`Config must be a JSON object: ${resolvedConfigPath}`);
186
- }
187
-
188
- return config;
189
- }
190
-
191
- function normalizeTargetDirs(targetDirs = [], config = {}, options = {}) {
192
- const configuredDirs = Array.isArray(config.dirs) ? config.dirs : [];
193
- const dirs = [...targetDirs, ...configuredDirs].map((dir) => String(dir || "").trim()).filter(Boolean);
194
-
195
- if (dirs.length === 0) {
196
- throw new Error("install requires at least one target directory");
197
- }
198
-
199
- const baseDir = path.resolve(options.pathBaseDir || process.env.INIT_CWD || process.cwd());
200
- return [...new Set(dirs)].map((dir) => normalizeTargetDir(dir, options.relativePaths, baseDir));
201
- }
202
-
203
- function normalizeTargetDir(dir, relativePaths, baseDir) {
204
- if (path.isAbsolute(dir)) {
205
- return path.resolve(dir);
206
- }
207
- if (!relativePaths) {
208
- throw new Error(`Target directory must be an absolute path unless --relative is used: ${dir}`);
209
- }
210
- return path.resolve(baseDir, dir);
211
- }
212
-
213
- function splitList(value) {
214
- return String(value || "")
215
- .split(path.delimiter)
216
- .map((entry) => entry.trim())
217
- .filter(Boolean);
218
- }
219
-
220
- function copyFile(source, destination) {
221
- ensureDirectory(path.dirname(destination));
222
- fs.copyFileSync(source, destination);
223
- try {
224
- fs.chmodSync(destination, 0o755);
225
- } catch {
226
- // Windows and some package managers may ignore chmod.
227
- }
228
- }
229
-
230
- function writeExecutable(destination, content) {
231
- ensureDirectory(path.dirname(destination));
232
- fs.writeFileSync(destination, content);
233
- try {
234
- fs.chmodSync(destination, 0o755);
235
- } catch {
236
- // Windows and some package managers may ignore chmod.
237
- }
238
- }
239
-
240
- function makeGitHook(command, cacheBaseDir) {
241
- return [
242
- "#!/bin/sh",
243
- "set -eu",
244
- `X7_CODE_LINE_BASE=${shellQuote(path.resolve(cacheBaseDir))}`,
245
- "export X7_CODE_LINE_BASE",
246
- `npx --no-install x7-code-line ${command}`,
247
- ""
248
- ].join("\n");
249
- }
250
-
251
- function shellQuote(value) {
252
- return `'${String(value).replace(/'/g, "'\\''")}'`;
253
- }
254
-
255
- function writeJson(destination, value) {
256
- fs.writeFileSync(destination, `${JSON.stringify(value, null, 2)}\n`);
257
- }
258
-
259
- function ensureDirectory(directory) {
260
- fs.mkdirSync(directory, { recursive: true });
261
- }
262
-
263
- module.exports = {
264
- addDirs,
265
- CACHE_DIR_NAME,
266
- install,
267
- installFromPostinstall
268
- };
93
+
94
+ function installGitHooksInto(target, cacheBaseDir = process.cwd()) {
95
+ for (const gitDir of target.gitDirs) {
96
+ installGitHooks(gitDir, cacheBaseDir);
97
+ }
98
+ }
99
+
100
+ function installGitHooks(gitDir, cacheBaseDir) {
101
+ const hooksDir = path.join(gitDir, "hooks");
102
+ ensureDirectory(hooksDir);
103
+
104
+ writeExecutable(path.join(hooksDir, "pre-commit"), makeGitHook("git-pre-commit", cacheBaseDir));
105
+ writeExecutable(path.join(hooksDir, "commit-msg"), makeGitHook("git-commit-msg \"$1\"", cacheBaseDir));
106
+ }
107
+
108
+ function resolveGitTargets(targetDir, config = {}) {
109
+ const configured = Array.isArray(config.gitDirs) ? config.gitDirs : [];
110
+ const gitDirs = configured.map((gitDir) => path.resolve(targetDir, gitDir));
111
+ const defaultGitDir = path.join(targetDir, ".git");
112
+
113
+ if (fs.existsSync(defaultGitDir)) {
114
+ gitDirs.unshift(defaultGitDir);
115
+ }
116
+
117
+ return [...new Set(gitDirs)].filter((gitDir) => {
118
+ try {
119
+ return fs.statSync(gitDir).isDirectory();
120
+ } catch {
121
+ return false;
122
+ }
123
+ });
124
+ }
125
+
126
+ function validateTargets(targetDirs, config = {}) {
127
+ return targetDirs.map((targetDir) => validateTarget(targetDir, config));
128
+ }
129
+
130
+ function validateTarget(targetDir, config = {}) {
131
+ const resolvedTarget = path.resolve(targetDir);
132
+ assertReachableDirectory(resolvedTarget);
133
+ const gitDirs = resolveGitTargets(resolvedTarget, config);
134
+
135
+ if (gitDirs.length === 0) {
136
+ throw new Error(`Target directory must contain a reachable .git directory: ${resolvedTarget}`);
137
+ }
138
+
139
+ const configured = Array.isArray(config.gitDirs) ? config.gitDirs : [];
140
+ if (configured.length > 0) {
141
+ const missing = configured
142
+ .map((gitDir) => path.resolve(resolvedTarget, gitDir))
143
+ .filter((gitDir) => !gitDirs.includes(gitDir));
144
+ if (missing.length > 0) {
145
+ throw new Error(`Configured gitDirs are not reachable in target directory: ${missing.join(", ")}`);
146
+ }
147
+ }
148
+
149
+ return { targetDir: resolvedTarget, gitDirs };
150
+ }
151
+
152
+ function assertReachableDirectory(directory) {
153
+ let stat;
154
+ try {
155
+ stat = fs.statSync(directory);
156
+ } catch {
157
+ throw new Error(`Target directory does not exist or is not reachable: ${directory}`);
158
+ }
159
+
160
+ if (!stat.isDirectory()) {
161
+ throw new Error(`Target path is not a directory: ${directory}`);
162
+ }
163
+
164
+ try {
165
+ fs.accessSync(directory, fs.constants.R_OK);
166
+ } catch {
167
+ throw new Error(`Target directory is not readable: ${directory}`);
168
+ }
169
+ }
170
+
171
+ function assertInstalledBase(cacheBaseDir) {
172
+ const installFile = path.join(cacheBaseDir, CACHE_DIR_NAME, "install.json");
173
+ try {
174
+ const stat = fs.statSync(installFile);
175
+ if (!stat.isFile()) {
176
+ throw new Error("");
177
+ }
178
+ } catch {
179
+ throw new Error(`Current directory is not an installed x7-code-line base: ${cacheBaseDir}`);
180
+ }
181
+ }
182
+
183
+ function readConfig(configPath) {
184
+ if (!configPath) {
185
+ return {};
186
+ }
187
+
188
+ const resolvedConfigPath = path.resolve(configPath);
189
+ const raw = fs.readFileSync(resolvedConfigPath, "utf8");
190
+ const config = JSON.parse(raw);
191
+
192
+ if (!config || typeof config !== "object" || Array.isArray(config)) {
193
+ throw new Error(`Config must be a JSON object: ${resolvedConfigPath}`);
194
+ }
195
+
196
+ return config;
197
+ }
198
+
199
+ function normalizeTargetDirs(targetDirs = [], config = {}, options = {}) {
200
+ const configuredDirs = Array.isArray(config.dirs) ? config.dirs : [];
201
+ const dirs = [...targetDirs, ...configuredDirs].map((dir) => String(dir || "").trim()).filter(Boolean);
202
+
203
+ if (dirs.length === 0) {
204
+ throw new Error("install requires at least one target directory");
205
+ }
206
+
207
+ const baseDir = path.resolve(options.pathBaseDir || process.env.INIT_CWD || process.cwd());
208
+ return [...new Set(dirs)].map((dir) => normalizeTargetDir(dir, options.relativePaths, baseDir));
209
+ }
210
+
211
+ function normalizeTargetDir(dir, relativePaths, baseDir) {
212
+ if (path.isAbsolute(dir)) {
213
+ return path.resolve(dir);
214
+ }
215
+ if (!relativePaths) {
216
+ throw new Error(`Target directory must be an absolute path unless --relative is used: ${dir}`);
217
+ }
218
+ return path.resolve(baseDir, dir);
219
+ }
220
+
221
+ function splitList(value) {
222
+ return String(value || "")
223
+ .split(path.delimiter)
224
+ .map((entry) => entry.trim())
225
+ .filter(Boolean);
226
+ }
227
+
228
+ function copyFile(source, destination) {
229
+ ensureDirectory(path.dirname(destination));
230
+ fs.copyFileSync(source, destination);
231
+ try {
232
+ fs.chmodSync(destination, 0o755);
233
+ } catch {
234
+ // Windows and some package managers may ignore chmod.
235
+ }
236
+ }
237
+
238
+ function writeExecutable(destination, content) {
239
+ ensureDirectory(path.dirname(destination));
240
+ fs.writeFileSync(destination, content);
241
+ try {
242
+ fs.chmodSync(destination, 0o755);
243
+ } catch {
244
+ // Windows and some package managers may ignore chmod.
245
+ }
246
+ }
247
+
248
+ function makeGitHook(command, cacheBaseDir) {
249
+ return [
250
+ "#!/bin/sh",
251
+ "set -eu",
252
+ `X7_CODE_LINE_BASE=${shellQuote(path.resolve(cacheBaseDir))}`,
253
+ "export X7_CODE_LINE_BASE",
254
+ `npx --no-install x7-code-line ${command}`,
255
+ ""
256
+ ].join("\n");
257
+ }
258
+
259
+ function shellQuote(value) {
260
+ return `'${String(value).replace(/'/g, "'\\''")}'`;
261
+ }
262
+
263
+ function writeJson(destination, value) {
264
+ fs.writeFileSync(destination, `${JSON.stringify(value, null, 2)}\n`);
265
+ }
266
+
267
+ function ensureDirectory(directory) {
268
+ fs.mkdirSync(directory, { recursive: true });
269
+ }
270
+
271
+ module.exports = {
272
+ addDirs,
273
+ CACHE_DIR_NAME,
274
+ install,
275
+ installFromPostinstall
276
+ };
@@ -1,13 +1,13 @@
1
- "use strict";
2
-
3
- const { installFromPostinstall } = require("./install");
4
-
5
- try {
6
- const installed = installFromPostinstall();
7
- if (process.env.X7_CODE_LINE_DEBUG === "1") {
8
- console.error(`[x7-code-line] installed into ${installed.join(", ")}`);
9
- }
10
- } catch (error) {
11
- console.error(`[x7-code-line] postinstall failed: ${error.message}`);
12
- process.exit(1);
13
- }
1
+ "use strict";
2
+
3
+ const { installFromPostinstall } = require("./install");
4
+
5
+ try {
6
+ const installed = installFromPostinstall();
7
+ if (process.env.X7_CODE_LINE_DEBUG === "1") {
8
+ console.error(`[x7-code-line] installed into ${installed.join(", ")}`);
9
+ }
10
+ } catch (error) {
11
+ console.error(`[x7-code-line] postinstall failed: ${error.message}`);
12
+ process.exit(1);
13
+ }
@@ -1,14 +1,30 @@
1
- {
2
- "hooks": {
3
- "UserPromptSubmit": [
4
- {
5
- "command": "npx --no-install x7-code-line prompt-submit"
6
- }
7
- ],
8
- "Stop": [
9
- {
10
- "command": "npx --no-install x7-code-line stop"
11
- }
12
- ]
13
- }
14
- }
1
+ {
2
+ "hooks": {
3
+ "UserPromptSubmit": [
4
+ {
5
+ "matcher": "*",
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "npx --no-install x7-code-line prompt-submit",
10
+ "timeout": 30,
11
+ "statusMessage": "Logging UserPromptSubmit hook"
12
+ }
13
+ ]
14
+ }
15
+ ],
16
+ "Stop": [
17
+ {
18
+ "matcher": "*",
19
+ "hooks": [
20
+ {
21
+ "type": "command",
22
+ "command": "npx --no-install x7-code-line stop",
23
+ "timeout": 30,
24
+ "statusMessage": "Logging Stop hook"
25
+ }
26
+ ]
27
+ }
28
+ ]
29
+ }
30
+ }
@@ -1,14 +1,17 @@
1
- {
2
- "hooks": {
3
- "beforeSubmitPrompt": [
4
- {
5
- "command": "npx --no-install x7-code-line prompt-submit"
6
- }
7
- ],
8
- "stop": [
9
- {
10
- "command": "npx --no-install x7-code-line stop"
11
- }
12
- ]
13
- }
14
- }
1
+ {
2
+ "version": 1,
3
+ "hooks": {
4
+ "beforeSubmitPrompt": [
5
+ {
6
+ "comment": "记录代码id",
7
+ "command": "npx --no-install x7-code-line prompt-submit"
8
+ }
9
+ ],
10
+ "stop": [
11
+ {
12
+ "comment": "记录AI代码标识",
13
+ "command": "npx --no-install x7-code-line stop"
14
+ }
15
+ ]
16
+ }
17
+ }