File size: 13,860 Bytes
04f192c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.scijava</groupId>
    <artifactId>pom-scijava</artifactId>
    <version>40.0.0</version>
    <relativePath />
  </parent>

  <groupId>copilotj</groupId>
  <artifactId>CopilotJBridge</artifactId>
  <version>1.1.0-SNAPSHOT</version>

  <name>Copilot Bridge</name>
  <description>CopilotJ bridge for Fiji/ImageJ2.</description>
  <url>https://copilotj.chat/</url>
  <inceptionYear>2024</inceptionYear>
  <organization>
    <name>CVCD</name>
    <url>https://cvcd.xyz/</url>
  </organization>
  <licenses>
    <license>
      <name>Apache 2</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>

  <developers>
    <!-- See https://imagej.net/Team -->
    <developer>
      <id>yzx9</id>
      <name>Zexin Yuan</name>
      <url>https://github.com/yzx9</url>
      <roles>
        <role>founder</role>
        <role>lead</role>
        <role>developer</role>
        <role>debugger</role>
        <role>reviewer</role>
        <role>support</role>
        <role>maintainer</role>
      </roles>
    </developer>
    <developer>
      <id>00jacklu</id>
      <name>Jack Lu</name>
      <url>https://github.com/00jacklu</url>
      <roles>
        <role>founder</role>
        <role>lead</role>
        <role>developer</role>
        <role>debugger</role>
        <role>reviewer</role>
        <role>support</role>
        <role>maintainer</role>
      </roles>
    </developer>
  </developers>
  <contributors>
    <contributor>
      <name>Curtis Rueden</name>
      <url>https://github.com/ctrueden</url>
      <properties><id>ctrueden</id></properties>
    </contributor>
  </contributors>

  <mailingLists>
    <mailingList>
      <name>Image.sc Forum</name>
      <archive>https://forum.image.sc/tag/copilotj</archive>
    </mailingList>
  </mailingLists>

  <scm>
    <connection>scm:git:https://github.com/neurogeom/CopilotJ</connection>
    <developerConnection>scm:git:git@github.com:neurogeom/CopilotJ</developerConnection>
    <tag>HEAD</tag>
    <url>https://github.com/neurogeom/CopilotJ</url>
  </scm>
  <issueManagement>
    <system>GitHub Issues</system>
    <url>https://github.com/neurogeom/CopilotJ</url>
  </issueManagement>
  <ciManagement>
    <system>GitHub Actions</system>
    <url>https://github.com/neurogeom/CopilotJ/actions</url>
  </ciManagement>

  <properties>
    <package-name>copilotj</package-name>
    <main-class>copilotj.DefaultCopilotJBridgeService</main-class>
    <license.licenseName>apache_v2</license.licenseName>
    <license.copyrightOwners>CopilotJ developers.</license.copyrightOwners>

    <!-- MCP stack versions (override pom-scijava where needed). The MCP SDK and
         Jetty 12 require Java 17 bytecode, so they cannot live on Fiji's shared
         classpath; they are bundled into an isolated lib/mcp-bundle.jar instead. -->
    <mcp.version>2.0.0</mcp.version>
    <jetty.version>12.0.16</jetty.version>
    <jackson.version>2.18.0</jackson.version>
    <slf4j.version>2.0.9</slf4j.version>

    <!-- The MCP stack is intentionally Java 17 (provided, isolated inside
         mcp-bundle). Skip pom-scijava's bytecode-version enforcer, which would
         otherwise ban these Java 17 dependencies. The core itself still
         compiles to Java 8 (see maven-compiler-plugin excludes). -->
    <enforcer.skip>true</enforcer.skip>
  </properties>

  <dependencies>
    <!-- ImageJ / SciJava (compile; Fiji supplies at runtime, scijava distributes
         the newer version when installing into a Fiji.app directory). -->
    <dependency>
      <groupId>net.imagej</groupId>
      <artifactId>imagej</artifactId>
    </dependency>
    <dependency>
      <groupId>net.imagej</groupId>
      <artifactId>imagej-common</artifactId>
    </dependency>
    <dependency>
      <groupId>net.imagej</groupId>
      <artifactId>ij</artifactId>
    </dependency>
    <dependency>
      <groupId>net.imagej</groupId>
      <artifactId>imagej-plugins-commands</artifactId>
    </dependency>
    <dependency>
      <groupId>net.imagej</groupId>
      <artifactId>imagej-legacy</artifactId>
    </dependency>
    <dependency>
      <groupId>sc.fiji</groupId>
      <artifactId>fiji</artifactId>
    </dependency>
    <dependency>
      <groupId>org.scijava</groupId>
      <artifactId>scijava-common</artifactId>
    </dependency>

    <!-- Web -->
    <dependency>
      <groupId>org.java-websocket</groupId>
      <artifactId>Java-WebSocket</artifactId>
      <version>1.6.0</version>
    </dependency>

    <!-- Appose for managed Python process lifecycle -->
    <dependency>
      <groupId>org.apposed</groupId>
      <artifactId>appose</artifactId>
      <version>0.11.0</version>
    </dependency>

    <!-- MCP stack (PROVIDED): NOT distributed into Fiji's shared classpath.
         Bundled into the isolated lib/mcp-bundle.jar (see mcp-bundle.xml) and
         loaded at runtime via a child-first ClassLoader. jackson is also used by
         the core (EventHandler); Fiji supplies its own jackson at runtime. -->
    <dependency>
      <groupId>io.modelcontextprotocol.sdk</groupId>
      <artifactId>mcp-core</artifactId>
      <version>${mcp.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.modelcontextprotocol.sdk</groupId>
      <artifactId>mcp-json-jackson2</artifactId>
      <version>${mcp.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-server</artifactId>
      <version>${jetty.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-util</artifactId>
      <version>${jetty.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-http</artifactId>
      <version>${jetty.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-io</artifactId>
      <version>${jetty.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-security</artifactId>
      <version>${jetty.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty.ee10</groupId>
      <artifactId>jetty-ee10-servlet</artifactId>
      <version>${jetty.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-core</artifactId>
      <version>${jackson.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-annotations</artifactId>
      <version>${jackson.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>${jackson.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.datatype</groupId>
      <artifactId>jackson-datatype-jsr310</artifactId>
      <version>${jackson.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j.version}</version>
      <scope>provided</scope>
    </dependency>

    <!-- ij1-patcher: used only by the dev exec (forked JVM) to patch ImageJ1.
         Version is managed by pom-scijava (not pinned here) so it stays aligned
         with the rest of the SciJava stack; NOT part of the MCP bundle. -->
    <dependency>
      <groupId>net.imagej</groupId>
      <artifactId>ij1-patcher</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- Unit tests. pom-scijava does not manage the junit-jupiter
         aggregator artifact, so its version is pinned via the inherited
         junit-jupiter.version property (resolves to 5.11.2 under pom-scijava
         40). surefire 3.5.1 auto-activates the JUnit Platform engine when
         junit-jupiter-engine is on the test classpath — no plugin config
         needed. mockito-core is managed by pom-scijava (4.11.0), so no
         version is pinned here. -->
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>${junit-jupiter.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <repositories>
    <repository>
      <id>scijava.public</id>
      <url>https://maven.scijava.org/content/groups/public</url>
    </repository>
  </repositories>

  <build>
    <resources>
      <resource>
        <directory>${project.basedir}/src/main/resources</directory>
      </resource>
      <resource>
        <directory>${project.basedir}/..</directory>
        <targetPath>META-INF/copilotj</targetPath>
        <includes>
          <include>copilotj/**/*.py</include>
          <include>copilotj/**/*.toml</include>
          <include>knowledge_bank/**/*.toml</include>
          <include>assets/**</include>
          <include>pyproject.toml</include>
          <include>uv.lock</include>
        </includes>
        <excludes>
          <exclude>**/__pycache__/**</exclude>
          <exclude>**/test/**</exclude>
          <exclude>assets/knowledge_base/*.faiss</exclude>
          <exclude>assets/knowledge_base/*.pkl</exclude>
          <exclude>assets/knowledge_base/rag_manifest.json</exclude>
          <exclude>assets/knowledge_base/*.rebuild.hash</exclude>
        </excludes>
      </resource>
    </resources>

    <plugins>
      <!-- Compile the core to Java 8 bytecode (exclude MCP sources), then compile
           the MCP sources to Java 17 bytecode into a separate output directory. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <executions>
          <execution>
            <id>default-compile</id>
            <configuration>
              <excludes>
                <exclude>copilotj/mcp/**</exclude>
              </excludes>
            </configuration>
          </execution>
          <execution>
            <id>compile-mcp</id>
            <phase>process-classes</phase>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <release>17</release>
              <includes>
                <include>copilotj/mcp/**/*.java</include>
              </includes>
              <outputDirectory>${project.build.directory}/mcp-classes</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Assemble the isolated MCP bundle: MCP classes + MCP provided deps
           (incl. transitive reactor-core), with merged META-INF/services. Output
           as lib/mcp-bundle.jar inside the core's output dir so it becomes an
           embedded resource of the final JAR. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.7.1</version>
        <configuration>
          <descriptors>
            <descriptor>${project.basedir}/src/assembly/mcp-bundle.xml</descriptor>
          </descriptors>
          <outputDirectory>${project.build.outputDirectory}/lib</outputDirectory>
          <finalName>mcp-bundle</finalName>
          <appendAssemblyId>false</appendAssemblyId>
          <attach>false</attach>
        </configuration>
        <executions>
          <execution>
            <id>make-mcp-bundle</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- Dev: run the plugin in a forked Java 21 JVM (mvn exec:exec). -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>3.2.0</version>
        <configuration>
          <executable>${java.home}/bin/java</executable>
          <!-- Use the compile classpath (includes provided-scoped deps) so the
               forked dev JVM has jackson (used by the core EventHandler) and the
               MCP stack. In a real Fiji these are supplied by Fiji / the embedded
               mcp-bundle, so they are provided-scoped, not distributed. -->
          <classpathScope>compile</classpathScope>
          <arguments>
            <argument>-javaagent:${settings.localRepository}/net/imagej/ij1-patcher/${ij1-patcher.version}/ij1-patcher-${ij1-patcher.version}.jar=init</argument>
            <argument>--add-opens=java.base/java.lang=ALL-UNNAMED</argument>
            <argument>-Dij.debug=true</argument>
            <argument>-Dscijava.log.level=debug</argument>
            <argument>-Dcopilotj.maxRetryWaitSecond=1</argument>
            <argument>-classpath</argument>
            <classpath/>
            <argument>copilotj.DefaultCopilotJBridgeService</argument>
          </arguments>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>