crosspad-mcp-server 5.0.1 → 6.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/README.md +31 -18
- package/dist/config.d.ts +2 -2
- package/dist/config.js +17 -13
- package/dist/config.js.map +1 -1
- package/dist/index.js +139 -31
- package/dist/index.js.map +1 -1
- package/dist/tools/app-manager.d.ts +43 -9
- package/dist/tools/app-manager.js +195 -117
- package/dist/tools/app-manager.js.map +1 -1
- package/dist/tools/architecture.js +0 -2
- package/dist/tools/architecture.js.map +1 -1
- package/dist/tools/build.d.ts +4 -0
- package/dist/tools/build.js +4 -2
- package/dist/tools/build.js.map +1 -1
- package/dist/tools/idf-build.d.ts +13 -0
- package/dist/tools/idf-build.js +8 -4
- package/dist/tools/idf-build.js.map +1 -1
- package/dist/tools/idf-flash.d.ts +20 -0
- package/dist/tools/idf-flash.js +184 -0
- package/dist/tools/idf-flash.js.map +1 -0
- package/dist/tools/idf-monitor.d.ts +29 -0
- package/dist/tools/idf-monitor.js +168 -0
- package/dist/tools/idf-monitor.js.map +1 -0
- package/dist/tools/midi.d.ts +27 -0
- package/dist/tools/midi.js +112 -0
- package/dist/tools/midi.js.map +1 -0
- package/dist/tools/repo-actions.d.ts +46 -0
- package/dist/tools/repo-actions.js +273 -0
- package/dist/tools/repo-actions.js.map +1 -0
- package/dist/tools/symbols.d.ts +16 -1
- package/dist/tools/symbols.js +118 -50
- package/dist/tools/symbols.js.map +1 -1
- package/dist/tools/test.d.ts +7 -0
- package/dist/tools/test.js +4 -2
- package/dist/tools/test.js.map +1 -1
- package/dist/utils/device.d.ts +38 -0
- package/dist/utils/device.js +287 -0
- package/dist/utils/device.js.map +1 -0
- package/dist/utils/remote-client.d.ts +1 -0
- package/dist/utils/remote-client.js +24 -1
- package/dist/utils/remote-client.js.map +1 -1
- package/package.json +6 -3
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Send MIDI events to the CrossPad simulator via TCP remote control.
|
|
3
|
+
*
|
|
4
|
+
* Supports: note_on, note_off, cc (control change), program_change.
|
|
5
|
+
* Uses the same remote control protocol as other sim commands.
|
|
6
|
+
*/
|
|
7
|
+
import { sendRemoteCommand, isSimulatorRunning } from "../utils/remote-client.js";
|
|
8
|
+
/**
|
|
9
|
+
* Send a MIDI event to the running simulator.
|
|
10
|
+
*/
|
|
11
|
+
export async function crosspadMidiSend(params) {
|
|
12
|
+
const running = await isSimulatorRunning();
|
|
13
|
+
if (!running) {
|
|
14
|
+
return {
|
|
15
|
+
success: false,
|
|
16
|
+
type: params.type,
|
|
17
|
+
channel: params.channel,
|
|
18
|
+
details: {},
|
|
19
|
+
error: "Simulator is not running. Use crosspad_build action=pc_run to start it.",
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
// Validate channel
|
|
23
|
+
if (params.channel < 0 || params.channel > 15) {
|
|
24
|
+
return {
|
|
25
|
+
success: false,
|
|
26
|
+
type: params.type,
|
|
27
|
+
channel: params.channel,
|
|
28
|
+
details: {},
|
|
29
|
+
error: "MIDI channel must be 0-15",
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
let cmd;
|
|
33
|
+
const details = { channel: params.channel };
|
|
34
|
+
switch (params.type) {
|
|
35
|
+
case "note_on": {
|
|
36
|
+
const note = params.note ?? 60;
|
|
37
|
+
const velocity = params.velocity ?? 127;
|
|
38
|
+
if (note < 0 || note > 127) {
|
|
39
|
+
return { success: false, type: params.type, channel: params.channel, details, error: "Note must be 0-127" };
|
|
40
|
+
}
|
|
41
|
+
if (velocity < 0 || velocity > 127) {
|
|
42
|
+
return { success: false, type: params.type, channel: params.channel, details, error: "Velocity must be 0-127" };
|
|
43
|
+
}
|
|
44
|
+
cmd = { cmd: "midi", type: "note_on", channel: params.channel, note, velocity };
|
|
45
|
+
details.note = note;
|
|
46
|
+
details.velocity = velocity;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
case "note_off": {
|
|
50
|
+
const note = params.note ?? 60;
|
|
51
|
+
const velocity = params.velocity ?? 0;
|
|
52
|
+
if (note < 0 || note > 127) {
|
|
53
|
+
return { success: false, type: params.type, channel: params.channel, details, error: "Note must be 0-127" };
|
|
54
|
+
}
|
|
55
|
+
cmd = { cmd: "midi", type: "note_off", channel: params.channel, note, velocity };
|
|
56
|
+
details.note = note;
|
|
57
|
+
details.velocity = velocity;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
case "cc": {
|
|
61
|
+
const ccNum = params.cc_num ?? 0;
|
|
62
|
+
const value = params.value ?? 0;
|
|
63
|
+
if (ccNum < 0 || ccNum > 127) {
|
|
64
|
+
return { success: false, type: params.type, channel: params.channel, details, error: "CC number must be 0-127" };
|
|
65
|
+
}
|
|
66
|
+
if (value < 0 || value > 127) {
|
|
67
|
+
return { success: false, type: params.type, channel: params.channel, details, error: "Value must be 0-127" };
|
|
68
|
+
}
|
|
69
|
+
cmd = { cmd: "midi", type: "cc", channel: params.channel, cc: ccNum, value };
|
|
70
|
+
details.cc = ccNum;
|
|
71
|
+
details.value = value;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
case "program_change": {
|
|
75
|
+
const program = params.program ?? 0;
|
|
76
|
+
if (program < 0 || program > 127) {
|
|
77
|
+
return { success: false, type: params.type, channel: params.channel, details, error: "Program must be 0-127" };
|
|
78
|
+
}
|
|
79
|
+
cmd = { cmd: "midi", type: "program_change", channel: params.channel, program };
|
|
80
|
+
details.program = program;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
default:
|
|
84
|
+
return {
|
|
85
|
+
success: false,
|
|
86
|
+
type: params.type,
|
|
87
|
+
channel: params.channel,
|
|
88
|
+
details: {},
|
|
89
|
+
error: `Unknown MIDI event type: ${params.type}`,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const resp = await sendRemoteCommand(cmd);
|
|
94
|
+
return {
|
|
95
|
+
success: resp.ok === true,
|
|
96
|
+
type: params.type,
|
|
97
|
+
channel: params.channel,
|
|
98
|
+
details,
|
|
99
|
+
error: resp.ok ? undefined : resp.error ?? "Simulator rejected MIDI command",
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
catch (err) {
|
|
103
|
+
return {
|
|
104
|
+
success: false,
|
|
105
|
+
type: params.type,
|
|
106
|
+
channel: params.channel,
|
|
107
|
+
details,
|
|
108
|
+
error: err.message,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=midi.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"midi.js","sourceRoot":"","sources":["../../src/tools/midi.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAsBlF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,MAAsB;IAC3D,MAAM,OAAO,GAAG,MAAM,kBAAkB,EAAE,CAAC;IAC3C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO;YACL,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,yEAAyE;SACjF,CAAC;IACJ,CAAC;IAED,mBAAmB;IACnB,IAAI,MAAM,CAAC,OAAO,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,GAAG,EAAE,EAAE,CAAC;QAC9C,OAAO;YACL,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,OAAO,EAAE,EAAE;YACX,KAAK,EAAE,2BAA2B;SACnC,CAAC;IACJ,CAAC;IAED,IAAI,GAA4B,CAAC;IACjC,MAAM,OAAO,GAA2B,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,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AAE,MAAM,CAAC,OAAO;YACvB,OAAO;YACP,KAAK,EAAE,GAAG,CAAC,OAAO;SACnB,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mutable repo operations: submodule update and commit.
|
|
3
|
+
*
|
|
4
|
+
* These are intentionally separate from repos.ts (read-only status)
|
|
5
|
+
* to make the mutation surface explicit.
|
|
6
|
+
*/
|
|
7
|
+
export interface SubmoduleUpdateResult {
|
|
8
|
+
success: boolean;
|
|
9
|
+
submodule: string;
|
|
10
|
+
repo: string;
|
|
11
|
+
old_sha: string | null;
|
|
12
|
+
new_sha: string | null;
|
|
13
|
+
commits_pulled: number;
|
|
14
|
+
changed_files: string[];
|
|
15
|
+
staged: boolean;
|
|
16
|
+
error?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface CommitResult {
|
|
19
|
+
success: boolean;
|
|
20
|
+
repo: string;
|
|
21
|
+
commit_hash: string | null;
|
|
22
|
+
message: string;
|
|
23
|
+
files_committed: string[];
|
|
24
|
+
error?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Update a submodule in a parent repo to the latest commit on its tracking branch.
|
|
28
|
+
*
|
|
29
|
+
* Workflow:
|
|
30
|
+
* 1. cd into submodule
|
|
31
|
+
* 2. git fetch origin
|
|
32
|
+
* 3. git checkout origin/<branch> (default: main)
|
|
33
|
+
* 4. cd back to parent, git add <submodule>
|
|
34
|
+
* 5. Report old→new SHA, commits pulled, files changed
|
|
35
|
+
*/
|
|
36
|
+
export declare function crosspadSubmoduleUpdate(submodule: string, repo: string, branch?: string): SubmoduleUpdateResult;
|
|
37
|
+
/**
|
|
38
|
+
* Commit changes in a specific repo.
|
|
39
|
+
*
|
|
40
|
+
* Safety:
|
|
41
|
+
* - Refuses if working tree has merge conflicts
|
|
42
|
+
* - If files specified, stages only those files
|
|
43
|
+
* - If no files specified, commits whatever is currently staged
|
|
44
|
+
* - Never pushes to remote
|
|
45
|
+
*/
|
|
46
|
+
export declare function crosspadCommit(repo: string, message: string, files?: string[]): CommitResult;
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mutable repo operations: submodule update and commit.
|
|
3
|
+
*
|
|
4
|
+
* These are intentionally separate from repos.ts (read-only status)
|
|
5
|
+
* to make the mutation surface explicit.
|
|
6
|
+
*/
|
|
7
|
+
import fs from "fs";
|
|
8
|
+
import path from "path";
|
|
9
|
+
import { getRepos } from "../config.js";
|
|
10
|
+
import { runCommand } from "../utils/exec.js";
|
|
11
|
+
import { getHead } from "../utils/git.js";
|
|
12
|
+
const REPO_ALIASES = {
|
|
13
|
+
idf: "platform-idf",
|
|
14
|
+
pc: "crosspad-pc",
|
|
15
|
+
arduino: "ESP32-S3",
|
|
16
|
+
core: "crosspad-core",
|
|
17
|
+
gui: "crosspad-gui",
|
|
18
|
+
};
|
|
19
|
+
function resolveRepo(repo) {
|
|
20
|
+
const repos = getRepos();
|
|
21
|
+
const canonical = REPO_ALIASES[repo] ?? repo;
|
|
22
|
+
if (repos[canonical]) {
|
|
23
|
+
return { name: canonical, root: repos[canonical] };
|
|
24
|
+
}
|
|
25
|
+
// Try partial match
|
|
26
|
+
for (const [name, repoPath] of Object.entries(repos)) {
|
|
27
|
+
if (name.toLowerCase().includes(repo.toLowerCase())) {
|
|
28
|
+
return { name, root: repoPath };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
function getAvailableRepoNames() {
|
|
34
|
+
return Object.keys(getRepos());
|
|
35
|
+
}
|
|
36
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
37
|
+
// SUBMODULE PATHS — where each submodule lives inside parent repos
|
|
38
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
39
|
+
const SUBMODULE_PATHS = {
|
|
40
|
+
"platform-idf": {
|
|
41
|
+
"crosspad-core": "components/crosspad-core",
|
|
42
|
+
"crosspad-gui": "components/crosspad-gui",
|
|
43
|
+
"crosspad-instructions": "components/crosspad-instructions",
|
|
44
|
+
"crosspad-sampler": "components/crosspad-sampler",
|
|
45
|
+
},
|
|
46
|
+
"crosspad-pc": {
|
|
47
|
+
"crosspad-core": "crosspad-core",
|
|
48
|
+
"crosspad-gui": "crosspad-gui",
|
|
49
|
+
},
|
|
50
|
+
"ESP32-S3": {
|
|
51
|
+
"crosspad-core": "lib/crosspad-core",
|
|
52
|
+
"crosspad-gui": "lib/crosspad-gui",
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
function getSubmodulePath(repoName, submodule) {
|
|
56
|
+
return SUBMODULE_PATHS[repoName]?.[submodule] ?? null;
|
|
57
|
+
}
|
|
58
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
59
|
+
// SUBMODULE UPDATE
|
|
60
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
61
|
+
/**
|
|
62
|
+
* Update a submodule in a parent repo to the latest commit on its tracking branch.
|
|
63
|
+
*
|
|
64
|
+
* Workflow:
|
|
65
|
+
* 1. cd into submodule
|
|
66
|
+
* 2. git fetch origin
|
|
67
|
+
* 3. git checkout origin/<branch> (default: main)
|
|
68
|
+
* 4. cd back to parent, git add <submodule>
|
|
69
|
+
* 5. Report old→new SHA, commits pulled, files changed
|
|
70
|
+
*/
|
|
71
|
+
export function crosspadSubmoduleUpdate(submodule, repo, branch = "main") {
|
|
72
|
+
const resolvedRepo = resolveRepo(repo);
|
|
73
|
+
if (!resolvedRepo) {
|
|
74
|
+
return {
|
|
75
|
+
success: false,
|
|
76
|
+
submodule,
|
|
77
|
+
repo,
|
|
78
|
+
old_sha: null,
|
|
79
|
+
new_sha: null,
|
|
80
|
+
commits_pulled: 0,
|
|
81
|
+
changed_files: [],
|
|
82
|
+
staged: false,
|
|
83
|
+
error: `Unknown repo "${repo}". Available: ${getAvailableRepoNames().join(", ")}`,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const subPath = getSubmodulePath(resolvedRepo.name, submodule);
|
|
87
|
+
if (!subPath) {
|
|
88
|
+
const knownSubs = Object.keys(SUBMODULE_PATHS[resolvedRepo.name] ?? {});
|
|
89
|
+
return {
|
|
90
|
+
success: false,
|
|
91
|
+
submodule,
|
|
92
|
+
repo: resolvedRepo.name,
|
|
93
|
+
old_sha: null,
|
|
94
|
+
new_sha: null,
|
|
95
|
+
commits_pulled: 0,
|
|
96
|
+
changed_files: [],
|
|
97
|
+
staged: false,
|
|
98
|
+
error: `Submodule "${submodule}" not found in ${resolvedRepo.name}. Known: ${knownSubs.join(", ")}`,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
const fullSubPath = path.join(resolvedRepo.root, subPath);
|
|
102
|
+
if (!fs.existsSync(fullSubPath)) {
|
|
103
|
+
return {
|
|
104
|
+
success: false,
|
|
105
|
+
submodule,
|
|
106
|
+
repo: resolvedRepo.name,
|
|
107
|
+
old_sha: null,
|
|
108
|
+
new_sha: null,
|
|
109
|
+
commits_pulled: 0,
|
|
110
|
+
changed_files: [],
|
|
111
|
+
staged: false,
|
|
112
|
+
error: `Submodule directory not found: ${fullSubPath}`,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
// Get current SHA
|
|
116
|
+
const oldSha = getHead(fullSubPath);
|
|
117
|
+
// Fetch latest
|
|
118
|
+
const fetchResult = runCommand("git fetch origin", fullSubPath, 30_000);
|
|
119
|
+
if (!fetchResult.success) {
|
|
120
|
+
return {
|
|
121
|
+
success: false,
|
|
122
|
+
submodule,
|
|
123
|
+
repo: resolvedRepo.name,
|
|
124
|
+
old_sha: oldSha,
|
|
125
|
+
new_sha: null,
|
|
126
|
+
commits_pulled: 0,
|
|
127
|
+
changed_files: [],
|
|
128
|
+
staged: false,
|
|
129
|
+
error: `git fetch failed: ${fetchResult.stderr}`,
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
// Checkout target
|
|
133
|
+
const checkoutResult = runCommand(`git checkout origin/${branch}`, fullSubPath, 15_000);
|
|
134
|
+
if (!checkoutResult.success) {
|
|
135
|
+
return {
|
|
136
|
+
success: false,
|
|
137
|
+
submodule,
|
|
138
|
+
repo: resolvedRepo.name,
|
|
139
|
+
old_sha: oldSha,
|
|
140
|
+
new_sha: null,
|
|
141
|
+
commits_pulled: 0,
|
|
142
|
+
changed_files: [],
|
|
143
|
+
staged: false,
|
|
144
|
+
error: `git checkout origin/${branch} failed: ${checkoutResult.stderr}`,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
// Get new SHA
|
|
148
|
+
const newSha = getHead(fullSubPath);
|
|
149
|
+
// Count commits between old and new
|
|
150
|
+
let commitsPulled = 0;
|
|
151
|
+
let changedFiles = [];
|
|
152
|
+
if (oldSha && newSha && oldSha !== newSha) {
|
|
153
|
+
const countResult = runCommand(`git rev-list --count ${oldSha}..${newSha}`, fullSubPath);
|
|
154
|
+
if (countResult.success) {
|
|
155
|
+
commitsPulled = parseInt(countResult.stdout.trim(), 10) || 0;
|
|
156
|
+
}
|
|
157
|
+
const diffResult = runCommand(`git diff --name-only ${oldSha}..${newSha}`, fullSubPath);
|
|
158
|
+
if (diffResult.success) {
|
|
159
|
+
changedFiles = diffResult.stdout
|
|
160
|
+
.trim()
|
|
161
|
+
.split("\n")
|
|
162
|
+
.filter((l) => l.length > 0);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// Stage the submodule update in parent repo
|
|
166
|
+
const addResult = runCommand(`git add ${subPath}`, resolvedRepo.root, 10_000);
|
|
167
|
+
return {
|
|
168
|
+
success: true,
|
|
169
|
+
submodule,
|
|
170
|
+
repo: resolvedRepo.name,
|
|
171
|
+
old_sha: oldSha,
|
|
172
|
+
new_sha: newSha,
|
|
173
|
+
commits_pulled: commitsPulled,
|
|
174
|
+
changed_files: changedFiles,
|
|
175
|
+
staged: addResult.success,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
179
|
+
// COMMIT
|
|
180
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
181
|
+
/**
|
|
182
|
+
* Commit changes in a specific repo.
|
|
183
|
+
*
|
|
184
|
+
* Safety:
|
|
185
|
+
* - Refuses if working tree has merge conflicts
|
|
186
|
+
* - If files specified, stages only those files
|
|
187
|
+
* - If no files specified, commits whatever is currently staged
|
|
188
|
+
* - Never pushes to remote
|
|
189
|
+
*/
|
|
190
|
+
export function crosspadCommit(repo, message, files) {
|
|
191
|
+
const resolvedRepo = resolveRepo(repo);
|
|
192
|
+
if (!resolvedRepo) {
|
|
193
|
+
return {
|
|
194
|
+
success: false,
|
|
195
|
+
repo,
|
|
196
|
+
commit_hash: null,
|
|
197
|
+
message,
|
|
198
|
+
files_committed: [],
|
|
199
|
+
error: `Unknown repo "${repo}". Available: ${getAvailableRepoNames().join(", ")}`,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
// Check for merge conflicts
|
|
203
|
+
const statusResult = runCommand("git status --porcelain", resolvedRepo.root);
|
|
204
|
+
if (statusResult.success) {
|
|
205
|
+
const conflicted = statusResult.stdout
|
|
206
|
+
.split("\n")
|
|
207
|
+
.filter((l) => l.startsWith("UU") || l.startsWith("AA") || l.startsWith("DD"));
|
|
208
|
+
if (conflicted.length > 0) {
|
|
209
|
+
return {
|
|
210
|
+
success: false,
|
|
211
|
+
repo: resolvedRepo.name,
|
|
212
|
+
commit_hash: null,
|
|
213
|
+
message,
|
|
214
|
+
files_committed: [],
|
|
215
|
+
error: `Merge conflicts detected:\n${conflicted.join("\n")}\nResolve conflicts before committing.`,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// Stage specific files if provided
|
|
220
|
+
if (files && files.length > 0) {
|
|
221
|
+
const fileList = files.map((f) => `"${f}"`).join(" ");
|
|
222
|
+
const addResult = runCommand(`git add ${fileList}`, resolvedRepo.root, 10_000);
|
|
223
|
+
if (!addResult.success) {
|
|
224
|
+
return {
|
|
225
|
+
success: false,
|
|
226
|
+
repo: resolvedRepo.name,
|
|
227
|
+
commit_hash: null,
|
|
228
|
+
message,
|
|
229
|
+
files_committed: [],
|
|
230
|
+
error: `git add failed: ${addResult.stderr}`,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
// Check something is staged
|
|
235
|
+
const diffResult = runCommand("git diff --cached --name-only", resolvedRepo.root);
|
|
236
|
+
const stagedFiles = diffResult.success
|
|
237
|
+
? diffResult.stdout.trim().split("\n").filter((l) => l.length > 0)
|
|
238
|
+
: [];
|
|
239
|
+
if (stagedFiles.length === 0) {
|
|
240
|
+
return {
|
|
241
|
+
success: false,
|
|
242
|
+
repo: resolvedRepo.name,
|
|
243
|
+
commit_hash: null,
|
|
244
|
+
message,
|
|
245
|
+
files_committed: [],
|
|
246
|
+
error: "Nothing staged to commit. Stage files first or specify files parameter.",
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
// Commit — escape message for shell safety
|
|
250
|
+
const escapedMessage = message.replace(/'/g, "'\\''");
|
|
251
|
+
const commitResult = runCommand(`git commit -m '${escapedMessage}'`, resolvedRepo.root, 30_000);
|
|
252
|
+
if (!commitResult.success) {
|
|
253
|
+
return {
|
|
254
|
+
success: false,
|
|
255
|
+
repo: resolvedRepo.name,
|
|
256
|
+
commit_hash: null,
|
|
257
|
+
message,
|
|
258
|
+
files_committed: stagedFiles,
|
|
259
|
+
error: `git commit failed: ${commitResult.stderr || commitResult.stdout}`,
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
// Get the new commit hash
|
|
263
|
+
const hashResult = runCommand("git rev-parse HEAD", resolvedRepo.root);
|
|
264
|
+
const commitHash = hashResult.success ? hashResult.stdout.trim() : null;
|
|
265
|
+
return {
|
|
266
|
+
success: true,
|
|
267
|
+
repo: resolvedRepo.name,
|
|
268
|
+
commit_hash: commitHash,
|
|
269
|
+
message,
|
|
270
|
+
files_committed: stagedFiles,
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|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CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7B,OAAO;YACL,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,WAAW,EAAE,IAAI;YACjB,OAAO;YACP,eAAe,EAAE,EAAE;YACnB,KAAK,EAAE,yEAAyE;SACjF,CAAC;IACJ,CAAC;IAED,2CAA2C;IAC3C,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACtD,MAAM,YAAY,GAAG,UAAU,CAAC,kBAAkB,cAAc,GAAG,EAAE,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAEhG,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAC1B,OAAO;YACL,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,YAAY,CAAC,IAAI;YACvB,WAAW,EAAE,IAAI;YACjB,OAAO;YACP,eAAe,EAAE,WAAW;YAC5B,KAAK,EAAE,sBAAsB,YAAY,CAAC,MAAM,IAAI,YAAY,CAAC,MAAM,EAAE;SAC1E,CAAC;IACJ,CAAC;IAED,0BAA0B;IAC1B,MAAM,UAAU,GAAG,UAAU,CAAC,oBAAoB,EAAE,YAAY,CAAC,IAAI,CAAC,CAAC;IACvE,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IAExE,OAAO;QACL,OAAO,EAAE,IAAI;QACb,IAAI,EAAE,YAAY,CAAC,IAAI;QACvB,WAAW,EAAE,UAAU;QACvB,OAAO;QACP,eAAe,EAAE,WAAW;KAC7B,CAAC;AACJ,CAAC"}
|
package/dist/tools/symbols.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export interface SymbolResult {
|
|
|
4
4
|
file: string;
|
|
5
5
|
line: number;
|
|
6
6
|
context: string;
|
|
7
|
+
surrounding?: string[];
|
|
7
8
|
repo: string;
|
|
8
9
|
}
|
|
9
10
|
export interface SymbolSearchResult {
|
|
@@ -13,8 +14,22 @@ export interface SymbolSearchResult {
|
|
|
13
14
|
total_matches: number;
|
|
14
15
|
truncated: boolean;
|
|
15
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Build a regex pattern that matches definition lines containing the query.
|
|
19
|
+
* Each kind has a specific pattern that only matches declarations/definitions.
|
|
20
|
+
*/
|
|
21
|
+
/** @internal exported for testing */
|
|
22
|
+
export declare function buildPattern(query: string, kind: string): string;
|
|
16
23
|
/**
|
|
17
24
|
* Search for symbol definitions (classes, functions, macros, enums) across CrossPad repos.
|
|
18
25
|
* Only matches definition lines, not usages.
|
|
19
26
|
*/
|
|
20
|
-
export declare function crosspadSearchSymbols(query: string, kind?: string, repos?: string[], maxResults?: number): SymbolSearchResult;
|
|
27
|
+
export declare function crosspadSearchSymbols(query: string, kind?: string, repos?: string[], maxResults?: number, contextLines?: number): SymbolSearchResult;
|
|
28
|
+
/** @internal exported for testing */
|
|
29
|
+
export declare function escapeForShell(s: string): string;
|
|
30
|
+
/** @internal exported for testing */
|
|
31
|
+
export declare function escapeForRegex(s: string): string;
|
|
32
|
+
/** @internal exported for testing */
|
|
33
|
+
export declare function classifyDefinition(line: string): SymbolResult["kind"] | null;
|
|
34
|
+
/** @internal exported for testing */
|
|
35
|
+
export declare function extractSymbolName(line: string, kind: SymbolResult["kind"]): string | null;
|