@boyingliu01/opencode-plugin 0.21.0 → 0.24.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 +5 -2
- package/index.ts +215 -164
- package/package.json +1 -1
- package/skills/delphi-review/.delphi-config.json.example +24 -1
- package/skills/delphi-review/AGENTS.md +3 -3
- package/skills/delphi-review/SKILL.md +43 -0
- package/skills/sprint-flow/AGENTS.md +3 -3
- package/skills/test-specification-alignment/AGENTS.md +3 -3
package/README.md
CHANGED
|
@@ -9,7 +9,8 @@ OpenCode plugin exposing xp-gate quality gates and AI workflow skills.
|
|
|
9
9
|
- **gate-principles** ⇄ `xp-gate principles <path>`: Run Clean Code + SOLID
|
|
10
10
|
principles checker (Gate 4 standalone).
|
|
11
11
|
- **gate-arch** ⇄ `xp-gate arch`: Run architecture validation (Gate 6
|
|
12
|
-
standalone
|
|
12
|
+
standalone) with the pinned local @archlinter/cli built-in rules and baseline
|
|
13
|
+
ratchet; an optional config file opts into archlint's own `--config` path.
|
|
13
14
|
- **session-reload-model**: Reload session model from config. After switching
|
|
14
15
|
provider configs (opencode.json + oh-my-openagent.json via switch-coding-plan.sh),
|
|
15
16
|
updates the session model in OpenCode DB to match the new config, so restarted
|
|
@@ -67,7 +68,9 @@ Or via local path (development):
|
|
|
67
68
|
- One of:
|
|
68
69
|
- `xp-gate` CLI installed globally (`npm install -g @boyingliu01/xp-gate`) — **preferred**, or
|
|
69
70
|
- the xp-gate repo checked out locally with `src/principles/index.ts` reachable — **fallback** (the tool will shell out via `npx -y tsx`)
|
|
70
|
-
- `
|
|
71
|
+
- `@archlinter/cli` installed locally or on PATH (for `gate-arch` only; the
|
|
72
|
+
default built-in-rules path needs no `architecture.yaml` — passing one opts
|
|
73
|
+
into archlint's own `--config` schema validation, which rejects pre-0.16 files)
|
|
71
74
|
|
|
72
75
|
## Graceful Degradation
|
|
73
76
|
|
package/index.ts
CHANGED
|
@@ -319,175 +319,226 @@ function extractTitleFromText(text: string): string {
|
|
|
319
319
|
|
|
320
320
|
// ── Plugin definition ──
|
|
321
321
|
|
|
322
|
+
const SQLITE_TIMEOUT_MS = 5_000
|
|
323
|
+
|
|
324
|
+
// Boy Scout (#447): XpGatePlugin used to inline five tool({...}) definitions
|
|
325
|
+
// (191 lines, 7-8 brace levels). Each tool now lives in its own factory;
|
|
326
|
+
// XpGatePlugin is pure wiring.
|
|
327
|
+
function gateCheckTool(directory: string) {
|
|
328
|
+
return tool({
|
|
329
|
+
description: "Run xp-gate quality gates (Gate 4 + Gate 6) on a file or directory. Prefers global xp-gate CLI; falls back to direct checker source.",
|
|
330
|
+
args: {
|
|
331
|
+
path: z.string().describe("File or directory path (absolute or relative to workspace)"),
|
|
332
|
+
gates: z.array(z.string()).optional().describe("Optional gate subset (e.g. ['principles', 'arch'])"),
|
|
333
|
+
},
|
|
334
|
+
async execute(args, ctx) {
|
|
335
|
+
const cwd = ctx.directory || directory
|
|
336
|
+
const target = args.path.startsWith("/") ? args.path : `${cwd}/${args.path}`
|
|
337
|
+
const gatesFlag = args.gates?.length ? ` --gates ${args.gates.join(",")}` : ""
|
|
338
|
+
const result = await runXpGate(`check "${target}"${gatesFlag}`, cwd)
|
|
339
|
+
if (result) {
|
|
340
|
+
const upgrade = await getUpgradeSuggestion(cwd)
|
|
341
|
+
return upgrade ? `${result}\n${upgrade}` : result
|
|
342
|
+
}
|
|
343
|
+
const cmd = `node ${directory}/src/npm-package/bin/xp-gate.js check "${target}"${gatesFlag}`
|
|
344
|
+
return runCmd(cmd, cwd)
|
|
345
|
+
},
|
|
346
|
+
})
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function gatePrinciplesTool(directory: string) {
|
|
350
|
+
return tool({
|
|
351
|
+
description: "Run Clean Code + SOLID principles checker (Gate 4 standalone) on a file or directory.",
|
|
352
|
+
args: {
|
|
353
|
+
path: z.string().describe("Source file or directory path to check"),
|
|
354
|
+
},
|
|
355
|
+
async execute(args, ctx) {
|
|
356
|
+
const cwd = ctx.directory || directory
|
|
357
|
+
const target = args.path.startsWith("/") ? args.path : `${cwd}/${args.path}`
|
|
358
|
+
const result = await runXpGate(`principles "${target}"`, cwd)
|
|
359
|
+
if (result) {
|
|
360
|
+
const upgrade = await getUpgradeSuggestion(cwd)
|
|
361
|
+
return upgrade ? `${result}\n${upgrade}` : result
|
|
362
|
+
}
|
|
363
|
+
const cmd = `npx -y tsx ${directory}/src/principles/index.ts --files "${target}" --format console`
|
|
364
|
+
return runCmd(cmd, cwd)
|
|
365
|
+
},
|
|
366
|
+
})
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function gateArchTool(directory: string) {
|
|
370
|
+
return tool({
|
|
371
|
+
description:
|
|
372
|
+
"Run architecture validation (Gate 6 standalone) on the repository with the pinned local @archlinter/cli built-in rules and baseline ratchet.",
|
|
373
|
+
args: {
|
|
374
|
+
config: z
|
|
375
|
+
.string()
|
|
376
|
+
.optional()
|
|
377
|
+
.describe(
|
|
378
|
+
"Optional architecture config file (opts into archlint --config; pre-0.16 schemas are rejected by archlint itself)",
|
|
379
|
+
),
|
|
380
|
+
},
|
|
381
|
+
async execute(args, ctx) {
|
|
382
|
+
const cwd = ctx.directory || directory
|
|
383
|
+
// #447: default to the built-in-rules path — no --config. Forcing
|
|
384
|
+
// `--config architecture.yaml` hit the pre-0.16 schema archlint rejects.
|
|
385
|
+
const archArgs = args.config ? `arch --use-config ${args.config}` : "arch"
|
|
386
|
+
const result = await runXpGate(archArgs, cwd)
|
|
387
|
+
if (result) {
|
|
388
|
+
const upgrade = await getUpgradeSuggestion(cwd)
|
|
389
|
+
return upgrade ? `${result}\n${upgrade}` : result
|
|
390
|
+
}
|
|
391
|
+
const fallback = args.config
|
|
392
|
+
? `npx -y @archlinter/cli scan . --config ${args.config}`
|
|
393
|
+
: `npx -y @archlinter/cli scan .`
|
|
394
|
+
return runCmd(fallback, cwd)
|
|
395
|
+
},
|
|
396
|
+
})
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
function readCurrentSessionModel(dbPath: string, sessionId: string): string {
|
|
400
|
+
try {
|
|
401
|
+
const escapedId = sessionId.replace(/'/g, "''")
|
|
402
|
+
const currentRaw = execSync(
|
|
403
|
+
`sqlite3 "${dbPath}" "SELECT model FROM session WHERE id = '${escapedId}'"`,
|
|
404
|
+
{ encoding: "utf8", timeout: SQLITE_TIMEOUT_MS }
|
|
405
|
+
).trim()
|
|
406
|
+
if (!currentRaw) return "unknown"
|
|
407
|
+
try {
|
|
408
|
+
const parsed = JSON.parse(currentRaw)
|
|
409
|
+
return `${parsed.providerID || "?"}/${parsed.id || "?"}`
|
|
410
|
+
} catch {
|
|
411
|
+
return currentRaw
|
|
412
|
+
}
|
|
413
|
+
} catch {
|
|
414
|
+
return "unknown"
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function writeSessionModel(dbPath: string, sessionId: string, modelJson: string): void {
|
|
419
|
+
const escapedId = sessionId.replace(/'/g, "''")
|
|
420
|
+
const escapedModel = modelJson.replace(/'/g, "''")
|
|
421
|
+
const sql = `UPDATE session SET model = '${escapedModel}', time_updated = ${Date.now()} WHERE id = '${escapedId}'`
|
|
422
|
+
try {
|
|
423
|
+
execSync(`sqlite3 "${dbPath}" "${sql}"`, { timeout: SQLITE_TIMEOUT_MS })
|
|
424
|
+
} catch (err) {
|
|
425
|
+
// Contract is to propagate: the caller renders the failure as
|
|
426
|
+
// "Session reload failed: <message>". Wrapped so the IO sits inside
|
|
427
|
+
// error handling (Boy Scout), not to swallow anything.
|
|
428
|
+
throw err
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// Boy Scout (#447): the tool's execute() body inlined 40+ lines at 5 brace
|
|
433
|
+
// levels (tool → execute → try → JSON.stringify options). The logic lives at
|
|
434
|
+
// module scope; execute() is pure wiring.
|
|
435
|
+
function reloadSessionModel(sessionId: string): string {
|
|
436
|
+
const dbPath = join(homedir(), ".local", "share", "opencode", "opencode.db")
|
|
437
|
+
const configDir = join(homedir(), ".config", "opencode")
|
|
438
|
+
const omoConfigPath = join(configDir, "oh-my-openagent.json")
|
|
439
|
+
|
|
440
|
+
if (!existsSync(dbPath)) {
|
|
441
|
+
return "Session reload failed: OpenCode database not found at " + dbPath
|
|
442
|
+
}
|
|
443
|
+
if (!existsSync(omoConfigPath)) {
|
|
444
|
+
return "Session reload failed: oh-my-openagent.json not found at " + omoConfigPath
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
let omoConfig: Record<string, unknown>
|
|
448
|
+
try {
|
|
449
|
+
omoConfig = JSON.parse(readFileSync(omoConfigPath, "utf8"))
|
|
450
|
+
} catch (err) {
|
|
451
|
+
const msg = err instanceof Error ? err.message : String(err)
|
|
452
|
+
return "Session reload failed: could not parse oh-my-openagent.json: " + msg
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
const agents = omoConfig?.["agents"] as Record<string, { model?: string }> | undefined
|
|
456
|
+
const sisyphusModel = agents?.["sisyphus"]?.["model"]
|
|
457
|
+
if (!sisyphusModel || typeof sisyphusModel !== "string") {
|
|
458
|
+
return "Session reload failed: could not find sisyphus.model in oh-my-openagent.json"
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
const slashIdx = sisyphusModel.indexOf("/")
|
|
462
|
+
if (slashIdx === -1) {
|
|
463
|
+
return `Session reload failed: model "${sisyphusModel}" is not in provider/model format`
|
|
464
|
+
}
|
|
465
|
+
const providerID = sisyphusModel.substring(0, slashIdx)
|
|
466
|
+
const modelID = sisyphusModel.substring(slashIdx + 1)
|
|
467
|
+
|
|
468
|
+
const oldModel = readCurrentSessionModel(dbPath, sessionId)
|
|
469
|
+
try {
|
|
470
|
+
writeSessionModel(dbPath, sessionId, JSON.stringify({ id: modelID, providerID }))
|
|
471
|
+
return `Session model reloaded: ${oldModel} → ${providerID}/${modelID}`
|
|
472
|
+
} catch (err) {
|
|
473
|
+
const msg = err instanceof Error ? err.message : String(err)
|
|
474
|
+
return `Session reload failed: ${msg}`
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
function sessionReloadModelTool() {
|
|
479
|
+
return tool({
|
|
480
|
+
description: "Reload session model from config. After switching provider configs (opencode.json + oh-my-openagent.json via switch-coding-plan.sh), updates the session model in OpenCode DB to match the new config. This ensures restarted sessions use the current provider/model.",
|
|
481
|
+
args: {
|
|
482
|
+
sessionId: z.string().optional().describe("Session ID to reload (defaults to current session)"),
|
|
483
|
+
},
|
|
484
|
+
async execute(args, ctx) {
|
|
485
|
+
return reloadSessionModel(args.sessionId || ctx.sessionID)
|
|
486
|
+
},
|
|
487
|
+
})
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
// Boy Scout (#447): same treatment as reloadSessionModel — logic at module
|
|
491
|
+
// scope, execute() is pure wiring.
|
|
492
|
+
function renameSession(sessionId: string, newTitle?: string): string {
|
|
493
|
+
const dbPath = join(homedir(), ".local", "share", "opencode", "opencode.db")
|
|
494
|
+
|
|
495
|
+
if (!existsSync(dbPath)) {
|
|
496
|
+
return "Session rename failed: OpenCode database not found at " + dbPath
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// `||` (not `??`): an explicitly empty title falls back to auto-generation,
|
|
500
|
+
// matching the original if/else.
|
|
501
|
+
const title = newTitle || generateSessionTitle(dbPath, sessionId)
|
|
502
|
+
if (!title || title.trim().length === 0) {
|
|
503
|
+
return "Session rename failed: could not generate a title (no user messages found)"
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
const trimmed = title.trim().substring(0, 120)
|
|
507
|
+
const escapedTitle = trimmed.replace(/'/g, "''")
|
|
508
|
+
const escapedId = sessionId.replace(/'/g, "''")
|
|
509
|
+
const sql = `UPDATE session SET title = '${escapedTitle}', time_updated = ${Date.now()} WHERE id = '${escapedId}'`
|
|
510
|
+
try {
|
|
511
|
+
execSync(`sqlite3 "${dbPath}" "${sql}"`, { timeout: SQLITE_TIMEOUT_MS })
|
|
512
|
+
return `Session renamed to: "${trimmed}"`
|
|
513
|
+
} catch (err) {
|
|
514
|
+
const msg = err instanceof Error ? err.message : String(err)
|
|
515
|
+
return `Session rename failed: ${msg}`
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function sessionRenameTool() {
|
|
520
|
+
return tool({
|
|
521
|
+
description: "Rename an OpenCode session. When called without newTitle, analyzes the session's recent conversation and auto-generates a descriptive title based on the work done.",
|
|
522
|
+
args: {
|
|
523
|
+
sessionId: z.string().optional().describe("Session ID to rename (defaults to current session)"),
|
|
524
|
+
newTitle: z.string().optional().describe("New session title. If omitted, auto-generate from conversation content."),
|
|
525
|
+
},
|
|
526
|
+
async execute(args, ctx) {
|
|
527
|
+
return renameSession(args.sessionId || ctx.sessionID, args.newTitle)
|
|
528
|
+
},
|
|
529
|
+
})
|
|
530
|
+
}
|
|
531
|
+
|
|
322
532
|
export const XpGatePlugin = async (input: OpenCodePluginInput) => {
|
|
323
533
|
const { directory } = input
|
|
324
534
|
|
|
325
535
|
return {
|
|
326
536
|
tool: {
|
|
327
|
-
"gate-check":
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
},
|
|
333
|
-
async execute(args, ctx) {
|
|
334
|
-
const cwd = ctx.directory || directory
|
|
335
|
-
const target = args.path.startsWith("/") ? args.path : `${cwd}/${args.path}`
|
|
336
|
-
const gatesFlag = args.gates?.length ? ` --gates ${args.gates.join(",")}` : ""
|
|
337
|
-
const result = await runXpGate(`check "${target}"${gatesFlag}`, cwd)
|
|
338
|
-
if (result) {
|
|
339
|
-
const upgrade = await getUpgradeSuggestion(cwd)
|
|
340
|
-
return upgrade ? `${result}\n${upgrade}` : result
|
|
341
|
-
}
|
|
342
|
-
const cmd = `node ${directory}/src/npm-package/bin/xp-gate.js check "${target}"${gatesFlag}`
|
|
343
|
-
return runCmd(cmd, cwd)
|
|
344
|
-
},
|
|
345
|
-
}),
|
|
346
|
-
"gate-principles": tool({
|
|
347
|
-
description: "Run Clean Code + SOLID principles checker (Gate 4 standalone) on a file or directory.",
|
|
348
|
-
args: {
|
|
349
|
-
path: z.string().describe("Source file or directory path to check"),
|
|
350
|
-
},
|
|
351
|
-
async execute(args, ctx) {
|
|
352
|
-
const cwd = ctx.directory || directory
|
|
353
|
-
const target = args.path.startsWith("/") ? args.path : `${cwd}/${args.path}`
|
|
354
|
-
const result = await runXpGate(`principles "${target}"`, cwd)
|
|
355
|
-
if (result) {
|
|
356
|
-
const upgrade = await getUpgradeSuggestion(cwd)
|
|
357
|
-
return upgrade ? `${result}\n${upgrade}` : result
|
|
358
|
-
}
|
|
359
|
-
const cmd = `npx -y tsx ${directory}/src/principles/index.ts --files "${target}" --format console`
|
|
360
|
-
return runCmd(cmd, cwd)
|
|
361
|
-
},
|
|
362
|
-
}),
|
|
363
|
-
"gate-arch": tool({
|
|
364
|
-
description: "Run architecture validation (Gate 6 standalone, layer boundary checks) on the repository.",
|
|
365
|
-
args: {
|
|
366
|
-
config: z.string().describe("Path to architecture config file").default("architecture.yaml"),
|
|
367
|
-
},
|
|
368
|
-
async execute(args, ctx) {
|
|
369
|
-
const cwd = ctx.directory || directory
|
|
370
|
-
const config = args.config || "architecture.yaml"
|
|
371
|
-
const result = await runXpGate(`arch --config ${config}`, cwd)
|
|
372
|
-
if (result) {
|
|
373
|
-
const upgrade = await getUpgradeSuggestion(cwd)
|
|
374
|
-
return upgrade ? `${result}\n${upgrade}` : result
|
|
375
|
-
}
|
|
376
|
-
const cmd = `npx -y @archlinter/cli scan . --config ${config}`
|
|
377
|
-
return runCmd(cmd, cwd)
|
|
378
|
-
},
|
|
379
|
-
}),
|
|
380
|
-
"session-reload-model": tool({
|
|
381
|
-
description: "Reload session model from config. After switching provider configs (opencode.json + oh-my-openagent.json via switch-coding-plan.sh), updates the session model in OpenCode DB to match the new config. This ensures restarted sessions use the current provider/model.",
|
|
382
|
-
args: {
|
|
383
|
-
sessionId: z.string().optional().describe("Session ID to reload (defaults to current session)"),
|
|
384
|
-
},
|
|
385
|
-
async execute(args, ctx) {
|
|
386
|
-
const sessionId = args.sessionId || ctx.sessionID
|
|
387
|
-
const dbPath = join(homedir(), ".local", "share", "opencode", "opencode.db")
|
|
388
|
-
const configDir = join(homedir(), ".config", "opencode")
|
|
389
|
-
const omoConfigPath = join(configDir, "oh-my-openagent.json")
|
|
390
|
-
|
|
391
|
-
if (!existsSync(dbPath)) {
|
|
392
|
-
return "Session reload failed: OpenCode database not found at " + dbPath
|
|
393
|
-
}
|
|
394
|
-
if (!existsSync(omoConfigPath)) {
|
|
395
|
-
return "Session reload failed: oh-my-openagent.json not found at " + omoConfigPath
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
let omoConfig: Record<string, unknown>
|
|
399
|
-
try {
|
|
400
|
-
omoConfig = JSON.parse(readFileSync(omoConfigPath, "utf8"))
|
|
401
|
-
} catch (err) {
|
|
402
|
-
const msg = err instanceof Error ? err.message : String(err)
|
|
403
|
-
return "Session reload failed: could not parse oh-my-openagent.json: " + msg
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
const agents = omoConfig?.["agents"] as Record<string, { model?: string }> | undefined
|
|
407
|
-
const sisyphusModel = agents?.["sisyphus"]?.["model"]
|
|
408
|
-
if (!sisyphusModel || typeof sisyphusModel !== "string") {
|
|
409
|
-
return "Session reload failed: could not find sisyphus.model in oh-my-openagent.json"
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
const slashIdx = sisyphusModel.indexOf("/")
|
|
413
|
-
if (slashIdx === -1) {
|
|
414
|
-
return `Session reload failed: model "${sisyphusModel}" is not in provider/model format`
|
|
415
|
-
}
|
|
416
|
-
const providerID = sisyphusModel.substring(0, slashIdx)
|
|
417
|
-
const modelID = sisyphusModel.substring(slashIdx + 1)
|
|
418
|
-
|
|
419
|
-
let oldModel = "unknown"
|
|
420
|
-
try {
|
|
421
|
-
const escapedId = sessionId.replace(/'/g, "''")
|
|
422
|
-
const currentRaw = execSync(
|
|
423
|
-
`sqlite3 "${dbPath}" "SELECT model FROM session WHERE id = '${escapedId}'"`,
|
|
424
|
-
{ encoding: "utf8", timeout: 5000 }
|
|
425
|
-
).trim()
|
|
426
|
-
if (currentRaw) {
|
|
427
|
-
try {
|
|
428
|
-
const parsed = JSON.parse(currentRaw)
|
|
429
|
-
oldModel = `${parsed.providerID || "?"}/${parsed.id || "?"}`
|
|
430
|
-
} catch {
|
|
431
|
-
oldModel = currentRaw
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
} catch {
|
|
435
|
-
oldModel = "unknown"
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
const newModelJson = JSON.stringify({ id: modelID, providerID })
|
|
439
|
-
const escapedId = sessionId.replace(/'/g, "''")
|
|
440
|
-
const escapedModel = newModelJson.replace(/'/g, "''")
|
|
441
|
-
const sql = `UPDATE session SET model = '${escapedModel}', time_updated = ${Date.now()} WHERE id = '${escapedId}'`
|
|
442
|
-
|
|
443
|
-
try {
|
|
444
|
-
execSync(`sqlite3 "${dbPath}" "${sql}"`, { timeout: 5000 })
|
|
445
|
-
return `Session model reloaded: ${oldModel} → ${providerID}/${modelID}`
|
|
446
|
-
} catch (err) {
|
|
447
|
-
const msg = err instanceof Error ? err.message : String(err)
|
|
448
|
-
return `Session reload failed: ${msg}`
|
|
449
|
-
}
|
|
450
|
-
},
|
|
451
|
-
}),
|
|
452
|
-
"session-rename": tool({
|
|
453
|
-
description: "Rename an OpenCode session. When called without newTitle, analyzes the session's recent conversation and auto-generates a descriptive title based on the work done.",
|
|
454
|
-
args: {
|
|
455
|
-
sessionId: z.string().optional().describe("Session ID to rename (defaults to current session)"),
|
|
456
|
-
newTitle: z.string().optional().describe("New session title. If omitted, auto-generates from conversation content."),
|
|
457
|
-
},
|
|
458
|
-
async execute(args, ctx) {
|
|
459
|
-
const sessionId = args.sessionId || ctx.sessionID
|
|
460
|
-
const dbPath = join(homedir(), ".local", "share", "opencode", "opencode.db")
|
|
461
|
-
|
|
462
|
-
if (!existsSync(dbPath)) {
|
|
463
|
-
return "Session rename failed: OpenCode database not found at " + dbPath
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
let title: string
|
|
467
|
-
if (args.newTitle) {
|
|
468
|
-
title = args.newTitle
|
|
469
|
-
} else {
|
|
470
|
-
title = generateSessionTitle(dbPath, sessionId)
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
if (!title || title.trim().length === 0) {
|
|
474
|
-
return "Session rename failed: could not generate a title (no user messages found)"
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
title = title.trim().substring(0, 120)
|
|
478
|
-
|
|
479
|
-
const escapedTitle = title.replace(/'/g, "''")
|
|
480
|
-
const escapedId = sessionId.replace(/'/g, "''")
|
|
481
|
-
const sql = `UPDATE session SET title = '${escapedTitle}', time_updated = ${Date.now()} WHERE id = '${escapedId}'`
|
|
482
|
-
try {
|
|
483
|
-
execSync(`sqlite3 "${dbPath}" "${sql}"`, { timeout: 5000 })
|
|
484
|
-
return `Session renamed to: "${title}"`
|
|
485
|
-
} catch (err) {
|
|
486
|
-
const msg = err instanceof Error ? err.message : String(err)
|
|
487
|
-
return `Session rename failed: ${msg}`
|
|
488
|
-
}
|
|
489
|
-
},
|
|
490
|
-
}),
|
|
537
|
+
"gate-check": gateCheckTool(directory),
|
|
538
|
+
"gate-principles": gatePrinciplesTool(directory),
|
|
539
|
+
"gate-arch": gateArchTool(directory),
|
|
540
|
+
"session-reload-model": sessionReloadModelTool(),
|
|
541
|
+
"session-rename": sessionRenameTool(),
|
|
491
542
|
},
|
|
492
543
|
"chat.message": async (_input: { message: string }) => {
|
|
493
544
|
if (!checked) {
|
package/package.json
CHANGED
|
@@ -66,5 +66,28 @@
|
|
|
66
66
|
"max_review_rounds": 5,
|
|
67
67
|
"distinct_models_required": true,
|
|
68
68
|
"cross_provider_required": true
|
|
69
|
-
}
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
"$comment_seat_fields": [
|
|
72
|
+
"Optional per-seat fields (#481). The prompt ceiling is a seat x model route",
|
|
73
|
+
"property, not a global constant: max_prompt_bytes (UTF-8 bytes, default 40000)",
|
|
74
|
+
"is the hard pre-send gate; prompt_calibration carries the measured bounds used",
|
|
75
|
+
"to classify a pre-response drop as SIZE_EXCEEDED instead of a network fault.",
|
|
76
|
+
"Recalibrate (binary search 3-5 probes in [last_pass, last_fail]) whenever the",
|
|
77
|
+
"model or gateway changes. See docs/plans/2026-10-14-sprint-c-design.md section 2.",
|
|
78
|
+
"Example expert entry:",
|
|
79
|
+
" \"architecture\": {",
|
|
80
|
+
" \"provider\": \"bailian-tp\",",
|
|
81
|
+
" \"model\": \"qwen-plus\",",
|
|
82
|
+
" \"seat_id\": \"architecture\",",
|
|
83
|
+
" \"max_prompt_bytes\": 26624,",
|
|
84
|
+
" \"prompt_calibration\": {",
|
|
85
|
+
" \"measured_at\": \"2026-10-05\",",
|
|
86
|
+
" \"model_id\": \"qwen-plus\",",
|
|
87
|
+
" \"gateway\": \"bailian\",",
|
|
88
|
+
" \"last_pass_bytes\": 26624,",
|
|
89
|
+
" \"last_fail_bytes\": 36897",
|
|
90
|
+
" }",
|
|
91
|
+
" }"
|
|
92
|
+
]
|
|
70
93
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# SKILLS/DELPHI-REVIEW KNOWLEDGE BASE
|
|
2
2
|
|
|
3
|
-
**Generated:** 2026-10-
|
|
4
|
-
**Commit:**
|
|
3
|
+
**Generated:** 2026-10-14
|
|
4
|
+
**Commit:** e466ce16
|
|
5
5
|
**Branch:** main
|
|
6
|
-
**Version:** 0.
|
|
6
|
+
**Version:** 0.24.0.0
|
|
7
7
|
|
|
8
8
|
## OVERVIEW
|
|
9
9
|
Delphi Consensus Review — multi-round anonymous expert review (≥90% threshold, exactly 3 experts with distinct executable model IDs). Supports design, requirements, and code-walkthrough modes.
|
|
@@ -329,6 +329,15 @@ Each round MUST output a structured round marker:
|
|
|
329
329
|
|
|
330
330
|
#### Qoder 平台(Custom Agent 模式 — 只能做到同模型三角色)
|
|
331
331
|
|
|
332
|
+
**通道契约(native-first + external fallback,#414)**:每轮评审开始先探测 native 通道——三个 Custom Agent(`delphi-architecture/technical/feasibility`)是否存在且绑定互异(`xp-gate doctor delphi` 一条命令给出全部判定)。但 **native 通道已被实测证伪**(见下):subagent 派发采纳 agent 提示词、丢弃 model 绑定,三席永远是会话模型。因此 Qoder 的通道决策表实际收敛为:
|
|
333
|
+
|
|
334
|
+
| 探测结果 | 通道 | 处置 |
|
|
335
|
+
|---|---|---|
|
|
336
|
+
| 需要 distinct-models 证据的评审 | **external** | `.delphi-config.json` + `scripts/delphi-external-review.cjs`(外部 provider 三模型) |
|
|
337
|
+
| 仅需同模型三角色自查(不计入共识证据) | native | 三 Custom Agent 并行,报告中注明「同模型自查,不构成多模型凭据」 |
|
|
338
|
+
|
|
339
|
+
降级证据落盘 `delphi-reviewed.json`:`channel`(native/external)、`fallback_reason`(如 `qoder_native_drops_model_binding`)、`probe_evidence`(doctor/日志摘录)。两通道同不变量:三专家齐全、`requested_model` 互异(external)、consensus ≥90%、**无单专家路径**。
|
|
340
|
+
|
|
332
341
|
Qoder 的内置模型**没有本地推理端点**:推理请求由 Qoder 客户端经服务端代理发出,凭证是一次性 job token。所以不能照搬 OpenCode 的 `base_url + api_key` 直连方式;Qoder 侧内置模型的唯一入口是 **Custom Agent** —— 每个专家一个独立 agent 文件,frontmatter 用 `model` 字段声明模型。
|
|
333
342
|
|
|
334
343
|
**契约结论(先说结论)**:这条路径**不满足**"三个不同可执行模型 ID"契约。2026-09-23 做过一次排除混杂因素的复测:先把 `~/.qoder/agents/delphi-*.md` 三份文件绑成三个不同的 0.1× 内置模型(`qfmodel` / `dfmodel` / `gfmodel`;架构角与会话模型同名,所以真正有判别力的是技术角与可行性角),**再**新开会话——新 CLI 进程,`session.config.loaded` 记录 `model: "qfmodel"`,注册表加载的必然是已修好的绑定——然后只派发三个 subagent,各回一句话、不调工具。结果:三个独立的 `is_subagent: true` turn,`turn.started` / `model.request.started` / `model.response.completed` 三处的 `model` 全为会话模型 `qfmodel`,`dfmodel` / `gfmodel` 出现 0 次;同时三份回复分别命中架构 / 技术 / 可行性视角,说明角色提示词确实生效、agent 也确实被加载。即 `subagent_type` 派发路径采纳 Custom Agent 的提示词,但**丢弃**它的 `model` 绑定。
|
|
@@ -408,6 +417,20 @@ delphi-review(
|
|
|
408
417
|
> (1) `dsh-tool-subagent` 的 `modelSelectionSettings: true`(仅能力开关),
|
|
409
418
|
> (2) 宿主设置 `SubagentModelSelectionConfig.enabled = true` 且 `allowedModels` ≥3 个不同模型。
|
|
410
419
|
> 该路线依赖宿主配置,CI / 一次性会话不可靠,故不作为默认路径。
|
|
420
|
+
|
|
421
|
+
**DSH 双通道契约(native-first + external fallback,#443)**:评审开始先探测 native 通道,两层开关缺一不可——
|
|
422
|
+
|
|
423
|
+
| 探测步骤 | 方法 | 判定 |
|
|
424
|
+
|---|---|---|
|
|
425
|
+
| ① 工具 schema | 当前会话 `subagent` 工具的参数里是否暴露 `provider` / `model` 字段 | 无 → native 不可用(`enabled` 默认 `false`) |
|
|
426
|
+
| ② 模型清单 | `list_subagent_models` 工具是否注册;可用时返回条数是否 ≥3 且互异 | 未注册或 <3 条 → native 不可用 |
|
|
427
|
+
| ③ 运行时兜底 | 上述任一不满足时调用 subagent 会抛 `child model selection is disabled` | 直接判定,不试错 |
|
|
428
|
+
|
|
429
|
+
- **native 可用**:三个专家并行派发,每个显式传 `model`(取自 `allowedModels` 三个互异条目);`resolved_model` 以平台日志/回执为准,无日志时按 #437 过渡标准注明「执行层验证待平台支持」。
|
|
430
|
+
- **native 不可用**:降级 **external**(本 skill 的 `delphi-review` 插件工具,或 `.delphi-config.json` + `scripts/delphi-external-review.cjs`)。缺 API key 时必须给出明确指引(导出环境变量),不得静默失败。
|
|
431
|
+
- 降级证据落盘 `delphi-reviewed.json`:`channel`、`fallback_reason`(如 `dsh_subagent_model_selection_disabled`)、`probe_evidence`(①②③ 的实测摘录)。
|
|
432
|
+
- 两通道同不变量:三专家齐全、`requested_model` 互异、consensus ≥90%、**无单专家路径**。
|
|
433
|
+
- 可用性探测可用 `xp-gate doctor delphi` 复核(DSH 环境下含 `subagentModelSelection` 持久化设置检查)。
|
|
411
434
|
#### WorkBuddy 平台(Expert 团队模式)
|
|
412
435
|
|
|
413
436
|
WorkBuddy 侧以 Team 型专家团(示例:`delphi-review-team`,安装在 `~/.workbuddy/plugins/marketplaces/my-experts/plugins/`,创建方式见 [docs/platform-workbuddy.md](../../docs/platform-workbuddy.md))承载评审,触发本技能后按此路由执行:
|
|
@@ -432,6 +455,26 @@ WorkBuddy 侧以 Team 型专家团(示例:`delphi-review-team`,安装在 `
|
|
|
432
455
|
|
|
433
456
|
**成本**:3 专家合计 x0.17/轮;主理人选 local 会话模型则零 credits。
|
|
434
457
|
|
|
458
|
+
### 席位 prompt 上限与降序裁剪(强制 — #481)
|
|
459
|
+
|
|
460
|
+
prompt 字节上限是 **席位×模型路由 属性**,不是全局安全值(2026-10-05 实测:同一网关下
|
|
461
|
+
`g-glm-5.3-flash` 席 32-39KB 连续 6 次断连,他席 36KB 一次通过)。编排规则:
|
|
462
|
+
|
|
463
|
+
1. **发送前硬闸**:runner 按 expert 条目的 `max_prompt_bytes`(默认 40000 字节,UTF-8 计)
|
|
464
|
+
拒发超限请求,输出 `error_type: "prompt_budget_exceeded"`。
|
|
465
|
+
2. **失败分类**:响应前断连且字节数超过该席位标定的 `last_pass_bytes` →
|
|
466
|
+
`error_type: "SIZE_EXCEEDED"`(不是网络故障,重试同一 payload 无意义);
|
|
467
|
+
其余失败输出 `network_error` / `retryable_error`,编排层按 `error_type` 字段断言,不解析散文。
|
|
468
|
+
3. **超限时按降序裁剪,每步只做一步**:
|
|
469
|
+
① 去附录(探针填充、日志附录、非必需长引用)→ ② 去非本轮 AC 原文 →
|
|
470
|
+
③ 去测试清单(枚举 → 计数)→ ④ 拆分两次调用(按 diff 对半,同报告合并)→
|
|
471
|
+
⑤ 仍失败 → `PROCESS_BLOCK` 交人裁定。**不得以两席结果冒充 3/3 共识。**
|
|
472
|
+
4. **标定**:上限按「固定语义核心 + 确定性填充附录」构造探针,在
|
|
473
|
+
`[last_pass, last_fail]` 区间二分 3-5 次测得;记录行含
|
|
474
|
+
`seat_id × model_id × gateway × max_passing_bytes × measured_at`;
|
|
475
|
+
模型或网关变更即重标。协议全文与种子标定表见
|
|
476
|
+
[docs/plans/2026-10-14-sprint-c-design.md](../../docs/plans/2026-10-14-sprint-c-design.md) §2。
|
|
477
|
+
|
|
435
478
|
### 共识阈值
|
|
436
479
|
|
|
437
480
|
| 阈值 | 说明 |
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# SKILLS/SPRINT-FLOW KNOWLEDGE BASE
|
|
2
2
|
|
|
3
|
-
**Generated:** 2026-10-
|
|
4
|
-
**Commit:**
|
|
3
|
+
**Generated:** 2026-10-14
|
|
4
|
+
**Commit:** e466ce16
|
|
5
5
|
**Branch:** main
|
|
6
|
-
**Version:** 0.
|
|
6
|
+
**Version:** 0.24.0.0
|
|
7
7
|
|
|
8
8
|
## OVERVIEW
|
|
9
9
|
**6-phase** development pipeline (v2.0 compact redesign, Issue #290): PREP → DESIGN → BUILD → VERIFY → SHIP → CLOSE. Phase 3/6 BUILD default build mode is **ralph-loop** (REQ-level iteration, 40-67% token savings vs parallel). HARD-GATE between DESIGN (2/6) and BUILD (3/6): design must pass Delphi review (≥90% consensus) before any coding.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# SKILLS/TEST-SPECIFICATION-ALIGNMENT KNOWLEDGE BASE
|
|
2
2
|
|
|
3
|
-
**Generated:** 2026-10-
|
|
4
|
-
**Commit:**
|
|
3
|
+
**Generated:** 2026-10-14
|
|
4
|
+
**Commit:** e466ce16
|
|
5
5
|
**Branch:** main
|
|
6
|
-
**Version:** 0.
|
|
6
|
+
**Version:** 0.24.0.0
|
|
7
7
|
|
|
8
8
|
## OVERVIEW
|
|
9
9
|
Test-Specification Alignment Engine — two-stage validation ensuring tests accurately reflect requirements and design specs.
|