@jingyi0605/codingns 0.3.5 → 0.3.6
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 +13 -0
- package/bin/codingns.mjs +880 -9
- package/dist/public/assets/{TerminalPage-CgrfstRm.js → TerminalPage-D00S4KM6.js} +16 -16
- package/dist/public/assets/index-BlOinYqR.js +122 -0
- package/dist/public/assets/index-Dg_7g6lA.css +1 -0
- package/dist/public/index.html +2 -2
- package/dist/server/config/opencode-base-url-resolver.d.ts +7 -0
- package/dist/server/config/opencode-base-url-resolver.js +48 -11
- package/dist/server/config/opencode-base-url-resolver.js.map +1 -1
- package/dist/server/config/opencode-system-probe-helper-client.d.ts +4 -0
- package/dist/server/config/opencode-system-probe-helper-client.js +29 -0
- package/dist/server/config/opencode-system-probe-helper-client.js.map +1 -1
- package/dist/server/config/opencode-system-probe-helper-process.d.ts +12 -0
- package/dist/server/config/opencode-system-probe-helper-process.js +34 -7
- package/dist/server/config/opencode-system-probe-helper-process.js.map +1 -1
- package/dist/server/modules/assistant-capability/assistant-capability-controller.d.ts +144 -0
- package/dist/server/modules/assistant-capability/assistant-capability-controller.js +242 -1
- package/dist/server/modules/assistant-capability/assistant-capability-controller.js.map +1 -1
- package/dist/server/modules/assistant-capability/assistant-capability-service.d.ts +133 -2
- package/dist/server/modules/assistant-capability/assistant-capability-service.js +395 -2
- package/dist/server/modules/assistant-capability/assistant-capability-service.js.map +1 -1
- package/dist/server/modules/butler/butler-inbox-instruction-adapter.js +7 -6
- package/dist/server/modules/butler/butler-inbox-instruction-adapter.js.map +1 -1
- package/dist/server/modules/butler/butler-workspace-context.js +24 -13
- package/dist/server/modules/butler/butler-workspace-context.js.map +1 -1
- package/dist/server/modules/debug-target/debug-target-controller.d.ts +13 -0
- package/dist/server/modules/debug-target/debug-target-controller.js +77 -2
- package/dist/server/modules/debug-target/debug-target-controller.js.map +1 -1
- package/dist/server/modules/debug-target/debug-target-service.d.ts +11 -2
- package/dist/server/modules/debug-target/debug-target-service.js +138 -3
- package/dist/server/modules/debug-target/debug-target-service.js.map +1 -1
- package/dist/server/modules/git/git-command-helper-client.d.ts +2 -0
- package/dist/server/modules/git/git-command-helper-client.js +52 -3
- package/dist/server/modules/git/git-command-helper-client.js.map +1 -1
- package/dist/server/modules/git/git-command-helper-process.js +62 -9
- package/dist/server/modules/git/git-command-helper-process.js.map +1 -1
- package/dist/server/modules/git/git-command-runner.d.ts +1 -0
- package/dist/server/modules/git/git-command-runner.js +25 -0
- package/dist/server/modules/git/git-command-runner.js.map +1 -1
- package/dist/server/modules/git/git-controller.js +8 -7
- package/dist/server/modules/git/git-controller.js.map +1 -1
- package/dist/server/modules/git/git-read-service.d.ts +7 -7
- package/dist/server/modules/git/git-read-service.js +41 -24
- package/dist/server/modules/git/git-read-service.js.map +1 -1
- package/dist/server/modules/model-switch/cc-switch-adapter.js +6 -2
- package/dist/server/modules/model-switch/cc-switch-adapter.js.map +1 -1
- package/dist/server/modules/provider/codex-model-options.js +2 -3
- package/dist/server/modules/provider/codex-model-options.js.map +1 -1
- package/dist/server/modules/provider/opencode-model-options.js +2 -3
- package/dist/server/modules/provider/opencode-model-options.js.map +1 -1
- package/dist/server/modules/provider/provider-discovery-helper-client.d.ts +9 -4
- package/dist/server/modules/provider/provider-discovery-helper-client.js +87 -11
- package/dist/server/modules/provider/provider-discovery-helper-client.js.map +1 -1
- package/dist/server/modules/provider/provider-discovery-helper-process.js +52 -47
- package/dist/server/modules/provider/provider-discovery-helper-process.js.map +1 -1
- package/dist/server/modules/provider/provider-discovery-runtime.d.ts +4 -0
- package/dist/server/modules/provider/provider-discovery-runtime.js +65 -0
- package/dist/server/modules/provider/provider-discovery-runtime.js.map +1 -0
- package/dist/server/modules/sessions/session-history-service.d.ts +5 -2
- package/dist/server/modules/sessions/session-history-service.js +214 -26
- package/dist/server/modules/sessions/session-history-service.js.map +1 -1
- package/dist/server/modules/sessions/session-live-runtime-service.d.ts +2 -0
- package/dist/server/modules/sessions/session-live-runtime-service.js +67 -23
- package/dist/server/modules/sessions/session-live-runtime-service.js.map +1 -1
- package/dist/server/modules/skills/builtin-skill-service.d.ts +12 -0
- package/dist/server/modules/skills/builtin-skill-service.js +49 -0
- package/dist/server/modules/skills/builtin-skill-service.js.map +1 -0
- package/dist/server/modules/skills/builtin-skills/codingns-assistant/SKILL.md +75 -0
- package/dist/server/modules/skills/builtin-skills/codingns-assistant/agents/openai.yaml +4 -0
- package/dist/server/modules/skills/builtin-skills/codingns-assistant/references/cli-workflow.md +130 -0
- package/dist/server/modules/skills/skill-manager-service.d.ts +7 -0
- package/dist/server/modules/skills/skill-manager-service.js +98 -0
- package/dist/server/modules/skills/skill-manager-service.js.map +1 -1
- package/dist/server/modules/tailscale/tailscale-helper-client.d.ts +1 -0
- package/dist/server/modules/tailscale/tailscale-helper-client.js +12 -0
- package/dist/server/modules/tailscale/tailscale-helper-client.js.map +1 -1
- package/dist/server/modules/tasks/task-helper-client.d.ts +5 -0
- package/dist/server/modules/tasks/task-helper-client.js +45 -0
- package/dist/server/modules/tasks/task-helper-client.js.map +1 -1
- package/dist/server/modules/tasks/task-helper-process-handlers.d.ts +10 -3
- package/dist/server/modules/tasks/task-helper-process-handlers.js +7 -5
- package/dist/server/modules/tasks/task-helper-process-handlers.js.map +1 -1
- package/dist/server/modules/tasks/task-helper-process.js +11 -1
- package/dist/server/modules/tasks/task-helper-process.js.map +1 -1
- package/dist/server/modules/tasks/task-lane-executors.js +2 -2
- package/dist/server/modules/tasks/task-lane-executors.js.map +1 -1
- package/dist/server/modules/tasks/task-types.d.ts +1 -0
- package/dist/server/modules/tasks/task-types.js +1 -0
- package/dist/server/modules/tasks/task-types.js.map +1 -1
- package/dist/server/modules/terminal/command-template-service.d.ts +2 -2
- package/dist/server/modules/terminal/command-template-service.js +4 -4
- package/dist/server/modules/terminal/command-template-service.js.map +1 -1
- package/dist/server/modules/terminal/runtime/terminal-log-writer-client.js +1 -1
- package/dist/server/modules/terminal/runtime/terminal-log-writer-client.js.map +1 -1
- package/dist/server/modules/terminal/runtime/terminal-log-writer-process.js +160 -11
- package/dist/server/modules/terminal/runtime/terminal-log-writer-process.js.map +1 -1
- package/dist/server/modules/terminal/template-port-runtime.d.ts +1 -1
- package/dist/server/modules/terminal/template-port-runtime.js +87 -37
- package/dist/server/modules/terminal/template-port-runtime.js.map +1 -1
- package/dist/server/modules/terminal/terminal-service.d.ts +4 -0
- package/dist/server/modules/terminal/terminal-service.js +35 -1
- package/dist/server/modules/terminal/terminal-service.js.map +1 -1
- package/dist/server/modules/workbench/workbench-service.js +3 -3
- package/dist/server/modules/workbench/workbench-service.js.map +1 -1
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.d.ts +1 -0
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.js +118 -39
- package/dist/server/modules/workbench/workspace-panel-snapshot-service.js.map +1 -1
- package/dist/server/modules/workspace/workspace-code-composition.d.ts +1 -0
- package/dist/server/modules/workspace/workspace-code-composition.js +183 -1
- package/dist/server/modules/workspace/workspace-code-composition.js.map +1 -1
- package/dist/server/modules/workspace/workspace-service.js +54 -17
- package/dist/server/modules/workspace/workspace-service.js.map +1 -1
- package/dist/server/modules/worktree/worktree-cleanup-service.d.ts +1 -1
- package/dist/server/modules/worktree/worktree-cleanup-service.js +22 -17
- package/dist/server/modules/worktree/worktree-cleanup-service.js.map +1 -1
- package/dist/server/modules/worktree/worktree-controller.js +6 -5
- package/dist/server/modules/worktree/worktree-controller.js.map +1 -1
- package/dist/server/modules/worktree/worktree-manager.d.ts +1 -1
- package/dist/server/modules/worktree/worktree-manager.js +26 -19
- package/dist/server/modules/worktree/worktree-manager.js.map +1 -1
- package/dist/server/modules/worktree/worktree-merge-service.d.ts +2 -2
- package/dist/server/modules/worktree/worktree-merge-service.js +34 -27
- package/dist/server/modules/worktree/worktree-merge-service.js.map +1 -1
- package/dist/server/modules/worktree/worktree-sync-service.d.ts +1 -1
- package/dist/server/modules/worktree/worktree-sync-service.js +5 -3
- package/dist/server/modules/worktree/worktree-sync-service.js.map +1 -1
- package/dist/server/routes/assistant.js +24 -0
- package/dist/server/routes/assistant.js.map +1 -1
- package/dist/server/server/create-server.js +16 -1
- package/dist/server/server/create-server.js.map +1 -1
- package/dist/server/shared/http/request-abort.d.ts +2 -0
- package/dist/server/shared/http/request-abort.js +38 -0
- package/dist/server/shared/http/request-abort.js.map +1 -0
- package/dist/server/ws/workbench-ws-hub.d.ts +1 -0
- package/dist/server/ws/workbench-ws-hub.js +25 -3
- package/dist/server/ws/workbench-ws-hub.js.map +1 -1
- package/package.json +1 -1
- package/scripts/postinstall.mjs +33 -0
- package/dist/public/assets/index-Cek6u0b9.css +0 -1
- package/dist/public/assets/index-THHY79si.js +0 -122
package/bin/codingns.mjs
CHANGED
|
@@ -229,7 +229,7 @@ async function runAssistantCommand(argv) {
|
|
|
229
229
|
helpTopic: "terminals.history"
|
|
230
230
|
}, (options) => ({
|
|
231
231
|
beforeSeq: readOptionalTrimmedValue(options.values["before-seq"]),
|
|
232
|
-
limit:
|
|
232
|
+
limit: readAssistantTerminalHistoryLimitOption(options.values.limit)
|
|
233
233
|
})));
|
|
234
234
|
return;
|
|
235
235
|
}
|
|
@@ -246,6 +246,303 @@ async function runAssistantCommand(argv) {
|
|
|
246
246
|
})));
|
|
247
247
|
return;
|
|
248
248
|
}
|
|
249
|
+
case "terminals:close": {
|
|
250
|
+
const [terminalId, ...tail] = rest;
|
|
251
|
+
await printAssistantResponse(await requestAssistant({
|
|
252
|
+
method: "DELETE",
|
|
253
|
+
path: `/api/assistant/terminals/${requirePositional(terminalId, "terminalId")}`,
|
|
254
|
+
argv: tail,
|
|
255
|
+
helpTopic: "terminals.close"
|
|
256
|
+
}));
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
case "debug-targets:compatibility-matrix":
|
|
260
|
+
await printAssistantResponse(await requestAssistant({
|
|
261
|
+
method: "GET",
|
|
262
|
+
path: "/api/assistant/debug-targets/compatibility-matrix",
|
|
263
|
+
argv: rest,
|
|
264
|
+
helpTopic: "debug-targets.compatibility-matrix"
|
|
265
|
+
}));
|
|
266
|
+
return;
|
|
267
|
+
case "debug-targets:analyze":
|
|
268
|
+
await printAssistantResponse(await requestAssistant({
|
|
269
|
+
method: "POST",
|
|
270
|
+
path: "/api/assistant/debug-targets/analyze",
|
|
271
|
+
argv: rest,
|
|
272
|
+
supportedOptions: ["workspace-id", "root-path", "command-hint"],
|
|
273
|
+
repeatableOptions: ["command-hint"],
|
|
274
|
+
helpTopic: "debug-targets.analyze"
|
|
275
|
+
}, (options) => ({
|
|
276
|
+
workspaceId: requireOptionValue(options.values["workspace-id"], "workspace-id"),
|
|
277
|
+
rootPath: requireOptionValue(options.values["root-path"], "root-path"),
|
|
278
|
+
commandHints: readMultiOptionValues(options.values["command-hint"])
|
|
279
|
+
})));
|
|
280
|
+
return;
|
|
281
|
+
case "debug-targets:framework-analysis": {
|
|
282
|
+
const [targetId, ...tail] = rest;
|
|
283
|
+
await printAssistantResponse(await requestAssistant({
|
|
284
|
+
method: "GET",
|
|
285
|
+
path: `/api/assistant/debug-targets/${requirePositional(targetId, "targetId")}/framework-analysis`,
|
|
286
|
+
argv: tail,
|
|
287
|
+
helpTopic: "debug-targets.framework-analysis"
|
|
288
|
+
}));
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
case "debug-targets:refresh-framework-analysis": {
|
|
292
|
+
const [targetId, ...tail] = rest;
|
|
293
|
+
await printAssistantResponse(await requestAssistant({
|
|
294
|
+
method: "POST",
|
|
295
|
+
path: `/api/assistant/debug-targets/${requirePositional(targetId, "targetId")}/framework-analysis/refresh`,
|
|
296
|
+
argv: tail,
|
|
297
|
+
helpTopic: "debug-targets.refresh-framework-analysis"
|
|
298
|
+
}));
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
case "debug-targets:launch-plan": {
|
|
302
|
+
const [targetId, ...tail] = rest;
|
|
303
|
+
await printAssistantResponse(await requestAssistant({
|
|
304
|
+
method: "POST",
|
|
305
|
+
path: `/api/assistant/debug-targets/${requirePositional(targetId, "targetId")}/launch-plan`,
|
|
306
|
+
argv: tail,
|
|
307
|
+
supportedOptions: ["port-request"],
|
|
308
|
+
repeatableOptions: ["port-request"],
|
|
309
|
+
helpTopic: "debug-targets.launch-plan"
|
|
310
|
+
}, (options) => ({
|
|
311
|
+
portRequests: parseDebugPortRequests(options.values["port-request"])
|
|
312
|
+
})));
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
case "debug-targets:run": {
|
|
316
|
+
const [targetId, ...tail] = rest;
|
|
317
|
+
await printAssistantResponse(await requestAssistant({
|
|
318
|
+
method: "POST",
|
|
319
|
+
path: `/api/assistant/debug-targets/${requirePositional(targetId, "targetId")}/run`,
|
|
320
|
+
argv: tail,
|
|
321
|
+
supportedOptions: ["shell", "runtime-type", "port-request"],
|
|
322
|
+
repeatableOptions: ["port-request"],
|
|
323
|
+
helpTopic: "debug-targets.run"
|
|
324
|
+
}, (options) => ({
|
|
325
|
+
shell: readOptionalTrimmedValue(options.values.shell),
|
|
326
|
+
runtimeType: readOptionalTrimmedValue(options.values["runtime-type"]),
|
|
327
|
+
portRequests: parseDebugPortRequests(options.values["port-request"])
|
|
328
|
+
})));
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
case "debug-targets:runtime-latest": {
|
|
332
|
+
const [targetId, ...tail] = rest;
|
|
333
|
+
await printAssistantResponse(await requestAssistant({
|
|
334
|
+
method: "GET",
|
|
335
|
+
path: `/api/assistant/debug-targets/${requirePositional(targetId, "targetId")}/runtime-latest`,
|
|
336
|
+
argv: tail,
|
|
337
|
+
helpTopic: "debug-targets.runtime-latest"
|
|
338
|
+
}));
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
case "debug-targets:runtimes": {
|
|
342
|
+
const [targetId, ...tail] = rest;
|
|
343
|
+
await printAssistantResponse(await requestAssistant({
|
|
344
|
+
method: "GET",
|
|
345
|
+
path: `/api/assistant/debug-targets/${requirePositional(targetId, "targetId")}/runtimes`,
|
|
346
|
+
argv: tail,
|
|
347
|
+
supportedOptions: ["limit"],
|
|
348
|
+
helpTopic: "debug-targets.runtimes"
|
|
349
|
+
}, (options) => ({
|
|
350
|
+
limit: readOptionalTrimmedValue(options.values.limit)
|
|
351
|
+
})));
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
case "debug-runtimes:get": {
|
|
355
|
+
const [runtimeId, ...tail] = rest;
|
|
356
|
+
await printAssistantResponse(await requestAssistant({
|
|
357
|
+
method: "GET",
|
|
358
|
+
path: `/api/assistant/debug-runtimes/${requirePositional(runtimeId, "runtimeId")}`,
|
|
359
|
+
argv: tail,
|
|
360
|
+
helpTopic: "debug-runtimes.get"
|
|
361
|
+
}));
|
|
362
|
+
return;
|
|
363
|
+
}
|
|
364
|
+
case "workspaces:list":
|
|
365
|
+
await printAssistantResponse(await requestAssistant({
|
|
366
|
+
method: "GET",
|
|
367
|
+
path: "/api/assistant/workspaces",
|
|
368
|
+
argv: rest,
|
|
369
|
+
helpTopic: "workspaces.list"
|
|
370
|
+
}));
|
|
371
|
+
return;
|
|
372
|
+
case "workspaces:browse":
|
|
373
|
+
await printAssistantResponse(await requestAssistant({
|
|
374
|
+
method: "GET",
|
|
375
|
+
path: "/api/assistant/workspaces/browse",
|
|
376
|
+
argv: rest,
|
|
377
|
+
supportedOptions: ["path"],
|
|
378
|
+
helpTopic: "workspaces.browse"
|
|
379
|
+
}, (options) => ({
|
|
380
|
+
path: readOptionalTrimmedValue(options.values.path)
|
|
381
|
+
})));
|
|
382
|
+
return;
|
|
383
|
+
case "workspaces:mkdir":
|
|
384
|
+
await printAssistantResponse(await requestAssistant({
|
|
385
|
+
method: "POST",
|
|
386
|
+
path: "/api/assistant/workspaces/directories",
|
|
387
|
+
argv: rest,
|
|
388
|
+
supportedOptions: ["parent-path", "directory-name"],
|
|
389
|
+
helpTopic: "workspaces.mkdir"
|
|
390
|
+
}, (options) => ({
|
|
391
|
+
parentPath: requireOptionValue(options.values["parent-path"], "parent-path"),
|
|
392
|
+
directoryName: requireOptionValue(options.values["directory-name"], "directory-name")
|
|
393
|
+
})));
|
|
394
|
+
return;
|
|
395
|
+
case "workspaces:import":
|
|
396
|
+
await printAssistantResponse(await requestAssistant({
|
|
397
|
+
method: "POST",
|
|
398
|
+
path: "/api/assistant/workspaces/import",
|
|
399
|
+
argv: rest,
|
|
400
|
+
supportedOptions: ["path", "name"],
|
|
401
|
+
helpTopic: "workspaces.import"
|
|
402
|
+
}, (options) => ({
|
|
403
|
+
path: requireOptionValue(options.values.path, "path"),
|
|
404
|
+
name: readOptionalTrimmedValue(options.values.name)
|
|
405
|
+
})));
|
|
406
|
+
return;
|
|
407
|
+
case "workspaces:clone":
|
|
408
|
+
await printAssistantResponse(await requestAssistant({
|
|
409
|
+
method: "POST",
|
|
410
|
+
path: "/api/assistant/workspaces/clone",
|
|
411
|
+
argv: rest,
|
|
412
|
+
supportedOptions: [
|
|
413
|
+
"repository-url",
|
|
414
|
+
"parent-path",
|
|
415
|
+
"directory-name",
|
|
416
|
+
"name",
|
|
417
|
+
"auth-mode",
|
|
418
|
+
"username",
|
|
419
|
+
"password",
|
|
420
|
+
"auth-token"
|
|
421
|
+
],
|
|
422
|
+
helpTopic: "workspaces.clone"
|
|
423
|
+
}, (options) => ({
|
|
424
|
+
repositoryUrl: requireOptionValue(options.values["repository-url"], "repository-url"),
|
|
425
|
+
parentPath: requireOptionValue(options.values["parent-path"], "parent-path"),
|
|
426
|
+
directoryName: readOptionalTrimmedValue(options.values["directory-name"]),
|
|
427
|
+
name: readOptionalTrimmedValue(options.values.name),
|
|
428
|
+
auth: buildWorkspaceCloneAuth(options.values)
|
|
429
|
+
})));
|
|
430
|
+
return;
|
|
431
|
+
case "workspaces:reorder":
|
|
432
|
+
await printAssistantResponse(await requestAssistant({
|
|
433
|
+
method: "PUT",
|
|
434
|
+
path: "/api/assistant/workspaces/reorder",
|
|
435
|
+
argv: rest,
|
|
436
|
+
supportedOptions: ["workspace-id"],
|
|
437
|
+
repeatableOptions: ["workspace-id"],
|
|
438
|
+
helpTopic: "workspaces.reorder"
|
|
439
|
+
}, (options) => ({
|
|
440
|
+
workspaceIds: requireMultiOptionValues(options.values["workspace-id"], "workspace-id")
|
|
441
|
+
})));
|
|
442
|
+
return;
|
|
443
|
+
case "workspaces:management": {
|
|
444
|
+
const [workspaceId, ...tail] = rest;
|
|
445
|
+
await printAssistantResponse(await requestAssistant({
|
|
446
|
+
method: "GET",
|
|
447
|
+
path: `/api/assistant/workspaces/${requirePositional(workspaceId, "workspaceId")}/management`,
|
|
448
|
+
argv: tail,
|
|
449
|
+
helpTopic: "workspaces.management"
|
|
450
|
+
}));
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
case "workspaces:nav-state": {
|
|
454
|
+
const [workspaceId, ...tail] = rest;
|
|
455
|
+
await printAssistantResponse(await requestAssistant({
|
|
456
|
+
method: "PUT",
|
|
457
|
+
path: `/api/assistant/workspaces/${requirePositional(workspaceId, "workspaceId")}/navigation-state`,
|
|
458
|
+
argv: tail,
|
|
459
|
+
supportedOptions: ["collapsed", "background-color"],
|
|
460
|
+
helpTopic: "workspaces.nav-state"
|
|
461
|
+
}, (options) => {
|
|
462
|
+
const payload = {};
|
|
463
|
+
const collapsed = readOptionalTrimmedValue(options.values.collapsed);
|
|
464
|
+
const backgroundColor = readOptionalTrimmedValue(options.values["background-color"]);
|
|
465
|
+
|
|
466
|
+
if (collapsed !== null) {
|
|
467
|
+
payload.collapsed = parseBooleanOption(collapsed, "collapsed");
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
if (backgroundColor !== null) {
|
|
471
|
+
payload.backgroundColor = normalizeBackgroundColorOption(backgroundColor);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
return payload;
|
|
475
|
+
}));
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
case "workspaces:remove": {
|
|
479
|
+
const [workspaceId, ...tail] = rest;
|
|
480
|
+
await printAssistantResponse(await requestAssistant({
|
|
481
|
+
method: "DELETE",
|
|
482
|
+
path: `/api/assistant/workspaces/${requirePositional(workspaceId, "workspaceId")}`,
|
|
483
|
+
argv: tail,
|
|
484
|
+
helpTopic: "workspaces.remove"
|
|
485
|
+
}));
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
case "worktrees:tree":
|
|
489
|
+
await printAssistantResponse(await requestAssistant({
|
|
490
|
+
method: "GET",
|
|
491
|
+
path: "/api/assistant/worktrees/tree",
|
|
492
|
+
argv: rest,
|
|
493
|
+
supportedOptions: ["root-workspace-id"],
|
|
494
|
+
helpTopic: "worktrees.tree"
|
|
495
|
+
}, (options) => ({
|
|
496
|
+
rootWorkspaceId: requireOptionValue(options.values["root-workspace-id"], "root-workspace-id")
|
|
497
|
+
})));
|
|
498
|
+
return;
|
|
499
|
+
case "worktrees:create":
|
|
500
|
+
await printAssistantResponse(await requestAssistant({
|
|
501
|
+
method: "POST",
|
|
502
|
+
path: "/api/assistant/worktrees",
|
|
503
|
+
argv: rest,
|
|
504
|
+
supportedOptions: ["source-workspace-id", "branch-name", "display-name", "base-ref"],
|
|
505
|
+
helpTopic: "worktrees.create"
|
|
506
|
+
}, (options) => ({
|
|
507
|
+
sourceWorkspaceId: requireOptionValue(options.values["source-workspace-id"], "source-workspace-id"),
|
|
508
|
+
branchName: requireOptionValue(options.values["branch-name"], "branch-name"),
|
|
509
|
+
displayName: readOptionalTrimmedValue(options.values["display-name"]),
|
|
510
|
+
baseRef: readOptionalTrimmedValue(options.values["base-ref"])
|
|
511
|
+
})));
|
|
512
|
+
return;
|
|
513
|
+
case "worktrees:merge-preview": {
|
|
514
|
+
const [workspaceId, ...tail] = rest;
|
|
515
|
+
await printAssistantResponse(await requestAssistant({
|
|
516
|
+
method: "POST",
|
|
517
|
+
path: `/api/assistant/worktrees/${requirePositional(workspaceId, "workspaceId")}/merge-preview`,
|
|
518
|
+
argv: tail,
|
|
519
|
+
helpTopic: "worktrees.merge-preview"
|
|
520
|
+
}));
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
case "worktrees:merge": {
|
|
524
|
+
const [workspaceId, ...tail] = rest;
|
|
525
|
+
await printAssistantResponse(await requestAssistant({
|
|
526
|
+
method: "POST",
|
|
527
|
+
path: `/api/assistant/worktrees/${requirePositional(workspaceId, "workspaceId")}/merge-into-parent`,
|
|
528
|
+
argv: tail,
|
|
529
|
+
helpTopic: "worktrees.merge"
|
|
530
|
+
}));
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
case "worktrees:cleanup": {
|
|
534
|
+
const [workspaceId, ...tail] = rest;
|
|
535
|
+
await printAssistantResponse(await requestAssistant({
|
|
536
|
+
method: "POST",
|
|
537
|
+
path: `/api/assistant/worktrees/${requirePositional(workspaceId, "workspaceId")}/cleanup`,
|
|
538
|
+
argv: tail,
|
|
539
|
+
supportedFlags: ["delete-branch"],
|
|
540
|
+
helpTopic: "worktrees.cleanup"
|
|
541
|
+
}, (options) => ({
|
|
542
|
+
deleteBranch: options.flags["delete-branch"] === true
|
|
543
|
+
})));
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
249
546
|
default:
|
|
250
547
|
console.error(`[codingns] 不支持的 assistant 子命令:${group}${action ? ` ${action}` : ""}`);
|
|
251
548
|
printAssistantHelpTopic("assistant", 1);
|
|
@@ -336,7 +633,9 @@ async function requestAssistant(command, buildPayload) {
|
|
|
336
633
|
"base-url",
|
|
337
634
|
"token",
|
|
338
635
|
...(command.supportedOptions ?? [])
|
|
339
|
-
]
|
|
636
|
+
],
|
|
637
|
+
repeatableOptions: command.repeatableOptions ?? [],
|
|
638
|
+
supportedFlags: command.supportedFlags ?? []
|
|
340
639
|
});
|
|
341
640
|
|
|
342
641
|
if (options.help) {
|
|
@@ -366,13 +665,14 @@ async function requestAssistant(command, buildPayload) {
|
|
|
366
665
|
let response;
|
|
367
666
|
|
|
368
667
|
try {
|
|
668
|
+
const usesJsonBody = command.method === "POST" || command.method === "PUT";
|
|
369
669
|
response = await fetch(url, {
|
|
370
670
|
method: command.method,
|
|
371
671
|
headers: {
|
|
372
672
|
Authorization: `Bearer ${accessToken}`,
|
|
373
|
-
...(
|
|
673
|
+
...(usesJsonBody ? { "Content-Type": "application/json" } : {})
|
|
374
674
|
},
|
|
375
|
-
body:
|
|
675
|
+
body: usesJsonBody ? JSON.stringify(payload ?? {}) : undefined
|
|
376
676
|
});
|
|
377
677
|
} catch (error) {
|
|
378
678
|
const message = error instanceof Error ? error.message : "未知网络错误";
|
|
@@ -571,10 +871,14 @@ function parseArgs(argv, input = {}) {
|
|
|
571
871
|
}
|
|
572
872
|
|
|
573
873
|
function resolveAssistantBaseUrl(input) {
|
|
574
|
-
const
|
|
874
|
+
const configuredBaseUrl = readStringOption(
|
|
575
875
|
input,
|
|
576
876
|
process.env.CODINGNS_BASE_URL,
|
|
577
|
-
process.env.CODINGNS_SERVER_BASE_URL
|
|
877
|
+
process.env.CODINGNS_SERVER_BASE_URL
|
|
878
|
+
);
|
|
879
|
+
const baseUrl = readStringOption(
|
|
880
|
+
configuredBaseUrl,
|
|
881
|
+
configuredBaseUrl ? "" : readAssistantCredentialField("apiBaseUrl"),
|
|
578
882
|
"http://127.0.0.1:3002"
|
|
579
883
|
);
|
|
580
884
|
|
|
@@ -586,19 +890,109 @@ function resolveAssistantBaseUrl(input) {
|
|
|
586
890
|
}
|
|
587
891
|
|
|
588
892
|
function resolveAssistantAccessToken(input) {
|
|
589
|
-
const
|
|
893
|
+
const configuredAccessToken = readStringOption(
|
|
590
894
|
input,
|
|
591
895
|
process.env.CODINGNS_ACCESS_TOKEN,
|
|
592
896
|
process.env.CODINGNS_TOKEN
|
|
593
897
|
);
|
|
898
|
+
const accessToken = readStringOption(
|
|
899
|
+
configuredAccessToken,
|
|
900
|
+
configuredAccessToken ? "" : readAssistantCredentialField("accessToken")
|
|
901
|
+
);
|
|
594
902
|
|
|
595
903
|
if (!accessToken) {
|
|
596
|
-
fail(
|
|
904
|
+
fail(
|
|
905
|
+
"缺少助手调用 access token,请传 --token、设置 CODINGNS_ACCESS_TOKEN,或在当前目录/上级目录提供 BUTLER_AUTH.json(也可用 CODINGNS_AUTH_FILE 指定)"
|
|
906
|
+
);
|
|
597
907
|
}
|
|
598
908
|
|
|
599
909
|
return accessToken;
|
|
600
910
|
}
|
|
601
911
|
|
|
912
|
+
var cachedAssistantCredential;
|
|
913
|
+
|
|
914
|
+
function readAssistantCredentialField(field) {
|
|
915
|
+
const credential = readAssistantCredential();
|
|
916
|
+
|
|
917
|
+
if (!credential) {
|
|
918
|
+
return "";
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
const value = credential[field];
|
|
922
|
+
return typeof value === "string" ? value : "";
|
|
923
|
+
}
|
|
924
|
+
|
|
925
|
+
function readAssistantCredential() {
|
|
926
|
+
if (cachedAssistantCredential !== undefined) {
|
|
927
|
+
return cachedAssistantCredential;
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
const credentialFilePath = resolveAssistantCredentialFilePath();
|
|
931
|
+
|
|
932
|
+
if (!credentialFilePath) {
|
|
933
|
+
cachedAssistantCredential = null;
|
|
934
|
+
return cachedAssistantCredential;
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
let rawContent;
|
|
938
|
+
|
|
939
|
+
try {
|
|
940
|
+
rawContent = fs.readFileSync(credentialFilePath, "utf8");
|
|
941
|
+
} catch (error) {
|
|
942
|
+
const message = error instanceof Error ? error.message : "未知错误";
|
|
943
|
+
fail(`读取助手认证文件失败:${credentialFilePath}(${message})`);
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
let parsed;
|
|
947
|
+
|
|
948
|
+
try {
|
|
949
|
+
parsed = JSON.parse(rawContent);
|
|
950
|
+
} catch (error) {
|
|
951
|
+
const message = error instanceof Error ? error.message : "未知错误";
|
|
952
|
+
fail(`助手认证文件不是合法 JSON:${credentialFilePath}(${message})`);
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
cachedAssistantCredential = {
|
|
956
|
+
filePath: credentialFilePath,
|
|
957
|
+
accessToken: typeof parsed?.accessToken === "string" ? parsed.accessToken.trim() : "",
|
|
958
|
+
apiBaseUrl: typeof parsed?.apiBaseUrl === "string" ? parsed.apiBaseUrl.trim() : ""
|
|
959
|
+
};
|
|
960
|
+
return cachedAssistantCredential;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
function resolveAssistantCredentialFilePath() {
|
|
964
|
+
const configuredPath = readStringOption(
|
|
965
|
+
process.env.CODINGNS_AUTH_FILE,
|
|
966
|
+
process.env.BUTLER_AUTH_FILE
|
|
967
|
+
);
|
|
968
|
+
|
|
969
|
+
if (configuredPath) {
|
|
970
|
+
return path.resolve(configuredPath);
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
return findFileUpward(process.cwd(), "BUTLER_AUTH.json");
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
function findFileUpward(startPath, fileName) {
|
|
977
|
+
let currentPath = path.resolve(startPath);
|
|
978
|
+
|
|
979
|
+
while (true) {
|
|
980
|
+
const candidatePath = path.join(currentPath, fileName);
|
|
981
|
+
|
|
982
|
+
if (fs.existsSync(candidatePath) && fs.statSync(candidatePath).isFile()) {
|
|
983
|
+
return candidatePath;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
const parentPath = path.dirname(currentPath);
|
|
987
|
+
|
|
988
|
+
if (parentPath === currentPath) {
|
|
989
|
+
return null;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
currentPath = parentPath;
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
|
|
602
996
|
function readStringOption(...values) {
|
|
603
997
|
for (const value of values) {
|
|
604
998
|
if (typeof value === "string" && value.trim().length > 0) {
|
|
@@ -614,6 +1008,27 @@ function readOptionalTrimmedValue(value) {
|
|
|
614
1008
|
return normalized.length > 0 ? normalized : null;
|
|
615
1009
|
}
|
|
616
1010
|
|
|
1011
|
+
function readAssistantTerminalHistoryLimitOption(value) {
|
|
1012
|
+
const normalized = readOptionalTrimmedValue(value);
|
|
1013
|
+
|
|
1014
|
+
if (!normalized) {
|
|
1015
|
+
return null;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
const parsed = Number.parseInt(normalized, 10);
|
|
1019
|
+
|
|
1020
|
+
if (!Number.isInteger(parsed) || parsed < 1) {
|
|
1021
|
+
return normalized;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
if (parsed <= 100) {
|
|
1025
|
+
return normalized;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
console.warn("[codingns] assistant terminals history 的 --limit 最大为 100,已自动收敛到 100。");
|
|
1029
|
+
return "100";
|
|
1030
|
+
}
|
|
1031
|
+
|
|
617
1032
|
function readMultiOptionValues(value) {
|
|
618
1033
|
const values = Array.isArray(value)
|
|
619
1034
|
? value
|
|
@@ -753,8 +1168,13 @@ assistant 例子:
|
|
|
753
1168
|
|
|
754
1169
|
codingns assistant capabilities list --token <token>
|
|
755
1170
|
codingns assistant projects list --status active --token <token>
|
|
1171
|
+
codingns assistant workspaces list --token <token>
|
|
1172
|
+
codingns assistant debug-targets analyze --workspace-id <id> --root-path <path> --token <token>
|
|
1173
|
+
codingns assistant debug-targets launch-plan <targetId> --port-request role=backend,cwd=apps/api,port=44001 --token <token>
|
|
1174
|
+
codingns assistant worktrees tree --root-workspace-id <id> --token <token>
|
|
756
1175
|
codingns assistant sessions send <sessionId> --message "继续修复类型错误" --token <token>
|
|
757
1176
|
codingns assistant terminals send <terminalId> --input "npm test\\n" --token <token>
|
|
1177
|
+
codingns assistant terminals close <terminalId> --token <token>
|
|
758
1178
|
|
|
759
1179
|
skills 例子:
|
|
760
1180
|
|
|
@@ -840,6 +1260,115 @@ codingns assistant projects get
|
|
|
840
1260
|
|
|
841
1261
|
用法:
|
|
842
1262
|
codingns assistant projects get <projectId> --token <token>
|
|
1263
|
+
`.trim();
|
|
1264
|
+
case "workspaces":
|
|
1265
|
+
return `
|
|
1266
|
+
codingns assistant workspaces
|
|
1267
|
+
|
|
1268
|
+
可用动作:
|
|
1269
|
+
list 列出当前工作区
|
|
1270
|
+
browse 浏览可导入目录
|
|
1271
|
+
mkdir 创建目录
|
|
1272
|
+
import 导入工作区
|
|
1273
|
+
clone 克隆并导入工作区
|
|
1274
|
+
reorder 调整工作区顺序
|
|
1275
|
+
management 读取工作区管理摘要
|
|
1276
|
+
nav-state 更新导航状态
|
|
1277
|
+
remove 移除工作区
|
|
1278
|
+
|
|
1279
|
+
示例:
|
|
1280
|
+
codingns assistant workspaces list --token <token>
|
|
1281
|
+
codingns assistant workspaces import --path /repo/demo --token <token>
|
|
1282
|
+
`.trim();
|
|
1283
|
+
case "workspaces.list":
|
|
1284
|
+
return `
|
|
1285
|
+
codingns assistant workspaces list
|
|
1286
|
+
|
|
1287
|
+
用途:
|
|
1288
|
+
列出当前可见工作区。
|
|
1289
|
+
|
|
1290
|
+
用法:
|
|
1291
|
+
codingns assistant workspaces list --token <token>
|
|
1292
|
+
`.trim();
|
|
1293
|
+
case "workspaces.browse":
|
|
1294
|
+
return `
|
|
1295
|
+
codingns assistant workspaces browse
|
|
1296
|
+
|
|
1297
|
+
用途:
|
|
1298
|
+
浏览本地目录,给导入或 clone 选目标位置。
|
|
1299
|
+
|
|
1300
|
+
用法:
|
|
1301
|
+
codingns assistant workspaces browse [--path <path>] --token <token>
|
|
1302
|
+
`.trim();
|
|
1303
|
+
case "workspaces.mkdir":
|
|
1304
|
+
return `
|
|
1305
|
+
codingns assistant workspaces mkdir
|
|
1306
|
+
|
|
1307
|
+
用途:
|
|
1308
|
+
在指定父目录下创建新目录。
|
|
1309
|
+
|
|
1310
|
+
用法:
|
|
1311
|
+
codingns assistant workspaces mkdir --parent-path <path> --directory-name <name> --token <token>
|
|
1312
|
+
`.trim();
|
|
1313
|
+
case "workspaces.import":
|
|
1314
|
+
return `
|
|
1315
|
+
codingns assistant workspaces import
|
|
1316
|
+
|
|
1317
|
+
用途:
|
|
1318
|
+
把已有目录导入成工作区。
|
|
1319
|
+
|
|
1320
|
+
用法:
|
|
1321
|
+
codingns assistant workspaces import --path <path> [--name <name>] --token <token>
|
|
1322
|
+
`.trim();
|
|
1323
|
+
case "workspaces.clone":
|
|
1324
|
+
return `
|
|
1325
|
+
codingns assistant workspaces clone
|
|
1326
|
+
|
|
1327
|
+
用途:
|
|
1328
|
+
克隆 Git 仓库并导入成工作区。
|
|
1329
|
+
|
|
1330
|
+
用法:
|
|
1331
|
+
codingns assistant workspaces clone --repository-url <url> --parent-path <path> [--directory-name <name>] [--name <name>] [--auth-mode none|basic|token] [--username <name>] [--password <password>] [--auth-token <token>] --token <token>
|
|
1332
|
+
`.trim();
|
|
1333
|
+
case "workspaces.reorder":
|
|
1334
|
+
return `
|
|
1335
|
+
codingns assistant workspaces reorder
|
|
1336
|
+
|
|
1337
|
+
用途:
|
|
1338
|
+
调整工作区显示顺序,必须提交当前全部可见工作区。
|
|
1339
|
+
|
|
1340
|
+
用法:
|
|
1341
|
+
codingns assistant workspaces reorder --workspace-id <id> [--workspace-id <id>] --token <token>
|
|
1342
|
+
`.trim();
|
|
1343
|
+
case "workspaces.management":
|
|
1344
|
+
return `
|
|
1345
|
+
codingns assistant workspaces management
|
|
1346
|
+
|
|
1347
|
+
用途:
|
|
1348
|
+
读取工作区 Git 和代码构成摘要。
|
|
1349
|
+
|
|
1350
|
+
用法:
|
|
1351
|
+
codingns assistant workspaces management <workspaceId> --token <token>
|
|
1352
|
+
`.trim();
|
|
1353
|
+
case "workspaces.nav-state":
|
|
1354
|
+
return `
|
|
1355
|
+
codingns assistant workspaces nav-state
|
|
1356
|
+
|
|
1357
|
+
用途:
|
|
1358
|
+
更新工作区导航状态,比如折叠状态和背景色。
|
|
1359
|
+
|
|
1360
|
+
用法:
|
|
1361
|
+
codingns assistant workspaces nav-state <workspaceId> [--collapsed true|false] [--background-color #RRGGBB|none] --token <token>
|
|
1362
|
+
`.trim();
|
|
1363
|
+
case "workspaces.remove":
|
|
1364
|
+
return `
|
|
1365
|
+
codingns assistant workspaces remove
|
|
1366
|
+
|
|
1367
|
+
用途:
|
|
1368
|
+
移除工作区入口,不直接删除磁盘目录。
|
|
1369
|
+
|
|
1370
|
+
用法:
|
|
1371
|
+
codingns assistant workspaces remove <workspaceId> --token <token>
|
|
843
1372
|
`.trim();
|
|
844
1373
|
case "sessions":
|
|
845
1374
|
return `
|
|
@@ -925,6 +1454,7 @@ codingns assistant terminals
|
|
|
925
1454
|
list 列出项目或工作区下的终端
|
|
926
1455
|
history 读取终端历史输出
|
|
927
1456
|
send 向受控终端发送输入
|
|
1457
|
+
close 关闭受控终端
|
|
928
1458
|
|
|
929
1459
|
示例:
|
|
930
1460
|
codingns assistant terminals list --project-id <projectId> --token <token>
|
|
@@ -959,15 +1489,226 @@ codingns assistant terminals send
|
|
|
959
1489
|
|
|
960
1490
|
用法:
|
|
961
1491
|
codingns assistant terminals send <terminalId> --input "npm test\\n" --token <token>
|
|
1492
|
+
`.trim();
|
|
1493
|
+
case "terminals.close":
|
|
1494
|
+
return `
|
|
1495
|
+
codingns assistant terminals close
|
|
1496
|
+
|
|
1497
|
+
用途:
|
|
1498
|
+
关闭指定受控终端,常用于停止调试进程或回收运行资源。
|
|
1499
|
+
|
|
1500
|
+
用法:
|
|
1501
|
+
codingns assistant terminals close <terminalId> --token <token>
|
|
1502
|
+
`.trim();
|
|
1503
|
+
case "debug-targets":
|
|
1504
|
+
return `
|
|
1505
|
+
codingns assistant debug-targets
|
|
1506
|
+
|
|
1507
|
+
可用动作:
|
|
1508
|
+
compatibility-matrix 读取框架兼容矩阵
|
|
1509
|
+
analyze 分析工作区调试目标
|
|
1510
|
+
framework-analysis 读取框架分析结果
|
|
1511
|
+
refresh-framework-analysis 刷新框架分析结果
|
|
1512
|
+
launch-plan 生成启动计划,可显式请求端口
|
|
1513
|
+
run 启动调试目标,可显式请求端口
|
|
1514
|
+
runtime-latest 读取最近一次运行态
|
|
1515
|
+
runtimes 读取运行历史
|
|
1516
|
+
|
|
1517
|
+
示例:
|
|
1518
|
+
codingns assistant debug-targets analyze --workspace-id <id> --root-path /repo/demo --token <token>
|
|
1519
|
+
codingns assistant debug-targets launch-plan <targetId> --port-request role=backend,cwd=apps/api,port=44001 --token <token>
|
|
1520
|
+
`.trim();
|
|
1521
|
+
case "debug-targets.compatibility-matrix":
|
|
1522
|
+
return `
|
|
1523
|
+
codingns assistant debug-targets compatibility-matrix
|
|
1524
|
+
|
|
1525
|
+
用途:
|
|
1526
|
+
读取平台当前支持的框架兼容矩阵和建议注入方式。
|
|
1527
|
+
|
|
1528
|
+
用法:
|
|
1529
|
+
codingns assistant debug-targets compatibility-matrix --token <token>
|
|
1530
|
+
`.trim();
|
|
1531
|
+
case "debug-targets.analyze":
|
|
1532
|
+
return `
|
|
1533
|
+
codingns assistant debug-targets analyze
|
|
1534
|
+
|
|
1535
|
+
用途:
|
|
1536
|
+
分析指定工作区下的调试目标、服务和框架兼容性。
|
|
1537
|
+
|
|
1538
|
+
用法:
|
|
1539
|
+
codingns assistant debug-targets analyze --workspace-id <id> --root-path <path> [--command-hint "pnpm dev"] [--command-hint "node server.js"] --token <token>
|
|
1540
|
+
`.trim();
|
|
1541
|
+
case "debug-targets.framework-analysis":
|
|
1542
|
+
return `
|
|
1543
|
+
codingns assistant debug-targets framework-analysis
|
|
1544
|
+
|
|
1545
|
+
用途:
|
|
1546
|
+
读取指定调试目标当前的框架分析结果。
|
|
1547
|
+
|
|
1548
|
+
用法:
|
|
1549
|
+
codingns assistant debug-targets framework-analysis <targetId> --token <token>
|
|
1550
|
+
`.trim();
|
|
1551
|
+
case "debug-targets.refresh-framework-analysis":
|
|
1552
|
+
return `
|
|
1553
|
+
codingns assistant debug-targets refresh-framework-analysis
|
|
1554
|
+
|
|
1555
|
+
用途:
|
|
1556
|
+
刷新指定调试目标的框架分析结果。
|
|
1557
|
+
|
|
1558
|
+
用法:
|
|
1559
|
+
codingns assistant debug-targets refresh-framework-analysis <targetId> --token <token>
|
|
1560
|
+
`.trim();
|
|
1561
|
+
case "debug-targets.launch-plan":
|
|
1562
|
+
return `
|
|
1563
|
+
codingns assistant debug-targets launch-plan
|
|
1564
|
+
|
|
1565
|
+
用途:
|
|
1566
|
+
生成调试目标启动计划,可通过重复的 --port-request 显式请求服务端口。
|
|
1567
|
+
|
|
1568
|
+
用法:
|
|
1569
|
+
codingns assistant debug-targets launch-plan <targetId> [--port-request role=frontend,cwd=apps/web,port=43001] [--port-request role=backend,cwd=apps/api,port=44001] --token <token>
|
|
1570
|
+
`.trim();
|
|
1571
|
+
case "debug-targets.run":
|
|
1572
|
+
return `
|
|
1573
|
+
codingns assistant debug-targets run
|
|
1574
|
+
|
|
1575
|
+
用途:
|
|
1576
|
+
启动调试目标,可选指定 shell、runtimeType 和显式端口请求。
|
|
1577
|
+
|
|
1578
|
+
用法:
|
|
1579
|
+
codingns assistant debug-targets run <targetId> [--shell zsh] [--runtime-type tmux|embedded-pty|conpty-powershell|conpty-cmd|conpty-git-bash] [--port-request role=backend,cwd=apps/api,port=44001] --token <token>
|
|
1580
|
+
`.trim();
|
|
1581
|
+
case "debug-targets.runtime-latest":
|
|
1582
|
+
return `
|
|
1583
|
+
codingns assistant debug-targets runtime-latest
|
|
1584
|
+
|
|
1585
|
+
用途:
|
|
1586
|
+
读取指定调试目标最近一次运行态,没有运行记录时返回 null。
|
|
1587
|
+
|
|
1588
|
+
用法:
|
|
1589
|
+
codingns assistant debug-targets runtime-latest <targetId> --token <token>
|
|
1590
|
+
`.trim();
|
|
1591
|
+
case "debug-targets.runtimes":
|
|
1592
|
+
return `
|
|
1593
|
+
codingns assistant debug-targets runtimes
|
|
1594
|
+
|
|
1595
|
+
用途:
|
|
1596
|
+
读取指定调试目标最近几次运行历史。
|
|
1597
|
+
|
|
1598
|
+
用法:
|
|
1599
|
+
codingns assistant debug-targets runtimes <targetId> [--limit 5] --token <token>
|
|
1600
|
+
`.trim();
|
|
1601
|
+
case "debug-runtimes":
|
|
1602
|
+
return `
|
|
1603
|
+
codingns assistant debug-runtimes
|
|
1604
|
+
|
|
1605
|
+
可用动作:
|
|
1606
|
+
get 读取单个调试运行时详情
|
|
1607
|
+
|
|
1608
|
+
示例:
|
|
1609
|
+
codingns assistant debug-runtimes get <runtimeId> --token <token>
|
|
1610
|
+
`.trim();
|
|
1611
|
+
case "debug-runtimes.get":
|
|
1612
|
+
return `
|
|
1613
|
+
codingns assistant debug-runtimes get
|
|
1614
|
+
|
|
1615
|
+
用途:
|
|
1616
|
+
读取指定调试运行时详情,包括服务、绑定、租约和终端实例。
|
|
1617
|
+
|
|
1618
|
+
用法:
|
|
1619
|
+
codingns assistant debug-runtimes get <runtimeId> --token <token>
|
|
1620
|
+
`.trim();
|
|
1621
|
+
case "worktrees":
|
|
1622
|
+
return `
|
|
1623
|
+
codingns assistant worktrees
|
|
1624
|
+
|
|
1625
|
+
可用动作:
|
|
1626
|
+
tree 读取工作树结构
|
|
1627
|
+
create 创建子工作树
|
|
1628
|
+
merge-preview 读取合并预览
|
|
1629
|
+
merge 合并回父工作区
|
|
1630
|
+
cleanup 清理子工作树
|
|
1631
|
+
|
|
1632
|
+
示例:
|
|
1633
|
+
codingns assistant worktrees tree --root-workspace-id <id> --token <token>
|
|
1634
|
+
codingns assistant worktrees create --source-workspace-id <id> --branch-name feature/demo --token <token>
|
|
1635
|
+
`.trim();
|
|
1636
|
+
case "worktrees.tree":
|
|
1637
|
+
return `
|
|
1638
|
+
codingns assistant worktrees tree
|
|
1639
|
+
|
|
1640
|
+
用途:
|
|
1641
|
+
读取某个根工作区下面的工作树结构。
|
|
1642
|
+
|
|
1643
|
+
用法:
|
|
1644
|
+
codingns assistant worktrees tree --root-workspace-id <id> --token <token>
|
|
1645
|
+
`.trim();
|
|
1646
|
+
case "worktrees.create":
|
|
1647
|
+
return `
|
|
1648
|
+
codingns assistant worktrees create
|
|
1649
|
+
|
|
1650
|
+
用途:
|
|
1651
|
+
从指定工作区创建新的子工作树。
|
|
1652
|
+
|
|
1653
|
+
用法:
|
|
1654
|
+
codingns assistant worktrees create --source-workspace-id <id> --branch-name <name> [--display-name <name>] [--base-ref <ref>] --token <token>
|
|
1655
|
+
`.trim();
|
|
1656
|
+
case "worktrees.merge-preview":
|
|
1657
|
+
return `
|
|
1658
|
+
codingns assistant worktrees merge-preview
|
|
1659
|
+
|
|
1660
|
+
用途:
|
|
1661
|
+
查看子工作树合并回父工作区前的阻塞项和预览。
|
|
1662
|
+
|
|
1663
|
+
用法:
|
|
1664
|
+
codingns assistant worktrees merge-preview <workspaceId> --token <token>
|
|
1665
|
+
`.trim();
|
|
1666
|
+
case "worktrees.merge":
|
|
1667
|
+
return `
|
|
1668
|
+
codingns assistant worktrees merge
|
|
1669
|
+
|
|
1670
|
+
用途:
|
|
1671
|
+
把子工作树合并回父工作区。
|
|
1672
|
+
|
|
1673
|
+
用法:
|
|
1674
|
+
codingns assistant worktrees merge <workspaceId> --token <token>
|
|
1675
|
+
`.trim();
|
|
1676
|
+
case "worktrees.cleanup":
|
|
1677
|
+
return `
|
|
1678
|
+
codingns assistant worktrees cleanup
|
|
1679
|
+
|
|
1680
|
+
用途:
|
|
1681
|
+
清理已经完成的子工作树,可选同时删除分支。
|
|
1682
|
+
|
|
1683
|
+
用法:
|
|
1684
|
+
codingns assistant worktrees cleanup <workspaceId> [--delete-branch] --token <token>
|
|
962
1685
|
`.trim();
|
|
963
1686
|
default:
|
|
964
1687
|
return `
|
|
965
1688
|
codingns assistant 用法:
|
|
966
1689
|
|
|
967
|
-
codingns assistant help [capabilities|projects|sessions|terminals] [action]
|
|
1690
|
+
codingns assistant help [capabilities|projects|sessions|terminals|debug-targets|debug-runtimes|workspaces|worktrees] [action]
|
|
968
1691
|
codingns assistant capabilities list [--base-url http://127.0.0.1:3002] --token <token>
|
|
969
1692
|
codingns assistant projects list [--workspace-id <id>] [--status active|paused|archived] [--risk-level low|medium|high] --token <token>
|
|
970
1693
|
codingns assistant projects get <projectId> [--base-url ...] --token <token>
|
|
1694
|
+
codingns assistant debug-targets compatibility-matrix [--base-url ...] --token <token>
|
|
1695
|
+
codingns assistant debug-targets analyze --workspace-id <id> --root-path <path> [--command-hint <command>] [--command-hint <command>] [--base-url ...] --token <token>
|
|
1696
|
+
codingns assistant debug-targets framework-analysis <targetId> [--base-url ...] --token <token>
|
|
1697
|
+
codingns assistant debug-targets refresh-framework-analysis <targetId> [--base-url ...] --token <token>
|
|
1698
|
+
codingns assistant debug-targets launch-plan <targetId> [--port-request role=backend,cwd=apps/api,port=44001] [--base-url ...] --token <token>
|
|
1699
|
+
codingns assistant debug-targets run <targetId> [--shell zsh] [--runtime-type tmux|embedded-pty|conpty-powershell|conpty-cmd|conpty-git-bash] [--port-request role=backend,cwd=apps/api,port=44001] [--base-url ...] --token <token>
|
|
1700
|
+
codingns assistant debug-targets runtime-latest <targetId> [--base-url ...] --token <token>
|
|
1701
|
+
codingns assistant debug-targets runtimes <targetId> [--limit 5] [--base-url ...] --token <token>
|
|
1702
|
+
codingns assistant debug-runtimes get <runtimeId> [--base-url ...] --token <token>
|
|
1703
|
+
codingns assistant workspaces list [--base-url ...] --token <token>
|
|
1704
|
+
codingns assistant workspaces browse [--path <path>] [--base-url ...] --token <token>
|
|
1705
|
+
codingns assistant workspaces mkdir --parent-path <path> --directory-name <name> [--base-url ...] --token <token>
|
|
1706
|
+
codingns assistant workspaces import --path <path> [--name <name>] [--base-url ...] --token <token>
|
|
1707
|
+
codingns assistant workspaces clone --repository-url <url> --parent-path <path> [--directory-name <name>] [--name <name>] [--auth-mode none|basic|token] [--username <name>] [--password <password>] [--auth-token <token>] [--base-url ...] --token <token>
|
|
1708
|
+
codingns assistant workspaces reorder --workspace-id <id> [--workspace-id <id>] [--base-url ...] --token <token>
|
|
1709
|
+
codingns assistant workspaces management <workspaceId> [--base-url ...] --token <token>
|
|
1710
|
+
codingns assistant workspaces nav-state <workspaceId> [--collapsed true|false] [--background-color #RRGGBB|none] [--base-url ...] --token <token>
|
|
1711
|
+
codingns assistant workspaces remove <workspaceId> [--base-url ...] --token <token>
|
|
971
1712
|
codingns assistant sessions list --project <projectId> [--base-url ...] --token <token>
|
|
972
1713
|
codingns assistant sessions get <sessionId> [--base-url ...] --token <token>
|
|
973
1714
|
codingns assistant sessions messages <sessionId> [--cursor <cursor>] [--limit 40] [--direction forward|backward] --token <token>
|
|
@@ -977,11 +1718,18 @@ codingns assistant 用法:
|
|
|
977
1718
|
codingns assistant terminals list [--workspace-id <id> | --project-id <id>] --token <token>
|
|
978
1719
|
codingns assistant terminals history <terminalId> [--before-seq <n>] [--limit 20] --token <token>
|
|
979
1720
|
codingns assistant terminals send <terminalId> --input "npm test\\n" --token <token>
|
|
1721
|
+
codingns assistant terminals close <terminalId> [--base-url ...] --token <token>
|
|
1722
|
+
codingns assistant worktrees tree --root-workspace-id <id> [--base-url ...] --token <token>
|
|
1723
|
+
codingns assistant worktrees create --source-workspace-id <id> --branch-name <name> [--display-name <name>] [--base-ref <ref>] [--base-url ...] --token <token>
|
|
1724
|
+
codingns assistant worktrees merge-preview <workspaceId> [--base-url ...] --token <token>
|
|
1725
|
+
codingns assistant worktrees merge <workspaceId> [--base-url ...] --token <token>
|
|
1726
|
+
codingns assistant worktrees cleanup <workspaceId> [--delete-branch] [--base-url ...] --token <token>
|
|
980
1727
|
|
|
981
1728
|
环境变量:
|
|
982
1729
|
|
|
983
1730
|
CODINGNS_BASE_URL 默认 Host 地址,未传时默认 http://127.0.0.1:3002
|
|
984
1731
|
CODINGNS_ACCESS_TOKEN 默认 Bearer token
|
|
1732
|
+
CODINGNS_AUTH_FILE 可选认证文件,支持读取 apiBaseUrl/accessToken
|
|
985
1733
|
`.trim();
|
|
986
1734
|
}
|
|
987
1735
|
}
|
|
@@ -1041,6 +1789,7 @@ codingns skills 用法:
|
|
|
1041
1789
|
|
|
1042
1790
|
CODINGNS_BASE_URL 默认 Host 地址,未传时默认 http://127.0.0.1:3002
|
|
1043
1791
|
CODINGNS_ACCESS_TOKEN 默认 Bearer token
|
|
1792
|
+
CODINGNS_AUTH_FILE 可选认证文件,支持读取 apiBaseUrl/accessToken
|
|
1044
1793
|
`.trim();
|
|
1045
1794
|
}
|
|
1046
1795
|
}
|
|
@@ -1057,6 +1806,128 @@ function buildAssistantHelpTopic(action, rest) {
|
|
|
1057
1806
|
return `${action}.${rest[0]}`;
|
|
1058
1807
|
}
|
|
1059
1808
|
|
|
1809
|
+
function buildWorkspaceCloneAuth(values) {
|
|
1810
|
+
const authMode = readOptionalTrimmedValue(values["auth-mode"]);
|
|
1811
|
+
|
|
1812
|
+
if (!authMode || authMode === "none") {
|
|
1813
|
+
return authMode === "none" ? { mode: "none" } : undefined;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
if (authMode === "basic") {
|
|
1817
|
+
return {
|
|
1818
|
+
mode: "basic",
|
|
1819
|
+
username: readOptionalTrimmedValue(values.username),
|
|
1820
|
+
password: readOptionalTrimmedValue(values.password)
|
|
1821
|
+
};
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
if (authMode === "token") {
|
|
1825
|
+
return {
|
|
1826
|
+
mode: "token",
|
|
1827
|
+
username: readOptionalTrimmedValue(values.username),
|
|
1828
|
+
token: readOptionalTrimmedValue(values["auth-token"])
|
|
1829
|
+
};
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
fail(`不支持的 --auth-mode:${authMode}`);
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
function parseDebugPortRequests(value) {
|
|
1836
|
+
const values = Array.isArray(value)
|
|
1837
|
+
? value
|
|
1838
|
+
: typeof value === "string"
|
|
1839
|
+
? [value]
|
|
1840
|
+
: [];
|
|
1841
|
+
|
|
1842
|
+
return values
|
|
1843
|
+
.map((item) => item.trim())
|
|
1844
|
+
.filter((item) => item.length > 0)
|
|
1845
|
+
.map((item) => parseDebugPortRequest(item));
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
function parseDebugPortRequest(value) {
|
|
1849
|
+
const segments = value
|
|
1850
|
+
.split(",")
|
|
1851
|
+
.map((item) => item.trim())
|
|
1852
|
+
.filter((item) => item.length > 0);
|
|
1853
|
+
const request = {
|
|
1854
|
+
serviceId: null,
|
|
1855
|
+
role: null,
|
|
1856
|
+
cwd: null,
|
|
1857
|
+
name: null,
|
|
1858
|
+
command: null,
|
|
1859
|
+
port: null
|
|
1860
|
+
};
|
|
1861
|
+
|
|
1862
|
+
for (const segment of segments) {
|
|
1863
|
+
const [rawKey, ...rest] = segment.split("=");
|
|
1864
|
+
const key = rawKey?.trim().toLowerCase() ?? "";
|
|
1865
|
+
const parsedValue = rest.join("=").trim();
|
|
1866
|
+
|
|
1867
|
+
if (!key || !parsedValue) {
|
|
1868
|
+
fail(`无效的 --port-request:${value}`);
|
|
1869
|
+
}
|
|
1870
|
+
|
|
1871
|
+
switch (key) {
|
|
1872
|
+
case "service-id":
|
|
1873
|
+
request.serviceId = parsedValue;
|
|
1874
|
+
break;
|
|
1875
|
+
case "role":
|
|
1876
|
+
request.role = parsedValue;
|
|
1877
|
+
break;
|
|
1878
|
+
case "cwd":
|
|
1879
|
+
request.cwd = parsedValue;
|
|
1880
|
+
break;
|
|
1881
|
+
case "name":
|
|
1882
|
+
request.name = parsedValue;
|
|
1883
|
+
break;
|
|
1884
|
+
case "command":
|
|
1885
|
+
request.command = parsedValue;
|
|
1886
|
+
break;
|
|
1887
|
+
case "port": {
|
|
1888
|
+
const port = Number.parseInt(parsedValue, 10);
|
|
1889
|
+
|
|
1890
|
+
if (!Number.isInteger(port)) {
|
|
1891
|
+
fail(`--port-request 中的 port 非法:${parsedValue}`);
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
request.port = port;
|
|
1895
|
+
break;
|
|
1896
|
+
}
|
|
1897
|
+
default:
|
|
1898
|
+
fail(`--port-request 不支持的键:${rawKey}`);
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
if (!Number.isInteger(request.port)) {
|
|
1903
|
+
fail(`--port-request 缺少 port:${value}`);
|
|
1904
|
+
}
|
|
1905
|
+
|
|
1906
|
+
if (!request.serviceId && !request.role && !request.cwd && !request.name && !request.command) {
|
|
1907
|
+
fail(`--port-request 至少要提供 service-id、role、cwd、name、command 之一:${value}`);
|
|
1908
|
+
}
|
|
1909
|
+
|
|
1910
|
+
return request;
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
function parseBooleanOption(value, field) {
|
|
1914
|
+
const normalized = value.toLowerCase();
|
|
1915
|
+
|
|
1916
|
+
if (normalized === "true") {
|
|
1917
|
+
return true;
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
if (normalized === "false") {
|
|
1921
|
+
return false;
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
fail(`参数 --${field} 只接受 true 或 false`);
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1927
|
+
function normalizeBackgroundColorOption(value) {
|
|
1928
|
+
return value.toLowerCase() === "none" ? null : value;
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1060
1931
|
function buildSkillsHelpTopic(action) {
|
|
1061
1932
|
if (!action || action === "--help" || action === "-h") {
|
|
1062
1933
|
return "skills";
|